Sha256: 0152d6852d6bfd8e6061a1acf003948dca122332188d60d9f00d27a43c5f2426
Contents?: true
Size: 1.48 KB
Versions: 11
Compression:
Stored size: 1.48 KB
Contents
/* * history.js */ var $currentHistoryIndex = 0; var $history = []; // Browser History $w.__defineGetter__("history", function(){ return { get length(){ return $history.length; }, back : function(count){ if(count){ go(-count); }else{go(-1);} }, forward : function(count){ if(count){ go(count); }else{go(1);} }, go : function(target){ if(typeof target == "number"){ target = $currentHistoryIndex+target; if(target > -1 && target < $history.length){ if($history[target].location == "hash"){ $w.location.hash = $history[target].value; }else{ $w.location = $history[target].value; } $currentHistoryIndex = target; //remove the last item added to the history //since we are moving inside the history $history.pop(); } }else{ //TODO: walk throu the history and find the 'best match' } } }; }); //Here locationPart is the particutlar method/attribute // of the location object that was modified. This allows us // to modify the correct portion of the location object // when we navigate the history var __setHistory__ = function( value, locationPart){ if ( value == "about:blank" ) { return; } $debug("adding value to history: " +value); $currentHistoryIndex++; $history.push({ location: locationPart||"href", value: value }); }; // Local Variables: // espresso-indent-level:4 // c-basic-offset:4 // End:
Version data entries
11 entries across 11 versions & 2 rubygems