From 8b54b723dadf87b2ca058499bf1a8d832c9fa70b Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 17 Feb 2015 17:13:32 -0500 Subject: [PATCH] LP#1402797 Move aDisabled from patron/app to services/ui so it can be used everywhere Signed-off-by: Mike Rylander Signed-off-by: Bill Erickson --- .../js/ui/default/staff/circ/patron/app.js | 25 --------------- .../web/js/ui/default/staff/services/ui.js | 31 +++++++++++++++++-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 70247fd988..f80486fd46 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -1566,28 +1566,3 @@ function($scope , $routeParams , $window , $location , egCore) { $scope.user_perms_url = url; }]) -.directive('aDisabled', function() { - return { - compile: function(tElement, tAttrs, transclude) { - //Disable ngClick - tAttrs["ngClick"] = ("ng-click", "!("+tAttrs["aDisabled"]+") && ("+tAttrs["ngClick"]+")"); - - //Toggle "disabled" to class when aDisabled becomes true - return function (scope, iElement, iAttrs) { - scope.$watch(iAttrs["aDisabled"], function(newValue) { - if (newValue !== undefined) { - iElement.toggleClass("disabled", newValue); - } - }); - - //Disable href on click - iElement.on("click", function(e) { - if (scope.$eval(iAttrs["aDisabled"])) { - e.preventDefault(); - } - }); - }; - } - }; -}) - diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index ca79115ef6..25312c667c 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -181,6 +181,31 @@ function($modal, $interpolate) { return service; }]) +.directive('aDisabled', function() { + return { + restrict : 'A', + compile: function(tElement, tAttrs, transclude) { + //Disable ngClick + tAttrs["ngClick"] = ("ng-click", "!("+tAttrs["aDisabled"]+") && ("+tAttrs["ngClick"]+")"); + + //Toggle "disabled" to class when aDisabled becomes true + return function (scope, iElement, iAttrs) { + scope.$watch(iAttrs["aDisabled"], function(newValue) { + if (newValue !== undefined) { + iElement.toggleClass("disabled", newValue); + } + }); + + //Disable href on click + iElement.on("click", function(e) { + if (scope.$eval(iAttrs["aDisabled"])) { + e.preventDefault(); + } + }); + }; + } + }; +}) /** * Nested org unit selector modeled as a Bootstrap dropdown button. @@ -196,12 +221,12 @@ function($modal, $interpolate) { // Each org unit is passed into this function and, for // any org units where the response value is true, the // org unit will not be added to the selector. - hiddenTest : '&', + hiddenTest : '=', // Each org unit is passed into this function and, for // any org units where the response value is true, the // org unit will not be available for selection. - disableTest : '&', + disableTest : '=', // Caller can either $watch(selected, ..) or register an // onchange handler. @@ -220,7 +245,7 @@ function($modal, $interpolate) { + '' + '