forked from EvanOman/KanbanBoard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKanban.js
5289 lines (4208 loc) · 192 KB
/
Kanban.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright(c) 2012, Eckhardt Optics
The JavaScript code in this page is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
Document : kanban.js
Created on : May 23, 2012
Authors : Evan Oman, John Eckhardt
Description:
This file handles all of the functionality requitred to:
1. Provide the user with a usable and interactive Kanban interface for the Bugzilla Bug tracking system
2. Communicate with the PHP files that query the Bugzilla Server
3. Communicate with the PHP files that store .ini settings
*/
//First we want global variables to store the priority icons and the jobMap colors
var prioMap = {};
var jobMap = {};
var prioSortKey = {};
var limitWIP ={};
colDivChar = "";
//USed to store form data in case the user submits a bad value to the server
var cardChangeData = [];
//These variables represent our loading ajax calls. At first we are waiting for them(hence the defferred)
var getCompsVersXHR = $.Deferred();
var getNamesXHR = $.Deferred();
var getAccProXHR = $.Deferred();
var getFormFieldsXHR = $.Deferred();
//An object that stores the compoonent and version relationship to the product
var componentData = null;
//Stores the .ini setting where a card can be and where it goes if something is wrong
var allowedColumnMap = {};
var defaultColumnMap = {};
//Stores the neswted column object that we use to build the board
var columnNest = {};
//Used to store which columns belong hidden on load
var tabColumns = [];
//Stores the relationship between Bugzilla's names for columns and our column IDs
var colSortKeyMap = {};
//HEre we have a global array that stores the ids of all the items being sorted
var sortingArray = [];
//Starts the update timer that keeps the board up to date
var updateTimer = setTimeout(updateBoard, 30000);
//The base element for determing shift selection
var baseShiftClickItem;
//Some bugzilla field names are different than the bug parameter names. This object stores these relationships
var bugzillaFieldtoParam = {
"bug_status": "status",
"bug_severity": "severity",
"rep_platform": "platform"
};
//Stores the current filter being applied to the tab columns
var tabColumnFilter = {};
//Stores the updated card data for a card whose edit dialog is open
var updateData = {};
//Keeps a record of the loading messages telling the user about status related changes:
var messageArr =[];
//Stores the ids that have administrative privelages
var adminIds = [];
//Provides a default Card color if the .ini doesnt work
var defaultCardColor = "rgb(255,255,255)";
//Here we set the global search limit(to prevent massive server and client side lag)
var cardPopulateLimit = 5000;
//Stores the current offset for each tabcolumn(to prevent overload)
var tabSearchOffset = {};
//Sets the default theme to hot-sneaks
//$("#jqueryCss").attr("href", "themes/hot-sneaks/jquery-ui.css");
var theme;
//Pulls down the .ini settings and sets variables accordingly
function initialize()
{
$.ajax({
url: "ajax_get_options.php",
dataType: "json",
success: function(data){
if (data.error)
{
alert(data.error);
}
else if (!data.success)
{
alert("Something is wrong");
}
else
{
if (!$.isEmptyObject(data.options))
{
prioMap = data.options.prioIcons;
jobMap = data.options.jobColors;
allowedColumnMap = data.options.allowedColumnMap;
defaultColumnMap = data.options.defaultColumnMap;
limitWIP = data.options.limitWIP;
theme = data.options.theme.theme;
$("#jqueryCss").attr("href", "themes/"+theme+"/jquery-ui.css");
if (!$.isEmptyObject(data.options.colDivChar))
{
colDivChar = data.options.colDivChar.colDivChar;
}
if (!$.isEmptyObject(data.options.tabColumns))
{
tabColumns = data.options.tabColumns.tabColumns;
}
if (!$.isEmptyObject(data.options.adminIds))
{
adminIds = data.options.adminIds.adminIds;
}
}
else
{
}
//We dont want this function to run until the initialize function completes but we also want the document to be ready
$(document).ready(function() {
//First things first we want to populate the board with the correct cards:
boardCardPopulate();
//And configure the board according to the user type
if (adminIds.indexOf(userID) == -1 && adminIds.length != 0)
{
$("#btnOptions").remove();
$("#dialogOptions").empty().dialog("destroy");
}
});
}
},
error: function(jqXHR, textStatus, errorThrown){
alert("There was an error:" + textStatus);
}
});
}
//Here we call initialize so it is the first function to fire
initialize();
/*---------------------------------------------------------------------------BEGIN DOCUMENT READY ------------------------------------------------------------------------*/
$(document).ready(function() {
//Add a loading class to the dialogs so they cant be used until all of the fields are loaded
$('body, #Details, #dialogSearch, #dialogOptions, #productChangeDiv').addClass("loading");
//Adds the current product to the options
$("select[name='boardProduct'], #product, #searchProduct, #optProduct").append("<option>"+boardProduct+"</option>");
$("select[name='boardProduct'], #product").val(boardProduct);
/*-------------AJAX Calls---------------------*/
getCompsVersXHR = $.ajax({
//Need this to be completed before other actions occur:
//async: false,
url: "ajax_POST.php",
type: "POST",
data: {
"method": "Bug.fields",
"names": ["component", "version"],
"value_field": "product"
},
dataType: "json",
success: function(data){
if (data.result.faultString != null)
{
alert(data.result.faultString+'\nError Code: '+data.result.faultCode);
}
else if (!data.result)
{
alert("Something is wrong");
}
else
{
//Stores the comoponent and version data for future use
componentData = data.result.fields;
getCompsVers([boardProduct], "Details");
getCompsVers(null, "dialogSearch");
getCompsVers(null, "dialogOptions");
}
},
error: function(jqXHR, textStatus, errorThrown){
alert("(Fields)There was an error:" + textStatus);
}
});
//An Ajax call that finds all accessible product ids.
getAccProXHR = $.ajax({
url: "ajax_POST.php",
type: "POST",
data:{
"method": "Product.get_accessible_products"
},
dataType: "json",
success: function(data){
if (data.result.faultString != null)
{
alert(data.result.faultString+'\nError Code: '+data.result.faultCode);
}
else if (!data.result)
{
alert("Something is wrong");
}
var productIds = data.result.ids;
getNames(productIds);
},
error: function(jqXHR, textStatus, errorThrown){
alert("There was an error:" + textStatus);
}
});
//A single Ajax call that finds all the specified field option values
getFormFieldsXHR = $.ajax({
url: "ajax_POST.php",
//async: false,
type: "POST",
data: {
"method": "Bug.fields"
},
dataType: "json",
success: function(data){
if (data.result.faultString != null)
{
alert(data.result.faultString+'\nError Code: '+data.result.faultCode);
}
else if (!data.result)
{
alert("Something is wrong");
}
else
{
//Instead of merely populating existing fields, I am going to actually build the dialog add/edit
//menu based off of the Bugzilla field-type parameter which has the following map:
/*
*Number Form Type
* 0 Unknown
* 1 Free Text(iput type=text?)
* 2 Drop Down(Select)
* 3 Multiple-Selection Box(Select multiple = multiple)
* 4 Large Text Box(textarea)
* 5 Date/Time(datepicker)
* 6 Bug Id(input type=number?)
* 7 Bug URLs(input)
*/
for (var j in data.result.fields)
{
//Gets the backend name for the field
var fieldName = data.result.fields[j].name;
if (fieldName == "component" || fieldName == "product" || fieldName == "classification")
{
continue;
}
//Gets the display name for the field
var fieldDisplayName = data.result.fields[j].display_name;
//Finds the field type number:
var fieldType = data.result.fields[j].type;
var html = $("<div>");
html.append("<label>"+fieldDisplayName+"</label>");
switch(fieldType){
case 2:
html.append( "<select class=' ui-widget-content ui-corner-all' name='"+fieldName+"'></select>");
break;
case 3:
html.append("<select class=' ui-widget-content ui-corner-all' name='"+fieldName+"' multiple='multiple'></select>");
break;
case 4:
html.append( "<textarea class=' ui-widget-content ui-corner-all' name='"+fieldName+"' style='height:100%; width: 100%;'></textarea>");
break;
case 5:
var date = "<input class=' ui-widget-content ui-corner-all' type='text' name='"+fieldName+"'/>";
//Allows calendar plugin
$( date ).datepicker({
dateFormat: "yy-mm-dd"
}).appendTo(html);
break;
case 7:
case 8:
case 0:
if (fieldName == "assigned_to")
{
html.append("<input class=' ui-widget-content ui-corner-all' type='text' name='"+fieldName+"'/>");
break;
}
else
{
continue;
}
case 1:
case 6:
html.append("<input class=' ui-widget-content ui-corner-all' type='text' name='"+fieldName+"'/>");
break;
default:
console.error("Invalid Field Type\nField Name: "+fieldName+"\nType: " +fieldType);
break;
}
//Appends the field to the dialogs
$("#detailsLeft, #optFilterDiv, #searchFieldsDiv").append(html);
//Priority has a context menue that needs to be populated as well
if (fieldName == "priority")
{
//Populates the priority context menu as well
for (var i in data.result.fields[j].values)
{
//get the value
var prio = data.result.fields[j].values[i].name;
var sortkey = data.result.fields[j].values[i].sort_key;
prioSortKey[prio]=sortkey;
//create an option element with the inner html being the name
var a = $("<a>").html(prio);
//append the option to the context menu
$("#setPriority").append(a);
}
}
//Need to create the column-ID map:
else if (fieldName == "cf_whichcolumn")
{
//Populates the priority context menu as well
for (var k in data.result.fields[j].values)
{
//get the value
var colName = data.result.fields[j].values[k].name;
var columnID = data.result.fields[j].values[k].sort_key;
colSortKeyMap[colName] = "column_"+columnID;
if (colName != "---")
{
var anc = $("<a>").html(colName).attr("value", colSortKeyMap[colName]);
//append the option to the context menu
$("#moveAllCards, #moveCardTo").append(anc);
}
}
//Starts the column appending process
buildBoardHelper();
}
if ( fieldType == 2 || fieldType == 3)
{
//iterate through all the allowed values for this field
for (var i in data.result.fields[j].values)
{
//get the value
var nameVal = data.result.fields[j].values[i].name;
//create an option element with a value and the inner html being the name
selectOption = $("<option>").val(nameVal).html(nameVal);
//append the option to the <select>
$("select[name="+fieldName+"]").append(selectOption);
}
}
}
//Then we want to remove the loading screen
$('#Details, #dialogSearch, #dialogOptions').removeClass("loading");
}
},
error: function(jqXHR, textStatus){
alert("(Fields)There was an error:" + textStatus);
}
});
/*-------------Jquery UI Initialization---------------------*/
//These features require that the columns be initialized:
//We need to wait for the columns to be added
$.when(getFormFieldsXHR).done(function(){
//Enables the sortable behavior that allows the reordering of the cards
$( ".column,.tablists" ).sortable({
connectWith: ".column,.tablists",
placeholder: "ui-state-highlight",
forcePlaceholderSize: true,
tolerance: 'pointer',
appendTo: 'body',
cursorAt: {
top: 15
},
cancel: "li:has(.loading), li.swimlane",
//The items parameter expects only a selector which prevents the use of Jquery so here I have made a(likely very inefficent) selector which selects every li with a card in it that isn't loading
items: "li:has(.card):not(:has(.loading)), li.swimlane",
start: function(event, ui)
{
//If the element is part of a selected group we need to hide the selected elements because we are moving
if ($(ui.item).find(".card").hasClass("sorting-selected"))
{
$(".column .sorting-selected, .tablists .sorting-selected").each(function(){
var id = $(this).attr("id");
sortingArray.push(id);
}).parent().hide();
}
},
stop: function(event, ui)
{
//If isSorted is true we know that the sorted card has been successfully received. If it equals undefined we know that the receive was never hit(ie the sortable
//card was dragged back to its original column). The only way we want to cancel is if isSorted is false
var condition = ($(ui.item).data("isSorted") || typeof($(ui.item).data("isSorted")) == "undefined");
//If the card we are moving is part of a selected group we need to move the group wherever the card moves to
if ($(ui.item).find(".card").hasClass("sorting-selected") && condition)
{
var sortColumn = ui.item.parent().attr("id");
var cardArr = [];
$(".sorting-selected").each(function(){
var col = $(this).data("cf_whichcolumn");
if (col != sortColumn)
{
cardArr.push($(this));
}
});
if (cardArr.length)
{
appendCard(cardArr, sortColumn);
}
$(".sorting-selected").removeClass("sorting-selected").parent().show();
}
$(".sorting-selected:hidden").parent().show();
$(ui.item).removeData();
sortingArray = [];
},
//Updates the cards position whenever it is moved
receive: function(event, ui) {
var cardId = ui.item.find(".card").attr("id");
var status = $("#"+cardId).data("status");
var col = $(this);
var colID = reverseKeyLookup(colSortKeyMap, col.attr("id"));
if (allowedColumnMap[status].indexOf(colID) == -1)
{
$(ui.item).data("isSorted", false);
alert(colID + " is not a valid Column choice for the "+status+" status");
$(ui.sender).sortable('cancel');
}
else
{
//Updates the card's stored position
updatePosition(col.attr("id"),cardId );
$(document).trigger("columnChange", [$(ui.sender).attr("id"), $(this).attr("id")]);
$(ui.item).data("isSorted", true);
}
$(".sorting-selected:hidden").parent().show();
},
helper: function(event, element){
//If the element doesnt has a selected class we know that this element doesn't need the helper div
if (!$(element).find(".card").hasClass("sorting-selected"))
{
return element;
}
//If the above is false we know that there are selected elements that need to be cloned and shown in the drag
else
{
var div = $("<div></div>");
$(".sorting-selected").clone().appendTo(div);
return div;
}
}
}).disableSelection();
//Initially diables the sorting of tabbed items
$(".tablists").sortable("disable");
});
//Adds button styling to all the buttons
$("button").button();
//Sets up the invalids entry dialog menu
$( "#dialogInvalid" ).dialog({
autoOpen: false,
show: "blind",
hide: "explode",
modal: true,
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
//Sets up the changed data dialog menu
$( "#dialogDataChanged" ).dialog({
autoOpen: false,
title: "External Change Detected",
show: "blind",
hide: "explode",
modal: true,
height: "auto",
width: 500,
resizable: false,
closeOnEscape: false,
open: function(event, ui) {
$(" .ui-dialog-titlebar-close", $(this).parent()).hide();
},
buttons: {
"Keep My Changes": function(){
$(this).dialog("close");
},
"Use External Changes": function(){
var cardId = $("#dialogAddEditCard").data("cardId")
// $("#dialogAddEditCard").dialog("close");
editCard($("#"+cardId).data());
$(this).dialog("close");
}
}
});
//Sets up the changed data dialog menu
$( "#dialogChangeProduct" ).dialog({
autoOpen: false,
title: "Change your Product?",
show: "blind",
hide: "explode",
modal: true,
height: "auto",
width: 500,
resizable: false,
buttons: {
"Change Product": function(){
var newProduct = $("select[name='boardProduct']").val();
changeBoardProduct(newProduct);
$(this).dialog("close");
},
Cancel: function(){
$(this).dialog("close");
}
}
});
//Sets up the invalids entry dialog menu
$( "#dialogNoResults" ).dialog({
autoOpen: false,
show: "blind",
hide: "explode",
modal: true,
buttons: {
Close: function() {
$( this ).dialog( "close" );
}
}
});
//Creates the sort/filter dialog
$( "#dialogSort" ).dialog({
autoOpen: false,
resizable: false,
height: 250,
width: "auto",
show: {
effect: 'blind'
},
hide: "explode",
modal: true
});
//Creates the options dialog
$( "#dialogOptions" ).dialog({
autoOpen: false,
resizable: false,
height: 750,
width: 1350,
show: {
effect: 'blind'
},
hide: "explode",
modal: true,
buttons: {
Save: function(){
//Want to make sure all of the option value have been loading before we can save anything
if (!$("#dialogOptions").hasClass("loading"))
{
dialogOptionsSave();
}
},
Close: function() {
$("#adminInputs input").each(function(){
$(this).parent().remove();
});
$( this ).dialog( "close" );
}
}
});
//Creates the search dialog box
$( "#dialogSearch" ).dialog({
autoOpen: false,
resizable: false,
height: "auto",
width: 1400,
show: {
effect: 'blind',
complete: function() {
$("#searchSummary").focus();
}
},
hide: "explode",
modal: true,
close: function(){
//Here we completely reset the search dialog
$( "#bugs tbody tr, #next" ).remove();
$("#prev, #next" ).remove();
$("#pageNumDiv, #Results p").empty();
$("#searchSummary").val("");
$("#dialogSearch .box").hide();
}
});
//Creates the filter dialog box
$( "#dialogFilter").dialog({
autoOpen: false,
resizable: false,
height: "auto",
width: 1400,
title: "Advanced Filter",
show: {
effect: 'blind'
},
hide: "explode",
modal: true,
buttons: {
"Apply Filter": function(){
dialogFilterSubmit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function(){
$("#dialogFilter #optFilterDiv .box select, #dialogFilter #optFilterDiv .box input, #filterFieldOption").val("");
}
});
//Creates the edit dialog box
$( "#dialogAddEditCard" ).dialog({
autoOpen: false,
height: 650,
width: 1060,
resizable: false,
show: {
effect: 'highlight',
complete: function() {
$("#Details textarea[name=summary]").focus();
}
},
hide: "explode",
modal: true,
buttons: {
"Save Card": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
//Resets all the feilds to null to allow a fresh dialog window each time
close: function() {
$("#Details input, #Details textarea, #Details select").val("");
}
});
//Allows the tabs on the edit dialog
$( "#edit-tabs" ).tabs();
//Sets up radio button styling
$("#sortRadioDiv").buttonset();
/*-------------Event Handlers-----------------*/
$("body").ajaxSuccess(function(e, request, options){
if (options.dataType == 'json') {
var data = eval('(' + request.responseText + ')');
if (data.result != null)
{
if (data.result.faultCode != null)
{
if (data.result.faultCode == 300 || data.result.faultCode == 301 || data.result.faultCode == 410)
{
document.location.href = "loginpage.php";
}
}
}
}
})
$("body").on("click", ".bigBanners .tabNextBugs", function(){
var tab = $(this).parent().siblings(".tablists");
var id = tab.attr("id");
tab.parent().addClass("loading");
tablistCardPopulate(id, cardPopulateLimit, tabSearchOffset[id]);
});
$(".toolbar").on("click", "#btnChangeProduct", function() {
//if we have a product already selected, let's check to make sure they want to change
if (boardProduct.length) {
$("#dialogChangeProduct").empty().append("<p>Do you want to switch products from <b>"+boardProduct+ "</b> to <b>"+$(".toolbar select[name='boardProduct']").val()+"</b>?(This will reload the page)</p>");
$("#dialogChangeProduct").dialog("open");
} else {
//otherwise, just change it
changeBoardProduct($(".toolbar select[name='boardProduct']").val());
}
});
$(".toolbar select[name='boardProduct']").change(function(){
var product = $(this).val();
if (product != boardProduct)
{
if ($('#btnChangeProduct').length == 0) {
var btn = $("<button id='btnChangeProduct'>").text("Change Products").button().css("font-size", "12px");
$(".toolbar select[name='boardProduct']").after(btn);
}
}
else
{
$("#btnChangeProduct").remove();
}
})
$("#themeSelect").change(function(){
var theme = $(this).val();
$("#jqueryCss").attr("href", "themes/"+theme+"/jquery-ui.css");
});
$("#dialogOptions").on("click", "#addAdmin", function(){
$(this).parent().before("<td><input type='number' min='1' /></td>")
});
$(".columnContainer").on("click", ".btnRemoveFilter", function(){
//Resets the filter object to empty;
tabColumnFilter = {};
//Filters with a null filter which resets the tablists to pre filter state
advancedFilter(null, ".tablists");
});
$(".toolbar").on("click", "#btnFilter", function(){
dialogFilterOpen();
});
//Sets a change on the default column choice to make sure that the defaulted column is listed as an allowed column
$( "#defaultColumnDiv " ).on( "change",".box select:not([multiple='multiple'])" ,function(e) {
var defVal = $(this).val();
var multiple = $(this).siblings("[multiple='multiple']");
var valArr = multiple.val();
if (valArr != null)
{
valArr.push(defVal);
multiple.val(valArr);
}
else
{
multiple.val(defVal);
}
});
$( ".columnContainer" ).on( "click",".column, .tablists" ,function(e) {
$('.sorting-selected').removeClass('sorting-selected');
});
$( ".columnContainer" ).on( "click",".card" ,function(e) {
e.stopPropagation();
if (!$(this).hasClass("loading"))
{
if (e.ctrlKey)
{
$(this).toggleClass('sorting-selected');
}
else if (e.shiftKey)
{
if (!$('.sorting-selected').length)
{
$(this).toggleClass('sorting-selected');
}
else
{
$('.sorting-selected').removeClass('sorting-selected');
//Re adds the class to the end elements
$("#"+baseShiftClickItem).addClass('sorting-selected');
$(this).addClass('sorting-selected');
var startCol = $("#"+baseShiftClickItem).closest("ul").attr("id");
var endCol = $(this).closest("ul").attr("id");
var startIndex = $("#"+baseShiftClickItem).parent().index();
var endIndex = $(this).parent().index();
if (startCol == endCol)
{
if (startIndex < endIndex && Math.abs(startIndex - endIndex) != 1)
{
$("#"+startCol +" li:lt("+endIndex+"):gt("+startIndex+") .card").addClass('sorting-selected');
}
else if (Math.abs(startIndex - endIndex) != 1)
{
$("#"+startCol +" li:lt("+startIndex+"):gt("+endIndex+") .card").addClass('sorting-selected');
}
}
else
{
var startColKey = parseInt(startCol.substr(7));
var endColKey = parseInt(endCol.substr(7));
$(".column").filter(function(){
var colID = $(this).attr("id");
//Grtabs the number part of our column id
var colKey = parseInt(colID.substr(7));
if (startColKey < endColKey)
{
if (colKey > startColKey && colKey < endColKey)
{
return true;
}
}
else
{
if (colKey < startColKey && colKey > endColKey)
{
return true;
}
}
return false;
}).find(".card").addClass("sorting-selected");
if (startColKey < endColKey)
{
$("#"+startCol+" li:gt("+startIndex+") .card").addClass("sorting-selected");
$("#"+endCol+" li:lt("+endIndex+") .card").addClass("sorting-selected");
}
else
{
$("#"+startCol+" li:lt("+startIndex+") .card").addClass("sorting-selected");
$("#"+endCol+" li:gt("+endIndex+") .card").addClass("sorting-selected");
}
}
}
}
else
{
$('.sorting-selected').removeClass('sorting-selected');
}
if ($('.sorting-selected').length == 1)
{
baseShiftClickItem = $('.sorting-selected').attr("id");
}
}
else
{
$(this).removeClass("sorting-selected");
}
});
//Add card partameter to this event and call update position on it
$(document).bind("columnChange", function(event, sender, receiver){
//If the user drags a card into a tablist we want to make sure that it matches the filter being applied
if ($("#"+receiver).hasClass("tablists"))
{
advancedFilter(tabColumnFilter, ".tablists");
}
columnWIPCheck(sender);
columnWIPCheck(receiver);
});
$("#dialogAddEditCard").on("click", "#btnCommentSubmit", function(e){
if ($("#commentReplyText").val() != "" )
{
//Gets the id of the card to which the comment is being appended
var cardId = $("#dialogAddEditCard").data("cardId");
sendComment(cardId);
}
});