123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- (function ($) {
- /**
- * Attach auto-submit to admin view form.
- */
- Drupal.behaviors.feedbackAdminForm = {
- attach: function (context) {
- $('#feedback-admin-view-form', context).once('feedback', function () {
- $(this).find('fieldset.feedback-messages :input[type="checkbox"]').click(function () {
- this.form.submit();
- });
- });
- }
- };
- /**
- * Attach collapse behavior to the feedback form block.
- */
- Drupal.behaviors.feedbackForm = {
- attach: function (context) {
- $('#block-feedback-form', context).once('feedback', function () {
- var $block = $(this);
- $block.find('span.feedback-link')
- .prepend('<span id="feedback-form-toggle">[ + ]</span> ')
- .css('cursor', 'pointer')
- .toggle(function () {
- Drupal.feedbackFormToggle($block, false);
- },
- function() {
- Drupal.feedbackFormToggle($block, true);
- }
- );
- $block.find('form').hide();
- $block.show();
- });
- }
- };
- /**
- * Re-collapse the feedback form after every successful form submission.
- */
- Drupal.behaviors.feedbackFormSubmit = {
- attach: function (context) {
- var $context = $(context);
- if (!$context.is('#feedback-status-message')) {
- return;
- }
- // Collapse the form.
- $('#block-feedback-form .feedback-link').click();
- // Blend out and remove status message.
- window.setTimeout(function () {
- $context.fadeOut('slow', function () {
- $context.remove();
- });
- }, 3000);
- }
- };
- /**
- * Collapse or uncollapse the feedback form block.
- */
- Drupal.feedbackFormToggle = function ($block, enable) {
- $block.find('form').slideToggle('medium');
- if (enable) {
- $('#feedback-form-toggle', $block).html('[ + ]');
- }
- else {
- $('#feedback-form-toggle', $block).html('[ − ]');
- }
- };
- })(jQuery);
|