Abstract conditional script loading and allow jsPDF to load as needed (as with canvg); update jsPDF
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2847 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -25,10 +25,6 @@
|
|||||||
<script src="spinbtn/JQuerySpinBtn.min.js"></script>
|
<script src="spinbtn/JQuerySpinBtn.min.js"></script>
|
||||||
<script src="touch.js"></script>
|
<script src="touch.js"></script>
|
||||||
|
|
||||||
<script src="jspdf/underscore-min.js"></script>
|
|
||||||
<script src="jspdf/jspdf.js"></script>
|
|
||||||
<script src="jspdf/jspdf.plugin.svgToPdf.js"></script>
|
|
||||||
|
|
||||||
<!--{if svg_edit_release}>
|
<!--{if svg_edit_release}>
|
||||||
<script src="svgedit.compiled.js"></script>
|
<script src="svgedit.compiled.js"></script>
|
||||||
<!{else}-->
|
<!{else}-->
|
||||||
|
|||||||
@@ -202,19 +202,37 @@ var saveAs;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCanvg (callCanvg) {
|
/**
|
||||||
return function (win, data) {
|
* @param {string} globalCheck A global which can be used to determine if the script is already loaded
|
||||||
if (window.canvg) {
|
* @param {array} scripts An array of scripts to preload (in order)
|
||||||
callCanvg(win, data);
|
* @param {function} cb The callback to execute upon load.
|
||||||
} else { // Might not be set up yet
|
*/
|
||||||
$.getScript('canvg/rgbcolor.js', function() {
|
function executeAfterLoads (globalCheck, scripts, cb) {
|
||||||
$.getScript('canvg/canvg.js', function() {
|
return function () {
|
||||||
callCanvg(win, data);
|
var args = arguments;
|
||||||
});
|
function endCallback () {
|
||||||
});
|
cb.apply(null, args);
|
||||||
|
}
|
||||||
|
if (window[globalCheck]) {
|
||||||
|
endCallback();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scripts.reduceRight(function (oldFunc, script) {
|
||||||
|
return function () {
|
||||||
|
$.getScript(script, oldFunc);
|
||||||
|
};
|
||||||
|
}, endCallback)();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkCanvg (callCanvg) {
|
||||||
|
return executeAfterLoads('canvg', ['canvg/rgbcolor.js', 'canvg/canvg.js'], callCanvg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeJSPDF (callJSPDF) {
|
||||||
|
return executeAfterLoads('jsPDF', ['jspdf/underscore-min.js', 'jspdf/jspdf.js', 'jspdf/jspdf.plugin.svgToPdf.js'], callJSPDF)();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXPORTS
|
* EXPORTS
|
||||||
@@ -1127,17 +1145,20 @@ var saveAs;
|
|||||||
var res = svgCanvas.getResolution();
|
var res = svgCanvas.getResolution();
|
||||||
var orientation = res.w > res.h ? 'landscape' : 'portrait';
|
var orientation = res.w > res.h ? 'landscape' : 'portrait';
|
||||||
var units = 'pt'; // curConfig.baseUnit; // We could use baseUnit, but that is presumably not intended for export purposes
|
var units = 'pt'; // curConfig.baseUnit; // We could use baseUnit, but that is presumably not intended for export purposes
|
||||||
var doc = new jsPDF(orientation, units, [res.w, res.h]); // Todo: Give options to use predefined jsPDF formats like "a4", etc. from pull-down (with option to keep customizable)
|
|
||||||
var docTitle = svgCanvas.getDocumentTitle();
|
executeJSPDF(function () {
|
||||||
doc.setProperties({
|
var doc = new jsPDF(orientation, units, [res.w, res.h]); // Todo: Give options to use predefined jsPDF formats like "a4", etc. from pull-down (with option to keep customizable)
|
||||||
title: docTitle/*,
|
var docTitle = svgCanvas.getDocumentTitle();
|
||||||
subject: '',
|
doc.setProperties({
|
||||||
author: '',
|
title: docTitle/*,
|
||||||
keywords: '',
|
subject: '',
|
||||||
creator: ''*/
|
author: '',
|
||||||
|
keywords: '',
|
||||||
|
creator: ''*/
|
||||||
|
});
|
||||||
|
svgElementToPdf(data.svg, doc, {});
|
||||||
|
doc.save(docTitle + '.pdf');
|
||||||
});
|
});
|
||||||
svgElementToPdf(data.svg, doc, {});
|
|
||||||
doc.save(docTitle + '.pdf');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
c.width = svgCanvas.contentW;
|
c.width = svgCanvas.contentW;
|
||||||
|
|||||||
Reference in New Issue
Block a user