Skip to content

Instantly share code, notes, and snippets.

View djs070's full-sized avatar

David Smith djs070

  • Sydney, Australia
View GitHub Profile
@djs070
djs070 / backbutton.js
Created April 19, 2012 07:14
Javascript back button (only sends back if previous page within current site)
if (document.referrer.indexOf(window.location.hostname) != -1){
document.write('<div class="back-link js-only">' +
'<a href="javascript: window.history.go(-1)">Back</a>' +
'</div>'
);
}
@djs070
djs070 / gist:4029875
Created November 7, 2012 06:42
jQuery tabs script
// Define elements
var $tabContainer = $('.tab-container');
var tabContentClass = '.tab-content';
var tabHeadingClass = '.tab-heading';
// Hide all tab content
$tabContainer.find(tabContentClass).hide();
// When tab button is clicked...
$tabContainer.find(tabHeadingClass).click(function(){
@djs070
djs070 / insertAtCaret.jquery.js
Created November 7, 2012 22:42
insert_at_caret
jQuery.fn.extend({
insertAtCaret: function(myValue){
return this.each(function(i) {
if (document.selection) {
//For browsers like Internet Explorer
this.focus();
sel = document.selection.createRange();
sel.text = myValue;
this.focus();
}
@djs070
djs070 / 1.js
Created November 15, 2012 07:04 — forked from mxriverlynn/1.js
$(function(){...}) vs (function($){...})($)
(function($) {
// Backbone code in here
})(jQuery);
@djs070
djs070 / gist:4157370
Created November 27, 2012 21:53 — forked from tvandervossen/gist:1231476
Mobile Safari viewport sizes on iOS 4.3 and 5
iPad
1024 × 690 In landscape on iOS 4.3
1024 × 672 In landscape on iOS 5
768 × 946 In portrait on iOS 4.3
768 × 928 In portrait on iOS 5
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3
1024 × 644 Always showing bookmarks bar in landscape on iOS 5
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3
@djs070
djs070 / simple-jquery-modal-with-cookie
Created November 29, 2012 05:22
simple jquery modal with cookie
@djs070
djs070 / log.js
Created December 11, 2012 00:10
Paul Irish's Console.log Wrapper
// usage: log('inside coolFunc',this,arguments);
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
};
<div class="related-content">
<?php
$related_products_query = new EntityFieldQuery();
$related_products = $related_products_query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'product')
->propertyCondition('status', 1)
->fieldCondition('field_related_products', 'target_id', $node->nid)
->execute();
@djs070
djs070 / gist:4570480
Last active November 14, 2017 06:26
Install NVM & Node 0.8.17 on Fedora/CentOS
# install git
yum install git -y
# get nvm
git clone git://github.com/creationix/nvm.git ~/nvm
# activate nvm
// Media Queries in Sass 3.2
//
// These mixins make media queries a breeze with Sass.
// The media queries from mobile up until desktop all
// trigger at different points along the way
//
// And important point to remember is that and width
// over the portrait width is considered to be part of the
// landscape width. This allows us to capture widths of devices
// that might not fit the dimensions exactly. This means the break