New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

regional-model-addons

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regional-model-addons - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "regional-model-addons",
"version": "1.0.1",
"version": "1.0.2",
"description": "addons to the regional model",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,2 +0,2 @@

export * from "./picto.js"
export * from "."
export * from "./picto_editellipse"

@@ -3,0 +3,0 @@ export * from "./picto_editimage"

@@ -6,3 +6,3 @@ // rfmm_fabric/picto_editellipse.js

import { base_picto_constructor } from "../../module.js"
import { base_picto_constructor } from "."

@@ -81,3 +81,6 @@ const __PictoEditEllipse = {

var y = fjs_object.height * this.minor_pos
return fabric.util.transformPoint({ x: x, y: y }, fabric.util.multiplyTransformMatrices(fjs_object.canvas.viewportTransform, fjs_object.calcTransformMatrix()))
return fabric.util.transformPoint(
{ x: x, y: y },
fabric.util.multiplyTransformMatrices(fjs_object.canvas.viewportTransform, fjs_object.calcTransformMatrix())
)
},

@@ -84,0 +87,0 @@

@@ -6,4 +6,3 @@ // rfmm_fabric/picto_editimage.js

import { createPictoClass } from "../../module.js"
import { base_picto_constructor } from "./picto.js"
import { base_picto_constructor, createPictoClass } from "."

