summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/sdk-app/src/main/webapp/app/fusion/external/ebz/angular_js/checklist-model.js
diff options
context:
space:
mode:
authorTATTAVARADA <statta@research.att.com>2017-04-27 07:53:18 -0400
committerst782s <statta@research.att.com>2017-04-27 08:31:27 -0400
commit6beb446925c967aca92f5513adf36c5db77c00d6 (patch)
tree9392057ed0739de2445c5b2a2a8bee6dcdacbcf7 /ecomp-sdk/sdk-app/src/main/webapp/app/fusion/external/ebz/angular_js/checklist-model.js
parent246b225194e3e8dc1926294de591a94fd9787fa7 (diff)
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-sdk/sdk-app/src/main/webapp/app/fusion/external/ebz/angular_js/checklist-model.js')
-rw-r--r--ecomp-sdk/sdk-app/src/main/webapp/app/fusion/external/ebz/angular_js/checklist-model.js99
1 files changed, 0 insertions, 99 deletions
diff --git a/ecomp-sdk/sdk-app/src/main/webapp/app/fusion/external/ebz/angular_js/checklist-model.js b/ecomp-sdk/sdk-app/src/main/webapp/app/fusion/external/ebz/angular_js/checklist-model.js
deleted file mode 100644
index 09d8cefb..00000000
--- a/ecomp-sdk/sdk-app/src/main/webapp/app/fusion/external/ebz/angular_js/checklist-model.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Checklist-model
- * AngularJS directive for list of checkboxes
- */
-
-angular.module('checklist-model', [])
-.directive('checklistModel', ['$parse', '$compile', function($parse, $compile) {
- // contains
- function contains(arr, item) {
- if (angular.isArray(arr)) {
- for (var i = 0; i < arr.length; i++) {
- if (angular.equals(arr[i], item)) {
- return true;
- }
- }
- }
- return false;
- }
-
- // add
- function add(arr, item) {
- arr = angular.isArray(arr) ? arr : [];
- for (var i = 0; i < arr.length; i++) {
- if (angular.equals(arr[i], item)) {
- return arr;
- }
- }
- arr.push(item);
- return arr;
- }
-
- // remove
- function remove(arr, item) {
- if (angular.isArray(arr)) {
- for (var i = 0; i < arr.length; i++) {
- if (angular.equals(arr[i], item)) {
- arr.splice(i, 1);
- break;
- }
- }
- }
- return arr;
- }
-
- // http://stackoverflow.com/a/19228302/1458162
- function postLinkFn(scope, elem, attrs) {
- // compile with `ng-model` pointing to `checked`
- $compile(elem)(scope);
-
- // getter / setter for original model
- var getter = $parse(attrs.checklistModel);
- var setter = getter.assign;
-
- // value added to list
- var value = $parse(attrs.checklistValue)(scope.$parent);
-
- // watch UI checked change
- scope.$watch('checked', function(newValue, oldValue) {
- if (newValue === oldValue) {
- return;
- }
- var current = getter(scope.$parent);
- if (newValue === true) {
- setter(scope.$parent, add(current, value));
- } else {
- setter(scope.$parent, remove(current, value));
- }
- });
-
- // watch original model change
- scope.$parent.$watch(attrs.checklistModel, function(newArr, oldArr) {
- scope.checked = contains(newArr, value);
- }, true);
- }
-
- return {
- restrict: 'A',
- priority: 1000,
- terminal: true,
- scope: true,
- compile: function(tElement, tAttrs) {
- if (tElement[0].tagName !== 'INPUT' || tAttrs.type !== 'checkbox') {
- throw 'checklist-model should be applied to `input[type="checkbox"]`.';
- }
-
- if (!tAttrs.checklistValue) {
- throw 'You should provide `checklist-value`.';
- }
-
- // exclude recursion
- tElement.removeAttr('checklist-model');
-
- // local scope var storing individual checkbox model
- tElement.attr('ng-model', 'checked');
-
- return postLinkFn;
- }
- };
-}]);