Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
52
core/modules/quickedit/js/models/BaseModel.js
Normal file
52
core/modules/quickedit/js/models/BaseModel.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* @file
|
||||
* A Backbone Model subclass that enforces validation when calling set().
|
||||
*/
|
||||
|
||||
(function (Backbone) {
|
||||
|
||||
"use strict";
|
||||
|
||||
Drupal.quickedit.BaseModel = Backbone.Model.extend(/** @lends Drupal.quickedit.BaseModel# */{
|
||||
|
||||
/**
|
||||
* @constructs
|
||||
*
|
||||
* @augments Backbone.Model
|
||||
*
|
||||
* @param {object} options
|
||||
*
|
||||
* @return {Drupal.quickedit.BaseModel}
|
||||
*/
|
||||
initialize: function (options) {
|
||||
this.__initialized = true;
|
||||
return Backbone.Model.prototype.initialize.call(this, options);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object|string} key
|
||||
* @param {*} val
|
||||
* @param {object} [options]
|
||||
*
|
||||
* @return {*}
|
||||
*/
|
||||
set: function (key, val, options) {
|
||||
if (this.__initialized) {
|
||||
// Deal with both the "key", value and {key:value}-style arguments.
|
||||
if (typeof key === 'object') {
|
||||
key.validate = true;
|
||||
}
|
||||
else {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
options.validate = true;
|
||||
}
|
||||
}
|
||||
return Backbone.Model.prototype.set.call(this, key, val, options);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}(Backbone));
|
Reference in a new issue