re-enabling drag and drop import

master
Mark MacKay 2012-10-25 20:30:58 -05:00
parent 81d984bf6f
commit 19b706bbfa
5 changed files with 944 additions and 942 deletions

View File

@ -3625,42 +3625,41 @@
//image handling
else {
alert("sorry, bitmap import is temporalily disabled")
//var reader = new FileReader();
//reader.onloadend = function(e) {
// // lets insert the new image until we know its dimensions
// insertNewImage = function(img_width, img_height){
// var newImage = svgCanvas.addSvgElementFromJson({
// "element": "image",
// "attr": {
// "x": 0,
// "y": 0,
// "width": img_width,
// "height": img_height,
// "id": svgCanvas.getNextId(),
// "style": "pointer-events:inherit"
// }
// });
// svgCanvas.setHref(newImage, e.target.result);
// svgCanvas.selectOnly([newImage])
// svgCanvas.alignSelectedElements("m", "page")
// svgCanvas.alignSelectedElements("c", "page")
// updateContextPanel();
// }
// // put a placeholder img so we know the default dimensions
// var img_width = 100;
// var img_height = 100;
// var img = new Image()
// img.src = e.target.result
// document.body.appendChild(img);
// img.onload = function() {
// img_width = img.offsetWidth
// img_height = img.offsetHeight
// insertNewImage(img_width, img_height);
// document.body.removeChild(img);
// }
//};
//reader.readAsDataURL(file)
var reader = new FileReader();
reader.onloadend = function(e) {
// lets insert the new image until we know its dimensions
insertNewImage = function(img_width, img_height){
var newImage = svgCanvas.addSvgElementFromJson({
"element": "image",
"attr": {
"x": 0,
"y": 0,
"width": img_width,
"height": img_height,
"id": svgCanvas.getNextId(),
"style": "pointer-events:inherit"
}
});
svgCanvas.setHref(newImage, e.target.result);
svgCanvas.selectOnly([newImage])
svgCanvas.alignSelectedElements("m", "page")
svgCanvas.alignSelectedElements("c", "page")
updateContextPanel();
}
// put a placeholder img so we know the default dimensions
var img_width = 100;
var img_height = 100;
var img = new Image()
img.src = e.target.result
document.body.appendChild(img);
img.onload = function() {
img_width = img.offsetWidth
img_height = img.offsetHeight
insertNewImage(img_width, img_height);
document.body.removeChild(img);
}
};
reader.readAsDataURL(file)
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -388,10 +388,12 @@
<label id="seg_type_label">Straight</label>
</div>
<!--
<label class="draginput checkbox" data-title="Link Control Points">
<span>Linked Control Points</span>
<div class="push_bottom"><input type="checkbox" id="tool_node_link" checked="checked" /></div>
</label>
-->
<div class="clearfix"></div>
<div class="tool_button" id="tool_node_clone" title="Adds a node">Add Node</div>

View File

@ -3625,42 +3625,41 @@
//image handling
else {
alert("sorry, bitmap import is temporalily disabled")
//var reader = new FileReader();
//reader.onloadend = function(e) {
// // lets insert the new image until we know its dimensions
// insertNewImage = function(img_width, img_height){
// var newImage = svgCanvas.addSvgElementFromJson({
// "element": "image",
// "attr": {
// "x": 0,
// "y": 0,
// "width": img_width,
// "height": img_height,
// "id": svgCanvas.getNextId(),
// "style": "pointer-events:inherit"
// }
// });
// svgCanvas.setHref(newImage, e.target.result);
// svgCanvas.selectOnly([newImage])
// svgCanvas.alignSelectedElements("m", "page")
// svgCanvas.alignSelectedElements("c", "page")
// updateContextPanel();
// }
// // put a placeholder img so we know the default dimensions
// var img_width = 100;
// var img_height = 100;
// var img = new Image()
// img.src = e.target.result
// document.body.appendChild(img);
// img.onload = function() {
// img_width = img.offsetWidth
// img_height = img.offsetHeight
// insertNewImage(img_width, img_height);
// document.body.removeChild(img);
// }
//};
//reader.readAsDataURL(file)
var reader = new FileReader();
reader.onloadend = function(e) {
// lets insert the new image until we know its dimensions
insertNewImage = function(img_width, img_height){
var newImage = svgCanvas.addSvgElementFromJson({
"element": "image",
"attr": {
"x": 0,
"y": 0,
"width": img_width,
"height": img_height,
"id": svgCanvas.getNextId(),
"style": "pointer-events:inherit"
}
});
svgCanvas.setHref(newImage, e.target.result);
svgCanvas.selectOnly([newImage])
svgCanvas.alignSelectedElements("m", "page")
svgCanvas.alignSelectedElements("c", "page")
updateContextPanel();
}
// put a placeholder img so we know the default dimensions
var img_width = 100;
var img_height = 100;
var img = new Image()
img.src = e.target.result
document.body.appendChild(img);
img.onload = function() {
img_width = img.offsetWidth
img_height = img.offsetHeight
insertNewImage(img_width, img_height);
document.body.removeChild(img);
}
};
reader.readAsDataURL(file)
}
}
}

File diff suppressed because it is too large Load Diff