summaryrefslogtreecommitdiffstats
path: root/static/functions/sort.js
diff options
context:
space:
mode:
authorGit <git@what.cd>2012-10-27 08:00:09 +0000
committerGit <git@what.cd>2012-10-27 08:00:09 +0000
commitac74044ec272101a730c5735b76b5ec8f5df9ca5 (patch)
tree6e2067111e2d5a3a1e0fcb1f985fec4ff74d8c55 /static/functions/sort.js
parent7d8e070bf839a73e8d2d058feceda42ba7fa0563 (diff)
downloadGazelle-ac74044ec272101a730c5735b76b5ec8f5df9ca5.zip
Gazelle-ac74044ec272101a730c5735b76b5ec8f5df9ca5.tar.gz
Gazelle-ac74044ec272101a730c5735b76b5ec8f5df9ca5.tar.bz2
Empty commit
Diffstat (limited to 'static/functions/sort.js')
-rw-r--r--static/functions/sort.js183
1 files changed, 103 insertions, 80 deletions
diff --git a/static/functions/sort.js b/static/functions/sort.js
index 11e3f2f..fe47206 100644
--- a/static/functions/sort.js
+++ b/static/functions/sort.js
@@ -1,82 +1,105 @@
- var sortCollageTable;
- jQuery(document).ready(function ($) {
- sortCollageTable = {
- counter: function () {
- var x = 10;
- $('.sort_numbers').each(function () {
- this.value = x;
- x += 10;
- });
- this.serializer();
- },
- color : function () {
- var i = 0, css;
- $('.drag').each(function () {
- css = i % 2 === 0 ? ['rowa', 'rowb'] : ['rowb', 'rowa'];
- $(this).removeClass(css[0]).addClass(css[1]);
- i++;
- });
- },
- serializer : function () {
- var s = this.container.sortable('serialize');
- this.serialInput.val(s);
- },
- save : function () {
- this.form.submit();
- },
- widthFix : function(e, row) {
- row.children('td').each(function () {
- $(this).width($(this).width());
- });
- return row;
- },
- init : function () {
- this.container = $('#manage_collage_table');
- this.form = $('#drag_drop_collage_form');
- this.serialInput = $('#drag_drop_collage_sort_order');
- $('.drag_drop_save').toggleClass('hidden');
-
- this.container.sortable({
- items: '.drag',
- axis: 'y',
- containment: '.thin',
- forcePlaceholderSize: true,
- helper: sortCollageTable.widthFix,
- stop: function () {
- sortCollageTable.postSort();
- }
- });
+var sortableTable;
+jQuery(document).ready(function ($) {
+ sortableTable = {
+ container : $('#manage_collage_table'),
+ form : $('#drag_drop_collage_form'),
+ serialInput : $('#drag_drop_collage_sort_order'),
+ check : $('#check_all'),
+ counter : function () {
+ var x = 10;
+ $('input.sort_numbers').each(function () {
+ this.value = x;
+ x += 10;
+ });
+ this.serializer();
+ },
+ color : function () {
+ var i = 0, css;
+ $('tr.drag').each(function () {
+ css = i % 2 === 0 ? ['rowa', 'rowb'] : ['rowb', 'rowa'];
+ $(this).removeClass(css[0]).addClass(css[1]);
+ i++;
+ });
+ },
+ serializer : function () {
+ this.serialInput.val(this.container.sortable('serialize'));
+ },
+ save : function () {
+ sortableTable.form.submit();
+ },
+ widthFix : function(e, row) {
+ row.children('td').each(function () {
+ $(this).width($(this).width());
+ });
+ return row;
+ },
+ init : function () {
+ $('.drag_drop_save').removeClass('hidden');
- $('.save_sortable_collage').click(function () {
- sortCollageTable.save();
- });
-
- this.tableSorter();
- },
- tableSorter : function () {
- this.container.tablesorter({
- cssHeader : 'headerSort',
- textExtraction: sortCollageTable.extractor,
- headers : {
- 0: {
- sorter : false
- },
- 6: {
- sorter : false
- }
- }
- });
- this.container.bind('sortEnd', function () {
- sortCollageTable.postSort();
- });
- },
- extractor : function (node) {
- return node.textContent || node.innerText;
- },
- postSort : function () {
- this.color();
- this.counter();
+ this.noteToggle();
+ this.draggable();
+ this.tableSorter();
+
+ if (this.check.length !== 0) {
+ this.checks();
+ } else {
+ $('.save_sortable_collage').click(sortableTable.save);
}
- };
- sortCollageTable.init();
- }); \ No newline at end of file
+ },
+ draggable : function () {
+ this.container.sortable({
+ items: '.drag',
+ axis: 'y',
+ containment: '.thin',
+ forcePlaceholderSize: true,
+ helper: sortableTable.widthFix,
+ stop: sortableTable.postSort
+ });
+ },
+ tableSorter : function () {
+ this.container.tablesorter({
+ cssHeader : 'headerSort',
+ textExtraction: sortableTable.extractor,
+ headers : {
+ 0: {
+ sorter : false
+ },
+ 6: {
+ sorter : false
+ }
+ }
+ }).on('sortEnd', sortableTable.postSort);
+ },
+ extractor : function (node) {
+ return node.textContent || node.innerText;
+ },
+ postSort : function () {
+ sortableTable.color();
+ sortableTable.counter();
+ },
+ noteToggle : function () {
+ var span = $('<a href="#" title="Toggle Note">(Hide)</a>').click(function (e) {
+ e.preventDefault();
+ $('#drag_drop_textnote > :first-child').toggle();
+ $this = $(this);
+ $this.text($this.text() === '(Hide)' ? '(Show)' : '(Hide)');
+ });
+ $('#sorting_head').append(' ', span);
+ },
+ checks : function () {
+ this.check.on('click', 'input', function () {
+ var s = this.checked ?
+ 'td.center :checkbox:not(:checked)' :
+ 'td.center :checked';
+ $(s).click();
+ }).find('span').html('<input type="checkbox" />');
+
+ this.container.on('click', 'td > :checkbox', function() {
+ $(this).parents('tr').toggleClass('row_checked');
+ }).on('dblclick', 'tr.drag', function () {
+ $(this).find(':checkbox').click();
+ });
+ }
+ };
+ sortableTable.init();
+}); \ No newline at end of file