169 lines
6.1 KiB
HTML
169 lines
6.1 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<!--
|
||
|
* WYMeditor : what you see is What You Mean web-based editor
|
||
|
* Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/
|
||
|
* Dual licensed under the MIT (MIT-license.txt)
|
||
|
* and GPL (GPL-license.txt) licenses.
|
||
|
*
|
||
|
* For further information visit:
|
||
|
* http://www.wymeditor.org/
|
||
|
*
|
||
|
* File Name:
|
||
|
* 14-more-inline-elements.html
|
||
|
* WYMeditor integration example - more inline elements.
|
||
|
* See the documentation for more info.
|
||
|
*
|
||
|
* File Authors:
|
||
|
* Jean-Francois Hovinne - http://www.hovinne.com/
|
||
|
-->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<title>WYMeditor</title>
|
||
|
<script type="text/javascript" src="../jquery/jquery.js"></script>
|
||
|
<script type="text/javascript" src="../wymeditor/jquery.wymeditor.min.js"></script>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
jQuery(function() {
|
||
|
jQuery('.wymeditor').wymeditor({
|
||
|
|
||
|
html: '<p>Hello, World!<\/p>', //set editor's value
|
||
|
stylesheet: 'styles.css', //styles to load
|
||
|
postInit: function(wym) {
|
||
|
|
||
|
//add the 'Wrap' translation (used here for the dialog's title)
|
||
|
jQuery.extend(WYMeditor.STRINGS['en'], {
|
||
|
'Wrap': 'Wrap'
|
||
|
});
|
||
|
|
||
|
//set the editor's content
|
||
|
wym._html("<p>This is some text with which to test.</p>"
|
||
|
+ "<p>Select 'some text' and click on the Wrap button.</p>"
|
||
|
+ "<p>Select it again and click on the Unwrap button.</p>");
|
||
|
|
||
|
//construct the wrap button's html
|
||
|
//note: the button image needs to be created ;)
|
||
|
var html = "<li class='wym_tools_wrap'>"
|
||
|
+ "<a href='#'"
|
||
|
+ " title='Wrap'"
|
||
|
+ " style='background-image:"
|
||
|
+ " url(../wymeditor/skins/default/icons.png)'>"
|
||
|
+ "Wrap"
|
||
|
+ "</a></li>";
|
||
|
|
||
|
//add the button to the tools box
|
||
|
jQuery(wym._box)
|
||
|
.find(wym._options.toolsSelector + wym._options.toolsListSelector)
|
||
|
.append(html);
|
||
|
|
||
|
//construct the unwrap button's html
|
||
|
//note: the button image needs to be created ;)
|
||
|
html = "<li class='wym_tools_unwrap'>"
|
||
|
+ "<a href='#'"
|
||
|
+ " title='Unwrap'"
|
||
|
+ " style='background-image:"
|
||
|
+ " url(../wymeditor/skins/default/icons.png)'>"
|
||
|
+ "Unwrap"
|
||
|
+ "</a></li>";
|
||
|
|
||
|
//add the button to the tools box
|
||
|
jQuery(wym._box)
|
||
|
.find(wym._options.toolsSelector + wym._options.toolsListSelector)
|
||
|
.append(html);
|
||
|
|
||
|
//construct the dialog's html
|
||
|
html = "<body class='wym_dialog wym_dialog_wrap'"
|
||
|
+ " onload='WYMeditor.INIT_DIALOG(" + WYMeditor.INDEX + ")'"
|
||
|
+ ">"
|
||
|
+ "<form>"
|
||
|
+ "<fieldset>"
|
||
|
+ "<input type='hidden' class='wym_dialog_type' value='"
|
||
|
+ "Wrap"
|
||
|
+ "' />"
|
||
|
+ "<legend>Wrap</legend>"
|
||
|
+ "<div class='row'>"
|
||
|
+ "<label>Type</label>"
|
||
|
+ "<select class='wym_select_inline_element'>"
|
||
|
+ "<option selected value='abbr'>Abbreviation</option>"
|
||
|
+ "<option value='acronym'>Acronym</option>"
|
||
|
+ "<option value='cite'>Citation, reference</option>"
|
||
|
+ "<option value='code'>Code</option>"
|
||
|
+ "<option value='del'>Deleted content</option>"
|
||
|
+ "<option value='ins'>Inserted content</option>"
|
||
|
+ "<option value='span'>Generic</option>"
|
||
|
+ "</select>"
|
||
|
+ "</div>"
|
||
|
+ "<div class='row'>"
|
||
|
+ "<label>Title</label>"
|
||
|
+ "<input type='text' class='wym_title' value='' size='40' />"
|
||
|
+ "</div>"
|
||
|
+ "<div class='row row-indent'>"
|
||
|
+ "<input class='wym_submit wym_submit_wrap' type='button'"
|
||
|
+ " value='{Submit}' />"
|
||
|
+ "<input class='wym_cancel' type='button'"
|
||
|
+ "value='{Cancel}' />"
|
||
|
+ "</div>"
|
||
|
+ "</fieldset>"
|
||
|
+ "</form>"
|
||
|
+ "</body>";
|
||
|
|
||
|
//handle click event on wrap button
|
||
|
jQuery(wym._box)
|
||
|
.find('li.wym_tools_wrap a').click(function() {
|
||
|
wym.dialog( 'Wrap', null, html );
|
||
|
return(false);
|
||
|
});
|
||
|
|
||
|
//handle click event on unwrap button
|
||
|
jQuery(wym._box)
|
||
|
.find('li.wym_tools_unwrap a').click(function() {
|
||
|
wym.unwrap();
|
||
|
return(false);
|
||
|
});
|
||
|
|
||
|
},
|
||
|
|
||
|
//handle click event on dialog's submit button
|
||
|
postInitDialog: function( wym, wdw ) {
|
||
|
|
||
|
//wdw is the dialog's window
|
||
|
//wym is the WYMeditor instance
|
||
|
|
||
|
var body = wdw.document.body;
|
||
|
|
||
|
jQuery( body )
|
||
|
.find('input.wym_submit_wrap')
|
||
|
.click(function() {
|
||
|
|
||
|
var tag = jQuery(body).find('.wym_select_inline_element').val();
|
||
|
var title = jQuery(body).find('.wym_title').val();
|
||
|
|
||
|
wym.wrap( '<' + tag + ' title="' + title + '">', '</' + tag + '>' );
|
||
|
wdw.close();
|
||
|
|
||
|
});
|
||
|
}
|
||
|
|
||
|
});
|
||
|
});
|
||
|
|
||
|
</script>
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<h1>WYMeditor integration example - more inline elements</h1>
|
||
|
<h2>Adding <code title="Abbreviation">abbr</code>, <code title="Acronym">acronym</code>, <code title="Citation">cite</code>,
|
||
|
<code title="Code">code</code>, <code title="Deleted content">del</code>, <code title="Inserted content">ins</code>
|
||
|
and <code title="Generic inline element">span</code> support</h2>
|
||
|
<p><a href="http://www.wymeditor.org/">WYMeditor</a> is a web-based XHTML WYSIWYM editor.</p>
|
||
|
<form method="post" action="">
|
||
|
<textarea class="wymeditor"></textarea>
|
||
|
<input type="submit" class="wymupdate" />
|
||
|
</form>
|
||
|
|
||
|
</body>
|
||
|
|
||
|
</html>
|