Author: bleny Date: 2014-04-29 11:44:05 +0200 (Tue, 29 Apr 2014) New Revision: 1911 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1911 Log: modify FilterView to disable all form while refreshing filter values Modified: trunk/wao-web/src/main/webapp/wao.js Modified: trunk/wao-web/src/main/webapp/wao.js =================================================================== --- trunk/wao-web/src/main/webapp/wao.js 2014-04-29 09:24:03 UTC (rev 1910) +++ trunk/wao-web/src/main/webapp/wao.js 2014-04-29 09:44:05 UTC (rev 1911) @@ -107,8 +107,25 @@ }); }; + this.lock = function () { + if ( ! this.$spinner) { + this.$spinner = this.$filtersForm.spin(); + } else { + this.$spinner.spin(); + } + this.$inputs.attr('disabled', 'disabled'); + this.$selects.attr('disabled', 'disabled'); + }; + + this.unlock = function () { + this.$spinner.spin(false); + this.$inputs.removeAttr('disabled'); + this.$selects.removeAttr('disabled'); + }; + $(this.model).on('updated', function () { self.refreshFilterValues(); + self.unlock(); }); }; @@ -121,6 +138,7 @@ this.view = new FilterView(this.model, $filtersForm); this.updateFilterValues = function () { + this.view.lock(); var filter = this.view.getFilter(); this.model.updateFilterValues(filter); }; @@ -196,18 +214,6 @@ this.notifications = new Notifications(); - this.startSpinner = function () { - if ( ! this.$spinner) { - this.$spinner = $('body').spin(); - } else { - this.$spinner.spin(); - } - }; - - this.stopSpinner = function () { - this.$spinner.spin(false); - }; - this.getNestedPropertyValue = function(path, data) { return path.split('.').reduce(function(prev, prop){ return prev && prev[prop] @@ -215,23 +221,11 @@ }; this.get = function (url, data, successCallback) { - this.startSpinner(); - var stopSpinningAfterCallingSuccessCallback = function () { - var result = successCallback.apply(this, arguments); - self.stopSpinner(); - return result; - }; - $.get(url, data, stopSpinningAfterCallingSuccessCallback); + $.get(url, data, successCallback); }; this.post = function (url, data, successCallback) { - this.startSpinner(); - var stopSpinningAfterCallingSuccessCallback = function () { - var result = successCallback.apply(this, arguments); - self.stopSpinner(); - return result; - }; - $.post(url, data, stopSpinningAfterCallingSuccessCallback); + $.post(url, data, successCallback); }; this.toData = function ($form) {
participants (1)
-
bleny@users.forge.codelutin.com