-
Notifications
You must be signed in to change notification settings - Fork 988
/
listresponse.js
executable file
·207 lines (197 loc) · 6.81 KB
/
listresponse.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
/*
* JavaScript functions for LimeSurvey response browse
*
*/
// @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GNU/GPL License v2 or later
/**
* Scroll the pager and the footer when scrolling horizontally
*/
$(document).ready(function(){
$('#displayResponsesContainer').scroll(function(){
$('#pager').css({
'left': $(this).scrollLeft() ,
});
});
});
$(document).on("click","[data-delete]",function(event){
event.preventDefault();
var responseid=$(this).data("delete");
var url=$(this).attr("href"); // Or replace responseid by post if needed
var buttons = {};
buttons[sDelCaption] = function(){
$.ajax({
url : url,
type : "POST"
})
.done(function() {
jQuery("#displayresponses").delRowData(responseid);
});
$( this ).dialog( "close" );
};
buttons[sCancel] = function(){ $( this ).dialog( "close" ); };
var dialog=$("<p>"+strdeleteconfirm+"</p>").dialog({
modal:true,
buttons: buttons
});
});
$(function() {
/* Launch jqgrid */
jQuery("#displayresponses").jqGrid({
recordtext : sRecordText,
emptyrecords : sEmptyRecords,
pgtext : sPageText,
loadtext : sLoadText,
align : "center",
url : jsonUrl,
editurl : jsonActionUrl,
datatype : "json",
mtype : "POST",
colNames : colNames,
colModel : colModels,
toppager : false,
height : "100%",
//shrinkToFit : false,
ignoreCase : true,
rowNum : 10,
editable : false,
scrollOffset : 0,
sortable : true,
hidegrid : false,
sortname : 'id',
sortorder : 'asc',
viewrecords : true,
rowList : [ 10, 25, 50, 100, 250, 500, 1000 ],
multiselect : true,
loadonce : false, // use ajax request
pager : "#pager",
caption : sCaption,
beforeRequest: function(){
/* activate tooltip on header */
for (i = 0; i < colModels.length; i++) {
var col=i+1;
$("tr.ui-jqgrid-labels th:eq("+col+") .questiontext").attr('title',colModels[i]['title']);
}
$(".ui-jqgrid-labels").tooltip();
},
loadComplete: function(){
/* activate tooltip on answers : must be limited ? */
$("#displayresponses").tooltip({ tooltipClass: "tooltip-text" });
},
beforeSelectRow: function(rowid, event) {
/* deactivate row select on tools */
if($(event.target).is("a") || $(event.target).closest("a").length )
return false;
return true;
}
});
/* Add navgrid */
jQuery("#displayresponses").jqGrid( 'navGrid', '#pager',
{
add: false,
edit: false,
del: true,
alertcap: sWarningMsg,
alerttext: sSelectRowMsg,
searchtitle : sSearchTitle,
refreshtitle : sRefreshTitle,
deltitle : sDelTitle,
search: true,
refresh: true,
view: false,
position: "left"
},
{}, // edit options
{}, // add options
{
msg : strDeleteAllConfirm,
bSubmit : sDelCaption,
caption : sDelCaption,
bCancel : sCancel,
width : 700,
afterShowForm: function($form) {
var dialog = $form.closest('div.ui-jqdialog'),
selRowId = jQuery("#displayresponses").jqGrid('getGridParam', 'selrow'),
selRowCoordinates = $('#'+selRowId).offset();
dialog.offset(selRowCoordinates);
$(document).scrollTop(selRowCoordinates.top);
},
},
{ // Search options
caption : sSearchCaption,
Find : sFind,
multipleSearch: true,
odata : [ sOperator1, sOperator2, sOperator3,
sOperator4, sOperator5, sOperator6,
sOperator7, sOperator8, sOperator9,
sOperator10, sOperator11, sOperator12,
sOperator13, sOperator14 ],
Reset : sReset,
width: 700
}
);
/* quick search toolbar */
jQuery("#displayresponses").jqGrid('filterToolbar', {
searchOnEnter : false,
defaultSearch : 'cn'
});
/* Column button */
jQuery("#displayresponses").jqGrid(
'navButtonAdd',
'#pager',
{
buttonicon : "ui-icon-calculator",
caption : "",
title : sSelectColumns,
onClickButton : function() {
jQuery("#displayresponses").jqGrid(
'columnChooser',
{
caption : sSelectColumns,
bSubmit : sSubmit,
bCancel : sCancel,
done : function(perm) {
if (perm) {
this.jqGrid("remapColumns",perm,true);
var hidden = [];
$.each($("#displayresponses").getGridParam("colModel"),
function(i,obj) {
if(obj.hasOwnProperty('index') && obj.hidden){
hidden.push(obj.index);
}
});
$.post( jsonBaseUrl+"&sa=setHiddenColumns", { aHiddenFields: hidden.join("|") } );
}
}
});
}
}
);
if(typeof sDownLoad!=="undefined")
{
jQuery("#displayresponses").navButtonAdd('#pager',{
//caption:sDownLoad, // Remove it ? no it's more clear ;)
caption:'',
title:sDownLoad, // Todo dynamically update download selected , download all
buttonicon:"glyphicon glyphicon-download-alt",
onClickButton: function(){
selectedlist=jQuery("#displayresponses").getGridParam('selarrrow').join(",");// Or send like an array ?
if(selectedlist!="")
{
sendPost(jsonActionUrl,null,["oper","responseid"],["downloadzip",selectedlist]);
}
else
{
if(confirm(sConfirmationArchiveMessage))
sendPost(jsonActionUrl,null,["oper"],["downloadzip"]);;
//sendPost(sDownloadUrl,null,"responseid",0);
}
},
position:"last",
});
}
/* Grid resize : only heigth ? */
jQuery("#displayresponses").jqGrid('gridResize', {
handles: "n, s",
minHeight : 100
});
});