Skip to content

Commit

Permalink
allow customizing dialog messages and help links
Browse files Browse the repository at this point in the history
  • Loading branch information
anandology committed Dec 10, 2009
1 parent 78612cd commit 8044e80
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
12 changes: 5 additions & 7 deletions wmd.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
body
{
background-color: White
}

.wmd-panel
{
Expand All @@ -19,7 +15,9 @@ body
.wmd-button-bar
{
width: 100%;
/*
background-color: Silver;
*/
}

.wmd-input
Expand All @@ -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;
}
Expand Down
41 changes: 24 additions & 17 deletions wmd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function setup_wmd(wmd_options) {

var Attacklab = Attacklab || {};
wmd_options = wmd_options || top.wmd_options || {};

Expand All @@ -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;
Expand All @@ -43,8 +43,8 @@ Attacklab.wmdBase = function(){

// The text that appears on the upper part of the dialog box when
// entering links.
var imageDialogText = "<p style='margin-top: 0px'><b>Enter the image URL.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/images/cloud1.jpg \"Optional title\"</p>";
var linkDialogText = "<p style='margin-top: 0px'><b>Enter the web address.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/ \"Optional title\"</p>";
var imageDialogText = wmd_options.imageDialogText || "<p style='margin-top: 0px'><b>Enter the image URL.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/images/cloud1.jpg \"Optional title\"</p>";
var linkDialogText = wmd_options.linkDialogText || "<p style='margin-top: 0px'><b>Enter the web address.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/ \"Optional title\"</p>";

// The default text that appears in the dialog input box when entering
// links.
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2305,4 +2312,4 @@ if(!Attacklab.wmd)
Attacklab.Util.startEditor();
};

}
}

0 comments on commit 8044e80

Please sign in to comment.