Skip to content

Instantly share code, notes, and snippets.

@tobiasdalhof
tobiasdalhof / ga-video.js
Created August 2, 2016 08:06 — forked from kyleridolfo/ga-video.js
HTML5 Video Tracking for Google Tag Manager
<script>
// Let's wrap everything inside a function so variables are not defined as globals
(function(){
// This is gonna our percent buckets ( 10%-90% )
var divisor = 10;
// We're going to save our players status on this object.
var videos_status = {};
// This is the funcion that is gonna handle the event sent by the player listeners
function eventHandler(e){
switch(e.type) {
<?php
/**
* Hint: I stored the rating_header.phtml under /template/rating.
* Load the template whereever you want by doing <?php echo $this->getLayout()->createBlock('core/template')->setTemplate('rating/rating_header.phtml')->toHtml(); ?> in your template file.
*/
/**
* Getting reviews collection object.
*/
@tobiasdalhof
tobiasdalhof / gulpfile.js
Last active September 24, 2016 15:16
October CMS with Gulp, Less and LiveReload
/**
* Dependencies
*/
var gulp = require('gulp');
var glob = require('glob');
var less = require('gulp-less');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var minifycss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
<script>
/*!
* @preserve
* jquery.scrolldepth.js | v0.9.1
* Copyright (c) 2016 Rob Flaherty (@robflaherty)
* Licensed under the MIT and GPL licenses.
*/
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";var n,t,o,r,i={minHeight:0,elements:[],percentage:!0,userTiming:!0,pixelDepth:!0,nonInteraction:!0,gaGlobal:!1,gtmOverride:!1},l=e(window),a=[],c=!1,u=0;e.scrollDepth=function(p){function s(e,i,l,a){r?(r({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:e,eventLabel:i,eventValue:1,eventNonInteraction:p.nonInteraction}),p.pixelDepth&&arguments.length>2&&l>u&&(u=l,r({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:"Pixel Depth",eventLabel:m(l),eventValue:1,eventNonInteraction:p.nonInteraction})),p.userTiming&&arguments.length>3&&r({event:"ScrollTiming",eventCategory:"Scroll Depth",eventAction:e,eventLabel:i,eventTiming:a})):(n&&(window[o]("send"
@tobiasdalhof
tobiasdalhof / .hyper.js
Created April 9, 2017 18:24
Config for hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
@tobiasdalhof
tobiasdalhof / bootstrap.css
Created October 5, 2017 07:20
Bootstrap 4 Utility Classes Only
/*!
* Bootstrap v4.0.0-beta (https://getbootstrap.com)
* Copyright 2011-2017 The Bootstrap Authors
* Copyright 2011-2017 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
.align-baseline {
vertical-align: baseline !important;
}
function alphabetPosition(text) {
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('')
const letters = text.replace(/\s/g, '').split('');
const numbers = [];
letters.forEach(letter => {
letter = letter.toLowerCase();
alphabet.find((value, index) => {
if (value === letter) {
import DeliveryMessageHelper from "./Helper";
export default class DeliveryMessageShopify {
static EVENT_DONE () {
return 'DeliveryMessageShopify::DONE'
}
constructor () {
this.shop = Shopify.shop
this.isProductPage = DeliveryMessageShopify.checkProductPage()
@tobiasdalhof
tobiasdalhof / Helper.js
Created May 7, 2018 08:22
Helper class
export default class DeliveryMessageHelper {
/**
* Get current URL without trailing slash.
* @returns {string}
*/
static getCurrentURL () {
return window.location.origin + window.location.pathname
}
/**
@tobiasdalhof
tobiasdalhof / optout.html
Last active May 9, 2022 17:01
Magento Fooman Google Analytics GDPR
<div>
<input type="checkbox" name="toggleGoogleAnalytics" id="toggleGoogleAnalytics">
<label for="toggleGoogleAnalytics">Allow Google Analytics to track my visit.</label>
</div>
<script>
var gaProperty = 'YOUR-ANALYTICS-PROPERTY';
var gaDisableCookieName = 'ga-disable-' + gaProperty;
var gaIsAllowed = document.cookie.indexOf(gaDisableCookieName + '=true') === -1
var gaCheckbox = document.getElementById('toggleGoogleAnalytics');