Projet

Général

Profil

Révision fc3d89c3

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media/js/plugins/media.views.js
25 25
      return false;
26 26
    });
27 27

  
28
    // Return focus to the correct part of the form.
29
    $('.ctools-auto-submit-full-form .ctools-auto-submit-click', context).click(function () {
30
      settings.lastFocus = document.activeElement.id;
31

  
32
      // Add custom class to allow customize look and feel of the field while processing ajax
33
      // This way user can have a better user expierence using the exposed filters
34
      $(document.activeElement).addClass('media-ajaxing-disabled');
35
      // Remove focus to the active element
36
      $(document.activeElement).blur();
37

  
38
      // Before go with ajax, suppress key events
39
      $('body').bind('keydown keyup', suppressKeyEvents);
40
    });
41
    if (settings.lastFocus) {
42
      // Note, we just use each() so we can declare variables in a new scope.
43
      $('#' + settings.lastFocus, context).each(function () {
44
        var $this = $(this),
45
            val = $this.val();
46

  
47
        $this.focus();
48

  
49
        // Clear and reset the value to put the cursor at the end.
50
        $this.val('');
51
        $this.val(val);
52

  
53
        // After input recover focus, remove suppression of key events
54
        $('body').unbind('keydown keyup', suppressKeyEvents);
55
      });
56
    }
57

  
28 58
    // We loop through the views listed in Drupal.settings.media.browser.views
29 59
    // and set them up individually.
30 60
    var views_ids = [];
......
170 200
  $(view).addClass('media-browser-views-processed');
171 201
}
172 202

  
203
/**
204
 * Helper callback to supress propagation and default behaviour of an event
205
 *
206
 * This function is used in this way to make private and accesible only for the current scope
207
 */
208
var suppressKeyEvents = function(e) {
209
  e.stopImmediatePropagation();
210
  e.preventDefault();
211
}
212

  
173 213
}(jQuery));

Formats disponibles : Unified diff