Skip to content

Commit 432c268

Browse files
committed
Merge pull request #2 from HighgateCross/master
Add docs and remove keyboard shortcuts
2 parents b59713c + bd2ed74 commit 432c268

File tree

2 files changed

+41
-217
lines changed

2 files changed

+41
-217
lines changed

docs/doc.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<h3>Option</h3>
2+
<h4>add <em>boolean (true)</em></h4>
3+
<p>Apparently this option doesnt do anything, but it should enable or disable the ability to add items to a listable list.</p>
4+
<h4>add_after <em>boolean (true)</em></h4>
5+
<p>Apparently this option is broken, but if false, it should add the listable item before the field divider instead of after.</p>
6+
<h4>add_image <em>filepath ("/javascripts/listable/images/add.png")</em></h4>
7+
<p>Sets the file path for the add icon.</p>
8+
<h4>auto_build <em>boolean (true)</em></h4>
9+
<p>When true, auto_build will tell listable to build out the listable based on the hidden inputs. Leaving this as 'true' is highly recommended.</p>
10+
<h4>connectWith <em>selector ('')</em></h4>
11+
<p>This option is identical to the <a href="http://api.jqueryui.com/sortable/#option-connectWith">connectWith option for sortable</a>. It is a selector for other listable elements with which this listable should be connected to. It is a one-way relationship.</p>
12+
<h4>controls <em>boolean (true)</em></h4>
13+
<p>A boolean which turns on or off the listable controls. When false, the controls are not generated.</p>
14+
<h4>delete <em>boolean (true)</em></h4>
15+
<p>A boolean which turns on or off a listable's ability to delete items.</p>
16+
<h4>delete_confirmation <em>boolean (false)</em></h4>
17+
<p>A boolean which turns on or off a warning when deleting an item.</p>
18+
<h4>delete_image <em>filepath ("/javascripts/listable/images/delete.png")</em></h4>
19+
<p>Sets the file path for the delete icon.</p>
20+
<h4>depth <em>boolean (false)</em></h4>
21+
<p>A boolean which turns on or off the depth attribute for the listable items.</p>
22+
<h4>deeper_image <em>filepath ("/javascripts/listable/images/right_arrow.png")</em></h4>
23+
<p>Sets the file path for the deeper icon.</p>
24+
<h4>edit <em>boolean (true)</em></h4>
25+
<p>A boolean which turns on or off a listable's ability to edit items.</p>
26+
<h4>edit_image <em>filepath ("/javascripts/listable/images/edit.png")</em></h4>
27+
<p>Sets the file path for the edit icon.</p>
28+
<h4>fancybox_padding <em>integer (null)</em></h4>
29+
<p>Sets the padding amount between the FancyBox wrapper and its content.</p>
30+
<h4>field_dividers_enabled <em>boolean (true)</em></h4>
31+
<p>Sets the padding amount between the FancyBox wrapper and its content.</p>
32+
33+
<h3>Public variables</h3>
34+
<h4>$.fn.listable.current_listable</h4>
35+
<p>Sets the current_listable. Useful when saving changes to a listable on a page with multiple listables.</p>
36+
<h3>Methods</h3>
37+
<p>save(itemType [, option1, option2])</p>
38+
<p>&nbsp;</p>
39+
<p style="padding-left: 30px;">&nbsp;</p>

jquery.listable.js

Lines changed: 2 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
$.widget( "ui.listable", $.ui.mouse, {
1616
// Options to be used as defaults
1717
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
2020
'add_image' : '/javascripts/listable/images/add.png',
2121
'auto_build' : true,
2222
'connectWith' : '',
@@ -35,7 +35,6 @@
3535
'gear_transition' : 'fade',
3636
'image_dragging' : false,
3737
'initial_add' : true,
38-
'keyboard_shortcuts' : false,
3938
'max_depth' : false,
4039
'shallower_image' : '/javascripts/listable/images/left_arrow.png',
4140
'types' : [],
@@ -140,220 +139,6 @@
140139
this.element.find('img').live('dragstart', function(event) { event.preventDefault(); });
141140
}
142141

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-
}
357142
// The following couple lines deal with a variable that mitigates whether keyboard shortcuts work or not
358143
$(window).focus(function(){
359144
no_focus = true;

0 commit comments

Comments
 (0)