This commit is contained in:
jdescottes 2014-03-30 22:49:14 +02:00
parent d64a228a8b
commit db9e832984
5 changed files with 43 additions and 62 deletions

File diff suppressed because one or more lines are too long

View File

@ -16168,7 +16168,7 @@ if (typeof Function.prototype.bind !== "function") {
$.subscribe(Events.USER_SETTINGS_CHANGED, $.proxy(this.onUserSettingsChange_, this));
$.subscribe(Events.FRAME_SIZE_CHANGED, $.proxy(this.onFrameSizeChanged_, this));
this.centerColumnWrapperHorizontally_();
window.setTimeout(this.afterWindowResize_.bind(this), 100);
};
ns.DrawingController.prototype.initMouseBehavior = function() {
@ -16426,7 +16426,8 @@ if (typeof Function.prototype.bind !== "function") {
settingsContainerWidth = $('#application-action-section').outerWidth(true),
availableWidth = $('#main-wrapper').width() - leftSectionWidth - rightSectionWidth - toolsContainerWidth - settingsContainerWidth;
return availableWidth-50;
var comfortMargin = 10;
return availableWidth - comfortMargin;
};
ns.DrawingController.prototype.getContainerHeight_ = function () {
@ -18152,6 +18153,9 @@ if (typeof Function.prototype.bind !== "function") {
this.palettes = this.retrieveUserPalettes();
this.originalPalettes = this.retrieveUserPalettes();
this.selectedPaletteId = null;
// Keep track of all spectrum instances created, to dispose them when closing the popup
this.spectrumContainers = [];
};
ns.PaletteManagerController.prototype.init = function () {
@ -18212,6 +18216,11 @@ if (typeof Function.prototype.bind !== "function") {
};
};
ns.PaletteManagerController.prototype.redraw = function () {
this.createPaletteListMarkup();
this.selectPalette(this.selectedPaletteId);
};
ns.PaletteManagerController.prototype.selectPalette = function (paletteId) {
this.deselectCurrentPalette();
var paletteListItem = this.palettesList.querySelector('[data-palette-id='+paletteId+']');
@ -18223,9 +18232,6 @@ if (typeof Function.prototype.bind !== "function") {
};
ns.PaletteManagerController.prototype.refreshPaletteDetails = function () {
// Destroy and disconnect events
this.destroySpectrumPickers();
this.createPaletteHeadMarkup();
this.createPaletteBodyMarkup();
this.initPaletteDetailsEvents();
@ -18321,7 +18327,8 @@ if (typeof Function.prototype.bind !== "function") {
} else if (target.classList.contains('palette-manager-palette-button')) {
var action = target.dataset.action;
if (action === 'save') {
this.savePaletteAndRedraw(this.getSelectedPalette().id);
this.savePalette(this.getSelectedPalette().id);
this.redraw();
} else if (action === 'revert') {
this.revertChanges();
} else if (action === 'delete') {
@ -18336,8 +18343,8 @@ if (typeof Function.prototype.bind !== "function") {
ns.PaletteManagerController.prototype.initPaletteCardsSpectrum = function () {
var oSelf = this;
var colorSquares = $(this.getSpectrumSelector_());
colorSquares.spectrum({
var container = $(this.getSpectrumSelector_());
container.spectrum({
clickoutFiresChange : true,
showInput: true,
showButtons: false,
@ -18351,40 +18358,43 @@ if (typeof Function.prototype.bind !== "function") {
var colorId = parseInt(target.parentNode.dataset.colorId, 10);
var palette = oSelf.getSelectedPalette();
var color = palette.colors[colorId];
colorSquares.spectrum("set", color);
container.spectrum("set", color);
}
});
this.spectrumContainers.push(container);
};
/**
* Destroy all spectrum instances generated by the palette manager
*/
ns.PaletteManagerController.prototype.destroySpectrumPickers = function () {
var sp = $(this.getSpectrumSelector_());
if (sp) {
sp.spectrum("destroy");
}
this.spectrumContainers.forEach(function (container) {
container.spectrum("destroy");
});
this.spectrumContainers = [];
};
ns.PaletteManagerController.prototype.updateColorInSelectedPalette = function (colorId, color) {
var palette = this.getSelectedPalette();
palette.colors.splice(colorId, 1, '#' + (color.toHex().toUpperCase()));
var hexColor = '#' + (color.toHex().toUpperCase());
palette.colors.splice(colorId, 1, hexColor);
this.createPaletteListMarkup();
this.selectPalette(this.selectedPaletteId);
this.redraw();
};
ns.PaletteManagerController.prototype.addColorInSelectedPalette = function (color) {
var selectedPalette = this.getSelectedPalette();
selectedPalette.colors.push(color);
this.createPaletteListMarkup();
this.selectPalette(this.selectedPaletteId);
this.redraw();
};
ns.PaletteManagerController.prototype.removeColorInSelectedPalette = function (colorId) {
var palette = this.getSelectedPalette();
palette.colors.splice(colorId, 1);
this.createPaletteListMarkup();
this.selectPalette(this.selectedPaletteId);
this.redraw();
};
ns.PaletteManagerController.prototype.renameSelectedPalette = function () {
@ -18392,8 +18402,7 @@ if (typeof Function.prototype.bind !== "function") {
var name = window.prompt('Please enter a new name for palette "' + palette.name + '"', palette.name);
if (name) {
palette.name = name;
this.createPaletteListMarkup();
this.selectPalette(palette.id);
this.redraw();
}
};
@ -18448,8 +18457,7 @@ if (typeof Function.prototype.bind !== "function") {
palette.name = originalPalette.name;
palette.colors = originalPalette.colors.slice(0);
this.createPaletteListMarkup();
this.selectPalette(palette.id);
this.redraw();
};
ns.PaletteManagerController.prototype.deleteSelectedPalette = function () {
@ -18479,8 +18487,7 @@ if (typeof Function.prototype.bind !== "function") {
this.savePalette(palette.id);
}.bind(this));
this.createPaletteListMarkup();
this.selectPalette(this.getSelectedPalette().id);
this.redraw();
};
ns.PaletteManagerController.prototype.savePalette = function (paletteId) {
@ -18494,16 +18501,11 @@ if (typeof Function.prototype.bind !== "function") {
}
this.persistToLocalStorage();
$.publish(Events.SHOW_NOTIFICATION, [{"content": "Palette " + palette.name + " successfully saved !"}]);
window.setTimeout($.publish.bind($, Events.HIDE_NOTIFICATION), 2000);
};
ns.PaletteManagerController.prototype.savePaletteAndRedraw = function (paletteId) {
this.savePalette(paletteId);
this.createPaletteListMarkup();
this.selectPalette(this.getSelectedPalette().id);
};
ns.PaletteManagerController.prototype.persistToLocalStorage = function () {
window.localStorage.setItem('piskel.palettes', JSON.stringify(this.originalPalettes));
this.originalPalettes = this.retrieveUserPalettes();

View File

@ -78,24 +78,6 @@ body {
bottom: 0;
}
.piskel-name-container {
overflow:hidden;
position:fixed;
top:10px;
left:10px;
color:white;
font-family:Tahoma;
z-index: 10000;
}
.piskel-name-container #piskel-name {
border :none;
color : lightgrey;
background: transparent;
font-size:16pt;
}
.column {
display: inline-block;
}
@ -260,7 +242,7 @@ body {
border-bottom: 0;
font-weight: bold;
font-size: 13px;
z-index: 10000;
z-index: 30000;
max-width: 300px;
}
@ -2326,7 +2308,7 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
.minimap-crop-frame {
position:absolute;
border:1px solid rgba(255,255,255,0.5);
z-index:9999;
z-index:100;
box-sizing : border-box;
-moz-box-sizing : border-box;
cursor : pointer;

View File

@ -20,12 +20,9 @@
z-index : 20000;
transition:opacity 0.5s;
color:white;">
<span style="top:45%">Loading pixels ...</span>
<span style="top:45%">Loading Piskel ...</span>
</div>
<script type="text/javascript" src="js/lib/iframeLoader.js"></script>
<div class="piskel-name-container">
<input readonly id="piskel-name" type="text" value=""/>
</div>
<div id="main-wrapper" class="main-wrapper">
<iframe src="templates/drawing-tools.html" onload="iframeloader.onLoad(event)" data-iframe-loader="display"></iframe>

View File

@ -21,7 +21,7 @@
<script type="text/template" id="palette-details-head-template">
<span class="palette-manager-details-head-name">{{name}}</span>
<span class="palette-manager-details-head-edit-icon">&nbsp;</span>
<span class="palette-manager-details-head-edit-icon" title="edit name">&nbsp;</span>
<div class="palette-manager-details-head-actions">
<button class="palette-manager-palette-button button button-primary" {{save:disabled}} data-action="save" type="button">Save</button>
<button class="palette-manager-palette-button button " {{revert:disabled}} data-action="revert" type="button">Revert</button>