Created
May 22, 2009 17:14
-
-
Save davglass/116244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | |
<%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.1" prefix="str" %> | |
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> | |
<%@ attribute name="rteData" type="java.lang.String" required="true" %> | |
<%@ attribute name="editorData" type="java.lang.String" required="true" %> | |
<%@ attribute name="formname" type="java.lang.String" required="true" %> | |
<link rel="stylesheet" type="text/css" href="<c:url value='/scripts/yui_2.7.0/yui/build/assets/skins/sam/skin.css'/>" /> | |
<link rel="stylesheet" type="text/css" href="<c:url value='/scripts/yui_2.7.0/yui/build/fonts/fonts-min.css'/>" /> | |
<link rel="stylesheet" type="text/css" href="<c:url value='/scripts/yui_2.7.0/yui/build/resize/assets/skins/sam/resize.css'/>" /> | |
<link rel="stylesheet" type="text/css" href="<c:url value='/scripts/yui_2.7.0/yui/build/editor/assets/skins/sam/editor.css'/>" /> | |
<link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/rte.css'/>" /> | |
<script type="text/javascript" src="<c:url value='/scripts/yui_2.7.0/yui/build/yahoo-dom-event/yahoo-dom-event.js'/>"></script> | |
<script type="text/javascript" src="<c:url value='/scripts/yui_2.7.0/yui/build/animation/animation-min.js'/>"></script> | |
<script type="text/javascript" src="<c:url value='/scripts/yui_2.7.0/yui/build/element/element-min.js'/>"></script> | |
<script type="text/javascript" src="<c:url value='/scripts/yui_2.7.0/yui/build/dragdrop/dragdrop-min.js'/>"></script> | |
<script type="text/javascript" src="<c:url value='/scripts/yui_2.7.0/yui/build/resize/resize-min.js'/>"></script> | |
<script type="text/javascript" src="<c:url value='/scripts/yui_2.7.0/yui/build/editor/editor-debug.js'/>"></script> | |
<div class="yui-skin-sam"> | |
<textarea name="${rteData}" id="${rteData}" > | |
<c:out value="${editorData}" escapeXml="false" /> | |
</textarea> | |
<span id="required" style="color: red;display:inline">*</span> | |
<strong><spring:message code="warning.word.copypaste"/></strong> | |
</div> | |
<script> | |
var Dom = YAHOO.util.Dom, | |
Event = YAHOO.util.Event, | |
editor = null, | |
resize = null; | |
(function() { | |
Event.onDOMReady(function() { | |
editor = new YAHOO.widget.Editor('<c:out value="${rteData}"/>',BPS.defaultEditorAttrs); | |
delete editor._defaultToolbar.titlebar; | |
editor.on('toolbarLoaded', function() { | |
var toolsConfig = { | |
label: 'Tools', | |
buttons: [ | |
{ | |
type: 'push', | |
label: 'Spell Check', | |
value: 'spellcheck' | |
} | |
] | |
}; | |
editor.toolbar.addButtonGroup(toolsConfig); | |
editor.toolbar.on('spellcheckClick', function(ev) { | |
editor.saveHTML(); | |
BPS.xscSpellcheck('<c:out value="${rteData}"/>'); | |
}); | |
}); | |
editor.on('editorContentLoaded', function() { | |
resize = new YAHOO.util.Resize(editor.get('element_cont').get('element'), { | |
handles: ['br'], | |
autoRatio: true, | |
status: true, | |
proxy: true, | |
setSize: false //This is where the magic happens | |
}); | |
resize.on('startResize', function() { | |
this.hide(); | |
this.set('disabled', true); | |
}, editor, true); | |
resize.on('resize', function(args) { | |
var h = args.height; | |
var th = (this.toolbar.get('element').clientHeight + 2); //It has a 1px border.. | |
var dh = (this.dompath.clientHeight + 1); //It has a 1px top border.. | |
var newH = (h - th - dh); | |
this.set('width', args.width + 'px'); | |
this.set('height', newH + 'px'); | |
this.set('disabled', false); | |
this.show(); | |
}, editor, true); | |
}); | |
editor.render(); | |
}); | |
})(); | |
addLoadEvent(function(){ | |
BPS.initializeSpellCheck( | |
"<%=org.springframework.web.servlet.support.RequestContextUtils.getLocale(request).getLanguage()%>", | |
"<c:url value='/common/xmlmind/xsc_server.jsp'/>", | |
"<c:out value="${formname}"/>"); | |
}); | |
function spellcheckFinish() { | |
var value = document.getElementById("iframehtmlcopy").value; | |
editor.setEditorHTML(value); | |
} | |
</script> | |
BPS.defaultEditorAttrs = { | |
height: '200px', | |
width: '730px', | |
dompath: true, | |
animate: true, | |
handleSubmit: true, | |
filterWord: true, | |
toolbar: { | |
titlebar: 'My Editor', | |
buttons: [ | |
{ group: 'fontstyle', label: 'Font Name and Size', | |
buttons: [ | |
{ type: 'select', label: 'Arial', value: 'fontname', disabled: true, | |
menu: [ | |
{ text: 'Arial', checked: true }, | |
{ text: 'Arial Black' }, | |
{ text: 'Comic Sans MS' }, | |
{ text: 'Courier New' }, | |
{ text: 'Lucida Console' }, | |
{ text: 'Tahoma' }, | |
{ text: 'Times New Roman' }, | |
{ text: 'Trebuchet MS' }, | |
{ text: 'Verdana' } | |
] | |
}, | |
{ type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true } | |
] | |
}, | |
{ type: 'separator' }, | |
{ group: 'textstyle', label: 'Font Style', | |
buttons: [ | |
{ type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' }, | |
{ type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' }, | |
{ type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' } | |
] | |
}, | |
{ type: 'separator' }, | |
{ group: 'alignment', label: 'Alignment', | |
buttons: [ | |
{ type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' }, | |
{ type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' }, | |
{ type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' }, | |
{ type: 'push', label: 'Justify', value: 'justifyfull' } | |
] | |
}, | |
{ type: 'separator' }, | |
{ group: 'indentlist', label: 'Lists', | |
buttons: [ | |
{ type: 'push', label: 'Indent', value: 'indent', disabled: true }, | |
{ type: 'push', label: 'Outdent', value: 'outdent', disabled: true }, | |
{ type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' }, | |
{ type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' } | |
] | |
} | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment