Newer
Older
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
/*
scp.js
osTicket SCP
Copyright (c) osTicket.com
*/
function selectAll(formObj,task,highlight){
var highlight = highlight || false;
for (var i=0;i < formObj.length;i++){
var e = formObj.elements[i];
if (e.type == 'checkbox' && !e.disabled){
if(task==0){
e.checked =false;
}else if(task==1){
e.checked = true;
}else{
e.checked = (e.checked) ? false : true;
}
if(highlight && 0) {
highLight(e.value,e.checked);
}
}
}
return false;
}
function reset_all(formObj){
return selectAll(formObj,0,true);
}
function select_all(formObj,highlight){
return selectAll(formObj,1,highlight);
}
function toogle_all(formObj,highlight){
var highlight = highlight || false;
return selectAll(formObj,2,highlight);
}
function checkbox_checker(formObj, min,max) {
var checked=$("input[type=checkbox]:checked").length;
var action= action?action:"process";
if (max>0 && checked > max ){
msg="You're limited to only " + max + " selections.\n"
msg=msg + "You have made " + checked + " selections.\n"
msg=msg + "Please remove " + (checked-max) + " selection(s)."
alert(msg)
return (false);
}
if (checked< min ){
alert("Please make at least " + min + " selections. " + checked + " checked so far.")
return (false);
}
return (true);
}
$(document).ready(function(){
$("input:not(.dp):visible:enabled:first").focus();
$('table.list tbody tr:odd').addClass('odd');
if($.browser.msie) {
$('.inactive').mouseenter(function() {
var elem = $(this);
var ie_shadow = $('<div>').addClass('ieshadow').css({
height:$('ul', elem).height()
});
elem.append(ie_shadow);
}).mouseleave(function() {
$('.ieshadow').remove();
});
}
$("form#save :input").change(function() {
var fObj = $(this).closest('form');
if(!fObj.data('changed')){
fObj.data('changed', true);
$('input[type=submit]', fObj).css('color', 'red');
$(window).bind('beforeunload', function(e) {
return 'Are you sure you want to leave? Any changes or info you\'ve entered will be discarded!';
});
}
});
$("form#save :input[type=reset]").click(function() {
var fObj = $(this).closest('form');
if(fObj.data('changed')){
$('input[type=submit]', fObj).removeAttr('style');
$('label', fObj).removeAttr('style');
$('label', fObj).removeClass('strike');
fObj.data('changed', false);
$(window).unbind('beforeunload');
$('form#save').submit(function() {
$(window).unbind('beforeunload');
return true;
});
$('select#setting_options').change(function() {
$(this).closest('form').submit();
});
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
$(".clearrule").live('click',function() {
$(this).closest("tr").find(":input").val('');
return false;
});
//Canned attachments.
$('#canned_attachments, #faq_attachments').delegate('input:checkbox', 'click', function(e) {
var elem = $(this);
if(!$(this).is(':checked') && confirm("Are you sure you want to remove this attachment?")==true) {
elem.parent().addClass('strike');
} else {
elem.attr('checked', 'checked');
elem.parent().removeClass('strike');
}
});
$('form select#cannedResp').change(function() {
var fObj=$(this).closest('form');
var cannedId = $(this).val();
var ticketId = $(':input[name=id]',fObj).val();
$(this).find('option:first').attr('selected', 'selected').parent('select');
$.ajax({
type: "GET",
url: 'ajax.php/kb/canned-response/'+cannedId+'.json',
data: 'tid='+ticketId,
dataType: 'json',
cache: false,
success: function(canned){
//Canned response.
if(canned.response) {
if($('#append',fObj).is(':checked') && $('#response',fObj).val())
$('#response',fObj).val($('#response',fObj).val()+"\n\n"+canned.response+"\n");
else
$('#response',fObj).val(canned.response);
}
//Canned attachments.
if(canned.files && $('#canned_attachments',fObj).length) {
$.each(canned.files,function(i, j) {
if(!$('#canned_attachments #f'+j.id,fObj).length) {
var file='<label><input type="checkbox" name="cannedattachments[]" value="' + j.id+'" id="f'+j.id+'" checked="checked">';
file+= '<a href="file.php?h=' + j.hash + j.key+ '">'+ j.name +'</a></label>';
$('#canned_attachments', fObj).append(file);
}
});
}
}
})
.done(function() { })
.fail(function() { });
});
/* global inits */
/* Get config settings from the backend */
$.get('ajax.php/config/ui.json',
function(config){
/*
if(config && config.max_attachments)
alert(config.max_attachments);
*/
},
'json')
.error( function() {});
/* NicEdit richtext init */
var rtes = $('.richtext');
var rtes_count = rtes.length;
for(i=0;i<rtes_count;i++) {
var initial_value = rtes[i].value;
rtes[i].id = 'rte-'+i;
new nicEditor({iconsPath:'images/nicEditorIcons.gif'}).panelInstance('rte-'+i);
if(initial_value=='') {
nicEditors.findEditor('rte-'+i).setContent('');
}
}
/* Typeahead init */
$('#ticket-search').typeahead({
source: function (typeahead, query) {
$.ajax({
url: "ajax.php/tickets?q="+query,
dataType: 'json',
success: function (data) {
typeahead.process(data);
}
});
},
onselect: function (obj) {
$('#ticket-search').closest('form').submit();
},
property: "value"
});