From 03569e31340366c1b7aac67e0b12d0769fcf6d7a Mon Sep 17 00:00:00 2001 From: Eston Bond Date: Mon, 15 Nov 2010 15:01:12 -0800 Subject: [PATCH] Hook up format selector --- lib/gollum/frontend/public/css/editor.css | 19 +++++- .../javascript/gollum-editor/gollum.editor.js | 58 +++++++++++++++++-- lib/gollum/frontend/templates/editor.mustache | 3 +- lib/gollum/frontend/templates/layout.mustache | 2 - 4 files changed, 72 insertions(+), 10 deletions(-) diff --git a/lib/gollum/frontend/public/css/editor.css b/lib/gollum/frontend/public/css/editor.css index 840408b1..7898622b 100644 --- a/lib/gollum/frontend/public/css/editor.css +++ b/lib/gollum/frontend/public/css/editor.css @@ -180,6 +180,7 @@ a#function-image:hover span { background-position: -324px -28px; } float: right; font-size: 1.1em; + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: bold; line-height: 1.6em; padding: 0.5em 0.7em; @@ -189,7 +190,6 @@ a#function-image:hover span { background-position: -324px -28px; } border-radius: 0.5em; -moz-border-radius: 0.5em; -webkit-border-radius: 0.5em; - -moz-outline: none; } @@ -200,7 +200,22 @@ a#function-image:hover span { background-position: -324px -28px; } -moz-outline: none; } - +#gollum-editor #gollum-editor-function-bar + #gollum-editor-format-selector label { + color: #999; + float: right; + font-size: 1.1em; + font-weight: bold; + line-height: 1.6em; + padding: 0.6em 0.5em 0 0; +} + +#gollum-editor #gollum-editor-function-bar + #gollum-editor-format-selector label:after { + content: ':'; +} + + /* @section form-fields */ #gollum-editor textarea#gollum-editor-body { 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 3010fae6..59538144 100644 --- a/lib/gollum/frontend/public/javascript/gollum-editor/gollum.editor.js +++ b/lib/gollum/frontend/public/javascript/gollum-editor/gollum.editor.js @@ -56,6 +56,7 @@ // Initialize the function bar by loading proper definitions if ( EditorHas.functionBar() ) { + var htmlSetMarkupLang = $('#gollum-editor-body').attr('data-markup-lang'); @@ -72,15 +73,18 @@ + 'type ' + ActiveOptions.MarkupType); return; } + + if ( EditorHas.formatSelector() ) { + FormatSelector.init( + $('#gollum-editor-format-selector select') ); + } + // activate the function bar debug('Activating function bar'); FunctionBar.activate(); } ); - } else { - // loaded language already - debug('Activating function bar'); - FunctionBar.activate(); } + } // EditorHas.functionBar } @@ -143,6 +147,18 @@ LanguageDefinition._LANG[name] = definitionObject; }, + getActiveLanguage: function() { + return LanguageDefinition._ACTIVE_LANG; + }, + + setActiveLanguage: function( name ) { + if ( !LanguageDefinition.isLoadedFor(name) ) { + LanguageDefinition.loadFor( name ); + } else { + LanguageDefinition._ACTIVE_LANG = name; + } + }, + /** * gets a definition object for a specified attribute @@ -176,7 +192,7 @@ */ loadFor: function( markup_name, on_complete ) { // attempt to load the definition for this language - var script_uri = 'js/gollum-editor/langs/' + markup_name + '.js'; + var script_uri = '/javascript/gollum-editor/langs/' + markup_name + '.js'; $.ajax({ url: script_uri, dataType: 'script', @@ -233,6 +249,10 @@ return $('#gollum-editor .collapsed, #gollum-editor .expanded').length; }, + formatSelector: function() { + return $('#gollum-editor-format-selector select').length; + }, + /** * EditorHas.functionBar @@ -444,6 +464,34 @@ } } }; + + + var FormatSelector = { + + $_SELECTOR: null, + + changeFormat: function( newFormat ) { + + }, + + evtChangeFormat: function( e ) { + var newMarkup = $(this).val(); + LanguageDefinition.setActiveLanguage( newMarkup ); + }, + + init: function( $sel ) { + debug('Initializing format selector'); + + FormatSelector.$_SELECTOR = $sel; + + // set format selector to the current language + var currentLang = LanguageDefinition.getActiveLanguage(); + FormatSelector.$_SELECTOR.val( currentLang ); + FormatSelector.$_SELECTOR.change( FormatSelector.evtChangeFormat ); + } + + + }; /** diff --git a/lib/gollum/frontend/templates/editor.mustache b/lib/gollum/frontend/templates/editor.mustache index ffb85119..ba38397f 100644 --- a/lib/gollum/frontend/templates/editor.mustache +++ b/lib/gollum/frontend/templates/editor.mustache @@ -45,7 +45,7 @@ Image -
+
+