|
|
|
@ -10,34 +10,34 @@ module.exports = require('./PropertyView').extend({ |
|
|
|
`;
|
|
|
|
}, |
|
|
|
|
|
|
|
init() { |
|
|
|
const model = this.model; |
|
|
|
this.list = model.get('list') || model.get('options') || []; |
|
|
|
this.className = this.className + ' '+ this.pfx +'list'; |
|
|
|
}, |
|
|
|
|
|
|
|
onRender() { |
|
|
|
var pfx = this.pfx; |
|
|
|
var ppfx = this.ppfx; |
|
|
|
var itemCls = ppfx + 'radio-item-label'; |
|
|
|
var prop = this.property; |
|
|
|
const pfx = this.pfx; |
|
|
|
const ppfx = this.ppfx; |
|
|
|
const itemCls = `${ppfx}radio-item-label`; |
|
|
|
const model = this.model; |
|
|
|
const prop = model.get('property'); |
|
|
|
const options = model.get('list') || model.get('options') || []; |
|
|
|
|
|
|
|
if(!this.$input) { |
|
|
|
if(this.list && this.list.length) { |
|
|
|
if (!this.$input) { |
|
|
|
if(options && options.length) { |
|
|
|
let inputStr = ''; |
|
|
|
_.each(this.list, el => { |
|
|
|
var cl = el.className ? el.className + ' ' + pfx + 'icon ' + itemCls : '', |
|
|
|
id = prop + '-' + el.value, |
|
|
|
labelTxt = el.name ? el.name : el.value; |
|
|
|
var titleAttr = el.title ? 'title="' + el.title + '"': ''; |
|
|
|
inputStr += '<div class="' + ppfx + 'radio-item">'+ |
|
|
|
'<input class="'+pfx+'radio" type="radio" id="'+ id +'" name="'+prop+'" value="'+el.value+'" />'+ |
|
|
|
'<label class="'+(cl ? cl : itemCls)+'" ' + titleAttr + ' for="'+ id +'">' + (cl ? '' : labelTxt) + '</label></div>'; |
|
|
|
|
|
|
|
options.forEach(el => { |
|
|
|
let cl = el.className ? `${el.className} ${pfx}icon ${itemCls}` : ''; |
|
|
|
let id = `${prop}-${el.value}`; |
|
|
|
let labelTxt = el.name || el.value; |
|
|
|
let titleAttr = el.title ? `title="${el.title}"` : ''; |
|
|
|
inputStr += ` |
|
|
|
<div class="${ppfx}radio-item"> |
|
|
|
<input type="radio" class="${pfx}radio" id="${id}" name="${prop}" value="${el.value}"/> |
|
|
|
<label class="${cl || itemCls}" ${titleAttr} for="${id}">${cl ? '' : labelTxt}</label> |
|
|
|
</div>`; |
|
|
|
}); |
|
|
|
|
|
|
|
this.$inputEl = $(inputStr); |
|
|
|
this.input = this.$inputEl.get(0); |
|
|
|
this.$el.find('#'+ pfx +'input-holder').html(this.$inputEl); |
|
|
|
this.$input = this.$inputEl.find('input[name="'+this.property+'"]'); |
|
|
|
this.$el.find(`#${pfx}input-holder`).html(this.$inputEl); |
|
|
|
this.$input = this.$inputEl.find(`input[name="${prop}"]`); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|