Skip to content

Instantly share code, notes, and snippets.

@reubenmoes
reubenmoes / gist:22707e196fd9c968634d
Last active August 29, 2015 14:09
Remove logging using grunt-contrib-uglify
uglify: {
options: {
banner: '<%= banner %>',
compress: {
//THE MAGIC HAPPENS HERE
drop_console: true,
drop_debugger: true
}
},
dist: {
@reubenmoes
reubenmoes / ckeditor.styles.js
Created December 9, 2014 20:57
ckeditor.styles.js example
/*
* This file is used/requested by the 'Styles' button.
* The 'Styles' button is not enabled by default in DrupalFull and DrupalFiltered toolbars.
*/
if(typeof(CKEDITOR) !== 'undefined') {
CKEDITOR.addStylesSet( 'drupal',
[
/* Block Styles */
@reubenmoes
reubenmoes / ckeditor.config.js
Created December 9, 2014 20:58
Example ckeditor.config.js that forces image height/width
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/*
WARNING: clear browser's cache after you modify this file.
If you don't do this, you may notice that browser is ignoring all your changes.
*/
CKEDITOR.editorConfig = function(config) {
@reubenmoes
reubenmoes / gist:ffc933891740754c4e31
Last active August 29, 2015 14:17
Modernizr Position Fixed + Transforms Combo Test
//Test if browser supports position fixed and transforms in combination
//http://stackoverflow.com/questions/18572488/transform-doesnt-work-on-position-fixed-divs-on-android
Modernizr.addTest('fixedtransforms', function(){
var css = '#modernizr { position: fixed; top: 0; left: 10px; width: 100%; height: 50px; -moz-transform: transformX(-20px); -ms-transform: translateX(-20px); -webkit-transform: translateX(-20px); transform: translateX(-20px); }';
return Modernizr.testStyles(css, function(element, rule){
//NOTE: Android gives false positives
return navigator.userAgent.indexOf('Android 4.1') === -1 &&
navigator.userAgent.indexOf('Android 2.') === -1 &&
element.getBoundingClientRect().left === -10;
@reubenmoes
reubenmoes / gist:ef129ab50fe8f971ae61
Last active August 29, 2015 14:18
Drupal: theme_date_display_range with a human friendly date.
//
//implements theme_date_display_range()
//A more human friendly date range
//Example output:
//Oct 8 to 15, 2015
//Oct 8 to Nov 3, 2015
//Oct 8, 2015 to Jan 3, 2016
function dnv_date_display_range($variables) {
$timezone = $variables['timezone'];
$attributes_start = $variables['attributes_start'];
@reubenmoes
reubenmoes / gist:be52204bac6bceb6ca97
Last active August 29, 2015 14:19
Open JS thing with click/esc key close listeners
/*
* Close the thing and bind close listeners
*/
function closeThing(){
//Do some stuff
//Unbind close listeners
$(document).off('keyup.closeThing').off('click.closeThing');
}
@reubenmoes
reubenmoes / socialShare.js
Created May 1, 2015 17:14
socialShare.js
vec.socialShare = {
selector: '.js-share_link',
init: function() {
$(vec.socialShare.selector).click(function(event){
event.preventDefault();
@reubenmoes
reubenmoes / gallery.js
Created May 14, 2015 04:11
Load Fresco.js async and bind gallery of thumbnails
@reubenmoes
reubenmoes / drupal.metatags_preprocess_html.php
Created May 21, 2015 01:46
Drupal add graph metatags with preprocess_html
/**
* Implements hook_preprocess_html()
*
* Adds open graph tags
*
* @param array $variables
*/
function module_preprocess_html(&$variables) {
/*