mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Added save project dialogue
This commit is contained in:
parent
d97b6f5ca5
commit
f9a1cfc3d3
@ -7,13 +7,4 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.export-actions {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
button {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -78,7 +78,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.pixel-export {
|
div.pixel-export, div.save-project {
|
||||||
input {
|
input {
|
||||||
background: $indent;
|
background: $indent;
|
||||||
border: none;
|
border: none;
|
||||||
@ -164,4 +164,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
button {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
10
css/_save-project.scss
Normal file
10
css/_save-project.scss
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#save-project {
|
||||||
|
.save-project-configuration {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
input {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,4 +15,5 @@
|
|||||||
@import 'resize-menus';
|
@import 'resize-menus';
|
||||||
@import 'palette-editor';
|
@import 'palette-editor';
|
||||||
@import 'splash-page';
|
@import 'splash-page';
|
||||||
@import "export";
|
@import "export";
|
||||||
|
@import "save-project";
|
@ -30,27 +30,7 @@ for (var i = 1; i < mainMenuItems.length; i++) {
|
|||||||
showDialogue('new-pixel');
|
showDialogue('new-pixel');
|
||||||
break;
|
break;
|
||||||
case 'Save project':
|
case 'Save project':
|
||||||
//create name
|
openSaveProjectWindow();
|
||||||
var selectedPalette = getText('palette-button');
|
|
||||||
if (selectedPalette != 'Choose a palette...'){
|
|
||||||
var paletteAbbreviation = palettes[selectedPalette].abbreviation;
|
|
||||||
var fileName = 'pixel-'+paletteAbbreviation+'-'+canvasSize[0]+'x'+canvasSize[1]+'.lpe';
|
|
||||||
} else {
|
|
||||||
var fileName = 'pixel-'+canvasSize[0]+'x'+canvasSize[1]+'.lpe';
|
|
||||||
selectedPalette = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
//set download link
|
|
||||||
var linkHolder = document.getElementById('save-project-link-holder');
|
|
||||||
// create file content
|
|
||||||
var content = getProjectData();
|
|
||||||
|
|
||||||
linkHolder.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(content);
|
|
||||||
linkHolder.download = fileName;
|
|
||||||
linkHolder.click();
|
|
||||||
|
|
||||||
ga('send', 'event', 'Pixel Editor Save', selectedPalette, canvasSize[0]+'/'+canvasSize[1]); /*global ga*/
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Open':
|
case 'Open':
|
||||||
//if a document exists
|
//if a document exists
|
||||||
|
33
js/_saveProject.js
Normal file
33
js/_saveProject.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
function openSaveProjectWindow() {
|
||||||
|
//create name
|
||||||
|
var selectedPalette = getText('palette-button');
|
||||||
|
if (selectedPalette != 'Choose a palette...'){
|
||||||
|
var paletteAbbreviation = palettes[selectedPalette].abbreviation;
|
||||||
|
var fileName = 'pixel-'+paletteAbbreviation+'-'+canvasSize[0]+'x'+canvasSize[1];
|
||||||
|
} else {
|
||||||
|
var fileName = 'pixel-'+canvasSize[0]+'x'+canvasSize[1];
|
||||||
|
selectedPalette = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
setValue('lpe-file-name', fileName);
|
||||||
|
|
||||||
|
document.getElementById("save-project-confirm").addEventListener("click", saveProject);
|
||||||
|
|
||||||
|
showDialogue('save-project', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveProject() {
|
||||||
|
var fileName = `${getValue('lpe-file-name')}.lpe`;
|
||||||
|
|
||||||
|
// create file content
|
||||||
|
var content = getProjectData();
|
||||||
|
|
||||||
|
//set download link
|
||||||
|
var linkHolder = document.getElementById('save-project-link-holder');
|
||||||
|
|
||||||
|
linkHolder.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(content);
|
||||||
|
linkHolder.download = fileName;
|
||||||
|
linkHolder.click();
|
||||||
|
|
||||||
|
ga('send', 'event', 'Pixel Editor Save', selectedPalette, canvasSize[0]+'/'+canvasSize[1]); /*global ga*/
|
||||||
|
}
|
@ -54,6 +54,7 @@
|
|||||||
//=include _paletteBlock.js
|
//=include _paletteBlock.js
|
||||||
//=include _splashPage.js
|
//=include _splashPage.js
|
||||||
//=include _pixelExport.js
|
//=include _pixelExport.js
|
||||||
|
//=include _saveProject.js
|
||||||
|
|
||||||
/**load file**/
|
/**load file**/
|
||||||
//=include _loadImage.js
|
//=include _loadImage.js
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
{{> credits-popup}}
|
{{> credits-popup}}
|
||||||
{{> settings-popup}}
|
{{> settings-popup}}
|
||||||
{{> pixel-export-popup}}
|
{{> pixel-export-popup}}
|
||||||
|
{{> save-project-popup}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/pixel-editor/pixel-editor.js"></script>
|
<script src="/pixel-editor/pixel-editor.js"></script>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<input id="file-name" autocomplete="off" />
|
<input id="file-name" autocomplete="off" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="export-actions">
|
<div class="popup-actions">
|
||||||
<button class="default" id = "export-confirm">Export</button>
|
<button class="default" id = "export-confirm">Export</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
14
views/save-project-popup.hbs
Normal file
14
views/save-project-popup.hbs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<div id="save-project" class="save-project">
|
||||||
|
<button class="close-button">{{svg "x.svg" width="20" height="20"}}</button>
|
||||||
|
|
||||||
|
<h1>Save Project</h1>
|
||||||
|
|
||||||
|
<div class="save-project-configuration">
|
||||||
|
<h2>File Name</h2>
|
||||||
|
<input id="lpe-file-name" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="popup-actions">
|
||||||
|
<button class="default" id = "save-project-confirm">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user