diff --git a/README b/README index df2e709..1cb86e0 100644 --- a/README +++ b/README @@ -1,39 +1,22 @@ - _____ _____ - /\ \ /\ \ - /::\ \ /::\ \ - \:::\ \ /::::\ \ - \:::\ \ /::::::\ \ - \:::\ \ /:::/\:::\ \ - \:::\ \ /:::/ \:::\ \ - /::::\ \ /:::/ \:::\ \ - /::::::\ \ /:::/ / \:::\ \ - /:::/\:::\ \ /:::/ / \:::\ \ - /:::/ \:::\____\/:::/____/ \:::\____\ - /:::/ \::/ /\:::\ \ \::/ / - /:::/ / \/____/ \:::\ \ \/____/ - /:::/ / \:::\ \ -/:::/ / \:::\ \ -\::/ / \:::\ \ - \/____/ \:::\ \ - \:::\ \ - \:::\____\ - \::/ / - \/____/ - TYPE/CODE - From 2010 till ∞ + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ -typecode-js UI Library v0.1 - -All components require jQuery and the seed file (tc.seed.js) to be loaded first. -Other dependencies are listed in individual source files. - +typecode-js UI Library v0.2 Versions 0.1 - first release version, only whole version with all files in top level directory - - -Some notes added as an example. \ No newline at end of file +0.2 - Experimenting with requirejs \ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 565a39a..2560465 100644 --- a/doc/index.html +++ b/doc/index.html @@ -60,7 +60,7 @@

Patterns Accross Components

The majority of the components in Typecode-JS are constructor functions that take one argument when they are instantiated. The convention we use is to call this argument options. It's an object that the user passes in that defines configuration parameters for the given component. It is typically merged with a set of defaults that the component defines. Sometimes certain config params are required to be passed in, and sometimes they really are optional. Internally, a given component usually has a variable named o, which is the result of merging the passed in options with the defaults.

-

A lot of the instantiable components in the library manipulate, create, and/or refer to HTML elements that are either already in or eventually get added to the DOM. For example, an NI.Overlay overlay refers to an HTML container element (such as a <div>) that holds whatever content is being displayed in a pop-up. Typically, components of this nature keep a variable named $e, which is a jQuery object representing the outermost element that the component affects. (The dollar sign in variable names is just a convention we use to signify that the variable is a jQuery object). Many of the components that have an $e element allow that element to be explicitly passed in through the options object. In some cases, you can alternatively pass in an option named selector, which is a jQuery selector that the component will use to find and define its $e variable. This pattern is currently not fully consistent throughout the library, but it's what we've generaly been moving to.

+

A lot of the instantiable components in the library manipulate, create, and/or refer to HTML elements that are either already in or eventually get added to the DOM. For example, an NI.Overlay overlay refers to an HTML container element (such as a <div>) that holds whatever content is being displayed in a pop-up. Typically, components of this nature keep a variable named $e, which is a jQuery object representing the outermost element that the component affects. (The dollar Log in variable names is just a convention we use to signify that the variable is a jQuery object). Many of the components that have an $e element allow that element to be explicitly passed in through the options object. In some cases, you can alternatively pass in an option named selector, which is a jQuery selector that the component will use to find and define its $e variable. This pattern is currently not fully consistent throughout the library, but it's what we've generaly been moving to.

We're generally good about not defining the visual styling of elements used throughout the library. Occasionally, you will see some javascript code in Typecode-JS that does explicitly set css properties on certain elements. We only do this when the elements require those properties to do what they're supposed to. These properties tend to be things like display or position and never affect the visual design of anything.

