bundles/org.eclipse.orion.client.git/web/orion/git/uiUtil.js
function createCompareWidget(serviceRegistry, commandService, resource, hasConflicts, parentDivId, commandSpanId, editableInComparePage, gridRenderer, compareTo, toggleCommandSpanId, 
								 preferencesService, saveCmdContainerId, saveCmdId, titleIds, containerModel, standAloneOptions) {
		var setCompareSelection = function(diffProvider, cmdProvider, ignoreWhitespace, type) {
				var comparerOptions = {
				toggleable: true,
				type: type, //$NON-NLS-0$ //From user preference
				ignoreWhitespace: ignoreWhitespace,//From user reference
				readonly: !saveCmdContainerId || !editableInComparePage,
				hasConflicts: hasConflicts,
				diffProvider: diffProvider,
				resource: resource,
				compareTo: compareTo,
				saveLeft: {	saveCmdContainerId: saveCmdContainerId, saveCmdId: saveCmdId, titleIds: titleIds},
				editableInComparePage: editableInComparePage,
				standAlone: (standAloneOptions ? true : false)
			};
			var viewOptions = {
				parentDivId: parentDivId,
				commandProvider: cmdProvider,
				highlighters: (standAloneOptions ? standAloneOptions.highlighters : null)
			};
			var comparer = new mResourceComparer.ResourceComparer(serviceRegistry, commandService, comparerOptions, viewOptions);
			if(containerModel) {
				containerModel.resourceComparer = comparer;
				containerModel.destroy = function() {
					this.resourceComparer.destroy();
				};
			}
			comparer.start().then(function(maxHeight) {
				var vH = 420;
				if (maxHeight < vH) {
					vH = maxHeight;
				}
				var diffContainer = lib.node(parentDivId);
				diffContainer.style.height = vH + "px"; //$NON-NLS-0$
			});
		};
		
		var diffProvider = new mResourceComparer.DefaultDiffProvider(serviceRegistry);
		var cmdProvider = new mCompareCommands.CompareCommandFactory({commandService: commandService, commandSpanId: commandSpanId, toggleCommandSpanId: toggleCommandSpanId, gridRenderer: gridRenderer, serviceRegistry: serviceRegistry});
		var ignoreWhitespace = false;
		var mode = "inline";  //$NON-NLS-0$
		if (preferencesService) {
			cmdProvider.addEventListener("compareConfigChanged", function(e) { //$NON-NLS-0$
				var data;
				switch (e.name) {
					case "mode":  //$NON-NLS-0$
						data = {mode: e.value};
					break;
					case "ignoreWhiteSpace":  //$NON-NLS-0$
						data = {ignoreWhitespace: e.value};
					break;
				}
				if (data) {
					preferencesService.put("/git/compareSettings", data); //$NON-NLS-1$
				}
			}.bind(this));
			preferencesService.get("/git/compareSettings").then(function(prefs) {  //$NON-NLS-0$
				ignoreWhitespace = prefs["ignoreWhitespace"] || ignoreWhitespace; //$NON-NLS-0$
				mode =  prefs["mode"] || mode; //$NON-NLS-0$
				setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
			});
		} else {
			setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
		}
	}
function createCompareWidget(serviceRegistry, commandService, resource, hasConflicts, parentDivId, commandSpanId, editableInComparePage, gridRenderer, compareTo, toggleCommandSpanId, 
								 preferencesService, saveCmdContainerId, saveCmdId, titleIds, containerModel, standAloneOptions) {
		var setCompareSelection = function(diffProvider, cmdProvider, ignoreWhitespace, type) {
				var comparerOptions = {
				toggleable: true,
				type: type, //$NON-NLS-0$ //From user preference
				ignoreWhitespace: ignoreWhitespace,//From user reference
				readonly: !saveCmdContainerId || !editableInComparePage,
				hasConflicts: hasConflicts,
				diffProvider: diffProvider,
				resource: resource,
				compareTo: compareTo,
				saveLeft: {	saveCmdContainerId: saveCmdContainerId, saveCmdId: saveCmdId, titleIds: titleIds},
				editableInComparePage: editableInComparePage,
				standAlone: (standAloneOptions ? true : false)
			};
			var viewOptions = {
				parentDivId: parentDivId,
				commandProvider: cmdProvider,
				highlighters: (standAloneOptions ? standAloneOptions.highlighters : null)
			};
			var comparer = new mResourceComparer.ResourceComparer(serviceRegistry, commandService, comparerOptions, viewOptions);
			if(containerModel) {
				containerModel.resourceComparer = comparer;
				containerModel.destroy = function() {
					this.resourceComparer.destroy();
				};
			}
			comparer.start().then(function(maxHeight) {
				var vH = 420;
				if (maxHeight < vH) {
					vH = maxHeight;
				}
				var diffContainer = lib.node(parentDivId);
				diffContainer.style.height = vH + "px"; //$NON-NLS-0$
			});
		};
		
		var diffProvider = new mResourceComparer.DefaultDiffProvider(serviceRegistry);
		var cmdProvider = new mCompareCommands.CompareCommandFactory({commandService: commandService, commandSpanId: commandSpanId, toggleCommandSpanId: toggleCommandSpanId, gridRenderer: gridRenderer, serviceRegistry: serviceRegistry});
		var ignoreWhitespace = false;
		var mode = "inline";  //$NON-NLS-0$
		if (preferencesService) {
			cmdProvider.addEventListener("compareConfigChanged", function(e) { //$NON-NLS-0$
				var data;
				switch (e.name) {
					case "mode":  //$NON-NLS-0$
						data = {mode: e.value};
					break;
					case "ignoreWhiteSpace":  //$NON-NLS-0$
						data = {ignoreWhitespace: e.value};
					break;
				}
				if (data) {
					preferencesService.put("/git/compareSettings", data); //$NON-NLS-1$
				}
			}.bind(this));
			preferencesService.get("/git/compareSettings").then(function(prefs) {  //$NON-NLS-0$
				ignoreWhitespace = prefs["ignoreWhitespace"] || ignoreWhitespace; //$NON-NLS-0$
				mode =  prefs["mode"] || mode; //$NON-NLS-0$
				setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
			});
		} else {
			setCompareSelection(diffProvider, cmdProvider, ignoreWhitespace, mode);
		}
	}
