Sha256: 59c89c8d93269e7f5c10aad15009b4be2134b10a1a05466dcf56d52e6f4bfcc6
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
angular.module('EssayApp.directives').directive "languageCell", ['$timeout', ($timeout) -> restrict: 'A' scope: true require: "ngModel" link: (scope, element, attrs, ngModel) -> item = scope.$eval(attrs.languageCell) return unless item scope.value = $.extend { selected: false }, item, true activateCell = (cell) -> # element.addClass('active') clearCell = (cell) -> # element.removeClass('active') checkCell = () -> if isSelected() scope.value.selected = true activateCell(element) else scope.value.selected = false clearCell(element) isSelected = (record) -> if ngModel?.$modelValue?.length > 0 ngModel?.$modelValue?.filter( (x) -> x.id == scope.value?.id ).length > 0 else return false unSelect = (value, items) -> # value.selected = false for x in items if x.id == value.id x.selected = false fn = () -> ngModel?.$modelValue?.length $timeout (-> element.find('a, [clickable]').off('click.languagecell').on('click.languagecell', (e) -> e.preventDefault() items = ngModel?.$modelValue return unless items? active = scope.value.selected unSelect(scope.value, items) if scope.value && itels?.length > 0 scope.value.selected = !active if active items = items.filter (i)-> i.id != scope.value.id else items.push(scope.value) ngModel?.$setViewValue(items) scope.$apply() return false ) return ), 0, false scope.$watch fn, (len) -> checkCell() checkCell() ]
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_cms-0.1.5 | app/assets/javascripts/app/directives/language_cell.js.coffee |