PATH:
usr
/
local
/
jetapps
/
frontend
/
jetbackup
/
app
/
directives
'use strict'; define([ 'app' ], function (app) { app.directive("alertBox", ["$timeout", "$compile", "lang", function($timeout, $compile, lang) { var _counter = 0; var ID_DEFAULT_PREFIX = "alert"; var LABELS = [{ name: "errorLabel", defaultText: lang.t("Error:") }, { name: "warnLabel", defaultText: lang.t("Warning:") }, { name: "infoLabel" // defaultText: lang.t("Information:") }, { name: "successLabel", defaultText: lang.t("Success:") }, { name: "moreLabel", defaultText: lang.t("What went wrong?") }]; var initializeModel = function(hasModel, attrs, modelValue) { var data = {}; if (hasModel) { if (angular.isString(modelValue)) { data.message = modelValue; } else if (angular.isObject(modelValue)) { angular.copy(modelValue, data); } else { throw new TypeError("ngModel must be a string or object."); } } if (!angular.isDefined(data.type)) { if (angular.isDefined(attrs.type) && attrs.type) { data.type = attrs.type; } else { data.type = "info"; } } if (angular.isDefined(data.closable)) { data.closable = ((data.type === "danger") ? false : data.closable); } else if (angular.isDefined(attrs.closable)) { data.closable = ((data.type === "danger") ? false : true); } else { data.closable = false; } if (angular.isDefined(data.autoClose)) { data.autoClose = ((data.type === "danger") ? false : data.autoClose); } else if (angular.isDefined(attrs.autoClose)) { data.autoClose = ((data.type === "danger") ? false : data.autoClose); } else { data.autoClose = false; } if (!angular.isDefined(data.id)) { if (!angular.isDefined(attrs.id)) { data.id = ID_DEFAULT_PREFIX + _counter++; } else { data.id = attrs.id; } } if (hasModel && !angular.isDefined(data.message) && !data.message) { throw new Error("No message provided in the model's message property."); } return data; }; var renderBody = function(scope, element, transclude) { var type = scope.alert.type; var typeBlock = element[0].querySelector(".alert-" + type); var messageSpan = typeBlock.querySelector(".alert-body"); transclude(function(clone) { angular.element(messageSpan).append(clone); }); }; return { restrict: "EA", template: '<div>\n' + ' <div ng-show="alert.type === \'danger\'" class=\'alert alert-danger ng-hide\'>\n' + ' <button id="{{\'btnClose_danger_\' + alert.id}}" type=\'button\' class=\'close\' ng-if=\'alert.closeable\' ng-click=\'runClose()\'>×</button>\n' + ' <button id="{{\'btnMore_danger_\' + alert.id}}" type=\'button\' class=\'btn btn-more btn-link pull-right flip\' ng-if=\'hasToggleHandler\' ng-click=\'runToggleMore()\'>{{moreLabel}}</button>\n' + ' <span class=\'glyphicon glyphicon-remove-sign\'></span>\n' + ' <div class=\'alert-message\'>\n' + ' <strong class="alert-title" ng-show="errorLabel">{{errorLabel}}</strong>\n' + ' <span class="alert-body"><span id="{{\'txtMessage_danger_\' + alert.id}}" ng-bind-html="alert.message" ng-if="alert && alert.message"></span></span>\n' + ' <ul ng-if="alert.list && alert.list.length" class="alert-list">\n' + ' <li ng-repeat="value in alert.list">\n' + ' <span id="{{\'txtList_danger_\' + alert.id + \'_\' + $index}}" ng-bind-html="value"></span>\n' + ' </li>\n' + ' </ul>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <div ng-show="alert.type === \'warning\'" class=\'alert alert-warning ng-hide\'>\n' + ' <button id="{{\'btnClose_warning_\' + alert.id}}" type=\'button\' class=\'close\' ng-if=\'alert.closeable\' ng-click=\'runClose()\'>×</button>\n' + ' <button id="{{\'btnMore_warning_\' + alert.id}}" type=\'button\' class=\'btn btn-more btn-link pull-right flip\' ng-if=\'hasToggleHandler\' ng-click=\'runToggleMore()\'>{{moreLabel}}</button>\n' + ' <span class=\'glyphicon glyphicon-exclamation-sign\'></span>\n' + ' <div class=\'alert-message\'>\n' + ' <strong class="alert-title" ng-show="warnLabel">{{warnLabel}}</strong>\n' + ' <span class="alert-body"><span id="{{\'txtMessage_warning_\' + alert.id}}" ng-bind-html="alert.message" ng-if="alert && alert.message"></span></span>\n' + ' <ul ng-if="alert.list && alert.list.length" class="alert-list">\n' + ' <li ng-repeat="value in alert.list">\n' + ' <span id="{{\'txtList_warning_\' + alert.id + \'_\' + $index}}" ng-bind-html="value"></span>\n' + ' </li>\n' + ' </ul>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <div ng-show="alert.type === \'success\'" class=\'alert alert-success ng-hide\'>\n' + ' <button id="{{\'btnClose_success_\' + alert.id}}" type=\'button\' class=\'close\' ng-if=\'alert.closeable\' ng-click=\'runClose()\'>×</button>\n' + ' <button id="{{\'btnMore_success_\' + alert.id}}" type=\'button\' class=\'btn btn-more btn-link pull-right flip\' ng-if=\'hasToggleHandler\' ng-click=\'runToggleMore()\'>{{moreLabel}}</button>\n' + ' <span class=\'glyphicon glyphicon-ok-sign\'></span>\n' + ' <div class=\'alert-message\'>\n' + ' <strong class="alert-title" ng-show="successLabel">{{successLabel}}</strong>\n' + ' <span class="alert-body"><span id="{{\'txtMessage_success_\' + alert.id}}" ng-bind-html="alert.message" ng-if="alert && alert.message"></span></span>\n' + ' <ul ng-if="alert.list && alert.list.length" class="alert-list">\n' + ' <li ng-repeat="value in alert.list">\n' + ' <span id="{{\'txtList_success_\' + alert.id + \'_\' + $index}}" ng-bind-html="value"></span>\n' + ' </li>\n' + ' </ul>\n' + ' </div>\n' + ' </div>\n' + '\n' + ' <div ng-show="alert.type === \'info\'" class=\'alert alert-info ng-hide\'>\n' + ' <button id="{{\'btnClose_info_\' + alert.id}}" type=\'button\' class=\'close\' ng-if=\'alert.closeable\' ng-click=\'runClose()\'>×</button>\n' + ' <button id="{{\'btnMore_info_\' + alert.id}}" type=\'button\' class=\'btn btn-more btn-link pull-right flip\' ng-if=\'hasToggleHandler\' ng-click=\'runToggleMore()\'>{{moreLabel}}</button>\n' + ' <span class=\'glyphicon glyphicon-info-sign\'></span>\n' + ' <div class=\'alert-message\'>\n' + ' <strong class="alert-title" ng-show="infoLabel">{{infoLabel}}</strong>\n' + ' <span class="alert-body"><span id="{{\'txtMessage_info_\' + alert.id}}" ng-bind-html="alert.message" ng-if="alert && alert.message"></span></span>\n' + ' <ul ng-if="alert.list && alert.list.length" class="alert-list">\n' + ' <li ng-repeat="value in alert.list">\n' + ' <span id="{{\'txtList_info_\' + alert.id + \'_\' + $index}}" ng-bind-html="value"></span>\n' + ' </li>\n' + ' </ul>\n' + ' </div>\n' + ' </div>\n' + '</div>', transclude: true, replace: true, require: "?ngModel", scope: { close: "&onClose", toggleMore: "&onToggleMore", autoClose: "=", errorLabel: "@", warnLabel: "@", infoLabel: "@", successLabel: "@", moreLabel: "@" }, compile: function(element, attrs) { LABELS.forEach(function(label) { if (!angular.isDefined(attrs[label.name])) { attrs[label.name] = label.defaultText; } }); return function(scope, element, attrs, ngModelCtrl, transclude) { if (ngModelCtrl) { ngModelCtrl.$formatters.push(function(modelValue) { return initializeModel(true, attrs, modelValue); }); ngModelCtrl.$render = function() { scope.alert = ngModelCtrl.$viewValue; }; } else { scope.alert = initializeModel(false, attrs); renderBody(scope, element, transclude); } scope.$watch("alert.label", function(newVal) { if ( angular.isDefined(newVal) ) { LABELS.forEach(function(label) { attrs.$set(label.name, newVal); }); } }); scope.runClose = function() { if (scope.timer) { var timer = scope.timer; scope.timer = null; delete scope.timer; $timeout.cancel(timer); } scope.$emit("closeAlertCalled", { id: scope.alert.id }); scope.alert.type = ''; //ngModel.$setViewValue(scope.type); scope.close(); }; var msecs = scope.autoClose ? parseInt(scope.autoClose, 10) : null; if (msecs && !isNaN(msecs)) { scope.timer = $timeout(function() { scope.runClose(); }, msecs); } scope.hasToggleHandler = angular.isDefined(attrs.onToggleMore); scope.showMore = false; scope.runToggleMore = function() { scope.showMore = !scope.showMore; var e = { id: scope.alert.id, show: scope.showMore }; scope.$emit("toggleMoreAlertCalled", e); scope.toggleMore(e); }; }; } }; } ]); });
[-] alertBox.js
[edit]
[+]
..
[-] sortBy.js
[edit]