Sha256: f8c3859534713a84a0a122e2c2369fefb0bcb2d2b00a6ddd648d6be589232c62
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
angular.module('EssayApp.directives').directive("checkboxList", [ -> restrict: 'A', scope: true, link: (scope, elem, attrs, ngModel)-> # Determine initial checked boxes if (scope.$eval(attrs.checkboxList).indexOf(attrs.checkId) != -1) elem.prop('checked', true) else elem.prop('checked', false) # Update array on click elem.on 'change', -> index = scope.$eval("#{attrs.checkboxList}.indexOf(#{attrs.checkId})") # Add if checked if (elem.prop('checked')) scope.$apply scope.$eval("#{attrs.checkboxList}.push(#{attrs.checkId})") if (index == -1) # Remove if unchecked else scope.$apply scope.$eval("#{attrs.checkboxList}.splice(#{index}, 1)") if (index != -1) # console.log attrs.checkId, elem.prop('checked'), scope.$eval(attrs.checkboxList), "#{attrs.checkboxList}.splice(#{index}, 1)" # Sort and update DOM display # scope.$apply() scope.$watch( "#{attrs.checkboxList}.length", (len)-> if (scope.$eval("#{attrs.checkboxList}.indexOf(#{attrs.checkId})") != -1) elem.prop('checked', true) elem.uniform('update') if attrs.checkUniform else elem.prop('checked', false) elem.uniform('update') if attrs.checkUniform ) ])
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_cms-0.1.5 | app/assets/javascripts/app/directives/check_box_list.js.coffee |