2011-02-24 21:11:21 +00:00
|
|
|
(function($, window, undefined){
|
|
|
|
|
|
|
|
var toggleFormAndLink = function(type) {
|
|
|
|
return function() {
|
|
|
|
$("#create-" + type + "-form")
|
|
|
|
.find("input[type='text']").val("").end()
|
|
|
|
.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();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var addNewCheckbox = function($table, name, value, text, cellsPerRow) {
|
|
|
|
var $row = $table.find("tr:last");
|
|
|
|
if ($row.find("td").length === cellsPerRow) {
|
|
|
|
$row = $("<tr/>");
|
|
|
|
$table.append($row);
|
|
|
|
}
|
|
|
|
|
|
|
|
var $cell = $("<td/>").append($("<input/>").attr({
|
|
|
|
type: "checkbox",
|
|
|
|
name: name,
|
|
|
|
value: value,
|
|
|
|
id: name + "_" + value,
|
|
|
|
checked: "checked"
|
|
|
|
})).append($("<label/>").attr("for", name + "_" + value).text(text));
|
|
|
|
|
|
|
|
$row.append($cell);
|
|
|
|
$table.append($row);
|
|
|
|
};
|
|
|
|
|
|
|
|
var setupSystemForm = function() {
|
|
|
|
$("#create-system-link, #create-system-cancel").click(toggleFormAndLink("system"));
|
|
|
|
|
|
|
|
$("#create-system-submit").click(function() {
|
|
|
|
var submitting = false;
|
|
|
|
return function() {
|
|
|
|
if (submitting) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
submitting = true;
|
|
|
|
|
|
|
|
var $container = $("#create-system-form");
|
2011-02-28 07:27:38 +00:00
|
|
|
var $icon = $(this).find(".submit-icon");
|
2011-02-28 00:38:47 +00:00
|
|
|
var data = {
|
|
|
|
SystemName: $("#SystemName").val(),
|
|
|
|
SystemAbbreviation: $("#SystemAbbreviation").val(),
|
|
|
|
SystemReleaseDate: $("#SystemReleaseDate").val(),
|
|
|
|
SystemIcon: $("#SystemIcon").val()
|
|
|
|
};
|
2011-02-24 21:11:21 +00:00
|
|
|
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();
|
2011-02-28 07:27:38 +00:00
|
|
|
$icon.toggleClass("submit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
},
|
|
|
|
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;
|
2011-02-28 07:27:38 +00:00
|
|
|
$icon.toggleClass("submit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}());
|
|
|
|
|
|
|
|
$(".edit-system-link").click(function() {
|
|
|
|
var $link = $(this);
|
2011-02-28 07:27:38 +00:00
|
|
|
$link.toggleClass("edit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
var systemId = $link.siblings("input[name='SystemIds']").val();
|
|
|
|
|
|
|
|
$.vgquotes.getResourceById("system", systemId, function(system) {
|
2011-02-28 07:27:38 +00:00
|
|
|
$link.toggleClass("edit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
if (system === null) {
|
|
|
|
alert("Unable to fetch system " + systemId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleFormAndLink("system")();
|
|
|
|
$("#create-system-form > .edit-mode").val(systemId);
|
|
|
|
$("#create-system-form > fieldset > legend").text("Edit System");
|
|
|
|
|
|
|
|
//populate system form with system data
|
|
|
|
$("#SystemName").val(system.Name);
|
|
|
|
$("#SystemAbbreviation").val(system.Abbreviation);
|
|
|
|
$("#SystemReleaseDate").val($.vgquotes.parseAndFormatDate(system.ReleaseDate));
|
2011-02-28 00:38:47 +00:00
|
|
|
$("#SystemIcon").val(system.Icon);
|
2011-02-24 21:11:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".delete-system-link").click(function() {
|
|
|
|
var $link = $(this);
|
2011-02-28 07:27:38 +00:00
|
|
|
$link.toggleClass("delete-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
var systemId = $link.siblings("input[name='SystemIds']").val();
|
|
|
|
|
|
|
|
$.ajax("/system/delete", {
|
|
|
|
type: "POST",
|
|
|
|
data: { id: systemId },
|
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
if (data.Error !== null) {
|
|
|
|
alert(data.Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//remove checkbox for that system
|
|
|
|
$link.parent().empty();
|
|
|
|
},
|
2011-02-28 07:27:38 +00:00
|
|
|
complete: function() { $link.toggleClass("delete-icon loading-icon"); }
|
2011-02-24 21:11:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var setupGameForm = function() {
|
|
|
|
$("#create-game-link, #create-game-cancel").click(toggleFormAndLink("game"));
|
|
|
|
|
|
|
|
$("#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");
|
2011-02-28 07:27:38 +00:00
|
|
|
var $icon = $(this).find(".submit-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
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();
|
2011-02-28 07:27:38 +00:00
|
|
|
$icon.toggleClass("submit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
},
|
|
|
|
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;
|
2011-02-28 07:27:38 +00:00
|
|
|
$icon.toggleClass("submit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}());
|
|
|
|
|
|
|
|
$("#edit-game-link").click(function() {
|
2011-02-28 07:27:38 +00:00
|
|
|
$("#edit-game-link").toggleClass("edit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
var gameId = $("#GameId").val();
|
|
|
|
$.vgquotes.getResourceById("game", gameId, function(game) {
|
2011-02-28 07:27:38 +00:00
|
|
|
$("#edit-game-link").toggleClass("edit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
if (game === null) {
|
|
|
|
alert("Unable to fetch game " + gameId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleFormAndLink("game")();
|
|
|
|
$("#create-game-form > .edit-mode").val(1);
|
|
|
|
$("#create-game-form > fieldset > legend").text("Edit Game");
|
|
|
|
|
|
|
|
//populate game form with game data
|
|
|
|
$("#GameName").val(game.Name);
|
|
|
|
$("#GameWebsite").val(game.Website);
|
2011-02-28 00:38:47 +00:00
|
|
|
$("#GameIcon").val(game.Icon);
|
2011-02-24 21:11:21 +00:00
|
|
|
$.each(game.Regions, function() {
|
|
|
|
$("input[name='GameRegions'][value='" + this + "']").attr("checked", "checked");
|
|
|
|
});
|
|
|
|
$.each(game.Systems, function() {
|
|
|
|
$("input[name='SystemIds'][value='" + this.Id + "']").attr("checked", "checked");
|
|
|
|
});
|
|
|
|
$.each(game.Publishers, function() {
|
|
|
|
$("input[name='PublisherIds'][value='" + this.Id + "']").attr("checked", "checked");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#delete-game-link").click(function() {
|
|
|
|
var $link = $(this);
|
|
|
|
var gameId = $("#GameId").val();
|
|
|
|
|
|
|
|
$.ajax("/game/delete", {
|
|
|
|
type: "POST",
|
|
|
|
data: { id: gameId },
|
2011-02-28 07:27:38 +00:00
|
|
|
beforeSend: function() { $link.toggleClass("delete-icon loading-icon"); },
|
2011-02-24 21:11:21 +00:00
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
if (data.Error !== null) {
|
|
|
|
alert(data.Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//remove game from the dropdown
|
|
|
|
$("#GameId option[value='" + gameId + "']").remove();
|
|
|
|
},
|
2011-02-28 07:27:38 +00:00
|
|
|
complete: function() { $link.toggleClass("delete-icon loading-icon"); }
|
2011-02-24 21:11:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var setupPublisherForm = function() {
|
|
|
|
$("#create-publisher-link, #create-publisher-cancel").click(toggleFormAndLink("publisher"));
|
|
|
|
|
|
|
|
$("#create-publisher-submit").click(function() {
|
|
|
|
var submitting = false;
|
|
|
|
return function() {
|
|
|
|
if (submitting) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
submitting = true;
|
|
|
|
var $container = $("#create-publisher-form");
|
2011-02-28 07:27:38 +00:00
|
|
|
var $icon = $(this).find(".submit-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
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();
|
2011-02-28 07:27:38 +00:00
|
|
|
$icon.toggleClass("submit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
},
|
|
|
|
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;
|
2011-02-28 07:27:38 +00:00
|
|
|
$icon.toggleClass("submit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}());
|
|
|
|
|
|
|
|
$(".edit-publisher-link").click(function() {
|
|
|
|
var $link = $(this);
|
2011-02-28 07:27:38 +00:00
|
|
|
$link.toggleClass("edit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
var publisherId = $link.siblings("input[name='PublisherIds']").val();
|
|
|
|
|
|
|
|
$.vgquotes.getResourceById("publisher", publisherId, function(publisher) {
|
2011-02-28 07:27:38 +00:00
|
|
|
$link.toggleClass("edit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
if (publisher === null) {
|
|
|
|
alert("Unable to fetch publisher " + publisherId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleFormAndLink("publisher")();
|
|
|
|
$("#create-publisher-form > .edit-mode").val(publisherId);
|
|
|
|
$("#create-publisher-form > fieldset > legend").text("Edit Publisher");
|
|
|
|
|
|
|
|
//populate publisher form with publisher data
|
|
|
|
$("#PublisherName").val(publisher.Name);
|
|
|
|
$("#PublisherWebsite").val(publisher.Website);
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".delete-publisher-link").click(function() {
|
|
|
|
var $link = $(this);
|
2011-02-28 07:27:38 +00:00
|
|
|
$link.toggleClass("delete-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
|
|
|
|
$.ajax("/publisher/delete", {
|
|
|
|
type: "POST",
|
|
|
|
data: { id: $link.siblings("input[name='PublisherIds']").val() },
|
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
if (data.Error !== null) {
|
|
|
|
alert(data.Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//remove checkbox for that publisher
|
|
|
|
$link.parent().empty();
|
|
|
|
},
|
2011-02-28 07:27:38 +00:00
|
|
|
complete: function() { $link.toggleClass("delete-icon loading-icon"); }
|
2011-02-24 21:11:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var setupCategoryForm = function() {
|
|
|
|
var makeCategoryForm = function(categoryId) {
|
|
|
|
if ($("#new-category-name").length > 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var submitCategory = function() {
|
|
|
|
var $link = $(this);
|
|
|
|
var url = "/category/create";
|
|
|
|
var data = { CategoryName: $input.val() };
|
|
|
|
if (categoryId !== undefined) {
|
|
|
|
url = "/category/edit";
|
|
|
|
data.CategoryId = categoryId;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax(url, {
|
|
|
|
data: data,
|
|
|
|
type: "POST",
|
2011-02-28 07:27:38 +00:00
|
|
|
beforeSend: function() { $link.toggleClass("submit-icon loading-icon"); },
|
2011-02-24 21:11:21 +00:00
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
if (data.Error !== null) {
|
|
|
|
alert(data.Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (categoryId === undefined) {
|
|
|
|
//add category checkbox to table
|
|
|
|
var $checkbox = $("<input/>")
|
|
|
|
.css("display", "none")
|
|
|
|
.attr({
|
|
|
|
"id": "category_" + data.Data.Id,
|
|
|
|
"type": "checkbox",
|
|
|
|
"name": "CategoryIds",
|
|
|
|
"checked": "checked"
|
|
|
|
}).val(data.Data.Id);
|
|
|
|
|
|
|
|
var $label = $("<label/>")
|
|
|
|
.css("display", "none")
|
|
|
|
.attr("for", $checkbox.attr("id"))
|
|
|
|
.text(data.Data.Name);
|
|
|
|
|
|
|
|
$("#new-category-name").before($checkbox).before($label);
|
|
|
|
} else {
|
|
|
|
$("#new-category-name").siblings("label").text(data.Data.Name);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
complete: function() {
|
2011-02-28 07:27:38 +00:00
|
|
|
$link.toggleClass("submit-icon loading-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
var $cell = $("#new-category-name").parent();
|
|
|
|
$cell
|
|
|
|
.children(":visible").remove().end()
|
|
|
|
.children().show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
var $table = $("#category-checkbox-table"), $cell;
|
2011-02-28 07:27:38 +00:00
|
|
|
var $submit = $("<a/>").attr({ href: "#", title: "submit" }).addClass("submit-icon").click(submitCategory);
|
|
|
|
var $cancel = $("<a/>").attr({ href: "#", title: "cancel" }).addClass("cancel-icon");
|
2011-02-24 21:11:21 +00:00
|
|
|
var $input = $("<input/>").attr({ id: "new-category-name", type: "text" }).bind("keyup", function(e) {
|
|
|
|
if (e.which === 13) {
|
|
|
|
e.preventDefault(); //make sure the parent form doesn't get submitted
|
2011-02-28 07:27:38 +00:00
|
|
|
submitCategory.call($(this).siblings(".submit-icon").get(0)); //make sure to invoke it with the correct context
|
2011-02-24 21:11:21 +00:00
|
|
|
} else if (e.which === 27) {
|
|
|
|
e.preventDefault();
|
|
|
|
$cancel.click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (categoryId !== undefined) {
|
|
|
|
$cell = $table.find("input[value='" + categoryId + "']").parent();
|
|
|
|
$cell.children().hide();
|
|
|
|
$cancel.click(function() {
|
|
|
|
$input.remove();
|
|
|
|
$submit.remove();
|
|
|
|
$cancel.remove();
|
|
|
|
$cell.children().show();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$input.val($cell.find("label").text());
|
|
|
|
$cell.append($input).append($submit).append($cancel);
|
|
|
|
$input.select();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var $row = $table.find("tr:last");
|
2011-03-04 08:20:37 +00:00
|
|
|
if ($row.length === 0) {
|
|
|
|
$row = $("<tr/>");
|
|
|
|
$table.append($row);
|
|
|
|
}
|
2011-02-24 21:11:21 +00:00
|
|
|
$cell = $("<td/>");
|
|
|
|
if ($row.find("td").length === 5) {
|
|
|
|
$row = $("<tr/>");
|
|
|
|
$table.append($row);
|
|
|
|
}
|
|
|
|
|
|
|
|
$row.append($cell);
|
|
|
|
$input.val("Category name");
|
|
|
|
|
|
|
|
$cancel.click(function() {
|
|
|
|
$cell.remove();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$cell.append($input).append($submit).append($cancel);
|
|
|
|
$input.select();
|
|
|
|
};
|
|
|
|
|
|
|
|
$("#create-category-link").click(function() {
|
|
|
|
makeCategoryForm.call(this);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
$(".edit-category-link").click(function() {
|
|
|
|
var categoryId = $(this).siblings("input[name='CategoryIds']").val();
|
|
|
|
makeCategoryForm.call(this, categoryId);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
$(".delete-category-link").click(function() {
|
|
|
|
var categoryId = $(this).siblings("input[name='CategoryIds']").val();
|
|
|
|
var $link = $(this);
|
|
|
|
$.ajax("/category/delete", {
|
|
|
|
type: "POST",
|
|
|
|
data: { id: categoryId },
|
2011-02-28 07:27:38 +00:00
|
|
|
beforeSend: function() { $link.toggleClass("delete-icon loading-icon"); },
|
2011-02-24 21:11:21 +00:00
|
|
|
success: function(data) {
|
|
|
|
if (data.Error !== null) {
|
|
|
|
alert(data.Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//remove checkbox
|
|
|
|
$("#category-checkbox-table").find("input[value='" + categoryId + "']").parent().empty();
|
|
|
|
},
|
2011-02-28 07:27:38 +00:00
|
|
|
complete: function() { $link.toggleClass("delete-icon loading-icon"); }
|
2011-02-24 21:11:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var setupFlagLink = function() {
|
|
|
|
$(".dismiss-flag-link").click(function() {
|
|
|
|
var $link = $(this);
|
|
|
|
var $container = $link.parents(".quote-flag");
|
|
|
|
var flagId = $container.find(".quote-flag-id").val();
|
|
|
|
var quoteId = $("#quote-id").val();
|
|
|
|
|
|
|
|
$.ajax("/dismiss-flag", {
|
|
|
|
type: "POST",
|
|
|
|
data: { quoteId: quoteId, flagId : flagId },
|
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
if (data.Error !== null) {
|
|
|
|
alert(data.Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$container.remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
//initialize everything
|
|
|
|
(function() {
|
|
|
|
$(document).ready(function() {
|
|
|
|
setupGameForm();
|
|
|
|
setupSystemForm();
|
|
|
|
setupPublisherForm();
|
|
|
|
setupCategoryForm();
|
|
|
|
setupFlagLink();
|
|
|
|
});
|
|
|
|
}());
|
|
|
|
|
|
|
|
}(jQuery, window));
|