ComponentJS.plugin("testdrive",function(e,t,n){var o={};t.usecase=function(){var n=t.params("usecase",arguments,{name:{pos:0,req:!0,valid:"string"},desc:{pos:1,req:!0,valid:"string"},conf:{def:{},valid:"object"},func:{pos:2,req:!0,valid:"(function|null)"}});if(null===n.func)delete o[n.name];else{if(e.isdefined(o[n.name]))throw e.exception("usecase",'usecase of name "'+n.name+'" already defined');o[n.name]={desc:n.desc,conf:n.conf,func:n.func}}},t.suite=function(){var s=n.jQuery||n.$;if("function"!=typeof s)throw new Error("testdrive#suite() requires jQuery");var i="ComponentJS-testdrive-suite",r=s("body > ."+i);0===r.length&&((r=s('
ComponentJS Test-Drive Use-Cases Suite
close
')).hide(),s("body").append(r));var a=s(n).width(),c=a/10*8,l=function(e){s(r).animate({top:-400},300,"swing",function(){s(r).hide(),s(r).remove(),"function"==typeof e&&e()})};if(s("body > ."+i).filter(":visible").length>0)l();else{r.width(c).height(400).css("box-sizing","content-box").css("top",-400).css("left",a/2-c/2).css("position","absolute").css("z-index",1e4).css("background-color","#f8f8f8").css("-webkit-box-shadow","0 4px 16px 0 #909090").css("box-shadow","0 4px 16px 0 #909090").css("-webkit-border-radius","0 0 8px 8px").css("border-radius","0 0 8px 8px").css("color","#000000").css("font-family","sans-serif").css("font-size","11pt"),s("."+i+"-head",r).width(c-20).height(20).css("box-sizing","content-box").css("position","relative").css("background","#666666").css("background","-moz-linear-gradient(top, #666666 0%, #333333 49%, #222222 51%, #000000 100%)").css("background","-webkit-linear-gradient(top, #666666 0% ,#333333 49% ,#222222 51%, #000000 100%)").css("background","linear-gradient(to bottom, #666666 0%, #333333 49%, #222222 51%, #000000 100%)").css("color","#ffffff").css("padding","7px 10px 7px 10px").css("font-size","16px"),s("."+i+"-head-close",r).css("position","absolute").css("right","10px").css("top","6px").css("padding","4px 10px 4px 10px").css("font-size","12px").css("color","#c0c0c0").css("border","1px solid #606060").css("cursor","pointer"),s("."+i+"-list",r).width(c).height(370).css("overflow","scroll").css("overflow-x","hidden");var f=s("");f.append('Identifier | Description |
');var u=0;e.foreach(e.keysof(o).sort(),function(e){f.append(''+e+' | '+o[e].desc+" |
")}),s("."+i+"-list",r).html(f),s("."+i+"-list table",r).width(c).css("border-collapse","collapse"),s("."+i+"-list-row",r).css("cursor","pointer"),s("."+i+"-list-row-first",r).width(c).css("background-color","#909090").css("color","#f0f0f0"),s("."+i+"-list-row-1",r).width(c).css("background-color","#f0f0f0"),s("."+i+"-list-name",r).css("padding","2px 10px 2px 10px").css("font-family","monospace").css("white-space","nowrap"),s("."+i+"-list-desc",r).width("100%").css("padding","2px 10px 2px 10px"),s("."+i+"-list-row",r).on("click",function(e){var n=e.target;"tr"!==s(n).prop("tagName")&&(n=s(n).parent());var o=s(n).data("id");"string"==typeof o&&""!==o&&l(function(){t.drive(o).then(null,function(e){alert('ComponentJS: testdrive: use case "" failed: '+e)})})}),s("."+i+"-head-close",r).on("click",l),d=void 0,s(r).show().animate({top:0},300,"swing",d);var d}},t.promise=function(){var e={exports:{}};t=this,n="Thenable",o=function(){var e=function(t){if(!(this instanceof e))return new e(t);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof t&&t.call(this,this.fulfill.bind(this),this.reject.bind(this))},t=function(e,t,n){if(0!==e[t].length){var o=e[t];e[t]=[];var s=function(){for(var e=0;e0&&(c=setTimeout(function(){c=null,a||(a=!0,t.debug(1,'drive: usecase "'+n.name+'", TIMEOUT after '+n.timeout+" ms"),i.reject(new Error('usecase "'+n.name+'": timeout')))},n.timeout));var l={};e.extend(l,s.conf),e.extend(l,n.conf),t.debug(1,'drive: usecase "'+n.name+'" ('+o[n.name].desc+"), EXECUTING"+(e.keysof(n.conf).length>0?" with configuration "+e.json(n.conf):"")+(n.timeout>0?" and timeout of "+n.timeout+" ms":""));var f;try{f=s.func.apply(l,[l])}catch(e){a||(a=!0,t.debug(1,'drive: usecase "'+n.name+'", EXCEPTION: '+e.message),i.reject(new Error('usecase "'+n.name+'": '+e.message)))}return null!==c&&(clearTimeout(c),c=null),a||("object"!=typeof f&&"function"!=typeof f||"function"!=typeof f.then?i.fulfill(!0):r=f),r=r.then(null,function(e){return t.debug(1,'drive: usecase "'+n.name+'" failed: '+e),e})},t.ensure=function(){var e=t.params("ensure",arguments,{path:{pos:0,req:!0,valid:"string"},state:{pos:1,req:!0,valid:"string"},min:{def:!0,valid:"boolean"},max:{def:!1,valid:"boolean"},sync:{def:!1,valid:"boolean"}}),n=new t.promise,o=t(e.path);return o.state({state:e.state,min:e.min,max:e.max,sync:e.sync,func:function(e){n.fulfill(o)}}),n.proxy};var s=[],i=function(n,o,i){var r;if(e.states.length<=1)throw e.exception("await(internal)","no user-defined component states");if(o===e.states[1].state&&"enter"===i)for(r=0;r