Projet

Général

Profil

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

root / drupal7 / sites / all / themes / simplecorp / template.php @ b9383c72

1
<?php 
2
        
3
/**
4
 * Add javascript files for jquery slideshow.
5
 */
6
if (theme_get_setting('slideshow_js','simplecorp')):
7

    
8
        drupal_add_js(drupal_get_path('theme', 'simplecorp') . '/js/plugins/jquery.flexslider-min.js');
9

    
10
        //Initialize slideshow using theme settings
11
        $effect=theme_get_setting('slideshow_effect','simplecorp');
12
        $effect_time=theme_get_setting('slideshow_effect_time','simplecorp')*1000;
13
        $slideshow_controls=theme_get_setting('slideshow_controls','simplecorp');
14
        $slideshow_random=theme_get_setting('slideshow_random','simplecorp');
15
        $slideshow_pause=theme_get_setting('slideshow_pause','simplecorp');
16
        $slideshow_touch=theme_get_setting('slideshow_touch','simplecorp');
17

    
18
        drupal_add_js('
19
                jQuery(document).ready(function($) {
20

21
                    $(window).load(function() {
22

23
                        $(".flexslider").fadeIn("slow");
24

25
                        $(".flexslider").flexslider({
26
                            useCSS: false,
27
                            animation: "'.$effect.'",
28
                            controlNav: '.$slideshow_controls.',
29
                            directionNav: '.$slideshow_controls.',
30
                            animationLoop: true,
31
                            touch: '.$slideshow_touch.',
32
                            pauseOnHover: '.$slideshow_pause.',
33
                            nextText: "&rsaquo;",
34
                            prevText: "&lsaquo;",
35
                            keyboard: true,
36
                            slideshowSpeed: '.$effect_time.',
37
                            randomize: '.$slideshow_random.',
38
                            start: function(slider) {
39
                                slider.removeClass("loading");
40
                            }
41
                        });
42
                    });
43
                });',array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
44
        );
45

    
46
endif;
47

    
48
/**
49
 * Add javascript files for jquery carousel.
50
 */
51
if (theme_get_setting('carousel_js','simplecorp')):
52

    
53
        drupal_add_js(drupal_get_path('theme', 'simplecorp') . '/js/plugins/jquery.jcarousel.min.js');
54
        drupal_add_js(drupal_get_path('theme', 'simplecorp') . '/js/jquery.easing-1.3.min.js');
55

    
56
        //Initialize slideshow using theme settings
57
        $carousel_effect_time=theme_get_setting('carousel_effect_time','simplecorp')*1000;
58
        $carousel_effect=theme_get_setting('carousel_effect','simplecorp');
59

    
60
        drupal_add_js('
61
                jQuery(document).ready(function($) {
62

63
                    var currentWindowWidth = jQuery(window).width();
64
                    jQuery(window).resize(function() {
65
                        currentWindowWidth = jQuery(window).width();
66
                    });
67

68
                    $(window).load(function() {
69

70
                        $("ul#projects-carousel").fadeIn("fast");
71

72
                        if (jQuery(".portfolio-item-hover-content").length && jQuery()) {
73
                            function hover_effect() {
74
                                jQuery(".portfolio-item-hover-content").hover(function() {
75
                                    jQuery(this).find("div,a").stop(0, 0).removeAttr("style");
76
                                    jQuery(this).find(".hover-options").animate({
77
                                        opacity: 0.9
78
                                    }, "fast");
79
                                    jQuery(this).find("a").animate({
80
                                        "top": "60%"
81
                                    });
82
                                }, function() {
83
                                    jQuery(this).find(".hover-options").stop(0, 0).animate({
84
                                        opacity: 0
85
                                    }, "fast");
86
                                    jQuery(this).find("a").stop(0, 0).animate({
87
                                        "top": "150%"
88
                                    }, "slow");
89
                                    jQuery(this).find("a.zoom").stop(0, 0).animate({
90
                                        "top": "150%"
91
                                    }, "slow");
92
                                });
93
                            }
94
                            hover_effect();
95
                        }
96
                                
97
                        (function() {
98
                            var jQuerycarousel = jQuery("#projects-carousel");
99
                            if (jQuerycarousel.length) {
100
                                var scrollCount;
101
                                if (jQuery(window).width() < 480) {
102
                                    scrollCount = 1;
103
                                } else if (jQuery(window).width() < 768) {
104
                                    scrollCount = 1;
105
                                } else if (jQuery(window).width() < 960) {
106
                                    scrollCount = 3;
107
                                } else {
108
                                    scrollCount = 4;
109
                                }
110
                                jQuerycarousel.jcarousel({
111
                                    animation: '.$carousel_effect_time.',
112
                                    easing: "'.$carousel_effect.'",
113
                                    scroll: scrollCount,
114
                                    initCallback: function() {
115
                                        jQuerycarousel.removeClass("loading")
116
                                    },
117
                                });
118
                            }
119
                        })();
120
                    });
121
                });',        array('type' => 'inline', 'scope' => 'footer', 'weight' => 7)
122
        );        
