mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
settings is fully moved to required.
This commit is contained in:
parent
73f3459264
commit
6f8c73771d
54 changed files with 533 additions and 439 deletions
31
UI/Mixins/AsChangeTrackingModel.js
Normal file
31
UI/Mixins/AsChangeTrackingModel.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
define(
|
||||
function () {
|
||||
|
||||
return function () {
|
||||
|
||||
var originalInit = this.prototype.initialize;
|
||||
|
||||
this.prototype.initialize = function () {
|
||||
|
||||
this.isSaved = true;
|
||||
|
||||
this.on('change', function () {
|
||||
this.isSaved = false;
|
||||
}, this);
|
||||
|
||||
this.on('sync', function () {
|
||||
this.isSaved = true;
|
||||
}, this);
|
||||
|
||||
|
||||
if (originalInit) {
|
||||
originalInit.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
37
UI/Mixins/AsModelBoundView.js
Normal file
37
UI/Mixins/AsModelBoundView.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
define(
|
||||
['backbone.modelbinder'],
|
||||
function (ModelBinder) {
|
||||
|
||||
return function () {
|
||||
|
||||
var originalOnRender = this.prototype.onRender,
|
||||
originalBeforeClose = this.prototype.onBeforeClose;
|
||||
|
||||
this.prototype.onRender = function () {
|
||||
if (this.model) {
|
||||
this._modelBinder = new ModelBinder();
|
||||
this._modelBinder.bind(this.model, this.el);
|
||||
}
|
||||
if (originalOnRender) {
|
||||
originalOnRender.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
this.prototype.beforeClose = function () {
|
||||
|
||||
if (this._modelBinder) {
|
||||
this._modelBinder.unbind();
|
||||
delete this._modelBinder;
|
||||
}
|
||||
|
||||
if (originalBeforeClose) {
|
||||
originalBeforeClose.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
38
UI/Mixins/AsNamedView.js
Normal file
38
UI/Mixins/AsNamedView.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
define(
|
||||
function () {
|
||||
|
||||
return function () {
|
||||
|
||||
this.viewName = function () {
|
||||
if (this.template) {
|
||||
var regex = new RegExp('\/', 'g');
|
||||
|
||||
return this.template
|
||||
.toLocaleLowerCase()
|
||||
.replace('template', '')
|
||||
.replace(regex, '-');
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
var originalOnRender = this.onRender;
|
||||
|
||||
this.onRender = function () {
|
||||
|
||||
this.$el.removeClass('iv-' + this.viewName());
|
||||
this.$el.addClass('iv-' + this.viewName());
|
||||
|
||||
if (originalOnRender) {
|
||||
return originalOnRender.call(this);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
|
@ -1,31 +0,0 @@
|
|||
"use strict";
|
||||
define(['app'], function () {
|
||||
|
||||
NzbDrone.Mixins.SaveIfChangedModel = {
|
||||
// originalInitialize: this.initialize,
|
||||
|
||||
initialize: function () {
|
||||
this.isSaved = true;
|
||||
|
||||
this.on('change', function () {
|
||||
this.isSaved = false;
|
||||
}, this);
|
||||
|
||||
this.on('sync', function () {
|
||||
this.isSaved = true;
|
||||
}, this);
|
||||
|
||||
// if (originalInitialize) {
|
||||
// originalInitialize.call(this);
|
||||
// }
|
||||
},
|
||||
|
||||
saveIfChanged: function (options) {
|
||||
if (!this.isSaved) {
|
||||
this.save(undefined, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return NzbDrone.Missing.SaveIfChangedModel;
|
||||
});
|
|
@ -1,47 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var oldMarionetteItemViewRender = Marionette.ItemView.prototype.render;
|
||||
var oldItemCollectionViewRender = Marionette.CollectionView.prototype.render;
|
||||
|
||||
|
||||
Marionette.View.prototype.viewName = function () {
|
||||
if (this.template) {
|
||||
var regex = new RegExp('\/', 'g');
|
||||
|
||||
return this.template
|
||||
.toLocaleLowerCase()
|
||||
.replace('template', '')
|
||||
.replace(regex, '-');
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
Marionette.ItemView.prototype.self$ = function (selector) {
|
||||
return this.$(selector).not("[class*='iv-'] " + selector);
|
||||
};
|
||||
|
||||
Marionette.ItemView.prototype.render = function () {
|
||||
|
||||
var result = oldMarionetteItemViewRender.apply(this, arguments);
|
||||
|
||||
this.$el.removeClass('iv-' + this.viewName());
|
||||
|
||||
//check to see if el has bindings (name attribute)
|
||||
// any element that has a name attribute and isn't child of another view.
|
||||
if (this.self$('[name]').length > 0) {
|
||||
if (!this.model) {
|
||||
throw 'view ' + this.viewName() + ' has binding attributes but model is not defined';
|
||||
}
|
||||
|
||||
if (!this._modelBinder) {
|
||||
this._modelBinder = new Backbone.ModelBinder();
|
||||
}
|
||||
|
||||
this._modelBinder.bind(this.model, this.el);
|
||||
}
|
||||
|
||||
this.$el.addClass('iv-' + this.viewName());
|
||||
|
||||
return result;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue