Refactor deck naming
This commit is contained in:
@@ -150,25 +150,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
|||||||
function () {
|
function () {
|
||||||
if (that.deckContentsDirty) {
|
if (that.deckContentsDirty) {
|
||||||
if (confirm("Do you wish to save this deck?")) {
|
if (confirm("Do you wish to save this deck?")) {
|
||||||
if (that.deckName == null) {
|
that.saveCurrentDeck();
|
||||||
var newDeckName = prompt("Enter the name of the deck", "");
|
|
||||||
if (newDeckName != null) {
|
|
||||||
if (newDeckName.length < 3 || newDeckName.length > 100)
|
|
||||||
alert("Deck name has to have at least 3 characters and at most 100 characters.");
|
|
||||||
else {
|
|
||||||
that.deckName = newDeckName;
|
|
||||||
that.saveDeck(false);
|
|
||||||
that.deckName = null;
|
|
||||||
$("#editingDeck").text("New deck");
|
|
||||||
that.clearDeck();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
that.saveDeck(false);
|
|
||||||
that.deckName = null;
|
|
||||||
$("#editingDeck").text("New deck");
|
|
||||||
that.clearDeck();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
that.deckName = null;
|
that.deckName = null;
|
||||||
@@ -179,20 +161,7 @@ var GempLotrDeckBuildingUI = Class.extend({
|
|||||||
|
|
||||||
saveDeckBut.click(
|
saveDeckBut.click(
|
||||||
function () {
|
function () {
|
||||||
if (that.deckName == null) {
|
that.saveCurrentDeck();
|
||||||
var newDeckName = prompt("Enter the name of the deck", "");
|
|
||||||
if (newDeckName == null)
|
|
||||||
return;
|
|
||||||
if (newDeckName.length < 3 || newDeckName.length > 100)
|
|
||||||
alert("Deck name has to have at least 3 characters and at most 100 characters.");
|
|
||||||
else {
|
|
||||||
that.deckName = newDeckName;
|
|
||||||
$("#editingDeck").text(newDeckName);
|
|
||||||
that.saveDeck(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
that.saveDeck(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
renameDeckBut.click(
|
renameDeckBut.click(
|
||||||
@@ -375,6 +344,24 @@ var GempLotrDeckBuildingUI = Class.extend({
|
|||||||
this.layoutUI(true);
|
this.layoutUI(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
saveCurrentDeck:function() {
|
||||||
|
var that = this;
|
||||||
|
if (that.deckName == null) {
|
||||||
|
var newDeckName = prompt("Enter the name of the deck", "");
|
||||||
|
if (newDeckName == null)
|
||||||
|
return;
|
||||||
|
if (newDeckName.length < 3 || newDeckName.length > 100)
|
||||||
|
alert("Deck name has to have at least 3 characters and at most 100 characters.");
|
||||||
|
else {
|
||||||
|
that.deckName = newDeckName;
|
||||||
|
$("#editingDeck").text(newDeckName);
|
||||||
|
that.saveDeck(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
that.saveDeck(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
renameCurrentDeck:function() {
|
renameCurrentDeck:function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
that.renameDeck(that.deckName, function (newDeckName) {
|
that.renameDeck(that.deckName, function (newDeckName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user