|
|
|
@ -1,13 +1,11 @@ |
|
|
|
import Backbone from 'backbone'; |
|
|
|
import { View } from '../../common'; |
|
|
|
import { createEl } from '../../utils/dom'; |
|
|
|
import CssRuleView from './CssRuleView'; |
|
|
|
import CssGroupRuleView from './CssGroupRuleView'; |
|
|
|
|
|
|
|
const $ = Backbone.$; |
|
|
|
const getBlockId = (pfx, order) => `${pfx}${order ? `-${parseFloat(order)}` : ''}`; |
|
|
|
|
|
|
|
const getBlockId = (pfx, order) => |
|
|
|
`${pfx}${order ? `-${parseFloat(order)}` : ''}`; |
|
|
|
|
|
|
|
export default Backbone.View.extend({ |
|
|
|
export default class CssRulesView extends View { |
|
|
|
initialize(o) { |
|
|
|
const config = o.config || {}; |
|
|
|
this.atRules = {}; |
|
|
|
@ -18,7 +16,7 @@ export default Backbone.View.extend({ |
|
|
|
const coll = this.collection; |
|
|
|
this.listenTo(coll, 'add', this.addTo); |
|
|
|
this.listenTo(coll, 'reset', this.render); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Add to collection |
|
|
|
@ -27,7 +25,7 @@ export default Backbone.View.extend({ |
|
|
|
* */ |
|
|
|
addTo(model) { |
|
|
|
this.addToCollection(model); |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Add new object to collection |
|
|
|
@ -100,16 +98,11 @@ export default Backbone.View.extend({ |
|
|
|
} |
|
|
|
|
|
|
|
return rendered; |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
getMediaWidth(mediaText) { |
|
|
|
return ( |
|
|
|
mediaText && |
|
|
|
mediaText |
|
|
|
.replace(`(${this.em.getConfig('mediaCondition')}: `, '') |
|
|
|
.replace(')', '') |
|
|
|
); |
|
|
|
}, |
|
|
|
return mediaText && mediaText.replace(`(${this.em.getConfig('mediaCondition')}: `, '').replace(')', ''); |
|
|
|
} |
|
|
|
|
|
|
|
render() { |
|
|
|
this.renderStarted = 1; |
|
|
|
@ -119,18 +112,13 @@ export default Backbone.View.extend({ |
|
|
|
$el.empty(); |
|
|
|
|
|
|
|
// Create devices related DOM structure, ensure also to have a default container
|
|
|
|
const prs = em |
|
|
|
.get('DeviceManager') |
|
|
|
.getAll() |
|
|
|
.pluck('priority'); |
|
|
|
const prs = em.get('DeviceManager').getAll().pluck('priority'); |
|
|
|
prs.every(pr => pr) && prs.unshift(0); |
|
|
|
prs.forEach(pr => |
|
|
|
$(`<div id="${getBlockId(className, pr)}"></div>`).appendTo(frag) |
|
|
|
); |
|
|
|
prs.forEach(pr => frag.appendChild(createEl('div', { id: getBlockId(className, pr) }))); |
|
|
|
|
|
|
|
collection.each(model => this.addToCollection(model, frag)); |
|
|
|
$el.append(frag); |
|
|
|
$el.attr('class', className); |
|
|
|
return this; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|