Skip to content

Commit

Permalink
history was calling memnber function incorrectly, resulting in callin…
Browse files Browse the repository at this point in the history
…g an undefined function
  • Loading branch information
client9 committed Apr 3, 2010
1 parent 08e50f8 commit 15e5abc
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions src/window/history.js
Expand Up @@ -4,71 +4,73 @@
*
*/

History = function(owner){
History = function(owner) {
var $current = 0,
$history = [null],
$owner = owner;

return {
get length(){
return $history.length;
},
back : function(count){
if(count){
go(-count);
}else{
go(-1);
}
},
get current(){
return this.item($current);
},
get previous(){
return this.item($current-1);
},
forward : function(count){
if(count){
go(count);
}else{go(1);}
},
go : function(target){
if(typeof target == "number"){
go : function(target) {
if (typeof target == "number") {
target = $current + target;
if(target > -1 && target < $history.length){
if($history[target].type == "hash"){
if($owner.location){
if (target > -1 && target < $history.length){
if ($history[target].type == "hash") {
if ($owner.location) {
$owner.location.hash = $history[target].value;
}
}else{
if($owner.location){
} else {
if ($owner.location) {
$owner.location = $history[target].value;
}
}
$current = target;
}
}else{
} else {
//TODO: walk through the history and find the 'best match'?
}
},
item: function(index){
if(index < history.length) {
get length() {
return $history.length;
},
back : function(count) {
if (count) {
this.go(-count);
} else {
this.go(-1);
}
},
get current() {
return this.item($current);
},
get previous() {
return this.item($current-1);
},
forward : function(count) {
if (count) {
this.go(count);
} else {
this.go(1);
}
},
item: function(index) {
if (index < history.length) {
return $history[index];
} else {
return null;
}
},

add: function(newLocation, type){
add: function(newLocation, type) {
//not a standard interface, we expose it to simplify
//history state modifications
if(newLocation !== $history[$current]){
if (newLocation !== $history[$current]) {
$history.slice(0, $current);
$history.push({
type: type||"href",
value: value
});
}
}
};
}; /* closes 'return {' */
};

0 comments on commit 15e5abc

Please sign in to comment.