diff --git a/css/forms.css b/css/forms.css
index f78c1729..8cc1dd53 100644
--- a/css/forms.css
+++ b/css/forms.css
@@ -16,20 +16,22 @@
.button {
height: 24px;
- border: none;
box-sizing: border-box;
- border-top: 1px solid #666;
- border-left: 1px solid #333;
- border-right: 1px solid #333;
- border-bottom: 1px solid #333;
+
background-color: #3f3f3f;
+ border: 1px solid #333;
+ border-top-color: #666;
+ border-bottom-color: #222;
+
cursor: pointer;
- color: white;
- font-size: 1rem;
- font-weight: bold;
- text-align: center;
text-decoration: none;
- text-shadow: 0px -1px 0 #000;
+
+ color: white;
+ text-shadow: 0px -1px 0 black;
+ font-weight: bold;
+ font-size: 1rem;
+ text-align: center;
+
transition: background-color 0.2s linear;
}
@@ -37,4 +39,31 @@
text-decoration: none;
background-color: #484848;
color: gold;
+}
+
+.button-primary {
+ background-color: rgb(255,215,0); /* gold */
+
+ border-color: rgb(179, 164, 0);
+ border-top-color: white;
+ border-bottom-color: rgb(151, 133, 0);
+
+ color: black;
+ text-shadow: 0px 1px 0 #fff;
+}
+
+.button-primary:hover {
+ background-color: rgb(255,235,20);
+ color: #333;
+}
+
+.button[disabled=disabled],
+.button[disabled=disabled]:hover {
+ cursor:default;
+ background-color: #aaa;
+ color: #777;
+ text-shadow: 0px 1px 0 #bbb;
+ border-color: #666;
+ border-top-color: #999;
+ border-bottom-color: #555;
}
\ No newline at end of file
diff --git a/css/settings.css b/css/settings.css
index b1361d92..5b58f9bd 100644
--- a/css/settings.css
+++ b/css/settings.css
@@ -93,11 +93,18 @@
}
/* Gif Export Setting panel*/
-.export-gif-upload-button {
+.gif-upload-button,
+.gif-render-button {
+ /*float : right;*/
margin-top : 10px;
+ margin-right : 10px;
}
-.export-gif-preview {
+.gif-export-radio-group {
+ margin:10px 0;
+}
+
+.gif-export-preview {
margin-top:20px;
max-width:240px;
position:relative;
@@ -122,6 +129,19 @@
margin: 15px 0;
}
+.import-section-disabled {
+ color : #888;
+}
+
+.import-section-preview {
+ display : inline-block;
+ height : 60px;
+ width: 60px;
+ border : 1px dashed #999;
+ border-radius: 3px;
+ margin-left : 10px;
+}
+
.import-resize-field {
width: 30px;
margin: 0px 8px;
@@ -138,23 +158,10 @@
width: 130px;
overflow: hidden;
- height: 1rem;
+ height: 1.5rem;
+ word-break : break-all;
vertical-align: middle;
font-style: italic;
font-weight: normal;
text-shadow: none;
-}
-
-.import-button {
- float: right;
- padding : 8px 10px;
- height: auto;
- background: gold;
- color: black;
- text-shadow: 0px 1px 0 #fff;
- border-radius: 2px;
- font-size : 1.2rem;
- border-color: rgb(179, 164, 0);
- border-top-color: white;
- border-bottom-color: rgb(151, 133, 0);
}
\ No newline at end of file
diff --git a/js/controller/settings/GifExportController.js b/js/controller/settings/GifExportController.js
index 58ed6ca6..42e57d3d 100644
--- a/js/controller/settings/GifExportController.js
+++ b/js/controller/settings/GifExportController.js
@@ -24,9 +24,9 @@
];
ns.GifExportController.prototype.init = function () {
- this.radioTemplate_ = pskl.utils.Template.get("export-gif-radio-template");
+ this.radioTemplate_ = pskl.utils.Template.get("gif-export-radio-template");
- this.previewContainerEl = document.querySelectorAll(".export-gif-preview div")[0];
+ this.previewContainerEl = document.querySelectorAll(".gif-export-preview")[0];
this.radioGroupEl = document.querySelectorAll(".gif-export-radio-group")[0];
this.uploadForm = $("[name=gif-export-upload-form]");
@@ -56,7 +56,7 @@
};
ns.GifExportController.prototype.updatePreview_ = function (src) {
- this.previewContainerEl.innerHTML = "
";
+ this.previewContainerEl.innerHTML = "

";
};
ns.GifExportController.prototype.getSelectedDpi_ = function () {
diff --git a/js/controller/settings/ImportController.js b/js/controller/settings/ImportController.js
index 4e9bc792..f28166f9 100644
--- a/js/controller/settings/ImportController.js
+++ b/js/controller/settings/ImportController.js
@@ -1,6 +1,8 @@
(function () {
var ns = $.namespace('pskl.controller.settings');
var DEFAULT_FILE_STATUS = 'No file selected ...';
+ var PREVIEW_HEIGHT = 60;
+
ns.ImportController = function (piskelController) {
this.piskelController = piskelController;
this.importedImage_ = null;
@@ -10,12 +12,15 @@
this.importForm = $("[name=import-form]");
this.hiddenFileInput = $("[name=file-upload-input]");
this.fileInputButton = $(".file-input-button");
- this.fileInputStatus=$(".file-input-status");
+ this.fileInputStatus = $(".file-input-status");
this.fileInputStatus.html(DEFAULT_FILE_STATUS);
+ this.importPreview = $(".import-section-preview");
+
this.resizeWidth = $("[name=resize-width]");
this.resizeHeight = $("[name=resize-height]");
this.smoothResize = $("[name=smooth-resize-checkbox]");
+ this.submitButton = $("[name=import-submit]");
this.importForm.submit(this.onImportFormSubmit_.bind(this));
this.hiddenFileInput.change(this.onFileUploadChange_.bind(this));
@@ -69,7 +74,7 @@
var file = files[0];
if (this.isImage_(file)) {
this.readImageFile_(file);
- this.enableAdditionalInputs_();
+ this.enableDisabledSections_();
} else {
this.reset_();
throw "File is not an image : " + file.type;
@@ -77,10 +82,16 @@
}
};
- ns.ImportController.prototype.enableAdditionalInputs_ = function () {
+ ns.ImportController.prototype.enableDisabledSections_ = function () {
this.resizeWidth.removeAttr('disabled');
this.resizeHeight.removeAttr('disabled');
this.smoothResize.removeAttr('disabled');
+ this.submitButton.removeAttr('disabled');
+
+ this.fileInputButton.removeClass('button-primary');
+ this.fileInputButton.blur();
+
+ $('.import-section-disabled').removeClass('import-section-disabled');
};
ns.ImportController.prototype.readImageFile_ = function (imageFile) {
@@ -101,12 +112,22 @@
ns.ImportController.prototype.onImageLoaded_ = function (evt) {
var w = this.importedImage_.width,
h = this.importedImage_.height;
- this.resizeWidth.val(w);
- this.resizeHeight.val(h);
-
var filePath = this.hiddenFileInput.val();
var fileName = this.extractFileNameFromPath_(filePath);
this.fileInputStatus.html(fileName);
+
+ this.resizeWidth.val(w);
+ this.resizeHeight.val(h);
+
+ this.importPreview.width("auto");
+ this.importPreview.append(this.createImagePreview_());
+ };
+
+ ns.ImportController.prototype.createImagePreview_ = function () {
+ var image = document.createElement('IMG');
+ image.src = this.importedImage_.src;
+ image.setAttribute('height', PREVIEW_HEIGHT);
+ return image;
};
ns.ImportController.prototype.extractFileNameFromPath_ = function (path) {
@@ -123,59 +144,23 @@
ns.ImportController.prototype.importImageToPiskel_ = function () {
if (this.importedImage_) {
- var image = pskl.utils.ImageResizer.resize(this.importedImage_, this.resizeWidth.val(), this.resizeHeight.val());
- var frames = this.createFramesFromImage(image);
- var confirmationMessage = "You are about to erase your current Piskel. " +
- "A new Piskel will be created from your picture, size : " + image.width + "x" + image.height;
+ if (window.confirm("You are about to create a new Piskel, unsaved changes will be lost.")) {
+ var w = this.resizeWidth.val(),
+ h = this.resizeHeight.val(),
+ smoothing = !!this.smoothResize.prop('checked');
- if (window.confirm(confirmationMessage)) {
- var piskel = pskl.utils.Serializer.createPiskel([frames]);
+ var image = pskl.utils.ImageResizer.resize(this.importedImage_, w, h, smoothing);
+ var frame = pskl.utils.FrameUtils.createFromImage(image);
+
+ var piskel = pskl.utils.Serializer.createPiskel([frame]);
pskl.app.piskelController.setPiskel(piskel);
- pskl.app.animationController.setFPS(12);
+ pskl.app.animationController.setFPS(Constants.DEFAULT.FPS);
this.reset_();
}
}
};
- ns.ImportController.prototype.createFramesFromImage = function (image) {
- var w = image.width,
- h = image.height;
- var canvas = pskl.CanvasUtils.createCanvas(w, h);
- var context = canvas.getContext('2d');
-
- context.drawImage(image, 0,0,w,h,0,0,w,h);
- var imgData = context.getImageData(0,0,w,h).data;
- // Draw the zoomed-up pixels to a different canvas context
- var frames = [];
- for (var x=0;x
-
-
+ -->
\ No newline at end of file
diff --git a/templates/settings/import.html b/templates/settings/import.html
index 0201dd42..405cd092 100644
--- a/templates/settings/import.html
+++ b/templates/settings/import.html
@@ -6,22 +6,26 @@