UNPKG

acha-framework

Version:

is a modular framework on both client (angular.js) and server (node.js) side, it provides security, orm, ioc, obfuscation and ...

68 lines 2.09 kB
(function ($, angular, underscore, window, document, undefined) { 'use strict'; angular.module('frontend.directives').directive('datePicker', [ '$document', function ($document) { return { restrict: 'E', replace: true, scope: { tag: '<?', disabled: '=?', visible: '=?', cssClass: '=?', culture: '=?', format: '=?', onChange: '=?', model: '=?' }, templateUrl: '/templates/framework/directives/date-picker/template.html', link: function (scope, element, attr) { scope.vm = { showPlate: false, model: scope.model }; scope.vm.init = function () { if (angular.isUndefined(scope.disabled)) { scope.disabled = false; } if (angular.isUndefined(scope.visible)) { scope.visible = true; } if (angular.isUndefined(scope.cssClass)) { scope.cssClass = ''; } scope.vm.bind(); }; scope.vm.onChange = function (date, tag) { scope.model = date; if (scope.onChange) { scope.onChange(date, tag); } }; scope.vm.closeElseWhere = function (e) { scope.$apply(function () { scope.vm.showPlate = false; }); }; scope.vm.prevent = function ($event) { $event.stopPropagation(); $event.preventDefault(); }; scope.vm.toggle = function () { if (scope.disabled) return; scope.vm.showPlate = !scope.vm.showPlate; }; scope.vm.bind = function () { scope.$on('$destroy', function () { $document.off('click', scope.vm.closeElseWhere); }); $document.on('click', scope.vm.closeElseWhere); }; scope.vm.init(); } }; } ]); }(jQuery, angular, _, window, document));