ComponentJS.plugin("testdrive",function(a,b,c){b.suite=function(){var e=c.jQuery||c.$;if("function"!=typeof e)throw new Error("testdrive#suite() requires jQuery");var f="ComponentJS-testdrive-suite",g=e("body > ."+f);0===g.length&&(g=e('
ComponentJS Test-Drive Use-Cases Suite
close
'),g.hide(),e("body").append(g));var h=function(a){e(g).show().animate({top:0},300,"swing",a)},i=function(a){e(g).animate({top:-l},300,"swing",function(){e(g).hide(),e(g).remove(),"function"==typeof a&&a()})};if(e("body > ."+f).filter(":visible").length>0)return void i();var j=e(c).width(),k=j/10*8,l=400;g.width(k).height(l).css("top",-l).css("left",j/2-k/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"),e("."+f+"-head",g).width(k-20).height(20).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"),e("."+f+"-head-close",g).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"),e("."+f+"-list",g).width(k).height(l-30).css("overflow","scroll").css("overflow-x","hidden");var m=e("");m.append('Identifier | Description |
');var n=0;a.foreach(a.keysof(d).sort(),function(a){m.append(''+a+' | '+d[a].desc+" |
")}),e("."+f+"-list",g).html(m),e("."+f+"-list table",g).width(k).css("border-collapse","collapse"),e("."+f+"-list-row",g).css("cursor","pointer"),e("."+f+"-list-row-first",g).width(k).css("background-color","#909090").css("color","#f0f0f0"),e("."+f+"-list-row-1",g).width(k).css("background-color","#f0f0f0"),e("."+f+"-list-name",g).css("padding","2px 10px 2px 10px").css("font-family","monospace"),e("."+f+"-list-desc",g).width("100%").css("padding","2px 10px 2px 10px"),e("."+f+"-list-row",g).on("click",function(a){var c=a.target;"tr"!==e(c).prop("tagName")&&(c=e(c).parent());var d=e(c).data("id");"string"==typeof d&&""!==d&&i(function(){b.drive(d).then(null,function(a){alert('ComponentJS: testdrive: use case "" failed: '+a)})})}),e("."+f+"-head-close",g).on("click",i),h()},b.promise=function(){var a={exports:{}};return function(b,c,d){"function"==typeof define&&"undefined"!=typeof define.amd?define(c,function(){return d(b)}):"object"==typeof a&&"object"==typeof a.exports?a.exports=d(b):b[c]=function(){var a=b[c],e=d(b);return e.noConflict=function(){return b[c]=a,e},e}()}(this,"Thenable",function(){var a=0,b=1,c=2,d=function(b){return this instanceof d?(this.id="Thenable/1.0.7",this.state=a,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},void("function"==typeof b&&b.call(this,this.fulfill.bind(this),this.reject.bind(this)))):new d(b)};d.prototype={fulfill:function(a){return e(this,b,"fulfillValue",a)},reject:function(a){return e(this,c,"rejectReason",a)},then:function(a,b){var c=this,e=new d;return c.onFulfilled.push(h(a,e,"fulfill")),c.onRejected.push(h(b,e,"reject")),f(c),e.proxy}};var e=function(b,c,d,e){return b.state===a&&(b.state=c,b[d]=e,f(b)),b},f=function(a){a.state===b?g(a,"onFulfilled",a.fulfillValue):a.state===c&&g(a,"onRejected",a.rejectReason)},g=function(a,b,c){if(0!==a[b].length){var d=a[b];a[b]=[];var e=function(){for(var a=0;a0&&(i=setTimeout(function(){i=null,h||(h=!0,b.debug(1,'drive: usecase "'+c.name+'", TIMEOUT after '+c.timeout+" ms"),f.reject(new Error('usecase "'+c.name+'": timeout')))},c.timeout));var j={};a.extend(j,e.conf),a.extend(j,c.conf),b.debug(1,'drive: usecase "'+c.name+'" ('+d[c.name].desc+"), EXECUTING"+(a.keysof(c.conf).length>0?" with configuration "+a.json(c.conf):"")+(c.timeout>0?" and timeout of "+c.timeout+" ms":""));var k;try{k=e.func.apply(j,[j])}catch(l){h||(h=!0,b.debug(1,'drive: usecase "'+c.name+'", EXCEPTION: '+l.message),f.reject(new Error('usecase "'+c.name+'": '+l.message)))}return null!==i&&(clearTimeout(i),i=null),h||("object"!=typeof k&&"function"!=typeof k||"function"!=typeof k.then?f.fulfill(!0):g=k),g=g.then(null,function(a){return b.debug(1,'drive: usecase "'+c.name+'" failed: '+a),a})},b.ensure=function(){var a=b.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"}}),c=new b.promise,d=b(a.path);return d.state({state:a.state,min:a.min,max:a.max,sync:a.sync,func:function(a){c.fulfill(d)}}),c.proxy};var e=[];b.await=function(c,d,g){var h=b.params("await",arguments,{path:{pos:0,req:!0,valid:"string"},state:{pos:1,req:!0,valid:"string"},direction:{pos:2,def:"enter",valid:"string"}});if(a.states.length<=1)throw a.exception("await","no user-defined component states");var i=a.state_name2idx(h.state);if(-1===i)throw a.exception("await",'invalid state name "'+h.state+'": no such state defined');if(!h.direction.match(/^(?:enter|leave)$/))throw a.exception("await",'invalid direction "'+h.direction+'"');var j,k=new b.promise;for(j=0;j