1 //== Dialogs.Main Module =====================================================//
4 * Include this module 'dialogs.main' in your module's dependency list where you
5 * intend to use it. Then inject the 'dialogs' service in your controllers that
9 angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires angular-sanitize.min.js (ngSanitize) //code.angularjs.org/1.2.1/angular-sanitize.min.js
11 .config(['$translateProvider','dialogsProvider',function($translateProvider,dialogsProvider){
13 * if Angular-Translate is not loaded, use the translate substitute
14 * module and create default translations to use as default modal texts
17 angular.module('pascalprecht.translate');
19 // console.log('Dialogs: Creating default translations for use without Angular-Translate.');
21 // This will set default modal buttons, header and message text
22 $translateProvider.translations('en-US',{
23 DIALOGS_ERROR: "Error",
24 DIALOGS_ERROR_MSG: "An unknown error has occurred.",
25 DIALOGS_CLOSE: "Close",
26 DIALOGS_PLEASE_WAIT: "Please Wait",
27 DIALOGS_PLEASE_WAIT_ELIPS: "Please Wait...",
28 DIALOGS_PLEASE_WAIT_MSG: "Waiting on operation to complete.",
29 DIALOGS_PERCENT_COMPLETE: "% Complete",
30 DIALOGS_NOTIFICATION: "Notification",
31 DIALOGS_NOTIFICATION_MSG: "Unknown application notification.",
32 DIALOGS_CONFIRMATION: "Confirmation",
33 DIALOGS_CONFIRMATION_MSG: "Confirmation required.",
41 * Attempt to ascertain if page is using Font Awesome instead of the
42 * regular Bootstrap Icons. If you are changing the stylesheet name or
43 * not including it from a CDN or have included Font-Awesome as a
44 * concatentation of CSS sheets together, then you will have to manually
45 * set Font-Awesome usage in your Angular Module's config by including
46 * the $dialogsProvider and calling the method $dialogsProvider.useFontAwesome().
49 var _sheets = document.styleSheets;
52 for(var i = (_sheets.length - 1);i >= 0;i--){
56 if(!_sheets[i].disabled){
57 // check href of style sheet first
58 if(_sheets[i].href !== null)
59 _matches = _sheets[i].match(/font\-*awesome/i);
61 if(angular.isArray(_matches)){
62 dialogsProvider.useFontAwesome();
63 break; // done, leave the style sheet for loop
65 // try to find css rule .fa, in case style sheet has been concatenated
66 _rules = _sheets[i].cssRules;
67 for(var x = (_rules.length - 1);x >= 0;x--){
68 if(_rules[x].selectorText.toLowerCase() == '.fa'){
69 dialogsProvider.useFontAwesome();
70 break sheetLoop; // done, exit both for loops
77 /* Removed in favor of above, will delete this permanently after more testing
78 angular.forEach(_sheets,function(_sheet,key){
80 if(!angular.equals(_sheet.href,null))
81 _matches = _sheet.href.match(/font\-*awesome/);
83 if(!_sheet.disabled && angular.isArray(_matches)){
84 // console.log('Dialogs: Using Font-Awesome Icons');
85 dialogsProvider.useFontAwesome();
90 // console.log('Error Message: ' + err);
94 // Add default templates via $templateCache
95 .run(['$templateCache','$interpolate',function($templateCache,$interpolate){
97 // get interpolation symbol (possible that someone may have changed it in their application instead of using '{{}}')
98 var startSym = $interpolate.startSymbol();
99 var endSym = $interpolate.endSymbol();
101 $templateCache.put('/dialogs/error.html','<div class="modal-header dialog-header-error"><button type="button" class="close" ng-click="close()">×</button><h4 class="modal-title text-danger"><span class="'+startSym+'icon'+endSym+'"></span> <span ng-bind-html="header"></span></h4></div><div class="modal-body text-danger" ng-bind-html="msg"></div><div class="modal-footer"><button type="button" class="btn btn-default" ng-click="close()">'+startSym+'"DIALOGS_CLOSE" | translate'+endSym+'</button></div>');
102 $templateCache.put('/dialogs/wait.html','<div class="modal-header dialog-header-wait"><h4 class="modal-title"><span class="'+startSym+'icon'+endSym+'"></span> '+startSym+'header'+endSym+'</h4></div><div class="modal-body"><p ng-bind-html="msg"></p><div class="progress progress-striped active"><div class="progress-bar progress-bar-info" ng-style="getProgress()"></div><span class="sr-only">'+startSym+'progress'+endSym+''+startSym+'"DIALOGS_PERCENT_COMPLETE" | translate'+endSym+'</span></div></div>');
103 $templateCache.put('/dialogs/notify.html','<div class="modal-header dialog-header-notify"><button type="button" class="close" ng-click="close()" class="pull-right">×</button><h4 class="modal-title text-info"><span class="'+startSym+'icon'+endSym+'"></span> '+startSym+'header'+endSym+'</h4></div><div class="modal-body text-info" ng-bind-html="msg"></div><div class="modal-footer"><button type="button" class="btn btn-primary" ng-click="close()">'+startSym+'"DIALOGS_OK" | translate'+endSym+'</button></div>');
104 $templateCache.put('/dialogs/confirm.html','<div class="modal-header dialog-header-confirm"><button type="button" class="close" ng-click="no()">×</button><h4 class="modal-title"><span class="'+startSym+'icon'+endSym+'"></span> '+startSym+'header'+endSym+'</h4></div><div class="modal-body" ng-bind-html="msg"></div><div class="modal-footer"><button type="button" class="btn btn-default" ng-click="yes()">'+startSym+'"DIALOGS_YES" | translate'+endSym+'</button><button type="button" class="btn btn-primary" ng-click="no()">'+startSym+'"DIALOGS_NO" | translate'+endSym+'</button></div>');
105 }]); // end run / dialogs.main