diff options
Diffstat (limited to 'dev-random2/static/js')
-rw-r--r-- | dev-random2/static/js/html5shiv.js | 3 | ||||
-rw-r--r-- | dev-random2/static/js/microTags.js | 159 | ||||
-rw-r--r-- | dev-random2/static/js/microTags.min.js | 18 |
3 files changed, 180 insertions, 0 deletions
diff --git a/dev-random2/static/js/html5shiv.js b/dev-random2/static/js/html5shiv.js new file mode 100644 index 0000000..74c9564 --- /dev/null +++ b/dev-random2/static/js/html5shiv.js @@ -0,0 +1,3 @@ +/*! HTML5 Shiv pre3.5 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed + Uncompressed source: https://github.com/aFarkas/html5shiv */ +(function(a,b){function h(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function i(){var a=l.elements;return typeof a=="string"?a.split(" "):a}function j(a){var b={},c=a.createElement,f=a.createDocumentFragment,g=f();a.createElement=function(a){l.shivMethods||c(a);var f;return b[a]?f=b[a].cloneNode():e.test(a)?f=(b[a]=c(a)).cloneNode():f=c(a),f.canHaveChildren&&!d.test(a)?g.appendChild(f):f},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+i().join().replace(/\w+/g,function(a){return b[a]=c(a),g.createElement(a),'c("'+a+'")'})+");return n}")(l,g)}function k(a){var b;return a.documentShived?a:(l.shivCSS&&!f&&(b=!!h(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),g||(b=!j(a)),b&&(a.documentShived=b),a)}function p(a){var b,c=a.getElementsByTagName("*"),d=c.length,e=RegExp("^(?:"+i().join("|")+")$","i"),f=[];while(d--)b=c[d],e.test(b.nodeName)&&f.push(b.applyElement(q(b)));return f}function q(a){var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(n+":"+a.nodeName);while(d--)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function r(a){var b,c=a.split("{"),d=c.length,e=RegExp("(^|[\\s,>+~])("+i().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),f="$1"+n+"\\:$2";while(d--)b=c[d]=c[d].split("}"),b[b.length-1]=b[b.length-1].replace(e,f),c[d]=b.join("}");return c.join("{")}function s(a){var b=a.length;while(b--)a[b].removeNode()}function t(a){var b,c,d=a.namespaces,e=a.parentWindow;return!o||a.printShived?a:(typeof d[n]=="undefined"&&d.add(n),e.attachEvent("onbeforeprint",function(){var d,e,f,g=a.styleSheets,i=[],j=g.length,k=Array(j);while(j--)k[j]=g[j];while(f=k.pop())if(!f.disabled&&m.test(f.media)){for(d=f.imports,j=0,e=d.length;j<e;j++)k.push(d[j]);try{i.push(f.cssText)}catch(l){}}i=r(i.reverse().join("")),c=p(a),b=h(a,i)}),e.attachEvent("onafterprint",function(){s(c),b.removeNode(!0)}),a.printShived=!0,a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea|object|iframe)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g;(function(){var c=b.createElement("a");c.innerHTML="<xyz></xyz>",f="hidden"in c,f&&typeof injectElementWithStyles=="function"&&injectElementWithStyles("#modernizr{}",function(b){b.hidden=!0,f=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).display=="none"}),g=c.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var l={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:k};a.html5=l,k(b);var m=/^$|\b(?:all|print)\b/,n="html5shiv",o=!g&&function(){var c=b.documentElement;return typeof b.namespaces!="undefined"&&typeof b.parentWindow!="undefined"&&typeof c.applyElement!="undefined"&&typeof c.removeNode!="undefined"&&typeof a.attachEvent!="undefined"}();l.type+=" print",l.shivPrint=t,t(b)})(this,document)
\ No newline at end of file diff --git a/dev-random2/static/js/microTags.js b/dev-random2/static/js/microTags.js new file mode 100644 index 0000000..5de44e3 --- /dev/null +++ b/dev-random2/static/js/microTags.js @@ -0,0 +1,159 @@ + +(function(doc, win, v) { + + /** + * The microTags exception + * + * @class microTags.error + * @constructor + * @param message {String} an error message + * @example + * try { + * var t = new microTags(undefined); + * } + * catch(e) { + * if (e instaceOf micrTags.error) { + * console.debug("Epic fail: " + e.message); + * } + * } + */ + function error(message) { + this.message = "microTags: " + message; + } + error.prototype = Error.prototype; + + /** + * Create a new microTags instance + * + * @class microTags + * @constructor + * @param element {HTMLElement} an element containing tags + * @param options {Object} A JSON hash containing options + */ + function microTags(element, options) { + if (!(element && element.nodeName)) + throw new error("argument #1 must be an HTMLElement !"); + this._el = element; + this._children = element.children; + + this._max_size = 3; + this._min_size = 0.7; + this._max_angle = 10; + this._min_angle = -10; + + if (options != undefined) + this._set_options(options); + + this._max_count = this._get_max_count(); + + self = this; + this.eachTag(function(element, count) { + self._make_inline(element, count); + self._set_size(element, count); + self._set_tilt(element, count); + }); + } + + /** + * the microTags current version + * + * @attribute version {String} + */ + microTags.prototype.version = v; + microTags.version = v; + + + microTags.prototype._set_options = function(options) { + var max_size = options['max-size'], + min_size = options['min-size'], + max_angle = options['max-angle'], + min_angle = options['min-angle']; + + if ((max_size >= 1) && (max_size > min_size)) + this._max_size = max_size; + else + throw error("option `max-size` must be >= 1 and > min-size"); + + if ((min_size > 0) && (min_size < max_size)) + this._min_size = min_size; + else + throw error("option `min-size` must be > 0 and < max-size"); + + if (max_angle > min_angle) { + this._max_angle = max_angle; + this._min_angle = min_angle; + } + else + throw error("option `max-angle` must be > `min-angle`"); + + } + + /** + * Apply a function on each tag + * + * @param [Function] callback: the function to apply + */ + microTags.prototype.eachTag = function(callback) { + var i, child, tag, count; + for (i=0; i < this._children.length; i++) { + child = this._children[i]; + if (child.attributes != undefined) { + window._c = child; + count = parseInt(child.attributes["data-count"].value || "1"); + callback(child, count); + } + } + } + + + microTags.prototype._get_max_count = function() { + var max = 0; + this.eachTag(function(element, count) { + max = (max < count) ? count : max; + }); + return max; + } + + + microTags.prototype._make_inline = function(element, coun) { + element.style['display'] = 'inline-block'; + } + + + microTags.prototype._set_size = function(element, count) { + var size, + max = this._max_size, + min = this._min_size, + max_count = this._max_count; + + size = (count * max / max_count); + size = (size >= min) ? size : min; + element.style['fontSize'] = size + 'em'; + } + + + microTags.prototype._set_tilt = function(element, count) { + var angle, + max = this._max_angle, + min = this._min_angle; + angle = min + (Math.random() * (max - min)); + element.style['transform'] = 'rotate(' + angle + 'deg)'; + element.style['MozTransform'] = 'rotate(' + angle + 'deg)'; + element.style['OTransform'] = 'rotate(' + angle + 'deg)'; + element.style['WebkitTransform'] = 'rotate(' + angle + 'deg)'; + element.style['msTransform'] = 'rotate(' + angle + 'deg)'; + } + + + if (win != undefined) { + win.microTags = microTags; + win.microTags.error = error; + + if (win.define && win.define.call) { + win.define(function() { + return microTags; + }); + } + } + +})(window.document, window, "0.3.2"); diff --git a/dev-random2/static/js/microTags.min.js b/dev-random2/static/js/microTags.min.js new file mode 100644 index 0000000..30015de --- /dev/null +++ b/dev-random2/static/js/microTags.min.js @@ -0,0 +1,18 @@ + +(function(doc,win,v){function error(message){this.message="microTags: "+message;} +error.prototype=Error.prototype;function microTags(element,options){if(!(element&&element.nodeName)) +throw new error("argument #1 must be an HTMLElement !");this._el=element;this._children=element.children;this._max_size=3;this._min_size=0.7;this._max_angle=10;this._min_angle=-10;if(options!=undefined) +this._set_options(options);this._max_count=this._get_max_count();self=this;this.eachTag(function(element,count){self._make_inline(element,count);self._set_size(element,count);self._set_tilt(element,count);});} +microTags.prototype.version=v;microTags.version=v;microTags.prototype._set_options=function(options){var max_size=options['max-size'],min_size=options['min-size'],max_angle=options['max-angle'],min_angle=options['min-angle'];if((max_size>=1)&&(max_size>min_size)) +this._max_size=max_size;else +throw error("option `max-size` must be >= 1 and > min-size");if((min_size>0)&&(min_size<max_size)) +this._min_size=min_size;else +throw error("option `min-size` must be > 0 and < max-size");if(max_angle>min_angle){this._max_angle=max_angle;this._min_angle=min_angle;} +else +throw error("option `max-angle` must be > `min-angle`");} +microTags.prototype.eachTag=function(callback){var i,child,tag,count;for(i=0;i<this._children.length;i++){child=this._children[i];if(child.attributes!=undefined){window._c=child;count=parseInt(child.attributes["data-count"].value||"1");callback(child,count);}}} +microTags.prototype._get_max_count=function(){var max=0;this.eachTag(function(element,count){max=(max<count)?count:max;});return max;} +microTags.prototype._make_inline=function(element,coun){element.style['display']='inline-block';} +microTags.prototype._set_size=function(element,count){var size,max=this._max_size,min=this._min_size,max_count=this._max_count;size=(count*max/max_count);size=(size>=min)?size:min;element.style['fontSize']=size+'em';} +microTags.prototype._set_tilt=function(element,count){var angle,max=this._max_angle,min=this._min_angle;angle=min+(Math.random()*(max-min));element.style['transform']='rotate('+angle+'deg)';element.style['MozTransform']='rotate('+angle+'deg)';element.style['OTransform']='rotate('+angle+'deg)';element.style['WebkitTransform']='rotate('+angle+'deg)';element.style['msTransform']='rotate('+angle+'deg)';} +if(win!=undefined){win.microTags=microTags;win.microTags.error=error;if(win.define&&win.define.call){win.define(function(){return microTags;});}}})(window.document,window,"0.3.2");
\ No newline at end of file |