@@ -89,7 +88,7 @@
-
-
-
+
+
+
diff --git a/src/UI/jQuery/RouteBinder.js b/src/UI/jQuery/RouteBinder.js
index 34918b78d..7a9640564 100644
--- a/src/UI/jQuery/RouteBinder.js
+++ b/src/UI/jQuery/RouteBinder.js
@@ -1,74 +1,51 @@
-'use strict';
-define(
- [
- 'backbone',
- 'jquery',
- 'System/StatusModel'
- ], function (Backbone, $, StatusModel) {
- //This module will automatically route all relative links through backbone router rather than
- //causing links to reload pages.
+var Backbone = require('backbone');
+var $ = require('jquery');
+var StatusModel = require('../System/StatusModel');
- var routeBinder = {
-
- bind: function () {
- var self = this;
- $(document).on('click', 'a[href]', function (event) {
- self._handleClick(event);
- });
- },
-
- _handleClick: function (event) {
- var $target = $(event.target);
-
- //check if tab nav
- if ($target.parents('.nav-tabs').length) {
+module.exports = (function(){
+ var routeBinder = {
+ bind : function(){
+ var self = this;
+ $(document).on('click', 'a[href]', function(event){
+ self._handleClick(event);
+ });
+ },
+ _handleClick : function(event){
+ var $target = $(event.target);
+ if($target.parents('.nav-tabs').length) {
+ return;
+ }
+ if($target.hasClass('no-router')) {
+ return;
+ }
+ var href = event.target.getAttribute('href');
+ if(!href && $target.closest('a') && $target.closest('a')[0]) {
+ var linkElement = $target.closest('a')[0];
+ if($(linkElement).hasClass('no-router')) {
return;
}
-
- if ($target.hasClass('no-router')) {
- return;
- }
-
- var href = event.target.getAttribute('href');
-
- if (!href && $target.closest('a') && $target.closest('a')[0]) {
-
- var linkElement = $target.closest('a')[0];
-
- if ($(linkElement).hasClass('no-router')) {
- return;
- }
-
- href = linkElement.getAttribute('href');
- }
-
- event.preventDefault();
-
- if (!href) {
- throw 'couldn\'t find route target';
- }
-
- if (!href.startsWith('http')) {
- if (event.ctrlKey) {
- window.open(href, '_blank');
- }
-
- else {
- var relativeHref = href.replace(StatusModel.get('urlBase'), '');
-
- Backbone.history.navigate(relativeHref, { trigger: true });
- }
- }
- else if (href.contains('#')) {
- //Open in new tab without dereferer (since it doesn't support fragments)
+ href = linkElement.getAttribute('href');
+ }
+ event.preventDefault();
+ if(!href) {
+ throw 'couldn\'t find route target';
+ }
+ if(!href.startsWith('http')) {
+ if(event.ctrlKey) {
window.open(href, '_blank');
}
else {
- //Open in new tab
- window.open('http://www.dereferer.org/?' + encodeURI(href), '_blank');
+ var relativeHref = href.replace(StatusModel.get('urlBase'), '');
+ Backbone.history.navigate(relativeHref, {trigger : true});
}
}
- };
-
- return routeBinder;
- });
+ else if(href.contains('#')) {
+ window.open(href, '_blank');
+ }
+ else {
+ window.open('http://www.dereferer.org/?' + encodeURI(href), '_blank');
+ }
+ }
+ };
+ return routeBinder;
+}).call(this);
\ No newline at end of file
diff --git a/src/UI/jQuery/ToTheTop.js b/src/UI/jQuery/ToTheTop.js
index fb4763e5f..37ff13ce7 100644
--- a/src/UI/jQuery/ToTheTop.js
+++ b/src/UI/jQuery/ToTheTop.js
@@ -1,26 +1,21 @@
-'use strict';
-define(
- [
- 'jquery',
- 'bootstrap'
- ], function ($) {
- $(document).ready(function () {
+var $ = require('jquery');
+require('bootstrap');
- var _window = $(window);
- var _scrollButton = $('#scroll-up');
-
- $(window).scroll(function () {
- if (_window.scrollTop() > 100) {
- _scrollButton.fadeIn();
- }
- else {
- _scrollButton.fadeOut();
- }
- });
-
- _scrollButton.click(function () {
- $('html, body').animate({ scrollTop: 0 }, 600);
- return false;
- });
+module.exports = (function(){
+ $(document).ready(function(){
+ var _window = $(window);
+ var _scrollButton = $('#scroll-up');
+ $(window).scroll(function(){
+ if(_window.scrollTop() > 100) {
+ _scrollButton.fadeIn();
+ }
+ else {
+ _scrollButton.fadeOut();
+ }
+ });
+ _scrollButton.click(function(){
+ $('html, body').animate({scrollTop : 0}, 600);
+ return false;
});
});
+}).call(this);
\ No newline at end of file
diff --git a/src/UI/jQuery/jquery.spin.js b/src/UI/jQuery/jquery.spin.js
index edae78deb..eb66e99d1 100644
--- a/src/UI/jQuery/jquery.spin.js
+++ b/src/UI/jQuery/jquery.spin.js
@@ -1,63 +1,46 @@
-define(
- [
- 'jquery'
- ], function ($) {
- 'use strict';
-
- $.fn.spinForPromise = function (promise) {
- var self = this;
-
- if (!promise || promise.state() !== 'pending') {
- return this;
- }
- promise.always(function () {
- self.stopSpin();
- });
-
- return this.startSpin();
- };
-
- $.fn.startSpin = function () {
-
- var icon = this.find('i').andSelf('i');
-
- if (!icon || !icon.attr('class')) {
- return this;
- }
-
- var iconClasses = icon.attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/);
-
- if (iconClasses.length === 0) {
- return this;
- }
-
- var iconClass = $.trim(iconClasses[0]);
-
- this.addClass('disabled');
-
- if (icon.hasClass('icon-can-spin')) {
- icon.addClass('icon-spin');
- }
- else {
- icon.attr('data-idle-icon', iconClass);
- icon.removeClass(iconClass);
- icon.addClass('icon-nd-spinner');
- }
+var $ = require('jquery');
+module.exports = (function(){
+ 'use strict';
+ $.fn.spinForPromise = function(promise){
+ var self = this;
+ if(!promise || promise.state() !== 'pending') {
return this;
- };
-
- $.fn.stopSpin = function () {
- var icon = this.find('i').andSelf('i');
-
- this.removeClass('disabled');
- icon.removeClass('icon-spin icon-nd-spinner');
- var idleIcon = icon.attr('data-idle-icon');
-
- if (idleIcon) {
- icon.addClass(idleIcon);
- }
-
+ }
+ promise.always(function(){
+ self.stopSpin();
+ });
+ return this.startSpin();
+ };
+ $.fn.startSpin = function(){
+ var icon = this.find('i').andSelf('i');
+ if(!icon || !icon.attr('class')) {
return this;
- };
- });
+ }
+ var iconClasses = icon.attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/);
+ if(iconClasses.length === 0) {
+ return this;
+ }
+ var iconClass = $.trim(iconClasses[0]);
+ this.addClass('disabled');
+ if(icon.hasClass('icon-can-spin')) {
+ icon.addClass('icon-spin');
+ }
+ else {
+ icon.attr('data-idle-icon', iconClass);
+ icon.removeClass(iconClass);
+ icon.addClass('icon-nd-spinner');
+ }
+ return this;
+ };
+ $.fn.stopSpin = function(){
+ var icon = this.find('i').andSelf('i');
+ this.removeClass('disabled');
+ icon.removeClass('icon-spin icon-nd-spinner');
+ var idleIcon = icon.attr('data-idle-icon');
+ if(idleIcon) {
+ icon.addClass(idleIcon);
+ }
+ return this;
+ };
+}).call(this);
\ No newline at end of file
diff --git a/src/UI/jQuery/jquery.validation.js b/src/UI/jQuery/jquery.validation.js
index 661e8310b..877666fab 100644
--- a/src/UI/jQuery/jquery.validation.js
+++ b/src/UI/jQuery/jquery.validation.js
@@ -1,105 +1,75 @@
-define(
- [
- 'jquery'
- ], function ($) {
- 'use strict';
+var $ = require('jquery');
- $.fn.processServerError = function (error) {
-
- var validationName = error.propertyName.toLowerCase();
-
- var errorMessage = this.formatErrorMessage(error);
-
- this.find('.validation-errors')
- .addClass('alert alert-danger')
- .append('
' + errorMessage + '
');
-
- if (!validationName || validationName === '') {
+module.exports = (function(){
+ 'use strict';
+ $.fn.processServerError = function(error){
+ var validationName = error.propertyName.toLowerCase();
+ var errorMessage = this.formatErrorMessage(error);
+ this.find('.validation-errors').addClass('alert alert-danger').append('
' + errorMessage + '
');
+ if(!validationName || validationName === '') {
+ this.addFormError(error);
+ return this;
+ }
+ var input = this.find('[name]').filter(function(){
+ return this.name.toLowerCase() === validationName;
+ });
+ if(input.length === 0) {
+ input = this.find('[validation-name]').filter(function(){
+ return $(this).attr('validation-name').toLowerCase() === validationName;
+ });
+ if(input.length === 0) {
this.addFormError(error);
+ console.error('couldn\'t find input for ' + error.propertyName);
return this;
}
-
- var input = this.find('[name]').filter(function () {
- return this.name.toLowerCase() === validationName;
- });
-
- if (input.length === 0) {
- input = this.find('[validation-name]').filter(function () {
- return $(this).attr('validation-name').toLowerCase() === validationName;
- });
-
- //still not found?
- if (input.length === 0) {
- this.addFormError(error);
- console.error('couldn\'t find input for ' + error.propertyName);
- return this;
- }
+ }
+ var formGroup = input.parents('.form-group');
+ if(formGroup.length === 0) {
+ formGroup = input.parent();
+ }
+ else {
+ var inputGroup = formGroup.find('.input-group');
+ if(inputGroup.length === 0) {
+ formGroup.append('
' + errorMessage + '');
}
-
- var formGroup = input.parents('.form-group');
-
- if(formGroup.length === 0) {
- formGroup = input.parent();
- }
- else{
- var inputGroup = formGroup.find('.input-group');
-
- if (inputGroup.length === 0) {
- formGroup.append('
' + errorMessage + '');
- }
-
- else {
- inputGroup.parent().append('
' + errorMessage + '');
- }
- }
-
- formGroup.addClass('has-error');
-
- return formGroup.find('.help-inline').text();
- };
-
-
- $.fn.processClientError = function (error) {
-
- };
-
- $.fn.addFormError = function (error) {
-
- var errorMessage = this.formatErrorMessage(error);
-
- if (this.find('.modal-body')) {
- this.find('.modal-body').prepend('
' + errorMessage + '
');
- }
-
else {
- this.prepend('
' + errorMessage + '
');
+ inputGroup.parent().append('
' + errorMessage + '');
}
- };
-
- $.fn.removeAllErrors = function () {
- this.find('.has-error').removeClass('has-error');
- this.find('.error').removeClass('error');
- this.find('.validation-errors').removeClass('alert').removeClass('alert-danger').html('');
- this.find('.validation-error').remove();
- return this.find('.help-inline.error-message').remove();
- };
-
- $.fn.formatErrorMessage = function (error) {
-
- var errorMessage = error.errorMessage;
-
- if (error.infoLink) {
- if (error.detailedDescription) {
- errorMessage += '
';
- }
- else {
- errorMessage += '
';
- }
+ }
+ formGroup.addClass('has-error');
+ return formGroup.find('.help-inline').text();
+ };
+ $.fn.processClientError = function(error){
+ };
+ $.fn.addFormError = function(error){
+ var errorMessage = this.formatErrorMessage(error);
+ if(this.find('.modal-body')) {
+ this.find('.modal-body').prepend('
' + errorMessage + '
');
+ }
+ else {
+ this.prepend('
' + errorMessage + '
');
+ }
+ };
+ $.fn.removeAllErrors = function(){
+ this.find('.has-error').removeClass('has-error');
+ this.find('.error').removeClass('error');
+ this.find('.validation-errors').removeClass('alert').removeClass('alert-danger').html('');
+ this.find('.validation-error').remove();
+ return this.find('.help-inline.error-message').remove();
+ };
+ $.fn.formatErrorMessage = function(error){
+ var errorMessage = error.errorMessage;
+ if(error.infoLink) {
+ if(error.detailedDescription) {
+ errorMessage += '
';
}
- else if (error.detailedDescription) {
- errorMessage += '
';
+ else {
+ errorMessage += '
';
}
-
- return errorMessage;
- };
- });
+ }
+ else if(error.detailedDescription) {
+ errorMessage += '
';
+ }
+ return errorMessage;
+ };
+}).call(this);
\ No newline at end of file
diff --git a/src/UI/main.js b/src/UI/main.js
index ae7af9f4a..e7a16368c 100644
--- a/src/UI/main.js
+++ b/src/UI/main.js
@@ -1,17 +1,47 @@
-require.config({
- urlArgs: 'v=' + window.NzbDrone.Version
+var $ = require('jquery');
+var Backbone = require('backbone');
+var Marionette = require('marionette');
+var RouteBinder = require('./jQuery/RouteBinder');
+var SignalRBroadcaster = require('./Shared/SignalRBroadcaster');
+var NavbarLayout = require('./Navbar/NavbarLayout');
+var AppLayout = require('./AppLayout');
+var SeriesController = require('./Series/SeriesController');
+var Router = require('./Router');
+var ModalController = require('./Shared/Modal/ModalController');
+var ControlPanelController = require('./Shared/ControlPanel/ControlPanelController');
+var serverStatusModel = require('./System/StatusModel');
+var Tooltip = require('./Shared/Tooltip');
+require('./Instrumentation/StringFormat');
+require('./LifeCycle');
+require('./Hotkeys/Hotkeys');
+require('./Mixins/jquery.ajax');
+
+new SeriesController();
+new ModalController();
+new ControlPanelController();
+new Router();
+var app = new Marionette.Application();
+app.addInitializer(function(){
+ console.log('starting application');
});
-
-if (window.NzbDrone.Production) {
- require.config({
- waitSeconds: 45
+app.addInitializer(SignalRBroadcaster.appInitializer, {app : app});
+app.addInitializer(Tooltip.appInitializer, {app : app});
+app.addInitializer(function(){
+ Backbone.history.start({
+ pushState : true,
+ root : serverStatusModel.get('urlBase')
});
-}
+ RouteBinder.bind();
+ AppLayout.navbarRegion.show(new NavbarLayout());
+ $('body').addClass('started');
+});
+app.addInitializer(function(){
+ var footerText = serverStatusModel.get('version');
+ if(serverStatusModel.get('branch') !== 'master') {
+ footerText += '' + serverStatusModel.get('branch');
+ }
+ $('#footer-region .version').html(footerText);
+});
+app.start();
-define(
- [
- 'app'
- ], function (app) {
- 'use strict';
- app.start();
- });
\ No newline at end of file
+module.exports = app;
diff --git a/src/UI/piwikCheck.js b/src/UI/piwikCheck.js
index 895af5f31..31e9c14f8 100644
--- a/src/UI/piwikCheck.js
+++ b/src/UI/piwikCheck.js
@@ -8,10 +8,4 @@ if(window.NzbDrone.Analytics) {
g.defer = true;
g.src = 'http://piwik.nzbdrone.com/piwik.js';
s.parentNode.insertBefore(g, s);
-}
-
-// piwik is used to send anonymous information about your browser and which parts of the web interface you use to Sonarr servers.
-// We use this information to prioritize features and browser support.
-// We will NEVER include any personal information or any information that could identify you.
-//
-// You can opt out of this in general settings
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/UI/polyfills.js b/src/UI/polyfills.js
index 5bce992df..08bea2e83 100644
--- a/src/UI/polyfills.js
+++ b/src/UI/polyfills.js
@@ -1,30 +1,33 @@
window.console = window.console || {};
-window.console.log = window.console.log || function(){};
-window.console.group = window.console.group || function(){};
-window.console.groupEnd = window.console.groupEnd || function(){};
-window.console.debug = window.console.debug || function(){};
-window.console.warn = window.console.warn || function(){};
-window.console.assert = window.console.assert || function(){};
-
-
-if (!String.prototype.startsWith) {
+window.console.log = window.console.log || function(){
+};
+window.console.group = window.console.group || function(){
+};
+window.console.groupEnd = window.console.groupEnd || function(){
+};
+window.console.debug = window.console.debug || function(){
+};
+window.console.warn = window.console.warn || function(){
+};
+window.console.assert = window.console.assert || function(){
+};
+if(!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
- enumerable: false,
- configurable: false,
- writable: false,
- value: function (searchString, position) {
+ enumerable : false,
+ configurable : false,
+ writable : false,
+ value : function(searchString, position){
position = position || 0;
return this.indexOf(searchString, position) === position;
}
});
}
-
-if (!String.prototype.endsWith) {
+if(!String.prototype.endsWith) {
Object.defineProperty(String.prototype, 'endsWith', {
- enumerable: false,
- configurable: false,
- writable: false,
- value: function (searchString, position) {
+ enumerable : false,
+ configurable : false,
+ writable : false,
+ value : function(searchString, position){
position = position || this.length;
position = position - searchString.length;
var lastIndex = this.lastIndexOf(searchString);
@@ -32,10 +35,8 @@ if (!String.prototype.endsWith) {
}
});
}
-
-if(!('contains' in String.prototype))
-{
- String.prototype.contains = function(str, startIndex) {
+if(!('contains' in String.prototype)) {
+ String.prototype.contains = function(str, startIndex){
return -1 !== String.prototype.indexOf.call(this, str, startIndex);
};
-}
+}
\ No newline at end of file
diff --git a/src/UI/reqres.js b/src/UI/reqres.js
index 88c237908..a39b792ed 100644
--- a/src/UI/reqres.js
+++ b/src/UI/reqres.js
@@ -1,15 +1,9 @@
-define(
- [
- 'marionette',
- 'backbone'
- ], function (Marionette, Backbone) {
- 'use strict';
- var reqres = new Backbone.Wreqr.RequestResponse();
+var Wreqr = require('./JsLibraries/backbone.wreqr');
- reqres.Requests = {
- GetEpisodeFileById : 'GetEpisodeFileById',
- GetAlternateNameBySeasonNumber : 'GetAlternateNameBySeasonNumber'
- };
+var reqres = new Wreqr.RequestResponse();
+reqres.Requests = {
+ GetEpisodeFileById : 'GetEpisodeFileById',
+ GetAlternateNameBySeasonNumber : 'GetAlternateNameBySeasonNumber'
+};
- return reqres;
- });
+module.exports = reqres;
\ No newline at end of file
diff --git a/src/UI/vent.js b/src/UI/vent.js
index 3b466361c..1b0d285b0 100644
--- a/src/UI/vent.js
+++ b/src/UI/vent.js
@@ -1,42 +1,35 @@
-define(
- [
- 'marionette',
- 'backbone'
- ], function (Marionette, Backbone) {
- 'use strict';
+var Wreqr = require('./JsLibraries/backbone.wreqr');
- var vent = new Backbone.Wreqr.EventAggregator();
-
- vent.Events = {
- SeriesAdded : 'series:added',
- SeriesDeleted : 'series:deleted',
- CommandComplete : 'command:complete',
- ServerUpdated : 'server:updated',
- EpisodeFileDeleted : 'episodefile:deleted'
- };
-
- vent.Commands = {
- EditSeriesCommand : 'EditSeriesCommand',
- DeleteSeriesCommand : 'DeleteSeriesCommand',
- OpenModalCommand : 'OpenModalCommand',
- CloseModalCommand : 'CloseModalCommand',
- ShowEpisodeDetails : 'ShowEpisodeDetails',
- ShowHistoryDetails : 'ShowHistoryDetails',
- ShowLogDetails : 'ShowLogDetails',
- SaveSettings : 'saveSettings',
- ShowLogFile : 'showLogFile',
- ShowRenamePreview : 'showRenamePreview',
- ShowFileBrowser : 'showFileBrowser',
- CloseFileBrowser : 'closeFileBrowser',
- OpenControlPanelCommand : 'OpenControlPanelCommand',
- CloseControlPanelCommand : 'CloseControlPanelCommand'
- };
-
- vent.Hotkeys = {
- NavbarSearch : 'navbar:search',
- SaveSettings : 'settings:save',
- ShowHotkeys : 'hotkeys:show'
- };
-
- return vent;
- });
+module.exports = (function(){
+ 'use strict';
+ var vent = new Wreqr.EventAggregator();
+ vent.Events = {
+ SeriesAdded : 'series:added',
+ SeriesDeleted : 'series:deleted',
+ CommandComplete : 'command:complete',
+ ServerUpdated : 'server:updated',
+ EpisodeFileDeleted : 'episodefile:deleted'
+ };
+ vent.Commands = {
+ EditSeriesCommand : 'EditSeriesCommand',
+ DeleteSeriesCommand : 'DeleteSeriesCommand',
+ OpenModalCommand : 'OpenModalCommand',
+ CloseModalCommand : 'CloseModalCommand',
+ ShowEpisodeDetails : 'ShowEpisodeDetails',
+ ShowHistoryDetails : 'ShowHistoryDetails',
+ ShowLogDetails : 'ShowLogDetails',
+ SaveSettings : 'saveSettings',
+ ShowLogFile : 'showLogFile',
+ ShowRenamePreview : 'showRenamePreview',
+ ShowFileBrowser : 'showFileBrowser',
+ CloseFileBrowser : 'closeFileBrowser',
+ OpenControlPanelCommand : 'OpenControlPanelCommand',
+ CloseControlPanelCommand : 'CloseControlPanelCommand'
+ };
+ vent.Hotkeys = {
+ NavbarSearch : 'navbar:search',
+ SaveSettings : 'settings:save',
+ ShowHotkeys : 'hotkeys:show'
+ };
+ return vent;
+}).call(this);
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 000000000..650b3081b
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,42 @@
+module.exports = {
+ entry : 'main.js',
+ resolve : {
+ root : 'src/UI',
+ alias : {
+ 'templates' : '/templates',
+ 'backbone' : 'Shims/backbone',
+ 'moment' : 'JsLibraries/moment',
+ 'filesize' : 'JsLibraries/filesize',
+ 'handlebars' : 'Shared/Shims/handlebars',
+ 'handlebars.helpers' : 'JsLibraries/handlebars.helpers',
+ 'bootstrap' : 'JsLibraries/bootstrap',
+ 'backbone.deepmodel' : 'JsLibraries/backbone.deep.model',
+ 'backbone.pageable' : 'JsLibraries/backbone.pageable',
+ 'backbone-pageable' : 'JsLibraries/backbone.pageable',
+ 'backbone.validation' : 'Shims/backbone.validation',
+ 'backbone.modelbinder' : 'JsLibraries/backbone.modelbinder',
+ 'backbone.collectionview' : 'Shims/backbone.collectionview',
+ 'backgrid' : 'Shims/backgrid',
+ 'backgrid.paginator' : 'Shims/backgrid.paginator',
+ 'backgrid.selectall' : 'Shims/backbone.backgrid.selectall',
+ 'fullcalendar' : 'JsLibraries/fullcalendar',
+ 'backstrech' : 'JsLibraries/jquery.backstretch',
+ 'underscore' : 'JsLibraries/lodash.underscore',
+ 'marionette' : 'Shims/backbone.marionette',
+ 'signalR' : 'Shims/jquery.signalR',
+ 'jquery-ui' : 'JsLibraries/jquery-ui',
+ 'jquery.knob' : 'JsLibraries/jquery.knob',
+ 'jquery.easypiechart' : 'JsLibraries/jquery.easypiechart',
+ 'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot',
+ 'messenger' : 'Shims/messenger',
+ 'jquery' : 'Shims/jquery',
+ 'typeahead' : 'JsLibraries/typeahead',
+ 'zero.clipboard' : 'JsLibraries/zero.clipboard',
+ 'bootstrap.tagsinput' : 'JsLibraries/bootstrap.tagsinput',
+ 'libs' : 'JsLibraries/'
+ }
+ }, output : {
+ filename : '_output/UI/main.js',
+ sourceMapFilename : '_output/UI/main.map'
+ }
+};