home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 March / maximum-cd-2012-03.iso / DiscContents / npp.5.9.6.2.Installer.exe / user.manual / sites / all / modules / feedback / feedback5dbc.js < prev   
Encoding:
JavaScript  |  2011-07-18  |  2.4 KB  |  80 lines

  1. // $Id: feedback.js,v 1.3.2.2 2010/01/08 22:21:11 sun Exp $
  2.  
  3. /**
  4.  * Attach auto-submit to admin view form.
  5.  */
  6. Drupal.behaviors.feedbackAdminForm = function (context) {
  7.   $('#feedback-admin-view-form:not(.feedback-processed)', context).addClass('feedback-processed').each(function () {
  8.     $(this).find('fieldset.feedback-messages :input[type="checkbox"]').click(function () {
  9.       this.form.submit();
  10.     });
  11.   });
  12. };
  13.  
  14. /**
  15.  * Attach collapse behavior to the feedback form block (once).
  16.  */
  17. Drupal.behaviors.feedbackForm = function (context) {
  18.   $('#block-feedback-form:not(.feedback-processed)', context).addClass('feedback-processed').each(function () {
  19.     var $block = $(this);
  20.     $block.find('span.feedback-link')
  21.       .prepend('<span id="feedback-form-toggle">[ + ]</span> ')
  22.       .css('cursor', 'pointer')
  23.       .toggle(function () {
  24.           Drupal.feedbackFormToggle($block, false);
  25.         },
  26.         function() {
  27.           Drupal.feedbackFormToggle($block, true);
  28.         }
  29.       );
  30.     $block.find('form').hide()
  31.       .find(':input[name="ajax"]').val(1).end()
  32.       .submit(function() {
  33.         // Toggle throbber/button.
  34.         $('#feedback-throbber', this).addClass('throbbing');
  35.         $('#feedback-submit', this).fadeOut('fast', function () {
  36.           Drupal.feedbackFormSubmit($(this).parents('form'));
  37.         });
  38.         return false;
  39.       });
  40.     $block.show();
  41.   });
  42. };
  43.  
  44. /**
  45.  * Collapse or uncollapse the feedback form block.
  46.  */
  47. Drupal.feedbackFormToggle = function ($block, enable) {
  48.   $block.find('form').slideToggle('medium');
  49.   if (enable) {
  50.     $('#feedback-form-toggle', $block).html('[ + ]');
  51.   }
  52.   else {
  53.     $('#feedback-form-toggle', $block).html('[ − ]');
  54.   }
  55. };
  56.  
  57. /**
  58.  * Collapse or uncollapse the feedback form block.
  59.  */
  60. Drupal.feedbackFormSubmit = function ($form) {
  61.   $.post($form.get(0).action, $form.serialize(), function (data) {
  62.     // Collapse the form.
  63.     $('#block-feedback-form').find('.feedback-link').click();
  64.     // Display status message.
  65.     $form.parent().parent().append('<div id="feedback-status-message">' + data.message + '</div>');
  66.     // Reset form values.
  67.     $(':input[name="message"]', $form).val('');
  68.     $('#feedback-throbber', $form).removeClass('throbbing');
  69.     $('#feedback-submit', $form).show();
  70.     // Blend out status message.
  71.     window.setTimeout(function () {
  72.       $('#feedback-status-message').fadeOut('slow', function () {
  73.         $(this).remove();
  74.       });
  75.     }, 3000);
  76.   }, 'json');
  77.   return false;
  78. };
  79.  
  80.