123

    
124
endif;
125

    
126
/**
127
 * Add custom javascript for main menu
128
 */
129
if (theme_get_setting('main_menu_custom_js','simplecorp')):
130
        drupal_add_js('
131
                jQuery(document).ready(function($) {
132

133
                    if (jQuery("#main-navigation, #main-navigation .content").length && jQuery()) {
134
                        var arrowimages = {
135
                            down: ["downarrowclass", "./images/plus.png", 23],
136
                            right: ["rightarrowclass", "./images/plus-white.png"]
137
                        }
138
                        var jqueryslidemenu = {
139
                            animateduration: {
140
                                over: 200,
141
                                out: 100
142
                            },
143
                            //duration of slide in/ out animation, in milliseconds
144
                            buildmenu: function(menuid, arrowsvar) {
145

146
                                jQuery(document).ready(function(jQuery) {
147
                                    var jQuerymainmenu = jQuery("#" + menuid + ">ul.menu:not(.sf-menu)")
148
                                    var jQueryheaders = jQuerymainmenu.find("ul").parent()
149

150
                                    jQueryheaders.each(function(i) {
151
                                        var jQuerycurobj = jQuery(this)
152
                                        var jQuerysubul = jQuery(this).find("ul:eq(0)")
153
                                        this._dimensions = {
154
                                            w: this.offsetWidth,
155
                                            h: this.offsetHeight,
156
                                            subulw: jQuerysubul.outerWidth(),
157
                                            subulh: jQuerysubul.outerHeight()
158
                                        }
159
                                        this.istopheader = jQuerycurobj.parents("ul").length == 1 ? true : false
160
                                        jQuerysubul.css({
161
                                            top: this.istopheader ? this._dimensions.h + "px" : 0
162
                                        })
163
                                        jQuerycurobj.children("a:eq(0)").css(this.istopheader ? {
164
                                            paddingRight: arrowsvar.down[2]
165
                                        } : {}).append("<span class=" + (this.istopheader ? arrowsvar.down[0] : arrowsvar.right[0]) + " />")
166

167
                                        jQuerycurobj.hover(
168

169
                                        function(e) {
170
                                            var jQuerytargetul = jQuery(this).children("ul:eq(0)")
171
                                            this._offsets = {
172
                                                left: jQuery(this).offset().left,
173
                                                top: jQuery(this).offset().top
174
                                            }
175
                                            var menuleft = this.istopheader ? 0 : this._dimensions.w
176
                                            menuleft = (this._offsets.left + menuleft + this._dimensions.subulw > jQuery(window).width()) ? (this.istopheader ? -this._dimensions.subulw + this._dimensions.w : -this._dimensions.w) : menuleft
177
                                            if (jQuerytargetul.queue().length <= 1) //if 1 or less queued animations
178
                                            jQuerytargetul.css({
179
                                                left: menuleft + "px",
180
                                                width: this._dimensions.subulw + "px"
181
                                            }).slideDown(jqueryslidemenu.animateduration.over)
182
                                        }, function(e) {
183
                                            var jQuerytargetul = jQuery(this).children("ul:eq(0)")
184
                                            jQuerytargetul.slideUp(jqueryslidemenu.animateduration.out)
185
                                        }) //end hover
186
                                        jQuerycurobj.click(function() {
187
                                            jQuery(this).children("ul:eq(0)").hide()
188
                                        })
189
                                    }) //end jQueryheaders.each()
190

191
                                    jQuerymainmenu.find("ul").css({
192
                                        display: "none",
193
                                        visibility: "visible"
194
                                    })
195

196
                                }) //end document.ready
197
                            }
198
                        }
199

200
                        jqueryslidemenu.buildmenu("main-navigation .content", arrowimages)
201
                        jqueryslidemenu.buildmenu("main-navigation", arrowimages)
202

203
                    }
204
                });', array('type' => 'inline', 'scope' => 'footer', 'weight' => 6)
205
        );
