diff options
| author | Harry (OpenERP) <hmo@tinyerp.com> | 2012-08-09 18:52:39 +0530 |
|---|---|---|
| committer | Harry (OpenERP) <hmo@tinyerp.com> | 2012-08-09 18:52:39 +0530 |
| commit | 1b5259b3e374a8f9c385d18706aadbdf0a2403df (patch) | |
| tree | b446fae6a43cba80943121cd3fe55f1fada3a954 /addons/web/static/src/js/coresetup.js | |
| parent | 68998d4c827bb080d262da593c7766e25fb3427e (diff) | |
| parent | e46fb9fda8ba93d3eb8ac2907a75012f7a4d920e (diff) | |
[MERGE]
bzr revid: hmo@tinyerp.com-20120809132239-blyhpfxwn2szlqec
Diffstat (limited to 'addons/web/static/src/js/coresetup.js')
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index a5a62b9bcc1..6ba62162e93 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -19,15 +19,14 @@ instance.web.OldWidget = instance.web.Widget.extend({ this._super(parent); this.element_id = element_id; this.element_id = this.element_id || _.uniqueId('widget-'); + var tmp = document.getElementById(this.element_id); - this.$element = tmp ? $(tmp) : $(document.createElement(this.tagName)); + this.setElement(tmp || this._make_descriptive()); }, renderElement: function() { var rendered = this.render(); if (rendered) { - var elem = $(rendered); - this.$element.replaceWith(elem); - this.$element = elem; + this.replaceElement($(rendered)); } return this; }, @@ -394,13 +393,13 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess timer = setTimeout(waitLoop, CHECK_INTERVAL); }, synchronized_mode: function(to_execute) { - var synch = this.synch; - this.synch = true; - try { - return to_execute(); - } finally { - this.synch = synch; - } + var synch = this.synch; + this.synch = true; + try { + return to_execute(); + } finally { + this.synch = synch; + } } }); @@ -416,12 +415,12 @@ instance.web.Bus = instance.web.Class.extend(instance.web.EventDispatcherMixin, // check gtk bindings // http://unixpapa.com/js/key.html _.each('click,dblclick,keydown,keypress,keyup'.split(','), function(evtype) { - $('html').on(evtype, self, function(ev) { + $('html').on(evtype, function(ev) { self.trigger(evtype, ev); }); }); _.each('resize,scroll'.split(','), function(evtype) { - $(window).on(evtype, self, function(ev) { + $(window).on(evtype, function(ev) { self.trigger(evtype, ev); }); }); @@ -541,16 +540,48 @@ $.async_when = function() { // special tweak for the web client var old_async_when = $.async_when; $.async_when = function() { - if (instance.connection.synch) - return $.when.apply(this, arguments); - else - return old_async_when.apply(this, arguments); + if (instance.connection.synch) + return $.when.apply(this, arguments); + else + return old_async_when.apply(this, arguments); }; /** Setup blockui */ if ($.blockUI) { $.blockUI.defaults.baseZ = 1100; - $.blockUI.defaults.message = '<img src="/web/static/src/img/throbber2.gif">'; + $.blockUI.defaults.message = '<div class="oe_blockui_spin" style="height: 50px">'; + $.blockUI.defaults.css.border = '0'; + $.blockUI.defaults.css["background-color"] = ''; + $.blockUI.spinners = []; +} +instance.web.blockUI = function() { + var tmp = $.blockUI.apply($, arguments); + var target = $(".oe_blockui_spin")[0]; + 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 + }; + var spinner = new Spinner(opts).spin(target); + $.blockUI.spinners.push(spinner); + return tmp; +} +instance.web.unblockUI = function() { + _.each($.blockUI.spinners, function(el) { + el.stop(); + }); + return $.unblockUI.apply($, arguments); } /** Setup default session */ @@ -641,32 +672,6 @@ instance.connection.on('module_loaded', this, function () { */ instance.web.client_actions = new instance.web.Registry(); -/** - * Client action to reload the whole interface. - * If params has an entry 'menu_id', it opens the given menu entry. - */ -instance.web.Reload = instance.web.Widget.extend({ - init: function(parent, params) { - this._super(parent); - this.menu_id = (params && params.menu_id) || false; - }, - start: function() { - var l = window.location; - var timestamp = new Date().getTime(); - var search = "?ts=" + timestamp; - if (l.search) { - search = l.search + "&ts=" + timestamp; - } - var hash = l.hash; - if (this.menu_id) { - hash = "#menu_id=" + this.menu_id; - } - var url = l.protocol + "//" + l.host + l.pathname + search + hash; - window.location = url; - } -}); -instance.web.client_actions.add("reload", "instance.web.Reload"); - }; // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: |
