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/27 15:11:36 UTC

[15/49] allura git commit: [#7897] ticket:804 Show help modal on "info" click

[#7897] ticket:804 Show help modal on "info" click


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

Branch: refs/heads/ib/7897
Commit: ebd486c6bae45ab1547802440269243352f07569
Parents: af54461
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Jun 18 17:25:45 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Jul 27 14:23:54 2015 +0300

----------------------------------------------------------------------
 Allura/allura/lib/widgets/form_fields.py        |  1 +
 .../lib/widgets/resources/js/sf_markitup.js     | 40 +++++++++++++++++++-
 .../allura/templates/widgets/markdown_edit.html |  2 +-
 3 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ebd486c6/Allura/allura/lib/widgets/form_fields.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py
index 40efd03..e6be401 100644
--- a/Allura/allura/lib/widgets/form_fields.py
+++ b/Allura/allura/lib/widgets/form_fields.py
@@ -271,6 +271,7 @@ class MarkdownEdit(ew.TextArea):
     def resources(self):
         for r in super(MarkdownEdit, self).resources():
             yield r
+        yield ew.JSLink('js/jquery.lightbox_me.js')
         yield ew.CSSLink('css/markdown_editor/editor.css')
         yield ew.JSLink('js/markdown_editor/editor.js')
         yield ew.JSLink('js/markdown_editor/marked.js')

http://git-wip-us.apache.org/repos/asf/allura/blob/ebd486c6/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 fd69c66..f57fb4b 100644
--- a/Allura/allura/lib/widgets/resources/js/sf_markitup.js
+++ b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
@@ -23,7 +23,45 @@ $(window).load(function() {
         $('div.markdown_edit').each(function(){
             var $container = $(this);
             var $textarea = $('textarea', $container);
-            new Editor({element: $textarea[0]}).render();
+
+            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},
+            new Editor({
+              element: $textarea[0],
+              toolbar: toolbar
+            }).render();
+
+            function show_help() {
+              $help_contents.html('Loading...');
+              $.get($help_contents.attr('data-url'), function (data) {
+                $help_contents.html(data);
+                var display_section = function(evt) {
+                  var $all_sections = $('.markdown_syntax_section', $help_contents);
+                  var $this_section = $(location.hash.replace('#', '.'), $help_contents);
+                  if ($this_section.length == 0) {
+                    $this_section = $('.md_ex_toc', $help_contents);
+                  }
+                  $all_sections.addClass('hidden_in_modal');
+                  $this_section.removeClass('hidden_in_modal');
+                  $('.markdown_syntax_toc_crumb').toggle(!$this_section.is('.md_ex_toc'));
+                };
+                $('.markdown_syntax_toc a', $help_contents).click(display_section);
+                $(window).bind('hashchange', display_section); // handle back button
+              });
+              $help_area.lightbox_me();
+            }
+
+            function show_preview() {
+              console.log('preview');
+            }
+
+            $('.close', $help_area).bind('click', function() {
+              $help_area.hide();
+            });
         });
     }
 });

http://git-wip-us.apache.org/repos/asf/allura/blob/ebd486c6/Allura/allura/templates/widgets/markdown_edit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/markdown_edit.html b/Allura/allura/templates/widgets/markdown_edit.html
index 8339bc7..773ea09 100644
--- a/Allura/allura/templates/widgets/markdown_edit.html
+++ b/Allura/allura/templates/widgets/markdown_edit.html
@@ -21,7 +21,7 @@
   <textarea id="{{id or rendered_name}}" name="{{rendered_name}}" class="{{widget.css_class}}" {{widget.j2_attrs(attrs)}}>{{value or ''}}</textarea>
   <div class="modal markdown_help" style="display:none">
     <b data-icon="{{g.icons['close'].char}}" class="ico {{g.icons['close'].css}} close"></b>
-    <div class="markdown_help_contents"></div>
+    <div class="markdown_help_contents" data-url="{{c.app.url}}markdown_syntax_dialog"></div>
   </div>
   <input type="hidden" class="markdown_project" value="{{c.project.shortname}}">
   <input type="hidden" class="markdown_neighborhood" value="{{c.project.neighborhood._id}}">