more style updates to the quote form

This commit is contained in:
tmont 2011-02-24 21:00:22 +00:00
parent d779e17c11
commit 7286a8c126
3 changed files with 173 additions and 107 deletions

View File

@ -60,7 +60,7 @@
<fieldset>
<legend>Create new system</legend>
<p class="error-message"></p>
<p class="error-summary"></p>
<p>
<%= Html.Label("Name", "SystemName", new { @class = "label" })%>
@ -80,8 +80,10 @@
<%= Html.TextBox("SystemReleaseDate", null) %>
</p>
<%= Html.Button("Save System", new { id = "create-system-submit" })%>
<%= Html.Button("Cancel", new { id = "create-system-cancel" })%>
<p>
<a href="#" class="submit-link button-link" id="create-system-submit" title="save sstemy">Save System</a>
<a href="#" class="cancel-link button-link" id="create-system-cancel" title="cancel">Cancel</a>
</p>
</fieldset>
</div>
@ -96,7 +98,7 @@
<fieldset>
<legend>Create new publisher</legend>
<p class="error-message"></p>
<p class="error-summary"></p>
<p>
<%= Html.Label("Name", "PublisherName", new { @class = "label" })%>
@ -115,8 +117,10 @@
</fieldset>
</div>
<%= Html.Button("Save Game", new { id = "create-game-submit" })%>
<%= Html.Button("Cancel", new { id = "create-game-cancel" })%>
<p>
<a href="#" class="submit-link button-link" id="create-game-submit" title="save game">Save Game</a>
<a href="#" class="cancel-link button-link" id="create-game-cancel" title="cancel">Cancel</a>
</p>
</fieldset>
</div>

View File

