Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
5ca5bce628
|
@ -173,10 +173,12 @@ svgEditor.addExtension("imagelib", function() {
|
||||||
} else {
|
} else {
|
||||||
$(this).text(title);
|
$(this).text(title);
|
||||||
}
|
}
|
||||||
|
submit.removeAttr('disabled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
preview.append('<div>'+title+'</div>');
|
preview.append('<div>'+title+'</div>');
|
||||||
|
submit.removeAttr('disabled');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(cur_meta && cur_meta.preview_url) {
|
if(cur_meta && cur_meta.preview_url) {
|
||||||
|
@ -192,10 +194,12 @@ svgEditor.addExtension("imagelib", function() {
|
||||||
preview.children().each(function() {
|
preview.children().each(function() {
|
||||||
if($(this).data('id') == id) {
|
if($(this).data('id') == id) {
|
||||||
$(this).html(entry);
|
$(this).html(entry);
|
||||||
|
submit.removeAttr('disabled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
preview.append($('<div>').append(entry));
|
preview.append($('<div>').append(entry));
|
||||||
|
submit.removeAttr('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -214,11 +218,10 @@ svgEditor.addExtension("imagelib", function() {
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
var preview;
|
var preview, submit;
|
||||||
|
|
||||||
function toggleMulti(show) {
|
function toggleMulti(show) {
|
||||||
var submit;
|
|
||||||
|
|
||||||
$('#lib_framewrap, #imglib_opts').css({right: (show ? 200 : 10)});
|
$('#lib_framewrap, #imglib_opts').css({right: (show ? 200 : 10)});
|
||||||
if(!preview) {
|
if(!preview) {
|
||||||
preview = $('<div id=imglib_preview>').css({
|
preview = $('<div id=imglib_preview>').css({
|
||||||
|
@ -231,7 +234,7 @@ svgEditor.addExtension("imagelib", function() {
|
||||||
overflow: 'auto'
|
overflow: 'auto'
|
||||||
}).insertAfter('#lib_framewrap');
|
}).insertAfter('#lib_framewrap');
|
||||||
|
|
||||||
submit = $('<button>Import selected</button>').appendTo('#imgbrowse').click(function() {
|
submit = $('<button disabled>Import selected</button>').appendTo('#imgbrowse').click(function() {
|
||||||
$.each(multi_arr, function(i) {
|
$.each(multi_arr, function(i) {
|
||||||
var type = this[0];
|
var type = this[0];
|
||||||
var data = this[1];
|
var data = this[1];
|
||||||
|
@ -254,6 +257,7 @@ svgEditor.addExtension("imagelib", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
preview.toggle(show);
|
preview.toggle(show);
|
||||||
|
submit.toggle(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showBrowser() {
|
function showBrowser() {
|
||||||
|
|
|
@ -54,6 +54,59 @@
|
||||||
background: -webkit-gradient(radial, center center, 3, center center, 1000, from(#bbb), to(#222));
|
background: -webkit-gradient(radial, center center, 3, center center, 1000, from(#bbb), to(#222));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#rulers > div {
|
||||||
|
position: absolute;
|
||||||
|
background: #DDD;
|
||||||
|
z-index: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ruler_corner {
|
||||||
|
top: 76px;
|
||||||
|
left: 41px;
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ruler_x {
|
||||||
|
height: 15px;
|
||||||
|
top: 76px;
|
||||||
|
left: 56px;
|
||||||
|
right: 30px;
|
||||||
|
border-bottom: 1px solid;
|
||||||
|
border-left: 1px solid #777;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rulers.moved #ruler_corner,
|
||||||
|
#rulers.moved #ruler_x {
|
||||||
|
top: 101px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ruler_y {
|
||||||
|
width: 15px;
|
||||||
|
top: 91px;
|
||||||
|
left: 41px;
|
||||||
|
bottom: 78px;
|
||||||
|
border-right: 1px solid;
|
||||||
|
border-top: 1px solid #777;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rulers.moved #ruler_y {
|
||||||
|
top: 116px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ruler_x canvas {
|
||||||
|
margin-left: -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ruler_y canvas {
|
||||||
|
margin-top: -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#svg_editor div#palette_holder {
|
#svg_editor div#palette_holder {
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
|
@ -721,6 +774,7 @@ span.zoom_tool {
|
||||||
display: none;
|
display: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#svg_editor .tools_flyout_v {
|
#svg_editor .tools_flyout_v {
|
||||||
|
|
|
@ -49,9 +49,21 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
|
||||||
<body>
|
<body>
|
||||||
<div id="svg_editor">
|
<div id="svg_editor">
|
||||||
|
|
||||||
|
<div id="rulers">
|
||||||
|
<div id="ruler_corner"></div>
|
||||||
|
<div id="ruler_x">
|
||||||
|
<canvas height="15"></canvas>
|
||||||
|
</div>
|
||||||
|
<div id="ruler_y">
|
||||||
|
<canvas width="15"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="workarea">
|
<div id="workarea">
|
||||||
<style id="styleoverrides" type="text/css" media="screen" scoped="scoped"></style>
|
<style id="styleoverrides" type="text/css" media="screen" scoped="scoped"></style>
|
||||||
<div id="svgcanvas"></div>
|
<div id="svgcanvas" style="position:relative">
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="sidepanels">
|
<div id="sidepanels">
|
||||||
|
@ -528,7 +540,7 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
|
||||||
<div id="tools_bottom_3">
|
<div id="tools_bottom_3">
|
||||||
<div id="palette_holder"><div id="palette" title="Click to change fill color, shift-click to change stroke color"></div></div>
|
<div id="palette_holder"><div id="palette" title="Click to change fill color, shift-click to change stroke color"></div></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="copyright"><span id="copyrightLabel">Powered by</span> <a href="http://svg-edit.googlecode.com/" target="_blank">SVG-edit v2.5.1</a></div>
|
<div id="copyright"><span id="copyrightLabel">Powered by</span> <a href="http://svg-edit.googlecode.com/" target="_blank">SVG-edit v2.6-alpha</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="option_lists">
|
<div id="option_lists">
|
||||||
|
@ -669,6 +681,11 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
|
||||||
<label><span id="svginfo_snap_step">Snapping Step-Size:</span> <input type="text" id="grid_snapping_step" size="3" value="10"/></label>
|
<label><span id="svginfo_snap_step">Snapping Step-Size:</span> <input type="text" id="grid_snapping_step" size="3" value="10"/></label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset id="units_rulers">
|
||||||
|
<legend id="svginfo_units_rulers">Units & Rulers</legend>
|
||||||
|
<label><span id="svginfo_rulers_onoff">Show rulers</span><input type="checkbox" value="show_rulers" id="show_rulers" checked></label>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -51,7 +51,8 @@
|
||||||
wireframe: false,
|
wireframe: false,
|
||||||
colorPickerCSS: null,
|
colorPickerCSS: null,
|
||||||
gridSnapping: false,
|
gridSnapping: false,
|
||||||
snappingStep: 10
|
snappingStep: 10,
|
||||||
|
showRulers: true
|
||||||
},
|
},
|
||||||
uiStrings = Editor.uiStrings = {
|
uiStrings = Editor.uiStrings = {
|
||||||
"invalidAttrValGiven":"Invalid value given",
|
"invalidAttrValGiven":"Invalid value given",
|
||||||
|
@ -93,7 +94,7 @@
|
||||||
if(val) curPrefs[key] = val;
|
if(val) curPrefs[key] = val;
|
||||||
key = 'svg-edit-'+key;
|
key = 'svg-edit-'+key;
|
||||||
var host = location.hostname,
|
var host = location.hostname,
|
||||||
onweb = host && host.indexOf('.') != -1,
|
onweb = host && host.indexOf('.') >= 0,
|
||||||
store = (val != undefined),
|
store = (val != undefined),
|
||||||
storage = false;
|
storage = false;
|
||||||
// Some FF versions throw security errors here
|
// Some FF versions throw security errors here
|
||||||
|
@ -251,7 +252,7 @@
|
||||||
$.svgIcons(curConfig.imgPath + 'svg_edit_icons.svg', {
|
$.svgIcons(curConfig.imgPath + 'svg_edit_icons.svg', {
|
||||||
w:24, h:24,
|
w:24, h:24,
|
||||||
id_match: false,
|
id_match: false,
|
||||||
no_img: true,
|
no_img: (!!window.opera), // Opera gives odd behavior w/images
|
||||||
fallback_path: curConfig.imgPath,
|
fallback_path: curConfig.imgPath,
|
||||||
fallback:{
|
fallback:{
|
||||||
'new_image':'clear.png',
|
'new_image':'clear.png',
|
||||||
|
@ -435,6 +436,12 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
svgEditor.runCallbacks();
|
svgEditor.runCallbacks();
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
$('.flyout_arrow_horiz:empty').each(function() {
|
||||||
|
$(this).append($.getSvgIcon('arrow_right').width(5).height(5));
|
||||||
|
});
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -452,7 +459,7 @@
|
||||||
"#aaaaff", "#d4aaff", "#ffaaff", "#ffaad4",
|
"#aaaaff", "#d4aaff", "#ffaaff", "#ffaad4",
|
||||||
];
|
];
|
||||||
|
|
||||||
isMac = (navigator.platform.indexOf("Mac") != -1);
|
isMac = (navigator.platform.indexOf("Mac") >= 0);
|
||||||
modKey = (isMac ? "meta+" : "ctrl+"); // ⌘
|
modKey = (isMac ? "meta+" : "ctrl+"); // ⌘
|
||||||
path = svgCanvas.pathActions,
|
path = svgCanvas.pathActions,
|
||||||
undoMgr = svgCanvas.undoMgr,
|
undoMgr = svgCanvas.undoMgr,
|
||||||
|
@ -646,8 +653,9 @@
|
||||||
// unless we're already in always set the mode of the editor to select because
|
// unless we're already in always set the mode of the editor to select because
|
||||||
// upon creation of a text element the editor is switched into
|
// upon creation of a text element the editor is switched into
|
||||||
// select mode and this event fires - we need our UI to be in sync
|
// select mode and this event fires - we need our UI to be in sync
|
||||||
|
|
||||||
if (mode != "multiselect" && !is_node) {
|
if (mode !== "multiselect" && !is_node) {
|
||||||
|
// FIXME: This also needs to fire if only one element is selected via multiselect
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,6 +746,7 @@
|
||||||
|
|
||||||
var contextChanged = function(win, context) {
|
var contextChanged = function(win, context) {
|
||||||
$('#workarea,#sidepanels').css('top', context?100:75);
|
$('#workarea,#sidepanels').css('top', context?100:75);
|
||||||
|
$('#rulers').toggleClass('moved', context);
|
||||||
if(cur_context && !context) {
|
if(cur_context && !context) {
|
||||||
// Back to normal
|
// Back to normal
|
||||||
workarea[0].scrollTop -= 25;
|
workarea[0].scrollTop -= 25;
|
||||||
|
@ -1237,7 +1246,7 @@
|
||||||
$.svgIcons(svgicons, {
|
$.svgIcons(svgicons, {
|
||||||
w:24, h:24,
|
w:24, h:24,
|
||||||
id_match: false,
|
id_match: false,
|
||||||
no_img: true,
|
no_img: (!!window.opera),
|
||||||
fallback: fallback_obj,
|
fallback: fallback_obj,
|
||||||
placement: placement_obj,
|
placement: placement_obj,
|
||||||
callback: function(icons) {
|
callback: function(icons) {
|
||||||
|
@ -1281,7 +1290,7 @@
|
||||||
// updates the toolbar (colors, opacity, etc) based on the selected element
|
// updates the toolbar (colors, opacity, etc) based on the selected element
|
||||||
// This function also updates the opacity and id elements that are in the context panel
|
// This function also updates the opacity and id elements that are in the context panel
|
||||||
var updateToolbar = function() {
|
var updateToolbar = function() {
|
||||||
if (selectedElement != null && $.inArray(selectedElement.tagName, ['use', 'image', 'foreignObject', 'g', 'a']) === -1) {
|
if (selectedElement != null && ['use', 'image', 'foreignObject', 'g', 'a'].indexOf(selectedElement.tagName) === -1) {
|
||||||
|
|
||||||
// get opacity values
|
// get opacity values
|
||||||
var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity"));
|
var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity"));
|
||||||
|
@ -1444,12 +1453,12 @@
|
||||||
if(!is_node && currentMode != 'pathedit') {
|
if(!is_node && currentMode != 'pathedit') {
|
||||||
$('#selected_panel').show();
|
$('#selected_panel').show();
|
||||||
// Elements in this array already have coord fields
|
// Elements in this array already have coord fields
|
||||||
if($.inArray(elname, ['line', 'circle', 'ellipse']) != -1) {
|
if(['line', 'circle', 'ellipse'].indexOf(elname) >= 0) {
|
||||||
$('#xy_panel').hide();
|
$('#xy_panel').hide();
|
||||||
} else {
|
} else {
|
||||||
var x,y;
|
var x,y;
|
||||||
// Get BBox vals for g, polyline and path
|
// Get BBox vals for g, polyline and path
|
||||||
if($.inArray(elname, ['g', 'polyline', 'path']) != -1) {
|
if(['g', 'polyline', 'path'].indexOf(elname) >= 0) {
|
||||||
var bb = svgCanvas.getStrokedBBox([elem]);
|
var bb = svgCanvas.getStrokedBBox([elem]);
|
||||||
if(bb) {
|
if(bb) {
|
||||||
x = bb.x;
|
x = bb.x;
|
||||||
|
@ -1465,7 +1474,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elements in this array cannot be converted to a path
|
// Elements in this array cannot be converted to a path
|
||||||
var no_path = $.inArray(elname, ['image', 'text', 'path', 'g', 'use']) == -1;
|
var no_path = ['image', 'text', 'path', 'g', 'use'].indexOf(elname) == -1;
|
||||||
$('#tool_topath').toggle(no_path);
|
$('#tool_topath').toggle(no_path);
|
||||||
$('#tool_reorient').toggle(elname == 'path');
|
$('#tool_reorient').toggle(elname == 'path');
|
||||||
$('#tool_reorient').toggleClass('disabled', angle == 0);
|
$('#tool_reorient').toggleClass('disabled', angle == 0);
|
||||||
|
@ -1658,7 +1667,7 @@
|
||||||
|
|
||||||
var changeStrokeWidth = function(ctl) {
|
var changeStrokeWidth = function(ctl) {
|
||||||
var val = ctl.value;
|
var val = ctl.value;
|
||||||
if(val == 0 && selectedElement && $.inArray(selectedElement.nodeName, ['line', 'polyline']) != -1) {
|
if(val == 0 && selectedElement && ['line', 'polyline'].indexOf(selectedElement.nodeName) >= 0) {
|
||||||
val = ctl.value = 1;
|
val = ctl.value = 1;
|
||||||
}
|
}
|
||||||
svgCanvas.setStrokeWidth(val);
|
svgCanvas.setStrokeWidth(val);
|
||||||
|
@ -2698,6 +2707,11 @@
|
||||||
// set grid setting
|
// set grid setting
|
||||||
curConfig.gridSnapping = $('#grid_snapping_on')[0].checked;
|
curConfig.gridSnapping = $('#grid_snapping_on')[0].checked;
|
||||||
curConfig.snappingStep = $('#grid_snapping_step').val();
|
curConfig.snappingStep = $('#grid_snapping_step').val();
|
||||||
|
curConfig.showRulers = $('#show_rulers')[0].checked;
|
||||||
|
|
||||||
|
$('#rulers').toggle(curConfig.showRulers);
|
||||||
|
if(curConfig.showRulers) updateRulers();
|
||||||
|
|
||||||
svgCanvas.setConfig(curConfig);
|
svgCanvas.setConfig(curConfig);
|
||||||
|
|
||||||
updateCanvas();
|
updateCanvas();
|
||||||
|
@ -2714,7 +2728,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var setIcon = Editor.setIcon = function(elem, icon_id, forcedSize) {
|
var setIcon = Editor.setIcon = function(elem, icon_id, forcedSize) {
|
||||||
var icon = (typeof icon_id == 'string') ? $.getSvgIcon(icon_id, true) : icon_id;
|
var icon = (typeof icon_id === 'string') ? $.getSvgIcon(icon_id, true) : icon_id.clone();
|
||||||
if(!icon) {
|
if(!icon) {
|
||||||
console.log('NOTE: Icon image missing: ' + icon_id);
|
console.log('NOTE: Icon image missing: ' + icon_id);
|
||||||
return;
|
return;
|
||||||
|
@ -3045,6 +3059,14 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
workarea.scroll(function() {
|
||||||
|
$('#ruler_x')[0].scrollLeft = workarea[0].scrollLeft;
|
||||||
|
$('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
|
||||||
|
});
|
||||||
|
|
||||||
|
}());
|
||||||
|
|
||||||
$('#url_notice').click(function() {
|
$('#url_notice').click(function() {
|
||||||
$.alert(this.title);
|
$.alert(this.title);
|
||||||
});
|
});
|
||||||
|
@ -3433,6 +3455,8 @@
|
||||||
workarea.css('right', parseInt(workarea.css('right'))+deltax);
|
workarea.css('right', parseInt(workarea.css('right'))+deltax);
|
||||||
sidepanels.css('width', parseInt(sidepanels.css('width'))+deltax);
|
sidepanels.css('width', parseInt(sidepanels.css('width'))+deltax);
|
||||||
layerpanel.css('width', parseInt(layerpanel.css('width'))+deltax);
|
layerpanel.css('width', parseInt(layerpanel.css('width'))+deltax);
|
||||||
|
var ruler_x = $('#ruler_x');
|
||||||
|
ruler_x.css('right', parseInt(ruler_x.css('right')) + deltax);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#sidepanel_handle')
|
$('#sidepanel_handle')
|
||||||
|
@ -3464,9 +3488,11 @@
|
||||||
var deltax = (w > 2 || close ? 2 : SIDEPANEL_OPENWIDTH) - w;
|
var deltax = (w > 2 || close ? 2 : SIDEPANEL_OPENWIDTH) - w;
|
||||||
var sidepanels = $('#sidepanels');
|
var sidepanels = $('#sidepanels');
|
||||||
var layerpanel = $('#layerpanel');
|
var layerpanel = $('#layerpanel');
|
||||||
workarea.css('right', parseInt(workarea.css('right'))+deltax);
|
var ruler_x = $('#ruler_x');
|
||||||
sidepanels.css('width', parseInt(sidepanels.css('width'))+deltax);
|
workarea.css('right', parseInt(workarea.css('right')) + deltax);
|
||||||
layerpanel.css('width', parseInt(layerpanel.css('width'))+deltax);
|
sidepanels.css('width', parseInt(sidepanels.css('width')) + deltax);
|
||||||
|
layerpanel.css('width', parseInt(layerpanel.css('width')) + deltax);
|
||||||
|
ruler_x.css('right', parseInt(ruler_x.css('right')) + deltax);
|
||||||
};
|
};
|
||||||
|
|
||||||
// this function highlights the layer passed in (by fading out the other layers)
|
// this function highlights the layer passed in (by fading out the other layers)
|
||||||
|
@ -4111,13 +4137,115 @@
|
||||||
w_area[0].scrollLeft = new_ctr.x - w_orig/2;
|
w_area[0].scrollLeft = new_ctr.x - w_orig/2;
|
||||||
w_area[0].scrollTop = new_ctr.y - h_orig/2;
|
w_area[0].scrollTop = new_ctr.y - h_orig/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(curConfig.showRulers) {
|
||||||
|
updateRulers(cnvs, zoom);
|
||||||
|
workarea.scroll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make [1,2,5] array
|
||||||
|
var r_intervals = [];
|
||||||
|
for(var i = .1; i < 1E5; i *= 10) {
|
||||||
|
r_intervals.push(1 * i);
|
||||||
|
r_intervals.push(2 * i);
|
||||||
|
r_intervals.push(5 * i);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateRulers(scanvas, zoom) {
|
||||||
|
if(!zoom) zoom = svgCanvas.getZoom();
|
||||||
|
if(!scanvas) scanvas = $("#svgcanvas");
|
||||||
|
|
||||||
|
var c_elem = svgCanvas.getContentElem();
|
||||||
|
|
||||||
|
for(var d = 0; d < 2; d++) {
|
||||||
|
var is_x = (d === 0);
|
||||||
|
var dim = is_x ? 'x' : 'y';
|
||||||
|
var lentype = is_x?'width':'height';
|
||||||
|
|
||||||
|
var content_d = c_elem.getAttribute(dim)-0;
|
||||||
|
|
||||||
|
var hcanv = $('#ruler_' + dim + ' canvas')[0];
|
||||||
|
// Set the canvas size to the width of the container
|
||||||
|
var len = hcanv[lentype] = scanvas[lentype]();
|
||||||
|
var ctx = hcanv.getContext("2d");
|
||||||
|
|
||||||
|
var unit = 1; // 1 = 1px
|
||||||
|
|
||||||
|
// Calculate the main number interval
|
||||||
|
var raw_m = 50 / zoom;
|
||||||
|
|
||||||
|
var multi = 1;
|
||||||
|
for(var i = 0; i < r_intervals.length; i++) {
|
||||||
|
var num = r_intervals[i];
|
||||||
|
multi = num;
|
||||||
|
if(raw_m <= num) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var big_int = unit * multi * zoom;
|
||||||
|
|
||||||
|
ctx.font = "9px sans-serif";
|
||||||
|
|
||||||
|
var ruler_d = ((content_d / zoom) % multi) * zoom;
|
||||||
|
|
||||||
|
for (; ruler_d < len; ruler_d += big_int) {
|
||||||
|
var real_d = Math.round((ruler_d) - content_d );
|
||||||
|
|
||||||
|
var cur_d = Math.round(ruler_d) + .5;
|
||||||
|
if(is_x) {
|
||||||
|
ctx.moveTo(cur_d, 15);
|
||||||
|
ctx.lineTo(cur_d, 0);
|
||||||
|
} else {
|
||||||
|
ctx.moveTo(15, cur_d);
|
||||||
|
ctx.lineTo(0, cur_d);
|
||||||
|
}
|
||||||
|
|
||||||
|
var label = Math.round(real_d / zoom);
|
||||||
|
|
||||||
|
// Do anything special for negative numbers?
|
||||||
|
// var is_neg = label < 0;
|
||||||
|
// real_d2 = Math.abs(real_d2);
|
||||||
|
|
||||||
|
// Change 1000s to Ks
|
||||||
|
if(label !== 0 && label !== 1000 && label % 1000 === 0) {
|
||||||
|
label = (label / 1000) + 'K';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_x) {
|
||||||
|
ctx.fillText(label, ruler_d+2, 8);
|
||||||
|
} else {
|
||||||
|
var str = (label+'').split('');
|
||||||
|
for(var i = 0; i < str.length; i++) {
|
||||||
|
ctx.fillText(str[i], 1, (ruler_d+9) + i*9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var part = big_int / 10;
|
||||||
|
for(var i = 1; i < 10; i++) {
|
||||||
|
var sub_d = Math.round(ruler_d + part * i) + .5;
|
||||||
|
var line_num = (i % 2)?12:10;
|
||||||
|
if(is_x) {
|
||||||
|
ctx.moveTo(sub_d, 15);
|
||||||
|
ctx.lineTo(sub_d, line_num);
|
||||||
|
} else {
|
||||||
|
ctx.moveTo(15, sub_d);
|
||||||
|
ctx.lineTo(line_num ,sub_d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.strokeStyle = "#000";
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $(function() {
|
// $(function() {
|
||||||
updateCanvas(true);
|
updateCanvas(true);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// var revnums = "svg-editor.js ($Rev: 1762 $) ";
|
// var revnums = "svg-editor.js ($Rev: 1774 $) ";
|
||||||
// revnums += svgCanvas.getVersion();
|
// revnums += svgCanvas.getVersion();
|
||||||
// $('#copyright')[0].setAttribute("title", revnums);
|
// $('#copyright')[0].setAttribute("title", revnums);
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,11 @@ if(window.opera) {
|
||||||
// config - An object that contains configuration data
|
// config - An object that contains configuration data
|
||||||
$.SvgCanvas = function(container, config)
|
$.SvgCanvas = function(container, config)
|
||||||
{
|
{
|
||||||
var isOpera = !!window.opera,
|
var userAgent = navigator.userAgent,
|
||||||
isWebkit = navigator.userAgent.indexOf("AppleWebKit") != -1,
|
// Note: Browser sniffing should only be used if no other detection method is possible
|
||||||
|
isOpera = !!window.opera,
|
||||||
|
isWebkit = userAgent.indexOf("AppleWebKit") >= 0,
|
||||||
|
isGecko = userAgent.indexOf('Gecko/') >= 0,
|
||||||
|
|
||||||
// Object populated later with booleans indicating support for features
|
// Object populated later with booleans indicating support for features
|
||||||
support = {},
|
support = {},
|
||||||
|
@ -406,7 +409,7 @@ var Utils = this.Utils = function() {
|
||||||
// Cross-browser compatible method of converting a string to an XML tree
|
// Cross-browser compatible method of converting a string to an XML tree
|
||||||
// found this function here: http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f
|
// found this function here: http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f
|
||||||
"text2xml": function(sXML) {
|
"text2xml": function(sXML) {
|
||||||
if(sXML.indexOf('<svg:svg') !== -1) {
|
if(sXML.indexOf('<svg:svg') >= 0) {
|
||||||
sXML = sXML.replace(/<(\/?)svg:/g, '<$1').replace('xmlns:svg', 'xmlns');
|
sXML = sXML.replace(/<(\/?)svg:/g, '<$1').replace('xmlns:svg', 'xmlns');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +516,7 @@ var svgWhiteListNS = {};
|
||||||
$.each(svgWhiteList, function(elt,atts){
|
$.each(svgWhiteList, function(elt,atts){
|
||||||
var attNS = {};
|
var attNS = {};
|
||||||
$.each(atts, function(i, att){
|
$.each(atts, function(i, att){
|
||||||
if (att.indexOf(':') != -1) {
|
if (att.indexOf(':') >= 0) {
|
||||||
var v = att.split(':');
|
var v = att.split(':');
|
||||||
attNS[v[1]] = nsRevMap[v[0]];
|
attNS[v[1]] = nsRevMap[v[0]];
|
||||||
} else {
|
} else {
|
||||||
|
@ -559,9 +562,9 @@ var convertToNum, convertToUnit, setUnitAttr;
|
||||||
var num = val.substr(0, val.length-1)/100;
|
var num = val.substr(0, val.length-1)/100;
|
||||||
var res = getResolution();
|
var res = getResolution();
|
||||||
|
|
||||||
if($.inArray(attr, w_attrs) !== -1) {
|
if(w_attrs.indexOf(attr) >= 0) {
|
||||||
return num * res.w;
|
return num * res.w;
|
||||||
} else if($.inArray(attr, h_attrs) !== -1) {
|
} else if(h_attrs.indexOf(attr) >= 0) {
|
||||||
return num * res.h;
|
return num * res.h;
|
||||||
} else {
|
} else {
|
||||||
return num * Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2);
|
return num * Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2);
|
||||||
|
@ -594,9 +597,9 @@ var convertToNum, convertToUnit, setUnitAttr;
|
||||||
var res = getResolution();
|
var res = getResolution();
|
||||||
unit = '%';
|
unit = '%';
|
||||||
val *= 100;
|
val *= 100;
|
||||||
if($.inArray(attr, w_attrs) !== -1) {
|
if(w_attrs.indexOf(attr) >= 0) {
|
||||||
val = val / res.w;
|
val = val / res.w;
|
||||||
} else if($.inArray(attr, h_attrs) !== -1) {
|
} else if(h_attrs.indexOf(attr) >= 0) {
|
||||||
val = val / res.h;
|
val = val / res.h;
|
||||||
} else {
|
} else {
|
||||||
return val / Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2);
|
return val / Math.sqrt((res.w*res.w) + (res.h*res.h))/Math.sqrt(2);
|
||||||
|
@ -621,7 +624,7 @@ var convertToNum, convertToUnit, setUnitAttr;
|
||||||
// val - String with the attribute value to check
|
// val - String with the attribute value to check
|
||||||
canvas.isValidUnit = function(attr, val) {
|
canvas.isValidUnit = function(attr, val) {
|
||||||
var valid = false;
|
var valid = false;
|
||||||
if($.inArray(attr, unit_attrs) != -1) {
|
if(unit_attrs.indexOf(attr) >= 0) {
|
||||||
// True if it's just a number
|
// True if it's just a number
|
||||||
if(!isNaN(val)) {
|
if(!isNaN(val)) {
|
||||||
valid = true;
|
valid = true;
|
||||||
|
@ -2134,7 +2137,7 @@ var getStrokedBBox = this.getStrokedBBox = function(elems) {
|
||||||
|
|
||||||
// Get the BBox from the raw path for these elements
|
// Get the BBox from the raw path for these elements
|
||||||
var elemNames = ['ellipse','path','line','polyline','polygon'];
|
var elemNames = ['ellipse','path','line','polyline','polygon'];
|
||||||
if($.inArray(elem.tagName, elemNames) != -1) {
|
if(elemNames.indexOf(elem.tagName) >= 0) {
|
||||||
bb = good_bb = canvas.convertToPath(elem, true);
|
bb = good_bb = canvas.convertToPath(elem, true);
|
||||||
} else if(elem.tagName == 'rect') {
|
} else if(elem.tagName == 'rect') {
|
||||||
// Look for radius
|
// Look for radius
|
||||||
|
@ -2515,7 +2518,7 @@ var sanitizeSvg = this.sanitizeSvg = function(node) {
|
||||||
while(p--) {
|
while(p--) {
|
||||||
var nv = props[p].split(":");
|
var nv = props[p].split(":");
|
||||||
// now check that this attribute is supported
|
// now check that this attribute is supported
|
||||||
if (allowedAttrs.indexOf(nv[0]) != -1) {
|
if (allowedAttrs.indexOf(nv[0]) >= 0) {
|
||||||
node.setAttribute(nv[0],nv[1]);
|
node.setAttribute(nv[0],nv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2531,8 +2534,8 @@ var sanitizeSvg = this.sanitizeSvg = function(node) {
|
||||||
// (but not for links)
|
// (but not for links)
|
||||||
var href = getHref(node);
|
var href = getHref(node);
|
||||||
if(href &&
|
if(href &&
|
||||||
$.inArray(node.nodeName, ["filter", "linearGradient", "pattern",
|
["filter", "linearGradient", "pattern",
|
||||||
"radialGradient", "textPath", "use"]) != -1)
|
"radialGradient", "textPath", "use"].indexOf(node.nodeName) >= 0)
|
||||||
{
|
{
|
||||||
// TODO: we simply check if the first character is a #, is this bullet-proof?
|
// TODO: we simply check if the first character is a #, is this bullet-proof?
|
||||||
if (href[0] != "#") {
|
if (href[0] != "#") {
|
||||||
|
@ -2639,7 +2642,7 @@ var getBBox = this.getBBox = function(elem) {
|
||||||
bb.x = ret.x + parseFloat(selected.getAttribute('x')||0);
|
bb.x = ret.x + parseFloat(selected.getAttribute('x')||0);
|
||||||
bb.y = ret.y + parseFloat(selected.getAttribute('y')||0);
|
bb.y = ret.y + parseFloat(selected.getAttribute('y')||0);
|
||||||
ret = bb;
|
ret = bb;
|
||||||
} else if(~$.inArray(elname, visElems_arr)) {
|
} else if(~visElems_arr.indexOf(elname)) {
|
||||||
try { ret = selected.getBBox();}
|
try { ret = selected.getBBox();}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
// Check if element is child of a foreignObject
|
// Check if element is child of a foreignObject
|
||||||
|
@ -2670,7 +2673,7 @@ var getBBox = this.getBBox = function(elem) {
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// elem - The (text) DOM element to clone
|
// elem - The (text) DOM element to clone
|
||||||
var ffClone = function(elem) {
|
var ffClone = function(elem) {
|
||||||
if(navigator.userAgent.indexOf('Gecko/') == -1) return elem;
|
if(isGecko) return elem;
|
||||||
var clone = elem.cloneNode(true)
|
var clone = elem.cloneNode(true)
|
||||||
elem.parentNode.insertBefore(clone, elem);
|
elem.parentNode.insertBefore(clone, elem);
|
||||||
elem.parentNode.removeChild(elem);
|
elem.parentNode.removeChild(elem);
|
||||||
|
@ -3216,24 +3219,24 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
|
||||||
var k = tlist.numberOfItems;
|
var k = tlist.numberOfItems;
|
||||||
while (k--) {
|
while (k--) {
|
||||||
var xform = tlist.getItem(k);
|
var xform = tlist.getItem(k);
|
||||||
if (xform.type == 0) {
|
if (xform.type === 0) {
|
||||||
tlist.removeItem(k);
|
tlist.removeItem(k);
|
||||||
}
|
}
|
||||||
// remove identity matrices
|
// remove identity matrices
|
||||||
else if (xform.type == 1) {
|
else if (xform.type === 1) {
|
||||||
if (isIdentity(xform.matrix)) {
|
if (isIdentity(xform.matrix)) {
|
||||||
tlist.removeItem(k);
|
tlist.removeItem(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// remove zero-degree rotations
|
// remove zero-degree rotations
|
||||||
else if (xform.type == 4) {
|
else if (xform.type === 4) {
|
||||||
if (xform.angle == 0) {
|
if (xform.angle === 0) {
|
||||||
tlist.removeItem(k);
|
tlist.removeItem(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End here if all it has is a rotation
|
// End here if all it has is a rotation
|
||||||
if(tlist.numberOfItems == 1 && getRotationAngle(selected)) return null;
|
if(tlist.numberOfItems === 1 && getRotationAngle(selected)) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this element had no transforms, we are done
|
// if this element had no transforms, we are done
|
||||||
|
@ -3241,6 +3244,43 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
|
||||||
selected.removeAttribute("transform");
|
selected.removeAttribute("transform");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make this work for more than 2
|
||||||
|
if (tlist) {
|
||||||
|
var k = tlist.numberOfItems;
|
||||||
|
var mxs = [];
|
||||||
|
while (k--) {
|
||||||
|
var xform = tlist.getItem(k);
|
||||||
|
if (xform.type === 1) {
|
||||||
|
mxs.push([xform.matrix, k]);
|
||||||
|
} else if(mxs.length) {
|
||||||
|
mxs = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mxs.length === 2) {
|
||||||
|
var m_new = svgroot.createSVGTransformFromMatrix(matrixMultiply(mxs[1][0], mxs[0][0]));
|
||||||
|
tlist.removeItem(mxs[0][1]);
|
||||||
|
tlist.removeItem(mxs[1][1]);
|
||||||
|
tlist.insertItemBefore(m_new, mxs[1][1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// combine matrix + translate
|
||||||
|
k = tlist.numberOfItems;
|
||||||
|
|
||||||
|
if(k === 2 && tlist.getItem(0).type === 1 && tlist.getItem(1).type === 2) {
|
||||||
|
var mt = svgroot.createSVGTransform();
|
||||||
|
logMatrix(tlist.getItem(0).matrix);
|
||||||
|
logMatrix(transformListToTransform(tlist).matrix);
|
||||||
|
|
||||||
|
mt.setMatrix(transformListToTransform(tlist).matrix);
|
||||||
|
tlist.clear();
|
||||||
|
tlist.appendItem(mt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Grouped SVG element
|
// Grouped SVG element
|
||||||
var gsvg = $(selected).data('gsvg');
|
var gsvg = $(selected).data('gsvg');
|
||||||
|
@ -3503,7 +3543,7 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
|
||||||
if(child.getAttribute('clip-path')) {
|
if(child.getAttribute('clip-path')) {
|
||||||
// tx, ty
|
// tx, ty
|
||||||
var attr = child.getAttribute('clip-path');
|
var attr = child.getAttribute('clip-path');
|
||||||
if($.inArray(attr, clipPaths_done) === -1) {
|
if(clipPaths_done.indexOf(attr) === -1) {
|
||||||
updateClipPath(attr, tx, ty);
|
updateClipPath(attr, tx, ty);
|
||||||
clipPaths_done.push(attr);
|
clipPaths_done.push(attr);
|
||||||
}
|
}
|
||||||
|
@ -3902,9 +3942,6 @@ var isIdentity = function(m) {
|
||||||
return (m.a == 1 && m.b == 0 && m.c == 0 && m.d == 1 && m.e == 0 && m.f == 0);
|
return (m.a == 1 && m.b == 0 && m.c == 0 && m.d == 1 && m.e == 0 && m.f == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// matrixMultiply() is provided because WebKit didn't implement multiply() correctly
|
|
||||||
// on the SVGMatrix interface. See https://bugs.webkit.org/show_bug.cgi?id=16062
|
|
||||||
|
|
||||||
// Function: matrixMultiply
|
// Function: matrixMultiply
|
||||||
// This function tries to return a SVGMatrix that is the multiplication m1*m2.
|
// This function tries to return a SVGMatrix that is the multiplication m1*m2.
|
||||||
// We also round to zero when it's near zero
|
// We also round to zero when it's near zero
|
||||||
|
@ -3916,21 +3953,11 @@ var isIdentity = function(m) {
|
||||||
// The matrix object resulting from the calculation
|
// The matrix object resulting from the calculation
|
||||||
var matrixMultiply = this.matrixMultiply = function() {
|
var matrixMultiply = this.matrixMultiply = function() {
|
||||||
var NEAR_ZERO = 1e-14,
|
var NEAR_ZERO = 1e-14,
|
||||||
multi2 = function(m1, m2) {
|
|
||||||
var m = svgroot.createSVGMatrix();
|
|
||||||
m.a = m1.a*m2.a + m1.c*m2.b;
|
|
||||||
m.b = m1.b*m2.a + m1.d*m2.b,
|
|
||||||
m.c = m1.a*m2.c + m1.c*m2.d,
|
|
||||||
m.d = m1.b*m2.c + m1.d*m2.d,
|
|
||||||
m.e = m1.a*m2.e + m1.c*m2.f + m1.e,
|
|
||||||
m.f = m1.b*m2.e + m1.d*m2.f + m1.f;
|
|
||||||
return m;
|
|
||||||
},
|
|
||||||
args = arguments, i = args.length, m = args[i-1];
|
args = arguments, i = args.length, m = args[i-1];
|
||||||
|
|
||||||
while(i-- > 1) {
|
while(i-- > 1) {
|
||||||
var m1 = args[i-1];
|
var m1 = args[i-1];
|
||||||
m = multi2(m1, m);
|
m = m1.multiply(m);
|
||||||
}
|
}
|
||||||
if (Math.abs(m.a) < NEAR_ZERO) m.a = 0;
|
if (Math.abs(m.a) < NEAR_ZERO) m.a = 0;
|
||||||
if (Math.abs(m.b) < NEAR_ZERO) m.b = 0;
|
if (Math.abs(m.b) < NEAR_ZERO) m.b = 0;
|
||||||
|
@ -4170,8 +4197,7 @@ var removeFromSelection = this.removeFromSelection = function(elemsToRemove) {
|
||||||
if (elemsToRemove.length == 0) { return; }
|
if (elemsToRemove.length == 0) { return; }
|
||||||
|
|
||||||
// find every element and remove it from our array copy
|
// find every element and remove it from our array copy
|
||||||
var newSelectedItems = new Array(selectedElements.length),
|
var newSelectedItems = new Array(selectedElements.length);
|
||||||
newSelectedBBoxes = new Array(selectedBBoxes.length),
|
|
||||||
j = 0,
|
j = 0,
|
||||||
len = selectedElements.length;
|
len = selectedElements.length;
|
||||||
for (var i = 0; i < len; ++i) {
|
for (var i = 0; i < len; ++i) {
|
||||||
|
@ -4180,7 +4206,6 @@ var removeFromSelection = this.removeFromSelection = function(elemsToRemove) {
|
||||||
// keep the item
|
// keep the item
|
||||||
if (elemsToRemove.indexOf(elem) == -1) {
|
if (elemsToRemove.indexOf(elem) == -1) {
|
||||||
newSelectedItems[j] = elem;
|
newSelectedItems[j] = elem;
|
||||||
if (j==0) newSelectedBBoxes[j] = selectedBBoxes[i];
|
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
else { // remove the item and its selector
|
else { // remove the item and its selector
|
||||||
|
@ -4190,7 +4215,6 @@ var removeFromSelection = this.removeFromSelection = function(elemsToRemove) {
|
||||||
}
|
}
|
||||||
// the copy becomes the master now
|
// the copy becomes the master now
|
||||||
selectedElements = newSelectedItems;
|
selectedElements = newSelectedItems;
|
||||||
selectedBBoxes = newSelectedBBoxes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: selectAllInCurrentLayer
|
// Function: selectAllInCurrentLayer
|
||||||
|
@ -4273,7 +4297,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
||||||
|
|
||||||
// for foreign content, go up until we find the foreignObject
|
// for foreign content, go up until we find the foreignObject
|
||||||
// WebKit browsers set the mouse target to the svgcanvas div
|
// WebKit browsers set the mouse target to the svgcanvas div
|
||||||
if ($.inArray(mouse_target.namespaceURI, [mathns, htmlns]) != -1 &&
|
if ([mathns, htmlns].indexOf(mouse_target.namespaceURI) >= 0 &&
|
||||||
mouse_target.id != "svgcanvas")
|
mouse_target.id != "svgcanvas")
|
||||||
{
|
{
|
||||||
while (mouse_target.nodeName != "foreignObject") {
|
while (mouse_target.nodeName != "foreignObject") {
|
||||||
|
@ -4284,7 +4308,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
||||||
|
|
||||||
// Get the desired mouse_target with jQuery selector-fu
|
// Get the desired mouse_target with jQuery selector-fu
|
||||||
// If it's root-like, select the root
|
// If it's root-like, select the root
|
||||||
if($.inArray(mouse_target, [svgroot, container, svgcontent, current_layer]) !== -1) {
|
if([svgroot, container, svgcontent, current_layer].indexOf(mouse_target) >= 0) {
|
||||||
return svgroot;
|
return svgroot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4365,7 +4389,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This would seem to be unnecessary...
|
// This would seem to be unnecessary...
|
||||||
// if($.inArray(current_mode, ['select', 'resize']) == -1) {
|
// if(['select', 'resize'].indexOf(current_mode) == -1) {
|
||||||
// setGradient();
|
// setGradient();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -4830,13 +4854,13 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
||||||
sy = height ? (height+dy)/height : 1,
|
sy = height ? (height+dy)/height : 1,
|
||||||
sx = width ? (width+dx)/width : 1;
|
sx = width ? (width+dx)/width : 1;
|
||||||
// if we are dragging on the north side, then adjust the scale factor and ty
|
// if we are dragging on the north side, then adjust the scale factor and ty
|
||||||
if(current_resize_mode.indexOf("n") != -1) {
|
if(current_resize_mode.indexOf("n") >= 0) {
|
||||||
sy = height ? (height-dy)/height : 1;
|
sy = height ? (height-dy)/height : 1;
|
||||||
ty = height;
|
ty = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we dragging on the east side, then adjust the scale factor and tx
|
// if we dragging on the east side, then adjust the scale factor and tx
|
||||||
if(current_resize_mode.indexOf("w") != -1) {
|
if(current_resize_mode.indexOf("w") >= 0) {
|
||||||
sx = width ? (width-dx)/width : 1;
|
sx = width ? (width-dx)/width : 1;
|
||||||
tx = width;
|
tx = width;
|
||||||
}
|
}
|
||||||
|
@ -6442,7 +6466,7 @@ var pathActions = this.pathActions = function() {
|
||||||
var index = indexes[i];
|
var index = indexes[i];
|
||||||
var seg = p.segs[index];
|
var seg = p.segs[index];
|
||||||
if(seg.ptgrip) {
|
if(seg.ptgrip) {
|
||||||
if($.inArray(index, p.selected_pts) == -1 && index >= 0) {
|
if(p.selected_pts.indexOf(index) == -1 && index >= 0) {
|
||||||
p.selected_pts.push(index);
|
p.selected_pts.push(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6466,7 +6490,7 @@ var pathActions = this.pathActions = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removePtFromSelection = function(index) {
|
this.removePtFromSelection = function(index) {
|
||||||
var pos = $.inArray(index, p.selected_pts);
|
var pos = p.selected_pts.indexOf(index);
|
||||||
if(pos == -1) {
|
if(pos == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7691,7 +7715,7 @@ var removeUnusedDefElems = this.removeUnusedDefElems = function() {
|
||||||
while (i--) {
|
while (i--) {
|
||||||
var defelem = defelems[i];
|
var defelem = defelems[i];
|
||||||
var id = defelem.id;
|
var id = defelem.id;
|
||||||
if($.inArray(id, defelem_uses) == -1) {
|
if(defelem_uses.indexOf(id) == -1) {
|
||||||
// Not found, so remove
|
// Not found, so remove
|
||||||
defelem.parentNode.removeChild(defelem);
|
defelem.parentNode.removeChild(defelem);
|
||||||
numRemoved++;
|
numRemoved++;
|
||||||
|
@ -7723,7 +7747,7 @@ var svgCanvasToString = this.svgCanvasToString = function() {
|
||||||
|
|
||||||
// Keep SVG-Edit comment on top
|
// Keep SVG-Edit comment on top
|
||||||
$.each(svgcontent.childNodes, function(i, node) {
|
$.each(svgcontent.childNodes, function(i, node) {
|
||||||
if(i && node.nodeType == 8 && node.data.indexOf('Created with') != -1) {
|
if(i && node.nodeType == 8 && node.data.indexOf('Created with') >= 0) {
|
||||||
svgcontent.insertBefore(node, svgcontent.firstChild);
|
svgcontent.insertBefore(node, svgcontent.firstChild);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -7815,7 +7839,7 @@ var svgToString = this.svgToString = function(elem, indent) {
|
||||||
|
|
||||||
// only serialize attributes we don't use internally
|
// only serialize attributes we don't use internally
|
||||||
if (attrVal != "" &&
|
if (attrVal != "" &&
|
||||||
$.inArray(attr.localName, ['width','height','xmlns','x','y','viewBox','id','overflow']) == -1)
|
['width','height','xmlns','x','y','viewBox','id','overflow'].indexOf(attr.localName) == -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!attr.namespaceURI || nsMap[attr.namespaceURI]) {
|
if(!attr.namespaceURI || nsMap[attr.namespaceURI]) {
|
||||||
|
@ -7830,7 +7854,7 @@ var svgToString = this.svgToString = function(elem, indent) {
|
||||||
attr = attrs.item(i);
|
attr = attrs.item(i);
|
||||||
var attrVal = toXml(attr.nodeValue);
|
var attrVal = toXml(attr.nodeValue);
|
||||||
//remove bogus attributes added by Gecko
|
//remove bogus attributes added by Gecko
|
||||||
if ($.inArray(attr.localName, ['-moz-math-font-style', '_moz-math-font-style']) !== -1) continue;
|
if (['-moz-math-font-style', '_moz-math-font-style'].indexOf(attr.localName) >= 0) continue;
|
||||||
if (attrVal != "") {
|
if (attrVal != "") {
|
||||||
if(attrVal.indexOf('pointer-events') === 0) continue;
|
if(attrVal.indexOf('pointer-events') === 0) continue;
|
||||||
if(attr.localName === "class" && attrVal.indexOf('se_') === 0) continue;
|
if(attr.localName === "class" && attrVal.indexOf('se_') === 0) continue;
|
||||||
|
@ -8071,8 +8095,8 @@ var uniquifyElems = this.uniquifyElems = function(g) {
|
||||||
var href = getHref(n);
|
var href = getHref(n);
|
||||||
// TODO: what if an <image> or <a> element refers to an element internally?
|
// TODO: what if an <image> or <a> element refers to an element internally?
|
||||||
if(href &&
|
if(href &&
|
||||||
$.inArray(n.nodeName, ["filter", "linearGradient", "pattern",
|
["filter", "linearGradient", "pattern",
|
||||||
"radialGradient", "textPath", "use"]) != -1)
|
"radialGradient", "textPath", "use"].indexOf(n.nodeName) >= 0)
|
||||||
{
|
{
|
||||||
var refid = href.substr(1);
|
var refid = href.substr(1);
|
||||||
if (!(refid in ids)) {
|
if (!(refid in ids)) {
|
||||||
|
@ -8120,7 +8144,15 @@ var uniquifyElems = this.uniquifyElems = function(g) {
|
||||||
// Function convertGradients
|
// Function convertGradients
|
||||||
// Converts gradients from userSpaceOnUse to objectBoundingBox
|
// Converts gradients from userSpaceOnUse to objectBoundingBox
|
||||||
var convertGradients = this.convertGradients = function(elem) {
|
var convertGradients = this.convertGradients = function(elem) {
|
||||||
$(elem).find('linearGradient, radialGradient').each(function() {
|
var elems = $(elem).find('linearGradient, radialGradient');
|
||||||
|
if(!elems.length && isWebkit) {
|
||||||
|
// Bug in webkit prevents regular *Gradient selector search
|
||||||
|
elems = $(elem).find('*').filter(function() {
|
||||||
|
return (this.tagName.indexOf('Gradient') >= 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
elems.each(function() {
|
||||||
var grad = this;
|
var grad = this;
|
||||||
if($(grad).attr('gradientUnits') === 'userSpaceOnUse') {
|
if($(grad).attr('gradientUnits') === 'userSpaceOnUse') {
|
||||||
// TODO: Support more than one element with this ref by duplicating parent grad
|
// TODO: Support more than one element with this ref by duplicating parent grad
|
||||||
|
@ -8128,7 +8160,7 @@ var convertGradients = this.convertGradients = function(elem) {
|
||||||
if(!elems.length) return;
|
if(!elems.length) return;
|
||||||
|
|
||||||
// get object's bounding box
|
// get object's bounding box
|
||||||
var bb = elems[0].getBBox();
|
var bb = getBBox(elems[0]);
|
||||||
|
|
||||||
if(grad.tagName === 'linearGradient') {
|
if(grad.tagName === 'linearGradient') {
|
||||||
var g_coords = $(grad).attr(['x1', 'y1', 'x2', 'y2']);
|
var g_coords = $(grad).attr(['x1', 'y1', 'x2', 'y2']);
|
||||||
|
@ -8199,9 +8231,14 @@ var convertToGroup = this.convertToGroup = function(elem) {
|
||||||
|
|
||||||
ts = $elem.attr('transform');
|
ts = $elem.attr('transform');
|
||||||
var pos = $elem.attr(['x','y']);
|
var pos = $elem.attr(['x','y']);
|
||||||
|
|
||||||
|
// if(ts.length) {
|
||||||
|
//
|
||||||
|
// ts += " ";
|
||||||
|
// }
|
||||||
|
|
||||||
// Not ideal, but works
|
// Not ideal, but works
|
||||||
ts += "translate(" + pos.x + "," + pos.y + ")";
|
ts += "translate(" + (pos.x || 0) + "," + (pos.x || 0) + ")";
|
||||||
|
|
||||||
var prev = $elem.prev();
|
var prev = $elem.prev();
|
||||||
|
|
||||||
|
@ -8223,6 +8260,7 @@ var convertToGroup = this.convertToGroup = function(elem) {
|
||||||
// g.appendChild(elem.firstChild.cloneNode(true));
|
// g.appendChild(elem.firstChild.cloneNode(true));
|
||||||
if (ts)
|
if (ts)
|
||||||
g.setAttribute("transform", ts);
|
g.setAttribute("transform", ts);
|
||||||
|
console.log('t',g.getAttribute('transform'));
|
||||||
|
|
||||||
var parent = elem.parentNode;
|
var parent = elem.parentNode;
|
||||||
|
|
||||||
|
@ -8241,6 +8279,7 @@ var convertToGroup = this.convertToGroup = function(elem) {
|
||||||
}
|
}
|
||||||
batchCmd.addSubCommand(new InsertElementCommand(g));
|
batchCmd.addSubCommand(new InsertElementCommand(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
convertGradients(g);
|
convertGradients(g);
|
||||||
|
|
||||||
// recalculate dimensions on the top-level children so that unnecessary transforms
|
// recalculate dimensions on the top-level children so that unnecessary transforms
|
||||||
|
@ -8258,7 +8297,7 @@ var convertToGroup = this.convertToGroup = function(elem) {
|
||||||
// TODO: See what ungroupSelectedElement does to absorb matrix
|
// TODO: See what ungroupSelectedElement does to absorb matrix
|
||||||
canvas.ungroupSelectedElement();
|
canvas.ungroupSelectedElement();
|
||||||
canvas.groupSelectedElements();
|
canvas.groupSelectedElements();
|
||||||
|
//
|
||||||
addCommandToHistory(batchCmd);
|
addCommandToHistory(batchCmd);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -8340,6 +8379,12 @@ this.setSvgString = function(xmlString) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// For Firefox: Put all gradients in defs
|
||||||
|
if(isGecko) {
|
||||||
|
content.find('linearGradient, radialGradient').appendTo(findDefs());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set ref element for <use> elements
|
// Set ref element for <use> elements
|
||||||
|
|
||||||
// TODO: This should also be done if the object is re-added through "redo"
|
// TODO: This should also be done if the object is re-added through "redo"
|
||||||
|
@ -8489,16 +8534,23 @@ this.importSvgString = function(xmlString) {
|
||||||
|
|
||||||
// Uncomment this once Firefox has fixed their symbol bug:
|
// Uncomment this once Firefox has fixed their symbol bug:
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=353575
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=353575
|
||||||
// var symbol = svgdoc.createElementNS(svgns, "symbol");
|
var symbol = svgdoc.createElementNS(svgns, "symbol");
|
||||||
// while (svg.firstChild) {
|
var defs = findDefs();
|
||||||
// symbol.appendChild(svg.firstChild);
|
|
||||||
// }
|
while (svg.firstChild) {
|
||||||
// var attrs = svg.attributes;
|
var first = svg.firstChild;
|
||||||
// for(var i=0; i < attrs.length; i++) {
|
if(isGecko && first.tagName === 'defs') {
|
||||||
// var attr = attrs[i];
|
// Move all gradients into root for Firefox
|
||||||
// symbol.setAttribute(attr.nodeName, attr.nodeValue);
|
$(first).find('linearGradient, radialGradient').appendTo(defs);
|
||||||
// }
|
}
|
||||||
var symbol = svg;
|
symbol.appendChild(first);
|
||||||
|
}
|
||||||
|
var attrs = svg.attributes;
|
||||||
|
for(var i=0; i < attrs.length; i++) {
|
||||||
|
var attr = attrs[i];
|
||||||
|
symbol.setAttribute(attr.nodeName, attr.nodeValue);
|
||||||
|
}
|
||||||
|
// var symbol = svg;
|
||||||
symbol.id = getNextId();
|
symbol.id = getNextId();
|
||||||
|
|
||||||
var use_el = svgdoc.createElementNS(svgns, "use");
|
var use_el = svgdoc.createElementNS(svgns, "use");
|
||||||
|
@ -8577,7 +8629,7 @@ var identifyLayers = function() {
|
||||||
// create a new layer and add all the orphans to it
|
// create a new layer and add all the orphans to it
|
||||||
if (orphans.length > 0) {
|
if (orphans.length > 0) {
|
||||||
var i = 1;
|
var i = 1;
|
||||||
while ($.inArray(("Layer " + i), layernames) != -1) { i++; }
|
while (layernames.indexOf(("Layer " + i)) >= 0) { i++; }
|
||||||
var newname = "Layer " + i;
|
var newname = "Layer " + i;
|
||||||
current_layer = svgdoc.createElementNS(svgns, "g");
|
current_layer = svgdoc.createElementNS(svgns, "g");
|
||||||
var layer_title = svgdoc.createElementNS(svgns, "title");
|
var layer_title = svgdoc.createElementNS(svgns, "title");
|
||||||
|
@ -9136,7 +9188,7 @@ this.getZoom = function(){return current_zoom;};
|
||||||
// Function: getVersion
|
// Function: getVersion
|
||||||
// Returns a string which describes the revision number of SvgCanvas.
|
// Returns a string which describes the revision number of SvgCanvas.
|
||||||
this.getVersion = function() {
|
this.getVersion = function() {
|
||||||
return "svgcanvas.js ($Rev: 1764 $)";
|
return "svgcanvas.js ($Rev: 1775 $)";
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: setUiStrings
|
// Function: setUiStrings
|
||||||
|
@ -9657,7 +9709,7 @@ this.getStrokeWidth = function() {
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// val - A Float indicating the new stroke width value
|
// val - A Float indicating the new stroke width value
|
||||||
this.setStrokeWidth = function(val) {
|
this.setStrokeWidth = function(val) {
|
||||||
if(val == 0 && $.inArray(current_mode, ['line', 'path']) != -1) {
|
if(val == 0 && ['line', 'path'].indexOf(current_mode) >= 0) {
|
||||||
canvas.setStrokeWidth(1);
|
canvas.setStrokeWidth(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -10313,7 +10365,7 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set x,y vals on elements that don't have them
|
// Set x,y vals on elements that don't have them
|
||||||
if((attr == 'x' || attr == 'y') && $.inArray(elem.tagName, ['g', 'polyline', 'path']) != -1) {
|
if((attr == 'x' || attr == 'y') && ['g', 'polyline', 'path'].indexOf(elem.tagName) >= 0) {
|
||||||
var bbox = getStrokedBBox([elem]);
|
var bbox = getStrokedBBox([elem]);
|
||||||
var diff_x = attr == 'x' ? newValue - bbox.x : 0;
|
var diff_x = attr == 'x' ? newValue - bbox.x : 0;
|
||||||
var diff_y = attr == 'y' ? newValue - bbox.y : 0;
|
var diff_y = attr == 'y' ? newValue - bbox.y : 0;
|
||||||
|
@ -10322,7 +10374,7 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// only allow the transform/opacity attribute to change on <g> elements, slightly hacky
|
// only allow the transform/opacity attribute to change on <g> elements, slightly hacky
|
||||||
if (elem.tagName == "g" && $.inArray(attr, ['transform', 'opacity', 'filter']) !== -1);
|
if (elem.tagName == "g" && ['transform', 'opacity', 'filter'].indexOf(attr) >= 0);
|
||||||
var oldval = attr == "#text" ? elem.textContent : elem.getAttribute(attr);
|
var oldval = attr == "#text" ? elem.textContent : elem.getAttribute(attr);
|
||||||
if (oldval == null) oldval = "";
|
if (oldval == null) oldval = "";
|
||||||
if (oldval != String(newValue)) {
|
if (oldval != String(newValue)) {
|
||||||
|
@ -10356,7 +10408,7 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) {
|
||||||
// Use the Firefox ffClone hack for text elements with gradients or
|
// Use the Firefox ffClone hack for text elements with gradients or
|
||||||
// where other text attributes are changed.
|
// where other text attributes are changed.
|
||||||
if(elem.nodeName == 'text') {
|
if(elem.nodeName == 'text') {
|
||||||
if((newValue+'').indexOf('url') == 0 || $.inArray(attr, ['font-size','font-family','x','y']) != -1 && elem.textContent) {
|
if((newValue+'').indexOf('url') == 0 || ['font-size','font-family','x','y'].indexOf(attr) >= 0 && elem.textContent) {
|
||||||
elem = ffClone(elem);
|
elem = ffClone(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10364,7 +10416,7 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) {
|
||||||
// codedread: it is now possible for this function to be called with elements
|
// codedread: it is now possible for this function to be called with elements
|
||||||
// that are not in the selectedElements array, we need to only request a
|
// that are not in the selectedElements array, we need to only request a
|
||||||
// selector if the element is in that array
|
// selector if the element is in that array
|
||||||
if ($.inArray(elem, selectedElements) != -1) {
|
if (selectedElements.indexOf(elem) >= 0) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// Due to element replacement, this element may no longer
|
// Due to element replacement, this element may no longer
|
||||||
// be part of the DOM
|
// be part of the DOM
|
||||||
|
@ -10566,6 +10618,12 @@ this.ungroupSelectedElement = function() {
|
||||||
if($(g).data('gsvg') || $(g).data('symbol')) {
|
if($(g).data('gsvg') || $(g).data('symbol')) {
|
||||||
// Is svg, so actually convert to group
|
// Is svg, so actually convert to group
|
||||||
|
|
||||||
|
convertToGroup(g);
|
||||||
|
return;
|
||||||
|
} else if(g.tagName === 'use') {
|
||||||
|
// Somehow doesn't have data set, so retrieve
|
||||||
|
var symbol = getElem(getHref(g).substr(1));
|
||||||
|
$(g).data('symbol', symbol);
|
||||||
convertToGroup(g);
|
convertToGroup(g);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,6 @@ $(function() {
|
||||||
elems = $(svgdoc.firstChild).children(); //.getElementsByTagName('foreignContent');
|
elems = $(svgdoc.firstChild).children(); //.getElementsByTagName('foreignContent');
|
||||||
|
|
||||||
if(!opts.no_img) {
|
if(!opts.no_img) {
|
||||||
|
|
||||||
var testSrc = data_pre + 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';
|
var testSrc = data_pre + 'PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';
|
||||||
|
|
||||||
testImg = $(new Image()).attr({
|
testImg = $(new Image()).attr({
|
||||||
|
@ -222,7 +221,7 @@ $(function() {
|
||||||
}).appendTo('body')
|
}).appendTo('body')
|
||||||
.load(function () {
|
.load(function () {
|
||||||
// Safari 4 crashes, Opera and Chrome don't
|
// Safari 4 crashes, Opera and Chrome don't
|
||||||
makeIcons(!isSafari);
|
makeIcons(true);
|
||||||
}).error(function () {
|
}).error(function () {
|
||||||
makeIcons();
|
makeIcons();
|
||||||
});
|
});
|
||||||
|
|
|
@ -142,6 +142,7 @@ class WikiControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# Tempfile doesn't know how to open files with binary flag, hence the two-step process
|
# Tempfile doesn't know how to open files with binary flag, hence the two-step process
|
||||||
Tempfile.open('instiki_export_file') { |f| @tempfile_path = f.path }
|
Tempfile.open('instiki_export_file') { |f| @tempfile_path = f.path }
|
||||||
|
# some wacky bug in Ruby 1.9.2p0's Tempfile is fixed by
|
||||||
@tempfile_path.to_s
|
@tempfile_path.to_s
|
||||||
begin
|
begin
|
||||||
File.open(@tempfile_path, 'wb') { |f| f.write(r.body); @exported_file = f.path }
|
File.open(@tempfile_path, 'wb') { |f| f.write(r.body); @exported_file = f.path }
|
||||||
|
|
Loading…
Reference in a new issue