function createCompareWidget ( serviceRegistry , commandService , resource , hasConflicts , parentDivId , commandSpanId , editableInComparePage , gridRenderer , compareTo , toggleCommandSpanId , preferencesService , saveCmdContainerId , saveCmdId , titleIds , containerModel , standAloneOptions ) { var setCompareSelection = function ( diffProvider , cmdProvider , ignoreWhitespace , type ) { var comparerOptions = { toggleable : true , type : type , //$NON-NLS-0$ //From user preference ignoreWhitespace : ignoreWhitespace , //From user reference readonly : ! saveCmdContainerId || ! editableInComparePage , hasConflicts : hasConflicts , diffProvider : diffProvider , resource : resource , compareTo : compareTo , saveLeft : { saveCmdContainerId : saveCmdContainerId , saveCmdId : saveCmdId , titleIds : titleIds } , editableInComparePage : editableInComparePage , standAlone : ( standAloneOptions ? true : false ) } ; var viewOptions = { parentDivId : parentDivId , commandProvider : cmdProvider , highlighters : ( standAloneOptions ? standAloneOptions . highlighters : null ) } ; var comparer = new mResourceComparer . ResourceComparer ( serviceRegistry , commandService , comparerOptions , viewOptions ) ; if ( containerModel ) { containerModel . resourceComparer = comparer ; containerModel . destroy = function ( ) { this . resourceComparer . destroy ( ) ; } ; } comparer . start ( ) . then ( function ( maxHeight ) { var vH = 420 ; if ( maxHeight < vH ) { vH = maxHeight ; } var diffContainer = lib . node ( parentDivId ) ; diffContainer . style . height = vH + "px" ; //$NON-NLS-0$ } ) ; } ; var diffProvider = new mResourceComparer . DefaultDiffProvider ( serviceRegistry ) ; var cmdProvider = new mCompareCommands . CompareCommandFactory ( { commandService : commandService , commandSpanId : commandSpanId , toggleCommandSpanId : toggleCommandSpanId , gridRenderer : gridRenderer , serviceRegistry : serviceRegistry } ) ; var ignoreWhitespace = false ; var mode = "inline" ; //$NON-NLS-0$ if ( preferencesService ) { cmdProvider . addEventListener ( "compareConfigChanged" , function ( e ) { //$NON-NLS-0$ var data ; switch ( e . name ) { case "mode" : //$NON-NLS-0$ data = { mode : e . value } ; break ; case "ignoreWhiteSpace" : //$NON-NLS-0$ data = { ignoreWhitespace : e . value } ; break ; } if ( data ) { preferencesService . put ( "/git/compareSettings" , data ) ; //$NON-NLS-1$ } } . bind ( this ) ) ; preferencesService . get ( "/git/compareSettings" ) . then ( function ( prefs ) { //$NON-NLS-0$ ignoreWhitespace = prefs [ "ignoreWhitespace" ] || ignoreWhitespace ; //$NON-NLS-0$ mode = prefs [ "mode" ] || mode ; //$NON-NLS-0$ setCompareSelection ( diffProvider , cmdProvider , ignoreWhitespace , mode ) ; } ) ; } else { setCompareSelection ( diffProvider , cmdProvider , ignoreWhitespace , mode ) ; } }
Create an embedded toggleable compare widget inside a given DIV.
@param {Object} serviceRegistry The serviceRegistry.
@param {Object} commandService The commandService.
@param {String} resoure The URL string of the complex URL which will be resolved by a diff provider into two file URLs and the unified diff.
@param {Boolean} hasConflicts The flag to indicate if the compare contains conflicts.
@param {Object} parentDivId The DIV node or string id of the DIV that holds the compare widget.
@param {String} commandSpanId The id of the DIV where all the commands of the compare view are rendered. "Open in compare page", "toggle", "navigate diff" commands will be rendered.
@param {Boolean} editableInComparePage The flag to indicate if opening compage will be editable on the left side. Default is false. Optional.
@param {Object} gridRenderer If all the commands have to be rendered as grids, especially inside a row of Orion explorer, this has to be provided. Optional.
@param {String} compareTo Optional. If the resource parameter is a simple file URL then this can be used as the second file URI to compare with.
@param {String} toggleCommandSpanId Optional. The id of the DIV where the "toggle" command will be rendered. If this parameter is defined, the "toggle" command will ONLY be rendered in this DIV.
Create an embedded toggleable compare widget inside a given DIV .