Skip to content

Instantly share code, notes, and snippets.

View doublejosh's full-sized avatar
🎰
front-ending

Josh Lind doublejosh

🎰
front-ending
View GitHub Profile
@doublejosh
doublejosh / datasources.js
Created January 4, 2017 19:41
Manage past use of datasources via param
/**
* Discover pane (web parts > 9.0).
*
* @namespace Tabia.DiscoverPane
*/
var Tabia = window.Tabia || {};
(function ($, _, Tabia, groucho, module) {
@doublejosh
doublejosh / jquery.paramClick.js
Created November 29, 2016 20:41
Late click via param
/**
* @file Click a DOM element via parameter (after the page load).
*
* Example: /techspecs?click=personal-sources#data-sources
*/
(function ($) {
/**
* @todo waitFor().
@doublejosh
doublejosh / campaign_param_parse.php
Last active October 14, 2016 19:24
Campaign param parse
<?php
/**
* Determine relevant taxonomy terms from multi-code "utm_campaign" parameter.
*
* @example _tableau_landing_pages_parse_campaigns([type]-[topic]-[segment]-[audience])
*
* @param string $param
*
* @return array
@doublejosh
doublejosh / stripCamelPrefix.js
Created September 28, 2016 00:12
Remove specific prefix word from camelCase strings
/**
* Remove prefix word from camelCase strings.
*
* @example stripCamelPrefix('myOldThing'); // oldThing
*
* @param {string} str
* @param {string} prefix
*
* @return {string}
*/
@doublejosh
doublejosh / get_bound.js
Created August 2, 2016 21:07
Get all bound events
$.each($._data(document, 'events'), function(i, e) {
console.log(i, e);
});
<?php
// Debug the PHP Drupal code in this statement with all "errors"...
if (arg(1) = 'node') {
arg(2) = $nodeID
load_node($nodeID);
echo drupal_render(node_view($nodeID,'teaser'));
}
<!-- How would you make the following link show all content when clicked? -->
<p><a href="#" id="opener">Expand All</a><p>
<ul id="stuff">
<li>
<strong>Some Content</strong>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse at leo quis lectus imperdiet consectetur.
/**
* Try properties against object and use first available value.
*
* @param {array} properties
* @param {object} obj
*
* @return {string|boolean}
*/
_.firstObj = function (properties, obj) {
var prop = _.first(_.intersection(properties, _.keys(obj)));
/**
* Reach nested data object properties via string.
*
* @param {object} obj
* @param {string} desc
*
* @return {mixed}
*/
_.strProp = function (obj, desc) {
var arr = desc.split('.');
/**
* Try properties against object and map first value with callback.
*
* @param {array} properties
* @param {object} obj
* @param {function} callback
*
* @return {string|boolean}
*/
_.mapFirst = function (properties, obj, callback) {