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
The following commit(s) were added to refs/heads/master by this push:
new 0531030 [OPENMEETINGS-2000] moving JS code to npm (incomplete, broken)
0531030 is described below
commit 0531030f00f7e06f3b99306a99570fba991d4f93
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Sat Dec 26 01:38:32 2020 +0700
[OPENMEETINGS-2000] moving JS code to npm (incomplete, broken)
---
.../src/main/front/wb/src/raw-tool-clipart.js | 52 -------------------
.../src/main/front/wb/src/wb-tool-clipart.js | 60 ++++++++++++++++++++++
.../src/main/front/wb/src/wb-tool-shape.js | 9 ++--
openmeetings-web/src/main/front/wb/src/wb-tools.js | 5 +-
openmeetings-web/src/main/front/wb/src/wb.js | 5 +-
5 files changed, 71 insertions(+), 60 deletions(-)
diff --git a/openmeetings-web/src/main/front/wb/src/raw-tool-clipart.js
b/openmeetings-web/src/main/front/wb/src/raw-tool-clipart.js
deleted file mode 100644
index 4e91d01..0000000
--- a/openmeetings-web/src/main/front/wb/src/raw-tool-clipart.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
-var Clipart = function(wb, btn, s, sBtn) {
- const art = Shape(wb, sBtn);
- art.add2Canvas = function() {}
- art.createShape = function(canvas) {
- const imgSrc = btn.data('image')
- , opts = {
- left: art.orig.x
- , top: art.orig.y
- , scaleX: 0.
- , scaleY: 0.
- , omType: 'Clipart'
- , _src: imgSrc
- , opacity: art.opacity
- };
- if (imgSrc.toLowerCase().endsWith('svg')) {
- fabric.loadSVGFromURL(imgSrc, function(elements) {
- art.orig.width = 32;
- art.orig.height = 32;
- art.obj =
fabric.util.groupSVGElements(elements, opts);
- art.obj.set(opts);
- canvas.add(art.obj);
- });
- } else {
- fabric.Image.fromURL(imgSrc, function(img) {
- art.orig.width = img.width;
- art.orig.height = img.height;
- art.obj = img.set(opts);
- canvas.add(art.obj);
- });
- }
- };
- art.updateShape = function(pointer) {
- if (!art.obj) {
- return; // not ready
- }
- const dx = pointer.x - art.orig.x
- , dy = pointer.y - art.orig.y
- , d = Math.sqrt(dx * dx + dy * dy)
- , scale = d / art.obj.width;
- art.obj.set({
- scaleX: scale
- , scaleY: scale
- , angle: Math.atan2(dy, dx) * 180 / Math.PI
- });
- };
- art.internalActivate = function() {
- ToolUtil.disableAllProps(s);
- ToolUtil.enableOpacity(s, art);
- };
- return art;
-};
diff --git a/openmeetings-web/src/main/front/wb/src/wb-tool-clipart.js
b/openmeetings-web/src/main/front/wb/src/wb-tool-clipart.js
new file mode 100644
index 0000000..a6f5910
--- /dev/null
+++ b/openmeetings-web/src/main/front/wb/src/wb-tool-clipart.js
@@ -0,0 +1,60 @@
+/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
+const WbShape = require('./wb-tool-shape');
+const ToolUtil = require('./wb-tool-util');
+
+module.exports = class Clipart extends WbShape {
+ constructor(wb, btn, settings, sBtn) {
+ super(wb, sBtn);
+
+ const self = this;
+ this.createShape = (canvas) => {
+ const imgSrc = btn.data('image')
+ , opts = {
+ left: self.orig.x
+ , top: self.orig.y
+ , scaleX: 0.
+ , scaleY: 0.
+ , omType: 'Clipart'
+ , _src: imgSrc
+ , opacity: self.opacity
+ };
+ if (imgSrc.toLowerCase().endsWith('svg')) {
+ fabric.loadSVGFromURL(imgSrc,
function(elements) {
+ self.orig.width = 32;
+ self.orig.height = 32;
+ self.obj =
fabric.util.groupSVGElements(elements, opts);
+ self.obj.set(opts);
+ canvas.add(self.obj);
+ });
+ } else {
+ fabric.Image.fromURL(imgSrc, function(img) {
+ self.orig.width = img.width;
+ self.orig.height = img.height;
+ self.obj = img.set(opts);
+ canvas.add(self.obj);
+ });
+ }
+ };
+ this.internalActivate = () => {
+ ToolUtil.disableAllProps(settings);
+ ToolUtil.enableOpacity(settings, this);
+ };
+ }
+
+ add2Canvas() {}
+
+ updateShape(pointer) {
+ if (!this.obj) {
+ return; // not ready
+ }
+ const dx = pointer.x - this.orig.x
+ , dy = pointer.y - this.orig.y
+ , d = Math.sqrt(dx * dx + dy * dy)
+ , scale = d / this.obj.width;
+ this.obj.set({
+ scaleX: scale
+ , scaleY: scale
+ , angle: Math.atan2(dy, dx) * 180 / Math.PI
+ });
+ };
+};
diff --git a/openmeetings-web/src/main/front/wb/src/wb-tool-shape.js
b/openmeetings-web/src/main/front/wb/src/wb-tool-shape.js
index 1386cc8..7178bb4 100644
--- a/openmeetings-web/src/main/front/wb/src/wb-tool-shape.js
+++ b/openmeetings-web/src/main/front/wb/src/wb-tool-shape.js
@@ -11,16 +11,13 @@ module.exports = class WbShape extends WbShapeBase {
});
const self = this;
- function _add2Canvas(canvas) {
- canvas.add(self.obj);
- }
function _mouseDown(o) {
const canvas = this
, pointer = canvas.getPointer(o.e);
self.isDown = true;
self.orig = {x: pointer.x, y: pointer.y};
self.createShape.call(self, canvas);
- _add2Canvas(canvas);
+ self.add2Canvas.call(self, canvas);
};
function _mouseMove(o) {
const canvas = this;
@@ -62,6 +59,10 @@ module.exports = class WbShape extends WbShapeBase {
};
}
+ add2Canvas(canvas) {
+ canvas.add(this.obj);
+ }
+
createShape() {}
updateShape() {}
internalActivate() {}
diff --git a/openmeetings-web/src/main/front/wb/src/wb-tools.js
b/openmeetings-web/src/main/front/wb/src/wb-tools.js
index 3aebd1a..01a7d08 100644
--- a/openmeetings-web/src/main/front/wb/src/wb-tools.js
+++ b/openmeetings-web/src/main/front/wb/src/wb-tools.js
@@ -12,6 +12,7 @@ const ULine = require('./wb-tool-uline');
const Rect = require('./wb-tool-rect');
const Ellipse = require('./wb-tool-ellipse');
const Arrow = require('./wb-tool-arrow');
+const Clipart = require('./wb-tool-clipart');
const ACTIVE = 'active';
@@ -126,7 +127,7 @@ module.exports = class WbTools {
.click(function() {
_setCurrent(c, cur);
});
- _initToolBtn(cur.data('mode'), false,
Clipart(wb, cur, settings, sBtn));
+ _initToolBtn(cur.data('mode'), false, new
Clipart(wb, cur, settings, sBtn));
});
_initGroupHandle(c, tools);
}
@@ -332,7 +333,7 @@ module.exports = class WbTools {
_initTexts(sBtn);
_initDrawings(sBtn);
// FIXME TODO _initToolBtn('math',
_firstToolItem, TMath(wb, settings, sBtn));
- // FIXME TODO _initCliparts(sBtn);
+ _initCliparts(sBtn);
tools.find('.om-icon.settings').click(function() {
settings.show();
});
diff --git a/openmeetings-web/src/main/front/wb/src/wb.js
b/openmeetings-web/src/main/front/wb/src/wb.js
index c1be23f..c3fc141 100644
--- a/openmeetings-web/src/main/front/wb/src/wb.js
+++ b/openmeetings-web/src/main/front/wb/src/wb.js
@@ -2,6 +2,7 @@
const Role = require('./wb-role');
const WbTools = require('./wb-tools');
const WbZoom = require('./wb-zoom');
+const APointer = require('./wb-tool-apointer');
require('fabric'); // will produce `fabric` namespace
const BUMPER = 100
@@ -390,7 +391,7 @@ module.exports = class Wb {
}
switch(o.omType) {
case 'pointer':
-
APointer(wb).create(canvases[o.slide], o);
+ new
APointer(wb).create(canvases[o.slide], o);
break;
case 'Video':
Player.create(canvases[o.slide], o, wb);
@@ -423,7 +424,7 @@ module.exports = class Wb {
const o = _arr[i];
switch(o.omType) {
case 'pointer':
-
_modifyHandler(APointer(wb).create(canvases[o.slide], o));
+ _modifyHandler(new
APointer(wb).create(canvases[o.slide], o));
break;
case 'Video':
{