mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 04:59:35 -07:00
rjs -> webpack
This commit is contained in:
parent
344f3d66ef
commit
428a1439e5
399 changed files with 11591 additions and 16139 deletions
|
@ -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);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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('<div><i class="icon-exclamation-sign"></i>' + errorMessage + '</div>');
|
||||
|
||||
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('<div><i class="icon-exclamation-sign"></i>' + errorMessage + '</div>');
|
||||
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('<span class="help-inline validation-error">' + errorMessage + '</span>');
|
||||
}
|
||||
|
||||
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('<span class="help-inline validation-error">' + errorMessage + '</span>');
|
||||
}
|
||||
|
||||
else {
|
||||
inputGroup.parent().append('<span class="help-block validation-error">' + errorMessage + '</span>');
|
||||
}
|
||||
}
|
||||
|
||||
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('<div class="alert alert-danger validation-error">' + errorMessage + '</div>');
|
||||
}
|
||||
|
||||
else {
|
||||
this.prepend('<div class="alert alert-danger validation-error">' + errorMessage + '</div>');
|
||||
inputGroup.parent().append('<span class="help-block validation-error">' + errorMessage + '</span>');
|
||||
}
|
||||
};
|
||||
|
||||
$.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 += ' <a class="no-router" target="_blank" href="' + error.infoLink + '"><i class="icon-external-link" title="' + error.detailedDescription + '"></i></a>';
|
||||
}
|
||||
else {
|
||||
errorMessage += ' <a class="no-router" target="_blank" href="' + error.infoLink + '"><i class="icon-external-link"></i></a>';
|
||||
}
|
||||
}
|
||||
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('<div class="alert alert-danger validation-error">' + errorMessage + '</div>');
|
||||
}
|
||||
else {
|
||||
this.prepend('<div class="alert alert-danger validation-error">' + errorMessage + '</div>');
|
||||
}
|
||||
};
|
||||
$.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 += ' <a class="no-router" target="_blank" href="' + error.infoLink + '"><i class="icon-external-link" title="' + error.detailedDescription + '"></i></a>';
|
||||
}
|
||||
else if (error.detailedDescription) {
|
||||
errorMessage += ' <i class="icon-nd-form-info" title="' + error.detailedDescription + '"></i>';
|
||||
else {
|
||||
errorMessage += ' <a class="no-router" target="_blank" href="' + error.infoLink + '"><i class="icon-external-link"></i></a>';
|
||||
}
|
||||
|
||||
return errorMessage;
|
||||
};
|
||||
});
|
||||
}
|
||||
else if(error.detailedDescription) {
|
||||
errorMessage += ' <i class="icon-nd-form-info" title="' + error.detailedDescription + '"></i>';
|
||||
}
|
||||
return errorMessage;
|
||||
};
|
||||
}).call(this);
|
Loading…
Add table
Add a link
Reference in a new issue