From 8044e805e3a0e2feef53d1db96a4c6d17485165c Mon Sep 17 00:00:00 2001 From: Anand Chitipothu Date: Thu, 10 Dec 2009 19:15:14 +0530 Subject: [PATCH] allow customizing dialog messages and help links --- wmd.css | 12 +++++------- wmd.js | 41 ++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/wmd.css b/wmd.css index a0ff793..0367c2c 100644 --- a/wmd.css +++ b/wmd.css @@ -1,7 +1,3 @@ -body -{ - background-color: White -} .wmd-panel { @@ -19,7 +15,9 @@ body .wmd-button-bar { width: 100%; + /* background-color: Silver; + */ } .wmd-input @@ -30,12 +28,12 @@ body border: 1px solid DarkGray; } -#wmd-preview +.wmd-preview { - background-color: LightSkyBlue; + background-color: LightGray; } -#wmd-output +.wmd-output { background-color: Pink; } diff --git a/wmd.js b/wmd.js index 75ff0a9..dd2cfee 100644 --- a/wmd.js +++ b/wmd.js @@ -1,5 +1,5 @@ function setup_wmd(wmd_options) { - + var Attacklab = Attacklab || {}; wmd_options = wmd_options || top.wmd_options || {}; @@ -18,7 +18,7 @@ Attacklab.wmdBase = function(){ wmd.Global = {}; wmd.buttons = {}; - wmd.showdown = top.Attacklab.showdown; + wmd.showdown = top.Attacklab && top.Attacklab.showdown; var util = wmd.Util; var position = wmd.Position; @@ -43,8 +43,8 @@ Attacklab.wmdBase = function(){ // The text that appears on the upper part of the dialog box when // entering links. - var imageDialogText = "

Enter 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\"

"; - var 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\"

"; + var imageDialogText = wmd_options.imageDialogText || "

Enter 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\"

"; + var linkDialogText = wmd_options.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\"

"; // The default text that appears in the dialog input box when entering // links. @@ -59,9 +59,9 @@ Attacklab.wmdBase = function(){ var pastePollInterval = 100; // The link and title for the help button - var helpLink = "http://wmd-editor.com/"; - var helpHoverTitle = "WMD website"; - var helpTarget = "_blank"; + var helpLink = wmd_options.helpLink || "http://wmd-editor.com/"; + var helpHoverTitle = wmd_options.helpHoverTitle || "WMD website"; + var helpTarget = wmd_options.helpTarget || "_blank"; // ------------------------------------------------------------------- // END OF YOUR CHANGES @@ -930,22 +930,27 @@ Attacklab.wmdBase = function(){ var xoffset = 0; - function addButton(name, title, textOp) { + function createButton(name, title, textOp) { var button = document.createElement("li"); wmd.buttons[name] = button; - button.className = "wmd-button " + name; + button.XShift = xoffset + "px"; + xoffset -= 20; - button.title = title; + if (title) + button.title = title; + if (textOp) button.textOp = textOp; - - button.XShift = xoffset + "px"; - xoffset -= 20; - + + return button; + } + + function addButton(name, title, textOp) { + var button = createButton(name, title, textOp); + setupButton(button, true); buttonRow.appendChild(button); - return button; } @@ -1000,8 +1005,10 @@ Attacklab.wmdBase = function(){ manager.redo(); }; - var helpButton = addButton("wmd-help-button"); + var helpButton = createButton("wmd-help-button"); helpButton.isHelp = true; + setupButton(helpButton, true); + buttonRow.appendChild(helpButton); var helpAnchor = document.createElement("a"); helpAnchor.href = helpLink; @@ -2305,4 +2312,4 @@ if(!Attacklab.wmd) Attacklab.Util.startEditor(); }; -} +} \ No newline at end of file