Skip to content

Instantly share code, notes, and snippets.

View davidemaser's full-sized avatar

David Maser davidemaser

View GitHub Profile
@davidemaser
davidemaser / shopifyCartQueue.js
Created April 17, 2017 19:10
Using the Shopify queue to add items to the cart
Shopify.queue = [];
Shopify.moveAlong = function() {
if (Shopify.queue.length) {
var request = Shopify.queue.shift();
Shopify.addItem(request.variantId, request.quantity, request.properties, Shopify.moveAlong);
}
else {
document.location.href = '/cart';
}
};
@davidemaser
davidemaser / generator.js
Created December 6, 2016 22:23
DOM element generator in vanilla JavaScript. Builds dom elements from JSON formatted parameters.
/**
* Created by David Maser
*/
var generator = {
dom : document,
accept : ['button','div','section','ul','li','nav','form','radio','checkbox','footer','header'],
build:function(obj){
function testParentType(s){
if(s.indexOf('.')>-1){
return 'c'; // c for class
@davidemaser
davidemaser / generator_JQ.js
Last active November 30, 2019 11:32
DOM element generator using JQUERY. Builds dom elements from JSON formatted parameters.
/**
* Created by David Maser.
*/
var generator = {
accept : ['button','div','section','ul','li','nav','form','radio','checkbox','footer','header'],
build:function(obj){
if(typeof obj == 'object') {
var _core = obj.core;
for (var i in _core) {
var _valid = $.inArray(_core[i].type,generator.accept);
@davidemaser
davidemaser / ipad.js
Last active July 29, 2016 20:23
iPad Viewport fix
jQuery(window).bind('orientationchange', function() {
/* a */
var client = {
/*
Let's put all the client values in an object
to keep the code as readable as possible.
DOM manipulations by jQuery can cause errors
in values read from the browser. If we receive
inconsistent values for the client.width or
client.height objects, use vanilla javascript
@davidemaser
davidemaser / barebones_jq.html
Last active February 1, 2016 17:04
Just the most incredibly simple barebones html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
@davidemaser
davidemaser / organizr.json
Last active January 20, 2016 15:27
orGanizr JSON Structure
{"element":[
{
"tag":"section",
"id":"main",
"class":"",
"count":1,
"parent":"",
"parentMap":"",
"parentChild":0
},
@davidemaser
davidemaser / organizr.html
Last active January 20, 2016 15:27
orGanizr plugin initiator
<script>
$(document).ready(function(){
$(this).organizr({
jsonData:'assets/ajax/bones.json',
jsFiles: false,
dataAsync:true
});
});
</script>
@davidemaser
davidemaser / organizr.js
Last active August 29, 2015 14:25
Organizr is an advanced jQuery plugin that can build and populate an html page with data pulled from a single json file. Organizr can also import into your page other javascript libraries and css files allowing you to build a complex html page just by specifying it's structure and content in a json file.
/**
* Created by david-maser on 31/12/14.
*/
(function( $ ) {
$.fn.organizr = function (options) {
var defaults = {
parent: 'body',
margin: 0,
padding: 0,
dataType: 'json',
@davidemaser
davidemaser / parallax.json
Last active January 20, 2016 15:28
Parallax plugin JSON structure
{"image":[
{
"src":"assets/images/arcterys.png",
"width":2000,
"height":1125,
"id":"home",
"type":"background",
"tag":"article",
"text":"This is the home section",
"textSize":30,
@davidemaser
davidemaser / parallax.html
Last active January 20, 2016 15:28
parallax plugin initiator
<script>
$(document).ready(function(){
$(this).parallax();
});
</script>