Fixed bug where selectedChanged and elementChanged were called too often
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1575 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
2513923d61
commit
4c0148a684
|
@ -1070,10 +1070,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 +1385,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 +1559,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 +1690,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 +1796,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 +2284,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 +2699,6 @@
|
|||
shower.toggleClass('disabled', !has_enabled);
|
||||
});
|
||||
|
||||
|
||||
operaRepaint();
|
||||
};
|
||||
|
||||
|
|
|
@ -2609,7 +2609,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) {
|
||||
|
@ -2620,7 +2620,7 @@ function BatchCommand(text) {
|
|||
}
|
||||
selectedBBoxes[0] = null;
|
||||
}
|
||||
call("selected", selectedElements);
|
||||
if(!noCall) call("selected", selectedElements);
|
||||
};
|
||||
|
||||
// TODO: do we need to worry about selectedBBoxes here?
|
||||
|
@ -3012,7 +3012,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;
|
||||
|
@ -3296,8 +3297,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
|
||||
|
@ -3640,7 +3641,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();
|
||||
|
@ -4187,10 +4190,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 {
|
||||
|
@ -4225,6 +4233,10 @@ function BatchCommand(text) {
|
|||
$(textinput).blur();
|
||||
|
||||
curtext = false;
|
||||
|
||||
// if(support.editableText) {
|
||||
// curtext.removeAttribute('editable');
|
||||
// }
|
||||
},
|
||||
setInputElem: function(elem) {
|
||||
textinput = elem;
|
||||
|
@ -4237,13 +4249,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;
|
||||
|
||||
|
@ -9170,6 +9187,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 New Issue