allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [03/41] allura git commit: [#7897] ticket:804 Hide "code" from toolbar, since it's syntax is not matching Allura's
Date Wed, 29 Jul 2015 21:10:03 GMT
[#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/fa17621d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/fa17621d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/fa17621d

Branch: refs/heads/master
Commit: fa17621dc329716b8f9a6dd62635bfa8ea69483d
Parents: ad4eee7
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Jun 18 18:10:41 2015 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon Jul 27 14:23:54 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/fa17621d/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.


Mime
View raw message