206
endif;
207

    
208

    
209
/**
210
 * Add jquery.tipsy.js file for header social icons
211
 */
212
if (theme_get_setting('header_tooltip_js','simplecorp')):
213

    
214
        drupal_add_js(drupal_get_path('theme', 'simplecorp') . '/js/plugins/jquery.tipsy.js');
215
        drupal_add_js('
216
                jQuery(document).ready(function($) {
217
                    if (jQuery().tipsy) {
218
                        jQuery("#social-01").tipsy({ gravity: "n" });
219
                        jQuery("#social-02").tipsy({ gravity: "n" });
220
                        jQuery("#social-03").tipsy({ gravity: "n" });
221
                        jQuery("#social-04").tipsy({ gravity: "n" });
222
                        jQuery("#social-05").tipsy({ gravity: "n" });
223
                        jQuery("#social-06").tipsy({ gravity: "n" });
224
                        jQuery("#social-07").tipsy({ gravity: "n" });
225
                        jQuery("#social-07").tipsy({ gravity: "n" });
226
                        jQuery("#social-08").tipsy({ gravity: "n" });
227
                        jQuery("#social-09").tipsy({ gravity: "n" });
228
                        jQuery("#social-10").tipsy({ gravity: "n" });
229
                        jQuery("#social-11").tipsy({ gravity: "n" });
230
                        jQuery("#team-01").tipsy({ gravity: "s" });
231
                    }
232
                });', array('type' => 'inline', 'scope' => 'footer', 'weight' => 9)
233
        );
234
endif;                        
235

    
236

    
237
/**
238
 * Add jquery.prettyPhoto.js and prettyPhoto.css files for portfolio items
239
 */
240
if (theme_get_setting('prettyphoto_js','simplecorp')):
241
        
242
        drupal_add_js(drupal_get_path('theme', 'simplecorp') . '/js/plugins/jquery.prettyPhoto.js');
243
        drupal_add_css(drupal_get_path('theme', 'simplecorp') . '/css/plugins/prettyPhoto.css');
244
        
245
        $prettyphoto_theme=theme_get_setting('prettyphoto_theme','simplecorp');
246
        $prettyphoto_social_tools=theme_get_setting('prettyphoto_social_tools','simplecorp');
247

    
248
        if ($prettyphoto_social_tools):
249
                drupal_add_js('
250
                        jQuery("a[data-rel^=prettyPhoto], a.prettyPhoto, a[rel^=prettyPhoto]").prettyPhoto({
251
                            overlay_gallery: false,
252
                            theme: "'.$prettyphoto_theme.'",
253
                        });', array('type' => 'inline', 'scope' => 'footer', 'weight' => 15)
254
                );
255
        else:
256
                drupal_add_js('
257
                        jQuery("a[data-rel^=prettyPhoto], a.prettyPhoto, a[rel^=prettyPhoto]").prettyPhoto({
258
                            overlay_gallery: false,
259
                            theme: "'.$prettyphoto_theme.'",
260
                            social_tools: false,
261
                        });', array('type' => 'inline', 'scope' => 'footer', 'weight' => 15)
262
                );
263
        endif;
264

    
265

    
266
endif;
267

    
268

    
269
/**
270
 * Add Javascript for responsive mobile menu
271
 */
