remove cancel button from import steps, add big select mode buttons

This commit is contained in:
juliandescottes 2017-05-09 01:16:29 +02:00 committed by Julian Descottes
parent 80a1edf027
commit 42f329980c
5 changed files with 45 additions and 48 deletions

View File

@ -222,6 +222,29 @@
margin-bottom: 10px margin-bottom: 10px
} }
.import-mode-section {
display: flex;
border: 3px solid #666;
border-radius: 3px;
padding: 10px;
margin-bottom: 10px;
align-items: center;
}
.import-mode-section .button {
width: 90px;
height: 40px;
font-size: 16px;
margin-left: 10px;
flex-grow: 0;
flex-shrink: 0;
}
.import-mode-section-description {
flex-grow: 1;
}
.import-mode-option, .import-mode-option,
.import-resize-option, .import-resize-option,
.insert-mode-option { .insert-mode-option {

View File

@ -11,10 +11,8 @@
ns.AbstractImportStep.prototype.init = function () { ns.AbstractImportStep.prototype.init = function () {
this.nextButton = this.container.querySelector('.import-next-button'); this.nextButton = this.container.querySelector('.import-next-button');
this.backButton = this.container.querySelector('.import-back-button'); this.backButton = this.container.querySelector('.import-back-button');
this.cancelButton = this.container.querySelector('.import-cancel-button');
this.addEventListener(this.nextButton, 'click', this.onNextClick); this.addEventListener(this.nextButton, 'click', this.onNextClick);
this.addEventListener(this.cancelButton, 'click', this.onCancelClick);
this.addEventListener(this.backButton, 'click', this.onBackClick); this.addEventListener(this.backButton, 'click', this.onBackClick);
}; };
@ -30,10 +28,6 @@
pskl.utils.Event.removeAllEventListeners(this); pskl.utils.Event.removeAllEventListeners(this);
}; };
ns.AbstractImportStep.prototype.onCancelClick = function () {
this.importController.closeDialog();
};
ns.AbstractImportStep.prototype.onNextClick = function () { ns.AbstractImportStep.prototype.onNextClick = function () {
this.importController.next(this); this.importController.next(this);
}; };

View File

@ -49,7 +49,9 @@
this.createPiskelFromImage().then(function (piskel) { this.createPiskelFromImage().then(function (piskel) {
this.mergeData.mergePiskel = piskel; this.mergeData.mergePiskel = piskel;
this.superclass.onNextClick.call(this); this.superclass.onNextClick.call(this);
}.bind(this)); }.bind(this)).catch(function (e) {
console.error(e);
});
}; };
ns.ImageImport.prototype.onShow = function () { ns.ImageImport.prototype.onShow = function () {

View File

@ -15,15 +15,14 @@
ns.SelectMode.prototype.init = function () { ns.SelectMode.prototype.init = function () {
this.superclass.init.call(this); this.superclass.init.call(this);
this.importMode = this.container.querySelector('.import-mode'); var replaceButton = this.container.querySelector('.import-mode-replace-button');
this.addEventListener(this.importMode, 'change', this.onImportModeChange_); var mergeButton = this.container.querySelector('.import-mode-merge-button');
// Set the initial importMode value in the merge data. this.addEventListener(replaceButton, 'click', this.onReplaceButtonClick_);
this.mergeData.importMode = this.getSelectedMode_(); this.addEventListener(mergeButton, 'click', this.onMergeButtonClick_);
}; };
ns.SelectMode.prototype.onShow = function () { ns.SelectMode.prototype.onShow = function () {
this.refresh_();
this.superclass.onShow.call(this); this.superclass.onShow.call(this);
}; };
@ -31,29 +30,13 @@
this.superclass.destroy.call(this); this.superclass.destroy.call(this);
}; };
ns.SelectMode.prototype.refresh_ = function () { ns.SelectMode.prototype.onReplaceButtonClick_ = function () {
var mergePiskel = this.mergeData.mergePiskel; this.mergeData.importMode = ns.SelectMode.MODES.REPLACE;
if (mergePiskel) { this.onNextClick();
this.nextButton.removeAttribute('disabled');
} else {
this.nextButton.setAttribute('disabled', true);
}
if (this.mergeData.importMode === ns.SelectMode.MODES.MERGE) {
// If the user wants to merge with the existing content, there are more steps ahead.
this.nextButton.textContent = 'next';
} else {
// Otherwise this is the last step, update the button text.
this.nextButton.textContent = 'import';
}
}; };
ns.SelectMode.prototype.onImportModeChange_ = function () { ns.SelectMode.prototype.onMergeButtonClick_ = function () {
this.mergeData.importMode = this.getSelectedMode_(); this.mergeData.importMode = ns.SelectMode.MODES.MERGE;
this.refresh_(); this.onNextClick();
};
ns.SelectMode.prototype.getSelectedMode_ = function () {
return this.importMode.querySelector(':checked').value;
}; };
})(); })();

