mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-24 16:56:16 -04:00
initial commit
This commit is contained in:
commit
f5b2b47136
46 changed files with 2350 additions and 0 deletions
74
app/elements/routing.html
Normal file
74
app/elements/routing.html
Normal file
|
@ -0,0 +1,74 @@
|
|||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<script src="../bower_components/page/page.js"></script>
|
||||
<script>
|
||||
window.addEventListener('WebComponentsReady', function() {
|
||||
|
||||
// We use Page.js for routing. This is a Micro
|
||||
// client-side router inspired by the Express router
|
||||
// More info: https://visionmedia.github.io/page.js/
|
||||
|
||||
// Removes end / from app.baseUrl which page.base requires for production
|
||||
if (window.location.port === '') { // if production
|
||||
page.base(app.baseUrl.replace(/\/$/, ''));
|
||||
}
|
||||
|
||||
// Middleware
|
||||
function scrollToTop(ctx, next) {
|
||||
app.scrollPageToTop();
|
||||
next();
|
||||
}
|
||||
|
||||
function closeDrawer(ctx, next) {
|
||||
app.closeDrawer();
|
||||
next();
|
||||
}
|
||||
|
||||
// Routes
|
||||
page('*', scrollToTop, closeDrawer, function(ctx, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
page('/', function() {
|
||||
app.route = 'home';
|
||||
});
|
||||
|
||||
page(app.baseUrl, function() {
|
||||
app.route = 'home';
|
||||
});
|
||||
|
||||
page('/users', function() {
|
||||
app.route = 'users';
|
||||
});
|
||||
|
||||
page('/users/:name', function(data) {
|
||||
app.route = 'user-info';
|
||||
app.params = data.params;
|
||||
});
|
||||
|
||||
page('/contact', function() {
|
||||
app.route = 'contact';
|
||||
});
|
||||
|
||||
// 404
|
||||
page('*', function() {
|
||||
app.$.toast.text = 'Can\'t find: ' + window.location.href + '. Redirected you to Home Page';
|
||||
app.$.toast.show();
|
||||
page.redirect(app.baseUrl);
|
||||
});
|
||||
|
||||
// add #! before urls
|
||||
page({
|
||||
hashbang: true
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue