You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2013/08/27 21:44:58 UTC

svn commit: r1517952 - in /openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user: ChatPanel.java ChatToolbar.html ChatToolbar.java

Author: solomax
Date: Tue Aug 27 19:44:57 2013
New Revision: 1517952

URL: http://svn.apache.org/r1517952
Log:
[OPENMEETINGS-558] chat toolbar is added

Added:
    openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.html
    openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.java
Modified:
    openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java

Modified: openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java?rev=1517952&r1=1517951&r2=1517952&view=diff
==============================================================================
--- openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java (original)
+++ openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java Tue Aug 27 19:44:57 2013
@@ -49,7 +49,6 @@ import org.slf4j.Logger;
 
 import com.googlecode.wicket.jquery.ui.plugins.emoticons.EmoticonsBehavior;
 import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor;
-import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.DefaultWysiwygToolbar;
 
 public class ChatPanel extends UserPanel {
 	private static final Logger log = Red5LoggerFactory.getLogger(ChatPanel.class, webAppRootKey);
@@ -98,7 +97,7 @@ public class ChatPanel extends UserPanel
 		add(new EmoticonsBehavior("#" + MESSAGE_AREA_ID));
 		add(new WebMarkupContainer("messages").setMarkupId(MESSAGE_AREA_ID));
 		final Form<Void> f = new Form<Void>("sendForm");
-		DefaultWysiwygToolbar toolbar = new DefaultWysiwygToolbar("toolbarContainer");
+		ChatToolbar toolbar = new ChatToolbar("toolbarContainer");
 		f.add(toolbar);
 		f.add(new WysiwygEditor("message", new PropertyModel<String>(ChatPanel.this, "message"), toolbar).setOutputMarkupId(true));
 		f.add(new Button("send").add(new AjaxFormSubmitBehavior("onclick"){

Added: openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.html
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.html?rev=1517952&view=auto
==============================================================================
--- openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.html (added)
+++ openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.html Tue Aug 27 19:44:57 2013
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+
+<wicket:panel>
+	<script type="text/javascript">
+    function emtClick(emoticon) {
+        var editor = $($('#bToolbar').attr('data-target'));
+        editor.html(editor.html() + ' ' + emoticon + ' ');
+    }
+	$(function() {
+		 var emots = [":-)", ":)", ":o)", ":c)", ":^)", ":-D", ":-(", ":-9", ";-)", ":-P", ":-p", ":-Þ", ":-b"
+		 	, ":-O", ":-/", ":-X", ":-#", ":'(", "B-)", "8-)", ":-\\", ";*(", ":-*", ":]", ":>", "=]", "=)", "8)"
+		 	, ":}", ":D", "8D", "XD", "xD", "=D", ":(", ":<", ":[", ":{", "=(", ";)", ";]", ";D", ":P", ":p"
+		 	, "=P", "=p", ":b", ":Þ", ":O", "8O", ":/", "=/", ":S", ":#", ":X", "B)", "O:)", "<3", ";(", ">:)"
+		 	, ">;)", ">:(", "O_o", "O_O", "o_o", "0_o", "T_T", "^_^", "?-)"];
+		 var emotMenuList = $('#emotMenuList');
+		 var rowSize = 15;
+		 var row = $('<tr></tr>');
+		 for (var i = 0; i < emots.length; ++i) {
+		 	row.append('<td><div class="emt" onclick="emtClick(\'' + emots[i] + '\');" style="font-size: 10pt">'
+		 		+ emots[i] + '</div></td>');
+		 	if (i != 0 && i % rowSize == 0) {
+		 		emotMenuList.append(row);
+		 		row = $('<tr></tr>');
+		 	}
+		 }
+		 $('.emt').emoticonize();
+	});
+	</script>
+	<div wicket:id="toolbar" class="btn-toolbar" data-role="editor-toolbar">
+		<div class="btn-group">
+			<a id="emoticons" class="btn dropdown-toggle" data-toggle="dropdown" title="Emoticons">
+				<span class="emt" style="font-weight: bold;"> :) <b class="caret"></b></span>
+			</a>
+			<ul class="dropdown-menu" >
+				<li>
+					<table id="emotMenuList">
+					</table>
+				</li>
+			</ul>
+		</div>
+		<div class="btn-group">
+			<a id="fontSize" class="btn dropdown-toggle" data-toggle="dropdown" title="Font Size" style="font-weight: bold;"> A <b class="caret"></b></a>
+			<ul class="dropdown-menu">
+				<li><a data-edit="fontSize 5"><font size="3">Huge</font></a></li>
+				<li><a data-edit="fontSize 3"><font size="2">Normal</font></a></li>
+				<li><a data-edit="fontSize 1"><font size="1">Small</font></a></li>
+			</ul>
+			<a id="bold" class="btn" data-edit="bold" title="Bold (Ctrl/Cmd+B)" style="font-weight: bold;"> B
+			</a> <a id="italic" class="btn" data-edit="italic" title="Italic (Ctrl/Cmd+I)" style="font-style: italic;"> I
+			</a> <a id="strikethrough" class="btn" data-edit="strikethrough" title="Strikethrough" style="text-decoration: line-through;"> S
+			</a> <a id="underline" class="btn" data-edit="underline" title="Underline (Ctrl/Cmd+U)" style="text-decoration: underline;"> U
+			</a>
+		</div>
+	</div>
+</wicket:panel>
+</html>

Added: openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.java
URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.java?rev=1517952&view=auto
==============================================================================
--- openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.java (added)
+++ openmeetings/trunk/singlewebapp/src/main/java/org/apache/openmeetings/web/user/ChatToolbar.java Tue Aug 27 19:44:57 2013
@@ -0,0 +1,68 @@
+/*
+ * 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.openmeetings.web.user;
+
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.Component;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+
+import com.googlecode.wicket.jquery.core.IJQueryWidget.JQueryWidget;
+import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.IWysiwygToolbar;
+
+/**
+ * Provides a custom implementation for com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.IWysiwygToolbar suitable
+ * for chat}
+ */
+public class ChatToolbar extends Panel implements IWysiwygToolbar {
+	private static final long serialVersionUID = 1L;
+	private final WebMarkupContainer toolbar;
+
+	/**
+	 * Constructor
+	 * 
+	 * @param id
+	 *            the markup-id
+	 */
+	public ChatToolbar(String id) {
+		this(id, null);
+	}
+
+	/**
+	 * Constructor
+	 * 
+	 * @param id
+	 *            the markup-id
+	 * @param model
+	 *            the {@link org.apache.wicket.model.IModel}
+	 */
+	public ChatToolbar(String id, IModel<String> model) {
+		super(id, model);
+
+		this.toolbar = new WebMarkupContainer("toolbar");
+		this.toolbar.setMarkupId("bToolbar");
+		this.add(this.toolbar);
+
+	}
+
+	public void attachToEditor(Component editor) {
+		this.toolbar.add(AttributeModifier.replace("data-target", JQueryWidget.getSelector(editor)));
+	}
+}