diff --git a/dist/dialogs-default-translations.js b/dist/dialogs-default-translations.js index 4b3659b..c7515aa 100644 --- a/dist/dialogs-default-translations.js +++ b/dist/dialogs-default-translations.js @@ -1,141 +1 @@ -/** - * angular-dialog-service - A service to handle common dialog types in a web application. Built on top of Angular-Bootstrap's modal - * @version v5.3.0 - * @author Michael Conroy, michael.e.conroy@gmail.com - * @license MIT, http://www.opensource.org/licenses/MIT - */ -/** - * Dialog Default Translations. - * - * Include this module if you're not already using angular-translate in your application, and - * add it to your application module's dependency list in order to get default header and - * dialog messages to appear. - * - * Ex: var myApp = angular.module('myApplication',['dialogs.main','dialogs.default-translations']); - * - * It was necessary to separate this out for those already using angular-translate because this would - * automatically reset their translation list for 'en-US' - * - * For those already using angular-translate, just copy the list of DIALOG_[..] translations to your - * translation list where you set 'en-US' using the $translateProvider. - */ - -//== Translations =============================================================// - - angular.module('dialogs.default-translations',['pascalprecht.translate']) - /** - * Default translations in English. - * - * Use angular-translate's $translateProvider to provide translations in an - * alternate language. - * - * $translateProvider.translations('[lang]',{[translations]}); - * To use alternate translations set the preferred language to your desired - * language. - * $translateProvider.preferredLanguage('[lang]'); - */ - .config(['$translateProvider',function($translateProvider){ - $translateProvider.translations('de-DE',{ - DIALOGS_ERROR: "Error", - DIALOGS_ERROR_MSG: "Ein unbekannter Fehler ist aufgetreten.", - DIALOGS_CLOSE: "Schließen", - DIALOGS_PLEASE_WAIT: "Bitte warten", - DIALOGS_PLEASE_WAIT_ELIPS: "Bitte warten...", - DIALOGS_PLEASE_WAIT_MSG: "Warte auf Fertigstellung der Operation.", - DIALOGS_PERCENT_COMPLETE: "% fertig", - DIALOGS_NOTIFICATION: "Benachrichtigung", - DIALOGS_NOTIFICATION_MSG: "Unbekannte Anwendungsbenachrichtigung.", - DIALOGS_CONFIRMATION: "Bestätigung", - DIALOGS_CONFIRMATION_MSG: "Bestätigung erforderlich.", - DIALOGS_OK: "OK", - DIALOGS_YES: "Ja", - DIALOGS_NO: "Nein" - }); - - $translateProvider.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" - }); - - $translateProvider.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" - }); - - $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.translations('pt-BR',{ - DIALOGS_ERROR: "Erro", - DIALOGS_ERROR_MSG: "Ocorreu um erro inesperado.", - DIALOGS_CLOSE: "Fechar", - DIALOGS_PLEASE_WAIT: "Por favor aguarde", - DIALOGS_PLEASE_WAIT_ELIPS: "Por favor aguarde...", - DIALOGS_PLEASE_WAIT_MSG: "Aguardando que a operação termine.", - DIALOGS_PERCENT_COMPLETE: "% Completados", - DIALOGS_NOTIFICATION: "Notificação", - DIALOGS_NOTIFICATION_MSG: "Notificação de aplicação desconhecida.", - DIALOGS_CONFIRMATION: "Confirmação", - DIALOGS_CONFIRMATION_MSG: "Confirmação requerida.", - DIALOGS_OK: "OK", - DIALOGS_YES: "Sim", - DIALOGS_NO: "Não" - }); - - $translateProvider.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: "取消" - }); - - $translateProvider.preferredLanguage('en-US'); - }]); // end config +angular.module("dialogs.default-translations",["pascalprecht.translate"]).config(["$translateProvider",function(O){O.translations("de-DE",{DIALOGS_ERROR:"Error",DIALOGS_ERROR_MSG:"Ein unbekannter Fehler ist aufgetreten.",DIALOGS_CLOSE:"Schließen",DIALOGS_PLEASE_WAIT:"Bitte warten",DIALOGS_PLEASE_WAIT_ELIPS:"Bitte warten...",DIALOGS_PLEASE_WAIT_MSG:"Warte auf Fertigstellung der Operation.",DIALOGS_PERCENT_COMPLETE:"% fertig",DIALOGS_NOTIFICATION:"Benachrichtigung",DIALOGS_NOTIFICATION_MSG:"Unbekannte Anwendungsbenachrichtigung.",DIALOGS_CONFIRMATION:"Bestätigung",DIALOGS_CONFIRMATION_MSG:"Bestätigung erforderlich.",DIALOGS_OK:"OK",DIALOGS_YES:"Ja",DIALOGS_NO:"Nein"}),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("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.translations("pt-BR",{DIALOGS_ERROR:"Erro",DIALOGS_ERROR_MSG:"Ocorreu um erro inesperado.",DIALOGS_CLOSE:"Fechar",DIALOGS_PLEASE_WAIT:"Por favor aguarde",DIALOGS_PLEASE_WAIT_ELIPS:"Por favor aguarde...",DIALOGS_PLEASE_WAIT_MSG:"Aguardando que a operação termine.",DIALOGS_PERCENT_COMPLETE:"% Completados",DIALOGS_NOTIFICATION:"Notificação",DIALOGS_NOTIFICATION_MSG:"Notificação de aplicação desconhecida.",DIALOGS_CONFIRMATION:"Confirmação",DIALOGS_CONFIRMATION_MSG:"Confirmação requerida.",DIALOGS_OK:"OK",DIALOGS_YES:"Sim",DIALOGS_NO:"Não"}),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.preferredLanguage("en-US")}]); \ No newline at end of file diff --git a/dist/dialogs.js b/dist/dialogs.js index dfd18d7..2f4e71b 100644 --- a/dist/dialogs.js +++ b/dist/dialogs.js @@ -1,566 +1 @@ -/** - * angular-dialog-service - A service to handle common dialog types in a web application. Built on top of Angular-Bootstrap's modal - * @version v5.3.0 - * @author Michael Conroy, michael.e.conroy@gmail.com - * @license MIT, http://www.opensource.org/licenses/MIT - */ -(function(){ -"use strict"; -//== Translate Substitute Module =============================================// - -/** - * For those not using Angular-Translate (pascalprecht.translate), this will sub - * in for it so we don't have to include Angular-Translate if we don't want to. - */ - -var translateSubMod = angular.module('translate.sub',[]); - - /** - * $translate Service - * Sets up a $translateProvider service to use in your module's config - * function. $translate.Provider syntax is the same as Angular-Translate, - * use $translate.Provider.translations(lang,obj) to change the defaults - * for modal button, header and message text. - */ - translateSubMod.provider('$translate',[function(){ - var _translations = []; // object of key/value translation pairs - var _current = 'en-US'; // default language - - /** - * Translations - * Set the internal object of translation key/value pairs. - */ - this.translations = function(lang,obj){ - if(angular.isDefined(lang) && angular.isDefined(obj)){ - _translations[lang] = angular.copy(obj); - _current = lang; - } - }; // end translations - - this.$get = [function(){ - return { - /** - * Instant - * Retrieve the translation for the given key, if key not found - * return an empty string. - * Example: $translate.instant('DIALOGS_OK'); - */ - instant : function(what){ - if(angular.isDefined(what) && angular.isDefined(_translations[_current][what])) - return _translations[_current][what]; - else - return ''; - } // end instant - }; // end return - }]; // end $get - - }]); // end $translate - - /** - * Translate Filter - * For use in an Angular template. - * Example: {{"DIALOGS_CLOSE" | translate}} - */ - translateSubMod.filter('translate',['$translate',function($translate){ - return function(what){ - return $translate.instant(what); - }; - }]); // end translate / translate.sub -//== Controllers =============================================================// - -var ctrlrs; // will be dialogs.controllers module - -// determine if Angular-Translate is available, if not use the substitute -try{ - angular.module('pascalprecht.translate'); // throws error if module not loaded - // console.log('Dialogs (Angular-Translate): OK'); - - // dialogs.controllers: module declaration - ctrlrs = angular.module('dialogs.controllers',['ui.bootstrap.modal','pascalprecht.translate']); -}catch(err){ - // console.log('Dialogs: (Angular-Translate): ' + err.message); - // console.log('Dialogs: Attempting to use translate.sub module.'); - - // dialogs.controllers: module declaration - ctrlrs = angular.module('dialogs.controllers',['ui.bootstrap.modal','translate.sub']); -} // end try/catch - -// angular.module('dialogs.controllers',['ui.bootstrap.modal','pascalprecht.translate']) - -/** - * Error Dialog Controller - */ -ctrlrs.controller('errorDialogCtrl',['$scope','$uibModalInstance','$translate','data',function($scope,$uibModalInstance,$translate,data){ - //-- Variables -----// - - $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_ERROR'); - $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_ERROR_MSG'); - $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-warning' : 'glyphicon glyphicon-warning-sign'; - - //-- Methods -----// - - $scope.close = function(){ - $uibModalInstance.close(); - $scope.$destroy(); - }; // end close -}]); // end ErrorDialogCtrl - -/** - * Wait Dialog Controller - */ -ctrlrs.controller('waitDialogCtrl',['$scope','$uibModalInstance','$translate','$timeout','data',function($scope,$uibModalInstance,$translate,$timeout,data){ - //-- Variables -----// - - $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_PLEASE_WAIT_ELIPS'); - $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_PLEASE_WAIT_MSG'); - $scope.progress = (angular.isDefined(data.progress)) ? data.progress : 100; - $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-clock-o' : 'glyphicon glyphicon-time'; - - //-- Listeners -----// - - // Note: used $timeout instead of $scope.$apply() because I was getting a $$nextSibling error - - // close wait dialog - $scope.$on('dialogs.wait.complete',function(){ - $timeout(function(){ $uibModalInstance.close(); $scope.$destroy(); }); - }); // end on(dialogs.wait.complete) - - // update the dialog's message - $scope.$on('dialogs.wait.message',function(evt,args){ - $scope.msg = (angular.isDefined(args.msg)) ? args.msg : $scope.msg; - }); // end on(dialogs.wait.message) - - // update the dialog's progress (bar) and/or message - $scope.$on('dialogs.wait.progress',function(evt,args){ - $scope.msg = (angular.isDefined(args.msg)) ? args.msg : $scope.msg; - $scope.progress = (angular.isDefined(args.progress)) ? args.progress : $scope.progress; - }); // end on(dialogs.wait.progress) - - //-- Methods -----// - - $scope.getProgress = function(){ - return {'width': $scope.progress + '%'}; - }; // end getProgress - -}]); // end WaitDialogCtrl - -/** - * Notify Dialog Controller - */ -ctrlrs.controller('notifyDialogCtrl',['$scope','$uibModalInstance','$translate','data',function($scope,$uibModalInstance,$translate,data){ - //-- Variables -----// - - $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_NOTIFICATION'); - $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_NOTIFICATION_MSG'); - $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-info' : 'glyphicon glyphicon-info-sign'; - - //-- Methods -----// - - $scope.close = function(){ - $uibModalInstance.close(); - $scope.$destroy(); - }; // end close -}]); // end WaitDialogCtrl - -/** - * Confirm Dialog Controller - */ -ctrlrs.controller('confirmDialogCtrl',['$scope','$uibModalInstance','$translate','data',function($scope,$uibModalInstance,$translate,data){ - //-- Variables -----// - - $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_CONFIRMATION'); - $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_CONFIRMATION_MSG'); - $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-check' : 'glyphicon glyphicon-check'; - - //-- Methods -----// - - $scope.no = function(){ - $uibModalInstance.dismiss('no'); - }; // end close - - $scope.yes = function(){ - $uibModalInstance.close('yes'); - }; // end yes -}]); // end ConfirmDialogCtrl / dialogs.controllers -//== Services ================================================================// - -angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) - - .provider('dialogs',[function(){ - var _b = true; // backdrop - var _k = true; // keyboard - var _w = 'dialogs-default'; // windowClass - var _bdc = 'dialogs-backdrop-default'; // backdropClass - var _copy = true; // controls use of angular.copy - var _wTmpl = null; // window template - var _wSize = 'lg'; // large modal window default - var _animation = false; // true/false to use animation - - var _fa = false; // fontawesome flag - - var _setOpts = function(opts){ - var _opts = {}; - opts = opts || {}; - _opts.kb = (angular.isDefined(opts.keyboard)) ? !!opts.keyboard : _k; // values: true,false - _opts.bd = (angular.isDefined(opts.backdrop)) ? opts.backdrop : _b; // values: 'static',true,false - _opts.bdc = (angular.isDefined(opts.backdropClass)) ? opts.backdropClass : _bdc; // additional CSS class(es) to be added to the modal backdrop - _opts.ws = (angular.isDefined(opts.size) && ((opts.size === 'sm') || (opts.size === 'lg') || (opts.size === 'md'))) ? opts.size : _wSize; // values: 'sm', 'lg', 'md' - _opts.wc = (angular.isDefined(opts.windowClass)) ? opts.windowClass : _w; // additional CSS class(es) to be added to a modal window - _opts.anim = (angular.isDefined(opts.animation)) ? !!opts.animation : _animation; // values: true,false - return _opts; - }; // end _setOpts - - /** - * 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 - * backdrop to true and does not respond to mouse clicks). - * - * @param val mixed (true, false, 'static') - */ - this.useBackdrop = function(val){ // possible values : true, false, 'static' - if(angular.isDefined(val)) - _b = val; - }; // end useStaticBackdrop - - /** - * Use ESC Close - * - * Sets the use of the ESC (escape) key to close modal windows. - * - * @param val boolean - */ - this.useEscClose = function(val){ // possible values : true, false - if(angular.isDefined(val)) - _k = (!angular.equals(val,0) && !angular.equals(val,'false') && !angular.equals(val,'no') && !angular.equals(val,null) && !angular.equals(val,false)) ? true : false; - }; // end useESCClose - - /** - * Use Class - * - * Sets the additional CSS window class of the modal window template. - * - * @param val string - */ - this.useClass = function(val){ - if(angular.isDefined(val)) - _w = val; - }; // end useClass - - /** - * Use Copy - * - * Determines the use of angular.copy when sending data to the modal controller. - * - * @param val boolean - */ - this.useCopy = function(val){ - if(angular.isDefined(val)) - _copy = (!angular.equals(val,0) && !angular.equals(val,'false') && !angular.equals(val,'no') && !angular.equals(val,null) && !angular.equals(val,false)) ? true : false; - }; // end useCopy - - /** - * Set Window Template - * - * Sets a path to a template to use overriding modal's window template. - * - * @param val string - */ - this.setWindowTmpl = function(val){ - if(angular.isDefined(val)) - _wTmpl = val; - }; // end setWindowTmpl - - /** - * Set Size - * - * Sets the modal size to use (sm,lg,md) - * - * @param val string (sm,lg,md) - */ - this.setSize = function(val){ - if(angular.isDefined(val)) - _wSize = (angular.equals(val,'sm') || angular.equals(val,'lg') || angular.equals(val,'md')) ? val : _wSize; - }; // end setSize - - /** - * Use Animations - * - * Sets the use of animations to true - */ - this.useAnimation = function(){ - _animation = true; - }; // end useAnimation - - /** - * Use Font-Awesome. - * - * Sets Font-Awesome flag to true and substitutes font-awesome icons for - * Bootstrap's glyphicons. - */ - this.useFontAwesome = function(){ - _fa = true; - }; // end useFontAwesome - - - this.$get = ['$uibModal',function ($uibModal){ - - return { - /** - * Error Dialog - * - * @param header string - * @param msg string - * @param opts object - */ - error : function(header,msg,opts){ - opts = _setOpts(opts); - - return $uibModal.open({ - templateUrl : '/dialogs/error.html', - controller : 'errorDialogCtrl', - backdrop: opts.bd, - backdropClass: opts.bdc, - keyboard: opts.kb, - windowClass: opts.wc, - size: opts.ws, - animation: opts.anim, - resolve : { - data : function(){ - return { - header : angular.copy(header), - msg : angular.copy(msg), - fa : _fa - }; - } - } - }); // end modal.open - }, // end error - - /** - * Wait Dialog - * - * @param header string - * @param msg string - * @param progress int - * @param opts object - */ - wait : function(header,msg,progress,opts){ - opts = _setOpts(opts); - - return $uibModal.open({ - templateUrl : '/dialogs/wait.html', - controller : 'waitDialogCtrl', - backdrop: opts.bd, - backdropClass: opts.bdc, - keyboard: opts.kb, - windowClass: opts.wc, - size: opts.ws, - animation: opts.anim, - resolve : { - data : function(){ - return { - header : angular.copy(header), - msg : angular.copy(msg), - progress : angular.copy(progress), - fa : _fa - }; - } - } - }); // end modal.open - }, // end wait - - /** - * Notify Dialog - * - * @param header string - * @param msg string - * @param opts object - */ - notify : function(header,msg,opts){ - opts = _setOpts(opts); - - return $uibModal.open({ - templateUrl : '/dialogs/notify.html', - controller : 'notifyDialogCtrl', - backdrop: opts.bd, - backdropClass: opts.bdc, - keyboard: opts.kb, - windowClass: opts.wc, - size: opts.ws, - animation: opts.anim, - resolve : { - data : function(){ - return { - header : angular.copy(header), - msg : angular.copy(msg), - fa : _fa - }; - } - } - }); // end modal.open - }, // end notify - - /** - * Confirm Dialog - * - * @param header string - * @param msg string - * @param opts object - */ - confirm : function(header,msg,opts){ - opts = _setOpts(opts); - - return $uibModal.open({ - templateUrl : '/dialogs/confirm.html', - controller : 'confirmDialogCtrl', - backdrop: opts.bd, - backdropClass: opts.bdc, - keyboard: opts.kb, - windowClass: opts.wc, - size: opts.ws, - animation: opts.anim, - resolve : { - data : function(){ - return { - header : angular.copy(header), - msg : angular.copy(msg), - fa : _fa - }; - } - } - }); // end modal.open - }, // end confirm - - /** - * Create Custom Dialog - * - * @param url string - * @param ctrlr string - * @param data object - * @param opts object - */ - create : function(url,ctrlr,data,opts,ctrlAs){ - var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; - opts = _setOpts(opts); - - return $uibModal.open({ - templateUrl : url, - controller : ctrlr, - controllerAs : ctrlAs, - keyboard : opts.kb, - backdrop : opts.bd, - backdropClass: opts.bdc, - windowClass: opts.wc, - size: opts.ws, - animation: opts.anim, - resolve : { - data : function() { - if(copy) - return angular.copy(data); - else - return data; - } - } - }); // end modal.open - } // end create - - }; // end return - - }]; // end $get - }]); // end provider dialogs -//== Dialogs.Main Module =====================================================// - -/** - * Include this module 'dialogs.main' in your module's dependency list where you - * intend to use it. Then inject the 'dialogs' service in your controllers that - * need it. - */ - -angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires angular-sanitize.min.js (ngSanitize) //code.angularjs.org/1.2.1/angular-sanitize.min.js - - .config(['$translateProvider','dialogsProvider',function($translateProvider,dialogsProvider){ - /** - * if Angular-Translate is not loaded, use the translate substitute - * module and create default translations to use as default modal texts - */ - try{ - angular.module('pascalprecht.translate'); - }catch(err){ - // console.log('Dialogs: Creating default translations for use without Angular-Translate.'); - - // This will set default modal buttons, header and message text - $translateProvider.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" - }); - } // end try/catch - - /** - * Attempt to ascertain if page is using Font Awesome instead of the - * regular Bootstrap Icons. If you are changing the stylesheet name or - * not including it from a CDN or have included Font-Awesome as a - * concatentation of CSS sheets together, then you will have to manually - * set Font-Awesome usage in your Angular Module's config by including - * the $dialogsProvider and calling the method $dialogsProvider.useFontAwesome(). - */ - try{ - var _sheets = document.styleSheets; - - sheetLoop: - for(var i = (_sheets.length - 1);i >= 0;i--){ - var _matches = null; - var _rules = null; - - if(!_sheets[i].disabled){ - // check href of style sheet first - if(_sheets[i].href !== null) - _matches = _sheets[i].href.match(/font\-*awesome/i); - - if(angular.isArray(_matches)){ - dialogsProvider.useFontAwesome(); - break; // done, leave the style sheet for loop - }else{ - // try to find css rule .fa, in case style sheet has been concatenated - _rules = _sheets[i].cssRules; - for(var x = (_rules.length - 1);x >= 0;x--){ - if(typeof(_rules[x].selectorText) === 'string' && _rules[x].selectorText.toLowerCase() === '.fa'){ - dialogsProvider.useFontAwesome(); - break sheetLoop; // done, exit both for loops - } - } - } - } // end if(disabled) - } // end for - }catch(err){ - // console.log('Error Message: ' + err); - } - }]) // end config - - // Add default templates via $templateCache - .run(['$templateCache','$interpolate',function($templateCache,$interpolate){ - - // get interpolation symbol (possible that someone may have changed it in their application instead of using '{{}}') - var startSym = $interpolate.startSymbol(); - var endSym = $interpolate.endSymbol(); - - $templateCache.put('/dialogs/error.html',''); - $templateCache.put('/dialogs/wait.html',''); - $templateCache.put('/dialogs/notify.html',''); - $templateCache.put('/dialogs/confirm.html',''); - }]); // end run / dialogs.main - -})(); \ 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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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.close=function(){n.dismiss("cancel")},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",i=!1,r=!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:i,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(){i=!0},this.useFontAwesome=function(){r=!0},this.$get=["$uibModal",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:r}}}})},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:r}}}})},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:r}}}})},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:r}}}})},create:function(n,e,s,o,l){var i=o&&angular.isDefined(o.copy)?o.copy:t;return o=d(o),a.open({templateUrl:n,controller:e,controllerAs:l,keyboard:o.kb,backdrop:o.bd,backdropClass:o.bdc,windowClass:o.wc,size:o.ws,animation:o.anim,resolve:{data:function(){return i?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 i=l.length-1;i>=0;i--)if("string"==typeof l[i].selectorText&&".fa"===l[i].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/dist/dialogs.min.js b/dist/dialogs.min.js index c77c870..ab3312c 100644 --- a/dist/dialogs.min.js +++ b/dist/dialogs.min.js @@ -1 +1,5 @@ -!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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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=["$uibModal",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,l){var r=o&&angular.isDefined(o.copy)?o.copy:t;return o=d(o),a.open({templateUrl:n,controller:e,controllerAs:l,keyboard:o.kb,backdrop:o.bd,backdropClass:o.bdc,windowClass:o.wc,size:o.ws,animation:o.anim,resolve:{data:function(){return r?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("string"==typeof l[r].selectorText&&".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 +<<<<<<< HEAD +!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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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.close=function(){n.dismiss("cancel")},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",i=!1,r=!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:i,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(){i=!0},this.useFontAwesome=function(){r=!0},this.$get=["$uibModal",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:r}}}})},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:r}}}})},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:r}}}})},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:r}}}})},create:function(n,e,s,t,l){var i=t&&angular.isDefined(t.copy)?t.copy:o;return t=d(t),a.open({templateUrl:n,controller:e,controllerAs:l,keyboard:t.kb,backdrop:t.bd,backdropClass:t.bdc,windowClass:t.wc,size:t.ws,animation:t.anim,resolve:{data:function(){return i?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 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 i=l.length-1;i>=0;i--)if(".fa"==l[i].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",'")}])}(); +======= +!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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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=["$uibModal",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,l){var r=o&&angular.isDefined(o.copy)?o.copy:t;return o=d(o),a.open({templateUrl:n,controller:e,controllerAs:l,keyboard:o.kb,backdrop:o.bd,backdropClass:o.bdc,windowClass:o.wc,size:o.ws,animation:o.anim,resolve:{data:function(){return r?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("string"==typeof l[r].selectorText&&".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",'")}])}(); +>>>>>>> master diff --git a/example/js/dialogs.js b/example/js/dialogs.js index dfd18d7..01496a1 100644 --- a/example/js/dialogs.js +++ b/example/js/dialogs.js @@ -176,7 +176,11 @@ ctrlrs.controller('confirmDialogCtrl',['$scope','$uibModalInstance','$translate' $scope.no = function(){ $uibModalInstance.dismiss('no'); - }; // end close + }; // end reject + + $scope.close = function(){ + $uibModalInstance.dismiss('cancel'); + };// end close $scope.yes = function(){ $uibModalInstance.close('yes'); @@ -560,7 +564,7 @@ angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires ang $templateCache.put('/dialogs/error.html',''); $templateCache.put('/dialogs/wait.html',''); $templateCache.put('/dialogs/notify.html',''); - $templateCache.put('/dialogs/confirm.html',''); + $templateCache.put('/dialogs/confirm.html',''); }]); // end run / dialogs.main })(); \ No newline at end of file diff --git a/example/js/dialogs.min.js b/example/js/dialogs.min.js index 2c1ee5f..3f05906 100644 --- a/example/js/dialogs.min.js +++ b/example/js/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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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=["$uibModal",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,l){var r=t&&angular.isDefined(t.copy)?t.copy:o;return t=d(t),a.open({templateUrl:n,controller:e,controllerAs:l,keyboard:t.kb,backdrop:t.bd,backdropClass:t.bdc,windowClass:t.wc,size:t.ws,animation:t.anim,resolve:{data:function(){return r?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 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 +!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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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","$uibModalInstance","$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.close=function(){n.dismiss("cancel")},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",i=!1,r=!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:i,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(){i=!0},this.useFontAwesome=function(){r=!0},this.$get=["$uibModal",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:r}}}})},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:r}}}})},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:r}}}})},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:r}}}})},create:function(n,e,s,t,l){var i=t&&angular.isDefined(t.copy)?t.copy:o;return t=d(t),a.open({templateUrl:n,controller:e,controllerAs:l,keyboard:t.kb,backdrop:t.bd,backdropClass:t.bdc,windowClass:t.wc,size:t.ws,animation:t.anim,resolve:{data:function(){return i?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 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 i=l.length-1;i>=0;i--)if(".fa"==l[i].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-controllers.js b/src/dialogs-controllers.js index c9dfb8f..7980025 100644 --- a/src/dialogs-controllers.js +++ b/src/dialogs-controllers.js @@ -108,7 +108,11 @@ ctrlrs.controller('confirmDialogCtrl',['$scope','$uibModalInstance','$translate' $scope.no = function(){ $uibModalInstance.dismiss('no'); - }; // end close + }; // end reject + + $scope.close = function(){ + $uibModalInstance.dismiss('cancel'); + };// end close $scope.yes = function(){ $uibModalInstance.close('yes'); diff --git a/src/dialogs-main.js b/src/dialogs-main.js index 9899cb2..9f62117 100644 --- a/src/dialogs-main.js +++ b/src/dialogs-main.js @@ -88,5 +88,5 @@ angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires ang $templateCache.put('/dialogs/error.html',''); $templateCache.put('/dialogs/wait.html',''); $templateCache.put('/dialogs/notify.html',''); - $templateCache.put('/dialogs/confirm.html',''); + $templateCache.put('/dialogs/confirm.html',''); }]); // end run / dialogs.main diff --git a/src/dialogs.js b/src/dialogs.js new file mode 100644 index 0000000..79169df --- /dev/null +++ b/src/dialogs.js @@ -0,0 +1,564 @@ +(function(){ +"use strict"; +//== Translate Substitute Module =============================================// + +/** + * For those not using Angular-Translate (pascalprecht.translate), this will sub + * in for it so we don't have to include Angular-Translate if we don't want to. + */ + +var translateSubMod = angular.module('translate.sub',[]); + + /** + * $translate Service + * Sets up a $translateProvider service to use in your module's config + * function. $translate.Provider syntax is the same as Angular-Translate, + * use $translate.Provider.translations(lang,obj) to change the defaults + * for modal button, header and message text. + */ + translateSubMod.provider('$translate',[function(){ + var _translations = []; // object of key/value translation pairs + var _current = 'en-US'; // default language + + /** + * Translations + * Set the internal object of translation key/value pairs. + */ + this.translations = function(lang,obj){ + if(angular.isDefined(lang) && angular.isDefined(obj)){ + _translations[lang] = angular.copy(obj); + _current = lang; + } + }; // end translations + + this.$get = [function(){ + return { + /** + * Instant + * Retrieve the translation for the given key, if key not found + * return an empty string. + * Example: $translate.instant('DIALOGS_OK'); + */ + instant : function(what){ + if(angular.isDefined(what) && angular.isDefined(_translations[_current][what])) + return _translations[_current][what]; + else + return ''; + } // end instant + }; // end return + }]; // end $get + + }]); // end $translate + + /** + * Translate Filter + * For use in an Angular template. + * Example: {{"DIALOGS_CLOSE" | translate}} + */ + translateSubMod.filter('translate',['$translate',function($translate){ + return function(what){ + return $translate.instant(what); + }; + }]); // end translate / translate.sub +//== Controllers =============================================================// + +var ctrlrs; // will be dialogs.controllers module + +// determine if Angular-Translate is available, if not use the substitute +try{ + angular.module('pascalprecht.translate'); // throws error if module not loaded + // console.log('Dialogs (Angular-Translate): OK'); + + // dialogs.controllers: module declaration + ctrlrs = angular.module('dialogs.controllers',['ui.bootstrap.modal','pascalprecht.translate']); +}catch(err){ + // console.log('Dialogs: (Angular-Translate): ' + err.message); + // console.log('Dialogs: Attempting to use translate.sub module.'); + + // dialogs.controllers: module declaration + ctrlrs = angular.module('dialogs.controllers',['ui.bootstrap.modal','translate.sub']); +} // end try/catch + +// angular.module('dialogs.controllers',['ui.bootstrap.modal','pascalprecht.translate']) + +/** + * Error Dialog Controller + */ +ctrlrs.controller('errorDialogCtrl',['$scope','$uibModalInstance','$translate','data',function($scope,$uibModalInstance,$translate,data){ + //-- Variables -----// + + $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_ERROR'); + $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_ERROR_MSG'); + $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-warning' : 'glyphicon glyphicon-warning-sign'; + + //-- Methods -----// + + $scope.close = function(){ + $uibModalInstance.close(); + $scope.$destroy(); + }; // end close +}]); // end ErrorDialogCtrl + +/** + * Wait Dialog Controller + */ +ctrlrs.controller('waitDialogCtrl',['$scope','$uibModalInstance','$translate','$timeout','data',function($scope,$uibModalInstance,$translate,$timeout,data){ + //-- Variables -----// + + $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_PLEASE_WAIT_ELIPS'); + $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_PLEASE_WAIT_MSG'); + $scope.progress = (angular.isDefined(data.progress)) ? data.progress : 100; + $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-clock-o' : 'glyphicon glyphicon-time'; + + //-- Listeners -----// + + // Note: used $timeout instead of $scope.$apply() because I was getting a $$nextSibling error + + // close wait dialog + $scope.$on('dialogs.wait.complete',function(){ + $timeout(function(){ $uibModalInstance.close(); $scope.$destroy(); }); + }); // end on(dialogs.wait.complete) + + // update the dialog's message + $scope.$on('dialogs.wait.message',function(evt,args){ + $scope.msg = (angular.isDefined(args.msg)) ? args.msg : $scope.msg; + }); // end on(dialogs.wait.message) + + // update the dialog's progress (bar) and/or message + $scope.$on('dialogs.wait.progress',function(evt,args){ + $scope.msg = (angular.isDefined(args.msg)) ? args.msg : $scope.msg; + $scope.progress = (angular.isDefined(args.progress)) ? args.progress : $scope.progress; + }); // end on(dialogs.wait.progress) + + //-- Methods -----// + + $scope.getProgress = function(){ + return {'width': $scope.progress + '%'}; + }; // end getProgress + +}]); // end WaitDialogCtrl + +/** + * Notify Dialog Controller + */ +ctrlrs.controller('notifyDialogCtrl',['$scope','$uibModalInstance','$translate','data',function($scope,$uibModalInstance,$translate,data){ + //-- Variables -----// + + $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_NOTIFICATION'); + $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_NOTIFICATION_MSG'); + $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-info' : 'glyphicon glyphicon-info-sign'; + + //-- Methods -----// + + $scope.close = function(){ + $uibModalInstance.close(); + $scope.$destroy(); + }; // end close +}]); // end WaitDialogCtrl + +/** + * Confirm Dialog Controller + */ +ctrlrs.controller('confirmDialogCtrl',['$scope','$uibModalInstance','$translate','data',function($scope,$uibModalInstance,$translate,data){ + //-- Variables -----// + + $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_CONFIRMATION'); + $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_CONFIRMATION_MSG'); + $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-check' : 'glyphicon glyphicon-check'; + + //-- Methods -----// + + $scope.no = function(){ + $uibModalInstance.dismiss('no'); + }; // end reject + + $scope.close = function(){ + $uibModalInstance.dismiss('cancel'); + };// end close + + $scope.yes = function(){ + $uibModalInstance.close('yes'); + }; // end yes +}]); // end ConfirmDialogCtrl / dialogs.controllers +//== Services ================================================================// + +angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) + + .provider('dialogs',[function(){ + var _b = true; // backdrop + var _k = true; // keyboard + var _w = 'dialogs-default'; // windowClass + var _bdc = 'dialogs-backdrop-default'; // backdropClass + var _copy = true; // controls use of angular.copy + var _wTmpl = null; // window template + var _wSize = 'lg'; // large modal window default + var _animation = false; // true/false to use animation + + var _fa = false; // fontawesome flag + + var _setOpts = function(opts){ + var _opts = {}; + opts = opts || {}; + _opts.kb = (angular.isDefined(opts.keyboard)) ? !!opts.keyboard : _k; // values: true,false + _opts.bd = (angular.isDefined(opts.backdrop)) ? opts.backdrop : _b; // values: 'static',true,false + _opts.bdc = (angular.isDefined(opts.backdropClass)) ? opts.backdropClass : _bdc; // additional CSS class(es) to be added to the modal backdrop + _opts.ws = (angular.isDefined(opts.size) && ((opts.size === 'sm') || (opts.size === 'lg') || (opts.size === 'md'))) ? opts.size : _wSize; // values: 'sm', 'lg', 'md' + _opts.wc = (angular.isDefined(opts.windowClass)) ? opts.windowClass : _w; // additional CSS class(es) to be added to a modal window + _opts.anim = (angular.isDefined(opts.animation)) ? !!opts.animation : _animation; // values: true,false + return _opts; + }; // end _setOpts + + /** + * 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 + * backdrop to true and does not respond to mouse clicks). + * + * @param val mixed (true, false, 'static') + */ + this.useBackdrop = function(val){ // possible values : true, false, 'static' + if(angular.isDefined(val)) + _b = val; + }; // end useStaticBackdrop + + /** + * Use ESC Close + * + * Sets the use of the ESC (escape) key to close modal windows. + * + * @param val boolean + */ + this.useEscClose = function(val){ // possible values : true, false + if(angular.isDefined(val)) + _k = (!angular.equals(val,0) && !angular.equals(val,'false') && !angular.equals(val,'no') && !angular.equals(val,null) && !angular.equals(val,false)) ? true : false; + }; // end useESCClose + + /** + * Use Class + * + * Sets the additional CSS window class of the modal window template. + * + * @param val string + */ + this.useClass = function(val){ + if(angular.isDefined(val)) + _w = val; + }; // end useClass + + /** + * Use Copy + * + * Determines the use of angular.copy when sending data to the modal controller. + * + * @param val boolean + */ + this.useCopy = function(val){ + if(angular.isDefined(val)) + _copy = (!angular.equals(val,0) && !angular.equals(val,'false') && !angular.equals(val,'no') && !angular.equals(val,null) && !angular.equals(val,false)) ? true : false; + }; // end useCopy + + /** + * Set Window Template + * + * Sets a path to a template to use overriding modal's window template. + * + * @param val string + */ + this.setWindowTmpl = function(val){ + if(angular.isDefined(val)) + _wTmpl = val; + }; // end setWindowTmpl + + /** + * Set Size + * + * Sets the modal size to use (sm,lg,md) + * + * @param val string (sm,lg,md) + */ + this.setSize = function(val){ + if(angular.isDefined(val)) + _wSize = (angular.equals(val,'sm') || angular.equals(val,'lg') || angular.equals(val,'md')) ? val : _wSize; + }; // end setSize + + /** + * Use Animations + * + * Sets the use of animations to true + */ + this.useAnimation = function(){ + _animation = true; + }; // end useAnimation + + /** + * Use Font-Awesome. + * + * Sets Font-Awesome flag to true and substitutes font-awesome icons for + * Bootstrap's glyphicons. + */ + this.useFontAwesome = function(){ + _fa = true; + }; // end useFontAwesome + + + this.$get = ['$uibModal',function ($uibModal){ + + return { + /** + * Error Dialog + * + * @param header string + * @param msg string + * @param opts object + */ + error : function(header,msg,opts){ + opts = _setOpts(opts); + + return $uibModal.open({ + templateUrl : '/dialogs/error.html', + controller : 'errorDialogCtrl', + backdrop: opts.bd, + backdropClass: opts.bdc, + keyboard: opts.kb, + windowClass: opts.wc, + size: opts.ws, + animation: opts.anim, + resolve : { + data : function(){ + return { + header : angular.copy(header), + msg : angular.copy(msg), + fa : _fa + }; + } + } + }); // end modal.open + }, // end error + + /** + * Wait Dialog + * + * @param header string + * @param msg string + * @param progress int + * @param opts object + */ + wait : function(header,msg,progress,opts){ + opts = _setOpts(opts); + + return $uibModal.open({ + templateUrl : '/dialogs/wait.html', + controller : 'waitDialogCtrl', + backdrop: opts.bd, + backdropClass: opts.bdc, + keyboard: opts.kb, + windowClass: opts.wc, + size: opts.ws, + animation: opts.anim, + resolve : { + data : function(){ + return { + header : angular.copy(header), + msg : angular.copy(msg), + progress : angular.copy(progress), + fa : _fa + }; + } + } + }); // end modal.open + }, // end wait + + /** + * Notify Dialog + * + * @param header string + * @param msg string + * @param opts object + */ + notify : function(header,msg,opts){ + opts = _setOpts(opts); + + return $uibModal.open({ + templateUrl : '/dialogs/notify.html', + controller : 'notifyDialogCtrl', + backdrop: opts.bd, + backdropClass: opts.bdc, + keyboard: opts.kb, + windowClass: opts.wc, + size: opts.ws, + animation: opts.anim, + resolve : { + data : function(){ + return { + header : angular.copy(header), + msg : angular.copy(msg), + fa : _fa + }; + } + } + }); // end modal.open + }, // end notify + + /** + * Confirm Dialog + * + * @param header string + * @param msg string + * @param opts object + */ + confirm : function(header,msg,opts){ + opts = _setOpts(opts); + + return $uibModal.open({ + templateUrl : '/dialogs/confirm.html', + controller : 'confirmDialogCtrl', + backdrop: opts.bd, + backdropClass: opts.bdc, + keyboard: opts.kb, + windowClass: opts.wc, + size: opts.ws, + animation: opts.anim, + resolve : { + data : function(){ + return { + header : angular.copy(header), + msg : angular.copy(msg), + fa : _fa + }; + } + } + }); // end modal.open + }, // end confirm + + /** + * Create Custom Dialog + * + * @param url string + * @param ctrlr string + * @param data object + * @param opts object + */ + create : function(url,ctrlr,data,opts,ctrlAs){ + var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; + opts = _setOpts(opts); + + return $uibModal.open({ + templateUrl : url, + controller : ctrlr, + controllerAs : ctrlAs, + keyboard : opts.kb, + backdrop : opts.bd, + backdropClass: opts.bdc, + windowClass: opts.wc, + size: opts.ws, + animation: opts.anim, + resolve : { + data : function() { + if(copy) + return angular.copy(data); + else + return data; + } + } + }); // end modal.open + } // end create + + }; // end return + + }]; // end $get + }]); // end provider dialogs +//== Dialogs.Main Module =====================================================// + +/** + * Include this module 'dialogs.main' in your module's dependency list where you + * intend to use it. Then inject the 'dialogs' service in your controllers that + * need it. + */ + +angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires angular-sanitize.min.js (ngSanitize) //code.angularjs.org/1.2.1/angular-sanitize.min.js + + .config(['$translateProvider','dialogsProvider',function($translateProvider,dialogsProvider){ + /** + * if Angular-Translate is not loaded, use the translate substitute + * module and create default translations to use as default modal texts + */ + try{ + angular.module('pascalprecht.translate'); + }catch(err){ + // console.log('Dialogs: Creating default translations for use without Angular-Translate.'); + + // This will set default modal buttons, header and message text + $translateProvider.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" + }); + } // end try/catch + + /** + * Attempt to ascertain if page is using Font Awesome instead of the + * regular Bootstrap Icons. If you are changing the stylesheet name or + * not including it from a CDN or have included Font-Awesome as a + * concatentation of CSS sheets together, then you will have to manually + * set Font-Awesome usage in your Angular Module's config by including + * the $dialogsProvider and calling the method $dialogsProvider.useFontAwesome(). + */ + try{ + var _sheets = document.styleSheets; + + sheetLoop: + for(var i = (_sheets.length - 1);i >= 0;i--){ + var _matches = null; + var _rules = null; + + if(!_sheets[i].disabled){ + // check href of style sheet first + if(_sheets[i].href !== null) + _matches = _sheets[i].href.match(/font\-*awesome/i); + + if(angular.isArray(_matches)){ + dialogsProvider.useFontAwesome(); + break; // done, leave the style sheet for loop + }else{ + // try to find css rule .fa, in case style sheet has been concatenated + _rules = _sheets[i].cssRules; + for(var x = (_rules.length - 1);x >= 0;x--){ + if(_rules[x].selectorText.toLowerCase() == '.fa'){ + dialogsProvider.useFontAwesome(); + break sheetLoop; // done, exit both for loops + } + } + } + } // end if(disabled) + } // end for + }catch(err){ + // console.log('Error Message: ' + err); + } + }]) // end config + + // Add default templates via $templateCache + .run(['$templateCache','$interpolate',function($templateCache,$interpolate){ + + // get interpolation symbol (possible that someone may have changed it in their application instead of using '{{}}') + var startSym = $interpolate.startSymbol(); + var endSym = $interpolate.endSymbol(); + + $templateCache.put('/dialogs/error.html',''); + $templateCache.put('/dialogs/wait.html',''); + $templateCache.put('/dialogs/notify.html',''); + $templateCache.put('/dialogs/confirm.html',''); + }]); // end run / dialogs.main + +})(); \ No newline at end of file