diff --git a/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js b/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js index caf885a2..0ef3d2a5 100755 --- a/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js +++ b/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js @@ -168,6 +168,11 @@ }, setActiveLanguage: function( name ) { + // On first load _ACTIVE_LANG.length is 0 and evtChangeFormat isn't called. + if ( LanguageDefinition._ACTIVE_LANG.length <= 0 ) { + FormatSelector.updateCommitMessage( name ); + } + if(LanguageDefinition.getHookFunctionFor("deactivate")) { LanguageDefinition.getHookFunctionFor("deactivate")(); } @@ -747,9 +752,18 @@ */ evtChangeFormat: function( e ) { var newMarkup = $(this).val(); + FormatSelector.updateCommitMessage( newMarkup ); LanguageDefinition.setActiveLanguage( newMarkup ); }, + updateCommitMessage: function( newMarkup ) { + var msg = document.getElementById( "gollum-editor-message-field" ); + var val = msg.value; + // Must start with created or updated. + if (/^(?:created|updated)/i.test(val)) { + msg.value = val.replace( /\([^\)]*\)$/, "(" + newMarkup + ")" ); + } + }, /** * FormatSelector.init diff --git a/lib/gollum/frontend/templates/editor.mustache b/lib/gollum/frontend/templates/editor.mustache index 1ae57779..34c3c8cb 100644 --- a/lib/gollum/frontend/templates/editor.mustache +++ b/lib/gollum/frontend/templates/editor.mustache @@ -112,10 +112,14 @@
- + {{#is_create_page}} + + {{/is_create_page}} + {{#is_edit_page}} + + {{/is_edit_page}}
-
Preview