summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2012-08-02 16:36:50 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2012-08-02 16:36:50 +0200
commitd9aaf5c2d1efdb58e73f13e6c0279f9ef46f185c (patch)
treee277c698def030e60c213b00fd270671cde1ed24 /addons/web/static/src/js
parentc2ad177f93b9397960acdc5969017898ac754391 (diff)
[IMP] Cleaned dialog class to be closer to the Widget design
bzr revid: nicolas.vanhoren@openerp.com-20120802143650-czejc71u5atle2rs
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome.js58
1 files changed, 33 insertions, 25 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index d09f144571f..86fb457582d 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -57,7 +57,7 @@ instance.web.Dialog = instance.web.Widget.extend({
init: function (parent, options, content) {
var self = this;
this._super(parent);
- this.setElement(content || this.make(this.tagName));
+ this.content_to_set = content;
this.dialog_options = {
modal: true,
destroy_on_close: true,
@@ -81,11 +81,6 @@ instance.web.Dialog = instance.web.Widget.extend({
if (options) {
_.extend(this.dialog_options, options);
}
- if (this.dialog_options.autoOpen) {
- this.open();
- } else {
- instance.web.dialog(this.$element, this.get_options());
- }
},
get_options: function(options) {
var self = this,
@@ -114,31 +109,44 @@ instance.web.Dialog = instance.web.Widget.extend({
} else if (val.slice(-1) == "%") {
return Math.round(available_size / 100 * parseInt(val.slice(0, -1), 10));
} else {
- return parseInt(val, 10);
+ return parseInt(val, 10);
}
},
- open: function(options) {
- // TODO fme: bind window on resize
- if (this.template) {
- this.$element.html(this.renderElement());
+ renderElement: function() {
+ if (this.content_to_set) {
+ this.setElement(this.content_to_set);
+ } else if (this.template) {
+ this._super();
}
+ },
+ open: function(options) {
+ if (! this.dialog_inited)
+ this.init_dialog();
var o = this.get_options(options);
- instance.web.dialog(this.$element, o).dialog('open');
+ instance.web.dialog(this.$element, o).dialog('open');
if (o.height === 'auto' && o.max_height) {
this.$element.css({ 'max-height': o.max_height, 'overflow-y': 'auto' });
}
return this;
},
+ init_dialog: function(options) {
+ this.renderElement();
+ var o = this.get_options(options);
+ instance.web.dialog(this.$element, o);
+ var res = this.start();
+ this.dialog_inited = true;
+ return res;
+ },
close: function() {
this.$element.dialog('close');
},
on_close: function() {
- if (this.__tmp_dialog_destroying)
- return;
+ if (this.__tmp_dialog_destroying)
+ return;
if (this.dialog_options.destroy_on_close) {
- this.__tmp_dialog_closing = true;
+ this.__tmp_dialog_closing = true;
this.destroy();
- this.__tmp_dialog_closing = undefined;
+ this.__tmp_dialog_closing = undefined;
}
},
on_resized: function() {
@@ -148,10 +156,10 @@ instance.web.Dialog = instance.web.Widget.extend({
el.destroy();
});
if (! this.__tmp_dialog_closing) {
- this.__tmp_dialog_destroying = true;
- this.close();
- this.__tmp_dialog_destroying = undefined;
- }
+ this.__tmp_dialog_destroying = true;
+ this.close();
+ this.__tmp_dialog_destroying = undefined;
+ }
if (! this.isDestroyed()) {
this.$element.dialog('destroy');
}
@@ -261,11 +269,11 @@ instance.web.Loading = instance.web.Widget.extend({
this.count += increment;
if (this.count > 0) {
- if (instance.connection.debug) {
- this.$element.text(_.str.sprintf( _t("Loading (%d)"), this.count));
- } else {
- this.$element.text(_t("Loading"));
- }
+ if (instance.connection.debug) {
+ this.$element.text(_.str.sprintf( _t("Loading (%d)"), this.count));
+ } else {
+ this.$element.text(_t("Loading"));
+ }
this.$element.show();
this.getParent().$element.addClass('oe_wait');
} else {