Skip to content

Instantly share code, notes, and snippets.

@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@jaydson
jaydson / gist:1780598
Created February 9, 2012 15:11
How to detect a click event on a cross domain iframe
var myConfObj = {
iframeMouseOver : false
}
window.addEventListener('blur',function(){
if(myConfObj.iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="./parse_url.js"></script>
<script type="text/javascript">
var url1 = "http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content";
@O-Zone
O-Zone / transitionEnd.js
Last active November 23, 2023 22:43
Get the name of the browsers transitionEnd event. After calling this, window.transitionEnd will contain the browser specific name of the transitionEnd event. This is an extract of EvandroLG's transitionEnd snippet, without all support for testing different elements and using cache.
(function (window) {
var transitions = {
'transition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
'OTransition': 'otransitionend'
},
elem = document.createElement('div');
for(var t in transitions){
@patocallaghan
patocallaghan / example.html
Last active December 29, 2015 23:09
Mixin to do responsive sprites..Demo to follow...
<span class="logo" data-logo="examplelogo"></span>
<!-- By default the .logo element should span 100% width.
If you need it to be constrained in size use a container element with a width % value on it -->
<style>
.logo--header {
width: 25%;
}
</style>
<div class="logo--header">
@pbojinov
pbojinov / README.md
Last active June 24, 2024 05:39
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@Gaya
Gaya / responsive-svg-sprite-template.scss
Last active September 15, 2017 14:19
Responsive SVG Sprite Mixin
/*
* Generate a SVG-sprite mixin for Sass
* ====================================
*
* Gaya Kessler - http://gaya.ninja - http://twitter.com/GayaNinja
*
* SVGSprite is a wonderful package, but doesn't enable responsive sprites out of the box.
* This moustache template generates a sass file with a mixin for the generated SVG-sprite.
* Calculates the position and size of the background by filename.
* Included SVG image scales to width and height.
@agorilla
agorilla / _map-get-next.scss
Last active March 7, 2020 11:01
Sass function map-get-next
/// Function to get next map item
/// returns next map item or fallback value if map, key or next item does not exist
/// Github Repo: https://github.com/elcheio/sass-map-get-next-prev
/// Node Module: https://www.npmjs.com/package/sass-map-get-next-prev
///
/// @author Simon Koch <agorilla@me.com>
///
/// Licensed under the MIT license.
///
/// @access public
function makeIndex() {
return Math.random().toString(12).substring(2, 12);
}
function Awesome() {
Object.defineProperty(this, 'index', {
writable: false,
configurable: false,
value: makeIndex()
});
@nardan
nardan / nuke-modules.ps1
Last active March 18, 2020 07:50
Deleting Node Modules
Get-ChildItem -Path "." -Include "node_modules" -Recurse -Directory | Remove-Item -Recurse -Force