-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall.js
134 lines (116 loc) · 3.42 KB
/
all.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
$(document).ready(function(){
$('#task_name').autocomplete({
source: '/pr/suggest/exercise/?for=' + $('#for_women').val(),
select: function(event, ui) {
$('#task_id').val( ui.item.id );
$('#task_name').val( ui.item.label );
console.log(ui.item);
},
focus: function( event, ui ) {
$( "#task_name" ).val( ui.item.label );
return false;
}
});
$('#add').click(function(e){
e.preventDefault();
var a = $('#add_task').serializeArray();
console.log(a);
$('#add_task').submit();
});
$('.delete').click(function(e){
if (confirm("точно удалять?")) {
return true;
}
e.preventDefault();
return false;
});
$('.sorted').sortable({
items: 'tr.item',
placeholder: "ui-state-highlight"
});
$('#save_order').click(function(e){
e.preventDefault();
show_loader();
var res = $('.sorted').sortable('toArray');
console.log(res);
$.post('/pr/task/re_order/', {order:res.join('+')}, function(){ hide_loader(); }, 'json');
});
var show_loader = function(){
globalLoader.show();
};
var hide_loader = function(){
globalLoader.hide();
};
var update_ss_number = function(id, s_num){
globalLoader.show();
$.post('/pr/task/save_ss/', {number:s_num, task_id: id}, function(){ globalLoader.hide(); }, 'json');
};
$('.plus').click(function(e){
e.preventDefault();
var ss = $(this).parents('#toolbar').find('.super_set');
var s_num = parseInt($(ss).html(), 10) + 1;
$(ss).html(s_num);
var id = parseInt($(ss).parents('tr').attr('id').replace("task_id_", ""), 10);
update_ss_number(id, s_num);
}).button({
icons: {
primary: "ui-icon-circle-arrow-e"
},
text: false
});
$('.minus').click(function(e){
e.preventDefault();
var ss = $(this).parents('#toolbar').find('.super_set');
var s_num = parseInt($(ss).html(), 10) - 1;
if (s_num < 0) {
s_num = 0;
}
$(ss).html(s_num);
var id = parseInt($(ss).parents('tr').attr('id').replace("task_id_", ""), 10);
update_ss_number(id, s_num);
}).button({
icons: {
primary: "ui-icon-circle-arrow-w"
},
text: false
});
window.globalLoader = {
ID:'globalLoader',
entity:null,
init:function(){
if($('#'+globalLoader.ID).length){
globalLoader.entity = $('#'+globalLoader.ID);
return globalLoader;
}
$('<div id="'+globalLoader.ID+'"><div class="inner"></div></div>').appendTo($('body'));
globalLoader.entity=$('#'+globalLoader.ID);
globalLoader.setDefaultMessage();
$( globalLoader.entity ).dialog({
height: 70,
modal: true,
closeOnEscape: false,
resizable: false,
autoOpen: false
});
return globalLoader;
},
setDefaultMessage:function(){
globalLoader.setMessage('Loading...');
return globalLoader;
},
setMessage:function(message){
$('.inner',globalLoader.entity).html(message);
return globalLoader;
},
show:function(){
$( globalLoader.entity ).dialog('open');
return globalLoader;
},
hide:function(){
$( globalLoader.entity ).dialog('close');
globalLoader.setDefaultMessage();
return globalLoader;
}
};
globalLoader.init();
}); // doc ready