From 0eb201fb06d5fa57f00339ef865615638a885642 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 15 Nov 2020 02:28:58 +0300 Subject: [PATCH] cleanup and minor tweaks... Signed-off-by: Alex A. Naanou --- Viewer/features/base.js | 6 +- Viewer/features/core.js | 116 +-------------------------------------- Viewer/package-lock.json | 14 ++--- Viewer/package.json | 4 +- 4 files changed, 14 insertions(+), 126 deletions(-) diff --git a/Viewer/features/base.js b/Viewer/features/base.js index aee8572c..4d23112c 100755 --- a/Viewer/features/base.js +++ b/Viewer/features/base.js @@ -1563,12 +1563,12 @@ module.CropActions = actions.Actions({ // XXX save a crop (catalog).. // XXX - cropBefore: ['Crop/Crop current and $befor$e', + cropBefore: ['Crop|Image/Crop current and $befor$e', function(image, flatten){ image = image || this.current var list = this.data.getImages() return this.crop(list.slice(0, list.indexOf(image)+1), flatten) }], - cropAfter: ['Crop/Crop current and $after', + cropAfter: ['Crop|Image/Crop current and $after', function(image, flatten){ image = image || this.current var list = this.data.getImages() @@ -1621,7 +1621,7 @@ module.CropActions = actions.Actions({ this.crop(crop, flatten) }], - cropOutRibbonsBelow: ['Crop/Crop out ribbons be$low', + cropOutRibbonsBelow: ['Crop|Ribbon/Crop out ribbons be$low', function(ribbon, flatten){ if(this.data.length == 0){ return diff --git a/Viewer/features/core.js b/Viewer/features/core.js index 3f6b3ec7..6b2b157f 100755 --- a/Viewer/features/core.js +++ b/Viewer/features/core.js @@ -2447,120 +2447,8 @@ object.Constructor('Task', { }) -// XXX add .toString(..) -var bareEventMethod = function(name, func, options={}){ - var hidden - var method - return object.mixinFlat( - method = function(func, mode){ - var handlers = - // hidden... - options.handlerLocation == 'hidden' ? - (hidden = hidden || []) - // function... - : options.handlerLocation == 'method' ? - (method.__event_handlers__ = method.__event_handlers__ || []) - // context (default)... - : ((this.__event_handlers__ = this.__event_handlers__ || {})[name] = - this.__event_handlers__[name] || []) - - var args = [...arguments] - var handle = function(){ - handlers - .forEach(function(handler){ - handler(...args) }) } - var res - func ? - (res = func.call(this, handle, ...args)) - : handle(...args) - - return res }, - { - __event__: true, - get __event_handler_location__(){ - return ['hidden', 'method'].includes(options.handlerLocation) ? - options.handlerLocation - : 'context' }, - __event_handler_remove__: function(context, func){ - var handlers = - (options.handlerLocation == 'hidden' ? - hidden - : options.handlerLocation == 'method' ? - method.__event_handlers__ - : (context.__event_handlers__ || {})[name]) || [] - handlers.splice(handlers.indexOf(func), 1) - return this }, - toString: function(){ - return func.toString() - .replace(/^(function[^(]*\()[^,)]*, ?/, '$1') }, - }) } - - -// -// eventMethod(name[, func]) -// -> method -// -// -// Bind handler... -// method(handler) -// -> this -// -// Unbind handler... -// method(handler, false) -// -> this -// -// Trigger handlers... -// method(...args) -// -> this -// -// -// func(handle, ...args) -// -// -// XXX move this someplace generic... -// XXX should this be an EventFunction callable... -var eventMethod = function(name, func, options={}){ - return Object.assign( - bareEventMethod(name, - function(handle, ...args){ - // add handler... - // XXX handle handler tags... - if(typeof(args[0]) == 'function'){ - var handlers = - // hidden... - options.handlerLocation == 'hidden' ? - (hidden = hidden || []) - // function... - : options.handlerLocation == 'method' ? - (method.__event_handlers__ = method.__event_handlers__ || []) - // context (default)... - : ((this.__event_handlers__ = this.__event_handlers__ || {})[name] = - this.__event_handlers__[name] || []) - // add handler... - handlers.push(args[1]) - - // call the action... - } else { - func.call(handle, ...args) } - - return this }, - options), - { - // NOTE: this is a copy of bareEventMethod's .toString() as we - // still need to base the doc on the user's func... - toString: function(){ - return func.toString() - .replace(/^(function[^(]*\()[^,)]*, ?/, '$1') }, - }) } - -var EventHandlerMixin = { - on: function(event, func){ - }, - off: function(event, func){ - }, - trigger: function(event, ...args){ - }, -} +// XXX +var events = require('lib/types/event') var taskAction = diff --git a/Viewer/package-lock.json b/Viewer/package-lock.json index e81c8b27..fd1e68d4 100755 --- a/Viewer/package-lock.json +++ b/Viewer/package-lock.json @@ -1112,16 +1112,16 @@ } }, "ig-object": { - "version": "5.2.8", - "resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.2.8.tgz", - "integrity": "sha512-EzT4CP6d6lI8bnknNgT3W8mUQhSVXflO0yPbKD4dKsFcINiC6npjoEBz+8m3VQmWJhc+36pXD4JLwNxUEgzi+Q==" + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.3.0.tgz", + "integrity": "sha512-8I3w0Gqv96cx1Eirqrvtuh4Pq8X4U3tAexj4nMwceNu4jzZF1wg9FP3Im5ZZ99kQSk7CWl4tjSGe/aS5IXEoMw==" }, "ig-types": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-3.5.2.tgz", - "integrity": "sha512-oKI8eGHSt3Q1BlVG6GQ6DaKg7r/nt2PQ/NPqd2i2q7fvYF6HY4cc+YNpSvJ+TN50I6QVfwiXOIEhPqi8jwViUg==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/ig-types/-/ig-types-3.6.0.tgz", + "integrity": "sha512-zLy40mWfYXPeCw82zoAapgUUvpGvF0GNSZTAEX1s/qpAP2YYR9SnvP8QEJ1N/LqyNSpSC3q+axsBVYEqIgW2fg==", "requires": { - "ig-object": "^5.2.8", + "ig-object": "^5.3.0", "object-run": "^1.0.1" } }, diff --git a/Viewer/package.json b/Viewer/package.json index 99b77669..6360df52 100755 --- a/Viewer/package.json +++ b/Viewer/package.json @@ -31,8 +31,8 @@ "ig-actions": "^3.24.11", "ig-argv": "^2.15.0", "ig-features": "^3.4.2", - "ig-object": "^5.2.8", - "ig-types": "^3.5.2", + "ig-object": "^5.3.0", + "ig-types": "^3.6.0", "moment": "^2.29.1", "object-run": "^1.0.1", "requirejs": "^2.3.6",