272
if (theme_get_setting('responsive_menu_state','simplecorp')) {
273

    
274
$responsive_menu_switchwidth=(int)theme_get_setting('responsive_menu_switchwidth','simplecorp');
275
$responsive_menu_topoptiontext=theme_get_setting('responsive_menu_topoptiontext','simplecorp');
276
drupal_add_js(array('simplecorp' => array('responsive_menu_topoptiontext' => $responsive_menu_topoptiontext)), 'setting');
277

    
278
drupal_add_js(drupal_get_path('theme', 'simplecorp') .'/js/plugins/jquery.mobilemenu.min.js');
279
drupal_add_js('
280
jQuery(document).ready(function($) {
281

282
        $("#main-navigation > ul, #main-navigation .content > ul").mobileMenu({
283
        prependTo: "#navigation-wrapper",
284
        combine: false,
285
        switchWidth: '.$responsive_menu_switchwidth.',
286
        topOptionText: Drupal.settings.simplecorp[\'responsive_menu_topoptiontext\']
287
        });
288

289
});', array('type' => 'inline', 'scope' => 'footer', 'weight' => 10)
290
);
291
}
292

    
293
/**
294
 * Add Javascript for quicksand plugin
295
 */
296
if (theme_get_setting('quicksand_js','simplecorp')):
297
drupal_add_js(drupal_get_path('theme', 'simplecorp') .'/js/plugins/jquery.quicksand.js');
298
drupal_add_js(drupal_get_path('theme', 'simplecorp') .'/js/plugins/quicksand_initialize.js');
299
endif;        
300

    
301

    
302
/**
303
 * Add javascript for back to top action
304
 */
305
drupal_add_js('
306
jQuery(document).ready(function() { jQuery(".backtotop").click(function(){ jQuery("html, body").animate({scrollTop:0}, "slow"); return false; }); });
307
', array('type' => 'inline', 'scope' => 'footer', 'weight' => 9)
308
);
309

    
310

    
311
/**
312
 * Add Javascript for jTweetsAnywhere plugin
313
 */
314
if (theme_get_setting('jtweetanywhere_js','simplecorp')):
315

    
316
        drupal_add_js(drupal_get_path('theme', 'simplecorp') .'/js/plugins/jquery.jtweetsanywhere-1.3.1.js');
317
        drupal_add_css(drupal_get_path('theme', 'simplecorp') . '/css/plugins/jquery.jtweetsanywhere-1.3.1.css');
318

    
319
        //Initialize slideshow using theme settings
320
        $jtweetanywhere_id=theme_get_setting('jtweetanywhere_id','simplecorp');
321
    drupal_add_js(array('simplecorp' => array('jtweetanywhere_id' => $jtweetanywhere_id)), 'setting');
322

    
323
        drupal_add_js('
324
                jQuery(document).ready(function($) {
325
                    $("#jTweets").jTweetsAnywhere({
326
                        username: Drupal.settings.simplecorp[\'jtweetanywhere_id\'],
327
                        count: 2,
328
                        showTweetFeed: {
329
                            showInReplyTo: false,
330
                            paging: {
331
                                mode: "none"
332
                            }
333
                        }
334
                    });
335
                });',        array('type' => 'inline', 'scope' => 'footer', 'weight' => 16)
336
        );
337
endif;        
338

    
339

    
340
/**
341
 * Return a themed breadcrumb trail.
342
 *
343
 * @param $breadcrumb
344
 *   An array containing the breadcrumb links.
345
 * @return
346
 *   A string containing the breadcrumb output.
347
 */
348
function simplecorp_breadcrumb($variables){
349
        $breadcrumb = $variables['breadcrumb'];
350
        $breadcrumb_separator=theme_get_setting('breadcrumb_separator','simplecorp');
351

    
352
        if (!empty($breadcrumb)) {
353
        $breadcrumb[] = drupal_get_title();
354
        return '<div id="breadcrumb">' . implode(' <span class="breadcrumb-separator">' . $breadcrumb_separator . ' </span>' , $breadcrumb) . '</div>';
355
        }
356

    
357
}
358

    
359

    
360
/**
361
 * Add files for custom buttons.
362
 */
363
if (!(theme_get_setting('button_color','simplecorp') == '')):
364
        drupal_add_css(drupal_get_path('theme', 'simplecorp') . '/css/shortcodes/buttons.css');
365
endif;
366

    
367
function simplecorp_button($variables) {
368
        $button_color = theme_get_setting('button_color','simplecorp');
369
        if($button_color == '') {
370
                $button_classes = '';
371
        } else {
372
                $button_classes = ' button small round ';
373
        }        
374
        $element = $variables['element'];
375
        $element['#attributes']['type'] = 'submit';
376
        element_set_attributes($element, array('id', 'name', 'value'));
377

    
378
        $element['#attributes']['class'][] = 'form-' . $element['#button_type'] . $button_classes . $button_color;
379
        if (!empty($element['#attributes']['disabled'])) {
380
        $element['#attributes']['class'][] = 'form-button-disabled';
381
        }
382

    
383
        return '<input' . drupal_attributes($element['#attributes']) . ' />';
384
}
385

    
386
/**
387
 * Add styles for theme color schemes.
388
 */
389
if (!(theme_get_setting('theme_color','simplecorp') == 'default')):
390
        $theme_color = theme_get_setting('theme_color','simplecorp');
391
        drupal_add_css(drupal_get_path('theme', 'simplecorp') . '/css/color-schemes/' . $theme_color . '/styles.css', array('group' => CSS_THEME, 'weight' => 120));
392
endif;
393

    
394

    
395
/**
396
 * Add columns.css
397
 */
398
if (theme_get_setting('columns_enable','simplecorp')):
399
        drupal_add_css(drupal_get_path('theme', 'simplecorp') . '/css/shortcodes/columns.css', array('group' => CSS_THEME, 'weight' => 116));
400
endif;
401

    
402

    
403
/**
404
 * Add lists.css
405
 */
406
if (theme_get_setting('lists_enable','simplecorp')):
407
        drupal_add_css(drupal_get_path('theme', 'simplecorp') . '/css/shortcodes/lists.css', array('group' => CSS_THEME, 'weight' => 117));
408
endif;
409

    
410

    
411
/**
412
 * Add boxes.css
413
 */
414
if (theme_get_setting('boxes_enable','simplecorp')):
415
        drupal_add_css(drupal_get_path('theme', 'simplecorp') . '/css/shortcodes/boxes.css', array('group' => CSS_THEME, 'weight' => 118));
416
endif;
417

    
418

    
419
/**
420
 * Page alter.
421
 */
422
function simplecorp_page_alter($page) {
423
        if (theme_get_setting('responsive_meta','simplecorp')):
424
                $mobileoptimized = array(
425
                '#type' => 'html_tag',
426
                '#tag' => 'meta',
427
                '#attributes' => array(
428
                'name' =>  'MobileOptimized',
429
                'content' =>  'width'
430
                )
431
                );
432

    
433
                $handheldfriendly = array(
434
                '#type' => 'html_tag',
435
                '#tag' => 'meta',
436
                '#attributes' => array(
437
                'name' =>  'HandheldFriendly',
438
                'content' =>  'true'
439
                )
440
                );
441

    
442
                $viewport = array(
443
                '#type' => 'html_tag',
444
                '#tag' => 'meta',
445
                '#attributes' => array(
446
                'name' =>  'viewport',
447
                'content' =>  'width=device-width, initial-scale=1'
448
                )
449
                );
450

    
451
                drupal_add_html_head($mobileoptimized, 'MobileOptimized');
452
                drupal_add_html_head($handheldfriendly, 'HandheldFriendly');
453
                drupal_add_html_head($viewport, 'viewport');
454
        endif;
455
}
456

    
457

    
458
/**
459
 * Preprocess function for node.tpl.php.
460
 */
461
function simplecorp_preprocess_node(&$variables) {
462
        $node = $variables['node'];
463
        $variables['submitted_day'] = format_date($node->created, 'custom', 'j');
464
        $variables['submitted_month'] = format_date($node->created, 'custom', 'F');
465
        $variables['submitted_year'] = format_date($node->created, 'custom', 'Y');
466
}
467

    
468

    
469
/**
470
 * Preprocess function for comment.tpl.php.
471
 */
472
function simplecorp_preprocess_comment(&$variables) {
473
        $comment = $variables['comment'];
474
        $variables['submitted_day_c'] = format_date($comment->created, 'custom', 'jS');
475
        $variables['submitted_month_c'] = format_date($comment->created, 'custom', 'F');
476
        $variables['submitted_year_c'] = format_date($comment->created, 'custom', 'Y');
477
}
478

    
479

    
480
/**
481
 * Implements hook_preprocess_html().
482
 */
483
function simplecorp_preprocess_html(&$vars) {
484
        $vars['rdf'] = new stdClass;
485

    
486
        if (module_exists('rdf')) {
487
        $vars['doctype'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">' . "\n";
488
        $vars['rdf']->version = ' version="HTML+RDFa 1.1"';
489
        $vars['rdf']->namespaces = $vars['rdf_namespaces'];
490
        $vars['rdf']->profile = ' profile="' . $vars['grddl_profile'] . '"';
491
        }
492
        else {
493
        $vars['doctype'] = '<!DOCTYPE html>' . "\n";
494
        $vars['rdf']->version = '';
495
        $vars['rdf']->namespaces = '';
496
        $vars['rdf']->profile = '';
497
        }
498
}
499

    
500
?>