summaryrefslogtreecommitdiff
path: root/addons/pad/static
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2015-03-10 08:47:55 +0100
committerGéry Debongnie <ged@odoo.com>2015-03-18 09:09:22 +0100
commit5e6171bb6f43a2e0c35152fe456125ec8e1fd77e (patch)
tree3a016f21068fc724db379fdda3e7bfa16a8c08f1 /addons/pad/static
parent90050c24bb3331189329414d81ace9e839387377 (diff)
[REF] various addons: update to the new module system
Diffstat (limited to 'addons/pad/static')
-rw-r--r--addons/pad/static/src/js/pad.js169
1 files changed, 86 insertions, 83 deletions
diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js
index a6f2ce69553..53b7d18b964 100644
--- a/addons/pad/static/src/js/pad.js
+++ b/addons/pad/static/src/js/pad.js
@@ -1,88 +1,91 @@
-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();
- $('#oe_main_menu_navbar').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('<div class="oe_pad_readonly"><div>');
- self.$('.oe_pad_readonly').html(data);
- }).fail(function() {
- self.$('.oe_pad_content').text(_t('Unable to load pad'));
- });
- } else {
- self.$('.oe_pad_content').addClass('oe_pad_loading').show().text(_t("This pad will be initialized on first edit"));
- }
+odoo.define('pad.pad', ['web.core', 'web.form_common'], function (require) {
+
+var core = require('web.core');
+var form_common = require('web.form_common');
+
+var _t = core._t;
+
+var FieldPad = form_common.AbstractField.extend(form_common.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();
+ $('#oe_main_menu_navbar').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('<div class="oe_pad_readonly"><div>');
+ self.$('.oe_pad_readonly').html(data);
+ }).fail(function() {
+ self.$('.oe_pad_content').text(_t('Unable to load pad'));
+ });
+ } else {
+ self.$('.oe_pad_content').addClass('oe_pad_loading').show().text(_t("This pad will be initialized on first edit"));
}
- else {
- var def = $.when();
- if (! value || !_.str.startsWith(value, 'http')) {
- def = self.view.dataset.call('pad_generate_url', {
- context: {
- model: self.view.model,
- field_name: self.name,
- object_id: self.view.datarecord.id
- },
- }).done(function(data) {
- if (! data.url) {
- self.set("configured", false);
- } else {
- self.set("value", data.url);
- }
- });
- }
- def.then(function() {
- value = self.get('value');
- if (_.str.startsWith(value, 'http')) {
- var content = '<iframe width="100%" height="100%" frameborder="0" src="' + value + '?showChat=false&userName=' + self.session.username + '"></iframe>';
- self.$('.oe_pad_content').html(content);
- self._dirty_flag = true;
- }
- else {
- self.$('.oe_pad_content').text(value);
+ }
+ else {
+ var def = $.when();
+ if (! value || !_.str.startsWith(value, 'http')) {
+ def = self.view.dataset.call('pad_generate_url', {
+ context: {
+ model: self.view.model,
+ field_name: self.name,
+ object_id: self.view.datarecord.id
+ },
+ }).done(function(data) {
+ if (! data.url) {
+ self.set("configured", false);
+ } else {
+ self.set("value", data.url);
}
});
}
- });
- },
- });
+ def.then(function() {
+ value = self.get('value');
+ if (_.str.startsWith(value, 'http')) {
+ var content = '<iframe width="100%" height="100%" frameborder="0" src="' + value + '?showChat=false&userName=' + self.session.username + '"></iframe>';
+ self.$('.oe_pad_content').html(content);
+ self._dirty_flag = true;
+ }
+ else {
+ self.$('.oe_pad_content').text(value);
+ }
+ });
+ }
+ });
+ },
+});
+
+core.form_widget_registry.add('pad', FieldPad);
- instance.web.form.widgets = instance.web.form.widgets.extend({
- 'pad': 'instance.web.form.FieldPad',
- });
-};
+}); \ No newline at end of file