Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed Function.prototype.extend

  • Loading branch information...
commit df311ddd7466d180d745342591b43e540bcc68e3 1 parent 3657841
@jvinet authored
Showing with 171 additions and 152 deletions.
  1. +2 −0  README.md
  2. +153 −141 jquery.js
  3. +2 −0  src/base.js
  4. +5 −9 src/history.js
  5. +9 −2 src/util.js
View
2  README.md
@@ -91,6 +91,8 @@ Here are some Javascript frameworks that are much more featureful and mature.
- http://code.google.com/p/trimpath/wiki/TrimJunction
- http://www.sproutcore.com
- http://jamal-mvc.com
+- http://code.quirkey.com/sammy/
+- http://documentcloud.github.com/backbone/
# Doc TODO #
View
294 jquery.js
153 additions, 141 deletions not shown
View
2  src/base.js
@@ -77,6 +77,8 @@
var self = this;
this.state = {}; // any internal state data you may need to store
+
+ console.log("state: "); console.log(this.state);
};
})();
View
14 src/history.js
@@ -71,12 +71,10 @@
* Update the location.href with our special history anchor.
*/
setloc: function(anchor) {
- var href = window.location.href;
- var base = href.indexOf('#') > -1 ? href.substring(0, href.indexOf('#')) : href;
// assemble the new href
- var newhref = base + '#' + Jive.history.current + '|' + anchor;
- Jive.debug("[history] Setting new href: "+newhref);
- window.location.href = newhref;
+ var hash = Jive.history.current + '|' + anchor;
+ Jive.debug("[history] Setting new hash: "+hash);
+ window.location.hash = hash;
},
/**
@@ -93,10 +91,8 @@
return;
}
Jive.debug("[history] Location changed: "+window.location.href);
- // look for the history index in the href anchor
- var href = window.location.href;
- var anchor = href.indexOf('#') > -1 ? href.substring(href.indexOf('#')+1) : '';
- var m = /^([0-9]+)|/.exec(anchor);
+ // look for the history index in the hash
+ var m = /^([0-9]+)|/.exec(window.location.hash);
if(m[1]) Jive.history.go(m[1]);
}
}
View
11 src/util.js
@@ -25,8 +25,15 @@
document.cookie = ck;
}
- Function.prototype.mixin = function(p) {
- jQuery.extend(this.prototype, p.prototype);
+ Function.prototype.extend = function(p) {
+ // handle constructor functions or objects
+ if(typeof p == "object") {
+ jQuery.extend(this.prototype, p);
+ } else {
+ jQuery.extend(this.prototype, new p);
+ }
return this;
}
+ // backwards compat
+ Function.prototype.mixin = Function.prototype.extend;
})();
Please sign in to comment.
Something went wrong with that request. Please try again.