allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [15/42] allura git commit: [#7897] ticket:804 Show help modal on "info" click
Date Wed, 22 Jul 2015 12:31:11 GMT
[#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/404bd07c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/404bd07c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/404bd07c

Branch: refs/heads/ib/7897
Commit: 404bd07c021607342dddc273efa4d7ecd8ed212a
Parents: 62be737
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Jun 18 17:25:45 2015 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Jul 22 10:59:51 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/404bd07c/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/404bd07c/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/404bd07c/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}}">


Mime
View raw message