Projet

Général

Profil

Paste
Télécharger (3,87 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / adaptivetheme / at_core / inc / forms / at_core.submit.menutoggle.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * Save the Menu Toggle CSS to file
6
 */
7
function at_core_submit_menu_toggle($values, $theme_name, $path) {
8
  $smalltouch_portrait_media_query  = $values['smalltouch_portrait_media_query'];
9
  $smalltouch_landscape_media_query = $values['smalltouch_landscape_media_query'];
10
  $tablet_portrait_media_query      = $values['tablet_portrait_media_query'];
11
  $tablet_landscape_media_query     = $values['tablet_landscape_media_query'];
12
  $bigscreen_media_query            = $values['bigscreen_media_query'];
13

    
14
  // if landscape is seleted force portrait to be true, because form states are display only!
15
  if (isset($values['menu_toggle_tablet_landscape']) && $values['menu_toggle_tablet_landscape'] == 1) {
16
    if ($values['menu_toggle_tablet_portrait'] == 0) {
17
      $values['menu_toggle_tablet_portrait'] = 1;
18
    }
19
  }
20

    
21
  $menu_toggle_css = array();
22
  $menu_toggle_css_active = '
23
  .at-mt .at-menu-toggle-button {
24
    position: static;
25
    top: 0;
26
  }
27
  .at-mt .menu-toggle {
28
    display: none;
29
  }
30
  .at-mt .menu-toggle ul li,
31
  .at-mt .menu-toggle ul li a {
32
    display: block;
33
    float:none;
34
  }';
35

    
36
  $menu_toggle_css_inactive = '
37
  .at-mt .at-menu-toggle-button {
38
    position: absolute;
39
    top: -99999em;
40
  }
41
  .at-mt .menu-toggle {
42
    display:block !important;
43
  }';
44

    
45
  // We need extra overrides for superfish if the module is active, pre Superfish module 1.9
46
  if (module_exists('superfish')) {
47
  $menu_toggle_superfish_css = '
48
  .at-mt .menu-toggle .sf-menu {
49
    float: none;
50
    margin: 0;
51
    height: auto;
52
  }
53
  .at-mt .menu-toggle .sf-menu ul,
54
  .at-mt .menu-toggle .sf-menu li {
55
    margin: 0;
56
    position: relative;
57
    top: 0;
58
    display: block;
59
    float: none;
60
    clear: both;
61
    width: 100% !important;
62
    left: 0 !important;
63
  }
64
  .at-mt .menu-toggle .sf-menu ul {
65
    left: 0;
66
    position: static;
67
  }
68
  .at-mt .menu-toggle .sf-hidden {
69
    display: none !important;
70
  }';
71
  }
72
  else {
73
    $menu_toggle_superfish_css = '';
74
  }
75

    
76
  $comment = "/* Menu toggle is using the media queries from the standard, tablet and smalltouch layout settings */\n";
77

    
78
  // Smalltouch portrait
79
  $smalltouch_portrait_css = $menu_toggle_css_active . $menu_toggle_superfish_css;
80
  $menu_toggle_css[] = $comment . '@media ' . $smalltouch_portrait_media_query . ' {' . "\n" . $smalltouch_portrait_css . "\n" . '}';
81

    
82
  // Smalltouch landscape
83
  $smalltouch_landscape_css = $menu_toggle_css_active . $menu_toggle_superfish_css;
84
  $menu_toggle_css[] = '@media ' . $smalltouch_landscape_media_query . ' {' . "\n" . $smalltouch_landscape_css . "\n" . '}';
85

    
86
  // Tablet portrait
87
  if (isset($values['menu_toggle_tablet_portrait']) && $values['menu_toggle_tablet_portrait'] == 1) {
88
    $tablet_portrait_css = $menu_toggle_css_active . $menu_toggle_superfish_css;
89
  }
90
  else {
91
    $tablet_portrait_css = $menu_toggle_css_inactive;
92
  }
93
  $menu_toggle_css[] = '@media ' . $tablet_portrait_media_query . ' {' . "\n" . $tablet_portrait_css . "\n" . '}';
94

    
95
  // Tablet landscape
96
  if (isset($values['menu_toggle_tablet_landscape']) && $values['menu_toggle_tablet_landscape'] == 1) {
97
    $tablet_landscape_css = $menu_toggle_css_active . $menu_toggle_superfish_css;
98
  }
99
  else {
100
    $tablet_landscape_css = $menu_toggle_css_inactive;
101
  }
102
  $menu_toggle_css[] = '@media ' . $tablet_landscape_media_query . ' {' . "\n" . $tablet_landscape_css . "\n" . '}';
103

    
104
  // Bigscreen is always inactive
105
  $menu_toggle_css[] = '@media ' . $bigscreen_media_query . ' {' . "\n" . $menu_toggle_css_inactive . "\n" . '}';
106

    
107
  // Contextual links can get messed up, add a brutal override to make sure that does not happen
108
  $menu_toggle_css[] = '.at-mt .at-menu-toggle div.contextual-links-wrapper ul.contextual-links{display:none}';
109

    
110
  $menu_toggle_css_processed = implode("\n", $menu_toggle_css);
111
  $file_name = $theme_name . '.menutoggle.css';
112
  $filepath = $path . '/' . $file_name;
113
  file_unmanaged_save_data($menu_toggle_css_processed, $filepath, FILE_EXISTS_REPLACE);
114
}