View File

@ -50,7 +50,6 @@
</div> </div>
</form> </form>
<div class="import-step-buttons"> <div class="import-step-buttons">
<button class="import-cancel-button button">cancel</button>
<button class="import-back-button button">back</button> <button class="import-back-button button">back</button>
<button class="import-next-button button button-primary">next</button> <button class="import-next-button button button-primary">next</button>
</div> </div>
@ -67,20 +66,19 @@
<div class="import-step-content"> <div class="import-step-content">
<div class="import-mode"> <div class="import-mode">
<div class="import-mode-title">How do you want to import the new content?</div> <div class="import-mode-title">How do you want to import the new content?</div>
<label class="import-mode-option"> <div class="import-mode-section">
<input type="radio" checked="checked" name="import-mode" id="select-mode-replace" value="replace"/> <span class="import-mode-section-description">Combine the imported content and your existing sprite.</span>
<span>Replace your current sprite</span> <button class="import-mode-merge-button button-primary button">Merge</button>
</label> </div>
<label class="import-mode-option"> <div class="import-mode-section">
<input type="radio" name="import-mode" id="select-mode-merge" value="merge"/> <span class="import-mode-section-description">Replace your current sprite by the imported content.</span>
<span>Merge with your current sprite</span> <button class="import-mode-replace-button button-primary button">Replace</button>
</label> </div>
</div> </div>
<div class="import-step-buttons"> <div class="import-step-buttons">
<button class="import-cancel-button button">cancel</button>
<button class="import-back-button button">back</button> <button class="import-back-button button">back</button>
<button class="import-next-button button button-primary">next</button> <button style="display: none" class="import-next-button button button-primary">next</button>
</div> </div>
</div> </div>
</div> </div>
@ -120,7 +118,6 @@
<div class="import-resize-anchor-container"></div> <div class="import-resize-anchor-container"></div>
</div> </div>
<div class="import-step-buttons"> <div class="import-step-buttons">
<button class="import-cancel-button button">cancel</button>
<button class="import-back-button button">back</button> <button class="import-back-button button">back</button>
<button class="import-next-button button button-primary">next</button> <button class="import-next-button button button-primary">next</button>
</div> </div>
@ -181,7 +178,6 @@
</label> </label>
</div> </div>
<div class="import-step-buttons"> <div class="import-step-buttons">
<button class="import-cancel-button button">cancel</button>
<button class="import-back-button button">back</button> <button class="import-back-button button">back</button>
<button class="import-next-button button button-primary">import</button> <button class="import-next-button button button-primary">import</button>
</div> </div>
@ -193,7 +189,6 @@
<div class="import-step-container"> <div class="import-step-container">
<div>THIS IS AN INVALID FILEZ</div> <div>THIS IS AN INVALID FILEZ</div>
<div class="import-step-buttons"> <div class="import-step-buttons">
<button class="import-cancel-button button">cancel</button>
<button class="import-back-button button">back</button> <button class="import-back-button button">back</button>
<button class="import-next-button button button-primary">next</button> <button class="import-next-button button button-primary">next</button>
</div> </div>