You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/07/08 11:58:42 UTC

[07/21] allura git commit: [#7897] ticket:804 Hide "code" from toolbar, since it's syntax is not matching Allura's

[#7897] ticket:804 Hide "code" from toolbar, since it's syntax is not matching Allura's


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/390e9338
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/390e9338
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/390e9338

Branch: refs/heads/ib/7897
Commit: 390e9338e106fc9688c3c507b3ebfa7eae4214db
Parents: f9d0f80
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Jun 18 18:10:41 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Jul 7 10:26:10 2015 +0300

----------------------------------------------------------------------
 .../lib/widgets/resources/js/sf_markitup.js     | 31 +++++++++++++++-----
 1 file changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/390e9338/Allura/allura/lib/widgets/resources/js/sf_markitup.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/sf_markitup.js b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
index b10e331..266d77a 100644
--- a/Allura/allura/lib/widgets/resources/js/sf_markitup.js
+++ b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
@@ -27,16 +27,31 @@ $(window).load(function() {
             var $help_area = $('div.markdown_help', $container);
             var $help_contents = $('div.markdown_help_contents', $container);
 
-            var toolbar = Editor.toolbar;
-            toolbar[11] = {name: 'info', action: show_help};
-            toolbar[12] = {name: 'preview', action: show_preview};
-            var editor = new Editor({
+            var toolbar = [];
+            // Exclude "code" tool from toolbar, since it's syntax not matching Allura's
+            // Override actions for "info" & "preview" tools
+            for (var i in Editor.toolbar) {
+              var tool = Editor.toolbar[i];
+              if (tool !== null && typeof tool === 'object') {
+                switch(tool.name) {
+                  case 'code':
+                    continue;
+                  case 'info':
+                    tool = {name: 'info', action: show_help};
+                    break;
+                  case 'preview':
+                    tool = {name: 'preview', action: show_preview};
+                    break;
+                }
+              }
+              toolbar.push(tool);
+            }
+            new Editor({
               element: $textarea[0],
               toolbar: toolbar
-            });
-            editor.render();
+            }).render();
 
-            function show_help() {
+            function show_help(editor) {
               $help_contents.html('Loading...');
               $.get($help_contents.attr('data-url'), function (data) {
                 $help_contents.html(data);
@@ -56,7 +71,7 @@ $(window).load(function() {
               $help_area.lightbox_me();
             }
 
-            function show_preview() {
+            function show_preview(editor) {
               /*
                * This is pretty much the same as original Editor.togglePreview,
                * but rendered text is fetched from the server.