|
15 | 15 | $.widget( "ui.listable", $.ui.mouse, { |
16 | 16 | // Options to be used as defaults |
17 | 17 | options: { |
18 | | - 'add' : true, |
19 | | - 'add_after' : true, |
| 18 | + 'add' : true, // Broken but should enable adding list items |
| 19 | + 'add_after' : true, // Maybe Broken. Might need to be changed to default false and to set adding new items at the top of the list |
20 | 20 | 'add_image' : '/javascripts/listable/images/add.png', |
21 | 21 | 'auto_build' : true, |
22 | 22 | 'connectWith' : '', |
|
35 | 35 | 'gear_transition' : 'fade', |
36 | 36 | 'image_dragging' : false, |
37 | 37 | 'initial_add' : true, |
38 | | - 'keyboard_shortcuts' : false, |
39 | 38 | 'max_depth' : false, |
40 | 39 | 'shallower_image' : '/javascripts/listable/images/left_arrow.png', |
41 | 40 | 'types' : [], |
|
140 | 139 | this.element.find('img').live('dragstart', function(event) { event.preventDefault(); }); |
141 | 140 | } |
142 | 141 |
|
143 | | - if (settings.keyboard_shortcuts) { // If the setting for keyboard_shortcuts is true then add the event listners for keyboard shortcuts. These event listeners are not full abstracted and the default for keyboard_shortcuts should be false. |
144 | | - $(window).keypress(function(event){ |
145 | | - if (event.which == 106 && no_focus) { // j is pressed |
146 | | - if (this.current_divider && this.current_divider.parent().length) { |
147 | | - previous_divider = this.current_divider; |
148 | | - if (this.current_divider.next().next('.field_divider').length) { |
149 | | - this.current_divider = this.current_divider.next().next('.field_divider'); |
150 | | - this.current_divider.attr('hil','highlighted'); |
151 | | - previous_divider.attr('hil',''); |
152 | | - } |
153 | | - } else { |
154 | | - $('.field_divider:first').attr('hil','highlighted'); |
155 | | - this.current_divider = $('.field_divider:first'); |
156 | | - } |
157 | | - } else if (event.which == 107 && no_focus) { // k is pressed |
158 | | - if (this.current_divider && this.current_divider.parent().length) { |
159 | | - previous_divider = this.current_divider; |
160 | | - if (this.current_divider.prev().prev('.field_divider').length) { |
161 | | - this.current_divider = this.current_divider.prev().prev('.field_divider'); |
162 | | - this.current_divider.attr('hil','highlighted'); |
163 | | - previous_divider.attr('hil',''); |
164 | | - } |
165 | | - } else { |
166 | | - $('.field_divider:last').attr('hil','highlighted'); |
167 | | - this.current_divider = $('.field_divider:last'); |
168 | | - } |
169 | | - } else if (event.which == 97 && no_focus) { // a is pressed |
170 | | - if (this.current_divider && this.current_divider.parent().length) { |
171 | | - $('#fancy_inline form').hide(); |
172 | | - $('#textfield_form').show(); |
173 | | - $.fancybox({ |
174 | | - 'href' : '#fancy_inline', |
175 | | - 'onComplete' : function(){ |
176 | | - document.getElementById('tx_label_name').focus(); |
177 | | - }, |
178 | | - 'onClosed': function(){ |
179 | | - update = false; |
180 | | - } |
181 | | - }); |
182 | | - } |
183 | | - } else if (event.which == 115 && no_focus) { // s is pressed |
184 | | - if (this.current_divider && this.current_divider.parent().length) { |
185 | | - $('#fancy_inline form').hide(); |
186 | | - $('#textarea_form').show(); |
187 | | - $.fancybox({ |
188 | | - 'href' : '#fancy_inline', |
189 | | - 'onComplete' : function(){ |
190 | | - document.getElementById('ta_label_name').focus(); |
191 | | - }, |
192 | | - 'onClosed': function(){ |
193 | | - update = false; |
194 | | - } |
195 | | - }); |
196 | | - } |
197 | | - } else if (event.which == 100 && no_focus) { // d is pressed |
198 | | - if (this.current_divider && this.current_divider.parent().length) { |
199 | | - $('#fancy_inline form').hide(); |
200 | | - $('#checkbox_form').show(); |
201 | | - $.fancybox({ |
202 | | - 'href' : '#fancy_inline', |
203 | | - 'onComplete' : function(){ |
204 | | - document.getElementById('cb_label_name').focus(); |
205 | | - }, |
206 | | - 'onClosed': function(){ |
207 | | - update = false; |
208 | | - } |
209 | | - |
210 | | - }); |
211 | | - } |
212 | | - } else if (event.which == 102 && no_focus) { // f is pressed |
213 | | - if (this.current_divider && this.current_divider.parent().length) { |
214 | | - $('#fancy_inline form').hide(); |
215 | | - $('#radio_form').show(); |
216 | | - $.fancybox({ |
217 | | - 'href' : '#fancy_inline', |
218 | | - 'onComplete' : function(){ |
219 | | - document.getElementById('ra_label_name').focus(); |
220 | | - }, |
221 | | - 'onClosed': function(){ |
222 | | - update = false; |
223 | | - } |
224 | | - |
225 | | - }); |
226 | | - } |
227 | | - } else if (event.which == 103 && no_focus) { // g is pressed |
228 | | - if (this.current_divider && this.current_divider.parent().length) { |
229 | | - $('#fancy_inline form').hide(); |
230 | | - $('#select_form').show(); |
231 | | - $.fancybox({ |
232 | | - 'href' : '#fancy_inline', |
233 | | - 'onComplete' : function(){ |
234 | | - document.getElementById('sl_label_name').focus(); |
235 | | - }, |
236 | | - 'onClosed': function(){ |
237 | | - update = false; |
238 | | - } |
239 | | - |
240 | | - }); |
241 | | - } |
242 | | - } else if (event.which == 122 && no_focus) { // g is pressed |
243 | | - if (this.current_divider && this.current_divider.parent().length) { |
244 | | - $('#fancy_inline form').hide(); |
245 | | - $('#email_form').show(); |
246 | | - $.fancybox({ |
247 | | - 'href' : '#fancy_inline', |
248 | | - 'onComplete' : function(){ |
249 | | - document.getElementById('em_label_name').focus(); |
250 | | - }, |
251 | | - 'onClosed': function(){ |
252 | | - update = false; |
253 | | - } |
254 | | - |
255 | | - }); |
256 | | - } |
257 | | - } else if (event.which == 101 && no_focus && settings.delete) { // e is pressed |
258 | | - if (this.current_divider && this.current_divider.prev().prev('.field_divider').length) { |
259 | | - new_divider = this.current_divider.prev().prev('.field_divider'); |
260 | | - $('.field_'+this.current_divider.prev().children('.delete_field').attr('class').replace(/delete_field field_/,'')).remove(); |
261 | | - this.current_divider.prev().remove(); |
262 | | - this.current_divider.remove(); |
263 | | - this.current_divider = new_divider; |
264 | | - this.current_divider.attr('hil','highlighted'); |
265 | | - } |
266 | | - } else if (event.which == 120 && no_focus) { // x is pressed |
267 | | - if (this.current_divider && this.current_divider.parent().length) { |
268 | | - $('#fancy_inline form').hide(); |
269 | | - $('#tinymce_form').show(); |
270 | | - $.fancybox({ |
271 | | - 'href' : '#fancy_inline', |
272 | | - 'onComplete' : function(){ |
273 | | - document.getElementById('tm_label_name').focus(); |
274 | | - }, |
275 | | - 'onClosed': function(){ |
276 | | - update = false; |
277 | | - } |
278 | | - |
279 | | - }); |
280 | | - } |
281 | | - } else if (event.which == 99 && no_focus) { // x is pressed |
282 | | - if (this.current_divider && this.current_divider.parent().length) { |
283 | | - var checked = 1; |
284 | | - this.current_divider.after('\ |
285 | | - <li class="form_field field_'+$.fn.listable.counter+'">\ |
286 | | - <label class="field_'+$.fn.listable.counter+'">Opinion (Captcha)</label>\ |
287 | | - <a class="delete_field field_'+$.fn.listable.counter+'" href="#"><img src="'+settings.delete_image+'" alt="delete field" /></a>\ |
288 | | - </li>\ |
289 | | - <li class="field_divider field_'+$.fn.listable.counter+'">\ |
290 | | - <img src="'+settings.add_image+'" alt="add field" />\ |
291 | | - </li>'); |
292 | | - $(settings.variable_vault).append('<input type="hidden" name="field_label[]" value="opinion" class="field_'+$.fn.listable.counter+'" >\ |
293 | | - <input type="hidden" name="field_type[]" value="captcha" class="field_'+$.fn.listable.counter+'" >\ |
294 | | - <input type="hidden" name="field_order[]" value="0" class="field_'+$.fn.listable.counter+'" >\ |
295 | | - <input type="hidden" name="field_length[]" value="16" class="field_'+$.fn.listable.counter+'" >\ |
296 | | - <input type="hidden" name="field_mandatory[]" value="0" class="field_'+$.fn.listable.counter+'" >\ |
297 | | - <input type="hidden" name="field_static_label[]" value="" class="field_'+$.fn.listable.counter+'" >\ |
298 | | - <input type="hidden" name="field_inline[]" value="" class="field_'+$.fn.listable.counter+'" >\ |
299 | | - <input type="hidden" name="field_validation[]" value="captcha" class="field_'+$.fn.listable.counter+'" >\ |
300 | | - <input type="hidden" name="field_options[]" value="" class="field_'+$.fn.listable.counter+'" >\ |
301 | | - '); |
302 | | - $.fn.listable.counter++; |
303 | | - if (settings.controls) { |
304 | | - $('.controls').hide('fast'); |
305 | | - } |
306 | | - no_focus = true; |
307 | | - } |
308 | | - } else if (event.which == 118 && no_focus) { // x is pressed |
309 | | - if (this.current_divider && this.current_divider.parent().length) { |
310 | | - $('#fancy_inline form').hide(); |
311 | | - $('#file_form').show(); |
312 | | - $.fancybox({ |
313 | | - 'href' : '#fancy_inline', |
314 | | - 'onComplete' : function(){ |
315 | | - document.getElementById('fl_label_name').focus(); |
316 | | - }, |
317 | | - 'onClosed': function(){ |
318 | | - update = false; |
319 | | - } |
320 | | - |
321 | | - }); |
322 | | - } |
323 | | - } else if (event.which == 98 && no_focus) { // b is pressed |
324 | | - if (this.current_divider && this.current_divider.parent().length) { |
325 | | - $('#fancy_inline form').hide(); |
326 | | - $('#datepicker_form').show(); |
327 | | - $.fancybox({ |
328 | | - 'href' : '#fancy_inline', |
329 | | - 'onComplete' : function(){ |
330 | | - document.getElementById('dp_label_name').focus(); |
331 | | - }, |
332 | | - 'onClosed': function(){ |
333 | | - update = false; |
334 | | - } |
335 | | - |
336 | | - }); |
337 | | - } |
338 | | - } else if (event.which == 119 && no_focus) { // w is pressed |
339 | | - if (this.current_divider && this.current_divider.parent().length) { |
340 | | - $('#fancy_inline form').hide(); |
341 | | - $('#session_variable_form').show(); |
342 | | - $.fancybox({ |
343 | | - 'href' : '#fancy_inline', |
344 | | - 'onComplete' : function(){ |
345 | | - document.getElementById('sv_label_name').focus(); |
346 | | - }, |
347 | | - 'onClosed': function(){ |
348 | | - update = false; |
349 | | - } |
350 | | - |
351 | | - }); |
352 | | - } |
353 | | - } |
354 | | - |
355 | | - }); |
356 | | - } |
357 | 142 | // The following couple lines deal with a variable that mitigates whether keyboard shortcuts work or not |
358 | 143 | $(window).focus(function(){ |
359 | 144 | no_focus = true; |
|
0 commit comments