post merge

This commit is contained in:
juliandescottes
2015-04-07 23:15:36 +02:00
16 changed files with 299 additions and 21 deletions

View File

@@ -12,11 +12,17 @@
this.addEventListener(this.hiddenFileInput, 'change', this.onFileUploadChange_);
this.hiddenOpenPiskelInput = document.querySelector('[name="open-piskel-input"]');
this.addEventListener(this.hiddenOpenPiskelInput, 'change', this.onOpenPiskelChange_);
this.addEventListener('.browse-local-button', 'click', this.onBrowseLocalClick_);
this.addEventListener('.file-input-button', 'click', this.onFileInputClick_);
this.addEventListener('.open-piskel-button', 'click', this.onOpenPiskelClick_);
// different handlers, depending on the Environment
if (pskl.utils.Environment.detectNodeWebkit()) {
this.addEventListener('.open-piskel-button', 'click', this.openPiskelDesktop_);
} else {
this.addEventListener(this.hiddenOpenPiskelInput, 'change', this.onOpenPiskelChange_);
this.addEventListener('.open-piskel-button', 'click', this.onOpenPiskelClick_);
}
this.initRestoreSession_();
};
@@ -55,6 +61,11 @@
}
};
ns.ImportController.prototype.openPiskelDesktop_ = function (evt) {
this.closeDrawer_();
pskl.app.desktopStorageService.openPiskel();
};
ns.ImportController.prototype.onOpenPiskelClick_ = function (evt) {
this.hiddenOpenPiskelInput.click();
};

View File

@@ -29,7 +29,18 @@
this.isPublicCheckbox.setAttribute('checked', true);
}
this.addEventListener('#save-file-button', 'click', this.saveFile_);
//Environment dependent configuration:
if (pskl.utils.Environment.detectNodeWebkit()) {
// running in Node-Webkit...
this.addEventListener('#save-file-button', 'click', this.saveFileDesktop);
// hide the "save in browser" part of the gui
var saveInBrowserSection = document.querySelector('#save-in-browser');
saveInBrowserSection.style.display = 'none';
} else {
// running in browser...
this.addEventListener('#save-file-button', 'click', this.saveFileBrowser_);
}
this.addEventListener('#save-browser-button', 'click', this.saveLocal_);
this.saveOnlineButton = document.querySelector('#save-online-button');
@@ -53,9 +64,18 @@
};
ns.SaveController.prototype.updateLocalStatusFilename_ = function () {
this.saveFileStatus.innerHTML = pskl.utils.Template.getAndReplace('save-file-status-template', {
name : this.getLocalFilename_()
});
if (pskl.utils.Environment.detectNodeWebkit()) {
var fileName = this.piskelController.getSavePath();
if (fileName !== null) {
this.saveFileStatus.innerHTML = pskl.utils.Template.getAndReplace('save-file-status-desktop-template', {
name : this.piskelController.getSavePath()
});
}
} else {
this.saveFileStatus.innerHTML = pskl.utils.Template.getAndReplace('save-file-status-template', {
name : this.getLocalFilename_()
});
}
};
ns.SaveController.prototype.getLocalFilename_ = function () {
@@ -122,7 +142,20 @@
}
};
/**
* @deprecated - renamed "saveFileBrowser_"
* @private
*/
ns.SaveController.prototype.saveFile_ = function () {
// detect if this is running in NodeWebkit
if (pskl.utils.Environment.detectNodeWebkit()) {
this.saveFileDesktop_();
} else {
this.saveFileBrowser_();
}
};
ns.SaveController.prototype.saveFileBrowser_ = function () {
this.beforeSaving_();
pskl.utils.BlobUtils.stringToBlob(pskl.app.piskelController.serialize(), function(blob) {
pskl.utils.FileUtils.downloadAsFile(blob, this.getLocalFilename_());
@@ -131,6 +164,10 @@
}.bind(this), "application/piskel+json");
};
ns.SaveController.prototype.saveFileDesktop_ = function () {
pskl.app.desktopStorageService.save();
};
ns.SaveController.prototype.getName = function () {
return this.nameInput.value;
};

View File

@@ -50,7 +50,10 @@
var piskel = pskl.model.Piskel.fromLayers(resizedLayers, this.piskelController.getPiskel().getDescriptor());
// propagate savepath to new Piskel
piskel.savePath = pskl.app.piskelController.getSavePath();
pskl.app.piskelController.setPiskel(piskel, true);
$.publish(Events.CLOSE_SETTINGS_DRAWER);
};