mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 13:10:13 -07:00
Moved source code under src folder - massive change
This commit is contained in:
parent
2fc8123d6b
commit
5bf0e197ec
1499 changed files with 1054 additions and 1444 deletions
55
src/UI/jQuery/RouteBinder.js
Normal file
55
src/UI/jQuery/RouteBinder.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
define(function () {
|
||||
//This module will automatically route all relative links through backbone router rather than
|
||||
//causing links to reload pages.
|
||||
|
||||
var routeBinder = {
|
||||
|
||||
bind: function (router) {
|
||||
var self = this;
|
||||
$(document).on('click', 'a[href]', function (event) {
|
||||
self._handleClick(event, router);
|
||||
});
|
||||
},
|
||||
|
||||
_handleClick: function (event, router) {
|
||||
var $target = $(event.target);
|
||||
|
||||
//check if tab nav
|
||||
if ($target.parents('.nav-tabs').length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target.hasClass('no-router')) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var href = event.target.getAttribute('href');
|
||||
|
||||
if (!href && $target.parent('a') && $target.parent('a')[0]) {
|
||||
|
||||
var linkElement = $target.parent('a')[0];
|
||||
|
||||
href = linkElement.getAttribute('href');
|
||||
}
|
||||
|
||||
if (!href) {
|
||||
throw 'couldn\'t find route target';
|
||||
}
|
||||
|
||||
|
||||
if (!href.startsWith('http')) {
|
||||
router.navigate(href, { trigger: true });
|
||||
}
|
||||
|
||||
else {
|
||||
//Open in new tab
|
||||
window.open(href, '_blank');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return routeBinder;
|
||||
});
|
||||
25
src/UI/jQuery/ToTheTop.js
Normal file
25
src/UI/jQuery/ToTheTop.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'bootstrap'
|
||||
], 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;
|
||||
});
|
||||
});
|
||||
});
|
||||
10
src/UI/jQuery/TooltipBinder.js
Normal file
10
src/UI/jQuery/TooltipBinder.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'bootstrap'
|
||||
], function () {
|
||||
|
||||
$('body').tooltip({
|
||||
selector: '[title]'
|
||||
});
|
||||
});
|
||||
58
src/UI/jQuery/jquery.spin.js
Normal file
58
src/UI/jQuery/jquery.spin.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
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');
|
||||
|
||||
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;
|
||||
};
|
||||
});
|
||||
63
src/UI/jQuery/jquery.validation.js
Normal file
63
src/UI/jQuery/jquery.validation.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
define(
|
||||
[
|
||||
'jquery'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.fn.processServerError = function (error) {
|
||||
|
||||
var validationName = error.propertyName.toLowerCase();
|
||||
|
||||
this.find('.validation-errors')
|
||||
.addClass('alert alert-error')
|
||||
.append('<div><i class="icon-exclamation-sign"></i>' + error.errorMessage + '</div>');
|
||||
|
||||
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 controlGroup = input.parents('.control-group');
|
||||
|
||||
if(controlGroup.length ===0){
|
||||
controlGroup = input.parent();
|
||||
}
|
||||
else{
|
||||
controlGroup.find('.controls').append('<span class="help-inline error-message">' + error.errorMessage + '</span>');
|
||||
}
|
||||
|
||||
controlGroup.addClass('error');
|
||||
|
||||
return controlGroup.find('.help-inline').text();
|
||||
};
|
||||
|
||||
|
||||
$.fn.processClientError = function (error) {
|
||||
|
||||
};
|
||||
|
||||
$.fn.addFormError = function (error) {
|
||||
this.find('.control-group').parent().prepend('<div class="alert alert-error validation-error">' + error.errorMessage + '</div>')
|
||||
};
|
||||
|
||||
$.fn.removeAllErrors = function () {
|
||||
this.find('.error').removeClass('error');
|
||||
this.find('.validation-errors').removeClass('alert').removeClass('alert-error').html('');
|
||||
this.find('.validation-error').remove();
|
||||
return this.find('.help-inline.error-message').remove();
|
||||
};
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue