-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
131 lines (105 loc) · 3 KB
/
app.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
$(document).ready(function() {
// cancel button
$(".cancel-form").click(function(){
javascript:history.go(-1);
});
});
$(document).ready(function() {
// districts(subject form)
$("#add_district")
.attr("disabled", true)
.hide();
$("#add-district-button").click(function(event) {
$("#subject_district_id").attr("disabled", true);
$(".district-operations").slideUp('fast');
$("#add_district")
.attr("disabled", false)
.show('fast');
$("#back-district-select").show();
});
// back to list districts
$("#back-district-select").click(function(event) {
$("#add_district")
.attr("disabled", true)
.hide('fast');
$("#subject_district_id").attr("disabled", false);
$(".district-operations").slideDown('fast');
$("#back-district-select").hide();
});
});
// districts load(subject form)
$(document).ready(function() {
// functions :
function disabled_district(){
$("#subject_district_id")
.attr("disabled", true)
.html("<option>Нет района</option>");
}
function enable_district(){
$("#subject_district_id")
.attr("disabled", false)
}
// all districts :
var districts = $("#subject_district_id").html();
// first state
var city_first = $("#subject_city_id :selected").text();
var opt_fir = $(districts).filter("optgroup[label='"+city_first+"']").html();
$("#subject_district_id").html(opt_fir);
if (!opt_fir) {
disabled_district();
};
// change city
$("#subject_city_id").change(function(event) {
var city = $("#subject_city_id :selected").text();
var options = $(districts).filter("optgroup[label='"+city+"']").html();
if (options) {
enable_district();
$("#subject_district_id").html(options);
}
else{
disabled_district();
};
});
});
// last call customer
$(document).ready(function() {
$("#man-called-but").click(function(event) {
var customer_id = $(this).attr("data-customer-id");
$.ajax({
url: '/customers/lastcallcustomer',
type: 'POST',
dataType: 'json',
data: {id: customer_id },
success: function(data, textStatus, xhr) {
$("#last-call-value")
.html(data)
.effect("highlight", {color: '#676767'}, 1000);
}
});
});
});
// live search for customer
$(document).ready(function() {
$('#customer th a').live("click", function() {
$.getScript(this.href);
return false;
});
$('#customers_search input').keyup(function(){
$.get($("#customers_search").attr("action"), $("#customers_search").serialize(), null, "script");
return false;
});
});
// live search for tasks
$(document).ready(function() {
$('#task th a').live("click", function() {
$.getScript(this.href);
return false;
});
$('#tasks_search input').keyup(function(){
$.get($("#tasks_search").attr("action"), $("#tasks_search").serialize(), null, "script");
return false;
});
});
// add photo to subject
$(document).ready(function() {
});