openerp.pad = function(instance) { var _t = instance.web._t; instance.web.form.FieldPad = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeWidgetMixin, { template: 'FieldPad', content: "", init: function() { var self = this; this._super.apply(this, arguments); this._configured_deferred = this.view.dataset.call('pad_is_configured').done(function(data) { self.set("configured", !!data); }).fail(function(data, event) { event.preventDefault(); self.set("configured", true); }); this.pad_loading_request = null; }, initialize_content: function() { var self = this; this.$('.oe_pad_switch').click(function() { self.$el.toggleClass('oe_pad_fullscreen'); self.$el.find('.oe_pad_switch').toggleClass('fa-expand fa-compress'); self.view.$el.find('.oe_chatter').toggle(); }); this._configured_deferred.always(function() { var configured = self.get('configured'); self.$(".oe_unconfigured").toggle(!configured); self.$(".oe_configured").toggle(configured); }); this.render_value(); }, render_value: function() { var self = this; $.when(this._configured_deferred, this.pad_loading_request).always(function() { if (! self.get('configured')) { return; }; var value = self.get('value'); if (self.get('effective_readonly')) { if (_.str.startsWith(value, 'http')) { self.pad_loading_request = self.view.dataset.call('pad_get_content', {url: value}).done(function(data) { self.$('.oe_pad_content').removeClass('oe_pad_loading').html('