[pollen] branch develop updated (da5356b -> 5cfefb8)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository pollen. See http://git.chorem.org/pollen.git from da5356b fix UI in form new 5cfefb8 Improve directive auto-save The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 5cfefb86ca1a22cb0fe358579035d8774320f7c6 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 5 18:19:06 2014 +0200 Improve directive auto-save Summary of changes: pollen-ui-angular/src/main/webapp/js/directives.js | 53 ++++++++++++++++------ 1 file changed, 39 insertions(+), 14 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit 5cfefb86ca1a22cb0fe358579035d8774320f7c6 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Aug 5 18:19:06 2014 +0200 Improve directive auto-save --- pollen-ui-angular/src/main/webapp/js/directives.js | 53 ++++++++++++++++------ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/directives.js b/pollen-ui-angular/src/main/webapp/js/directives.js index 451aa94..92b4eb7 100644 --- a/pollen-ui-angular/src/main/webapp/js/directives.js +++ b/pollen-ui-angular/src/main/webapp/js/directives.js @@ -208,19 +208,19 @@ angular.module('pollenDirective', []) $timeout(function () { scope.oldVal[attrs.ngModel] = scope.$eval(attrs.ngModel); scope.$watch(attrs.ngModel, function (newVal, oldVal) { - if (angular.isDefined(oldVal) && newVal != scope.oldVal[attrs.ngModel]) { + if (scope.$eval(attrs.ngModel) != scope.oldVal[attrs.ngModel]) { scope.change = true; } else { scope.change = false; } }, true); - }, 500); + }); var save = function () { - if (scope.change) { - scope.change = false; - scope.oldVal[attrs.ngModel] = scope.$eval(attrs.ngModel);; + if (scope.change && !scope.lock) { scope.$apply(function () { + scope.change = false; + scope.oldVal[attrs.ngModel] = scope.$eval(attrs.ngModel);; scope.$eval(attrs.autoSave); }); } @@ -233,6 +233,29 @@ angular.module('pollenDirective', []) scope.timeout = $timeout(save,1000); }); + element.bind('dp.change', function(newDate) { + try { + scope.$digest(); + } + catch (e) { + } + }); + + element.bind('dp.show', function() { + console.log('is open'); + scope.lock = true; + + }) + + element.bind('dp.hide', function () { + scope.lock = false; + if (scope.timeout) { + $timeout.cancel(scope.timeout); + } + + scope.timeout = $timeout(save, 100); + }) + element.bind('blur', function () { if (scope.timeout) { $timeout.cancel(scope.timeout) @@ -486,6 +509,10 @@ angular.module('pollenDirective', []) } }]) +///////////////////////////////////////////////////////// +// DATE TIME PICKER DIRECTIVE // +// http://eonasdan.github.io/bootstrap-datetimepicker/ // +///////////////////////////////////////////////////////// .directive("datetimepicker", ["$timeout", "$route", "SessionStorage", function ($timeout, $route, SessionStorage) { return { restrict : "E", @@ -549,16 +576,14 @@ angular.module('pollenDirective', []) }); }); - scope.dateTimePicker.on("dp.change", function(e) { - $timeout.cancel(scope.timeout); - - scope.timeout = $timeout(function () { - scope.$apply(function () { - scope.ngModel = new Date(scope.dateTimePicker.data("DateTimePicker").getDate().format()); - element.trigger("change"); - }); - }, 500); + scope.dateTimePicker.on("dp.show", function (e) { + if (angular.isUndefined(scope.ngModel) || scope.ngModel == null) { + scope.ngModel = scope.dateTimePicker.data("DateTimePicker").setDate(moment()); + } + }) + scope.dateTimePicker.on("dp.change", function(e) { + scope.ngModel = new Date(scope.dateTimePicker.data("DateTimePicker").getDate().format()).getTime(); }); scope.exit = function() { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm