moved mixins to require.js

This commit is contained in:
kay.one 2013-06-20 22:35:56 -07:00
parent 72772bed5a
commit 467c88f711
6 changed files with 81 additions and 89 deletions

View File

@ -1,14 +0,0 @@
"use strict";
define(['app','backgrid'], function () {
NzbDrone.Missing.Row = Backgrid.Row.extend({
events: {
'click .x-search': 'search'
},
search: function () {
window.alert('Episode Search');
}
});
return NzbDrone.Missing.Row;
});

View File

@ -1,19 +1,19 @@
"use strict"; "use strict";
define([ define(
'app', [
'Missing/Collection', 'app',
'Missing/Row', 'Missing/Row',
'Cells/AirDateCell', 'Missing/Collection',
'Series/Index/Table/SeriesStatusCell', 'Cells/AirDateCell',
'Shared/Toolbar/ToolbarLayout', 'Series/Index/Table/SeriesStatusCell',
'Cells/SeriesTitleCell', 'Shared/Toolbar/ToolbarLayout',
'Cells/EpisodeNumberCell', 'Cells/SeriesTitleCell',
'Cells/EpisodeTitleCell', 'Cells/EpisodeNumberCell',
'Cells/AirDateCell', 'Cells/EpisodeTitleCell',
'Shared/Grid/Pager', 'Cells/AirDateCell',
'Shared/LoadingView' 'Shared/Grid/Pager',
], 'Shared/LoadingView'
function () { ], function (App, MissingRow) {
NzbDrone.Missing.MissingLayout = Backbone.Marionette.Layout.extend({ NzbDrone.Missing.MissingLayout = Backbone.Marionette.Layout.extend({
template: 'Missing/MissingLayoutTemplate', template: 'Missing/MissingLayoutTemplate',
@ -23,36 +23,36 @@ define([
pager : '#x-pager' pager : '#x-pager'
}, },
columns: [ columns:
{ [
name : 'series', {
label : 'Series Title', name : 'series',
sortable: false, label : 'Series Title',
cell : NzbDrone.Cells.SeriesTitleCell sortable: false,
}, cell : NzbDrone.Cells.SeriesTitleCell
{ },
name : 'this', {
label : 'Episode', name : 'this',
sortable: false, label : 'Episode',
cell : NzbDrone.Cells.EpisodeNumberCell sortable: false,
}, cell : NzbDrone.Cells.EpisodeNumberCell
{ },
name : 'this', {
label : 'Episode Title', name : 'this',
sortable: false, label : 'Episode Title',
cell : NzbDrone.Cells.EpisodeTitleCell sortable: false,
}, cell : NzbDrone.Cells.EpisodeTitleCell
{ },
name : 'airDate', {
label: 'Air Date', name : 'airDate',
cell : NzbDrone.Cells.AirDateCell label: 'Air Date',
} cell : NzbDrone.Cells.AirDateCell
], }
],
_showTable: function () { _showTable: function () {
this.missing.show(new Backgrid.Grid( this.missing.show(new Backgrid.Grid({
{ row : MissingRow,
row : NzbDrone.Missing.Row,
columns : this.columns, columns : this.columns,
collection: this.missingCollection, collection: this.missingCollection,
className : 'table table-hover' className : 'table table-hover'
@ -70,8 +70,7 @@ define([
this.missing.show(new NzbDrone.Shared.LoadingView()); this.missing.show(new NzbDrone.Shared.LoadingView());
this.missingCollection = new NzbDrone.Missing.Collection(); this.missingCollection = new NzbDrone.Missing.Collection();
this.missingCollection.fetch() this.missingCollection.fetch().done(function () {
.done(function () {
self._showTable(); self._showTable();
}); });
} }

View File

@ -1,16 +1,16 @@
"use strict"; "use strict";
define(['app','backgrid'], function () { define(
[
'backgrid'
], function (Backgrid) {
NzbDrone.Missing.Row = Backgrid.Row.extend({ return Backgrid.Row.extend({
events: { events: {
'click .x-search': 'search' 'click .x-search': 'search'
}, },
search: function () {
search: function () { window.alert('Episode Search');
window.alert('Episode Search'); }
} });
}); });
return NzbDrone.Mixins.Row;
});

View File

@ -1,23 +1,26 @@
//try to add ajax data as query string to DELETE calls. //try to add ajax data as query string to DELETE calls.
"use strict"; "use strict";
define(['jquery'], function () { define(function () {
var original = Backbone.ajax; return function () {
Backbone.ajax = function () { var original = this.ajax;
this.ajax = function () {
var xhr = arguments[0]; var xhr = arguments[0];
//check if ajax call was made with data option //check if ajax call was made with data option
if (xhr && xhr.data && xhr.type === 'DELETE') { if (xhr && xhr.data && xhr.type === 'DELETE') {
if (xhr.url.indexOf('?') === -1) { if (xhr.url.indexOf('?') === -1) {
xhr.url = xhr.url + '?' + $.param(xhr.data); xhr.url = xhr.url + '?' + $.param(xhr.data);
}
else {
xhr.url = xhr.url + '&' + $.param(xhr.data);
}
} }
else {
xhr.url = xhr.url + '&' + $.param(xhr.data);
}
}
return original.apply(this, arguments); return original.apply(this, arguments);
};
}; };
}); });

View File

@ -68,10 +68,14 @@ require.config({
backbone: { backbone: {
deps : deps :
[ [
'mixins/backbone.ajax',
'underscore', 'underscore',
'$' '$'
], ],
exports: 'Backbone' exports: 'Backbone',
init : function (AjaxMixin) {
AjaxMixin.apply(Backbone);
}
}, },
@ -87,7 +91,7 @@ require.config({
[ [
'backbone', 'backbone',
'handlebars', 'handlebars',
'mixins/backbone.marionette.templates', 'Handlebars/backbone.marionette.templates',
'mixins/AsNamedView', 'mixins/AsNamedView',
'Handlebars/Helpers/DateTime' 'Handlebars/Helpers/DateTime'
@ -122,6 +126,9 @@ require.config({
[ [
'backbone' 'backbone'
], ],
exports: 'Backgrid',
init: function () { init: function () {
Backgrid.Column.prototype.defaults = { Backgrid.Column.prototype.defaults = {
name : undefined, name : undefined,
@ -199,7 +206,6 @@ define(
window.NzbDrone.History = {}; window.NzbDrone.History = {};
window.NzbDrone.Logs = {}; window.NzbDrone.Logs = {};
window.NzbDrone.Release = {}; window.NzbDrone.Release = {};
window.NzbDrone.Mixins = {};
window.NzbDrone.Events = { window.NzbDrone.Events = {
SeriesAdded: 'seriesAdded' SeriesAdded: 'seriesAdded'
@ -214,9 +220,7 @@ define(
}; };
window.NzbDrone.addInitializer(function () { window.NzbDrone.addInitializer(function () {
console.log('starting application'); console.log('starting application');
}); });
NzbDrone.addRegions({ NzbDrone.addRegions({