This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch 4.0.x
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/4.0.x by this push:
new 24cdac6 [OPENMEETINGS-1884] empty texts are dismissed, flexible text
is improved
24cdac6 is described below
commit 24cdac6bfe34de241ffe8fef36870f8a4231558f
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Tue Aug 14 16:47:31 2018 +0700
[OPENMEETINGS-1884] empty texts are dismissed, flexible text is improved
---
.../openmeetings/web/room/wb/raw-tool-text.js | 49 +++++++----
.../openmeetings/web/room/wb/raw-tool-textbox.js | 94 +++++++---------------
.../apache/openmeetings/web/room/wb/raw-wb-area.js | 2 +-
.../openmeetings/web/room/wb/raw-wb-board.js | 18 ++++-
4 files changed, 80 insertions(+), 83 deletions(-)
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-text.js
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-text.js
index 70eae8e..79e3cf8 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-text.js
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-tool-text.js
@@ -2,29 +2,42 @@
var Text = function(wb, s) {
const text = ShapeBase();
text.obj = null;
+ text.fabricType = 'i-text';
text.fill.color = '#000000';
text.stroke.width = 50; //fontSize
text.stroke.color = '#000000';
text.style = {bold: false, italic: false};
+ text.createTextObj = function(canvas, pointer) {
+ return new fabric.IText('', {
+ 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
+ });
+ };
+ text._onMouseDown = function() {
+ text.obj.enterEditing();
+ };
+ text._onActivate = function() {
+ WbArea.removeDeleteHandler();
+ };
+ text._onDeactivate = function() {
+ WbArea.addDeleteHandler();
+ };
text.mouseDown = function(o) {
const canvas = this
, pointer = canvas.getPointer(o.e)
, ao = canvas.getActiveObject();
- if (!!ao && ao.type === 'i-text') {
+ if (!!ao && text.fabricType === ao.type) {
text.obj = ao;
} else {
- text.obj = new fabric.IText('', {
- 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
- });
+ text.obj = text.createTextObj(canvas, pointer);
if (text.style.bold) {
text.obj.fontWeight = 'bold'
}
@@ -33,14 +46,15 @@ var Text = function(wb, s) {
}
canvas.add(text.obj).setActiveObject(text.obj);
}
- text.obj.enterEditing();
+ text._onMouseDown();
};
text.activate = function() {
wb.eachCanvas(function(canvas) {
canvas.on('mouse:down', text.mouseDown);
+ canvas.on('mouse:dblclick', text.doubleClick);
canvas.selection = true;
canvas.forEachObject(function(o) {
- if (o.type === 'i-text') {
+ if (text.fabricType === o.type) {
o.selectable = true;
}
});
@@ -59,19 +73,20 @@ var Text = function(wb, s) {
} else {
i.removeClass('ui-state-active selected');
}
- WbArea.removeDeleteHandler();
+ text._onActivate();
};
text.deactivate = function() {
wb.eachCanvas(function(canvas) {
canvas.off('mouse:down', text.mouseDown);
+ canvas.off('mouse:dblclick', text.doubleClick);
canvas.selection = false;
canvas.forEachObject(function(o) {
- if (o.type === 'i-text') {
+ if (text.fabricType === o.type) {
o.selectable = false;
}
});
});
- WbArea.addDeleteHandler();
+ text._onDeactivate();
};
return text;
};
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
index ccea128..5cce21f 100644
---
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
@@ -1,75 +1,41 @@
/* 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();
+ const text = Text(wb, s);
+ text.fabricType = 'textbox';
- text.mouseDown = function(o) {
+ text.createTextObj = function(canvas, pointer) {
+ return 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
+ });
+ };
+ text.doubleClick = function(e) {
const canvas = this
- , pointer = canvas.getPointer(o.e)
- , ao = canvas.getActiveObject();
- if (!!ao && ao.type === 'textbox') {
+ , ao = e.target;
+ if (!!ao && text.fabricType === ao.type) {
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();
+ WbArea.removeDeleteHandler();
}
- 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._onMouseDown = function() {
+ WbArea.addDeleteHandler();
};
- 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;
- }
- });
- });
+ text._onActivate = function() {
+ WbArea.addDeleteHandler();
+ };
+ text._onDeactivate = function() {
WbArea.addDeleteHandler();
};
return text;
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-area.js
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-area.js
index 6886efd..b2ae438 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-area.js
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-area.js
@@ -25,7 +25,7 @@ var DrawWbArea = function() {
return true;
}
const arr = [], objs = canvas.getActiveObjects();
- for (let i =0; i < objs.length; ++i) {
+ for (let i = 0; i < objs.length; ++i) {
arr.push({
uid: objs[i].uid
, slide: objs[i].slide
diff --git
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-board.js
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-board.js
index 0b4c20b..2b1eddf 100644
---
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-board.js
+++
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/raw-wb-board.js
@@ -349,7 +349,6 @@ var Wb = function() {
if (!!__o) {
const cnvs = canvases[o.slide];
if (!!cnvs) {
- cnvs.discardActiveObject();
if ('Video' === __o.omType) {
$('#wb-video-' + __o.uid).remove();
}
@@ -502,6 +501,21 @@ var Wb = function() {
s.find('.wb-dim-w').val(o.width);
s.find('.wb-dim-h').val(o.height);
}
+ function selectionCleared(e) {
+ const o = e.target;
+ if (!o || '' !== o.text) {
+ return;
+ }
+ if ('textbox' === o.type || 'i-text' === o.type) {
+ wbAction('deleteObj', JSON.stringify({
+ wbId: wb.id
+ , obj: [{
+ uid: o.uid
+ , slide: o.slide
+ }]
+ }));
+ }
+ }
function pathCreatedHandler(o) {
o.path.uid = UUID.generate();
o.path.slide = this.slide;
@@ -553,6 +567,7 @@ var Wb = function() {
, 'path:created': pathCreatedHandler
//, 'text:editing:exited': textEditedHandler
//, 'text:changed': textChangedHandler
+ , 'before:selection:cleared': selectionCleared
});
canvas.on({
'wb:object:created': objCreatedHandler
@@ -563,6 +578,7 @@ var Wb = function() {
'object:added': objAddedHandler
, 'object:selected': objSelectedHandler
, 'path:created': pathCreatedHandler
+ , 'before:selection:cleared': selectionCleared
//, 'text:editing:exited': textEditedHandler
//, 'text:changed': textChangedHandler
});