Skip to content

Instantly share code, notes, and snippets.

@vdchristelle
vdchristelle / page.tpl.php
Last active December 22, 2015 10:48
Ability to set linebreak in $h1_title Titel splitsen
<h1><?php print str_replace('[', '<span>', str_replace(']', '</span>', $h1_title)); ?></h1>
of <h1><?php print str_replace(array('[', ']'), array('<span>', '</span>'), $h1_title); ?></h1>
@vdchristelle
vdchristelle / template.php
Created September 9, 2013 07:00
GoogleAnalytics data komt niet binnen Opmerking van beneden, de Marketeers komen dikwijls tot de vaststelling dat de GA module niet werkt. Eén van de oorzaken kan onderstaand stukje code zijn: Dit stukje komt uit het template.php bestand in het basetheme. De 2 lijnen die in commentaar staan moeten ook in commentaar blijven. Fitnesspecialist was …
function basetheme_preprocess_html(&$vars) {
$vars['theme_folder'] = base_path() . path_to_theme();
// Function to cleanup html source a bit more
function indent($string) {
$spacing = " ";
$string = ltrim(str_replace('<link', $spacing . '<link', $string));
$string = ltrim(str_replace('<meta', $spacing . '<meta', $string));
$string = ltrim(str_replace('<script', $spacing . '<script', $string));
@vdchristelle
vdchristelle / export navigation view.php
Created September 9, 2013 07:20
Menu items with images (menu blocks)
$view = new view();
$view->name = 'navigation';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Navigation';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@vdchristelle
vdchristelle / capitalize only first letter of a string.js
Created September 9, 2013 07:25
capitalize only first letter of a string
// capitalize only first letter of a string
function capitaliseFirstLetter(string){
return string.charAt(0).toUpperCase() + string.slice(1);
}
@vdchristelle
vdchristelle / accordion effect on hover.js
Created September 9, 2013 07:26
accordion effect on hover
/**
* accordion effect on hover
* HTML: .sub-menu-1 ul li.expanded ul li
*/
$('.sub-menu-1 .expanded').hover(function() {
that = this;
setTimeout(function() {
$(that).find('ul').slideDown();
$(that).siblings().find('ul').slideUp();
@vdchristelle
vdchristelle / disable html5 validation.js
Created September 9, 2013 07:26
disable html5 validation
/* disable html5 validation */
$('form').each(function() {
$(this).attr('novalidate', 'novalidate');
});
@vdchristelle
vdchristelle / get image brightness.js
Created September 9, 2013 07:28
Calculate the brighness of the image and change color of another element e.g. banner text
/**
* jQuery function will convert each color to gray scale and return average of all pixels, so final value will be between 0 (darkest) and 255 (brightest){Object} $
* docu: http://stackoverflow.com/questions/13762864/image-dark-light-detection-client-sided-script
* docu: http://jsfiddle.net/s7Wx2/7/
*/
(function ($) {
//darkness of picture
function getImageLightness(imageSrc,callback) {
@vdchristelle
vdchristelle / language block select list.js
Created September 9, 2013 07:30
make a select from our language list
if($(window).width() > 550){
// make a select from our language list
$('.language ul').each(function(){
var select = $(document.createElement('select')).attr('class', 'select').insertBefore($(this).hide());
$('ul.language-switcher-locale-url > li').each(function(){
var link = $(this).find('a');
var url = link.attr('href');
option = $(document.createElement('option')).appendTo(select).val(url).html($(this).html());
@vdchristelle
vdchristelle / extra css class on teasertext when no image.js
Created September 9, 2013 07:33
nieuwsitems uitvullen als er geen foto geupload is met jQuery of in preprocess_html()
$(document).ready(function() {
//optie 1
$('.sidebar-menu').find('li.active').next().addClass('nextitem');
$('.mainmenu').find('li.active').next().addClass('nextitem');
//if news has no image, add extra classes
if ( $('.node-nieuws-item .group-left .group_testimonial_img').length == 0) {
$('.node-nieuws-item .group-left').addClass('hide');
$('.node-nieuws-item .group-right').addClass('width_100');
@vdchristelle
vdchristelle / adding numbers to slides and menu blocks.js
Created September 9, 2013 07:37
add numbering to the menu blocks and the references slider Used in: LIS Hydraulics
$(document).ready(function(){
//add numbering to the menu blocks and the references slider
//needed: ul with class 'counter'
//reset variables
var i = 0;
var total = 0;
$('.subpages-overzicht').find('ul.counter').children('li').each(function(){