Skip to content

Instantly share code, notes, and snippets.

View msrafi's full-sized avatar

Rafi msrafi

  • Jersey City
View GitHub Profile
@msrafi
msrafi / UDscntest.js
Created June 4, 2014 16:10
matchMedia-setting
(function(){var a=function(c){var b=this;b.obj=c;b.showData=b.obj.attr("data-showOn");if(b.showData!==undefined){b.init()}else{return}};a.prototype.init=function(){var c=this,b=store.getAll();c.showOn=c.showData.split(" ");c.expLength=c.showOn.length;c.currExp=$.map(b,function(d,f){return d});c.loop()};a.prototype.loop=function(){var d=this;d.count=0;for(var c=0;c<d.expLength;c++){for(var b=0;b<d.currExp.length;b++){if(d.showOn[c]===d.currExp[b]){d.count++;break}}if(c+1===d.expLength){d.validate()}}};a.prototype.validate=function(){var b=this;b.obj.show()};$.fn.setExperince=function(){return this.each(function(){var b=new a($(this))})}})();
(function() {
var UDexp = function(obj) {
var sf = this;
sf.obj = obj;
sf.showData = sf.obj.attr('data-showOn');
if (sf.showData !== undefined) {
sf.init();
} else {
// Fruit.js
define(['jquery'], function($) {
'use strict';
var Fruit = Object.makeSubclass();
Fruit.prototype._init = function() {
};
@msrafi
msrafi / jQuery - bindif
Created April 30, 2014 21:16
BindIFEvent Handler - Bennadel
// Wrap the plugin definition in a callback bubble so we can bind
// it to the dollar sign.
(function( $ ){
// This jQuery plugin creates proxied event handlers that
// consult with an additional conditional callback to see if
// the original event handler should be executed.
$.fn.bindIf = function(
eventType,
eventHandler,
// jQuery.support.transition
// to verify that CSS3 transition is supported (or any of its browser-specific implementations)
$.support.transition = (function(){
var thisBody = document.body || document.documentElement,
thisStyle = thisBody.style,
support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined;
return support;
})();
@msrafi
msrafi / 0_reuse_code.js
Created April 26, 2014 13:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
// jQuery.support.css3
// verifies css3 properties across browsers
// i.e. $.support.css3('transition')
$.support.css3 = function(prop) {
var
support = false,
thisBody = document.body || document.documentElement,
thisStyle = thisBody.style,
uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1),
props = [
@msrafi
msrafi / has3d.js
Created March 19, 2014 17:50 — forked from jgonera/has3d.js
function has3d(){
var el = $('<p>')[0], $iframe = $('<iframe>'), has3d, t,
transforms = {
'webkitTransform': '-webkit-transform',
'OTransform': '-o-transform',
'msTransform': '-ms-transform',
'transform': 'transform'
};
// Add it to the body to get the computed style
function has3d(){
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',
'msTransform':'-ms-transform',
'MozTransform':'-moz-transform',
'transform':'transform'
};
var sliding = false; // variable outside function scope to detect a slide is in progress
function slideTo(target, duration){ // credit to Mahieddine Abdelkader & Ludwig Wendzich for original ideas.
var to = isNaN(target) ? $(target).offset().top : target, //find scroll to position
from = $(window).scrollTop() //find starting point
dy = to-from, //calculate change in scroll position - deltaY
body = $("body"), // TODO: better to have it outside of local scope already rather than fetching it every time...
duration = isNaN(duration) ? 500 : duration;
// We're going to use translate-y to move the the page so it feels like we're at the *from* scroll position, when we're actually instantly at the *to* scroll position. */
{
"files":
{
"jquery" : "http://code.jquery.com/jquery.js",
"jquery.min" : "http://code.jquery.com/jquery.min.js",
"jquery-cookie" : "https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js",
"jquery-dotimeout" : "https://raw.github.com/cowboy/jquery-dotimeout/master/jquery.ba-dotimeout.min.js",
"jquery-extra-selectors" : "https://raw.github.com/keithclark/JQuery-Extended-Selectors/master/jquery-extra-selectors.js",
"jquery-flexslider" : "https://raw.github.com/mbmufffin/FlexSlider/master/jquery.flexslider-min.js",
"jquery-mediaelement" : "https://raw.github.com/johndyer/mediaelement/master/build/mediaelement-and-player.js",