Skip to content

Instantly share code, notes, and snippets.

@ryanand26
ryanand26 / gist:e03d6eacab6c474a34df
Last active August 29, 2015 14:13
Karma configuration
// given relative path test/fixtures/ to karma
// Important: These paths must be exposed in karma.conf.js
var path = '';
if (typeof window.__karma__ !== 'undefined') {
path += 'base/';
}
jasmine.getFixtures().fixturesPath = path + 'test/fixtures';
jasmine.getJSONFixtures().fixturesPath = path + 'test/fixtures';
/**
@ryanand26
ryanand26 / PhantomJS-Click-Event
Created November 6, 2014 10:03
PhantomJS Click event
// Source : http://stackoverflow.com/a/17789929
// Patch since PhantomJS does not implement click() on HTMLElement. In some
// cases we need to execute the native click on an element. However, jQuery's
// $.fn.click() does not dispatch to the native function on <a> elements, so we
// can't use it in our implementations: $el[0].click() to correctly dispatch.
if (!HTMLElement.prototype.click) {
HTMLElement.prototype.click = function() {
var ev = document.createEvent('MouseEvent');
ev.initMouseEvent(
'click',
@ryanand26
ryanand26 / centerOnLatLng
Last active August 29, 2015 14:05
Center google map whilst maintaining bounds
function centerOnLatLng(center) {
var map = this.map,
bounds = map.getBounds(),
ne = bounds.getNorthEast(),
sw = bounds.getSouthWest(),
neLatDif, swLatDif,
neLonDif, swLonDif,
newBoundary = new google.maps.LatLngBounds();
//Lat
@ryanand26
ryanand26 / gist:9830443
Last active August 29, 2015 13:57
Basic Trident test
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trident Test</title>
@ryanand26
ryanand26 / jquery-validation-integrated.js
Created March 24, 2014 11:12
jQuery Validation integration
/*jslint bitwise: true, eqeqeq: true, passfail: false, nomen: false, plusplus: false, undef: true, evil: true */
/*global window, document, $, jQuery, LBI, self, Modernizr, setTimeout, define, require */
define(['validate', 'createFormError' ], function (validateInclude, createFormError) {
var validationInitialized = false,
isSelectValid = 'is-select-valid',
isSelectValidMobile = 'is-select-valid-mobile',
validationDefaults = {
errorClass: "has-error",
validClass: "is-valid-marker",
@ryanand26
ryanand26 / placeholder-shim.js
Created February 6, 2014 12:16
Shim for placeholder support (My version)
/*jslint bitwise: true, eqeqeq: true, passfail: false, nomen: false, plusplus: false, undef: true, evil: true */
/*global window, document, $, jQuery, LBI, self, Modernizr, setTimeout, define, require */
define("utils/placeholder-shim", function () {
var hasPlaceholder,
placeHolderClass = 'showing-placeholder';
function testForPlaceholder (){
var i = document.createElement('input');
return 'placeholder' in i;
}
@ryanand26
ryanand26 / Modernizr.highres
Created January 17, 2014 11:55
Device Pixel Density detection. Before using check why it's not including 'only screen and (min-resolution: ' + num + 'dppx)' or the window property.
//RM: Before using check why it's not including 'only screen and (min-resolution: ' + num + 'dppx)' or the window property..
// Device Pixel Density
// High res devices should have devicePixelRatio and a pixel density around 2, otherwise assume low res
// http://www.robertprice.co.uk/robblog/archive/2011/5/Detecting_Retina_Displays_From_JavaScript_And_CSS.shtml
// http://bradbirdsall.com/mobile-web-in-high-resolution
// http://www.w3.org/blog/CSS/2012/06/14/unprefix-webkit-device-pixel-ratio/
// by @matthewlein
http://blog.jcoglan.com/2013/11/15/why-github-is-not-your-cv/
@ryanand26
ryanand26 / SublimeLinter.sublime-setting
Created October 23, 2013 13:22
My SublimeLinter user settings file
/*
SublimeLinter user settings
*/
{
"jshint_options":
{
// To fix column positions for JSHint errors you may want to add `"indent": 1` to your
// **User** "jshint_options". This issue affects users with tabs for indentation.
// This fix was reverted due to a conflict with using the `"white": true` option.
// "indent": 1,
@ryanand26
ryanand26 / accordion-css-slide-open.scss
Last active October 25, 2022 08:48
CSS keyframe animation for use with display:none
@include keyframes(slideInAccordion) {
0% {
min-height: 0;
max-height: 0;
display: none;
}
1% {
min-height: 0;
max-height: 0;