diff --git a/lib/gollum/frontend/public/javascript/gollum-editor/gollum.editor.js b/lib/gollum/frontend/public/javascript/gollum-editor/gollum.editor.js index 33129efd..0a1aabe9 100755 --- a/lib/gollum/frontend/public/javascript/gollum-editor/gollum.editor.js +++ b/lib/gollum/frontend/public/javascript/gollum-editor/gollum.editor.js @@ -6,34 +6,35 @@ * $.GollumEditor(); on DOM ready. */ (function($) { - + // Editor options var DefaultOptions = { MarkupType: 'markdown', EditorMode: 'code', NewFile: false, HasFunctionBar: true, - Debug: false + Debug: false, + NoDefinitionsFor: [] }; var ActiveOptions = {}; - - /** + + /** * $.GollumEditor * * You don't need to do anything. Just run this on DOM ready. */ $.GollumEditor = function( IncomingOptions ) { - - ActiveOptions = $.extend( DefaultOptions, IncomingOptions ); - + + ActiveOptions = $.extend( DefaultOptions, IncomingOptions ); + debug('GollumEditor loading'); - + if ( EditorHas.baseEditorMarkup() ) { - + if ( EditorHas.titleDisplayed() ) { $('#gollum-editor-title-field').addClass('active'); } - + if ( EditorHas.editSummaryMarkup() ) { $.GollumEditor.Placeholder.add($('#gollum-editor-edit-summary input')); $('#gollum-editor form[name="gollum-editor"]').submit(function( e ) { @@ -44,63 +45,64 @@ $(this).submit(); }); } - + if ( EditorHas.collapsibleInputs() ) { - $('#gollum-editor .collapsed a.button, ' + + $('#gollum-editor .collapsed a.button, ' + '#gollum-editor .expanded a.button').click(function( e ) { e.preventDefault(); $(this).parent().toggleClass('expanded'); $(this).parent().toggleClass('collapsed'); }); } - + if ( EditorHas.previewButton() ) { - var formAction = + var formAction = $('#gollum-editor #gollum-editor-preview').click(function() { // make a dummy form, submit to new target window // get form fields var oldAction = $('#gollum-editor form').attr('action'); var $form = $($('#gollum-editor form').get(0)); - $form.attr('action', '/preview'); + $form.attr('action', this.href); $form.attr('target', '_blank'); $form.submit(); - - + + $form.attr('action', oldAction); $form.removeAttr('target'); + return false; }); } - + // Initialize the function bar by loading proper definitions if ( EditorHas.functionBar() ) { - + var htmlSetMarkupLang = $('#gollum-editor-body').attr('data-markup-lang'); - + if ( htmlSetMarkupLang ) { ActiveOptions.MarkupType = htmlSetMarkupLang; } - + // load language definition LanguageDefinition.setActiveLanguage( ActiveOptions.MarkupType ); if ( EditorHas.formatSelector() ) { - FormatSelector.init( + FormatSelector.init( $('#gollum-editor-format-selector select') ); } - + if ( EditorHas.help() ) { $('#gollum-editor-help').hide(); $('#gollum-editor-help').removeClass('jaws'); } - - } + + } // EditorHas.functionBar - } + } // EditorHas.baseEditorMarkup }; - - - + + + /** * $.GollumEditor.defineLanguage * Defines a set of language actions that Gollum can use. @@ -109,42 +111,42 @@ $.GollumEditor.defineLanguage = function( language_name, languageObject ) { if ( typeof languageObject == 'object' ) { LanguageDefinition.define( language_name, languageObject ); - } else { - debug('GollumEditor.defineLanguage: definition for ' + language_name + + } else { + debug('GollumEditor.defineLanguage: definition for ' + language_name + ' is not an object'); } }; - - + + /** * debug * Prints debug information to console.log if debug output is enabled. - * + * * @param mixed Whatever you want to dump to console.log * @return void */ var debug = function(m) { - if ( ActiveOptions.Debug && + if ( ActiveOptions.Debug && typeof console != 'undefined' ) { console.log( m ); } }; - - - + + + /** * LanguageDefinition * Language definition file handler * Loads language definition files as necessary. */ var LanguageDefinition = { - + _ACTIVE_LANG: '', _LOADED_LANGS: [], _LANG: {}, - - /** - * Defines a language + + /** + * Defines a language * * @param name string The name of the language * @param name object The definition object @@ -154,11 +156,11 @@ LanguageDefinition._LOADED_LANGS.push( name ); LanguageDefinition._LANG[name] = definitionObject; }, - + getActiveLanguage: function() { return LanguageDefinition._ACTIVE_LANG; }, - + setActiveLanguage: function( name ) { if ( !LanguageDefinition.isLoadedFor(name) ) { LanguageDefinition._ACTIVE_LANG = null; @@ -168,27 +170,27 @@ // well, fake it and turn everything off for this one LanguageDefinition.define( name, {} ); } - + // update features that rely on the language definition if ( EditorHas.functionBar() ) { FunctionBar.refresh(); } - + if ( LanguageDefinition.isValid() && EditorHas.formatSelector() ) { FormatSelector.updateSelected(); } - + } ); } else { LanguageDefinition._ACTIVE_LANG = name; FunctionBar.refresh(); } }, - - + + /** * gets a definition object for a specified attribute - * + * * @param string attr The specified attribute. * @param string specified_lang The language to pull a definition for. * @return object if exists, null otherwise @@ -197,17 +199,17 @@ if ( !specified_lang ) { specified_lang = LanguageDefinition._ACTIVE_LANG; } - + if ( LanguageDefinition.isLoadedFor(specified_lang) && - LanguageDefinition._LANG[specified_lang][attr] && + LanguageDefinition._LANG[specified_lang][attr] && typeof LanguageDefinition._LANG[specified_lang][attr] == 'object' ) { return LanguageDefinition._LANG[specified_lang][attr]; } - + return null; }, - - + + /** * loadFor * Asynchronously loads a definition file for the current markup. @@ -217,23 +219,36 @@ * @return void */ loadFor: function( markup_name, on_complete ) { + // Keep us from hitting 404s on our site, check the definition blacklist + if ( ActiveOptions.NoDefinitionsFor.length ) { + for ( var i=0; i < ActiveOptions.NoDefinitionsFor.length; i++ ) { + if ( markup_name == ActiveOptions.NoDefinitionsFor[i] ) { + // we don't have this. get out. + if ( typeof on_complete == 'function' ) { + on_complete( null, 'error' ); + return; + } + } + } + } + // attempt to load the definition for this language - var script_uri = '/javascript/gollum-editor/langs/' + markup_name + '.js'; + var script_uri = '/javascripts/editor/langs/' + markup_name + '.js'; $.ajax({ - url: script_uri, + url: script_uri, dataType: 'script', - complete: function( xhr, textStatus ) { + complete: function( xhr, textStatus ) { if ( typeof on_complete == 'function' ) { on_complete( xhr, textStatus ); } } }); }, - - + + /** * isLoadedFor - * Checks to see if a definition file has been loaded for the + * Checks to see if a definition file has been loaded for the * specified markup language. * * @param string markup_name The name of the markup. @@ -243,7 +258,7 @@ if ( LanguageDefinition._LOADED_LANGS.length === 0 ) { return false; } - + for ( var i=0; i < LanguageDefinition._LOADED_LANGS.length; i++ ) { if ( LanguageDefinition._LOADED_LANGS[i] == markup_name ) { return true; @@ -251,24 +266,24 @@ } return false; }, - + isValid: function() { - return ( LanguageDefinition._ACTIVE_LANG && - typeof LanguageDefinition._LANG[LanguageDefinition._ACTIVE_LANG] == + return ( LanguageDefinition._ACTIVE_LANG && + typeof LanguageDefinition._LANG[LanguageDefinition._ACTIVE_LANG] == 'object' ); } - + }; - - + + /** * EditorHas * Various conditionals to check what features of the Gollum Editor are * active/operational. */ var EditorHas = { - - + + /** * EditorHas.baseEditorMarkup * True if the basic editor form is in place. @@ -276,14 +291,14 @@ * @return boolean */ baseEditorMarkup: function() { - return ( $('#gollum-editor').length && + return ( $('#gollum-editor').length && $('#gollum-editor-body').length ); }, - - + + /** * EditorHas.collapsibleInputs - * True if the editor contains collapsible inputs for things like the + * True if the editor contains collapsible inputs for things like the * sidebar or footer, false otherwise. * * @return boolean @@ -291,11 +306,11 @@ collapsibleInputs: function() { return $('#gollum-editor .collapsed, #gollum-editor .expanded').length; }, - - + + /** * EditorHas.formatSelector - * True if the editor has a format selector (for switching between + * True if the editor has a format selector (for switching between * language types), false otherwise. * * @return boolean @@ -303,8 +318,8 @@ formatSelector: function() { return $('#gollum-editor-format-selector select').length; }, - - + + /** * EditorHas.functionBar * True if the Function Bar markup exists. @@ -312,11 +327,11 @@ * @return boolean */ functionBar: function() { - return ( ActiveOptions.HasFunctionBar && + return ( ActiveOptions.HasFunctionBar && $('#gollum-editor-function-bar').length ); }, - - + + /** * EditorHas.ff4Environment * True if in a Firefox 4.0 Beta environment. @@ -327,11 +342,11 @@ var ua = new RegExp(/Firefox\/4.0b/); return ( ua.test( navigator.userAgent ) ); }, - - + + /** * EditorHas.editSummaryMarkup - * True if the editor has a summary field (Gollum's commit message), + * True if the editor has a summary field (Gollum's commit message), * false otherwise. * * @return boolean @@ -339,8 +354,8 @@ editSummaryMarkup: function() { return ( $('input#gollum-editor-message-field').length > 0 ); }, - - + + /** * EditorHas.help * True if the editor contains the inline help sector, false otherwise. @@ -348,11 +363,11 @@ * @return boolean */ help: function() { - return ( $('#gollum-editor #gollum-editor-help').length && + return ( $('#gollum-editor #gollum-editor-help').length && $('#gollum-editor #function-help').length ); }, - - + + /** * EditorHas.mathJax * True if the editor has MathJax enabled and running, false otherwise. @@ -362,8 +377,8 @@ mathJax: function() { return (typeof window.MathJax == 'object'); }, - - + + /** * EditorHas.previewButton * True if the editor has a preview button, false otherwise. @@ -373,8 +388,8 @@ previewButton: function() { return ( $('#gollum-editor #gollum-editor-preview').length ); }, - - + + /** * EditorHas.titleDisplayed * True if the editor is displaying a title field, false otherwise. @@ -384,29 +399,29 @@ titleDisplayed: function() { return ( ActiveOptions.NewFile ); } - + }; - - + + /** * FunctionBar * * Things the function bar does. */ var FunctionBar = { - + isActive: false, - - + + /** * FunctionBar.activate - * Activates the function bar, attaching all click events + * Activates the function bar, attaching all click events * and displaying the bar. * */ activate: function() { debug('Activating function bar'); - + // check these out $('#gollum-editor-function-bar a.function-button').each(function() { if ( LanguageDefinition.getDefinitionFor( $(this).attr('id') ) ) { @@ -422,18 +437,18 @@ $('#gollum-editor-function-bar').addClass( 'active' ); FunctionBar.isActive = true; }, - - + + deactivate: function() { $('#gollum-editor-function-bar a.function-button').unbind('click'); $('#gollum-editor-function-bar').removeClass( 'active' ); FunctionBar.isActive = false; }, - - + + /** * FunctionBar.evtFunctionButtonClick - * Event handler for the function buttons. Traps the click and + * Event handler for the function buttons. Traps the click and * executes the proper language action. * * @param jQuery.Event jQuery event object. @@ -445,8 +460,8 @@ FunctionBar.executeAction( def ); } }, - - + + /** * FunctionBar.executeAction * Executes a language-specific defined action for a function button. @@ -462,73 +477,67 @@ var repText = selText; var reselect = true; var cursor = null; - + // execute a replacement function if one exists - if ( definitionObject.exec && + if ( definitionObject.exec && typeof definitionObject.exec == 'function' ) { definitionObject.exec( txt, selText, $('#gollum-editor-body') ); return; } - + // execute a search/replace if they exist var searchExp = /([^\n]+)/gi; - if ( definitionObject.search && + if ( definitionObject.search && typeof definitionObject.search == 'object' ) { debug('Replacing search Regex'); - searchExp = definitionObject.search; + searchExp = null; + searchExp = new RegExp ( definitionObject.search ); debug( searchExp ); } - debug(repText); + debug('repText is ' + '"' + repText + '"'); // replace text if ( definitionObject.replace && typeof definitionObject.replace == 'string' ) { debug('Running replacement - using ' + definitionObject.replace); var rt = definitionObject.replace; - var matches = searchExp.exec( repText ); - if ( matches && matches.length > 1 ) { - debug(matches); - for ( var i = 1; i < matches.length; i++ ) { - var searchStr = '$' + i; - debug('searching for ' + searchStr + ' to replace with ' + matches[i]); - rt = rt.replace( searchStr, matches[i] ); - } - // remove any excess backreferences from the replace string - rt = rt.replace( /\$[\d]/g, '' ); - repText = rt; - } else if ( repText === '' ) { + repText = repText.replace( searchExp, rt ); + // remove backreferences + repText = repText.replace( /\$[\d]/g, '' ); + + if ( repText === '' ) { debug('Search string is empty'); - + // find position of $1 - this is where we will place the cursor - cursor = rt.indexOf('$1'); - + cursor = rt.indexOf('$1'); + // we have an empty string, so just remove backreferences repText = rt.replace( /\$[\d]/g, '' ); - - // if the position of $1 doesn't exist, stick the cursor in + + // if the position of $1 doesn't exist, stick the cursor in // the middle if ( cursor == -1 ) { cursor = Math.floor( rt.length / 2 ); - } + } } } - + // append if necessary - if ( definitionObject.append && + if ( definitionObject.append && typeof definitionObject.append == 'string' ) { if ( repText == selText ) { reselect = false; } repText += definitionObject.append; } - + if ( repText ) { - FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), + FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText, reselect, cursor ); } - + }, - - + + /** * getFieldSelectionPosition * Retrieves the selection range for the textarea. @@ -539,8 +548,8 @@ if ($field.length) { var start = 0, end = 0; var el = $field.get(0); - - if (typeof el.selectionStart == "number" && + + if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") { start = el.selectionStart; end = el.selectionEnd; @@ -551,9 +560,9 @@ stored_range.setEndPoint( 'EndToEnd', range ); start = stored_range.text.length - range.text.length; end = start + range.text.length; - - // so, uh, we're close, but we need to search for line breaks and - // adjust the start/end points accordingly since IE counts them as + + // so, uh, we're close, but we need to search for line breaks and + // adjust the start/end points accordingly since IE counts them as // 2 characters in TextRange. var s = start; var lb = 0; @@ -564,12 +573,12 @@ ++lb; } } - + if ( lb ) { debug('IE start: compensating for ' + lb + ' line breaks'); - start = start - lb; + start = start - lb; lb = 0; - } + } var e = end; for ( i=0; i < e; i++ ) { @@ -577,24 +586,24 @@ ++lb; } } - + if ( lb ) { debug('IE end: compensating for ' + lb + ' line breaks'); - end = end - lb; - } + end = end - lb; + } } - + return { start: start, end: end }; } // end if ($field.length) }, - - + + /** * getFieldSelection - * Returns the currently selected substring of the textarea. + * Returns the currently selected substring of the textarea. * * @param jQuery A jQuery object for the textarea. * @return string Selected string. @@ -602,24 +611,25 @@ getFieldSelection: function( $field ) { var selStr = ''; var selPos; - + if ( $field.length ) { selPos = FunctionBar.getFieldSelectionPosition( $field ); selStr = $field.val().substring( selPos.start, selPos.end ); - debug('Selected: ' + selStr + ' (' + selPos.start + ', ' + + debug('Selected: ' + selStr + ' (' + selPos.start + ', ' + selPos.end + ')'); return selStr; } return false; }, - - + + isShown: function() { return ($('#gollum-editor-function-bar').is(':visible')); }, - + refresh: function() { if ( EditorHas.functionBar() ) { + debug('Refreshing function bar'); if ( LanguageDefinition.isValid() ) { $('#gollum-editor-function-bar a.function-button').unbind('click'); FunctionBar.activate(); @@ -635,14 +645,14 @@ if ( Help.isShown() ) { Help.hide(); } - } + } } }, - - + + /** * replaceFieldSelection - * Replaces the currently selected substring of the textarea with + * Replaces the currently selected substring of the textarea with * a new string. * * @param jQuery A jQuery object for the textarea. @@ -656,26 +666,26 @@ if ( reselect === false) { selectNew = false; } - + var scrollTop = null; if ( $field[0].scrollTop ) { scrollTop = $field[0].scrollTop; } - - $field.val( fullStr.substring(0, selPos.start) + replaceText + + + $field.val( fullStr.substring(0, selPos.start) + replaceText + fullStr.substring(selPos.end) ); $field[0].focus(); - + if ( selectNew ) { if ( $field[0].setSelectionRange ) { if ( cursorOffset ) { - $field[0].setSelectionRange( + $field[0].setSelectionRange( selPos.start + cursorOffset, selPos.start + cursorOffset ); } else { - $field[0].setSelectionRange( selPos.start, - selPos.start + replaceText.length ); + $field[0].setSelectionRange( selPos.start, + selPos.start + replaceText.length ); } } else if ( $field[0].createTextRange ) { var range = $field[0].createTextRange(); @@ -683,14 +693,14 @@ if ( cursorOffset ) { range.moveEnd( selPos.start + cursorOffset ); range.moveStart( selPos.start + cursorOffset ); - } else { + } else { range.moveEnd( 'character', selPos.start + replaceText.length ); - range.moveStart( 'character', selPos.start ); + range.moveStart( 'character', selPos.start ); } range.select(); } } - + if ( scrollTop ) { // this jumps sometimes in FF $field[0].scrollTop = scrollTop; @@ -699,20 +709,20 @@ }; - + /** * FormatSelector * * Functions relating to the format selector (if it exists) */ var FormatSelector = { - + $_SELECTOR: null, - + /** * FormatSelector.evtChangeFormat - * Event handler for when a format has been changed by the format - * selector. Will automatically load a new language definition + * Event handler for when a format has been changed by the format + * selector. Will automatically load a new language definition * via JS if necessary. * * @return void @@ -721,8 +731,8 @@ var newMarkup = $(this).val(); LanguageDefinition.setActiveLanguage( newMarkup ); }, - - + + /** * FormatSelector.init * Initializes the format selector. @@ -731,21 +741,21 @@ */ init: function( $sel ) { debug('Initializing format selector'); - + // unbind events if init is being called twice for some reason if ( FormatSelector.$_SELECTOR && typeof FormatSelector.$_SELECTOR == 'object' ) { FormatSelector.$_SELECTOR.unbind( 'change' ); } - + FormatSelector.$_SELECTOR = $sel; - + // set format selector to the current language FormatSelector.updateSelected(); FormatSelector.$_SELECTOR.change( FormatSelector.evtChangeFormat ); }, - - + + /** * FormatSelector.update */ @@ -753,50 +763,50 @@ var currentLang = LanguageDefinition.getActiveLanguage(); FormatSelector.$_SELECTOR.val( currentLang ); } - + }; - - - + + + /** * Help - * - * Functions that manage the display and loading of inline help files. + * + * Functions that manage the display and loading of inline help files. */ var Help = { - + _ACTIVE_HELP: '', _LOADED_HELP_LANGS: [], _HELP: {}, - - + + /** - * Help.define + * Help.define * - * Defines a new help context and enables the help function if it + * 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. + * @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 + * @param object definitionObject The definition object being loaded from a * language / help definition file. * @return void */ - define: function( name, definitionObject ) { + 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 ); } @@ -806,13 +816,13 @@ } } }, - - + + /** * Help.generateHelpMenuFor * Generates the markup for the main help menu given a context name. - * - * @param string name The context name. + * + * @param string name The context name. * @return void */ generateHelpMenuFor: function( name ) { @@ -821,24 +831,24 @@ 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 = $('
  • ' + + + var $newLi = $('
  • ' + helpData[i].menuName + '
  • '); $('#gollum-editor-help-parent').append( $newLi ); if ( i === 0 ) { @@ -847,17 +857,17 @@ } $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 + * 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. @@ -871,21 +881,21 @@ if ( typeof subData.content[i] != 'object' ) { break; } - + var $subLi = $('
  • ' + subData.content[i].menuName + '
  • '); - + $('#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').css('display', 'none'); + } else { $('#gollum-editor-help').animate({ opacity: 0 }, 200, @@ -893,12 +903,12 @@ $('#gollum-editor-help') .animate({ height: 'hide' }, 200); }); - } + } }, - + show: function() { if ( $.browser.msie ) { - // bypass effects for internet explorer, since it does weird crap + // bypass effects for internet explorer, since it does weird crap // to text antialiasing with opacity animations $('#gollum-editor-help').css('display', 'block'); } else { @@ -909,13 +919,13 @@ $('#gollum-editor-help') .animate({ opacity: 1 }, 300); }); - } + } }, - - + + /** * Help.showHelpFor - * Displays the actual help content given the two menu indexes, which are + * 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 @@ -927,11 +937,11 @@ 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, + * Returns true if help is loaded for a specific markup language, * false otherwise. * * @param string name The name of the markup language. @@ -945,17 +955,17 @@ } 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. + * 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 @@ -967,11 +977,11 @@ typeof helpArr[0].content == 'object' && helpArr[0].content.length ); }, - - + + /** * Help.setActiveHelp - * Sets the active help definition to the one defined in the argument, + * 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. @@ -980,7 +990,10 @@ setActiveHelp: function( name ) { if ( !Help.isLoadedFor( name ) ) { if ( $('#function-help').length ) { - $('#function-help').addClass('disabled'); + $('#function-help').addClass('disabled'); + } + if ( Help.isShown() ) { + Help.hide(); } } else { Help._ACTIVE_HELP_LANG = name; @@ -991,11 +1004,11 @@ $('#function-help').unbind('click'); $('#function-help').click( Help.evtHelpButtonClick ); Help.generateHelpMenuFor( name ); - } + } } }, - - + + /** * Help.evtHelpButtonClick * Event handler for clicking the help button in the function bar. @@ -1008,12 +1021,12 @@ if ( Help.isShown() ) { Help.hide(); } else { Help.show(); } }, - - + + /** * Help.evtParentMenuClick - * 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 + * 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 * the actual plain text. * * @param jQuery.Event e The jQuery event object. @@ -1023,30 +1036,30 @@ 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'); $(this).addClass('selected'); Help.generateSubMenu( subData, helpIndex ); $($('#gollum-editor-help-list li a').get(0)).click(); }, - - + + /** * Help.evtSubMenuClick - * Event handler for clicking an item in a help submenu. Renders the + * 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 + * @return void */ evtSubMenuClick: function( e ) { e.preventDefault(); if ( $(this).hasClass('selected') ) { return; } - + // split index rel data var rawIndex = $(this).attr('rel').split(':'); $('#gollum-editor-help-list li a').removeClass('selected'); @@ -1054,18 +1067,18 @@ 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);