Last active
August 29, 2015 14:02
-
-
Save magnum/bc687f0afda8227461f9 to your computer and use it in GitHub Desktop.
laba test drupal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Project: Bootstrap Hover Dropdown | |
* Author: Cameron Spear | |
* Contributors: Mattia Larentis | |
* | |
* Dependencies: Bootstrap's Dropdown plugin, jQuery | |
* | |
* A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience. | |
* | |
* License: MIT | |
* | |
* http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/ | |
*/ | |
;(function ($, window, undefined) { | |
// outside the scope of the jQuery plugin to | |
// keep track of all dropdowns | |
var $allDropdowns = $(); | |
// if instantlyCloseOthers is true, then it will instantly | |
// shut other nav items when a new one is hovered over | |
$.fn.dropdownHover = function (options) { | |
// don't do anything if touch is supported | |
// (plugin causes some issues on mobile) | |
if('ontouchstart' in document) return this; // don't want to affect chaining | |
// the element we really care about | |
// is the dropdown-toggle's parent | |
$allDropdowns = $allDropdowns.add(this.parent()); | |
return this.each(function () { | |
var $this = $(this), | |
$parent = $this.parent(), | |
defaults = { | |
delay: 500, | |
instantlyCloseOthers: true | |
}, | |
data = { | |
delay: $(this).data('delay'), | |
instantlyCloseOthers: $(this).data('close-others') | |
}, | |
showEvent = 'show.bs.dropdown', | |
hideEvent = 'hide.bs.dropdown', | |
// shownEvent = 'shown.bs.dropdown', | |
// hiddenEvent = 'hidden.bs.dropdown', | |
settings = $.extend(true, {}, defaults, options, data), | |
timeout; | |
$parent.hover(function (event) { | |
// so a neighbor can't open the dropdown | |
if(!$parent.hasClass('open') && !$this.is(event.target)) { | |
// stop this event, stop executing any code | |
// in this callback but continue to propagate | |
return true; | |
} | |
openDropdown(event); | |
}, function () { | |
timeout = window.setTimeout(function () { | |
$parent.removeClass('open'); | |
$this.trigger(hideEvent); | |
}, settings.delay); | |
}); | |
// this helps with button groups! | |
$this.hover(function (event) { | |
// this helps prevent a double event from firing. | |
// see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55 | |
if(!$parent.hasClass('open') && !$parent.is(event.target)) { | |
// stop this event, stop executing any code | |
// in this callback but continue to propagate | |
return true; | |
} | |
openDropdown(event); | |
}); | |
// handle submenus | |
$parent.find('.dropdown-submenu').each(function (){ | |
var $this = $(this); | |
var subTimeout; | |
$this.hover(function () { | |
window.clearTimeout(subTimeout); | |
$this.children('.dropdown-menu').show(); | |
// always close submenu siblings instantly | |
$this.siblings().children('.dropdown-menu').hide(); | |
}, function () { | |
var $submenu = $this.children('.dropdown-menu'); | |
subTimeout = window.setTimeout(function () { | |
$submenu.hide(); | |
}, settings.delay); | |
}); | |
}); | |
function openDropdown(event) { | |
$allDropdowns.find(':focus').blur(); | |
if(settings.instantlyCloseOthers === true) | |
$allDropdowns.removeClass('open'); | |
window.clearTimeout(timeout); | |
$parent.addClass('open'); | |
$this.trigger(showEvent); | |
} | |
}); | |
}; | |
$(document).ready(function () { | |
// apply dropdownHover to all elements with the data-hover="dropdown" attribute | |
$('[data-hover="dropdown"]').dropdownHover(); | |
}); | |
})(jQuery, this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = Laba Portfolio Bootstrap Sub-theme | |
description = A Bootstrap Sub-theme. | |
core = 7.x | |
base theme = bootstrap | |
;;;;;;;;;;;;;;;;;;;;; | |
;; Regions | |
;;;;;;;;;;;;;;;;;;;;; | |
regions[navigation] = 'Navigation' | |
regions[header] = 'Top Bar' | |
regions[highlighted] = 'Highlighted' | |
regions[help] = 'Help' | |
regions[content] = 'Content' | |
regions[sidebar_first] = 'Primary' | |
regions[sidebar_second] = 'Secondary' | |
regions[footer] = 'Footer' | |
regions[page_top] = 'Page top' | |
regions[page_bottom] = 'Page bottom' | |
;;;;;;;;;;;;;;;;;;;;; | |
;; Stylesheets | |
;;;;;;;;;;;;;;;;;;;;; | |
stylesheets[all][] = css/style.css | |
stylesheets[all][] = css/custom.css | |
; For information on choosing the desired method, please read the Drupal | |
; Bootstrap sub-theme "how-to" documentation: | |
; https://drupal.org/node/1978010 | |
; ;---------------------------------- | |
; ; METHOD 1: Bootstrap Source Files | |
; ;---------------------------------- | |
; | |
; ;;;;;;;;;;;;;;;;;;;;; | |
; ;; Scripts | |
; ;;;;;;;;;;;;;;;;;;;;; | |
; | |
; scripts[] = 'bootstrap/js/affix.js' | |
; scripts[] = 'bootstrap/js/alert.js' | |
; scripts[] = 'bootstrap/js/button.js' | |
; scripts[] = 'bootstrap/js/carousel.js' | |
; scripts[] = 'bootstrap/js/collapse.js' | |
; scripts[] = 'bootstrap/js/dropdown.js' | |
; scripts[] = 'bootstrap/js/modal.js' | |
; scripts[] = 'bootstrap/js/tooltip.js' | |
; scripts[] = 'bootstrap/js/popover.js' | |
; scripts[] = 'bootstrap/js/scrollspy.js' | |
; scripts[] = 'bootstrap/js/tab.js' | |
; scripts[] = 'bootstrap/js/transition.js' | |
; | |
; ; Disable BootstrapCDN if using Bootstrap source files in your sub-theme. | |
; settings[bootstrap_cdn] = '' | |
; ;------------------------- | |
; ; METHOD 2: Bootstrap CDN | |
; ;------------------------- | |
; | |
; Method 2 uses BootstrapCDN, the only thing you might need to provide here | |
; is overrides to Bootstrap theme settings. Copy them here from the base theme | |
; to override. | |
scripts[] = 'js/bootstrap-hover-dropdown.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* template.php | |
*/ | |
function bootstrap_laba_portfolio_menu_link(array $variables) { | |
$element = $variables['element']; | |
$sub_menu = ''; | |
if ($element['#below']) { | |
// Prevent dropdown functions from being added to management menu so it | |
// does not affect the navbar module. | |
if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) { | |
$sub_menu = drupal_render($element['#below']); | |
} | |
else{ | |
unset($element['#below']['#theme_wrappers']); | |
$sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>'; | |
$element['#localized_options']['attributes']['class'][] = 'dropdown-toggle disabled'; | |
$element['#localized_options']['attributes']['data-toggle'] = 'dropdown'; | |
$element['#localized_options']['attributes']['data-hover'] = 'dropdown'; | |
$element['#localized_options']['attributes']['data-delay'] = '100'; | |
$element['#localized_options']['attributes']['data-close-others'] = 'false'; | |
// Check if this element is nested within another | |
if ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] > 1)) { | |
// Generate as dropdown submenu | |
$element['#attributes']['class'][] = 'dropdown-submenu'; | |
$element['#localized_options']['attributes']['tabindex'][] = '-1'; | |
} | |
else { | |
// Generate as standard dropdown | |
$element['#attributes']['class'][] = 'dropdown'; | |
$element['#localized_options']['html'] = TRUE; | |
$element['#title'] .= '<span class="caret"></span>'; | |
} | |
} | |
// Set dropdown trigger element to # to prevent inadvertant page loading with submenu click | |
$element['#localized_options']['attributes']['data-target'] = '#'; | |
} | |
// On primary navigation menu, class 'active' is not set on active menu item. | |
// @see https://drupal.org/node/1896674 | |
if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) { | |
$element['#attributes']['class'][] = 'active'; | |
} | |
$output = l($element['#title'], $element['#href'], $element['#localized_options']); | |
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment