mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-26 23:06:43 -04:00
rjs -> webpack
This commit is contained in:
@@ -1,48 +1,35 @@
|
||||
'use strict';
|
||||
var ModelBinder = require('backbone.modelbinder');
|
||||
|
||||
define(
|
||||
['backbone.modelbinder'],
|
||||
function (ModelBinder) {
|
||||
|
||||
return function () {
|
||||
|
||||
var originalOnRender = this.prototype.onRender;
|
||||
var originalBeforeClose = this.prototype.onBeforeClose;
|
||||
|
||||
this.prototype.onRender = function () {
|
||||
|
||||
if (!this.model) {
|
||||
throw 'View has no model for binding';
|
||||
}
|
||||
|
||||
if (!this._modelBinder) {
|
||||
this._modelBinder = new ModelBinder();
|
||||
}
|
||||
|
||||
var options = {
|
||||
changeTriggers: {'': 'change typeahead:selected typeahead:autocompleted', '[contenteditable]': 'blur', '[data-onkeyup]': 'keyup'}
|
||||
};
|
||||
|
||||
this._modelBinder.bind(this.model, this.el, null, options);
|
||||
|
||||
if (originalOnRender) {
|
||||
originalOnRender.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
this.prototype.onBeforeClose = function () {
|
||||
|
||||
if (this._modelBinder) {
|
||||
this._modelBinder.unbind();
|
||||
delete this._modelBinder;
|
||||
}
|
||||
|
||||
if (originalBeforeClose) {
|
||||
originalBeforeClose.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
module.exports = function(){
|
||||
var originalOnRender = this.prototype.onRender;
|
||||
var originalBeforeClose = this.prototype.onBeforeClose;
|
||||
this.prototype.onRender = function(){
|
||||
if(!this.model) {
|
||||
throw 'View has no model for binding';
|
||||
}
|
||||
if(!this._modelBinder) {
|
||||
this._modelBinder = new ModelBinder();
|
||||
}
|
||||
var options = {
|
||||
changeTriggers : {
|
||||
"" : 'change typeahead:selected typeahead:autocompleted',
|
||||
"[contenteditable]" : 'blur',
|
||||
"[data-onkeyup]" : 'keyup'
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
this._modelBinder.bind(this.model, this.el, null, options);
|
||||
if(originalOnRender) {
|
||||
originalOnRender.call(this);
|
||||
}
|
||||
};
|
||||
this.prototype.onBeforeClose = function(){
|
||||
if(this._modelBinder) {
|
||||
this._modelBinder.unbind();
|
||||
delete this._modelBinder;
|
||||
}
|
||||
if(originalBeforeClose) {
|
||||
originalBeforeClose.call(this);
|
||||
}
|
||||
};
|
||||
return this;
|
||||
};
|
||||
Reference in New Issue
Block a user