add shared routing
This commit is contained in:
parent
2807ef810f
commit
b29e4cd59d
12 changed files with 2435 additions and 14 deletions
|
@ -16,12 +16,12 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"version": "1.1.48",
|
"version": "1.1.49",
|
||||||
"_release": "1.1.48",
|
"_release": "1.1.49",
|
||||||
"_resolution": {
|
"_resolution": {
|
||||||
"type": "version",
|
"type": "version",
|
||||||
"tag": "1.1.48",
|
"tag": "1.1.49",
|
||||||
"commit": "1301ee3681a29577ba045c0ce20fd0e914cee168"
|
"commit": "6fe9a4ae4aa727695fbd17a40486065ce46c0892"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/MediaBrowser/emby-webcomponents.git",
|
"_source": "git://github.com/MediaBrowser/emby-webcomponents.git",
|
||||||
"_target": "~1.1.5",
|
"_target": "~1.1.5",
|
||||||
|
|
527
dashboard-ui/bower_components/emby-webcomponents/router.js
vendored
Normal file
527
dashboard-ui/bower_components/emby-webcomponents/router.js
vendored
Normal file
|
@ -0,0 +1,527 @@
|
||||||
|
define(['loading', 'viewManager', 'skinManager', 'pluginManager', 'backdrop', 'browser'], function (loading, viewManager, skinManager, pluginManager, backdrop, browser) {
|
||||||
|
|
||||||
|
var connectionManager;
|
||||||
|
|
||||||
|
function isStartup(ctx) {
|
||||||
|
var path = ctx.pathname;
|
||||||
|
|
||||||
|
if (path.indexOf('welcome') != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.indexOf('connectlogin') != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.indexOf('login') != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.indexOf('manuallogin') != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.indexOf('manualserver') != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.indexOf('selectserver') != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path.indexOf('localpin') != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function allowAnonymous(ctx) {
|
||||||
|
|
||||||
|
return isStartup(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirectToLogin() {
|
||||||
|
|
||||||
|
backdrop.clear();
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
connectionManager.connect().then(function (result) {
|
||||||
|
handleConnectionResult(result, loading);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleConnectionResult(result, loading) {
|
||||||
|
|
||||||
|
switch (result.State) {
|
||||||
|
|
||||||
|
case MediaBrowser.ConnectionState.SignedIn:
|
||||||
|
{
|
||||||
|
loading.hide();
|
||||||
|
skinManager.loadUserSkin();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.ServerSignIn:
|
||||||
|
{
|
||||||
|
result.ApiClient.getPublicUsers().then(function (users) {
|
||||||
|
|
||||||
|
if (users.length) {
|
||||||
|
show('/startup/login.html?serverid=' + result.Servers[0].Id);
|
||||||
|
} else {
|
||||||
|
goToLocalLogin(result.ApiClient, result.Servers[0].Id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.ServerSelection:
|
||||||
|
{
|
||||||
|
show('/startup/selectserver.html');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.ConnectSignIn:
|
||||||
|
{
|
||||||
|
show('/startup/welcome.html');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MediaBrowser.ConnectionState.ServerUpdateNeeded:
|
||||||
|
{
|
||||||
|
require(['alert'], function (alert) {
|
||||||
|
alert(Globalize.translate('core#ServerUpdateNeeded', '<a href="https://emby.media">https://emby.media</a>')).then(function () {
|
||||||
|
show('/startup/selectserver.html');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToLocalLogin(apiClient, serverId) {
|
||||||
|
|
||||||
|
show('/startup/manuallogin.html?serverid=' + serverId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var cacheParam = new Date().getTime();
|
||||||
|
function loadContentUrl(ctx, next, route, request) {
|
||||||
|
|
||||||
|
var url = route.contentPath || route.path;
|
||||||
|
|
||||||
|
if (url.toLowerCase().indexOf('http') != 0 && url.indexOf('file:') != 0) {
|
||||||
|
url = baseUrl() + '/' + url;
|
||||||
|
}
|
||||||
|
|
||||||
|
url += url.indexOf('?') == -1 ? '?' : '&';
|
||||||
|
url += 'v=' + cacheParam;
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.onload = xhr.onerror = function () {
|
||||||
|
if (this.status < 400) {
|
||||||
|
loadContent(ctx, route, this.response, request);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.onerror = next;
|
||||||
|
xhr.open('GET', url, true);
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRoute(ctx, next, route) {
|
||||||
|
|
||||||
|
authenticate(ctx, route, function () {
|
||||||
|
initRoute(ctx, next, route);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initRoute(ctx, next, route) {
|
||||||
|
|
||||||
|
var onInitComplete = function (controllerFactory) {
|
||||||
|
sendRouteToViewManager(ctx, next, route, controllerFactory);
|
||||||
|
};
|
||||||
|
|
||||||
|
require(route.dependencies || [], function () {
|
||||||
|
|
||||||
|
if (route.controller) {
|
||||||
|
require([route.controller], onInitComplete);
|
||||||
|
} else {
|
||||||
|
onInitComplete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelCurrentLoadRequest() {
|
||||||
|
var currentRequest = currentViewLoadRequest;
|
||||||
|
if (currentRequest) {
|
||||||
|
currentRequest.cancel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentViewLoadRequest;
|
||||||
|
function sendRouteToViewManager(ctx, next, route, controllerFactory) {
|
||||||
|
|
||||||
|
cancelCurrentLoadRequest();
|
||||||
|
|
||||||
|
var isBackNav = ctx.isBack;
|
||||||
|
|
||||||
|
var currentRequest = {
|
||||||
|
url: baseUrl() + ctx.path,
|
||||||
|
transition: route.transition,
|
||||||
|
isBack: isBackNav,
|
||||||
|
state: ctx.state,
|
||||||
|
type: route.type,
|
||||||
|
controllerFactory: controllerFactory,
|
||||||
|
options: {
|
||||||
|
supportsThemeMedia: route.supportsThemeMedia || false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
currentViewLoadRequest = currentRequest;
|
||||||
|
|
||||||
|
var onNewViewNeeded = function () {
|
||||||
|
if (typeof route.path === 'string') {
|
||||||
|
|
||||||
|
loadContentUrl(ctx, next, route, currentRequest);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// ? TODO
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isBackNav) {
|
||||||
|
// Don't force a new view for home due to the back menu
|
||||||
|
if (route.type != 'home') {
|
||||||
|
onNewViewNeeded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
viewManager.tryRestoreView(currentRequest).then(function () {
|
||||||
|
|
||||||
|
// done
|
||||||
|
currentRouteInfo = {
|
||||||
|
route: route,
|
||||||
|
path: ctx.path
|
||||||
|
};
|
||||||
|
|
||||||
|
}, onNewViewNeeded);
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstConnectionResult;
|
||||||
|
function start() {
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
require(['connectionManager'], function (connectionManagerInstance) {
|
||||||
|
|
||||||
|
connectionManager = connectionManagerInstance;
|
||||||
|
|
||||||
|
connectionManager.connect().then(function (result) {
|
||||||
|
|
||||||
|
firstConnectionResult = result;
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
|
||||||
|
page({
|
||||||
|
click: false,
|
||||||
|
hashbang: true,
|
||||||
|
enableHistory: enableHistory()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableHistory() {
|
||||||
|
|
||||||
|
if (browser.xboxOne) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableNativeHistory() {
|
||||||
|
return page.enableNativeHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
function authenticate(ctx, route, callback) {
|
||||||
|
|
||||||
|
var firstResult = firstConnectionResult;
|
||||||
|
if (firstResult) {
|
||||||
|
|
||||||
|
firstConnectionResult = null;
|
||||||
|
|
||||||
|
if (firstResult.State != MediaBrowser.ConnectionState.SignedIn) {
|
||||||
|
|
||||||
|
handleConnectionResult(firstResult, loading);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var server = connectionManager.currentLoggedInServer();
|
||||||
|
var pathname = ctx.pathname.toLowerCase();
|
||||||
|
|
||||||
|
console.log('Emby.Page - processing path request ' + pathname);
|
||||||
|
|
||||||
|
if (server) {
|
||||||
|
|
||||||
|
console.log('Emby.Page - user is authenticated');
|
||||||
|
|
||||||
|
if (ctx.isBack && (route.isDefaultRoute /*|| isStartup(ctx)*/)) {
|
||||||
|
handleBackToDefault();
|
||||||
|
}
|
||||||
|
else if (route.isDefaultRoute) {
|
||||||
|
console.log('Emby.Page - loading skin home page');
|
||||||
|
skinManager.loadUserSkin();
|
||||||
|
} else {
|
||||||
|
console.log('Emby.Page - next()');
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Emby.Page - user is not authenticated');
|
||||||
|
|
||||||
|
if (!allowAnonymous(ctx)) {
|
||||||
|
|
||||||
|
console.log('Emby.Page - route does not allow anonymous access, redirecting to login');
|
||||||
|
redirectToLogin();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
console.log('Emby.Page - proceeding to ' + pathname);
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var isHandlingBackToDefault;
|
||||||
|
function handleBackToDefault() {
|
||||||
|
|
||||||
|
skinManager.loadUserSkin();
|
||||||
|
|
||||||
|
if (isHandlingBackToDefault) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isHandlingBackToDefault = true;
|
||||||
|
|
||||||
|
// This must result in a call to either
|
||||||
|
// skinManager.loadUserSkin();
|
||||||
|
// Logout
|
||||||
|
// Or exit app
|
||||||
|
|
||||||
|
skinManager.getCurrentSkin().showBackMenu().then(function () {
|
||||||
|
|
||||||
|
isHandlingBackToDefault = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadContent(ctx, route, html, request) {
|
||||||
|
|
||||||
|
html = Globalize.translateDocument(html, route.dictionary);
|
||||||
|
request.view = html;
|
||||||
|
|
||||||
|
viewManager.loadView(request);
|
||||||
|
|
||||||
|
currentRouteInfo = {
|
||||||
|
route: route,
|
||||||
|
path: ctx.path
|
||||||
|
};
|
||||||
|
//next();
|
||||||
|
|
||||||
|
ctx.handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var baseRoute = window.location.href.split('?')[0].replace('/index.html', '');
|
||||||
|
// support hashbang
|
||||||
|
baseRoute = baseRoute.split('#')[0];
|
||||||
|
if (baseRoute.lastIndexOf('/') == baseRoute.length - 1) {
|
||||||
|
baseRoute = baseRoute.substring(0, baseRoute.length - 1);
|
||||||
|
}
|
||||||
|
function baseUrl() {
|
||||||
|
return baseRoute;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHandler(route) {
|
||||||
|
return function (ctx, next) {
|
||||||
|
handleRoute(ctx, next, route);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWindowLocationSearch(win) {
|
||||||
|
|
||||||
|
var currentPath = currentRouteInfo ? (currentRouteInfo.path || '') : '';
|
||||||
|
|
||||||
|
var index = currentPath.indexOf('?');
|
||||||
|
var search = '';
|
||||||
|
|
||||||
|
if (index != -1) {
|
||||||
|
search = currentPath.substring(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return search || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function param(name, url) {
|
||||||
|
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
|
||||||
|
var regexS = "[\\?&]" + name + "=([^&#]*)";
|
||||||
|
var regex = new RegExp(regexS, "i");
|
||||||
|
|
||||||
|
var results = regex.exec(url || getWindowLocationSearch());
|
||||||
|
if (results == null)
|
||||||
|
return "";
|
||||||
|
else
|
||||||
|
return decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||||
|
}
|
||||||
|
|
||||||
|
function back() {
|
||||||
|
|
||||||
|
page.back();
|
||||||
|
}
|
||||||
|
function canGoBack() {
|
||||||
|
|
||||||
|
var curr = current();
|
||||||
|
|
||||||
|
if (!curr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curr.type == 'home') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return page.canGoBack();
|
||||||
|
}
|
||||||
|
function show(path, options) {
|
||||||
|
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
|
var baseRoute = baseUrl();
|
||||||
|
path = path.replace(baseRoute, '');
|
||||||
|
|
||||||
|
if (currentRouteInfo && currentRouteInfo.path == path) {
|
||||||
|
|
||||||
|
// can't use this with home right now due to the back menu
|
||||||
|
if (currentRouteInfo.route.type != 'home') {
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
page.show(path, options);
|
||||||
|
setTimeout(resolve, 500);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentRouteInfo;
|
||||||
|
function current() {
|
||||||
|
return currentRouteInfo ? currentRouteInfo.route : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function goHome() {
|
||||||
|
|
||||||
|
var skin = skinManager.getCurrentSkin();
|
||||||
|
|
||||||
|
var homeRoute = skin.getRoutes().filter(function (r) {
|
||||||
|
return r.type == 'home';
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
return show(pluginManager.mapRoute(skin, homeRoute));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showItem(item) {
|
||||||
|
|
||||||
|
if (typeof (item) === 'string') {
|
||||||
|
Emby.Models.item(item).then(showItem);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
skinManager.getCurrentSkin().showItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTitle(title) {
|
||||||
|
skinManager.getCurrentSkin().setTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
function gotoSettings() {
|
||||||
|
show('/settings/settings.html');
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectServer() {
|
||||||
|
show('/startup/selectserver.html');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showVideoOsd() {
|
||||||
|
var skin = skinManager.getCurrentSkin();
|
||||||
|
|
||||||
|
var homeRoute = skin.getRoutes().filter(function (r) {
|
||||||
|
return r.type == 'video-osd';
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
return show(pluginManager.mapRoute(skin, homeRoute));
|
||||||
|
}
|
||||||
|
|
||||||
|
var allRoutes = [];
|
||||||
|
|
||||||
|
function addRoute(path, newRoute) {
|
||||||
|
|
||||||
|
page(path, getHandler(newRoute));
|
||||||
|
allRoutes.push(newRoute);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRoutes() {
|
||||||
|
return allRoutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTransparency(level) {
|
||||||
|
|
||||||
|
if (level == 'full' || level == Emby.TransparencyLevel.Full) {
|
||||||
|
backdrop.clear(true);
|
||||||
|
document.documentElement.classList.add('transparentDocument');
|
||||||
|
}
|
||||||
|
else if (level == 'backdrop' || level == Emby.TransparencyLevel.Backdrop) {
|
||||||
|
backdrop.externalBackdrop(true);
|
||||||
|
document.documentElement.classList.add('transparentDocument');
|
||||||
|
} else {
|
||||||
|
backdrop.externalBackdrop(false);
|
||||||
|
document.documentElement.classList.remove('transparentDocument');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushState(state, title, url) {
|
||||||
|
|
||||||
|
state.navigate = false;
|
||||||
|
|
||||||
|
page.pushState(state, title, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
addRoute: addRoute,
|
||||||
|
param: param,
|
||||||
|
back: back,
|
||||||
|
show: show,
|
||||||
|
start: start,
|
||||||
|
baseUrl: baseUrl,
|
||||||
|
canGoBack: canGoBack,
|
||||||
|
current: current,
|
||||||
|
redirectToLogin: redirectToLogin,
|
||||||
|
goHome: goHome,
|
||||||
|
gotoSettings: gotoSettings,
|
||||||
|
showItem: showItem,
|
||||||
|
setTitle: setTitle,
|
||||||
|
selectServer: selectServer,
|
||||||
|
showVideoOsd: showVideoOsd,
|
||||||
|
setTransparency: setTransparency,
|
||||||
|
getRoutes: getRoutes,
|
||||||
|
|
||||||
|
pushState: pushState,
|
||||||
|
|
||||||
|
TransparencyLevel: {
|
||||||
|
None: 0,
|
||||||
|
Backdrop: 1,
|
||||||
|
Full: 2
|
||||||
|
},
|
||||||
|
enableNativeHistory: enableNativeHistory
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
|
@ -32,14 +32,14 @@
|
||||||
"web-component-tester": "^4.0.0",
|
"web-component-tester": "^4.0.0",
|
||||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/polymerelements/iron-icon",
|
"homepage": "https://github.com/PolymerElements/iron-icon",
|
||||||
"_release": "1.0.8",
|
"_release": "1.0.8",
|
||||||
"_resolution": {
|
"_resolution": {
|
||||||
"type": "version",
|
"type": "version",
|
||||||
"tag": "v1.0.8",
|
"tag": "v1.0.8",
|
||||||
"commit": "f36b38928849ef3853db727faa8c9ef104d611eb"
|
"commit": "f36b38928849ef3853db727faa8c9ef104d611eb"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/polymerelements/iron-icon.git",
|
"_source": "git://github.com/PolymerElements/iron-icon.git",
|
||||||
"_target": "^1.0.0",
|
"_target": "^1.0.0",
|
||||||
"_originalSource": "polymerelements/iron-icon"
|
"_originalSource": "PolymerElements/iron-icon"
|
||||||
}
|
}
|
|
@ -36,7 +36,7 @@
|
||||||
"tag": "v1.3.0",
|
"tag": "v1.3.0",
|
||||||
"commit": "1662093611cda3fd29125cdab94a61d3d88093da"
|
"commit": "1662093611cda3fd29125cdab94a61d3d88093da"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/PolymerElements/iron-selector.git",
|
"_source": "git://github.com/polymerelements/iron-selector.git",
|
||||||
"_target": "^1.0.0",
|
"_target": "^1.0.0",
|
||||||
"_originalSource": "PolymerElements/iron-selector"
|
"_originalSource": "polymerelements/iron-selector"
|
||||||
}
|
}
|
40
dashboard-ui/bower_components/page.js/.bower.json
vendored
Normal file
40
dashboard-ui/bower_components/page.js/.bower.json
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"name": "page",
|
||||||
|
"description": "Tiny client-side router",
|
||||||
|
"keywords": [
|
||||||
|
"page",
|
||||||
|
"route",
|
||||||
|
"router",
|
||||||
|
"routes",
|
||||||
|
"pushState"
|
||||||
|
],
|
||||||
|
"main": "page.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/visionmedia/page.js"
|
||||||
|
},
|
||||||
|
"ignore": [
|
||||||
|
".gitignore",
|
||||||
|
".npmignore",
|
||||||
|
".travis.yml",
|
||||||
|
"component.json",
|
||||||
|
"examples",
|
||||||
|
"History.md",
|
||||||
|
"Makefile",
|
||||||
|
"package.json",
|
||||||
|
"Readme.md",
|
||||||
|
"test"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/visionmedia/page.js",
|
||||||
|
"version": "1.6.4",
|
||||||
|
"_release": "1.6.4",
|
||||||
|
"_resolution": {
|
||||||
|
"type": "version",
|
||||||
|
"tag": "1.6.4",
|
||||||
|
"commit": "d11509f1f0fed0309391d995919c25dce84b8abd"
|
||||||
|
},
|
||||||
|
"_source": "git://github.com/visionmedia/page.js.git",
|
||||||
|
"_target": "~1.6.3",
|
||||||
|
"_originalSource": "page.js"
|
||||||
|
}
|
5
dashboard-ui/bower_components/page.js/.jsbeautifyrc
vendored
Normal file
5
dashboard-ui/bower_components/page.js/.jsbeautifyrc
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"indent_size": 2,
|
||||||
|
"indent_char": " ",
|
||||||
|
"indent_with_tabs": false
|
||||||
|
}
|
23
dashboard-ui/bower_components/page.js/.jshintrc
vendored
Normal file
23
dashboard-ui/bower_components/page.js/.jshintrc
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"browser": true,
|
||||||
|
"node":true,
|
||||||
|
"expr": true,
|
||||||
|
"laxcomma": true,
|
||||||
|
"-W079": true,
|
||||||
|
"-W014": true,
|
||||||
|
"curly": false,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"immed": true,
|
||||||
|
"latedef": true,
|
||||||
|
"newcap": true,
|
||||||
|
"noarg": true,
|
||||||
|
"quotmark": "single",
|
||||||
|
"regexp": true,
|
||||||
|
"undef": true,
|
||||||
|
"unused": false,
|
||||||
|
"strict": true,
|
||||||
|
"trailing": false,
|
||||||
|
"smarttabs": true,
|
||||||
|
"latedef": false,
|
||||||
|
"indent": 2
|
||||||
|
}
|
23
dashboard-ui/bower_components/page.js/bower.json
vendored
Normal file
23
dashboard-ui/bower_components/page.js/bower.json
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"name": "page",
|
||||||
|
"description": "Tiny client-side router",
|
||||||
|
"keywords": ["page", "route", "router", "routes", "pushState"],
|
||||||
|
"main": "page.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/visionmedia/page.js"
|
||||||
|
},
|
||||||
|
"ignore": [
|
||||||
|
".gitignore",
|
||||||
|
".npmignore",
|
||||||
|
".travis.yml",
|
||||||
|
"component.json",
|
||||||
|
"examples",
|
||||||
|
"History.md",
|
||||||
|
"Makefile",
|
||||||
|
"package.json",
|
||||||
|
"Readme.md",
|
||||||
|
"test"
|
||||||
|
],
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
619
dashboard-ui/bower_components/page.js/index.js
vendored
Normal file
619
dashboard-ui/bower_components/page.js/index.js
vendored
Normal file
|
@ -0,0 +1,619 @@
|
||||||
|
/* globals require, module */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var pathtoRegexp = require('path-to-regexp');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect click event
|
||||||
|
*/
|
||||||
|
var clickEvent = ('undefined' !== typeof document) && document.ontouchstart ? 'touchstart' : 'click';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To work properly with the URL
|
||||||
|
* history.location generated polyfill in https://github.com/devote/HTML5-History-API
|
||||||
|
*/
|
||||||
|
|
||||||
|
var location = ('undefined' !== typeof window) && (window.history.location || window.location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform initial dispatch.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var dispatch = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode URL components (query string, pathname, hash).
|
||||||
|
* Accommodates both regular percent encoding and x-www-form-urlencoded format.
|
||||||
|
*/
|
||||||
|
var decodeURLComponents = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base path.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var base = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Running flag.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var running;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HashBang option
|
||||||
|
*/
|
||||||
|
|
||||||
|
var hashbang = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Previous context, for capturing
|
||||||
|
* page exit events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var prevContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register `path` with callback `fn()`,
|
||||||
|
* or route `path`, or redirection,
|
||||||
|
* or `page.start()`.
|
||||||
|
*
|
||||||
|
* page(fn);
|
||||||
|
* page('*', fn);
|
||||||
|
* page('/user/:id', load, user);
|
||||||
|
* page('/user/' + user.id, { some: 'thing' });
|
||||||
|
* page('/user/' + user.id);
|
||||||
|
* page('/from', '/to')
|
||||||
|
* page();
|
||||||
|
*
|
||||||
|
* @param {String|Function} path
|
||||||
|
* @param {Function} fn...
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function page(path, fn) {
|
||||||
|
// <callback>
|
||||||
|
if ('function' === typeof path) {
|
||||||
|
return page('*', path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// route <path> to <callback ...>
|
||||||
|
if ('function' === typeof fn) {
|
||||||
|
var route = new Route(path);
|
||||||
|
for (var i = 1; i < arguments.length; ++i) {
|
||||||
|
page.callbacks.push(route.middleware(arguments[i]));
|
||||||
|
}
|
||||||
|
// show <path> with [state]
|
||||||
|
} else if ('string' === typeof path) {
|
||||||
|
page['string' === typeof fn ? 'redirect' : 'show'](path, fn);
|
||||||
|
// start [options]
|
||||||
|
} else {
|
||||||
|
page.start(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.callbacks = [];
|
||||||
|
page.exits = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current path being processed
|
||||||
|
* @type {String}
|
||||||
|
*/
|
||||||
|
page.current = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of pages navigated to.
|
||||||
|
* @type {number}
|
||||||
|
*
|
||||||
|
* page.len == 0;
|
||||||
|
* page('/login');
|
||||||
|
* page.len == 1;
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.len = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get or set basepath to `path`.
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.base = function(path) {
|
||||||
|
if (0 === arguments.length) return base;
|
||||||
|
base = path;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind with the given `options`.
|
||||||
|
*
|
||||||
|
* Options:
|
||||||
|
*
|
||||||
|
* - `click` bind to click events [true]
|
||||||
|
* - `popstate` bind to popstate [true]
|
||||||
|
* - `dispatch` perform initial dispatch [true]
|
||||||
|
*
|
||||||
|
* @param {Object} options
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.start = function(options) {
|
||||||
|
options = options || {};
|
||||||
|
if (running) return;
|
||||||
|
running = true;
|
||||||
|
if (false === options.dispatch) dispatch = false;
|
||||||
|
if (false === options.decodeURLComponents) decodeURLComponents = false;
|
||||||
|
if (false !== options.popstate) window.addEventListener('popstate', onpopstate, false);
|
||||||
|
if (false !== options.click) {
|
||||||
|
document.addEventListener(clickEvent, onclick, false);
|
||||||
|
}
|
||||||
|
if (true === options.hashbang) hashbang = true;
|
||||||
|
if (!dispatch) return;
|
||||||
|
var url = (hashbang && ~location.hash.indexOf('#!')) ? location.hash.substr(2) + location.search : location.pathname + location.search + location.hash;
|
||||||
|
page.replace(url, null, true, dispatch);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unbind click and popstate event handlers.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.stop = function() {
|
||||||
|
if (!running) return;
|
||||||
|
page.current = '';
|
||||||
|
page.len = 0;
|
||||||
|
running = false;
|
||||||
|
document.removeEventListener(clickEvent, onclick, false);
|
||||||
|
window.removeEventListener('popstate', onpopstate, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show `path` with optional `state` object.
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* @param {Object} state
|
||||||
|
* @param {Boolean} dispatch
|
||||||
|
* @return {Context}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.show = function(path, state, dispatch, push) {
|
||||||
|
var ctx = new Context(path, state);
|
||||||
|
page.current = ctx.path;
|
||||||
|
if (false !== dispatch) page.dispatch(ctx);
|
||||||
|
if (false !== ctx.handled && false !== push) ctx.pushState();
|
||||||
|
return ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Goes back in the history
|
||||||
|
* Back should always let the current route push state and then go back.
|
||||||
|
*
|
||||||
|
* @param {String} path - fallback path to go back if no more history exists, if undefined defaults to page.base
|
||||||
|
* @param {Object} [state]
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.back = function(path, state) {
|
||||||
|
if (page.len > 0) {
|
||||||
|
// this may need more testing to see if all browsers
|
||||||
|
// wait for the next tick to go back in history
|
||||||
|
history.back();
|
||||||
|
page.len--;
|
||||||
|
} else if (path) {
|
||||||
|
setTimeout(function() {
|
||||||
|
page.show(path, state);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
setTimeout(function() {
|
||||||
|
page.show(base, state);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register route to redirect from one path to other
|
||||||
|
* or just redirect to another route
|
||||||
|
*
|
||||||
|
* @param {String} from - if param 'to' is undefined redirects to 'from'
|
||||||
|
* @param {String} [to]
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
page.redirect = function(from, to) {
|
||||||
|
// Define route from a path to another
|
||||||
|
if ('string' === typeof from && 'string' === typeof to) {
|
||||||
|
page(from, function(e) {
|
||||||
|
setTimeout(function() {
|
||||||
|
page.replace(to);
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for the push state and replace it with another
|
||||||
|
if ('string' === typeof from && 'undefined' === typeof to) {
|
||||||
|
setTimeout(function() {
|
||||||
|
page.replace(from);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace `path` with optional `state` object.
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* @param {Object} state
|
||||||
|
* @return {Context}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
page.replace = function(path, state, init, dispatch) {
|
||||||
|
var ctx = new Context(path, state);
|
||||||
|
page.current = ctx.path;
|
||||||
|
ctx.init = init;
|
||||||
|
ctx.save(); // save before dispatching, which may redirect
|
||||||
|
if (false !== dispatch) page.dispatch(ctx);
|
||||||
|
return ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch the given `ctx`.
|
||||||
|
*
|
||||||
|
* @param {Object} ctx
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.dispatch = function(ctx) {
|
||||||
|
var prev = prevContext,
|
||||||
|
i = 0,
|
||||||
|
j = 0;
|
||||||
|
|
||||||
|
prevContext = ctx;
|
||||||
|
|
||||||
|
function nextExit() {
|
||||||
|
var fn = page.exits[j++];
|
||||||
|
if (!fn) return nextEnter();
|
||||||
|
fn(prev, nextExit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextEnter() {
|
||||||
|
var fn = page.callbacks[i++];
|
||||||
|
|
||||||
|
if (ctx.path !== page.current) {
|
||||||
|
ctx.handled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!fn) return unhandled(ctx);
|
||||||
|
fn(ctx, nextEnter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev) {
|
||||||
|
nextExit();
|
||||||
|
} else {
|
||||||
|
nextEnter();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unhandled `ctx`. When it's not the initial
|
||||||
|
* popstate then redirect. If you wish to handle
|
||||||
|
* 404s on your own use `page('*', callback)`.
|
||||||
|
*
|
||||||
|
* @param {Context} ctx
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function unhandled(ctx) {
|
||||||
|
if (ctx.handled) return;
|
||||||
|
var current;
|
||||||
|
|
||||||
|
if (hashbang) {
|
||||||
|
current = base + location.hash.replace('#!', '');
|
||||||
|
} else {
|
||||||
|
current = location.pathname + location.search;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current === ctx.canonicalPath) return;
|
||||||
|
page.stop();
|
||||||
|
ctx.handled = false;
|
||||||
|
location.href = ctx.canonicalPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an exit route on `path` with
|
||||||
|
* callback `fn()`, which will be called
|
||||||
|
* on the previous context when a new
|
||||||
|
* page is visited.
|
||||||
|
*/
|
||||||
|
page.exit = function(path, fn) {
|
||||||
|
if (typeof path === 'function') {
|
||||||
|
return page.exit('*', path);
|
||||||
|
}
|
||||||
|
|
||||||
|
var route = new Route(path);
|
||||||
|
for (var i = 1; i < arguments.length; ++i) {
|
||||||
|
page.exits.push(route.middleware(arguments[i]));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove URL encoding from the given `str`.
|
||||||
|
* Accommodates whitespace in both x-www-form-urlencoded
|
||||||
|
* and regular percent-encoded form.
|
||||||
|
*
|
||||||
|
* @param {str} URL component to decode
|
||||||
|
*/
|
||||||
|
function decodeURLEncodedURIComponent(val) {
|
||||||
|
if (typeof val !== 'string') { return val; }
|
||||||
|
return decodeURLComponents ? decodeURIComponent(val.replace(/\+/g, ' ')) : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a new "request" `Context`
|
||||||
|
* with the given `path` and optional initial `state`.
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* @param {Object} state
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Context(path, state) {
|
||||||
|
if ('/' === path[0] && 0 !== path.indexOf(base)) path = base + (hashbang ? '#!' : '') + path;
|
||||||
|
var i = path.indexOf('?');
|
||||||
|
|
||||||
|
this.canonicalPath = path;
|
||||||
|
this.path = path.replace(base, '') || '/';
|
||||||
|
if (hashbang) this.path = this.path.replace('#!', '') || '/';
|
||||||
|
|
||||||
|
this.title = document.title;
|
||||||
|
this.state = state || {};
|
||||||
|
this.state.path = path;
|
||||||
|
this.querystring = ~i ? decodeURLEncodedURIComponent(path.slice(i + 1)) : '';
|
||||||
|
this.pathname = decodeURLEncodedURIComponent(~i ? path.slice(0, i) : path);
|
||||||
|
this.params = {};
|
||||||
|
|
||||||
|
// fragment
|
||||||
|
this.hash = '';
|
||||||
|
if (!hashbang) {
|
||||||
|
if (!~this.path.indexOf('#')) return;
|
||||||
|
var parts = this.path.split('#');
|
||||||
|
this.path = parts[0];
|
||||||
|
this.hash = decodeURLEncodedURIComponent(parts[1]) || '';
|
||||||
|
this.querystring = this.querystring.split('#')[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose `Context`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.Context = Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push state.
|
||||||
|
*
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Context.prototype.pushState = function() {
|
||||||
|
page.len++;
|
||||||
|
history.pushState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the context state.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Context.prototype.save = function() {
|
||||||
|
history.replaceState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize `Route` with the given HTTP `path`,
|
||||||
|
* and an array of `callbacks` and `options`.
|
||||||
|
*
|
||||||
|
* Options:
|
||||||
|
*
|
||||||
|
* - `sensitive` enable case-sensitive routes
|
||||||
|
* - `strict` enable strict matching for trailing slashes
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* @param {Object} options.
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Route(path, options) {
|
||||||
|
options = options || {};
|
||||||
|
this.path = (path === '*') ? '(.*)' : path;
|
||||||
|
this.method = 'GET';
|
||||||
|
this.regexp = pathtoRegexp(this.path,
|
||||||
|
this.keys = [],
|
||||||
|
options.sensitive,
|
||||||
|
options.strict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose `Route`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
page.Route = Route;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return route middleware with
|
||||||
|
* the given callback `fn()`.
|
||||||
|
*
|
||||||
|
* @param {Function} fn
|
||||||
|
* @return {Function}
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
Route.prototype.middleware = function(fn) {
|
||||||
|
var self = this;
|
||||||
|
return function(ctx, next) {
|
||||||
|
if (self.match(ctx.path, ctx.params)) return fn(ctx, next);
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this route matches `path`, if so
|
||||||
|
* populate `params`.
|
||||||
|
*
|
||||||
|
* @param {String} path
|
||||||
|
* @param {Object} params
|
||||||
|
* @return {Boolean}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
Route.prototype.match = function(path, params) {
|
||||||
|
var keys = this.keys,
|
||||||
|
qsIndex = path.indexOf('?'),
|
||||||
|
pathname = ~qsIndex ? path.slice(0, qsIndex) : path,
|
||||||
|
m = this.regexp.exec(decodeURIComponent(pathname));
|
||||||
|
|
||||||
|
if (!m) return false;
|
||||||
|
|
||||||
|
for (var i = 1, len = m.length; i < len; ++i) {
|
||||||
|
var key = keys[i - 1];
|
||||||
|
var val = decodeURLEncodedURIComponent(m[i]);
|
||||||
|
if (val !== undefined || !(hasOwnProperty.call(params, key.name))) {
|
||||||
|
params[key.name] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "populate" events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var onpopstate = (function () {
|
||||||
|
var loaded = false;
|
||||||
|
if ('undefined' === typeof window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (document.readyState === 'complete') {
|
||||||
|
loaded = true;
|
||||||
|
} else {
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
loaded = true;
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return function onpopstate(e) {
|
||||||
|
if (!loaded) return;
|
||||||
|
if (e.state) {
|
||||||
|
var path = e.state.path;
|
||||||
|
page.replace(path, e.state);
|
||||||
|
} else {
|
||||||
|
page.show(location.pathname + location.hash, undefined, undefined, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
/**
|
||||||
|
* Handle "click" events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onclick(e) {
|
||||||
|
|
||||||
|
if (1 !== which(e)) return;
|
||||||
|
|
||||||
|
if (e.metaKey || e.ctrlKey || e.shiftKey) return;
|
||||||
|
if (e.defaultPrevented) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ensure link
|
||||||
|
var el = e.target;
|
||||||
|
while (el && 'A' !== el.nodeName) el = el.parentNode;
|
||||||
|
if (!el || 'A' !== el.nodeName) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Ignore if tag has
|
||||||
|
// 1. "download" attribute
|
||||||
|
// 2. rel="external" attribute
|
||||||
|
if (el.hasAttribute('download') || el.getAttribute('rel') === 'external') return;
|
||||||
|
|
||||||
|
// ensure non-hash for the same path
|
||||||
|
var link = el.getAttribute('href');
|
||||||
|
if (!hashbang && el.pathname === location.pathname && (el.hash || '#' === link)) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Check for mailto: in the href
|
||||||
|
if (link && link.indexOf('mailto:') > -1) return;
|
||||||
|
|
||||||
|
// check target
|
||||||
|
if (el.target) return;
|
||||||
|
|
||||||
|
// x-origin
|
||||||
|
if (!sameOrigin(el.href)) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// rebuild path
|
||||||
|
var path = el.pathname + el.search + (el.hash || '');
|
||||||
|
|
||||||
|
// strip leading "/[drive letter]:" on NW.js on Windows
|
||||||
|
if (typeof process !== 'undefined' && path.match(/^\/[a-zA-Z]:\//)) {
|
||||||
|
path = path.replace(/^\/[a-zA-Z]:\//, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
// same page
|
||||||
|
var orig = path;
|
||||||
|
|
||||||
|
if (path.indexOf(base) === 0) {
|
||||||
|
path = path.substr(base.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashbang) path = path.replace('#!', '');
|
||||||
|
|
||||||
|
if (base && orig === path) return;
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
page.show(orig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event button.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function which(e) {
|
||||||
|
e = e || window.event;
|
||||||
|
return null === e.which ? e.button : e.which;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if `href` is the same origin.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function sameOrigin(href) {
|
||||||
|
var origin = location.protocol + '//' + location.hostname;
|
||||||
|
if (location.port) origin += ':' + location.port;
|
||||||
|
return (href && (0 === href.indexOf(origin)));
|
||||||
|
}
|
||||||
|
|
||||||
|
page.sameOrigin = sameOrigin;
|
1184
dashboard-ui/bower_components/page.js/page.js
vendored
Normal file
1184
dashboard-ui/bower_components/page.js/page.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -45,7 +45,7 @@
|
||||||
"tag": "v1.0.11",
|
"tag": "v1.0.11",
|
||||||
"commit": "e3c1ab0c72905b58fb4d9adc2921ea73b5c085a5"
|
"commit": "e3c1ab0c72905b58fb4d9adc2921ea73b5c085a5"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/polymerelements/paper-behaviors.git",
|
"_source": "git://github.com/PolymerElements/paper-behaviors.git",
|
||||||
"_target": "^1.0.0",
|
"_target": "^1.0.0",
|
||||||
"_originalSource": "polymerelements/paper-behaviors"
|
"_originalSource": "PolymerElements/paper-behaviors"
|
||||||
}
|
}
|
|
@ -32,14 +32,14 @@
|
||||||
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0"
|
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0"
|
||||||
},
|
},
|
||||||
"ignore": [],
|
"ignore": [],
|
||||||
"homepage": "https://github.com/polymerelements/paper-ripple",
|
"homepage": "https://github.com/PolymerElements/paper-ripple",
|
||||||
"_release": "1.0.5",
|
"_release": "1.0.5",
|
||||||
"_resolution": {
|
"_resolution": {
|
||||||
"type": "version",
|
"type": "version",
|
||||||
"tag": "v1.0.5",
|
"tag": "v1.0.5",
|
||||||
"commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5"
|
"commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5"
|
||||||
},
|
},
|
||||||
"_source": "git://github.com/polymerelements/paper-ripple.git",
|
"_source": "git://github.com/PolymerElements/paper-ripple.git",
|
||||||
"_target": "^1.0.0",
|
"_target": "^1.0.0",
|
||||||
"_originalSource": "polymerelements/paper-ripple"
|
"_originalSource": "PolymerElements/paper-ripple"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue