Minor: Spacing
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2825 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<script src="embedapi.js"></script>
|
<script src="embedapi.js"></script>
|
||||||
<script>
|
<script>
|
||||||
/*globals $, EmbeddedSVGEdit*/
|
/*globals $, EmbeddedSVGEdit*/
|
||||||
var initEmbed;
|
var initEmbed;
|
||||||
$(function () {'use strict';
|
$(function () {'use strict';
|
||||||
|
|
||||||
var svgCanvas = null;
|
var svgCanvas = null;
|
||||||
@@ -39,32 +39,32 @@
|
|||||||
svgCanvas.getSvgString()(handleSvgData);
|
svgCanvas.getSvgString()(handleSvgData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportSvg() {
|
function exportSvg() {
|
||||||
var str = document.getElementById('svgedit').contentWindow.svgEditor.uiStrings.notification.loadingImage;
|
var str = document.getElementById('svgedit').contentWindow.svgEditor.uiStrings.notification.loadingImage;
|
||||||
var exportWindow = window.open(
|
var exportWindow = window.open(
|
||||||
'data:text/html;charset=utf-8,' + encodeURIComponent('<title>' + str + '</title><h1>' + str + '</h1>'),
|
'data:text/html;charset=utf-8,' + encodeURIComponent('<title>' + str + '</title><h1>' + str + '</h1>'),
|
||||||
'svg-edit-exportWindow'
|
'svg-edit-exportWindow'
|
||||||
);
|
);
|
||||||
svgCanvas.rasterExport('PNG', null, exportWindow.name);
|
svgCanvas.rasterExport('PNG', null, exportWindow.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add event handlers
|
// Add event handlers
|
||||||
$('#load').click(loadSvg);
|
$('#load').click(loadSvg);
|
||||||
$('#save').click(saveSvg);
|
$('#save').click(saveSvg);
|
||||||
$('#export').click(exportSvg);
|
$('#export').click(exportSvg);
|
||||||
$('body').append(
|
$('body').append(
|
||||||
$('<iframe src="svg-editor.html?extensions=ext-xdomain-messaging.js' +
|
$('<iframe src="svg-editor.html?extensions=ext-xdomain-messaging.js' +
|
||||||
window.location.href.replace(/\?(.*)$/, '&$1') + // Append arguments to this file onto the iframe
|
window.location.href.replace(/\?(.*)$/, '&$1') + // Append arguments to this file onto the iframe
|
||||||
'" width="900px" height="600px" id="svgedit" onload="initEmbed();"></iframe>'
|
'" width="900px" height="600px" id="svgedit" onload="initEmbed();"></iframe>'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button id="load">Load example</button>
|
<button id="load">Load example</button>
|
||||||
<button id="save">Save data</button>
|
<button id="save">Save data</button>
|
||||||
<button id="export">Export data</button>
|
<button id="export">Export data</button>
|
||||||
<br/>
|
<br/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ svgCanvas.setSvgString('string')
|
|||||||
- Or if a callback is needed:
|
- Or if a callback is needed:
|
||||||
svgCanvas.setSvgString('string')(function(data, error){
|
svgCanvas.setSvgString('string')(function(data, error){
|
||||||
if (error){
|
if (error){
|
||||||
// There was an error
|
// There was an error
|
||||||
} else{
|
} else{
|
||||||
// Handle data
|
// Handle data
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -41,13 +41,13 @@ var cbid = 0;
|
|||||||
|
|
||||||
function getCallbackSetter (d) {
|
function getCallbackSetter (d) {
|
||||||
return function () {
|
return function () {
|
||||||
var t = this, // New callback
|
var t = this, // New callback
|
||||||
args = [].slice.call(arguments),
|
args = [].slice.call(arguments),
|
||||||
cbid = t.send(d, args, function(){}); // The callback (currently it's nothing, but will be set later)
|
cbid = t.send(d, args, function(){}); // The callback (currently it's nothing, but will be set later)
|
||||||
|
|
||||||
return function(newcallback){
|
return function(newcallback){
|
||||||
t.callbacks[cbid] = newcallback; // Set callback
|
t.callbacks[cbid] = newcallback; // Set callback
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,11 +60,11 @@ function addCallback (t, data) {
|
|||||||
var result = data.result || data.error,
|
var result = data.result || data.error,
|
||||||
cbid = data.id;
|
cbid = data.id;
|
||||||
if (t.callbacks[cbid]) {
|
if (t.callbacks[cbid]) {
|
||||||
if (data.result) {
|
if (data.result) {
|
||||||
t.callbacks[cbid](result);
|
t.callbacks[cbid](result);
|
||||||
} else {
|
} else {
|
||||||
t.callbacks[cbid](result, 'error');
|
t.callbacks[cbid](result, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,15 +72,15 @@ function messageListener (e) {
|
|||||||
// We accept and post strings as opposed to objects for the sake of IE9 support; this
|
// We accept and post strings as opposed to objects for the sake of IE9 support; this
|
||||||
// will most likely be changed in the future
|
// will most likely be changed in the future
|
||||||
if (typeof e.data !== 'string') {
|
if (typeof e.data !== 'string') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var allowedOrigins = this.allowedOrigins,
|
var allowedOrigins = this.allowedOrigins,
|
||||||
data = e.data && JSON.parse(e.data);
|
data = e.data && JSON.parse(e.data);
|
||||||
if (!data || typeof data !== 'object' || data.namespace !== 'svg-edit' ||
|
if (!data || typeof data !== 'object' || data.namespace !== 'svg-edit' ||
|
||||||
e.source !== this.frame.contentWindow ||
|
e.source !== this.frame.contentWindow ||
|
||||||
(allowedOrigins.indexOf('*') === -1 && allowedOrigins.indexOf(e.origin) === -1)
|
(allowedOrigins.indexOf('*') === -1 && allowedOrigins.indexOf(e.origin) === -1)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addCallback(this, data);
|
addCallback(this, data);
|
||||||
}
|
}
|
||||||
@@ -94,12 +94,12 @@ function getMessageListener (t) {
|
|||||||
/**
|
/**
|
||||||
* @param {HTMLIFrameElement} frame
|
* @param {HTMLIFrameElement} frame
|
||||||
* @param {array} [allowedOrigins=[]] Array of origins from which incoming
|
* @param {array} [allowedOrigins=[]] Array of origins from which incoming
|
||||||
* messages will be allowed when same origin is not used; defaults to none.
|
* messages will be allowed when same origin is not used; defaults to none.
|
||||||
* If supplied, it should probably be the same as svgEditor's allowedOrigins
|
* If supplied, it should probably be the same as svgEditor's allowedOrigins
|
||||||
*/
|
*/
|
||||||
function EmbeddedSVGEdit (frame, allowedOrigins) {
|
function EmbeddedSVGEdit (frame, allowedOrigins) {
|
||||||
if (!(this instanceof EmbeddedSVGEdit)) { // Allow invocation without 'new' keyword
|
if (!(this instanceof EmbeddedSVGEdit)) { // Allow invocation without 'new' keyword
|
||||||
return new EmbeddedSVGEdit(frame);
|
return new EmbeddedSVGEdit(frame);
|
||||||
}
|
}
|
||||||
this.allowedOrigins = allowedOrigins || [];
|
this.allowedOrigins = allowedOrigins || [];
|
||||||
// Initialize communication
|
// Initialize communication
|
||||||
@@ -125,7 +125,7 @@ function EmbeddedSVGEdit (frame, allowedOrigins) {
|
|||||||
|
|
||||||
// TODO: rewrite the following, it's pretty scary.
|
// TODO: rewrite the following, it's pretty scary.
|
||||||
for (i = 0; i < functions.length; i++) {
|
for (i = 0; i < functions.length; i++) {
|
||||||
this[functions[i]] = getCallbackSetter(functions[i]);
|
this[functions[i]] = getCallbackSetter(functions[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Older IE may need a polyfill for addEventListener, but so it would for SVG
|
// Older IE may need a polyfill for addEventListener, but so it would for SVG
|
||||||
|
|||||||
@@ -990,18 +990,18 @@ PubSub implementation
|
|||||||
// @TODO: Add different output options
|
// @TODO: Add different output options
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case 'pt': k = 1; break;
|
case 'pt': k = 1; break;
|
||||||
case 'mm': k = 72 / 25.4; break;
|
case 'mm': k = 72 / 25.4; break;
|
||||||
case 'cm': k = 72 / 2.54; break;
|
case 'cm': k = 72 / 2.54; break;
|
||||||
case 'in': k = 72; break;
|
case 'in': k = 72; break;
|
||||||
case 'px': k = 96 / 72; break;
|
case 'px': k = 96 / 72; break;
|
||||||
case 'pc': k = 12; break;
|
case 'pc': k = 12; break;
|
||||||
case 'em': k = 12; break;
|
case 'em': k = 12; break;
|
||||||
case 'ex': k = 6; break;
|
case 'ex': k = 6; break;
|
||||||
default:
|
default:
|
||||||
throw ('Invalid unit: ' + unit);
|
throw ('Invalid unit: ' + unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dimensions are stored as user units and converted to points on output
|
// Dimensions are stored as user units and converted to points on output
|
||||||
if (pageFormats.hasOwnProperty(format_as_string)) {
|
if (pageFormats.hasOwnProperty(format_as_string)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user