Fix indenting offset

2 spaces, not 3
This commit is contained in:
Joshua Peek
2011-09-27 16:26:03 -05:00
parent 095a392359
commit 3a8d65bd3e
@@ -233,7 +233,7 @@
} }
// attempt to load the definition for this language // attempt to load the definition for this language
var script_uri = '/javascript/editor/langs/' + markup_name + '.js'; var script_uri = '/javascripts/editor/langs/' + markup_name + '.js';
$.ajax({ $.ajax({
url: script_uri, url: script_uri,
dataType: 'script', dataType: 'script',
@@ -776,226 +776,215 @@
var Help = { var Help = {
_ACTIVE_HELP: '', _ACTIVE_HELP: '',
_LOADED_HELP_LANGS: [], _LOADED_HELP_LANGS: [],
_HELP: {}, _HELP: {},
/**
* Help.define
*
* Defines a new help context and enables the help function if it
* exists in the Gollum Function Bar.
*
* @param string name The name you're giving to this help context.
* Generally, this should match the language name.
* @param object definitionObject The definition object being loaded from a
* language / help definition file.
* @return void
*/
define: function( name, definitionObject ) {
if ( Help.isValidHelpFormat( definitionObject ) ) {
debug('help is a valid format');
Help._ACTIVE_HELP_LANG = name;
Help._LOADED_HELP_LANGS.push( name );
Help._HELP[name] = definitionObject;
if ( $("#function-help").length ) {
if ( $('#function-help').hasClass('disabled') ) {
$('#function-help').removeClass('disabled');
}
$('#function-help').unbind('click');
$('#function-help').click( Help.evtHelpButtonClick );
// generate help menus
Help.generateHelpMenuFor( name );
}
} else {
if ( $('#function-help').length ) {
$('#function-help').addClass('disabled');
}
}
},
/**
* Help.generateHelpMenuFor
* Generates the markup for the main help menu given a context name.
*
* @param string name The context name.
* @return void
*/
generateHelpMenuFor: function( name ) {
if ( !Help._HELP[name] ) {
debug('Help is not defined for ' + name.toString());
return false;
}
var helpData = Help._HELP[name];
if ( EditorHas.mathJax() && Help.isLoadedFor('mathjax') ) {
debug('Adding MathJax support to help');
// TODO
}
// clear this shiz out
$('#gollum-editor-help-parent').html('');
$('#gollum-editor-help-list').html('');
$('#gollum-editor-help-content').html('');
// go go inefficient algorithm
for ( var i=0; i < helpData.length; i++ ) {
if ( typeof helpData[i] != 'object' ) {
break;
}
var $newLi = $('<li><a href="#" rel="' + i + '">' +
helpData[i].menuName + '</a></li>');
$('#gollum-editor-help-parent').append( $newLi );
if ( i === 0 ) {
// select on first run
$newLi.children('a').addClass('selected');
}
$newLi.children('a').click( Help.evtParentMenuClick );
}
// generate parent submenu on first run
Help.generateSubMenu( helpData[0], 0 );
$($('#gollum-editor-help-list li a').get(0)).click();
},
/**
* Help.generateSubMenu
* Generates the markup for the inline help sub-menu given the data
* object for the submenu and the array index to start at.
*
* @param object subData The data for the sub-menu.
* @param integer index The index clicked on (parent menu index).
* @return void
*/
generateSubMenu: function( subData, index ) {
$('#gollum-editor-help-list').html('');
$('#gollum-editor-help-content').html('');
for ( var i=0; i < subData.content.length; i++ ) {
if ( typeof subData.content[i] != 'object' ) {
break;
}
var $subLi = $('<li><a href="#" rel="' + index + ':' + i + '">' +
subData.content[i].menuName + '</a></li>');
/** $('#gollum-editor-help-list').append( $subLi );
* Help.define $subLi.children('a').click( Help.evtSubMenuClick );
* }
* Defines a new help context and enables the help function if it },
* exists in the Gollum Function Bar.
*
* @param string name The name you're giving to this help context.
* Generally, this should match the language name.
* @param object definitionObject The definition object being loaded from a
* language / help definition file.
* @return void
*/
define: function( name, definitionObject ) {
if ( Help.isValidHelpFormat( definitionObject ) ) {
debug('help is a valid format');
Help._ACTIVE_HELP_LANG = name; hide: function() {
Help._LOADED_HELP_LANGS.push( name ); if ( $.browser.msie ) {
Help._HELP[name] = definitionObject; $('#gollum-editor-help').css('display', 'none');
} else {
$('#gollum-editor-help').animate({
opacity: 0
}, 200, function() {
$('#gollum-editor-help')
.animate({ height: 'hide' }, 200);
});
}
},
if ( $("#function-help").length ) { show: function() {
if ( $('#function-help').hasClass('disabled') ) { if ( $.browser.msie ) {
$('#function-help').removeClass('disabled'); // bypass effects for internet explorer, since it does weird crap
} // to text antialiasing with opacity animations
$('#function-help').unbind('click'); $('#gollum-editor-help').css('display', 'block');
$('#function-help').click( Help.evtHelpButtonClick ); } else {
$('#gollum-editor-help').animate({
height: 'show'
}, 200, function() {
$('#gollum-editor-help')
.animate({ opacity: 1 }, 300);
});
}
},
// generate help menus /**
Help.generateHelpMenuFor( name ); * Help.showHelpFor
} * Displays the actual help content given the two menu indexes, which are
} else { * rendered in the rel="" attributes of the help menus
if ( $('#function-help').length ) { *
$('#function-help').addClass('disabled'); * @param integer index1 parent index
} * @param integer index2 submenu index
} * @return void
}, */
showHelpFor: function( index1, index2 ) {
var html =
Help._HELP[Help._ACTIVE_HELP_LANG][index1].content[index2].data;
$('#gollum-editor-help-content').html(html);
},
/**
* Help.isLoadedFor
* Returns true if help is loaded for a specific markup language,
* false otherwise.
*
* @param string name The name of the markup language.
* @return boolean
*/
isLoadedFor: function( name ) {
for ( var i=0; i < Help._LOADED_HELP_LANGS.length; i++ ) {
if ( name == Help._LOADED_HELP_LANGS[i] ) {
return true;
}
}
return false;
},
/** isShown: function() {
* Help.generateHelpMenuFor return ($('#gollum-editor-help').is(':visible'));
* Generates the markup for the main help menu given a context name. },
*
* @param string name The context name.
* @return void
*/
generateHelpMenuFor: function( name ) {
if ( !Help._HELP[name] ) {
debug('Help is not defined for ' + name.toString());
return false;
}
var helpData = Help._HELP[name];
if ( EditorHas.mathJax() && Help.isLoadedFor('mathjax') ) { /**
debug('Adding MathJax support to help'); * Help.isValidHelpFormat
// TODO * Does a quick check to make sure that the help definition isn't in a
} * completely messed-up format.
*
* @param object (Array) helpArr The help definition array.
* @return boolean
*/
isValidHelpFormat: function( helpArr ) {
return ( typeof helpArr == 'object' &&
helpArr.length &&
typeof helpArr[0].menuName == 'string' &&
typeof helpArr[0].content == 'object' &&
helpArr[0].content.length );
},
// clear this shiz out /**
$('#gollum-editor-help-parent').html(''); * Help.setActiveHelp
$('#gollum-editor-help-list').html(''); * Sets the active help definition to the one defined in the argument,
$('#gollum-editor-help-content').html(''); * re-rendering the help menu to match the new definition.
*
// go go inefficient algorithm * @param string name The name of the help definition.
for ( var i=0; i < helpData.length; i++ ) { * @return void
if ( typeof helpData[i] != 'object' ) { */
break; setActiveHelp: function( name ) {
} if ( !Help.isLoadedFor( name ) ) {
if ( $('#function-help').length ) {
var $newLi = $('<li><a href="#" rel="' + i + '">' + $('#function-help').addClass('disabled');
helpData[i].menuName + '</a></li>'); }
$('#gollum-editor-help-parent').append( $newLi ); if ( Help.isShown() ) {
if ( i === 0 ) { Help.hide();
// select on first run }
$newLi.children('a').addClass('selected'); } else {
}
$newLi.children('a').click( Help.evtParentMenuClick );
}
// generate parent submenu on first run
Help.generateSubMenu( helpData[0], 0 );
$($('#gollum-editor-help-list li a').get(0)).click();
},
/**
* Help.generateSubMenu
* Generates the markup for the inline help sub-menu given the data
* object for the submenu and the array index to start at.
*
* @param object subData The data for the sub-menu.
* @param integer index The index clicked on (parent menu index).
* @return void
*/
generateSubMenu: function( subData, index ) {
$('#gollum-editor-help-list').html('');
$('#gollum-editor-help-content').html('');
for ( var i=0; i < subData.content.length; i++ ) {
if ( typeof subData.content[i] != 'object' ) {
break;
}
var $subLi = $('<li><a href="#" rel="' + index + ':' + i + '">' +
subData.content[i].menuName + '</a></li>');
$('#gollum-editor-help-list').append( $subLi );
$subLi.children('a').click( Help.evtSubMenuClick );
}
},
hide: function() {
if ( $.browser.msie ) {
$('#gollum-editor-help').css('display', 'none');
} else {
$('#gollum-editor-help').animate({
opacity: 0
}, 200,
function() {
$('#gollum-editor-help')
.animate({ height: 'hide' }, 200);
});
}
},
show: function() {
if ( $.browser.msie ) {
// bypass effects for internet explorer, since it does weird crap
// to text antialiasing with opacity animations
$('#gollum-editor-help').css('display', 'block');
} else {
$('#gollum-editor-help').animate({
height: 'show'
}, 200,
function() {
$('#gollum-editor-help')
.animate({ opacity: 1 }, 300);
});
}
},
/**
* Help.showHelpFor
* Displays the actual help content given the two menu indexes, which are
* rendered in the rel="" attributes of the help menus
*
* @param integer index1 parent index
* @param integer index2 submenu index
* @return void
*/
showHelpFor: function( index1, index2 ) {
var html =
Help._HELP[Help._ACTIVE_HELP_LANG][index1].content[index2].data;
$('#gollum-editor-help-content').html(html);
},
/**
* Help.isLoadedFor
* Returns true if help is loaded for a specific markup language,
* false otherwise.
*
* @param string name The name of the markup language.
* @return boolean
*/
isLoadedFor: function( name ) {
for ( var i=0; i < Help._LOADED_HELP_LANGS.length; i++ ) {
if ( name == Help._LOADED_HELP_LANGS[i] ) {
return true;
}
}
return false;
},
isShown: function() {
return ( $('#gollum-editor-help').is(':visible') );
},
/**
* Help.isValidHelpFormat
* Does a quick check to make sure that the help definition isn't in a
* completely messed-up format.
*
* @param object (Array) helpArr The help definition array.
* @return boolean
*/
isValidHelpFormat: function( helpArr ) {
return ( typeof helpArr == 'object' &&
helpArr.length &&
typeof helpArr[0].menuName == 'string' &&
typeof helpArr[0].content == 'object' &&
helpArr[0].content.length );
},
/**
* Help.setActiveHelp
* Sets the active help definition to the one defined in the argument,
* re-rendering the help menu to match the new definition.
*
* @param string name The name of the help definition.
* @return void
*/
setActiveHelp: function( name ) {
if ( !Help.isLoadedFor( name ) ) {
if ( $('#function-help').length ) {
$('#function-help').addClass('disabled');
}
if ( Help.isShown() ) {
Help.hide();
}
} else {
Help._ACTIVE_HELP_LANG = name; Help._ACTIVE_HELP_LANG = name;
if ( $("#function-help").length ) { if ( $("#function-help").length ) {
if ( $('#function-help').hasClass('disabled') ) { if ( $('#function-help').hasClass('disabled') ) {
@@ -1005,80 +994,76 @@
$('#function-help').click( Help.evtHelpButtonClick ); $('#function-help').click( Help.evtHelpButtonClick );
Help.generateHelpMenuFor( name ); Help.generateHelpMenuFor( name );
} }
} }
}, },
/**
* Help.evtHelpButtonClick
* Event handler for clicking the help button in the function bar.
*
* @param jQuery.Event e The jQuery event object.
* @return void
*/
evtHelpButtonClick: function( e ) {
e.preventDefault();
if ( Help.isShown() ) { Help.hide(); }
else { Help.show(); }
},
/** /**
* Help.evtHelpButtonClick * Help.evtParentMenuClick
* Event handler for clicking the help button in the function bar. * Event handler for clicking on an item in the parent menu. Automatically
* * renders the submenu for the parent menu as well as the first result for
* @param jQuery.Event e The jQuery event object. * the actual plain text.
* @return void *
*/ * @param jQuery.Event e The jQuery event object.
evtHelpButtonClick: function( e ) { * @return void
e.preventDefault(); */
if ( Help.isShown() ) { Help.hide(); } evtParentMenuClick: function( e ) {
else { Help.show(); } e.preventDefault();
}, // short circuit if we've selected this already
if ( $(this).hasClass('selected') ) { return; }
// populate from help data for this
var helpIndex = $(this).attr('rel');
var subData = Help._HELP[Help._ACTIVE_HELP_LANG][helpIndex];
/** $('#gollum-editor-help-parent li a').removeClass('selected');
* Help.evtParentMenuClick $(this).addClass('selected');
* Event handler for clicking on an item in the parent menu. Automatically Help.generateSubMenu( subData, helpIndex );
* renders the submenu for the parent menu as well as the first result for $($('#gollum-editor-help-list li a').get(0)).click();
* the actual plain text. },
*
* @param jQuery.Event e The jQuery event object.
* @return void
*/
evtParentMenuClick: function( e ) {
e.preventDefault();
// short circuit if we've selected this already
if ( $(this).hasClass('selected') ) { return; }
// populate from help data for this /**
var helpIndex = $(this).attr('rel'); * Help.evtSubMenuClick
var subData = Help._HELP[Help._ACTIVE_HELP_LANG][helpIndex]; * Event handler for clicking an item in a help submenu. Renders the
* appropriate text for the submenu link.
*
* @param jQuery.Event e The jQuery event object.
* @return void
*/
evtSubMenuClick: function( e ) {
e.preventDefault();
if ( $(this).hasClass('selected') ) { return; }
$('#gollum-editor-help-parent li a').removeClass('selected'); // split index rel data
$(this).addClass('selected'); var rawIndex = $(this).attr('rel').split(':');
Help.generateSubMenu( subData, helpIndex ); $('#gollum-editor-help-list li a').removeClass('selected');
$($('#gollum-editor-help-list li a').get(0)).click(); $(this).addClass('selected');
}, Help.showHelpFor( rawIndex[0], rawIndex[1] );
}
};
// Publicly-accessible function to Help.define
$.GollumEditor.defineHelp = Help.define;
/** // Dialog exists as its own thing now
* Help.evtSubMenuClick $.GollumEditor.Dialog = $.GollumDialog;
* Event handler for clicking an item in a help submenu. Renders the $.GollumEditor.replaceSelection = function( repText ) {
* appropriate text for the submenu link. FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText );
* };
* @param jQuery.Event e The jQuery event object.
* @return void
*/
evtSubMenuClick: function( e ) {
e.preventDefault();
if ( $(this).hasClass('selected') ) { return; }
// split index rel data // Placeholder exists as its own thing now
var rawIndex = $(this).attr('rel').split(':'); $.GollumEditor.Placeholder = $.GollumPlaceholder;
$('#gollum-editor-help-list li a').removeClass('selected');
$(this).addClass('selected');
Help.showHelpFor( rawIndex[0], rawIndex[1] );
}
};
// Publicly-accessible function to Help.define
$.GollumEditor.defineHelp = Help.define;
// Dialog exists as its own thing now
$.GollumEditor.Dialog = $.GollumDialog;
$.GollumEditor.replaceSelection = function( repText ) {
FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText );
};
// Placeholder exists as its own thing now
$.GollumEditor.Placeholder = $.GollumPlaceholder;
})(jQuery); })(jQuery);