Projet

Général

Profil

Paste
Télécharger (2,77 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / adminimal_theme / js / adminimal_theme.js @ 5024cef7

1
(function($) {
2
'use strict';
3

    
4
// Define jRespond Media queries.
5
var jRes = jRespond([
6
  {
7
    label: 'mobile',
8
    enter: 0,
9
    exit: 480
10
  },{
11
    label: 'tablet',
12
    enter: 481,
13
    exit: 979
14
  },{
15
    label: 'desktop',
16
    enter: 980,
17
    exit: 9999
18
  }
19
]);
20

    
21
// Detect Operating system and add class to the body.
22
Drupal.behaviors.adminimal_os_class = {
23
  attach: function (context, settings) {
24
    // Detect if OS is mac based.
25
    if (navigator.userAgent.indexOf('Mac OS X') != -1) {
26
      $("body").addClass("mac");
27
    }
28
  }
29
};
30

    
31
// Modify the Search field for module filter.
32
Drupal.behaviors.adminimal_module_filter_box = {
33
  attach: function (context, settings) {
34
    //Add default hint value using the HTML5 placeholder attribute.
35
    $('input#edit-module-filter-name').attr( "placeholder", Drupal.t('Search') );
36
  }
37
};
38

    
39
// Fix some krumo styling.
40
Drupal.behaviors.krumo_remove_class = {
41
  attach: function (context, settings) {
42
    // Find status messages that has krumo div inside them, and change the classes.
43
    $('#console .messages.status').has("div.krumo-root").removeClass().addClass( "krumo-wrapper" );
44
  }
45
};
46

    
47
// Add media query classes to the body tag.
48
Drupal.behaviors.adminimal_media_queries = {
49
  attach: function (context, settings) {
50
    jRes.addFunc([
51
      {
52
        breakpoint: 'mobile',
53
          enter: function() {
54
            $( "body" ).addClass( "mq-mobile" );
55
          },
56
          exit: function() {
57
            $( "body" ).removeClass( "mq-mobile" );
58
          }
59
      },{
60
        breakpoint: 'tablet',
61
          enter: function() {
62
            $( "body" ).addClass( "mq-tablet" );
63
          },
64
          exit: function() {
65
            $( "body" ).removeClass( "mq-tablet" );
66
          }
67
      },{
68
        breakpoint: 'desktop',
69
          enter: function() {
70
            $( "body" ).addClass( "mq-desktop" );
71
          },
72
          exit: function() {
73
            $( "body" ).removeClass( "mq-desktop" );
74
          }
75
      }
76
    ]);
77
  }
78
};
79

    
80
// Move the active primary tab on mobile to be displayed last.
81
Drupal.behaviors.adminimal_move_active_primary_tab = {
82
  attach: function (context, settings) {
83
    // Add primary tabs class to the branding div for the bottom border.
84
    $('#branding').has("ul.tabs.primary").addClass( "has-primary-tabs" );
85

    
86
    // register enter and exit functions for a single breakpoint
87
    jRes.addFunc({
88
      breakpoint: 'mobile',
89
        enter: function() {
90
          $( "ul.tabs.primary li.active" ).clone().appendTo( "ul.tabs.primary" ).removeClass( "active" ).addClass( "current" );
91
          $( "ul.tabs.primary li.active" ).css("display", "none");
92
        },
93
        exit: function() {
94
          $( "ul.tabs.primary li.active" ).css("display", "table");
95
          $( "ul.tabs.primary li.current" ).css("display", "none");
96
        }
97
    });
98
  }
99
};
100

    
101
})(jQuery);