summaryrefslogtreecommitdiffstats
path: root/static/functions/release_sort.js
diff options
context:
space:
mode:
authorGit <git@what.cd>2012-11-16 08:00:21 +0000
committerGit <git@what.cd>2012-11-16 08:00:21 +0000
commiteb6d64c3a9374192c1a6ec99d9b5644bdbe3265a (patch)
tree61843c572a2cc4d75e890a815c817dece1dcc665 /static/functions/release_sort.js
parent88d8e565f0d339a62e4d8f7336fe45830b6b2fc0 (diff)
downloadGazelle-eb6d64c3a9374192c1a6ec99d9b5644bdbe3265a.zip
Gazelle-eb6d64c3a9374192c1a6ec99d9b5644bdbe3265a.tar.gz
Gazelle-eb6d64c3a9374192c1a6ec99d9b5644bdbe3265a.tar.bz2
Empty commit
Diffstat (limited to 'static/functions/release_sort.js')
-rw-r--r--static/functions/release_sort.js66
1 files changed, 33 insertions, 33 deletions
diff --git a/static/functions/release_sort.js b/static/functions/release_sort.js
index 8a74077..ab1664b 100644
--- a/static/functions/release_sort.js
+++ b/static/functions/release_sort.js
@@ -1,40 +1,40 @@
//Couldn't use an associative array because javascript sorting is stupid http://dev-answers.blogspot.com/2012/03/javascript-object-keys-being-sorted-in.html
-(function($) {
- var DEFAULT = '\x3Cul class=\"sortable_list ui-sortable\" id=\"sortable\" style=\"\"\x3E\n\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"1_0\"\x3EAlbum\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"3_0\"\x3ESoundtrack\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"5_0\"\x3EEP\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"6_0\"\x3EAnthology\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"7_0\"\x3ECompilation\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"9_0\"\x3ESingle\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"11_0\"\x3ELive album\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"13_0\"\x3ERemix\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"14_0\"\x3EBootleg\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"15_0\"\x3EInterview\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"16_0\"\x3EMixtape\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"21_0\"\x3EUnknown\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"1024_0\"\x3EGuest Appearance\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"1023_0\"\x3ERemixed By\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"1022_0\"\x3EComposition\x3C\x2Fli\x3E\n\t\t\x3Cli class=\"sortable_item\" style=\"\"\x3E\x3Cinput type=\"checkbox\" id=\"1021_0\"\x3EProduced By\x3C\x2Fli\x3E\n\t\t\x3C\x2Ful\x3E';
- $(document).ready(function() {
+jQuery(document).ready(function ($) {
+ var serialize = function () {
+ var a = [];
+ $('#sortable input').each(function () {
+ a.push($(this).attr('id'));
+ });
+ $('#sorthide').val(JSON.stringify(a));
+ };
+
serialize();
- $("#sortable").sortable({
- placeholder: "ui-state-highlight",
- update: function() {
- serialize();
- }
- });
- $("#toggle_sortable").click(function () {
- $('#sortable_container').slideToggle(function() {
- $("#toggle_sortable").text($(this).is(":visible") ? "Collapse" : "Expand");
+
+ $('#sortable')
+ .on('click', 'input', function () {
+ // the + converts the boolean to either 1 or 0
+ var c = +$(this).is(':checked'),
+ old_id = $(this).attr('id'),
+ new_id = old_id.slice(0, -1) + c;
+ $(this).attr('id', new_id);
+ serialize();
+ })
+ .sortable({
+ placeholder: 'ui-state-highlight',
+ update: serialize
+ });
+
+ $('#toggle_sortable').click(function (e) {
+ e.preventDefault();
+ $('#sortable_container').slideToggle(function () {
+ $('#toggle_sortable').text($(this).is(':visible') ? 'Collapse' : 'Expand');
});
});
- $("#reset_sortable").click(function () {
- $('#sortable').html(DEFAULT);
+
+ $('#reset_sortable').click(function (e) {
+ e.preventDefault();
+ $('#sortable').html(sortable_list_default); // var sortable_list_default is found on edit.php
serialize();
});
- });
- function serialize() {
- var a = new Array();
- $("#sortable").find("input").each(function (i) {
- $(this).unbind("click");
- $(this).click(function() {
- var c = $(this).attr("checked") == "checked" ? 1 : 0;
- var old_id = $(this).attr("id");
- var new_id = old_id.slice(0, - 1) + c;
- $(this).attr("id", new_id);
- serialize();
- });
- a.push($(this).attr("id"));
- });
- $("#sorthide").val(JSON.stringify(a));
- }
-}
-(jQuery));
-
+}); \ No newline at end of file