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,7 +349,16 @@
$("#create-publisher-link, #create-publisher-cancel").click(toggleFormAndLink("publisher"));
$("#create-system-submit").click(function() {
var submitting = false;
return function() {
if (submitting) {
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();
@ -357,7 +371,10 @@
$.ajax(url, {
type: "POST",
data: data,
beforeSend: function() { $container.clearModelErrors(); },
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);
@ -372,14 +389,27 @@
$("#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 submitting = false;
return function() {
if (submitting) {
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();
@ -392,7 +422,10 @@
$.ajax(url, {
type: "POST",
data: data,
beforeSend: function() { $container.clearModelErrors(); },
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);
@ -407,18 +440,31 @@
}
toggleFormAndLink("publisher")();
},
complete: function() {
submitting = false;
$link.toggleClass("submit-link loading-link");
}
});
return false;
});
}
}());
$("#create-game-submit").click(function() {
var submitting = false;
return function() {
if (submitting) {
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;
@ -431,7 +477,10 @@
type: "POST",
data: data,
traditional: true,
beforeSend: function() { $container.clearModelErrors(); },
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);
@ -447,11 +496,16 @@
}
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();
});
}());