Skip to content

Instantly share code, notes, and snippets.

View telesma's full-sized avatar

Frank Rossi telesma

View GitHub Profile
@bradoyler
bradoyler / inview.js
Created April 2, 2015 02:38
inview jquery plugin
// based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/
(function ($) {
var inviewObjects = {}, viewportSize, viewportOffset,
d = document, w = window, documentElement = d.documentElement, expando = $.expando, timer;
$.event.special.inview = {
add: function(data) {
inviewObjects[data.guid + "-" + this[expando]] = { data: data, $element: $(this) };
@aaronfischer
aaronfischer / browserUpdate.html
Last active August 29, 2015 14:12
browser update modal
<div id="browserUpdate" class="browserUpdate overlay">
<a href="#" class="overlay-close js-close"><i class="icn-x icon-box -rev"></i></a>
<div class="view view-directory swiper-container browserUpdate-container">
<div class="swiper-slide">
<div class="row cf">
<div class="col-18 ac ci browserUpdate-info">
<img class="browserUpdate-warning-icon" src="/sites/all/themes/adu/assets/media/img/optimized/browserUpdate/warning.png" alt="warning icon">
<h4>Did you know your browser is out of date?</h4>
<p>To get the best possible experience using our website we recommend that you upgrade to a newer version or other web broswer. A list of the most popular web browsers can be found below. </p>
<p><strong>By closing this window you acknowledge that your experience on this website may be degraded.</strong></p>
@hartzis
hartzis / gist:83b51a916fcd10f1908d
Created October 25, 2014 19:55
iframe download file angular without jquery
.directive('fileDownload', function ($compile) {
var fd = {
restrict: 'A',
link: function (scope, iElement, iAttrs) {
scope.$on("downloadFile", function (e, url) {
// console.log('dl url-', url);
var iFrame = iElement.find("iframe");
if (!(iFrame && iFrame.length > 0)) {
iFrame = angular.element("<iframe style='position:fixed;display:none;top:-1px;left:-1px;'/>");
iElement.append(iFrame);
@amcdnl
amcdnl / diffList.js
Last active August 29, 2015 14:06 — forked from katowulf/diffList.js
define(['angular'], function(angular) {
// add a few helpers
Array.prototype.union = function(a){
var r = this.slice(0);
a.forEach(function(i) { if (r.indexOf(i) < 0) r.push(i); });
return r;
};
Array.prototype.diff = function(a){
@mildlygeeky
mildlygeeky / gist:14b814ec8c815a1f5c6f
Last active January 3, 2019 11:43
Dynamic Navigation using native Craft CMS and Twig templates
{# For this, I wanted the nav to show the top-level node and second-level nodes #}
{# when on level 1, and then show the second-level and its children when on #}
{# level 2 or level 3 (so we get good parent, child, and sibling navigation. #}
{# Requires string 'sectionName' to be passed with Structure section name #}
{% if entry.showLeftNavigation %}
<nav class="interior-page__nav">
/* =============================================================================
Media queries for different screen sizes
========================================================================== */
// xs only
.screen-xs(@rules) {
@media (max-width: @screen-xs-max) { @rules(); }
}
// sm and larger
@stinoga
stinoga / index.js
Created December 23, 2013 18:05
Replacing query string parameter values.
// Update the appropriate href query string parameter
function paramReplace(name, string, value) {
// Find the param with regex
// Grab the first character in the returned string (should be ? or &)
// Replace our href string with our new value, passing on the name and delimeter
var re = new RegExp("[\\?&]" + name + "=([^&#]*)"),
delimeter = re.exec(string)[0].charAt(0),
newString = string.replace(re, delimeter + name + "=" + value);
return newString;
@berzniz
berzniz / jshipster_and_and.js
Last active May 22, 2022 23:15
Some small javascript hacks for hipsters
// Boring
if (isThisAwesome) {
alert('yes'); // it's not
}
// Awesome
isThisAwesome && alert('yes');
// Also cool for guarding your code
var aCoolFunction = undefined;
@asafge
asafge / ng-really.js
Created November 12, 2013 13:06
ng-really? An AngularJS directive that creates a confirmation dialog for an action.
/**
* A generic confirmation for risky actions.
* Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function
*/
angular.module('app').directive('ngReallyClick', [function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('click', function() {
var message = attrs.ngReallyMessage;
@oslego
oslego / css-feature-detect.js
Last active December 23, 2015 11:29
Feather-weight CSS feature detect script that adds class names to the <body> element to signal support.
(function(){
// feather-weight Modernizr-like CSS feature check
['shape-inside','flow-into','shiny-new-feature'].forEach(function(property){
// check if any variant exists, prefixed or not
var isCapable = ['-webkit-','-ms-','-moz-',''].some(function(prefix){
return prefix + property in document.body.style
})
property = isCapable ? property : 'no-' + property;