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/22 14:31:05 UTC
[09/42] allura git commit: [#7897] ticket:804 Get rid of all the
stuff which does not needed with a new widget
[#7897] ticket:804 Get rid of all the stuff which does not needed with a new widget
- Textarea tabby plugin (jquery.textarea.js). New plugin handles tabs by
itself
- help/preview buttons
- old css/js
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/62be7371
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/62be7371
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/62be7371
Branch: refs/heads/ib/7897
Commit: 62be7371a0cfb8b9aef22ba61ae66914c80269a5
Parents: 5be1b18
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Jun 18 16:55:24 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Jul 22 10:59:51 2015 +0300
----------------------------------------------------------------------
Allura/LICENSE | 1 -
Allura/allura/lib/widgets/form_fields.py | 9 +-
.../lib/widgets/resources/css/markitup_sf.css | 27 --
.../lib/widgets/resources/js/jquery.textarea.js | 267 -------------------
.../lib/widgets/resources/js/sf_markitup.js | 59 +---
.../allura/templates/widgets/markdown_edit.html | 7 -
LICENSE | 1 -
rat-excludes.txt | 1 -
8 files changed, 4 insertions(+), 368 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/Allura/LICENSE
----------------------------------------------------------------------
diff --git a/Allura/LICENSE b/Allura/LICENSE
index 452064c..9823dc6 100644
--- a/Allura/LICENSE
+++ b/Allura/LICENSE
@@ -228,7 +228,6 @@ under the MIT license. For details, see the individual files:
allura/lib/widgets/resources/js/jquery.autosize-min.js
allura/lib/widgets/resources/js/jquery.colorPicker.js
allura/lib/widgets/resources/js/jquery.tagsinput.js
- allura/lib/widgets/resources/js/jquery.textarea.js
allura/public/nf/js/jquery.flot.js
allura/public/nf/js/jquery.maxlength.min.js
allura/public/nf/js/jquery.viewport.js
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/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 b201f6a..40efd03 100644
--- a/Allura/allura/lib/widgets/form_fields.py
+++ b/Allura/allura/lib/widgets/form_fields.py
@@ -256,11 +256,11 @@ class AutoResizeTextarea(ew.TextArea):
''')
-class MarkdownEdit(AutoResizeTextarea):
+class MarkdownEdit(ew.TextArea):
template = 'jinja:allura:templates/widgets/markdown_edit.html'
validator = fev.UnicodeString()
defaults = dict(
- AutoResizeTextarea.defaults,
+ ew.TextArea.defaults,
name=None,
value=None,
show_label=True)
@@ -271,13 +271,10 @@ class MarkdownEdit(AutoResizeTextarea):
def resources(self):
for r in super(MarkdownEdit, self).resources():
yield r
- yield ew.JSLink('js/jquery.lightbox_me.js')
- yield ew.JSLink('js/jquery.textarea.js')
- yield ew.JSLink('js/sf_markitup.js')
- yield ew.CSSLink('css/markitup_sf.css')
yield ew.CSSLink('css/markdown_editor/editor.css')
yield ew.JSLink('js/markdown_editor/editor.js')
yield ew.JSLink('js/markdown_editor/marked.js')
+ yield ew.JSLink('js/sf_markitup.js')
class PageList(ew_core.Widget):
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/Allura/allura/lib/widgets/resources/css/markitup_sf.css
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/css/markitup_sf.css b/Allura/allura/lib/widgets/resources/css/markitup_sf.css
deleted file mode 100644
index f8d4cba..0000000
--- a/Allura/allura/lib/widgets/resources/css/markitup_sf.css
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-.markdown_edit textarea{
- height: 200px;
- width: 95%;
- font-family: Consolas, "Andale Mono", "Lucida Console", monospace;
-}
-.markdown_edit .btn{
- margin: 5px 5px 5px 0;
- display: inline-block;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/Allura/allura/lib/widgets/resources/js/jquery.textarea.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/jquery.textarea.js b/Allura/allura/lib/widgets/resources/js/jquery.textarea.js
deleted file mode 100644
index af572ba..0000000
--- a/Allura/allura/lib/widgets/resources/js/jquery.textarea.js
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Tabby jQuery plugin version 0.12
- *
- * Ted Devito - http://teddevito.com/demos/textarea.html
- *
- * Copyright (c) 2009 Ted Devito
- *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-// create closure
-
-(function($) {
-
- // plugin definition
-
- $.fn.tabby = function(options) {
- //debug(this);
- // build main options before element iteration
- var opts = $.extend({}, $.fn.tabby.defaults, options);
- var pressed = $.fn.tabby.pressed;
-
- // iterate and reformat each matched element
- return this.each(function() {
- $this = $(this);
-
- // build element specific options
- var options = $.meta ? $.extend({}, opts, $this.data()) : opts;
-
- $this.bind('keydown',function (e) {
- var kc = $.fn.tabby.catch_kc(e);
- if (16 == kc) pressed.shft = true;
- /*
- because both CTRL+TAB and ALT+TAB default to an event (changing tab/window) that
- will prevent js from capturing the keyup event, we'll set a timer on releasing them.
- */
- if (17 == kc) {pressed.ctrl = true; setTimeout("$.fn.tabby.pressed.ctrl = false;",1000);}
- if (18 == kc) {pressed.alt = true; setTimeout("$.fn.tabby.pressed.alt = false;",1000);}
-
- if (9 == kc && !pressed.ctrl && !pressed.alt) {
- e.preventDefault; // does not work in O9.63 ??
- pressed.last = kc; setTimeout("$.fn.tabby.pressed.last = null;",0);
- process_keypress ($(e.target).get(0), pressed.shft, options);
- return false;
- }
-
- }).bind('keyup',function (e) {
- if (16 == $.fn.tabby.catch_kc(e)) pressed.shft = false;
- }).bind('blur',function (e) { // workaround for Opera -- http://www.webdeveloper.com/forum/showthread.php?p=806588
- if (9 == pressed.last) $(e.target).one('focus',function (e) {pressed.last = null;}).get(0).focus();
- });
-
- });
- };
-
- // define and expose any extra methods
- $.fn.tabby.catch_kc = function(e) { return e.keyCode ? e.keyCode : e.charCode ? e.charCode : e.which; };
- $.fn.tabby.pressed = {shft : false, ctrl : false, alt : false, last: null};
-
- // private function for debugging
- function debug($obj) {
- if (window.console && window.console.log)
- window.console.log('textarea count: ' + $obj.size());
- };
-
- function process_keypress (o,shft,options) {
- var scrollTo = o.scrollTop;
- //var tabString = String.fromCharCode(9);
-
- // gecko; o.setSelectionRange is only available when the text box has focus
- if (o.setSelectionRange) gecko_tab (o, shft, options);
-
- // ie; document.selection is always available
- else if (document.selection) ie_tab (o, shft, options);
-
- o.scrollTop = scrollTo;
- }
-
- // plugin defaults
- $.fn.tabby.defaults = {tabString : String.fromCharCode(9)};
-
- function gecko_tab (o, shft, options) {
- var ss = o.selectionStart;
- var es = o.selectionEnd;
-
- // when there's no selection and we're just working with the caret, we'll add/remove the tabs at the caret, providing more control
- if(ss == es) {
- // SHIFT+TAB
- if (shft) {
- // check to the left of the caret first
- if ("\t" == o.value.substring(ss-options.tabString.length, ss)) {
- o.value = o.value.substring(0, ss-options.tabString.length) + o.value.substring(ss); // put it back together omitting one character to the left
- o.focus();
- o.setSelectionRange(ss - options.tabString.length, ss - options.tabString.length);
- }
- // then check to the right of the caret
- else if ("\t" == o.value.substring(ss, ss + options.tabString.length)) {
- o.value = o.value.substring(0, ss) + o.value.substring(ss + options.tabString.length); // put it back together omitting one character to the right
- o.focus();
- o.setSelectionRange(ss,ss);
- }
- }
- // TAB
- else {
- o.value = o.value.substring(0, ss) + options.tabString + o.value.substring(ss);
- o.focus();
- o.setSelectionRange(ss + options.tabString.length, ss + options.tabString.length);
- }
- }
- // selections will always add/remove tabs from the start of the line
- else {
- // split the textarea up into lines and figure out which lines are included in the selection
- var lines = o.value.split("\n");
- var indices = new Array();
- var sl = 0; // start of the line
- var el = 0; // end of the line
- var sel = false;
- for (var i in lines) {
- el = sl + lines[i].length;
- indices.push({start: sl, end: el, selected: (sl <= ss && el > ss) || (el >= es && sl < es) || (sl > ss && el < es)});
- sl = el + 1;// for "\n"
- }
-
- // walk through the array of lines (indices) and add tabs where appropriate
- var modifier = 0;
- for (var i in indices) {
- if (indices[i].selected) {
- var pos = indices[i].start + modifier; // adjust for tabs already inserted/removed
- // SHIFT+TAB
- if (shft && options.tabString == o.value.substring(pos,pos+options.tabString.length)) { // only SHIFT+TAB if there's a tab at the start of the line
- o.value = o.value.substring(0,pos) + o.value.substring(pos + options.tabString.length); // omit the tabstring to the right
- modifier -= options.tabString.length;
- }
- // TAB
- else if (!shft) {
- o.value = o.value.substring(0,pos) + options.tabString + o.value.substring(pos); // insert the tabstring
- modifier += options.tabString.length;
- }
- }
- }
- o.focus();
- var ns = ss + ((modifier > 0) ? options.tabString.length : (modifier < 0) ? -options.tabString.length : 0);
- var ne = es + modifier;
- o.setSelectionRange(ns,ne);
- }
- }
-
- function ie_tab (o, shft, options) {
- var range = document.selection.createRange();
-
- if (o == range.parentElement()) {
- // when there's no selection and we're just working with the caret, we'll add/remove the tabs at the caret, providing more control
- if ('' == range.text) {
- // SHIFT+TAB
- if (shft) {
- var bookmark = range.getBookmark();
- //first try to the left by moving opening up our empty range to the left
- range.moveStart('character', -options.tabString.length);
- if (options.tabString == range.text) {
- range.text = '';
- } else {
- // if that didn't work then reset the range and try opening it to the right
- range.moveToBookmark(bookmark);
- range.moveEnd('character', options.tabString.length);
- if (options.tabString == range.text)
- range.text = '';
- }
- // move the pointer to the start of them empty range and select it
- range.collapse(true);
- range.select();
- }
-
- else {
- // very simple here. just insert the tab into the range and put the pointer at the end
- range.text = options.tabString;
- range.collapse(false);
- range.select();
- }
- }
- // selections will always add/remove tabs from the start of the line
- else {
-
- var selection_text = range.text;
- var selection_len = selection_text.length;
- var selection_arr = selection_text.split("\r\n");
-
- var before_range = document.body.createTextRange();
- before_range.moveToElementText(o);
- before_range.setEndPoint("EndToStart", range);
- var before_text = before_range.text;
- var before_arr = before_text.split("\r\n");
- var before_len = before_text.length; // - before_arr.length + 1;
-
- var after_range = document.body.createTextRange();
- after_range.moveToElementText(o);
- after_range.setEndPoint("StartToEnd", range);
- var after_text = after_range.text; // we can accurately calculate distance to the end because we're not worried about MSIE trimming a \r\n
-
- var end_range = document.body.createTextRange();
- end_range.moveToElementText(o);
- end_range.setEndPoint("StartToEnd", before_range);
- var end_text = end_range.text; // we can accurately calculate distance to the end because we're not worried about MSIE trimming a \r\n
-
- var check_html = $(o).html();
- $("#r3").text(before_len + " + " + selection_len + " + " + after_text.length + " = " + check_html.length);
- if((before_len + end_text.length) < check_html.length) {
- before_arr.push("");
- before_len += 2; // for the \r\n that was trimmed
- if (shft && options.tabString == selection_arr[0].substring(0,options.tabString.length))
- selection_arr[0] = selection_arr[0].substring(options.tabString.length);
- else if (!shft) selection_arr[0] = options.tabString + selection_arr[0];
- } else {
- if (shft && options.tabString == before_arr[before_arr.length-1].substring(0,options.tabString.length))
- before_arr[before_arr.length-1] = before_arr[before_arr.length-1].substring(options.tabString.length);
- else if (!shft) before_arr[before_arr.length-1] = options.tabString + before_arr[before_arr.length-1];
- }
-
- for (var i = 1; i < selection_arr.length; i++) {
- if (shft && options.tabString == selection_arr[i].substring(0,options.tabString.length))
- selection_arr[i] = selection_arr[i].substring(options.tabString.length);
- else if (!shft) selection_arr[i] = options.tabString + selection_arr[i];
- }
-
- if (1 == before_arr.length && 0 == before_len) {
- if (shft && options.tabString == selection_arr[0].substring(0,options.tabString.length))
- selection_arr[0] = selection_arr[0].substring(options.tabString.length);
- else if (!shft) selection_arr[0] = options.tabString + selection_arr[0];
- }
-
- if ((before_len + selection_len + after_text.length) < check_html.length) {
- selection_arr.push("");
- selection_len += 2; // for the \r\n that was trimmed
- }
-
- before_range.text = before_arr.join("\r\n");
- range.text = selection_arr.join("\r\n");
-
- var new_range = document.body.createTextRange();
- new_range.moveToElementText(o);
-
- if (0 < before_len) new_range.setEndPoint("StartToEnd", before_range);
- else new_range.setEndPoint("StartToStart", before_range);
- new_range.setEndPoint("EndToEnd", range);
-
- new_range.select();
-
- }
- }
- }
-
-// end of closure
-})(jQuery);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/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 ecb84db..fd69c66 100644
--- a/Allura/allura/lib/widgets/resources/js/sf_markitup.js
+++ b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
@@ -23,64 +23,7 @@ $(window).load(function() {
$('div.markdown_edit').each(function(){
var $container = $(this);
var $textarea = $('textarea', $container);
- new Editor({
- element: $textarea[0]
- }).render();
- $textarea.tabby({tabString : " "});
- var $preview = $('a.markdown_preview', $container);
- var $edit = $('a.markdown_edit', $container);
- var $help = $('a.markdown_help', $container);
- var $preview_area = $('div.markdown_preview', $container);
- var $help_area = $('div.markdown_help', $container);
- var $help_contents = $('div.markdown_help_contents', $container);
- $preview.click(function(evt){
- evt.preventDefault();
- var cval = $.cookie('_session_id');
- $.post('/nf/markdown_to_html', {
- markdown:$textarea.val(),
- project:$('input.markdown_project', $container).val(),
- neighborhood:$('input.markdown_neighborhood', $container).val(),
- app:$('input.markdown_app', $container).val(),
- _session_id:cval
- },
- function(resp){
- $preview_area.html(resp);
- $preview_area.show();
- $textarea.hide();
- $preview.hide();
- $edit.show();
- });
- });
- $edit.click(function(evt){
- evt.preventDefault();
- $preview_area.hide();
- $textarea.show();
- $preview.show();
- $edit.hide();
- });
- $help.click(function(evt){
- evt.preventDefault();
- $help_contents.html('Loading...');
- $.get($help.attr('href'), 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();
- });
- $('.close', $help_area).bind('click', function() {
- $help_area.hide();
- });
+ new Editor({element: $textarea[0]}).render();
});
}
});
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/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 b134558..8339bc7 100644
--- a/Allura/allura/templates/widgets/markdown_edit.html
+++ b/Allura/allura/templates/widgets/markdown_edit.html
@@ -18,14 +18,7 @@
-#}
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
<div class="markdown_edit">
- <a href="#" class="markdown_preview btn" title="Preview"><b data-icon="{{g.icons['search'].char}}" class="ico {{g.icons['search'].css}}"></b> Preview</a>
- <a href="#" class="markdown_edit btn" style="display:none" title="Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}"></b> Edit</a>
- <a href="{{c.app.url}}markdown_syntax_dialog" class="markdown_help btn" title="Formatting Help"><b data-icon="{{g.icons['help'].char}}" class="ico {{g.icons['help'].css}}"></b> Formatting Help</a>
- <div style="clear:both"></div>
<textarea id="{{id or rendered_name}}" name="{{rendered_name}}" class="{{widget.css_class}}" {{widget.j2_attrs(attrs)}}>{{value or ''}}</textarea>
- <div class="markdown_preview" style="display:none"></div>
- <a href="#" class="markdown_preview btn" title="Preview"><b data-icon="{{g.icons['search'].char}}" class="ico {{g.icons['search'].css}}"></b> Preview</a>
- <a href="#" class="markdown_edit btn" style="display:none" title="Edit"><b data-icon="{{g.icons['pencil'].char}}" class="ico {{g.icons['pencil'].css}}"></b> Edit</a>
<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>
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index d36ef6e..d371ff5 100644
--- a/LICENSE
+++ b/LICENSE
@@ -229,7 +229,6 @@ under the MIT license. For details, see the individual files:
Allura/allura/lib/widgets/resources/js/jquery.autosize-min.js
Allura/allura/lib/widgets/resources/js/jquery.colorPicker.js
Allura/allura/lib/widgets/resources/js/jquery.tagsinput.js
- Allura/allura/lib/widgets/resources/js/jquery.textarea.js
Allura/allura/public/nf/js/jquery.flot.js
Allura/allura/public/nf/js/jquery.maxlength.min.js
allura/public/nf/js/jquery.viewport.js
http://git-wip-us.apache.org/repos/asf/allura/blob/62be7371/rat-excludes.txt
----------------------------------------------------------------------
diff --git a/rat-excludes.txt b/rat-excludes.txt
index ee547eb..95c2eaf 100644
--- a/rat-excludes.txt
+++ b/rat-excludes.txt
@@ -22,7 +22,6 @@ Allura/allura/lib/widgets/resources/js/jqfontselector.js
Allura/allura/lib/widgets/resources/js/jquery.autosize-min.js
Allura/allura/lib/widgets/resources/js/jquery.colorPicker.js
Allura/allura/lib/widgets/resources/js/jquery.tagsinput.js
-Allura/allura/lib/widgets/resources/js/jquery.textarea.js
Allura/allura/public/nf/js/jquery.flot.js
Allura/allura/public/nf/js/jquery.maxlength.min.js
Allura/allura/public/nf/js/jquery.tablesorter.js