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

Version Path
envjs19-0.3.8.20101029121421 src/window/history.js
envjs-0.3.8 src/window/history.js
envjs-0.3.7 src/window/history.js
envjs-0.3.6 src/window/history.js
envjs-0.3.5 src/window/history.js
envjs-0.3.4 src/window/history.js
envjs-0.3.3 src/window/history.js
envjs-0.3.2 src/window/history.js
envjs-0.3.1 src/window/history.js
envjs-0.3.0 src/window/history.js
envjs-0.2.0 src/window/history.js