Skip to content

Instantly share code, notes, and snippets.

View ChezFre's full-sized avatar

Chez Fre ChezFre

View GitHub Profile
@ChezFre
ChezFre / email.html
Created September 27, 2013 19:13
HTML Mail Template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Your Message Subject or Title</title>
<style type="text/css">
/* Client-specific Styles */
@ChezFre
ChezFre / orientation.js
Created February 13, 2014 19:27
iOS orientation bug fix
/*! A fix for the iOS orientationchange zoom bug. Script by @scottjehl, rebound by @wilto.MIT / GPLv2 License.*/(function(a){function m(){d.setAttribute("content",g),h=!0}function n(){d.setAttribute("content",f),h=!1}function o(b){l=b.accelerationIncludingGravity,i=Math.abs(l.x),j=Math.abs(l.y),k=Math.abs(l.z),(!a.orientation||a.orientation===180)&&(i>7||(k>6&&j<8||k<8&&j>6)&&i>5)?h&&n():h||m()}var b=navigator.userAgent;if(!(/iPhone|iPad|iPod/.test(navigator.platform)&&/OS [1-5]_[0-9_]* like Mac OS X/i.test(b)&&b.indexOf("AppleWebKit")>-1))return;var c=a.document;if(!c.querySelector)return;var d=c.querySelector("meta[name=viewport]"),e=d&&d.getAttribute("content"),f=e+",maximum-scale=1",g=e+",maximum-scale=10",h=!0,i,j,k,l;if(!d)return;a.addEventListener("orientationchange",m,!1),a.addEventListener("devicemotion",o,!1)})(this);
@ChezFre
ChezFre / main.js
Created February 13, 2014 19:32
Main Javascript file, wrapped in JQuery closure
var main;
(function($) {
/*
* Main
*
* @return init - public constructor
*/
main = function() {
@ChezFre
ChezFre / horizontal-slider-multiple-items.js
Created February 19, 2014 09:25
Horizontal Caroufredsel slider showing a fixed number of items (n), scrolling n number of items per slide
var $prevBtn = $('<button />', { id: 'prevShirtsBtn' });
var $nextBtn = $('<button />', { id: 'nextShirtsBtn' });
$("#element").before($prevBtn).after($nextBtn)
.carouFredSel({
width: '100%',
debug: false,
items: {
visible: '4'
},
@ChezFre
ChezFre / ajaxComplete.js
Created February 20, 2014 09:39
Fires when an Ajax request has completed, allowing you to reinitialise certain hooks on elements that may have been replaced (i.e. a selectbox that requires custom styling in exposed filters).
$(document).ajaxComplete(function(e, xhr, settings) {
// Drupal.settings.basePath == /
// Drupal.settings.pathPrefix == lang/
if (settings.url == Drupal.settings.basePath + Drupal.settings.pathPrefix + "?q=views/ajax" ||
settings.url == Drupal.settings.basePath + Drupal.settings.pathPrefix +"views/ajax" ||
settings.url == Drupal.settings.basePath + "?q=system/ajax" ||
settings.url == Drupal.settings.basePath + "system/ajax") {
@ChezFre
ChezFre / nolink.php
Created February 24, 2014 15:14
Allow adding links to your navigation that have no path. - Use the value 'nolink' as href attribute.
@ChezFre
ChezFre / index.html
Created March 18, 2014 09:12
Default HTML
<!-- HTML5 Doctype. Remember to delete these comments (Quirks Mode). -->
<!doctype html>
<!-- Modernizr HTML tags with IE classes. -->
<!--[if lt IE 7]> <html lang="" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="" class="no-js"> <!--<![endif]-->
<!-- Let's get started. -->
@ChezFre
ChezFre / template.php
Created March 21, 2014 21:20
Add placeholder to form elements in Drupal
/**
* $vars['#id''] = Form ID, can be found via Krumo
* $vars['field_name'] = Name of the input element you want to access
*/
function theme_form_alter(&$vars) {
//krumo($vars);
if( $vars['#id'] = " ") {
@ChezFre
ChezFre / template.php
Last active August 29, 2015 13:57
Make a webform submit via Ajax instead of going to a seperate page Doesn't work with Webform 4.x, only with 3.x
<?php
function hook_form_alter(&$form, &$form_state, $form_id) {
if($form_id == "webform_client_form_22") {
// get the nid so we can use it in the wrapper value
$nid = $form['#node']->nid;
// add the ajax properties to the submit button
$form['actions']['submit']['#ajax'] = array(
'callback' => 'hook_webform_js_submit', // update function
@ChezFre
ChezFre / import.bash
Last active August 29, 2015 13:59
Import MySQL Database via CLI
mysql -u username -p database < file.sql
/*******
** OF **
*******/
mysql -u username -pPASSWORD
> source file.sql;