Added keyboard shortcut option for extension buttons, made import of connectors work, fixed issue 442
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1286 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
ee393cd933
commit
363eef5d57
|
@ -1,6 +1,5 @@
|
|||
$(function() {
|
||||
svgCanvas.addExtension("Connector", function(vars) {
|
||||
|
||||
var svgcontent = vars.content,
|
||||
svgroot = vars.root,
|
||||
getNextId = vars.getNextId,
|
||||
|
@ -144,6 +143,7 @@ $(function() {
|
|||
type: "mode",
|
||||
icon: "images/cut.png",
|
||||
title: "Connect two objects",
|
||||
key: "L",
|
||||
events: {
|
||||
'click': function() {
|
||||
svgCanvas.setMode("connector");
|
||||
|
@ -198,7 +198,6 @@ $(function() {
|
|||
var i = elems.length;
|
||||
var connectors = $(svgcontent).find("." + conn_class);
|
||||
if(!connectors.length) return;
|
||||
|
||||
connections = [];
|
||||
|
||||
while(i--) {
|
||||
|
@ -349,6 +348,14 @@ $(function() {
|
|||
showPanel(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
elementChanged: function(opts) {
|
||||
var elem = opts.elems[0];
|
||||
if (elem && elem.tagName == 'svg' && elem.id == "svgcontent") {
|
||||
// Update svgcontent (can change on import)
|
||||
svgcontent = elem;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<script type="text/javascript" src="locale/locale.js"></script>
|
||||
<script type="text/javascript" src="svgcanvas.js"></script>
|
||||
<script type="text/javascript" src="svg-editor.js"></script>
|
||||
<!-- <script type="text/javascript" src="ext-connector.js"></script> -->
|
||||
<script type="text/javascript" src="ext-connector.js"></script>
|
||||
|
||||
<!-- Release version of script tags: >
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
|
||||
|
|
|
@ -235,6 +235,10 @@ function svg_edit_setup() {
|
|||
// we tell it to skip focusing the text control if the
|
||||
// text element was previously in focus
|
||||
updateContextPanel();
|
||||
|
||||
svgCanvas.runExtensions("elementChanged", {
|
||||
elems: elems
|
||||
});
|
||||
};
|
||||
|
||||
var zoomChanged = function(window, bbox, autoCenter) {
|
||||
|
@ -307,6 +311,24 @@ function svg_edit_setup() {
|
|||
|
||||
// Add given events to button
|
||||
$.each(btn.events, function(name, func) {
|
||||
if(name == "click") {
|
||||
if(btn.type == 'mode') {
|
||||
var new_func = function() {
|
||||
if (toolButtonClick('#' + id)) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
button.bind(name, new_func);
|
||||
if(btn.key) {
|
||||
$(document).bind('keydown', {combi: btn.key}, new_func);
|
||||
if(btn.title) button.attr("title", btn.title + ' ['+btn.key+']');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
button.bind(name, func);
|
||||
}
|
||||
|
||||
button.bind(name, function() {
|
||||
if(name == "click" && btn.type == 'mode') {
|
||||
if (toolButtonClick('#' + id)) {
|
||||
|
|
|
@ -78,7 +78,8 @@ var isOpera = !!window.opera,
|
|||
return $('<p/>').html(str).text();
|
||||
};
|
||||
|
||||
|
||||
var unit_types = {'em':0,'ex':0,'px':1,'cm':35.43307,'mm':3.543307,'in':90,'pt':1.25,'pc':15,'%':0};
|
||||
|
||||
// These command objects are used for the Undo/Redo stack
|
||||
// attrs contains the values that the attributes had before the change
|
||||
function ChangeElementCommand(elem, attrs, text) {
|
||||
|
@ -4432,6 +4433,7 @@ function BatchCommand(text) {
|
|||
current_mode = "select";
|
||||
removeAllPointGripsFromPath();
|
||||
canvas.clearSelection();
|
||||
pathActions.clear();
|
||||
if(selPath) {
|
||||
call("selected", [elem]);
|
||||
canvas.addToSelection([elem], true);
|
||||
|
@ -7248,6 +7250,16 @@ function BatchCommand(text) {
|
|||
rect.setAttribute('x',.1);
|
||||
var crect = rect.cloneNode(false);
|
||||
support.goodDecimals = (crect.getAttribute('x').indexOf(',') == -1);
|
||||
|
||||
// Get correct em/ex values
|
||||
var rect = document.createElementNS(svgns,'rect');
|
||||
rect.setAttribute('width',"1em");
|
||||
rect.setAttribute('height',"1ex");
|
||||
svgcontent.appendChild(rect);
|
||||
var bb = rect.getBBox();
|
||||
unit_types.em = bb.width;
|
||||
unit_types.ex = bb.height;
|
||||
svgcontent.removeChild(rect);
|
||||
}());
|
||||
}
|
||||
// Static class for various utility functions
|
||||
|
|
Loading…
Reference in New Issue