Skip to content

Instantly share code, notes, and snippets.

@zanvar
Created May 29, 2009 02:59
Show Gist options
  • Save zanvar/119747 to your computer and use it in GitHub Desktop.
Save zanvar/119747 to your computer and use it in GitHub Desktop.
<%@ 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" %>
<%@ attribute name="readOnly" 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}" style="visibility: hidden;">
<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', ${readOnly});
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment