mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Feature : Save Piskel project as File
First commit : Removed Local storage feature Added 'download project' 'open project' options First attempt at simplifying right panel. To be continued ...
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
|
||||
var BASE64_REGEX = /\s*;\s*base64\s*(?:;|$)/i;
|
||||
|
||||
ns.ImageToBlob = {
|
||||
imageDataToBlob : function(dataURI, type, callback) {
|
||||
ns.BlobUtils = {
|
||||
dataToBlob : function(dataURI, type, callback) {
|
||||
var header_end = dataURI.indexOf(","),
|
||||
data = dataURI.substring(header_end + 1),
|
||||
isBase64 = BASE64_REGEX.test(dataURI.substring(0, header_end)),
|
||||
@@ -26,13 +26,18 @@
|
||||
canvasToBlob : function(canvas, callback, type /*, ...args*/) {
|
||||
type = type || "image/png";
|
||||
|
||||
if (this.mozGetAsFile) {
|
||||
callback(this.mozGetAsFile("canvas", type));
|
||||
if (canvas.mozGetAsFile) {
|
||||
callback(canvas.mozGetAsFile("canvas", type));
|
||||
} else {
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
var dataURI = canvas.toDataURL.apply(canvas, args);
|
||||
pskl.utils.ImageToBlob.imageDataToBlob(dataURI, type, callback);
|
||||
pskl.utils.BlobUtils.dataToBlob(dataURI, type, callback);
|
||||
}
|
||||
},
|
||||
|
||||
stringToBlob : function (string, callback, type) {
|
||||
type = type || "text/plain";
|
||||
pskl.utils.BlobUtils.dataToBlob('data:'+type+',' + string, type, callback);
|
||||
}
|
||||
};
|
||||
})();
|
||||
24
src/js/utils/DateUtils.js
Normal file
24
src/js/utils/DateUtils.js
Normal file
@@ -0,0 +1,24 @@
|
||||
(function () {
|
||||
var ns = $.namespace('pskl.utils');
|
||||
|
||||
var pad = function (num) {
|
||||
if (num < 10) {
|
||||
return "0" + num;
|
||||
} else {
|
||||
return "" + num;
|
||||
}
|
||||
};
|
||||
|
||||
ns.DateUtils = {
|
||||
format : function (date, format) {
|
||||
return pskl.utils.Template.replace(format, {
|
||||
Y : date.getFullYear(),
|
||||
M : pad(date.getMonth() + 1),
|
||||
D : pad(date.getDate()),
|
||||
H : pad(date.getHours()),
|
||||
m : pad(date.getMinutes()),
|
||||
s : pad(date.getSeconds())
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -10,7 +10,7 @@
|
||||
reader.readAsDataURL(file);
|
||||
},
|
||||
|
||||
downloadAsFile : function (filename, content) {
|
||||
downloadAsFile : function (content, filename) {
|
||||
var saveAs = window.saveAs || (navigator.msSaveBlob && navigator.msSaveBlob.bind(navigator));
|
||||
if (saveAs) {
|
||||
saveAs(content, filename);
|
||||
|
||||
@@ -17,6 +17,15 @@
|
||||
return dummyEl.children[0];
|
||||
},
|
||||
|
||||
getAndReplace : function (templateId, dict) {
|
||||
var result = "";
|
||||
var tpl = pskl.utils.Template.get(templateId);
|
||||
if (tpl) {
|
||||
result = pskl.utils.Template.replace(tpl, dict);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
replace : function (template, dict) {
|
||||
for (var key in dict) {
|
||||
if (dict.hasOwnProperty(key)) {
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
return JSON.stringify({
|
||||
modelVersion : Constants.MODEL_VERSION,
|
||||
piskel : {
|
||||
name : piskel.getDescriptor().name,
|
||||
description : piskel.getDescriptor().description,
|
||||
fps : pskl.app.piskelController.getFPS(),
|
||||
height : piskel.getHeight(),
|
||||
width : piskel.getWidth(),
|
||||
layers : serializedLayers,
|
||||
|
||||
Reference in New Issue
Block a user