X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fresources%2FMETA-INF%2Fresources%2Fdesigner%2Flib%2Fdialogs.js;h=dfd18d784e9e4ad055752f00a8cfd1a7b48eb699;hb=390dee7212365cf78fe38a1c36d6cc2392708b03;hp=b8d26d1d1452913f1191513420699f1c14e802c2;hpb=ea5b0b5b35ddee80a07bef4af391387ed348658b;p=clamp.git diff --git a/src/main/resources/META-INF/resources/designer/lib/dialogs.js b/src/main/resources/META-INF/resources/designer/lib/dialogs.js index b8d26d1d..dfd18d78 100644 --- a/src/main/resources/META-INF/resources/designer/lib/dialogs.js +++ b/src/main/resources/META-INF/resources/designer/lib/dialogs.js @@ -1,3 +1,9 @@ +/** + * 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 =============================================// @@ -84,7 +90,7 @@ try{ /** * Error Dialog Controller */ -ctrlrs.controller('errorDialogCtrl',['$scope','$modalInstance','$translate','data',function($scope,$modalInstance,$translate,data){ +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'); @@ -94,7 +100,7 @@ ctrlrs.controller('errorDialogCtrl',['$scope','$modalInstance','$translate','dat //-- Methods -----// $scope.close = function(){ - $modalInstance.close(); + $uibModalInstance.close(); $scope.$destroy(); }; // end close }]); // end ErrorDialogCtrl @@ -102,7 +108,7 @@ ctrlrs.controller('errorDialogCtrl',['$scope','$modalInstance','$translate','dat /** * Wait Dialog Controller */ -ctrlrs.controller('waitDialogCtrl',['$scope','$modalInstance','$translate','$timeout','data',function($scope,$modalInstance,$translate,$timeout,data){ +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'); @@ -116,7 +122,7 @@ ctrlrs.controller('waitDialogCtrl',['$scope','$modalInstance','$translate','$tim // close wait dialog $scope.$on('dialogs.wait.complete',function(){ - $timeout(function(){ $modalInstance.close(); $scope.$destroy(); }); + $timeout(function(){ $uibModalInstance.close(); $scope.$destroy(); }); }); // end on(dialogs.wait.complete) // update the dialog's message @@ -141,7 +147,7 @@ ctrlrs.controller('waitDialogCtrl',['$scope','$modalInstance','$translate','$tim /** * Notify Dialog Controller */ -ctrlrs.controller('notifyDialogCtrl',['$scope','$modalInstance','$translate','data',function($scope,$modalInstance,$translate,data){ +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'); @@ -151,7 +157,7 @@ ctrlrs.controller('notifyDialogCtrl',['$scope','$modalInstance','$translate','da //-- Methods -----// $scope.close = function(){ - $modalInstance.close(); + $uibModalInstance.close(); $scope.$destroy(); }; // end close }]); // end WaitDialogCtrl @@ -159,7 +165,7 @@ ctrlrs.controller('notifyDialogCtrl',['$scope','$modalInstance','$translate','da /** * Confirm Dialog Controller */ -ctrlrs.controller('confirmDialogCtrl',['$scope','$modalInstance','$translate','data',function($scope,$modalInstance,$translate,data){ +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'); @@ -169,11 +175,11 @@ ctrlrs.controller('confirmDialogCtrl',['$scope','$modalInstance','$translate','d //-- Methods -----// $scope.no = function(){ - $modalInstance.dismiss('no'); + $uibModalInstance.dismiss('no'); }; // end close $scope.yes = function(){ - $modalInstance.close('yes'); + $uibModalInstance.close('yes'); }; // end yes }]); // end ConfirmDialogCtrl / dialogs.controllers //== Services ================================================================// @@ -184,28 +190,31 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) 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.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.ws = (angular.isDefined(opts.size) && (angular.equals(opts.size,'sm') || angular.equals(opts.size,'lg') || angular.equals(opts.size,'md'))) ? opts.size : _wSize; // values: 'sm', 'lg', 'md' + _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 + * 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') @@ -217,7 +226,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use ESC Close - * + * * Sets the use of the ESC (escape) key to close modal windows. * * @param val boolean @@ -241,7 +250,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Use Copy - * + * * Determines the use of angular.copy when sending data to the modal controller. * * @param val boolean @@ -266,7 +275,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) /** * Set Size * - * Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 + + * Sets the modal size to use (sm,lg,md) * * @param val string (sm,lg,md) */ @@ -275,6 +284,15 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) _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. * @@ -286,8 +304,8 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) }; // end useFontAwesome - this.$get = ['$modal',function ($modal){ - + this.$get = ['$uibModal',function ($uibModal){ + return { /** * Error Dialog @@ -299,13 +317,15 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) error : function(header,msg,opts){ opts = _setOpts(opts); - return $modal.open({ + 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 { @@ -317,7 +337,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end error - + /** * Wait Dialog * @@ -329,13 +349,15 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) wait : function(header,msg,progress,opts){ opts = _setOpts(opts); - return $modal.open({ + 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 { @@ -348,7 +370,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end wait - + /** * Notify Dialog * @@ -359,13 +381,15 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) notify : function(header,msg,opts){ opts = _setOpts(opts); - return $modal.open({ + 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 { @@ -377,7 +401,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end notify - + /** * Confirm Dialog * @@ -388,13 +412,15 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) confirm : function(header,msg,opts){ opts = _setOpts(opts); - return $modal.open({ + 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 { @@ -406,7 +432,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) } }); // end modal.open }, // end confirm - + /** * Create Custom Dialog * @@ -415,19 +441,22 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers']) * @param data object * @param opts object */ - create : function(url,ctrlr,data,opts){ + create : function(url,ctrlr,data,opts,ctrlAs){ var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy; opts = _setOpts(opts); - return $modal.open({ + 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() { + data : function() { if(copy) return angular.copy(data); else @@ -499,7 +528,7 @@ angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires ang if(!_sheets[i].disabled){ // check href of style sheet first if(_sheets[i].href !== null) - _matches = _sheets[i].match(/font\-*awesome/i); + _matches = _sheets[i].href.match(/font\-*awesome/i); if(angular.isArray(_matches)){ dialogsProvider.useFontAwesome(); @@ -508,7 +537,7 @@ angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires ang // 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'){ + if(typeof(_rules[x].selectorText) === 'string' && _rules[x].selectorText.toLowerCase() === '.fa'){ dialogsProvider.useFontAwesome(); break sheetLoop; // done, exit both for loops } @@ -516,19 +545,6 @@ angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires ang } } // end if(disabled) } // end for - - /* Removed in favor of above, will delete this permanently after more testing - angular.forEach(_sheets,function(_sheet,key){ - var _matches = null; - if(!angular.equals(_sheet.href,null)) - _matches = _sheet.href.match(/font\-*awesome/); - - if(!_sheet.disabled && angular.isArray(_matches)){ - // console.log('Dialogs: Using Font-Awesome Icons'); - dialogsProvider.useFontAwesome(); - } - }); - */ }catch(err){ // console.log('Error Message: ' + err); } @@ -546,4 +562,5 @@ angular.module('dialogs.main',['dialogs.services','ngSanitize']) // requires ang $templateCache.put('/dialogs/notify.html',''); $templateCache.put('/dialogs/confirm.html',''); }]); // end run / dialogs.main + })(); \ No newline at end of file