', { class: 'flyout_arrow_horiz' }));
+ showBtn = refBtn.clone().attr('id', _tlsId + '_show').append($$b('
', {
+ class: 'flyout_arrow_horiz'
+ }));
+ refBtn.before(showBtn); // Create a flyout div
- refBtn.before(showBtn);
- // Create a flyout div
flyoutHolder = makeFlyoutHolder(_tlsId, refBtn);
}
@@ -28287,24 +31054,21 @@
if (opts.isDefault) {
placementObj['#' + _tlsId + '_show'] = btn.id;
- }
- // TODO: Find way to set the current icon using the iconloader if this is not default
-
+ } // TODO: Find way to set the current icon using the iconloader if this is not default
// Include data for extension button as well as ref button
+
+
var curH = holders['#' + flyoutHolder[0].id] = [{
sel: '#' + id,
fn: btn.events.click,
icon: btn.id,
key: btn.key,
isDefault: Boolean(btn.includeWith && btn.includeWith.isDefault)
- }, refData];
-
- // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'}
+ }, refData]; // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'}
var pos = 'position' in opts ? opts.position : 'last';
- var len = flyoutHolder.children().length;
+ var len = flyoutHolder.children().length; // Add at given position or end
- // Add at given position or end
if (!isNaN(pos) && pos >= 0 && pos < len) {
flyoutHolder.children().eq(pos).before(button);
} else {
@@ -28330,8 +31094,10 @@
}
});
}
+
if (btn.key) {
$$b(document).bind('keydown', btn.key, func);
+
if (btn.title) {
button.attr('title', btn.title + ' [' + btn.key + ']');
}
@@ -28344,15 +31110,17 @@
setupFlyouts(holders);
});
-
$$b.each(btnSelects, function () {
- addAltDropDown(this.elem, this.list, this.callback, { seticon: true });
+ addAltDropDown(this.elem, this.list, this.callback, {
+ seticon: true
+ });
});
if (svgicons) {
return new Promise(function (resolve, reject) {
$$b.svgIcons(svgicons, {
- w: 24, h: 24,
+ w: 24,
+ h: 24,
id_match: false,
no_img: !isWebkit(),
fallback: fallbackObj,
@@ -28363,6 +31131,7 @@
if ($$b.pref('iconsize') !== 'm') {
prepResize();
}
+
runCallback();
resolve();
}
@@ -28370,32 +31139,38 @@
});
}
}
+
return runCallback();
};
var getPaint = function getPaint(color, opac, type) {
// update the editor's fill paint
- var opts = { alpha: opac };
+ var opts = {
+ alpha: opac
+ };
+
if (color.startsWith('url(#')) {
var refElem = svgCanvas.getRefElem(color);
+
if (refElem) {
refElem = refElem.cloneNode(true);
} else {
refElem = $$b('#' + type + '_color defs *')[0];
}
+
opts[refElem.tagName] = refElem;
} else if (color.startsWith('#')) {
opts.solidColor = color.substr(1);
} else {
opts.solidColor = 'none';
}
+
return new $$b.jGraduate.Paint(opts);
- };
-
- // $('#text').focus(function () { textBeingEntered = true; });
+ }; // $('#text').focus(function () { textBeingEntered = true; });
// $('#text').blur(function () { textBeingEntered = false; });
-
// bind the selected event to our function that handles updates to the UI
+
+
svgCanvas.bind('selected', selectedChanged);
svgCanvas.bind('transition', elementTransition);
svgCanvas.bind('changed', elementChanged);
@@ -28406,15 +31181,18 @@
// Ignore Chrome
return;
}
+
var exportWindowName = data.exportWindowName;
if (exportWindowName) {
exportWindow = window.open('', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
}
+
if (!exportWindow || exportWindow.closed) {
$$b.alert(uiStrings$1.notification.popupWindowBlocked);
return;
}
+
exportWindow.location.href = data.output;
});
svgCanvas.bind('zoomed', zoomChanged);
@@ -28430,22 +31208,20 @@
function (win, _ref14) {
var center = _ref14.center,
newCtr = _ref14.newCtr;
-
updateCanvas(center, newCtr);
});
svgCanvas.bind('contextset', contextChanged);
svgCanvas.bind('extension_added', extAdded);
svgCanvas.textActions.setInputElem($$b('#text')[0]);
-
var str = '
';
$$b.each(palette, function (i, item) {
str += '
';
});
- $$b('#palette').append(str);
-
- // Set up editor background functionality
+ $$b('#palette').append(str); // Set up editor background functionality
// TODO add checkerboard as "pattern"
+
var colorBlocks = ['#FFF', '#888', '#000']; // ,'url(data:image/gif;base64,R0lGODlhEAAQAIAAAP%2F%2F%2F9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG%2Bgq4jM3IFLJgpswNly%2FXkcBpIiVaInlLJr9FZWAQA7)'];
+
str = '';
$$b.each(colorBlocks, function () {
str += '
';
@@ -28460,9 +31236,7 @@
$$b(this).addClass(curBg);
});
});
-
setBackground($$b.pref('bkgd_color'), $$b.pref('bkgd_url'));
-
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
var changeRectRadius = function changeRectRadius(ctl) {
@@ -28475,9 +31249,11 @@
var changeStrokeWidth = function changeStrokeWidth(ctl) {
var val = ctl.value;
+
if (val === 0 && selectedElement && ['line', 'polyline'].includes(selectedElement.nodeName)) {
val = ctl.value = 1;
}
+
svgCanvas.setStrokeWidth(val);
};
@@ -28490,10 +31266,13 @@
if (val == null) {
val = ctl.value;
}
+
$$b('#group_opacity').val(val);
+
if (!ctl || !ctl.handle) {
$$b('#opac_slider').slider('option', 'value', val);
}
+
svgCanvas.setOpacity(val / 100);
};
@@ -28501,12 +31280,15 @@
if (val == null) {
val = ctl.value;
}
+
$$b('#blur').val(val);
var complete = false;
+
if (!ctl || !ctl.handle) {
$$b('#blur_slider').slider('option', 'value', val);
complete = true;
}
+
if (noUndo) {
svgCanvas.setBlurNoUndo(val);
} else {
@@ -28518,31 +31300,31 @@
svgCanvas.setStrokeAttr('stroke-dasharray', $$b(this).val());
operaRepaint();
});
-
$$b('#stroke_linejoin').change(function () {
svgCanvas.setStrokeAttr('stroke-linejoin', $$b(this).val());
operaRepaint();
- });
+ }); // Lose focus for select elements when changed (Allows keyboard shortcuts to work better)
- // Lose focus for select elements when changed (Allows keyboard shortcuts to work better)
$$b('select').change(function () {
$$b(this).blur();
- });
+ }); // fired when user wants to move elements to another layer
- // fired when user wants to move elements to another layer
var promptMoveLayerOnce = false;
$$b('#selLayerNames').change(function () {
var destLayer = this.options[this.selectedIndex].value;
var confirmStr = uiStrings$1.notification.QmoveElemsToLayer.replace('%s', destLayer);
+
var moveToLayer = function moveToLayer(ok) {
if (!ok) {
return;
}
+
promptMoveLayerOnce = true;
svgCanvas.moveSelectedToLayer(destLayer);
svgCanvas.clearSelection();
populateLayers();
};
+
if (destLayer) {
if (promptMoveLayerOnce) {
moveToLayer(true);
@@ -28551,23 +31333,18 @@
}
}
});
-
$$b('#font_family').change(function () {
svgCanvas.setFontFamily(this.value);
});
-
$$b('#seg_type').change(function () {
svgCanvas.setSegType($$b(this).val());
});
-
$$b('#text').bind('keyup input', function () {
svgCanvas.setTextContent(this.value);
});
-
$$b('#image_url').change(function () {
setImageURL(this.value);
});
-
$$b('#link_url').change(function () {
if (this.value.length) {
svgCanvas.setLinkURL(this.value);
@@ -28575,11 +31352,9 @@
svgCanvas.removeHyperlink();
}
});
-
$$b('#g_title').change(function () {
svgCanvas.setGroupTitle(this.value);
});
-
$$b('.attr_changer').change(function () {
var attr = this.getAttribute('data-attr');
var val = this.value;
@@ -28596,17 +31371,16 @@
val = svgCanvas.convertToNum(attr, val);
} else if (curConfig.baseUnit !== 'px') {
// Convert unitless value to one with given unit
-
var unitData = getTypeMap();
if (selectedElement[attr] || svgCanvas.getMode() === 'pathedit' || attr === 'x' || attr === 'y') {
val *= unitData[curConfig.baseUnit];
}
}
- }
-
- // if the user is changing the id, then de-select the element first
+ } // if the user is changing the id, then de-select the element first
// change the ID, then re-select it with the new ID
+
+
if (attr === 'id') {
var elem = selectedElement;
svgCanvas.clearSelection();
@@ -28615,28 +31389,29 @@
} else {
svgCanvas.changeSelectedAttribute(attr, val);
}
- this.blur();
- });
- // Prevent selection of elements when shift-clicking
+ this.blur();
+ }); // Prevent selection of elements when shift-clicking
+
$$b('#palette').mouseover(function () {
var inp = $$b('
');
$$b(this).append(inp);
inp.focus().remove();
});
-
$$b('.palette_item').mousedown(function (evt) {
// shift key or right click for stroke
var picker = evt.shiftKey || evt.button === 2 ? 'stroke' : 'fill';
var color = $$b(this).data('rgb');
- var paint = void 0;
+ var paint; // Webkit-based browsers returned 'initial' here for no stroke
- // Webkit-based browsers returned 'initial' here for no stroke
if (color === 'none' || color === 'transparent' || color === 'initial') {
color = 'none';
paint = new $$b.jGraduate.Paint();
} else {
- paint = new $$b.jGraduate.Paint({ alpha: 100, solidColor: color.substr(1) });
+ paint = new $$b.jGraduate.Paint({
+ alpha: 100,
+ solidColor: color.substr(1)
+ });
}
paintBox[picker].setPaint(paint);
@@ -28645,23 +31420,21 @@
if (color !== 'none' && svgCanvas.getPaintOpacity(picker) !== 1) {
svgCanvas.setPaintOpacity(picker, 1.0);
}
+
updateToolButtonState();
}).bind('contextmenu', function (e) {
e.preventDefault();
});
-
$$b('#toggle_stroke_tools').on('click', function () {
$$b('#tools_bottom').toggleClass('expanded');
});
(function () {
var wArea = workarea[0];
-
var lastX = null,
lastY = null,
panning = false,
keypan = false;
-
$$b('#svgcanvas').bind('mousemove mouseup', function (evt) {
if (panning === false) {
return;
@@ -28669,13 +31442,13 @@
wArea.scrollLeft -= evt.clientX - lastX;
wArea.scrollTop -= evt.clientY - lastY;
-
lastX = evt.clientX;
lastY = evt.clientY;
if (evt.type === 'mouseup') {
panning = false;
}
+
return false;
}).mousedown(function (evt) {
if (evt.button === 1 || keypan === true) {
@@ -28685,11 +31458,9 @@
return false;
}
});
-
$$b(window).mouseup(function () {
panning = false;
});
-
$$b(document).bind('keydown', 'space', function (evt) {
svgCanvas.spaceKey = keypan = true;
evt.preventDefault();
@@ -28705,11 +31476,11 @@
workarea.css('cursor', zoomInIcon);
}
});
-
/**
* @param {boolean} active
* @returns {undefined}
*/
+
editor.setPanning = function (active) {
svgCanvas.spaceKey = keypan = active;
};
@@ -28719,12 +31490,10 @@
var button = $$b('#main_icon');
var overlay = $$b('#main_icon span');
var list = $$b('#main_menu');
-
var onButton = false;
var height = 0;
var jsHover = true;
var setClick = false;
-
/*
// Currently unused
const hideMenu = function () {
@@ -28734,9 +31503,9 @@
$$b(window).mouseup(function (evt) {
if (!onButton) {
- button.removeClass('buttondown');
- // do not hide if it was the file input as that input needs to be visible
+ button.removeClass('buttondown'); // do not hide if it was the file input as that input needs to be visible
// for its change event to fire
+
if (evt.target.tagName !== 'INPUT') {
list.fadeOut(200);
} else if (!setClick) {
@@ -28746,23 +31515,26 @@
});
}
}
+
onButton = false;
}).mousedown(function (evt) {
// $('.contextMenu').hide();
var islib = $$b(evt.target).closest('div.tools_flyout, .contextMenu').length;
+
if (!islib) {
$$b('.tools_flyout:visible,.contextMenu').fadeOut(250);
}
});
-
overlay.bind('mousedown', function () {
if (!button.hasClass('buttondown')) {
// Margin must be reset in case it was changed before;
list.css('margin-left', 0).show();
+
if (!height) {
height = list.height();
- }
- // Using custom animation as slideDown has annoying 'bounce effect'
+ } // Using custom animation as slideDown has annoying 'bounce effect'
+
+
list.css('height', 0).animate({
height: height
}, 200);
@@ -28770,20 +31542,19 @@
} else {
list.fadeOut(200);
}
+
button.toggleClass('buttondown buttonup');
}).hover(function () {
onButton = true;
}).mouseout(function () {
onButton = false;
});
+ var listItems = $$b('#main_menu li'); // Check if JS method of hovering needs to be used (Webkit bug)
- var listItems = $$b('#main_menu li');
-
- // Check if JS method of hovering needs to be used (Webkit bug)
listItems.mouseover(function () {
jsHover = $$b(this).css('background-color') === 'rgba(0, 0, 0, 0)';
-
listItems.unbind('mouseover');
+
if (jsHover) {
listItems.mouseover(function () {
this.style.backgroundColor = '#FFC';
@@ -28793,9 +31564,9 @@
});
}
});
- })();
- // Made public for UI customization.
+ })(); // Made public for UI customization.
// TODO: Group UI functions into a public editor.ui interface.
+
/**
* See {@link http://api.jquery.com/bind/#bind-eventType-eventData-handler}
* @callback module:SVGEditor.DropDownCallback
@@ -28803,35 +31574,41 @@
* @listens external:jQuery.Event
* @returns {undefined|boolean} Calls `preventDefault()` and `stopPropagation()`
*/
+
/**
* @param {Element|string} elem DOM Element or selector
* @param {module:SVGEditor.DropDownCallback} callback Mouseup callback
* @param {boolean} dropUp
* @returns {undefined}
*/
+
+
editor.addDropDown = function (elem, callback, dropUp) {
if (!$$b(elem).length) {
return;
} // Quit if called on non-existent element
+
+
var button = $$b(elem).find('button');
var list = $$b(elem).find('ul').attr('id', $$b(elem)[0].id + '-list');
+
if (dropUp) {
$$b(elem).addClass('dropup');
} else {
// Move list to place where it can overflow container
$$b('#option_lists').append(list);
}
- list.find('li').bind('mouseup', callback);
+ list.find('li').bind('mouseup', callback);
var onButton = false;
$$b(window).mouseup(function (evt) {
if (!onButton) {
button.removeClass('down');
list.hide();
}
+
onButton = false;
});
-
button.bind('mousedown', function () {
if (!button.hasClass('down')) {
if (!dropUp) {
@@ -28841,11 +31618,13 @@
left: pos.left - 10
});
}
+
list.show();
onButton = true;
} else {
list.hide();
}
+
button.toggleClass('down');
}).hover(function () {
onButton = true;
@@ -28857,16 +31636,15 @@
editor.addDropDown('#font_family_dropdown', function () {
$$b('#font_family').val($$b(this).text()).change();
});
-
editor.addDropDown('#opacity_dropdown', function () {
if ($$b(this).find('div').length) {
return;
}
+
var perc = parseInt($$b(this).text().split('%')[0], 10);
changeOpacity(false, perc);
- }, true);
+ }, true); // For slider usage, see: http://jqueryui.com/demos/slider/
- // For slider usage, see: http://jqueryui.com/demos/slider/
$$b('#opac_slider').slider({
start: function start() {
$$b('#opacity_dropdown li:not(.special)').hide();
@@ -28879,9 +31657,7 @@
changeOpacity(ui);
}
});
-
editor.addDropDown('#blur_dropdown', $$b.noop);
-
var slideStart = false;
$$b('#blur_slider').slider({
max: 10,
@@ -28899,30 +31675,34 @@
changeBlur(ui, null, slideStart);
}
});
-
editor.addDropDown('#zoom_dropdown', function () {
var item = $$b(this);
var val = item.data('val');
+
if (val) {
zoomChanged(window, val);
} else {
- changeZoom({ value: parseFloat(item.text()) });
+ changeZoom({
+ value: parseFloat(item.text())
+ });
}
}, true);
-
addAltDropDown('#stroke_linecap', '#linecap_opts', function () {
setStrokeOpt(this, true);
- }, { dropUp: true });
-
+ }, {
+ dropUp: true
+ });
addAltDropDown('#stroke_linejoin', '#linejoin_opts', function () {
setStrokeOpt(this, true);
- }, { dropUp: true });
-
+ }, {
+ dropUp: true
+ });
addAltDropDown('#tool_position', '#position_opts', function () {
var letter = this.id.replace('tool_pos', '').charAt(0);
svgCanvas.alignSelectedElements(letter, 'page');
- }, { multiclick: true });
-
+ }, {
+ multiclick: true
+ });
/*
When a flyout icon is selected
(if flyout) {
@@ -28935,10 +31715,11 @@
, else:
- Just run its stuff
*/
-
// Unfocus text input when workarea is mousedowned.
+
(function () {
- var inp = void 0;
+ var inp;
+
var unfocus = function unfocus() {
$$b(inp).blur();
};
@@ -28949,8 +31730,8 @@
workarea.mousedown(unfocus);
}).blur(function () {
uiContext = 'canvas';
- workarea.unbind('mousedown', unfocus);
- // Go back to selecting text if in textedit mode
+ workarea.unbind('mousedown', unfocus); // Go back to selecting text if in textedit mode
+
if (svgCanvas.getMode() === 'textedit') {
$$b('#text').focus();
}
@@ -29020,8 +31801,8 @@
var zoomImage = function zoomImage(multiplier) {
var res = svgCanvas.getResolution();
- multiplier = multiplier ? res.zoom * multiplier : 1;
- // setResolution(res.w * multiplier, res.h * multiplier, true);
+ multiplier = multiplier ? res.zoom * multiplier : 1; // setResolution(res.w * multiplier, res.h * multiplier, true);
+
$$b('#zoom').val(multiplier * 100);
svgCanvas.setZoom(multiplier);
zoomDone();
@@ -29045,10 +31826,10 @@
if (toolButtonClick('#tool_path')) {
svgCanvas.setMode('path');
}
- };
-
- // Delete is a contextual tool that only appears in the ribbon if
+ }; // Delete is a contextual tool that only appears in the ribbon if
// an element has been selected
+
+
var deleteSelected = function deleteSelected() {
if (selectedElement != null || multiselected) {
svgCanvas.deleteSelectedElements();
@@ -29122,6 +31903,7 @@
dx *= multi;
dy *= multi;
}
+
svgCanvas.moveSelectedElements(dx, dy);
}
};
@@ -29167,20 +31949,23 @@
if (selectedElement == null || multiselected) {
return;
}
+
if (!cw) {
step *= -1;
}
+
var angle = parseFloat($$b('#angle').val()) + step;
svgCanvas.setRotationAngle(angle);
updateContextPanel();
};
-
/**
* @fires module:svgcanvas.SvgCanvas#event:ext-onNewDocument
* @returns {undefined}
*/
+
+
var clickClear = function clickClear() {
- var _curConfig$dimensions = slicedToArray(curConfig.dimensions, 2),
+ var _curConfig$dimensions = _slicedToArray(curConfig.dimensions, 2),
x = _curConfig$dimensions[0],
y = _curConfig$dimensions[1];
@@ -29188,6 +31973,7 @@
if (!ok) {
return;
}
+
setSelectMode();
svgCanvas.clear();
svgCanvas.setResolution(x, y);
@@ -29221,38 +32007,49 @@
svgCanvas.save(saveOpts);
};
- var loadingURL = void 0;
+ var loadingURL;
+
var clickExport = function clickExport() {
- $$b.select('Select an image type for export: ', [
- // See http://kangax.github.io/jstests/toDataUrl_mime_type_test/ for a useful list of MIME types and browser support
+ $$b.select('Select an image type for export: ', [// See http://kangax.github.io/jstests/toDataUrl_mime_type_test/ for a useful list of MIME types and browser support
// 'ICO', // Todo: Find a way to preserve transparency in SVG-Edit if not working presently and do full packaging for x-icon; then switch back to position after 'PNG'
- 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'], function () {
- var _ref15 = asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(imgType) {
+ 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'],
+ /*#__PURE__*/
+ function () {
+ var _ref15 = _asyncToGenerator(
+ /*#__PURE__*/
+ regeneratorRuntime.mark(function _callee5(imgType) {
var exportWindowName, openExportWindow, chrome, quality;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
- openExportWindow = function openExportWindow() {
+ openExportWindow = function _ref16() {
var str = uiStrings$1.notification.loadingImage;
+
if (curConfig.exportWindowType === 'new') {
editor.exportWindowCt++;
}
+
exportWindowName = curConfig.canvasName + editor.exportWindowCt;
- var popHTML = void 0,
- popURL = void 0;
+ var popHTML, popURL;
+
if (loadingURL) {
popURL = loadingURL;
} else {
- popHTML = '\n \n
\n
' + str + '\n \n
' + str + '
\n ';
+ popHTML = "\n \n
\n
".concat(str, "\n \n
").concat(str, "
\n ");
+
if (typeof URL !== 'undefined' && URL.createObjectURL) {
- var blob = new Blob([popHTML], { type: 'text/html' });
+ var blob = new Blob([popHTML], {
+ type: 'text/html'
+ });
popURL = URL.createObjectURL(blob);
} else {
popURL = 'data:text/html;base64;charset=utf-8,' + encode64(popHTML);
}
+
loadingURL = popURL;
}
+
exportWindow = window.open(popURL, exportWindowName);
};
@@ -29261,60 +32058,62 @@
break;
}
- return _context5.abrupt('return');
+ return _context5.abrupt("return");
case 3:
- // Open placeholder window (prevents popup)
- exportWindowName = void 0;
chrome = isChrome();
if (!(imgType === 'PDF')) {
- _context5.next = 10;
+ _context5.next = 9;
break;
}
if (!customExportPDF && !chrome) {
openExportWindow();
}
+
svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined);
- _context5.next = 14;
+ _context5.next = 13;
break;
- case 10:
+ case 9:
if (!customExportImage) {
openExportWindow();
}
+
quality = parseInt($$b('#image-slider').val(), 10) / 100;
/* const results = */
- _context5.next = 14;
+
+ _context5.next = 13;
return svgCanvas.rasterExport(imgType, quality, exportWindowName);
- case 14:
- case 'end':
+ case 13:
+ case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
- return function (_x5) {
+ return function (_x3) {
return _ref15.apply(this, arguments);
};
}(), function () {
var sel = $$b(this);
+
if (sel.val() === 'JPEG' || sel.val() === 'WEBP') {
if (!$$b('#image-slider').length) {
- $$b('
').appendTo(sel.parent());
+ $$b("
")).appendTo(sel.parent());
}
} else {
$$b('#image-slider').parent().remove();
}
});
- };
-
- // by default, svgCanvas.open() is a no-op.
+ }; // by default, svgCanvas.open() is a no-op.
// it is up to an extension mechanism (opera widget, etc)
// to call setCustomHandlers() which will make it do something
+
+
var clickOpen = function clickOpen() {
svgCanvas.open();
};
@@ -29338,8 +32137,7 @@
var clickGroup = function clickGroup() {
// group
if (multiselected) {
- svgCanvas.groupSelectedElements();
- // ungroup
+ svgCanvas.groupSelectedElements(); // ungroup
} else if (selectedElement) {
svgCanvas.ungroupSelectedElement();
}
@@ -29361,9 +32159,12 @@
if (supportsNonSS) {
return;
}
+
var wfRules = $$b('#wireframe_rules');
+
if (!wfRules.length) {
- /* wfRules = */$$b('').appendTo('head');
+ /* wfRules = */
+ $$b('').appendTo('head');
} else {
wfRules.empty();
}
@@ -29375,7 +32176,6 @@
cancel: 'button,fieldset',
containment: 'window'
}).css('position', 'absolute');
-
var docprops = false;
var preferences = false;
@@ -29383,13 +32183,13 @@
if (docprops) {
return;
}
- docprops = true;
- // This selects the correct radio button by using the array notation
- $$b('#image_save_opts input').val([$$b.pref('img_save')]);
+ docprops = true; // This selects the correct radio button by using the array notation
+
+ $$b('#image_save_opts input').val([$$b.pref('img_save')]); // update resolution option with actual resolution
- // update resolution option with actual resolution
var res = svgCanvas.getResolution();
+
if (curConfig.baseUnit !== 'px') {
res.w = convertUnit(res.w) + curConfig.baseUnit;
res.h = convertUnit(res.h) + curConfig.baseUnit;
@@ -29398,7 +32198,6 @@
$$b('#canvas_width').val(res.w);
$$b('#canvas_height').val(res.h);
$$b('#canvas_title').val(svgCanvas.getDocumentTitle());
-
$$b('#svg_docprops').show();
};
@@ -29406,10 +32205,10 @@
if (preferences) {
return;
}
- preferences = true;
- $$b('#main_menu').hide();
- // Update background color with current one
+ preferences = true;
+ $$b('#main_menu').hide(); // Update background color with current one
+
var blocks = $$b('#bg_blocks div');
var curBg = 'cur_background';
var canvasBg = curPrefs.bkgd_color;
@@ -29418,20 +32217,23 @@
var blk = $$b(this);
var isBg = blk.css('background-color') === canvasBg;
blk.toggleClass(curBg, isBg);
+
if (isBg) {
$$b('#canvas_bg_url').removeClass(curBg);
}
});
+
if (!canvasBg) {
blocks.eq(0).addClass(curBg);
}
+
if (url) {
$$b('#canvas_bg_url').val(url);
}
+
$$b('#grid_snapping_on').prop('checked', curConfig.gridSnapping);
$$b('#grid_snapping_step').attr('value', curConfig.snappingStep);
$$b('#grid_color').attr('value', curConfig.gridColor);
-
$$b('#svg_prefs').show();
};
@@ -29460,11 +32262,13 @@
if (!ok) {
return false;
}
+
saveChanges();
});
} else {
saveChanges();
}
+
setSelectMode();
};
@@ -29485,9 +32289,8 @@
// set title
var newTitle = $$b('#canvas_title').val();
updateTitle(newTitle);
- svgCanvas.setDocumentTitle(newTitle);
+ svgCanvas.setDocumentTitle(newTitle); // update resolution
- // update resolution
var width = $$b('#canvas_width'),
w = width.val();
var height = $$b('#canvas_height'),
@@ -29512,47 +32315,46 @@
if (!svgCanvas.setResolution(w, h)) {
$$b.alert(uiStrings$1.notification.noContentToFitTo);
return false;
- }
+ } // Set image save option
+
- // Set image save option
$$b.pref('img_save', $$b('#image_save_opts :checked').val());
updateCanvas();
hideDocProperties();
};
-
/**
* Save user preferences based on current values in the UI
* @function module:SVGEditor.savePreferences
* @returns {undefined}
*/
+
+
var savePreferences = editor.savePreferences = function () {
// Set background
var color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
- setBackground(color, $$b('#canvas_bg_url').val());
+ setBackground(color, $$b('#canvas_bg_url').val()); // set language
- // set language
var lang = $$b('#lang_select').val();
+
if (lang !== $$b.pref('lang')) {
editor.putLocale(lang, goodLangs, curConfig);
- }
+ } // set icon size
- // set icon size
- setIconSize($$b('#iconsize').val());
- // set grid setting
+ setIconSize($$b('#iconsize').val()); // set grid setting
+
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
-
$$b('#rulers').toggle(curConfig.showRulers);
+
if (curConfig.showRulers) {
updateRulers();
}
+
curConfig.baseUnit = $$b('#base_unit').val();
-
svgCanvas.setConfig(curConfig);
-
updateCanvas();
hidePreferences();
};
@@ -29561,10 +32363,12 @@
var cancelOverlays = function cancelOverlays() {
$$b('#dialog_box').hide();
+
if (!editingsource && !docprops && !preferences) {
if (curContext) {
svgCanvas.leaveContext();
}
+
return;
}
@@ -29583,12 +32387,15 @@
} else if (preferences) {
hidePreferences();
}
+
resetScrollPos();
};
- var winWh = { width: $$b(window).width(), height: $$b(window).height() };
+ var winWh = {
+ width: $$b(window).width(),
+ height: $$b(window).height()
+ }; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
- // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
if (isIE()) {
(function () {
resetScrollPos = function resetScrollPos() {
@@ -29602,7 +32409,6 @@
left: workarea[0].scrollLeft,
top: workarea[0].scrollTop
};
-
$$b(window).resize(resetScrollPos);
editor.ready(function () {
// TODO: Find better way to detect when to do this to minimize
@@ -29611,7 +32417,6 @@
resetScrollPos();
}, 500);
});
-
workarea.scroll(function () {
curScrollPos = {
left: workarea[0].scrollLeft,
@@ -29636,6 +32441,7 @@
if ($$b('#ruler_x').length) {
$$b('#ruler_x')[0].scrollLeft = workarea[0].scrollLeft;
}
+
if ($$b('#ruler_y').length) {
$$b('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
}
@@ -29645,27 +32451,21 @@
$$b('#url_notice').click(function () {
$$b.alert(this.title);
});
-
- $$b('#change_image_url').click(promptImgURL);
-
- // added these event handlers for all the push buttons so they
+ $$b('#change_image_url').click(promptImgURL); // added these event handlers for all the push buttons so they
// behave more like buttons being pressed-in and not images
+
(function () {
var toolnames = ['clear', 'open', 'save', 'source', 'delete', 'delete_multi', 'paste', 'clone', 'clone_multi', 'move_top', 'move_bottom'];
var curClass = 'tool_button_current';
-
var allTools = '';
-
$$b.each(toolnames, function (i, item) {
allTools += (i ? ',' : '') + '#tool_' + item;
});
-
$$b(allTools).mousedown(function () {
$$b(this).addClass(curClass);
}).bind('mousedown mouseout', function () {
$$b(this).removeClass(curClass);
});
-
$$b('#tool_undo, #tool_redo').mousedown(function () {
if (!$$b(this).hasClass('disabled')) {
$$b(this).addClass(curClass);
@@ -29673,42 +32473,49 @@
}).bind('mousedown mouseout', function () {
$$b(this).removeClass(curClass);
});
- })();
-
- // switch modifier key in tooltips if mac
+ })(); // switch modifier key in tooltips if mac
// NOTE: This code is not used yet until I can figure out how to successfully bind ctrl/meta
// in Opera and Chrome
+
+
if (isMac() && !window.opera) {
var shortcutButtons = ['tool_clear', 'tool_save', 'tool_source', 'tool_undo', 'tool_redo', 'tool_clone'];
var _i2 = shortcutButtons.length;
+
while (_i2--) {
var button = document.getElementById(shortcutButtons[_i2]);
+
if (button) {
var title = button.title;
-
var index = title.indexOf('Ctrl+');
button.title = [title.substr(0, index), 'Cmd+', title.substr(index + 5)].join('');
}
}
- }
-
- // TODO: go back to the color boxes having white background-color and then setting
+ } // TODO: go back to the color boxes having white background-color and then setting
// background-image to none.png (otherwise partially transparent gradients look weird)
+
+
var colorPicker = function colorPicker(elem) {
- var picker = elem.attr('id') === 'stroke_color' ? 'stroke' : 'fill';
- // const opacity = (picker == 'stroke' ? $('#stroke_opacity') : $('#fill_opacity'));
- var title = picker === 'stroke' ? uiStrings$1.ui.pick_stroke_paint_opacity : uiStrings$1.ui.pick_fill_paint_opacity;
- // let wasNone = false; // Currently unused
+ var picker = elem.attr('id') === 'stroke_color' ? 'stroke' : 'fill'; // const opacity = (picker == 'stroke' ? $('#stroke_opacity') : $('#fill_opacity'));
+
+ var title = picker === 'stroke' ? uiStrings$1.ui.pick_stroke_paint_opacity : uiStrings$1.ui.pick_fill_paint_opacity; // let wasNone = false; // Currently unused
+
var pos = elem.offset();
var paint = paintBox[picker].paint;
-
$$b('#color_picker').draggable({
cancel: '.jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker',
containment: 'window'
- }).css(curConfig.colorPickerCSS || { left: pos.left - 140, bottom: 40 }).jGraduate({
+ }).css(curConfig.colorPickerCSS || {
+ left: pos.left - 140,
+ bottom: 40
+ }).jGraduate({
paint: paint,
- window: { pickerTitle: title },
- images: { clientPath: curConfig.jGraduatePath },
+ window: {
+ pickerTitle: title
+ },
+ images: {
+ clientPath: curConfig.jGraduatePath
+ },
newstop: 'inverse'
}, function (p) {
paint = new $$b.jGraduate.Paint(p);
@@ -29721,33 +32528,32 @@
};
var PaintBox = function PaintBox(container, type) {
- var paintColor = void 0,
- paintOpacity = void 0;
- var cur = curConfig[type === 'fill' ? 'initFill' : 'initStroke'];
- // set up gradients to be used for the buttons
- var svgdocbox = new DOMParser().parseFromString('
', 'text/xml');
+ var paintColor, paintOpacity;
+ var cur = curConfig[type === 'fill' ? 'initFill' : 'initStroke']; // set up gradients to be used for the buttons
+ var svgdocbox = new DOMParser().parseFromString("
"), 'text/xml');
var docElem = svgdocbox.documentElement;
docElem = $$b(container)[0].appendChild(document.importNode(docElem, true));
docElem.setAttribute('width', 16.5);
-
this.rect = docElem.firstElementChild;
this.defs = docElem.getElementsByTagName('defs')[0];
this.grad = this.defs.firstElementChild;
- this.paint = new $$b.jGraduate.Paint({ solidColor: cur.color });
+ this.paint = new $$b.jGraduate.Paint({
+ solidColor: cur.color
+ });
this.type = type;
this.setPaint = function (paint, apply) {
this.paint = paint;
-
var ptype = paint.type;
var opac = paint.alpha / 100;
-
var fillAttr = 'none';
+
switch (ptype) {
case 'solidColor':
fillAttr = paint[ptype] !== 'none' ? '#' + paint[ptype] : paint[ptype];
break;
+
case 'linearGradient':
case 'radialGradient':
this.grad.remove();
@@ -29780,15 +32586,17 @@
// These elements don't have fill or stroke, so don't change
// the current value
return;
+
case 'g':
case 'a':
{
var childs = selectedElement.getElementsByTagName('*');
-
var gPaint = null;
+
for (var _i3 = 0, len = childs.length; _i3 < len; _i3++) {
var elem = childs[_i3];
var p = elem.getAttribute(type);
+
if (_i3 === 0) {
gPaint = p;
} else if (gPaint !== p) {
@@ -29802,11 +32610,15 @@
paintColor = null;
return;
}
+
paintColor = gPaint;
paintOpacity = 1;
break;
- }default:
+ }
+
+ default:
paintOpacity = parseFloat(selectedElement.getAttribute(type + '-opacity'));
+
if (isNaN(paintOpacity)) {
paintOpacity = 1.0;
}
@@ -29821,9 +32633,8 @@
}
paintOpacity *= 100;
+ var paint = getPaint(paintColor, paintOpacity, type); // update the rect inside #fill_color/#stroke_color
- var paint = getPaint(paintColor, paintOpacity, type);
- // update the rect inside #fill_color/#stroke_color
this.setPaint(paint);
};
@@ -29833,7 +32644,9 @@
switch (ptype) {
case 'linearGradient':
case 'radialGradient':
- var paint = new $$b.jGraduate.Paint({ copy: this.paint });
+ var paint = new $$b.jGraduate.Paint({
+ copy: this.paint
+ });
svgCanvas.setPaint(type, paint);
break;
}
@@ -29842,36 +32655,37 @@
paintBox.fill = new PaintBox('#fill_color', 'fill');
paintBox.stroke = new PaintBox('#stroke_color', 'stroke');
-
$$b('#stroke_width').val(curConfig.initStroke.width);
- $$b('#group_opacity').val(curConfig.initOpacity * 100);
+ $$b('#group_opacity').val(curConfig.initOpacity * 100); // Use this SVG elem to test vectorEffect support
- // Use this SVG elem to test vectorEffect support
var testEl = paintBox.fill.rect.cloneNode(false);
testEl.setAttribute('style', 'vector-effect:non-scaling-stroke');
var supportsNonSS = testEl.style.vectorEffect === 'non-scaling-stroke';
testEl.removeAttribute('style');
- var svgdocbox = paintBox.fill.rect.ownerDocument;
- // Use this to test support for blur element. Seems to work to test support in Webkit
+ var svgdocbox = paintBox.fill.rect.ownerDocument; // Use this to test support for blur element. Seems to work to test support in Webkit
+
var blurTest = svgdocbox.createElementNS(NS.SVG, 'feGaussianBlur');
+
if (blurTest.stdDeviationX === undefined) {
$$b('#tool_blur').hide();
}
- $$b(blurTest).remove();
- // Test for zoom icon support
+ $$b(blurTest).remove(); // Test for zoom icon support
+
(function () {
var pre = '-' + uaPrefix.toLowerCase() + '-zoom-';
var zoom = pre + 'in';
workarea.css('cursor', zoom);
+
if (workarea.css('cursor') === zoom) {
zoomInIcon = zoom;
zoomOutIcon = pre + 'out';
}
- workarea.css('cursor', 'auto');
- })();
- // Test for embedImage support (use timeout to not interfere with page load)
+ workarea.css('cursor', 'auto');
+ })(); // Test for embedImage support (use timeout to not interfere with page load)
+
+
setTimeout(function () {
svgCanvas.embedImage('images/logo.png', function (datauri) {
if (!datauri) {
@@ -29883,32 +32697,26 @@
}
});
}, 1000);
-
$$b('#fill_color, #tool_fill .icon_label').click(function () {
colorPicker($$b('#fill_color'));
updateToolButtonState();
});
-
$$b('#stroke_color, #tool_stroke .icon_label').click(function () {
colorPicker($$b('#stroke_color'));
updateToolButtonState();
});
-
$$b('#group_opacityLabel').click(function () {
$$b('#opacity_dropdown button').mousedown();
$$b(window).mouseup();
});
-
$$b('#zoomLabel').click(function () {
$$b('#zoom_dropdown button').mousedown();
$$b(window).mouseup();
});
-
$$b('#tool_move_top').mousedown(function (evt) {
$$b('#tools_stacking').show();
evt.preventDefault();
});
-
$$b('.layer_button').mousedown(function () {
$$b(this).addClass('layer_buttonpressed');
}).mouseout(function () {
@@ -29916,7 +32724,6 @@
}).mouseup(function () {
$$b(this).removeClass('layer_buttonpressed');
});
-
$$b('.push_button').mousedown(function () {
if (!$$b(this).hasClass('disabled')) {
$$b(this).addClass('push_button_pressed').removeClass('push_button');
@@ -29925,12 +32732,12 @@
$$b(this).removeClass('push_button_pressed').addClass('push_button');
}).mouseup(function () {
$$b(this).removeClass('push_button_pressed').addClass('push_button');
- });
+ }); // ask for a layer name
- // ask for a layer name
$$b('#layer_new').click(function () {
- var uniqName = void 0,
+ var uniqName,
i = svgCanvas.getCurrentDrawing().getNumLayers();
+
do {
uniqName = uiStrings$1.layers.layer + ' ' + ++i;
} while (svgCanvas.getCurrentDrawing().hasLayer(uniqName));
@@ -29939,10 +32746,12 @@
if (!newName) {
return;
}
+
if (svgCanvas.getCurrentDrawing().hasLayer(newName)) {
$$b.alert(uiStrings$1.notification.dupeLayerName);
return;
}
+
svgCanvas.createLayer(newName);
updateContextPanel();
populateLayers();
@@ -29952,10 +32761,10 @@
function deleteLayer() {
if (svgCanvas.deleteCurrentLayer()) {
updateContextPanel();
- populateLayers();
- // This matches what SvgCanvas does
+ populateLayers(); // This matches what SvgCanvas does
// TODO: make this behavior less brittle (svg-editor should get which
// layer is selected from the canvas and then select that one in the UI)
+
$$b('#layerlist tr.layer').removeClass('layersel');
$$b('#layerlist tr.layer:first').addClass('layersel');
}
@@ -29963,15 +32772,16 @@
function cloneLayer() {
var name = svgCanvas.getCurrentDrawing().getCurrentLayerName() + ' copy';
-
$$b.prompt(uiStrings$1.notification.enterUniqueLayerName, name, function (newName) {
if (!newName) {
return;
}
+
if (svgCanvas.getCurrentDrawing().hasLayer(newName)) {
$$b.alert(uiStrings$1.notification.dupeLayerName);
return;
}
+
svgCanvas.cloneLayer(newName);
updateContextPanel();
populateLayers();
@@ -29982,6 +32792,7 @@
if ($$b('#layerlist tr.layersel').index() === svgCanvas.getCurrentDrawing().getNumLayers() - 1) {
return;
}
+
svgCanvas.mergeLayer();
updateContextPanel();
populateLayers();
@@ -29989,8 +32800,8 @@
function moveLayer(pos) {
var total = svgCanvas.getCurrentDrawing().getNumLayers();
-
var curIndex = $$b('#layerlist tr.layersel').index();
+
if (curIndex > 0 || curIndex < total - 1) {
curIndex += pos;
svgCanvas.setCurrentLayerPosition(total - curIndex - 1);
@@ -29999,15 +32810,12 @@
}
$$b('#layer_delete').click(deleteLayer);
-
$$b('#layer_up').click(function () {
moveLayer(-1);
});
-
$$b('#layer_down').click(function () {
moveLayer(1);
});
-
$$b('#layer_rename').click(function () {
// const curIndex = $('#layerlist tr.layersel').prevAll().length; // Currently unused
var oldName = $$b('#layerlist tr.layersel td.layername').text();
@@ -30015,6 +32823,7 @@
if (!newName) {
return;
}
+
if (oldName === newName || svgCanvas.getCurrentDrawing().hasLayer(newName)) {
$$b.alert(uiStrings$1.notification.layerHasThatName);
return;
@@ -30024,18 +32833,17 @@
populateLayers();
});
});
-
var SIDEPANEL_MAXWIDTH = 300;
var SIDEPANEL_OPENWIDTH = 150;
var sidedrag = -1,
sidedragging = false,
allowmove = false;
-
/**
* @param {Float} delta
* @fires module:svgcanvas.SvgCanvas#event:ext-workareaResized
* @returns {undefined}
*/
+
var changeSidePanelWidth = function changeSidePanelWidth(delta) {
var rulerX = $$b('#ruler_x');
$$b('#sidepanels').width('+=' + delta);
@@ -30049,31 +32857,35 @@
if (!allowmove) {
return;
}
+
if (sidedrag === -1) {
return;
}
+
sidedragging = true;
var deltaX = sidedrag - evt.pageX;
var sideWidth = $$b('#sidepanels').width();
+
if (sideWidth + deltaX > SIDEPANEL_MAXWIDTH) {
- deltaX = SIDEPANEL_MAXWIDTH - sideWidth;
- // sideWidth = SIDEPANEL_MAXWIDTH;
+ deltaX = SIDEPANEL_MAXWIDTH - sideWidth; // sideWidth = SIDEPANEL_MAXWIDTH;
} else if (sideWidth + deltaX < 2) {
- deltaX = 2 - sideWidth;
- // sideWidth = 2;
+ deltaX = 2 - sideWidth; // sideWidth = 2;
}
+
if (deltaX === 0) {
return;
}
+
sidedrag -= deltaX;
changeSidePanelWidth(deltaX);
};
-
/**
* If width is non-zero, then fully close it, otherwise fully open it
* @param {boolean} close Forces the side panel closed
* @returns {undefined}
*/
+
+
var toggleSidePanel = function toggleSidePanel(close) {
var w = $$b('#sidepanels').width();
var deltaX = (w > 2 || close ? 2 : SIDEPANEL_OPENWIDTH) - w;
@@ -30083,8 +32895,8 @@
$$b('#sidepanel_handle').mousedown(function (evt) {
sidedrag = evt.pageX;
$$b(window).mousemove(resizeSidePanel);
- allowmove = false;
- // Silly hack for Chrome, which always runs mousemove right after mousedown
+ allowmove = false; // Silly hack for Chrome, which always runs mousemove right after mousedown
+
setTimeout(function () {
allowmove = true;
}, 20);
@@ -30092,19 +32904,16 @@
if (!sidedragging) {
toggleSidePanel();
}
+
sidedrag = -1;
sidedragging = false;
});
-
$$b(window).mouseup(function () {
sidedrag = -1;
sidedragging = false;
$$b('#svg_editor').unbind('mousemove', resizeSidePanel);
});
-
- populateLayers();
-
- // function changeResolution (x,y) {
+ populateLayers(); // function changeResolution (x,y) {
// const {zoom} = svgCanvas.getResolution();
// setResolution(x * zoom, y * zoom);
// }
@@ -30120,6 +32929,7 @@
var origVal = Number(elem.value);
var sugVal = origVal + step;
var increasing = sugVal >= origVal;
+
if (step === 0) {
return origVal;
}
@@ -30128,23 +32938,30 @@
if (increasing) {
return Math.round(origVal * 1.1);
}
+
return Math.round(origVal / 1.1);
}
+
if (origVal <= 1) {
if (increasing) {
return origVal * 2;
}
+
return origVal / 2;
}
+
return sugVal;
}
function stepZoom(elem, step) {
var origVal = Number(elem.value);
+
if (origVal === 0) {
return 100;
}
+
var sugVal = origVal + step;
+
if (step === 0) {
return origVal;
}
@@ -30152,13 +32969,13 @@
if (origVal >= 100) {
return sugVal;
}
+
if (sugVal >= origVal) {
return origVal * 2;
}
- return origVal / 2;
- }
- // function setResolution (w, h, center) {
+ return origVal / 2;
+ } // function setResolution (w, h, center) {
// updateCanvas();
// // w -= 0; h -= 0;
// // $('#svgcanvas').css({width: w, height: h});
@@ -30174,8 +32991,10 @@
// // }
// }
+
$$b('#resolution').change(function () {
var wh = $$b('#canvas_width,#canvas_height');
+
if (!this.selectedIndex) {
if ($$b('#canvas_width').val() === 'fit') {
wh.removeAttr('disabled').val(100);
@@ -30188,15 +33007,14 @@
$$b('#canvas_height').val(dims[1]);
wh.removeAttr('disabled');
}
- });
+ }); // Prevent browser from erroneously repopulating fields
- // Prevent browser from erroneously repopulating fields
$$b('input,select').attr('autocomplete', 'off');
-
/**
* Associate all button actions as well as non-button keyboard shortcuts
* @namespace {PlainObject} module:SVGEditor~Actions
*/
+
var Actions = function () {
/**
* @typedef {PlainObject} module:SVGEditor.ToolButton
@@ -30209,218 +33027,508 @@
* @property {string} [icon] The button ID
* @property {boolean} isDefault For flyout holders
*/
+
/**
*
* @name module:SVGEditor~ToolButtons
* @type {module:SVGEditor.ToolButton[]}
*/
- var toolButtons = [{ sel: '#tool_select', fn: clickSelect, evt: 'click', key: ['V', true] }, { sel: '#tool_fhpath', fn: clickFHPath, evt: 'click', key: ['Q', true] }, { sel: '#tool_line', fn: clickLine, evt: 'click', key: ['L', true], parent: '#tools_line', prepend: true }, { sel: '#tool_rect', fn: clickRect, evt: 'mouseup',
- key: ['R', true], parent: '#tools_rect', icon: 'rect' }, { sel: '#tool_square', fn: clickSquare, evt: 'mouseup',
- parent: '#tools_rect', icon: 'square' }, { sel: '#tool_fhrect', fn: clickFHRect, evt: 'mouseup',
- parent: '#tools_rect', icon: 'fh_rect' }, { sel: '#tool_ellipse', fn: clickEllipse, evt: 'mouseup',
- key: ['E', true], parent: '#tools_ellipse', icon: 'ellipse' }, { sel: '#tool_circle', fn: clickCircle, evt: 'mouseup',
- parent: '#tools_ellipse', icon: 'circle' }, { sel: '#tool_fhellipse', fn: clickFHEllipse, evt: 'mouseup',
- parent: '#tools_ellipse', icon: 'fh_ellipse' }, { sel: '#tool_path', fn: clickPath, evt: 'click', key: ['P', true] }, { sel: '#tool_text', fn: clickText, evt: 'click', key: ['T', true] }, { sel: '#tool_image', fn: clickImage, evt: 'mouseup' }, { sel: '#tool_zoom', fn: clickZoom, evt: 'mouseup', key: ['Z', true] }, { sel: '#tool_clear', fn: clickClear, evt: 'mouseup', key: ['N', true] }, { sel: '#tool_save', fn: function fn() {
+ var toolButtons = [{
+ sel: '#tool_select',
+ fn: clickSelect,
+ evt: 'click',
+ key: ['V', true]
+ }, {
+ sel: '#tool_fhpath',
+ fn: clickFHPath,
+ evt: 'click',
+ key: ['Q', true]
+ }, {
+ sel: '#tool_line',
+ fn: clickLine,
+ evt: 'click',
+ key: ['L', true],
+ parent: '#tools_line',
+ prepend: true
+ }, {
+ sel: '#tool_rect',
+ fn: clickRect,
+ evt: 'mouseup',
+ key: ['R', true],
+ parent: '#tools_rect',
+ icon: 'rect'
+ }, {
+ sel: '#tool_square',
+ fn: clickSquare,
+ evt: 'mouseup',
+ parent: '#tools_rect',
+ icon: 'square'
+ }, {
+ sel: '#tool_fhrect',
+ fn: clickFHRect,
+ evt: 'mouseup',
+ parent: '#tools_rect',
+ icon: 'fh_rect'
+ }, {
+ sel: '#tool_ellipse',
+ fn: clickEllipse,
+ evt: 'mouseup',
+ key: ['E', true],
+ parent: '#tools_ellipse',
+ icon: 'ellipse'
+ }, {
+ sel: '#tool_circle',
+ fn: clickCircle,
+ evt: 'mouseup',
+ parent: '#tools_ellipse',
+ icon: 'circle'
+ }, {
+ sel: '#tool_fhellipse',
+ fn: clickFHEllipse,
+ evt: 'mouseup',
+ parent: '#tools_ellipse',
+ icon: 'fh_ellipse'
+ }, {
+ sel: '#tool_path',
+ fn: clickPath,
+ evt: 'click',
+ key: ['P', true]
+ }, {
+ sel: '#tool_text',
+ fn: clickText,
+ evt: 'click',
+ key: ['T', true]
+ }, {
+ sel: '#tool_image',
+ fn: clickImage,
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_zoom',
+ fn: clickZoom,
+ evt: 'mouseup',
+ key: ['Z', true]
+ }, {
+ sel: '#tool_clear',
+ fn: clickClear,
+ evt: 'mouseup',
+ key: ['N', true]
+ }, {
+ sel: '#tool_save',
+ fn: function fn() {
if (editingsource) {
saveSourceEditor();
} else {
clickSave();
}
},
- evt: 'mouseup', key: ['S', true] }, { sel: '#tool_export', fn: clickExport, evt: 'mouseup' }, { sel: '#tool_open', fn: clickOpen, evt: 'mouseup', key: ['O', true] }, { sel: '#tool_import', fn: clickImport, evt: 'mouseup' }, { sel: '#tool_source', fn: showSourceEditor, evt: 'click', key: ['U', true] }, { sel: '#tool_wireframe', fn: clickWireframe, evt: 'click', key: ['F', true] }, { sel: '#tool_source_cancel,.overlay,#tool_docprops_cancel,#tool_prefs_cancel',
- fn: cancelOverlays, evt: 'click', key: ['esc', false, false], hidekey: true }, { sel: '#tool_source_save', fn: saveSourceEditor, evt: 'click' }, { sel: '#tool_docprops_save', fn: saveDocProperties, evt: 'click' }, { sel: '#tool_docprops', fn: showDocProperties, evt: 'mouseup' }, { sel: '#tool_prefs_save', fn: savePreferences, evt: 'click' }, { sel: '#tool_prefs_option', fn: function fn() {
- showPreferences();return false;
+ evt: 'mouseup',
+ key: ['S', true]
+ }, {
+ sel: '#tool_export',
+ fn: clickExport,
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_open',
+ fn: clickOpen,
+ evt: 'mouseup',
+ key: ['O', true]
+ }, {
+ sel: '#tool_import',
+ fn: clickImport,
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_source',
+ fn: showSourceEditor,
+ evt: 'click',
+ key: ['U', true]
+ }, {
+ sel: '#tool_wireframe',
+ fn: clickWireframe,
+ evt: 'click',
+ key: ['F', true]
+ }, {
+ sel: '#tool_source_cancel,.overlay,#tool_docprops_cancel,#tool_prefs_cancel',
+ fn: cancelOverlays,
+ evt: 'click',
+ key: ['esc', false, false],
+ hidekey: true
+ }, {
+ sel: '#tool_source_save',
+ fn: saveSourceEditor,
+ evt: 'click'
+ }, {
+ sel: '#tool_docprops_save',
+ fn: saveDocProperties,
+ evt: 'click'
+ }, {
+ sel: '#tool_docprops',
+ fn: showDocProperties,
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_prefs_save',
+ fn: savePreferences,
+ evt: 'click'
+ }, {
+ sel: '#tool_prefs_option',
+ fn: function fn() {
+ showPreferences();
+ return false;
},
- evt: 'mouseup' }, { sel: '#tool_delete,#tool_delete_multi', fn: deleteSelected,
- evt: 'click', key: ['del/backspace', true] }, { sel: '#tool_reorient', fn: reorientPath, evt: 'click' }, { sel: '#tool_node_link', fn: linkControlPoints, evt: 'click' }, { sel: '#tool_node_clone', fn: clonePathNode, evt: 'click' }, { sel: '#tool_node_delete', fn: deletePathNode, evt: 'click' }, { sel: '#tool_openclose_path', fn: opencloseSubPath, evt: 'click' }, { sel: '#tool_add_subpath', fn: addSubPath, evt: 'click' }, { sel: '#tool_move_top', fn: moveToTopSelected, evt: 'click', key: 'ctrl+shift+]' }, { sel: '#tool_move_bottom', fn: moveToBottomSelected, evt: 'click', key: 'ctrl+shift+[' }, { sel: '#tool_topath', fn: convertToPath$$1, evt: 'click' }, { sel: '#tool_make_link,#tool_make_link_multi', fn: makeHyperlink, evt: 'click' }, { sel: '#tool_undo', fn: clickUndo, evt: 'click' }, { sel: '#tool_redo', fn: clickRedo, evt: 'click' }, { sel: '#tool_clone,#tool_clone_multi', fn: clickClone, evt: 'click', key: ['D', true] }, { sel: '#tool_group_elements', fn: clickGroup, evt: 'click', key: ['G', true] }, { sel: '#tool_ungroup', fn: clickGroup, evt: 'click' }, { sel: '#tool_unlink_use', fn: clickGroup, evt: 'click' }, { sel: '[id^=tool_align]', fn: clickAlign, evt: 'click' },
- // these two lines are required to make Opera work properly with the flyout mechanism
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_delete,#tool_delete_multi',
+ fn: deleteSelected,
+ evt: 'click',
+ key: ['del/backspace', true]
+ }, {
+ sel: '#tool_reorient',
+ fn: reorientPath,
+ evt: 'click'
+ }, {
+ sel: '#tool_node_link',
+ fn: linkControlPoints,
+ evt: 'click'
+ }, {
+ sel: '#tool_node_clone',
+ fn: clonePathNode,
+ evt: 'click'
+ }, {
+ sel: '#tool_node_delete',
+ fn: deletePathNode,
+ evt: 'click'
+ }, {
+ sel: '#tool_openclose_path',
+ fn: opencloseSubPath,
+ evt: 'click'
+ }, {
+ sel: '#tool_add_subpath',
+ fn: addSubPath,
+ evt: 'click'
+ }, {
+ sel: '#tool_move_top',
+ fn: moveToTopSelected,
+ evt: 'click',
+ key: 'ctrl+shift+]'
+ }, {
+ sel: '#tool_move_bottom',
+ fn: moveToBottomSelected,
+ evt: 'click',
+ key: 'ctrl+shift+['
+ }, {
+ sel: '#tool_topath',
+ fn: convertToPath$$1,
+ evt: 'click'
+ }, {
+ sel: '#tool_make_link,#tool_make_link_multi',
+ fn: makeHyperlink,
+ evt: 'click'
+ }, {
+ sel: '#tool_undo',
+ fn: clickUndo,
+ evt: 'click'
+ }, {
+ sel: '#tool_redo',
+ fn: clickRedo,
+ evt: 'click'
+ }, {
+ sel: '#tool_clone,#tool_clone_multi',
+ fn: clickClone,
+ evt: 'click',
+ key: ['D', true]
+ }, {
+ sel: '#tool_group_elements',
+ fn: clickGroup,
+ evt: 'click',
+ key: ['G', true]
+ }, {
+ sel: '#tool_ungroup',
+ fn: clickGroup,
+ evt: 'click'
+ }, {
+ sel: '#tool_unlink_use',
+ fn: clickGroup,
+ evt: 'click'
+ }, {
+ sel: '[id^=tool_align]',
+ fn: clickAlign,
+ evt: 'click'
+ }, // these two lines are required to make Opera work properly with the flyout mechanism
// {sel: '#tools_rect_show', fn: clickRect, evt: 'click'},
// {sel: '#tools_ellipse_show', fn: clickEllipse, evt: 'click'},
- { sel: '#tool_bold', fn: clickBold, evt: 'mousedown' }, { sel: '#tool_italic', fn: clickItalic, evt: 'mousedown' }, { sel: '#sidepanel_handle', fn: toggleSidePanel, key: ['X'] }, { sel: '#copy_save_done', fn: cancelOverlays, evt: 'click' },
-
- // Shortcuts not associated with buttons
-
- { key: 'ctrl+left', fn: function fn() {
+ {
+ sel: '#tool_bold',
+ fn: clickBold,
+ evt: 'mousedown'
+ }, {
+ sel: '#tool_italic',
+ fn: clickItalic,
+ evt: 'mousedown'
+ }, {
+ sel: '#sidepanel_handle',
+ fn: toggleSidePanel,
+ key: ['X']
+ }, {
+ sel: '#copy_save_done',
+ fn: cancelOverlays,
+ evt: 'click'
+ }, // Shortcuts not associated with buttons
+ {
+ key: 'ctrl+left',
+ fn: function fn() {
rotateSelected(0, 1);
}
- }, { key: 'ctrl+right', fn: function fn() {
+ }, {
+ key: 'ctrl+right',
+ fn: function fn() {
rotateSelected(1, 1);
}
- }, { key: 'ctrl+shift+left', fn: function fn() {
+ }, {
+ key: 'ctrl+shift+left',
+ fn: function fn() {
rotateSelected(0, 5);
}
- }, { key: 'ctrl+shift+right', fn: function fn() {
+ }, {
+ key: 'ctrl+shift+right',
+ fn: function fn() {
rotateSelected(1, 5);
}
- }, { key: 'shift+O', fn: selectPrev }, { key: 'shift+P', fn: selectNext }, { key: [modKey + 'up', true], fn: function fn() {
+ }, {
+ key: 'shift+O',
+ fn: selectPrev
+ }, {
+ key: 'shift+P',
+ fn: selectNext
+ }, {
+ key: [modKey + 'up', true],
+ fn: function fn() {
zoomImage(2);
}
- }, { key: [modKey + 'down', true], fn: function fn() {
+ }, {
+ key: [modKey + 'down', true],
+ fn: function fn() {
zoomImage(0.5);
}
- }, { key: [modKey + ']', true], fn: function fn() {
+ }, {
+ key: [modKey + ']', true],
+ fn: function fn() {
moveUpDownSelected('Up');
}
- }, { key: [modKey + '[', true], fn: function fn() {
+ }, {
+ key: [modKey + '[', true],
+ fn: function fn() {
moveUpDownSelected('Down');
}
- }, { key: ['up', true], fn: function fn() {
+ }, {
+ key: ['up', true],
+ fn: function fn() {
moveSelected(0, -1);
}
- }, { key: ['down', true], fn: function fn() {
+ }, {
+ key: ['down', true],
+ fn: function fn() {
moveSelected(0, 1);
}
- }, { key: ['left', true], fn: function fn() {
+ }, {
+ key: ['left', true],
+ fn: function fn() {
moveSelected(-1, 0);
}
- }, { key: ['right', true], fn: function fn() {
+ }, {
+ key: ['right', true],
+ fn: function fn() {
moveSelected(1, 0);
}
- }, { key: 'shift+up', fn: function fn() {
+ }, {
+ key: 'shift+up',
+ fn: function fn() {
moveSelected(0, -10);
}
- }, { key: 'shift+down', fn: function fn() {
+ }, {
+ key: 'shift+down',
+ fn: function fn() {
moveSelected(0, 10);
}
- }, { key: 'shift+left', fn: function fn() {
+ }, {
+ key: 'shift+left',
+ fn: function fn() {
moveSelected(-10, 0);
}
- }, { key: 'shift+right', fn: function fn() {
+ }, {
+ key: 'shift+right',
+ fn: function fn() {
moveSelected(10, 0);
}
- }, { key: ['alt+up', true], fn: function fn() {
+ }, {
+ key: ['alt+up', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(0, -1);
}
- }, { key: ['alt+down', true], fn: function fn() {
+ }, {
+ key: ['alt+down', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(0, 1);
}
- }, { key: ['alt+left', true], fn: function fn() {
+ }, {
+ key: ['alt+left', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(-1, 0);
}
- }, { key: ['alt+right', true], fn: function fn() {
+ }, {
+ key: ['alt+right', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(1, 0);
}
- }, { key: ['alt+shift+up', true], fn: function fn() {
+ }, {
+ key: ['alt+shift+up', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(0, -10);
}
- }, { key: ['alt+shift+down', true], fn: function fn() {
+ }, {
+ key: ['alt+shift+down', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(0, 10);
}
- }, { key: ['alt+shift+left', true], fn: function fn() {
+ }, {
+ key: ['alt+shift+left', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(-10, 0);
}
- }, { key: ['alt+shift+right', true], fn: function fn() {
+ }, {
+ key: ['alt+shift+right', true],
+ fn: function fn() {
svgCanvas.cloneSelectedElements(10, 0);
}
- }, { key: 'A', fn: function fn() {
+ }, {
+ key: 'A',
+ fn: function fn() {
svgCanvas.selectAllInCurrentLayer();
}
- },
+ }, // Standard shortcuts
+ {
+ key: modKey + 'z',
+ fn: clickUndo
+ }, {
+ key: modKey + 'shift+z',
+ fn: clickRedo
+ }, {
+ key: modKey + 'y',
+ fn: clickRedo
+ }, {
+ key: modKey + 'x',
+ fn: cutSelected
+ }, {
+ key: modKey + 'c',
+ fn: copySelected
+ }, {
+ key: modKey + 'v',
+ fn: pasteInCenter
+ }]; // Tooltips not directly associated with a single function
- // Standard shortcuts
- { key: modKey + 'z', fn: clickUndo }, { key: modKey + 'shift+z', fn: clickRedo }, { key: modKey + 'y', fn: clickRedo }, { key: modKey + 'x', fn: cutSelected }, { key: modKey + 'c', fn: copySelected }, { key: modKey + 'v', fn: pasteInCenter }];
-
- // Tooltips not directly associated with a single function
var keyAssocs = {
'4/Shift+4': '#tools_rect_show',
'5/Shift+5': '#tools_ellipse_show'
};
-
return {
/** @lends module:SVGEditor~Actions */
+
/**
* @returns {undefined}
*/
setAll: function setAll() {
var flyouts = {};
-
$$b.each(toolButtons, function (i, opts) {
// Bind function to button
- var btn = void 0;
+ var btn;
+
if (opts.sel) {
btn = $$b(opts.sel);
+
if (!btn.length) {
return true;
} // Skip if markup does not exist
+
+
if (opts.evt) {
if (isTouch() && opts.evt === 'click') {
opts.evt = 'mousedown';
}
- btn[opts.evt](opts.fn);
- }
- // Add to parent flyout menu, if able to be displayed
+ btn[opts.evt](opts.fn);
+ } // Add to parent flyout menu, if able to be displayed
+
+
if (opts.parent && $$b(opts.parent + '_show').length) {
var fH = $$b(opts.parent);
+
if (!fH.length) {
fH = makeFlyoutHolder(opts.parent.substr(1));
}
+
if (opts.prepend) {
btn[0].style.margin = 'initial';
}
+
fH[opts.prepend ? 'prepend' : 'append'](btn);
if (!Array.isArray(flyouts[opts.parent])) {
flyouts[opts.parent] = [];
}
+
flyouts[opts.parent].push(opts);
}
- }
+ } // Bind function to shortcut key
+
- // Bind function to shortcut key
if (opts.key) {
// Set shortcut based on options
- var keyval = void 0,
-
- // disInInp = true,
+ var keyval,
+ // disInInp = true,
pd = false;
+
if (Array.isArray(opts.key)) {
keyval = opts.key[0];
+
if (opts.key.length > 1) {
pd = opts.key[1];
- }
- // if (opts.key.length > 2) { disInInp = opts.key[2]; }
+ } // if (opts.key.length > 2) { disInInp = opts.key[2]; }
+
} else {
keyval = opts.key;
}
+
keyval += '';
-
var fn = opts.fn;
-
$$b.each(keyval.split('/'), function (i, key) {
$$b(document).bind('keydown', key, function (e) {
fn();
+
if (pd) {
e.preventDefault();
- }
- // Prevent default on ALL keys?
+ } // Prevent default on ALL keys?
+
+
return false;
});
- });
+ }); // Put shortcut in title
- // Put shortcut in title
if (opts.sel && !opts.hidekey && btn.attr('title')) {
var newTitle = btn.attr('title').split('[')[0] + ' (' + keyval + ')';
- keyAssocs[keyval] = opts.sel;
- // Disregard for menu items
+ keyAssocs[keyval] = opts.sel; // Disregard for menu items
+
if (!btn.parents('#main_menu').length) {
btn.attr('title', newTitle);
}
}
}
- });
-
- // Setup flyouts
- setupFlyouts(flyouts);
-
- // Misc additional actions
+ }); // Setup flyouts
+ setupFlyouts(flyouts); // Misc additional actions
// Make 'return' keypress trigger the change event
+
$$b('.attr_changer, #image_url').bind('keydown', 'return', function (evt) {
$$b(this).change();
evt.preventDefault();
});
-
$$b(window).bind('keydown', 'tab', function (e) {
if (uiContext === 'canvas') {
e.preventDefault();
@@ -30432,7 +33540,6 @@
selectPrev();
}
});
-
$$b('#tool_zoom').dblclick(dblclickZoom);
},
@@ -30442,25 +33549,29 @@
setTitles: function setTitles() {
$$b.each(keyAssocs, function (keyval, sel) {
var menu = $$b(sel).parents('#main_menu').length;
-
$$b(sel).each(function () {
- var t = void 0;
+ var t;
+
if (menu) {
t = $$b(this).text().split(' [')[0];
} else {
t = this.title.split(' [')[0];
}
- var keyStr = '';
- // Shift+Up
+
+ var keyStr = ''; // Shift+Up
+
$$b.each(keyval.split('/'), function (i, key) {
var modBits = key.split('+');
var mod = '';
+
if (modBits.length > 1) {
mod = modBits[0] + '+';
key = modBits[1];
}
+
keyStr += (i ? '/' : '') + mod + (uiStrings$1['key_' + key] || key);
});
+
if (menu) {
this.lastChild.textContent = t + ' [' + keyStr + ']';
} else {
@@ -30480,15 +33591,16 @@
});
}
};
- }();
+ }(); // Select given tool
+
- // Select given tool
editor.ready(function () {
- var tool = void 0;
+ var tool;
var itool = curConfig.initTool,
container = $$b('#tools_left, #svg_editor .tools_flyout'),
preTool = container.find('#tool_' + itool),
regTool = container.find('#' + itool);
+
if (preTool.length) {
tool = preTool;
} else if (regTool.length) {
@@ -30496,6 +33608,7 @@
} else {
tool = $$b('#tool_select');
}
+
tool.click().mouseup();
if (curConfig.wireframe) {
@@ -30527,19 +33640,57 @@
if (curConfig.gridColor) {
$$b('#grid_color').val(curConfig.gridColor);
}
+ }); // init SpinButtons
+
+ $$b('#rect_rx').SpinButton({
+ min: 0,
+ max: 1000,
+ stateObj: stateObj,
+ callback: changeRectRadius
});
-
- // init SpinButtons
- $$b('#rect_rx').SpinButton({ min: 0, max: 1000, stateObj: stateObj, callback: changeRectRadius });
- $$b('#stroke_width').SpinButton({ min: 0, max: 99, smallStep: 0.1, stateObj: stateObj, callback: changeStrokeWidth });
- $$b('#angle').SpinButton({ min: -180, max: 180, step: 5, stateObj: stateObj, callback: changeRotationAngle });
- $$b('#font_size').SpinButton({ min: 0.001, stepfunc: stepFontSize, stateObj: stateObj, callback: changeFontSize });
- $$b('#group_opacity').SpinButton({ min: 0, max: 100, step: 5, stateObj: stateObj, callback: changeOpacity });
- $$b('#blur').SpinButton({ min: 0, max: 10, step: 0.1, stateObj: stateObj, callback: changeBlur });
- $$b('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, stateObj: stateObj, callback: changeZoom })
- // Set default zoom
+ $$b('#stroke_width').SpinButton({
+ min: 0,
+ max: 99,
+ smallStep: 0.1,
+ stateObj: stateObj,
+ callback: changeStrokeWidth
+ });
+ $$b('#angle').SpinButton({
+ min: -180,
+ max: 180,
+ step: 5,
+ stateObj: stateObj,
+ callback: changeRotationAngle
+ });
+ $$b('#font_size').SpinButton({
+ min: 0.001,
+ stepfunc: stepFontSize,
+ stateObj: stateObj,
+ callback: changeFontSize
+ });
+ $$b('#group_opacity').SpinButton({
+ min: 0,
+ max: 100,
+ step: 5,
+ stateObj: stateObj,
+ callback: changeOpacity
+ });
+ $$b('#blur').SpinButton({
+ min: 0,
+ max: 10,
+ step: 0.1,
+ stateObj: stateObj,
+ callback: changeBlur
+ });
+ $$b('#zoom').SpinButton({
+ min: 0.001,
+ max: 10000,
+ step: 50,
+ stepfunc: stepZoom,
+ stateObj: stateObj,
+ callback: changeZoom
+ }) // Set default zoom
.val(svgCanvas.getZoom() * 100);
-
$$b('#workarea').contextMenu({
menu: 'cmenu_canvas',
inSpeed: 0
@@ -30548,41 +33699,53 @@
case 'delete':
deleteSelected();
break;
+
case 'cut':
cutSelected();
break;
+
case 'copy':
copySelected();
break;
+
case 'paste':
svgCanvas.pasteElements();
break;
+
case 'paste_in_place':
svgCanvas.pasteElements('in_place');
break;
+
case 'group':
case 'group_elements':
svgCanvas.groupSelectedElements();
break;
+
case 'ungroup':
svgCanvas.ungroupSelectedElement();
break;
+
case 'move_front':
moveToTopSelected();
break;
+
case 'move_up':
moveUpDownSelected('Up');
break;
+
case 'move_down':
moveUpDownSelected('Down');
break;
+
case 'move_back':
moveToBottomSelected();
break;
+
default:
if (hasCustomHandler(action)) {
getCustomHandler(action).call();
}
+
break;
}
});
@@ -30592,12 +33755,15 @@
case 'dupe':
cloneLayer();
break;
+
case 'delete':
deleteLayer();
break;
+
case 'merge_down':
mergeLayer();
break;
+
case 'merge_all':
svgCanvas.mergeAllLayers();
updateContextPanel();
@@ -30610,29 +33776,28 @@
menu: 'cmenu_layers',
inSpeed: 0
}, lmenuFunc);
-
$$b('#layer_moreopts').contextMenu({
menu: 'cmenu_layers',
inSpeed: 0,
allowLeft: true
}, lmenuFunc);
-
$$b('.contextMenu li').mousedown(function (ev) {
ev.preventDefault();
});
-
$$b('#cmenu_canvas li').disableContextMenu();
canvMenu.enableContextMenuItems('#delete,#cut,#copy');
function enableOrDisableClipboard() {
- var svgeditClipboard = void 0;
+ var svgeditClipboard;
+
try {
svgeditClipboard = localStorage.getItem('svgedit_clipboard');
} catch (err) {}
+
canvMenu[(svgeditClipboard ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
}
- enableOrDisableClipboard();
+ enableOrDisableClipboard();
window.addEventListener('storage', function (e) {
if (e.key !== 'svgedit_clipboard') {
return;
@@ -30640,41 +33805,44 @@
enableOrDisableClipboard();
});
-
window.addEventListener('beforeunload', function (e) {
// Suppress warning if page is empty
if (undoMgr.getUndoStackSize() === 0) {
editor.showSaveWarning = false;
- }
+ } // showSaveWarning is set to 'false' when the page is saved.
+
- // showSaveWarning is set to 'false' when the page is saved.
if (!curConfig.no_save_warning && editor.showSaveWarning) {
// Browser already asks question about closing the page
e.returnValue = uiStrings$1.notification.unsavedChanges; // Firefox needs this when beforeunload set by addEventListener (even though message is not used)
+
return uiStrings$1.notification.unsavedChanges;
}
}, false);
-
/**
* Expose the uiStrings
* @function module:SVGEditor.canvas.getUIStrings
* @returns {module:SVGEditor.uiStrings}
*/
+
editor.canvas.getUIStrings = function () {
return uiStrings$1;
};
-
/**
* @callback module:SVGEditor.OpenPrepCallback
* @param {boolean} noChanges
* @returns {undefined}
*/
+
/**
* @param {module:SVGEditor.OpenPrepCallback} func Confirmation dialog callback
* @returns {undefined}
*/
+
+
editor.openPrep = function (func) {
$$b('#main_menu').hide();
+
if (undoMgr.getUndoStackSize() === 0) {
func(true);
} else {
@@ -30684,8 +33852,7 @@
function onDragEnter(e) {
e.stopPropagation();
- e.preventDefault();
- // and indicator should be displayed here, such as "drop files here"
+ e.preventDefault(); // and indicator should be displayed here, such as "drop files here"
}
function onDragOver(e) {
@@ -30695,13 +33862,13 @@
function onDragLeave(e) {
e.stopPropagation();
- e.preventDefault();
- // hypothetical indicator should be removed here
- }
- // Use HTML5 File API: http://www.w3.org/TR/FileAPI/
+ e.preventDefault(); // hypothetical indicator should be removed here
+ } // Use HTML5 File API: http://www.w3.org/TR/FileAPI/
// if browser has HTML5 File API support, then we will show the open menu item
// and provide a file input to click. When that change event fires, it will
// get the text contents of the file and send it to the canvas
+
+
if (window.FileReader) {
var importImage = function importImage(e) {
$$b.process_cancel(uiStrings$1.notification.loadingImage);
@@ -30710,6 +33877,7 @@
$$b('#workarea').removeAttr('style');
$$b('#main_menu').hide();
var file = e.type === 'drop' ? e.dataTransfer.files[0] : this.files[0];
+
if (!file) {
$$b('#dialog_box').hide();
return;
@@ -30717,29 +33885,35 @@
/* if (file.type === 'application/pdf') { // Todo: Handle PDF imports
}
else */
+
+
if (file.type.includes('image')) {
// Detected an image
// svg handling
- var reader = void 0;
+ var reader;
+
if (file.type.includes('svg')) {
reader = new FileReader();
+
reader.onloadend = function (e) {
var newElement = svgCanvas.importSvgString(e.target.result, true);
svgCanvas.ungroupSelectedElement();
svgCanvas.ungroupSelectedElement();
svgCanvas.groupSelectedElements();
svgCanvas.alignSelectedElements('m', 'page');
- svgCanvas.alignSelectedElements('c', 'page');
- // highlight imported element, otherwise we get strange empty selectbox
+ svgCanvas.alignSelectedElements('c', 'page'); // highlight imported element, otherwise we get strange empty selectbox
+
svgCanvas.selectOnly([newElement]);
$$b('#dialog_box').hide();
};
+
reader.readAsText(file);
} else {
// bitmap handling
reader = new FileReader();
- reader.onloadend = function (_ref16) {
- var result = _ref16.target.result;
+
+ reader.onloadend = function (_ref17) {
+ var result = _ref17.target.result;
// let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) {
@@ -30760,19 +33934,23 @@
svgCanvas.alignSelectedElements('c', 'page');
updateContextPanel();
$$b('#dialog_box').hide();
- };
- // create dummy img so we know the default dimensions
+ }; // create dummy img so we know the default dimensions
+
+
var imgWidth = 100;
var imgHeight = 100;
var img = new Image();
img.style.opacity = 0;
+
img.onload = function () {
imgWidth = img.offsetWidth || img.naturalWidth || img.width;
imgHeight = img.offsetHeight || img.naturalHeight || img.height;
insertNewImage(imgWidth, imgHeight);
};
+
img.src = result;
};
+
reader.readAsDataURL(file);
}
}
@@ -30782,35 +33960,35 @@
workarea[0].addEventListener('dragover', onDragOver, false);
workarea[0].addEventListener('dragleave', onDragLeave, false);
workarea[0].addEventListener('drop', importImage, false);
-
var open = $$b('
').click(function () {
var f = this;
editor.openPrep(function (ok) {
if (!ok) {
return;
}
+
svgCanvas.clear();
+
if (f.files.length === 1) {
$$b.process_cancel(uiStrings$1.notification.loadingImage);
var reader = new FileReader();
+
reader.onloadend = function (e) {
loadSvgString(e.target.result);
updateCanvas();
};
+
reader.readAsText(f.files[0]);
}
});
});
$$b('#tool_open').show().prepend(open);
-
var imgImport = $$b('
').change(importImage);
$$b('#tool_import').show().prepend(imgImport);
- }
+ } // $(function () {
- // $(function () {
- updateCanvas(true);
- // });
+ updateCanvas(true); // });
// const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
@@ -30823,63 +34001,72 @@
* @fires module:svgcanvas.SvgCanvas#event:ext-langChanged
* @returns {undefined}
*/
+
var setLang = editor.setLang = function (lang, allStrings) {
editor.langChanged = true;
$$b.pref('lang', lang);
$$b('#lang_select').val(lang);
+
if (!allStrings) {
return;
}
- $$b.extend(uiStrings$1, allStrings);
- // const notif = allStrings.notification; // Currently unused
+ $$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused
// $.extend will only replace the given strings
+
var oldLayerName = $$b('#layerlist tr.layersel td.layername').text();
var renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1';
-
svgCanvas.setUiStrings(allStrings);
Actions.setTitles();
if (renameLayer) {
svgCanvas.renameCurrentLayer(uiStrings$1.common.layer + ' 1');
populateLayers();
- }
+ } // In case extensions loaded before the locale, now we execute a callback on them
+
- // In case extensions loaded before the locale, now we execute a callback on them
if (extsPreLang.length) {
while (extsPreLang.length) {
var ext = extsPreLang.shift();
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
- importLocale: getImportLocale({ defaultLang: lang, defaultName: ext.name })
+ importLocale: getImportLocale({
+ defaultLang: lang,
+ defaultName: ext.name
+ })
});
}
} else {
- svgCanvas.runExtensions('langReady', /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */{ lang: lang, uiStrings: uiStrings$1 });
+ svgCanvas.runExtensions('langReady',
+ /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
+ {
+ lang: lang,
+ uiStrings: uiStrings$1
+ });
}
- svgCanvas.runExtensions('langChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */lang);
- // Update flyout tooltips
- setFlyoutTitles();
+ svgCanvas.runExtensions('langChanged',
+ /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */
+ lang); // Update flyout tooltips
+
+ setFlyoutTitles(); // Copy title for certain tool elements
- // Copy title for certain tool elements
var elems = {
'#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block',
'#fill_color': '#tool_fill label, #tool_fill .color_block',
'#linejoin_miter': '#cur_linejoin',
'#linecap_butt': '#cur_linecap'
};
-
$$b.each(elems, function (source, dest) {
$$b(dest).attr('title', $$b(source)[0].title);
- });
+ }); // Copy alignment titles
- // Copy alignment titles
$$b('#multiselected_panel div[id^=tool_align]').each(function () {
$$b('#tool_pos' + this.id.substr(10))[0].title = this.title;
});
};
+
init$7(
/**
* @implements {module:locale.LocaleEditorInit}
@@ -30907,15 +34094,17 @@
// We pass in a function as we don't know the extension name here when defining this `addLangData` method
return {
lang: langParam,
- importLocale: getImportLocale({ defaultLang: langParam, defaultName: name })
+ importLocale: getImportLocale({
+ defaultLang: langParam,
+ defaultName: name
+ })
};
}, true);
},
-
curConfig: curConfig
- });
- // Load extensions
+ }); // Load extensions
// Bit of a hack to run extensions in local Opera/IE9
+
if (document.location.protocol === 'file:') {
setTimeout(extAndLocaleFunc, 100);
} else {
@@ -30923,11 +34112,11 @@
extAndLocaleFunc();
}
};
-
/**
* @callback module:SVGEditor.ReadyCallback
* @returns {undefined}
*/
+
/**
* Queues a callback to be invoked when the editor is ready (or
* to be invoked immediately if it is already ready--i.e.,
@@ -30935,6 +34124,8 @@
* @param {module:SVGEditor.ReadyCallback} cb Callback to be queued to invoke
* @returns {undefined}
*/
+
+
editor.ready = function (cb) {
if (!isReady) {
callbacks.push(cb);
@@ -30942,45 +34133,47 @@
cb();
}
};
-
/**
* Invokes the callbacks previous set by `svgEditor.ready`
* @returns {undefined}
*/
+
+
editor.runCallbacks = function () {
callbacks.forEach(function (cb) {
cb();
});
isReady = true;
};
-
/**
* @param {string} str The SVG string to load
* @returns {undefined}
*/
+
+
editor.loadFromString = function (str) {
editor.ready(function () {
loadSvgString(str);
});
};
-
/**
* Not presently in use
* @param {PlainObject} featList
* @returns {undefined}
*/
- editor.disableUI = function (featList) {
- // $(function () {
+
+
+ editor.disableUI = function (featList) {// $(function () {
// $('#tool_wireframe, #tool_image, #main_button, #tool_source, #sidepanels').remove();
// $('#tools_top').css('left', 5);
// });
};
-
/**
* @callback module:SVGEditor.URLLoadCallback
* @param {boolean} success
* @returns {undefined}
*/
+
/**
* @param {string} url URL from which to load an SVG string via Ajax
* @param {PlainObject} [opts] May contain properties: `cache`, `callback`
@@ -30988,6 +34181,8 @@
* @param {module:SVGEditor.URLLoadCallback} opts.callback Invoked with `true` or `false` depending on success
* @returns {undefined}
*/
+
+
editor.loadFromURL = function (url, opts) {
if (!opts) {
opts = {};
@@ -30996,8 +34191,6 @@
var _opts = opts,
cache = _opts.cache,
cb = _opts.callback;
-
-
editor.ready(function () {
$$b.ajax({
url: url,
@@ -31022,28 +34215,31 @@
});
});
};
-
/**
* @param {string} str The Data URI to base64-decode (if relevant) and load
* @returns {undefined}
*/
+
+
editor.loadFromDataURI = function (str) {
editor.ready(function () {
var base64 = false;
var pre = str.match(/^data:image\/svg\+xml;base64,/);
+
if (pre) {
base64 = true;
} else {
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
}
+
if (pre) {
pre = pre[0];
}
+
var src = str.slice(pre.length);
loadSvgString(base64 ? decode64(src) : decodeURIComponent(src));
});
};
-
/**
* @param {string} name Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
@@ -31051,6 +34247,8 @@
* @throws {Error} If called too early
* @returns {Promise} Resolves to `undefined`
*/
+
+
editor.addExtension = function (name, init$$1, importLocale) {
// Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave).
@@ -31058,16 +34256,15 @@
if (!svgCanvas) {
throw new Error('Extension added too early');
}
- return svgCanvas.addExtension.call(this, name, init$$1, importLocale);
- // });
- };
- // Defer injection to wait out initial menu processing. This probably goes
+ return svgCanvas.addExtension.call(this, name, init$$1, importLocale); // });
+ }; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu.
+
+
editor.ready(function () {
injectExtendedContextMenuItemsIntoDom();
});
-
var extensionsAdded = false;
var messageQueue = [];
/**
@@ -31076,12 +34273,16 @@
* @fires module:svgcanvas.SvgCanvas#event:message
* @returns {undefined}
*/
- var messageListener = function messageListener(_ref17) {
- var data = _ref17.data,
- origin = _ref17.origin;
+ var messageListener = function messageListener(_ref18) {
+ var data = _ref18.data,
+ origin = _ref18.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
- var messageObj = { data: data, origin: origin };
+ var messageObj = {
+ data: data,
+ origin: origin
+ };
+
if (!extensionsAdded) {
messageQueue.push(messageObj);
} else {
@@ -31090,10 +34291,10 @@
svgCanvas.call('message', messageObj);
}
};
- window.addEventListener('message', messageListener);
- // Run init once DOM is loaded
+ window.addEventListener('message', messageListener); // Run init once DOM is loaded
// jQuery(editor.init);
+
Promise.resolve().then(function () {
// We wait a micro-task to let the svgEditor variable be defined for module checks
editor.init();
@@ -31101,20 +34302,21 @@
// TO BUILD AN IIFE VERSION OF THIS FILE (AS CAN WORK ON OLDER BROWSERS),
window.svgEditor = editor;
- window.svgEditor.modules = false;
+ window.svgEditor.modules = false; // URL OVERRIDE CONFIG
- // URL OVERRIDE CONFIG
editor.setConfig({
/**
To override the ability for URLs to set URL-based SVG content,
uncomment the following:
*/
// preventURLContentLoading: true,
+
/**
To override the ability for URLs to set other configuration (including
extension config), uncomment the following:
*/
// preventAllURLConfig: true,
+
/**
To override the ability for URLs to set their own extensions,
uncomment the following (note that if `setConfig()` is used in
@@ -31123,29 +34325,27 @@
*/
// lockExtensions: true,
});
-
editor.setConfig({
/*
Provide default values here which differ from that of the editor but
which the URL can override
*/
- }, { allowInitialUserOverride: true });
+ }, {
+ allowInitialUserOverride: true
+ }); // EXTENSION CONFIG
- // EXTENSION CONFIG
editor.setConfig({
- extensions: [
- // 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js', 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js', 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js', 'ext-storage.js'
- ], noDefaultExtensions: false // noDefaultExtensions can only be meaningfully used in svgedit-config-iife.js or in the URL
- });
+ extensions: [// 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js', 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js', 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js', 'ext-storage.js'
+ ],
+ noDefaultExtensions: false // noDefaultExtensions can only be meaningfully used in svgedit-config-iife.js or in the URL
+
+ }); // STYLESHEET CONFIG
- // STYLESHEET CONFIG
editor.setConfig({
stylesheets: ['@default', '../svgedit-custom.css']
- });
+ }); // OTHER CONFIG
- // OTHER CONFIG
- editor.setConfig({
- // canvasName: 'default',
+ editor.setConfig({// canvasName: 'default',
// canvas_expansion: 3,
// initFill: {
// color: 'FF0000', // solid red
@@ -31168,6 +34368,7 @@
// langPath: 'locale/',
// extPath: 'extensions/',
// jGraduatePath: 'jgraduate/images/',
+
/*
Uncomment the following to allow at least same domain (embedded) access,
including `file:///` access.
@@ -31189,9 +34390,8 @@
// noStorageOnLoad: false, // Some interaction with ext-storage.js; prevent even the loading of previously saved local storage
// forceStorage: false, // Some interaction with ext-storage.js; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not
// emptyStorageOnDecline: true, // Used by ext-storage.js; empty any prior storage if the user declines to store
- });
+ }); // PREF CHANGES
- // PREF CHANGES
/**
setConfig() can also be used to set preferences in addition to
configuration (see defaultPrefs in svg-editor.js for a list of
@@ -31205,9 +34405,10 @@
Failing to use allowInitialUserOverride will ensure preferences
are hard-coded here regardless of URL or prior user storage setting.
*/
- editor.setConfig({
- // lang: '', // Set dynamically within locale.js if not previously set
+
+ editor.setConfig({// lang: '', // Set dynamically within locale.js if not previously set
// iconsize: '', // Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise
+
/**
* When showing the preferences dialog, svg-editor.js currently relies
* on curPrefs instead of $.pref, so allowing an override for bkgd_color
@@ -31222,10 +34423,11 @@
// save_notice_done: false,
// export_notice_done: false
});
- editor.setConfig({
- // Indicate pref settings here if you wish to allow user storage or URL settings
+ editor.setConfig({// Indicate pref settings here if you wish to allow user storage or URL settings
// to be able to override your default preferences (unless other config options
// have already explicitly prevented one or the other)
- }, { allowInitialUserOverride: true });
+ }, {
+ allowInitialUserOverride: true
+ });
}());