--- /dev/null
+<%--\r
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+--%>\r
+\r
+<%@ include file="/html/taglib/init.jsp" %>\r
+\r
+<%\r
+String cssClass = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:cssClass"));\r
+String editorImpl = (String)request.getAttribute("liferay-ui:input-editor:editorImpl");\r
+String initMethod = (String)request.getAttribute("liferay-ui:input-editor:initMethod");\r
+String name = namespace + GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:name"));\r
+\r
+String onChangeMethod = (String)request.getAttribute("liferay-ui:input-editor:onChangeMethod");\r
+\r
+if (Validator.isNotNull(onChangeMethod)) {\r
+ onChangeMethod = namespace + onChangeMethod;\r
+}\r
+\r
+boolean resizable = GetterUtil.getBoolean((String)request.getAttribute("liferay-ui:input-editor:resizable"));\r
+boolean skipEditorLoading = GetterUtil.getBoolean((String)request.getAttribute("liferay-ui:input-editor:skipEditorLoading"));\r
+%>\r
+\r
+<c:if test="<%= !skipEditorLoading %>">\r
+ <liferay-util:html-top outputKey="js_editor_tinymce">\r
+\r
+ <%\r
+ long javaScriptLastModified = ServletContextUtil.getLastModified(application, "/html/js/", true);\r
+ %>\r
+\r
+ <script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNHost() + themeDisplay.getPathJavaScript() + "/editor/tiny_mce/tiny_mce.js", javaScriptLastModified)) %>" type="text/javascript"></script>\r
+\r
+ <script type="text/javascript">\r
+ Liferay.namespace('EDITORS')['<%= editorImpl %>'] = true;\r
+ </script>\r
+ </liferay-util:html-top>\r
+</c:if>\r
+\r
+<div class="<%= cssClass %>">\r
+ <textarea id="<%= name %>" name="<%= name %>" style="height: 100%; width: 100%;"></textarea>\r
+</div>\r
+\r
+<aui:script>\r
+ window['<%= name %>'] = {\r
+ onChangeCallbackCounter: 0,\r
+\r
+ destroy: function() {\r
+ tinyMCE.editors['<%= name %>'].destroy();\r
+\r
+ delete window['<%= name %>'];\r
+ },\r
+\r
+ focus: function() {\r
+ tinyMCE.editors['<%= name %>'].focus();\r
+ },\r
+\r
+ fileBrowserCallback: function(field_name, url, type) {\r
+ },\r
+\r
+ getHTML: function() {\r
+ return tinyMCE.editors['<%= name %>'].getContent();\r
+ },\r
+\r
+ init: function(value) {\r
+ if (typeof value == 'string') {\r
+ value = decodeURIComponent(value);\r
+ }\r
+ else {\r
+ value = '';\r
+ }\r
+\r
+ window['<%= name %>'].setHTML(value);\r
+ },\r
+\r
+ initInstanceCallback: function() {\r
+ <c:if test="<%= Validator.isNotNull(initMethod) %>">\r
+ window['<%= name %>'].init(<%= HtmlUtil.escape(namespace + initMethod) %>());\r
+ </c:if>\r
+ },\r
+\r
+ <%\r
+ if (Validator.isNotNull(onChangeMethod)) {\r
+ %>\r
+\r
+ onChangeCallback: function(tinyMCE) {\r
+\r
+ // This purposely ignores the first callback event because each call\r
+ // to setContent triggers an undo level which fires the callback\r
+ // when no changes have yet been made.\r
+\r
+ // setContent is not really the correct way of initializing this\r
+ // editor with content. The content should be placed statically\r
+ // (from the editor's perspective) within the textarea. This is a\r
+ // problem from the portal's perspective because it's passing the\r
+ // content via a javascript method (initMethod).\r
+\r
+ var onChangeCallbackCounter = window['<%= name %>'].onChangeCallbackCounter;\r
+\r
+ if (onChangeCallbackCounter > 0) {\r
+\r
+ <%= HtmlUtil.escapeJS(onChangeMethod) %>(window['<%= name %>'].getHTML());\r
+\r
+ }\r
+\r
+ onChangeCallbackCounter++;\r
+ },\r
+\r
+ <%\r
+ }\r
+ %>\r
+\r
+ setHTML: function(value) {\r
+ tinyMCE.editors['<%= name %>'].setContent(value);\r
+ }\r
+ };\r
+\r
+ tinyMCE.init(\r
+ {\r
+ convert_urls: false,\r
+ elements: '<%= name %>',\r
+ extended_valid_elements: 'a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]',\r
+ file_browser_callback: window['<%= name %>'].fileBrowserCallback,\r
+ init_instance_callback: window['<%= name %>'].initInstanceCallback,\r
+ invalid_elements: 'script',\r
+ language: '<%= HtmlUtil.escape(locale.getLanguage()) %>',\r
+ mode: 'textareas',\r
+\r
+ <%\r
+ if (Validator.isNotNull(onChangeMethod)) {\r
+ %>\r
+\r
+ onchange_callback: window['<%= name %>'].onChangeCallback,\r
+\r
+ <%\r
+ }\r
+ %>\r
+\r
+ plugins: 'preview,print,contextmenu',\r
+ relative_urls: false,\r
+ remove_script_host: false,\r
+ theme: 'advanced',\r
+ theme_advanced_buttons1_add: 'code,preview,print',\r
+ theme_advanced_buttons2: '',\r
+ theme_advanced_buttons3: '',\r
+ theme_advanced_disable: 'formatselect,styleselect,help,strikethrough',\r
+ theme_advanced_resize_horizontal: '<%= resizable %>',\r
+ theme_advanced_toolbar_align: 'left',\r
+ theme_advanced_toolbar_location: 'top'\r
+ }\r
+ );\r
+</aui:script>
\ No newline at end of file