|
|
@ -2,50 +2,49 @@ var Backbone = require('backbone');
|
|
|
|
var $ = require('jquery');
|
|
|
|
var $ = require('jquery');
|
|
|
|
var StatusModel = require('../System/StatusModel');
|
|
|
|
var StatusModel = require('../System/StatusModel');
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = (function(){
|
|
|
|
var routeBinder = {
|
|
|
|
var routeBinder = {
|
|
|
|
bind : function(){
|
|
|
|
bind : function(){
|
|
|
|
var self = this;
|
|
|
|
var self = this;
|
|
|
|
$(document).on('click', 'a[href]', function(event){
|
|
|
|
$(document).on('click', 'a[href]', function(event){
|
|
|
|
self._handleClick(event);
|
|
|
|
self._handleClick(event);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_handleClick : function(event){
|
|
|
|
_handleClick : function(event){
|
|
|
|
var $target = $(event.target);
|
|
|
|
var $target = $(event.target);
|
|
|
|
if($target.parents('.nav-tabs').length) {
|
|
|
|
if($target.parents('.nav-tabs').length) {
|
|
|
|
return;
|
|
|
|
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]) {
|
|
|
|
|
|
|
|
var linkElement = $target.closest('a')[0];
|
|
|
|
|
|
|
|
if($(linkElement).hasClass('no-router')) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var href = event.target.getAttribute('href');
|
|
|
|
href = linkElement.getAttribute('href');
|
|
|
|
if(!href && $target.closest('a') && $target.closest('a')[0]) {
|
|
|
|
}
|
|
|
|
var linkElement = $target.closest('a')[0];
|
|
|
|
event.preventDefault();
|
|
|
|
if($(linkElement).hasClass('no-router')) {
|
|
|
|
if(!href) {
|
|
|
|
return;
|
|
|
|
throw 'couldn\'t find route target';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
href = linkElement.getAttribute('href');
|
|
|
|
if(!href.startsWith('http')) {
|
|
|
|
}
|
|
|
|
if(event.ctrlKey) {
|
|
|
|
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('#')) {
|
|
|
|
|
|
|
|
window.open(href, '_blank');
|
|
|
|
window.open(href, '_blank');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
window.open('http://www.dereferer.org/?' + encodeURI(href), '_blank');
|
|
|
|
var relativeHref = href.replace(StatusModel.get('urlBase'), '');
|
|
|
|
|
|
|
|
Backbone.history.navigate(relativeHref, {trigger : true});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
else if(href.contains('#')) {
|
|
|
|
return routeBinder;
|
|
|
|
window.open(href, '_blank');
|
|
|
|
}).call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
window.open('http://www.dereferer.org/?' + encodeURI(href), '_blank');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = routeBinder;
|
|
|
|