Projet

Général

Profil

Paste
Télécharger (1,7 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / themes / rubik / js / rubik.js @ 6c38d829

1
/**
2
 * Implementation of Drupal behavior.
3
 */
4
(function($) {
5
Drupal.behaviors.rubik = {};
6
Drupal.behaviors.rubik.attach = function(context) {
7
  // If there are both main column and side column buttons, only show the main
8
  // column buttons if the user scrolls past the ones to the side.
9
  $('div.form:has(div.column-main div.form-actions):not(.rubik-processed)').each(function() {
10
    var form = $(this);
11
    var offset = $('div.column-side div.form-actions', form).height() + $('div.column-side div.form-actions', form).offset().top;
12
    $(window).scroll(function () {
13
      if ($(this).scrollTop() > offset) {
14
        $('div.column-main div.form-actions', form).show();
15
      }
16
      else {
17
        $('div.column-main div.form-actions', form).hide();
18
      }
19
    });
20
    form.addClass('rubik-processed');
21
  });
22

    
23
  $('a.toggler:not(.rubik-processed)', context).each(function() {
24
    var id = $(this).attr('href').split('#')[1];
25
    // Target exists, add click handler.
26
    if ($('#' + id).size() > 0) {
27
      $(this).click(function() {
28
        toggleable = $('#' + id);
29
        toggleable.toggle();
30
        $(this).toggleClass('toggler-active');
31
        return false;
32
      });
33
    }
34
    // Target does not exist, remove click handler.
35
    else {
36
      $(this).addClass('toggler-disabled');
37
      $(this).click(function() { return false; });
38
    }
39
    // Mark as processed.
40
    $(this).addClass('rubik-processed');
41
  });
42
};
43
$(document).ready(function() {
44
  // If there's no active secondary tab, make the first one show.
45
  var activeli = $('.primary-tabs li.active .secondary-tabs li.active');
46
  if (activeli.length == 0) {
47
    $('.primary-tabs li.active .secondary-tabs li:first-child a').css('display', 'block');
48
  }
49
});
50
})(jQuery);