Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
ad3fe74cfd
3 changed files with 107 additions and 51 deletions
|
@ -100,7 +100,7 @@
|
|||
|
||||
#svg_editor div#palette {
|
||||
float: left;
|
||||
width: 6848px;
|
||||
width: 672px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
|
|
|
@ -401,8 +401,18 @@
|
|||
|
||||
Editor.canvas = svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas"), curConfig);
|
||||
|
||||
var palette = ["#000000","#202020","#404040","#606060","#808080","#a0a0a0","#c0c0c0","#e0e0e0","#ffffff","#800000","#ff0000","#808000","#ffff00","#008000","#00ff00","#008080","#00ffff","#000080","#0000ff","#800080","#ff00ff","#2b0000","#550000","#800000","#aa0000","#d40000","#ff0000","#ff2a2a","#ff5555","#ff8080","#ffaaaa","#ffd5d5","#280b0b","#501616","#782121","#a02c2c","#c83737","#d35f5f","#de8787","#e9afaf","#f4d7d7","#241c1c","#483737","#6c5353","#916f6f","#ac9393","#c8b7b7","#e3dbdb","#2b1100","#552200","#803300","#aa4400","#d45500","#ff6600","#ff7f2a","#ff9955","#ffb380","#ffccaa","#ffe6d5","#28170b","#502d16","#784421","#a05a2c","#c87137","#d38d5f","#deaa87","#e9c6af","#f4e3d7","#241f1c","#483e37","#6c5d53","#917c6f","#ac9d93","#c8beb7","#e3dedb","#2b2200","#554400","#806600","#aa8800","#d4aa00","#ffcc00","#ffd42a","#ffdd55","#ffe680","#ffeeaa","#fff6d5","#28220b","#504416","#786721","#a0892c","#c8ab37","#d3bc5f","#decd87","#e9ddaf","#f4eed7","#24221c","#484537","#6c6753","#918a6f","#aca793","#c8c4b7","#e3e2db","#222b00","#445500","#668000","#88aa00","#aad400","#ccff00","#d4ff2a","#ddff55","#e5ff80","#eeffaa","#f6ffd5","#22280b","#445016","#677821","#89a02c","#abc837","#bcd35f","#cdde87","#dde9af","#eef4d7","#22241c","#454837","#676c53","#8a916f","#a7ac93","#c4c8b7","#e2e3db","#112b00","#225500","#338000","#44aa00","#55d400","#66ff00","#7fff2a","#99ff55","#b3ff80","#ccffaa","#e5ffd5","#17280b","#2d5016","#447821","#5aa02c","#71c837","#8dd35f","#aade87","#c6e9af","#e3f4d7","#1f241c","#3e4837","#5d6c53","#7c916f","#9dac93","#bec8b7","#dee3db","#002b00","#005500","#008000","#00aa00","#00d400","#00ff00","#2aff2a","#55ff55","#80ff80","#aaffaa","#d5ffd5","#0b280b","#165016","#217821","#2ca02c","#37c837","#5fd35f","#87de87","#afe9af","#d7f4d7","#1c241c","#374837","#536c53","#6f916f","#93ac93","#b7c8b7","#dbe3db","#002b11","#005522","#008033","#00aa44","#00d455","#00ff66","#2aff80","#55ff99","#80ffb3","#aaffcc","#d5ffe6","#0b2817","#16502d","#217844","#2ca05a","#37c871","#5fd38d","#87deaa","#afe9c6","#d7f4e3","#1c241f","#37483e","#536c5d","#6f917c","#93ac9d","#b7c8be","#dbe3de","#002b22","#005544","#008066","#00aa88","#00d4aa","#00ffcc","#2affd5","#55ffdd","#80ffe6","#aaffee","#d5fff6","#0b2822","#165044","#217867","#2ca089","#37c8ab","#5fd3bc","#87decd","#afe9dd","#d7f4ee","#1c2422","#374845","#536c67","#6f918a","#93aca7","#b7c8c4","#dbe3e2","#00222b","#004455","#006680","#0088aa","#00aad4","#00ccff","#2ad4ff","#55ddff","#80e5ff","#aaeeff","#d5f6ff","#0b2228","#164450","#216778","#2c89a0","#37abc8","#5fbcd3","#87cdde","#afdde9","#d7eef4","#1c2224","#374548","#53676c","#6f8a91","#93a7ac","#b7c4c8","#dbe2e3","#00112b","#002255","#003380","#0044aa","#0055d4","#0066ff","#2a7fff","#5599ff","#80b3ff","#aaccff","#d5e5ff","#0b1728","#162d50","#214478","#2c5aa0","#3771c8","#5f8dd3","#87aade","#afc6e9","#d7e3f4","#1c1f24","#373e48","#535d6c","#6f7c91","#939dac","#b7bec8","#dbdee3","#00002b","#000055","#000080","#0000aa","#0000d4","#0000ff","#2a2aff","#5555ff","#8080ff","#aaaaff","#d5d5ff","#0b0b28","#161650","#212178","#2c2ca0","#3737c8","#5f5fd3","#8787de","#afafe9","#d7d7f4","#1c1c24","#373748","#53536c","#6f6f91","#9393ac","#b7b7c8","#dbdbe3","#11002b","#220055","#330080","#4400aa","#5500d4","#6600ff","#7f2aff","#9955ff","#b380ff","#ccaaff","#e5d5ff","#170b28","#2d1650","#442178","#5a2ca0","#7137c8","#8d5fd3","#aa87de","#c6afe9","#e3d7f4","#1f1c24","#3e3748","#5d536c","#7c6f91","#9d93ac","#beb7c8","#dedbe3","#22002b","#440055","#660080","#8800aa","#aa00d4","#cc00ff","#d42aff","#dd55ff","#e580ff","#eeaaff","#f6d5ff","#220b28","#441650","#672178","#892ca0","#ab37c8","#bc5fd3","#cd87de","#ddafe9","#eed7f4","#221c24","#453748","#67536c","#8a6f91","#a793ac","#c4b7c8","#e2dbe3","#2b0022","#550044","#800066","#aa0088","#d400aa","#ff00cc","#ff2ad4","#ff55dd","#ff80e5","#ffaaee","#ffd5f6","#280b22","#501644","#782167","#a02c89","#c837ab","#d35fbc","#de87cd","#e9afdd","#f4d7ee","#241c22","#483745","#6c5367","#916f8a","#ac93a7","#c8b7c4","#e3dbe2","#2b0011","#550022","#800033","#aa0044","#d40055","#ff0066","#ff2a7f","#ff5599","#ff80b2","#ffaacc","#ffd5e5","#280b17","#50162d","#782144","#a02c5a","#c83771","#d35f8d","#de87aa","#e9afc6","#f4d7e3","#241c1f","#48373e","#6c535d","#916f7c","#ac939d","#c8b7be","#e3dbde"],
|
||||
|
||||
var palette = ["#000000", "#3f3f3f", "#7f7f7f", "#bfbfbf", "#ffffff",
|
||||
"#ff0000", "#ff7f00", "#ffff00", "#7fff00",
|
||||
"#00ff00", "#00ff7f", "#00ffff", "#007fff",
|
||||
"#0000ff", "#7f00ff", "#ff00ff", "#ff007f",
|
||||
"#7f0000", "#7f3f00", "#7f7f00", "#3f7f00",
|
||||
"#007f00", "#007f3f", "#007f7f", "#003f7f",
|
||||
"#00007f", "#3f007f", "#7f007f", "#7f003f",
|
||||
"#ffaaaa", "#ffd4aa", "#ffffaa", "#d4ffaa",
|
||||
"#aaffaa", "#aaffd4", "#aaffff", "#aad4ff",
|
||||
"#aaaaff", "#d4aaff", "#ffaaff", "#ffaad4",
|
||||
];
|
||||
|
||||
isMac = false, //(navigator.platform.indexOf("Mac") != -1);
|
||||
modKey = "", //(isMac ? "meta+" : "ctrl+");
|
||||
path = svgCanvas.pathActions,
|
||||
|
@ -1070,10 +1080,13 @@
|
|||
$('#stroke_style').val(selectedElement.getAttribute("stroke-dasharray")||"none");
|
||||
|
||||
var attr = selectedElement.getAttribute("stroke-linejoin") || 'miter';
|
||||
$('#linejoin_' + attr).mouseup();
|
||||
|
||||
setStrokeOpt($('#linejoin_' + attr)[0]);
|
||||
|
||||
attr = selectedElement.getAttribute("stroke-linecap") || 'butt';
|
||||
|
||||
setStrokeOpt($('#linecap_' + attr)[0]);
|
||||
|
||||
var attr = selectedElement.getAttribute("stroke-linecap") || 'butt';
|
||||
$('#linecap_' + attr).mouseup();
|
||||
}
|
||||
|
||||
// All elements including image and group have opacity
|
||||
|
@ -1382,11 +1395,6 @@
|
|||
operaRepaint();
|
||||
});
|
||||
|
||||
// $('#stroke_linecap').change(function(){
|
||||
// svgCanvas.setStrokeAttr('stroke-linecap', $(this).val());
|
||||
// operaRepaint();
|
||||
// });
|
||||
|
||||
|
||||
// Lose focus for select elements when changed (Allows keyboard shortcuts to work better)
|
||||
$('select').change(function(){$(this).blur();});
|
||||
|
@ -1561,6 +1569,20 @@
|
|||
}());
|
||||
|
||||
|
||||
function setStrokeOpt(opt, changeElem) {
|
||||
var id = opt.id;
|
||||
var bits = id.split('_');
|
||||
var pre = bits[0];
|
||||
var val = bits[1];
|
||||
|
||||
if(changeElem) {
|
||||
svgCanvas.setStrokeAttr('stroke-' + pre, val);
|
||||
}
|
||||
operaRepaint();
|
||||
setIcon('#cur_' + pre , id, 20);
|
||||
$(opt).addClass('current').siblings().removeClass('current');
|
||||
}
|
||||
|
||||
(function() {
|
||||
var button = $('#main_icon');
|
||||
var overlay = $('#main_icon span');
|
||||
|
@ -1678,12 +1700,7 @@
|
|||
if(dropUp) {
|
||||
$(elem).addClass('dropup');
|
||||
}
|
||||
list.find('li').bind('mouseup', function() {
|
||||
callback.apply(this, arguments);
|
||||
if(!opts.multiclick) {
|
||||
$(this).addClass('current').siblings().removeClass('current');
|
||||
}
|
||||
});
|
||||
list.find('li').bind('mouseup', callback);
|
||||
|
||||
$(window).mouseup(function(evt) {
|
||||
if(!on_button) {
|
||||
|
@ -1789,21 +1806,11 @@
|
|||
}, true);
|
||||
|
||||
addAltDropDown('#stroke_linecap', '#linecap_opts', function() {
|
||||
var val = this.id.split('_')[1];
|
||||
svgCanvas.setStrokeAttr('stroke-linecap', val);
|
||||
operaRepaint();
|
||||
var icon = $.getSvgIcon(this.id).clone();
|
||||
$('#cur_linecap').empty().append(icon);
|
||||
$.resizeSvgIcons({'#cur_linecap .svg_icon': 20});
|
||||
setStrokeOpt(this, true);
|
||||
}, {dropUp: true});
|
||||
|
||||
addAltDropDown('#stroke_linejoin', '#linejoin_opts', function() {
|
||||
var val = this.id.split('_')[1];
|
||||
svgCanvas.setStrokeAttr('stroke-linejoin', val);
|
||||
operaRepaint();
|
||||
var icon = $.getSvgIcon(this.id).clone();
|
||||
$('#cur_linejoin').empty().append(icon);
|
||||
$.resizeSvgIcons({'#cur_linejoin .svg_icon': 20});
|
||||
setStrokeOpt(this, true);
|
||||
}, {dropUp: true});
|
||||
|
||||
addAltDropDown('#tool_position', '#position_opts', function() {
|
||||
|
@ -2287,14 +2294,20 @@
|
|||
svgCanvas.setBackground(color, url);
|
||||
}
|
||||
|
||||
var setIcon = function(elem, icon_id) {
|
||||
var setIcon = function(elem, icon_id, forcedSize) {
|
||||
var icon = $.getSvgIcon(icon_id).clone();
|
||||
$(elem).empty().append(icon);
|
||||
var size = curPrefs.iconsize;
|
||||
if(size && size !== 'm') {
|
||||
var icon_sizes = { s:16, m:24, l:32, xl:48}, obj = {};
|
||||
obj[elem + ' .svg_icon'] = icon_sizes[size];
|
||||
if(forcedSize) {
|
||||
var obj = {};
|
||||
obj[elem + ' .svg_icon'] = forcedSize;
|
||||
$.resizeSvgIcons(obj);
|
||||
} else {
|
||||
var size = curPrefs.iconsize;
|
||||
if(size && size !== 'm') {
|
||||
var icon_sizes = { s:16, m:24, l:32, xl:48}, obj = {};
|
||||
obj[elem + ' .svg_icon'] = icon_sizes[size];
|
||||
$.resizeSvgIcons(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2696,7 +2709,6 @@
|
|||
shower.toggleClass('disabled', !has_enabled);
|
||||
});
|
||||
|
||||
|
||||
operaRepaint();
|
||||
};
|
||||
|
||||
|
@ -3459,7 +3471,7 @@
|
|||
updateCanvas(true);
|
||||
// });
|
||||
|
||||
// var revnums = "svg-editor.js ($Rev: 1574 $) ";
|
||||
// var revnums = "svg-editor.js ($Rev: 1577 $) ";
|
||||
// revnums += svgCanvas.getVersion();
|
||||
// $('#copyright')[0].setAttribute("title", revnums);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* svgcanvas.js
|
||||
*
|
||||
* Licensed under the Apache License, Version 2
|
||||
|
@ -2610,7 +2610,7 @@ function BatchCommand(text) {
|
|||
|
||||
// Function: clearSelection
|
||||
// Clears the selection. The 'selected' handler is then called.
|
||||
this.clearSelection = function() {
|
||||
this.clearSelection = function(noCall) {
|
||||
if (selectedElements[0] != null) {
|
||||
var len = selectedElements.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
|
@ -2621,7 +2621,7 @@ function BatchCommand(text) {
|
|||
}
|
||||
selectedBBoxes[0] = null;
|
||||
}
|
||||
call("selected", selectedElements);
|
||||
if(!noCall) call("selected", selectedElements);
|
||||
};
|
||||
|
||||
// TODO: do we need to worry about selectedBBoxes here?
|
||||
|
@ -3013,7 +3013,8 @@ function BatchCommand(text) {
|
|||
// only clear selection if shift is not pressed (otherwise, add
|
||||
// element to selection)
|
||||
if (!evt.shiftKey) {
|
||||
canvas.clearSelection();
|
||||
// No need to do the call here as it will be done on addToSelection
|
||||
canvas.clearSelection(true);
|
||||
}
|
||||
canvas.addToSelection([mouse_target]);
|
||||
justSelected = mouse_target;
|
||||
|
@ -3290,6 +3291,12 @@ function BatchCommand(text) {
|
|||
if (selectedElements[0] != null) {
|
||||
var dx = x - start_x;
|
||||
var dy = y - start_y;
|
||||
|
||||
if(evt.shiftKey) { // restrict to movement up/down/left/right (WRS)
|
||||
if (Math.abs(dx)>Math.abs(dy)) dy=0;
|
||||
else dx=0;
|
||||
}
|
||||
|
||||
if (dx != 0 || dy != 0) {
|
||||
var len = selectedElements.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
|
@ -3297,8 +3304,8 @@ function BatchCommand(text) {
|
|||
if (selected == null) break;
|
||||
if (i==0) {
|
||||
var box = canvas.getBBox(selected);
|
||||
selectedBBoxes[i].x = box.x + dx;
|
||||
selectedBBoxes[i].y = box.y + dy;
|
||||
// selectedBBoxes[i].x = box.x + dx;
|
||||
// selectedBBoxes[i].y = box.y + dy;
|
||||
}
|
||||
|
||||
// update the dummy transform in our transform list
|
||||
|
@ -3543,6 +3550,12 @@ function BatchCommand(text) {
|
|||
case "pathedit":
|
||||
x *= current_zoom;
|
||||
y *= current_zoom;
|
||||
|
||||
if(evt.shiftKey) { // restrict path segments to horizontal/vertical (WRS)
|
||||
if (Math.abs(start_x-x)>Math.abs(start_y-y)) {y=start_y; mouse_y=y;}
|
||||
else {x=start_x; mouse_x=x;}
|
||||
}
|
||||
|
||||
if(rubberBox && rubberBox.getAttribute('display') != 'none') {
|
||||
assignAttributes(rubberBox, {
|
||||
'x': Math.min(start_x,x),
|
||||
|
@ -3579,6 +3592,12 @@ function BatchCommand(text) {
|
|||
cx = center.x;
|
||||
cy = center.y;
|
||||
var angle = ((Math.atan2(cy-y,cx-x) * (180/Math.PI))-90) % 360;
|
||||
|
||||
if(evt.shiftKey) { // restrict rotations to nice angles (WRS)
|
||||
var snap = 45;
|
||||
angle= Math.round(angle/snap)*snap;
|
||||
}
|
||||
|
||||
canvas.setRotationAngle(angle<-180?(360+angle):angle, true);
|
||||
call("changed", selectedElements);
|
||||
break;
|
||||
|
@ -3641,7 +3660,9 @@ function BatchCommand(text) {
|
|||
cur_text.font_family = selected.getAttribute("font-family");
|
||||
}
|
||||
selectorManager.requestSelector(selected).showGrips(true);
|
||||
call("selected", [selected]);
|
||||
|
||||
// This shouldn't be necessary as it was done on mouseDown...
|
||||
// call("selected", [selected]);
|
||||
}
|
||||
// always recalculate dimensions to strip off stray identity transforms
|
||||
recalculateAllSelectedDimensions();
|
||||
|
@ -4188,10 +4209,15 @@ function BatchCommand(text) {
|
|||
allow_dbl = false;
|
||||
current_mode = "textedit";
|
||||
selectorManager.requestSelector(curtext).showGrips(false);
|
||||
|
||||
|
||||
textActions.init();
|
||||
$(curtext).css('cursor', 'text');
|
||||
|
||||
// if(support.editableText) {
|
||||
// curtext.setAttribute('editable', 'simple');
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(!arguments.length) {
|
||||
setCursor();
|
||||
} else {
|
||||
|
@ -4226,6 +4252,10 @@ function BatchCommand(text) {
|
|||
$(textinput).blur();
|
||||
|
||||
curtext = false;
|
||||
|
||||
// if(support.editableText) {
|
||||
// curtext.removeAttribute('editable');
|
||||
// }
|
||||
},
|
||||
setInputElem: function(elem) {
|
||||
textinput = elem;
|
||||
|
@ -4238,13 +4268,18 @@ function BatchCommand(text) {
|
|||
},
|
||||
init: function(inputElem) {
|
||||
if(!curtext) return;
|
||||
|
||||
// if(support.editableText) {
|
||||
// curtext.select();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(!curtext.parentNode) {
|
||||
// Result of the ffClone, need to get correct element
|
||||
curtext = selectedElements[0];
|
||||
selectorManager.requestSelector(curtext).showGrips(false);
|
||||
}
|
||||
|
||||
|
||||
var str = curtext.textContent;
|
||||
var len = str.length;
|
||||
|
||||
|
@ -5487,6 +5522,12 @@ function BatchCommand(text) {
|
|||
}
|
||||
|
||||
var lastx = current_path_pts[len-2], lasty = current_path_pts[len-1];
|
||||
|
||||
if (evt.shiftKey) { // restrict to horizonontal/vertical (WRS)
|
||||
if (Math.abs(x-lastx)>Math.abs(y-lasty)) y=lasty;
|
||||
else x=lastx;
|
||||
}
|
||||
|
||||
// we store absolute values in our path points array for easy checking above
|
||||
current_path_pts.push(x);
|
||||
current_path_pts.push(y);
|
||||
|
@ -5496,14 +5537,14 @@ function BatchCommand(text) {
|
|||
|
||||
// set stretchy line to latest point
|
||||
assignAttributes(stretchy, {
|
||||
'x1': mouse_x,
|
||||
'y1': mouse_y,
|
||||
'x2': mouse_x,
|
||||
'y2': mouse_y
|
||||
'x1': x,
|
||||
'y1': y,
|
||||
'x2': x,
|
||||
'y2': y
|
||||
});
|
||||
var index = (current_path_pts.length/2 - 1);
|
||||
if(subpath) index += path.segs.length;
|
||||
addPointGrip(index, mouse_x, mouse_y);
|
||||
addPointGrip(index, x, y);
|
||||
}
|
||||
keep = true;
|
||||
}
|
||||
|
@ -9048,7 +9089,7 @@ function BatchCommand(text) {
|
|||
// Function: getVersion
|
||||
// Returns a string which describes the revision number of SvgCanvas.
|
||||
this.getVersion = function() {
|
||||
return "svgcanvas.js ($Rev: 1573 $)";
|
||||
return "svgcanvas.js ($Rev: 1576 $)";
|
||||
};
|
||||
|
||||
this.setUiStrings = function(strs) {
|
||||
|
@ -9171,6 +9212,9 @@ function BatchCommand(text) {
|
|||
support.pathInsertItemBefore = false;
|
||||
}
|
||||
|
||||
// TODO: Find better way to check support for this
|
||||
support.editableText = isOpera;
|
||||
|
||||
// Correct decimals on clone attributes (Opera/win/non-en)
|
||||
var rect = document.createElementNS(svgns,'rect');
|
||||
rect.setAttribute('x',.1);
|
||||
|
|
Loading…
Reference in a new issue