mirror of https://github.com/artf/grapesjs.git
4 changed files with 19 additions and 16 deletions
@ -1,32 +1,32 @@ |
|||||
define(['backbone'], |
define(['backbone'], |
||||
function (Backbone) { |
function (Backbone) { |
||||
return Backbone.Model.extend({ |
return Backbone.Model.extend({ |
||||
|
|
||||
idAttribute: 'name', |
idAttribute: 'name', |
||||
|
|
||||
defaults: { |
defaults: { |
||||
name: '', |
name: '', |
||||
label: '', |
label: '', |
||||
type: 'class', |
type: 'class', |
||||
active: true, |
active: true, |
||||
}, |
}, |
||||
|
|
||||
initialize: function() { |
initialize: function() { |
||||
this.set('name', this.escapeName(this.get('name'))); |
this.set('name', this.escapeName(this.get('name'))); |
||||
var label = this.get('label').trim(); |
var label = this.get('label').trim(); |
||||
if(!label) |
if(!label) |
||||
this.set('label', this.get('name')); |
this.set('label', this.get('name')); |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* Escape string |
* Escape string |
||||
* @param {string} name |
* @param {string} name |
||||
* @return {string} |
* @return {string} |
||||
* @private |
* @private |
||||
*/ |
*/ |
||||
escapeName: function(name) { |
escapeName: function(name) { |
||||
return name.toLowerCase().replace(/([^a-z0-9\w]+)/gi, '-'); |
return name.replace(/([^a-z0-9\w]+)/gi, '-'); |
||||
}, |
}, |
||||
|
|
||||
}); |
}); |
||||
}); |
}); |
||||
|
|||||
Loading…
Reference in new issue