| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 // $Id: auto-submit.js,v 1.1.2.2 2010/06/16 16:15:00 merlinofchaos Exp $ 2 3 /** 4 * To make a form auto submit, all you have to do is 3 things: 5 * 6 * ctools_add_js('auto-submit'); 7 * 8 * On gadgets you want to auto-submit when changed, add the ctools-auto-submit 9 * class. With FAPI, add: 10 * @code 11 * '#attributes' => array('class' => 'ctools-auto-submit'), 12 * @endcode 13 * 14 * If you want to have auto-submit for every form element, 15 * add the ctools-auto-submit-full-form to the form. With FAPI, add: 16 * @code 17 * '#attributes' => array('class' => 'ctools-auto-submit-full-form'), 18 * @endcode 19 * 20 * Finally, you have to identify which button you want clicked for autosubmit. 21 * The behavior of this button will be honored if it's ajaxy or not: 22 * @code 23 * '#attributes' => array('class' => 'ctools-use-ajax ctools-auto-submit-click'), 24 * @endcode 25 * 26 * Currently only 'select' and 'textfield' types are supported. We probably 27 * could use additional support for radios and checkboxes. 28 */ 29 30 Drupal.behaviors.CToolsAutoSubmit = function() { 31 var timeoutID = 0; 32 33 // Bind to any select widgets that will be auto submitted. 34 $('select.ctools-auto-submit:not(.ctools-auto-submit-processed),.ctools-auto-submit-full-form select:not(.ctools-auto-submit-processed)') 35 .addClass('.ctools-auto-submit-processed') 36 .change(function() { 37 $(this.form).find('.ctools-auto-submit-click').click(); 38 }); 39 40 // Bind to any textfield widgets that will be auto submitted. 41 $('input[type=text].ctools-auto-submit:not(.ctools-auto-submit-processed),.ctools-auto-submit-full-form input[type=text]:not(.ctools-auto-submit-processed)') 42 .addClass('.ctools-auto-submit-processed') 43 .keyup(function(e) { 44 var form = this.form; 45 switch (e.keyCode) { 46 case 16: // shift 47 case 17: // ctrl 48 case 18: // alt 49 case 20: // caps lock 50 case 33: // page up 51 case 34: // page down 52 case 35: // end 53 case 36: // home 54 case 37: // left arrow 55 case 38: // up arrow 56 case 39: // right arrow 57 case 40: // down arrow 58 case 9: // tab 59 case 13: // enter 60 case 27: // esc 61 return false; 62 default: 63 if (!$(form).hasClass('ctools-ajaxing')) { 64 if ((timeoutID)) { 65 clearTimeout(timeoutID); 66 } 67 68 timeoutID = setTimeout(function() { $(form).find('.ctools-auto-submit-click').click(); }, 300); 69 } 70 } 71 }); 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |