/[drupal]/contributions/modules/feedback/feedback.js
ViewVC logotype

Contents of /contributions/modules/feedback/feedback.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Thu Oct 1 03:20:33 2009 UTC (8 weeks ago) by sun
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +7 -6 lines
File MIME type: text/javascript
by sun: Ported to Drupal 7.
1 // $Id: feedback.js,v 1.3 2008/10/19 19:10:23 sun Exp $
2 (function ($) {
3
4 /**
5 * Attach collapse behavior to the feedback form block (once).
6 */
7 Drupal.feedbackSetup = function() {
8 $block = $('#block-feedback-form');
9 $block.find('span.feedback-link')
10 .prepend('<span id="feedback-form-toggle">[ + ]</span> ')
11 .css('cursor', 'pointer')
12 .toggle(function() {
13 Drupal.feedbackFormToggle($block, false);
14 },
15 function() {
16 Drupal.feedbackFormToggle($block, true);
17 }
18 );
19 $block.find('form')
20 .find(':input[name="ajax"]').val(1).end()
21 .submit(function() {
22 $('#feedback-submit', this).fadeOut('fast', function() {
23 Drupal.feedbackFormSubmit($(this).parents('form').get(0));
24 });
25 return false;
26 });
27 // Attach auto-submit to admin view form.
28 $('fieldset.feedback-messages :input[type="checkbox"]').click(function() {
29 $(this).parents('form').submit();
30 });
31 }
32
33 /**
34 * Collapse or uncollapse the feedback form block.
35 */
36 Drupal.feedbackFormToggle = function($block, enable) {
37 $block.find('.content').slideToggle('medium');
38 if (enable) {
39 $('#feedback-form-toggle', $block).html('[ + ]');
40 }
41 else {
42 $('#feedback-form-toggle', $block).html('[ &minus; ]');
43 }
44 }
45
46 /**
47 * Collapse or uncollapse the feedback form block.
48 */
49 Drupal.feedbackFormSubmit = function(form) {
50 var $form = $(form);
51 $.post(form.action, $form.serialize(), function(data) {
52 // Collapse the form.
53 $('#block-feedback-form').find('.feedback-link').click();
54 // Display status message.
55 $form.parent().parent().append('<div id="feedback-status-message">' + data.message + '</div>');
56 // Reset form values.
57 $(':input[name="message"]', $form).val('');
58 $('#feedback-submit', $form).show();
59 // Blend out status message.
60 window.setTimeout(function() {
61 $('#feedback-status-message').fadeOut('slow', function() {
62 $(this).remove();
63 });
64 }, 3000);
65 }, 'json');
66 return false;
67 }
68
69 $(document).ready(function() {
70 Drupal.feedbackSetup();
71 });
72
73 })(jQuery)

  ViewVC Help
Powered by ViewVC 1.1.2