mirror of https://github.com/artf/grapesjs.git
4 changed files with 19 additions and 16 deletions
@ -1,32 +1,32 @@ |
|||
define(['backbone'], |
|||
function (Backbone) { |
|||
return Backbone.Model.extend({ |
|||
function (Backbone) { |
|||
return Backbone.Model.extend({ |
|||
|
|||
idAttribute: 'name', |
|||
|
|||
defaults: { |
|||
name: '', |
|||
defaults: { |
|||
name: '', |
|||
label: '', |
|||
type: 'class', |
|||
active: true, |
|||
}, |
|||
}, |
|||
|
|||
initialize: function() { |
|||
this.set('name', this.escapeName(this.get('name'))); |
|||
initialize: function() { |
|||
this.set('name', this.escapeName(this.get('name'))); |
|||
var label = this.get('label').trim(); |
|||
if(!label) |
|||
this.set('label', this.get('name')); |
|||
}, |
|||
}, |
|||
|
|||
/** |
|||
/** |
|||
* Escape string |
|||
* @param {string} name |
|||
* @return {string} |
|||
* @private |
|||
*/ |
|||
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