Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: bower_components/app-router/app-router.html

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bower_components/app-router/README.md ('k') | bower_components/app-router/app-router.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!-- Copyright (C) 2014 Erik Ringsmuth - MIT license -->
2 <script type="text/javascript">
3 !function(t,e){function i(t,i,r){var n=e.createEvent("CustomEvent");return n.ini tCustomEvent(t,!1,!0,i),r.dispatchEvent(n)}e.registerElement("app-route",{protot ype:Object.create(HTMLElement.prototype)}),e.registerElement("active-route",{pro totype:Object.create(HTMLElement.prototype)});var r=Object.create(HTMLElement.pr ototype),n={},a="ActiveXObject"in t;r.attachedCallback=function(){"manual"!==thi s.getAttribute("init")&&this.init()},r.init=function(){this.isInitialized||(this .isInitialized=!0,this.activeRoute=e.createElement("app-route"),this.stateChange Handler=this.go.bind(this),t.addEventListener("popstate",this.stateChangeHandler ,!1),a&&t.addEventListener("hashchange",this.stateChangeHandler,!1),this.activeR outeContent=e.createElement("active-route"),this.appendChild(this.activeRouteCon tent),this.hasAttribute("shadow")&&(this.activeRouteContent=this.activeRouteCont ent.createShadowRoot()),this.go())},r.detachedCallback=function(){t.removeEventL istener("popstate",this.stateChangeHandler,!1),a&&t.removeEventListener("hashcha nge",this.stateChangeHandler,!1)},r.go=function(){var e=this.parseUrlPath(t.loca tion.href),r={path:e};if(i("state-change",r,this)){for(var n=this.querySelectorA ll("app-route"),a=0;a<n.length;a++)if(this.testRoute(n[a].getAttribute("path"),e ,this.getAttribute("trailingSlash"),n[a].hasAttribute("regex")))return void this .activateRoute(n[a],e);i("not-found",r,this)}},r.activateRoute=function(t,e){var r={path:e,route:t,oldRoute:this.activeRoute};if(i("activate-route-start",r,this )&&i("activate-route-start",r,t)){this.activeRoute.removeAttribute("active"),t.s etAttribute("active","active"),this.activeRoute=t;var n=t.getAttribute("import") ,a=t.getAttribute("path"),s=t.hasAttribute("regex"),o=t.getAttribute("element"), c=t.hasAttribute("template"),l=!c;l&&n?this.importAndActivateCustomElement(n,o,a ,e,s,r):l&&!n&&o?this.activateCustomElement(o,a,e,s,r):c&&n?this.importAndActiva teTemplate(n,t,r):c&&!n&&this.activateTemplate(t,r)}},r.importAndActivateCustomE lement=function(t,i,r,a,s,o){if(!n.hasOwnProperty(t)){n[t]=!0;var c=e.createElem ent("link");c.setAttribute("rel","import"),c.setAttribute("href",t),e.head.appen dChild(c)}this.activateCustomElement(i||t.split("/").slice(-1)[0].replace(".html ",""),r,a,s,o)},r.activateCustomElement=function(i,r,n,a,s){var o=e.createElemen t(i),c=this.routeArguments(r,n,t.location.href,a);for(var l in c)c.hasOwnPropert y(l)&&(o[l]=c[l]);this.activeElement(o,s)},r.importAndActivateTemplate=function( t,i,r){if(n.hasOwnProperty(t)){var a=e.querySelector('link[href="'+t+'"]');a.imp ort?this.activeElement(e.importNode(a.import.querySelector("template").content,! 0),r):a.onload=function(){i.hasAttribute("active")&&this.activeElement(e.importN ode(a.import.querySelector("template").content,!0),r)}.bind(this)}else{n[t]=!0;v ar s=e.createElement("link");s.setAttribute("rel","import"),s.setAttribute("href ",t),s.onload=function(){i.hasAttribute("active")&&this.activeElement(e.importNo de(s.import.querySelector("template").content,!0),r)}.bind(this),e.head.appendCh ild(s)}},r.activateTemplate=function(t,i){var r=e.importNode(t.querySelector("te mplate").content,!0);this.activeElement(r,i)},r.activeElement=function(t,e){for( ;this.activeRouteContent.firstChild;)this.activeRouteContent.removeChild(this.ac tiveRouteContent.firstChild);this.activeRouteContent.appendChild(t),i("activate- route-end",e,this),i("activate-route-end",e,e.route)},r.parseUrlPath=function(t) {var e=t.split("/"),i="/"+e.splice(3,e.length-3).join("/"),r=i.split(/[\?#]/)[0] ,n=i.indexOf("#");if(-1!==n){var a=i.substring(n).split("?")[0];"#/"===a.substri ng(0,2)?r=a.substring(1):"#!/"===a.substring(0,3)&&(r=a.substring(2))}return r}, r.testRoute=function(t,e,i,r){if("ignore"===i&&("/"===e.slice(-1)&&(e=e.slice(0, -1)),"/"!==t.slice(-1)||r||(t=t.slice(0,-1))),r){if("/"!==t.charAt(0))return!1;t =t.slice(1);var n="";if("/"===t.slice(-1))t=t.slice(0,-1);else{if("/i"!==t.slice (-2))return!1;t=t.slice(0,-2),n="i"}return new RegExp(t,n).test(e)}if(t===e||"*" ===t)return!0;if(-1===t.indexOf("*")&&-1===t.indexOf(":"))return!1;var a=e.split ("/"),s=t.split("/");if(a.length!==s.length)return!1;for(var o=0;o<s.length;o++) {var c=s[o];if(c!==a[o]&&"*"!==c&&":"!==c.charAt(0))return!1}return!0},r.routeAr guments=function(t,e,i,r){var n={},a=e.split("/");if(!r)for(var s=t.split("/"),o =0;o<s.length;o++){var c=s[o];":"===c.charAt(0)&&(n[c.substring(1)]=a[o])}var l= i.indexOf("?"),h="";if(-1!==l){h=i.substring(l);var u=h.indexOf("#");-1!==u&&(h= h.substring(0,u))}var v=i.indexOf("#/"),p=i.indexOf("#!/");if(-1!==v||-1!==p){va r m="";m=i.substring(-1!==v?v:p),l=m.indexOf("?"),-1!==l&&(h=m.substring(l))}var d=h.substring(1).split("&");1===d.length&&""===d[0]&&(d=[]);for(var f=0;f<d.len gth;f++){var g=d[f],b=g.split("=");n[b[0]]=b.splice(1,b.length-1).join("=")}for( var A in n){var E=n[A];n[A]="true"===E?!0:"false"===E?!1:isNaN(E)||""===E?decode URIComponent(E):+E}return n},e.registerElement("app-router",{prototype:r})}(wind ow,document);
4 </script>
OLDNEW
« no previous file with comments | « bower_components/app-router/README.md ('k') | bower_components/app-router/app-router.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698