@@ -225,3 +224,8 @@ const __PictoEditImage = {

this._cache_canvas_ctx.drawImage(img, trap_bounds.width + 1, 0, img.naturalWidth, img.naturalHeight)
var image_data_raw = this._cache_canvas_ctx.getImageData(trap_bounds.width + 1, 0, img.naturalWidth, img.naturalHeight),
var image_data_raw = this._cache_canvas_ctx.getImageData(
trap_bounds.width + 1,
0,
img.naturalWidth,
img.naturalHeight
),
image_data_trans

@@ -310,3 +314,8 @@ } catch (e) {

// transparent dst pixels this will not fire.
if (src_bounds.left <= src_x && src_x <= src_bounds.right && src_bounds.top <= src_y && src_y <= src_bounds.bottom) {
if (
src_bounds.left <= src_x &&
src_x <= src_bounds.right &&
src_bounds.top <= src_y &&
src_y <= src_bounds.bottom
) {
// If we are here, we need to plant the pixel from src to the right place in dst

@@ -371,3 +380,6 @@ var index_src = src_y * _w_mult_src + src_x * 4,

positionHandler: this.alter_mode_position_handler,
actionHandler: this.alter_mode_anchor_wrapper(index > 0 ? index - 1 : lastControl, this.alter_mode_action_handler),
actionHandler: this.alter_mode_anchor_wrapper(
index > 0 ? index - 1 : lastControl,
this.alter_mode_action_handler
),
actionName: "modifyPolygon",

@@ -397,3 +409,9 @@ pointIndex: index,

y = fabricObject.points[this.pointIndex].y - fabricObject.pathOffset.y
return fabric.util.transformPoint({ x: x, y: y }, fabric.util.multiplyTransformMatrices(fabricObject.canvas.viewportTransform, fabricObject.calcTransformMatrix()))
return fabric.util.transformPoint(
{ x: x, y: y },
fabric.util.multiplyTransformMatrices(
fabricObject.canvas.viewportTransform,
fabricObject.calcTransformMatrix()
)
)
},

@@ -400,0 +418,0 @@

@@ -7,4 +7,4 @@ // rfmm_fabric/picto_editline.js

import { RFMath } from "regional-model-base"
import { createPictoClass } from "../../module.js"
import { base_picto_constructor } from "./picto.js"
import { createPictoClass } from "."
import { base_picto_constructor } from "."

@@ -129,3 +129,6 @@ /**

positionHandler: this.alter_mode_position_handler,
actionHandler: this.alter_mode_anchor_wrapper(index > 0 ? index - 1 : lastControl, this.alter_mode_action_handler),
actionHandler: this.alter_mode_anchor_wrapper(
index > 0 ? index - 1 : lastControl,
this.alter_mode_action_handler
),
actionName: "modifyPolygon",

@@ -307,3 +310,6 @@ pointIndex: index,

{ x: this.points[0].x - this.pathOffset.x, y: this.points[0].y - this.pathOffset.y },
fabric.util.multiplyTransformMatrices(fabricObject.canvas.viewportTransform, fabricObject.calcTransformMatrix())
fabric.util.multiplyTransformMatrices(
fabricObject.canvas.viewportTransform,
fabricObject.calcTransformMatrix()
)
)

@@ -543,3 +549,6 @@ }.bind(this),

.map((p) => {
return fabric.util.transformPoint(p, fabric.util.multiplyTransformMatrices(this.canvas.viewportTransform, matrix))
return fabric.util.transformPoint(
p,
fabric.util.multiplyTransformMatrices(this.canvas.viewportTransform, matrix)
)
})

@@ -846,3 +855,7 @@ return transformed

// We need to convert these back to radii
this._corner_recompute_change_radius(pt_adjacent.corner_index, pt_adjacent.corner_angle, pt_adjacent.touch_dist)
this._corner_recompute_change_radius(
pt_adjacent.corner_index,
pt_adjacent.corner_angle,
pt_adjacent.touch_dist
)
something_changed = 1

@@ -986,3 +999,9 @@ }

// This is needed for ITL calculations
pt_cache.arc_center = RFMath.corner_center_find(pt_prev, pt, pt_next, pt_cache.corner_radius, pt_cache.corner_angle)
pt_cache.arc_center = RFMath.corner_center_find(
pt_prev,
pt,
pt_next,
pt_cache.corner_radius,
pt_cache.corner_angle
)

@@ -998,3 +1017,6 @@ //console.warn(pt_cache)

Object.assign(pt_cache, this._corners_calc_point_cache_for_corner_aux(pt_cache, corner_index, pt_prev, pt, pt_next))
Object.assign(
pt_cache,
this._corners_calc_point_cache_for_corner_aux(pt_cache, corner_index, pt_prev, pt, pt_next)
)

@@ -1033,3 +1055,9 @@ this.points[corner_index]._point_cache = pt_cache

y = fabricObject.points[this.pointIndex].y - fabricObject.pathOffset.y
return fabric.util.transformPoint({ x: x, y: y }, fabric.util.multiplyTransformMatrices(fabricObject.canvas.viewportTransform, fabricObject.calcTransformMatrix()))
return fabric.util.transformPoint(
{ x: x, y: y },
fabric.util.multiplyTransformMatrices(
fabricObject.canvas.viewportTransform,
fabricObject.calcTransformMatrix()
)
)
},

@@ -1036,0 +1064,0 @@

@@ -6,3 +6,3 @@ // rfmm_fabric/picto_editpoly.js

import { _PictoEditLine, createPictoClass } from "../../module.js"
import { _PictoEditLine, createPictoClass } from "."

@@ -9,0 +9,0 @@ const _PictoEditPoly = {

@@ -6,3 +6,3 @@ // rfmm_fabric/picto_editimage.js

import { createPictoClass, _PictoEditImage } from "../../module.js"
import { createPictoClass, _PictoEditImage } from "."

@@ -9,0 +9,0 @@ const _PictoEditVideo = {

@@ -6,3 +6,3 @@ // rfmm_fabric/picto_test.js

import { createPictoClass } from "../../module.js"
import { createPictoClass } from "."

@@ -9,0 +9,0 @@ const PictoTest = createPictoClass(fabric.Polygon, {

@@ -1,2 +0,2 @@

// rfmm_fabric/picto.js
// rfmm_fabric
// Josh Reed 2020

@@ -3,0 +3,0 @@ //

@@ -6,16 +6,17 @@ // rfmm_fabric/r_canvas_test.js

import {
RegionCanvas,
PictoEditLine
} from "../module.js"
import { RegionCanvas, PictoEditLine } from ".."
class RegionCanvasTest extends RegionCanvas
{
constructor(html_id, app)
{
class RegionCanvasTest extends RegionCanvas {
constructor(html_id, app) {
super(html_id, app)
this.$button_a = this.member_get_element('button_a').click(()=>{this.button_a()})
this.$button_b = this.member_get_element('button_b').click(()=>{this.button_b()})
this.$button_c = this.member_get_element('button_c').click(()=>{this.button_c()})
this.$button_a = this.member_get_element("button_a").click(() => {
this.button_a()
})
this.$button_b = this.member_get_element("button_b").click(() => {
this.button_b()
})
this.$button_c = this.member_get_element("button_c").click(() => {
this.button_c()
})

@@ -25,34 +26,57 @@ this.overlay_setup()

get test_points()
{
var points = [{
x: 30, y: 40
}, {
x: 160, y: 30
}, {
x: 300, y: 50
}, {
x: 250, y: 550
}, {
x: 190, y: 440
}, {
x: 150, y: 300
}, {
x: 150, y: 550
}, {
x: 90, y: 550
}, {
x: 60, y: 530
}, {
x: -20, y: 550
}, {
x: -40, y: 400
}, {
x: 0, y: 200
}]
get test_points() {
var points = [
{
x: 30,
y: 40,
},
{
x: 160,
y: 30,
},
{
x: 300,
y: 50,
},
{
x: 250,
y: 550,
},
{
x: 190,
y: 440,
},
{
x: 150,
y: 300,
},
{
x: 150,
y: 550,
},
{
x: 90,
y: 550,
},
{
x: 60,
y: 530,
},
{
x: -20,
y: 550,
},
{
x: -40,
y: 400,
},
{
x: 0,
y: 200,
},
]
return points
}
button_a()
{
button_a() {
console.warn("Button A Pressed")

@@ -62,7 +86,7 @@ console.log("Adding new fjs object.")

var new_custom = new PictoEditLine(this.test_points, {
fill: 'transparent',
stroke: '#888888',
fill: "transparent",
stroke: "#888888",
strokeWidth: 4,
originX: 'center',
originY: 'center',
originX: "center",
originY: "center",
})

@@ -76,14 +100,10 @@ this.fjs_canvas.add(new_custom)

button_b()
{
button_b() {
console.warn("Button B Pressed")
console.log("Change to or from edit mode")
if(this.toggle)
{
if (this.toggle) {
this.toggle = 0
this.custom.edit_mode_set(this.custom.picto_edit_modes.default)
}
else
{
} else {
this.toggle = 1

@@ -94,4 +114,3 @@ this.custom.edit_mode_set(this.custom.picto_edit_modes.alter)

button_c()
{
button_c() {
console.warn("Button C Pressed")

@@ -101,3 +120,3 @@ console.log("Redraw canvas")

this.custom.setCoords(true)
this.fjs_canvas.renderAll();
this.fjs_canvas.renderAll()
this.fjs_canvas.calcOffset() // TEMP

@@ -110,9 +129,8 @@ this.fjs_canvas.setZoom(this.fjs_canvas.getZoom())

activate()
{
activate() {
super.activate()
this.canvas_setup('test_canvas', {w: 1000, h: 1000})
this.canvas_setup("test_canvas", { w: 1000, h: 1000 })
}
}
export { RegionCanvasTest }
export { RegionCanvasTest }

@@ -6,8 +6,4 @@ // rfmm_fabric/r_canvas.js

import {
Region
} from "regional-model-base"
import {
PictoEvents
} from "../module.js"
import { Region } from "regional-model-base"
import { PictoEvents } from ".."

@@ -17,22 +13,19 @@ /**

*/
class RegionCanvas extends Region
{
constructor(html_id, app)
{
class RegionCanvas extends Region {
constructor(html_id, app) {
super(html_id, app)
this.bg_color = "transparent";
this.bb_bg_color = "#191919";
this.bb_field_strokewid = 2; // Width of border stroke around bb field.
this.$fjs_canvas_container = this.member_get_element('canvas_container')
this.bg_color = "transparent"
this.bb_bg_color = "#191919"
this.bb_field_strokewid = 2 // Width of border stroke around bb field.
this.$fjs_canvas_container = this.member_get_element("canvas_container")
// HTML Element to load images for the background in.
this.$bg_image_loader = $("<img></img>").css('position', 'absolute').css('left', '-9999px')
$('body').append(this.$bg_image_loader)
this.$bg_image_loader = $("<img></img>").css("position", "absolute").css("left", "-9999px")
$("body").append(this.$bg_image_loader)
}
/** How far out the user can zoom. Dependent on how big the project is */
get min_zoom()
{
get min_zoom() {
// 0.45 is a good number for 1024 wide, and 0.3 is a good number for 1920

@@ -45,4 +38,3 @@ // So, you need about 0.6 - 0.15 * N , where N is the number of thousands of pixels wide

/** How far in the user can zoom. */
get max_zoom()
{
get max_zoom() {
return 5

@@ -60,33 +52,33 @@ }

*/
canvas_setup(canvas_id, bounding_dims)
{
bounding_dims = bounding_dims || {w: 1000, h: 1000}
canvas_setup(canvas_id, bounding_dims) {
bounding_dims = bounding_dims || { w: 1000, h: 1000 }
this.settings.bounding_dims = bounding_dims
// HTML Manipulation
this.$fjs_canvas = $('<canvas></canvas>')
.attr('id', canvas_id)
.attr('width', this.$fjs_canvas_container.width())
.attr('height', this.$fjs_canvas_container.height())
this.$fjs_canvas_container.empty().append(this.$fjs_canvas);
this.$fjs_canvas = $("<canvas></canvas>")
.attr("id", canvas_id)
.attr("width", this.$fjs_canvas_container.width())
.attr("height", this.$fjs_canvas_container.height())
this.$fjs_canvas_container.empty().append(this.$fjs_canvas)
// Canvas will not use percentages for dimension, so we must bind the resize for this and this alone
$(window).off('resize').resize(()=>
{
this.canvas_resize_recalc()
})
$(window)
.off("resize")
.resize(() => {
this.canvas_resize_recalc()
})
// Canvas Formalization
this.fjs_canvas = new fabric.Canvas(canvas_id, {backgroundColor: "transparent", preserveObjectStacking: true});
this.fjs_canvas = new fabric.Canvas(canvas_id, { backgroundColor: "transparent", preserveObjectStacking: true })
// The canvas on which we render thumbnails:
// First remove it if it existed
if(this.$canvas_thumbnail != undefined)
{
if (this.$canvas_thumbnail != undefined) {
this.$canvas_thumbnail.remove()
}
// Then re-instantiate it.
this.$canvas_thumbnail = $('<canvas></canvas>')
.attr('width', bounding_dims.w)
.attr('height', bounding_dims.h)
.css('position', 'absolute').css('left', '-9999px')
$('body').append(this.$canvas_thumbnail)
this.$canvas_thumbnail = $("<canvas></canvas>")
.attr("width", bounding_dims.w)
.attr("height", bounding_dims.h)
.css("position", "absolute")
.css("left", "-9999px")
$("body").append(this.$canvas_thumbnail)

@@ -96,3 +88,3 @@ // A place for data that is specific to the lifetime of the canvas (between canvas_setup()) calls.

genobj: {},
tempobjs: []
tempobjs: [],
}

@@ -103,3 +95,3 @@

this.canvas_setup_bb()
this.canvas_setup_zoom_and_pan();
this.canvas_setup_zoom_and_pan()
}

@@ -110,6 +102,5 @@

*/
canvas_resize_recalc()
{
this.fjs_canvas.setWidth(this.$fjs_canvas_container.width());
this.fjs_canvas.setHeight(this.$fjs_canvas_container.height());
canvas_resize_recalc() {
this.fjs_canvas.setWidth(this.$fjs_canvas_container.width())
this.fjs_canvas.setHeight(this.$fjs_canvas_container.height())
}

@@ -121,16 +112,33 @@

*/
canvas_setup_events()
{
canvas_setup_events() {
this.cevent_setup()
var picto_events = new PictoEvents(this.fjs_canvas)
this.cevent_add_function('_picto_object_moved', 'object:moved',(fjse)=>{picto_events.on_object_moved(fjse)})
this.cevent_add_function('_picto_object_scaled', 'object:scaled',(fjse)=>{picto_events.on_object_scaled(fjse)})
this.cevent_add_function('_picto_object_rotated', 'object:rotated',(fjse)=>{picto_events.on_object_rotated(fjse)})
this.cevent_add_function('_picto_mouse_up', 'mouse:up',(fjse)=>{picto_events.on_any_click(fjse)})
this.cevent_add_function('_mouse_location_tracker', 'mouse:move',(fjse)=>{picto_events.on_mouse_move(fjse)})
this.cevent_add_function('_on_text_changed', 'text:changed',(fjse)=>{picto_events.on_text_changed(fjse)})
this.cevent_add_function("_selection_created", "selection:created", (fjse)=>{picto_events.on_selection(fjse)});
this.cevent_add_function("_selection_updated", "selection:updated", (fjse)=>{picto_events.on_selection(fjse)});
this.cevent_add_function("_selection_cleared", "selection:cleared", (fjse)=>{picto_events.on_selection_cleared(fjse)});
this.cevent_add_function("_picto_object_moved", "object:moved", (fjse) => {
picto_events.on_object_moved(fjse)
})
this.cevent_add_function("_picto_object_scaled", "object:scaled", (fjse) => {
picto_events.on_object_scaled(fjse)
})
this.cevent_add_function("_picto_object_rotated", "object:rotated", (fjse) => {
picto_events.on_object_rotated(fjse)
})
this.cevent_add_function("_picto_mouse_up", "mouse:up", (fjse) => {
picto_events.on_any_click(fjse)
})
this.cevent_add_function("_mouse_location_tracker", "mouse:move", (fjse) => {
picto_events.on_mouse_move(fjse)
})
this.cevent_add_function("_on_text_changed", "text:changed", (fjse) => {
picto_events.on_text_changed(fjse)
})
this.cevent_add_function("_selection_created", "selection:created", (fjse) => {
picto_events.on_selection(fjse)
})
this.cevent_add_function("_selection_updated", "selection:updated", (fjse) => {
picto_events.on_selection(fjse)
})
this.cevent_add_function("_selection_cleared", "selection:cleared", (fjse) => {
picto_events.on_selection_cleared(fjse)
})
}

@@ -141,11 +149,10 @@

*/
canvas_setup_bb()
{
canvas_setup_bb() {
var pbb = this.get_bb_def()
//Create bounding dimensions.
var bw = 25; //Border width in pixels
var t = pbb.top - bw; //Overall bounding box coordinates
var l = pbb.left - bw;
var w = pbb.width + 2*bw;
var h = pbb.height + 2*bw;
var bw = 25 //Border width in pixels
var t = pbb.top - bw //Overall bounding box coordinates
var l = pbb.left - bw
var w = pbb.width + 2 * bw
var h = pbb.height + 2 * bw

@@ -155,9 +162,10 @@ var bb_field = new fabric.Rect({

top: pbb.top - this.bb_field_strokewid,
width:pbb.width + this.bb_field_strokewid,
height:pbb.height + this.bb_field_strokewid,
stroke:"#191919",
strokeWidth:this.bb_field_strokewid,
width: pbb.width + this.bb_field_strokewid,
height: pbb.height + this.bb_field_strokewid,
stroke: "#191919",
strokeWidth: this.bb_field_strokewid,
selectable: false,
hoverCursor: "default",
fill: this.bb_bg_color});
fill: this.bb_bg_color,
})

@@ -170,9 +178,10 @@ // Must be commented out for fabricjs

top: t - this.bb_field_strokewid,
width:w + this.bb_field_strokewid,
height:h + this.bb_field_strokewid,
stroke:"#191919",
strokeWidth:this.bb_field_strokewid,
width: w + this.bb_field_strokewid,
height: h + this.bb_field_strokewid,
stroke: "#191919",
strokeWidth: this.bb_field_strokewid,
selectable: false,
hoverCursor: "default",
fill: 'transparent'});
fill: "transparent",
})

@@ -182,7 +191,8 @@ var bb_background = new fabric.Image(null, {

top: pbb.top,
width:pbb.width,
height:pbb.height,
width: pbb.width,
height: pbb.height,
selectable: false,
hoverCursor: "default",
opacity: 0.0});
opacity: 0.0,
})

@@ -197,7 +207,7 @@ var bb_greyout = new fabric.Rect({

fill: "#AAAAAA",
});
this.fjs_canvas.add(bb_field); //CAMERADAY
})
this.fjs_canvas.add(bb_field) //CAMERADAY
this.genobj_set("bb_field", bb_field)
//this.CANVAS.add(this.bb_border);
this.fjs_canvas.add(bb_background);
this.fjs_canvas.add(bb_background)
this.genobj_set("bb_background", bb_background)

@@ -210,5 +220,4 @@ //this.CANVAS.add(this.bb_greyout);

*/
canvas_rerender()
{
this.fjs_canvas.requestRenderAll();
canvas_rerender() {
this.fjs_canvas.requestRenderAll()
this.canvas_reset_bbs()

@@ -220,4 +229,3 @@ }

*/
canvas_reset_bbs()
{
canvas_reset_bbs() {
// We call this here to ensure that all selection bounding boxes are redrawn succesfully. setZoom() just happens

@@ -230,4 +238,3 @@ // to perform this coordinate reset, so I use it here. If it's too slow or causes other issues one day, it would

//Simply sets up zoom and pan for the passed this.$fjs_canvas_container div region.
canvas_setup_zoom_and_pan()
{
canvas_setup_zoom_and_pan() {
// Clear any existing events

@@ -241,18 +248,17 @@ this.$fjs_canvas_container.off("mousemove")

//Listener for if mouse move while on canvas.
var lMousemove = function(e)
{
var lMousemove = function (e) {
//If the pan has been started and is above the threshold, but is not yet moving.
if(this.pan_start && (Math.abs(this.pan_start.x - e.clientX) > 5 || Math.abs(this.pan_start.y - e.clientY) > 5))
{
this.pan_data = this.pan_start;
this.pan_start = null;
if (
this.pan_start &&
(Math.abs(this.pan_start.x - e.clientX) > 5 || Math.abs(this.pan_start.y - e.clientY) > 5)
) {
this.pan_data = this.pan_start
this.pan_start = null
}
if(this.pan_data)
{
if (this.pan_data) {
//Make drag dist by relative pixel change of cursor
var delta = new fabric.Point(e.clientX-this.pan_data.x,e.clientY-this.pan_data.y) ;
this.fjs_canvas.relativePan(delta);
this.pan_data = {x:e.clientX,y:e.clientY};
this.pan_marker = 1; //Is not null if the last click cycle was dragging. used for context menu logic.
var delta = new fabric.Point(e.clientX - this.pan_data.x, e.clientY - this.pan_data.y)
this.fjs_canvas.relativePan(delta)
this.pan_data = { x: e.clientX, y: e.clientY }
this.pan_marker = 1 //Is not null if the last click cycle was dragging. used for context menu logic.
}

@@ -262,70 +268,75 @@ }.bind(this)

//Listener for if mouse click while on canvas
var lMousedown = function(e)
{
var lMousedown = function (e) {
//If is right click
if(e.button == 2)
{
e.preventDefault();
e.stopPropagation();
this.pan_start = {x:e.clientX,y:e.clientY};
if (e.button == 2) {
e.preventDefault()
e.stopPropagation()
this.pan_start = { x: e.clientX, y: e.clientY }
console.log("You fool, you've fallen victim to one of the classic blunders!")
}
this.pan_marker = null;
this.pan_marker = null
}.bind(this)
//Disable right click menu
this.$fjs_canvas_container.bind('contextmenu', function(e) {
return false;
}.bind(this));
this.$fjs_canvas_container.bind(
"contextmenu",
function (e) {
return false
}.bind(this)
)
this.$fjs_canvas_container.bind('mouseup', function(e){
if(this.pan_data)
{
e.preventDefault(); // Prevent default right click menu if we are panning...
}
this.pan_data = null;
this.pan_start = null;
}.bind(this))
this.$fjs_canvas_container.bind(
"mouseup",
function (e) {
if (this.pan_data) {
e.preventDefault() // Prevent default right click menu if we are panning...
}
this.pan_data = null
this.pan_start = null
}.bind(this)
)
//Add listeners
this.$fjs_canvas_container.on('mousewheel DOMMouseScroll', function(e)
{
var e = window.event || e; //Cross compatiblity with IE
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail || e.deltaY))); //Delta will be either 1 or -1 depending on direction.
var ptr = this.fjs_canvas.getPointer(e, true); // get pointer positions. TODO make this work properly with offsets.
//Note, the zoom level returned by getZoom is a multiplier. i.e. zoom=2 means things are twice as large now.
var zoom = Math.min(this.max_zoom, Math.max(this.min_zoom, this.fjs_canvas.getZoom() * (1 + 0.1 * delta)));
//console.log(zoom + " " + ptr.x + " " + ptr.y);
this.$fjs_canvas_container.on(
"mousewheel DOMMouseScroll",
function (e) {
var e = window.event || e //Cross compatiblity with IE
var delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail || e.deltaY)) //Delta will be either 1 or -1 depending on direction.
var ptr = this.fjs_canvas.getPointer(e, true) // get pointer positions. TODO make this work properly with offsets.
//Note, the zoom level returned by getZoom is a multiplier. i.e. zoom=2 means things are twice as large now.
var zoom = Math.min(
this.max_zoom,
Math.max(this.min_zoom, this.fjs_canvas.getZoom() * (1 + 0.1 * delta))
)
//console.log(zoom + " " + ptr.x + " " + ptr.y);
this.fjs_canvas.zoomToPoint(new fabric.Point(ptr.x, ptr.y), zoom);
}.bind(this));
this.$fjs_canvas_container.mousemove(lMousemove);
this.$fjs_canvas_container.mousedown(lMousedown);
this.fjs_canvas.zoomToPoint(new fabric.Point(ptr.x, ptr.y), zoom)
}.bind(this)
)
this.$fjs_canvas_container.mousemove(lMousemove)
this.$fjs_canvas_container.mousedown(lMousedown)
}
//Requires min_zoom to have been set. Zooms the canvas to the standard position (centered at min_zoom).
zoom_standard()
{
zoom_standard() {
console.log("Setting zoom standard (level " + this.min_zoom + ")")
this.fjs_canvas.setZoom(1);
var vpw = this.fjs_canvas.width / this.min_zoom;
var vph = this.fjs_canvas.height / this.min_zoom;
this.fjs_canvas.setZoom(1)
var vpw = this.fjs_canvas.width / this.min_zoom
var vph = this.fjs_canvas.height / this.min_zoom
//var x = (this.bb.getCenterPoint().x - vpw / 2);
//var y = (this.bb.getCenterPoint().y - vph / 2);
var x = (this.genobj_get('bb_field').getCenterPoint().x - vpw / 2);
var y = (this.genobj_get('bb_field').getCenterPoint().y - vph / 2);
var x = this.genobj_get("bb_field").getCenterPoint().x - vpw / 2
var y = this.genobj_get("bb_field").getCenterPoint().y - vph / 2
this.fjs_canvas.absolutePan({x:x, y:y});
this.fjs_canvas.setZoom(this.min_zoom);
this.fjs_canvas.renderAll();
this.fjs_canvas.absolutePan({ x: x, y: y })
this.fjs_canvas.setZoom(this.min_zoom)
this.fjs_canvas.renderAll()
}
zoom_in()
{
zoom_in() {
this.zoom_direction(1)
}
zoom_out()
{
zoom_out() {
this.zoom_direction(-1)

@@ -338,11 +349,10 @@ }

*/
zoom_direction(dir)
{
var bb_field = this.genobj_get('bb_field')
zoom_direction(dir) {
var bb_field = this.genobj_get("bb_field")
var vpw = this.fjs_canvas.width / this.fjs_canvas.getZoom() // equal to capture_w
var vph = this.fjs_canvas.height / this.fjs_canvas.getZoom() // height of vp when zoom is reapplied.
var x1 = (bb_field.getCenterPoint().x - vpw / 2);
var y1 = (bb_field.getCenterPoint().y - vph / 2);
var x1 = bb_field.getCenterPoint().x - vpw / 2
var y1 = bb_field.getCenterPoint().y - vph / 2
this.fjs_canvas.setZoom(this.fjs_canvas.getZoom()+(0.1*dir));
this.fjs_canvas.setZoom(this.fjs_canvas.getZoom() + 0.1 * dir)
}

@@ -353,5 +363,4 @@

*/
get_bb_def()
{
return {top: 0, left: 0, width: this.settings.bounding_dims.w, height: this.settings.bounding_dims.h};
get_bb_def() {
return { top: 0, left: 0, width: this.settings.bounding_dims.w, height: this.settings.bounding_dims.h }
}

@@ -364,4 +373,3 @@

*/
genobj_setup()
{
genobj_setup() {
this.cdata.genobj = {}

@@ -374,4 +382,3 @@ }

*/
genobj_get(key)
{
genobj_get(key) {
return this.cdata.genobj[key]

@@ -385,5 +392,4 @@ }

*/
genobj_set(key, fjs_ref)
{
return this.cdata.genobj[key] = fjs_ref
genobj_set(key, fjs_ref) {
return (this.cdata.genobj[key] = fjs_ref)
}

@@ -397,4 +403,3 @@

*/
tempobj_add(fjs_ref)
{
tempobj_add(fjs_ref) {
this.cdata.tempobjs.push(fjs_ref)

@@ -407,4 +412,3 @@ this.fjs_canvas.add(fjs_ref)

*/
tempobjs_get()
{
tempobjs_get() {
return this.cdata.tempobjs

@@ -416,6 +420,4 @@ }

*/
tempobjs_clear()
{
for(var x = 0; x < this.cdata.tempobjs.length; x++)
{
tempobjs_clear() {
for (var x = 0; x < this.cdata.tempobjs.length; x++) {
this.fjs_canvas.remove(this.cdata.tempobjs[x])

@@ -430,18 +432,16 @@ }

*/
background_set_image(data)
{
background_set_image(data) {
//console.log("Setting image with dataurl " + data.substring(0, 100) + "...")
var img_dom = this.$bg_image_loader.get(0);
img_dom.onload=function()
{
var img_dom = this.$bg_image_loader.get(0)
img_dom.onload = function () {
//console.log("Loaded")
var bb_bg_ref = this.genobj_get('bb_background');
bb_bg_ref.setElement(img_dom); //The image is NOT scaled to fit.
bb_bg_ref.set({"opacity": 1.0});
var bb_bg_ref = this.genobj_get("bb_background")
this.fjs_canvas.renderAll();
bb_bg_ref.setElement(img_dom) //The image is NOT scaled to fit.
bb_bg_ref.set({ opacity: 1.0 })
this.fjs_canvas.renderAll()
}.bind(this)
// Set the dom image's source, which will trigger an onload ver soon after because it is a dataurl.
img_dom.src=data;
img_dom.src = data
}

@@ -452,7 +452,6 @@

*/
background_clear()
{
var bb_bg_ref = this.genobj_get('bb_background');
bb_bg_ref.set({"opacity": 0.0});
this.fjs_canvas.renderAll();
background_clear() {
var bb_bg_ref = this.genobj_get("bb_background")
bb_bg_ref.set({ opacity: 0.0 })
this.fjs_canvas.renderAll()
}

@@ -463,10 +462,38 @@

*/
cevent_setup()
{
cevent_setup() {
this.all_fjs_event_strings = [
"object:modified","object:moving","object:scaling","object:rotating","object:skewing","object:moved",
"object:scaled","object:rotated","object:skewed","before:transform","before:selection:cleared","selection:cleared",
"selection:created","selection:updated","mouse:up","mouse:down","mouse:move","mouse:up:before","mouse:down:before",
"mouse:move:before","mouse:dblclick","mouse:wheel","mouse:over","mouse:out","drop","dragover","dragenter","dragleave",
"after:render", "object:selected", "text:editing:entered", "text:editing:exited", "text:changed"];
"object:modified",
"object:moving",
"object:scaling",
"object:rotating",
"object:skewing",
"object:moved",
"object:scaled",
"object:rotated",
"object:skewed",
"before:transform",
"before:selection:cleared",
"selection:cleared",
"selection:created",
"selection:updated",
"mouse:up",
"mouse:down",
"mouse:move",
"mouse:up:before",
"mouse:down:before",
"mouse:move:before",
"mouse:dblclick",
"mouse:wheel",
"mouse:over",
"mouse:out",
"drop",
"dragover",
"dragenter",
"dragleave",
"after:render",
"object:selected",
"text:editing:entered",
"text:editing:exited",
"text:changed",
]
/* Format data = {

@@ -482,18 +509,17 @@ mouse_over: {

}*/
this.cevent_data = {
}
for(var x = 0; x < this.all_fjs_event_strings.length; x++)
{
this.cevent_data = {}
for (var x = 0; x < this.all_fjs_event_strings.length; x++) {
var fjsstr = this.all_fjs_event_strings[x]
this.cevent_data[fjsstr] = {enabled: true, fn_list: []}
this.fjs_canvas.on(fjsstr, function(c_ref)
{
return function(fjse)
{
this._cevent_masterfunction(c_ref, fjse)
}.bind(this);
}.bind(this)(fjsstr));
this.cevent_data[fjsstr] = { enabled: true, fn_list: [] }
this.fjs_canvas.on(
fjsstr,
function (c_ref) {
return function (fjse) {
this._cevent_masterfunction(c_ref, fjse)
}.bind(this)
}.bind(this)(fjsstr)
)
}
}
/**

@@ -506,6 +532,5 @@ * Add a function to the canvas event stack. This function will be enabled by default. Args:

*/
cevent_add_function(id, fjs_event_code, fn)
{
cevent_add_function(id, fjs_event_code, fn) {
//console.log("Adding function " + id)
this.cevent_data[fjs_event_code].fn_list[id] = {enabled: true, temp_disabled: false, fn: fn}
this.cevent_data[fjs_event_code].fn_list[id] = { enabled: true, temp_disabled: false, fn: fn }
}

@@ -517,17 +542,12 @@

*/
cevent_del_function(id)
{
cevent_del_function(id) {
//console.log("Removing function " + id)
for(var x = 0; x < this.all_fjs_event_strings.length; x++)
{
var fjsstr = this.all_fjs_event_strings[x];
var databloc = this.cevent_data[fjsstr];
for (var x = 0; x < this.all_fjs_event_strings.length; x++) {
var fjsstr = this.all_fjs_event_strings[x]
var databloc = this.cevent_data[fjsstr]
//Loop through all associated functions
for(var fn_id in databloc.fn_list)
{
if (databloc.fn_list.hasOwnProperty(fn_id))
{
if (fn_id == id)
{
delete this.cevent_data[fjsstr].fn_list[fn_id];
for (var fn_id in databloc.fn_list) {
if (databloc.fn_list.hasOwnProperty(fn_id)) {
if (fn_id == id) {
delete this.cevent_data[fjsstr].fn_list[fn_id]
}

@@ -544,16 +564,11 @@ }

*/
cevent_enable_function(id, enabled)
{
for(var x = 0; x < this.all_fjs_event_strings.length; x++)
{
var fjsstr = this.all_fjs_event_strings[x];
var databloc = this.cevent_data[fjsstr];
cevent_enable_function(id, enabled) {
for (var x = 0; x < this.all_fjs_event_strings.length; x++) {
var fjsstr = this.all_fjs_event_strings[x]
var databloc = this.cevent_data[fjsstr]
//Loop through all associated functions
for(var fn_id in databloc.fn_list)
{
if (databloc.fn_list.hasOwnProperty(fn_id))
{
if (fn_id == id)
{
this.cevent_data[fjsstr].fn_list[fn_id].enabled = enabled;
for (var fn_id in databloc.fn_list) {
if (databloc.fn_list.hasOwnProperty(fn_id)) {
if (fn_id == id) {
this.cevent_data[fjsstr].fn_list[fn_id].enabled = enabled
}

@@ -564,3 +579,3 @@ }

}
/**

@@ -571,5 +586,4 @@ * Set the fjse event of fjs_event_code to 'enabled' where 'enabled' is true to enable the function and false to disable (but not remove) it.

*/
cevent_enable_fjs(fjs_event_code, enabled)
{
this.cevent_data[fjs_event_code].enabled = enabled;
cevent_enable_fjs(fjs_event_code, enabled) {
this.cevent_data[fjs_event_code].enabled = enabled
}

@@ -581,15 +595,11 @@

*/
cevent_disable_all_but(list_of_ids)
{
for(var x = 0; x < this.all_fjs_event_strings.length; x++)
{
var fjsstr = this.all_fjs_event_strings[x];
var databloc = this.cevent_data[fjsstr];
cevent_disable_all_but(list_of_ids) {
for (var x = 0; x < this.all_fjs_event_strings.length; x++) {
var fjsstr = this.all_fjs_event_strings[x]
var databloc = this.cevent_data[fjsstr]
//Loop through all associated functions
for(var fn_id in databloc.fn_list)
{
if (databloc.fn_list.hasOwnProperty(fn_id))
{
for (var fn_id in databloc.fn_list) {
if (databloc.fn_list.hasOwnProperty(fn_id)) {
//This sets temp_disabled to TRUE if fn_id is not in list_of_ids
this.cevent_data[fjsstr].fn_list[fn_id].temp_disabled = (list_of_ids.indexOf(fn_id) < 0);
this.cevent_data[fjsstr].fn_list[fn_id].temp_disabled = list_of_ids.indexOf(fn_id) < 0
//console.log("Setting function " + fn_id + " to " + ((list_of_ids.indexOf(fn_id) < 0) ? "disabled" : "enabled"))

@@ -600,3 +610,3 @@ }

}
/**

@@ -606,13 +616,9 @@ * Enable all events. NOTE this does not ENABLE all functions; rather it removes the temp_disabled flag from all functions.

*/
cevent_undisable_all()
{
for(var x = 0; x < this.all_fjs_event_strings.length; x++)
{
var fjsstr = this.all_fjs_event_strings[x];
var databloc = this.cevent_data[fjsstr];
cevent_undisable_all() {
for (var x = 0; x < this.all_fjs_event_strings.length; x++) {
var fjsstr = this.all_fjs_event_strings[x]
var databloc = this.cevent_data[fjsstr]
//Loop through all associated functions
for(var fn_id in databloc.fn_list)
{
if (databloc.fn_list.hasOwnProperty(fn_id))
{
for (var fn_id in databloc.fn_list) {
if (databloc.fn_list.hasOwnProperty(fn_id)) {
this.cevent_data[fjsstr].fn_list[fn_id].temp_disabled = false

@@ -630,18 +636,13 @@ }

*/
_cevent_masterfunction(fjs_event_code, fjse)
{
var databloc = this.cevent_data[fjs_event_code];
_cevent_masterfunction(fjs_event_code, fjse) {
var databloc = this.cevent_data[fjs_event_code]
//If this FJS event call is currently enabled
if(databloc.enabled)
{
if (databloc.enabled) {
//Loop through all associated functions
for(var fn_id in databloc.fn_list)
{
if (databloc.fn_list.hasOwnProperty(fn_id))
{
for (var fn_id in databloc.fn_list) {
if (databloc.fn_list.hasOwnProperty(fn_id)) {
//Actually call each of those functions if enabled.
if(databloc.fn_list[fn_id].enabled && !databloc.fn_list[fn_id].temp_disabled)
{
if (databloc.fn_list[fn_id].enabled && !databloc.fn_list[fn_id].temp_disabled) {
//console.log("Calling function " + fn_id)
databloc.fn_list[fn_id].fn(fjse);
databloc.fn_list[fn_id].fn(fjse)
}

@@ -657,9 +658,8 @@ }

*/
debug_enable_bounding_rects()
{
this.fjs_canvas.on('after:render', () => {
this.fjs_canvas.contextContainer.strokeStyle = '#555';
debug_enable_bounding_rects() {
this.fjs_canvas.on("after:render", () => {
this.fjs_canvas.contextContainer.strokeStyle = "#555"
this.fjs_canvas.forEachObject((obj) => {
var bound = obj.getBoundingRect();
var bound = obj.getBoundingRect()

@@ -671,14 +671,13 @@ this.fjs_canvas.contextContainer.strokeRect(

bound.height
);
)
})
});
})
}
settings_refresh()
{
settings_refresh() {
super.settings_refresh()
this.settings.bounding_dims = {w: 1000, h: 1000}
this.settings.bounding_dims = { w: 1000, h: 1000 }
}
}
export { RegionCanvas }
export { RegionCanvas }

@@ -8,3 +8,3 @@ /* rfmm_filesys/r_file_upload_multi.js

import { Region, RegionAppUser, generate_hash } from "regional-model-base"
import { get_name_and_ext_from_filename } from "../module.js"
import { get_name_and_ext_from_filename } from ".."

@@ -65,25 +65,28 @@ class RegionFileUpload extends Region {

// This can be called only once so it belongs in the constructor
this.file_dropzone = new Dropzone("[" + Region.member_attr_name + "=" + RegionFileUpload.member_name_dropzone + "]", {
url: this.get_splitupload_url(),
init: function () {
this.on("sending", _this.dropzone_on_sending.bind(_this))
this.on("error", _this.dropzone_on_error.bind(_this)) // Called by dropzone.js if something goes wrong during upload
this.on("success", _this.dropzone_on_success.bind(_this)) // Called when upload complete.
this.on("processing", function () {
//Fixes bug https://stackoverflow.com/questions/18059128/dropzone-js-uploads-only-two-files-when-autoprocessqueue-set-to-false
this.options.autoProcessQueue = true
})
this.on("addedfile", _this.dropzone_on_added.bind(_this))
},
headers: {
"X-CSRF-TOKEN": this.app.token_get_csrf(),
},
paramName: "file",
autoProcessQueue: false,
maxFiles: 200,
chunking: true,
forceChunking: true,
maxFilesize: 10 * 1024, // 10 GB, in megabytes
chunkSize: 5 * 1024 * 1024, // 5 MB, in bytes
})
this.file_dropzone = new Dropzone(
"[" + Region.member_attr_name + "=" + RegionFileUpload.member_name_dropzone + "]",
{
url: this.get_splitupload_url(),
init: function () {
this.on("sending", _this.dropzone_on_sending.bind(_this))
this.on("error", _this.dropzone_on_error.bind(_this)) // Called by dropzone.js if something goes wrong during upload
this.on("success", _this.dropzone_on_success.bind(_this)) // Called when upload complete.
this.on("processing", function () {
//Fixes bug https://stackoverflow.com/questions/18059128/dropzone-js-uploads-only-two-files-when-autoprocessqueue-set-to-false
this.options.autoProcessQueue = true
})
this.on("addedfile", _this.dropzone_on_added.bind(_this))
},
headers: {
"X-CSRF-TOKEN": this.app.token_get_csrf(),
},
paramName: "file",
autoProcessQueue: false,
maxFiles: 200,
chunking: true,
forceChunking: true,
maxFilesize: 10 * 1024, // 10 GB, in megabytes
chunkSize: 5 * 1024 * 1024, // 5 MB, in bytes
}
)
// Prevents the flickering progress bar problem

@@ -236,3 +239,9 @@ this.file_dropzone.on("uploadprogress", function (file, progress, bytesSent) {

mupload_create_record(upload_file, destination_folder_id) {
return this.app.gpq_backend[this.get_gpq_route_create()](upload_file.name, destination_folder_id, upload_file.mimetype, upload_file.ext, upload_file.unique_hash)
return this.app.gpq_backend[this.get_gpq_route_create()](
upload_file.name,
destination_folder_id,
upload_file.mimetype,
upload_file.ext,
upload_file.unique_hash
)
}

@@ -325,3 +334,6 @@

this.mupload_delete_all()
this.fail_with_error("Something has gone wrong with the file upload. Please try again later.", 1)
this.fail_with_error(
"Something has gone wrong with the file upload. Please try again later.",
1
)
}

@@ -366,3 +378,6 @@ })

// Notify the user that one file failed, but don't stop the flow.
var lines = ["The server encountered an error when attempting to process one or more of the files.", "Those files have been deleted. The rest that succeeded have been uploaded."]
var lines = [
"The server encountered an error when attempting to process one or more of the files.",
"Those files have been deleted. The rest that succeeded have been uploaded.",
]
this.fail_with_error(lines.join(" "), 0)

@@ -369,0 +384,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc