diff options
| author | Christophe Matthieu <chm@openerp.com> | 2012-12-13 15:57:14 +0100 |
|---|---|---|
| committer | Christophe Matthieu <chm@openerp.com> | 2012-12-13 15:57:14 +0100 |
| commit | 23b6b96fbc4dccf5d6bba6eda2e04ddf8a9d3224 (patch) | |
| tree | d1ab63b0fb1b7d7bf5d6d46fbb2638e75bfe861a /addons | |
| parent | 265b6d67dfc388ba1d7e6453dc2a35e88b0fa36d (diff) | |
[IMP] pad: add abord for $.get request
bzr revid: chm@openerp.com-20121213145714-b9d4f2u8iqdg8r1m
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/pad/static/src/js/pad.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index 5b33fd3eaa1..5cd2ac622cb 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -7,9 +7,6 @@ openerp.pad = function(instance) { start: function() { this._super.apply(this, arguments); var self = this; - this.on('click', '.oe_pad_switch', function(){ - self.$el.toggleClass('oe_pad_fullscreen'); - }); this.on('change:effective_readonly',this,function(){ self.renderElement(); }); @@ -37,6 +34,9 @@ openerp.pad = function(instance) { renderElement: function(){ var self = this; var value = this.get('value'); + if (this.pad_loading_request) { + this.pad_loading_request.abort(); + } if(!_.str.startsWith(value,'http')){ this.configured = false; this.content = ""; @@ -46,24 +46,22 @@ openerp.pad = function(instance) { this.content = '<iframe width="100%" height="100%" frameborder="0" src="'+value+'?showChat=false&userName='+this.session.username+'"></iframe>'; }else{ this.content = '<div class="oe_pad_loading">... Loading pad ...</div>'; - $.get(value+'/export/html').success(function(data){ - if(!self.get('effective_readonly')){ - return false; - } + this.pad_loading_request = $.get(value+'/export/html') + .done(function(data){ groups = /\<\s*body\s*\>(.*?)\<\s*\/body\s*\>/.exec(data); data = (groups || []).length >= 2 ? groups[1] : ''; self.$('.oe_pad_content').html('<div class="oe_pad_readonly"><div>'); self.$('.oe_pad_readonly').html(data); }).error(function(){ - if(!self.get('effective_readonly')){ - return false; - } self.$('.oe_pad_content').text('Unable to load pad'); }); } } this._super(); this.$('.oe_pad_content').html(this.content); + this.$('.oe_pad_switch').click(function(){ + self.$el.toggleClass('oe_pad_fullscreen'); + }); }, }); |
