-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Conversation
Interested to see where this goes, I just ran across #232 myself. Good luck! |
The proposal writes """keyboard - Indicates whether the dialog should be closable by hitting the ESC key, defaults to true""". But keyboard should go further, e.g. provide a way to have a default button focused (issue 144), or provide keyboard shortcuts / key bindings for buttons. |
How's it going you guys? Any fork already on github that can be checked out / can be helped with? One thing that is dear to me is good support for using one dialog with different controllers, e.g. the re-opening of a currently open dialog with new a controller. I used it for a Login dialog that seamlessly becomes a register dialog. |
@Narretz Still wip, hopefully I will push a new branch in a week or so. Regarding your use case - I'm not sure I follow - are you after re-using the same partial with different controllers? |
Yep, exactly, use the same dialog with different controllers (templates, resolves). At the moment, this works nicely with re-opening an existing dialog with a new config object. Otherwise you'll get some flicker when you close the first and open the second dialog. |
@Narretz yeh, so in the re-written version we are going to dump distinction between opening a pre-configured dialog and opening a dialog. From where the observed flicker is coming? Is it the resolve section that eats up time? |
Great to see the dialogs getting some love. Hope to see a preview soon... |
Hm, I made a plunkr to show the re-opening issue. |
@hall5714 haha ok now you have me really thinking i'm doing stuff wrong. so i'm using the tpls version because otherwise the partials wouldn't load... aren't the templates meant to be used? how else are the components supposed to work? are you suggesting that i write my own version of all the partials in the library or copy the templates i want to use to the appropriate path? that seems messy.. i'm installed via bower btw, although i also have the source |
@scamden I'll try to give you a basic run down 😄 The template version compiles all the HTML into javascript strings and stores them in $templateCache. This way when it's used in production we aren't constantly sending HTTP requests for template partials. So you have two ways you can do this: Use the source and individually include components (literally have <script></script> tags for each directive you use individually). Or use the non template version of the minified source and make sure the entire template directory is in your path. The former has the advantage of being able to run the normal grunt job to compile the production version of ui-bootstrap, but with your custom templates. In either case you can modify the templates for your particular use-case. I prefer the former, but that's largely because bytes are expensive with large proejcts, and I want to ensure I include nothing more than I need for any given project. |
I've been going through the code and it definitely looks a lot cleaner. I'm having some trouble showing the modal though. It's 2 things... 1) It looks like the Bootstrap code display: none isn't switching to display: block, although I see in the modal code it's supposed to -> self.modalEl.css('display', 'block'), and 2) For some reason scope.animate isn't being set to true to trigger the opacity fade. Am I doing something wrong, or is it a bug in my app code? Here's how I'm triggering the modal. scope.openWidgetModal = function() {
var modalOptions = {
template: '<div class="modal-dialog"><widget-inner-tabbed ></widget-inner-tabbed></div>'
};
$modal.open(modalOptions);
} |
I can't find any reference to "display : block" in the code. I guess it's handled purely by animations. Even if you don't have animations, you have to set the display of the modal to "block" in your css, and remove all bootstrap styles that are introduced by the "fade" class in the modal window directive.
This opens the modal without any animation at all. |
@Narretz @mfrye no, it should work perfectly fine with AngularJS >= 1.0.5. The problem seems to be in the unneeded I'm going to merge this refactoring PR during the weekend as IMO all is done apart from docs. So spotting any bugs early on would help making sure that we've got a solid service here. |
@albv ah, this would explain things! No, this version is meant to be used with BS 2.3.x. I'm going to merge it over the weekend, re-base the bootstrap3 branch on top of the latest master and then we will be able to change it to support bootstrap3. |
I think it has nothing to do with bootstrap. The problem is that the "in" class for the modal never gets set: http://plnkr.co/edit/YvDS917yLqqmIoqD2Zk9?p=preview In the modal-window directive, $timeout is used to set $scope.animate = true. But it appears that the last argument of timeout (the invokeApply) skips the apply, so the change in $scope.animate is never picked up by the view layer. Or something like that. Line 179 in bootstrap.js in the plunker.
It does work when set to true |
@pkozlowski-opensource yeah I wasn't sure if you had integrated BS 3 or not. They made a couple changes in BS 3 to where the standard modal is:
BS2 had the modal in the center rather than taking up the whole screen, and didn't have the display: none as well. So I believe the modal class would now need to be clicked instead of the modal-backdrop to hide everything. I don't believe I can create a plunker to replicate the exact setup I have as the modal template I'm using is apart of a fairly complex component setup. |
@hall5714 thanks for the run down! i was aware of the way the template cache / template module builder thing works cause we stole the idea from this project to use in our build! sweet for testing. anyway to your suggestion, three questions:
it seems to me that allowing us to supply the templates to the modal service would fix all of these issues, and not require me to modify the library, but i'm definitely open to other suggestions. thanks again for helping a fledgling open sourcer. |
@scamden No problem :) Ideally modifying the templates IS the way we can customize this stuff. In my perfect universe each and every directive would be completely independent of styling altogether. So you could drop in Foundation/Bootstrap 2 or 3/Whatever and add some And my method does indeed make bower all but useless. I typically don't use bower often, because where I don't modify I typically use CDNs, and where I do modify I typically want customization (Bootstrap, Angular-UI, etc). As for the grunt process, that was a bit off. I should have said build process... basically building the source via On your last point, at this moment there isn't a way to define custom backdrop/window elements. Basically backdrop can be "turned off" but when on it always compiles a |
thanks @hall5714 ! i think i have my head wrapped arounda decent build now. really appreciate the tips. unfortunately even modifying the window.html template isn't going to work. the tests rely on the modal class being there in order to find them in the dom.. it seems i can't remove that class and still be able to build. is this refactor meant to replace the $dialog service because it seems very opinionated that it's only for modals? |
I had to change the modalWindow and modalBackdrop link function timeout to be able to show the modal otherwise the HTML is created but the in class is never added to the modal so it stays hidden. $timeout(function () {
scope.animate = true;
}, 0, true); // use true instead of false Also for IE8 I had to change the $modalStack.open $compile calls to var modalDomEl = $compile(angular.element('<div modal-window>').html(modal.content))(modal.scope); and backdropDomEl = $compile(angular.element('<div modal-backdrop>'))($rootScope); because using Thanks for your hard work 👍 |
Guys, the rewrite just landed in master as d7a4852! Thanks to all who took time to review the early draft, especially @Narretz and @scamden and @hall5714 I'm going to close this PR now (plus some other associated issues). I need to re-read through the whole conversation regarding class overriding but @hall5714 is right, the way to go is to override templates. @scamden to override a couple of templates you don't need to build anything, just use one of techniques described here: If there are still unresolved problems let's open separate issues for each problem. One again, thnx for your patience and early feedback! |
@pkozlowski-opensource thanks! that stack overflow totally fixed the modal window side! thanks so much! still would be nice to be able to have differing backdrops, but this crushes so many bugs with the old service that i can't really complain :) |
@pkozlowski-opensource when will this fix be available in a release in the bower repository? Thanks |
Can i ask, what is meant to go in the window.html and backdrop.html file? the demo you have included doesn't have these files and the demo doesn't seem to do anything? so im finding it a bit hard to work out how to actually use the new modal service. |
@stivni We should cut a release this weekend - can't promise but this is the plan for now. |
@sianabanana those are default templates for backdrop's HTML and modal window decoration HTML. If you want to use standard bootstrap look & feel you don't need to change those nor include this markup in your modal's content. |
Are there any plans for a replacement for $dialog.messageBox in any shape or form? |
I've committed to using the new $modal, but was relying on $dialog.messageBox. So I've knocked together a replacement based on the original. It's not pretty and is undocumented, but it does the job. Here it is for anyone in the same boat (note the code has been updated on 9-Sept-2013 with asafdav's feebdack):
The template which should go in 'templates/messageBox/messageBox.html' is just a copy of templates/dialog/message.html:
After including the module and having |
richardcrichardc thank you for sharing your messageBox code, Just replace if (modalOptions)
angular.extend(options, modalOptions);
$modal.open(options); With if (modalOptions)
angular.extend(options, modalOptions);
return $modal.open(options); Then you can use it like regular $modal, for instance: var modal = $messageBox.open(title, msg, btns);
modal.result.then(function(result){
if (result === "ok") {
console.log("great");
}
}); Thanks again |
asafdav - very good point. I've updated the code in my previous comment. |
Is there any peculiar reason why an ng-include would not work inside a modal? |
@georgiosd I'm having the same issue; did you ever manage to get an ngInclude directive working inside a |
I honestly cannot remember and i am away from my computer for a month :( |
I think that at this point it is cleat to everyone that the current
$dialog
service got in a state where it is hardy maintainable. There are tons of issues opened for it and some of the design decisions make it impossible to move forward with the current code.I'm in the process of re-writing the current service and the modal directive, will try to push the first version for review over the weekend (if everything goes as planned).
Going to close all the existing issues for
$dialog
and 'modal' as a duplicate of this one.As a reminder, early draft of the design is available here:
https://gist.github.com/ajoslin/5477996
@ajoslin I'm not sure if keeping is as gist is the best thing at the moment as I can't easily modify it. Not sure how to progress - I can fork of course but how do we merge all the versions? Anyway I will be working on the forked gist for now.