This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git

commit 01137c9a698848279158ae9f4d9d487f4306d2c4
Author: Maxim Solodovnik <solomax...@gmail.com>
AuthorDate: Sat Aug 11 15:03:21 2018 +0700

    [OPENMEETINGS-1884] flexible textbox is implemented
---
 .../openmeetings/web/room/wb/raw-tool-textbox.js   |  76 +++++++++++++++++++++
 .../src/main/webapp/css/images/textbox.png         | Bin 0 -> 7147 bytes
 2 files changed, 76 insertions(+)

diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-textbox.js
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-textbox.js
new file mode 100644
index 0000000..ccea128
--- /dev/null
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-textbox.js
@@ -0,0 +1,76 @@
+/* Licensed under the Apache License, Version 2.0 (the "License") 
http://www.apache.org/licenses/LICENSE-2.0 */
+var Textbox = function(wb, s) {
+       const text = Text();
+
+       text.mouseDown = function(o) {
+               const canvas = this
+                       , pointer = canvas.getPointer(o.e)
+                       , ao = canvas.getActiveObject();
+               if (!!ao && ao.type === 'textbox') {
+                       text.obj = ao;
+               } else {
+                       text.obj = new fabric.Textbox('', {
+                               left: pointer.x
+                               , top: pointer.y
+                               , padding: 7
+                               , fill: text.fill.enabled ? text.fill.color : 
'rgba(0,0,0,0)'
+                               , stroke: text.stroke.enabled ? 
text.stroke.color : 'rgba(0,0,0,0)'
+                               //, strokeWidth: text.stroke.width
+                               , fontSize: text.stroke.width
+                               , fontFamily: text.fontFamily
+                               , opacity: text.opacity
+                               , breakWords: true
+                               , width: canvas.width / 4
+                               , lockScalingX: false
+                               , lockScalingY: true
+                       });
+                       if (text.style.bold) {
+                               text.obj.fontWeight = 'bold'
+                       }
+                       if (text.style.italic) {
+                               text.obj.fontStyle = 'italic'
+                       }
+                       canvas.add(text.obj).setActiveObject(text.obj);
+               }
+               text.obj.enterEditing();
+       };
+       text.activate = function() {
+               wb.eachCanvas(function(canvas) {
+                       canvas.on('mouse:down', text.mouseDown);
+                       canvas.selection = true;
+                       canvas.forEachObject(function(o) {
+                               if (o.type === 'textbox') {
+                                       o.selectable = true;
+                               }
+                       });
+               });
+               text.fontFamily = $('#wb-text-style-block').css('font-family');
+               ToolUtil.enableAllProps(s, text);
+               const b = s.find('.wb-prop-b').button("enable");
+               if (text.style.bold) {
+                       b.addClass('ui-state-active selected');
+               } else {
+                       b.removeClass('ui-state-active selected');
+               }
+               const i = s.find('.wb-prop-i').button("enable");
+               if (text.style.italic) {
+                       i.addClass('ui-state-active selected');
+               } else {
+                       i.removeClass('ui-state-active selected');
+               }
+               WbArea.removeDeleteHandler();
+       };
+       text.deactivate = function() {
+               wb.eachCanvas(function(canvas) {
+                       canvas.off('mouse:down', text.mouseDown);
+                       canvas.selection = false;
+                       canvas.forEachObject(function(o) {
+                               if (o.type === 'textbox') {
+                                       o.selectable = false;
+                               }
+                       });
+               });
+               WbArea.addDeleteHandler();
+       };
+       return text;
+};
diff --git a/openmeetings-web/src/main/webapp/css/images/textbox.png 
b/openmeetings-web/src/main/webapp/css/images/textbox.png
new file mode 100644
index 0000000..7345e05
Binary files /dev/null and 
b/openmeetings-web/src/main/webapp/css/images/textbox.png differ

Reply via email to