From 8d1836bd30f8d06b2da6e36c8b34d250b73847b0 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 21 Aug 2012 11:30:00 +0200 Subject: [IMP] improved loading messages bzr revid: nicolas.vanhoren@openerp.com-20120821093000-4jf6lh7a8o124hsd --- addons/web/static/src/js/coresetup.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 229a82a1784..a34a7dadd30 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -528,6 +528,14 @@ if ($.blockUI) { $.blockUI.defaults.css["background-color"] = ''; } +var messages_by_seconds = [ + [0, "Loading..."], + [30, "Still Loading..."], + [60, "Still Loading...
Please be patient."], + [120, "Hey, guess what?
It's still loading."], + [300, "You may not believe it,
but the application is actually loading..."], +]; + instance.web.Throbber = instance.web.Widget.extend({ template: "Throbber", start: function() { @@ -548,6 +556,23 @@ instance.web.Throbber = instance.web.Widget.extend({ left: 'auto' // Left position relative to parent in px }; this.spin = new Spinner(opts).spin(this.$element[0]); + this.start_time = new Date().getTime(); + this.act_message(); + }, + act_message: function() { + var self = this; + setTimeout(function() { + if (self.isDestroyed()) + return; + var seconds = (new Date().getTime() - self.start_time) / 1000; + var mes; + _.each(messages_by_seconds, function(el) { + if (seconds >= el[0]) + mes = el[1]; + }); + self.$(".oe_throbber_message").html(mes); + self.act_message(); + }, 1000); }, destroy: function() { if (this.spin) -- cgit v1.2.3 From 49b3c7b7535e181dd0d447096c0469b6d526dfac Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 18:54:49 +0200 Subject: [IMP] made the loading messages translatable bzr revid: nicolas.vanhoren@openerp.com-20120824165449-mfb4ftxnq3vd0p84 --- addons/web/static/src/js/coresetup.js | 156 +++++++++++++++++----------------- 1 file changed, 80 insertions(+), 76 deletions(-) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index a34a7dadd30..af6442bd747 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -520,82 +520,6 @@ $.async_when = function() { return old_async_when.apply(this, arguments); }; -/** Setup blockui */ -if ($.blockUI) { - $.blockUI.defaults.baseZ = 1100; - $.blockUI.defaults.message = '
'; - $.blockUI.defaults.css.border = '0'; - $.blockUI.defaults.css["background-color"] = ''; -} - -var messages_by_seconds = [ - [0, "Loading..."], - [30, "Still Loading..."], - [60, "Still Loading...
Please be patient."], - [120, "Hey, guess what?
It's still loading."], - [300, "You may not believe it,
but the application is actually loading..."], -]; - -instance.web.Throbber = instance.web.Widget.extend({ - template: "Throbber", - start: function() { - var opts = { - lines: 13, // The number of lines to draw - length: 7, // The length of each line - width: 4, // The line thickness - radius: 10, // The radius of the inner circle - rotate: 0, // The rotation offset - color: '#FFF', // #rgb or #rrggbb - speed: 1, // Rounds per second - trail: 60, // Afterglow percentage - shadow: false, // Whether to render a shadow - hwaccel: false, // Whether to use hardware acceleration - className: 'spinner', // The CSS class to assign to the spinner - zIndex: 2e9, // The z-index (defaults to 2000000000) - top: 'auto', // Top position relative to parent in px - left: 'auto' // Left position relative to parent in px - }; - this.spin = new Spinner(opts).spin(this.$element[0]); - this.start_time = new Date().getTime(); - this.act_message(); - }, - act_message: function() { - var self = this; - setTimeout(function() { - if (self.isDestroyed()) - return; - var seconds = (new Date().getTime() - self.start_time) / 1000; - var mes; - _.each(messages_by_seconds, function(el) { - if (seconds >= el[0]) - mes = el[1]; - }); - self.$(".oe_throbber_message").html(mes); - self.act_message(); - }, 1000); - }, - destroy: function() { - if (this.spin) - this.spin.stop(); - this._super(); - }, -}); -instance.web.Throbber.throbbers = []; - -instance.web.blockUI = function() { - var tmp = $.blockUI.apply($, arguments); - var throbber = new instance.web.Throbber(); - instance.web.Throbber.throbbers.push(throbber); - throbber.appendTo($(".oe_blockui_spin_container")); - return tmp; -} -instance.web.unblockUI = function() { - _.each(instance.web.Throbber.throbbers, function(el) { - el.destroy(); - }); - return $.unblockUI.apply($, arguments); -} - /** Setup default session */ instance.session = new instance.web.Session(); @@ -679,6 +603,86 @@ instance.session.on('module_loaded', this, function () { $.timeago.settings.translator = instance.web._t; }); +/** Setup blockui */ +if ($.blockUI) { + $.blockUI.defaults.baseZ = 1100; + $.blockUI.defaults.message = '
'; + $.blockUI.defaults.css.border = '0'; + $.blockUI.defaults.css["background-color"] = ''; +} + +var messages_by_seconds = function() { + return [ + [0, _t("Loading...")], + [30, _t("Still loading...")], + [60, _t("Still loading...
Please be patient.")], + [120, _t("Don't leave yet,
it's still loading...")], + [300, _t("You may not believe it,
but the application is actually loading...")], + [600, _t("You know, sometimes,
OpenERP can be a little bit slow,
because it's loading...")], + [3600, _t("Maybe you should consider pressing F5...")], + ]; +}; + +instance.web.Throbber = instance.web.Widget.extend({ + template: "Throbber", + start: function() { + var opts = { + lines: 13, // The number of lines to draw + length: 7, // The length of each line + width: 4, // The line thickness + radius: 10, // The radius of the inner circle + rotate: 0, // The rotation offset + color: '#FFF', // #rgb or #rrggbb + speed: 1, // Rounds per second + trail: 60, // Afterglow percentage + shadow: false, // Whether to render a shadow + hwaccel: false, // Whether to use hardware acceleration + className: 'spinner', // The CSS class to assign to the spinner + zIndex: 2e9, // The z-index (defaults to 2000000000) + top: 'auto', // Top position relative to parent in px + left: 'auto' // Left position relative to parent in px + }; + this.spin = new Spinner(opts).spin(this.$element[0]); + this.start_time = new Date().getTime(); + this.act_message(); + }, + act_message: function() { + var self = this; + setTimeout(function() { + if (self.isDestroyed()) + return; + var seconds = (new Date().getTime() - self.start_time) / 1000; + var mes; + _.each(messages_by_seconds(), function(el) { + if (seconds >= el[0]) + mes = el[1]; + }); + self.$(".oe_throbber_message").html(mes); + self.act_message(); + }, 1000); + }, + destroy: function() { + if (this.spin) + this.spin.stop(); + this._super(); + }, +}); +instance.web.Throbber.throbbers = []; + +instance.web.blockUI = function() { + var tmp = $.blockUI.apply($, arguments); + var throbber = new instance.web.Throbber(); + instance.web.Throbber.throbbers.push(throbber); + throbber.appendTo($(".oe_blockui_spin_container")); + return tmp; +} +instance.web.unblockUI = function() { + _.each(instance.web.Throbber.throbbers, function(el) { + el.destroy(); + }); + return $.unblockUI.apply($, arguments); +} + /** * Registry for all the client actions key: tag value: widget */ -- cgit v1.2.3 From 5e338c591ac76f57453563792fe20e9a20f31edc Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 24 Aug 2012 20:27:07 +0200 Subject: [IMP] made a whole-application replace of $element by $el bzr revid: nicolas.vanhoren@openerp.com-20120824182707-vt91ef40ieeudwyw --- addons/web/static/src/js/coresetup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index af6442bd747..8e0f4da4148 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -642,7 +642,7 @@ instance.web.Throbber = instance.web.Widget.extend({ top: 'auto', // Top position relative to parent in px left: 'auto' // Left position relative to parent in px }; - this.spin = new Spinner(opts).spin(this.$element[0]); + this.spin = new Spinner(opts).spin(this.$el[0]); this.start_time = new Date().getTime(); this.act_message(); }, -- cgit v1.2.3