diff --git a/images/grippie.png b/images/grippie.png new file mode 100644 index 00000000..6524d416 Binary files /dev/null and b/images/grippie.png differ diff --git a/jquery-wmd-plugin.js b/jquery-wmd-plugin.js index 0cd2065c..e4ed755e 100644 --- a/jquery-wmd-plugin.js +++ b/jquery-wmd-plugin.js @@ -1,4 +1,4 @@ -/* +/* * jQuery wmd plugin. */ diff --git a/jquery.textarearesizer.js b/jquery.textarearesizer.js new file mode 100644 index 00000000..55b61981 --- /dev/null +++ b/jquery.textarearesizer.js @@ -0,0 +1,77 @@ +/* + jQuery TextAreaResizer plugin + Created on 17th January 2008 by Ryan O'Dell + Version 1.0.4 + + Converted from Drupal -> textarea.js + Found source: http://plugins.jquery.com/misc/textarea.js + $Id: textarea.js,v 1.11.2.1 2007/04/18 02:41:19 drumm Exp $ + + 1.0.1 Updates to missing global 'var', added extra global variables, fixed multiple instances, improved iFrame support + 1.0.2 Updates according to textarea.focus + 1.0.3 Further updates including removing the textarea.focus and moving private variables to top + 1.0.4 Re-instated the blur/focus events, according to information supplied by dec + + +*/ +(function($) { + /* private variable "oHover" used to determine if you're still hovering over the same element */ + var textarea, staticOffset; // added the var declaration for 'staticOffset' thanks to issue logged by dec. + var iLastMousePos = 0; + var iMin = 32; + var grip; + /* TextAreaResizer plugin */ + $.fn.TextAreaResizer = function() { + return this.each(function() { + textarea = $(this).addClass('processed'), staticOffset = null; + + // 18-01-08 jQuery bind to pass data element rather than direct mousedown - Ryan O'Dell + // When wrapping the text area, work around an IE margin bug. See: + // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout + $(this).wrap('
') + .parent().append($('
').bind("mousedown",{el: this} , startDrag)); + + var grippie = $('div.grippie', $(this).parent())[0]; + grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px'; + + }); + }; + /* private functions */ + function startDrag(e) { + textarea = $(e.data.el); + textarea.blur(); + iLastMousePos = mousePosition(e).y; + staticOffset = textarea.height() - iLastMousePos + 5; + textarea.css('opacity', 0.25); + $(document).mousemove(performDrag).mouseup(endDrag); + return false; + } + + function performDrag(e) { + var iThisMousePos = mousePosition(e).y; + var iMousePos = staticOffset + iThisMousePos; + if (iLastMousePos >= (iThisMousePos)) { + iMousePos -= 5; + } + iLastMousePos = iThisMousePos; + iMousePos = Math.max(iMin, iMousePos); + textarea.height(iMousePos + 'px'); + if (iMousePos < iMin) { + endDrag(e); + } + return false; + } + + function endDrag(e) { + $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag); + textarea.css('opacity', 1); + textarea.focus(); + textarea = null; + staticOffset = null; + iLastMousePos = 0; + } + + function mousePosition(e) { + return { x: e.clientX + document.documentElement.scrollLeft, y: e.clientY + document.documentElement.scrollTop }; + }; +})(jQuery); \ No newline at end of file diff --git a/jquery.textarearesizer.min.js b/jquery.textarearesizer.min.js new file mode 100644 index 00000000..d7939ca7 --- /dev/null +++ b/jquery.textarearesizer.min.js @@ -0,0 +1 @@ +(function($){var textarea,staticOffset;var iLastMousePos=0;var iMin=32;var grip;$.fn.TextAreaResizer=function(){return this.each(function(){textarea=$(this).addClass('processed'),staticOffset=null;$(this).wrap('
').parent().append($('
').bind("mousedown",{el:this},startDrag));var grippie=$('div.grippie',$(this).parent())[0];grippie.style.marginRight=(grippie.offsetWidth-$(this)[0].offsetWidth)+'px'})};function startDrag(e){textarea=$(e.data.el);textarea.blur();iLastMousePos=mousePosition(e).y;staticOffset=textarea.height()-iLastMousePos+5;textarea.css('opacity',0.25);$(document).mousemove(performDrag).mouseup(endDrag);return false}function performDrag(e){var iThisMousePos=mousePosition(e).y;var iMousePos=staticOffset+iThisMousePos;if(iLastMousePos>=(iThisMousePos)){iMousePos-=5}iLastMousePos=iThisMousePos;iMousePos=Math.max(iMin,iMousePos);textarea.height(iMousePos+'px');if(iMousePosEnter the image URL.

" + - "

You can also add a title, which will be displayed as a tool tip.

" + - "

Example:
http://wmd-editor.com/images/cloud1.jpg \"Optional title\"

", + "

输入图片地址:

" + + "

您还可以为图片添加一个 tip ,即 img 元素的 alt 属性。

" + + "

示例:
http://wmd-editor.com/images/cloud1.jpg \"可选标题\"

", linkDialogText: - "

Enter the web address.

" + - "

You can also add a title, which will be displayed as a tool tip.

" + - "

Example:
http://wmd-editor.com/ \"Optional title\"

", + "

输入 Web 地址:

" + + "

您还可以添加一个标题,即 a 元素的 title 属性。

" + + "

示例:
http://wmd-editor.com/ \"可选标题\"

", // The default text that appears in the dialog input box when entering // links. @@ -1295,7 +1295,7 @@ var UndoManager = function(textarea, pastePollInterval, callback){ // {{{ WMDEditor.util = util; WMDEditor.position = position; WMDEditor.TextareaState = TextareaState; -WMDEditor.Checks = Checks; +WMDEditor.Chunks = Chunks; WMDEditor.InputPoller = InputPoller; WMDEditor.PreviewManager = PreviewManager; WMDEditor.UndoManager = UndoManager; @@ -1521,52 +1521,64 @@ var wmdBase = function(wmd, wmd_options){ // {{{ return button; } + var spacerIndex = 0; function addSpacer() { var spacer = document.createElement("li"); - spacer.className = "wmd-spacer"; + switch(spacerIndex){ + case 0: + spacer.className = "wmd-spacer wmd-spacer1"; + break; + case 1: + spacer.className = "wmd-spacer wmd-spacer2"; + break; + case 2: + spacer.className = "wmd-spacer wmd-spacer3"; + break; + } buttonRow.appendChild(spacer); + spacerIndex = spacerIndex + 1; return spacer; } - var boldButton = addButton("wmd-bold-button", "Strong Ctrl+B", command.doBold); - var italicButton = addButton("wmd-italic-button", "Emphasis Ctrl+I", command.doItalic); + var boldButton = addButton("wmd-bold-button", "加粗 Ctrl+B", command.doBold); + var italicButton = addButton("wmd-italic-button", "斜体 Ctrl+I", command.doItalic); var spacer1 = addSpacer(); - var linkButton = addButton("wmd-link-button", "Hyperlink Ctrl+L", function(chunk, postProcessing, useDefaultText) { + var linkButton = addButton("wmd-link-button", "链接 Ctrl+L", function(chunk, postProcessing, useDefaultText) { return command.doLinkOrImage(chunk, postProcessing, false); }); - var quoteButton = addButton("wmd-quote-button", "Blockquote
Ctrl+Q", command.doBlockquote); - var codeButton = addButton("wmd-code-button", "Code Sample
 Ctrl+K", command.doCode);
-            var imageButton = addButton("wmd-image-button", "Image  Ctrl+G", function(chunk, postProcessing, useDefaultText) {
+            var quoteButton = addButton("wmd-quote-button", "引用 
Ctrl+Q", command.doBlockquote); + var codeButton = addButton("wmd-code-button", "代码片段
 Ctrl+K", command.doCode);
+            var imageButton = addButton("wmd-image-button", "图片  Ctrl+G", function(chunk, postProcessing, useDefaultText) {
                 return command.doLinkOrImage(chunk, postProcessing, true);
             });
             
             var spacer2 = addSpacer();
 
-            var olistButton = addButton("wmd-olist-button", "Numbered List 
    Ctrl+O", function(chunk, postProcessing, useDefaultText) { + var olistButton = addButton("wmd-olist-button", "数字列表
      Ctrl+O", function(chunk, postProcessing, useDefaultText) { command.doList(chunk, postProcessing, true, useDefaultText); }); - var ulistButton = addButton("wmd-ulist-button", "Bulleted List