From 89e50393150f85f7ff539993ddf745ff8470dd8f Mon Sep 17 00:00:00 2001 From: "Andrew Mahon (Type/Code)" Date: Sun, 4 Nov 2012 14:31:46 -0500 Subject: [PATCH 01/83] require.js'd merlin --- lib/tc.merlin.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tc.merlin.js b/lib/tc.merlin.js index 3b3e6c2..55c5cc2 100644 --- a/lib/tc.merlin.js +++ b/lib/tc.merlin.js @@ -15,7 +15,10 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define([ + 'jquery', + 'lib/typecode-js/lib/tc.validation' +], function($) { var NI = window.NI; @@ -469,4 +472,4 @@ typecode-js v 0.1 NI.Merlin = Merlin; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file From 7312bf32ba2d9ad0f210b890819576cbb8e571ae Mon Sep 17 00:00:00 2001 From: "Andrew Mahon (Type/Code)" Date: Tue, 6 Nov 2012 21:26:46 -0500 Subject: [PATCH 02/83] added a lot of require stuff to the library --- lib/field/tc.field.autocomplete.js | 7 +++++-- lib/field/tc.field.counter.js | 9 +++++++-- lib/field/tc.field.dropdown.js | 7 +++++-- lib/field/tc.field.hint.js | 9 +++++++-- lib/field/tc.field.simple_tooltip.js | 9 +++++++-- lib/field/tc.field.std.js | 9 ++++++--- lib/field/tc.field.validator.js | 14 +++++++++----- lib/tc.field.js | 7 +++++-- lib/tc.merlin.js | 7 ++++++- 9 files changed, 57 insertions(+), 21 deletions(-) diff --git a/lib/field/tc.field.autocomplete.js b/lib/field/tc.field.autocomplete.js index 5dfaba2..45402f8 100644 --- a/lib/field/tc.field.autocomplete.js +++ b/lib/field/tc.field.autocomplete.js @@ -18,7 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define([ + 'jquery', + './../tc.field' +], function($) { var NI = window.NI, delegates = {}; @@ -503,4 +506,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/tc.field.counter.js index 78a09b4..a5f182a 100644 --- a/lib/field/tc.field.counter.js +++ b/lib/field/tc.field.counter.js @@ -18,7 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define([ + 'jquery', + './../tc.field' +], function($) { var NI = window.NI; @@ -71,4 +74,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/tc.field.dropdown.js index 366fd3a..fc33c79 100644 --- a/lib/field/tc.field.dropdown.js +++ b/lib/field/tc.field.dropdown.js @@ -18,7 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define([ + 'jquery', + './../tc.field' +], function($) { var NI = window.NI, field = NI.field; @@ -653,4 +656,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/tc.field.hint.js index 13f439c..d25e24e 100644 --- a/lib/field/tc.field.hint.js +++ b/lib/field/tc.field.hint.js @@ -18,7 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define([ + 'jquery', + './../tc.field' +], function($) { var NI = window.NI; @@ -108,4 +111,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/tc.field.simple_tooltip.js index 3d3aeba..8afb9f6 100644 --- a/lib/field/tc.field.simple_tooltip.js +++ b/lib/field/tc.field.simple_tooltip.js @@ -18,7 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define([ + 'jquery', + './../tc.field' +], function($) { var NI = window.NI; @@ -94,4 +97,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.std.js b/lib/field/tc.field.std.js index b77df12..2fcadf5 100644 --- a/lib/field/tc.field.std.js +++ b/lib/field/tc.field.std.js @@ -18,10 +18,13 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define([ + 'jquery', + './../tc.field' +], function($) { var NI = window.NI, - field = NI.field; + field = NI.field; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // standard field type @@ -674,4 +677,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.validator.js b/lib/field/tc.field.validator.js index 89c798e..47c764d 100644 --- a/lib/field/tc.field.validator.js +++ b/lib/field/tc.field.validator.js @@ -18,7 +18,9 @@ typecode-js v 0.1 // Dependencies: // NI.field -(function(window, $) { +define([ + 'jquery' +], function($) { var NI = window.NI, field = NI.field; @@ -190,8 +192,10 @@ typecode-js v 0.1 } - field.extensions.Validator = Validator; - field.extensions.SimpleTooltipValidatorError = SimpleTooltipValidatorError; - field.extensions.ValidatorError = ValidatorError; + //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/tc.field.js b/lib/tc.field.js index f1b89e4..fcd9173 100644 --- a/lib/tc.field.js +++ b/lib/tc.field.js @@ -15,7 +15,9 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define([ + 'jquery' +], function($) { var NI = window.NI, field = { extensions: {} }; @@ -358,4 +360,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/tc.merlin.js b/lib/tc.merlin.js index 55c5cc2..1780c0b 100644 --- a/lib/tc.merlin.js +++ b/lib/tc.merlin.js @@ -17,7 +17,12 @@ typecode-js v 0.1 define([ 'jquery', - 'lib/typecode-js/lib/tc.validation' + 'lib/typecode-js/lib/tc.validation', + 'lib/typecode-js/lib/field/tc.field.validator', + 'lib/typecode-js/lib/field/tc.field.std', + 'lib/typecode-js/lib/field/tc.field.hint', + 'lib/typecode-js/lib/field/tc.field.simple_tooltip', + 'lib/typecode-js/lib/field/tc.field.hint' ], function($) { var NI = window.NI; From 55096b90fab7cab6de94eaa379ec0c0e636b6c79 Mon Sep 17 00:00:00 2001 From: Andrew Mahon Date: Wed, 7 Nov 2012 15:39:35 -0500 Subject: [PATCH 03/83] small changes to enable field validation with require js wrpping --- lib/field/tc.field.validator.js | 19 +++++++++++++------ lib/tc.merlin.js | 1 - 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/field/tc.field.validator.js b/lib/field/tc.field.validator.js index 47c764d..ae20eda 100644 --- a/lib/field/tc.field.validator.js +++ b/lib/field/tc.field.validator.js @@ -19,14 +19,17 @@ typecode-js v 0.1 // NI.field define([ - 'jquery' -], function($) { + 'require', + 'jquery', + 'lib/typecode-js/lib/tc.validation', + 'lib/typecode-js/lib/tc.field' +], function(require, $) { var NI = window.NI, field = NI.field; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - + function Validator(field, options) { var me, o, internal; @@ -42,6 +45,9 @@ define([ internal = { managed_field:null }; + + console.log('Validator'); + console.log(o.manager); if (!o.manager || !(o.manager instanceof NI.ValidationManager)) { o.manager = new NI.ValidationManager({ @@ -192,9 +198,10 @@ define([ } - //field.extensions.Validator = Validator; - //field.extensions.SimpleTooltipValidatorError = SimpleTooltipValidatorError; - //field.extensions.ValidatorError = ValidatorError; + + field.extensions.Validator = Validator; + field.extensions.SimpleTooltipValidatorError = SimpleTooltipValidatorError; + field.extensions.ValidatorError = ValidatorError; return Validator; diff --git a/lib/tc.merlin.js b/lib/tc.merlin.js index 1780c0b..6f66b0b 100644 --- a/lib/tc.merlin.js +++ b/lib/tc.merlin.js @@ -17,7 +17,6 @@ typecode-js v 0.1 define([ 'jquery', - 'lib/typecode-js/lib/tc.validation', 'lib/typecode-js/lib/field/tc.field.validator', 'lib/typecode-js/lib/field/tc.field.std', 'lib/typecode-js/lib/field/tc.field.hint', From 3c6ecd762b74151fd2b8d905f0fedd00dd69c32e Mon Sep 17 00:00:00 2001 From: "Andrew Mahon (Type/Code)" Date: Thu, 8 Nov 2012 16:52:51 -0500 Subject: [PATCH 04/83] some changes to field stuff --- lib/field/tc.field.autocomplete.js | 2 +- lib/field/tc.field.dropdown.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/field/tc.field.autocomplete.js b/lib/field/tc.field.autocomplete.js index 45402f8..7b83c1a 100644 --- a/lib/field/tc.field.autocomplete.js +++ b/lib/field/tc.field.autocomplete.js @@ -20,7 +20,7 @@ typecode-js v 0.1 define([ 'jquery', - './../tc.field' + 'lib/typecode-js/lib/tc.field' ], function($) { var NI = window.NI, delegates = {}; diff --git a/lib/field/tc.field.dropdown.js b/lib/field/tc.field.dropdown.js index fc33c79..f39e049 100644 --- a/lib/field/tc.field.dropdown.js +++ b/lib/field/tc.field.dropdown.js @@ -19,9 +19,10 @@ typecode-js v 0.1 // NI.field define([ + 'require', 'jquery', - './../tc.field' -], function($) { + 'lib/typecode-js/lib/tc.field' +], function(require, $) { var NI = window.NI, field = NI.field; From 416d6382f02d21538a29172608ed07768cb37176 Mon Sep 17 00:00:00 2001 From: "Andrew Mahon (Type/Code)" Date: Thu, 8 Nov 2012 19:17:24 -0500 Subject: [PATCH 05/83] small work trying to get the features initialized in there --- lib/tc.app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tc.app.js b/lib/tc.app.js index 7d4580e..1eb03fe 100644 --- a/lib/tc.app.js +++ b/lib/tc.app.js @@ -41,7 +41,7 @@ typecode-js v 0.1 this.initialize_features(o.page.features); this.initialize_features(o.inner_page.features); o.page.initialized = true; - + console.log('hello') this.events.trigger('app.featuresInitialized'); } From b41258f9ccb16d4c787f9d01489175315fae55a9 Mon Sep 17 00:00:00 2001 From: "Andrew Mahon (Type/Code)" Date: Thu, 8 Nov 2012 21:07:50 -0500 Subject: [PATCH 06/83] removed some log statements --- lib/field/tc.field.validator.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/field/tc.field.validator.js b/lib/field/tc.field.validator.js index ae20eda..f0b7f0f 100644 --- a/lib/field/tc.field.validator.js +++ b/lib/field/tc.field.validator.js @@ -46,9 +46,6 @@ define([ managed_field:null }; - console.log('Validator'); - console.log(o.manager); - if (!o.manager || !(o.manager instanceof NI.ValidationManager)) { o.manager = new NI.ValidationManager({ watchEvents:['keyup', 'change', NI.field.co.SET_VAL_EVENT] From 90628cd431c2b81fe5daba4665318b68360e8e7b Mon Sep 17 00:00:00 2001 From: LevKanter Date: Tue, 13 Nov 2012 13:40:43 -0500 Subject: [PATCH 07/83] working on transition to requirejs --- examples/field.html | 54 +- examples/lib/require.js | 34 ++ lib/{tc.animator.js => Animator.js} | 7 +- lib/{tc.app.js => App-DEPRECATED.js} | 9 +- lib/App.js | 58 ++ ...owser_detection.js => BrowserDetection.js} | 57 +- lib/{tc.carousel.js => Carousel.js} | 7 +- lib/{tc.cookies.js => Cookies.js} | 11 +- lib/{tc.favicon.js => Favicon.js} | 9 +- lib/GoogleAnalytics.js | 49 ++ lib/{tc.merlin.js => Merlin.js} | 88 ++- lib/{tc.overlay.js => Overlay.js} | 7 +- ...{tc.social_rotator.js => SocialRotator.js} | 7 +- lib/{tc.tooltip.js => Tooltip.js} | 7 +- lib/{tc.anim_util.js => anim.js} | 25 +- lib/{tc.color.js => color.js} | 17 +- ...ature_detection.js => featuredetection.js} | 11 +- lib/{tc.field.js => field.js} | 12 +- ....field.autocomplete.js => Autocomplete.js} | 9 +- lib/field/{tc.field.counter.js => Counter.js} | 18 +- .../{tc.field.dropdown.js => Dropdown.js} | 17 +- lib/field/{tc.field.hint.js => Hint.js} | 8 +- ...eld.simple_tooltip.js => SimpleTooltip.js} | 8 +- .../{tc.field.validator.js => Validator.js} | 7 +- lib/field/{tc.field.std.js => std.js} | 10 +- lib/flippanel.js | 132 +++++ ...ics.header.js => googleanalyticsheader.js} | 8 +- ...c.merlin.autosave.js => MerlinAutosave.js} | 12 +- .../{tc.merlin.csrf.js => MerlinCSRF.js} | 9 +- .../{tc.merlin.data.js => MerlinData.js} | 13 +- lib/{tc.seed.js => seed.js} | 23 +- lib/tc.flippanel.js | 129 ----- lib/tc.google_analytics.js | 58 -- lib/tc.merlin.js.old | 535 ------------------ lib/{tc.validation.js => validation.js} | 27 +- requirepaths.js | 36 ++ 36 files changed, 574 insertions(+), 954 deletions(-) create mode 100644 examples/lib/require.js rename lib/{tc.animator.js => Animator.js} (96%) rename lib/{tc.app.js => App-DEPRECATED.js} (94%) create mode 100644 lib/App.js rename lib/{tc.browser_detection.js => BrowserDetection.js} (89%) rename lib/{tc.carousel.js => Carousel.js} (99%) rename lib/{tc.cookies.js => Cookies.js} (96%) rename lib/{tc.favicon.js => Favicon.js} (96%) create mode 100644 lib/GoogleAnalytics.js rename lib/{tc.merlin.js => Merlin.js} (85%) rename lib/{tc.overlay.js => Overlay.js} (98%) rename lib/{tc.social_rotator.js => SocialRotator.js} (97%) rename lib/{tc.tooltip.js => Tooltip.js} (99%) rename lib/{tc.anim_util.js => anim.js} (85%) rename lib/{tc.color.js => color.js} (90%) rename lib/{tc.feature_detection.js => featuredetection.js} (93%) rename lib/{tc.field.js => field.js} (97%) rename lib/field/{tc.field.autocomplete.js => Autocomplete.js} (99%) rename lib/field/{tc.field.counter.js => Counter.js} (90%) rename lib/field/{tc.field.dropdown.js => Dropdown.js} (98%) rename lib/field/{tc.field.hint.js => Hint.js} (97%) rename lib/field/{tc.field.simple_tooltip.js => SimpleTooltip.js} (96%) rename lib/field/{tc.field.validator.js => Validator.js} (97%) rename lib/field/{tc.field.std.js => std.js} (99%) create mode 100644 lib/flippanel.js rename lib/{tc.google_analytics.header.js => googleanalyticsheader.js} (93%) rename lib/merlin/{tc.merlin.autosave.js => MerlinAutosave.js} (94%) rename lib/merlin/{tc.merlin.csrf.js => MerlinCSRF.js} (93%) rename lib/merlin/{tc.merlin.data.js => MerlinData.js} (97%) rename lib/{tc.seed.js => seed.js} (95%) delete mode 100644 lib/tc.flippanel.js delete mode 100644 lib/tc.google_analytics.js delete mode 100644 lib/tc.merlin.js.old rename lib/{tc.validation.js => validation.js} (94%) create mode 100644 requirepaths.js 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 96% rename from lib/tc.animator.js rename to lib/Animator.js index 779c094..122b137 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; @@ -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/tc.app.js b/lib/App-DEPRECATED.js similarity index 94% rename from lib/tc.app.js rename to lib/App-DEPRECATED.js index 1eb03fe..5636d6d 100644 --- a/lib/tc.app.js +++ b/lib/App-DEPRECATED.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 App(options) { var o, i; @@ -41,7 +42,7 @@ typecode-js v 0.1 this.initialize_features(o.page.features); this.initialize_features(o.inner_page.features); o.page.initialized = true; - console.log('hello') + this.events.trigger('app.featuresInitialized'); } @@ -63,4 +64,4 @@ typecode-js v 0.1 NI.App = App; -}(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..f22f5ed --- /dev/null +++ b/lib/App.js @@ -0,0 +1,58 @@ +define(['jquery'], function($) { + + var App = function(options) { + var self = this, o; + + o = $.extend({ + page: { + _features: [], + add_feature: function(feature) { + this._features.push(feature); + } + } + }, options); + + this.page = o.page; + this.events = $({}); + this.runtime = {}; + + this.invoke_feature_set(this.page._features); + + this.page.add_feature = function() { + self.invoke_feature.apply(self, arguments); + }; + }; + + App.prototype.invoke_feature = function(feature) { + var self = this; + if ($.isFunction(feature)) { + feature(self); + } else if (typeof feature === "string") { + require([feature]); + } 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); + } + }); + } + }; + + App.prototype.invoke_feature_set = function(feature_set) { + var self = this; + if (!feature_set || typeof feature_set !== "object") { + return false; + } + $.each(feature_set, function(i, feature) { + self.invoke_feature(feature); + }); + }; + + return App; + +}); \ No newline at end of file diff --git a/lib/tc.browser_detection.js b/lib/BrowserDetection.js similarity index 89% rename from lib/tc.browser_detection.js rename to lib/BrowserDetection.js index 58aa836..7736a82 100644 --- a/lib/tc.browser_detection.js +++ b/lib/BrowserDetection.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 BrowserDetection(options) { var o, elements; @@ -41,37 +42,41 @@ typecode-js v 0.1 if (browser.webkit) { if(o.addClassToBody){ elements.body.addClass('browser-webkit'); - }; + } // check if it's chrome, safari, or an iOS browser - if (userAgent.match(/iPad/i) != null) { + if (userAgent.match(/iPad/i) !== null) { if(o.addClassToBody){ elements.body.addClass('browser-ipad os-ios'); - }; + } if(o.orientationListen){ listenToOrientationChange(); - }; + } if(o.detectWebApp){ - if (window.navigator.standalone) { elements.body.addClass('ios-webapp') } + 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){ listenToOrientationChange(); - }; + } if(o.detectWebApp){ - if (window.navigator.standalone) { elements.body.addClass('ios-webapp') } + if (window.navigator.standalone) { + elements.body.addClass('ios-webapp'); + } } } else if(userAgent.match(/Chrome/i)) { if(o.addClassToBody){ elements.body.addClass('browser-chrome'); - }; + } } else if(userAgent.match(/Safari/i)) { if(o.addClassToBody){ elements.body.addClass('browser-safari'); - }; + } } // ...if browser is NOT webkit, run through the other browsers @@ -79,43 +84,43 @@ typecode-js v 0.1 if (browser.msie) { if(o.addClassToBody){ elements.body.addClass('browser-ie'); - }; + } } else if (browser.mozilla) { if(o.addClassToBody){ elements.body.addClass('browser-firefox'); - }; + } } else if (browser.opera) { if(o.addClassToBody){ elements.body.addClass('browser-opera'); - }; + } } - }; + } // now, detect operating systems if (appVersion.indexOf("Mac")!=-1) { if(o.addClassToBody){ elements.body.addClass('os-mac'); - }; + } } else if (appVersion.indexOf("Win")!=-1) { if(o.addClassToBody){ elements.body.addClass('os-win'); - }; + } } else if (appVersion.indexOf("X11")!=-1) { if(o.addClassToBody){ elements.body.addClass('os-unix'); - }; + } } else if (appVersion.indexOf("Linux")!=-1) { if(o.addClassToBody){ elements.body.addClass('os-linux'); - }; + } } else { if(o.addClassToBody){ elements.body.addClass('os-unknown'); - }; - }; + } + } - }; + } @@ -137,7 +142,7 @@ typecode-js v 0.1 window.onorientationchange = function(){ var orientation = window.orientation; - orientationChanged(orientation) + orientationChanged(orientation); }; } @@ -148,4 +153,4 @@ typecode-js v 0.1 NI.BrowserDetection = BrowserDetection; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/tc.carousel.js b/lib/Carousel.js similarity index 99% rename from lib/tc.carousel.js rename to lib/Carousel.js index ec90868..c33f213 100644 --- a/lib/tc.carousel.js +++ b/lib/Carousel.js @@ -18,9 +18,10 @@ 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, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI, + var window = this, + NI = window.NI, generate, focussed; @@ -440,4 +441,4 @@ typecode-js v 0.1 NI.Carousel = Carousel; NI.Carousel.Generator = generate; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/tc.cookies.js b/lib/Cookies.js similarity index 96% rename from lib/tc.cookies.js rename to lib/Cookies.js index 463bf85..c7bac06 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,7 +56,7 @@ typecode-js v 0.1 } return cookies; } - } + }; this.o = o; this.internal_functions = internal_functions; @@ -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 96% rename from lib/tc.favicon.js rename to lib/Favicon.js index 0c2a182..4791a61 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; @@ -80,4 +81,4 @@ typecode-js v 0.1 NI.Favicon = Favicon; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/GoogleAnalytics.js b/lib/GoogleAnalytics.js new file mode 100644 index 0000000..f59966a --- /dev/null +++ b/lib/GoogleAnalytics.js @@ -0,0 +1,49 @@ +/* ============================================================================ + + >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 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; + +}); \ No newline at end of file diff --git a/lib/tc.merlin.js b/lib/Merlin.js similarity index 85% rename from lib/tc.merlin.js rename to lib/Merlin.js index 6f66b0b..8a62691 100644 --- a/lib/tc.merlin.js +++ b/lib/Merlin.js @@ -15,16 +15,10 @@ From 2010 till ∞ typecode-js v 0.1 */ -define([ - 'jquery', - 'lib/typecode-js/lib/field/tc.field.validator', - 'lib/typecode-js/lib/field/tc.field.std', - 'lib/typecode-js/lib/field/tc.field.hint', - 'lib/typecode-js/lib/field/tc.field.simple_tooltip', - 'lib/typecode-js/lib/field/tc.field.hint' -], function($) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; NI.co.Merlin = { NEXT_STEP:'next', @@ -132,43 +126,48 @@ define([ o.steps[i].initialize_fields = function(){ if(o.steps[i].fields){ - - o.steps[i].validationManager = new NI.ValidationManager({ - $mother:o.steps[i].$e, - watchEvents: o.validation_watch_events - }); - - o.steps[i].$e.bind('managerValidationPass', {merlin:me}, step_event_handlers.managerValidationPass) - .bind('managerValidationFail', {merlin:me}, step_event_handlers.managerValidationFail); - - o.steps[i].valid = true; - - for(var j in o.steps[i].fields){ - if (o.steps[i].fields[j].options && o.steps[i].fields[j].options.extensions && o.steps[i].fields[j].options.extensions.Validator) { - o.steps[i].fields[j].options.extensions.Validator.manager = o.steps[i].validationManager; - } - o.steps[i].fields[j].component = NI.field.new_instance({ - element: o.steps[i].$e.find(o.steps[i].fields[j].selector), - preprocess: $.isFunction(o.steps[i].fields[j].preprocess) ? o.steps[i].fields[j].preprocess : null, - options: $.extend({ - handlers: { - focus: step_input_handlers.focus, - keyup: step_input_handlers.modify, - change: step_input_handlers.modify, - //keypress: step_input_handlers.keypress, - keydown: step_input_handlers.keydown, - blur: step_input_handlers.blur - }, - event_data:{ - merlin:me - } - }, o.steps[i].fields[j].options) + + require(['NIvalidation'], function() { + + o.steps[i].validationManager = new NI.ValidationManager({ + $mother:o.steps[i].$e, + watchEvents: o.validation_watch_events }); + + o.steps[i].$e.bind('managerValidationPass', {merlin:me}, step_event_handlers.managerValidationPass) + .bind('managerValidationFail', {merlin:me}, step_event_handlers.managerValidationFail); + + o.steps[i].valid = true; + + for(var j in o.steps[i].fields){ + if (o.steps[i].fields[j].options && o.steps[i].fields[j].options.extensions && o.steps[i].fields[j].options.extensions.Validator) { + o.steps[i].fields[j].options.extensions.Validator.manager = o.steps[i].validationManager; + } + o.steps[i].fields[j].component = NI.field.new_instance({ + element: o.steps[i].$e.find(o.steps[i].fields[j].selector), + preprocess: $.isFunction(o.steps[i].fields[j].preprocess) ? o.steps[i].fields[j].preprocess : null, + options: $.extend({ + handlers: { + focus: step_input_handlers.focus, + keyup: step_input_handlers.modify, + change: step_input_handlers.modify, + //keypress: step_input_handlers.keypress, + keydown: step_input_handlers.keydown, + blur: step_input_handlers.blur + }, + event_data:{ + merlin:me + } + }, o.steps[i].fields[j].options) + }); - if(o.steps[i].fields[j].value || (o.steps[i].fields[j].value === '')){ - o.steps[i].fields[j].component.set_val(o.steps[i].fields[j].value); + if(o.steps[i].fields[j].value || (o.steps[i].fields[j].value === '')){ + o.steps[i].fields[j].component.set_val(o.steps[i].fields[j].value); + } } - } + + });// end require NIvalidation + } }; o.steps[i].initialize_fields(); @@ -190,9 +189,6 @@ define([ } }); - for(i in o.steps){ - - } } function show_step(step, nav_data){ diff --git a/lib/tc.overlay.js b/lib/Overlay.js similarity index 98% rename from lib/tc.overlay.js rename to lib/Overlay.js index 56e4e13..5ce2f1e 100644 --- a/lib/tc.overlay.js +++ b/lib/Overlay.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 Overlay(options) { var o, $e, $m, open, $elements; @@ -263,4 +264,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/tc.social_rotator.js b/lib/SocialRotator.js similarity index 97% rename from lib/tc.social_rotator.js rename to lib/SocialRotator.js index 5cc0e23..620eb63 100644 --- a/lib/tc.social_rotator.js +++ b/lib/SocialRotator.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; //var SocialButtons = { // twitter:function(options){ @@ -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 99% rename from lib/tc.tooltip.js rename to lib/Tooltip.js index ec0ed1b..f03f9f3 100644 --- a/lib/tc.tooltip.js +++ b/lib/Tooltip.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; // remove "px" from a string representing a css pixel dimension // and cast as a Number (i.e. trimpx("10px") returns 10) @@ -552,4 +553,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 85% rename from lib/tc.anim_util.js rename to lib/anim.js index d95899c..0c28db1 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 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); @@ -121,4 +122,4 @@ typecode-js v 0.1 NI.anim.requestAnimFrame = requestAnimFrame; NI.anim.Cycler = Cycler; -}(this)); +}); diff --git a/lib/tc.color.js b/lib/color.js similarity index 90% rename from lib/tc.color.js rename to lib/color.js index 1eab26d..89fc39e 100644 --- a/lib/tc.color.js +++ b/lib/color.js @@ -15,15 +15,12 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window, $) { +define(['jquery', 'NIseed'], function($) { - var NI = window.NI; - - function Color(options) { - - } - - Color.prototype = { + var window = this, + NI = window.NI, + + color = { getRGBFromHex:function(index,hex){ if(index.toLowerCase() == "r"){ return parseInt((this.cutHex(hex)).substring(0,2),16); @@ -40,6 +37,6 @@ typecode-js v 0.1 //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - NI.Color = Color; + NI.color = color; -}(this, this.jQuery)); \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/tc.feature_detection.js b/lib/featuredetection.js similarity index 93% rename from lib/tc.feature_detection.js rename to lib/featuredetection.js index 931b835..93e067b 100644 --- a/lib/tc.feature_detection.js +++ b/lib/featuredetection.js @@ -15,12 +15,11 @@ 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") { @@ -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 fcd9173..a112755 100644 --- a/lib/tc.field.js +++ b/lib/field.js @@ -15,12 +15,13 @@ From 2010 till ∞ typecode-js v 0.1 */ -define([ - 'jquery' -], function($) { +define(['jquery', 'NIseed'], function($) { var NI = window.NI, - field = { extensions: {} }; + field = { + extensions: {} + }, + console = NI.app.getConsole(true); //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // constants @@ -235,6 +236,9 @@ define([ //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})); }; diff --git a/lib/field/tc.field.autocomplete.js b/lib/field/Autocomplete.js similarity index 99% rename from lib/field/tc.field.autocomplete.js rename to lib/field/Autocomplete.js index 7b83c1a..2968d9f 100644 --- a/lib/field/tc.field.autocomplete.js +++ b/lib/field/Autocomplete.js @@ -18,12 +18,11 @@ typecode-js v 0.1 // Dependencies: // NI.field -define([ - 'jquery', - 'lib/typecode-js/lib/tc.field' -], function($) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI, delegates = {}; + var window = this, + NI = window.NI, + delegates = {}; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/lib/field/tc.field.counter.js b/lib/field/Counter.js similarity index 90% rename from lib/field/tc.field.counter.js rename to lib/field/Counter.js index a5f182a..9125577 100644 --- a/lib/field/tc.field.counter.js +++ b/lib/field/Counter.js @@ -18,12 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -define([ - 'jquery', - './../tc.field' -], function($) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -52,7 +50,7 @@ define([ function init(){ field.event_receiver.bind('focus keyup change', {field:field}, event_handlers.updated); - }; + } event_handlers = { updated:function(e,d){ @@ -62,11 +60,11 @@ define([ //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'); + } + } }; diff --git a/lib/field/tc.field.dropdown.js b/lib/field/Dropdown.js similarity index 98% rename from lib/field/tc.field.dropdown.js rename to lib/field/Dropdown.js index f39e049..0bbc29b 100644 --- a/lib/field/tc.field.dropdown.js +++ b/lib/field/Dropdown.js @@ -18,14 +18,11 @@ typecode-js v 0.1 // Dependencies: // NI.field -define([ - 'require', - 'jquery', - 'lib/typecode-js/lib/tc.field' -], function(require, $) { +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", @@ -44,20 +41,20 @@ define([ 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); diff --git a/lib/field/tc.field.hint.js b/lib/field/Hint.js similarity index 97% rename from lib/field/tc.field.hint.js rename to lib/field/Hint.js index d25e24e..7b85397 100644 --- a/lib/field/tc.field.hint.js +++ b/lib/field/Hint.js @@ -18,12 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -define([ - 'jquery', - './../tc.field' -], function($) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/lib/field/tc.field.simple_tooltip.js b/lib/field/SimpleTooltip.js similarity index 96% rename from lib/field/tc.field.simple_tooltip.js rename to lib/field/SimpleTooltip.js index 8afb9f6..af7be53 100644 --- a/lib/field/tc.field.simple_tooltip.js +++ b/lib/field/SimpleTooltip.js @@ -18,12 +18,10 @@ typecode-js v 0.1 // Dependencies: // NI.field -define([ - 'jquery', - './../tc.field' -], function($) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI; + var window = this, + NI = window.NI; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/lib/field/tc.field.validator.js b/lib/field/Validator.js similarity index 97% rename from lib/field/tc.field.validator.js rename to lib/field/Validator.js index f0b7f0f..f37c684 100644 --- a/lib/field/tc.field.validator.js +++ b/lib/field/Validator.js @@ -18,12 +18,7 @@ typecode-js v 0.1 // Dependencies: // NI.field -define([ - 'require', - 'jquery', - 'lib/typecode-js/lib/tc.validation', - 'lib/typecode-js/lib/tc.field' -], function(require, $) { +define(['jquery', 'NIseed', 'NIfield', 'NIvalidation'], function($) { var NI = window.NI, field = NI.field; 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 2fcadf5..06bc65f 100644 --- a/lib/field/tc.field.std.js +++ b/lib/field/std.js @@ -18,13 +18,11 @@ typecode-js v 0.1 // Dependencies: // NI.field -define([ - 'jquery', - './../tc.field' -], function($) { +define(['jquery', 'NIseed', 'NIfield'], function($) { - var NI = window.NI, - field = NI.field; + var window = this, + NI = window.NI, + field = NI.field; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: // standard field type diff --git a/lib/flippanel.js b/lib/flippanel.js new file mode 100644 index 0000000..00a0235 --- /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.flipPanel = 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/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/tc.seed.js b/lib/seed.js similarity index 95% rename from lib/tc.seed.js rename to lib/seed.js index 905a499..139e567 100644 --- a/lib/tc.seed.js +++ b/lib/seed.js @@ -15,10 +15,11 @@ From 2010 till ∞ typecode-js v 0.1 */ -(function(window) { +define(['jquery'], function($) { - var NI = {}, - fakeConsole; + var window = this, + NI = {}, + fakeConsole; NI.ex = { @@ -57,8 +58,8 @@ typecode-js v 0.1 if (s === "object") { if (v) { if (typeof v.length === "number" && - !(v.propertyIsEnumerable("length")) && - typeof v.splice === "function") { + !(v.propertyIsEnumerable("length")) && + typeof v.splice === "function") { s = "array"; } } else { @@ -122,11 +123,11 @@ typecode-js v 0.1 }, /** - * Initialize environment-specific components - * from an array of "feature" objects, each one - * of the form { feature: "foo", options: {} }, - * which invokes app[foo](options) - */ + * 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 = {}; @@ -303,4 +304,4 @@ typecode-js v 0.1 window.NI = NI; -}(this)); \ No newline at end of file +}); \ 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.validation.js b/lib/validation.js similarity index 94% rename from lib/tc.validation.js rename to lib/validation.js index cab9555..200674f 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.app.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..ddd2334 --- /dev/null +++ b/requirepaths.js @@ -0,0 +1,36 @@ +require = { + paths: { + 'jquery': 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.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', + 'NIGoogleAnalytics': 'lib/GoogleAnalytics', + 'NIgoogleanalyticsheader': 'lib/googleanalyticsheader', + + 'NIMerlin': 'lib/Merlin', + + 'NIOverlay': 'lib/Overlay', + 'NIseed': 'lib/seed', + 'NISocialRotator': 'lib/SocialRotator', + 'NITooltip': 'lib/Tooltip', + 'NIvalidation': 'lib/validation' + } +}; \ No newline at end of file From eb8cd9bfa0fc0a01d87806f9b4e6bff761265ec0 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Tue, 13 Nov 2012 13:46:00 -0500 Subject: [PATCH 08/83] updated readme --- README | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) 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 From c270cb838e53f7d7a1b76cc1ef7faf54ca6379d5 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Tue, 13 Nov 2012 14:11:07 -0500 Subject: [PATCH 09/83] app featuresInitialized event --- lib/App.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/App.js b/lib/App.js index f22f5ed..ae1735d 100644 --- a/lib/App.js +++ b/lib/App.js @@ -23,12 +23,20 @@ define(['jquery'], function($) { }; }; - App.prototype.invoke_feature = function(feature) { + 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]); + require([feature], function() { + callback(); + }); } else if (typeof feature === "object" && feature && $.isArray(feature.require)) { require(feature.require, function() { var args; @@ -39,17 +47,33 @@ define(['jquery'], function($) { }); feature.callback.apply(this, args); } + callback(); }); } }; App.prototype.invoke_feature_set = function(feature_set) { - var self = this; - if (!feature_set || typeof feature_set !== "object") { + var self = this, + n_features, + n_initialized, + callback; + + if (!feature_set || typeof feature_set !== "object" || !feature_set.length) { return false; } + + n_features = feature_set.length; + n_initialized = 0; + + callback = function() { + n_initialized += 1; + if (n_initialized === n_features) { + self.events.trigger('app.featuresInitialized'); + } + }; + $.each(feature_set, function(i, feature) { - self.invoke_feature(feature); + self.invoke_feature(feature, callback); }); }; From dd285eabe325e319592484ebf8e9ca1dbc516c9b Mon Sep 17 00:00:00 2001 From: LevKanter Date: Tue, 13 Nov 2012 14:17:11 -0500 Subject: [PATCH 10/83] improved App.prototype.invoke_feature_set by adding callback param --- lib/App.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/App.js b/lib/App.js index ae1735d..799e688 100644 --- a/lib/App.js +++ b/lib/App.js @@ -52,11 +52,11 @@ define(['jquery'], function($) { } }; - App.prototype.invoke_feature_set = function(feature_set) { + App.prototype.invoke_feature_set = function(feature_set, callback) { var self = this, n_features, n_initialized, - callback; + feature_init_callback; if (!feature_set || typeof feature_set !== "object" || !feature_set.length) { return false; @@ -65,15 +65,18 @@ define(['jquery'], function($) { n_features = feature_set.length; n_initialized = 0; - callback = function() { + 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, callback); + self.invoke_feature(feature, feature_init_callback); }); }; From ff1e8051518febc185fdb7ed355cf85ce71af028 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Wed, 14 Nov 2012 15:56:54 -0500 Subject: [PATCH 11/83] made NIApp require seed --- lib/App.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/App.js b/lib/App.js index 799e688..4ed1c62 100644 --- a/lib/App.js +++ b/lib/App.js @@ -1,6 +1,9 @@ -define(['jquery'], function($) { +define(['jquery', 'NIseed'], function($) { - var App = function(options) { + var window = this, + NI = window.NI, + + App = function(options) { var self = this, o; o = $.extend({ @@ -80,6 +83,8 @@ define(['jquery'], function($) { }); }; + NI.App = App; + return App; }); \ No newline at end of file From 0285d58f455a1f554627c1b6e9196148c3f5668a Mon Sep 17 00:00:00 2001 From: LevKanter Date: Wed, 14 Nov 2012 16:25:19 -0500 Subject: [PATCH 12/83] drop down automatically processes a native select --- lib/field/Dropdown.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/field/Dropdown.js b/lib/field/Dropdown.js index 0bbc29b..064419b 100644 --- a/lib/field/Dropdown.js +++ b/lib/field/Dropdown.js @@ -187,8 +187,16 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { 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") { From 94262422c02ac21e066e7933aa7afe4ed3a6316c Mon Sep 17 00:00:00 2001 From: LevKanter Date: Wed, 14 Nov 2012 16:32:47 -0500 Subject: [PATCH 13/83] App automatically 'fixes' global console --- lib/App.js | 5 ++++- lib/field/Dropdown.js | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/App.js b/lib/App.js index 4ed1c62..a8a02b4 100644 --- a/lib/App.js +++ b/lib/App.js @@ -12,9 +12,12 @@ define(['jquery', 'NIseed'], function($) { add_feature: function(feature) { this._features.push(feature); } - } + }, + debug: true }, options); + window.console = NI.app.getConsole(o.debug); + this.page = o.page; this.events = $({}); this.runtime = {}; diff --git a/lib/field/Dropdown.js b/lib/field/Dropdown.js index 064419b..38e6c34 100644 --- a/lib/field/Dropdown.js +++ b/lib/field/Dropdown.js @@ -110,9 +110,9 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { 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"](); @@ -145,7 +145,7 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { } } 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(); } @@ -223,7 +223,7 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { this.$e = $("
") .addClass(field.co.BASE_CLASS+ " " +field.Dropdown.CONTAINER_CLASS) .html("
"+ - "
"); + "
"); this._init_elements(); if (options.value_list) { this.populate(options.value_list); @@ -306,7 +306,7 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { $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; @@ -346,7 +346,7 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { $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); @@ -421,7 +421,7 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { } if (arguments[0] === false) { - this.elements.display.html(""+ this.internal.o.empty_text +""); + this.elements.display.html(""+ this.internal.o.empty_text +""); return; } }, @@ -486,7 +486,7 @@ define(['jquery', 'NIseed', 'NIfield'], function($) { 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; From 8a02a2b79872f1d698f619cddff75bc0eb3ce2fa Mon Sep 17 00:00:00 2001 From: LevKanter Date: Thu, 15 Nov 2012 14:04:59 -0500 Subject: [PATCH 14/83] allow Merlin steps config to pass $e instead of selector --- lib/Merlin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Merlin.js b/lib/Merlin.js index 8a62691..a22ca05 100644 --- a/lib/Merlin.js +++ b/lib/Merlin.js @@ -118,10 +118,14 @@ define(['jquery', 'NIseed'], function($) { var i, e_data; $.each(o.steps,function(i){ var k; - if(o.steps[i].selector && o.$e){ + if(o.steps[i].$e || (o.steps[i].selector && o.$e)){ o.steps[i].name = i; o.steps[i].n_times_shown = 0; - o.steps[i].$e = o.$e.find(o.steps[i].selector); + + if (!o.steps[i].$e) { + o.steps[i].$e = o.$e.find(o.steps[i].selector); + } + o.steps[i].$e.hide(); o.steps[i].initialize_fields = function(){ From 2706dde288525cac6bd3ed667c55441d5c3d1d92 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Thu, 15 Nov 2012 14:22:26 -0500 Subject: [PATCH 15/83] experimental change in step showing/hiding --- lib/Merlin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Merlin.js b/lib/Merlin.js index a22ca05..786c9e7 100644 --- a/lib/Merlin.js +++ b/lib/Merlin.js @@ -319,7 +319,15 @@ define(['jquery', 'NIseed'], function($) { } } else { - o.$e.find(internal.current_step.selector).show().siblings('.step').hide(); + //o.$e.find(internal.current_step.selector).show().siblings('.step').hide(); + + $.each(internal.steps, function() { + if (this.name == step) { + this.$e.show(); + } else { + this.$e.hide(); + } + }); } // end transition handling From ec2c44f433d875745a86b15610f8aca3569bf620 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Thu, 15 Nov 2012 15:39:05 -0500 Subject: [PATCH 16/83] more experimental merlin changes: made merlin transitions not rely on '.step' selectors and use step.$e instead --- lib/Merlin.js | 59 +++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/lib/Merlin.js b/lib/Merlin.js index 786c9e7..d250082 100644 --- a/lib/Merlin.js +++ b/lib/Merlin.js @@ -269,17 +269,17 @@ define(['jquery', 'NIseed'], function($) { // begin transition handling if (o.transition=='fade') { if (internal.counters.n_times_step_rendered !== 0) { - o.$e.find(internal.current_step.selector).fadeIn(o.transition_speed); - o.$e.find(internal.last_step.selector).fadeOut(o.transition_speed); + internal.current_step.$e.fadeIn(o.transition_speed); + internal.last_step.$e.fadeOut(o.transition_speed); } else { - o.$e.find(internal.current_step.selector).show().siblings('.step').hide(); + toggle_step_visibility(internal.current_step.name); } } else if (o.transition=='slide') { if (internal.counters.n_times_step_rendered !== 0) { - o.$e.find(internal.current_step.selector).siblings('.step').slideUp(o.transition_speed/2); - o.$e.find(internal.current_step.selector).delay(o.transition_speed/2).slideDown(o.transition_speed); + internal.last_step.$e.slideUp(o.transition_speed/2); + internal.current_step.$e.delay(o.transition_speed/2).slideDown(o.transition_speed); } else { - o.$e.find(internal.current_step.selector).show().siblings('.step').hide(); + toggle_step_visibility(internal.current_step.name); } } else if (o.transition=='horiz_slide') { @@ -289,45 +289,44 @@ define(['jquery', 'NIseed'], function($) { if (internal.counters.n_times_step_rendered !== 0) { - strip.children('.step').width( step_width ); + $.each(internal.steps, function() { + this.$e.width(step_width); + }); + strip.width( step_width * 2); - strip.find(internal.current_step.selector).show(); + internal.current_step.$e.show(); if ( internal.current_step.step_number > 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(); - - $.each(internal.steps, function() { - if (this.name == step) { - this.$e.show(); - } else { - this.$e.hide(); - } - }); + toggle_step_visibility(internal.current_step.name); } // end transition handling @@ -374,18 +373,22 @@ define(['jquery', 'NIseed'], function($) { 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){ From 1dd2a09678332ec85cbb5ba14e6cc5482925a5d8 Mon Sep 17 00:00:00 2001 From: Lev Kanter Date: Sat, 17 Nov 2012 14:24:19 -0500 Subject: [PATCH 17/83] carousel quick fix in .destroy(). added fullscreen.js --- lib/Carousel.js | 4 +- lib/fullscreen.js | 106 ++++++++++++++++++++++++++++++++++++++++++++++ requirepaths.js | 1 + 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 lib/fullscreen.js diff --git a/lib/Carousel.js b/lib/Carousel.js index c33f213..d1e691e 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -424,10 +424,10 @@ define(['jquery', 'NIseed'], function($) { if (o.keyboard) { $(window.document).unbind("keydown.carousel", events.keydown); } - if ($elements.prevBtn.length) { + if ($elements.prevBtn && $elements.prevBtn.length) { $elements.prevBtn.unbind("click"); } - if ($elements.nextBtn.length) { + if ($elements.nextBtn && $elements.nextBtn.length) { $elements.nextBtn.unbind("click"); } $e.remove(); diff --git a/lib/fullscreen.js b/lib/fullscreen.js new file mode 100644 index 0000000..6feff1c --- /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 fullscreen; + + if (typeof document.fullscreen === 'boolean') { + fullscreen = document.fullscreen; + } else if (typeof document.mozFullScreen === 'boolean') { + fullscreen = document.mozFullScreen; + } else if (typeof document.webkitIsFullScreen === 'boolean') { + fullscreen = document.webkitIsFullScreen; + } + + if (typeof fullscreen === 'boolean') { + if (fullscreen) { + 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/requirepaths.js b/requirepaths.js index ddd2334..19888f2 100644 --- a/requirepaths.js +++ b/requirepaths.js @@ -22,6 +22,7 @@ require = { 'NIfield.Validator': 'lib/field/Validator', 'NIflippanel': 'lib/flippanel', + 'NIfullscreen': 'lib/fullscreen', 'NIGoogleAnalytics': 'lib/GoogleAnalytics', 'NIgoogleanalyticsheader': 'lib/googleanalyticsheader', From f17c06d9edc45d8d02f74aa032dca74c06c43c1f Mon Sep 17 00:00:00 2001 From: Lev Kanter Date: Sat, 17 Nov 2012 16:37:03 -0500 Subject: [PATCH 18/83] small quick fix in fullscreen.js --- lib/fullscreen.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/fullscreen.js b/lib/fullscreen.js index 6feff1c..5c40028 100644 --- a/lib/fullscreen.js +++ b/lib/fullscreen.js @@ -44,18 +44,18 @@ define(['jquery', 'NIseed'], function($) { }, toggle: function() { - var fullscreen; + var fs; if (typeof document.fullscreen === 'boolean') { - fullscreen = document.fullscreen; + fs = document.fullscreen; } else if (typeof document.mozFullScreen === 'boolean') { - fullscreen = document.mozFullScreen; + fs = document.mozFullScreen; } else if (typeof document.webkitIsFullScreen === 'boolean') { - fullscreen = document.webkitIsFullScreen; + fs = document.webkitIsFullScreen; } - if (typeof fullscreen === 'boolean') { - if (fullscreen) { + if (typeof fs === 'boolean') { + if (fs) { this.cancel(); } else { this.request(); From 6581f8cc9f9dc179e878c8322902a0b580b26b00 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Mon, 19 Nov 2012 12:50:25 -0500 Subject: [PATCH 19/83] added setOrientation function to carousel --- lib/Carousel.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Carousel.js b/lib/Carousel.js index d1e691e..96b75d4 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -416,6 +416,13 @@ define(['jquery', 'NIseed'], function($) { } return me; }; + + // set the carousel to vertical or horizontal + // (chainable) + this.setOrientation = function(vertical) { + o.vertical = vertical; + return me; + }; // destroy this instance // (the carousel element is automatically removed from the DOM) From df73e5d1ef458a984c1e9daca8c1088f18579105 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Mon, 19 Nov 2012 13:51:34 -0500 Subject: [PATCH 20/83] small improvement to setOrientation function --- lib/Carousel.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Carousel.js b/lib/Carousel.js index 96b75d4..489503f 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -130,7 +130,8 @@ define(['jquery', 'NIseed'], function($) { me.add($panel); }); } - + + me.setOrientation(o.vertical); me.begin(true); } @@ -420,7 +421,15 @@ define(['jquery', 'NIseed'], function($) { // set the carousel to vertical or horizontal // (chainable) this.setOrientation = function(vertical) { - o.vertical = 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; }; From 0dd3ad21335539efafbd94cfe4cd9baa08913b4c Mon Sep 17 00:00:00 2001 From: LevKanter Date: Wed, 21 Nov 2012 14:59:36 -0500 Subject: [PATCH 21/83] removed some stuff in seed that's like honestly never used. added denounce function --- lib/seed.js | 107 ++++++++++------------------------------------------ 1 file changed, 19 insertions(+), 88 deletions(-) diff --git a/lib/seed.js b/lib/seed.js index 139e567..e78c6b3 100644 --- a/lib/seed.js +++ b/lib/seed.js @@ -88,25 +88,7 @@ define(['jquery'], function($) { }; 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; @@ -120,27 +102,6 @@ define(['jquery'], function($) { }); } 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); - } - }); - } } }; @@ -169,52 +130,6 @@ define(['jquery'], function($) { 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(); @@ -224,13 +139,28 @@ define(['jquery'], function($) { 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() { + timr = null; + fn.apply(self, args); + }; + window.clearTimeout(timer); + timer = window.setTimeout(execute, delay); + }; } }; NI.co = { keyboard: { - + BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, @@ -260,7 +190,7 @@ define(['jquery'], function($) { }, nodeTypes: { - + ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, @@ -276,6 +206,7 @@ define(['jquery'], function($) { }, directions: { + UP: 0, RIGHT: 1, DOWN: 2, From 31cdb5fd294cd804fd243a40a17d16604a76ed0d Mon Sep 17 00:00:00 2001 From: LevKanter Date: Wed, 21 Nov 2012 16:41:20 -0500 Subject: [PATCH 22/83] carousel this.syncCurrentAnimation function --- lib/Carousel.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Carousel.js b/lib/Carousel.js index 489503f..b076cc0 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -101,6 +101,7 @@ define(['jquery', 'NIseed'], function($) { $elements = { viewport: $viewport, scroll: $viewport.children(".scroll"), + currentTarget: null, prevBtn: null, nextBtn: null }; @@ -158,6 +159,8 @@ define(['jquery', 'NIseed'], function($) { if (!$panel.length) { return me; } + + $elements.currentTarget = $panel; // Determine if the target panel is a clone. // If it is, keep track of the real panel as $cloneTarget @@ -176,7 +179,9 @@ define(['jquery', 'NIseed'], function($) { } } - $elements.scroll.animate(targetPosition($panel), (noAnimate ? 0 : o.speed), o.easing, function() { + $elements.scroll.stop(true, false).animate(targetPosition($panel), (noAnimate ? 0 : o.speed), o.easing, function() { + + $elements.currentTarget = null; if ($cloneTarget) { $elements.scroll.css(targetPosition($cloneTarget)); @@ -432,6 +437,12 @@ define(['jquery', 'NIseed'], function($) { } return me; }; + + this.syncCurrentAnimation = function(noAnimate) { + if ($elements.currentTarget) { + moveTo($elements.currentTarget, noAnimate); + } + }; // destroy this instance // (the carousel element is automatically removed from the DOM) From a394091f8a9a650ff365e74513599b392a7edba6 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Wed, 21 Nov 2012 16:55:37 -0500 Subject: [PATCH 23/83] quickfix syncCurrentAnimation --- lib/Carousel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Carousel.js b/lib/Carousel.js index b076cc0..5000c41 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -438,9 +438,11 @@ define(['jquery', 'NIseed'], function($) { return me; }; - this.syncCurrentAnimation = function(noAnimate) { + this.syncCurrentAnimation = function() { if ($elements.currentTarget) { - moveTo($elements.currentTarget, noAnimate); + moveTo($elements.currentTarget, true); + } else { + moveTo(current(), true); } }; From ccb132fae8a098e568e3a288c01b2e777e4e500b Mon Sep 17 00:00:00 2001 From: LevKanter Date: Mon, 26 Nov 2012 12:08:35 -0500 Subject: [PATCH 24/83] elastic carousel --- lib/Carousel.js | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/Carousel.js b/lib/Carousel.js index 5000c41..9e35f6e 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -73,6 +73,7 @@ define(['jquery', 'NIseed'], function($) { easing: "swing", vertical: false, circular: true, + elastic: false, keyboard: true, touch: true, onBeforeMove: function(instance, info) {}, @@ -107,12 +108,16 @@ define(['jquery', 'NIseed'], function($) { }; 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.elastic) { + o.viewportDimensions = null; + } else { + if (typeof o.viewportDimensions.width === "number") { + $elements.viewport.width(o.viewportDimensions.width); + + } + if (typeof o.viewportDimensions.height === "number") { + $elements.viewport.height(o.viewportDimensions.height); + } } } @@ -125,6 +130,11 @@ define(['jquery', 'NIseed'], function($) { $elements.scroll[0].ontouchstart = events.touchstart; $elements.scroll[0].ontouchmove = events.touchmove; } + + if (o.elastic) { + syncElasticPanels(); + $(window).bind("resize", {instance: me}, events.elasticResize); + } if (o.panels && o.panels.length) { $.each(o.panels, function(i, $panel) { @@ -204,6 +214,16 @@ define(['jquery', 'NIseed'], function($) { return me; } + + function syncElasticPanels($panel) { + var w, h; + w = $e.width(); + h = $e.height(); + if (!$panel) { + $panel = $elements.scroll.children(selectors.panel); + } + $panel.width(w).height(h); + } events = { keydown: function(e) { @@ -242,7 +262,11 @@ define(['jquery', 'NIseed'], function($) { dy = touchInfo.y - e.touches[0].clientY; me[o.vertical && dy > 0 || !o.vertical && dx > 0 ? "next" : "prev"](); } - } + }, + elasticResize: NI.fn.debounce(function(e) { + syncElasticPanels(); + e.data.instance.syncCurrentAnimation(); + }, 100) }; function registerBtn(key) { @@ -285,7 +309,9 @@ define(['jquery', 'NIseed'], function($) { if (!o.vertical) { $panel.css("float", "left"); } - if (o.viewportDimensions) { + if (o.elastic) { + syncElasticPanels($panel); + } else if (o.viewportDimensions) { if (typeof o.viewportDimensions.width === "number") { $panel.width(o.viewportDimensions.width); } @@ -450,6 +476,9 @@ define(['jquery', 'NIseed'], function($) { // (the carousel element is automatically removed from the DOM) this.destroy = function() { me.blur(); + if (o.elastic) { + $(window).unbind("resize", events.elasticResize); + } if (o.keyboard) { $(window.document).unbind("keydown.carousel", events.keydown); } From e2f6399648e7bdb40a5c3240c4cac6e6b5c950b8 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Mon, 26 Nov 2012 14:01:12 -0500 Subject: [PATCH 25/83] added carousel elasticDelay option --- lib/Carousel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Carousel.js b/lib/Carousel.js index 9e35f6e..8e0f53f 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -74,6 +74,7 @@ define(['jquery', 'NIseed'], function($) { vertical: false, circular: true, elastic: false, + elasticDelay: 100, keyboard: true, touch: true, onBeforeMove: function(instance, info) {}, @@ -266,7 +267,7 @@ define(['jquery', 'NIseed'], function($) { elasticResize: NI.fn.debounce(function(e) { syncElasticPanels(); e.data.instance.syncCurrentAnimation(); - }, 100) + }, o.elasticDelay) }; function registerBtn(key) { From dbc1984efcf97829eaad8ceb2c7c8ffefb6bd280 Mon Sep 17 00:00:00 2001 From: LevKanter Date: Mon, 26 Nov 2012 19:05:13 -0500 Subject: [PATCH 26/83] starting to address code style --- lib/App-DEPRECATED.js | 67 --------- lib/Carousel.js | 318 +++++++++++++++++++++--------------------- styleguide.md | 23 +++ 3 files changed, 181 insertions(+), 227 deletions(-) delete mode 100644 lib/App-DEPRECATED.js create mode 100644 styleguide.md diff --git a/lib/App-DEPRECATED.js b/lib/App-DEPRECATED.js deleted file mode 100644 index 5636d6d..0000000 --- a/lib/App-DEPRECATED.js +++ /dev/null @@ -1,67 +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 -*/ - -define(['jquery', 'NIseed'], function($) { - - var window = this, - 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; - -}); \ No newline at end of file diff --git a/lib/Carousel.js b/lib/Carousel.js index 8e0f53f..7bf17b2 100644 --- a/lib/Carousel.js +++ b/lib/Carousel.js @@ -27,28 +27,28 @@ define(['jquery', 'NIseed'], function($) { generate = { carousel: function() { - return $("