Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
frost-nzcr4 frost-nzcr4
file 75 lines (68 sloc) 2.455 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Example: Custom controls - jWYSIWYG</title>
<link rel="stylesheet" type="text/css" href="../lib/blueprint/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="../lib/blueprint/print.css" media="print" />
<!--[if lt IE 8]><link rel="stylesheet" href="../lib/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]-->
<link rel="stylesheet" href="../../jquery.wysiwyg.css" type="text/css"/>
<script type="text/javascript" src="../lib/jquery.js"></script>
<script type="text/javascript" src="../../jquery.wysiwyg.js"></script>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
$("textarea").wysiwyg({
rmUnusedControls: true,
controls: {
bold: { visible : true },
html: { visible : true },
insertOrderedList: { visible : true },
removeFormat: { visible : true }
}
});

$("input[name=add]").click(function () {
$("textarea").wysiwyg("addControl", "quote", {
groupIndex: 2,
icon: './../tests/images/quote02.gif',
tooltip: 'Quote',
tags: ['blockquote'],
exec: function () {
var range = this.getInternalRange(),
common = range.commonAncestorContainer,
blockquote = this.dom.getElement("blockquote");

// if a text node is selected, we want to make the wrap the whole element, not just some text
if (common.nodeType === 3) {
common = common.parentNode;
}

if (blockquote && $(blockquote).hasClass("quote")) {
$(common).unwrap();
}
else {
if ("body" !== common.nodeName.toLowerCase()) {
$(common).wrap("<blockquote class='quote' />");
}
}
},
callback: function (event, Wysiwyg) {
alert("callback triggered!");
}
});
});

$("input[name=makeBold]").click(function () {
$("textarea").wysiwyg("triggerControl", "bold");
});
});
})(jQuery);
</script>
</head>
<body><div class="container">
<h1>jWYSIWYG</h1>
<h2>Example: Custom controls</h2>

<input type="button" value="Add new control" name="add"/>
<input type="button" value="Make selected text bold" name="makeBold"/>

<textarea name="text"></textarea>

<hr/>
<a href="index.html">Index</a>
</div></body>
</html>
Something went wrong with that request. Please try again.