Skip to content

Instantly share code, notes, and snippets.

View davestacey's full-sized avatar

DaveStacey davestacey

View GitHub Profile
@davestacey
davestacey / jquery_hover_swap_jpg
Last active August 29, 2015 13:56
Hover Swap jpg
// Homepage rollover Functions
function imageHilight ($obj) {
var imagetochange = $obj.find('img');
imagetochange.attr('src', imagetochange.attr('src').replace(/\.jpg/, '-on.jpg') );
//console.log('imageHilight');
}
function imageUnHilight ($obj) {
var imagetochange = $obj.find('img');
imagetochange.attr('src', imagetochange.attr('src').replace(/\-on.jpg/, '.jpg') );
(function($){
$.fn.beaBaseFunctions = function() {
var ns = ns || {}; // set nameSpace
/*******************************************
Set your namespaced functions as non global variables,
keep the global scope clear to reduce naming clashes and keep memory usage down
*******************************************/
// Init Functions
@davestacey
davestacey / clearfix_scss
Last active August 29, 2015 14:02
Clearfix mixin
@mixin clearfix {
&:after, &:before {
content: "";
display: table;
}
&:after {
clear: both;
}
& {
*zoom: 1;
@davestacey
davestacey / visible_invisible.scss
Last active August 29, 2015 14:02
Scss Visible & invisible
// Hide elements visually, but keep them available for screen-readers.
//
// Used for information required for screen-reader users to understand and use
// the site where visual display is undesirable. Information provided in this
// manner should be kept concise, to avoid unnecessary burden on the user.
// "!important" is used to prevent unintentional overrides.
@mixin element-invisible {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
@davestacey
davestacey / gist:3a9adde22a4f2e4defbc
Last active August 29, 2015 14:06
Drupal Module - add js
<?php
function ds_maps_preprocess_page(&$variables) {
//dpm("ds_maps_preprocess_page");
if (isset($variables['node']) && $variables['node']->type == 'map_geojson') {
//dpm("map_geojson");
// Add js
drupal_add_js(drupal_get_path('module', 'ds_maps') . '/ds_maps.js');
$variables['scripts'] = drupal_get_js();
}
}
(function($){
$.fn.mapBaseFunctions = function() {
var ns = ns || {}; // set nameSpace
/*******************************************
Set your namespaced functions as non global variables,
keep the global scope clear to reduce naming clashes and keep memory usage down
*******************************************/
// Init Functions
ns.mapInit = function() {
@davestacey
davestacey / gist:2a510acfab3a02f89559
Last active August 29, 2015 14:06
Leaflet via Drupal custom module - maps.js
(function($){
Drupal.behaviors.maps = {
attach:function (context, settings) {
// Add legends to each leaflet map instance in Drupal's settings array
$(settings.leaflet).each(function() {
// Get the map object from the current iteration
var map = this.lMap;
console.log('this.lMap', map);
// Get the geojson
@davestacey
davestacey / maps.module
Last active August 29, 2015 14:06
maps.module - Custom Drupal module to control leaflet and geoJSON data
<?php
function maps_preprocess_page(&$variables) {
//dpm("es_maps_preprocess_page");
// Set full basepath for JS
global $base_path;
$my_base_path = $GLOBALS['base_url'] . $GLOBALS['base_path'] . drupal_get_path('module', 'es_maps');
//dpm('$my_base_path', $my_base_path);
@davestacey
davestacey / gist:724e4416234a95ddd5ca
Last active August 29, 2015 14:07
geoJSON sample
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
$(settings.leaflet).each(function() {
var geoJsonFile = 'http://' + window.location.hostname + '/geoJSON';
//var geoJsonFile = basePath + '/data/newjson.geojson';
console.log('geoJsonFile PATH', geoJsonFile);
// Load the overlay Data - FeatureCollection
$.getJSON(geoJsonFile, function(data) {
console.log( "getJSON success, data=", data );
weHaveJSONData(data);
})//function(data)