diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/widget/abstract/fields.js | 2 | ||||
-rw-r--r-- | web/widget/abstract/inline.js | 42 | ||||
-rw-r--r-- | web/widget/abstract/node.js | 55 | ||||
-rw-r--r-- | web/widget/checkboxes.js | 2 |
4 files changed, 63 insertions, 38 deletions
diff --git a/web/widget/abstract/fields.js b/web/widget/abstract/fields.js index 0ba2d3a..a2ec5e0 100644 --- a/web/widget/abstract/fields.js +++ b/web/widget/abstract/fields.js @@ -5,7 +5,7 @@ define( [ - "acf2/widget/abstract/inline", + "acf2/widget/abstract/node", "jquery", "underscore", "acf2/widget/checkbox", diff --git a/web/widget/abstract/inline.js b/web/widget/abstract/inline.js index 6e159b6..dae1797 100644 --- a/web/widget/abstract/inline.js +++ b/web/widget/abstract/inline.js @@ -12,13 +12,7 @@ define( ) { this.txnMgr = data.txnMgr; return Base.init.call( - this, - data, - name, - meta, - Math.min(6, level + 1), - editable, - removable + this, data, name, meta, level, editable, removable ); }, @@ -26,11 +20,13 @@ define( createEl: function() { return $("<div>"); }, - showStatus: false, - requestData: function(value, meta) { this.path = value; - return this.refreshData(); + return this._requestData(value, meta); + }, + + _requestData: function(value, meta) { + return Base.requestData.call(this, value, meta); }, refreshData: function() { @@ -39,32 +35,6 @@ define( def.resolve(data, data.meta); }); return def; - }, - - showHeading: true, - - render: function(data, meta) { - if (this.showHeading) - this.el.html( - $("<h" + this.level + ">").text(meta["ui-name"]) - ); - }, - - wrap: function() { return this.el; }, - - validate: function(data) { - Base.validate.call(this, data); - - if (this.data.match(this.meta.condition)) { - var valid = data.validate(); - this.setStatus(data.status()); - statusBar.validationReady(valid); - } - - if (this.fields) - _.each(this.fields, function(field) { - field.trigger("updated"); - }); } }); } diff --git a/web/widget/abstract/node.js b/web/widget/abstract/node.js new file mode 100644 index 0000000..6d42345 --- /dev/null +++ b/web/widget/abstract/node.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012-2014 Kaarle Ritvanen + * See LICENSE file for license details + */ + +define( + ["acf2/statusbar", "acf2/widget/abstract/inline", "jquery", "underscore"], + function(statusBar, Base, $, _) { + return Base.extend({ + init: function( + data, name, meta, level, editable, removable + ) { + return Base.init.call( + this, + data, + name, + meta, + Math.min(6, level + 1), + editable, + removable + ); + }, + + showStatus: false, + + _requestData: function(value, meta) { return this.refreshData(); }, + + showHeading: true, + + render: function(data, meta) { + if (this.showHeading) + this.el.html( + $("<h" + this.level + ">").text(meta["ui-name"]) + ); + }, + + wrap: function() { return this.el; }, + + validate: function(data) { + Base.validate.call(this, data); + + if (this.data.match(this.meta.condition)) { + var valid = data.validate(); + this.setStatus(data.status()); + statusBar.validationReady(valid); + } + + if (this.fields) + _.each(this.fields, function(field) { + field.trigger("updated"); + }); + } + }); + } +); diff --git a/web/widget/checkboxes.js b/web/widget/checkboxes.js index c5bd52c..2252aa4 100644 --- a/web/widget/checkboxes.js +++ b/web/widget/checkboxes.js @@ -7,7 +7,7 @@ define( [ "acf2/dom", "acf2/statusbar", - "acf2/widget/abstract/inline", + "acf2/widget/abstract/node", "jquery", "underscore" ], |