Permalink
Browse files

Update URL to include hash

  • Loading branch information...
1 parent 96ab3ea commit ac653be516e789db4f8b8339e642ba361ddd078d @cpojer committed Mar 6, 2012
Showing with 5 additions and 5 deletions.
  1. +1 −1 Demos/other.html
  2. +4 −4 Source/History.js
View
@@ -17,7 +17,7 @@
<div id="more">
<a href="#">Back</a>
<a href="index.html">Load index.html</a>
- <a href="mootools.html">Load mootools.html</a>
+ <a href="mootools.html?s=1#moo">Load mootools.html</a>
</div>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent gravida sollicitudin mi ornare elementum. Vestibulum malesuada, justo eu ornare lacinia, nulla massa vestibulum leo, ac mollis tellus libero id tortor. Donec vitae purus eget ligula laoreet lacinia in quis diam. Etiam ultrices nulla a sapien hendrerit tempus. Suspendisse volutpat ultricies quam, nec mollis ligula gravida non. In consectetur rhoncus sem, quis egestas felis iaculis vitae. Proin condimentum lacus sit amet leo vestibulum interdum. Etiam ultrices, metus at egestas sodales, nunc augue facilisis ante, ac laoreet nulla augue ut arcu. Nullam consectetur, diam eu consectetur tristique, lectus velit vestibulum sapien, in auctor arcu lacus fermentum lacus. Vivamus mi elit, dapibus eget dictum quis, tincidunt sit amet elit. Aenean eget ultricies enim. In ac sapien quis ante condimentum mattis. Aenean venenatis luctus sollicitudin. Suspendisse arcu augue, consequat pretium dapibus quis, hendrerit non tellus.
View
@@ -22,7 +22,7 @@ var events = Element.NativeEvents,
location = window.location,
cleanURL = function(url){
if (url.match(/^https?:\/\//)) url = '/' + url.split('/').slice(3).join('/');
- return url.split('#')[0];
+ return url;
},
base = cleanURL(location.href),
history = window.history,
@@ -51,7 +51,7 @@ this.History = new new Class({
push: hasPushState ? function(url, title, state){
url = cleanURL(url);
if (base && base != url) base = null;
-
+
history.pushState(state || null, title || null, url);
this.onChange(url, state);
} : function(url){
@@ -92,9 +92,9 @@ this.History = new new Class({
forward: function(){
history.forward();
},
-
+
getPath: function(){
- return hasPushState ? cleanURL(location.href) : cleanURL(location.hash.substr(1));
+ return cleanURL(hasPushState ? location.href : location.hash.substr(1));
},
hasPushState: function(){

0 comments on commit ac653be

Please sign in to comment.