@ -181,6 +181,12 @@ ul.menu {
.cancel-link {
background: transparent url(/media/images/cancel.png) left center no-repeat;
}
.button-link {
background-color: #FFFFFF;
padding: 2px 2px 2px 18px;
border: 1px solid #000000 !important;
color: #000000 !important;
}
.checkbox-table {
}

View File

@ -30,6 +30,8 @@
.insertAfter($input);
}
});
return this;
};
$.fn.clearModelErrors = function() {
@ -43,6 +45,8 @@
.find(".error-summary")
.empty()
.hide();
return this;
};
$.vgquotes = function() {
@ -313,6 +317,7 @@
.find("input[type='checkbox']").removeAttr("checked").end()
.find("> .edit-mode").val(0).end()
.find("> fieldset > legend").text("Create new " + type).end()
.clearModelErrors()
.toggle();
$("#" + type + "-select").toggle();
@ -344,114 +349,163 @@
$("#create-publisher-link, #create-publisher-cancel").click(toggleFormAndLink("publisher"));
$("#create-system-submit").click(function() {
var $container = $("#create-system-form");
var data = { SystemName: $("#SystemName").val(), SystemAbbreviation: $("#SystemAbbreviation").val(), SystemReleaseDate: $("#SystemReleaseDate").val() };
var url = "/system/create";
var systemId = $container.find("> .edit-mode").val();
if (systemId > 0) {
url = "/system/edit";
data.SystemId = systemId;
}
$.ajax(url, {
type: "POST",
data: data,
beforeSend: function() { $container.clearModelErrors(); },
success: function(data, statux, $xhr) {
if (data.Error !== null) {
$container.applyModelErrors(data.Error, data.Data);
return;
}
if (systemId <= 0) {
//add checkbox to table
addNewCheckbox($("#system-checkbox-table"), "SystemIds", data.Data.Id, data.Data.Abbreviation, 6);
} else {
//update checkbox's label with new abbreviation
$("#system-checkbox-table").find("input[value='" + data.Data.Id +"'] + label").text(data.Data.Abbreviation);
}
toggleFormAndLink("system")();
var submitting = false;
return function() {
if (submitting) {
return false;
}
});
return false;
});
submitting = true;
var $container = $("#create-system-form");
var $link = $(this);
var data = { SystemName: $("#SystemName").val(), SystemAbbreviation: $("#SystemAbbreviation").val(), SystemReleaseDate: $("#SystemReleaseDate").val() };
var url = "/system/create";
var systemId = $container.find("> .edit-mode").val();
if (systemId > 0) {
url = "/system/edit";
data.SystemId = systemId;
}
$.ajax(url, {
type: "POST",
data: data,
beforeSend: function() {
$container.clearModelErrors();
$link.toggleClass("submit-link loading-link");
},
success: function(data, statux, $xhr) {
if (data.Error !== null) {
$container.applyModelErrors(data.Error, data.Data);
return;
}
if (systemId <= 0) {
//add checkbox to table
addNewCheckbox($("#system-checkbox-table"), "SystemIds", data.Data.Id, data.Data.Abbreviation, 6);
} else {
//update checkbox's label with new abbreviation
$("#system-checkbox-table").find("input[value='" + data.Data.Id +"'] + label").text(data.Data.Abbreviation);
}
toggleFormAndLink("system")();
},
complete: function() {
submitting = false;
$link.toggleClass("submit-link loading-link");
}
});
return false;
};
}());
$("#create-publisher-submit").click(function() {
var $container = $("#create-publisher-form");
var data = { PublisherName: $("#PublisherName").val(), PublisherWebsite: $("#PublisherWebsite").val() };
var url = "/publisher/create";
var publisherId = $container.find("> .edit-mode").val();
if (publisherId > 0) {
url = "/publisher/edit";
data.PublisherId = publisherId;
}
$.ajax(url, {
type: "POST",
data: data,
beforeSend: function() { $container.clearModelErrors(); },
success: function(data, statux, $xhr) {
if (data.Error !== null) {
$container.applyModelErrors(data.Error, data.Data);
return;
}
if (publisherId <= 0) {
addNewCheckbox($("#publisher-checkbox-table"), "PublisherIds", data.Data.Id, data.Data.Name, 4);
} else {
//update publisher name
$("#publisher-checkbox-table").find("input[value='" + data.Data.Id +"'] + label").text(data.Data.Name);
}
toggleFormAndLink("publisher")();
var submitting = false;
return function() {
if (submitting) {
return false;
}
});
return false;
});
submitting = true;
var $container = $("#create-publisher-form");
var $link = $(this);
var data = { PublisherName: $("#PublisherName").val(), PublisherWebsite: $("#PublisherWebsite").val() };
var url = "/publisher/create";
var publisherId = $container.find("> .edit-mode").val();
if (publisherId > 0) {
url = "/publisher/edit";
data.PublisherId = publisherId;
}
$.ajax(url, {
type: "POST",
data: data,
beforeSend: function() {
$container.clearModelErrors();
$link.toggleClass("submit-link loading-link");
},
success: function(data, statux, $xhr) {
if (data.Error !== null) {
$container.applyModelErrors(data.Error, data.Data);
return;
}
if (publisherId <= 0) {
addNewCheckbox($("#publisher-checkbox-table"), "PublisherIds", data.Data.Id, data.Data.Name, 4);
} else {
//update publisher name
$("#publisher-checkbox-table").find("input[value='" + data.Data.Id +"'] + label").text(data.Data.Name);
}
toggleFormAndLink("publisher")();
},
complete: function() {
submitting = false;
$link.toggleClass("submit-link loading-link");
}
});
return false;
}
}());
$("#create-game-submit").click(function() {
var regions = [], publishers = [], systems = [], data = { GameName: $("#GameName").val(), GameWebsite: $("#GameWebsite").val(), GameIcon: $("#GameIcon").val() };
$("input:checked[name='GameRegions']").each(function(index, input) { if (typeof(data.GameRegions) === "undefined") { data.GameRegions = []; } data.GameRegions.push(input.value); });
$("input:checked[name='SystemIds']").each(function(index, input) { if (typeof(data.SystemIds) === "undefined") { data.SystemIds = []; } data.SystemIds.push(input.value); });
$("input:checked[name='PublisherIds']").each(function(index, input) { if (typeof(data.PublisherIds) === "undefined") { data.PublisherIds = []; } data.PublisherIds.push(input.value); });
var $container = $("#create-game-form");
var url = "/game/create";
var submittingAnEdit = $("#create-game-form > .edit-mode").val() == 1;
if (submittingAnEdit) {
url = "/game/edit";
data.GameId = $("#GameId").val();
}
$.ajax(url, {
type: "POST",
data: data,
traditional: true,
beforeSend: function() { $container.clearModelErrors(); },
success: function(data, status, $xhr) {
if (data.Error !== null) {
$container.applyModelErrors(data.Error, data.Data);
return;
}
if (!submittingAnEdit) {
$("#GameId")
.append($("<option/>").attr({ value: data.Data.Id}).text(data.Data.Name))
.val(data.Data.Id);
} else {
$("#GameId option[value='" + data.Data.Id + "']").text(data.Data.Name); //make sure the new name is up to date
}
toggleFormAndLink("game")();
var submitting = false;
return function() {
if (submitting) {
return false;
}
});
return false;
});
submitting = true;
var regions = [], publishers = [], systems = [], data = { GameName: $("#GameName").val(), GameWebsite: $("#GameWebsite").val(), GameIcon: $("#GameIcon").val() };
$("input:checked[name='GameRegions']").each(function(index, input) { if (typeof(data.GameRegions) === "undefined") { data.GameRegions = []; } data.GameRegions.push(input.value); });
$("input:checked[name='SystemIds']").each(function(index, input) { if (typeof(data.SystemIds) === "undefined") { data.SystemIds = []; } data.SystemIds.push(input.value); });
$("input:checked[name='PublisherIds']").each(function(index, input) { if (typeof(data.PublisherIds) === "undefined") { data.PublisherIds = []; } data.PublisherIds.push(input.value); });
var $container = $("#create-game-form");
var $link = $(this);
var url = "/game/create";
var submittingAnEdit = $("#create-game-form > .edit-mode").val() == 1;
if (submittingAnEdit) {
url = "/game/edit";
data.GameId = $("#GameId").val();
}
$.ajax(url, {
type: "POST",
data: data,
traditional: true,
beforeSend: function() {
$container.clearModelErrors();
$link.toggleClass("submit-link loading-link");
},
success: function(data, status, $xhr) {
if (data.Error !== null) {
$container.applyModelErrors(data.Error, data.Data);
return;
}
if (!submittingAnEdit) {
$("#GameId")
.append($("<option/>").attr({ value: data.Data.Id}).text(data.Data.Name))
.val(data.Data.Id);
} else {
$("#GameId option[value='" + data.Data.Id + "']").text(data.Data.Name); //make sure the new name is up to date
}
toggleFormAndLink("game")();
},
complete: function() {
submitting = false;
$link.toggleClass("submit-link loading-link");
}
});
return false;
}
}());
$(".dismiss-flag-link").click(function() {
var $link = $(this);
@ -785,6 +839,8 @@
$("body").ajaxError(function(e, xhr, options, error){
$.vgquotes.ajaxErrorHandler.call(this, xhr);
});
$("#search-query").focus();
});
}());