JS2.OO.createClass("FactoryDebugger.Main");FactoryDebugger.Main.oo('extends',JS2.Main);(function(K,Package){var self=K;var _super=JS2.OO['super'];K.oo('member','components',['Components','Events','EventLog','ConsoleLog']);K.oo('method',"start",function(){this.factory.assign('dFactory',this.dFactory);this.notify('initHTML');this.notify('registerEvents');this.explorer=new JS2.ObjectExplorer();});K.oo('method',"e_initHTML",function(){this.jq=$(this.htmlCache.main());this.seed.append(this.jq);this.seed.setSeed(this.jq);WIDGET.tabs(this.jq);var config=this.parseCookie();this.position(config);var self=this;this.seed.jq.draggable({stop:function(){self.saveCookie()}});this.seed.first('.toggle').click(function(){self.toggle();self.saveCookie();});});K.oo('method',"parseCookie",function(){var config={};var m=document.cookie.match(/factoryDebugger=([\w,:]+);/);if(m){var options=m[1].split(/,/);for(var it106=0,o,it106__arr=options,it106__len=it106__arr.length;(o=it106__arr[it106])||it106<it106__len;it106++){var pair=o.split(':');config[pair[0]]=pair[1];}}
return config;});K.oo('method',"saveCookie",function(){var pos=this.seed.jq.position();var config={};config.top=pos.top;config.left=pos.left;if(this.seed.jq.is('.factoryDebuggerMin'))config.min=1;var cookie=null;for(var key in config){if(cookie){cookie+=',';}else{cookie='factoryDebugger=';}
cookie+=key+':'+config[key];}
document.cookie=cookie+';';});K.oo('method',"position",function(config){if(config.top){this.seed.jq[0].style.top=config.top+'px';this.seed.jq[0].style.left=config.left+'px';}
if(config.min){this.toggle();}});K.oo('method',"toggle",function(){this.seed.first('.fact-panes').toggle();this.seed.jq.toggleClass('factoryDebuggerMin');});K.oo('method',"notified",function(args){this.notify('notified',args);});K.oo('method',"finishNotified",function(args){this.notify('finishNotified',args);});K.oo('method',"compNotified",function(comp,args){this.notify('compNotified',comp,args);});K.oo('method',"toLog",function(comp,str){this.notify('log',comp,str);});K.oo('method',"exp",function(obj){this.explorer.explore(obj);});})(FactoryDebugger.Main,FactoryDebugger);JS2.OO.createClass("FactoryDebugger.Components");(function(K,Package){var self=K;var _super=JS2.OO['super'];K.oo('method',"e_initHTML",function(){this.jq=this.seed.first('.components');this.jqList=this.jq.find('ol:first');this.jqAll=this.jq.find('a.all');this.jqNone=this.jq.find('a.none');this.showList();this.jqSet=this.jq.find('.set');var self=this;this.jqSet.click(function(){self.setList()});this.jqAll.click(function(){self.jqList.find('input').attr("checked",true);});this.jqNone.click(function(){self.jqList.find('input').attr("checked",false);});this.jqList.click(function(evt){self.click(evt.target);});});K.oo('method',"click",function(ele){var jq=$(ele);if(!$(ele).is('label'))return;var compName=jq.html().replace(/(Controller|View)$/,'').replace(/^[\w\.]+\./,'');var nick=compName.substr(0,1).toLowerCase()+compName.substr(1);this.main.exp(this.dFactory.compLookup[nick]);});K.oo('method',"showList",function(){var html='';this.compLookup={};for(var it107=0,comp,it107__arr=this.dFactory.compList,it107__len=it107__arr.length;(comp=it107__arr[it107])||it107<it107__len;it107++){this.compLookup[comp.nickname]=true;html+=this.htmlCache.comp(comp.nickname,comp._klass);}
this.jqList.html(html);});K.oo('method',"setList",function(){this.compLookup={};var inputs=this.jqList.find('input');for(var it108=0,input,it108__arr=inputs,it108__len=it108__arr.length;(input=it108__arr[it108])||it108<it108__len;it108++){if(input.checked){this.compLookup[input.value]=true;}}});})(FactoryDebugger.Components,FactoryDebugger);JS2.OO.createClass("FactoryDebugger.Events");(function(K,Package){var self=K;var _super=JS2.OO['super'];K.oo('method',"e_initHTML",function(){this.jq=this.seed.first('.events');this.jqList=this.jq.find('ol:first');this.jqAll=this.jq.find('a.all');this.jqNone=this.jq.find('a.none');this.showList();this.jqSet=this.jq.find('.set');var self=this;this.jqSet.click(function(){self.setList()});this.jqAll.click(function(){self.jqList.find('input').attr("checked",true);});this.jqNone.click(function(){self.jqList.find('input').attr("checked",false);});});K.oo('method',"showList",function(){var html='';var chains=this.dFactory.compLookup.notifier.chains;this.eventLookup={};for(var evt in chains){this.eventLookup[evt]=true;html+=this.htmlCache.event(evt,evt);}
this.jqList.html(html);});K.oo('method',"setList",function(){this.eventLookup={};var inputs=this.jqList.find('input');for(var it109=0,input,it109__arr=inputs,it109__len=it109__arr.length;(input=it109__arr[it109])||it109<it109__len;it109++){if(input.checked){this.eventLookup[input.value]=true;}}});})(FactoryDebugger.Events,FactoryDebugger);JS2.OO.createClass("FactoryDebugger.EventLog");(function(K,Package){var self=K;var _super=JS2.OO['super'];K.oo('member','dependencies',['components','events']);K.oo('method',"e_initHTML",function(){this.jq=this.seed.first('.eventLog');this.jqLog=this.jq.find('ol');this.jqClear=this.jq.first('.clear');var self=this;this.jqClear.click(function(){self.jqLog.html('');});this.jqStack=[];this.jqLog.click(function(evt){self.click(evt.target);});this.argsStack=[];});K.oo('method',"click",function(ele){var jq=$(ele);if(jq.is('.name')){jq.siblings('.children').toggle();}else if(jq.is('.args')){var argsIdx=parseInt(jq.siblings('.argsIdx').html());this.main.exp(this.argsStack[argsIdx]);}});K.oo('method',"e_notified",function(args){var evt=args[0];if(this.events.eventLookup[evt]){this.jqCurrentEvent=$(this.htmlCache.event(evt,args.length,this.argsStack.length));if(this.jqStack.length==0){this.jqLog.append(this.jqCurrentEvent);}else{this.jqChildren.append(this.jqCurrentEvent);}
this.jqStack.push(this.jqCurrentEvent);this.argsStack.push(args);this.jqChildren=this.jqCurrentEvent.find('.children');}});K.oo('method',"e_finishNotified",function(args){if(this.jqStack.length==0)return;this.jqCurrentEvent=this.jqStack.pop();this.jqChildren=this.jqCurrentEvent.find('.children');});K.oo('method',"e_compNotified",function(comp,args){if(this.components.compLookup[comp.nickname]){this.jqChildren.append(this.htmlCache.component(comp._klass));}});})(FactoryDebugger.EventLog,FactoryDebugger);JS2.OO.createClass("FactoryDebugger.ConsoleLog");(function(K,Package){var self=K;var _super=JS2.OO['super'];K.oo('member','dependencies',['components']);K.oo('method',"e_initHTML",function(){this.jq=this.seed.first('.consoleLog');this.jqLog=this.jq.find('ol');this.jqELog=this.seed.find('.eventLog ol');this.jqClear=this.jq.first('.clear');var self=this;this.jqClear.click(function(){self.jqLog.html('');});this.redirect=false;this.jqRedirect=this.jq.find('input.redirect');this.jqRedirect.click(function(){self.redirect=this.checked;});});K.oo('method',"e_log",function(comp,str){if(this.redirect){this.jqELog.append('<li class="log">'+comp.nickname+': '+str+'</li>');}else{if(this.components.compLookup[comp.nickname]){this.jqLog.append('<li>'+str+'</li>');}}});})(FactoryDebugger.ConsoleLog,FactoryDebugger);JS2.OO.createClass("FactoryDebugger.Notifier");FactoryDebugger.Notifier.oo('extends',JS2.Notifier);(function(K,Package){var self=K;var _super=JS2.OO['super'];K.oo('method',"initialize",function(options){this.js2debugger=options.js2debugger;_super(this);});K.oo('method',"notify",function(){this.js2debugger.notified(arguments);var eventType=arguments[0];var args;if(arguments.length==2){args=[arguments[1]];}else{args=[];for(var i=1;i<arguments.length;i++)args.push(arguments[i]);}
var chain=this.chains[eventType];if(chain){for(var i=0,pair;pair=chain[i++];){this.js2debugger.compNotified(pair[0],args);pair[1].apply(pair[0],args);}}
this.js2debugger.finishNotified(arguments);});})(FactoryDebugger.Notifier,FactoryDebugger);FactoryDebugger.EventLog.oo('setHTMLCache',{"component":function(){return"<li class='component'>"+arguments[0]+"<\/li>"},"event":function(){return"<li class='event'><span class='name'>"+arguments[0]+" <\/span>(<span class='args'>"+arguments[1]+"<\/span>)<span class='argsIdx hidden'>"+arguments[2]+"<\/span><ol class='children'><\/ol><\/li>"}});FactoryDebugger.Components.oo('setHTMLCache',{"comp":function(){return"<li><input checked='checked' type='checkbox' value='"+arguments[0]+"' \/><label>"+arguments[1]+"<\/label><\/li>"}});FactoryDebugger.Main.oo('setHTMLCache',{"main":function(){return"<div class='factoryDebugger fact-tabs'><span class='toggle fact-button'>  <span class='button h p'>    <span>      <a href='javascript:void(0);' name='Submit'>        Toggle      <\/a>    <\/span>  <\/span><\/span><ul class='fact-tabList'><li>Event Log<\/li><li>Console<\/li><li>Components<\/li><li>Events<\/li><\/ul><div class='fact-panes'><div class='eventLog'><span class='clear fact-button'>  <span class='button h p'>    <span>      <a href='javascript:void(0);' name='Submit'>        Clear      <\/a>    <\/span>  <\/span><\/span><ol class='mainChild'><\/ol><\/div><div class='consoleLog'><span class='clear fact-button'>  <span class='button h p'>    <span>      <a href='javascript:void(0);' name='Submit'>        Clear      <\/a>    <\/span>  <\/span><\/span><input class='redirect' type='checkbox'>Merge with event log?<\/input><ol class='mainChild'><\/ol><\/div><div class='components'><a class='all'>All<\/a><span>&nbsp<\/span><a class='none'>None<\/a><span class='set fact-button'>  <span class='button h p'>    <span>      <a href='javascript:void(0);' name='Submit'>        Set      <\/a>    <\/span>  <\/span><\/span><ol class='mainChild'><\/ol><\/div><div class='events'><a class='all'>All<\/a><span>&nbsp<\/span><a class='none'>None<\/a><span class='set fact-button'>  <span class='button h p'>    <span>      <a href='javascript:void(0);' name='Submit'>        Set      <\/a>    <\/span>  <\/span><\/span><ol class='mainChild'><\/ol><\/div><\/div><\/div>"}});FactoryDebugger.Events.oo('setHTMLCache',{"event":function(){return"<li><input checked='checked' type='checkbox' value='"+arguments[0]+"' \/><label>"+arguments[1]+"<\/label><\/li>"},"main":function(){return"<ul class='events'><\/ul>"}});JS2.OO.createClass("JS2.ObjectExplorer");(function(K,Package){var self=K;var _super=JS2.OO['super'];K.oo('method',"initialize",function(){this.main=$(this.htmlCache.main());$(document.body).append(this.main);this.jq=this.main.first('.content');this.jqBack=this.main.first('.back');var self=this;this.jqBack.click(function(){self.back();});this.main.draggable();this.stack=[];this.hide();});K.oo('method',"explore",function(obj){this.obj=obj;this.stack.push(obj);this.show();});K.oo('method',"back",function(){this.stack.pop();this.obj=this.stack[this.stack.length-1];this.show();});K.oo('method',"show",function(){if(this.stack.length<=1){this.jqBack.html('');}else{this.jqBack.html('Back ('+(this.stack.length-1)+')');}
if(this.isArray()){this.showArray();}else if(typeof this.obj=='object'){this.showKlass();}else{this.showString();}
this.main.show();});K.oo('method',"hide",function(){this.main.hide();});K.oo('method',"isArray",function(){var obj=this.obj;if(obj&&obj.length&&obj[obj.length-1]!==undefined){return true;}
return false;});K.oo('method',"showArray",function(){var html='';var obj=this.obj;for(var i=0;i<obj.length;i++){var val=obj[i];if(typeof val=='function'){html+=this.htmlCache.method(i,val.toString());}else{html+=this.htmlCache.member(i,val.toString());}}
this.jq.html(html);var self=this;this.jq.find('.member .key').click(function(){var key=parseInt($(this).html());if(self.obj===undefined)return;var val=self.obj[key];if(val)self.explore(val);});this.jq.find('.method').click(function(){$(this).find('pre').toggle();});});K.oo('method',"showKlass",function(){var html='';var methods='';var members='';for(var key in this.obj){if(key=='_klass')continue;var val=this.obj[key];if(val===undefined)continue;if(typeof val=='function'){methods+=this.htmlCache.method(key,val.toString());}else{members+=this.htmlCache.member(key,val.toString());}}
var html=this.obj._klass?'<h2>'+this.obj._klass+'</h2>':'<h2>Object</h2>';html+='<h3>Members</h3><ul>'+members+'</ul>';html+='<h3>Methods</h3><ul>'+methods+'</ul>';this.jq.html(html);var self=this;this.jq.find('.member .key').click(function(){var key=$(this).html();if(self.obj===undefined)return;var val=self.obj[key];if(val)self.explore(val);});this.jq.find('.method').click(function(){$(this).find('pre').toggle();});});K.oo('method',"showString",function(){this.jq.html(this.obj);});})(JS2.ObjectExplorer,JS2);JS2.ObjectExplorer.oo('setHTMLCache',{"arrayIndex":function(){return"<li class='index'>"+arguments[0]+"<\/li><li class='val'>"+arguments[1]+"<\/li>"},"method":function(){return"<li class='method'>"+arguments[0]+":<pre class='hidden'>"+arguments[1]+"<\/pre><\/li>"},"member":function(){return"<li class='member'><span class='key'>"+arguments[0]+"<\/span>:<span class='val'>"+arguments[1]+"<\/span><\/li>"},"array":function(){return"<ol><\/ol>"},"main":function(){return"<div class='objectExplorer'><div class='back'><\/div><div class='content'><\/div><\/div>"},"string":function(){return"<div><\/div>"},"object":function(){return"<div><\/div>"}});