Free and Open source Web Builder Framework. Next generation tool for building templates without coding
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.
 
 
 
 

45 lines
1.1 KiB

define(['./TraitView'],
function (TraitView) {
return TraitView.extend({
initialize: function(o) {
TraitView.prototype.initialize.apply(this, arguments);
var iconCls = this.ppfx + 'chk-icon';
this.tmpl = '<div class="' + this.fieldClass +'"><label class="' + this.inputhClass +'"><i class="' + iconCls +'"></i></label></div>';
},
/**
* Fires when the input is changed
* @private
*/
onChange: function() {
this.model.set('value', this.getInputEl().checked);
},
/**
* Returns input element
* @return {HTMLElement}
* @private
*/
getInputEl: function() {
var first;
if(!this.$input)
first = 1;
var el = TraitView.prototype.getInputEl.apply(this, arguments);
if(first){
var md = this.model;
var name = md.get('name');
var target = this.target;
if(md.get('changeProp')){
el.checked = target.get(name);
} else {
var attrs = target.get('attributes');
el.checked = !!attrs[name];
}
}
return el;
},
});
});