diff --git a/README.md b/README.md index f17e36a..b8c8645 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,14 @@ Usage ```dialogs.notify('Something Happened','Something happened at this point in the application that I wish to let you know about');``` -```dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{});``` +```dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{resolve :{paramToResolve : function (){return 'value'}}});``` TODO: Add more usage explanations. Demos ----- - v4.2 : [Codepen: http://codepen.io/m-e-conroy/pen/rkIqv](http://codepen.io/m-e-conroy/pen/rkIqv) -- v4.2 : [Codepen: with UI-Bootstrap Date Picker directive](http://codepen.io/m-e-conroy/pen/DAxzs) +- v4.2 : [Codepen: with UI-Bootstrap Date Picker directive](http://codepen.io/m-e-conroy/pen/DAxzs) - v2.0 : [Codepen: http://codepen.io/m-e-conroy/pen/AmBpL](http://codepen.io/m-e-conroy/pen/AmBpL) - v1.0 : [Codepen: http://codepen.io/m-e-conroy/pen/ALsdF](http://codepen.io/m-e-conroy/pen/ALsdF) @@ -42,7 +42,7 @@ Release Versions - v3.0 : supports AngularJS 1.2 +, Angular UI Bootstrap 0.10.0 - v2.0 : supports AngularJS 1.2 + - v1.0 : supports AngularJS 1.1.5 and below. - + v5.2.8 ------ @@ -124,7 +124,7 @@ v5.2.1 + v5.2.x + -------- 1. [Angular Translate](https://github.com/angular-translate) is now optional. - + v4.2.0 & v5.x.x --------------- Same as v4.0.0 with the exception of the following: @@ -155,7 +155,7 @@ v2.0 Additional Dependencies v1.0 ---- -1. [Angular JS](http://www.angularjs.org) (version 1.1.5 and less) +1. [Angular JS](http://www.angularjs.org) (version 1.1.5 and less) 2. [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap/#/modal) (version <= 0.6.0, Non-Bootstrap 3 Branch) with embedded templates. 3. [Twitter Bootstrap CSS](http://getbootstrap.com) (version 2) @@ -175,10 +175,10 @@ Changes - v5.2.x 1. Angular-Translate is now optional, however in order to keep support for Angular-Translate and be able to switch it on and off easily without having to add lines of code to your modules I created a substitute module that is automatically included and used when Angular-Translate is not found. This subsitute (*translate-substitution.js : translate.sub*) is a provider service (*$translateProvider*) with the same *translations* method as the Angular-Translate provider service does. The provider service is also named *$translate* and has its own *instant* method. I did this such that, if in the future you do decide to use Angular-Translate all you will have to do is load the module before the dialog's service is loaded. 2. The *dialogs-default-translations.js* file is also now an optional dependency. - + - v5.1.0 1. Separated out the default translations into their own module: **dialogs-default-translations.js** Include this or the "min" version in your application if you are not already using $translationProvider elsewhere, otherwise just copy the translation list within the module to your translation list for 'en-US.' - + - v5.0.0 1. Optionally pass in options object, possible overrides are as follows @@ -203,7 +203,7 @@ Changes - **dialogsProvider.useBackdrop([true,false,'static'])** - True or false to use a backdrop for the modal, 'static' to use a backdrop and disallow closing on mouse click of the backdrop. - **dialogsProvider.useEscClose([true,false])** - Whether or not to allow the use of the 'ESC' key to close the modal - **dialogsProvider.useClass([string])** - Sets an additional CSS class to the modal window - - **dialogsProvider.useCopy([true,false])** - Determines whether to use angular.copy or not when passing a data object to the custom dialog service. Setting this to false will allow the modal to retain the two-way binding with the calling controller - thus changing data in the modal will automatically change it in the calling controller's scope. The default is setting is true, so if you want the two-way binding you need to set this to false. + - **dialogsProvider.useCopy([true,false])** - Determines whether to use angular.copy or not when passing a data object to the custom dialog service. Setting this to false will allow the modal to retain the two-way binding with the calling controller - thus changing data in the modal will automatically change it in the calling controller's scope. The default is setting is true, so if you want the two-way binding you need to set this to false. 3. Main module is no longer *dialogs* as this would conflict with the new naming of the service. It is now *dialogs.main,* include that in your application's module definition to use the *dialogs* service. 4. Added i18n support via [Angular-Translate](https://github.com/angular-translate), use the *$translateProvider* to set language specific defaults. Default language is currently *en-US.* An example is provided in the example folder that will show you how to change the defaults from English to Spanish. Translations can be set on the following: - DIALOGS_ERROR (modal header) diff --git a/dist/dialogs-default-translations.js b/dist/dialogs-default-translations.js index 04f61e5..de4764d 100644 --- a/dist/dialogs-default-translations.js +++ b/dist/dialogs-default-translations.js @@ -69,7 +69,7 @@ DIALOGS_NO: "取消" }); - $translateProvider.translations('es',{ + $translateProvider.translations('es-ES',{ DIALOGS_ERROR: "Error", DIALOGS_ERROR_MSG: "Se ha producido un error.", DIALOGS_CLOSE: "Cerrar", @@ -85,6 +85,23 @@ DIALOGS_YES: "Sí", DIALOGS_NO: "No" }); + + $translateProvider.translations("fr-FR", { + DIALOGS_ERROR: "Erreur", + DIALOGS_ERROR_MSG: "Une erreur inconnue s'est produite.", + DIALOGS_CLOSE: "Fermer", + DIALOGS_PLEASE_WAIT: "Patientez svp", + DIALOGS_PLEASE_WAIT_ELIPS: "Patienter svp...", + DIALOGS_PLEASE_WAIT_MSG: "En attente de la fin de l'opération.", + DIALOGS_PERCENT_COMPLETE: "% Terminer", + DIALOGS_NOTIFICATION: "Notification", + DIALOGS_NOTIFICATION_MSG: "Notification de l'application inconnue", + DIALOGS_CONFIRMATION: "Confirmer", + DIALOGS_CONFIRMATION_MSG: "Merci de confirmer", + DIALOGS_OK: "OK", + DIALOGS_YES: "Oui", + DIALOGS_NO: "Non" + }); $translateProvider.preferredLanguage('en-US'); }]); // end config diff --git a/dist/dialogs-default-translations.min.js b/dist/dialogs-default-translations.min.js index 49ede46..4b2d5d1 100644 --- a/dist/dialogs-default-translations.min.js +++ b/dist/dialogs-default-translations.min.js @@ -1 +1 @@ -angular.module("dialogs.default-translations",["pascalprecht.translate"]).config(["$translateProvider",function(O){O.translations("en-US",{DIALOGS_ERROR:"Error",DIALOGS_ERROR_MSG:"An unknown error has occurred.",DIALOGS_CLOSE:"Close",DIALOGS_PLEASE_WAIT:"Please Wait",DIALOGS_PLEASE_WAIT_ELIPS:"Please Wait...",DIALOGS_PLEASE_WAIT_MSG:"Waiting on operation to complete.",DIALOGS_PERCENT_COMPLETE:"% Complete",DIALOGS_NOTIFICATION:"Notification",DIALOGS_NOTIFICATION_MSG:"Unknown application notification.",DIALOGS_CONFIRMATION:"Confirmation",DIALOGS_CONFIRMATION_MSG:"Confirmation required.",DIALOGS_OK:"OK",DIALOGS_YES:"Yes",DIALOGS_NO:"No"}),O.translations("zh-CN",{DIALOGS_ERROR:"错误",DIALOGS_ERROR_MSG:"出现未知错误。",DIALOGS_CLOSE:"关闭",DIALOGS_PLEASE_WAIT:"请稍候",DIALOGS_PLEASE_WAIT_ELIPS:"请稍候...",DIALOGS_PLEASE_WAIT_MSG:"请等待操作完成。",DIALOGS_PERCENT_COMPLETE:"% 已完成",DIALOGS_NOTIFICATION:"通知",DIALOGS_NOTIFICATION_MSG:"未知应用程序的通知。",DIALOGS_CONFIRMATION:"确认",DIALOGS_CONFIRMATION_MSG:"确认要求。",DIALOGS_OK:"确定",DIALOGS_YES:"确认",DIALOGS_NO:"取消"}),O.translations("es",{DIALOGS_ERROR:"Error",DIALOGS_ERROR_MSG:"Se ha producido un error.",DIALOGS_CLOSE:"Cerrar",DIALOGS_PLEASE_WAIT:"Espere por favor",DIALOGS_PLEASE_WAIT_ELIPS:"Espere por favor...",DIALOGS_PLEASE_WAIT_MSG:"Completando operación.",DIALOGS_PERCENT_COMPLETE:"% Completado",DIALOGS_NOTIFICATION:"Notificación",DIALOGS_NOTIFICATION_MSG:"Notificación de una aplicación desconocida.",DIALOGS_CONFIRMATION:"Confirmación",DIALOGS_CONFIRMATION_MSG:"Se requiere confirmacion.",DIALOGS_OK:"Aceptar",DIALOGS_YES:"Sí",DIALOGS_NO:"No"}),O.preferredLanguage("en-US")}]); \ No newline at end of file +angular.module("dialogs.default-translations",["pascalprecht.translate"]).config(["$translateProvider",function(O){O.translations("en-US",{DIALOGS_ERROR:"Error",DIALOGS_ERROR_MSG:"An unknown error has occurred.",DIALOGS_CLOSE:"Close",DIALOGS_PLEASE_WAIT:"Please Wait",DIALOGS_PLEASE_WAIT_ELIPS:"Please Wait...",DIALOGS_PLEASE_WAIT_MSG:"Waiting on operation to complete.",DIALOGS_PERCENT_COMPLETE:"% Complete",DIALOGS_NOTIFICATION:"Notification",DIALOGS_NOTIFICATION_MSG:"Unknown application notification.",DIALOGS_CONFIRMATION:"Confirmation",DIALOGS_CONFIRMATION_MSG:"Confirmation required.",DIALOGS_OK:"OK",DIALOGS_YES:"Yes",DIALOGS_NO:"No"}),O.translations("zh-CN",{DIALOGS_ERROR:"错误",DIALOGS_ERROR_MSG:"出现未知错误。",DIALOGS_CLOSE:"关闭",DIALOGS_PLEASE_WAIT:"请稍候",DIALOGS_PLEASE_WAIT_ELIPS:"请稍候...",DIALOGS_PLEASE_WAIT_MSG:"请等待操作完成。",DIALOGS_PERCENT_COMPLETE:"% 已完成",DIALOGS_NOTIFICATION:"通知",DIALOGS_NOTIFICATION_MSG:"未知应用程序的通知。",DIALOGS_CONFIRMATION:"确认",DIALOGS_CONFIRMATION_MSG:"确认要求。",DIALOGS_OK:"确定",DIALOGS_YES:"确认",DIALOGS_NO:"取消"}),O.translations("es-ES",{DIALOGS_ERROR:"Error",DIALOGS_ERROR_MSG:"Se ha producido un error.",DIALOGS_CLOSE:"Cerrar",DIALOGS_PLEASE_WAIT:"Espere por favor",DIALOGS_PLEASE_WAIT_ELIPS:"Espere por favor...",DIALOGS_PLEASE_WAIT_MSG:"Completando operación.",DIALOGS_PERCENT_COMPLETE:"% Completado",DIALOGS_NOTIFICATION:"Notificación",DIALOGS_NOTIFICATION_MSG:"Notificación de una aplicación desconocida.",DIALOGS_CONFIRMATION:"Confirmación",DIALOGS_CONFIRMATION_MSG:"Se requiere confirmacion.",DIALOGS_OK:"Aceptar",DIALOGS_YES:"Sí",DIALOGS_NO:"No"}),O.translations("fr-FR",{DIALOGS_ERROR:"Erreur",DIALOGS_ERROR_MSG:"Une erreur inconnue s'est produite.",DIALOGS_CLOSE:"Fermer",DIALOGS_PLEASE_WAIT:"Patientez svp",DIALOGS_PLEASE_WAIT_ELIPS:"Patienter svp...",DIALOGS_PLEASE_WAIT_MSG:"En attente de la fin de l'opération.",DIALOGS_PERCENT_COMPLETE:"% Terminer",DIALOGS_NOTIFICATION:"Notification",DIALOGS_NOTIFICATION_MSG:"Notification de l'application inconnue",DIALOGS_CONFIRMATION:"Confirmer",DIALOGS_CONFIRMATION_MSG:"Merci de confirmer",DIALOGS_OK:"OK",DIALOGS_YES:"Oui",DIALOGS_NO:"Non"}),O.preferredLanguage("en-US")}]); \ No newline at end of file diff --git a/dist/dialogs.js b/dist/dialogs.js index 3e60bbd..3b0202d 100644 --- a/dist/dialogs.js +++ b/dist/dialogs.js @@ -212,9 +212,9 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use Backdrop - * + * * Sets the use of the modal backdrop. Either to have one or not and - * whether or not it responds to mouse clicks ('static' sets the + * whether or not it responds to mouse clicks ('static' sets the * backdrop to true and does not respond to mouse clicks). * * @param val mixed (true, false, 'static') @@ -226,7 +226,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use ESC Close - * + * * Sets the use of the ESC (escape) key to close modal windows. * * @param val boolean @@ -250,7 +250,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use Copy - * + * * Determines the use of angular.copy when sending data to the modal controller. * * @param val boolean @@ -275,7 +275,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Set Size * - * Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 + + * Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 + * * @param val string (sm,lg,md) */ @@ -305,7 +305,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) this.$get = ['$modal',function ($modal){ - + return { /** * Error Dialog @@ -337,7 +337,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end error - + /** * Wait Dialog * @@ -370,7 +370,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end wait - + /** * Notify Dialog * @@ -401,7 +401,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end notify - + /** * Confirm Dialog * @@ -432,7 +432,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end confirm - + /** * Create Custom Dialog * @@ -443,7 +443,14 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) */ create : function(url,ctrlr,data,opts){ var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; + var resolve = (opts && angular.isDefined(opts.resolve))? opts.resolve : {}; opts = _setOpts(opts); + resolve.data = function() { + if(copy) + return angular.copy(data); + else + return data; + }; return $modal.open({ templateUrl : url, @@ -454,14 +461,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) windowClass: opts.wc, size: opts.ws, animation: opts.anim, - resolve : { - data : function() { - if(copy) - return angular.copy(data); - else - return data; - } - } + resolve : resolve }); // end modal.open } // end create @@ -469,6 +469,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) }]; // end $get }]); // end provider dialogs + //== Dialogs.Main Module =====================================================// /** diff --git a/dist/dialogs.min.js b/dist/dialogs.min.js index bf5428f..860ef08 100644 --- a/dist/dialogs.min.js +++ b/dist/dialogs.min.js @@ -1 +1 @@ -!function(){"use strict";var a=angular.module("translate.sub",[]);a.provider("$translate",[function(){var a=[],n="en-US";this.translations=function(e,s){angular.isDefined(e)&&angular.isDefined(s)&&(a[e]=angular.copy(s),n=e)},this.$get=[function(){return{instant:function(e){return angular.isDefined(e)&&angular.isDefined(a[n][e])?a[n][e]:""}}}]}]),a.filter("translate",["$translate",function(a){return function(n){return a.instant(n)}}]);var n;try{angular.module("pascalprecht.translate"),n=angular.module("dialogs.controllers",["ui.bootstrap.modal","pascalprecht.translate"])}catch(e){n=angular.module("dialogs.controllers",["ui.bootstrap.modal","translate.sub"])}n.controller("errorDialogCtrl",["$scope","$modalInstance","$translate","data",function(a,n,e,s){a.header=angular.isDefined(s.header)?s.header:e.instant("DIALOGS_ERROR"),a.msg=angular.isDefined(s.msg)?s.msg:e.instant("DIALOGS_ERROR_MSG"),a.icon=angular.isDefined(s.fa)&&angular.equals(s.fa,!0)?"fa fa-warning":"glyphicon glyphicon-warning-sign",a.close=function(){n.close(),a.$destroy()}}]),n.controller("waitDialogCtrl",["$scope","$modalInstance","$translate","$timeout","data",function(a,n,e,s,t){a.header=angular.isDefined(t.header)?t.header:e.instant("DIALOGS_PLEASE_WAIT_ELIPS"),a.msg=angular.isDefined(t.msg)?t.msg:e.instant("DIALOGS_PLEASE_WAIT_MSG"),a.progress=angular.isDefined(t.progress)?t.progress:100,a.icon=angular.isDefined(t.fa)&&angular.equals(t.fa,!0)?"fa fa-clock-o":"glyphicon glyphicon-time",a.$on("dialogs.wait.complete",function(){s(function(){n.close(),a.$destroy()})}),a.$on("dialogs.wait.message",function(n,e){a.msg=angular.isDefined(e.msg)?e.msg:a.msg}),a.$on("dialogs.wait.progress",function(n,e){a.msg=angular.isDefined(e.msg)?e.msg:a.msg,a.progress=angular.isDefined(e.progress)?e.progress:a.progress}),a.getProgress=function(){return{width:a.progress+"%"}}}]),n.controller("notifyDialogCtrl",["$scope","$modalInstance","$translate","data",function(a,n,e,s){a.header=angular.isDefined(s.header)?s.header:e.instant("DIALOGS_NOTIFICATION"),a.msg=angular.isDefined(s.msg)?s.msg:e.instant("DIALOGS_NOTIFICATION_MSG"),a.icon=angular.isDefined(s.fa)&&angular.equals(s.fa,!0)?"fa fa-info":"glyphicon glyphicon-info-sign",a.close=function(){n.close(),a.$destroy()}}]),n.controller("confirmDialogCtrl",["$scope","$modalInstance","$translate","data",function(a,n,e,s){a.header=angular.isDefined(s.header)?s.header:e.instant("DIALOGS_CONFIRMATION"),a.msg=angular.isDefined(s.msg)?s.msg:e.instant("DIALOGS_CONFIRMATION_MSG"),a.icon=angular.isDefined(s.fa)&&angular.equals(s.fa,!0)?"fa fa-check":"glyphicon glyphicon-check",a.no=function(){n.dismiss("no")},a.yes=function(){n.close("yes")}}]),angular.module("dialogs.services",["ui.bootstrap.modal","dialogs.controllers"]).provider("dialogs",[function(){var a=!0,n=!0,e="dialogs-default",s="dialogs-backdrop-default",t=!0,o=null,l="lg",r=!1,i=!1,d=function(t){var o={};return t=t||{},o.kb=angular.isDefined(t.keyboard)?!!t.keyboard:n,o.bd=angular.isDefined(t.backdrop)?t.backdrop:a,o.bdc=angular.isDefined(t.backdropClass)?t.backdropClass:s,o.ws=!angular.isDefined(t.size)||"sm"!==t.size&&"lg"!==t.size&&"md"!==t.size?l:t.size,o.wc=angular.isDefined(t.windowClass)?t.windowClass:e,o.anim=angular.isDefined(t.animation)?!!t.animation:r,o};this.useBackdrop=function(n){angular.isDefined(n)&&(a=n)},this.useEscClose=function(a){angular.isDefined(a)&&(n=angular.equals(a,0)||angular.equals(a,"false")||angular.equals(a,"no")||angular.equals(a,null)||angular.equals(a,!1)?!1:!0)},this.useClass=function(a){angular.isDefined(a)&&(e=a)},this.useCopy=function(a){angular.isDefined(a)&&(t=angular.equals(a,0)||angular.equals(a,"false")||angular.equals(a,"no")||angular.equals(a,null)||angular.equals(a,!1)?!1:!0)},this.setWindowTmpl=function(a){angular.isDefined(a)&&(o=a)},this.setSize=function(a){angular.isDefined(a)&&(l=angular.equals(a,"sm")||angular.equals(a,"lg")||angular.equals(a,"md")?a:l)},this.useAnimation=function(){r=!0},this.useFontAwesome=function(){i=!0},this.$get=["$modal",function(a){return{error:function(n,e,s){return s=d(s),a.open({templateUrl:"/dialogs/error.html",controller:"errorDialogCtrl",backdrop:s.bd,backdropClass:s.bdc,keyboard:s.kb,windowClass:s.wc,size:s.ws,animation:s.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),fa:i}}}})},wait:function(n,e,s,t){return t=d(t),a.open({templateUrl:"/dialogs/wait.html",controller:"waitDialogCtrl",backdrop:t.bd,backdropClass:t.bdc,keyboard:t.kb,windowClass:t.wc,size:t.ws,animation:t.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),progress:angular.copy(s),fa:i}}}})},notify:function(n,e,s){return s=d(s),a.open({templateUrl:"/dialogs/notify.html",controller:"notifyDialogCtrl",backdrop:s.bd,backdropClass:s.bdc,keyboard:s.kb,windowClass:s.wc,size:s.ws,animation:s.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),fa:i}}}})},confirm:function(n,e,s){return s=d(s),a.open({templateUrl:"/dialogs/confirm.html",controller:"confirmDialogCtrl",backdrop:s.bd,backdropClass:s.bdc,keyboard:s.kb,windowClass:s.wc,size:s.ws,animation:s.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),fa:i}}}})},create:function(n,e,s,o){var l=o&&angular.isDefined(o.copy)?o.copy:t;return o=d(o),a.open({templateUrl:n,controller:e,keyboard:o.kb,backdrop:o.bd,backdropClass:o.bdc,windowClass:o.wc,size:o.ws,animation:o.anim,resolve:{data:function(){return l?angular.copy(s):s}}})}}}]}]),angular.module("dialogs.main",["dialogs.services","ngSanitize"]).config(["$translateProvider","dialogsProvider",function(a,n){try{angular.module("pascalprecht.translate")}catch(e){a.translations("en-US",{DIALOGS_ERROR:"Error",DIALOGS_ERROR_MSG:"An unknown error has occurred.",DIALOGS_CLOSE:"Close",DIALOGS_PLEASE_WAIT:"Please Wait",DIALOGS_PLEASE_WAIT_ELIPS:"Please Wait...",DIALOGS_PLEASE_WAIT_MSG:"Waiting on operation to complete.",DIALOGS_PERCENT_COMPLETE:"% Complete",DIALOGS_NOTIFICATION:"Notification",DIALOGS_NOTIFICATION_MSG:"Unknown application notification.",DIALOGS_CONFIRMATION:"Confirmation",DIALOGS_CONFIRMATION_MSG:"Confirmation required.",DIALOGS_OK:"OK",DIALOGS_YES:"Yes",DIALOGS_NO:"No"})}try{var s=document.styleSheets;a:for(var t=s.length-1;t>=0;t--){var o=null,l=null;if(!s[t].disabled){if(null!==s[t].href&&(o=s[t].href.match(/font\-*awesome/i)),angular.isArray(o)){n.useFontAwesome();break}l=s[t].cssRules;for(var r=l.length-1;r>=0;r--)if(".fa"==l[r].selectorText.toLowerCase()){n.useFontAwesome();break a}}}}catch(e){}}]).run(["$templateCache","$interpolate",function(a,n){var e=n.startSymbol(),s=n.endSymbol();a.put("/dialogs/error.html",'"),a.put("/dialogs/wait.html",'"),a.put("/dialogs/notify.html",'"),a.put("/dialogs/confirm.html",'")}])}(); \ No newline at end of file +!function(){"use strict";var a=angular.module("translate.sub",[]);a.provider("$translate",[function(){var a=[],n="en-US";this.translations=function(e,s){angular.isDefined(e)&&angular.isDefined(s)&&(a[e]=angular.copy(s),n=e)},this.$get=[function(){return{instant:function(e){return angular.isDefined(e)&&angular.isDefined(a[n][e])?a[n][e]:""}}}]}]),a.filter("translate",["$translate",function(a){return function(n){return a.instant(n)}}]);var n;try{angular.module("pascalprecht.translate"),n=angular.module("dialogs.controllers",["ui.bootstrap.modal","pascalprecht.translate"])}catch(e){n=angular.module("dialogs.controllers",["ui.bootstrap.modal","translate.sub"])}n.controller("errorDialogCtrl",["$scope","$modalInstance","$translate","data",function(a,n,e,s){a.header=angular.isDefined(s.header)?s.header:e.instant("DIALOGS_ERROR"),a.msg=angular.isDefined(s.msg)?s.msg:e.instant("DIALOGS_ERROR_MSG"),a.icon=angular.isDefined(s.fa)&&angular.equals(s.fa,!0)?"fa fa-warning":"glyphicon glyphicon-warning-sign",a.close=function(){n.close(),a.$destroy()}}]),n.controller("waitDialogCtrl",["$scope","$modalInstance","$translate","$timeout","data",function(a,n,e,s,o){a.header=angular.isDefined(o.header)?o.header:e.instant("DIALOGS_PLEASE_WAIT_ELIPS"),a.msg=angular.isDefined(o.msg)?o.msg:e.instant("DIALOGS_PLEASE_WAIT_MSG"),a.progress=angular.isDefined(o.progress)?o.progress:100,a.icon=angular.isDefined(o.fa)&&angular.equals(o.fa,!0)?"fa fa-clock-o":"glyphicon glyphicon-time",a.$on("dialogs.wait.complete",function(){s(function(){n.close(),a.$destroy()})}),a.$on("dialogs.wait.message",function(n,e){a.msg=angular.isDefined(e.msg)?e.msg:a.msg}),a.$on("dialogs.wait.progress",function(n,e){a.msg=angular.isDefined(e.msg)?e.msg:a.msg,a.progress=angular.isDefined(e.progress)?e.progress:a.progress}),a.getProgress=function(){return{width:a.progress+"%"}}}]),n.controller("notifyDialogCtrl",["$scope","$modalInstance","$translate","data",function(a,n,e,s){a.header=angular.isDefined(s.header)?s.header:e.instant("DIALOGS_NOTIFICATION"),a.msg=angular.isDefined(s.msg)?s.msg:e.instant("DIALOGS_NOTIFICATION_MSG"),a.icon=angular.isDefined(s.fa)&&angular.equals(s.fa,!0)?"fa fa-info":"glyphicon glyphicon-info-sign",a.close=function(){n.close(),a.$destroy()}}]),n.controller("confirmDialogCtrl",["$scope","$modalInstance","$translate","data",function(a,n,e,s){a.header=angular.isDefined(s.header)?s.header:e.instant("DIALOGS_CONFIRMATION"),a.msg=angular.isDefined(s.msg)?s.msg:e.instant("DIALOGS_CONFIRMATION_MSG"),a.icon=angular.isDefined(s.fa)&&angular.equals(s.fa,!0)?"fa fa-check":"glyphicon glyphicon-check",a.no=function(){n.dismiss("no")},a.yes=function(){n.close("yes")}}]),angular.module("dialogs.services",["ui.bootstrap.modal","dialogs.controllers"]).provider("dialogs",[function(){var a=!0,n=!0,e="dialogs-default",s="dialogs-backdrop-default",o=!0,t=null,l="lg",r=!1,i=!1,d=function(o){var t={};return o=o||{},t.kb=angular.isDefined(o.keyboard)?!!o.keyboard:n,t.bd=angular.isDefined(o.backdrop)?o.backdrop:a,t.bdc=angular.isDefined(o.backdropClass)?o.backdropClass:s,t.ws=!angular.isDefined(o.size)||"sm"!==o.size&&"lg"!==o.size&&"md"!==o.size?l:o.size,t.wc=angular.isDefined(o.windowClass)?o.windowClass:e,t.anim=angular.isDefined(o.animation)?!!o.animation:r,t};this.useBackdrop=function(n){angular.isDefined(n)&&(a=n)},this.useEscClose=function(a){angular.isDefined(a)&&(n=angular.equals(a,0)||angular.equals(a,"false")||angular.equals(a,"no")||angular.equals(a,null)||angular.equals(a,!1)?!1:!0)},this.useClass=function(a){angular.isDefined(a)&&(e=a)},this.useCopy=function(a){angular.isDefined(a)&&(o=angular.equals(a,0)||angular.equals(a,"false")||angular.equals(a,"no")||angular.equals(a,null)||angular.equals(a,!1)?!1:!0)},this.setWindowTmpl=function(a){angular.isDefined(a)&&(t=a)},this.setSize=function(a){angular.isDefined(a)&&(l=angular.equals(a,"sm")||angular.equals(a,"lg")||angular.equals(a,"md")?a:l)},this.useAnimation=function(){r=!0},this.useFontAwesome=function(){i=!0},this.$get=["$modal",function(a){return{error:function(n,e,s){return s=d(s),a.open({templateUrl:"/dialogs/error.html",controller:"errorDialogCtrl",backdrop:s.bd,backdropClass:s.bdc,keyboard:s.kb,windowClass:s.wc,size:s.ws,animation:s.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),fa:i}}}})},wait:function(n,e,s,o){return o=d(o),a.open({templateUrl:"/dialogs/wait.html",controller:"waitDialogCtrl",backdrop:o.bd,backdropClass:o.bdc,keyboard:o.kb,windowClass:o.wc,size:o.ws,animation:o.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),progress:angular.copy(s),fa:i}}}})},notify:function(n,e,s){return s=d(s),a.open({templateUrl:"/dialogs/notify.html",controller:"notifyDialogCtrl",backdrop:s.bd,backdropClass:s.bdc,keyboard:s.kb,windowClass:s.wc,size:s.ws,animation:s.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),fa:i}}}})},confirm:function(n,e,s){return s=d(s),a.open({templateUrl:"/dialogs/confirm.html",controller:"confirmDialogCtrl",backdrop:s.bd,backdropClass:s.bdc,keyboard:s.kb,windowClass:s.wc,size:s.ws,animation:s.anim,resolve:{data:function(){return{header:angular.copy(n),msg:angular.copy(e),fa:i}}}})},create:function(n,e,s,t){var l=t&&angular.isDefined(t.copy)?t.copy:o,r=t&&angular.isDefined(t.resolve)?t.resolve:{};return t=d(t),r.data=function(){return l?angular.copy(s):s},a.open({templateUrl:n,controller:e,keyboard:t.kb,backdrop:t.bd,backdropClass:t.bdc,windowClass:t.wc,size:t.ws,animation:t.anim,resolve:r})}}}]}]),angular.module("dialogs.main",["dialogs.services","ngSanitize"]).config(["$translateProvider","dialogsProvider",function(a,n){try{angular.module("pascalprecht.translate")}catch(e){a.translations("en-US",{DIALOGS_ERROR:"Error",DIALOGS_ERROR_MSG:"An unknown error has occurred.",DIALOGS_CLOSE:"Close",DIALOGS_PLEASE_WAIT:"Please Wait",DIALOGS_PLEASE_WAIT_ELIPS:"Please Wait...",DIALOGS_PLEASE_WAIT_MSG:"Waiting on operation to complete.",DIALOGS_PERCENT_COMPLETE:"% Complete",DIALOGS_NOTIFICATION:"Notification",DIALOGS_NOTIFICATION_MSG:"Unknown application notification.",DIALOGS_CONFIRMATION:"Confirmation",DIALOGS_CONFIRMATION_MSG:"Confirmation required.",DIALOGS_OK:"OK",DIALOGS_YES:"Yes",DIALOGS_NO:"No"})}try{var s=document.styleSheets;a:for(var o=s.length-1;o>=0;o--){var t=null,l=null;if(!s[o].disabled){if(null!==s[o].href&&(t=s[o].href.match(/font\-*awesome/i)),angular.isArray(t)){n.useFontAwesome();break}l=s[o].cssRules;for(var r=l.length-1;r>=0;r--)if(".fa"==l[r].selectorText.toLowerCase()){n.useFontAwesome();break a}}}}catch(e){}}]).run(["$templateCache","$interpolate",function(a,n){var e=n.startSymbol(),s=n.endSymbol();a.put("/dialogs/error.html",'"),a.put("/dialogs/wait.html",'"),a.put("/dialogs/notify.html",'"),a.put("/dialogs/confirm.html",'")}])}(); \ No newline at end of file diff --git a/src/dialogs-services.js b/src/dialogs-services.js index abdd9bc..c5244c6 100644 --- a/src/dialogs-services.js +++ b/src/dialogs-services.js @@ -28,9 +28,9 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use Backdrop - * + * * Sets the use of the modal backdrop. Either to have one or not and - * whether or not it responds to mouse clicks ('static' sets the + * whether or not it responds to mouse clicks ('static' sets the * backdrop to true and does not respond to mouse clicks). * * @param val mixed (true, false, 'static') @@ -42,7 +42,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use ESC Close - * + * * Sets the use of the ESC (escape) key to close modal windows. * * @param val boolean @@ -66,7 +66,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use Copy - * + * * Determines the use of angular.copy when sending data to the modal controller. * * @param val boolean @@ -91,7 +91,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Set Size * - * Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 + + * Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 + * * @param val string (sm,lg,md) */ @@ -121,7 +121,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) this.$get = ['$modal',function ($modal){ - + return { /** * Error Dialog @@ -153,7 +153,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end error - + /** * Wait Dialog * @@ -186,7 +186,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end wait - + /** * Notify Dialog * @@ -217,7 +217,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end notify - + /** * Confirm Dialog * @@ -248,7 +248,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end confirm - + /** * Create Custom Dialog * @@ -259,7 +259,14 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) */ create : function(url,ctrlr,data,opts){ var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; + var resolve = (opts && angular.isDefined(opts.resolve))? opts.resolve : {}; opts = _setOpts(opts); + resolve.data = function() { + if(copy) + return angular.copy(data); + else + return data; + }; return $modal.open({ templateUrl : url, @@ -270,18 +277,11 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) windowClass: opts.wc, size: opts.ws, animation: opts.anim, - resolve : { - data : function() { - if(copy) - return angular.copy(data); - else - return data; - } - } + resolve : resolve }); // end modal.open } // end create }; // end return }]; // end $get - }]); // end provider dialogs \ No newline at end of file + }]); // end provider dialogs diff --git a/src/dialogs.js b/src/dialogs.js index 420b273..df066b5 100644 --- a/src/dialogs.js +++ b/src/dialogs.js @@ -206,9 +206,9 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use Backdrop - * + * * Sets the use of the modal backdrop. Either to have one or not and - * whether or not it responds to mouse clicks ('static' sets the + * whether or not it responds to mouse clicks ('static' sets the * backdrop to true and does not respond to mouse clicks). * * @param val mixed (true, false, 'static') @@ -220,7 +220,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use ESC Close - * + * * Sets the use of the ESC (escape) key to close modal windows. * * @param val boolean @@ -244,7 +244,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use Copy - * + * * Determines the use of angular.copy when sending data to the modal controller. * * @param val boolean @@ -269,7 +269,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Set Size * - * Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 + + * Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 + * * @param val string (sm,lg,md) */ @@ -299,7 +299,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) this.$get = ['$modal',function ($modal){ - + return { /** * Error Dialog @@ -331,7 +331,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end error - + /** * Wait Dialog * @@ -364,7 +364,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end wait - + /** * Notify Dialog * @@ -395,7 +395,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end notify - + /** * Confirm Dialog * @@ -426,7 +426,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end confirm - + /** * Create Custom Dialog * @@ -437,7 +437,14 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) */ create : function(url,ctrlr,data,opts){ var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; + var resolve = (opts && angular.isDefined(opts.resolve))? opts.resolve : {}; opts = _setOpts(opts); + resolve.data = function() { + if(copy) + return angular.copy(data); + else + return data; + }; return $modal.open({ templateUrl : url, @@ -448,14 +455,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) windowClass: opts.wc, size: opts.ws, animation: opts.anim, - resolve : { - data : function() { - if(copy) - return angular.copy(data); - else - return data; - } - } + resolve : resolve }); // end modal.open } // end create @@ -463,6 +463,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) }]; // end $get }]); // end provider dialogs + //== Dialogs.Main Module =====================================================// /**