diff --git a/examples/field.html b/examples/field.html index 1f4e069..6ab6d36 100644 --- a/examples/field.html +++ b/examples/field.html @@ -43,11 +43,53 @@ - - + + + - + - - + diff --git a/examples/lib/require.js b/examples/lib/require.js new file mode 100644 index 0000000..bbce91a --- /dev/null +++ b/examples/lib/require.js @@ -0,0 +1,34 @@ +/* + RequireJS 2.1.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + Available via the MIT or new BSD license. + see: http://github.com/jrburke/requirejs for details +*/ +var requirejs,require,define; +(function(W){function D(b){return M.call(b)==="[object Function]"}function E(b){return M.call(b)==="[object Array]"}function t(b,c){if(b){var d;for(d=0;d-1;d-=1)if(b[d]&&c(b[d],d,b))break}}function A(b,c){for(var d in b)if(b.hasOwnProperty(d)&&c(b[d],d))break}function O(b,c,d,g){c&&A(c,function(c,j){if(d||!F.call(b,j))g&&typeof c!=="string"?(b[j]||(b[j]={}),O(b[j],c,d,g)):b[j]=c});return b}function r(b,c){return function(){return c.apply(b, +arguments)}}function X(b){if(!b)return b;var c=W;t(b.split("."),function(b){c=c[b]});return c}function G(b,c,d,g){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=g;if(d)c.originalError=d;return c}function ba(){if(H&&H.readyState==="interactive")return H;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return H=b});return H}var g,s,u,y,q,B,H,I,Y,Z,ca=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,da=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, +$=/\.js$/,ea=/^\.\//;s=Object.prototype;var M=s.toString,F=s.hasOwnProperty,fa=Array.prototype.splice,v=!!(typeof window!=="undefined"&&navigator&&document),aa=!v&&typeof importScripts!=="undefined",ga=v&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,R=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",w={},n={},P=[],J=!1;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(D(requirejs))return;n=requirejs;requirejs=void 0}typeof require!=="undefined"&& +!D(require)&&(n=require,require=void 0);g=requirejs=function(b,c,d,p){var i,j="_";!E(b)&&typeof b!=="string"&&(i=b,E(c)?(b=c,c=d,d=p):b=[]);if(i&&i.context)j=i.context;(p=w[j])||(p=w[j]=g.s.newContext(j));i&&p.configure(i);return p.require(b,c,d)};g.config=function(b){return g(b)};g.nextTick=typeof setTimeout!=="undefined"?function(b){setTimeout(b,4)}:function(b){b()};require||(require=g);g.version="2.1.1";g.jsExtRegExp=/^\/|:|\?|\.js$/;g.isBrowser=v;s=g.s={contexts:w,newContext:function(b){function c(a, +f,x){var e,m,b,c,d,h,i,g=f&&f.split("/");e=g;var j=k.map,l=j&&j["*"];if(a&&a.charAt(0)===".")if(f){e=k.pkgs[f]?g=[f]:g.slice(0,g.length-1);f=a=e.concat(a.split("/"));for(e=0;f[e];e+=1)if(m=f[e],m===".")f.splice(e,1),e-=1;else if(m==="..")if(e===1&&(f[2]===".."||f[0]===".."))break;else e>0&&(f.splice(e-1,2),e-=2);e=k.pkgs[f=a[0]];a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else a.indexOf("./")===0&&(a=a.substring(2));if(x&&(g||l)&&j){f=a.split("/");for(e=f.length;e>0;e-=1){b=f.slice(0,e).join("/");if(g)for(m= +g.length;m>0;m-=1)if(x=j[g.slice(0,m).join("/")])if(x=x[b]){c=x;d=e;break}if(c)break;!h&&l&&l[b]&&(h=l[b],i=e)}!c&&h&&(c=h,d=i);c&&(f.splice(0,d,c),a=f.join("/"))}return a}function d(a){v&&t(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===h.contextName)return f.parentNode.removeChild(f),!0})}function p(a){var f=k.paths[a];if(f&&E(f)&&f.length>1)return d(a),f.shift(),h.require.undef(a),h.require([a]),!0}function i(a){var f, +b=a?a.indexOf("!"):-1;b>-1&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function j(a,f,b,e){var m,K,d=null,g=f?f.name:null,j=a,l=!0,k="";a||(l=!1,a="_@r"+(M+=1));a=i(a);d=a[0];a=a[1];d&&(d=c(d,g,e),K=o[d]);a&&(d?k=K&&K.normalize?K.normalize(a,function(a){return c(a,g,e)}):c(a,g,e):(k=c(a,g,e),a=i(k),d=a[0],k=a[1],b=!0,m=h.nameToUrl(k)));b=d&&!K&&!b?"_unnormalized"+(N+=1):"";return{prefix:d,name:k,parentMap:f,unnormalized:!!b,url:m,originalName:j,isDefine:l,id:(d?d+"!"+k:k)+b}}function n(a){var f= +a.id,b=l[f];b||(b=l[f]=new h.Module(a));return b}function q(a,f,b){var e=a.id,m=l[e];if(F.call(o,e)&&(!m||m.defineEmitComplete))f==="defined"&&b(o[e]);else n(a).on(f,b)}function z(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(t(b,function(f){if(f=l[f])f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)g.onError(a)}function s(){P.length&&(fa.apply(C,[C.length-1,0].concat(P)),P=[])}function u(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,t(a.depMaps,function(e,c){var d=e.id, +g=l[d];g&&!a.depMatched[c]&&!b[d]&&(f[d]?(a.defineDep(c,o[d]),a.check()):u(g,f,b))}),b[e]=!0)}function w(){var a,f,b,e,m=(b=k.waitSeconds*1E3)&&h.startTime+b<(new Date).getTime(),c=[],g=[],i=!1,j=!0;if(!S){S=!0;A(l,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||g.push(b),!b.error))if(!b.inited&&m)p(f)?i=e=!0:(c.push(f),d(f));else if(!b.inited&&b.fetched&&a.isDefine&&(i=!0,!a.prefix))return j=!1});if(m&&c.length)return b=G("timeout","Load timeout for modules: "+c,null,c),b.contextName=h.contextName, +z(b);j&&t(g,function(a){u(a,{},{})});if((!m||e)&&i)if((v||aa)&&!T)T=setTimeout(function(){T=0;w()},50);S=!1}}function y(a){n(j(a[0],null,!0)).init(a[1],a[2])}function B(a){var a=a.currentTarget||a.srcElement,b=h.onScriptLoad;a.detachEvent&&!R?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=h.onScriptError;a.detachEvent&&!R||a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function I(){var a;for(s();C.length;)if(a=C.shift(),a[0]=== +null)return z(G("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));else y(a)}var S,U,h,L,T,k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},l={},V={},C=[],o={},Q={},M=1,N=1;L={require:function(a){return a.require?a.require:a.require=h.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=o[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return k.config&& +k.config[a.map.id]||{}},exports:o[a.map.id]}}};U=function(a){this.events=V[a.id]||{};this.map=a;this.shim=k.shim[a.id];this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};U.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=r(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}}, +defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;h.startTime=(new Date).getTime();var a=this.map;if(this.shim)h.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],r(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;Q[a]||(Q[a]=!0,h.load(this.map.id,a))},check:function(){if(this.enabled&& +!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,m=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(D(m)){if(this.events.error)try{e=h.execCb(c,m,b,e)}catch(d){a=d}else e=h.execCb(c,m,b,e);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)e=b.exports;else if(e===void 0&&this.usingExports)e=this.exports;if(a)return a.requireMap=this.map, +a.requireModules=[this.map.id],a.requireType="define",z(this.error=a)}else e=m;this.exports=e;if(this.map.isDefine&&!this.ignore&&(o[c]=e,g.onResourceLoad))g.onResourceLoad(h,this.map,this.depMaps);delete l[c];this.defined=!0}this.defining=!1;if(this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=j(a.prefix);this.depMaps.push(d);q(d,"defined",r(this,function(e){var m, +d;d=this.map.name;var x=this.map.parentMap?this.map.parentMap.name:null,i=h.makeRequire(a.parentMap,{enableBuildCallback:!0,skipMap:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,x,!0)})||""),e=j(a.prefix+"!"+d,this.map.parentMap),q(e,"defined",r(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=l[e.id]){this.depMaps.push(e);if(this.events.error)d.on("error",r(this,function(a){this.emit("error",a)}));d.enable()}}else m=r(this, +function(a){this.init([],function(){return a},null,{enabled:!0})}),m.error=r(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];A(l,function(a){a.map.id.indexOf(b+"_unnormalized")===0&&delete l[a.map.id]});z(a)}),m.fromText=r(this,function(b,e){var f=a.name,c=j(f),d=J;e&&(b=e);d&&(J=!1);n(c);try{g.exec(b)}catch(x){throw Error("fromText eval for "+f+" failed: "+x);}d&&(J=!0);this.depMaps.push(c);h.completeLoad(f);i([f],m)}),e.load(a.name,i,m,k)}));h.enable(d,this);this.pluginMaps[d.id]= +d},enable:function(){this.enabling=this.enabled=!0;t(this.depMaps,r(this,function(a,b){var c,e;if(typeof a==="string"){a=j(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=L[a.id]){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",r(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&q(a,"error",this.errback)}c=a.id;e=l[c];!L[c]&&e&&!e.enabled&&h.enable(a,this)}));A(this.pluginMaps,r(this,function(a){var b=l[a.id];b&&!b.enabled&& +h.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){t(this.events[a],function(a){a(b)});a==="error"&&delete this.events[a]}};h={config:k,contextName:b,registry:l,defined:o,urlFetched:Q,defQueue:C,Module:U,makeModuleMap:j,nextTick:g.nextTick,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e={paths:!0,config:!0,map:!0};A(a,function(a,b){e[b]? +b==="map"?O(k[b],a,!0,!0):O(k[b],a,!0):k[b]=a});if(a.shim)A(a.shim,function(a,b){E(a)&&(a={deps:a});if(a.exports&&!a.exportsFn)a.exportsFn=h.makeShimExports(a);c[b]=a}),k.shim=c;if(a.packages)t(a.packages,function(a){a=typeof a==="string"?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ea,"").replace($,"")}}),k.pkgs=b;A(l,function(a,b){if(!a.inited&&!a.map.unnormalized)a.map=j(b)});if(a.deps||a.callback)h.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b; +a.init&&(b=a.init.apply(W,arguments));return b||X(a.exports)}},makeRequire:function(a,f){function d(e,c,i){var k,p;if(f.enableBuildCallback&&c&&D(c))c.__requireJsBuild=!0;if(typeof e==="string"){if(D(c))return z(G("requireargs","Invalid require call"),i);if(a&&L[e])return L[e](l[a.id]);if(g.get)return g.get(h,e,a);k=j(e,a,!1,!0);k=k.id;return!F.call(o,k)?z(G("notloaded",'Module name "'+k+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):o[k]}I();h.nextTick(function(){I();p= +n(j(null,a));p.skipMap=f.skipMap;p.init(e,c,i,{enabled:!0});w()});return d}f=f||{};O(d,{isBrowser:v,toUrl:function(b){var d=b.lastIndexOf("."),f=null;d!==-1&&(f=b.substring(d,b.length),b=b.substring(0,d));return h.nameToUrl(c(b,a&&a.id,!0),f)},defined:function(b){b=j(b,a,!1,!0).id;return F.call(o,b)},specified:function(b){b=j(b,a,!1,!0).id;return F.call(o,b)||F.call(l,b)}});if(!a)d.undef=function(b){s();var c=j(b,a,!0),d=l[b];delete o[b];delete Q[c.url];delete V[b];if(d){if(d.events.defined)V[b]= +d.events;delete l[b]}};return d},enable:function(a){l[a.id]&&n(a).enable()},completeLoad:function(a){var b,c,d=k.shim[a]||{},g=d.exports;for(s();C.length;){c=C.shift();if(c[0]===null){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);y(c)}c=l[a];if(!b&&!o[a]&&c&&!c.inited)if(k.enforceDefine&&(!g||!X(g)))if(p(a))return;else return z(G("nodefine","No define call for "+a,null,[a]));else y([a,d.deps||[],d.exportsFn]);w()},nameToUrl:function(a,b){var c,d,i,h,j,l;if(g.jsExtRegExp.test(a))h=a+(b||"");else{c= +k.paths;d=k.pkgs;h=a.split("/");for(j=h.length;j>0;j-=1)if(l=h.slice(0,j).join("/"),i=d[l],l=c[l]){E(l)&&(l=l[0]);h.splice(0,j,l);break}else if(i){c=a===i.name?i.location+"/"+i.main:i.location;h.splice(0,j,c);break}h=h.join("/");h+=b||(/\?/.test(h)?"":".js");h=(h.charAt(0)==="/"||h.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+h}return k.urlArgs?h+((h.indexOf("?")===-1?"?":"&")+k.urlArgs):h},load:function(a,b){g.load(h,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if(a.type=== +"load"||ga.test((a.currentTarget||a.srcElement).readyState))H=null,a=B(a),h.completeLoad(a.id)},onScriptError:function(a){var b=B(a);if(!p(b.id))return z(G("scripterror","Script error",a,[b.id]))}};h.require=h.makeRequire();return h}};g({});t(["toUrl","undef","defined","specified"],function(b){g[b]=function(){var c=w._;return c.require[b].apply(c,arguments)}});if(v&&(u=s.head=document.getElementsByTagName("head")[0],y=document.getElementsByTagName("base")[0]))u=s.head=y.parentNode;g.onError=function(b){throw b; +};g.load=function(b,c,d){var g=b&&b.config||{},i;if(v)return i=g.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),i.type=g.scriptType||"text/javascript",i.charset="utf-8",i.async=!0,i.setAttribute("data-requirecontext",b.contextName),i.setAttribute("data-requiremodule",c),i.attachEvent&&!(i.attachEvent.toString&&i.attachEvent.toString().indexOf("[native code")<0)&&!R?(J=!0,i.attachEvent("onreadystatechange",b.onScriptLoad)):(i.addEventListener("load", +b.onScriptLoad,!1),i.addEventListener("error",b.onScriptError,!1)),i.src=d,I=i,y?u.insertBefore(i,y):u.appendChild(i),I=null,i;else aa&&(importScripts(d),b.completeLoad(c))};v&&N(document.getElementsByTagName("script"),function(b){if(!u)u=b.parentNode;if(q=b.getAttribute("data-main")){if(!n.baseUrl)B=q.split("/"),Y=B.pop(),Z=B.length?B.join("/")+"/":"./",n.baseUrl=Z,q=Y;q=q.replace($,"");n.deps=n.deps?n.deps.concat(q):[q];return!0}});define=function(b,c,d){var g,i;typeof b!=="string"&&(d=c,c=b,b= +null);E(c)||(d=c,c=[]);!c.length&&D(d)&&d.length&&(d.toString().replace(ca,"").replace(da,function(b,d){c.push(d)}),c=(d.length===1?["require"]:["require","exports","module"]).concat(c));if(J&&(g=I||ba()))b||(b=g.getAttribute("data-requiremodule")),i=w[g.getAttribute("data-requirecontext")];(i?i.defQueue:P).push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(n)}})(this); \ No newline at end of file diff --git a/lib/tc.animator.js b/lib/Animator.js similarity index 94% rename from lib/tc.animator.js rename to lib/Animator.js index 779c094..157ed75 100644 --- a/lib/tc.animator.js +++ b/lib/Animator.js @@ -15,9 +15,10 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; function Animator(options) { var o, internal, animations, finished_animations, running; @@ -79,7 +80,7 @@ typecode-js v 0.1 running = false; } - this.addAnimation = function(name,animation){ + this.add_animation = function(name,animation){ animation.pct = 0; animation.start_time = null; animations.push(animation); @@ -95,4 +96,4 @@ typecode-js v 0.1 NI.Animator = Animator; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/App.js b/lib/App.js new file mode 100644 index 0000000..8c34364 --- /dev/null +++ b/lib/App.js @@ -0,0 +1,108 @@ +define(['jquery', 'NIseed'], function($) { + + var window = this, + NI = window.NI, + + App = function(options) { + var self = this, o; + + o = $.extend({ + page: { + _features: [], + add_feature: function(feature) { + this._features.push(feature); + } + }, + debug: true + }, options); + + window.console = NI.fn.get_console(o.debug); + + this.page = o.page; + this.events = $({}); + this.runtime = {}; + + this.contexts = {}; + + this.invoke_feature_set(this.page._features); + this.page.add_feature = function() { + self.invoke_feature.apply(self, arguments); + }; + + }; + + App.prototype.invoke_feature = function(feature, callback) { + var self = this; + + if (!$.isFunction(callback)) { + callback = $.noop; + } + + if ($.isFunction(feature)) { + feature(self); + callback(); + } else if (typeof feature === 'string') { + require([feature], function() { + callback(); + }); + } else if (typeof feature === 'object' && feature && $.isArray(feature.require)) { + require(feature.require, function() { + var args; + if ($.isFunction(feature.callback)) { + args = [self]; + $.each(arguments, function(i, arg) { + args.push(arg); + }); + feature.callback.apply(this, args); + } + callback(); + }); + } + }; + + App.prototype.invoke_feature_set = function(feature_set, callback) { + var self = this, + n_features, + n_initialized, + feature_init_callback; + + if (!feature_set || typeof feature_set !== 'object' || !feature_set.length) { + return false; + } + + n_features = feature_set.length; + n_initialized = 0; + + feature_init_callback = function() { + n_initialized += 1; + if (n_initialized === n_features) { + self.events.trigger('app.featuresInitialized'); + if ($.isFunction(callback)) { + callback(); + } + } + }; + + $.each(feature_set, function(i, feature) { + self.invoke_feature(feature, feature_init_callback); + }); + }; + + App.prototype.new_context = function(name){ + var self = this, context_runtime; + if(self.contexts[name]){ + for(context_runtime in self.contexts[name]){ + if($.isFunction(self.contexts[name][context_runtime].destroy)){ + self.contexts[name][context_runtime].destroy(); + } + } + } + self.contexts[name] = {}; + return self.contexts[name]; + }; + + NI.App = App; + + return App; + +}); \ No newline at end of file diff --git a/lib/tc.browser_detection.js b/lib/BrowserDetection.js similarity index 53% rename from lib/tc.browser_detection.js rename to lib/BrowserDetection.js index 58aa836..f44ca1a 100644 --- a/lib/tc.browser_detection.js +++ b/lib/BrowserDetection.js @@ -11,117 +11,108 @@ \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL ```` `` JEEE. `"45EEEhw.,,,] -From 2010 till ∞ +From 2010 till infinity typecode-js v 0.1 */ -(function(window, $) { - - var NI = window.NI; - +define(['jquery', 'NIseed'], function($) { + + var window = this, + NI = window.NI; + function BrowserDetection(options) { var o, elements; - + o = $.extend({ - addClassToBody:true, - orientationListen:false, - detectWebApp:true + orientation_listen: false, + detect_touch: true, + detect_ios_version: true }, options); - + elements = { body:$('body') }; - + function init(){ var userAgent = navigator.userAgent; var appVersion = navigator.appVersion; - var browser = $.browser; - + var browser = {}; + + browser.mozilla = /mozilla/.test(userAgent.toLowerCase()) && !/webkit/.test(userAgent.toLowerCase()); + browser.webkit = /webkit/.test(userAgent.toLowerCase()); + browser.opera = /opera/.test(userAgent.toLowerCase()); + browser.msie = /msie/.test(userAgent.toLowerCase()); + // check if browser is webkit... if (browser.webkit) { - if(o.addClassToBody){ + if(o.add_class_to_body){ elements.body.addClass('browser-webkit'); - }; - + } + // check if it's chrome, safari, or an iOS browser - if (userAgent.match(/iPad/i) != null) { - if(o.addClassToBody){ - elements.body.addClass('browser-ipad os-ios'); - }; - if(o.orientationListen){ + if (userAgent.match(/iPad/i) !== null) { + elements.body.addClass('browser-ipad os-ios'); + if (window.navigator.standalone) { + elements.body.addClass('ios-webapp'); + } + if(o.orientation_listen){ listenToOrientationChange(); - }; - if(o.detectWebApp){ - if (window.navigator.standalone) { elements.body.addClass('ios-webapp') } } } else if(userAgent.match(/iPhone/i) || userAgent.match(/iPod/i)) { - if(o.addClassToBody){ - elements.body.addClass('browser-iphone os-ios'); - }; - if(o.orientationListen){ + elements.body.addClass('browser-iphone os-ios'); + if (window.navigator.standalone) { + elements.body.addClass('ios-webapp'); + } + if(o.orientation_listen){ listenToOrientationChange(); - }; - if(o.detectWebApp){ - if (window.navigator.standalone) { elements.body.addClass('ios-webapp') } } } else if(userAgent.match(/Chrome/i)) { - if(o.addClassToBody){ - elements.body.addClass('browser-chrome'); - }; + elements.body.addClass('browser-chrome'); } else if(userAgent.match(/Safari/i)) { - if(o.addClassToBody){ - elements.body.addClass('browser-safari'); - }; + elements.body.addClass('browser-safari'); } - + // ...if browser is NOT webkit, run through the other browsers } else { if (browser.msie) { - if(o.addClassToBody){ - elements.body.addClass('browser-ie'); - }; + elements.body.addClass('browser-ie'); } else if (browser.mozilla) { - if(o.addClassToBody){ - elements.body.addClass('browser-firefox'); - }; + elements.body.addClass('browser-firefox'); } else if (browser.opera) { - if(o.addClassToBody){ - elements.body.addClass('browser-opera'); - }; + elements.body.addClass('browser-opera'); } - }; + } - - // now, detect operating systems + // detect operating systems if (appVersion.indexOf("Mac")!=-1) { - if(o.addClassToBody){ - elements.body.addClass('os-mac'); - }; + elements.body.addClass('os-mac'); } else if (appVersion.indexOf("Win")!=-1) { - if(o.addClassToBody){ - elements.body.addClass('os-win'); - }; + elements.body.addClass('os-win'); } else if (appVersion.indexOf("X11")!=-1) { - if(o.addClassToBody){ - elements.body.addClass('os-unix'); - }; + elements.body.addClass('os-unix'); } else if (appVersion.indexOf("Linux")!=-1) { - if(o.addClassToBody){ - elements.body.addClass('os-linux'); - }; + elements.body.addClass('os-linux'); } else { - if(o.addClassToBody){ - elements.body.addClass('os-unknown'); - }; - }; - - }; - - - + elements.body.addClass('os-unknown'); + } + + // detect touch + if (o.detect_touch) { + if (!!('ontouchstart' in window) || !!('onmsgesturechange' in window)) { + elements.body.addClass('feature-touch'); + } + } + + // detect ios version + if (o.detect_ios_version) { + detectiOSVersion(); + } + + } + + function listenToOrientationChange() { - - function orientationChanged(orientation) { + function changed(orientation) { if (orientation === 0){ elements.body.removeClass('portrait landscape').addClass('portrait'); } else if (orientation === 180){ @@ -132,20 +123,33 @@ typecode-js v 0.1 elements.body.removeClass('portrait landscape').addClass('landscape'); } } - - orientationChanged(window.orientation); - + + changed(window.orientation); + window.onorientationchange = function(){ var orientation = window.orientation; - orientationChanged(orientation) + changed(orientation); }; } - + + function detectiOSVersion() { + var av, version; + if (/iP(hone|od|ad)/.test(navigator.platform)) { + av = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); + version = [parseInt(av[1], 10), parseInt(av[2], 10), parseInt(av[3] || 0, 10)]; + if (version[0] <= 5) { + elements.body.addClass('os-ios-lte5'); + } else { + elements.body.addClass('os-ios-gt5'); + } + } + } + init(); } -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - NI.BrowserDetection = BrowserDetection; - -}(this, this.jQuery)); \ No newline at end of file + + return BrowserDetection; + +}); \ No newline at end of file diff --git a/lib/Carousel.js b/lib/Carousel.js new file mode 100644 index 0000000..4289b72 --- /dev/null +++ b/lib/Carousel.js @@ -0,0 +1,524 @@ +/* ============================================================================ + + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ +typecode-js v 0.1 +*/ + +// this carousel implementation is based on the jQuery Tools "scrollable" implementation: +// https://github.com/jquerytools/jquerytools/blob/master/src/scrollable/scrollable.js + +define(['jquery', 'NIseed'], function($) { + + var window = this, + NI = window.NI, + generate, + focussed; + + generate = { + carousel: function() { + return $(''); + }, + prev_btn: function(instance) { + var $btn; + $btn = $('Previous'); + if (instance) { + $btn.on('click.carousel', function(e) { + e.preventDefault(); + instance.prev(); + }); + } + return $btn; + }, + next_btn: function(instance) { + var $btn; + $btn = $('Next'); + if (instance) { + $btn.on('click.carousel', function(e) { + e.preventDefault(); + instance.next(); + }); + } + return $btn; + } + }; + + function Carousel(options) { + var me, o, $e, selectors, $elements, handlers, touch_info; + + me = this; + + o = $.extend({ + $e: null, + viewport_dimensions: null, // { width: null, height: null }, + viewport_class: 'viewport', + scroll_class: 'scroll', + panels: [], + panel_class: 'panel', + active_class: 'state-active', + disabled_class: 'state-disabled', + clone_class: 'clone', + speed: 400, + easing: 'swing', + vertical: false, + circular: true, + elastic: false, + elastic_delay: 100, + keyboard: true, + touch: true, + on_before_move: function(instance, info) {}, + on_move: function(instance, info) {} + }, options); + + function init() { + + var $viewport; + + if (o.$e) { + if (typeof o.$e === 'string') { + o.$e = $(o.$e); + } + $e = o.$e; + } else { + $e = generate.carousel(); + } + + selectors = { + panel: '.' + o.panel_class, + active: '.' + o.active_class, + clone: '.' + o.clone_class + }; + + $viewport = $e.find('.' + o.viewport_class); + + $elements = { + viewport: $viewport, + scroll: $viewport.find('.' + o.scroll_class), + current_target: null, + prev_btn: null, + next_btn: null + }; + + if (o.viewport_dimensions) { + if (o.elastic) { + o.viewport_dimensions = null; + } else { + if (typeof o.viewport_dimensions.width === 'number') { + $elements.viewport.width(o.viewport_dimensions.width); + + } + if (typeof o.viewport_dimensions.height === 'number') { + $elements.viewport.height(o.viewport_dimensions.height); + } + } + } + + if (o.keyboard) { + $(window.document).on('keydown.carousel', handlers.keydown); + } + + if (o.touch) { + touch_info = {}; + $elements.scroll[0].ontouchstart = handlers.touchstart; + $elements.scroll[0].ontouchmove = handlers.touchmove; + } + + if (o.elastic) { + elastic_panel_sync(); + $(window).on('resize', handlers.elastic_resize); + } + + if (o.panels && o.panels.length) { + $.each(o.panels, function(i, $panel) { + me.add($panel); + }); + } + + me.set_orientation(o.vertical); + me.begin(true); + } + + function current() { + return $elements.scroll.find(selectors.panel + selectors.active); + } + + function target_position($panel) { + if (o.vertical) { + if (o.viewport_dimensions && typeof o.viewport_dimensions.height === 'number') { + return {top: -($panel.index()*o.viewport_dimensions.height)}; + } + return {top: -($panel.position().top)}; + } + if (o.viewport_dimensions && typeof o.viewport_dimensions.width === 'number') { + return {left: -($panel.index()*o.viewport_dimensions.width)}; + } + return {left: -($panel.position().left)}; + } + + function move_to($panel, no_anim) { + var info, $clone_target = false; + + if (!$panel.length) { + return me; + } + + $elements.current_target = $panel; + + // Determine if the target panel is a clone. + // If it is, keep track of the real panel as $clone_target + if ($panel.hasClass(o.clone_class)) { + $clone_target = $elements.scroll.children(selectors.panel).not(selectors.clone)[$panel.hasClass('head') ? 'last' : 'first'](); + $clone_target.addClass(o.active_class).siblings().removeClass(o.active_class); + } else { + $panel.addClass(o.active_class).siblings().removeClass(o.active_class); + } + + info = me.info(); + + if ($clone_target) { + info.clone_target = $clone_target; + } else { + info.clone_target = null; + } + + if ($.isFunction(o.on_before_move)) { + if (o.on_before_move(me, info) === false) { + return me; + } + } + + $elements.scroll.stop(true, false).animate(target_position($panel), (no_anim ? 0 : o.speed), o.easing, function() { + + $elements.current_target = null; + + if ($clone_target) { + $elements.scroll.css(target_position($clone_target)); + } + + if (!o.circular) { + if ($elements.prev_btn.length) { + $elements.prev_btn[info.index === 0 ? 'addClass' : 'removeClass'](o.disabled_class); + } + if ($elements.next_btn.length) { + $elements.next_btn[info.index === info.total-1 ? 'addClass' : 'removeClass'](o.disabled_class); + } + } + + if ($.isFunction(o.on_move)) { + o.on_move(me, info); + } + + me.iteration++; + } + ); + + return me; + } + + function elastic_panel_sync($panel) { + var w, h; + w = $e.width(); + h = $e.height(); + if (!$panel) { + $panel = $elements.scroll.children(selectors.panel); + } + $panel.width(w).height(h); + } + + + function sync_current_animation() { + if ($elements.current_target) { + move_to($elements.current_target, true); + } else { + move_to(current(), true); + } + return me; + } + + function register_btn(key) { + var $btn; + $btn = generate[key](me); + + if ($elements[key]) { + $elements[key].add($btn); + } else { + $elements[key] = $btn; + } + + return $btn; + } + + handlers = { + keydown: function(e) { + if (focussed != me) { + return; + } + if (me.info().total < 2) { + return; + } + + switch (e.which) { + case NI.co.keyboard.LEFT: + e.preventDefault(); + me.prev(); + break; + case NI.co.keyboard.RIGHT: + e.preventDefault(); + me.next(); + break; + } + }, + touchstart: function(e) { + touch_info.x = e.touches[0].clientX; + touch_info.y = e.touches[0].clientY; + }, + touchmove: function(e) { + var dx, dy; + if (e.touches.length === 1 && !$elements.scroll.is(':animated')) { + e.preventDefault(); + dx = touch_info.x - e.touches[0].clientX; + dy = touch_info.y - e.touches[0].clientY; + me[o.vertical && dy > 0 || !o.vertical && dx > 0 ? 'next' : 'prev'](); + } + }, + elastic_resize: NI.fn.debounce(function(e) { + elastic_panel_sync(); + sync_current_animation(); + }, o.elastic_delay) + }; + + // return an object with a reference to the currently active panel, + // the current index, and the total number of panels + this.info = function() { + var $panels, $current, $current_clone, $next, $prev,index; + $panels_with_clones = $elements.scroll.children(selectors.panel); + $panels = $elements.scroll.children(selectors.panel).not(selectors.clone); + $panels.each(function(i, panel) { + var $p = $(panel); + if ($p.hasClass(o.active_class)) { + $prev = $p.prev(); + $next = $p.next(); + $current = $p; + index = i; + return false; + } + }); + return { + $current: $current, + $next: $next, + $prev: $prev, + index: index, + total: $panels.length, + $panels: $panels, + $panels_with_clones: $panels_with_clones + }; + }; + + // add a panel to the end of the carousel + // (chainable) + this.add = function($panel) { + $panel.addClass(o.panel_class); + //if (!o.vertical) { + // $panel.css('float', 'left'); + //} + if (o.elastic) { + elastic_panel_sync($panel); + } else if (o.viewport_dimensions) { + if (typeof o.viewport_dimensions.width === 'number') { + $panel.width(o.viewport_dimensions.width); + } + if (typeof o.viewport_dimensions.height === 'number') { + $panel.height(o.viewport_dimensions.height); + } + } + $elements.scroll.append($panel); + return this; + }; + + // remove a panel from the carousel, + // (return the removed panel) + this.remove = function($panel) { + var info, panel_index, current_index; + + if (!($.contains($elements.scroll[0], $panel[0])) || $panel.hasClass(o.clone_class)) { + return false; + } + + info = this.info(); + + if (info.total === 1) { + $elements.scroll.children(selectors.clone).remove(); + return $panel.detach(); + } + + panel_index = $panel.index(); + current_index = info.$current.index(); + + $panel.detach(); + + // if the removed panel came before the currently active panel, + // update the offset of the scroll element + if (panel_index < current_index) { + move_to(info.$current, true); + } + // if the removed panel was the currently active panel, + // activate the previous sibling panel + else if (panel_index === current_index) { + this.to_index(current_index - 1, true); + } + + return $panel; + }; + + // generate a 'previous' button bound to this instance + // return a headless jQuery element representing the button + this.register_prev_btn = function() { + return register_btn('prev_btn'); + }; + + // generate a 'next' button bound to this instance + // return a headless jQuery element representing the button + this.register_next_btn = function() { + return register_btn('next_btn'); + }; + + // return the jQuery element that represents the carousel + this.get$e = function() { + return $e; + }; + + // Tell the Carousel to check itself before it wr-wr-wrecks itself. + // If the Carousel is circular, generate its secret clone elements. + // The Carousel should be refreshed after panels have been added to or removed from it. + // add() and remove() do not automatically call refresh() (to allow for simultaneous calls + // to manipulate the Carousel in row, without consecutively refreshing). + // (chainable) + this.refresh = function() { + var $panels; + if (o.circular) { + $elements.scroll.children(selectors.clone).remove(); + $panels = $elements.scroll.children(selectors.panel); + $panels.last().clone(false).addClass(o.clone_class +' head').prependTo($elements.scroll); + $panels.first().clone(false).addClass(o.clone_class +' tail').appendTo($elements.scroll); + } + return this; + }; + + + // move to the first panel and automatically refresh + // (unless no_refresh is true) + // (chainable) + this.begin = function(no_anim, no_refresh) { + if (!no_refresh) { + this.refresh(); + } + return move_to($elements.scroll.children(selectors.panel).not(selectors.clone).first(), no_anim); + }; + + // move to the last panel + // (chainable) + this.end = function(no_anim) { + return move_to($elements.scroll.children(selectors.panel).not(selectors.clone).last(), no_anim); + }; + + // move to the panel at the specified index + // (chainable) + this.to_index = function(index, no_anim) { + $elements.scroll.children(selectors.panel).not(selectors.clone).each(function(i, panel) { + if (i === index) { + move_to($(panel), no_anim); + return false; + } + }); + return this; + }; + + // move to the next panel + // (chainable) + this.next = function(no_anim) { + return move_to(current().next(selectors.panel), no_anim); + }; + + // move to the previous panel + // (chainable) + this.prev = function(no_anim) { + return move_to(current().prev(selectors.panel), no_anim); + }; + + // set focus on this carousel + // (chainable) + this.focus = function() { + focussed = me; + return me; + }; + + // remove focus from this carousel + // (chainable) + this.blur = function() { + if (focussed == me) { + focussed = null; + } + return me; + }; + + // set the carousel to vertical or horizontal + // (chainable) + this.set_orientation = function(vertical) { + if (vertical === true) { + o.vertical = true; + $e.addClass('orientation-vertical'); + $e.removeClass('orientation-horizontal'); + } else { + o.vertical = false; + $e.removeClass('orientation-vertical'); + $e.addClass('orientation-horizontal'); + } + return me; + }; + + this.sync_current_animation = sync_current_animation; + + // destroy this instance + // (the carousel element is automatically removed from the DOM) + this.destroy = function() { + me.blur(); + if (o.elastic) { + $(window).off('resize', handlers.elastic_resize); + } + if (o.keyboard) { + $(window.document).off('keydown.carousel', handlers.keydown); + } + if ($elements.prev_btn && $elements.prev_btn.length) { + $elements.prev_btn.off('click.carousel'); + } + if ($elements.next_btn && $elements.next_btn.length) { + $elements.next_btn.off('click.carousel'); + } + $e.remove(); + }; + + this.iteration = 0; + + init(); + } + +//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + + NI.Carousel = Carousel; + NI.Carousel.Generator = generate; + +}); diff --git a/lib/tc.cookies.js b/lib/Cookies.js similarity index 90% rename from lib/tc.cookies.js rename to lib/Cookies.js index 463bf85..4eee350 100644 --- a/lib/tc.cookies.js +++ b/lib/Cookies.js @@ -15,10 +15,11 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { + + var window = this, + NI = window.NI; - var NI = window.NI; - function Cookies(options) { var o, internal_functions; @@ -55,24 +56,24 @@ typecode-js v 0.1 } return cookies; } - } + }; this.o = o; this.internal_functions = internal_functions; } Cookies.prototype = { - setCookie:function(key, value, expires){ + set_cookie:function(key, value, expires){ document.cookie = this.internal_functions.constructCookieString(key, (value ? value : ''), (expires ? expires : this.o.default_expires)); }, - getCookie:function(key){ + get_cookie:function(key){ return this.internal_functions.extractCookiesForRegex(new RegExp(this.internal_functions.handleNamespace(key))); }, - getAllCookies:function(){ + get_all_cookies:function(){ return this.internal_functions.extractCookiesForRegex(new RegExp(this.internal_functions.handleNamespace(''))); }, - deleteCookie:function(key){ - this.setCookie(key,'',(new Date(-1))); + delete_cookie:function(key){ + this.set_cookie(key,'',(new Date(-1))); } }; @@ -80,4 +81,4 @@ typecode-js v 0.1 NI.Cookies = Cookies; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/tc.favicon.js b/lib/Favicon.js similarity index 80% rename from lib/tc.favicon.js rename to lib/Favicon.js index 0c2a182..f1bdc44 100644 --- a/lib/tc.favicon.js +++ b/lib/Favicon.js @@ -15,10 +15,11 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI; - + var window = this, + NI = window.NI; + function Favicon(options) { var o; @@ -35,7 +36,7 @@ typecode-js v 0.1 } var elements = { - head:document.getElementsByTagName("head")[0] + head:document.getElementsByTagName('head')[0] }; //following is from http://softwareas.com/dynamic-favicons @@ -44,22 +45,22 @@ typecode-js v 0.1 if (arguments.length==2) { document.title = optionalDocTitle; } - this.addLink(iconURL, "icon"); - this.addLink(iconURL, "shortcut icon"); + this.addLink(iconURL, 'icon'); + this.addLink(iconURL, 'shortcut icon'); }, addLink: function(iconURL, relValue) { - var link = document.createElement("link"); - link.type = "image/x-icon"; + var link = document.createElement('link'); + link.type = 'image/x-icon'; link.rel = relValue; link.href = iconURL; this.removeLinkIfExists(relValue); elements.head.appendChild(link); }, removeLinkIfExists: function(relValue) { - var links = elements.head.getElementsByTagName("link"); + var links = elements.head.getElementsByTagName('link'); for (var i=0; i internal.last_step.step_number ) { strip.animate({ 'margin-left' : -step_width }, o.transition_speed, 'easeInOutQuad', function(){ - strip.find(internal.last_step.selector).hide(); + internal.last_step.$e.hide(); strip.css({ 'margin-left' : 0, 'width' : '' }); - strip.children('.step').css('width', ''); + $.each(internal.steps, function() { + this.$e.css('width', ''); + }); } ); } else if ( internal.current_step.step_number < internal.last_step.step_number ) { strip.css({ 'margin-left' : -step_width }); strip.animate({ 'margin-left' : 0 }, o.transition_speed, 'easeInOutQuad', function(){ - strip.find(internal.last_step.selector).hide(); + internal.last_step.$e.hide(); strip.css({ 'width' : '' }); - strip.children('.step').css('width', ''); + $.each(internal.steps, function() { + this.$e.css('width', ''); + }); } ); } } else { - o.$e.find(internal.current_step.selector).show().siblings('.step').hide(); + toggle_step_visibility(internal.current_step.name); } } else { - o.$e.find(internal.current_step.selector).show().siblings('.step').hide(); + toggle_step_visibility(internal.current_step.name); } // end transition handling @@ -359,18 +366,22 @@ typecode-js v 0.1 set_location(internal.current_step.name); } - //if(internal.current_step.fields){ - // for(i in internal.current_step.fields){ - // internal.current_step.fields[i].component.event_receiver.trigger('change'); - // } - //} - internal.current_step.n_times_shown++; } function set_location(step){ window.location.hash = (o.name ? o.name + ':' : '') + step; } + + function toggle_step_visibility(step) { + $.each(internal.steps, function() { + if (this.name == step) { + this.$e.show(); + } else { + this.$e.hide(); + } + }); + } control_handlers = { next:function(e,d){ @@ -469,4 +480,4 @@ typecode-js v 0.1 NI.Merlin = Merlin; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/Merlin2.js b/lib/Merlin2.js new file mode 100644 index 0000000..2262825 --- /dev/null +++ b/lib/Merlin2.js @@ -0,0 +1,363 @@ +/* ============================================================================ + + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ +typecode-js v 0.1 +*/ + +define(['jquery', 'NIseed'], function($) { + + var window = this, + NI = window.NI; + + NI.co.Merlin = { + PREVIOUS_STEP: 'prev', + NEXT_STEP: 'next', + CURRENT_STEP: 'current', + + DISABLED_CLASS: 'state-disabled' + }; + + var Merlin = function(options) { + + var self = this, o, internal, fn, handlers; + + o = $.extend({ + name: null, + $e: null, + selector: '', + steps: {}, + data: {}, + controls: { + prev: null, + next: null + }, + transition: null, // function(last_step, current_step) {...} + first_step: null + }, options); + + internal = { + name: 'mod.Merlin' + (o.name ? ' ' + o.name : ''), + $e: (o.$e ? o.$e : $(o.selector)), + steps: o.steps, + data: o.data, + controls: o.controls, + last_step: null, + current_step: null, + n_step_renders: 0 + }; + + fn = { + init: function() { + fn.init_controls(); + fn.init_steps(); + fn.show_first_step(); + internal.$e.addClass('merlin-init'); + }, + init_controls: function() { + $.each(internal.controls, function(k, control) { + if (!control) { + return true; + } + if (handlers[k]) { + if (typeof control === 'string') { + control = $(control, internal.$e); + internal.controls[k] = control; + } + control.on('click.Merlin', handlers[k]); + } + }); + }, + init_steps: function() { + $.each(internal.steps, function(k, step) { + step.name = k; + step.n_times_shown = 0; + step.merlin = self; + if (!step.extensions){ + step.extensions = []; + } + if (!step.$e) { + if (step.selector) { + step.$e = internal.$e.find(step.selector); + } else { + return; + } + } + step.$e.hide(); + }); + }, + show_first_step: function() { + if (o.first_step) { + this.show_step(o.first_step); + } + }, + show_step: function(name, data) { + + // Sanity + + if (typeof name !== 'string' && !$.isFunction(name)) { + return false; + } + + // Validation + + if (internal.current_step && internal.current_step.valid === false) { + return false; + } + + // Provide Default Data + if(!data){ + data = { + + }; + } + + if (internal.current_step){ + data['previous_step'] = internal.current_step.name; + } + + // Special names + + if ($.isFunction(name)) { + name = name(self); + } + + if (name === NI.co.Merlin.PREVIOUS_STEP) { + if (internal.current_step && internal.current_step.prev) { + fn.show_step(internal.current_step.prev); + } + return; + } else if (name === NI.co.Merlin.NEXT_STEP) { + if (internal.current_step && internal.current_step.next) { + fn.show_step(internal.current_step.next); + } + return; + } else if (name === NI.co.Merlin.CURRENT_STEP) { + if (internal.current_step) { + fn.show_step(internal.current_step.name); + } + return; + } + + if (!internal.steps[name]) { + return false; + } + + if (internal.current_step) { + if (name === internal.current_step.name) { + if ($.isFunction(internal.current_step.visible)) { + internal.current_step.visible.apply(internal.current_step, [self, data]); + } + for(i = 0; i < internal.current_step.extensions.length; i++){ + if($.isFunction(internal.current_step.extensions[i].visible)){ + internal.current_step.extensions[i].visible.apply(internal.current_step, [self, data]); + } + } + return true; + } + for(i = 0; i < internal.current_step.extensions.length; i++){ + if($.isFunction(internal.current_step.extensions[i].finish)){ + if(internal.current_step.extensions[i].finish.apply(internal.current_step, [self, data]) === false){ + return false; + } + } + } + if ($.isFunction(internal.current_step.finish)) { + if (internal.current_step.finish.apply(internal.current_step, [self, data]) === false) { + return false; + } + } + internal.last_step = internal.current_step; + } else { + internal.last_step = null; + } + + internal.current_step = internal.steps[name]; + + fn.transition_steps(); + + if (internal.current_step.n_times_shown === 0) { + if ($.isFunction(internal.current_step.init)) { + internal.current_step.init.apply(internal.current_step, [self, data]); + } + for(i = 0; i < internal.current_step.extensions.length; i++){ + if($.isFunction(internal.current_step.extensions[i].init)){ + internal.current_step.extensions[i].init.apply(internal.current_step, [self, data]); + } + } + } + + fn.update_controls(); + + if ($.isFunction(internal.current_step.visible)) { + internal.current_step.visible.apply(internal.current_step, [self, data]); + } + for(i = 0; i < internal.current_step.extensions.length; i++){ + if($.isFunction(internal.current_step.extensions[i].visible)){ + internal.current_step.extensions[i].visible.apply(internal.current_step, [self, data]); + } + } + internal.n_step_renders += 1; + + internal.current_step.n_times_shown += 1; + }, + prev: function() { + this.show_step(NI.co.Merlin.PREVIOUS_STEP); + }, + next: function() { + this.show_step(NI.co.Merlin.NEXT_STEP); + }, + transition_steps: function() { + var last_step = internal.last_step, + current_step = internal.current_step; + + if ($.isFunction(o.transition)) { + o.transition.apply(self, [last_step, current_step]); + } else { + Merlin.default_step_transition(last_step, current_step); + } + }, + get_current_step: function() { + return internal.current_step ? internal.current_step : false; + }, + update_controls: function() { + var current_step = internal.current_step; + if (internal.controls.prev) { + if (current_step.prev) { + internal.controls.prev.removeClass(NI.co.Merlin.DISABLED_CLASS); + } else { + internal.controls.prev.addClass(NI.co.Merlin.DISABLED_CLASS); + } + } + if (internal.controls.next) { + if (current_step.next) { + internal.controls.next.removeClass(NI.co.Merlin.DISABLED_CLASS); + } else { + internal.controls.next.addClass(NI.co.Merlin.DISABLED_CLASS); + } + } + }, + set_data: function(d) { + var data; + + if (!d || typeof d !== 'object') { + return; + } + + data = internal.data; + + $.each(d, function(k, v) { + data[k] = v; + }); + }, + get_data: function() { + var d = {}; + $.each(internal.data, function(k, v) { + d[k] = v; + }); + return d; + }, + set_val: function(k, v) { + internal.data[k] = v; + }, + get_val: function(k) { + return internal.data[k]; + }, + get_dom: function() { + return internal.$e; + }, + get_name: function() { + return o.name; + }, + get_n_step_renders: function(){ + return internal.n_step_renders; + }, + get_step: function(name){ + if(internal.steps[name]){ + return internal.steps[name]; + } + return null; + }, + destroy: function() { + $.each(internal.controls, function(k, control) { + if (handlers[k]) { + if (typeof control === 'string') { + control = $(control); + } + control.off('click.Merlin', handlers[k]); + } + }); + $.each(internal.steps, function() { + if ($.isFunction(this.destroy)) { + this.destroy.apply(this, [self]); + } + }); + } + }; + + handlers = { + prev: function(e) { + e.preventDefault(); + if ($(this).hasClass(NI.co.Merlin.DISABLED_CLASS)) { + return; + } + fn.show_step(NI.co.Merlin.PREVIOUS_STEP); + }, + next: function(e) { + e.preventDefault(); + if ($(this).hasClass(NI.co.Merlin.DISABLED_CLASS)) { + return; + } + fn.show_step(NI.co.Merlin.NEXT_STEP); + }, + refresh: function(e) { + e.preventDefault(); + fn.show_step(NI.co.Merlin.CURRENT_STEP); + } + }; + + this.show_first_step = fn.show_first_step; + this.show_step = fn.show_step; + this.prev = fn.prev; + this.next = fn.next; + this.get_current_step = fn.get_current_step; + this.set_data = fn.set_data; + this.get_data = fn.get_data; + this.set_val = fn.set_val; + this.get_val = fn.get_val; + this.get_dom = fn.get_dom; + this.get_name = fn.get_name; + this.get_step = fn.get_step; + this.get_n_step_renders = fn.get_n_step_renders; + this.destroy = fn.destroy; + + fn.init(); + console.log(internal); + }; + + Merlin.default_step_transition = function(last_step, current_step) { + if (last_step && last_step.$e) { + last_step.$e.hide(); + } + if(current_step.$e){ + current_step.$e.show(); + } + + }; + + + + NI.Merlin = Merlin; + + return Merlin; +}); \ No newline at end of file diff --git a/lib/tc.overlay.js b/lib/Overlay.js similarity index 61% rename from lib/tc.overlay.js rename to lib/Overlay.js index 56e4e13..dadd9ff 100644 --- a/lib/tc.overlay.js +++ b/lib/Overlay.js @@ -15,37 +15,41 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; function Overlay(options) { - var o, $e, $m, open, $elements; + var o, $e, $m, open, $elements, handlers, generate; o = $.extend({ - context: "body", // Selector to element where overlay will be inserted. + context: 'body', // Selector to element where overlay will be inserted. autoflush: true, // If true, the Overlay automatically flushes its content when it is closed. flavor: null, // Additional classnames for Mask and Overlay. - maskClick: true, // Hide Overlay if Mask is Clicked. - maskFadeOutSpeed: 100, // Delay for mask Fade Out Animation. + mask_click: true, // Hide Overlay if Mask is Clicked. + mask_fadeout_speed: 100, // Delay for mask Fade Out Animation. escape: true, //ESC Keypress closes Overlay. - closeBtn: false, // Appends Close Button to Overlay. - isTouchDevice: false, // if true, the Overlay adjusts its behavior - // to be appropriate for touch devices - // (primarily by not using fixed positioning) - - onOpen: function(instance) {}, // Callback after Overlay is opened. - onClose: function(instance) {} // Callback after Overlay is hidden. + close_btn: false, // Appends Close Button to Overlay. + + // if true, the Overlay adjusts its behavior + // to be appropriate for touch devices + // (primarily by not using fixed positioning) + touch: false, + + open_transition: null, + on_open: function(instance) {}, // Callback after Overlay is opened. + on_close: function(instance) {} // Callback after Overlay is hidden. }, options); - function init(me){ + function init(me) { var $pane; $e = generate.overlay().hide().appendTo(o.context); $m = generate.mask().hide(); $e.before($m); - if (typeof o.flavor === "string") { + if (typeof o.flavor === 'string') { $e.addClass(o.flavor); $m.addClass(o.flavor); } else if ($.isArray(o.flavor)) { @@ -55,25 +59,25 @@ typecode-js v 0.1 }); } - $pane = $e.find(">.tier > .tier > .pane"); + $pane = $e.find('>.tier > .tier > .pane'); $elements = { pane: $pane, - hd: $pane.children(".hd"), - bd: $pane.children(".bd"), - ft: $pane.children(".ft") + hd: $pane.children('.hd'), + bd: $pane.children('.bd'), + ft: $pane.children('.ft') }; - if (o.maskClick) { - $e.bind("click", {instance:me, $pane:$elements.pane, allowPaneClick: true}, events.clickClose); - if (o.isTouchDevice) { - $m.bind("click", {instance: me}, events.clickClose); + if (o.mask_click) { + $e.on('click', {instance:me, $pane:$elements.pane, allowPaneClick: true}, handlers.click_close); + if (o.touch) { + $m.on('click', {instance: me}, handlers.click_close); } } open = false; } - var events = { + handlers = { keydown: function(e) { var key; key = e.keyCode || e.which; @@ -88,7 +92,7 @@ typecode-js v 0.1 break; } }, - clickClose: function(e) { + click_close: function(e) { var pane; if (e.data.$pane && e.data.allowPaneClick) { pane = e.data.$pane[0]; @@ -103,8 +107,8 @@ typecode-js v 0.1 } }; - var generate = { - overlay:function(){ + generate = { + overlay: function() { var $overlay = $( '
\
\
\ @@ -118,32 +122,32 @@ typecode-js v 0.1
\
' ); - if (o.isTouchDevice) { + if (o.touch) { $overlay.css({ - position: "absolute", - overflow: "visible" + position: 'absolute', + overflow: 'visible' }); } return $overlay; }, - mask:function(){ + mask: function() { var $mask = $( '
\
' ); - if (o.isTouchDevice) { + if (o.touch) { $mask.css({ - position: "absolute" + position: 'absolute' }); } return $mask; }, - closeBtn:function(instance){ + close_btn: function(instance) { var $btn; - $btn = $( "Close" ); + $btn = $('Close'); if (instance) { - $btn.bind("click", {instance:instance}, events.clickClose); + $btn.on('click', {instance:instance}, handlers.click_close); } return $btn; } @@ -153,78 +157,78 @@ typecode-js v 0.1 $elements.hd.empty(); $elements.bd.empty(); $elements.ft.empty(); - if (o.isTouchDevice) { - $m.css({ height: "100%" }); + if (o.touch) { + $m.css({ height: '100%' }); } return this; }; - this.getOverlay = function(){ + this.get$e = function(){ return $e; }; - this.setHeader = function($hd) { + this.set_header = function($hd) { $elements.hd.empty().append($hd); return this; }; - this.getHeader = function(){ + this.get_header = function(){ return $elements.hd; }; - this.setBody = function($bd) { + this.set_body = function($bd) { $elements.bd.empty().append($bd); return this; }; - this.getBody = function(){ + this.get_body = function(){ return $elements.bd; }; - this.setFooter = function($ft) { + this.set_footer = function($ft) { $elements.ft.empty().append($ft); return this; }; - this.getFooter = function(){ + this.get_footer = function(){ return $elements.ft; }; this.open = function(options) { var _o; _o = $.extend({ - hd:null, - bd:null, - ft:null - },options); + hd: null, + bd: null, + ft: null + }, options); - if (_o.hd) { this.setHeader(_o.hd); } - if (_o.bd) { this.setBody(_o.bd); } - if (_o.ft) { this.setFooter(_o.ft); } + if (_o.hd) { this.set_header(_o.hd); } + if (_o.bd) { this.set_body(_o.bd); } + if (_o.ft) { this.set_footer(_o.ft); } - if (o.closeBtn && !($elements.hd.find(".btn-close").length)) { - $elements.hd.append(generate.closeBtn(this)); + if (o.close_btn && !($elements.hd.find('.btn-close').length)) { + $elements.hd.append(generate.close_btn(this)); } - $e.find('.btn-close').bind("click", {instance:this}, events.clickClose); + $e.find('.btn-close').on('click', {instance:this}, handlers.click_close); - if(o.openTransition && $.isFunction(o.openTransition)){ - o.openTransition($e, $m); + if (o.open_transition && $.isFunction(o.open_transition)) { + o.open_transition($e, $m); } else { $m.fadeIn(); $e.fadeIn().scrollTop(0).focus(); } - if (o.isTouchDevice) { + if (o.touch) { $m.height( $(document).height() ); } - $(window.document).bind("keydown.overlay", {instance:this, escape:o.escape, $e:$e}, events.keydown); + $(window.document).on('keydown.overlay', {instance:this, escape:o.escape, $e:$e}, handlers.keydown); open = true; - if ($.isFunction(o.onOpen)) { - o.onOpen(this); + if ($.isFunction(o.on_open)) { + o.on_open(this); } return this; }; @@ -232,21 +236,21 @@ typecode-js v 0.1 this.close = function() { if (!open) { return this; } - if(o.closeTransition && $.isFunction(o.closeTransition)){ + if (o.closeTransition && $.isFunction(o.closeTransition)) { o.closeTransition($e, $m); } else { $m.fadeOut(); $e.hide().blur(); } - $(window.document).unbind("keydown.overlay", events.keydown); + $(window.document).off('keydown.overlay', handlers.keydown); if (o.autoflush === true) { this.flush(); } open = false; - if ($.isFunction(o.onClose)) { - o.onClose(this); + if ($.isFunction(o.on_close)) { + o.on_close(this); } return this; }; @@ -263,4 +267,4 @@ typecode-js v 0.1 NI.Overlay = Overlay; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/PushstateHelper.js b/lib/PushstateHelper.js new file mode 100644 index 0000000..aa060f9 --- /dev/null +++ b/lib/PushstateHelper.js @@ -0,0 +1,171 @@ +/* ============================================================================ + + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ +typecode-js v 0.1 +*/ + +// This module uses jQuery Hashchange (http://benalman.com/projects/jquery-hashchange-plugin/) +// as a fallback to emulate pushstate behavior on browsers that don't support pushstate. +// The hashchange plugin subsequently requires jQuery Migrate (https://github.com/jquery/jquery-migrate) +// if being used with jQuery version 1.9 + + +define(['jquery'], function($) { + + var window = this, + NI = window.NI; + + function PushstateHelper(options) { + + var self = this, o, internal, fn, handlers; + + o = $.extend({ + app: null, + use_hash: false + }, options); + + internal = { + name: 'mod.PushstateHelper', + previous_path: o.use_hash ? + window.location.hash.replace('#', '') : window.location.pathname + }; + + fn = { + init: function() { + $(document).on('click', '.js-use-pushstate, .js-simulate-pushstate, .js-do-popstate', handlers.doc_click); + $(window) + .on('popstate', handlers.popstate) + .on('pushstate', handlers.pushstate) + .on('simulate-pushstate', handlers.simulate_pushstate); + + if (o.use_hash) { + require(['jquery_migrate', 'hashchange'], function() { + $(window).on('hashchange', handlers.hashchange); + fn.statechange(window.location.hash); + }); + } else { + fn.statechange(window.location.pathname); + } + }, + statechange: function(pathname, data){ + var i, path_components, position, _event_data; + + if (o.use_hash) { + pathname = pathname.replace('#', ''); + } + + path_components = PushstateHelper.get_path_components(pathname); + + _event_data = { + path: pathname, + components: path_components, + data: data ? data : {} + }; + + _event_data.data.previous_path = internal.previous_path; + + o.app.events.trigger('navigationEvent:Pushstate', _event_data); + + internal.previous_path = _event_data.path; + }, + + get_path_components: function(){ + return internal.components; + } + }; + + handlers = { + doc_click: function(e, d) { + var $t, _href, _data; + e.preventDefault(); + $t = $(this); + _href = $t.attr('HREF'); + _data = $t.data(); + if($t.hasClass('js-use-pushstate')){ + e.stopPropagation(); + e.stopImmediatePropagation(); + if(o.use_hash){ + window.location.hash = _href; + fn.statechange(window.location.hash, _data); + } else { + history.pushState(null, null, _href); + fn.statechange(window.location.pathname, _data); + } + } else if($t.hasClass('js-simulate-pushstate')) { + e.stopPropagation(); + e.stopImmediatePropagation(); + fn.statechange(_href, _data); + } else if($t.hasClass('js-do-popstate')) { + e.stopPropagation(); + e.stopImmediatePropagation(); + history.back(); + } + }, + popstate: function(e, d) { + if(o.use_hash){ + fn.statechange(window.location.hash, d); + } else { + fn.statechange(window.location.pathname, d); + } + }, + pushstate: function(e, d) { + if(o.use_hash){ + if(window.location.hash != d.pathname){ + window.location.hash = d.pathname; + } + } else { + if(window.location.pathname != d.pathname){ + history.pushState(null, null, d.pathname); + } + } + if(!d || !d.prevent_propagation){ + fn.statechange(d.pathname, d); + } + }, + simulate_pushstate: function(e, d) { + if(!d || !d.prevent_propagation){ + fn.statechange(d.pathname, d); + } + }, + hashchange: function(e, d) { + if (!d || !d.prevent_propagation) { + fn.statechange(window.location.hash); + } + } + }; + + this.get_path_components = fn.get_path_components; + + fn.init(); + console.log(internal); + } + + PushstateHelper.get_path_components = function(path){ + var components, position; + if(path){ + components = path.split('/'); + position = components.length; + while(position--){ + if(!components[position].length){ + components.splice(position,1); + } + } + return components; + } + }; + + NI.PushstateHelper = PushstateHelper; + + return PushstateHelper; + +}); \ No newline at end of file diff --git a/lib/tc.social_rotator.js b/lib/SocialRotator.js similarity index 93% rename from lib/tc.social_rotator.js rename to lib/SocialRotator.js index 5cc0e23..d6c7ea3 100644 --- a/lib/tc.social_rotator.js +++ b/lib/SocialRotator.js @@ -15,31 +15,32 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; //var SocialButtons = { // twitter:function(options){ // var o, button; // o = $.extend({ - // + // // }, options); - // + // // button = $(''); - // + // // return button; // }, // facebook:function(options){ - // + // // }, // gplus:function(options){ - // + // // } //} - + function SocialRotator(options) { var o, internal; @@ -47,7 +48,7 @@ typecode-js v 0.1 element:null, button_class:'spread-button', cycle_length:3000, - fadeSpeed:600 + fade_speed:600 }, options); NI.ex.checkJQ(o.element); @@ -72,7 +73,7 @@ typecode-js v 0.1 function cycleButtons() { internal.spread_buttons.stop(true,true).animate({ 'opacity':0.0 - },o.fadeSpeed,function(){ + },o.fade_speed,function(){ internal.spread_buttons.css({ 'zIndex':internal.element_zIndex + 1 }); @@ -81,18 +82,18 @@ typecode-js v 0.1 internal.current_button = (internal.cycle_counter % 3); internal.spread_buttons.eq(internal.current_button).stop(true, true).animate({ opacity:1.0 - },o.fadeSpeed,function(){ + },o.fade_speed,function(){ internal.spread_buttons.eq(internal.current_button).css({ 'zIndex':internal.element_zIndex + 2 }); }); internal.spread_timer = setTimeout(cycleButtons, o.cycle_length); - }; + } o.element.hover( function () { if(internal.spread_timer){ - clearTimeout(internal.spread_timer) + clearTimeout(internal.spread_timer); } }, function () { @@ -128,4 +129,4 @@ typecode-js v 0.1 NI.SocialRotator = SocialRotator; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/tc.tooltip.js b/lib/Tooltip.js similarity index 91% rename from lib/tc.tooltip.js rename to lib/Tooltip.js index ec0ed1b..554faf3 100644 --- a/lib/tc.tooltip.js +++ b/lib/Tooltip.js @@ -15,14 +15,16 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; - // remove "px" from a string representing a css pixel dimension - // and cast as a Number (i.e. trimpx("10px") returns 10) + // remove 'px' from a string representing a css pixel dimension + // and cast as a Number (i.e. trimpx('10px') returns 10) // Used to parse px dimension values from CSS properties, - // such as "width" and "height" + // such as 'width' and 'height' + //TODO probably should just be replaced with parseInt (?) function trimPX(s) { if (s) { return Number(s.substring(0, s.length - 2)); @@ -55,7 +57,7 @@ typecode-js v 0.1 }, options); internal = { - guid: NI.fn.guid("tooltip"), + guid: NI.fn.guid('tooltip'), window:$(window), tooltip:(o.tooltip ? o.tooltip.appendTo(o.container) : $('
').appendTo(o.container)), tooltip_content:null, @@ -119,7 +121,7 @@ typecode-js v 0.1 }; }, right:function(container){ - var w = container.children(".tooltip-tail").css("width"); + var w = container.children('.tooltip-tail').css('width'); return { //border: '1px solid green', width: w, @@ -139,7 +141,7 @@ typecode-js v 0.1 }; }, left:function(container){ - var w = container.children(".tooltip-tail").css("width"); + var w = container.children('.tooltip-tail').css('width'); return { //border: '1px solid blue', width: w, @@ -170,10 +172,10 @@ typecode-js v 0.1 var output; if (markup instanceof $) { output = markup; - } else if (typeof markup === "string") { + } else if (typeof markup === 'string') { output = $(markup); } else { - output = $("

