mirror of https://github.com/artf/grapesjs.git
nocodeframeworkdrag-and-dropsite-buildersite-generatortemplate-builderui-builderweb-builderweb-builder-frameworkwebsite-builderno-codepage-builder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
639 B
32 lines
639 B
define(['backbone'],
|
|
function (Backbone) {
|
|
return Backbone.Model.extend({
|
|
|
|
idAttribute: 'name',
|
|
|
|
defaults: {
|
|
name: '',
|
|
label: '',
|
|
type: 'class',
|
|
active: true,
|
|
},
|
|
|
|
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}
|
|
*/
|
|
escapeName: function(name) {
|
|
return name.toLowerCase().replace(/([^a-z0-9\w]+)/gi, '-');
|
|
},
|
|
|
|
});
|
|
});
|
|
|