- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
/* globals jQuery */
|
2010-06-03 07:25:06 +00:00
|
|
|
/*
|
|
|
|
* ext-markers.js
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2
|
|
|
|
*
|
2018-05-16 00:53:27 +00:00
|
|
|
* Copyright(c) 2010 Will Schleter
|
2010-06-03 07:25:06 +00:00
|
|
|
* based on ext-arrows.js by Copyright(c) 2010 Alexis Deveria
|
|
|
|
*
|
|
|
|
* This extension provides for the addition of markers to the either end
|
2018-05-16 00:53:27 +00:00
|
|
|
* or the middle of a line, polyline, path, polygon.
|
|
|
|
*
|
2010-06-03 07:25:06 +00:00
|
|
|
* Markers may be either a graphic or arbitary text
|
2018-05-16 00:53:27 +00:00
|
|
|
*
|
2010-06-03 07:25:06 +00:00
|
|
|
* to simplify the coding and make the implementation as robust as possible,
|
|
|
|
* markers are not shared - every object has its own set of markers.
|
|
|
|
* this relationship is maintained by a naming convention between the
|
|
|
|
* ids of the markers and the ids of the object
|
2018-05-16 00:53:27 +00:00
|
|
|
*
|
2010-06-03 07:25:06 +00:00
|
|
|
* The following restrictions exist for simplicty of use and programming
|
|
|
|
* objects and their markers to have the same color
|
|
|
|
* marker size is fixed
|
|
|
|
* text marker font, size, and attributes are fixed
|
|
|
|
* an application specific attribute - se_type - is added to each marker element
|
|
|
|
* to store the type of marker
|
2014-02-12 09:38:38 +00:00
|
|
|
*
|
2010-06-03 07:25:06 +00:00
|
|
|
* TODO:
|
|
|
|
* remove some of the restrictions above
|
|
|
|
* add option for keeping text aligned to horizontal
|
|
|
|
* add support for dimension extension lines
|
|
|
|
*
|
|
|
|
*/
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
import svgEditor from '../svg-editor.js';
|
2018-05-16 00:53:27 +00:00
|
|
|
svgEditor.addExtension('Markers', function (S) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const $ = jQuery;
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
const svgCanvas = svgEditor.canvas;
|
2018-05-18 03:25:45 +00:00
|
|
|
const // {svgcontent} = S,
|
|
|
|
addElem = S.addSvgElementFromJson;
|
|
|
|
const mtypes = ['start', 'mid', 'end'];
|
|
|
|
const markerPrefix = 'se_marker_';
|
|
|
|
const idPrefix = 'mkr_';
|
2018-05-18 04:54:31 +00:00
|
|
|
|
|
|
|
// note - to add additional marker types add them below with a unique id
|
|
|
|
// and add the associated icon(s) to marker-icons.svg
|
|
|
|
// the geometry is normallized to a 100x100 box with the origin at lower left
|
|
|
|
// Safari did not like negative values for low left of viewBox
|
|
|
|
// remember that the coordinate system has +y downward
|
2018-05-18 03:25:45 +00:00
|
|
|
const markerTypes = {
|
2018-05-18 04:54:31 +00:00
|
|
|
nomarker: {},
|
|
|
|
leftarrow:
|
|
|
|
{element: 'path', attr: {d: 'M0,50 L100,90 L70,50 L100,10 Z'}},
|
|
|
|
rightarrow:
|
|
|
|
{element: 'path', attr: {d: 'M100,50 L0,90 L30,50 L0,10 Z'}},
|
|
|
|
textmarker:
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
{element: 'text', attr: {x: 0, y: 0, 'stroke-width': 0, stroke: 'none', 'font-size': 75, 'font-family': 'serif', 'text-anchor': 'left',
|
2018-05-18 04:54:31 +00:00
|
|
|
'xml:space': 'preserve'}},
|
|
|
|
forwardslash:
|
|
|
|
{element: 'path', attr: {d: 'M30,100 L70,0'}},
|
|
|
|
reverseslash:
|
|
|
|
{element: 'path', attr: {d: 'M30,0 L70,100'}},
|
|
|
|
verticalslash:
|
|
|
|
{element: 'path', attr: {d: 'M50,0 L50,100'}},
|
|
|
|
box:
|
|
|
|
{element: 'path', attr: {d: 'M20,20 L20,80 L80,80 L80,20 Z'}},
|
|
|
|
star:
|
|
|
|
{element: 'path', attr: {d: 'M10,30 L90,30 L20,90 L50,10 L80,90 Z'}},
|
|
|
|
xmark:
|
|
|
|
{element: 'path', attr: {d: 'M20,80 L80,20 M80,80 L20,20'}},
|
|
|
|
triangle:
|
|
|
|
{element: 'path', attr: {d: 'M10,80 L50,20 L80,80 Z'}},
|
|
|
|
mcircle:
|
|
|
|
{element: 'circle', attr: {r: 30, cx: 50, cy: 50}}
|
|
|
|
};
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const langList = {
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
en: [
|
2018-05-18 04:54:31 +00:00
|
|
|
{id: 'start_marker_list', title: 'Select start marker type'},
|
|
|
|
{id: 'mid_marker_list', title: 'Select mid marker type'},
|
|
|
|
{id: 'end_marker_list', title: 'Select end marker type'},
|
|
|
|
{id: 'nomarker', title: 'No Marker'},
|
|
|
|
{id: 'leftarrow', title: 'Left Arrow'},
|
|
|
|
{id: 'rightarrow', title: 'Right Arrow'},
|
|
|
|
{id: 'textmarker', title: 'Text Marker'},
|
|
|
|
{id: 'forwardslash', title: 'Forward Slash'},
|
|
|
|
{id: 'reverseslash', title: 'Reverse Slash'},
|
|
|
|
{id: 'verticalslash', title: 'Vertical Slash'},
|
|
|
|
{id: 'box', title: 'Box'},
|
|
|
|
{id: 'star', title: 'Star'},
|
|
|
|
{id: 'xmark', title: 'X'},
|
|
|
|
{id: 'triangle', title: 'Triangle'},
|
|
|
|
{id: 'mcircle', title: 'Circle'},
|
|
|
|
{id: 'leftarrow_o', title: 'Open Left Arrow'},
|
|
|
|
{id: 'rightarrow_o', title: 'Open Right Arrow'},
|
|
|
|
{id: 'box_o', title: 'Open Box'},
|
|
|
|
{id: 'star_o', title: 'Open Star'},
|
|
|
|
{id: 'triangle_o', title: 'Open Triangle'},
|
|
|
|
{id: 'mcircle_o', title: 'Open Circle'}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
// duplicate shapes to support unfilled (open) marker types with an _o suffix
|
|
|
|
$.each(['leftarrow', 'rightarrow', 'box', 'star', 'mcircle', 'triangle'], function (i, v) {
|
|
|
|
markerTypes[v + '_o'] = markerTypes[v];
|
|
|
|
});
|
|
|
|
|
2018-05-29 12:31:24 +00:00
|
|
|
/**
|
|
|
|
* @param elem - A graphic element will have an attribute like marker-start
|
|
|
|
* @param attr - marker-start, marker-mid, or marker-end
|
|
|
|
* @returns The marker element that is linked to the graphic element
|
|
|
|
*/
|
2018-05-18 04:54:31 +00:00
|
|
|
function getLinked (elem, attr) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const str = elem.getAttribute(attr);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (!str) { return null; }
|
2018-05-18 03:25:45 +00:00
|
|
|
const m = str.match(/\(#(.*)\)/);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (!m || m.length !== 2) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return S.getElem(m[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setIcon (pos, id) {
|
|
|
|
if (id.substr(0, 1) !== '\\') { id = '\\textmarker'; }
|
2018-05-18 03:25:45 +00:00
|
|
|
const ci = '#' + idPrefix + pos + '_' + id.substr(1);
|
2018-05-18 04:54:31 +00:00
|
|
|
svgEditor.setIcon('#cur_' + pos + '_marker_list', $(ci).children());
|
|
|
|
$(ci).addClass('current').siblings().removeClass('current');
|
|
|
|
}
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
let selElems;
|
2018-05-18 04:54:31 +00:00
|
|
|
// toggles context tool panel off/on
|
|
|
|
// sets the controls with the selected element's settings
|
|
|
|
function showPanel (on) {
|
|
|
|
$('#marker_panel').toggle(on);
|
|
|
|
|
|
|
|
if (on) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const el = selElems[0];
|
2018-05-18 04:54:31 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
let val, ci;
|
2018-05-18 04:54:31 +00:00
|
|
|
$.each(mtypes, function (i, pos) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const m = getLinked(el, 'marker-' + pos);
|
|
|
|
const txtbox = $('#' + pos + '_marker');
|
2018-05-18 04:54:31 +00:00
|
|
|
if (!m) {
|
|
|
|
val = '\\nomarker';
|
|
|
|
ci = val;
|
|
|
|
txtbox.hide(); // hide text box
|
|
|
|
} else {
|
|
|
|
if (!m.attributes.se_type) { return; } // not created by this extension
|
|
|
|
val = '\\' + m.attributes.se_type.textContent;
|
|
|
|
ci = val;
|
|
|
|
if (val === '\\textmarker') {
|
|
|
|
val = m.lastChild.textContent;
|
|
|
|
// txtbox.show(); // show text box
|
|
|
|
} else {
|
|
|
|
txtbox.hide(); // hide text box
|
|
|
|
}
|
|
|
|
}
|
|
|
|
txtbox.val(val);
|
|
|
|
setIcon(pos, ci);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addMarker (id, val) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const txtBoxBg = '#ffffff';
|
|
|
|
const txtBoxBorder = 'none';
|
|
|
|
const txtBoxStrokeWidth = 0;
|
2018-05-18 04:54:31 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
let marker = S.getElem(id);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (marker) { return; }
|
|
|
|
|
|
|
|
if (val === '' || val === '\\nomarker') { return; }
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const el = selElems[0];
|
|
|
|
const color = el.getAttribute('stroke');
|
2018-05-18 04:54:31 +00:00
|
|
|
// NOTE: Safari didn't like a negative value in viewBox
|
|
|
|
// so we use a standardized 0 0 100 100
|
|
|
|
// with 50 50 being mapped to the marker position
|
2018-05-18 03:25:45 +00:00
|
|
|
const strokeWidth = 10;
|
|
|
|
let refX = 50;
|
|
|
|
let refY = 50;
|
|
|
|
let viewBox = '0 0 100 100';
|
|
|
|
let markerWidth = 5;
|
|
|
|
let markerHeight = 5;
|
|
|
|
let seType;
|
2018-05-18 04:54:31 +00:00
|
|
|
if (val.substr(0, 1) === '\\') {
|
|
|
|
seType = val.substr(1);
|
|
|
|
} else { seType = 'textmarker'; }
|
|
|
|
|
|
|
|
if (!markerTypes[seType]) { return; } // an unknown type!
|
|
|
|
|
|
|
|
// create a generic marker
|
|
|
|
marker = addElem({
|
2018-05-18 03:25:45 +00:00
|
|
|
element: 'marker',
|
|
|
|
attr: {
|
|
|
|
id,
|
|
|
|
markerUnits: 'strokeWidth',
|
|
|
|
orient: 'auto',
|
|
|
|
style: 'pointer-events:none',
|
|
|
|
se_type: seType
|
2018-05-18 04:54:31 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (seType !== 'textmarker') {
|
2018-05-18 03:25:45 +00:00
|
|
|
const mel = addElem(markerTypes[seType]);
|
|
|
|
const fillcolor = (seType.substr(-2) === '_o')
|
|
|
|
? 'none'
|
|
|
|
: color;
|
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
mel.setAttribute('fill', fillcolor);
|
|
|
|
mel.setAttribute('stroke', color);
|
|
|
|
mel.setAttribute('stroke-width', strokeWidth);
|
|
|
|
marker.appendChild(mel);
|
|
|
|
} else {
|
2018-05-18 03:25:45 +00:00
|
|
|
const text = addElem(markerTypes[seType]);
|
2018-05-18 04:54:31 +00:00
|
|
|
// have to add text to get bounding box
|
|
|
|
text.textContent = val;
|
2018-05-18 03:25:45 +00:00
|
|
|
const tb = text.getBBox();
|
2018-05-18 04:54:31 +00:00
|
|
|
// alert(tb.x + ' ' + tb.y + ' ' + tb.width + ' ' + tb.height);
|
2018-05-18 03:25:45 +00:00
|
|
|
const pad = 1;
|
|
|
|
const bb = tb;
|
2018-05-18 04:54:31 +00:00
|
|
|
bb.x = 0;
|
|
|
|
bb.y = 0;
|
|
|
|
bb.width += pad * 2;
|
|
|
|
bb.height += pad * 2;
|
|
|
|
// shift text according to its size
|
|
|
|
text.setAttribute('x', pad);
|
|
|
|
text.setAttribute('y', bb.height - pad - tb.height / 4); // kludge?
|
|
|
|
text.setAttribute('fill', color);
|
|
|
|
refX = bb.width / 2 + pad;
|
|
|
|
refY = bb.height / 2 + pad;
|
|
|
|
viewBox = bb.x + ' ' + bb.y + ' ' + bb.width + ' ' + bb.height;
|
|
|
|
markerWidth = bb.width / 10;
|
|
|
|
markerHeight = bb.height / 10;
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const box = addElem({
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
element: 'rect',
|
|
|
|
attr: {
|
|
|
|
x: bb.x,
|
|
|
|
y: bb.y,
|
|
|
|
width: bb.width,
|
|
|
|
height: bb.height,
|
|
|
|
fill: txtBoxBg,
|
|
|
|
stroke: txtBoxBorder,
|
2018-05-18 04:54:31 +00:00
|
|
|
'stroke-width': txtBoxStrokeWidth
|
|
|
|
}
|
|
|
|
});
|
|
|
|
marker.setAttribute('orient', 0);
|
|
|
|
marker.appendChild(box);
|
|
|
|
marker.appendChild(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
marker.setAttribute('viewBox', viewBox);
|
|
|
|
marker.setAttribute('markerWidth', markerWidth);
|
|
|
|
marker.setAttribute('markerHeight', markerHeight);
|
|
|
|
marker.setAttribute('refX', refX);
|
|
|
|
marker.setAttribute('refY', refY);
|
|
|
|
S.findDefs().appendChild(marker);
|
|
|
|
|
|
|
|
return marker;
|
|
|
|
}
|
|
|
|
|
|
|
|
function convertline (elem) {
|
|
|
|
// this routine came from the connectors extension
|
|
|
|
// it is needed because midpoint markers don't work with line elements
|
|
|
|
if (!(elem.tagName === 'line')) { return elem; }
|
|
|
|
|
|
|
|
// Convert to polyline to accept mid-arrow
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const x1 = Number(elem.getAttribute('x1'));
|
|
|
|
const x2 = Number(elem.getAttribute('x2'));
|
|
|
|
const y1 = Number(elem.getAttribute('y1'));
|
|
|
|
const y2 = Number(elem.getAttribute('y2'));
|
|
|
|
const {id} = elem;
|
2018-05-18 04:54:31 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const midPt = (' ' + ((x1 + x2) / 2) + ',' + ((y1 + y2) / 2) + ' ');
|
|
|
|
const pline = addElem({
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
element: 'polyline',
|
|
|
|
attr: {
|
|
|
|
points: (x1 + ',' + y1 + midPt + x2 + ',' + y2),
|
|
|
|
stroke: elem.getAttribute('stroke'),
|
2018-05-18 04:54:31 +00:00
|
|
|
'stroke-width': elem.getAttribute('stroke-width'),
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
fill: 'none',
|
|
|
|
opacity: elem.getAttribute('opacity') || 1
|
2018-05-18 04:54:31 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$.each(mtypes, function (i, pos) { // get any existing marker definitions
|
2018-05-18 03:25:45 +00:00
|
|
|
const nam = 'marker-' + pos;
|
|
|
|
const m = elem.getAttribute(nam);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (m) { pline.setAttribute(nam, elem.getAttribute(nam)); }
|
|
|
|
});
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const batchCmd = new S.BatchCommand();
|
2018-05-18 04:54:31 +00:00
|
|
|
batchCmd.addSubCommand(new S.RemoveElementCommand(elem, elem.parentNode));
|
|
|
|
batchCmd.addSubCommand(new S.InsertElementCommand(pline));
|
|
|
|
|
|
|
|
$(elem).after(pline).remove();
|
|
|
|
svgCanvas.clearSelection();
|
|
|
|
pline.id = id;
|
|
|
|
svgCanvas.addToSelection([pline]);
|
|
|
|
S.addCommandToHistory(batchCmd);
|
|
|
|
return pline;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setMarker () {
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
const poslist = {start_marker: 'start', mid_marker: 'mid', end_marker: 'end'};
|
2018-05-18 03:25:45 +00:00
|
|
|
const pos = poslist[this.id];
|
|
|
|
const markerName = 'marker-' + pos;
|
|
|
|
let el = selElems[0];
|
|
|
|
const marker = getLinked(el, markerName);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (marker) { $(marker).remove(); }
|
|
|
|
el.removeAttribute(markerName);
|
2018-05-18 03:25:45 +00:00
|
|
|
let val = this.value;
|
2018-05-18 04:54:31 +00:00
|
|
|
if (val === '') { val = '\\nomarker'; }
|
|
|
|
if (val === '\\nomarker') {
|
|
|
|
setIcon(pos, val);
|
|
|
|
S.call('changed', selElems);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Set marker on element
|
2018-05-18 03:25:45 +00:00
|
|
|
const id = markerPrefix + pos + '_' + el.id;
|
2018-05-18 04:54:31 +00:00
|
|
|
addMarker(id, val);
|
|
|
|
svgCanvas.changeSelectedAttribute(markerName, 'url(#' + id + ')');
|
|
|
|
if (el.tagName === 'line' && pos === 'mid') { el = convertline(el); }
|
|
|
|
S.call('changed', selElems);
|
|
|
|
setIcon(pos, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
// called when the main system modifies an object
|
|
|
|
// this routine changes the associated markers to be the same color
|
|
|
|
function colorChanged (elem) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const color = elem.getAttribute('stroke');
|
2018-05-18 04:54:31 +00:00
|
|
|
|
|
|
|
$.each(mtypes, function (i, pos) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const marker = getLinked(elem, 'marker-' + pos);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (!marker) { return; }
|
|
|
|
if (!marker.attributes.se_type) { return; } // not created by this extension
|
2018-05-18 03:25:45 +00:00
|
|
|
const ch = marker.lastElementChild;
|
2018-05-18 04:54:31 +00:00
|
|
|
if (!ch) { return; }
|
2018-05-18 03:25:45 +00:00
|
|
|
const curfill = ch.getAttribute('fill');
|
|
|
|
const curstroke = ch.getAttribute('stroke');
|
2018-05-18 04:54:31 +00:00
|
|
|
if (curfill && curfill !== 'none') { ch.setAttribute('fill', color); }
|
|
|
|
if (curstroke && curstroke !== 'none') { ch.setAttribute('stroke', color); }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// called when the main system creates or modifies an object
|
|
|
|
// primary purpose is create new markers for cloned objects
|
|
|
|
function updateReferences (el) {
|
|
|
|
$.each(mtypes, function (i, pos) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const id = markerPrefix + pos + '_' + el.id;
|
|
|
|
const markerName = 'marker-' + pos;
|
|
|
|
const marker = getLinked(el, markerName);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (!marker || !marker.attributes.se_type) { return; } // not created by this extension
|
2018-05-18 03:25:45 +00:00
|
|
|
const url = el.getAttribute(markerName);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (url) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const len = el.id.length;
|
|
|
|
const linkid = url.substr(-len - 1, len);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (el.id !== linkid) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const val = $('#' + pos + '_marker').attr('value');
|
2018-05-18 04:54:31 +00:00
|
|
|
addMarker(id, val);
|
|
|
|
svgCanvas.changeSelectedAttribute(markerName, 'url(#' + id + ')');
|
|
|
|
if (el.tagName === 'line' && pos === 'mid') { el = convertline(el); }
|
|
|
|
S.call('changed', selElems);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// simulate a change event a text box that stores the current element's marker type
|
|
|
|
function triggerTextEntry (pos, val) {
|
|
|
|
$('#' + pos + '_marker').val(val);
|
|
|
|
$('#' + pos + '_marker').change();
|
2018-05-18 03:25:45 +00:00
|
|
|
// const txtbox = $('#'+pos+'_marker');
|
2018-05-18 04:54:31 +00:00
|
|
|
// if (val.substr(0,1)=='\\') {txtbox.hide();}
|
|
|
|
// else {txtbox.show();}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showTextPrompt (pos) {
|
2018-05-18 03:25:45 +00:00
|
|
|
let def = $('#' + pos + '_marker').val();
|
2018-05-18 04:54:31 +00:00
|
|
|
if (def.substr(0, 1) === '\\') { def = ''; }
|
|
|
|
$.prompt('Enter text for ' + pos + ' marker', def, function (txt) {
|
|
|
|
if (txt) { triggerTextEntry(pos, txt); }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
function setMarkerSet(obj) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const parts = this.id.split('_');
|
|
|
|
const set = parts[2];
|
2018-05-18 04:54:31 +00:00
|
|
|
switch (set) {
|
|
|
|
case 'off':
|
|
|
|
triggerTextEntry('start','\\nomarker');
|
|
|
|
triggerTextEntry('mid','\\nomarker');
|
|
|
|
triggerTextEntry('end','\\nomarker');
|
|
|
|
break;
|
|
|
|
case 'dimension':
|
|
|
|
triggerTextEntry('start','\\leftarrow');
|
|
|
|
triggerTextEntry('end','\\rightarrow');
|
|
|
|
showTextPrompt('mid');
|
|
|
|
break;
|
|
|
|
case 'label':
|
|
|
|
triggerTextEntry('mid','\\nomarker');
|
|
|
|
triggerTextEntry('end','\\rightarrow');
|
|
|
|
showTextPrompt('start');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// callback function for a toolbar button click
|
|
|
|
function setArrowFromButton (obj) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const parts = this.id.split('_');
|
|
|
|
const pos = parts[1];
|
|
|
|
let val = parts[2];
|
2018-05-18 04:54:31 +00:00
|
|
|
if (parts[3]) { val += '_' + parts[3]; }
|
|
|
|
|
|
|
|
if (val !== 'textmarker') {
|
|
|
|
triggerTextEntry(pos, '\\' + val);
|
|
|
|
} else {
|
|
|
|
showTextPrompt(pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
function getTitle (lang = 'en', id) {
|
|
|
|
const list = langList[lang];
|
|
|
|
for (const i in list) {
|
2018-05-18 04:54:31 +00:00
|
|
|
if (list.hasOwnProperty(i) && list[i].id === id) {
|
|
|
|
return list[i].title;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
// build the toolbar button array from the marker definitions
|
2018-05-18 03:25:45 +00:00
|
|
|
function buildButtonList (lang) {
|
|
|
|
const buttons = [];
|
|
|
|
// const i = 0;
|
2018-05-18 04:54:31 +00:00
|
|
|
/*
|
|
|
|
buttons.push({
|
|
|
|
id: idPrefix + 'markers_off',
|
|
|
|
title: 'Turn off all markers',
|
|
|
|
type: 'context',
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
events: { click: setMarkerSet },
|
2018-05-18 04:54:31 +00:00
|
|
|
panel: 'marker_panel'
|
|
|
|
});
|
|
|
|
buttons.push({
|
|
|
|
id: idPrefix + 'markers_dimension',
|
|
|
|
title: 'Dimension',
|
|
|
|
type: 'context',
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
events: { click: setMarkerSet },
|
2018-05-18 04:54:31 +00:00
|
|
|
panel: 'marker_panel'
|
|
|
|
});
|
|
|
|
buttons.push({
|
|
|
|
id: idPrefix + 'markers_label',
|
|
|
|
title: 'Label',
|
|
|
|
type: 'context',
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
events: { click: setMarkerSet },
|
2018-05-18 04:54:31 +00:00
|
|
|
panel: 'marker_panel'
|
|
|
|
});
|
2010-06-03 07:25:06 +00:00
|
|
|
*/
|
2018-05-18 04:54:31 +00:00
|
|
|
$.each(mtypes, function (k, pos) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const listname = pos + '_marker_list';
|
|
|
|
let def = true;
|
2018-05-18 04:54:31 +00:00
|
|
|
$.each(markerTypes, function (id, v) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const title = getTitle(lang, String(id));
|
2018-05-18 04:54:31 +00:00
|
|
|
buttons.push({
|
|
|
|
id: idPrefix + pos + '_' + id,
|
|
|
|
svgicon: id,
|
2018-05-18 03:25:45 +00:00
|
|
|
title,
|
2018-05-18 04:54:31 +00:00
|
|
|
type: 'context',
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
events: {click: setArrowFromButton},
|
2018-05-18 04:54:31 +00:00
|
|
|
panel: 'marker_panel',
|
|
|
|
list: listname,
|
|
|
|
isDefault: def
|
|
|
|
});
|
|
|
|
def = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return buttons;
|
|
|
|
}
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
let currentLang;
|
|
|
|
const ret = {
|
2018-05-18 04:54:31 +00:00
|
|
|
name: 'Markers',
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
svgicons: svgEditor.curConfig.extIconsPath + 'markers-icons.xml',
|
2018-05-18 03:25:45 +00:00
|
|
|
callback () {
|
2018-05-18 04:54:31 +00:00
|
|
|
$('#marker_panel').addClass('toolset').hide();
|
|
|
|
},
|
2018-05-18 03:25:45 +00:00
|
|
|
addLangData (lang) {
|
|
|
|
currentLang = lang;
|
2018-05-18 04:54:31 +00:00
|
|
|
return { data: langList[lang] };
|
|
|
|
},
|
2018-05-18 03:25:45 +00:00
|
|
|
selectedChanged (opts) {
|
2018-05-18 04:54:31 +00:00
|
|
|
// Use this to update the current selected elements
|
|
|
|
// console.log('selectChanged',opts);
|
|
|
|
selElems = opts.elems;
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const markerElems = ['line', 'path', 'polyline', 'polygon'];
|
2018-05-18 04:54:31 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
let i = selElems.length;
|
2018-05-18 04:54:31 +00:00
|
|
|
while (i--) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const elem = selElems[i];
|
|
|
|
if (elem && markerElems.includes(elem.tagName)) {
|
2018-05-18 04:54:31 +00:00
|
|
|
if (opts.selectedElement && !opts.multiselected) {
|
|
|
|
showPanel(true);
|
|
|
|
} else {
|
|
|
|
showPanel(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showPanel(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
elementChanged (opts) {
|
2018-05-18 04:54:31 +00:00
|
|
|
// console.log('elementChanged',opts);
|
2018-05-18 03:25:45 +00:00
|
|
|
const elem = opts.elems[0];
|
2018-05-18 04:54:31 +00:00
|
|
|
if (elem && (
|
|
|
|
elem.getAttribute('marker-start') ||
|
|
|
|
elem.getAttribute('marker-mid') ||
|
|
|
|
elem.getAttribute('marker-end')
|
|
|
|
)) {
|
|
|
|
colorChanged(elem);
|
|
|
|
updateReferences(elem);
|
|
|
|
}
|
|
|
|
// changing_flag = false; // Not apparently in use
|
|
|
|
}
|
|
|
|
};
|
2018-05-18 03:25:45 +00:00
|
|
|
// Todo: Check if the lang will be available in time
|
|
|
|
Object.defineProperties(ret, {
|
|
|
|
buttons: {
|
|
|
|
get () {
|
|
|
|
return buildButtonList(currentLang);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
context_tools: {
|
|
|
|
get () {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
type: 'input',
|
|
|
|
panel: 'marker_panel',
|
|
|
|
title: 'Start marker',
|
|
|
|
id: 'start_marker',
|
|
|
|
label: 's',
|
|
|
|
size: 3,
|
|
|
|
events: { change: setMarker }
|
|
|
|
}, {
|
|
|
|
type: 'button-select',
|
|
|
|
panel: 'marker_panel',
|
|
|
|
title: getTitle(currentLang, 'start_marker_list'),
|
|
|
|
id: 'start_marker_list',
|
|
|
|
colnum: 3,
|
|
|
|
events: { change: setArrowFromButton }
|
|
|
|
}, {
|
|
|
|
type: 'input',
|
|
|
|
panel: 'marker_panel',
|
|
|
|
title: 'Middle marker',
|
|
|
|
id: 'mid_marker',
|
|
|
|
label: 'm',
|
|
|
|
defval: '',
|
|
|
|
size: 3,
|
|
|
|
events: { change: setMarker }
|
|
|
|
}, {
|
|
|
|
type: 'button-select',
|
|
|
|
panel: 'marker_panel',
|
|
|
|
title: getTitle(currentLang, 'mid_marker_list'),
|
|
|
|
id: 'mid_marker_list',
|
|
|
|
colnum: 3,
|
|
|
|
events: { change: setArrowFromButton }
|
|
|
|
}, {
|
|
|
|
type: 'input',
|
|
|
|
panel: 'marker_panel',
|
|
|
|
title: 'End marker',
|
|
|
|
id: 'end_marker',
|
|
|
|
label: 'e',
|
|
|
|
size: 3,
|
|
|
|
events: { change: setMarker }
|
|
|
|
}, {
|
|
|
|
type: 'button-select',
|
|
|
|
panel: 'marker_panel',
|
|
|
|
title: getTitle(currentLang, 'end_marker_list'),
|
|
|
|
id: 'end_marker_list',
|
|
|
|
colnum: 3,
|
|
|
|
events: { change: setArrowFromButton }
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return ret;
|
2010-06-03 07:25:06 +00:00
|
|
|
});
|