|
|
|
@ -1,33 +1,35 @@ |
|
|
|
var Backbone = require('backbone'); |
|
|
|
module.exports = require('backbone').View.extend({ |
|
|
|
|
|
|
|
module.exports = Backbone.View.extend({ |
|
|
|
template: _.template(` |
|
|
|
<div class="<%= pfx %>dialog"> |
|
|
|
<div class="<%= pfx %>header"> |
|
|
|
<div class="<%= pfx %>title"><%= title %></div> |
|
|
|
<div class="<%= pfx %>btn-close">⨯</div> |
|
|
|
template({pfx, ppfx, content, title}) { |
|
|
|
return `<div class="${pfx}dialog ${ppfx}one-bg">
|
|
|
|
<div class="${pfx}header"> |
|
|
|
<div class="${pfx}title">${title}</div> |
|
|
|
<div class="${pfx}btn-close">⨯</div> |
|
|
|
</div> |
|
|
|
<div class="<%= pfx %>content"> |
|
|
|
<div id="<%= pfx %>c"> <%= content %> </div> |
|
|
|
<div class="${pfx}content"> |
|
|
|
<div id="${pfx}c">${content}</div> |
|
|
|
<div style="clear:both"></div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="<%= pfx %>backlayer"></div> |
|
|
|
<div class="<%= pfx %>collector" style="display: none"></div>`), |
|
|
|
<div class="${pfx}backlayer"></div> |
|
|
|
<div class="${pfx}collector" style="display: none"></div>`; |
|
|
|
}, |
|
|
|
|
|
|
|
events: {}, |
|
|
|
|
|
|
|
initialize(o) { |
|
|
|
this.config = o.config || {}; |
|
|
|
this.pfx = this.config.stylePrefix || ''; |
|
|
|
this.listenTo(this.model, 'change:open', this.updateOpen); |
|
|
|
this.listenTo(this.model, 'change:title', this.updateTitle); |
|
|
|
this.listenTo(this.model, 'change:content', this.updateContent); |
|
|
|
this.events['click .'+this.pfx+'btn-close'] = 'hide'; |
|
|
|
|
|
|
|
if(this.config.backdrop) |
|
|
|
this.events['click .'+this.pfx+'backlayer'] = 'hide'; |
|
|
|
|
|
|
|
const model = this.model; |
|
|
|
const config = o.config || {}; |
|
|
|
const pfx = config.stylePrefix || ''; |
|
|
|
const bkd = config.backdrop; |
|
|
|
this.config = config; |
|
|
|
this.pfx = pfx; |
|
|
|
this.ppfx = config.pStylePrefix || ''; |
|
|
|
this.listenTo(model, 'change:open', this.updateOpen); |
|
|
|
this.listenTo(model, 'change:title', this.updateTitle); |
|
|
|
this.listenTo(model, 'change:content', this.updateContent); |
|
|
|
this.events[`click .${pfx}btn-close`] = 'hide'; |
|
|
|
bkd && (this.events[`click .${pfx}backlayer`] = 'hide'); |
|
|
|
this.delegateEvents(); |
|
|
|
}, |
|
|
|
|
|
|
|
@ -116,10 +118,14 @@ module.exports = Backbone.View.extend({ |
|
|
|
}, |
|
|
|
|
|
|
|
render() { |
|
|
|
var obj = this.model.toJSON(); |
|
|
|
const el = this.$el; |
|
|
|
const pfx = this.pfx; |
|
|
|
const ppfx = this.ppfx; |
|
|
|
const obj = this.model.toJSON(); |
|
|
|
obj.pfx = this.pfx; |
|
|
|
this.$el.html( this.template(obj) ); |
|
|
|
this.$el.attr('class', this.pfx + 'container'); |
|
|
|
obj.ppfx = this.ppfx; |
|
|
|
el.html(this.template(obj)); |
|
|
|
el.attr('class', `${pfx}container`); |
|
|
|
this.updateOpen(); |
|
|
|
return this; |
|
|
|
}, |
|
|
|
|