more templates back into cli
This commit is contained in:
parent
be5fad55ca
commit
ba01a0a72b
121 changed files with 5 additions and 42 deletions
File diff suppressed because one or more lines are too long
7
middleman-cli/lib/middleman-templates/mobile/source/js/libs/respond.min.js
vendored
Executable file
7
middleman-cli/lib/middleman-templates/mobile/source/js/libs/respond.min.js
vendored
Executable file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* respond.js - A small and fast polyfill for min/max-width CSS3 Media Queries
|
||||
* Copyright 2011, Scott Jehl, scottjehl.com
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* Usage: Check out the readme file or github.com/scottjehl/respond
|
||||
*/
|
||||
(function(e,h){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=h;if(h){return}var u=e.document,r=u.documentElement,i=[],k=[],p=[],o={},g=30,f=u.getElementsByTagName("head")[0]||r,b=f.getElementsByTagName("link"),d=[],a=function(){var B=b,w=B.length;for(var z=0;z<w;z++){var y=B[z],x=y.href,A=y.media,v=y.rel&&y.rel.toLowerCase()==="stylesheet";if(!!x&&v&&!o[x]){if(!/^([a-zA-Z]+?:(\/\/)?(www\.)?)/.test(x)||x.replace(RegExp.$1,"").split("/")[0]===e.location.host){d.push({href:x,media:A})}else{o[x]=true}}}t()},t=function(){if(d.length){var v=d.shift();n(v.href,function(w){m(w,v.href,v.media);o[v.href]=true;t()})}},m=function(G,v,x){var E=G.match(/@media ([^\{]+)\{([\S\s]+?)(?=\}[\s]*\/\*\/mediaquery\*\/)/gmi),H=E&&E.length||0,v=v.substring(0,v.lastIndexOf("/")),w=function(I){return I.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+v+"$2$3")},y=!H&&x;if(v.length){v+="/"}if(y){H=1}for(var B=0;B<H;B++){var C;if(y){C=x;k.push(w(G))}else{C=E[B].match(/@media ([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;k.push(RegExp.$2&&w(RegExp.$2))}var z=C.split(","),F=z.length;for(var A=0;A<F;A++){var D=z[A];i.push({media:D.match(/(only\s+)?([a-zA-Z]+)(\sand)?/)&&RegExp.$2,rules:k.length-1,minw:D.match(/\(min\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1),maxw:D.match(/\(max\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1)})}}j()},l,q,j=function(E){var v="clientWidth",x=r[v],D=u.compatMode==="CSS1Compat"&&x||u.body[v]||x,z={},C=u.createDocumentFragment(),B=b[b.length-1],w=(new Date()).getTime();if(E&&l&&w-l<g){clearTimeout(q);q=setTimeout(j,g);return}else{l=w}for(var y in i){var F=i[y];if(!F.minw&&!F.maxw||(!F.minw||F.minw&&D>=F.minw)&&(!F.maxw||F.maxw&&D<=F.maxw)){if(!z[F.media]){z[F.media]=[]}z[F.media].push(k[F.rules])}}for(var y in p){if(p[y]&&p[y].parentNode===f){f.removeChild(p[y])}}for(var y in z){var G=u.createElement("style"),A=z[y].join("\n");G.type="text/css";G.media=y;if(G.styleSheet){G.styleSheet.cssText=A}else{G.appendChild(u.createTextNode(A))}C.appendChild(G);p.push(G)}f.insertBefore(C,B.nextSibling)},n=function(v,x){var w=c();if(!w){return}w.open("GET",v,true);w.onreadystatechange=function(){if(w.readyState!=4||w.status!=200&&w.status!=304){return}x(w.responseText)};if(w.readyState==4){return}w.send()},c=(function(){var v=false,w=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new XMLHttpRequest()}],y=w.length;while(y--){try{v=w[y]()}catch(x){continue}break}return function(){return v}})();a();respond.update=a;function s(){j(true)}if(e.addEventListener){e.addEventListener("resize",s,false)}else{if(e.attachEvent){e.attachEvent("onresize",s)}}})(this,(function(f){if(f.matchMedia){return true}var e,i=document,c=i.documentElement,g=c.firstElementChild||c.firstChild,h=!i.body,d=i.body||i.createElement("body"),b=i.createElement("div"),a="only all";b.id="mq-test-1";b.style.cssText="position:absolute;top:-99em";d.appendChild(b);b.innerHTML='_<style media="'+a+'"> #mq-test-1 { width: 9px; }</style>';if(h){c.insertBefore(d,g)}b.removeChild(b.firstChild);e=b.offsetWidth==9;if(h){c.removeChild(d)}else{d.removeChild(b)}return e})(this));
|
171
middleman-cli/lib/middleman-templates/mobile/source/js/mylibs/helper.js
Executable file
171
middleman-cli/lib/middleman-templates/mobile/source/js/mylibs/helper.js
Executable file
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* MBP - Mobile boilerplate helper functions
|
||||
*/
|
||||
(function(document){
|
||||
|
||||
window.MBP = window.MBP || {};
|
||||
|
||||
// Fix for iPhone viewport scale bug
|
||||
// http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
|
||||
|
||||
MBP.viewportmeta = document.querySelector && document.querySelector('meta[name="viewport"]');
|
||||
MBP.ua = navigator.userAgent;
|
||||
|
||||
MBP.scaleFix = function () {
|
||||
if (MBP.viewportmeta && /iPhone|iPad/.test(MBP.ua) && !/Opera Mini/.test(MBP.ua)) {
|
||||
MBP.viewportmeta.content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
|
||||
document.addEventListener("gesturestart", MBP.gestureStart, false);
|
||||
}
|
||||
};
|
||||
MBP.gestureStart = function () {
|
||||
MBP.viewportmeta.content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
|
||||
};
|
||||
|
||||
|
||||
// Hide URL Bar for iOS and Android by Scott Jehl
|
||||
// https://gist.github.com/1183357
|
||||
|
||||
MBP.hideUrlBar = function () {
|
||||
var win = window,
|
||||
doc = win.document;
|
||||
|
||||
// If there's a hash, or addEventListener is undefined, stop here
|
||||
if( !location.hash || !win.addEventListener ){
|
||||
|
||||
//scroll to 1
|
||||
window.scrollTo( 0, 1 );
|
||||
var scrollTop = 1,
|
||||
|
||||
//reset to 0 on bodyready, if needed
|
||||
bodycheck = setInterval(function(){
|
||||
if( doc.body ){
|
||||
clearInterval( bodycheck );
|
||||
scrollTop = "scrollTop" in doc.body ? doc.body.scrollTop : 1;
|
||||
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
|
||||
}
|
||||
}, 15 );
|
||||
|
||||
win.addEventListener( "load", function(){
|
||||
setTimeout(function(){
|
||||
//reset to hide addr bar at onload
|
||||
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
|
||||
}, 0);
|
||||
}, false );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Fast Buttons - read wiki below before using
|
||||
// https://github.com/shichuan/mobile-html5-boilerplate/wiki/JavaScript-Helper
|
||||
|
||||
MBP.fastButton = function (element, handler) {
|
||||
this.element = element;
|
||||
this.handler = handler;
|
||||
if (element.addEventListener) {
|
||||
element.addEventListener('touchstart', this, false);
|
||||
element.addEventListener('click', this, false);
|
||||
}
|
||||
};
|
||||
|
||||
MBP.fastButton.prototype.handleEvent = function(event) {
|
||||
switch (event.type) {
|
||||
case 'touchstart': this.onTouchStart(event); break;
|
||||
case 'touchmove': this.onTouchMove(event); break;
|
||||
case 'touchend': this.onClick(event); break;
|
||||
case 'click': this.onClick(event); break;
|
||||
}
|
||||
};
|
||||
|
||||
MBP.fastButton.prototype.onTouchStart = function(event) {
|
||||
event.stopPropagation();
|
||||
this.element.addEventListener('touchend', this, false);
|
||||
document.body.addEventListener('touchmove', this, false);
|
||||
this.startX = event.touches[0].clientX;
|
||||
this.startY = event.touches[0].clientY;
|
||||
this.element.style.backgroundColor = "rgba(0,0,0,.7)";
|
||||
};
|
||||
|
||||
MBP.fastButton.prototype.onTouchMove = function(event) {
|
||||
if(Math.abs(event.touches[0].clientX - this.startX) > 10 ||
|
||||
Math.abs(event.touches[0].clientY - this.startY) > 10 ) {
|
||||
this.reset();
|
||||
}
|
||||
};
|
||||
|
||||
MBP.fastButton.prototype.onClick = function(event) {
|
||||
event.stopPropagation();
|
||||
this.reset();
|
||||
this.handler(event);
|
||||
if(event.type == 'touchend') {
|
||||
MBP.preventGhostClick(this.startX, this.startY);
|
||||
}
|
||||
this.element.style.backgroundColor = "";
|
||||
};
|
||||
|
||||
MBP.fastButton.prototype.reset = function() {
|
||||
this.element.removeEventListener('touchend', this, false);
|
||||
document.body.removeEventListener('touchmove', this, false);
|
||||
this.element.style.backgroundColor = "";
|
||||
};
|
||||
|
||||
MBP.preventGhostClick = function (x, y) {
|
||||
MBP.coords.push(x, y);
|
||||
window.setTimeout(function (){
|
||||
MBP.coords.splice(0, 2);
|
||||
}, 2500);
|
||||
};
|
||||
|
||||
MBP.ghostClickHandler = function (event) {
|
||||
for(var i = 0, len = MBP.coords.length; i < len; i += 2) {
|
||||
var x = MBP.coords[i];
|
||||
var y = MBP.coords[i + 1];
|
||||
if(Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener('click', MBP.ghostClickHandler, true);
|
||||
}
|
||||
|
||||
MBP.coords = [];
|
||||
|
||||
|
||||
// iOS Startup Image
|
||||
// https://github.com/shichuan/mobile-html5-boilerplate/issues#issue/2
|
||||
|
||||
MBP.splash = function () {
|
||||
var filename = navigator.platform === 'iPad' ? 'h/' : 'l/';
|
||||
document.write('<link rel="apple-touch-startup-image" href="/img/' + filename + 'splash.png" />' );
|
||||
};
|
||||
|
||||
|
||||
// Autogrow
|
||||
// http://googlecode.blogspot.com/2009/07/gmail-for-mobile-html5-series.html
|
||||
|
||||
MBP.autogrow = function (element, lh) {
|
||||
|
||||
function handler(e){
|
||||
var newHeight = this.scrollHeight,
|
||||
currentHeight = this.clientHeight;
|
||||
if (newHeight > currentHeight) {
|
||||
this.style.height = newHeight + 3 * textLineHeight + "px";
|
||||
}
|
||||
}
|
||||
|
||||
var setLineHeight = (lh) ? lh : 12,
|
||||
textLineHeight = element.currentStyle ? element.currentStyle.lineHeight :
|
||||
getComputedStyle(element, null).lineHeight;
|
||||
|
||||
textLineHeight = (textLineHeight.indexOf("px") == -1) ? setLineHeight :
|
||||
parseInt(textLineHeight, 10);
|
||||
|
||||
element.style.overflow = "hidden";
|
||||
element.addEventListener ? element.addEventListener('keyup', handler, false) :
|
||||
element.attachEvent('onkeyup', handler);
|
||||
};
|
||||
|
||||
})(document);
|
||||
|
20
middleman-cli/lib/middleman-templates/mobile/source/js/plugins.js
Executable file
20
middleman-cli/lib/middleman-templates/mobile/source/js/plugins.js
Executable file
|
@ -0,0 +1,20 @@
|
|||
|
||||
// usage: log('inside coolFunc', this, arguments);
|
||||
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
|
||||
window.log = function(){
|
||||
log.history = log.history || []; // store logs to an array for reference
|
||||
log.history.push(arguments);
|
||||
if(this.console) {
|
||||
arguments.callee = arguments.callee.caller;
|
||||
var newarr = [].slice.call(arguments);
|
||||
(typeof console.log === 'object' ? log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr));
|
||||
}
|
||||
};
|
||||
|
||||
// make it safe to use console.log always
|
||||
(function(b){function c(){}for(var d="assert,clear,count,debug,dir,dirxml,error,exception,firebug,group,groupCollapsed,groupEnd,info,log,memoryProfile,memoryProfileEnd,profile,profileEnd,table,time,timeEnd,timeStamp,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
|
||||
{console.log();return window.console;}catch(err){return window.console={};}})());
|
||||
|
||||
|
||||
// place any jQuery/helper plugins in here, instead of separate, slower script files.
|
||||
|
0
middleman-cli/lib/middleman-templates/mobile/source/js/script.js
Executable file
0
middleman-cli/lib/middleman-templates/mobile/source/js/script.js
Executable file
Loading…
Add table
Add a link
Reference in a new issue