mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-13 16:43:58 -07:00
all tooltips are automatically converted to bootstrap.
This commit is contained in:
parent
ae44843ea7
commit
1b55859eb2
6 changed files with 14 additions and 9 deletions
56
UI/jQuery/RouteBinder.js
Normal file
56
UI/jQuery/RouteBinder.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
"use strict";
|
||||
define(function () {
|
||||
//This module will automatically route all 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;
|
||||
}
|
||||
|
||||
console.log('click');
|
||||
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 'couldnt find route target';
|
||||
}
|
||||
|
||||
|
||||
if (!href.startsWith('http')) {
|
||||
router.navigate(href, { trigger: true });
|
||||
}
|
||||
|
||||
else {
|
||||
//Open in new tab
|
||||
window.open(href, '_blank');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return routeBinder;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue