mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-19 21:44:30 -04:00
UI Cleanup - Updated Instrumentation, jQuery and Mixins subtrees.
This commit is contained in:
@@ -2,49 +2,67 @@ var Backbone = require('backbone');
|
||||
var $ = require('jquery');
|
||||
var StatusModel = require('../System/StatusModel');
|
||||
|
||||
//This module will automatically route all relative links through backbone router rather than
|
||||
//causing links to reload pages.
|
||||
|
||||
var routeBinder = {
|
||||
bind : function(){
|
||||
|
||||
bind : function() {
|
||||
var self = this;
|
||||
$(document).on('click', 'a[href]', function(event){
|
||||
$(document).on('click', 'a[href]', function(event) {
|
||||
self._handleClick(event);
|
||||
});
|
||||
},
|
||||
_handleClick : function(event){
|
||||
|
||||
_handleClick : function(event) {
|
||||
var $target = $(event.target);
|
||||
if($target.parents('.nav-tabs').length) {
|
||||
|
||||
//check if tab nav
|
||||
if ($target.parents('.nav-tabs').length) {
|
||||
return;
|
||||
}
|
||||
if($target.hasClass('no-router')) {
|
||||
|
||||
if ($target.hasClass('no-router')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = event.target.getAttribute('href');
|
||||
if(!href && $target.closest('a') && $target.closest('a')[0]) {
|
||||
|
||||
if (!href && $target.closest('a') && $target.closest('a')[0]) {
|
||||
|
||||
var linkElement = $target.closest('a')[0];
|
||||
if($(linkElement).hasClass('no-router')) {
|
||||
|
||||
if ($(linkElement).hasClass('no-router')) {
|
||||
return;
|
||||
}
|
||||
|
||||
href = linkElement.getAttribute('href');
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
if(!href) {
|
||||
|
||||
if (!href) {
|
||||
throw 'couldn\'t find route target';
|
||||
}
|
||||
if(!href.startsWith('http')) {
|
||||
if(event.ctrlKey) {
|
||||
|
||||
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});
|
||||
|
||||
Backbone.history.navigate(relativeHref, { trigger : true });
|
||||
}
|
||||
}
|
||||
else if(href.contains('#')) {
|
||||
} else if (href.contains('#')) {
|
||||
//Open in new tab without dereferer (since it doesn't support fragments)
|
||||
window.open(href, '_blank');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//Open in new tab
|
||||
window.open('http://www.dereferer.org/?' + encodeURI(href), '_blank');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = routeBinder;
|
||||
module.exports = routeBinder;
|
||||
Reference in New Issue
Block a user