No Data.

"); + output = $('

No Data.

'); } return output; } @@ -235,35 +237,35 @@ typecode-js v 0.1 // tts -- tooltip_size top:function(sp,trs,tts){ - var tail = get_tail("top"); + var tail = get_tail('top'); return { className:'top', - top:(sp.top - (tts.height) - o.tail_offset_top - (tail ? trimPX(tail.css("height")) : 0)) + o.offset_top, + top:(sp.top - (tts.height) - o.tail_offset_top - (tail ? trimPX(tail.css('height')) : 0)) + o.offset_top, left:((sp.left + (trs.width/2)) - (tts.width/2) + o.tail_offset_left) + o.offset_left }; }, bottom:function(sp,trs,tts){ - var tail = get_tail("bottom"); + var tail = get_tail('bottom'); return { className:'bottom', - top:(sp.top + trs.height + o.tail_offset_top + (tail ? trimPX(tail.css("height")) : 0) ) - o.offset_top, + top:(sp.top + trs.height + o.tail_offset_top + (tail ? trimPX(tail.css('height')) : 0) ) - o.offset_top, left:((sp.left + (trs.width/2)) - (tts.width/2) + o.tail_offset_left) + o.offset_left }; }, right:function(sp,trs,tts){ - var tail = get_tail("right"); + var tail = get_tail('right'); return { className:'right', top: (sp.top + (trs.height/2) - (tts.height/2)) + o.offset_top, - left: (sp.left + (trs.width) + o.tail_offset_top + (tail ? trimPX(tail.css("width")) : 0)) + o.offset_left + left: (sp.left + (trs.width) + o.tail_offset_top + (tail ? trimPX(tail.css('width')) : 0)) + o.offset_left }; }, left:function(sp,trs,tts){ - var tail = get_tail("left"); + var tail = get_tail('left'); return { className:'left', top: (sp.top + (trs.height/2) - (tts.height/2)) + o.offset_top, - left: (sp.left - (tts.width) - o.tail_offset_top - (tail ? trimPX(tail.css("width")) : 0)) - o.offset_left + left: (sp.left - (tts.width) - o.tail_offset_top - (tail ? trimPX(tail.css('width')) : 0)) - o.offset_left }; } }; @@ -344,11 +346,11 @@ typecode-js v 0.1 switch(target_pos.className){ case 'top': case 'bottom': - tail_animate_change.left = (internal.tooltip.width()/2) - o.tail_offset_left - (trimPX(tail.css("width"))/2); + tail_animate_change.left = (internal.tooltip.width()/2) - o.tail_offset_left - (trimPX(tail.css('width'))/2); break; case 'left': case 'right': - tail_animate_change.top = (internal.tooltip.height()/2) + o.tail_offset_top - (trimPX(tail.css("height"))/2); + tail_animate_change.top = (internal.tooltip.height()/2) + o.tail_offset_top - (trimPX(tail.css('height'))/2); break; } } else { @@ -358,11 +360,11 @@ typecode-js v 0.1 switch(target_pos.className){ case 'top': case 'bottom': - tail_css_change.left = (internal.tooltip.width()/2) - o.tail_offset_left - (trimPX(tail.css("width"))/2); + tail_css_change.left = (internal.tooltip.width()/2) - o.tail_offset_left - (trimPX(tail.css('width'))/2); break; case 'left': case 'right': - tail_css_change.top = (internal.tooltip.height()/2) + o.tail_offset_top - (trimPX(tail.css("height"))/2); + tail_css_change.top = (internal.tooltip.height()/2) + o.tail_offset_top - (trimPX(tail.css('height'))/2); break; } } @@ -385,9 +387,9 @@ typecode-js v 0.1 internal.visible = true; }); - $(window).bind("resize."+ internal.guid, handlers.window_resize); + $(window).bind('resize.'+ internal.guid, handlers.window_resize); if (o.modal_tooltip) { - $(document).bind("click."+ internal.guid, handlers.doc_click); + $(document).bind('click.'+ internal.guid, handlers.doc_click); } internal.has_been_shown = true; @@ -405,7 +407,7 @@ typecode-js v 0.1 }); $(window).unbind('resize.'+internal.guid); if (o.modal_tooltip) { - $(document).unbind("click."+ internal.guid); + $(document).unbind('click.'+ internal.guid); } } @@ -541,7 +543,7 @@ typecode-js v 0.1 } $(window).unbind('resize.'+internal.guid); if (o.modal_tooltip) { - $(document).unbind("click."+ internal.guid); + $(document).unbind('click.'+ internal.guid); } }; @@ -552,4 +554,4 @@ typecode-js v 0.1 NI.Tooltip = Tooltip; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/tc.anim_util.js b/lib/anim.js similarity index 75% rename from lib/tc.anim_util.js rename to lib/anim.js index d95899c..c6c5e5f 100644 --- a/lib/tc.anim_util.js +++ b/lib/anim.js @@ -15,22 +15,23 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI, - TWO_PI = 2*window.Math.PI; + var window = this, + NI = window.NI, + TWO_PI = 2*window.Math.PI; - var requestAnimFrame = (function() { + var request_anim_frame = (function() { var fn; - fn = window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(/* function */ callback, /* DOMElement */ element){ - window.setTimeout(callback, 1000 / 60); - }; + fn = window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function(/* function */ callback, /* DOMElement */ element){ + window.setTimeout(callback, 1000 / 60); + }; return function() { fn.apply(window, arguments); @@ -61,13 +62,13 @@ typecode-js v 0.1 theta: 0, speed: null }; - me.setSpeed(o.speed); - me[o.cycling ? "play" : "pause"](); + me.set_speed(o.speed); + me[o.cycling ? 'play' : 'pause'](); } function loop() { if (internal.cycling) { - requestAnimFrame(loop); + request_anim_frame(loop); } else { return; } @@ -96,7 +97,7 @@ typecode-js v 0.1 return this; }; - this.isCycling = function() { + this.is_cycling = function() { return internal.cycling; }; @@ -105,8 +106,8 @@ typecode-js v 0.1 return this; }; - this.setSpeed = function(speed) { - if (typeof speed === "number") { + this.set_speed = function(speed) { + if (typeof speed === 'number') { internal.speed = speed; } return this; @@ -118,7 +119,7 @@ typecode-js v 0.1 //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: NI.anim = NI.anim || {}; - NI.anim.requestAnimFrame = requestAnimFrame; + NI.anim.request_anim_frame = request_anim_frame; NI.anim.Cycler = Cycler; -}(this)); +}); diff --git a/lib/color.js b/lib/color.js new file mode 100644 index 0000000..24f0daa --- /dev/null +++ b/lib/color.js @@ -0,0 +1,42 @@ +/* ============================================================================ + + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ +typecode-js v 0.1 +*/ + +define(['jquery', 'NIseed'], function($) { + + var window = this, + NI = window.NI, + + color = { + get_rgb_from_hex:function(index,hex){ + if(index.toLowerCase() == 'r'){ + return parseInt((this.cut_hex(hex)).substring(0,2),16); + } else if(index.toLowerCase() == 'g'){ + return parseInt((this.cut_hex(hex)).substring(2,4),16); + } else if(index.toLowerCase() == 'b'){ + return parseInt((this.cut_hex(hex)).substring(4,6),16); + } + }, + cut_hex:function(h){ + return (h.charAt(0)=='#') ? h.substring(1,7) : h; + } + }; + +//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + + NI.color = color; + +}); \ No newline at end of file diff --git a/lib/tc.feature_detection.js b/lib/featuredetection.js similarity index 77% rename from lib/tc.feature_detection.js rename to lib/featuredetection.js index 931b835..3cb3444 100644 --- a/lib/tc.feature_detection.js +++ b/lib/featuredetection.js @@ -15,25 +15,24 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { - - var NI = window.NI, - cache = {}, - is; +define(['jquery', 'NIseed'], function($) { + var window = this, + NI = window.NI, + cache = {}, is = { touch: function() { - if (typeof cache.isTouch === "boolean") { - return cache.isTouch; + if (typeof cache.is_touch === 'boolean') { + return cache.is_touch; } - if (("ontouchstart" in window) || (window.DocumentTouch && document instanceof DocumentTouch)) { - cache.isTouch = true; + if (('ontouchstart' in window) || (window.DocumentTouch && document instanceof DocumentTouch)) { + cache.is_touch = true; } else { - cache.isTouch = false; + cache.is_touch = false; } - return cache.isTouch; + return cache.is_touch; } }; @@ -41,4 +40,4 @@ typecode-js v 0.1 NI.is = $.extend(NI.is || {}, is); -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/tc.field.js b/lib/field.js similarity index 97% rename from lib/tc.field.js rename to lib/field.js index f1b89e4..a112755 100644 --- a/lib/tc.field.js +++ b/lib/field.js @@ -15,10 +15,13 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { var NI = window.NI, - field = { extensions: {} }; + field = { + extensions: {} + }, + console = NI.app.getConsole(true); //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // constants @@ -233,6 +236,9 @@ typecode-js v 0.1 //throw new Error("field.new_instance: failed to determine field type"); field_type = "_Base"; } + if (! $.isFunction(field[field_type])) { + console.error('Field type ' + field_type + 'is not defined'); + } return new field[field_type]($.extend(o.options, {$e: field_info.$e})); }; @@ -358,4 +364,5 @@ typecode-js v 0.1 NI.field = field; -}(this, this.jQuery)); \ No newline at end of file + return NI.field; +}); \ No newline at end of file diff --git a/lib/field/tc.field.autocomplete.js b/lib/field/Autocomplete.js similarity index 97% rename from lib/field/tc.field.autocomplete.js rename to lib/field/Autocomplete.js index 5dfaba2..3b4f2eb 100644 --- a/lib/field/tc.field.autocomplete.js +++ b/lib/field/Autocomplete.js @@ -18,9 +18,11 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI, delegates = {}; + var window = this, + NI = window.NI, + delegates = {}; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -320,7 +322,7 @@ typecode-js v 0.1 function innerHighlight($item, node, pat) { var skip = 0; - if (node.nodeType == NI.co.nodeTypes.TEXT_NODE) { + if (node.nodeType == NI.co.node_types.TEXT_NODE) { var pos = node.data.toUpperCase().indexOf(pat); if (pos >= 0) { var spannode = document.createElement('span'); @@ -337,7 +339,7 @@ typecode-js v 0.1 } } - } else if (node.nodeType == NI.co.nodeTypes.ELEMENT_NODE && node.childNodes && !/(script|style)/i.test(node.tagName)) { + } else if (node.nodeType == NI.co.node_types.ELEMENT_NODE && node.childNodes && !/(script|style)/i.test(node.tagName)) { for (var i = 0; i < node.childNodes.length; ++i) { i += innerHighlight($item, node.childNodes[i], pat); } @@ -503,4 +505,4 @@ typecode-js v 0.1 init(); }; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/field/tc.field.counter.js b/lib/field/Counter.js similarity index 88% rename from lib/field/tc.field.counter.js rename to lib/field/Counter.js index 78a09b4..9125577 100644 --- a/lib/field/tc.field.counter.js +++ b/lib/field/Counter.js @@ -18,9 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -49,7 +50,7 @@ typecode-js v 0.1 function init(){ field.event_receiver.bind('focus keyup change', {field:field}, event_handlers.updated); - }; + } event_handlers = { updated:function(e,d){ @@ -59,11 +60,11 @@ typecode-js v 0.1 //elements.total.text(o.max); if (o.difference < 0) { - elements.count.parent().addClass('too-many') + elements.count.parent().addClass('too-many'); } else { - elements.count.parent().removeClass('too-many') - }; - } + elements.count.parent().removeClass('too-many'); + } + } }; @@ -71,4 +72,6 @@ typecode-js v 0.1 }; -}(this, this.jQuery)); \ No newline at end of file + return NI.field.extensions.Counter; + +}); \ No newline at end of file diff --git a/lib/field/tc.field.dropdown.js b/lib/field/Dropdown.js similarity index 94% rename from lib/field/tc.field.dropdown.js rename to lib/field/Dropdown.js index 366fd3a..38e6c34 100644 --- a/lib/field/tc.field.dropdown.js +++ b/lib/field/Dropdown.js @@ -18,10 +18,11 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI, - field = NI.field; + var window = this, + NI = window.NI, + field = NI.field; field.synthesize({ name: "Dropdown", @@ -40,20 +41,20 @@ typecode-js v 0.1 return $f; } - if (!($f[0].nodeName.toLowerCase() == "select")) { + if ($f[0].nodeName.toLowerCase() != "select") { return $f; } $e = $("
") .addClass(field.co.BASE_CLASS+ " " +field.Dropdown.CONTAINER_CLASS) .html("
"+ - "
"); + "
"); buf = ""; $f.find("option").each(function() { var $option = $(this); buf += "
"+ - field.get_display_text($option) +"
"; + field.get_display_text($option) +"
"; }); $e.find("."+ field.Dropdown.MENU_CLASS).html(buf); @@ -109,9 +110,9 @@ typecode-js v 0.1 if (me.$e[0] === e.target || $.contains(me.$e[0], e.target)) { // clicked somewhere on the dropdown - if (me.elements.display[0] === e.target || - $.contains(me.elements.display[0], e.target) || - (me.elements.trigarr && me.elements.trigarr[0] === e.target)) { + if (me.elements.display[0] === e.target || + $.contains(me.elements.display[0], e.target) || + (me.elements.trigarr && me.elements.trigarr[0] === e.target)) { // clicked somewhere on the dropdown display area me[me.internal.open ? "close" : "open"](); @@ -144,7 +145,7 @@ typecode-js v 0.1 } } else if (key == NI.co.keyboard.BACKSPACE || - key == NI.co.keyboard.DELETE) { + key == NI.co.keyboard.DELETE) { if (me.internal.filter_str.length) { me.clear_filter(); } @@ -186,8 +187,16 @@ typecode-js v 0.1 generate_from_dom: function(options) { var me, $items; me = this; - field._Base.prototype.generate_from_dom.apply(this, arguments); + + if (options.$e[0].nodeName.toLowerCase() == "select") { + this.$e = field.Dropdown.morph_native_select(options.$e); + } else { + this.$e = options.$e; + } + + this.$e.addClass(field.co.BASE_CLASS); this.$e.addClass(field.Dropdown.CONTAINER_CLASS); + this._init_elements(); $items = this.get_items(true); if (typeof(this.internal.o.item_handlers) === "object") { @@ -214,7 +223,7 @@ typecode-js v 0.1 this.$e = $("
") .addClass(field.co.BASE_CLASS+ " " +field.Dropdown.CONTAINER_CLASS) .html("
"+ - "
"); + "
"); this._init_elements(); if (options.value_list) { this.populate(options.value_list); @@ -297,7 +306,7 @@ typecode-js v 0.1 $items = $items.filter(include_secrets); } else if (!include_secrets) { $items = $items.filter(function() { - return !($(this).css("display") === "none"); + return ($(this).css("display") !== "none"); }); } return $items; @@ -337,7 +346,7 @@ typecode-js v 0.1 $items.each(function(i) { var $item = $(this); if ($item.attr(field.co.VALUE) == val) { - if (!me.internal.multi) { + if (!me.internal.multi) { $items.removeClass(field.co.ACTIVE_CLASS); } else { $item.children("input").attr("checked", true); @@ -412,7 +421,7 @@ typecode-js v 0.1 } if (arguments[0] === false) { - this.elements.display.html(""+ this.internal.o.empty_text +""); + this.elements.display.html(""+ this.internal.o.empty_text +""); return; } }, @@ -477,7 +486,7 @@ typecode-js v 0.1 me = this; $items = this.get_items(function() { var $item = $(this); - return ($item.hasClass("state-filtered") || !($item.css("display") === "none")); + return ($item.hasClass("state-filtered") || ($item.css("display") !== "none")); }); if (!$items.length) { return this; @@ -653,4 +662,4 @@ typecode-js v 0.1 } }); -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/field/tc.field.hint.js b/lib/field/Hint.js similarity index 95% rename from lib/field/tc.field.hint.js rename to lib/field/Hint.js index 13f439c..7b85397 100644 --- a/lib/field/tc.field.hint.js +++ b/lib/field/Hint.js @@ -18,9 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -108,4 +109,6 @@ typecode-js v 0.1 init(); }; -}(this, this.jQuery)); \ No newline at end of file + return NI.field.extensions.Hint; + +}); \ No newline at end of file diff --git a/lib/field/tc.field.simple_tooltip.js b/lib/field/SimpleTooltip.js similarity index 94% rename from lib/field/tc.field.simple_tooltip.js rename to lib/field/SimpleTooltip.js index 3d3aeba..af7be53 100644 --- a/lib/field/tc.field.simple_tooltip.js +++ b/lib/field/SimpleTooltip.js @@ -18,9 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -94,4 +95,6 @@ typecode-js v 0.1 init(); }; -}(this, this.jQuery)); \ No newline at end of file + return NI.field.extensions.SimpleTooltip; + +}); \ No newline at end of file diff --git a/lib/field/tc.field.validator.js b/lib/field/Validator.js similarity index 98% rename from lib/field/tc.field.validator.js rename to lib/field/Validator.js index 89c798e..f37c684 100644 --- a/lib/field/tc.field.validator.js +++ b/lib/field/Validator.js @@ -18,13 +18,13 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define(['jquery', 'NIseed', 'NIfield', 'NIvalidation'], function($) { var NI = window.NI, field = NI.field; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - + function Validator(field, options) { var me, o, internal; @@ -40,7 +40,7 @@ typecode-js v 0.1 internal = { managed_field:null }; - + if (!o.manager || !(o.manager instanceof NI.ValidationManager)) { o.manager = new NI.ValidationManager({ watchEvents:['keyup', 'change', NI.field.co.SET_VAL_EVENT] @@ -190,8 +190,11 @@ typecode-js v 0.1 } + field.extensions.Validator = Validator; field.extensions.SimpleTooltipValidatorError = SimpleTooltipValidatorError; field.extensions.ValidatorError = ValidatorError; -}(this, this.jQuery)); \ No newline at end of file + return Validator; + +}); \ No newline at end of file diff --git a/lib/field/tc.field.std.js b/lib/field/std.js similarity index 99% rename from lib/field/tc.field.std.js rename to lib/field/std.js index b77df12..06bc65f 100644 --- a/lib/field/tc.field.std.js +++ b/lib/field/std.js @@ -18,10 +18,11 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI, - field = NI.field; + var window = this, + NI = window.NI, + field = NI.field; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // standard field type @@ -674,4 +675,4 @@ typecode-js v 0.1 }); -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/flippanel.js b/lib/flippanel.js new file mode 100644 index 0000000..f29805b --- /dev/null +++ b/lib/flippanel.js @@ -0,0 +1,132 @@ +/* ============================================================================ + + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ +typecode-js v 0.1 +*/ + +define(['jquery', 'NIseed'], function($) { + + /* to use, the selector of the element with class .flip-panel must be passed. + + .flip-panel must have two direct children, .front and .back, as well as two triggers, + .front-trigger and .back-trigger. + + as a direct child of both .front and .back, there must be a div with class .inner + */ + this.NI.flip_panel = function(eleContainer) { + + // variables + var flipContainer, frontBox, frontInner, backBox, backInner, + frontTrigger, backTrigger, innerOuterDiff, speed, slideDelay, webkitPerspective; + + speed = 300; // speed of height change when flipping + slideDelay = 200; // delay after flip starts before changing height + + applyWebkitCSSinJS = true; + webkitPerspective = 600; + + + flipContainer = $(eleContainer); + frontBox = flipContainer.children('.front'); + frontInner = frontBox.children('.inner'); + frontTrigger = flipContainer.find('.front-trigger'); + backBox = flipContainer.children('.back'); + backInner = backBox.children('.inner'); + backTrigger = flipContainer.find('.back-trigger'); + + innerOuterDiff = frontBox.height() - frontInner.height(); + + + + + // events + frontTrigger.click(function(){ + frontBox.show(); + + if(applyWebkitCSSinJS) { + flipContainer.css('-webkit-perspective', webkitPerspective); + frontBox.css('-webkit-transform-style','preserve-3d'); + backBox.css('-webkit-transform-style','preserve-3d'); + } + + backBox.find('.btn-edu').css('opacity','0'); + + backBox.css({ + 'height': frontBox.height(), + 'position': 'absolute', + 'overflow': 'hidden' + }).show(0, function(){ + flipContainer.addClass('flip'); + }); + + frontBox.delay(slideDelay).hide(0, function(){ + frontBox.css('display','none'); + backBox.css('position','relative').animate({ + height: backInner.height() + innerOuterDiff + }, speed, function(){ + backBox.css({'height':'auto', 'overflow':'visible'}); + + if(applyWebkitCSSinJS) { + // if speed + slideDelay is less than the CSS transition // speed (400ms), additional delay should be put on this + flipContainer.css('-webkit-perspective','none'); + frontBox.css('-webkit-transform-style','flat'); + backBox.css('-webkit-transform-style','flat'); + } + + backBox.find('.btn-edu').animate({'opacity':'1'}, 400); + }); + }); + }); + + + + backTrigger.click(function(){ + backBox.css('position','absolute').show(); + + if(applyWebkitCSSinJS) { + flipContainer.css('-webkit-perspective', webkitPerspective); + frontBox.css('-webkit-transform-style','preserve-3d'); + backBox.css('-webkit-transform-style','preserve-3d'); + } + + frontBox.css({ + 'height': backBox.height(), + 'overflow': 'hidden' + }).show(0, function(){ + flipContainer.removeClass('flip'); + }); + + backBox.delay(slideDelay).hide(0, function(){ + frontBox.animate({ + height: frontInner.height() + innerOuterDiff + }, speed, function(){ + frontBox.css({'height':'auto', 'overflow':'visible'}); + + if(applyWebkitCSSinJS) { + // if speed + slideDelay is less than the CSS transition + // speed (400ms), additional delay should be put on this + flipContainer.css('-webkit-perspective','none'); + frontBox.css('-webkit-transform-style','flat'); + backBox.css('-webkit-transform-style','flat'); + } + + backBox.find('.btn-edu').css('opacity','0'); + }); + }); + }); + + + }; + +}); \ No newline at end of file diff --git a/lib/fullscreen.js b/lib/fullscreen.js new file mode 100644 index 0000000..5c40028 --- /dev/null +++ b/lib/fullscreen.js @@ -0,0 +1,106 @@ +/* ============================================================================ + + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ +typecode-js v 0.1 +*/ + +define(['jquery', 'NIseed'], function($) { + + var window = this, + NI = window.NI, + + fullscreen = { + + request: function(dom) { + dom = dom || document.documentElement; + if (dom.requestFullscreen) { + dom.requestFullscreen(); + } else if (dom.mozRequestFullScreen) { + dom.mozRequestFullScreen(); + } else if (dom.webkitRequestFullScreen) { + dom.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); + } + }, + + cancel: function() { + if (document.exitFullscreen) { + document.exitFullscreen(); + } else if (document.mozCancelFullScreen) { + document.mozCancelFullScreen(); + } else if (document.webkitCancelFullScreen) { + document.webkitCancelFullScreen(); + } + }, + + toggle: function() { + var fs; + + if (typeof document.fullscreen === 'boolean') { + fs = document.fullscreen; + } else if (typeof document.mozFullScreen === 'boolean') { + fs = document.mozFullScreen; + } else if (typeof document.webkitIsFullScreen === 'boolean') { + fs = document.webkitIsFullScreen; + } + + if (typeof fs === 'boolean') { + if (fs) { + this.cancel(); + } else { + this.request(); + } + } + }, + + register_change_handler: function(handler, event_data) { + var guid; + if (!$.isFunction(handler)) { + return null; + } + if (!event_data || typeof event_data !== 'object') { + event_data = {}; + } + guid = NI.fn.guid('fullscreen_'); + $(document).on('fullscreenchange.'+guid +' mozfullscreenchange.'+guid +' webkitfullscreenchange.'+guid, function(e, d) { + var fullscreen; + switch (e.type) { + case 'fullscreenchange': + fullscreen = document.fullscreen; + break; + case 'mozfullscreenchange': + fullscreen = document.mozFullScreen; + break; + case 'webkitfullscreenchange': + fullscreen = document.webkitIsFullScreen; + break; + } + e.data = $.extend(event_data, { + fullscreen: fullscreen + }); + handler.apply(this, [e, d]); + }); + return guid; + }, + + destroy_change_handler: function(id) { + var guid = id ? '.'+ id : ''; + $(document).off('fullscreenchange'+guid +' mozfullscreenchange'+guid +' webkitfullscreenchange'+guid); + } + }; + + NI.fullscreen = fullscreen; + + return fullscreen; + +}); \ No newline at end of file diff --git a/lib/tc.google_analytics.header.js b/lib/googleanalyticsheader.js similarity index 93% rename from lib/tc.google_analytics.header.js rename to lib/googleanalyticsheader.js index 923a31b..5548f58 100644 --- a/lib/tc.google_analytics.header.js +++ b/lib/googleanalyticsheader.js @@ -15,12 +15,12 @@ From 2010 till ∞ typecode-js v 0.1 */ -//Does not rely on tc.seed.js +define([], function() { -var _gaq = _gaq || []; + var window = this; + window._gaq = window._gaq || []; -(function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); -})(); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/merlin/tc.merlin.autosave.js b/lib/merlin/MerlinAutosave.js similarity index 94% rename from lib/merlin/tc.merlin.autosave.js rename to lib/merlin/MerlinAutosave.js index 9f9db2b..5aab65a 100644 --- a/lib/merlin/tc.merlin.autosave.js +++ b/lib/merlin/MerlinAutosave.js @@ -15,9 +15,10 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed', 'NIMerlin'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; function MerlinAutosave(options){ @@ -38,6 +39,7 @@ typecode-js v 0.1 _me = this; this.init = function(me, functions){ + var i; internal.functions = functions; @@ -47,7 +49,7 @@ typecode-js v 0.1 continue; } - me.internal.current_step.fields[i].component.event_receiver.bind('change keyup',{ name:i, },function(e,d){ + me.internal.current_step.fields[i].component.event_receiver.bind('change keyup',{ name:i },function(e,d){ if(internal.save_timeout){ clearTimeout(internal.save_timeout); } @@ -96,10 +98,10 @@ typecode-js v 0.1 }; - }; + } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: NI.MerlinAutosave = MerlinAutosave; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/merlin/tc.merlin.csrf.js b/lib/merlin/MerlinCSRF.js similarity index 93% rename from lib/merlin/tc.merlin.csrf.js rename to lib/merlin/MerlinCSRF.js index a969616..33e3c73 100644 --- a/lib/merlin/tc.merlin.csrf.js +++ b/lib/merlin/MerlinCSRF.js @@ -15,9 +15,10 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed', 'NIMerlin'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; function MerlinCSRF(options){ @@ -48,10 +49,10 @@ typecode-js v 0.1 return internal.data; }; - }; + } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: NI.MerlinCSRF = MerlinCSRF; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/merlin/tc.merlin.data.js b/lib/merlin/MerlinData.js similarity index 97% rename from lib/merlin/tc.merlin.data.js rename to lib/merlin/MerlinData.js index 7f9d0c6..47ef828 100644 --- a/lib/merlin/tc.merlin.data.js +++ b/lib/merlin/MerlinData.js @@ -15,9 +15,10 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed', 'NIMerlin'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; function MerlinData(options){ @@ -48,7 +49,7 @@ typecode-js v 0.1 me.get_val = this.get_val; me.set_val = this.set_val; - } + }; this.populate_fields = function(me,fields){ @@ -171,12 +172,10 @@ typecode-js v 0.1 }; - - - }; + } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: NI.MerlinData = MerlinData; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/particle/tc.particle.context.js b/lib/particle/tc.particle.context.js deleted file mode 100644 index b6f4601..0000000 --- a/lib/particle/tc.particle.context.js +++ /dev/null @@ -1,201 +0,0 @@ -/* ============================================================================ - - >4SESz., _, ,gSEE2zx.,_ .azx ,w. -@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ -\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. - ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ - :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 - {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, - \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F - ,ss :EE7 ;EEF L,szzw.. ,., `` - \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL - ```` `` JEEE. `"45EEEhw.,,,] - -From 2010 till ∞ -typecode-js v 0.1 -*/ - -if(!tc){ var tc = {}; } - -(function(tc) { - - - (function requestAnimationFrame() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = - window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if(!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if(!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - }()); - - if(!tc.particle){ tc.particle = {}; } - - tc.particle.context = function(dom,options){ - var _me, o; - _me = dom; - - o = $.extend({ - fps:30, - bounds: { - min_x: 0, - max_x: 1000, - min_y: 0, - max_y: 1000 - }, - bg_image:null - },options); - - this.initialize = function(){ - _me.context = _me.get(0).getContext('2d'); - _me.forces = []; - _me.particles = []; - _me.frame = 0; - _me.stopped = true; - _me.timer = null; - _me.mouse_pos = null; - _me.mouse_down_pos = null; - - _me.bounds = o.bounds; - _me.net_energy = 0; - if(o.bg_image){ - _me.bg_image = new Image(); - _me.bg_image.src = o.bg_image; - } - return _me; - } - - _me.setSize = function(size){ - _me.bounds = { - min_x: 0, - max_x: size.width, - min_y: 0, - max_y: size.height - }; - _me.css(size).attr('width',size.width).attr('height',size.height); - _me.anchor_offset = { - x:size.width/2, - y:size.height/3 - } - for(i = 0; i < _me.particles.length; i++){ - _me.particles[i]['set_anchor_offset'](_me.anchor_offset); - } - } - - _me.add_particle = function(particle){ - _me.particles.push(particle); - return _me.particles[_me.particles.length-1]; - } - - _me.add_global_force = function(pos, strength, radius){ - var force; - if(pos.x && pos.y){ - force = { - pos:Vector.create([pos.x,pos.y]), - strength:strength, - radius:radius - }; - _me.forces.push(force); - return _me.forces[_me.forces.length-1]; - } - } - - _me.update = function(){ - _me.frame++; - _me.net_energy = 0; - for(i = 0; i < _me.forces.length; i++){ - _me.forces[i].radius = (_me.forces[i].radius * 0.98); - } - if(_me.stopped){ - window.cancelAnimationFrame(); - } else { - window.requestAnimationFrame(_me.update); - for(i = 0; i < _me.particles.length; i++){ - _me.particles[i]['reset_forces'](); - _me.particles[i]['add_forces'](_me.forces); - _me.particles[i]['bounce_off_walls'](_me.bounds); - _me.particles[i]['handle_anchor'](); - //_me.particles[i]['collide_with_particles'](_me.particles,i); - _me.particles[i]['add_damping'](); - _me.particles[i]['update'](); - _me.net_energy = _me.net_energy + _me.particles[i].norm_dist_from_anchor; - } - _me.net_energy = _me.net_energy / _me.particles.length; - _me.mouse_down_pos = null; - _draw(); - } - - } - - _me.start = function(){ - _me.mouse_pos = null; - _me.mouse_down_pos = null; - if(_me.stopped){ - _me.stopped = false; - window.requestAnimationFrame(_me.update); - } - } - - _me.stop = function(){ - _me.stopped = true; - } - - function _draw(drawing_context){ - var opacity, i, alpha; - - _me.context.globalAlpha = 1.0; - _me.context.fillStyle = 'rgba(252,252,252,0.45)'; - _me.context.fillRect( - 0, - 0, - _me.bounds.max_x, - _me.bounds.max_y - ); - - if(_me.net_energy < 0.2 && _me.bg_image){ - opacity = (0.2/(_me.net_energy < 0.01 ? 0.01 : _me.net_energy)/20); - _me.context.globalAlpha = opacity - 0.01; - _me.context.drawImage( - _me.bg_image, - _me.anchor_offset.x-358, - _me.anchor_offset.y - ); - } - - if(opacity){ - alpha = 1.0 - opacity + 0.01; - } else { - alpha = 1.0; - } - - _me.context.globalAlpha = alpha; - - _me.context.fillStyle = '#000000'; - for(i = 0; i < _me.particles.length; i++){ - _me.particles[i].draw(_me.context); - } - } - - function _render(){ - - } - - return this.initialize(); - } - -})(tc); \ No newline at end of file diff --git a/lib/particle/tc.particle.particle.js b/lib/particle/tc.particle.particle.js deleted file mode 100644 index dd62a7f..0000000 --- a/lib/particle/tc.particle.particle.js +++ /dev/null @@ -1,238 +0,0 @@ -/* ============================================================================ - - >4SESz., _, ,gSEE2zx.,_ .azx ,w. -@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ -\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. - ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ - :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 - {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, - \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F - ,ss :EE7 ;EEF L,szzw.. ,., `` - \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL - ```` `` JEEE. `"45EEEhw.,,,] - -From 2010 till ∞ -typecode-js v 0.1 -*/ - -if(!tc){ var tc = {}; } - -(function(tc) { - if(!tc.particle){ tc.particle = {}; } - - tc.particle.particle = function(options){ - var _me, o, damping, color; - _me = this; - - var pos, - vel, - frc; - - color = new NI.Color(); - - this.options = $.extend({ - pos:{x:0,y:0}, - vel:{x:0,y:0}, - frc:{x:0,y:0}, - anchored:false, - anchor:{x:0,y:0}, - damping:0.89, - radius:5, - draw:function(context){ - context.beginPath(); - context.arc(this.pos.elements[0], this.pos.elements[1], this.o.radius, 0, (2*Math.PI), false); - context.fill(); - context.closePath(); - }, - color:"000000", - opacity:0.65, - attraction_coefficient: 1.0, - data:{}, - anchor_offset:{ - x:0, - y:0 - } - },options); - - o = this.options; - - this.initialize = function(){ - _me.pos = Vector.create([o.pos.x, o.pos.y]); - vel = Vector.create([o.vel.x, o.vel.y]); - frc = Vector.create([o.frc.x, o.frc.y]); - _me.anchor = Vector.create([ - (0+o.anchor.x+o.anchor_offset.x), - (0+o.anchor.y+o.anchor_offset.y) - ]); - _me.radius = o.radius; - _me.diameter = o.radius*2; - if(_me.options.opacity < 1.0){ - _me.fill = "rgba("+color.getRGBFromHex('r',o.color)+","+color.getRGBFromHex('g',o.color)+","+color.getRGBFromHex('b',o.color)+","+o.opacity+")"; - } else { - _me.fill = "#"+o.color; - } - _me.jitter = null; - _me.norm_dist_from_anchor = 0; - } - - _me.set_anchor_offset = function(offset){ - _me.anchor.elements[0] = (0+o.anchor.x+offset.x); - _me.anchor.elements[1] = (0+o.anchor.y+offset.y); - } - - _me.worker = function(new_worker){ - if(new_worker){ - _me.worker = new_worker; - } else { - return _me.worker; - } - } - - _me.name = function(new_name){ - if(new_name){ - _me.options.name = new_name; - } else { - return _me.options.name; - } - } - - _me.pos = function(new_pos){ - if(new_pos){ - _me.pos = new_pos; - } else { - return _me.pos; - } - } - - _me.vel = function(new_vel){ - if(new_vel){ - vel = new_vel; - } else { - return vel; - } - } - - _me.frc = function(new_frc){ - if(new_frc){ - frc = new_frc; - } else { - return frc; - } - } - - _me.radius = function(new_radius){ - if(new_radius){ - _me.options.radius = new_radius; - } else { - return _me.options.radius; - } - } - - _me.reset_forces = function(){ - frc.setElements([0, 0]); - damping = _me.options.damping; - } - - _me.add_forces = function(forces){ - var distance, length, pct, normal_distance; - for(var i = 0; i < forces.length; i++){ - distance = _me.pos.subtract(forces[i].pos); - length = Math.sqrt(distance.dot(distance)); - if(length < forces[i].radius){ - pct = (1 - (length / forces[i].radius)) * 20/o.radius ; - normal_distance = distance.multiply(1/length); - frc.elements[0] = frc.elements[0] - normal_distance.elements[0] * - forces[i].strength * pct * o.attraction_coefficient; - frc.elements[1] = frc.elements[1] - normal_distance.elements[1] * - forces[i].strength * pct * o.attraction_coefficient; - } - } - } - - _me.bounce_off_walls = function(bounds){ - var b_did_i_collide; - b_did_i_collide = false; - - if(_me.pos.elements[0] < bounds.min_x + o.radius){ - _me.pos.elements[0] = o.radius; - b_did_i_collide = true; - vel.elements[0] = vel.elements[0] * -1.0; - }else if(_me.pos.elements[0] > bounds.max_x - o.radius){ - _me.pos.elements[0] = bounds.max_x - o.radius; - b_did_i_collide = true; - vel.elements[0] = vel.elements[0] * -1.0; - } - - if(_me.pos.elements[1] < bounds.min_y + o.radius){ - _me.pos.elements[1] = o.radius; - b_did_i_collide = true; - vel.elements[1] = vel.elements[1] * -1.0; - }else if(_me.pos.elements[1] > bounds.max_y - o.radius){ - _me.pos.elements[1] = bounds.max_y - o.radius; - b_did_i_collide = true; - vel.elements[1] = vel.elements[1] * -1.0; - } - - if(b_did_i_collide){ - vel = vel.multiply(0.3); - } - } - - _me.handle_anchor = function(){ - if(!_me.anchor){ return; } - var distance, length, pct, normal_distance; - distance = _me.pos.subtract(_me.anchor); - length = Math.sqrt(distance.dot(distance)); - - if(length <= 0.5){ - return; - } - - pct = (length / 1000); - normal_distance = distance.multiply(1/length); - _me.norm_dist_from_anchor = (length / 100); - frc.elements[0] = frc.elements[0] - normal_distance.elements[0] * 10 * pct; - frc.elements[1] = frc.elements[1] - normal_distance.elements[1] * 10 * pct; - } - - _me.collide_with_particles = function(particles,j){ - for(var i = 0; i < particles.length; i++){ - if(i != j){ - var distance = _me.pos.subtract(particles[i].pos) - var length = Math.sqrt(distance.dot(distance)) - if(length < (o.radius + particles[i].radius())+2){ - var pct = 1 - (length / (o.radius + particles[i].radius() + 2)) - var normal_distance = distance.multiply((1/(length/4))) - frc.elements[0] = frc.elements[0] - normal_distance.elements[0] * -0.7// * pct - frc.elements[1] = frc.elements[1] - normal_distance.elements[1] * -0.7// * pct - } - } - } - } - - _me.stop = function(){ - frc.setElements([0, 0]) - vel.setElements([0, 0]) - } - - _me.add_damping = function(){ - vel = vel.multiply(damping); - } - - _me.update = function(){ - vel = vel.add(frc); - _me.pos = _me.pos.add(vel); - if(_me.jitter){ - _me.pos.elements[0] += _me.jitter.x; - _me.pos.elements[1] += _me.jitter.y; - _me.jitter = null; - } - } - - _me.draw = function(context){ - this.options.draw.call(_me,context); - } - - return this.initialize(); - } -})(tc); diff --git a/lib/seed.js b/lib/seed.js new file mode 100644 index 0000000..8c608be --- /dev/null +++ b/lib/seed.js @@ -0,0 +1,256 @@ +/* ============================================================================ + + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ +typecode-js v 0.1 +*/ + +define(['jquery'], function($) { + + var window = this, + NI = {}, + fakeConsole, + _id = 0; + + NI.ex = { + + checkStr: function(s) { + var t = typeof s; + if (t === 'string') { return true; } + console.error('Expected string, but found "'+ String(t) +'" instead'); + }, + + checkFn: function(fn) { + if ($.isFunction(fn)) { return true; } + console.error('Expected function, but found "'+ typeof fn +'" instead'); + }, + + checkJQ: function(o) { + if (o instanceof $) { return true; } + console.error('Expected jQuery object, but found "'+ typeof o +'" instead'); + }, + + checkJQNode: function($e, type) { + NI.ex.checkJQ($e); + type = type.toLowerCase(); + if ($e.length === 1) { + if ($e[0].nodeName.toLowerCase() === type) { + return true; + } + } + throw new TypeError('Expected jQuery object holding single '+ type +' element'); + }, + + typeOf: function(v) { + var s = typeof v; + if (s === 'object') { + if (v) { + if (typeof v.length === 'number' && + !(v.propertyIsEnumerable('length')) && + typeof v.splice === 'function') { + s = 'array'; + } + } else { + s = 'null'; + } + } + return s; + }, + + isEmpty: function(v) { + NI.ex.checkStr(v); + return $.trim(v) ? + false : true; + }, + + isHeadless: function($e) { + var node = $e[0]; + if (!node.parentNode) { + return true; + } + if (node.parentNode === NI.co.node_types.DOCUMENT_NODE) { + return true; + } + return false; + } + }; + + NI.fn = { + + get_console: function(debug) { + if (debug && typeof window.console !== 'undefined') { + return window.console; + } + if (!fakeConsole) { + fakeConsole = {}; + $.each(('assert,count,debug,dir,dirxml,error,exception,\ + group,groupCollapsed,groupEnd,info,log,markTimeline,\ + profile,profileEnd,time,timeEnd,trace,warn').split(','), function() { + fakeConsole[this] = $.noop; + }); + } + return fakeConsole; + }, + + // via http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/ + load_script: function(url, callback) { + var script = window.document.createElement('script'); + script.type = 'text/javascript'; + if (script.readyState) { + script.onreadystatechange = function() { + if (script.readyState == 'loaded' || script.readyState == 'complete') { + script.onreadystatechange = null; + if ($.isFunction(callback)) { + callback(); + } + } + }; + } else { + script.onload = function() { + if ($.isFunction(callback)) { + callback(); + } + }; + } + script.src = url; + window.document.getElementsByTagName('head')[0].appendChild(script); + }, + + guid: function(prefix) { + var id = _id++; + return (prefix || 'obj_')+ id; + }, + + random_element: function(array) { + if (NI.ex.typeOf(array) === 'array' && array.length > 0) { + return array[window.Math.floor(NI.math.random(array.length))]; + } + }, + + // debounce implementation from Underscore.js + // http://documentcloud.github.com/underscore/ + debounce: function(fn, delay) { + var timer; + return function() { + var self = this, args = arguments, + execute = function() { + timer = null; + fn.apply(self, args); + }; + window.clearTimeout(timer); + timer = window.setTimeout(execute, delay); + }; + }, + + once_visible: function($e, fn) { + if ($e.is(':visible')) { + fn(); + } else { + setTimeout(function() { + NI.fn.once_visible($e, fn); + }, 10); + } + }, + + // String interpolation + // var s = interpolate('Hello %', ['world']) + interpolate: function(str, args) { + var i; + if (args) { + for (i = 0; i < args.length; i += 1) { + str = str.replace('%', args[i]); + } + } + return str; + } + }; + + NI.co = { + + keyboard: { + + BACKSPACE: 8, + CAPS_LOCK: 20, + COMMA: 188, + CONTROL: 17, + DELETE: 46, + DOWN: 40, + END: 35, + ENTER: 13, + ESCAPE: 27, + HOME: 36, + INSERT: 45, + LEFT: 37, + NUMPAD_ADD: 107, + NUMPAD_DECIMAL: 110, + NUMPAD_DIVIDE: 111, + NUMPAD_ENTER: 108, + NUMPAD_MULTIPLY: 106, + NUMPAD_SUBTRACT: 109, + PAGE_DOWN: 34, + PAGE_UP: 33, + PERIOD: 190, + RIGHT: 39, + SHIFT: 16, + SPACE: 32, + TAB: 9, + UP: 38 + }, + + node_types: { + + ELEMENT_NODE: 1, + ATTRIBUTE_NODE: 2, + TEXT_NODE: 3, + CDATA_SECTION_NODE: 4, + ENTITY_REFERENCE_NODE: 5, + ENTITY_NODE: 6, + PROCESSING_INSTRUCTION_NODE: 7, + COMMENT_NODE: 8, + DOCUMENT_NODE: 9, + DOCUMENT_TYPE_NODE: 10, + DOCUMENT_FRAGMENT_NODE: 11, + NOTATION_NODE: 12 + }, + + directions: { + + UP: 0, + RIGHT: 1, + DOWN: 2, + LEFT: 3 + } + }; + + NI.math = { + + random: function() { + if (arguments.length === 0) { + return window.Math.random(); + } else if (arguments.length === 1) { + return window.Math.random()*arguments[0]; + } + return window.Math.random()*(arguments[1] - arguments[0]) + arguments[0]; + }, + + round: function(n, places) { + var p = window.Math.pow(10, places); + return window.Math.round(n*p)/p; + } + }; + +//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + + window.NI = NI; + +}); \ No newline at end of file diff --git a/lib/tc.app.js b/lib/tc.app.js deleted file mode 100644 index 7d4580e..0000000 --- a/lib/tc.app.js +++ /dev/null @@ -1,66 +0,0 @@ -/* ============================================================================ - - >4SESz., _, ,gSEE2zx.,_ .azx ,w. -@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ -\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. - ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ - :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 - {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, - \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F - ,ss :EE7 ;EEF L,szzw.. ,., `` - \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL - ```` `` JEEE. `"45EEEhw.,,,] - -From 2010 till ∞ -typecode-js v 0.1 -*/ - -(function(window, $) { - - var NI = window.NI; - - function App(options) { - var o, i; - - o = $.extend({ - name:'', - page:{ - classes: {}, - features: [] - }, - inner_page: { - classes: {}, - features: [] - } - }, options); - - this.classes = o.page.classes; - this.events = $({}); - this.runtime = {}; - - this.initialize_features(o.page.features); - this.initialize_features(o.inner_page.features); - o.page.initialized = true; - - this.events.trigger('app.featuresInitialized'); - } - - App.prototype.initialize_features = function(features) { - var i; - - if(features.length){ - for(i = 0; i < features.length; i += 1){ - if($.isFunction(features[i])){ - if(features[i](this) === false){ - break; - } - } - } - } - }; - -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - - NI.App = App; - -}(this, this.jQuery)); \ No newline at end of file diff --git a/lib/tc.carousel.js b/lib/tc.carousel.js deleted file mode 100644 index ec90868..0000000 --- a/lib/tc.carousel.js +++ /dev/null @@ -1,443 +0,0 @@ -/* ============================================================================ - - >4SESz., _, ,gSEE2zx.,_ .azx ,w. -@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ -\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. - ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ - :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 - {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, - \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F - ,ss :EE7 ;EEF L,szzw.. ,., `` - \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL - ```` `` JEEE. `"45EEEhw.,,,] - -From 2010 till ∞ -typecode-js v 0.1 -*/ - -// this carousel implementation is based on the jQuery Tools "scrollable" implementation: -// https://github.com/jquerytools/jquerytools/blob/master/src/scrollable/scrollable.js - -(function(window, $) { - - var NI = window.NI, - generate, - focussed; - - generate = { - carousel: function() { - return $(""); - }, - prevBtn: function(instance) { - var $btn; - $btn = $("Previous"); - if (instance) { - $btn.click(function(e) { - e.preventDefault(); - instance.prev(); - }); - } - return $btn; - }, - nextBtn: function(instance) { - var $btn; - $btn = $("Next"); - if (instance) { - $btn.click(function(e) { - e.preventDefault(); - instance.next(); - }); - } - return $btn; - } - }; - - function Carousel(options) { - var me, o, $e, selectors, $elements, events, touchInfo; - - me = this; - o = $.extend({ - container: null, - viewportDimensions: null, // { width: null, height: null }, - panels: [], - panelClass: "panel", - activeClass: "state-active", - disabledClass: "state-disabled", - cloneClass: "clone", - speed: 400, - easing: "swing", - vertical: false, - circular: true, - keyboard: true, - touch: true, - onBeforeMove: function(instance, info) {}, - onMove: function(instance, info) {} - }, options); - - function init() { - var $viewport; - - if (o.container) { - if (typeof o.container === "string") { - o.container = $(o.container); - } - $e = o.container; - } else { - $e = generate.carousel(); - } - - selectors = { - panel: "."+o.panelClass, - active: "."+o.activeClass, - clone: "."+o.cloneClass - }; - - $viewport = $e.find(".viewport"); - $elements = { - viewport: $viewport, - scroll: $viewport.children(".scroll"), - prevBtn: null, - nextBtn: null - }; - - if (o.viewportDimensions) { - if (typeof o.viewportDimensions.width === "number") { - $elements.viewport.width(o.viewportDimensions.width); - - } - if (typeof o.viewportDimensions.height === "number") { - $elements.viewport.height(o.viewportDimensions.height); - } - } - - if (o.keyboard) { - $(window.document).bind("keydown.carousel", {instance:me}, events.keydown); - } - - if (o.touch) { - touchInfo = {}; - $elements.scroll[0].ontouchstart = events.touchstart; - $elements.scroll[0].ontouchmove = events.touchmove; - } - - if (o.panels && o.panels.length) { - $.each(o.panels, function(i, $panel) { - me.add($panel); - }); - } - - me.begin(true); - } - - function current() { - return $elements.scroll.children(selectors.panel + selectors.active); - } - - function targetPosition($panel) { - if (o.vertical) { - if (o.viewportDimensions && typeof o.viewportDimensions.height === "number") { - return {top: -($panel.index()*o.viewportDimensions.height)}; - } - return {top: -($panel.position().top)}; - } - if (o.viewportDimensions && typeof o.viewportDimensions.width === "number") { - return {left: -($panel.index()*o.viewportDimensions.width)}; - } - return {left: -($panel.position().left)}; - } - - function moveTo($panel, noAnimate) { - var $cloneTarget = false, info; - - if (!$panel.length) { - return me; - } - - // Determine if the target panel is a clone. - // If it is, keep track of the real panel as $cloneTarget - if ($panel.hasClass(o.cloneClass)) { - $cloneTarget = $elements.scroll.children(selectors.panel).not(selectors.clone)[$panel.hasClass("head") ? "last" : "first"](); - $cloneTarget.addClass(o.activeClass).siblings().removeClass(o.activeClass); - } else { - $panel.addClass(o.activeClass).siblings().removeClass(o.activeClass); - } - - info = me.info(); - - if ($.isFunction(o.onBeforeMove)) { - if (o.onBeforeMove(me, info) === false) { - return me; - } - } - - $elements.scroll.animate(targetPosition($panel), (noAnimate ? 0 : o.speed), o.easing, function() { - - if ($cloneTarget) { - $elements.scroll.css(targetPosition($cloneTarget)); - } - - if (!o.circular) { - if ($elements.prevBtn.length) { - $elements.prevBtn[info.index === 0 ? "addClass" : "removeClass"](o.disabledClass); - } - if ($elements.nextBtn.length) { - $elements.nextBtn[info.index === info.total-1 ? "addClass" : "removeClass"](o.disabledClass); - } - } - - if ($.isFunction(o.onMove)) { - o.onMove(me, info); - } - } - ); - - return me; - } - - events = { - keydown: function(e) { - var key; - - if (focussed != me) { - return; - } - - if (me.info().total < 2) { - return; - } - - key = e.which; - - switch (key) { - case NI.co.keyboard.LEFT: - e.preventDefault(); - e.data.instance.prev(); - break; - case NI.co.keyboard.RIGHT: - e.preventDefault(); - e.data.instance.next(); - break; - } - }, - touchstart: function(e) { - touchInfo.x = e.touches[0].clientX; - touchInfo.y = e.touches[0].clientY; - }, - touchmove: function(e) { - var dx, dy; - if (e.touches.length === 1 && !$elements.scroll.is(":animated")) { - e.preventDefault(); - dx = touchInfo.x - e.touches[0].clientX; - dy = touchInfo.y - e.touches[0].clientY; - me[o.vertical && dy > 0 || !o.vertical && dx > 0 ? "next" : "prev"](); - } - } - }; - - function registerBtn(key) { - var $btn; - $btn = generate[key](me); - - if ($elements[key]) { - $elements[key].add($btn); - } else { - $elements[key] = $btn; - } - - return $btn; - } - - // return an object with a reference to the currently active panel, - // the current index, and the total number of panels - this.info = function() { - var $panels, $current, index; - $panels = $elements.scroll.children(selectors.panel).not(selectors.clone); - $panels.each(function(i, panel) { - var $p = $(panel); - if ($p.hasClass(o.activeClass)) { - $current = $p; - index = i; - return false; - } - }); - return { - $current: $current, - index: index, - total: $panels.length - }; - }; - - // add a panel to the end of the carousel - // (chainable) - this.add = function($panel) { - $panel.addClass(o.panelClass); - if (!o.vertical) { - $panel.css("float", "left"); - } - if (o.viewportDimensions) { - if (typeof o.viewportDimensions.width === "number") { - $panel.width(o.viewportDimensions.width); - } - if (typeof o.viewportDimensions.height === "number") { - $panel.height(o.viewportDimensions.height); - } - } - $elements.scroll.append($panel); - return this; - }; - - // remove a panel from the carousel, - // (return the removed panel) - this.remove = function($panel) { - var info, panelIndex, currentIndex; - - if (!($.contains($elements.scroll[0], $panel[0])) || $panel.hasClass(o.cloneClass)) { - return false; - } - - info = this.info(); - - if (info.total === 1) { - $elements.scroll.children(selectors.clone).remove(); - return $panel.detach(); - } - - panelIndex = $panel.index(); - currentIndex = info.$current.index(); - - $panel.detach(); - - // if the removed panel came before the currently active panel, - // update the offset of the scroll element - if (panelIndex < currentIndex) { - moveTo(info.$current, true); - } - // if the removed panel was the currently active panel, - // activate the previous sibling panel - else if (panelIndex === currentIndex) { - this.toIndex(currentIndex-1, true); - } - - return $panel; - }; - - // generate a "previous" button bound to this instance - // return a headless jQuery element representing the button - this.registerPrevBtn = function() { - return registerBtn("prevBtn"); - }; - - // generate a "next" button bound to this instance - // return a headless jQuery element representing the button - this.registerNextBtn = function() { - return registerBtn("nextBtn"); - }; - - // return the jQuery container element that represents the carousel - this.get = function() { - return $e; - }; - - // Tell the Carousel to check itself before it wr-wr-wrecks itself. - // If the Carousel is circular, generate its secret clone elements. - // The Carousel should be refreshed after panels have been added to or removed from it. - // add() and remove() do not automatically call refresh() (to allow for simultaneous calls - // to manipulate the Carousel in row, without consecutively refreshing). - // (chainable) - this.refresh = function() { - var $panels; - if (o.circular) { - $elements.scroll.children(selectors.clone).remove(); - $panels = $elements.scroll.children(selectors.panel); - $panels.last().clone(false).addClass(o.cloneClass +" head").prependTo($elements.scroll); - $panels.first().clone(false).addClass(o.cloneClass +" tail").appendTo($elements.scroll); - } - return this; - }; - - - // move to the first panel and automatically refresh - // (unless noRefresh is true) - // (chainable) - this.begin = function(noAnimate, noRefresh) { - if (!noRefresh) { - this.refresh(); - } - return moveTo($elements.scroll.children(selectors.panel).not(selectors.clone).first(), noAnimate); - }; - - // move to the last panel - // (chainable) - this.end = function(noAnimate) { - return moveTo($elements.scroll.children(selectors.panel).not(selectors.clone).last(), noAnimate); - }; - - // move to the panel at the specified index - // (chainable) - this.toIndex = function(index, noAnimate) { - $elements.scroll.children(selectors.panel).not(selectors.clone).each(function(i, panel) { - if (i === index) { - moveTo($(panel), noAnimate); - return false; - } - }); - return this; - }; - - // move to the next panel - // (chainable) - this.next = function(noAnimate) { - return moveTo(current().next(selectors.panel), noAnimate); - }; - - // move to the previous panel - // (chainable) - this.prev = function(noAnimate) { - return moveTo(current().prev(selectors.panel), noAnimate); - }; - - // set focus on this carousel - // (chainable) - this.focus = function() { - focussed = me; - return me; - }; - - // remove focus from this carousel - // (chainable) - this.blur = function() { - if (focussed == me) { - focussed = null; - } - return me; - }; - - // destroy this instance - // (the carousel element is automatically removed from the DOM) - this.destroy = function() { - me.blur(); - if (o.keyboard) { - $(window.document).unbind("keydown.carousel", events.keydown); - } - if ($elements.prevBtn.length) { - $elements.prevBtn.unbind("click"); - } - if ($elements.nextBtn.length) { - $elements.nextBtn.unbind("click"); - } - $e.remove(); - }; - - init(); - } - -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - - NI.Carousel = Carousel; - NI.Carousel.Generator = generate; - -}(this, this.jQuery)); \ No newline at end of file diff --git a/lib/tc.flippanel.js b/lib/tc.flippanel.js deleted file mode 100644 index 37a0935..0000000 --- a/lib/tc.flippanel.js +++ /dev/null @@ -1,129 +0,0 @@ -/* ============================================================================ - - >4SESz., _, ,gSEE2zx.,_ .azx ,w. -@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ -\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. - ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ - :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 - {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, - \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F - ,ss :EE7 ;EEF L,szzw.. ,., `` - \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL - ```` `` JEEE. `"45EEEhw.,,,] - -From 2010 till ∞ -typecode-js v 0.1 -*/ - -/* to use, the selector of the element with class .flip-panel must be passed. - - .flip-panel must have two direct children, .front and .back, as well as two triggers, - .front-trigger and .back-trigger. - - as a direct child of both .front and .back, there must be a div with class .inner -*/ -function flipPanel(eleContainer) { - - // variables - var flipContainer, frontBox, frontInner, backBox, backInner, - frontTrigger, backTrigger, innerOuterDiff, speed, slideDelay, webkitPerspective; - - speed = 300; // speed of height change when flipping - slideDelay = 200; // delay after flip starts before changing height - - applyWebkitCSSinJS = true; - webkitPerspective = 600; - - - flipContainer = $(eleContainer); - frontBox = flipContainer.children('.front'); - frontInner = frontBox.children('.inner'); - frontTrigger = flipContainer.find('.front-trigger'); - backBox = flipContainer.children('.back'); - backInner = backBox.children('.inner'); - backTrigger = flipContainer.find('.back-trigger'); - - innerOuterDiff = frontBox.height() - frontInner.height(); - - - - - // events - frontTrigger.click(function(){ - frontBox.show(); - - if(applyWebkitCSSinJS) { - flipContainer.css('-webkit-perspective', webkitPerspective); - frontBox.css('-webkit-transform-style','preserve-3d'); - backBox.css('-webkit-transform-style','preserve-3d'); - }; - - backBox.find('.btn-edu').css('opacity','0'); - - backBox.css({ - 'height': frontBox.height(), - 'position': 'absolute', - 'overflow': 'hidden' - }).show(0, function(){ - flipContainer.addClass('flip'); - }); - - frontBox.delay(slideDelay).hide(0, function(){ - frontBox.css('display','none'); - backBox.css('position','relative').animate({ - height: backInner.height() + innerOuterDiff - }, speed, function(){ - backBox.css({'height':'auto', 'overflow':'visible'}); - - if(applyWebkitCSSinJS) { - // if speed + slideDelay is less than the CSS transition speed (400ms), - // additional delay should be put on this - flipContainer.css('-webkit-perspective','none'); - frontBox.css('-webkit-transform-style','flat'); - backBox.css('-webkit-transform-style','flat'); - }; - - backBox.find('.btn-edu').animate({'opacity':'1'}, 400); - }); - }); - }); - - - - backTrigger.click(function(){ - backBox.css('position','absolute').show(); - - if(applyWebkitCSSinJS) { - flipContainer.css('-webkit-perspective', webkitPerspective); - frontBox.css('-webkit-transform-style','preserve-3d'); - backBox.css('-webkit-transform-style','preserve-3d'); - }; - - frontBox.css({ - 'height': backBox.height(), - 'overflow': 'hidden' - }).show(0, function(){ - flipContainer.removeClass('flip'); - }); - - backBox.delay(slideDelay).hide(0, function(){ - frontBox.animate({ - height: frontInner.height() + innerOuterDiff - }, speed, function(){ - frontBox.css({'height':'auto', 'overflow':'visible'}); - - if(applyWebkitCSSinJS) { - // if speed + slideDelay is less than the CSS transition speed (400ms), - // additional delay should be put on this - flipContainer.css('-webkit-perspective','none'); - frontBox.css('-webkit-transform-style','flat'); - backBox.css('-webkit-transform-style','flat'); - }; - - backBox.find('.btn-edu').css('opacity','0'); - }); - }); - }); - - -}; \ No newline at end of file diff --git a/lib/tc.google_analytics.js b/lib/tc.google_analytics.js deleted file mode 100644 index c7f2934..0000000 --- a/lib/tc.google_analytics.js +++ /dev/null @@ -1,58 +0,0 @@ -/* _____ _____ - /\ \ /\ \ - /::\ \ /::\ \ - \:::\ \ /::::\ \ - \:::\ \ /::::::\ \ - \:::\ \ /:::/\:::\ \ - \:::\ \ /:::/ \:::\ \ - /::::\ \ /:::/ \:::\ \ - /::::::\ \ /:::/ / \:::\ \ - /:::/\:::\ \ /:::/ / \:::\ \ - /:::/ \:::\____\/:::/____/ \:::\____\ - /:::/ \::/ /\:::\ \ \::/ / - /:::/ / \/____/ \:::\ \ \/____/ - /:::/ / \:::\ \ -/:::/ / \:::\ \ -\::/ / \:::\ \ - \/____/ \:::\ \ - \:::\ \ - \:::\____\ - \::/ / - \/____/ - TYPE/CODE - From 2010 till ∞ - typecode-js v0.1 - */ - -(function(window, $) { - - var NI = window.NI; - - function GoogleAnalytics(options) { - var o; - - o = $.extend({ - account:null - }, options); - - if(!o.account){ - return; - } - - _gaq.push(['_setAccount', o.account]); - - //console.log(window._gat); - //if(window._gat){ - // this.tracker = window._gat._createTracker(o.account); - // console.log(this.tracker); - //} - // - //console.log(this.tracker); - - } - -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - - NI.GoogleAnalytics = GoogleAnalytics; - -}(this, this.jQuery)); \ No newline at end of file diff --git a/lib/tc.merlin.js.old b/lib/tc.merlin.js.old deleted file mode 100644 index 1308f24..0000000 --- a/lib/tc.merlin.js.old +++ /dev/null @@ -1,535 +0,0 @@ -if(!tc){ var tc = {}; } - -tc.merlin = makeClass(); - -tc.merlin.prototype.options = { - name:null, - dom:null, - progress_element:null, - next_button:null, - back_button:null, - watch_keypress:true, - first_step:'start', - allow_hash_override_onload:false, - use_hashchange:true, - steps:{ - 'start':{ - progress_selector:'.1', - selector:'.start', - prev_step:null, - next_step:null - } - } -}; - -tc.merlin.prototype.init = function(app,options){ - tc.util.log('tc.merlin.init'); - this.options = tc.jQ.extend({},this.options,options); - this.app = app; - if(this.options.dom instanceof String){ - this.options.dom = tc.jQ(options.dom); - } - this.dom = this.options.dom; - this.magic = null; - this.event_data = {app:app,me:this}; - this.handle_steps(); - this.handle_controls(options.controls); - this.setup_events(app); - tc.util.dump(this.options); - if(this.options.use_hashchange && this.options.allow_hash_override_onload){ - this.set_address(window.location.hash.substring(1,window.location.hash.length)); - } else { - if(this.options.first_step){ - this.show_step(this.options.first_step); - //if(this.options.name){ - // window.location.hash = this.options.name+','+this.options.first_step; - //} else { - // window.location.hash = this.options.first_step; - //} - } - } - - this.current_hash = null; -}; - -tc.merlin.prototype.setup_events = function(app){ - tc.util.log('tc.merlin.setup_events'); - if (this.options.use_hashchange) { - tc.jQ(window) - .unbind('hashchange',this.event_data,this.handlers.hashchange) - .bind('hashchange',this.event_data,this.handlers.hashchange); - } - if(this.dom){ - this.dom.find('a.step_link').unbind('click').bind('click',this.event_data,this.handlers.a_click); - this.dom.bind('merlin-step-valid',this.event_data,this.handlers.valid); - this.dom.bind('merlin-step-invalid',this.event_data,this.handlers.invalid); - } - if(this.options.back_button){ - this.options.back_button.unbind('click').bind('click',this.event_data,this.handlers.prev_step); - } - if(this.options.next_button){ - this.options.next_button.addClass('disabled'); - this.options.next_button.unbind('click').bind('click',this.event_data,this.handlers.next_step); - } -}; - -tc.merlin.prototype.deallocate_magic = function() { - if (this.options.use_hashchange) { - tc.jQ(window).unbind('hashchange', this.handlers.hashchange); - } - if (this.dom) { - this.dom.find('a.step_link').unbind('click', this.handlers.a_click); - this.dom.unbind('merlin-step-valid', this.handlers.valid); - this.dom.unbind('merlin-step-invalid', this.handlers.invalid); - } - if (this.options.back_button) { - this.options.back_button.unbind('click', this.handlers.prev_step); - } - if (this.options.next_button) { - this.options.next_button.unbind('click', this.handlers.next_step); - } -}; - -tc.merlin.prototype.handle_controls = function(controls){ - tc.util.log('tc.merlin.handle_controls'); - if(this.options.progress_element){ - this.options.progress_element.find('a.indicator').bind('click',this.event_data,this.handlers.indicator_click); - } - if(this.options.error_indicator){ - this.options.error_indicator.html(''); - } -}; - -tc.merlin.prototype.handle_steps = function(){ - tc.util.log('tc.merlin.handle_steps'); - if(this.options.magic){ - this.magic = this.magic_spell(); - } - var i; - for(i in this.options.steps){ - if(this.options.steps[i].selector && this.dom){ - this.options.steps[i].dom = this.dom.find(this.options.steps[i].selector); - } - } -}; -/* Magic!! - __________________ - .-' \ _.-''-._ / '-. - .-/\ .'. .'. /\-. - _'/ \.' '. .' './ \'_ -:======:======::======:======: - '. '. \ '' / .' .' - '. . \ : : / . .' - '.' \ ' ' / '.' - ': \: :/ :' - '. \ / .' - '.\ /.' - '\/' -*/ -tc.merlin.prototype.magic_spell = function(){ - tc.util.log('tc.merlin.magic_spell'); - var i, magic_dust; - tc.util.dump(this.options); - tc.util.dump(this.dom); - tc.util.dump(this.options.steps); - - magic_dust = ({ - n_items:0, - overall_width:0, - page_width:0, - item_metadata:{ - max_width:0, - min_width:100000, - max_height:0, - min_height:100000, - marginLeft:0 - }, - $items:[], - init:function(merlin){ - tc.util.log('tc.merlin.magic_spell[magic_dust].init'); - this.merlin = merlin; - - for(i in this.merlin.options.steps){ - this.merlin.options.steps[i].magic_dom = this.merlin.dom.children().filter(this.merlin.options.steps[i].selector); - if(this.merlin.options.steps[i].magic_dom.length){ - this.$items.push(this.merlin.options.steps[i].magic_dom.get(0)); - - if(this.merlin.options.steps[i].magic_dom.outerWidth() < this.item_metadata.min_width){ - this.item_metadata.min_width = this.merlin.options.steps[i].magic_dom.outerWidth(); - } - if(this.merlin.options.steps[i].magic_dom.outerWidth() > this.item_metadata.max_width){ - this.item_metadata.max_width = this.merlin.options.steps[i].magic_dom.outerWidth(); - } - - if(this.merlin.options.steps[i].magic_dom.outerHeight() < this.item_metadata.min_height){ - this.item_metadata.min_height = this.merlin.options.steps[i].magic_dom.outerHeight(); - } - if(this.merlin.options.steps[i].magic_dom.outerHeight() > this.item_metadata.max_height){ - this.item_metadata.max_height = this.merlin.options.steps[i].magic_dom.outerHeight(); - } - } - } - - this.n_items = this.$items.length; - this.$items = tc.jQ(this.$items); - this.page_width = tc.jQ(window).width(); - this.overall_width = (this.page_width * this.n_items); - this.item_metadata.marginLeft = (this.page_width - this.item_metadata.max_width)/2 - - this.merlin.dom.css({ - 'width':this.overall_width + 'px', - 'height':this.item_metadata.max_height + 'px' - //'marginLeft':-1 * this.item_metadata.marginLeft - }); - this.$items.show().css({ - 'float':'left', - 'clear':'none', - 'width':this.item_metadata.max_width+'px', - 'marginLeft':this.item_metadata.marginLeft - }).removeClass('clearfix'); - - return this; - }, - resize_handler:function(e){ - tc.util.log('tc.merlin.magic_spell[magic_dust].resize_handler'); - - }, - show_step:function(step){ - tc.util.log('tc.merlin.magic_spell[magic_dust].show_step'); - if(!step.magic_dom){ - return; - } - tc.util.dump(step.magic_dom); - tc.util.dump(step.magic_dom.position().left); - tc.util.dump(this.item_metadata.marginLeft); - - tc.util.dump( (-1 * this.item_metadata.marginLeft) - ( step.magic_dom.position().left ) ); - - this.merlin.dom.css({ - //'marginLeft': ((-1 * this.item_metadata.marginLeft) - ( step.magic_dom.position().left )) + 'px' - 'marginLeft': (( step.magic_dom.position().left )) + 'px' - }); - - - } - }).init(this); - - tc.util.dump('----'); - tc.util.dump('----'); - tc.util.dump(magic_dust); - tc.util.dump('----'); - tc.util.dump('----'); - - return magic_dust; -}; -/* ** * * end magic * * ** */ - -tc.merlin.prototype.show_step = function(step,force){ - tc.util.log('tc.merlin.show_step['+step+']'); - var i, j, temp_e_data; - - tc.util.dump(step); - - if(this.current_step && !force){ - //this.current_step.dom.find('input, textarea').unbind('keyup change'); - - tc.util.dump(step); - tc.util.dump(this.current_step.step_name); - - if(step == this.current_step.step_name){ - if(!this.current_step.dom.filter(':visible').length){ - this.current_step.dom.show(); - } - return; - } - if(this.current_step){ - if(tc.jQ.isFunction(this.current_step.finish)){ - this.current_step.finish(this,this.current_step.dom); - //if(this.current_step.finish(this,this.current_step.dom) === false){ - // return; - //}; - } - } - } - if(force && this.current_step){ - if(tc.jQ.isFunction(this.current_step.finish)){ - this.current_step.finish(this,this.current_step.dom); - //if(this.current_step.finish(this,this.current_step.dom) === false){ - // return; - //}; - } - } - - if(!this.options.steps[step]){ - return; - } - - this.options.steps[step].step_name = step; - if(this.current_step && this.current_step.use_for_history){ - this.options.steps[step].prev_step = this.current_step.step_name; - } else if(this.current_step){ - this.options.steps[step].prev_step = this.current_step.prev_step; - } - this.current_step = this.options.steps[step]; - if(this.options.next_button){ - this.options.next_button.removeClass('disabled'); - } - if(this.current_step.progress_selector){ - if(this.options.progress_element){ - this.options.progress_element.find(this.current_step.progress_selector) - .addClass('cur') - .attr('href','#'+this.current_step.step_name) - .nextAll().removeClass('cur').attr('href','#'); - } - } - if(this.current_step.title && this.options.title){ - this.options.title.html(this.current_step.title); - } - if(this.current_step.sub_title && this.options.sub_title){ - this.options.sub_title.html(this.current_step.sub_title); - } - if(tc.jQ.isFunction(this.current_step)){ - this.current_step(this); - return; - } - - if(tc.jQ.isFunction(this.current_step.transition)){ - this.current_step.transition(this); - } else if(this.magic){ - this.magic.show_step(this.current_step); - } else if(this.dom && !this.magic){ - this.dom.find('.step').hide(); - this.dom.find(this.current_step.selector).show(); - } - - if(this.current_step.inputs && !this.current_step.has_been_initialized){ - for(i in this.current_step.inputs){ - temp_e_data = tc.jQ.extend({},this.event_data,{input:this.current_step.inputs[i]}); - if(!this.current_step.inputs[i].dom && this.current_step.inputs[i].selector){ - this.current_step.inputs[i].dom = this.current_step.dom.find(this.current_step.inputs[i].selector); - if(!this.current_step.inputs[i].dom.length){ - tc.util.dump(this.current_step.inputs[i].selector); - } - } - if(this.current_step.inputs[i].counter && !this.current_step.inputs[i].counter.dom){ - this.current_step.inputs[i].counter.dom = this.current_step.dom.find(this.current_step.inputs[i].counter.selector) - this.current_step.inputs[i].counter.dom.text('0/'+this.current_step.inputs[i].counter.limit); - } - this.current_step.inputs[i].dom - .bind('focus',temp_e_data,this.handlers.focus) - .bind('keyup change',temp_e_data,this.handlers.keypress) - .bind('blur',temp_e_data,this.handlers.blur) - .data({merlin:this,input:this.current_step.inputs[i]}) - .each(function(i,j){ - var $j; - $j = tc.jQ(j); - if($j.data().input.hint || ($j.data().input.hint === "")){ - j.value = $j.data().input.hint; - } - }); - if(this.current_step.inputs[i].handlers){ - for(j in this.current_step.inputs[i].handlers){ - this.current_step.inputs[i].dom.bind(j,this.event_data,this.current_step.inputs[i].handlers[j]); - } - } - if(this.current_step.inputs[i].focus_first){ - //this.current_step.inputs[i].dom.focus(); - } - } - } - - if (this.options.use_hashchange && !this.current_step.supress_hash) { - if(this.options.name){ - window.location.hash = this.options.name+','+step; - } else { - window.location.hash = step; - } - } - - if(tc.jQ.isFunction(this.current_step.init)){ - this.current_step.init(this,this.current_step.dom); - } - this.validate(false); - this.current_step.has_been_initialized = true; -}; - -tc.merlin.prototype.set_address = function(hash) { - tc.util.log("tc.merlin.set_address"); - var hash_buffer, force; - hash_buffer = hash.split(","); - if (this.options.name) { - if (hash_buffer[0] !== this.options.name) { - this.current_hash = null; - return; - } - hash = hash_buffer[1]; - force = true; - } else if (this.current_hash !== hash) { - force = false; - } - this.current_hash = hash; - this.show_step(this.current_hash, force); -}; - -tc.merlin.prototype.validate = function(on_submit){ - tc.util.log('tc.merlin.validate1'); - var i, valid, temp_valid; - if(!this.current_step.inputs){ - return true; - } - valid = true; - this.current_step.errors = []; - for(i in this.current_step.inputs){ - if(!this.current_step.inputs[i].validators){ - continue; - } - if(on_submit){ - this.current_step.inputs[i].dom.addClass('has-been-focused has-attempted-submit'); - if(this.current_step.inputs[i].hint && (this.current_step.inputs[i].dom.val() == this.current_step.inputs[i].hint)){ - this.current_step.inputs[i].dom.val(''); - } - } - if(tc.jQ.isFunction(this.current_step.inputs[i].validators)){ - temp_valid = this.current_step.inputs[i].validators(this,this.current_step.inputs[i].dom,this.current_step); - } else { - temp_valid = tc.validate(this.current_step.inputs[i].dom,this.current_step.inputs[i].validators); - } - - - if(!temp_valid.valid){ - tc.util.dump(temp_valid); - valid = false; - if(this.current_step.inputs[i].counter && this.current_step.inputs[i].dom.hasClass('has-been-focused')){ - this.current_step.inputs[i].counter.dom.addClass('invalid').removeClass('valid'); - } - } else{ - if(this.current_step.inputs[i].counter && this.current_step.inputs[i].counter.dom.hasClass('invalid')){ - this.current_step.inputs[i].counter.dom.addClass('valid').removeClass('invalid'); - } - } - } - if(valid){ - if(this.dom){ - this.dom.trigger('merlin-step-valid',{ - step:this.current_step - }); - } - this.current_step.dom.removeClass('invalid').addClass('valid'); - return true; - } else { - if(this.dom){ - this.dom.trigger('merlin-step-invalid',{ - step:this.current_step - }); - } - this.current_step.dom.removeClass('valid').addClass('invalid'); - return false; - } -}; - -tc.merlin.prototype.handlers = { - hashchange:function(e,d){ - tc.util.log('tc.merlin.handlers.hashchange['+window.location.hash+']'); - e.data.me.set_address(window.location.hash.substring(1,window.location.hash.length)); - }, - indicator_click:function(e,d){ - tc.util.log('tc.merlin.handlers.indicator_click'); - if(tc.jQ(e.target).parent().attr('href') == '#'){ e.preventDefault(); } - }, - a_click:function(e,d){ - tc.util.log('tc.merlin.handlers.a_click'); - }, - prev_step:function(e,d){ - tc.util.log('tc.merlin.handlers.prev_step'); - e.preventDefault(); - if(e.data.me.current_step && e.data.me.current_step.prev_step){ - if (e.data.me.options.use_hashchange) { - window.location.hash = e.data.me.current_step.prev_step; - } else { - e.data.me.show_step( e.data.me.current_step.prev_step ); - } - } - }, - next_step:function(e,d){ - tc.util.log('tc.merlin.handlers.next_step'); - var valid; - e.preventDefault(); - valid = e.data.me.validate(true); - if(!valid){ - if(e.data.me.options.error_indicator){ - e.data.me.options.error_indicator.html('Oops! Please fill in the fields marked in red.').show(); - } - return; - } else { - if(e.data.me.options.error_indicator){ - e.data.me.options.error_indicator.hide(); - } - } - if(e.target.className.indexOf('disabled') > 0){ - return; - } - if(e.data.me.current_step && e.data.me.current_step.next_step){ - - e.data.me.show_step( e.data.me.current_step.next_step ); - - //if (e.data.me.options.use_hashchange) { - // if(e.data.me.options.name){ - // window.location.hash = e.data.me.options.name+','+e.data.me.current_step.next_step; - // } else { - // window.location.hash = e.data.me.current_step.next_step; - // } - //} else { - // e.data.me.show_step( e.data.me.current_step.next_step ); - //} - } - }, - focus:function(e,d){ - var $t; - if(e.target.className.indexOf('has-been-focused') == -1){ - $t = tc.jQ(e.target); - $t.addClass('has-been-focused').removeClass('valid invalid'); //.filter('[type=text], textarea').val(''); - if (e.target.nodeName == "TEXTAREA" || (e.target.nodeName == "INPUT" && ($t.attr("type") == "text"))) { - if ($t.data().input.hint || $t.data().input.hint === "") { - $t.val(""); - } - } - } - }, - keypress:function(e,d){ - e.data.me.validate(false); - if(e.which == 13 && e.target.nodeName != 'TEXTAREA'){ - if(e.data.me.options.next_button && e.data.me.options.next_button.hasClass('enabled')){ - e.data.me.options.next_button.click(); - } - } - if(e.data.input.counter && e.data.input.counter.dom){ - e.data.input.counter.dom.text(e.data.input.dom.val().length+'/'+e.data.input.counter.limit); - } - }, - blur:function(e,d){ - var $t; - $t = tc.jQ(e.target); - if(!e.target.value.length){ - tc.jQ(e.target).removeClass('has-been-focused'); - if($t.data().input.hint || ($t.data().input.hint === "")){ - $t.val($t.data().input.hint); - } - } - }, - valid:function(e,d){ - tc.util.log('tc.merlin.handlers.valid'); - if(e.data.me.options.next_button){ - e.data.me.options.next_button.removeClass('disabled').addClass('enabled'); - } - if(e.data.me.options.error_indicator){ - e.data.me.options.error_indicator.hide(); - } - }, - invalid:function(e,d){ - tc.util.log('tc.merlin.handlers.invalid'); - if(e.data.me.options.next_button){ - e.data.me.options.next_button.removeClass('enabled').addClass('disabled'); - } - } -}; - diff --git a/lib/tc.seed.js b/lib/tc.seed.js deleted file mode 100644 index 905a499..0000000 --- a/lib/tc.seed.js +++ /dev/null @@ -1,306 +0,0 @@ -/* ============================================================================ - - >4SESz., _, ,gSEE2zx.,_ .azx ,w. -@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ -\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. - ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ - :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 - {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, - \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F - ,ss :EE7 ;EEF L,szzw.. ,., `` - \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL - ```` `` JEEE. `"45EEEhw.,,,] - -From 2010 till ∞ -typecode-js v 0.1 -*/ - -(function(window) { - - var NI = {}, - fakeConsole; - - NI.ex = { - - checkStr: function(s) { - var t = typeof s; - if (t === "string") { return true; } - //throw new TypeError("Expected string, but found "+ t +" instead"); - console.error("Expected string, but found '"+ String(t) +"' instead"); - }, - - checkFn: function(fn) { - if ($.isFunction(fn)) { return true; } - //throw new TypeError("Expected function, but found "+ typeof fn +" instead"); - console.error("Expected function, but found '"+ typeof fn +"' instead"); - }, - - checkJQ: function(o) { - if (o instanceof $) { return true; } - //throw new TypeError("Expected jQuery object, but found"+ typeof o +" instead"); - console.error("Expected jQuery object, but found '"+ typeof o +"' instead"); - }, - - checkJQNode: function($e, type) { - NI.ex.checkJQ($e); - type = type.toLowerCase(); - if ($e.length === 1) { - if ($e[0].nodeName.toLowerCase() === type) { - return true; - } - } - throw new TypeError("Expected jQuery object holding single "+ type +" element"); - }, - - typeOf: function(v) { - var s = typeof v; - if (s === "object") { - if (v) { - if (typeof v.length === "number" && - !(v.propertyIsEnumerable("length")) && - typeof v.splice === "function") { - s = "array"; - } - } else { - s = "null"; - } - } - return s; - }, - - isEmpty: function(v) { - NI.ex.checkStr(v); - return $.trim(v) ? - false : true; - }, - - isHeadless: function($e) { - var node = $e[0]; - if (!node.parentNode) { - return true; - } - if (node.parentNode === NI.co.nodeTypes.DOCUMENT_NODE) { - return true; - } - return false; - } - }; - - NI.app = { - - bootstrap: function(app, options) { - var o; - o = $.extend({ - debug: false - }, options); - - app.console = NI.app.getConsole(o.debug); - app.classes = {}; - app.runtime = {}; - NI.fn.eventPool(app); - - app.console.info("::::::::::::: Starting application :::::::::::::"); - app.console.info((app.name || "") + " " + (app.version || "")); - app.console.info("::::::::::::::::::::::::::::::::::::::::::::::::"); - - return app; - }, - - getConsole: function(debug) { - if (debug && typeof window.console !== "undefined") { - return window.console; - } - if (!fakeConsole) { - fakeConsole = {}; - $.each(("assert,count,debug,dir,dirxml,error,exception,\ - group,groupCollapsed,groupEnd,info,log,markTimeline,\ - profile,profileEnd,time,timeEnd,trace,warn").split(","), function() { - fakeConsole[this] = $.noop; - }); - } - return fakeConsole; - }, - - /** - * Initialize environment-specific components - * from an array of "feature" objects, each one - * of the form { feature: "foo", options: {} }, - * which invokes app[foo](options) - */ - initAppFeatures: function(app, env) { - if (!app.runtime) { - app.runtime = {}; - } - if ($.isArray(env.features)) { - $.each(env.features, function(i, o) { - if (app.runtime[o.feature]) { - NI.app.getConsole(true).warn(o.feature +" already initialized"); - } else if ($.isFunction(app[o.feature])) { - app.runtime[o.feature] = app[o.feature].call(app, o.options); - } - }); - } - } - }; - - NI.fn = { - - // via http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/ - loadScript: function(url, callback) { - var script = window.document.createElement("script"); - script.type = "text/javascript"; - if (script.readyState) { - script.onreadystatechange = function() { - if (script.readyState == "loaded" || script.readyState == "complete") { - script.onreadystatechange = null; - if ($.isFunction(callback)) { - callback(); - } - } - }; - } else { - script.onload = function() { - if ($.isFunction(callback)) { - callback(); - } - }; - } - script.src = url; - window.document.getElementsByTagName("head")[0].appendChild(script); - }, - - extend: function(sub, base) { - var F = function() {}; - F.prototype = base.prototype; - sub.prototype = new F(); - sub.prototype.constructor = sub; - sub.base = base.prototype; - if (base.prototype.constructor === Object.prototype.constructor) { - base.prototype.constructor = base; - } - }, - - clone: function(o) { - var F = function() {}; - F.prototype = o; - return new F(); - }, - - augment: function(dest, src) { - var i; - if (arguments[2]) { - for (i = 2; i < arguments.length; i += 1) { - dest.prototype[arguments[i]] = src.prototype[arguments[i]]; - } - } else { - for (i in src.prototype) { - if (!dest.prototype[i]) { - dest.prototype[i] = src.prototype[i]; - } - } - } - }, - - eventPool: function(target) { - var events = $({}); - target.bind = function() { - events.bind.apply(events, arguments); - }; - target.unbind = function() { - events.unbind.apply(events, arguments); - }; - target.trigger = function() { - events.trigger.apply(events, arguments); - }; - return target; - }, - - guid: function(prefix) { - return (prefix || "obj_")+ new Date().getTime(); - }, - - randomElement: function(array) { - if (NI.ex.typeOf(array) === "array" && array.length > 0) { - return array[window.Math.floor(NI.math.random(array.length))]; - } - } - }; - - NI.co = { - - keyboard: { - - BACKSPACE: 8, - CAPS_LOCK: 20, - COMMA: 188, - CONTROL: 17, - DELETE: 46, - DOWN: 40, - END: 35, - ENTER: 13, - ESCAPE: 27, - HOME: 36, - INSERT: 45, - LEFT: 37, - NUMPAD_ADD: 107, - NUMPAD_DECIMAL: 110, - NUMPAD_DIVIDE: 111, - NUMPAD_ENTER: 108, - NUMPAD_MULTIPLY: 106, - NUMPAD_SUBTRACT: 109, - PAGE_DOWN: 34, - PAGE_UP: 33, - PERIOD: 190, - RIGHT: 39, - SHIFT: 16, - SPACE: 32, - TAB: 9, - UP: 38 - }, - - nodeTypes: { - - ELEMENT_NODE: 1, - ATTRIBUTE_NODE: 2, - TEXT_NODE: 3, - CDATA_SECTION_NODE: 4, - ENTITY_REFERENCE_NODE: 5, - ENTITY_NODE: 6, - PROCESSING_INSTRUCTION_NODE: 7, - COMMENT_NODE: 8, - DOCUMENT_NODE: 9, - DOCUMENT_TYPE_NODE: 10, - DOCUMENT_FRAGMENT_NODE: 11, - NOTATION_NODE: 12 - }, - - directions: { - UP: 0, - RIGHT: 1, - DOWN: 2, - LEFT: 3 - } - }; - - NI.math = { - - random: function() { - if (arguments.length === 0) { - return window.Math.random(); - } else if (arguments.length === 1) { - return window.Math.random()*arguments[0]; - } - return window.Math.random()*(arguments[1] - arguments[0]) + arguments[0]; - }, - - round: function(n, places) { - var p = window.Math.pow(10, places); - return window.Math.round(n*p)/p; - } - }; - -//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - - window.NI = NI; - -}(this)); \ No newline at end of file diff --git a/lib/tc.validation.js b/lib/validation.js similarity index 94% rename from lib/tc.validation.js rename to lib/validation.js index cab9555..62f97dd 100644 --- a/lib/tc.validation.js +++ b/lib/validation.js @@ -15,16 +15,16 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI, - console = NI.app.getConsole(true); + var window = this, + NI = window.NI; + //console = NI.fn.getConsole(true); //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // regular expressions var regex = { - //email: /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i, email: /^[a-zA-Z0-9\+._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/, url: /^((ht|f)tps?:\/\/)?[a-zA-Z0-9-\.]+\.[a-zA-Z]{2,4}\/?([^\s<>\%"\,\{\}\\|\\\^\[\]`]+)?$/, @@ -92,9 +92,9 @@ typecode-js v 0.1 date = new Date(); month = (month*1) - 1; date.setFullYear(year, month, day); - if (date.getMonth() == month && - date.getDate() == day && - date.getFullYear() == year) { + if (date.getMonth() == month && + date.getDate() == day && + date.getFullYear() == year) { return true; } } catch(err) { @@ -128,7 +128,7 @@ typecode-js v 0.1 }; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -// field validation +// field validation //begin ValidationToken @@ -155,12 +155,7 @@ typecode-js v 0.1 //begin validate function validate(field, validators) { - var value, - validators, - token, - errors, - type, - master; + var value, token, errors, type, master; master = field.data("master"); @@ -288,7 +283,7 @@ typecode-js v 0.1 break; case "hex_color": if (value && !is.hex_color(value)){ - token.addError(error_messages["hex_color"]); + token.addError(error_messages["hex_color"]); } break; default: @@ -502,4 +497,4 @@ typecode-js v 0.1 NI.ValidationManager = ValidationManager; NI.is = $.extend(NI.is || {}, is); -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/requirepaths.js b/requirepaths.js new file mode 100644 index 0000000..93278b4 --- /dev/null +++ b/requirepaths.js @@ -0,0 +1,48 @@ +require = { + paths: { + 'jquery': 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min', + 'jquery_migrate': 'thirdparty/jquery-migrate-1.2.1.min', + 'hashchange': 'thirdparty/jquery-migrate-1.2.1.min', + + 'NIanim': 'lib/anim', + 'NIAnimator': 'lib/Animator', + 'NIApp': 'lib/App', + 'NIBrowserDetection': 'lib/BrowserDetection', + 'NICarousel': 'lib/Carousel', + 'NIcolor': 'lib/color', + 'NICookies': 'lib/Cookies', + 'NIFavicon': 'lib/Favicon', + 'NIfeaturedetection': 'lib/featuredetection', + + 'NIfield': 'lib/field', + 'NIfield.Autocomplete': 'lib/field/Autocomplete', + 'NIfield.Counter': 'lib/field/Counter', + 'NIfield.Dropdown': 'lib/field/Dropdown', + 'NIfield.Hint': 'lib/field/Hint', + 'NIfield.SimpleTooltip': 'lib/field/SimpleTooltip', + 'NIfield.std': 'lib/field/std', + 'NIfield.Validator': 'lib/field/Validator', + + 'NIflippanel': 'lib/flippanel', + 'NIfullscreen': 'lib/fullscreen', + 'NIGoogleAnalytics': 'lib/GoogleAnalytics', + 'NIgoogleanalyticsheader': 'lib/googleanalyticsheader', + + 'NIMerlin': 'lib/Merlin', + 'NIMerlin.Autosave': 'lib/merlin/MerlinAutosave', + 'NIMerlin.CSRF': 'lib/merlin/MerlinCSRF', + 'NIMerlin.Data': 'lib/merlin/MerlinData', + + 'NIOverlay': 'lib/Overlay', + 'NIseed': 'lib/seed', + 'NISocialRotator': 'lib/SocialRotator', + 'NITooltip': 'lib/Tooltip', + 'NIvalidation': 'lib/validation', + + 'NIPushstateHelper': 'lib/PushstateHelper' + }, + shim: { + jquery_migrate: ['jquery'], + hashchange: ['jquery', 'jquery_migrate'] + } +}; \ No newline at end of file diff --git a/styleguide.md b/styleguide.md new file mode 100644 index 0000000..9600138 --- /dev/null +++ b/styleguide.md @@ -0,0 +1,23 @@ + >4SESz., _, ,gSEE2zx.,_ .azx ,w. +@Sh. "QEE3. JEE3. &ss `*4EEEEE2x.,_ "EEV ,aS5^;dEEEE2x., VEEF _ +\E2`_,gF4EEEx.?jF EE5L `*4EEEEE2zpn..ZEEF ;sz. `*EEESzw.w* '|EE. + ,dEEF `"?j] _,_ ,_ _, _,. L.EEEF !EEF _,, `"`` EE7 ,,_ + :EEE7 ,ws,`|EEL`JEEL`JEE)`JEEL zE5` E3. / [EE3 ,w. zE2` Ek .zE5^JZE3.,6EF [3 + {EEE. VEE7.EE2 AE3. EEV ZEEL{EEL ws. ; [EE1 EEEt{E3. JEELEE3. JE5LJEEF ,w, + \EEk,,>^ JEEL,@EEF ZE5L,ZE5^ "Q3. V2`. \EEk,,J' "Q[ yE2^ VE[_zEE[,"QEL V5F + ,ss :EE7 ;EEF L,szzw.. ,., `` + \E5.,E5F EE1. /; ``*4EEEZhw._ EEEL + ```` `` JEEE. `"45EEEhw.,,,] + +From 2010 till ∞ + +Javascript Code Style Guide +=========================== + +Okay, this is not a big deal or anything, but for the sake of code consistency, let's have some guidelines. When adding new code to a file, the new code should stay consistent with what's already there (even if that breaks these following rules). + +* Spaces, not tabs. 4 spaces per indentation. +* No restriction for line length, but suggested ballpark is 100 characters. +* Use under_scores for variable names (including functions). Use hy-phens for CSS class names. +* Constructor functions (i.e. intended to be used with new operator) are an exception to the underscore rule. They are CamelCase and begin with a Capital letter. +* Prefer single quotes (i.e. first use single quotes, then double when needed). \ No newline at end of file diff --git a/thirdparty/jquery-migrate-1.2.1.min.js b/thirdparty/jquery-migrate-1.2.1.min.js new file mode 100644 index 0000000..62149c2 --- /dev/null +++ b/thirdparty/jquery-migrate-1.2.1.min.js @@ -0,0 +1,2 @@ +/*! jQuery Migrate v1.2.1 | (c) 2005, 2013 jQuery Foundation, Inc. and other contributors | jquery.org/license */ +jQuery.migrateMute===void 0&&(jQuery.migrateMute=!0),function(e,t,n){function r(n){var r=t.console;i[n]||(i[n]=!0,e.migrateWarnings.push(n),r&&r.warn&&!e.migrateMute&&(r.warn("JQMIGRATE: "+n),e.migrateTrace&&r.trace&&r.trace()))}function a(t,a,i,o){if(Object.defineProperty)try{return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){return r(o),i},set:function(e){r(o),i=e}}),n}catch(s){}e._definePropertyBroken=!0,t[a]=i}var i={};e.migrateWarnings=[],!e.migrateMute&&t.console&&t.console.log&&t.console.log("JQMIGRATE: Logging is active"),e.migrateTrace===n&&(e.migrateTrace=!0),e.migrateReset=function(){i={},e.migrateWarnings.length=0},"BackCompat"===document.compatMode&&r("jQuery is not compatible with Quirks Mode");var o=e("",{size:1}).attr("size")&&e.attrFn,s=e.attr,u=e.attrHooks.value&&e.attrHooks.value.get||function(){return null},c=e.attrHooks.value&&e.attrHooks.value.set||function(){return n},l=/^(?:input|button)$/i,d=/^[238]$/,p=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,f=/^(?:checked|selected)$/i;a(e,"attrFn",o||{},"jQuery.attrFn is deprecated"),e.attr=function(t,a,i,u){var c=a.toLowerCase(),g=t&&t.nodeType;return u&&(4>s.length&&r("jQuery.fn.attr( props, pass ) is deprecated"),t&&!d.test(g)&&(o?a in o:e.isFunction(e.fn[a])))?e(t)[a](i):("type"===a&&i!==n&&l.test(t.nodeName)&&t.parentNode&&r("Can't change the 'type' of an input or button in IE 6/7/8"),!e.attrHooks[c]&&p.test(c)&&(e.attrHooks[c]={get:function(t,r){var a,i=e.prop(t,r);return i===!0||"boolean"!=typeof i&&(a=t.getAttributeNode(r))&&a.nodeValue!==!1?r.toLowerCase():n},set:function(t,n,r){var a;return n===!1?e.removeAttr(t,r):(a=e.propFix[r]||r,a in t&&(t[a]=!0),t.setAttribute(r,r.toLowerCase())),r}},f.test(c)&&r("jQuery.fn.attr('"+c+"') may use property instead of attribute")),s.call(e,t,a,i))},e.attrHooks.value={get:function(e,t){var n=(e.nodeName||"").toLowerCase();return"button"===n?u.apply(this,arguments):("input"!==n&&"option"!==n&&r("jQuery.fn.attr('value') no longer gets properties"),t in e?e.value:null)},set:function(e,t){var a=(e.nodeName||"").toLowerCase();return"button"===a?c.apply(this,arguments):("input"!==a&&"option"!==a&&r("jQuery.fn.attr('value', val) no longer sets properties"),e.value=t,n)}};var g,h,v=e.fn.init,m=e.parseJSON,y=/^([^<]*)(<[\w\W]+>)([^>]*)$/;e.fn.init=function(t,n,a){var i;return t&&"string"==typeof t&&!e.isPlainObject(n)&&(i=y.exec(e.trim(t)))&&i[0]&&("<"!==t.charAt(0)&&r("$(html) HTML strings must start with '<' character"),i[3]&&r("$(html) HTML text after last tag is ignored"),"#"===i[0].charAt(0)&&(r("HTML string cannot start with a '#' character"),e.error("JQMIGRATE: Invalid selector string (XSS)")),n&&n.context&&(n=n.context),e.parseHTML)?v.call(this,e.parseHTML(i[2],n,!0),n,a):v.apply(this,arguments)},e.fn.init.prototype=e.fn,e.parseJSON=function(e){return e||null===e?m.apply(this,arguments):(r("jQuery.parseJSON requires a valid JSON string"),null)},e.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e.browser||(g=e.uaMatch(navigator.userAgent),h={},g.browser&&(h[g.browser]=!0,h.version=g.version),h.chrome?h.webkit=!0:h.webkit&&(h.safari=!0),e.browser=h),a(e,"browser",e.browser,"jQuery.browser is deprecated"),e.sub=function(){function t(e,n){return new t.fn.init(e,n)}e.extend(!0,t,this),t.superclass=this,t.fn=t.prototype=this(),t.fn.constructor=t,t.sub=this.sub,t.fn.init=function(r,a){return a&&a instanceof e&&!(a instanceof t)&&(a=t(a)),e.fn.init.call(this,r,a,n)},t.fn.init.prototype=t.fn;var n=t(document);return r("jQuery.sub() is deprecated"),t},e.ajaxSetup({converters:{"text json":e.parseJSON}});var b=e.fn.data;e.fn.data=function(t){var a,i,o=this[0];return!o||"events"!==t||1!==arguments.length||(a=e.data(o,t),i=e._data(o,t),a!==n&&a!==i||i===n)?b.apply(this,arguments):(r("Use of jQuery.fn.data('events') is deprecated"),i)};var j=/\/(java|ecma)script/i,w=e.fn.andSelf||e.fn.addBack;e.fn.andSelf=function(){return r("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"),w.apply(this,arguments)},e.clean||(e.clean=function(t,a,i,o){a=a||document,a=!a.nodeType&&a[0]||a,a=a.ownerDocument||a,r("jQuery.clean() is deprecated");var s,u,c,l,d=[];if(e.merge(d,e.buildFragment(t,a).childNodes),i)for(c=function(e){return!e.type||j.test(e.type)?o?o.push(e.parentNode?e.parentNode.removeChild(e):e):i.appendChild(e):n},s=0;null!=(u=d[s]);s++)e.nodeName(u,"script")&&c(u)||(i.appendChild(u),u.getElementsByTagName!==n&&(l=e.grep(e.merge([],u.getElementsByTagName("script")),c),d.splice.apply(d,[s+1,0].concat(l)),s+=l.length));return d});var Q=e.event.add,x=e.event.remove,k=e.event.trigger,N=e.fn.toggle,T=e.fn.live,M=e.fn.die,S="ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",C=RegExp("\\b(?:"+S+")\\b"),H=/(?:^|\s)hover(\.\S+|)\b/,A=function(t){return"string"!=typeof t||e.event.special.hover?t:(H.test(t)&&r("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'"),t&&t.replace(H,"mouseenter$1 mouseleave$1"))};e.event.props&&"attrChange"!==e.event.props[0]&&e.event.props.unshift("attrChange","attrName","relatedNode","srcElement"),e.event.dispatch&&a(e.event,"handle",e.event.dispatch,"jQuery.event.handle is undocumented and deprecated"),e.event.add=function(e,t,n,a,i){e!==document&&C.test(t)&&r("AJAX events should be attached to document: "+t),Q.call(this,e,A(t||""),n,a,i)},e.event.remove=function(e,t,n,r,a){x.call(this,e,A(t)||"",n,r,a)},e.fn.error=function(){var e=Array.prototype.slice.call(arguments,0);return r("jQuery.fn.error() is deprecated"),e.splice(0,0,"error"),arguments.length?this.bind.apply(this,e):(this.triggerHandler.apply(this,e),this)},e.fn.toggle=function(t,n){if(!e.isFunction(t)||!e.isFunction(n))return N.apply(this,arguments);r("jQuery.fn.toggle(handler, handler...) is deprecated");var a=arguments,i=t.guid||e.guid++,o=0,s=function(n){var r=(e._data(this,"lastToggle"+t.guid)||0)%o;return e._data(this,"lastToggle"+t.guid,r+1),n.preventDefault(),a[r].apply(this,arguments)||!1};for(s.guid=i;a.length>o;)a[o++].guid=i;return this.click(s)},e.fn.live=function(t,n,a){return r("jQuery.fn.live() is deprecated"),T?T.apply(this,arguments):(e(this.context).on(t,this.selector,n,a),this)},e.fn.die=function(t,n){return r("jQuery.fn.die() is deprecated"),M?M.apply(this,arguments):(e(this.context).off(t,this.selector||"**",n),this)},e.event.trigger=function(e,t,n,a){return n||C.test(e)||r("Global events are undocumented and deprecated"),k.call(this,e,t,n||document,a)},e.each(S.split("|"),function(t,n){e.event.special[n]={setup:function(){var t=this;return t!==document&&(e.event.add(document,n+"."+e.guid,function(){e.event.trigger(n,null,t,!0)}),e._data(this,n,e.guid++)),!1},teardown:function(){return this!==document&&e.event.remove(document,n+"."+e._data(this,n)),!1}}})}(jQuery,window); \ No newline at end of file diff --git a/thirdparty/jquery.ba-hashchange.min.js b/thirdparty/jquery.ba-hashchange.min.js new file mode 100644 index 0000000..3c607ba --- /dev/null +++ b/thirdparty/jquery.ba-hashchange.min.js @@ -0,0 +1,9 @@ +/* + * jQuery hashchange event - v1.3 - 7/21/2010 + * http://benalman.com/projects/jquery-hashchange-plugin/ + * + * Copyright (c) 2010 "Cowboy" Ben Alman + * Dual licensed under the MIT and GPL licenses. + * http://benalman.com/about/license/ + */ +(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('