You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2017/01/20 08:42:48 UTC
svn commit: r1779576 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main:
java/org/apache/myfaces/tobago/example/demo/
webapp/content/20-component/110-wysiwyg/00-tinymce/
Author: lofwyr
Date: Fri Jan 20 08:42:48 2017
New Revision: 1779576
URL: http://svn.apache.org/viewvc?rev=1779576&view=rev
Log:
Improve demo: TinyMCE
* fix the demo page for TinyMCE
* tinymce.js: TinyMCE is in readonly mode if <tc:textarea readonly=true> is set
[developed by hnoeth]
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TinyMceController.java
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.xhtml
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TinyMceController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TinyMceController.java?rev=1779576&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TinyMceController.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TinyMceController.java Fri Jan 20 08:42:48 2017
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.demo;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+import java.io.Serializable;
+
+@SessionScoped
+@Named
+public class TinyMceController extends SourceFileReader implements Serializable {
+
+ private String text;
+
+ public TinyMceController() {
+ text = "<h1>Sonne</h1>"
+ + "<p>Die Sonne ist ein Stern in der Galaxie Milchstraße.</p>";
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getSource() {
+ return getSource("tinymce.js");
+ }
+
+ public boolean isEditorAvailable() {
+ return !"error".equals(getSource("tinymce/js/tinymce/tinymce.min.js"));
+ }
+}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.js?rev=1779576&r1=1779575&r2=1779576&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.js Fri Jan 20 08:42:48 2017
@@ -50,6 +50,15 @@
});
text.outerHeight(text.outerHeight() - heightDelta);
}, 50);
+ },
+ setup: function(ed) {
+ ed.on('init', function(args) {
+ // TinyMCE v4
+ if (jQuery("#" + args.target.id.replace(/:/g, "\\:")).attr('readonly') == "readonly") {
+ console.debug("RO!");
+ tinymce.get(args.target.id).setMode('readonly');
+ }
+ });
}
});
},
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.xhtml?rev=1779576&r1=1779575&r2=1779576&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/110-wysiwyg/00-tinymce/tinymce.xhtml Fri Jan 20 08:42:48 2017
@@ -19,16 +19,17 @@
<ui:composition template="/main.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:param name="title" value="#{demoBundle.tinymce}"/>
- <tc:script file="content/20-component/110-wysiwyg/00-tinymce/tinymce/js/tinymce/tinymce.min.js"/>
- <tc:script file="content/20-component/110-wysiwyg/00-tinymce/tinymce.js"/>
+ <tc:script
+ file="#{request.contextPath}/content/20-component/110-wysiwyg/00-tinymce/tinymce/js/tinymce/tinymce.min.js"/>
+ <tc:script file="#{request.contextPath}/content/20-component/110-wysiwyg/00-tinymce/tinymce.js"/>
<tc:section label="Installation">
<p>Download <tc:link link="http://www.tinymce.com/" target="_blank" label="TinyMCE"/>
- and unpack the ZIP file directly beside this XHTML-file.
- Then restart this application (this is needed, because the resource manager needs to scan the content).</p>
+ and unpack the ZIP file directly beside this XHTML-file.</p>
</tc:section>
<tc:section label="Editor">
@@ -38,15 +39,24 @@
<code class="language-markup"><tc:dataAttribute name="html-editor" value=""/></code>,
to mark this textarea to be used as rich text editor. The rest does the script: tinymce.js</p>
- <tc:button label="show/hide" action="#{tinymceController.switchCollapsed}"/>
- <tc:box label="tinymce.js" collapsed="#{tinymceController.collapsed}">
- <pre><code class="language-javascript"><tc:out value="#{tinymceController.source}"/></code></pre>
+ <tc:box id="sourceCodeBox" label="tinymce.js" collapsed="true" collapsedMode="hidden">
+ <f:facet name="bar">
+ <tc:buttons>
+ <tc:button label="show" omit="true">
+ <tc:operation name="show" for="sourceCodeBox"/>
+ </tc:button>
+ <tc:button label="hide" omit="true">
+ <tc:operation name="hide" for="sourceCodeBox"/>
+ </tc:button>
+ </tc:buttons>
+ </f:facet>
+ <pre><code class="language-javascript"><tc:out value="#{tinyMceController.source}"/></code></pre>
</tc:box>
- <tc:out markup="strong" rendered="#{not tinymceController.editorAvailable}"
+ <tc:out markup="strong" rendered="#{not tinyMceController.editorAvailable}"
value="The TinyMCE is not installed! Using the fallback textarea."/>
- <tc:textarea value="#{tinymceController.text}">
+ <tc:textarea value="#{tinyMceController.text}">
<tc:style width="400px" height="300px"/>
<tc:dataAttribute name="html-editor" value=""/>
</tc:textarea>