Skip to content

Instantly share code, notes, and snippets.

View luigimannoni's full-sized avatar
🕐
Waiting for the deploy

Luigi Mannoni luigimannoni

🕐
Waiting for the deploy
View GitHub Profile
@luigimannoni
luigimannoni / countTo.directive.js
Created November 10, 2015 22:09
Angular count-to directive readapted to use Tweenmax.
var countTo = angular.module('countTo', [])
.directive('countTo', [function () {
return {
replace: false,
scope: true,
link: function (scope, element, attrs) {
var e = element[0];
var num, countToDuration, countTo, value;
var counter = { number: 0 }; // Must be an object to comply with GSAP
@luigimannoni
luigimannoni / json_search.module.php
Created November 10, 2015 22:06
JSON Search API for Drupal
<?php
/**
* implements hook_menu
*/
function json_search_menu (){
$items['json/search/%'] = array(
'page callback' => '_json_search',
'access arguments' => array('access content'),
'page arguments' => array(2),
'type' => MENU_CALLBACK,
@luigimannoni
luigimannoni / angularApp.run.js
Created November 10, 2015 22:02
CacheFactory setup and title/pageclass on rootscope.
angularApp.run(function($http, CacheFactory, $rootScope, $timeout, $window, $location, $route) {
var original = $location.path;
$location.path = function (path, reload) {
if (reload === false) {
var lastRoute = $route.current;
var un = $rootScope.$on('$locationChangeSuccess', function () {
$route.current = lastRoute;
un();
});
@luigimannoni
luigimannoni / extend.options.js
Created October 30, 2015 15:46
Javascript Extend Options
for(var key in _config)
if(_config.hasOwnProperty(key))
defaults[key] = _config[key];
@luigimannoni
luigimannoni / css3.scroller.js
Last active November 13, 2015 11:58
CSS3 Translate Scroller
function windowScrollToCSS(_config, _callback) {
var current, target, windowFinalY = 0,
defaults = {
to: 0,
scrollTime: 1.5,
easing: Power2.easeInOut,
delay: 0,
menu: true,
element: false,
force: false,
@luigimannoni
luigimannoni / gulpfile.js
Created October 29, 2015 14:34
Gulp nice error Handler
// Gulp
var gulp = require('gulp');
// Gulp plug-ins
var plumber = require('gulp-plumber'), // Error pipe streaming
util = require('gulp-util'), // Extends gulp utilities
notify = require('gulp-notify'); // Toast notifications for MacOS and Windows
// Error reporting function.
@luigimannoni
luigimannoni / raf.polyfill.js
Created October 29, 2015 14:31
RequestAnimationFrame Polyfill for IE9-
// RAF Polyfill
var lastTime = 0,
vendors = ['ms', 'moz', 'webkit', 'o'],
x,
length,
currTime,
timeToCall;
for(x = 0, length = vendors.length; x < length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
@luigimannoni
luigimannoni / smooth.scroller.js
Created October 29, 2015 14:30
Smooth scroller based on Tweenmax
var scrollTime = 0.5;
var scrollDistance = 170;
window.addEventListener('mousewheel', function(event){
event.preventDefault();
// Make header reapper if we are scrolling
if (globals.hidebars === true) {
globals.hidebars = false;
}
@luigimannoni
luigimannoni / gulpfile.js
Last active November 11, 2015 17:35
Gulp tasks
// Gulp
var gulp = require('gulp');
// Gulp plug-ins
var watch = require('gulp-watch'), // Watcher, runs tasks on file change
concat = require('gulp-concat'), // Concatenation of files
jshint = require('gulp-jshint'), // JS Linting
compass = require('gulp-compass'), // SASS compilator including Compass mixin libraries.
jade = require('gulp-jade'), // Compiles .jade files into raw HTML
minifyCSS = require('gulp-minify-css'), // Minify CSS
@luigimannoni
luigimannoni / eventsforce.safari.js
Last active October 29, 2015 13:22
Eventsforce Safari cookie redirect
// Script to sit inside the form page
var cookies = document.cookie;
var referrer = document.referrer;
var isSafari = /^((?!chrome).)*safari/i.test(navigator.userAgent);
if(isSafari && !navigator.userAgent.match('CriOS')) {
if ((cookies === '' ||
!cookies ||