mirror of
https://github.com/google/blockly.git
synced 2026-06-16 16:15:14 +02:00
No closure toolbox (#2819)
* Update the toolbox to not rely on closure and instead use the built in Blockly.tree component
This commit is contained in:
+198
-271
@@ -734,152 +734,7 @@ goog.ui.Menu.prototype.setAllowHighlightDisabled=function(a){this.allowHighlight
|
||||
goog.ui.Menu.prototype.handleEnterItem=function(a){this.allowAutoFocus_&&this.getKeyEventTarget().focus();return goog.ui.Menu.superClass_.handleEnterItem.call(this,a)};goog.ui.Menu.prototype.highlightNextPrefix=function(a){var b=new RegExp("^"+goog.string.regExpEscape(a),"i");return this.highlightHelper(function(a,d){var c=0>a?0:a,f=!1;do{++a;a==d&&(a=0,f=!0);var g=this.getChildAt(a).getCaption();if(g&&g.match(b))return a}while(!f||a!=c);return this.getHighlightedIndex()},this.getHighlightedIndex())};
|
||||
goog.ui.Menu.prototype.canHighlightItem=function(a){return(this.allowHighlightDisabled_||a.isEnabled())&&a.isVisible()&&a.isSupportedState(goog.ui.Component.State.HOVER)};goog.ui.Menu.prototype.decorateInternal=function(a){this.decorateContent(a);goog.ui.Menu.superClass_.decorateInternal.call(this,a)};
|
||||
goog.ui.Menu.prototype.handleKeyEventInternal=function(a){var b=goog.ui.Menu.superClass_.handleKeyEventInternal.call(this,a);b||this.forEachChild(function(c){!b&&c.getMnemonic&&c.getMnemonic()==a.keyCode&&(this.isEnabled()&&this.setHighlighted(c),b=c.handleKeyEvent(a))},this);return b};goog.ui.Menu.prototype.setHighlightedIndex=function(a){goog.ui.Menu.superClass_.setHighlightedIndex.call(this,a);(a=this.getChildAt(a))&&goog.style.scrollIntoContainerView(a.getElement(),this.getElement())};
|
||||
goog.ui.Menu.prototype.decorateContent=function(a){var b=this.getRenderer();a=this.getDomHelper().getElementsByTagNameAndClass("DIV",b.getCssClass()+"-content",a);for(var c=a.length,d=0;d<c;d++)b.decorateChildren(this,a[d])};goog.Thenable=function(){};goog.Thenable.prototype.then=function(a,b,c){};goog.Thenable.IMPLEMENTED_BY_PROP="$goog_Thenable";goog.Thenable.addImplementation=function(a){COMPILED?a.prototype[goog.Thenable.IMPLEMENTED_BY_PROP]=!0:a.prototype.$goog_Thenable=!0};goog.Thenable.isImplementedBy=function(a){if(!a)return!1;try{return COMPILED?!!a[goog.Thenable.IMPLEMENTED_BY_PROP]:!!a.$goog_Thenable}catch(b){return!1}};goog.async={};goog.async.FreeList=function(a,b,c){this.limit_=c;this.create_=a;this.reset_=b;this.occupants_=0;this.head_=null};goog.async.FreeList.prototype.get=function(){if(0<this.occupants_){this.occupants_--;var a=this.head_;this.head_=a.next;a.next=null}else a=this.create_();return a};goog.async.FreeList.prototype.put=function(a){this.reset_(a);this.occupants_<this.limit_&&(this.occupants_++,a.next=this.head_,this.head_=a)};goog.async.FreeList.prototype.occupants=function(){return this.occupants_};goog.async.WorkQueue=function(){this.workTail_=this.workHead_=null};goog.async.WorkQueue.DEFAULT_MAX_UNUSED=100;goog.async.WorkQueue.freelist_=new goog.async.FreeList(function(){return new goog.async.WorkItem},function(a){a.reset()},goog.async.WorkQueue.DEFAULT_MAX_UNUSED);goog.async.WorkQueue.prototype.add=function(a,b){var c=this.getUnusedItem_();c.set(a,b);this.workTail_?this.workTail_.next=c:(goog.asserts.assert(!this.workHead_),this.workHead_=c);this.workTail_=c};
|
||||
goog.async.WorkQueue.prototype.remove=function(){var a=null;this.workHead_&&(a=this.workHead_,this.workHead_=this.workHead_.next,this.workHead_||(this.workTail_=null),a.next=null);return a};goog.async.WorkQueue.prototype.returnUnused=function(a){goog.async.WorkQueue.freelist_.put(a)};goog.async.WorkQueue.prototype.getUnusedItem_=function(){return goog.async.WorkQueue.freelist_.get()};goog.async.WorkItem=function(){this.next=this.scope=this.fn=null};
|
||||
goog.async.WorkItem.prototype.set=function(a,b){this.fn=a;this.scope=b;this.next=null};goog.async.WorkItem.prototype.reset=function(){this.next=this.scope=this.fn=null};goog.async.throwException=function(a){goog.global.setTimeout(function(){throw a;},0)};goog.async.nextTick=function(a,b,c){var d=a;b&&(d=goog.bind(a,b));d=goog.async.nextTick.wrapCallback_(d);goog.isFunction(goog.global.setImmediate)&&(c||goog.async.nextTick.useSetImmediate_())?goog.global.setImmediate(d):(goog.async.nextTick.setImmediate_||(goog.async.nextTick.setImmediate_=goog.async.nextTick.getSetImmediateEmulator_()),goog.async.nextTick.setImmediate_(d))};
|
||||
goog.async.nextTick.useSetImmediate_=function(){return goog.global.Window&&goog.global.Window.prototype&&!goog.labs.userAgent.browser.isEdge()&&goog.global.Window.prototype.setImmediate==goog.global.setImmediate?!1:!0};
|
||||
goog.async.nextTick.getSetImmediateEmulator_=function(){var a=goog.global.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&!goog.labs.userAgent.engine.isPresto()&&(a=function(){var a=document.createElement("IFRAME");a.style.display="none";goog.dom.safe.setIframeSrc(a,goog.html.TrustedResourceUrl.fromConstant(goog.string.Const.EMPTY));document.documentElement.appendChild(a);var b=a.contentWindow;a=b.document;a.open();goog.dom.safe.documentWrite(a,
|
||||
goog.html.SafeHtml.EMPTY);a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host;a=goog.bind(function(a){if(("*"==d||a.origin==d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&!goog.labs.userAgent.browser.isIE()){var b=new a,c={},d=c;b.port1.onmessage=function(){if(goog.isDef(c.next)){c=c.next;var a=c.cb;
|
||||
c.cb=null;a()}};return function(a){d.next={cb:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(a){var b=document.createElement("SCRIPT");b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};document.documentElement.appendChild(b)}:function(a){goog.global.setTimeout(a,0)}};goog.async.nextTick.wrapCallback_=goog.functions.identity;
|
||||
goog.debug.entryPointRegistry.register(function(a){goog.async.nextTick.wrapCallback_=a});goog.ASSUME_NATIVE_PROMISE=!1;goog.async.run=function(a,b){goog.async.run.schedule_||goog.async.run.initializeRunner_();goog.async.run.workQueueScheduled_||(goog.async.run.schedule_(),goog.async.run.workQueueScheduled_=!0);goog.async.run.workQueue_.add(a,b)};
|
||||
goog.async.run.initializeRunner_=function(){if(goog.ASSUME_NATIVE_PROMISE||goog.global.Promise&&goog.global.Promise.resolve){var a=goog.global.Promise.resolve(void 0);goog.async.run.schedule_=function(){a.then(goog.async.run.processWorkQueue)}}else goog.async.run.schedule_=function(){goog.async.nextTick(goog.async.run.processWorkQueue)}};goog.async.run.forceNextTick=function(a){goog.async.run.schedule_=function(){goog.async.nextTick(goog.async.run.processWorkQueue);a&&a(goog.async.run.processWorkQueue)}};
|
||||
goog.async.run.workQueueScheduled_=!1;goog.async.run.workQueue_=new goog.async.WorkQueue;goog.DEBUG&&(goog.async.run.resetQueue=function(){goog.async.run.workQueueScheduled_=!1;goog.async.run.workQueue_=new goog.async.WorkQueue});goog.async.run.processWorkQueue=function(){for(var a;a=goog.async.run.workQueue_.remove();){try{a.fn.call(a.scope)}catch(b){goog.async.throwException(b)}goog.async.run.workQueue_.returnUnused(a)}goog.async.run.workQueueScheduled_=!1};goog.promise={};goog.promise.Resolver=function(){};goog.Promise=function(a,b){this.state_=goog.Promise.State_.PENDING;this.result_=void 0;this.callbackEntriesTail_=this.callbackEntries_=this.parent_=null;this.executing_=!1;0<goog.Promise.UNHANDLED_REJECTION_DELAY?this.unhandledRejectionId_=0:0==goog.Promise.UNHANDLED_REJECTION_DELAY&&(this.hadUnhandledRejection_=!1);goog.Promise.LONG_STACK_TRACES&&(this.stack_=[],this.addStackTrace_(Error("created")),this.currentStep_=0);if(a!=goog.nullFunction)try{var c=this;a.call(b,function(a){c.resolve_(goog.Promise.State_.FULFILLED,
|
||||
a)},function(a){if(goog.DEBUG&&!(a instanceof goog.Promise.CancellationError))try{if(a instanceof Error)throw a;throw Error("Promise rejected.");}catch(e){}c.resolve_(goog.Promise.State_.REJECTED,a)})}catch(d){this.resolve_(goog.Promise.State_.REJECTED,d)}};goog.Promise.LONG_STACK_TRACES=!1;goog.Promise.UNHANDLED_REJECTION_DELAY=0;goog.Promise.State_={PENDING:0,BLOCKED:1,FULFILLED:2,REJECTED:3};
|
||||
goog.Promise.CallbackEntry_=function(){this.next=this.context=this.onRejected=this.onFulfilled=this.child=null;this.always=!1};goog.Promise.CallbackEntry_.prototype.reset=function(){this.context=this.onRejected=this.onFulfilled=this.child=null;this.always=!1};goog.Promise.DEFAULT_MAX_UNUSED=100;goog.Promise.freelist_=new goog.async.FreeList(function(){return new goog.Promise.CallbackEntry_},function(a){a.reset()},goog.Promise.DEFAULT_MAX_UNUSED);
|
||||
goog.Promise.getCallbackEntry_=function(a,b,c){var d=goog.Promise.freelist_.get();d.onFulfilled=a;d.onRejected=b;d.context=c;return d};goog.Promise.returnEntry_=function(a){goog.Promise.freelist_.put(a)};goog.Promise.resolve=function(a){if(a instanceof goog.Promise)return a;var b=new goog.Promise(goog.nullFunction);b.resolve_(goog.Promise.State_.FULFILLED,a);return b};goog.Promise.reject=function(a){return new goog.Promise(function(b,c){c(a)})};
|
||||
goog.Promise.resolveThen_=function(a,b,c){goog.Promise.maybeThen_(a,b,c,null)||goog.async.run(goog.partial(b,a))};goog.Promise.race=function(a){return new goog.Promise(function(b,c){a.length||b(void 0);for(var d=0,e;d<a.length;d++)e=a[d],goog.Promise.resolveThen_(e,b,c)})};
|
||||
goog.Promise.all=function(a){return new goog.Promise(function(b,c){var d=a.length,e=[];if(d)for(var f=function(a,c){d--;e[a]=c;0==d&&b(e)},g=function(a){c(a)},h=0,k;h<a.length;h++)k=a[h],goog.Promise.resolveThen_(k,goog.partial(f,h),g);else b(e)})};
|
||||
goog.Promise.allSettled=function(a){return new goog.Promise(function(b,c){var d=a.length,e=[];if(d)for(var f=function(a,c,f){d--;e[a]=c?{fulfilled:!0,value:f}:{fulfilled:!1,reason:f};0==d&&b(e)},g=0,h;g<a.length;g++)h=a[g],goog.Promise.resolveThen_(h,goog.partial(f,g,!0),goog.partial(f,g,!1));else b(e)})};
|
||||
goog.Promise.firstFulfilled=function(a){return new goog.Promise(function(b,c){var d=a.length,e=[];if(d)for(var f=function(a){b(a)},g=function(a,b){d--;e[a]=b;0==d&&c(e)},h=0,k;h<a.length;h++)k=a[h],goog.Promise.resolveThen_(k,f,goog.partial(g,h));else b(void 0)})};goog.Promise.withResolver=function(){var a,b,c=new goog.Promise(function(c,e){a=c;b=e});return new goog.Promise.Resolver_(c,a,b)};
|
||||
goog.Promise.prototype.then=function(a,b,c){null!=a&&goog.asserts.assertFunction(a,"opt_onFulfilled should be a function.");null!=b&&goog.asserts.assertFunction(b,"opt_onRejected should be a function. Did you pass opt_context as the second argument instead of the third?");goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("then"));return this.addChildPromise_(goog.isFunction(a)?a:null,goog.isFunction(b)?b:null,c)};goog.Thenable.addImplementation(goog.Promise);
|
||||
goog.Promise.prototype.thenVoid=function(a,b,c){null!=a&&goog.asserts.assertFunction(a,"opt_onFulfilled should be a function.");null!=b&&goog.asserts.assertFunction(b,"opt_onRejected should be a function. Did you pass opt_context as the second argument instead of the third?");goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("then"));this.addCallbackEntry_(goog.Promise.getCallbackEntry_(a||goog.nullFunction,b||null,c))};
|
||||
goog.Promise.prototype.thenAlways=function(a,b){goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("thenAlways"));var c=goog.Promise.getCallbackEntry_(a,a,b);c.always=!0;this.addCallbackEntry_(c);return this};goog.Promise.prototype.thenCatch=function(a,b){goog.Promise.LONG_STACK_TRACES&&this.addStackTrace_(Error("thenCatch"));return this.addChildPromise_(null,a,b)};
|
||||
goog.Promise.prototype.cancel=function(a){this.state_==goog.Promise.State_.PENDING&&goog.async.run(function(){var b=new goog.Promise.CancellationError(a);this.cancelInternal_(b)},this)};goog.Promise.prototype.cancelInternal_=function(a){this.state_==goog.Promise.State_.PENDING&&(this.parent_?(this.parent_.cancelChild_(this,a),this.parent_=null):this.resolve_(goog.Promise.State_.REJECTED,a))};
|
||||
goog.Promise.prototype.cancelChild_=function(a,b){if(this.callbackEntries_){for(var c=0,d=null,e=null,f=this.callbackEntries_;f&&(f.always||(c++,f.child==a&&(d=f),!(d&&1<c)));f=f.next)d||(e=f);d&&(this.state_==goog.Promise.State_.PENDING&&1==c?this.cancelInternal_(b):(e?this.removeEntryAfter_(e):this.popEntry_(),this.executeCallback_(d,goog.Promise.State_.REJECTED,b)))}};
|
||||
goog.Promise.prototype.addCallbackEntry_=function(a){this.hasEntry_()||this.state_!=goog.Promise.State_.FULFILLED&&this.state_!=goog.Promise.State_.REJECTED||this.scheduleCallbacks_();this.queueEntry_(a)};
|
||||
goog.Promise.prototype.addChildPromise_=function(a,b,c){var d=goog.Promise.getCallbackEntry_(null,null,null);d.child=new goog.Promise(function(e,f){d.onFulfilled=a?function(b){try{var d=a.call(c,b);e(d)}catch(k){f(k)}}:e;d.onRejected=b?function(a){try{var d=b.call(c,a);!goog.isDef(d)&&a instanceof goog.Promise.CancellationError?f(a):e(d)}catch(k){f(k)}}:f});d.child.parent_=this;this.addCallbackEntry_(d);return d.child};
|
||||
goog.Promise.prototype.unblockAndFulfill_=function(a){goog.asserts.assert(this.state_==goog.Promise.State_.BLOCKED);this.state_=goog.Promise.State_.PENDING;this.resolve_(goog.Promise.State_.FULFILLED,a)};goog.Promise.prototype.unblockAndReject_=function(a){goog.asserts.assert(this.state_==goog.Promise.State_.BLOCKED);this.state_=goog.Promise.State_.PENDING;this.resolve_(goog.Promise.State_.REJECTED,a)};
|
||||
goog.Promise.prototype.resolve_=function(a,b){this.state_==goog.Promise.State_.PENDING&&(this===b&&(a=goog.Promise.State_.REJECTED,b=new TypeError("Promise cannot resolve to itself")),this.state_=goog.Promise.State_.BLOCKED,goog.Promise.maybeThen_(b,this.unblockAndFulfill_,this.unblockAndReject_,this)||(this.result_=b,this.state_=a,this.parent_=null,this.scheduleCallbacks_(),a!=goog.Promise.State_.REJECTED||b instanceof goog.Promise.CancellationError||goog.Promise.addUnhandledRejection_(this,b)))};
|
||||
goog.Promise.maybeThen_=function(a,b,c,d){if(a instanceof goog.Promise)return a.thenVoid(b,c,d),!0;if(goog.Thenable.isImplementedBy(a))return a.then(b,c,d),!0;if(goog.isObject(a))try{var e=a.then;if(goog.isFunction(e))return goog.Promise.tryThen_(a,e,b,c,d),!0}catch(f){return c.call(d,f),!0}return!1};goog.Promise.tryThen_=function(a,b,c,d,e){var f=!1,g=function(a){f||(f=!0,c.call(e,a))},h=function(a){f||(f=!0,d.call(e,a))};try{b.call(a,g,h)}catch(k){h(k)}};
|
||||
goog.Promise.prototype.scheduleCallbacks_=function(){this.executing_||(this.executing_=!0,goog.async.run(this.executeCallbacks_,this))};goog.Promise.prototype.hasEntry_=function(){return!!this.callbackEntries_};goog.Promise.prototype.queueEntry_=function(a){goog.asserts.assert(null!=a.onFulfilled);this.callbackEntriesTail_?this.callbackEntriesTail_.next=a:this.callbackEntries_=a;this.callbackEntriesTail_=a};
|
||||
goog.Promise.prototype.popEntry_=function(){var a=null;this.callbackEntries_&&(a=this.callbackEntries_,this.callbackEntries_=a.next,a.next=null);this.callbackEntries_||(this.callbackEntriesTail_=null);null!=a&&goog.asserts.assert(null!=a.onFulfilled);return a};goog.Promise.prototype.removeEntryAfter_=function(a){goog.asserts.assert(this.callbackEntries_);goog.asserts.assert(null!=a);a.next==this.callbackEntriesTail_&&(this.callbackEntriesTail_=a);a.next=a.next.next};
|
||||
goog.Promise.prototype.executeCallbacks_=function(){for(var a;a=this.popEntry_();)goog.Promise.LONG_STACK_TRACES&&this.currentStep_++,this.executeCallback_(a,this.state_,this.result_);this.executing_=!1};
|
||||
goog.Promise.prototype.executeCallback_=function(a,b,c){b==goog.Promise.State_.REJECTED&&a.onRejected&&!a.always&&this.removeUnhandledRejection_();if(a.child)a.child.parent_=null,goog.Promise.invokeCallback_(a,b,c);else try{a.always?a.onFulfilled.call(a.context):goog.Promise.invokeCallback_(a,b,c)}catch(d){goog.Promise.handleRejection_.call(null,d)}goog.Promise.returnEntry_(a)};
|
||||
goog.Promise.invokeCallback_=function(a,b,c){b==goog.Promise.State_.FULFILLED?a.onFulfilled.call(a.context,c):a.onRejected&&a.onRejected.call(a.context,c)};goog.Promise.prototype.addStackTrace_=function(a){if(goog.Promise.LONG_STACK_TRACES&&goog.isString(a.stack)){var b=a.stack.split("\n",4)[3];a=a.message;a+=Array(11-a.length).join(" ");this.stack_.push(a+b)}};
|
||||
goog.Promise.prototype.appendLongStack_=function(a){if(goog.Promise.LONG_STACK_TRACES&&a&&goog.isString(a.stack)&&this.stack_.length){for(var b=["Promise trace:"],c=this;c;c=c.parent_){for(var d=this.currentStep_;0<=d;d--)b.push(c.stack_[d]);b.push("Value: ["+(c.state_==goog.Promise.State_.REJECTED?"REJECTED":"FULFILLED")+"] <"+String(c.result_)+">")}a.stack+="\n\n"+b.join("\n")}};
|
||||
goog.Promise.prototype.removeUnhandledRejection_=function(){if(0<goog.Promise.UNHANDLED_REJECTION_DELAY)for(var a=this;a&&a.unhandledRejectionId_;a=a.parent_)goog.global.clearTimeout(a.unhandledRejectionId_),a.unhandledRejectionId_=0;else if(0==goog.Promise.UNHANDLED_REJECTION_DELAY)for(a=this;a&&a.hadUnhandledRejection_;a=a.parent_)a.hadUnhandledRejection_=!1};
|
||||
goog.Promise.addUnhandledRejection_=function(a,b){0<goog.Promise.UNHANDLED_REJECTION_DELAY?a.unhandledRejectionId_=goog.global.setTimeout(function(){a.appendLongStack_(b);goog.Promise.handleRejection_.call(null,b)},goog.Promise.UNHANDLED_REJECTION_DELAY):0==goog.Promise.UNHANDLED_REJECTION_DELAY&&(a.hadUnhandledRejection_=!0,goog.async.run(function(){a.hadUnhandledRejection_&&(a.appendLongStack_(b),goog.Promise.handleRejection_.call(null,b))}))};goog.Promise.handleRejection_=goog.async.throwException;
|
||||
goog.Promise.setUnhandledRejectionHandler=function(a){goog.Promise.handleRejection_=a};goog.Promise.CancellationError=function(a){goog.debug.Error.call(this,a)};goog.inherits(goog.Promise.CancellationError,goog.debug.Error);goog.Promise.CancellationError.prototype.name="cancel";goog.Promise.Resolver_=function(a,b,c){this.promise=a;this.resolve=b;this.reject=c};goog.Timer=function(a,b){goog.events.EventTarget.call(this);this.interval_=a||1;this.timerObject_=b||goog.Timer.defaultTimerObject;this.boundTick_=goog.bind(this.tick_,this);this.last_=goog.now()};goog.inherits(goog.Timer,goog.events.EventTarget);goog.Timer.MAX_TIMEOUT_=2147483647;goog.Timer.INVALID_TIMEOUT_ID_=-1;goog.Timer.prototype.enabled=!1;goog.Timer.defaultTimerObject=goog.global;goog.Timer.intervalScale=.8;goog.Timer.prototype.timer_=null;goog.Timer.prototype.getInterval=function(){return this.interval_};
|
||||
goog.Timer.prototype.setInterval=function(a){this.interval_=a;this.timer_&&this.enabled?(this.stop(),this.start()):this.timer_&&this.stop()};goog.Timer.prototype.tick_=function(){if(this.enabled){var a=goog.now()-this.last_;0<a&&a<this.interval_*goog.Timer.intervalScale?this.timer_=this.timerObject_.setTimeout(this.boundTick_,this.interval_-a):(this.timer_&&(this.timerObject_.clearTimeout(this.timer_),this.timer_=null),this.dispatchTick(),this.enabled&&(this.stop(),this.start()))}};
|
||||
goog.Timer.prototype.dispatchTick=function(){this.dispatchEvent(goog.Timer.TICK)};goog.Timer.prototype.start=function(){this.enabled=!0;this.timer_||(this.timer_=this.timerObject_.setTimeout(this.boundTick_,this.interval_),this.last_=goog.now())};goog.Timer.prototype.stop=function(){this.enabled=!1;this.timer_&&(this.timerObject_.clearTimeout(this.timer_),this.timer_=null)};goog.Timer.prototype.disposeInternal=function(){goog.Timer.superClass_.disposeInternal.call(this);this.stop();delete this.timerObject_};
|
||||
goog.Timer.TICK="tick";goog.Timer.callOnce=function(a,b,c){if(goog.isFunction(a))c&&(a=goog.bind(a,c));else if(a&&"function"==typeof a.handleEvent)a=goog.bind(a.handleEvent,a);else throw Error("Invalid listener argument");return Number(b)>goog.Timer.MAX_TIMEOUT_?goog.Timer.INVALID_TIMEOUT_ID_:goog.Timer.defaultTimerObject.setTimeout(a,b||0)};goog.Timer.clear=function(a){goog.Timer.defaultTimerObject.clearTimeout(a)};
|
||||
goog.Timer.promise=function(a,b){var c=null;return(new goog.Promise(function(d,e){c=goog.Timer.callOnce(function(){d(b)},a);c==goog.Timer.INVALID_TIMEOUT_ID_&&e(Error("Failed to schedule timer."))})).thenCatch(function(a){goog.Timer.clear(c);throw a;})};goog.string.StringBuffer=function(a,b){null!=a&&this.append.apply(this,arguments)};goog.string.StringBuffer.prototype.buffer_="";goog.string.StringBuffer.prototype.set=function(a){this.buffer_=""+a};goog.string.StringBuffer.prototype.append=function(a,b,c){this.buffer_+=String(a);if(null!=b)for(var d=1;d<arguments.length;d++)this.buffer_+=arguments[d];return this};goog.string.StringBuffer.prototype.clear=function(){this.buffer_=""};goog.string.StringBuffer.prototype.getLength=function(){return this.buffer_.length};
|
||||
goog.string.StringBuffer.prototype.toString=function(){return this.buffer_};goog.ui.tree={};goog.ui.tree.BaseNode=function(a,b,c){goog.ui.Component.call(this,c);this.config_=b||goog.ui.tree.BaseNode.defaultConfig;this.html_=goog.html.SafeHtml.htmlEscapePreservingNewlines(a);this.expanded_=this.selected_=!1;this.toolTip_=null;this.afterLabelHtml_=goog.html.SafeHtml.EMPTY;this.isUserCollapsible_=!0;this.depth_=-1};goog.inherits(goog.ui.tree.BaseNode,goog.ui.Component);
|
||||
goog.ui.tree.BaseNode.EventType={BEFORE_EXPAND:"beforeexpand",EXPAND:"expand",BEFORE_COLLAPSE:"beforecollapse",COLLAPSE:"collapse"};goog.ui.tree.BaseNode.allNodes={};goog.ui.tree.BaseNode.prototype.disposeInternal=function(){goog.ui.tree.BaseNode.superClass_.disposeInternal.call(this);this.tree&&(this.tree.removeNode(this),this.tree=null);this.setElementInternal(null)};
|
||||
goog.ui.tree.BaseNode.prototype.initAccessibility=function(){var a=this.getElement();if(a){var b=this.getLabelElement();b&&!b.id&&(b.id=this.getId()+".label");goog.a11y.aria.setRole(a,"treeitem");goog.a11y.aria.setState(a,"selected",!1);goog.a11y.aria.setState(a,"level",this.getDepth());b&&goog.a11y.aria.setState(a,"labelledby",b.id);(b=this.getIconElement())&&goog.a11y.aria.setRole(b,"presentation");(b=this.getExpandIconElement())&&goog.a11y.aria.setRole(b,"presentation");if(b=this.getChildrenElement())if(goog.a11y.aria.setRole(b,
|
||||
"group"),b.hasChildNodes())for(goog.a11y.aria.setState(a,goog.a11y.aria.State.EXPANDED,!1),a=this.getChildCount(),b=1;b<=a;b++){var c=this.getChildAt(b-1).getElement();goog.asserts.assert(c,"The child element cannot be null");goog.a11y.aria.setState(c,"setsize",a);goog.a11y.aria.setState(c,"posinset",b)}}};goog.ui.tree.BaseNode.prototype.createDom=function(){var a=this.getDomHelper().safeHtmlToNode(this.toSafeHtml());this.setElementInternal(a)};
|
||||
goog.ui.tree.BaseNode.prototype.enterDocument=function(){goog.ui.tree.BaseNode.superClass_.enterDocument.call(this);goog.ui.tree.BaseNode.allNodes[this.getId()]=this;this.initAccessibility()};goog.ui.tree.BaseNode.prototype.exitDocument=function(){goog.ui.tree.BaseNode.superClass_.exitDocument.call(this);delete goog.ui.tree.BaseNode.allNodes[this.getId()]};
|
||||
goog.ui.tree.BaseNode.prototype.addChildAt=function(a,b,c){goog.asserts.assert(!a.getParent());goog.asserts.assertInstanceof(a,goog.ui.tree.BaseNode);c=this.getChildAt(b-1);var d=this.getChildAt(b);goog.ui.tree.BaseNode.superClass_.addChildAt.call(this,a,b);a.previousSibling_=c;a.nextSibling_=d;c?c.nextSibling_=a:this.firstChild_=a;d?d.previousSibling_=a:this.lastChild_=a;(b=this.getTree())&&a.setTreeInternal(b);a.setDepth_(this.getDepth()+1);if(b=this.getElement())if(this.updateExpandIcon(),goog.a11y.aria.setState(b,
|
||||
goog.a11y.aria.State.EXPANDED,this.getExpanded()),this.getExpanded()){b=this.getChildrenElement();a.getElement()||a.createDom();var e=a.getElement(),f=d&&d.getElement();b.insertBefore(e,f);this.isInDocument()&&a.enterDocument();d||(c?c.updateExpandIcon():(goog.style.setElementShown(b,!0),this.setExpanded(this.getExpanded())))}};
|
||||
goog.ui.tree.BaseNode.prototype.add=function(a,b){goog.asserts.assert(!b||b.getParent()==this,"Can only add nodes before siblings");a.getParent()&&a.getParent().removeChild(a);this.addChildAt(a,b?this.indexOfChild(b):this.getChildCount());return a};
|
||||
goog.ui.tree.BaseNode.prototype.removeChild=function(a,b){var c=this.getTree(),d=c?c.getSelectedItem():null;if(d==a||a.contains(d))c.hasFocus()?(this.select(),goog.Timer.callOnce(this.onTimeoutSelect_,10,this)):this.select();goog.ui.tree.BaseNode.superClass_.removeChild.call(this,a);this.lastChild_==a&&(this.lastChild_=a.previousSibling_);this.firstChild_==a&&(this.firstChild_=a.nextSibling_);a.previousSibling_&&(a.previousSibling_.nextSibling_=a.nextSibling_);a.nextSibling_&&(a.nextSibling_.previousSibling_=
|
||||
a.previousSibling_);d=a.isLastSibling();a.tree=null;a.depth_=-1;if(c&&(c.removeNode(a),this.isInDocument())){c=this.getChildrenElement();if(a.isInDocument()){var e=a.getElement();c.removeChild(e);a.exitDocument()}d&&(d=this.getLastChild())&&d.updateExpandIcon();this.hasChildren()||(c.style.display="none",this.updateExpandIcon(),this.updateIcon_(),(d=this.getElement())&&goog.a11y.aria.removeState(d,goog.a11y.aria.State.EXPANDED))}return a};goog.ui.tree.BaseNode.prototype.remove=goog.ui.tree.BaseNode.prototype.removeChild;
|
||||
goog.ui.tree.BaseNode.prototype.onTimeoutSelect_=function(){this.select()};goog.ui.tree.BaseNode.prototype.getTree=goog.abstractMethod;goog.ui.tree.BaseNode.prototype.getDepth=function(){var a=this.depth_;0>a&&(a=this.computeDepth_(),this.setDepth_(a));return a};goog.ui.tree.BaseNode.prototype.computeDepth_=function(){var a=this.getParent();return a?a.getDepth()+1:0};
|
||||
goog.ui.tree.BaseNode.prototype.setDepth_=function(a){if(a!=this.depth_){this.depth_=a;var b=this.getRowElement();if(b){var c=this.getPixelIndent_()+"px";this.isRightToLeft()?b.style.paddingRight=c:b.style.paddingLeft=c}this.forEachChild(function(b){b.setDepth_(a+1)})}};goog.ui.tree.BaseNode.prototype.contains=function(a){for(;a;){if(a==this)return!0;a=a.getParent()}return!1};goog.ui.tree.BaseNode.EMPTY_CHILDREN_=[];
|
||||
goog.ui.tree.BaseNode.prototype.getChildren=function(){var a=[];this.forEachChild(function(b){a.push(b)});return a};goog.ui.tree.BaseNode.prototype.getFirstChild=function(){return this.getChildAt(0)};goog.ui.tree.BaseNode.prototype.getLastChild=function(){return this.getChildAt(this.getChildCount()-1)};goog.ui.tree.BaseNode.prototype.getPreviousSibling=function(){return this.previousSibling_};goog.ui.tree.BaseNode.prototype.getNextSibling=function(){return this.nextSibling_};
|
||||
goog.ui.tree.BaseNode.prototype.isLastSibling=function(){return!this.nextSibling_};goog.ui.tree.BaseNode.prototype.isSelected=function(){return this.selected_};goog.ui.tree.BaseNode.prototype.select=function(){var a=this.getTree();a&&a.setSelectedItem(this)};goog.ui.tree.BaseNode.prototype.deselect=goog.nullFunction;
|
||||
goog.ui.tree.BaseNode.prototype.setSelectedInternal=function(a){if(this.selected_!=a){this.selected_=a;this.updateRow();var b=this.getElement();b&&(goog.a11y.aria.setState(b,"selected",a),a&&(a=this.getTree().getElement(),goog.asserts.assert(a,"The DOM element for the tree cannot be null"),goog.a11y.aria.setState(a,"activedescendant",this.getId())))}};goog.ui.tree.BaseNode.prototype.getExpanded=function(){return this.expanded_};
|
||||
goog.ui.tree.BaseNode.prototype.setExpandedInternal=function(a){this.expanded_=a};
|
||||
goog.ui.tree.BaseNode.prototype.setExpanded=function(a){var b=a!=this.expanded_;if(!b||this.dispatchEvent(a?goog.ui.tree.BaseNode.EventType.BEFORE_EXPAND:goog.ui.tree.BaseNode.EventType.BEFORE_COLLAPSE)){this.expanded_=a;var c=this.getTree();var d=this.getElement();if(this.hasChildren()){if(!a&&c&&this.contains(c.getSelectedItem())&&this.select(),d){if(c=this.getChildrenElement())if(goog.style.setElementShown(c,a),goog.a11y.aria.setState(d,goog.a11y.aria.State.EXPANDED,a),a&&this.isInDocument()&&
|
||||
!c.hasChildNodes()){var e=[];this.forEachChild(function(a){e.push(a.toSafeHtml())});goog.dom.safe.setInnerHtml(c,goog.html.SafeHtml.concat(e));this.forEachChild(function(a){a.enterDocument()})}this.updateExpandIcon()}}else(c=this.getChildrenElement())&&goog.style.setElementShown(c,!1);d&&this.updateIcon_();b&&this.dispatchEvent(a?goog.ui.tree.BaseNode.EventType.EXPAND:goog.ui.tree.BaseNode.EventType.COLLAPSE)}};goog.ui.tree.BaseNode.prototype.toggle=function(){this.setExpanded(!this.getExpanded())};
|
||||
goog.ui.tree.BaseNode.prototype.expand=function(){this.setExpanded(!0)};goog.ui.tree.BaseNode.prototype.collapse=function(){this.setExpanded(!1)};goog.ui.tree.BaseNode.prototype.collapseChildren=function(){this.forEachChild(function(a){a.collapseAll()})};goog.ui.tree.BaseNode.prototype.collapseAll=function(){this.collapseChildren();this.collapse()};goog.ui.tree.BaseNode.prototype.expandChildren=function(){this.forEachChild(function(a){a.expandAll()})};
|
||||
goog.ui.tree.BaseNode.prototype.expandAll=function(){this.expandChildren();this.expand()};goog.ui.tree.BaseNode.prototype.reveal=function(){var a=this.getParent();a&&(a.setExpanded(!0),a.reveal())};goog.ui.tree.BaseNode.prototype.setIsUserCollapsible=function(a){(this.isUserCollapsible_=a)||this.expand();this.getElement()&&this.updateExpandIcon()};goog.ui.tree.BaseNode.prototype.isUserCollapsible=function(){return this.isUserCollapsible_};
|
||||
goog.ui.tree.BaseNode.prototype.toSafeHtml=function(){var a=this.getTree(),b=!a.getShowLines()||a==this.getParent()&&!a.getShowRootLines()?this.config_.cssChildrenNoLines:this.config_.cssChildren;a=this.getExpanded()&&this.hasChildren();b={"class":b,style:this.getLineStyle()};var c=[];a&&this.forEachChild(function(a){c.push(a.toSafeHtml())});a=goog.html.SafeHtml.create("div",b,c);return goog.html.SafeHtml.create("div",{"class":this.config_.cssItem,id:this.getId()},[this.getRowSafeHtml(),a])};
|
||||
goog.ui.tree.BaseNode.prototype.getPixelIndent_=function(){return Math.max(0,(this.getDepth()-1)*this.config_.indentWidth)};goog.ui.tree.BaseNode.prototype.getRowSafeHtml=function(){var a={};a["padding-"+(this.isRightToLeft()?"right":"left")]=this.getPixelIndent_()+"px";a={"class":this.getRowClassName(),style:a};var b=[this.getExpandIconSafeHtml(),this.getIconSafeHtml(),this.getLabelSafeHtml()];return goog.html.SafeHtml.create("div",a,b)};
|
||||
goog.ui.tree.BaseNode.prototype.getRowClassName=function(){var a=this.isSelected()?" "+this.config_.cssSelectedRow:"";return this.config_.cssTreeRow+a};goog.ui.tree.BaseNode.prototype.getLabelSafeHtml=function(){var a=goog.html.SafeHtml.create("span",{"class":this.config_.cssItemLabel,title:this.getToolTip()||null},this.getSafeHtml());return goog.html.SafeHtml.concat(a,goog.html.SafeHtml.create("span",{},this.getAfterLabelSafeHtml()))};goog.ui.tree.BaseNode.prototype.getAfterLabelHtml=function(){return goog.html.SafeHtml.unwrap(this.getAfterLabelSafeHtml())};
|
||||
goog.ui.tree.BaseNode.prototype.getAfterLabelSafeHtml=function(){return this.afterLabelHtml_};goog.ui.tree.BaseNode.prototype.setAfterLabelSafeHtml=function(a){this.afterLabelHtml_=a;var b=this.getAfterLabelElement();b&&goog.dom.safe.setInnerHtml(b,a)};goog.ui.tree.BaseNode.prototype.getIconSafeHtml=function(){return goog.html.SafeHtml.create("span",{style:{display:"inline-block"},"class":this.getCalculatedIconClass()})};goog.ui.tree.BaseNode.prototype.getCalculatedIconClass=goog.abstractMethod;
|
||||
goog.ui.tree.BaseNode.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.create("span",{type:"expand",style:{display:"inline-block"},"class":this.getExpandIconClass()})};
|
||||
goog.ui.tree.BaseNode.prototype.getExpandIconClass=function(){var a=this.getTree(),b=!a.getShowLines()||a==this.getParent()&&!a.getShowRootLines(),c=this.config_,d=new goog.string.StringBuffer;d.append(c.cssTreeIcon," ",c.cssExpandTreeIcon," ");if(this.hasChildren()){var e=0;a.getShowExpandIcons()&&this.isUserCollapsible_&&(e=this.getExpanded()?2:1);b||(e=this.isLastSibling()?e+4:e+8);switch(e){case 1:d.append(c.cssExpandTreeIconPlus);break;case 2:d.append(c.cssExpandTreeIconMinus);break;case 4:d.append(c.cssExpandTreeIconL);
|
||||
break;case 5:d.append(c.cssExpandTreeIconLPlus);break;case 6:d.append(c.cssExpandTreeIconLMinus);break;case 8:d.append(c.cssExpandTreeIconT);break;case 9:d.append(c.cssExpandTreeIconTPlus);break;case 10:d.append(c.cssExpandTreeIconTMinus);break;default:d.append(c.cssExpandTreeIconBlank)}}else b?d.append(c.cssExpandTreeIconBlank):this.isLastSibling()?d.append(c.cssExpandTreeIconL):d.append(c.cssExpandTreeIconT);return d.toString()};
|
||||
goog.ui.tree.BaseNode.prototype.getLineStyle=function(){var a=this.getExpanded()&&this.hasChildren();return goog.html.SafeStyle.create({"background-position":this.getBackgroundPosition(),display:a?null:"none"})};goog.ui.tree.BaseNode.prototype.getBackgroundPosition=function(){return(this.isLastSibling()?"-100":(this.getDepth()-1)*this.config_.indentWidth)+"px 0"};
|
||||
goog.ui.tree.BaseNode.prototype.getElement=function(){var a=goog.ui.tree.BaseNode.superClass_.getElement.call(this);a||(a=this.getDomHelper().getElement(this.getId()),this.setElementInternal(a));return a};goog.ui.tree.BaseNode.prototype.getRowElement=function(){var a=this.getElement();return a?a.firstChild:null};goog.ui.tree.BaseNode.prototype.getExpandIconElement=function(){var a=this.getRowElement();return a?a.firstChild:null};
|
||||
goog.ui.tree.BaseNode.prototype.getIconElement=function(){var a=this.getRowElement();return a?a.childNodes[1]:null};goog.ui.tree.BaseNode.prototype.getLabelElement=function(){var a=this.getRowElement();return a&&a.lastChild?a.lastChild.previousSibling:null};goog.ui.tree.BaseNode.prototype.getAfterLabelElement=function(){var a=this.getRowElement();return a?a.lastChild:null};goog.ui.tree.BaseNode.prototype.getChildrenElement=function(){var a=this.getElement();return a?a.lastChild:null};
|
||||
goog.ui.tree.BaseNode.prototype.setIconClass=function(a){this.iconClass_=a;this.isInDocument()&&this.updateIcon_()};goog.ui.tree.BaseNode.prototype.getIconClass=function(){return this.iconClass_};goog.ui.tree.BaseNode.prototype.setExpandedIconClass=function(a){this.expandedIconClass_=a;this.isInDocument()&&this.updateIcon_()};goog.ui.tree.BaseNode.prototype.getExpandedIconClass=function(){return this.expandedIconClass_};goog.ui.tree.BaseNode.prototype.setText=function(a){this.setSafeHtml(goog.html.SafeHtml.htmlEscape(a))};
|
||||
goog.ui.tree.BaseNode.prototype.getText=function(){return goog.string.unescapeEntities(goog.html.SafeHtml.unwrap(this.html_))};goog.ui.tree.BaseNode.prototype.setSafeHtml=function(a){this.html_=a;var b=this.getLabelElement();b&&goog.dom.safe.setInnerHtml(b,a);(a=this.getTree())&&a.setNode(this)};goog.ui.tree.BaseNode.prototype.getHtml=function(){return goog.html.SafeHtml.unwrap(this.getSafeHtml())};goog.ui.tree.BaseNode.prototype.getSafeHtml=function(){return this.html_};
|
||||
goog.ui.tree.BaseNode.prototype.setToolTip=function(a){this.toolTip_=a;var b=this.getLabelElement();b&&(b.title=a)};goog.ui.tree.BaseNode.prototype.getToolTip=function(){return this.toolTip_};goog.ui.tree.BaseNode.prototype.updateRow=function(){var a=this.getRowElement();a&&(a.className=this.getRowClassName())};
|
||||
goog.ui.tree.BaseNode.prototype.updateExpandIcon=function(){var a=this.getExpandIconElement();a&&(a.className=this.getExpandIconClass());if(a=this.getChildrenElement())a.style.backgroundPosition=this.getBackgroundPosition()};goog.ui.tree.BaseNode.prototype.updateIcon_=function(){this.getIconElement().className=this.getCalculatedIconClass()};
|
||||
goog.ui.tree.BaseNode.prototype.onMouseDown=function(a){"expand"==a.target.getAttribute("type")&&this.hasChildren()?this.isUserCollapsible_&&this.toggle():(this.select(),this.updateRow())};goog.ui.tree.BaseNode.prototype.onClick_=goog.events.Event.preventDefault;goog.ui.tree.BaseNode.prototype.onDoubleClick_=function(a){"expand"==a.target.getAttribute("type")&&this.hasChildren()||this.isUserCollapsible_&&this.toggle()};
|
||||
goog.ui.tree.BaseNode.prototype.onKeyDown=function(a){var b=!0;switch(a.keyCode){case goog.events.KeyCodes.RIGHT:if(a.altKey)break;this.hasChildren()&&(this.getExpanded()?this.getFirstChild().select():this.setExpanded(!0));break;case goog.events.KeyCodes.LEFT:if(a.altKey)break;if(this.hasChildren()&&this.getExpanded()&&this.isUserCollapsible_)this.setExpanded(!1);else{var c=this.getParent(),d=this.getTree();c&&(d.getShowRootNode()||c!=d)&&c.select()}break;case goog.events.KeyCodes.DOWN:(c=this.getNextShownNode())&&
|
||||
c.select();break;case goog.events.KeyCodes.UP:(c=this.getPreviousShownNode())&&c.select();break;default:b=!1}b&&(a.preventDefault(),(d=this.getTree())&&d.clearTypeAhead());return b};goog.ui.tree.BaseNode.prototype.getLastShownDescendant=function(){return this.getExpanded()&&this.hasChildren()?this.getLastChild().getLastShownDescendant():this};
|
||||
goog.ui.tree.BaseNode.prototype.getNextShownNode=function(){if(this.hasChildren()&&this.getExpanded())return this.getFirstChild();for(var a=this,b;a!=this.getTree();){b=a.getNextSibling();if(null!=b)return b;a=a.getParent()}return null};goog.ui.tree.BaseNode.prototype.getPreviousShownNode=function(){var a=this.getPreviousSibling();if(null!=a)return a.getLastShownDescendant();a=this.getParent();var b=this.getTree();return!b.getShowRootNode()&&a==b||this==b?null:a};
|
||||
goog.ui.tree.BaseNode.prototype.getClientData=goog.ui.tree.BaseNode.prototype.getModel;goog.ui.tree.BaseNode.prototype.setClientData=goog.ui.tree.BaseNode.prototype.setModel;goog.ui.tree.BaseNode.prototype.getConfig=function(){return this.config_};goog.ui.tree.BaseNode.prototype.setTreeInternal=function(a){this.tree!=a&&(this.tree=a,a.setNode(this),this.forEachChild(function(b){b.setTreeInternal(a)}))};
|
||||
goog.ui.tree.BaseNode.defaultConfig={indentWidth:19,cssRoot:"goog-tree-root goog-tree-item",cssHideRoot:"goog-tree-hide-root",cssItem:"goog-tree-item",cssChildren:"goog-tree-children",cssChildrenNoLines:"goog-tree-children-nolines",cssTreeRow:"goog-tree-row",cssItemLabel:"goog-tree-item-label",cssTreeIcon:"goog-tree-icon",cssExpandTreeIcon:"goog-tree-expand-icon",cssExpandTreeIconPlus:"goog-tree-expand-icon-plus",cssExpandTreeIconMinus:"goog-tree-expand-icon-minus",cssExpandTreeIconTPlus:"goog-tree-expand-icon-tplus",
|
||||
cssExpandTreeIconTMinus:"goog-tree-expand-icon-tminus",cssExpandTreeIconLPlus:"goog-tree-expand-icon-lplus",cssExpandTreeIconLMinus:"goog-tree-expand-icon-lminus",cssExpandTreeIconT:"goog-tree-expand-icon-t",cssExpandTreeIconL:"goog-tree-expand-icon-l",cssExpandTreeIconBlank:"goog-tree-expand-icon-blank",cssExpandedFolderIcon:"goog-tree-expanded-folder-icon",cssCollapsedFolderIcon:"goog-tree-collapsed-folder-icon",cssFileIcon:"goog-tree-file-icon",cssExpandedRootIcon:"goog-tree-expanded-folder-icon",
|
||||
cssCollapsedRootIcon:"goog-tree-collapsed-folder-icon",cssSelectedRow:"selected"};goog.events.FocusHandler=function(a){goog.events.EventTarget.call(this);this.element_=a;a=goog.userAgent.IE?"focusout":"blur";this.listenKeyIn_=goog.events.listen(this.element_,goog.userAgent.IE?"focusin":"focus",this,!goog.userAgent.IE);this.listenKeyOut_=goog.events.listen(this.element_,a,this,!goog.userAgent.IE)};goog.inherits(goog.events.FocusHandler,goog.events.EventTarget);goog.events.FocusHandler.EventType={FOCUSIN:"focusin",FOCUSOUT:"focusout"};
|
||||
goog.events.FocusHandler.prototype.handleEvent=function(a){var b=a.getBrowserEvent();b=new goog.events.BrowserEvent(b);b.type="focusin"==a.type||"focus"==a.type?goog.events.FocusHandler.EventType.FOCUSIN:goog.events.FocusHandler.EventType.FOCUSOUT;this.dispatchEvent(b)};goog.events.FocusHandler.prototype.disposeInternal=function(){goog.events.FocusHandler.superClass_.disposeInternal.call(this);goog.events.unlistenByKey(this.listenKeyIn_);goog.events.unlistenByKey(this.listenKeyOut_);delete this.element_};goog.debug.LogRecord=function(a,b,c,d,e){this.reset(a,b,c,d,e)};goog.debug.LogRecord.prototype.sequenceNumber_=0;goog.debug.LogRecord.prototype.exception_=null;goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS=!0;goog.debug.LogRecord.nextSequenceNumber_=0;
|
||||
goog.debug.LogRecord.prototype.reset=function(a,b,c,d,e){goog.debug.LogRecord.ENABLE_SEQUENCE_NUMBERS&&(this.sequenceNumber_="number"==typeof e?e:goog.debug.LogRecord.nextSequenceNumber_++);this.time_=d||goog.now();this.level_=a;this.msg_=b;this.loggerName_=c;delete this.exception_};goog.debug.LogRecord.prototype.getLoggerName=function(){return this.loggerName_};goog.debug.LogRecord.prototype.getException=function(){return this.exception_};
|
||||
goog.debug.LogRecord.prototype.setException=function(a){this.exception_=a};goog.debug.LogRecord.prototype.setLoggerName=function(a){this.loggerName_=a};goog.debug.LogRecord.prototype.getLevel=function(){return this.level_};goog.debug.LogRecord.prototype.setLevel=function(a){this.level_=a};goog.debug.LogRecord.prototype.getMessage=function(){return this.msg_};goog.debug.LogRecord.prototype.setMessage=function(a){this.msg_=a};goog.debug.LogRecord.prototype.getMillis=function(){return this.time_};
|
||||
goog.debug.LogRecord.prototype.setMillis=function(a){this.time_=a};goog.debug.LogRecord.prototype.getSequenceNumber=function(){return this.sequenceNumber_};goog.debug.LogBuffer=function(){goog.asserts.assert(goog.debug.LogBuffer.isBufferingEnabled(),"Cannot use goog.debug.LogBuffer without defining goog.debug.LogBuffer.CAPACITY.");this.clear()};goog.debug.LogBuffer.getInstance=function(){goog.debug.LogBuffer.instance_||(goog.debug.LogBuffer.instance_=new goog.debug.LogBuffer);return goog.debug.LogBuffer.instance_};goog.debug.LogBuffer.CAPACITY=0;
|
||||
goog.debug.LogBuffer.prototype.addRecord=function(a,b,c){var d=(this.curIndex_+1)%goog.debug.LogBuffer.CAPACITY;this.curIndex_=d;if(this.isFull_)return d=this.buffer_[d],d.reset(a,b,c),d;this.isFull_=d==goog.debug.LogBuffer.CAPACITY-1;return this.buffer_[d]=new goog.debug.LogRecord(a,b,c)};goog.debug.LogBuffer.isBufferingEnabled=function(){return 0<goog.debug.LogBuffer.CAPACITY};
|
||||
goog.debug.LogBuffer.prototype.clear=function(){this.buffer_=Array(goog.debug.LogBuffer.CAPACITY);this.curIndex_=-1;this.isFull_=!1};goog.debug.LogBuffer.prototype.forEachRecord=function(a){var b=this.buffer_;if(b[0]){var c=this.curIndex_,d=this.isFull_?c:-1;do d=(d+1)%goog.debug.LogBuffer.CAPACITY,a(b[d]);while(d!=c)}};goog.debug.Logger=function(a){this.name_=a;this.handlers_=this.children_=this.level_=this.parent_=null};goog.debug.Logger.ROOT_LOGGER_NAME="";goog.debug.Logger.ENABLE_HIERARCHY=!0;goog.debug.Logger.ENABLE_PROFILER_LOGGING=!1;goog.debug.Logger.ENABLE_HIERARCHY||(goog.debug.Logger.rootHandlers_=[]);goog.debug.Logger.Level=function(a,b){this.name=a;this.value=b};goog.debug.Logger.Level.prototype.toString=function(){return this.name};goog.debug.Logger.Level.OFF=new goog.debug.Logger.Level("OFF",Infinity);
|
||||
goog.debug.Logger.Level.SHOUT=new goog.debug.Logger.Level("SHOUT",1200);goog.debug.Logger.Level.SEVERE=new goog.debug.Logger.Level("SEVERE",1E3);goog.debug.Logger.Level.WARNING=new goog.debug.Logger.Level("WARNING",900);goog.debug.Logger.Level.INFO=new goog.debug.Logger.Level("INFO",800);goog.debug.Logger.Level.CONFIG=new goog.debug.Logger.Level("CONFIG",700);goog.debug.Logger.Level.FINE=new goog.debug.Logger.Level("FINE",500);goog.debug.Logger.Level.FINER=new goog.debug.Logger.Level("FINER",400);
|
||||
goog.debug.Logger.Level.FINEST=new goog.debug.Logger.Level("FINEST",300);goog.debug.Logger.Level.ALL=new goog.debug.Logger.Level("ALL",0);goog.debug.Logger.Level.PREDEFINED_LEVELS=[goog.debug.Logger.Level.OFF,goog.debug.Logger.Level.SHOUT,goog.debug.Logger.Level.SEVERE,goog.debug.Logger.Level.WARNING,goog.debug.Logger.Level.INFO,goog.debug.Logger.Level.CONFIG,goog.debug.Logger.Level.FINE,goog.debug.Logger.Level.FINER,goog.debug.Logger.Level.FINEST,goog.debug.Logger.Level.ALL];
|
||||
goog.debug.Logger.Level.predefinedLevelsCache_=null;goog.debug.Logger.Level.createPredefinedLevelsCache_=function(){goog.debug.Logger.Level.predefinedLevelsCache_={};for(var a=0,b;b=goog.debug.Logger.Level.PREDEFINED_LEVELS[a];a++)goog.debug.Logger.Level.predefinedLevelsCache_[b.value]=b,goog.debug.Logger.Level.predefinedLevelsCache_[b.name]=b};
|
||||
goog.debug.Logger.Level.getPredefinedLevel=function(a){goog.debug.Logger.Level.predefinedLevelsCache_||goog.debug.Logger.Level.createPredefinedLevelsCache_();return goog.debug.Logger.Level.predefinedLevelsCache_[a]||null};
|
||||
goog.debug.Logger.Level.getPredefinedLevelByValue=function(a){goog.debug.Logger.Level.predefinedLevelsCache_||goog.debug.Logger.Level.createPredefinedLevelsCache_();if(a in goog.debug.Logger.Level.predefinedLevelsCache_)return goog.debug.Logger.Level.predefinedLevelsCache_[a];for(var b=0;b<goog.debug.Logger.Level.PREDEFINED_LEVELS.length;++b){var c=goog.debug.Logger.Level.PREDEFINED_LEVELS[b];if(c.value<=a)return c}return null};goog.debug.Logger.getLogger=function(a){return goog.debug.LogManager.getLogger(a)};
|
||||
goog.debug.Logger.logToProfilers=function(a){if(goog.debug.Logger.ENABLE_PROFILER_LOGGING){var b=goog.global.msWriteProfilerMark;b?b(a):(b=goog.global.console)&&b.timeStamp&&b.timeStamp(a)}};goog.debug.Logger.prototype.getName=function(){return this.name_};
|
||||
goog.debug.Logger.prototype.addHandler=function(a){goog.debug.LOGGING_ENABLED&&(goog.debug.Logger.ENABLE_HIERARCHY?(this.handlers_||(this.handlers_=[]),this.handlers_.push(a)):(goog.asserts.assert(!this.name_,"Cannot call addHandler on a non-root logger when goog.debug.Logger.ENABLE_HIERARCHY is false."),goog.debug.Logger.rootHandlers_.push(a)))};
|
||||
goog.debug.Logger.prototype.removeHandler=function(a){if(goog.debug.LOGGING_ENABLED){var b=goog.debug.Logger.ENABLE_HIERARCHY?this.handlers_:goog.debug.Logger.rootHandlers_;return!!b&&goog.array.remove(b,a)}return!1};goog.debug.Logger.prototype.getParent=function(){return this.parent_};goog.debug.Logger.prototype.getChildren=function(){this.children_||(this.children_={});return this.children_};
|
||||
goog.debug.Logger.prototype.setLevel=function(a){goog.debug.LOGGING_ENABLED&&(goog.debug.Logger.ENABLE_HIERARCHY?this.level_=a:(goog.asserts.assert(!this.name_,"Cannot call setLevel() on a non-root logger when goog.debug.Logger.ENABLE_HIERARCHY is false."),goog.debug.Logger.rootLevel_=a))};goog.debug.Logger.prototype.getLevel=function(){return goog.debug.LOGGING_ENABLED?this.level_:goog.debug.Logger.Level.OFF};
|
||||
goog.debug.Logger.prototype.getEffectiveLevel=function(){if(!goog.debug.LOGGING_ENABLED)return goog.debug.Logger.Level.OFF;if(!goog.debug.Logger.ENABLE_HIERARCHY)return goog.debug.Logger.rootLevel_;if(this.level_)return this.level_;if(this.parent_)return this.parent_.getEffectiveLevel();goog.asserts.fail("Root logger has no level set.");return null};goog.debug.Logger.prototype.isLoggable=function(a){return goog.debug.LOGGING_ENABLED&&a.value>=this.getEffectiveLevel().value};
|
||||
goog.debug.Logger.prototype.log=function(a,b,c){goog.debug.LOGGING_ENABLED&&this.isLoggable(a)&&(goog.isFunction(b)&&(b=b()),this.doLogRecord_(this.getLogRecord(a,b,c)))};goog.debug.Logger.prototype.getLogRecord=function(a,b,c){a=goog.debug.LogBuffer.isBufferingEnabled()?goog.debug.LogBuffer.getInstance().addRecord(a,b,this.name_):new goog.debug.LogRecord(a,String(b),this.name_);c&&a.setException(c);return a};
|
||||
goog.debug.Logger.prototype.shout=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SHOUT,a,b)};goog.debug.Logger.prototype.severe=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.SEVERE,a,b)};goog.debug.Logger.prototype.warning=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.WARNING,a,b)};goog.debug.Logger.prototype.info=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.INFO,a,b)};
|
||||
goog.debug.Logger.prototype.config=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.CONFIG,a,b)};goog.debug.Logger.prototype.fine=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINE,a,b)};goog.debug.Logger.prototype.finer=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINER,a,b)};goog.debug.Logger.prototype.finest=function(a,b){goog.debug.LOGGING_ENABLED&&this.log(goog.debug.Logger.Level.FINEST,a,b)};
|
||||
goog.debug.Logger.prototype.logRecord=function(a){goog.debug.LOGGING_ENABLED&&this.isLoggable(a.getLevel())&&this.doLogRecord_(a)};goog.debug.Logger.prototype.doLogRecord_=function(a){goog.debug.Logger.ENABLE_PROFILER_LOGGING&&goog.debug.Logger.logToProfilers("log:"+a.getMessage());if(goog.debug.Logger.ENABLE_HIERARCHY)for(var b=this;b;)b.callPublish_(a),b=b.getParent();else{b=0;for(var c;c=goog.debug.Logger.rootHandlers_[b++];)c(a)}};
|
||||
goog.debug.Logger.prototype.callPublish_=function(a){if(this.handlers_)for(var b=0,c;c=this.handlers_[b];b++)c(a)};goog.debug.Logger.prototype.setParent_=function(a){this.parent_=a};goog.debug.Logger.prototype.addChild_=function(a,b){this.getChildren()[a]=b};goog.debug.LogManager={};goog.debug.LogManager.loggers_={};goog.debug.LogManager.rootLogger_=null;
|
||||
goog.debug.LogManager.initialize=function(){goog.debug.LogManager.rootLogger_||(goog.debug.LogManager.rootLogger_=new goog.debug.Logger(goog.debug.Logger.ROOT_LOGGER_NAME),goog.debug.LogManager.loggers_[goog.debug.Logger.ROOT_LOGGER_NAME]=goog.debug.LogManager.rootLogger_,goog.debug.LogManager.rootLogger_.setLevel(goog.debug.Logger.Level.CONFIG))};goog.debug.LogManager.getLoggers=function(){return goog.debug.LogManager.loggers_};
|
||||
goog.debug.LogManager.getRoot=function(){goog.debug.LogManager.initialize();return goog.debug.LogManager.rootLogger_};goog.debug.LogManager.getLogger=function(a){goog.debug.LogManager.initialize();return goog.debug.LogManager.loggers_[a]||goog.debug.LogManager.createLogger_(a)};goog.debug.LogManager.createFunctionForCatchErrors=function(a){return function(b){(a||goog.debug.LogManager.getRoot()).severe("Error: "+b.message+" ("+b.fileName+" @ Line: "+b.line+")")}};
|
||||
goog.debug.LogManager.createLogger_=function(a){var b=new goog.debug.Logger(a);if(goog.debug.Logger.ENABLE_HIERARCHY){var c=a.lastIndexOf("."),d=a.substr(0,c);c=a.substr(c+1);d=goog.debug.LogManager.getLogger(d);d.addChild_(c,b);b.setParent_(d)}return goog.debug.LogManager.loggers_[a]=b};goog.log={};goog.log.ENABLED=goog.debug.LOGGING_ENABLED;goog.log.ROOT_LOGGER_NAME=goog.debug.Logger.ROOT_LOGGER_NAME;goog.log.Logger=goog.debug.Logger;goog.log.Level=goog.debug.Logger.Level;goog.log.LogRecord=goog.debug.LogRecord;goog.log.getLogger=function(a,b){if(goog.log.ENABLED){var c=goog.debug.LogManager.getLogger(a);b&&c&&c.setLevel(b);return c}return null};goog.log.addHandler=function(a,b){goog.log.ENABLED&&a&&a.addHandler(b)};
|
||||
goog.log.removeHandler=function(a,b){return goog.log.ENABLED&&a?a.removeHandler(b):!1};goog.log.log=function(a,b,c,d){goog.log.ENABLED&&a&&a.log(b,c,d)};goog.log.error=function(a,b,c){goog.log.ENABLED&&a&&a.severe(b,c)};goog.log.warning=function(a,b,c){goog.log.ENABLED&&a&&a.warning(b,c)};goog.log.info=function(a,b,c){goog.log.ENABLED&&a&&a.info(b,c)};goog.log.fine=function(a,b,c){goog.log.ENABLED&&a&&a.fine(b,c)};goog.ui.tree.TreeNode=function(a,b,c){goog.ui.tree.BaseNode.call(this,a,b,c)};goog.inherits(goog.ui.tree.TreeNode,goog.ui.tree.BaseNode);goog.ui.tree.TreeNode.prototype.getTree=function(){if(this.tree)return this.tree;var a=this.getParent();return a&&(a=a.getTree())?(this.setTreeInternal(a),a):null};
|
||||
goog.ui.tree.TreeNode.prototype.getCalculatedIconClass=function(){var a=this.getExpanded(),b=this.getExpandedIconClass();if(a&&b)return b;b=this.getIconClass();if(!a&&b)return b;b=this.getConfig();if(this.hasChildren()){if(a&&b.cssExpandedFolderIcon)return b.cssTreeIcon+" "+b.cssExpandedFolderIcon;if(!a&&b.cssCollapsedFolderIcon)return b.cssTreeIcon+" "+b.cssCollapsedFolderIcon}else if(b.cssFileIcon)return b.cssTreeIcon+" "+b.cssFileIcon;return""};goog.structs={};goog.structs.getCount=function(a){return a.getCount&&"function"==typeof a.getCount?a.getCount():goog.isArrayLike(a)||goog.isString(a)?a.length:goog.object.getCount(a)};goog.structs.getValues=function(a){if(a.getValues&&"function"==typeof a.getValues)return a.getValues();if(goog.isString(a))return a.split("");if(goog.isArrayLike(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return goog.object.getValues(a)};
|
||||
goog.structs.getKeys=function(a){if(a.getKeys&&"function"==typeof a.getKeys)return a.getKeys();if(!a.getValues||"function"!=typeof a.getValues){if(goog.isArrayLike(a)||goog.isString(a)){var b=[];a=a.length;for(var c=0;c<a;c++)b.push(c);return b}return goog.object.getKeys(a)}};
|
||||
goog.structs.contains=function(a,b){return a.contains&&"function"==typeof a.contains?a.contains(b):a.containsValue&&"function"==typeof a.containsValue?a.containsValue(b):goog.isArrayLike(a)||goog.isString(a)?goog.array.contains(a,b):goog.object.containsValue(a,b)};goog.structs.isEmpty=function(a){return a.isEmpty&&"function"==typeof a.isEmpty?a.isEmpty():goog.isArrayLike(a)||goog.isString(a)?goog.array.isEmpty(a):goog.object.isEmpty(a)};
|
||||
goog.structs.clear=function(a){a.clear&&"function"==typeof a.clear?a.clear():goog.isArrayLike(a)?goog.array.clear(a):goog.object.clear(a)};goog.structs.forEach=function(a,b,c){if(a.forEach&&"function"==typeof a.forEach)a.forEach(b,c);else if(goog.isArrayLike(a)||goog.isString(a))goog.array.forEach(a,b,c);else for(var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length,g=0;g<f;g++)b.call(c,e[g],d&&d[g],a)};
|
||||
goog.structs.filter=function(a,b,c){if("function"==typeof a.filter)return a.filter(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.filter(a,b,c);var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length;if(d){var g={};for(var h=0;h<f;h++)b.call(c,e[h],d[h],a)&&(g[d[h]]=e[h])}else for(g=[],h=0;h<f;h++)b.call(c,e[h],void 0,a)&&g.push(e[h]);return g};
|
||||
goog.structs.map=function(a,b,c){if("function"==typeof a.map)return a.map(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.map(a,b,c);var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length;if(d){var g={};for(var h=0;h<f;h++)g[d[h]]=b.call(c,e[h],d[h],a)}else for(g=[],h=0;h<f;h++)g[h]=b.call(c,e[h],void 0,a);return g};
|
||||
goog.structs.some=function(a,b,c){if("function"==typeof a.some)return a.some(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.some(a,b,c);for(var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length,g=0;g<f;g++)if(b.call(c,e[g],d&&d[g],a))return!0;return!1};
|
||||
goog.structs.every=function(a,b,c){if("function"==typeof a.every)return a.every(b,c);if(goog.isArrayLike(a)||goog.isString(a))return goog.array.every(a,b,c);for(var d=goog.structs.getKeys(a),e=goog.structs.getValues(a),f=e.length,g=0;g<f;g++)if(!b.call(c,e[g],d&&d[g],a))return!1;return!0};goog.structs.Trie=function(a){this.value_=void 0;this.childNodes_={};a&&this.setAll(a)};goog.structs.Trie.prototype.set=function(a,b){this.setOrAdd_(a,b,!1)};goog.structs.Trie.prototype.add=function(a,b){this.setOrAdd_(a,b,!0)};
|
||||
goog.structs.Trie.prototype.setOrAdd_=function(a,b,c){for(var d=this,e=0;e<a.length;e++){var f=a.charAt(e);d.childNodes_[f]||(d.childNodes_[f]=new goog.structs.Trie);d=d.childNodes_[f]}if(c&&void 0!==d.value_)throw Error('The collection already contains the key "'+a+'"');d.value_=b};goog.structs.Trie.prototype.setAll=function(a){var b=goog.structs.getKeys(a);a=goog.structs.getValues(a);for(var c=0;c<b.length;c++)this.set(b[c],a[c])};
|
||||
goog.structs.Trie.prototype.getChildNode_=function(a){for(var b=this,c=0;c<a.length;c++){var d=a.charAt(c);b=b.childNodes_[d];if(!b)return}return b};goog.structs.Trie.prototype.get=function(a){return(a=this.getChildNode_(a))?a.value_:void 0};goog.structs.Trie.prototype.getKeyAndPrefixes=function(a,b){var c=this,d={},e=b||0;void 0!==c.value_&&(d[e]=c.value_);for(;e<a.length;e++){var f=a.charAt(e);if(!(f in c.childNodes_))break;c=c.childNodes_[f];void 0!==c.value_&&(d[e]=c.value_)}return d};
|
||||
goog.structs.Trie.prototype.getValues=function(){var a=[];this.getValuesInternal_(a);return a};goog.structs.Trie.prototype.getValuesInternal_=function(a){void 0!==this.value_&&a.push(this.value_);for(var b in this.childNodes_)this.childNodes_[b].getValuesInternal_(a)};goog.structs.Trie.prototype.getKeys=function(a){var b=[];if(a){for(var c=this,d=0;d<a.length;d++){var e=a.charAt(d);if(!c.childNodes_[e])return[];c=c.childNodes_[e]}c.getKeysInternal_(a,b)}else this.getKeysInternal_("",b);return b};
|
||||
goog.structs.Trie.prototype.getKeysInternal_=function(a,b){void 0!==this.value_&&b.push(a);for(var c in this.childNodes_)this.childNodes_[c].getKeysInternal_(a+c,b)};goog.structs.Trie.prototype.containsKey=function(a){return void 0!==this.get(a)};goog.structs.Trie.prototype.containsPrefix=function(a){return 0==a.length?!this.isEmpty():!!this.getChildNode_(a)};
|
||||
goog.structs.Trie.prototype.containsValue=function(a){if(this.value_===a)return!0;for(var b in this.childNodes_)if(this.childNodes_[b].containsValue(a))return!0;return!1};goog.structs.Trie.prototype.clear=function(){this.childNodes_={};this.value_=void 0};
|
||||
goog.structs.Trie.prototype.remove=function(a){for(var b=this,c=[],d=0;d<a.length;d++){var e=a.charAt(d);if(!b.childNodes_[e])throw Error('The collection does not have the key "'+a+'"');c.push([b,e]);b=b.childNodes_[e]}a=b.value_;for(delete b.value_;0<c.length;)if(e=c.pop(),b=e[0],e=e[1],b.childNodes_[e].isEmpty())delete b.childNodes_[e];else break;return a};goog.structs.Trie.prototype.clone=function(){return new goog.structs.Trie(this)};goog.structs.Trie.prototype.getCount=function(){return goog.structs.getCount(this.getValues())};
|
||||
goog.structs.Trie.prototype.isEmpty=function(){return void 0===this.value_&&goog.object.isEmpty(this.childNodes_)};goog.ui.tree.TypeAhead=function(){this.nodeMap_=new goog.structs.Trie;this.buffer_="";this.matchingNodes_=this.matchingLabels_=null;this.matchingNodeIndex_=this.matchingLabelIndex_=0};goog.ui.tree.TypeAhead.Offset={DOWN:1,UP:-1};
|
||||
goog.ui.tree.TypeAhead.prototype.handleNavigation=function(a){var b=!1;switch(a.keyCode){case goog.events.KeyCodes.DOWN:case goog.events.KeyCodes.UP:a.ctrlKey&&(this.jumpTo_(a.keyCode==goog.events.KeyCodes.DOWN?goog.ui.tree.TypeAhead.Offset.DOWN:goog.ui.tree.TypeAhead.Offset.UP),b=!0);break;case goog.events.KeyCodes.BACKSPACE:a=this.buffer_.length-1;b=!0;0<a?(this.buffer_=this.buffer_.substring(0,a),this.jumpToLabel_(this.buffer_)):0==a?this.buffer_="":b=!1;break;case goog.events.KeyCodes.ESC:this.buffer_=
|
||||
"",b=!0}return b};goog.ui.tree.TypeAhead.prototype.handleTypeAheadChar=function(a){var b=!1;a.ctrlKey||a.altKey||(a=String.fromCharCode(a.charCode||a.keyCode).toLowerCase(),goog.string.isUnicodeChar(a)&&(" "!=a||this.buffer_)&&(this.buffer_+=a,b=this.jumpToLabel_(this.buffer_)));return b};
|
||||
goog.ui.tree.TypeAhead.prototype.setNodeInMap=function(a){var b=a.getText();if(b&&!goog.string.isEmptyOrWhitespace(goog.string.makeSafe(b))){b=b.toLowerCase();var c=this.nodeMap_.get(b);c?c.push(a):this.nodeMap_.set(b,[a])}};
|
||||
goog.ui.tree.TypeAhead.prototype.removeNodeFromMap=function(a){var b=a.getText();if(b&&!goog.string.isEmptyOrWhitespace(goog.string.makeSafe(b))){b=b.toLowerCase();var c=this.nodeMap_.get(b);if(c){for(var d=a.getChildCount(),e=0;e<d;e++)this.removeNodeFromMap(a.getChildAt(e));goog.array.remove(c,a);c.length||this.nodeMap_.remove(b)}}};
|
||||
goog.ui.tree.TypeAhead.prototype.jumpToLabel_=function(a){var b=!1;(a=this.nodeMap_.getKeys(a))&&a.length&&(this.matchingLabelIndex_=this.matchingNodeIndex_=0,b=this.nodeMap_.get(a[0]),b=this.selectMatchingNode_(b))&&(this.matchingLabels_=a);return b};
|
||||
goog.ui.tree.TypeAhead.prototype.jumpTo_=function(a){var b=!1,c=this.matchingLabels_;if(c){b=null;var d=!1;if(this.matchingNodes_){var e=this.matchingNodeIndex_+a;0<=e&&e<this.matchingNodes_.length?(this.matchingNodeIndex_=e,b=this.matchingNodes_):d=!0}b||(e=this.matchingLabelIndex_+a,0<=e&&e<c.length&&(this.matchingLabelIndex_=e),c.length>this.matchingLabelIndex_&&(b=this.nodeMap_.get(c[this.matchingLabelIndex_])),b&&b.length&&d&&(this.matchingNodeIndex_=a==goog.ui.tree.TypeAhead.Offset.UP?b.length-
|
||||
1:0));if(b=this.selectMatchingNode_(b))this.matchingLabels_=c}return b};goog.ui.tree.TypeAhead.prototype.selectMatchingNode_=function(a){if(a){if(this.matchingNodeIndex_<a.length){var b=a[this.matchingNodeIndex_];this.matchingNodes_=a}b&&(b.reveal(),b.select())}return!!b};goog.ui.tree.TypeAhead.prototype.clear=function(){this.buffer_=""};goog.ui.tree.TreeControl=function(a,b,c){goog.ui.tree.BaseNode.call(this,a,b,c);this.setExpandedInternal(!0);this.setSelectedInternal(!0);this.selectedItem_=this;this.typeAhead_=new goog.ui.tree.TypeAhead;this.focusHandler_=this.keyHandler_=null;this.logger_=goog.log.getLogger("this");this.focused_=!1;this.focusedNode_=null;this.showRootLines_=this.showRootNode_=this.showExpandIcons_=this.showLines_=!0;if(goog.userAgent.IE)try{document.execCommand("BackgroundImageCache",!1,!0)}catch(d){goog.log.warning(this.logger_,
|
||||
"Failed to enable background image cache")}};goog.inherits(goog.ui.tree.TreeControl,goog.ui.tree.BaseNode);goog.ui.tree.TreeControl.prototype.getTree=function(){return this};goog.ui.tree.TreeControl.prototype.getDepth=function(){return 0};goog.ui.tree.TreeControl.prototype.reveal=function(){};goog.ui.tree.TreeControl.prototype.handleFocus_=function(a){this.focused_=!0;goog.dom.classlist.add(goog.asserts.assert(this.getElement()),"focused");this.selectedItem_&&this.selectedItem_.select()};
|
||||
goog.ui.tree.TreeControl.prototype.handleBlur_=function(a){this.focused_=!1;goog.dom.classlist.remove(goog.asserts.assert(this.getElement()),"focused")};goog.ui.tree.TreeControl.prototype.hasFocus=function(){return this.focused_};goog.ui.tree.TreeControl.prototype.getExpanded=function(){return!this.showRootNode_||goog.ui.tree.TreeControl.superClass_.getExpanded.call(this)};
|
||||
goog.ui.tree.TreeControl.prototype.setExpanded=function(a){this.showRootNode_?goog.ui.tree.TreeControl.superClass_.setExpanded.call(this,a):this.setExpandedInternal(a)};goog.ui.tree.TreeControl.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.EMPTY};goog.ui.tree.TreeControl.prototype.getIconElement=function(){var a=this.getRowElement();return a?a.firstChild:null};goog.ui.tree.TreeControl.prototype.getExpandIconElement=function(){return null};
|
||||
goog.ui.tree.TreeControl.prototype.updateExpandIcon=function(){};goog.ui.tree.TreeControl.prototype.getRowClassName=function(){return goog.ui.tree.TreeControl.superClass_.getRowClassName.call(this)+(this.showRootNode_?"":" "+this.getConfig().cssHideRoot)};
|
||||
goog.ui.tree.TreeControl.prototype.getCalculatedIconClass=function(){var a=this.getExpanded(),b=this.getExpandedIconClass();if(a&&b)return b;b=this.getIconClass();if(!a&&b)return b;b=this.getConfig();return a&&b.cssExpandedRootIcon?b.cssTreeIcon+" "+b.cssExpandedRootIcon:!a&&b.cssCollapsedRootIcon?b.cssTreeIcon+" "+b.cssCollapsedRootIcon:""};
|
||||
goog.ui.tree.TreeControl.prototype.setSelectedItem=function(a){if(this.selectedItem_!=a){var b=!1;this.selectedItem_&&(b=this.selectedItem_==this.focusedNode_,this.selectedItem_.setSelectedInternal(!1));if(this.selectedItem_=a)a.setSelectedInternal(!0),b&&a.select();this.dispatchEvent(goog.events.EventType.CHANGE)}};goog.ui.tree.TreeControl.prototype.getSelectedItem=function(){return this.selectedItem_};
|
||||
goog.ui.tree.TreeControl.prototype.setShowLines=function(a){this.showLines_!=a&&(this.showLines_=a,this.isInDocument()&&this.updateLinesAndExpandIcons_())};goog.ui.tree.TreeControl.prototype.getShowLines=function(){return this.showLines_};
|
||||
goog.ui.tree.TreeControl.prototype.updateLinesAndExpandIcons_=function(){function a(e){var f=e.getChildrenElement();if(f){var g=!c||b==e.getParent()&&!d?e.getConfig().cssChildrenNoLines:e.getConfig().cssChildren;f.className=g;if(f=e.getExpandIconElement())f.className=e.getExpandIconClass()}e.forEachChild(a)}var b=this,c=b.getShowLines(),d=b.getShowRootLines();a(this)};
|
||||
goog.ui.tree.TreeControl.prototype.setShowRootLines=function(a){this.showRootLines_!=a&&(this.showRootLines_=a,this.isInDocument()&&this.updateLinesAndExpandIcons_())};goog.ui.tree.TreeControl.prototype.getShowRootLines=function(){return this.showRootLines_};goog.ui.tree.TreeControl.prototype.setShowExpandIcons=function(a){this.showExpandIcons_!=a&&(this.showExpandIcons_=a,this.isInDocument()&&this.updateLinesAndExpandIcons_())};goog.ui.tree.TreeControl.prototype.getShowExpandIcons=function(){return this.showExpandIcons_};
|
||||
goog.ui.tree.TreeControl.prototype.setShowRootNode=function(a){if(this.showRootNode_!=a){this.showRootNode_=a;if(this.isInDocument()){var b=this.getRowElement();b&&(b.className=this.getRowClassName())}!a&&this.getSelectedItem()==this&&this.getFirstChild()&&this.setSelectedItem(this.getFirstChild())}};goog.ui.tree.TreeControl.prototype.getShowRootNode=function(){return this.showRootNode_};
|
||||
goog.ui.tree.TreeControl.prototype.initAccessibility=function(){goog.ui.tree.TreeControl.superClass_.initAccessibility.call(this);var a=this.getElement();goog.asserts.assert(a,"The DOM element for the tree cannot be null.");goog.a11y.aria.setRole(a,"tree");goog.a11y.aria.setState(a,"labelledby",this.getLabelElement().id)};
|
||||
goog.ui.tree.TreeControl.prototype.enterDocument=function(){goog.ui.tree.TreeControl.superClass_.enterDocument.call(this);var a=this.getElement();a.className=this.getConfig().cssRoot;a.setAttribute("hideFocus","true");this.attachEvents_();this.initAccessibility()};goog.ui.tree.TreeControl.prototype.exitDocument=function(){goog.ui.tree.TreeControl.superClass_.exitDocument.call(this);this.detachEvents_()};
|
||||
goog.ui.tree.TreeControl.prototype.attachEvents_=function(){var a=this.getElement();a.tabIndex=0;var b=this.keyHandler_=new goog.events.KeyHandler(a),c=this.focusHandler_=new goog.events.FocusHandler(a);this.getHandler().listen(c,goog.events.FocusHandler.EventType.FOCUSOUT,this.handleBlur_).listen(c,goog.events.FocusHandler.EventType.FOCUSIN,this.handleFocus_).listen(b,goog.events.KeyHandler.EventType.KEY,this.handleKeyEvent).listen(a,goog.events.EventType.MOUSEDOWN,this.handleMouseEvent_).listen(a,
|
||||
goog.events.EventType.CLICK,this.handleMouseEvent_).listen(a,goog.events.EventType.DBLCLICK,this.handleMouseEvent_)};goog.ui.tree.TreeControl.prototype.detachEvents_=function(){this.keyHandler_.dispose();this.keyHandler_=null;this.focusHandler_.dispose();this.focusHandler_=null};
|
||||
goog.ui.tree.TreeControl.prototype.handleMouseEvent_=function(a){goog.log.fine(this.logger_,"Received event "+a.type);var b=this.getNodeFromEvent_(a);if(b)switch(a.type){case goog.events.EventType.MOUSEDOWN:b.onMouseDown(a);break;case goog.events.EventType.CLICK:b.onClick_(a);break;case goog.events.EventType.DBLCLICK:b.onDoubleClick_(a)}};
|
||||
goog.ui.tree.TreeControl.prototype.handleKeyEvent=function(a){var b;(b=this.typeAhead_.handleNavigation(a)||this.selectedItem_&&this.selectedItem_.onKeyDown(a)||this.typeAhead_.handleTypeAheadChar(a))&&a.preventDefault();return b};goog.ui.tree.TreeControl.prototype.getNodeFromEvent_=function(a){for(var b=a.target;null!=b;){if(a=goog.ui.tree.BaseNode.allNodes[b.id])return a;if(b==this.getElement())break;b=b.parentNode}return null};
|
||||
goog.ui.tree.TreeControl.prototype.createNode=function(a){return new goog.ui.tree.TreeNode(a||goog.html.SafeHtml.EMPTY,this.getConfig(),this.getDomHelper())};goog.ui.tree.TreeControl.prototype.setNode=function(a){this.typeAhead_.setNodeInMap(a)};goog.ui.tree.TreeControl.prototype.removeNode=function(a){this.typeAhead_.removeNodeFromMap(a)};goog.ui.tree.TreeControl.prototype.clearTypeAhead=function(){this.typeAhead_.clear()};goog.ui.tree.TreeControl.defaultConfig=goog.ui.tree.BaseNode.defaultConfig;
|
||||
goog.ui.Menu.prototype.decorateContent=function(a){var b=this.getRenderer();a=this.getDomHelper().getElementsByTagNameAndClass("DIV",b.getCssClass()+"-content",a);for(var c=a.length,d=0;d<c;d++)b.decorateChildren(this,a[d])};
|
||||
var Blockly={};Blockly.Blocks=Object.create(null);Blockly.Msg={};goog.getMsgOrig=goog.getMsg;goog.getMsg=function(a,b){var c=goog.getMsg.blocklyMsgMap[a];c&&(a=Blockly.Msg[c]);return goog.getMsgOrig(a,b)};goog.getMsg.blocklyMsgMap={Today:"TODAY"};
|
||||
Blockly.utils={};Blockly.utils.base={};Blockly.utils.global=this||self;Blockly.utils.Coordinate=function(a,b){this.x=a;this.y=b};Blockly.utils.Coordinate.equals=function(a,b){return a==b?!0:a&&b?a.x==b.x&&a.y==b.y:!1};Blockly.utils.Coordinate.distance=function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)};Blockly.utils.Coordinate.magnitude=function(a){return Math.sqrt(a.x*a.x+a.y*a.y)};Blockly.utils.Coordinate.difference=function(a,b){return new Blockly.utils.Coordinate(a.x-b.x,a.y-b.y)};
|
||||
Blockly.utils.Coordinate.sum=function(a,b){return new Blockly.utils.Coordinate(a.x+b.x,a.y+b.y)};Blockly.utils.Coordinate.prototype.scale=function(a){this.x*=a;this.y*=a;return this};Blockly.utils.Coordinate.prototype.translate=function(a,b){this.x+=a;this.y+=b;return this};Blockly.utils.string={};Blockly.utils.string.startsWith=function(a,b){return 0==a.lastIndexOf(b,0)};Blockly.utils.string.shortestStringLength=function(a){return a.length?a.reduce(function(a,c){return a.length<c.length?a:c}).length:0};
|
||||
@@ -890,8 +745,13 @@ Blockly.utils.string.wrapScore_=function(a,b,c){for(var d=[0],e=[],f=0;f<a.lengt
|
||||
Blockly.utils.string.wrapMutate_=function(a,b,c){for(var d=Blockly.utils.string.wrapScore_(a,b,c),e,f=0;f<b.length-1;f++)if(b[f]!=b[f+1]){var g=[].concat(b);g[f]=!g[f];g[f+1]=!g[f+1];var h=Blockly.utils.string.wrapScore_(a,g,c);h>d&&(d=h,e=g)}return e?Blockly.utils.string.wrapMutate_(a,e,c):b};Blockly.utils.string.wrapToText_=function(a,b){for(var c=[],d=0;d<a.length;d++)c.push(a[d]),void 0!==b[d]&&c.push(b[d]?"\n":" ");return c.join("")};Blockly.utils.userAgent={};
|
||||
(function(a){function b(a){return-1!=c.indexOf(a.toUpperCase())}Blockly.utils.userAgent.raw=a;var c=Blockly.utils.userAgent.raw.toUpperCase();Blockly.utils.userAgent.IE=b("Trident")||b("MSIE");Blockly.utils.userAgent.EDGE=b("Edge");Blockly.utils.userAgent.JAVA_FX=b("JavaFX");Blockly.utils.userAgent.WEBKIT=b("WebKit")&&!Blockly.utils.userAgent.EDGE;Blockly.utils.userAgent.GECKO=b("Gecko")&&!Blockly.utils.userAgent.WEBKIT&&!Blockly.utils.userAgent.IE&&!Blockly.utils.userAgent.EDGE;Blockly.utils.userAgent.ANDROID=
|
||||
b("Android");Blockly.utils.userAgent.IPAD=b("iPad");Blockly.utils.userAgent.IPOD=b("iPod");Blockly.utils.userAgent.IPHONE=b("iPhone")&&!Blockly.utils.userAgent.IPAD&&!Blockly.utils.userAgent.IPOD;Blockly.utils.userAgent.MAC=b("Macintosh");Blockly.utils.userAgent.TABLET=Blockly.utils.userAgent.IPAD||Blockly.utils.userAgent.ANDROID&&!b("Mobile")||b("Silk");Blockly.utils.userAgent.MOBILE=!Blockly.utils.userAgent.TABLET&&(Blockly.utils.userAgent.IPOD||Blockly.utils.userAgent.IPHONE||Blockly.utils.userAgent.ANDROID||
|
||||
b("IEMobile"))})(Blockly.utils.global.navigator&&Blockly.utils.global.navigator.userAgent||"");Blockly.utils.Size=function(a,b){this.width=a;this.height=b};Blockly.utils.Size.equals=function(a,b){return a==b?!0:a&&b?a.width==b.width&&a.height==b.height:!1};Blockly.utils.style={};Blockly.utils.style.getSize=function(a){return new Blockly.utils.Size(a.offsetWidth,a.offsetHeight)};Blockly.utils.style.getPageOffset=function(a){var b=new Blockly.utils.Coordinate(0,0);a=a.getBoundingClientRect();var c=document.documentElement;c=new Blockly.utils.Coordinate(window.pageXOffset||c.scrollLeft,window.pageYOffset||c.scrollTop);b.x=a.left+c.x;b.y=a.top+c.y;return b};
|
||||
Blockly.utils.style.getViewportPageOffset=function(){var a=document.body,b=document.documentElement;return new Blockly.utils.Coordinate(a.scrollLeft||b.scrollLeft,a.scrollTop||b.scrollTop)};
|
||||
b("IEMobile"))})(Blockly.utils.global.navigator&&Blockly.utils.global.navigator.userAgent||"");Blockly.utils.Size=function(a,b){this.width=a;this.height=b};Blockly.utils.Size.equals=function(a,b){return a==b?!0:a&&b?a.width==b.width&&a.height==b.height:!1};Blockly.utils.style={};Blockly.utils.style.getSize=function(a){if("none"!=Blockly.utils.style.getStyle_(a,"display"))return Blockly.utils.style.getSizeWithDisplay_(a);var b=a.style,c=b.display,d=b.visibility,e=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";var f=a.offsetWidth;a=a.offsetHeight;b.display=c;b.position=e;b.visibility=d;return new Blockly.utils.Size(f,a)};Blockly.utils.style.getSizeWithDisplay_=function(a){return new Blockly.utils.Size(a.offsetWidth,a.offsetHeight)};
|
||||
Blockly.utils.style.getStyle_=function(a,b){return Blockly.utils.style.getComputedStyle(a,b)||Blockly.utils.style.getCascadedStyle(a,b)||a.style&&a.style[b]};Blockly.utils.style.getComputedStyle=function(a,b){if(document.defaultView&&document.defaultView.getComputedStyle){var c=document.defaultView.getComputedStyle(a,null);if(c)return c[b]||c.getPropertyValue(b)||""}return""};Blockly.utils.style.getCascadedStyle=function(a,b){return a.currentStyle?a.currentStyle[b]:null};
|
||||
Blockly.utils.style.getPageOffset=function(a){var b=new Blockly.utils.Coordinate(0,0);a=a.getBoundingClientRect();var c=document.documentElement;c=new Blockly.utils.Coordinate(window.pageXOffset||c.scrollLeft,window.pageYOffset||c.scrollTop);b.x=a.left+c.x;b.y=a.top+c.y;return b};Blockly.utils.style.getViewportPageOffset=function(){var a=document.body,b=document.documentElement;return new Blockly.utils.Coordinate(a.scrollLeft||b.scrollLeft,a.scrollTop||b.scrollTop)};
|
||||
Blockly.utils.style.setElementShown=function(a,b){a.style.display=b?"":"none"};Blockly.utils.style.isRightToLeft=function(a){return"rtl"==Blockly.utils.style.getStyle_(a,"direction")};
|
||||
Blockly.utils.style.getBorderBox=function(a){var b=Blockly.utils.style.getComputedStyle(a,"borderLeftWidth"),c=Blockly.utils.style.getComputedStyle(a,"borderRightWidth"),d=Blockly.utils.style.getComputedStyle(a,"borderTopWidth");a=Blockly.utils.style.getComputedStyle(a,"borderBottomWidth");return{top:parseFloat(d),right:parseFloat(c),bottom:parseFloat(a),left:parseFloat(b)}};
|
||||
Blockly.utils.style.scrollIntoContainerView=function(a,b,c){a=Blockly.utils.style.getContainerOffsetToScrollInto(a,b,c);b.scrollLeft=a.x;b.scrollTop=a.y};
|
||||
Blockly.utils.style.getContainerOffsetToScrollInto=function(a,b,c){var d=Blockly.utils.style.getPageOffset(a),e=Blockly.utils.style.getPageOffset(b),f=Blockly.utils.style.getBorderBox(b),g=d.x-e.x-f.left;d=d.y-e.y-f.top;e=Blockly.utils.style.getSizeWithDisplay_(a);a=b.clientWidth-e.width;e=b.clientHeight-e.height;f=b.scrollLeft;b=b.scrollTop;c?(f+=g-a/2,b+=d-e/2):(f+=Math.min(g,Math.max(g-a,0)),b+=Math.min(d,Math.max(d-e,0)));return new Blockly.utils.Coordinate(f,b)};
|
||||
Blockly.utils.noEvent=function(a){a.preventDefault();a.stopPropagation()};Blockly.utils.isTargetInput=function(a){return"textarea"==a.target.type||"text"==a.target.type||"number"==a.target.type||"email"==a.target.type||"password"==a.target.type||"search"==a.target.type||"tel"==a.target.type||"url"==a.target.type||a.target.isContentEditable};
|
||||
Blockly.utils.getRelativeXY=function(a){var b=new Blockly.utils.Coordinate(0,0),c=a.getAttribute("x");c&&(b.x=parseInt(c,10));if(c=a.getAttribute("y"))b.y=parseInt(c,10);if(c=(c=a.getAttribute("transform"))&&c.match(Blockly.utils.getRelativeXY.XY_REGEX_))b.x+=Number(c[1]),c[3]&&(b.y+=Number(c[3]));(a=a.getAttribute("style"))&&-1<a.indexOf("translate")&&(a=a.match(Blockly.utils.getRelativeXY.XY_STYLE_REGEX_))&&(b.x+=Number(a[1]),a[3]&&(b.y+=Number(a[3])));return b};
|
||||
Blockly.utils.getInjectionDivXY_=function(a){for(var b=0,c=0;a;){var d=Blockly.utils.getRelativeXY(a);b+=d.x;c+=d.y;if(-1!=(" "+(a.getAttribute("class")||"")+" ").indexOf(" injectionDiv "))break;a=a.parentNode}return new Blockly.utils.Coordinate(b,c)};Blockly.utils.getRelativeXY.XY_REGEX_=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/;Blockly.utils.getRelativeXY.XY_STYLE_REGEX_=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/;
|
||||
@@ -1008,7 +868,7 @@ this.potentialVariableMap_=null;this.cursor=this.createCursor();this.marker=this
|
||||
Blockly.Workspace.prototype.dispose=function(){this.listeners_.length=0;this.clear();delete Blockly.Workspace.WorkspaceDB_[this.id]};Blockly.Workspace.SCAN_ANGLE=3;Blockly.Workspace.prototype.sortObjects_=function(a,b){var c=a.getRelativeToSurfaceXY(),d=b.getRelativeToSurfaceXY();return c.y+Blockly.Workspace.prototype.sortObjects_.offset*c.x-(d.y+Blockly.Workspace.prototype.sortObjects_.offset*d.x)};Blockly.Workspace.prototype.addTopBlock=function(a){this.topBlocks_.push(a)};
|
||||
Blockly.Workspace.prototype.removeTopBlock=function(a){if(!Blockly.utils.arrayRemove(this.topBlocks_,a))throw Error("Block not present in workspace's list of top-most blocks.");};Blockly.Workspace.prototype.getTopBlocks=function(a){var b=[].concat(this.topBlocks_);a&&1<b.length&&(this.sortObjects_.offset=Math.sin(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)),this.RTL&&(this.sortObjects_.offset*=-1),b.sort(this.sortObjects_));return b};
|
||||
Blockly.Workspace.prototype.addTypedBlock=function(a){this.typedBlocksDB_[a.type]||(this.typedBlocksDB_[a.type]=[]);this.typedBlocksDB_[a.type].push(a)};Blockly.Workspace.prototype.removeTypedBlock=function(a){this.typedBlocksDB_[a.type].splice(this.typedBlocksDB_[a.type].indexOf(a),1);this.typedBlocksDB_[a.type].length||delete this.typedBlocksDB_[a.type]};
|
||||
Blockly.Workspace.prototype.getBlocksByType=function(a,b){if(!this.typedBlocksDB_[a])return[];var c=this.typedBlocksDB_[a].slice(0);b&&1<c.length&&(this.sortObjects_.offset=Math.sign(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)),this.RTL&&(this.sortObjects_.offset*=-1),c.sort(this.sortObjects_));return c};
|
||||
Blockly.Workspace.prototype.getBlocksByType=function(a,b){if(!this.typedBlocksDB_[a])return[];var c=this.typedBlocksDB_[a].slice(0);b&&1<c.length&&(this.sortObjects_.offset=Math.sin(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)),this.RTL&&(this.sortObjects_.offset*=-1),c.sort(this.sortObjects_));return c};
|
||||
Blockly.Workspace.prototype.addTopComment=function(a){this.topComments_.push(a);this.commentDB_[a.id]&&console.warn('Overriding an existing comment on this workspace, with id "'+a.id+'"');this.commentDB_[a.id]=a};Blockly.Workspace.prototype.removeTopComment=function(a){if(!Blockly.utils.arrayRemove(this.topComments_,a))throw Error("Comment not present in workspace's list of top-most comments.");delete this.commentDB_[a.id]};
|
||||
Blockly.Workspace.prototype.getTopComments=function(a){var b=[].concat(this.topComments_);a&&1<b.length&&(this.sortObjects_.offset=Math.sin(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)),this.RTL&&(this.sortObjects_.offset*=-1),b.sort(this.sortObjects_));return b};
|
||||
Blockly.Workspace.prototype.getAllBlocks=function(a){if(a){a=this.getTopBlocks(!0);for(var b=[],c=0;c<a.length;c++)b.push.apply(b,a[c].getDescendants(!0))}else for(b=this.getTopBlocks(!1),c=0;c<b.length;c++)b.push.apply(b,b[c].getChildren(!1));return b.filter(function(a){return!a.isInsertionMarker()})};
|
||||
@@ -1199,7 +1059,7 @@ Blockly.Gesture.prototype.updateIsDraggingWorkspace_=function(){if(this.flyout_?
|
||||
Blockly.Gesture.prototype.updateIsDragging_=function(){if(this.calledUpdateIsDragging_)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging_=!0;this.updateIsDraggingBubble_()||this.updateIsDraggingBlock_()||this.updateIsDraggingWorkspace_()};
|
||||
Blockly.Gesture.prototype.startDraggingBlock_=function(){this.blockDragger_=new Blockly.BlockDragger(this.targetBlock_,this.startWorkspace_);this.blockDragger_.startBlockDrag(this.currentDragDeltaXY_,this.healStack_);this.blockDragger_.dragBlock(this.mostRecentEvent_,this.currentDragDeltaXY_)};
|
||||
Blockly.Gesture.prototype.startDraggingBubble_=function(){this.bubbleDragger_=new Blockly.BubbleDragger(this.startBubble_,this.startWorkspace_);this.bubbleDragger_.startBubbleDrag();this.bubbleDragger_.dragBubble(this.mostRecentEvent_,this.currentDragDeltaXY_)};
|
||||
Blockly.Gesture.prototype.doStart=function(a){Blockly.utils.isTargetInput(a)?this.cancel():(this.hasStarted_=!0,Blockly.blockAnimations.disconnectUiStop(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.startWorkspace_.markFocused(),this.mostRecentEvent_=a,Blockly.hideChaff(!!this.flyout_),Blockly.Tooltip.block(),this.targetBlock_&&(this.targetBlock_.select(),!this.targetBlock_.isInFlyout&&a.shiftKey&&Blockly.Navigation.focusWorkspace()),
|
||||
Blockly.Gesture.prototype.doStart=function(a){Blockly.utils.isTargetInput(a)?this.cancel():(this.hasStarted_=!0,Blockly.blockAnimations.disconnectUiStop(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.startWorkspace_.markFocused(),this.mostRecentEvent_=a,Blockly.hideChaff(!!this.flyout_),Blockly.Tooltip.block(),this.targetBlock_&&(this.targetBlock_.select(),!this.targetBlock_.isInFlyout&&a.shiftKey&&Blockly.navigation.focusWorkspace()),
|
||||
Blockly.utils.isRightButton(a)?this.handleRightClick(a):("touchstart"!=a.type.toLowerCase()&&"pointerdown"!=a.type.toLowerCase()||"mouse"==a.pointerType||Blockly.longStart_(a,this),this.mouseDownXY_=new Blockly.utils.Coordinate(a.clientX,a.clientY),this.healStack_=a.altKey||a.ctrlKey||a.metaKey,this.bindMouseEvents(a)))};
|
||||
Blockly.Gesture.prototype.bindMouseEvents=function(a){this.onMoveWrapper_=Blockly.bindEventWithChecks_(document,"mousemove",null,this.handleMove.bind(this));this.onUpWrapper_=Blockly.bindEventWithChecks_(document,"mouseup",null,this.handleUp.bind(this));a.preventDefault();a.stopPropagation()};
|
||||
Blockly.Gesture.prototype.handleMove=function(a){this.updateFromEvent_(a);this.isDraggingWorkspace_?this.workspaceDragger_.drag(this.currentDragDeltaXY_):this.isDraggingBlock_?this.blockDragger_.dragBlock(this.mostRecentEvent_,this.currentDragDeltaXY_):this.isDraggingBubble_&&this.bubbleDragger_.dragBubble(this.mostRecentEvent_,this.currentDragDeltaXY_);a.preventDefault();a.stopPropagation()};
|
||||
@@ -1355,7 +1215,7 @@ Blockly.WorkspaceSvg.prototype.setVisible=function(a){this.scrollbar&&this.scrol
|
||||
Blockly.WorkspaceSvg.prototype.render=function(){for(var a=this.getAllBlocks(!1),b=a.length-1;0<=b;b--)a[b].render(!1);if(this.currentGesture_)for(a=this.currentGesture_.getInsertionMarkers(),b=0;b<a.length;b++)a[b].render(!1)};Blockly.WorkspaceSvg.prototype.traceOn=function(){console.warn("Deprecated call to traceOn, delete this.")};
|
||||
Blockly.WorkspaceSvg.prototype.highlightBlock=function(a,b){if(void 0===b){for(var c=0,d;d=this.highlightedBlocks_[c];c++)d.setHighlighted(!1);this.highlightedBlocks_.length=0}if(d=a?this.getBlockById(a):null)(c=void 0===b||b)?-1==this.highlightedBlocks_.indexOf(d)&&this.highlightedBlocks_.push(d):Blockly.utils.arrayRemove(this.highlightedBlocks_,d),d.setHighlighted(c)};
|
||||
Blockly.WorkspaceSvg.prototype.paste=function(a){!this.rendered||a.getElementsByTagName("block").length>=this.remainingCapacity()||(this.currentGesture_&&this.currentGesture_.cancel(),"comment"==a.tagName.toLowerCase()?this.pasteWorkspaceComment_(a):this.pasteBlock_(a))};
|
||||
Blockly.WorkspaceSvg.prototype.pasteBlock_=function(a){Blockly.Events.disable();try{var b=Blockly.Xml.domToBlock(a,this),c=Blockly.Navigation.marker_.getCurNode();if(Blockly.keyboardAccessibilityMode&&c){Blockly.Navigation.insertBlock(b,c.getLocation());return}var d=parseInt(a.getAttribute("x"),10),e=parseInt(a.getAttribute("y"),10);if(!isNaN(d)&&!isNaN(e)){this.RTL&&(d=-d);do{a=!1;var f=this.getAllBlocks(!1);c=0;for(var g;g=f[c];c++){var h=g.getRelativeToSurfaceXY();if(1>=Math.abs(d-h.x)&&1>=Math.abs(e-
|
||||
Blockly.WorkspaceSvg.prototype.pasteBlock_=function(a){Blockly.Events.disable();try{var b=Blockly.Xml.domToBlock(a,this),c=Blockly.navigation.marker_.getCurNode();if(Blockly.keyboardAccessibilityMode&&c){Blockly.navigation.insertBlock(b,c.getLocation());return}var d=parseInt(a.getAttribute("x"),10),e=parseInt(a.getAttribute("y"),10);if(!isNaN(d)&&!isNaN(e)){this.RTL&&(d=-d);do{a=!1;var f=this.getAllBlocks(!1);c=0;for(var g;g=f[c];c++){var h=g.getRelativeToSurfaceXY();if(1>=Math.abs(d-h.x)&&1>=Math.abs(e-
|
||||
h.y)){a=!0;break}}if(!a){var k=b.getConnections_(!1);c=0;for(var l;l=k[c];c++)if(l.closest(Blockly.SNAP_RADIUS,new Blockly.utils.Coordinate(d,e)).connection){a=!0;break}}a&&(d=this.RTL?d-Blockly.SNAP_RADIUS:d+Blockly.SNAP_RADIUS,e+=2*Blockly.SNAP_RADIUS)}while(a);b.moveBy(d,e)}}finally{Blockly.Events.enable()}Blockly.Events.isEnabled()&&!b.isShadow()&&Blockly.Events.fire(new Blockly.Events.BlockCreate(b));b.select()};
|
||||
Blockly.WorkspaceSvg.prototype.pasteWorkspaceComment_=function(a){Blockly.Events.disable();try{var b=Blockly.WorkspaceCommentSvg.fromXml(a,this),c=parseInt(a.getAttribute("x"),10),d=parseInt(a.getAttribute("y"),10);isNaN(c)||isNaN(d)||(this.RTL&&(c=-c),b.moveBy(c+50,d+50))}finally{Blockly.Events.enable()}Blockly.Events.isEnabled();b.select()};
|
||||
Blockly.WorkspaceSvg.prototype.refreshToolboxSelection=function(){var a=this.isFlyout?this.targetWorkspace:this;a&&!a.currentGesture_&&a.toolbox_&&a.toolbox_.flyout_&&a.toolbox_.refreshSelection()};Blockly.WorkspaceSvg.prototype.renameVariableById=function(a,b){Blockly.WorkspaceSvg.superClass_.renameVariableById.call(this,a,b);this.refreshToolboxSelection()};Blockly.WorkspaceSvg.prototype.deleteVariableById=function(a){Blockly.WorkspaceSvg.superClass_.deleteVariableById.call(this,a);this.refreshToolboxSelection()};
|
||||
@@ -1513,45 +1373,47 @@ Blockly.BlockDragSurfaceSvg.prototype.clearAndHide=function(a){a?a.appendChild(t
|
||||
Blockly.utils.svgPaths.arc=function(a,b,c,d){return a+" "+c+" "+c+" "+b+d};Blockly.blockRendering={};Blockly.blockRendering.constants={};Blockly.blockRendering.constants.NO_PADDING=0;Blockly.blockRendering.constants.SMALL_PADDING=3;Blockly.blockRendering.constants.MEDIUM_PADDING=5;Blockly.blockRendering.constants.MEDIUM_LARGE_PADDING=8;Blockly.blockRendering.constants.LARGE_PADDING=10;Blockly.blockRendering.constants.TALL_INPUT_FIELD_OFFSET_Y=Blockly.blockRendering.constants.MEDIUM_PADDING;Blockly.blockRendering.constants.DARK_PATH_OFFSET=1;
|
||||
Blockly.blockRendering.constants.TAB_HEIGHT=15;Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP=5;Blockly.blockRendering.constants.TAB_VERTICAL_OVERLAP=2.5;Blockly.blockRendering.constants.TAB_WIDTH=8;Blockly.blockRendering.constants.NOTCH_WIDTH=15;Blockly.blockRendering.constants.NOTCH_HEIGHT=4;Blockly.blockRendering.constants.MIN_BLOCK_WIDTH=12;Blockly.blockRendering.constants.EMPTY_BLOCK_SPACER_HEIGHT=16;Blockly.blockRendering.constants.CORNER_RADIUS=8;
|
||||
Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT=Blockly.blockRendering.constants.NOTCH_WIDTH;Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV=Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT-Blockly.blockRendering.constants.CORNER_RADIUS;Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER=5;Blockly.blockRendering.constants.STATEMENT_INPUT_PADDING_LEFT=20;Blockly.blockRendering.constants.BETWEEN_STATEMENT_PADDING_Y=4;Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH=66.5;
|
||||
Blockly.blockRendering.constants.START_HAT_HEIGHT=15;Blockly.blockRendering.constants.START_HAT_WIDTH=100;Blockly.blockRendering.constants.SPACER_DEFAULT_HEIGHT=15;Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT=24;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_WIDTH=Blockly.blockRendering.constants.TAB_WIDTH+14.5;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT=Blockly.blockRendering.constants.TAB_HEIGHT+11;Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_WIDTH=10;
|
||||
Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT;Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH=32;Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH=25;Blockly.blockRendering.constants.START_POINT=Blockly.utils.svgPaths.moveBy(0,0);Blockly.blockRendering.constants.TOP_LEFT_CORNER_START="m 0,"+Blockly.blockRendering.constants.CORNER_RADIUS;Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT=12;
|
||||
Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH=6;Blockly.blockRendering.constants.JAGGED_TEETH=function(){var a=Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT,b=Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH,c=Blockly.utils.svgPaths.line([Blockly.utils.svgPaths.point(6,3),Blockly.utils.svgPaths.point(-12,6),Blockly.utils.svgPaths.point(6,3)]);return{height:a,width:b,path:c}}();
|
||||
Blockly.blockRendering.constants.START_HAT_HEIGHT=15;Blockly.blockRendering.constants.START_HAT_WIDTH=100;Blockly.blockRendering.constants.SPACER_DEFAULT_HEIGHT=15;Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT=24;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_PADDING=14.5;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT=Blockly.blockRendering.constants.TAB_HEIGHT+11;Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_PADDING=2;
|
||||
Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT;Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH=32;Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH=25;Blockly.blockRendering.constants.START_POINT=Blockly.utils.svgPaths.moveBy(0,0);Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT=12;Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH=6;
|
||||
Blockly.blockRendering.constants.JAGGED_TEETH=function(){var a=Blockly.blockRendering.constants.JAGGED_TEETH_HEIGHT,b=Blockly.blockRendering.constants.JAGGED_TEETH_WIDTH,c=Blockly.utils.svgPaths.line([Blockly.utils.svgPaths.point(6,3),Blockly.utils.svgPaths.point(-12,6),Blockly.utils.svgPaths.point(6,3)]);return{height:a,width:b,path:c}}();
|
||||
Blockly.blockRendering.constants.START_HAT=function(){var a=Blockly.blockRendering.constants.START_HAT_HEIGHT,b=Blockly.blockRendering.constants.START_HAT_WIDTH,c=Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(30,-a),Blockly.utils.svgPaths.point(70,-a),Blockly.utils.svgPaths.point(b,0)]);return{height:a,width:b,path:c}}();
|
||||
Blockly.blockRendering.constants.PUZZLE_TAB=function(){function a(a){a=a?-1:1;var d=-a,e=c/2,f=e+2.5,l=e+.5,n=Blockly.utils.svgPaths.point(-b,a*e);e=Blockly.utils.svgPaths.point(b,a*e);return Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(0,a*f),Blockly.utils.svgPaths.point(-b,d*l),n])+Blockly.utils.svgPaths.curve("s",[Blockly.utils.svgPaths.point(b,2.5*d),e])}var b=Blockly.blockRendering.constants.TAB_WIDTH,c=Blockly.blockRendering.constants.TAB_HEIGHT,d=a(!0),e=a(!1);return{width:b,
|
||||
height:c,pathDown:e,pathUp:d}}();Blockly.blockRendering.constants.NOTCH=function(){function a(a){return Blockly.utils.svgPaths.line([Blockly.utils.svgPaths.point(a*d,c),Blockly.utils.svgPaths.point(3*a,0),Blockly.utils.svgPaths.point(a*d,-c)])}var b=Blockly.blockRendering.constants.NOTCH_WIDTH,c=Blockly.blockRendering.constants.NOTCH_HEIGHT,d=(b-3)/2,e=a(1),f=a(-1);return{width:b,height:c,pathLeft:e,pathRight:f}}();
|
||||
height:c,pathDown:e,pathUp:d}}();Blockly.blockRendering.constants.TRIANGLE=function(){function a(a){a=a?-1:1;return Blockly.utils.svgPaths.lineTo(-20,20*a/2)+Blockly.utils.svgPaths.lineTo(20,20*a/2)}var b=a(!0);return{width:20,height:20,pathDown:a(!1),pathUp:b}}();
|
||||
Blockly.blockRendering.constants.NOTCH=function(){function a(a){return Blockly.utils.svgPaths.line([Blockly.utils.svgPaths.point(a*d,c),Blockly.utils.svgPaths.point(3*a,0),Blockly.utils.svgPaths.point(a*d,-c)])}var b=Blockly.blockRendering.constants.NOTCH_WIDTH,c=Blockly.blockRendering.constants.NOTCH_HEIGHT,d=(b-3)/2,e=a(1),f=a(-1);return{width:b,height:c,pathLeft:e,pathRight:f}}();
|
||||
Blockly.blockRendering.constants.INSIDE_CORNERS=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.utils.svgPaths.arc("a","0 0,0",a,Blockly.utils.svgPaths.point(-a,a)),c=Blockly.utils.svgPaths.arc("a","0 0,0",a,Blockly.utils.svgPaths.point(a,a));return{height:a,pathTop:b,pathBottom:c}}();
|
||||
Blockly.blockRendering.constants.OUTSIDE_CORNERS=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.utils.svgPaths.arc("A","0 0,1",a,Blockly.utils.svgPaths.point(a,0));a=Blockly.utils.svgPaths.arc("a","0 0,1",a,Blockly.utils.svgPaths.point(-a,-a));return{topLeft:b,bottomLeft:a}}();Blockly.blockRendering.Measurable=function(){this.isInput=!1;this.height=this.width=0;this.type=null;this.centerline=this.xPos=0};Blockly.blockRendering.Measurable.prototype.isField=function(){return"field"==this.type};Blockly.blockRendering.Measurable.prototype.isHat=function(){return"hat"==this.type};Blockly.blockRendering.Measurable.prototype.isIcon=function(){return"icon"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isSpacer=function(){return"between-row spacer"==this.type||"in-row spacer"==this.type};Blockly.blockRendering.Measurable.prototype.isExternalInput=function(){return"external value input"==this.type};Blockly.blockRendering.Measurable.prototype.isInlineInput=function(){return"inline input"==this.type};Blockly.blockRendering.Measurable.prototype.isStatementInput=function(){return"statement input"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isPreviousConnection=function(){return"previous connection"==this.type};Blockly.blockRendering.Measurable.prototype.isNextConnection=function(){return"next connection"==this.type};Blockly.blockRendering.Measurable.prototype.isRoundedCorner=function(){return"round corner"==this.type};Blockly.blockRendering.Measurable.prototype.isSquareCorner=function(){return"square corner"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isJaggedEdge=function(){return"jagged edge"==this.type};
|
||||
Blockly.blockRendering.constants.OUTSIDE_CORNERS=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.utils.svgPaths.moveBy(0,a)+Blockly.utils.svgPaths.arc("a","0 0,1",a,Blockly.utils.svgPaths.point(a,-a));a=Blockly.utils.svgPaths.arc("a","0 0,1",a,Blockly.utils.svgPaths.point(-a,-a));return{topLeft:b,bottomLeft:a}}();Blockly.blockRendering.Measurable=function(){this.isInput=!1;this.height=this.width=0;this.type=null;this.centerline=this.xPos=0};Blockly.blockRendering.Measurable.prototype.connectionShape=Blockly.blockRendering.constants.PUZZLE_TAB;Blockly.blockRendering.Measurable.prototype.notchShape=Blockly.blockRendering.constants.NOTCH;Blockly.blockRendering.Measurable.prototype.isField=function(){return"field"==this.type};Blockly.blockRendering.Measurable.prototype.isHat=function(){return"hat"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isIcon=function(){return"icon"==this.type};Blockly.blockRendering.Measurable.prototype.isSpacer=function(){return"between-row spacer"==this.type||"in-row spacer"==this.type};Blockly.blockRendering.Measurable.prototype.isExternalInput=function(){return"external value input"==this.type};Blockly.blockRendering.Measurable.prototype.isInlineInput=function(){return"inline input"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isStatementInput=function(){return"statement input"==this.type};Blockly.blockRendering.Measurable.prototype.isPreviousConnection=function(){return"previous connection"==this.type};Blockly.blockRendering.Measurable.prototype.isNextConnection=function(){return"next connection"==this.type};Blockly.blockRendering.Measurable.prototype.isRoundedCorner=function(){return"round corner"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isSquareCorner=function(){return"square corner"==this.type};Blockly.blockRendering.Measurable.prototype.isJaggedEdge=function(){return"jagged edge"==this.type};
|
||||
Blockly.blockRendering.Input=function(a){Blockly.blockRendering.Input.superClass_.constructor.call(this);this.isInput=!0;this.input=a;this.align=a.align;if(this.connectedBlock=a.connection&&a.connection.targetBlock()?a.connection.targetBlock():null){var b=this.connectedBlock.getHeightWidth();this.connectedBlockWidth=b.width;this.connectedBlockHeight=b.height}else this.connectedBlockHeight=this.connectedBlockWidth=0;this.connection=a.connection;this.connectionOffsetY=this.connectionOffsetX=0};
|
||||
goog.inherits(Blockly.blockRendering.Input,Blockly.blockRendering.Measurable);Blockly.blockRendering.Icon=function(a){Blockly.blockRendering.Icon.superClass_.constructor.call(this);this.icon=a;this.isVisible=a.isVisible();this.type="icon";a=a.getCorrectedSize();this.height=a.height;this.width=a.width};goog.inherits(Blockly.blockRendering.Icon,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.JaggedEdge=function(){Blockly.blockRendering.JaggedEdge.superClass_.constructor.call(this);this.type="jagged edge";this.height=Blockly.blockRendering.constants.JAGGED_TEETH.height;this.width=Blockly.blockRendering.constants.JAGGED_TEETH.width};goog.inherits(Blockly.blockRendering.JaggedEdge,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Field=function(a,b){Blockly.blockRendering.Field.superClass_.constructor.call(this);this.field=a;this.isEditable=a.isCurrentlyEditable();this.flipRtl=a instanceof Blockly.FieldImage&&a.getFlipRtl();this.type="field";var c=this.field.getSize();this.height=c.height;this.width=c.width;this.parentInput=b};goog.inherits(Blockly.blockRendering.Field,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.InlineInput=function(a){Blockly.blockRendering.InlineInput.superClass_.constructor.call(this,a);this.type="inline input";this.connectedBlock?(this.width=this.connectedBlockWidth+Blockly.blockRendering.constants.TAB_WIDTH+Blockly.blockRendering.constants.DARK_PATH_OFFSET,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.DARK_PATH_OFFSET):(this.height=Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT,this.width=Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_WIDTH);
|
||||
this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;this.connectionHeight=Blockly.blockRendering.constants.PUZZLE_TAB.height;this.connectionWidth=Blockly.blockRendering.constants.PUZZLE_TAB.width};goog.inherits(Blockly.blockRendering.InlineInput,Blockly.blockRendering.Input);
|
||||
Blockly.blockRendering.StatementInput=function(a){Blockly.blockRendering.StatementInput.superClass_.constructor.call(this,a);this.type="statement input";this.connectedBlock?(this.width=Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER,this.connectedBlock.nextConnection&&(this.height-=Blockly.blockRendering.constants.NOTCH.height)):(this.height=Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT,
|
||||
this.width=Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH)};goog.inherits(Blockly.blockRendering.StatementInput,Blockly.blockRendering.Input);
|
||||
Blockly.blockRendering.ExternalValueInput=function(a){Blockly.blockRendering.ExternalValueInput.superClass_.constructor.call(this,a);this.type="external value input";this.height=this.connectedBlock?this.connectedBlockHeight-2*Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP:Blockly.blockRendering.constants.TAB_HEIGHT;this.width=Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_WIDTH;this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;this.connectionHeight=Blockly.blockRendering.constants.PUZZLE_TAB.height;
|
||||
this.connectionWidth=Blockly.blockRendering.constants.PUZZLE_TAB.width};goog.inherits(Blockly.blockRendering.ExternalValueInput,Blockly.blockRendering.Input);Blockly.blockRendering.OutputConnection=function(){Blockly.blockRendering.OutputConnection.superClass_.constructor.call(this);this.type="output connection";this.height=Blockly.blockRendering.constants.PUZZLE_TAB.height;this.width=Blockly.blockRendering.constants.PUZZLE_TAB.width;this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP};
|
||||
goog.inherits(Blockly.blockRendering.OutputConnection,Blockly.blockRendering.Measurable);Blockly.blockRendering.PreviousConnection=function(){Blockly.blockRendering.PreviousConnection.superClass_.constructor.call(this);this.type="previous connection";this.height=Blockly.blockRendering.constants.NOTCH.height;this.width=Blockly.blockRendering.constants.NOTCH.width};goog.inherits(Blockly.blockRendering.PreviousConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.NextConnection=function(){Blockly.blockRendering.NextConnection.superClass_.constructor.call(this);this.type="next connection";this.height=Blockly.blockRendering.constants.NOTCH.height;this.width=Blockly.blockRendering.constants.NOTCH.width};goog.inherits(Blockly.blockRendering.NextConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Hat=function(){Blockly.blockRendering.Hat.superClass_.constructor.call(this);this.type="hat";this.height=Blockly.blockRendering.constants.NO_PADDING;this.width=Blockly.blockRendering.constants.START_HAT.width};goog.inherits(Blockly.blockRendering.Hat,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.SquareCorner=function(){Blockly.blockRendering.SquareCorner.superClass_.constructor.call(this);this.type="square corner";this.height=Blockly.blockRendering.constants.NOTCH.height;this.width=Blockly.blockRendering.constants.NO_PADDING};goog.inherits(Blockly.blockRendering.SquareCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.RoundCorner=function(){Blockly.blockRendering.RoundCorner.superClass_.constructor.call(this);this.type="round corner";this.width=Blockly.blockRendering.constants.CORNER_RADIUS;this.height=Blockly.blockRendering.constants.NOTCH.height};goog.inherits(Blockly.blockRendering.RoundCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Row=function(){this.type="row";this.yPos=0;this.elements=[];this.height=this.width=0;this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=this.hasStatement=this.hasExternalInput=!1};Blockly.blockRendering.Row.prototype.isSpacer=function(){return!1};
|
||||
Blockly.blockRendering.Row.prototype.measure=function(){for(var a=0,b=0;b<this.elements.length;b++){var c=this.elements[b];this.width+=c.width;!c.isInput||"statement input"!=c.type&&"external value input"!=c.type||(a+=c.connectedBlockWidth);c.isSpacer()||(this.height=Math.max(this.height,c.height))}this.widthWithConnectedBlocks=this.width+a};
|
||||
Blockly.blockRendering.InlineInput=function(a){Blockly.blockRendering.InlineInput.superClass_.constructor.call(this,a);this.type="inline input";this.connectedBlock?(this.width=this.connectedBlockWidth+Blockly.blockRendering.constants.DARK_PATH_OFFSET,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.DARK_PATH_OFFSET):(this.height=Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.connectionShape.width+Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_PADDING);
|
||||
this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;this.connectionHeight=this.connectionShape.height;this.connectionWidth=this.connectionShape.width};goog.inherits(Blockly.blockRendering.InlineInput,Blockly.blockRendering.Input);
|
||||
Blockly.blockRendering.StatementInput=function(a){Blockly.blockRendering.StatementInput.superClass_.constructor.call(this,a);this.type="statement input";this.connectedBlock?(this.width=Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER,this.connectedBlock.nextConnection&&(this.height-=this.notchShape.height)):(this.height=Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT,this.width=
|
||||
Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH)};goog.inherits(Blockly.blockRendering.StatementInput,Blockly.blockRendering.Input);
|
||||
Blockly.blockRendering.ExternalValueInput=function(a){Blockly.blockRendering.ExternalValueInput.superClass_.constructor.call(this,a);this.type="external value input";this.height=this.connectedBlock?this.connectedBlockHeight-2*Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP:this.connectionShape.height;this.width=this.connectionShape.width+Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_PADDING;this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;this.connectionHeight=
|
||||
this.connectionShape.height;this.connectionWidth=this.connectionShape.width};goog.inherits(Blockly.blockRendering.ExternalValueInput,Blockly.blockRendering.Input);Blockly.blockRendering.OutputConnection=function(){Blockly.blockRendering.OutputConnection.superClass_.constructor.call(this);this.type="output connection";this.height=this.connectionShape.height;this.width=this.connectionShape.width;this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;this.startX=this.width};
|
||||
goog.inherits(Blockly.blockRendering.OutputConnection,Blockly.blockRendering.Measurable);Blockly.blockRendering.PreviousConnection=function(){Blockly.blockRendering.PreviousConnection.superClass_.constructor.call(this);this.type="previous connection";this.height=this.notchShape.height;this.width=this.notchShape.width};goog.inherits(Blockly.blockRendering.PreviousConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.NextConnection=function(){Blockly.blockRendering.NextConnection.superClass_.constructor.call(this);this.type="next connection";this.height=this.notchShape.height;this.width=this.notchShape.width};goog.inherits(Blockly.blockRendering.NextConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Hat=function(){Blockly.blockRendering.Hat.superClass_.constructor.call(this);this.type="hat";this.height=Blockly.blockRendering.constants.START_HAT.height;this.width=Blockly.blockRendering.constants.START_HAT.width;this.startY=this.height};goog.inherits(Blockly.blockRendering.Hat,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.SquareCorner=function(){Blockly.blockRendering.SquareCorner.superClass_.constructor.call(this);this.type="square corner";this.height=this.notchShape.height;this.width=Blockly.blockRendering.constants.NO_PADDING};goog.inherits(Blockly.blockRendering.SquareCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.RoundCorner=function(){Blockly.blockRendering.RoundCorner.superClass_.constructor.call(this);this.type="round corner";this.width=Blockly.blockRendering.constants.CORNER_RADIUS;this.height=this.notchShape.height};goog.inherits(Blockly.blockRendering.RoundCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Row=function(){this.type="row";this.yPos=0;this.elements=[];this.height=this.width=0;this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=this.hasStatement=this.hasExternalInput=!1};Blockly.blockRendering.Row.prototype.notchShape=Blockly.blockRendering.constants.NOTCH;Blockly.blockRendering.Row.prototype.isSpacer=function(){return!1};
|
||||
Blockly.blockRendering.Row.prototype.measure=function(){for(var a=0,b=0;b<this.elements.length;b++){var c=this.elements[b];this.width+=c.width;c.isInput&&("statement input"==c.type?a+=c.connectedBlockWidth:"external value input"==c.type&&(a+=c.connectedBlockWidth-c.connectionWidth));c.isSpacer()||(this.height=Math.max(this.height,c.height))}this.widthWithConnectedBlocks=this.width+a};
|
||||
Blockly.blockRendering.Row.prototype.getLastInput=function(){for(var a=this.elements.length-1;0<=a;a--){var b=this.elements[a];if(!b.isSpacer()){if(b.isInput)return b;if(b.isField())return b.parentInput}}return null};Blockly.blockRendering.Row.prototype.getFirstSpacer=function(){return this.elements[0]};Blockly.blockRendering.Row.prototype.getLastSpacer=function(){return this.elements[this.elements.length-1]};
|
||||
Blockly.blockRendering.BetweenRowSpacer=function(a,b){this.type="between-row spacer";this.width=b;this.height=a;this.followsStatement=!1};goog.inherits(Blockly.blockRendering.BetweenRowSpacer,Blockly.blockRendering.Measurable);Blockly.blockRendering.InRowSpacer=function(a){this.type="in-row spacer";this.width=a;this.height=Blockly.blockRendering.constants.SPACER_DEFAULT_HEIGHT};goog.inherits(Blockly.blockRendering.InRowSpacer,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.TopRow=function(a){Blockly.blockRendering.TopRow.superClass_.constructor.call(this);this.elements=[];this.type="top row";this.hasPreviousConnection=!!a.previousConnection;this.connection=a.previousConnection;a.inputList.length&&a.inputList[0].type==Blockly.NEXT_STATEMENT&&!a.isCollapsed()?this.height=Blockly.blockRendering.constants.LARGE_PADDING:this.height=Blockly.blockRendering.constants.MEDIUM_PADDING};goog.inherits(Blockly.blockRendering.TopRow,Blockly.blockRendering.Row);
|
||||
Blockly.blockRendering.TopRow.prototype.getPreviousConnection=function(){return this.hasPreviousConnection?this.elements[2]:null};
|
||||
Blockly.blockRendering.BottomRow=function(a){Blockly.blockRendering.BottomRow.superClass_.constructor.call(this);this.type="bottom row";this.hasNextConnection=!!a.nextConnection;this.connection=a.nextConnection;var b=a.inputList.length&&a.inputList[a.inputList.length-1].type==Blockly.NEXT_STATEMENT;this.hasFixedWidth=b&&a.getInputsInline();this.height=b?Blockly.blockRendering.constants.LARGE_PADDING:Blockly.blockRendering.constants.NOTCH.height};goog.inherits(Blockly.blockRendering.BottomRow,Blockly.blockRendering.Row);
|
||||
Blockly.blockRendering.BottomRow.prototype.getNextConnection=function(){return this.hasNextConnection?this.elements[2]:null};Blockly.blockRendering.RenderInfo=function(a){this.block_=a;this.outputConnection=a.outputConnection?new Blockly.blockRendering.OutputConnection:null;this.isInline=a.getInputsInline()&&!a.isCollapsed();this.isCollapsed=a.isCollapsed();this.isInsertionMarker=a.isInsertionMarker();this.RTL=a.RTL;this.statementEdge=this.width=this.widthWithChildren=this.height=0;this.rows=[];this.hiddenIcons=[];this.bottomRow=this.topRow=null;this.measure_()};
|
||||
Blockly.blockRendering.TopRow=function(a){Blockly.blockRendering.TopRow.superClass_.constructor.call(this);this.elements=[];this.type="top row";this.startY=0;this.hasPreviousConnection=!!a.previousConnection;this.connection=a.previousConnection;a.inputList.length&&a.inputList[0].type==Blockly.NEXT_STATEMENT&&!a.isCollapsed()?this.height=Blockly.blockRendering.constants.LARGE_PADDING:this.height=Blockly.blockRendering.constants.MEDIUM_PADDING};goog.inherits(Blockly.blockRendering.TopRow,Blockly.blockRendering.Row);
|
||||
Blockly.blockRendering.TopRow.prototype.getPreviousConnection=function(){return this.hasPreviousConnection?this.elements[2]:null};Blockly.blockRendering.TopRow.prototype.measure=function(){for(var a=0;a<this.elements.length;a++){var b=this.elements[a];this.width+=b.width;b.isSpacer()||("hat"==b.type&&(this.startY=b.startY,this.height+=b.height),this.height=Math.max(this.height,b.height))}this.widthWithConnectedBlocks=this.width};
|
||||
Blockly.blockRendering.BottomRow=function(a){Blockly.blockRendering.BottomRow.superClass_.constructor.call(this);this.type="bottom row";this.hasNextConnection=!!a.nextConnection;this.connection=a.nextConnection;this.overhangY=0;var b=a.inputList.length&&a.inputList[a.inputList.length-1].type==Blockly.NEXT_STATEMENT;this.hasFixedWidth=b&&a.getInputsInline();this.height=b?Blockly.blockRendering.constants.LARGE_PADDING:this.notchShape.height};goog.inherits(Blockly.blockRendering.BottomRow,Blockly.blockRendering.Row);
|
||||
Blockly.blockRendering.BottomRow.prototype.getNextConnection=function(){return this.hasNextConnection?this.elements[2]:null};Blockly.blockRendering.BottomRow.prototype.measure=function(){for(var a=0;a<this.elements.length;a++){var b=this.elements[a];this.width+=b.width;b.isSpacer()||("next connection"==b.type&&(this.height+=b.height,this.overhangY=b.height),this.height=Math.max(this.height,b.height))}this.widthWithConnectedBlocks=this.width};Blockly.blockRendering.RenderInfo=function(a){this.block_=a;this.outputConnection=a.outputConnection?new Blockly.blockRendering.OutputConnection:null;this.isInline=a.getInputsInline()&&!a.isCollapsed();this.isCollapsed=a.isCollapsed();this.isInsertionMarker=a.isInsertionMarker();this.RTL=a.RTL;this.statementEdge=this.width=this.widthWithChildren=this.height=0;this.rows=[];this.hiddenIcons=[];this.bottomRow=this.topRow=null;this.startY=this.startX=0;this.measure_()};
|
||||
Blockly.blockRendering.RenderInfo.prototype.measure_=function(){this.createRows_();this.addElemSpacing_();this.computeBounds_();this.alignRowElements_();this.addRowSpacing_();this.finalize_()};
|
||||
Blockly.blockRendering.RenderInfo.prototype.createRows_=function(){this.createTopRow_();this.rows.push(this.topRow);var a=new Blockly.blockRendering.Row,b=this.block_.getIcons();if(b.length)for(var c=0;c<b.length;c++){var d=b[c],e=new Blockly.blockRendering.Icon(d);this.isCollapsed&&d.collapseHidden?this.hiddenIcons.push(e):a.elements.push(e)}d=void 0;for(c=0;c<this.block_.inputList.length;c++)if(b=this.block_.inputList[c],b.isVisible()){this.shouldStartNewRow_(b,d)&&(this.rows.push(a),a=new Blockly.blockRendering.Row);
|
||||
for(d=0;d<b.fieldRow.length;d++)a.elements.push(new Blockly.blockRendering.Field(b.fieldRow[d],b));this.addInput_(b,a);d=b}this.isCollapsed&&(a.hasJaggedEdge=!0,a.elements.push(new Blockly.blockRendering.JaggedEdge));a.elements.length&&this.rows.push(a);this.createBottomRow_();this.rows.push(this.bottomRow)};
|
||||
Blockly.blockRendering.RenderInfo.prototype.createTopRow_=function(){var a=this.block_.hat?"cap"===this.block_.hat:Blockly.BlockSvg.START_HAT,b=!!this.block_.previousConnection,c=this.block_.getPreviousBlock();c=!!this.block_.outputConnection||a||c&&c.getNextBlock()==this.block_;this.topRow=new Blockly.blockRendering.TopRow(this.block_);c?this.topRow.elements.push(new Blockly.blockRendering.SquareCorner):this.topRow.elements.push(new Blockly.blockRendering.RoundCorner);a?this.topRow.elements.push(new Blockly.blockRendering.Hat):
|
||||
b&&this.topRow.elements.push(new Blockly.blockRendering.PreviousConnection)};Blockly.blockRendering.RenderInfo.prototype.createBottomRow_=function(){var a=!!this.block_.outputConnection||!!this.block_.getNextBlock();this.bottomRow=new Blockly.blockRendering.BottomRow(this.block_);a?this.bottomRow.elements.push(new Blockly.blockRendering.SquareCorner):this.bottomRow.elements.push(new Blockly.blockRendering.RoundCorner);this.bottomRow.hasNextConnection&&this.bottomRow.elements.push(new Blockly.blockRendering.NextConnection)};
|
||||
Blockly.blockRendering.RenderInfo.prototype.createTopRow_=function(){var a=this.block_.hat?"cap"===this.block_.hat:Blockly.BlockSvg.START_HAT,b=!!this.block_.previousConnection,c=this.block_.getPreviousBlock();c=!!this.block_.outputConnection||a||c&&c.getNextBlock()==this.block_;this.topRow=new Blockly.blockRendering.TopRow(this.block_);c?this.topRow.elements.push(new Blockly.blockRendering.SquareCorner):this.topRow.elements.push(new Blockly.blockRendering.RoundCorner);a?(a=new Blockly.blockRendering.Hat,
|
||||
this.topRow.elements.push(a),this.startY=a.startY):b&&this.topRow.elements.push(new Blockly.blockRendering.PreviousConnection)};
|
||||
Blockly.blockRendering.RenderInfo.prototype.createBottomRow_=function(){var a=!!this.block_.outputConnection||!!this.block_.getNextBlock();this.bottomRow=new Blockly.blockRendering.BottomRow(this.block_);a?this.bottomRow.elements.push(new Blockly.blockRendering.SquareCorner):this.bottomRow.elements.push(new Blockly.blockRendering.RoundCorner);this.bottomRow.hasNextConnection&&this.bottomRow.elements.push(new Blockly.blockRendering.NextConnection)};
|
||||
Blockly.blockRendering.RenderInfo.prototype.addInput_=function(a,b){this.isInline&&a.type==Blockly.INPUT_VALUE?(b.elements.push(new Blockly.blockRendering.InlineInput(a)),b.hasInlineInput=!0):a.type==Blockly.NEXT_STATEMENT?(b.elements.push(new Blockly.blockRendering.StatementInput(a)),b.hasStatement=!0):a.type==Blockly.INPUT_VALUE?(b.elements.push(new Blockly.blockRendering.ExternalValueInput(a)),b.hasExternalInput=!0):a.type==Blockly.DUMMY_INPUT&&(b.hasDummyInput=!0)};
|
||||
Blockly.blockRendering.RenderInfo.prototype.shouldStartNewRow_=function(a,b){return b?a.type==Blockly.NEXT_STATEMENT?!0:a.type==Blockly.INPUT_VALUE||a.type==Blockly.DUMMY_INPUT?!this.isInline:!1:!1};
|
||||
Blockly.blockRendering.RenderInfo.prototype.addElemSpacing_=function(){for(var a=0;a<this.rows.length;a++){var b=this.rows[a],c=b.elements;b.elements=[];"top row"!=b.type&&"bottom row"!=b.type&&b.elements.push(new Blockly.blockRendering.InRowSpacer(this.getInRowSpacing_(null,c[0])));for(var d=0;d<c.length;d++){b.elements.push(c[d]);var e=this.getInRowSpacing_(c[d],c[d+1]);b.elements.push(new Blockly.blockRendering.InRowSpacer(e))}}};
|
||||
@@ -1561,56 +1423,60 @@ b.isInput){if(a.isEditable){if(b.isInlineInput()||b.isExternalInput())return Blo
|
||||
Blockly.blockRendering.constants.LARGE_PADDING;if(a.isSquareCorner()){if(b.isHat())return Blockly.blockRendering.constants.NO_PADDING;if(b.isPreviousConnection())return Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;if(b.isNextConnection()){var c=(this.RTL?1:-1)*Blockly.blockRendering.constants.DARK_PATH_OFFSET/2;return Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT+c}}if(a.isRoundedCorner()){if(b.isPreviousConnection())return Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV;
|
||||
if(b.isNextConnection())return c=(this.RTL?1:-1)*Blockly.blockRendering.constants.DARK_PATH_OFFSET/2,Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV+c}return!a.isInput&&!b.isInput&&a.isEditable==b.isEditable||b.isJaggedEdge()?Blockly.blockRendering.constants.LARGE_PADDING:Blockly.blockRendering.constants.MEDIUM_PADDING};
|
||||
Blockly.blockRendering.RenderInfo.prototype.computeBounds_=function(){for(var a=0,b=0,c=0,d=0;d<this.rows.length;d++){var e=this.rows[d];e.measure();e.hasStatement||(b=Math.max(b,e.width));if(e.hasStatement){var f=e.getLastInput();a=Math.max(a,e.width-f.width)}c=Math.max(c,e.widthWithConnectedBlocks)}this.width=(this.statementEdge=a)?Math.max(b,a+2*Blockly.blockRendering.constants.NOTCH.width):b;for(d=0;d<this.rows.length;d++)e=this.rows[d],e.hasStatement&&(e.statementEdge=this.statementEdge);this.widthWithChildren=
|
||||
Math.max(b,c)};Blockly.blockRendering.RenderInfo.prototype.alignRowElements_=function(){for(var a=0;a<this.rows.length;a++){var b=this.rows[a];if(!b.hasStatement&&!b.hasInlineInput){var c=b.width,d=this.width;"bottom row"===b.type&&b.hasFixedWidth&&(d=Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH);(c=d-c)&&this.addAlignmentPadding_(b,c)}}};
|
||||
Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_=function(a,b){var c=a.elements,d=a.getLastInput();if(d){var e=a.getFirstSpacer(),f=a.getLastSpacer();a.hasExternalInput&&(f=c[c.length-3]);d.align==Blockly.ALIGN_LEFT?f.width+=b:d.align==Blockly.ALIGN_CENTRE?(e.width+=b/2,f.width+=b/2):d.align==Blockly.ALIGN_RIGHT&&(e.width+=b);a.width+=b}else if("top row"===a.type||"bottom row"===a.type)a.getLastSpacer().width+=b,a.width+=b};
|
||||
Math.max(b,c);this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)};
|
||||
Blockly.blockRendering.RenderInfo.prototype.alignRowElements_=function(){for(var a=0;a<this.rows.length;a++){var b=this.rows[a];if(!b.hasInlineInput){if(b.hasStatement){var c=b.getLastInput();c=b.width-c.width;var d=this.statementEdge-this.startX}else c=b.width,d=this.width-this.startX;"bottom row"===b.type&&b.hasFixedWidth&&(d=Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH);(c=d-c)&&this.addAlignmentPadding_(b,c)}}};
|
||||
Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_=function(a,b){var c=a.elements,d=a.getLastInput();if(d){var e=a.getFirstSpacer(),f=a.getLastSpacer();if(a.hasExternalInput||a.hasStatement)f=c[c.length-3];d.align==Blockly.ALIGN_LEFT?f.width+=b:d.align==Blockly.ALIGN_CENTRE?(e.width+=b/2,f.width+=b/2):d.align==Blockly.ALIGN_RIGHT&&(e.width+=b);a.width+=b}else if("top row"===a.type||"bottom row"===a.type)a.getLastSpacer().width+=b,a.width+=b};
|
||||
Blockly.blockRendering.RenderInfo.prototype.addRowSpacing_=function(){var a=this.rows;this.rows=[];for(var b=0;b<a.length;b++)this.rows.push(a[b]),b!==a.length-1&&this.rows.push(this.makeSpacerRow_(a[b],a[b+1]))};Blockly.blockRendering.RenderInfo.prototype.makeSpacerRow_=function(a,b){var c=this.getSpacerRowHeight_(a,b),d=this.getSpacerRowWidth_(a,b);c=new Blockly.blockRendering.BetweenRowSpacer(c,d);a.hasStatement&&(c.followsStatement=!0);return c};
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_=function(a,b){return"bottom row"===b.type&&b.hasFixedWidth?b.width:this.width};
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_=function(a,b){return"bottom row"===b.type&&b.hasFixedWidth?b.width:this.width-this.startX};
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowHeight_=function(a,b){return"top row"===a.type&&"bottom row"===b.type?Blockly.blockRendering.constants.EMPTY_BLOCK_SPACER_HEIGHT:"top row"===a.type||"bottom row"===b.type?Blockly.blockRendering.constants.NO_PADDING:a.hasExternalInput&&b.hasExternalInput?Blockly.blockRendering.constants.LARGE_PADDING:!a.hasStatement&&b.hasStatement?Blockly.blockRendering.constants.BETWEEN_STATEMENT_PADDING_Y:a.hasStatement&&b.hasStatement||b.hasDummyInput?Blockly.blockRendering.constants.LARGE_PADDING:
|
||||
Blockly.blockRendering.constants.MEDIUM_PADDING};Blockly.blockRendering.RenderInfo.prototype.getElemCenterline_=function(a,b){var c=a.yPos;if(b.isField()){if(c+=b.height/2,a.hasInlineInput||a.hasStatement)c+=Blockly.blockRendering.constants.TALL_INPUT_FIELD_OFFSET_Y}else c=b.isInlineInput()?c+b.height/2:b.isNextConnection()?c+(a.height+b.height/2):c+a.height/2;return c};
|
||||
Blockly.blockRendering.RenderInfo.prototype.finalize_=function(){for(var a=0,b=0;b<this.rows.length;b++){var c=this.rows[b];c.yPos=a;a+=c.height;c==this.bottomRow&&a<Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT&&(this.bottomRow.height+=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT-a,a=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT);if(!c.isSpacer())for(var d=0,e=0;e<c.elements.length;e++){var f=c.elements[e];f.xPos=d;f.centerline=this.getElemCenterline_(c,f);d+=f.width}}this.height=this.blockBottom=
|
||||
Blockly.blockRendering.constants.MEDIUM_PADDING};Blockly.blockRendering.RenderInfo.prototype.getElemCenterline_=function(a,b){var c=a.yPos;if(b.isField()){if(c+=b.height/2,a.hasInlineInput||a.hasStatement)c+=Blockly.blockRendering.constants.TALL_INPUT_FIELD_OFFSET_Y}else c=b.isInlineInput()?c+b.height/2:b.isNextConnection()?c+(a.height-a.overhangY+b.height/2):c+a.height/2;return c};
|
||||
Blockly.blockRendering.RenderInfo.prototype.finalize_=function(){for(var a=0,b=0;b<this.rows.length;b++){var c=this.rows[b];c.yPos=a;c.xPos=this.startX;a+=c.height;var d=a-this.topRow.startY;c==this.bottomRow&&d<Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT&&(d=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT-d,this.bottomRow.height+=d,a+=d);if(!c.isSpacer()){d=c.xPos;for(var e=0;e<c.elements.length;e++){var f=c.elements[e];f.xPos=d;f.centerline=this.getElemCenterline_(c,f);d+=f.width}}}this.height=
|
||||
a};Blockly.blockRendering.highlightConstants={};Blockly.blockRendering.highlightConstants.OFFSET=.5;Blockly.blockRendering.highlightConstants.START_POINT=Blockly.utils.svgPaths.moveBy(Blockly.blockRendering.highlightConstants.OFFSET,Blockly.blockRendering.highlightConstants.OFFSET);
|
||||
Blockly.blockRendering.highlightConstants.INSIDE_CORNER=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.blockRendering.highlightConstants.OFFSET,c=(1-Math.SQRT1_2)*(a+b)-b,d=Blockly.utils.svgPaths.moveBy(c,c)+Blockly.utils.svgPaths.arc("a","0 0,0",a,Blockly.utils.svgPaths.point(-c-b,a-c)),e=Blockly.utils.svgPaths.arc("a","0 0,0",a+b,Blockly.utils.svgPaths.point(a+b,a+b)),f=Blockly.utils.svgPaths.moveBy(c,-c)+Blockly.utils.svgPaths.arc("a","0 0,0",a+b,Blockly.utils.svgPaths.point(a-
|
||||
c,c+b));return{height:a,pathTop:function(a){return a?d:""},pathBottom:function(a){return a?e:f}}}();
|
||||
Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.blockRendering.highlightConstants.OFFSET,c=(1-Math.SQRT1_2)*(a-b)+b,d=Blockly.utils.svgPaths.moveBy(c,c),e=Blockly.utils.svgPaths.moveBy(b,a-b),f=Blockly.utils.svgPaths.arc("A","0 0,1",a-b,Blockly.utils.svgPaths.point(a,b));return{height:a,topLeft:function(a){return(a?d:e)+f},bottomLeft:function(d){return Blockly.utils.svgPaths.moveTo(c+b,d-c)+Blockly.utils.svgPaths.arc("A",
|
||||
"0 0,1",a-b,Blockly.utils.svgPaths.point(b,d-a))}}}();
|
||||
Blockly.blockRendering.highlightConstants.PUZZLE_TAB=function(){var a=Blockly.blockRendering.constants.TAB_WIDTH,b=Blockly.blockRendering.constants.TAB_HEIGHT,c=Blockly.utils.svgPaths.moveTo(-.25*a,8.4)+Blockly.utils.svgPaths.lineTo(-.45*a,-2.1),d=Blockly.utils.svgPaths.lineOnAxis("v",2.5)+Blockly.utils.svgPaths.moveBy(.97*-a,2.5)+Blockly.utils.svgPaths.curve("q",[Blockly.utils.svgPaths.point(.05*-a,10),Blockly.utils.svgPaths.point(.3*a,9.5)])+Blockly.utils.svgPaths.moveBy(.67*a,-1.9)+Blockly.utils.svgPaths.lineOnAxis("v",
|
||||
2.5),e=Blockly.utils.svgPaths.lineOnAxis("V",b+Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP-1.5)+Blockly.utils.svgPaths.moveBy(-.92*a,-.5)+Blockly.utils.svgPaths.curve("q",[Blockly.utils.svgPaths.point(-.19*a,-5.5),Blockly.utils.svgPaths.point(0,-11)])+Blockly.utils.svgPaths.moveBy(.92*a,1)+Blockly.utils.svgPaths.lineOnAxis("V",.5)+Blockly.utils.svgPaths.lineOnAxis("H",1),f=Blockly.utils.svgPaths.moveBy(-5,b-.7)+Blockly.utils.svgPaths.lineTo(.46*a,-2.1);return{width:a,height:b,pathUp:function(a){return a?
|
||||
c:e},pathDown:function(a){return a?d:f}}}();Blockly.blockRendering.highlightConstants.NOTCH=function(){return{pathLeft:Blockly.utils.svgPaths.lineOnAxis("h",Blockly.blockRendering.highlightConstants.OFFSET)+Blockly.blockRendering.constants.NOTCH.pathLeft}}();Blockly.blockRendering.highlightConstants.JAGGED_TEETH=function(){return{pathLeft:Blockly.utils.svgPaths.lineTo(5.1,2.6)+Blockly.utils.svgPaths.moveBy(-10.2,6.8)+Blockly.utils.svgPaths.lineTo(5.1,2.6)}}();
|
||||
Blockly.blockRendering.highlightConstants.START_HAT=function(){var a=Blockly.utils.svgPaths.moveBy(25,-8.7)+Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(29.7,-6.2),Blockly.utils.svgPaths.point(57.2,-.5),Blockly.utils.svgPaths.point(75,8.7)]),b=Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(17.8,-9.2),Blockly.utils.svgPaths.point(45.3,-14.9),Blockly.utils.svgPaths.point(75,-8.7)])+Blockly.utils.svgPaths.moveTo(100.5,.5);return{path:function(c){return c?a:b}}}();Blockly.blockRendering.Highlighter=function(a,b){this.info_=a;this.pathObject_=b;this.steps_=this.pathObject_.highlightSteps;this.inlineSteps_=this.pathObject_.highlightInlineSteps;this.RTL_=this.info_.RTL;this.highlightOffset_=Blockly.blockRendering.highlightConstants.OFFSET;this.outsideCornerPaths_=Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER;this.insideCornerPaths_=Blockly.blockRendering.highlightConstants.INSIDE_CORNER;this.puzzleTabPaths_=Blockly.blockRendering.highlightConstants.PUZZLE_TAB;
|
||||
Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.blockRendering.highlightConstants.OFFSET,c=(1-Math.SQRT1_2)*(a-b)+b,d=Blockly.utils.svgPaths.moveBy(c,c)+Blockly.utils.svgPaths.arc("a","0 0,1",a-b,Blockly.utils.svgPaths.point(a-c,-c+b)),e=Blockly.utils.svgPaths.moveBy(b,a)+Blockly.utils.svgPaths.arc("a","0 0,1",a-b,Blockly.utils.svgPaths.point(a,-a+b)),f=-c,g=Blockly.utils.svgPaths.moveBy(c,f)+Blockly.utils.svgPaths.arc("a",
|
||||
"0 0,1",a-b,Blockly.utils.svgPaths.point(-c+b,-f-a));return{height:a,topLeft:function(a){return a?d:e},bottomLeft:function(){return g}}}();
|
||||
Blockly.blockRendering.highlightConstants.PUZZLE_TAB=function(){var a=Blockly.blockRendering.constants.TAB_WIDTH,b=Blockly.blockRendering.constants.TAB_HEIGHT,c=Blockly.utils.svgPaths.moveBy(-2,-b+3.4)+Blockly.utils.svgPaths.lineTo(-.45*a,-2.1),d=Blockly.utils.svgPaths.lineOnAxis("v",2.5)+Blockly.utils.svgPaths.moveBy(.97*-a,2.5)+Blockly.utils.svgPaths.curve("q",[Blockly.utils.svgPaths.point(.05*-a,10),Blockly.utils.svgPaths.point(.3*a,9.5)])+Blockly.utils.svgPaths.moveBy(.67*a,-1.9)+Blockly.utils.svgPaths.lineOnAxis("v",
|
||||
2.5),e=Blockly.utils.svgPaths.lineOnAxis("v",-1.5)+Blockly.utils.svgPaths.moveBy(-.92*a,-.5)+Blockly.utils.svgPaths.curve("q",[Blockly.utils.svgPaths.point(-.19*a,-5.5),Blockly.utils.svgPaths.point(0,-11)])+Blockly.utils.svgPaths.moveBy(.92*a,1),f=Blockly.utils.svgPaths.moveBy(-5,b-.7)+Blockly.utils.svgPaths.lineTo(.46*a,-2.1);return{width:a,height:b,pathUp:function(a){return a?c:e},pathDown:function(a){return a?d:f}}}();
|
||||
Blockly.blockRendering.highlightConstants.NOTCH=function(){return{pathLeft:Blockly.utils.svgPaths.lineOnAxis("h",Blockly.blockRendering.highlightConstants.OFFSET)+Blockly.blockRendering.constants.NOTCH.pathLeft}}();Blockly.blockRendering.highlightConstants.JAGGED_TEETH=function(){return{pathLeft:Blockly.utils.svgPaths.lineTo(5.1,2.6)+Blockly.utils.svgPaths.moveBy(-10.2,6.8)+Blockly.utils.svgPaths.lineTo(5.1,2.6)}}();
|
||||
Blockly.blockRendering.highlightConstants.START_HAT=function(){var a=Blockly.blockRendering.constants.START_HAT.height,b=Blockly.utils.svgPaths.moveBy(25,-8.7)+Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(29.7,-6.2),Blockly.utils.svgPaths.point(57.2,-.5),Blockly.utils.svgPaths.point(75,8.7)]),c=Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(17.8,-9.2),Blockly.utils.svgPaths.point(45.3,-14.9),Blockly.utils.svgPaths.point(75,-8.7)])+Blockly.utils.svgPaths.moveTo(100.5,
|
||||
a+.5);return{path:function(a){return a?b:c}}}();Blockly.blockRendering.Highlighter=function(a,b){this.info_=a;this.pathObject_=b;this.steps_=this.pathObject_.highlightSteps;this.inlineSteps_=this.pathObject_.highlightInlineSteps;this.RTL_=this.info_.RTL;this.highlightOffset_=Blockly.blockRendering.highlightConstants.OFFSET;this.outsideCornerPaths_=Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER;this.insideCornerPaths_=Blockly.blockRendering.highlightConstants.INSIDE_CORNER;this.puzzleTabPaths_=Blockly.blockRendering.highlightConstants.PUZZLE_TAB;
|
||||
this.notchPaths_=Blockly.blockRendering.highlightConstants.NOTCH;this.startPaths_=Blockly.blockRendering.highlightConstants.START_HAT;this.jaggedTeethPaths_=Blockly.blockRendering.highlightConstants.JAGGED_TEETH};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawTopCorner=function(a){for(var b=0,c;c=a.elements[b];b++)"square corner"===c.type?this.steps_.push(Blockly.blockRendering.highlightConstants.START_POINT):"round corner"===c.type?this.steps_.push(this.outsideCornerPaths_.topLeft(this.RTL_)):"previous connection"===c.type?this.steps_.push(this.notchPaths_.pathLeft):"hat"===c.type?this.steps_.push(this.startPaths_.path(this.RTL_)):c.isSpacer()&&this.steps_.push("H",c.xPos+c.width-this.highlightOffset_);
|
||||
this.steps_.push("H",a.width-this.highlightOffset_)};Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_=function(a){this.info_.RTL&&(this.steps_.push("H",a.width-this.highlightOffset_),this.steps_.push(this.jaggedTeethPaths_.pathLeft),this.steps_.push(Blockly.utils.svgPaths.lineOnAxis("v",a.height-this.jaggedTeethPaths_.height-this.highlightOffset_)))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawValueInput=function(a){var b=a.getLastInput();this.RTL_?(a=a.height-b.connectionHeight+this.highlightOffset_,a=Blockly.utils.svgPaths.lineOnAxis("v",-this.highlightOffset_)+this.puzzleTabPaths_.pathDown(this.RTL_)+Blockly.utils.svgPaths.lineOnAxis("v",a)):a=Blockly.utils.svgPaths.moveTo(a.width,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_);this.steps_.push(a)};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawStatementInput=function(a){if(this.RTL_){var b=a.height-2*this.insideCornerPaths_.height;a=Blockly.utils.svgPaths.moveTo(a.statementEdge,a.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+Blockly.utils.svgPaths.lineOnAxis("v",b)+this.insideCornerPaths_.pathBottom(this.RTL_)}else a=Blockly.utils.svgPaths.moveTo(a.statementEdge,a.yPos+a.height)+this.insideCornerPaths_.pathBottom(this.RTL_);this.steps_.push(a)};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawRightSideRow=function(a){a.followsStatement&&this.steps_.push("H",a.width);this.RTL_&&(this.steps_.push("H",a.width-this.highlightOffset_),this.steps_.push("v",a.height))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawBottomRow=function(a){a=this.info_.height;if(this.RTL_)this.steps_.push("V",a);else{var b=this.info_.bottomRow.elements[0];"square corner"===b.type?this.steps_.push(Blockly.utils.svgPaths.moveTo(this.highlightOffset_,a-this.highlightOffset_)):"round corner"===b.type&&this.steps_.push(this.outsideCornerPaths_.bottomLeft(a))}};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawLeft=function(){this.info_.outputConnection&&this.steps_.push(this.puzzleTabPaths_.pathUp(this.RTL_));this.RTL_||(this.info_.topRow.elements[0].isSquareCorner()?this.steps_.push("V",this.highlightOffset_):this.steps_.push("V",this.outsideCornerPaths_.height))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawTopCorner=function(a){this.steps_.push(Blockly.utils.svgPaths.moveBy(a.xPos,this.info_.startY));for(var b=0,c;c=a.elements[b];b++)"square corner"===c.type?this.steps_.push(Blockly.blockRendering.highlightConstants.START_POINT):"round corner"===c.type?this.steps_.push(this.outsideCornerPaths_.topLeft(this.RTL_)):"previous connection"===c.type?this.steps_.push(this.notchPaths_.pathLeft):"hat"===c.type?this.steps_.push(this.startPaths_.path(this.RTL_)):
|
||||
c.isSpacer()&&0!=c.width&&this.steps_.push("H",c.xPos+c.width-this.highlightOffset_);this.steps_.push("H",a.xPos+a.width-this.highlightOffset_)};Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_=function(a){this.info_.RTL&&(this.steps_.push("H",a.width-this.highlightOffset_),this.steps_.push(this.jaggedTeethPaths_.pathLeft),this.steps_.push(Blockly.utils.svgPaths.lineOnAxis("v",a.height-this.jaggedTeethPaths_.height-this.highlightOffset_)))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawValueInput=function(a){var b=a.getLastInput();this.RTL_?(b=a.height-b.connectionHeight,a=Blockly.utils.svgPaths.moveTo(a.xPos+a.width-this.highlightOffset_,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+Blockly.utils.svgPaths.lineOnAxis("v",b)):a=Blockly.utils.svgPaths.moveTo(a.xPos+a.width,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_);this.steps_.push(a)};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawStatementInput=function(a){var b=a.xPos+a.statementEdge;if(this.RTL_){var c=a.height-2*this.insideCornerPaths_.height;a=Blockly.utils.svgPaths.moveTo(b,a.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+Blockly.utils.svgPaths.lineOnAxis("v",c)+this.insideCornerPaths_.pathBottom(this.RTL_)}else a=Blockly.utils.svgPaths.moveTo(b,a.yPos+a.height)+this.insideCornerPaths_.pathBottom(this.RTL_);this.steps_.push(a)};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawRightSideRow=function(a){var b=a.xPos+a.width-this.highlightOffset_;a.followsStatement&&this.steps_.push("H",b);this.RTL_&&(this.steps_.push("H",b),this.steps_.push("V",a.yPos+a.height-this.highlightOffset_))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawBottomRow=function(a){var b=a.yPos+a.height-a.overhangY;if(this.RTL_)this.steps_.push("V",b-this.highlightOffset_);else{var c=this.info_.bottomRow.elements[0];"square corner"===c.type?this.steps_.push(Blockly.utils.svgPaths.moveTo(a.xPos+this.highlightOffset_,b-this.highlightOffset_)):"round corner"===c.type&&(this.steps_.push(Blockly.utils.svgPaths.moveTo(a.xPos,b)),this.steps_.push(this.outsideCornerPaths_.bottomLeft()))}};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawLeft=function(){var a=this.info_.outputConnection;a&&(a=a.connectionOffsetY+a.height,this.RTL_?this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX,a)):(this.steps_.push(Blockly.utils.svgPaths.moveTo(this.info_.startX+this.highlightOffset_,this.info_.height-this.highlightOffset_)),this.steps_.push("V",a)),this.steps_.push(this.puzzleTabPaths_.pathUp(this.RTL_)));this.RTL_||(a=this.info_.topRow,a.elements[0].isRoundedCorner()?this.steps_.push("V",
|
||||
this.outsideCornerPaths_.height):this.steps_.push("V",a.startY+this.highlightOffset_))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawInlineInput=function(a){var b=this.highlightOffset_,c=a.xPos+a.connectionWidth,d=a.centerline-a.height/2,e=a.width-a.connectionWidth,f=d+b;this.RTL_?(d=a.connectionOffsetY-b,a=a.height-(a.connectionOffsetY+a.connectionHeight)+b,b=Blockly.utils.svgPaths.moveTo(c-b,f)+Blockly.utils.svgPaths.lineOnAxis("v",d)+this.puzzleTabPaths_.pathDown(this.RTL_)+Blockly.utils.svgPaths.lineOnAxis("v",a)+Blockly.utils.svgPaths.lineOnAxis("h",e)):b=Blockly.utils.svgPaths.moveTo(a.xPos+
|
||||
a.width+b,f)+Blockly.utils.svgPaths.lineOnAxis("v",a.height)+Blockly.utils.svgPaths.lineOnAxis("h",-e)+Blockly.utils.svgPaths.moveTo(c,d+a.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_);this.inlineSteps_.push(b)};Blockly.blockRendering.Debug=function(){this.debugElements_=[];this.svgRoot_=null};Blockly.blockRendering.Debug.prototype.clearElems=function(){for(var a=0,b;b=this.debugElements_[a];a++)Blockly.utils.dom.removeNode(b);this.debugElements_=[]};Blockly.blockRendering.Debug.prototype.drawSpacerRow=function(a,b,c){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"rowSpacerRect blockRenderDebug",x:c?-a.width:0,y:b,width:a.width,height:a.height},this.svgRoot_))};
|
||||
a.width+b,f)+Blockly.utils.svgPaths.lineOnAxis("v",a.height)+Blockly.utils.svgPaths.lineOnAxis("h",-e)+Blockly.utils.svgPaths.moveTo(c,d+a.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_);this.inlineSteps_.push(b)};Blockly.blockRendering.Debug=function(){this.debugElements_=[];this.svgRoot_=null};Blockly.blockRendering.Debug.prototype.clearElems=function(){for(var a=0,b;b=this.debugElements_[a];a++)Blockly.utils.dom.removeNode(b);this.debugElements_=[]};Blockly.blockRendering.Debug.prototype.drawSpacerRow=function(a,b,c){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"rowSpacerRect blockRenderDebug",x:c?-(a.xPos+a.width):a.xPos,y:b,width:a.width,height:a.height},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawSpacerElem=function(a,b,c){var d=a.xPos;c&&(d=-(d+a.width));b=Math.min(a.height,b);this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"elemSpacerRect blockRenderDebug",x:d,y:a.centerline-b/2,width:a.width,height:b},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawRenderedElem=function(a,b){var c=a.xPos;b&&(c=-(c+a.width));this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"rowRenderingRect blockRenderDebug",x:c,y:a.centerline-a.height/2,width:a.width,height:a.height},this.svgRoot_));a.isInput&&this.drawConnection(a.connection)};
|
||||
Blockly.blockRendering.Debug.prototype.drawConnection=function(a){if(a.type==Blockly.INPUT_VALUE){var b=4;var c="magenta";var d="none"}else a.type==Blockly.OUTPUT_VALUE?(b=2,d=c="magenta"):a.type==Blockly.NEXT_STATEMENT?(b=4,c="goldenrod",d="none"):a.type==Blockly.PREVIOUS_STATEMENT&&(b=2,d=c="goldenrod");this.debugElements_.push(Blockly.utils.dom.createSvgElement("circle",{"class":"blockRenderDebug",cx:a.offsetInBlock_.x,cy:a.offsetInBlock_.y,r:b,fill:d,stroke:c},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawRenderedRow=function(a,b,c){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"elemRenderingRect blockRenderDebug",x:c?-a.width:0,y:b,width:a.width,height:a.height},this.svgRoot_))};Blockly.blockRendering.Debug.prototype.drawRowWithElements=function(a,b,c){for(var d=0;d<a.elements.length;d++){var e=a.elements[d];e.isSpacer()?this.drawSpacerElem(e,a.height,c):this.drawRenderedElem(e,c)}this.drawRenderedRow(a,b,c)};
|
||||
Blockly.blockRendering.Debug.prototype.drawDebug=function(a,b){this.clearElems();this.svgRoot_=a.getSvgRoot();for(var c=0,d=0;d<b.rows.length;d++){var e=b.rows[d];e.isSpacer()?this.drawSpacerRow(e,c,b.RTL):this.drawRowWithElements(e,c,b.RTL);c+=e.height}a.previousConnection&&this.drawConnection(a.previousConnection);a.nextConnection&&this.drawConnection(a.nextConnection);a.outputConnection&&this.drawConnection(a.outputConnection)};Blockly.blockRendering.Drawer=function(a,b){this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.pathObject_=new Blockly.BlockSvg.PathObject;this.steps_=this.pathObject_.steps;this.inlineSteps_=this.pathObject_.inlineSteps;this.highlighter_=new Blockly.blockRendering.Highlighter(this.info_,this.pathObject_)};
|
||||
Blockly.blockRendering.Drawer.prototype.draw_=function(){this.hideHiddenIcons_();this.drawOutline_();this.drawInternals_();this.block_.setPaths_(this.pathObject_);this.block_.renderingDebugger.drawDebug(this.block_,this.info_);this.recordSizeOnBlock_()};
|
||||
Blockly.blockRendering.Debug.prototype.drawRenderedRow=function(a,b,c){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"elemRenderingRect blockRenderDebug",x:c?-(a.xPos+a.width):a.xPos,y:b,width:a.width,height:a.height},this.svgRoot_))};Blockly.blockRendering.Debug.prototype.drawRowWithElements=function(a,b,c){for(var d=0;d<a.elements.length;d++){var e=a.elements[d];e.isSpacer()?this.drawSpacerElem(e,a.height,c):this.drawRenderedElem(e,c)}this.drawRenderedRow(a,b,c)};
|
||||
Blockly.blockRendering.Debug.prototype.drawBoundingBox=function(a,b,c){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"blockBoundingBox blockRenderDebug",x:c?-a:0,y:0,width:a,height:b},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawDebug=function(a,b){this.clearElems();this.svgRoot_=a.getSvgRoot();for(var c=0,d=0;d<b.rows.length;d++){var e=b.rows[d];e.isSpacer()?this.drawSpacerRow(e,c,b.RTL):this.drawRowWithElements(e,c,b.RTL);c+=e.height}a.previousConnection&&this.drawConnection(a.previousConnection);a.nextConnection&&this.drawConnection(a.nextConnection);a.outputConnection&&this.drawConnection(a.outputConnection);this.drawBoundingBox(b.width,b.height,b.isRtl)};Blockly.blockRendering.Drawer=function(a,b){this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.inlinePath_=this.outlinePath_="";this.pathObject_=new Blockly.BlockSvg.PathObject;this.highlighter_=new Blockly.blockRendering.Highlighter(this.info_,this.pathObject_)};
|
||||
Blockly.blockRendering.Drawer.prototype.draw_=function(){this.hideHiddenIcons_();this.drawOutline_();this.drawInternals_();this.pathObject_.steps=[this.outlinePath_];this.pathObject_.inlineSteps=[this.inlinePath_];this.block_.setPaths_(this.pathObject_);this.block_.renderingDebugger.drawDebug(this.block_,this.info_);this.recordSizeOnBlock_()};
|
||||
Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_=function(){this.block_.height=this.info_.height+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.block_.width=this.info_.widthWithChildren+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.block_.startHat_=this.info_.topRow.startHat};Blockly.blockRendering.Drawer.prototype.hideHiddenIcons_=function(){for(var a=0;a<this.info_.hiddenIcons.length;a++)this.info_.hiddenIcons[a].icon.iconGroup_.setAttribute("display","none")};
|
||||
Blockly.blockRendering.Drawer.prototype.drawOutline_=function(){this.drawTop_();for(var a=1;a<this.info_.rows.length-1;a++){var b=this.info_.rows[a];b.hasJaggedEdge?this.drawJaggedEdge_(b):b.hasStatement?this.drawStatementInput_(b):b.hasExternalInput?this.drawValueInput_(b):this.drawRightSideRow_(b)}this.drawBottom_();this.drawLeft_()};
|
||||
Blockly.blockRendering.Drawer.prototype.drawTop_=function(){var a=this.info_.topRow,b=a.elements;this.highlighter_&&(this.highlighter_.drawTopCorner(a),this.highlighter_.drawRightSideRow(a));this.positionPreviousConnection_();for(var c=0,d;d=b[c];c++)"square corner"===d.type?this.steps_.push(Blockly.blockRendering.constants.START_POINT):"round corner"===d.type?this.steps_.push(Blockly.blockRendering.constants.TOP_LEFT_CORNER_START,Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft):"previous connection"===
|
||||
d.type?this.steps_.push(Blockly.blockRendering.constants.NOTCH.pathLeft):"hat"===d.type?this.steps_.push(Blockly.blockRendering.constants.START_HAT.path):d.isSpacer()&&this.steps_.push("h",d.width);this.steps_.push("v",a.height)};Blockly.blockRendering.Drawer.prototype.drawJaggedEdge_=function(a){this.highlighter_&&this.highlighter_.drawJaggedEdge_(a);this.steps_.push(Blockly.blockRendering.constants.JAGGED_TEETH.path);this.steps_.push("v",a.height-Blockly.blockRendering.constants.JAGGED_TEETH.height)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawValueInput_=function(a){var b=a.getLastInput();this.highlighter_&&this.highlighter_.drawValueInput(a);this.steps_.push("H",a.width);this.steps_.push(Blockly.blockRendering.constants.PUZZLE_TAB.pathDown);this.steps_.push("v",a.height-b.connectionHeight);this.positionExternalValueConnection_(a)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawStatementInput_=function(a){this.highlighter_&&this.highlighter_.drawStatementInput(a);this.steps_.push("H",a.statementEdge+Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT+Blockly.blockRendering.constants.NOTCH.width);this.steps_.push(Blockly.blockRendering.constants.NOTCH.pathRight+" h -"+(Blockly.blockRendering.constants.NOTCH_WIDTH-Blockly.blockRendering.constants.CORNER_RADIUS)+Blockly.blockRendering.constants.INSIDE_CORNERS.pathTop);this.steps_.push("v",
|
||||
a.height-2*Blockly.blockRendering.constants.INSIDE_CORNERS.height);this.steps_.push(Blockly.blockRendering.constants.INSIDE_CORNERS.pathBottom);this.positionStatementInputConnection_(a)};Blockly.blockRendering.Drawer.prototype.drawRightSideRow_=function(a){this.highlighter_&&this.highlighter_.drawRightSideRow(a);this.steps_.push("H",a.width);this.steps_.push("v",a.height)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawBottom_=function(){var a=this.info_.bottomRow,b=a.elements;this.highlighter_&&this.highlighter_.drawBottomRow(a);this.positionNextConnection_();this.steps_.push("v",a.height);for(a=b.length-1;0<=a;a--){var c=b[a];"next connection"===c.type?this.steps_.push(Blockly.blockRendering.constants.NOTCH.pathRight):"square corner"===c.type?this.steps_.push("H 0"):"round corner"===c.type?this.steps_.push(Blockly.blockRendering.constants.OUTSIDE_CORNERS.bottomLeft):
|
||||
c.isSpacer()&&this.steps_.push("h",-1*c.width)}};Blockly.blockRendering.Drawer.prototype.drawLeft_=function(){this.highlighter_&&this.highlighter_.drawLeft();var a=this.info_.outputConnection;this.positionOutputConnection_();a&&(this.steps_.push("V",a.connectionOffsetY+a.height),this.steps_.push(Blockly.blockRendering.constants.PUZZLE_TAB.pathUp));this.steps_.push("z")};
|
||||
Blockly.blockRendering.Drawer.prototype.drawTop_=function(){var a=this.info_.topRow,b=a.elements;this.highlighter_&&(this.highlighter_.drawTopCorner(a),this.highlighter_.drawRightSideRow(a));this.positionPreviousConnection_();this.outlinePath_+=Blockly.utils.svgPaths.moveBy(a.xPos,this.info_.startY);for(var c=0,d;d=b[c];c++)"round corner"===d.type?this.outlinePath_+=Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft:"previous connection"===d.type?this.outlinePath_+=a.notchShape.pathLeft:"hat"===
|
||||
d.type?this.outlinePath_+=Blockly.blockRendering.constants.START_HAT.path:d.isSpacer()&&(this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("h",d.width));this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("v",a.height)};Blockly.blockRendering.Drawer.prototype.drawJaggedEdge_=function(a){this.highlighter_&&this.highlighter_.drawJaggedEdge_(a);this.outlinePath_+=Blockly.blockRendering.constants.JAGGED_TEETH.path+Blockly.utils.svgPaths.lineOnAxis("v",a.height-Blockly.blockRendering.constants.JAGGED_TEETH.height)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawValueInput_=function(a){var b=a.getLastInput();this.highlighter_&&this.highlighter_.drawValueInput(a);this.positionExternalValueConnection_(a);this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("H",a.xPos+a.width)+b.connectionShape.pathDown+Blockly.utils.svgPaths.lineOnAxis("v",a.height-b.connectionHeight)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawStatementInput_=function(a){this.highlighter_&&this.highlighter_.drawStatementInput(a);var b=Blockly.blockRendering.constants.NOTCH.pathRight+" h -"+(Blockly.blockRendering.constants.NOTCH_WIDTH-Blockly.blockRendering.constants.CORNER_RADIUS)+Blockly.blockRendering.constants.INSIDE_CORNERS.pathTop;this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("H",a.xPos+a.statementEdge+Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT+Blockly.blockRendering.constants.NOTCH.width)+
|
||||
b+Blockly.utils.svgPaths.lineOnAxis("v",a.height-2*Blockly.blockRendering.constants.INSIDE_CORNERS.height)+Blockly.blockRendering.constants.INSIDE_CORNERS.pathBottom;this.positionStatementInputConnection_(a)};Blockly.blockRendering.Drawer.prototype.drawRightSideRow_=function(a){this.highlighter_&&this.highlighter_.drawRightSideRow(a);this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("H",a.xPos+a.width)+Blockly.utils.svgPaths.lineOnAxis("V",a.yPos+a.height)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawBottom_=function(){var a=this.info_.bottomRow,b=a.elements;this.highlighter_&&this.highlighter_.drawBottomRow(a);this.positionNextConnection_();this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("v",a.height-a.overhangY);for(var c=b.length-1;0<=c;c--){var d=b[c];"next connection"===d.type?this.outlinePath_+=a.notchShape.pathRight:"square corner"===d.type?this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("H",a.xPos):"round corner"===d.type?this.outlinePath_+=
|
||||
Blockly.blockRendering.constants.OUTSIDE_CORNERS.bottomLeft:d.isSpacer()&&(this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("h",-1*d.width))}};Blockly.blockRendering.Drawer.prototype.drawLeft_=function(){this.highlighter_&&this.highlighter_.drawLeft();var a=this.info_.outputConnection;this.positionOutputConnection_();a&&(this.outlinePath_+=Blockly.utils.svgPaths.lineOnAxis("V",a.connectionOffsetY+a.height)+a.connectionShape.pathUp);this.outlinePath_+="z"};
|
||||
Blockly.blockRendering.Drawer.prototype.drawInternals_=function(){for(var a=0;a<this.info_.rows.length;a++){var b=this.info_.rows[a];if(!b.isSpacer())for(var c=0;c<b.elements.length;c++){var d=b.elements[c];d.isInlineInput()?this.drawInlineInput_(d):(d.isIcon()||d.isField())&&this.layoutField_(d)}}};
|
||||
Blockly.blockRendering.Drawer.prototype.layoutField_=function(a){if("field"==a.type)var b=a.field.getSvgRoot();else"icon"==a.type&&(b=a.icon.iconGroup_);var c=a.centerline-a.height/2,d=a.xPos,e="";this.info_.RTL&&(d=-(d+a.width),a.flipRtl&&(d+=a.width,e="scale(-1 1)"));"icon"==a.type?(b.setAttribute("display","block"),b.setAttribute("transform","translate("+d+","+c+")"),a.icon.computeIconLocation()):b.setAttribute("transform","translate("+d+","+c+")"+e);this.info_.isInsertionMarker&&b.setAttribute("display",
|
||||
"none")};
|
||||
Blockly.blockRendering.Drawer.prototype.drawInlineInput_=function(a){this.highlighter_&&this.highlighter_.drawInlineInput(a);var b=a.width,c=a.height,d=a.connectionOffsetY,e=a.connectionHeight+d;this.inlineSteps_.push("M",a.xPos+a.connectionWidth+","+(a.centerline-c/2));this.inlineSteps_.push("v ",d);this.inlineSteps_.push(Blockly.blockRendering.constants.PUZZLE_TAB.pathDown);this.inlineSteps_.push("v",c-e);this.inlineSteps_.push("h",b-a.connectionWidth);this.inlineSteps_.push("v",-c);this.inlineSteps_.push("z");this.positionInlineInputConnection_(a)};
|
||||
Blockly.blockRendering.Drawer.prototype.positionInlineInputConnection_=function(a){var b=a.centerline-a.height/2;if(a.connection){var c=a.xPos+a.connectionWidth+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);a.connection.setOffsetInBlock(c,b+a.connectionOffsetY+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionStatementInputConnection_=function(a){var b=a.getLastInput();if(b.connection){var c=a.statementEdge+Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;this.info_.RTL&&(c*=-1);b.connection.setOffsetInBlock(c+.5,a.yPos+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionExternalValueConnection_=function(a){var b=a.getLastInput();if(b.connection){var c=a.width+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);b.connection.setOffsetInBlock(c,a.yPos)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionPreviousConnection_=function(){if(this.info_.topRow.hasPreviousConnection){var a=Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;this.info_.topRow.connection.setOffsetInBlock(this.info_.RTL?-a:a,0)}};Blockly.blockRendering.Drawer.prototype.positionNextConnection_=function(){var a=this.info_.bottomRow;if(a.hasNextConnection){var b=a.getNextConnection().xPos;a.connection.setOffsetInBlock((this.info_.RTL?-b:b)+.5,this.info_.height+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionOutputConnection_=function(){this.info_.outputConnection&&this.block_.outputConnection.setOffsetInBlock(0,this.info_.outputConnection.connectionOffsetY)};Blockly.blockRendering.render=function(a){a.renderingDebugger||(a.renderingDebugger=new Blockly.blockRendering.Debug);var b=new Blockly.blockRendering.RenderInfo(a);(new Blockly.blockRendering.Drawer(a,b)).draw_()};Blockly.utils.uiMenu={};Blockly.utils.uiMenu.getSize=function(a){a=a.getElement();var b=Blockly.utils.style.getSize(a);b.height=a.scrollHeight;return b};Blockly.utils.uiMenu.adjustBBoxesForRTL=function(a,b,c){b.left+=c.width;b.right+=c.width;a.left+=c.width;a.right+=c.width};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;Blockly.ContextMenu.eventWrapper_=null;Blockly.ContextMenu.show=function(a,b,c){Blockly.WidgetDiv.show(Blockly.ContextMenu,c,null);if(b.length){var d=Blockly.ContextMenu.populate_(b,c);goog.events.listen(d,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);Blockly.ContextMenu.position_(d,a,c);setTimeout(function(){d.getElement().focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()};
|
||||
Blockly.blockRendering.Drawer.prototype.drawInlineInput_=function(a){this.highlighter_&&this.highlighter_.drawInlineInput(a);var b=a.width,c=a.height,d=a.connectionOffsetY,e=a.connectionHeight+d;this.inlinePath_+=Blockly.utils.svgPaths.moveTo(a.xPos+a.connectionWidth,a.centerline-c/2)+Blockly.utils.svgPaths.lineOnAxis("v",d)+a.connectionShape.pathDown+Blockly.utils.svgPaths.lineOnAxis("v",c-e)+Blockly.utils.svgPaths.lineOnAxis("h",b-a.connectionWidth)+Blockly.utils.svgPaths.lineOnAxis("v",-c)+"z";
|
||||
this.positionInlineInputConnection_(a)};Blockly.blockRendering.Drawer.prototype.positionInlineInputConnection_=function(a){var b=a.centerline-a.height/2;if(a.connection){var c=a.xPos+a.connectionWidth+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);a.connection.setOffsetInBlock(c,b+a.connectionOffsetY+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionStatementInputConnection_=function(a){var b=a.getLastInput();if(b.connection){var c=a.xPos+a.statementEdge+Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;this.info_.RTL&&(c*=-1);b.connection.setOffsetInBlock(c+.5,a.yPos+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionExternalValueConnection_=function(a){var b=a.getLastInput();if(b.connection){var c=a.xPos+a.width+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);b.connection.setOffsetInBlock(c,a.yPos)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionPreviousConnection_=function(){var a=this.info_.topRow;if(a.hasPreviousConnection){var b=a.xPos+Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;a.connection.setOffsetInBlock(this.info_.RTL?-b:b,0)}};Blockly.blockRendering.Drawer.prototype.positionNextConnection_=function(){var a=this.info_.bottomRow;if(a.hasNextConnection){var b=a.getNextConnection(),c=b.xPos;a.connection.setOffsetInBlock((this.info_.RTL?-c:c)+.5,b.centerline-b.height/2+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionOutputConnection_=function(){if(this.info_.outputConnection){var a=this.info_.startX;this.block_.outputConnection.setOffsetInBlock(this.info_.RTL?-a:a,this.info_.outputConnection.connectionOffsetY)}};Blockly.blockRendering.render=function(a){a.renderingDebugger||(a.renderingDebugger=new Blockly.blockRendering.Debug);var b=new Blockly.blockRendering.RenderInfo(a);(new Blockly.blockRendering.Drawer(a,b)).draw_()};Blockly.utils.uiMenu={};Blockly.utils.uiMenu.getSize=function(a){a=a.getElement();var b=Blockly.utils.style.getSize(a);b.height=a.scrollHeight;return b};Blockly.utils.uiMenu.adjustBBoxesForRTL=function(a,b,c){b.left+=c.width;b.right+=c.width;a.left+=c.width;a.right+=c.width};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;Blockly.ContextMenu.eventWrapper_=null;Blockly.ContextMenu.show=function(a,b,c){Blockly.WidgetDiv.show(Blockly.ContextMenu,c,null);if(b.length){var d=Blockly.ContextMenu.populate_(b,c);goog.events.listen(d,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);Blockly.ContextMenu.position_(d,a,c);setTimeout(function(){d.getElement().focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()};
|
||||
Blockly.ContextMenu.populate_=function(a,b){var c=new goog.ui.Menu;c.setRightToLeft(b);for(var d=0,e;e=a[d];d++){var f=new goog.ui.MenuItem(e.text);f.setRightToLeft(b);c.addChild(f,!0);f.setEnabled(e.enabled);e.enabled&&(goog.events.listen(f,goog.ui.Component.EventType.ACTION,e.callback),f.handleContextMenu=function(){goog.events.dispatchEvent(this,goog.ui.Component.EventType.ACTION)})}return c};
|
||||
Blockly.ContextMenu.position_=function(a,b,c){var d=Blockly.utils.getViewportBBox();b={top:b.clientY+d.top,bottom:b.clientY+d.top,left:b.clientX+d.left,right:b.clientX+d.left};Blockly.ContextMenu.createWidget_(a);var e=Blockly.utils.uiMenu.getSize(a);c&&Blockly.utils.uiMenu.adjustBBoxesForRTL(d,b,e);Blockly.WidgetDiv.positionWithAnchor(d,b,e,c);a.getElement().focus()};
|
||||
Blockly.ContextMenu.createWidget_=function(a){a.render(Blockly.WidgetDiv.DIV);var b=a.getElement();Blockly.utils.dom.addClass(b,"blocklyContextMenu");Blockly.bindEventWithChecks_(b,"contextmenu",null,Blockly.utils.noEvent);a.setAllowAutoFocus(!0)};Blockly.ContextMenu.hide=function(){Blockly.WidgetDiv.hideIfOwner(Blockly.ContextMenu);Blockly.ContextMenu.currentBlock=null;Blockly.ContextMenu.eventWrapper_&&Blockly.unbindEvent_(Blockly.ContextMenu.eventWrapper_)};
|
||||
@@ -1824,39 +1690,38 @@ Blockly.ASTNode.prototype["in"]=function(){switch(this.type_){case Blockly.ASTNo
|
||||
Blockly.ASTNode.prototype.prev=function(){switch(this.type_){case Blockly.ASTNode.types.WORKSPACE:var a=new Blockly.utils.Coordinate(this.wsCoordinate_.x-Blockly.ASTNode.wsMove_,this.wsCoordinate_.y);return Blockly.ASTNode.createWorkspaceNode(this.location_,a);case Blockly.ASTNode.types.STACK:return this.navigateBetweenStacks_(!1);case Blockly.ASTNode.types.FIELD:return this.findPrevForField_();case Blockly.ASTNode.types.INPUT:return this.findPrevForInput_();case Blockly.ASTNode.types.BLOCK:a=this.location_.outputConnection;
|
||||
if(a=this.location_.previousConnection||a)return Blockly.ASTNode.createConnectionNode(a);break;case Blockly.ASTNode.types.PREVIOUS:if(a=this.location_.targetConnection)return Blockly.ASTNode.createConnectionNode(a);break;case Blockly.ASTNode.types.NEXT:return Blockly.ASTNode.createBlockNode(this.location_.getSourceBlock())}return null};
|
||||
Blockly.ASTNode.prototype.out=function(){switch(this.type_){case Blockly.ASTNode.types.STACK:var a=this.location_.getRelativeToSurfaceXY();a=new Blockly.utils.Coordinate(a.x,a.y+Blockly.ASTNode.DEFAULT_OFFSET_Y);return Blockly.ASTNode.createWorkspaceNode(this.location_.workspace,a);case Blockly.ASTNode.types.OUTPUT:return(a=this.location_.targetConnection)?Blockly.ASTNode.createConnectionNode(a):Blockly.ASTNode.createStackNode(this.location_.getSourceBlock());case Blockly.ASTNode.types.FIELD:return Blockly.ASTNode.createBlockNode(this.location_.getSourceBlock());
|
||||
case Blockly.ASTNode.types.INPUT:return Blockly.ASTNode.createBlockNode(this.location_.getSourceBlock());case Blockly.ASTNode.types.BLOCK:return this.getOutAstNodeForBlock_(this.location_);case Blockly.ASTNode.types.PREVIOUS:return this.getOutAstNodeForBlock_(this.location_.getSourceBlock());case Blockly.ASTNode.types.NEXT:return this.getOutAstNodeForBlock_(this.location_.getSourceBlock())}return null};Blockly.user={};Blockly.user.keyMap={};Blockly.user.keyMap.map_={};Blockly.user.keyMap.setActionForKey=function(a,b){var c=Blockly.user.keyMap.getKeyByActionName(b.name);c&&delete Blockly.user.keyMap.map_[c];Blockly.user.keyMap.map_[a]=b};Blockly.user.keyMap.setKeyMap=function(a){Blockly.user.keyMap.map_=a};Blockly.user.keyMap.getKeyMap=function(){return Blockly.user.keyMap.map_};Blockly.user.keyMap.getActionByKeyCode=function(a){return Blockly.user.keyMap.map_[a]};
|
||||
Blockly.user.keyMap.getKeyByActionName=function(a){for(var b=Object.keys(Blockly.user.keyMap.map_),c=0;c<b.length;c++){var d=b[c];if(a===Blockly.user.keyMap.map_[d].name)return d}return null};Blockly.user.keyMap.serializeKeyEvent=function(a){var b="";a.getModifierState("Shift")&&(b+="+");a.getModifierState("Control")&&(b+="ctrl");a.getModifierState("Alt")&&(b+="alt");a.getModifierState("Meta")&&(b+="meta");return b+=a.keyCode};
|
||||
Blockly.user.keyMap.createDefaultKeyMap=function(){var a={};a[goog.events.KeyCodes.W]=Blockly.Navigation.ACTION_PREVIOUS;a[goog.events.KeyCodes.A]=Blockly.Navigation.ACTION_OUT;a[goog.events.KeyCodes.S]=Blockly.Navigation.ACTION_NEXT;a[goog.events.KeyCodes.D]=Blockly.Navigation.ACTION_IN;a[goog.events.KeyCodes.I]=Blockly.Navigation.ACTION_INSERT;a[goog.events.KeyCodes.ENTER]=Blockly.Navigation.ACTION_MARK;a[goog.events.KeyCodes.X]=Blockly.Navigation.ACTION_DISCONNECT;a[goog.events.KeyCodes.T]=Blockly.Navigation.ACTION_TOOLBOX;
|
||||
a[goog.events.KeyCodes.E]=Blockly.Navigation.ACTION_EXIT;a[goog.events.KeyCodes.ESC]=Blockly.Navigation.ACTION_ESCAPE;return a};Blockly.Navigation={};Blockly.Navigation.cursor_=null;Blockly.Navigation.marker_=null;Blockly.Navigation.currentCategory_=null;Blockly.Navigation.flyoutBlock_=null;Blockly.Navigation.loggingCallback=null;Blockly.Navigation.STATE_FLYOUT=1;Blockly.Navigation.STATE_WS=2;Blockly.Navigation.STATE_TOOLBOX=3;Blockly.Navigation.currentState_=Blockly.Navigation.STATE_WS;Blockly.Navigation.setCursor=function(a){Blockly.Navigation.cursor_=a};
|
||||
Blockly.Navigation.setMarker=function(a){Blockly.Navigation.marker_=a};Blockly.Navigation.markAtCursor=function(){Blockly.Navigation.marker_.setLocation(Blockly.Navigation.cursor_.getCurNode())};Blockly.Navigation.removeMark=function(){Blockly.Navigation.marker_.setLocation(null);Blockly.Navigation.marker_.hide()};
|
||||
Blockly.Navigation.focusToolbox=function(){Blockly.Navigation.resetFlyout(!1);Blockly.Navigation.currentState_=Blockly.Navigation.STATE_TOOLBOX;var a=Blockly.getMainWorkspace(),b=a.getToolbox();Blockly.Navigation.marker_.getCurNode()||Blockly.Navigation.markAtCursor();a&&!Blockly.Navigation.currentCategory_&&(Blockly.Navigation.currentCategory_=b.tree_.firstChild_);b.tree_.setSelectedItem(Blockly.Navigation.currentCategory_)};
|
||||
Blockly.Navigation.nextCategory=function(){if(Blockly.Navigation.currentCategory_){var a=Blockly.Navigation.currentCategory_.getNextShownNode();a&&(a.select(),Blockly.Navigation.currentCategory_=a)}};Blockly.Navigation.previousCategory=function(){if(Blockly.Navigation.currentCategory_){var a=Blockly.Navigation.currentCategory_.getPreviousShownNode();a&&(a.select(),Blockly.Navigation.currentCategory_=a)}};
|
||||
Blockly.Navigation.inCategory=function(){if(Blockly.Navigation.currentCategory_){var a=Blockly.Navigation.currentCategory_;a.hasChildren()?a.getExpanded()?(a.getFirstChild().select(),Blockly.Navigation.currentCategory_=a.getFirstChild()):a.setExpanded(!0):Blockly.Navigation.focusFlyout()}};
|
||||
Blockly.Navigation.outCategory=function(){if(Blockly.Navigation.currentCategory_){var a=Blockly.Navigation.currentCategory_;if(a.hasChildren()&&a.getExpanded()&&a.isUserCollapsible())a.setExpanded(!1);else{var b=a.getParent();a=a.getTree();b&&(a.getShowRootNode()||b!=a)&&(b.select(),Blockly.Navigation.currentCategory_=b)}}};
|
||||
Blockly.Navigation.focusFlyout=function(){Blockly.Navigation.currentState_=Blockly.Navigation.STATE_FLYOUT;var a=Blockly.getMainWorkspace();var b=a.getToolbox(),c=Blockly.Navigation.cursor_;a=b?b.flyout_:a.getFlyout();Blockly.Navigation.marker_.getCurNode()||Blockly.Navigation.markAtCursor();a&&a.getWorkspace()&&(a=a.getWorkspace().getTopBlocks(),0<a.length&&(a=a[0],Blockly.Navigation.flyoutBlock_=a,a=Blockly.ASTNode.createBlockNode(Blockly.Navigation.flyoutBlock_),c.setLocation(a)))};
|
||||
Blockly.Navigation.selectNextBlockInFlyout=function(){if(Blockly.Navigation.flyoutBlock_){var a=Blockly.Navigation.getFlyoutBlocks_(),b=a.indexOf(Blockly.Navigation.flyoutBlock_),c=Blockly.Navigation.cursor_,d;-1<b&&a[++b]&&(d=a[b]);d&&(Blockly.Navigation.flyoutBlock_=d,a=Blockly.ASTNode.createBlockNode(d),c.setLocation(a))}};
|
||||
Blockly.Navigation.selectPreviousBlockInFlyout=function(){if(Blockly.Navigation.flyoutBlock_){var a=Blockly.Navigation.getFlyoutBlocks_(),b=a.indexOf(Blockly.Navigation.flyoutBlock_),c=Blockly.Navigation.cursor_,d;-1<b&&a[--b]&&(d=a[b]);d&&(Blockly.Navigation.flyoutBlock_=d,a=Blockly.ASTNode.createBlockNode(d),c.setLocation(a))}};
|
||||
Blockly.Navigation.getFlyoutBlocks_=function(){var a=Blockly.getMainWorkspace(),b=a.getToolbox(),c=[];(a=b?b.flyout_:a.getFlyout())&&a.getWorkspace()&&(c=a.getWorkspace().getTopBlocks());return c};
|
||||
Blockly.Navigation.insertFromFlyout=function(){var a=Blockly.getMainWorkspace().getFlyout();if(a&&a.isVisible()){var b=a.createBlock(Blockly.Navigation.flyoutBlock_);b.render();b.setConnectionsHidden(!1);Blockly.Navigation.cursor_.setLocation(Blockly.ASTNode.createBlockNode(b));Blockly.Navigation.modify()||Blockly.Navigation.warn("Something went wrong while inserting a block from the flyout.");Blockly.Navigation.focusWorkspace();a=b.previousConnection;b=b.outputConnection;a=Blockly.ASTNode.createConnectionNode(a?
|
||||
a:b);Blockly.Navigation.cursor_.setLocation(a);Blockly.Navigation.removeMark()}else Blockly.Navigation.warn("Trying to insert from the flyout when the flyout does not exist or is not visible")};Blockly.Navigation.resetFlyout=function(a){var b=Blockly.Navigation.cursor_;Blockly.Navigation.flyoutBlock_=null;b.hide();a&&b.workspace_.getFlyout().hide()};
|
||||
Blockly.Navigation.modify=function(){var a=Blockly.Navigation.marker_.getCurNode(),b=Blockly.Navigation.cursor_.getCurNode();if(!a)return Blockly.Navigation.warn("Cannot insert with no marked node."),!1;if(!b)return Blockly.Navigation.warn("Cannot insert with no cursor node."),!1;var c=a.getType(),d=b.getType();if(c==Blockly.ASTNode.types.FIELD)return Blockly.Navigation.warn("Should not have been able to mark a field."),!1;if(c==Blockly.ASTNode.types.BLOCK)return Blockly.Navigation.warn("Should not have been able to mark a block."),
|
||||
!1;if(c==Blockly.ASTNode.types.STACK)return Blockly.Navigation.warn("Should not have been able to mark a stack."),!1;if(d==Blockly.ASTNode.types.FIELD)return Blockly.Navigation.warn("Cannot attach a field to anything else."),!1;if(d==Blockly.ASTNode.types.WORKSPACE)return Blockly.Navigation.warn("Cannot attach a workspace to anything else."),!1;var e=b.getLocation(),f=a.getLocation();if(a.isConnection()){if(b.isConnection())return Blockly.Navigation.connect(e,f);if(d==Blockly.ASTNode.types.BLOCK||
|
||||
d==Blockly.ASTNode.types.STACK)return Blockly.Navigation.insertBlock(e,f)}else if(c==Blockly.ASTNode.types.WORKSPACE){if(b.isConnection()){if(d==Blockly.ASTNode.types.INPUT||d==Blockly.ASTNode.types.NEXT)return Blockly.Navigation.warn("Cannot move a next or input connection to the workspace."),!1;b=e.getSourceBlock()}else if(d==Blockly.ASTNode.types.BLOCK||d==Blockly.ASTNode.types.STACK)b=e;else return!1;if(b.isShadow())return Blockly.Navigation.warn("Cannot move a shadow block to the workspace."),
|
||||
!1;b.getParent()&&b.unplug(!1);b.moveTo(a.getWsCoordinate());return!0}Blockly.Navigation.warn("Unexpected state in Blockly.Navigation.modify.");return!1};Blockly.Navigation.connect=function(a,b){if(a){var c=a.getSourceBlock();b.type!=Blockly.PREVIOUS_STATEMENT&&b.type!=Blockly.OUTPUT_VALUE||c.positionNearConnection(a,b);try{return b.connect(a),!0}catch(d){Blockly.Navigation.warn("Connection failed with error: "+d)}}return!1};
|
||||
Blockly.Navigation.findBestConnection=function(a,b){if(!a||!b)return null;if(b.type===Blockly.PREVIOUS_STATEMENT)return a.nextConnection;if(b.type===Blockly.NEXT_STATEMENT)return a.previousConnection;if(b.type===Blockly.INPUT_VALUE)return a.outputConnection;if(b.type===Blockly.OUTPUT_VALUE)for(var c=0;c<a.inputList.length;c++){var d=a.inputList[c].connection;if(d.type===Blockly.INPUT_VALUE)return d}return null};
|
||||
Blockly.Navigation.insertBlock=function(a,b){var c=Blockly.Navigation.findBestConnection(a,b);c&&c.isConnected()&&!c.targetBlock().isShadow()?c.disconnect():c||Blockly.Navigation.warn("This block can not be inserted at the marked location.");return Blockly.Navigation.connect(c,b)};
|
||||
Blockly.Navigation.disconnectBlocks=function(){var a=Blockly.Navigation.cursor_.getCurNode();if(a.isConnection()){var b=a.getLocation();b.isConnected()?(a=b.isSuperior()?b:b.targetConnection,b=b.isSuperior()?b.targetConnection:b,b.getSourceBlock().isShadow()?Blockly.Navigation.log("Cannot disconnect a shadow block"):(a.disconnect(),b.bumpAwayFrom_(a),a.getSourceBlock().getRootBlock().bringToFront(),a=Blockly.ASTNode.createConnectionNode(a),Blockly.Navigation.cursor_.setLocation(a))):Blockly.Navigation.log("Cannot disconnect unconnected connection")}else Blockly.Navigation.log("Cannot disconnect blocks when the cursor is not on a connection")};
|
||||
Blockly.Navigation.focusWorkspace=function(){var a=Blockly.Navigation.cursor_,b=Blockly.getMainWorkspace().getToolbox()?!0:!1;Blockly.Navigation.resetFlyout(b);Blockly.Navigation.currentState_=Blockly.Navigation.STATE_WS;Blockly.Navigation.enableKeyboardAccessibility();if(Blockly.selected){b=Blockly.selected.previousConnection;var c=Blockly.selected.outputConnection;b=Blockly.ASTNode.createConnectionNode(b?b:c);a.setLocation(b);Blockly.selected.unselect()}else b=a.workspace_,c=new Blockly.utils.Coordinate(100,
|
||||
100),b=Blockly.ASTNode.createWorkspaceNode(b,c),a.setLocation(b)};Blockly.Navigation.handleEnterForWS=function(){var a=Blockly.Navigation.cursor_.getCurNode(),b=a.getType();b===Blockly.ASTNode.types.FIELD?a.getLocation().showEditor_():a.isConnection()||b==Blockly.ASTNode.types.WORKSPACE?Blockly.Navigation.markAtCursor():b==Blockly.ASTNode.types.BLOCK?Blockly.Navigation.warn("Cannot mark a block."):b==Blockly.ASTNode.types.STACK&&Blockly.Navigation.warn("Cannot mark a stack.")};
|
||||
Blockly.Navigation.navigate=function(a){a=Blockly.user.keyMap.serializeKeyEvent(a);return(a=Blockly.user.keyMap.getActionByKeyCode(a))?(a.func.call(),!0):!1};Blockly.Navigation.enableKeyboardAccessibility=function(){Blockly.keyboardAccessibilityMode=!0};Blockly.Navigation.disableKeyboardAccessibility=function(){Blockly.keyboardAccessibilityMode=!1};Blockly.Navigation.log=function(a){Blockly.Navigation.loggingCallback?Blockly.Navigation.loggingCallback("log",a):console.log(a)};
|
||||
Blockly.Navigation.warn=function(a){Blockly.Navigation.loggingCallback?Blockly.Navigation.loggingCallback("warn",a):console.warn(a)};Blockly.Navigation.error=function(a){Blockly.Navigation.loggingCallback?Blockly.Navigation.loggingCallback("error",a):console.error(a)};
|
||||
Blockly.Navigation.ACTION_PREVIOUS=new Blockly.Action("previous","Goes to the previous location",function(){Blockly.Navigation.currentState_===Blockly.Navigation.STATE_WS?Blockly.Navigation.cursor_.prev():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_FLYOUT?Blockly.Navigation.selectPreviousBlockInFlyout():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_TOOLBOX&&Blockly.Navigation.previousCategory()});
|
||||
Blockly.Navigation.ACTION_OUT=new Blockly.Action("out","Goes out",function(){Blockly.Navigation.currentState_===Blockly.Navigation.STATE_WS?Blockly.Navigation.cursor_.out():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_FLYOUT?Blockly.Navigation.focusToolbox():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_TOOLBOX&&Blockly.Navigation.outCategory()});
|
||||
Blockly.Navigation.ACTION_NEXT=new Blockly.Action("next","Goes to the next location",function(){Blockly.Navigation.currentState_===Blockly.Navigation.STATE_WS?Blockly.Navigation.cursor_.next():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_FLYOUT?Blockly.Navigation.selectNextBlockInFlyout():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_TOOLBOX&&Blockly.Navigation.nextCategory()});
|
||||
Blockly.Navigation.ACTION_IN=new Blockly.Action("in","Goes in",function(){Blockly.Navigation.currentState_===Blockly.Navigation.STATE_WS?Blockly.Navigation.cursor_["in"]():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_TOOLBOX&&Blockly.Navigation.inCategory()});Blockly.Navigation.ACTION_INSERT=new Blockly.Action("insert","Tries to connect the current location to the marked location",function(){Blockly.Navigation.currentState_===Blockly.Navigation.STATE_WS&&Blockly.Navigation.modify()});
|
||||
Blockly.Navigation.ACTION_MARK=new Blockly.Action("mark","Marks the current location",function(){Blockly.Navigation.currentState_===Blockly.Navigation.STATE_WS?Blockly.Navigation.handleEnterForWS():Blockly.Navigation.currentState_===Blockly.Navigation.STATE_FLYOUT&&Blockly.Navigation.insertFromFlyout()});Blockly.Navigation.ACTION_DISCONNECT=new Blockly.Action("disconnect","Disconnect the blocks",function(){Blockly.Navigation.currentState_===Blockly.Navigation.STATE_WS&&Blockly.Navigation.disconnectBlocks()});
|
||||
Blockly.Navigation.ACTION_TOOLBOX=new Blockly.Action("toolbox","Open the toolbox",function(){Blockly.getMainWorkspace().getToolbox()?Blockly.Navigation.focusToolbox():Blockly.Navigation.focusFlyout()});Blockly.Navigation.ACTION_EXIT=new Blockly.Action("exit","Exit the toolbox",function(){Blockly.Navigation.currentState_!==Blockly.Navigation.STATE_TOOLBOX&&Blockly.Navigation.currentState_!==Blockly.Navigation.STATE_FLYOUT||Blockly.Navigation.focusWorkspace()});
|
||||
Blockly.Navigation.ACTION_ESCAPE=new Blockly.Action("escape","Exit the toolbox",function(){Blockly.Navigation.currentState_!==Blockly.Navigation.STATE_TOOLBOX&&Blockly.Navigation.currentState_!==Blockly.Navigation.STATE_FLYOUT||Blockly.Navigation.focusWorkspace()});Blockly.Names=function(a,b){this.variablePrefix_=b||"";this.reservedDict_=Object.create(null);if(a)for(var c=a.split(","),d=0;d<c.length;d++)this.reservedDict_[c[d]]=!0;this.reset()};Blockly.Names.DEVELOPER_VARIABLE_TYPE="DEVELOPER_VARIABLE";Blockly.Names.prototype.reset=function(){this.db_=Object.create(null);this.dbReverse_=Object.create(null);this.variableMap_=null};Blockly.Names.prototype.setVariableMap=function(a){this.variableMap_=a};
|
||||
case Blockly.ASTNode.types.INPUT:return Blockly.ASTNode.createBlockNode(this.location_.getSourceBlock());case Blockly.ASTNode.types.BLOCK:return this.getOutAstNodeForBlock_(this.location_);case Blockly.ASTNode.types.PREVIOUS:return this.getOutAstNodeForBlock_(this.location_.getSourceBlock());case Blockly.ASTNode.types.NEXT:return this.getOutAstNodeForBlock_(this.location_.getSourceBlock())}return null};Blockly.user={};Blockly.user.keyMap={};Blockly.user.keyMap.map_={};Blockly.user.keyMap.modifierKeys=["Shift","Control","Alt","Meta"];Blockly.user.keyMap.setActionForKey=function(a,b){var c=Blockly.user.keyMap.getKeyByAction(b);c&&delete Blockly.user.keyMap.map_[c];Blockly.user.keyMap.map_[a]=b};Blockly.user.keyMap.setKeyMap=function(a){Blockly.user.keyMap.map_=a};Blockly.user.keyMap.getKeyMap=function(){return Object.assign({},Blockly.user.keyMap.map_)};Blockly.user.keyMap.getActionByKeyCode=function(a){return Blockly.user.keyMap.map_[a]};
|
||||
Blockly.user.keyMap.getKeyByAction=function(a){for(var b=Object.keys(Blockly.user.keyMap.map_),c=0,d;d=b[c];c++)if(Blockly.user.keyMap.map_[d].name===a.name)return d;return null};Blockly.user.keyMap.serializeKeyEvent=function(a){for(var b=Blockly.user.keyMap.modifierKeys,c="",d=0,e;e=b[d];d++)a.getModifierState(e)&&(c+=e);return c+=a.keyCode};
|
||||
Blockly.user.keyMap.createDefaultKeyMap=function(){var a={};a[goog.events.KeyCodes.W]=Blockly.navigation.ACTION_PREVIOUS;a[goog.events.KeyCodes.A]=Blockly.navigation.ACTION_OUT;a[goog.events.KeyCodes.S]=Blockly.navigation.ACTION_NEXT;a[goog.events.KeyCodes.D]=Blockly.navigation.ACTION_IN;a[goog.events.KeyCodes.I]=Blockly.navigation.ACTION_INSERT;a[goog.events.KeyCodes.ENTER]=Blockly.navigation.ACTION_MARK;a[goog.events.KeyCodes.X]=Blockly.navigation.ACTION_DISCONNECT;a[goog.events.KeyCodes.T]=Blockly.navigation.ACTION_TOOLBOX;
|
||||
a[goog.events.KeyCodes.E]=Blockly.navigation.ACTION_EXIT;a[goog.events.KeyCodes.ESC]=Blockly.navigation.ACTION_EXIT;return a};Blockly.navigation={};Blockly.navigation.cursor_=null;Blockly.navigation.marker_=null;Blockly.navigation.currentCategory_=null;Blockly.navigation.flyoutBlock_=null;Blockly.navigation.loggingCallback=null;Blockly.navigation.STATE_FLYOUT=1;Blockly.navigation.STATE_WS=2;Blockly.navigation.STATE_TOOLBOX=3;Blockly.navigation.currentState_=Blockly.navigation.STATE_WS;Blockly.navigation.setCursor=function(a){Blockly.navigation.cursor_=a};
|
||||
Blockly.navigation.setMarker=function(a){Blockly.navigation.marker_=a};Blockly.navigation.markAtCursor=function(){Blockly.navigation.marker_.setLocation(Blockly.navigation.cursor_.getCurNode())};Blockly.navigation.removeMark=function(){Blockly.navigation.marker_.setLocation(null);Blockly.navigation.marker_.hide()};
|
||||
Blockly.navigation.focusToolbox=function(){Blockly.navigation.resetFlyout(!1);Blockly.navigation.currentState_=Blockly.navigation.STATE_TOOLBOX;var a=Blockly.getMainWorkspace(),b=a.getToolbox();Blockly.navigation.marker_.getCurNode()||Blockly.navigation.markAtCursor();a&&!Blockly.navigation.currentCategory_&&(Blockly.navigation.currentCategory_=b.tree_.firstChild_);b.tree_.setSelectedItem(Blockly.navigation.currentCategory_)};
|
||||
Blockly.navigation.nextCategory=function(){if(Blockly.navigation.currentCategory_){var a=Blockly.navigation.currentCategory_.getNextShownNode();a&&(a.select(),Blockly.navigation.currentCategory_=a)}};Blockly.navigation.previousCategory=function(){if(Blockly.navigation.currentCategory_){var a=Blockly.navigation.currentCategory_.getPreviousShownNode();a&&(a.select(),Blockly.navigation.currentCategory_=a)}};
|
||||
Blockly.navigation.inCategory=function(){if(Blockly.navigation.currentCategory_){var a=Blockly.navigation.currentCategory_;a.hasChildren()?a.getExpanded()?(a.getFirstChild().select(),Blockly.navigation.currentCategory_=a.getFirstChild()):a.setExpanded(!0):Blockly.navigation.focusFlyout()}};
|
||||
Blockly.navigation.outCategory=function(){if(Blockly.navigation.currentCategory_){var a=Blockly.navigation.currentCategory_;if(a.hasChildren()&&a.getExpanded()&&a.isUserCollapsible())a.setExpanded(!1);else{var b=a.getParent();a=a.getTree();b&&b!=a&&(b.select(),Blockly.navigation.currentCategory_=b)}}};
|
||||
Blockly.navigation.focusFlyout=function(){Blockly.navigation.currentState_=Blockly.navigation.STATE_FLYOUT;var a=Blockly.getMainWorkspace();var b=a.getToolbox(),c=Blockly.navigation.cursor_;a=b?b.flyout_:a.getFlyout();Blockly.navigation.marker_.getCurNode()||Blockly.navigation.markAtCursor();a&&a.getWorkspace()&&(a=a.getWorkspace().getTopBlocks(),0<a.length&&(a=a[0],Blockly.navigation.flyoutBlock_=a,a=Blockly.ASTNode.createBlockNode(Blockly.navigation.flyoutBlock_),c.setLocation(a)))};
|
||||
Blockly.navigation.selectNextBlockInFlyout=function(){if(Blockly.navigation.flyoutBlock_){var a=Blockly.navigation.getFlyoutBlocks_(),b=a.indexOf(Blockly.navigation.flyoutBlock_),c=Blockly.navigation.cursor_,d;-1<b&&a[++b]&&(d=a[b]);d&&(Blockly.navigation.flyoutBlock_=d,a=Blockly.ASTNode.createBlockNode(d),c.setLocation(a))}};
|
||||
Blockly.navigation.selectPreviousBlockInFlyout=function(){if(Blockly.navigation.flyoutBlock_){var a=Blockly.navigation.getFlyoutBlocks_(),b=a.indexOf(Blockly.navigation.flyoutBlock_),c=Blockly.navigation.cursor_,d;-1<b&&a[--b]&&(d=a[b]);d&&(Blockly.navigation.flyoutBlock_=d,a=Blockly.ASTNode.createBlockNode(d),c.setLocation(a))}};
|
||||
Blockly.navigation.getFlyoutBlocks_=function(){var a=Blockly.getMainWorkspace(),b=a.getToolbox(),c=[];(a=b?b.flyout_:a.getFlyout())&&a.getWorkspace()&&(c=a.getWorkspace().getTopBlocks());return c};
|
||||
Blockly.navigation.insertFromFlyout=function(){var a=Blockly.getMainWorkspace().getFlyout();if(a&&a.isVisible()){var b=a.createBlock(Blockly.navigation.flyoutBlock_);b.render();b.setConnectionsHidden(!1);Blockly.navigation.cursor_.setLocation(Blockly.ASTNode.createBlockNode(b));Blockly.navigation.modify()||Blockly.navigation.warn("Something went wrong while inserting a block from the flyout.");Blockly.navigation.focusWorkspace();a=b.previousConnection;b=b.outputConnection;a=Blockly.ASTNode.createConnectionNode(a?
|
||||
a:b);Blockly.navigation.cursor_.setLocation(a);Blockly.navigation.removeMark()}else Blockly.navigation.warn("Trying to insert from the flyout when the flyout does not exist or is not visible")};Blockly.navigation.resetFlyout=function(a){var b=Blockly.navigation.cursor_;Blockly.navigation.flyoutBlock_=null;b.hide();a&&b.workspace_.getFlyout().hide()};
|
||||
Blockly.navigation.modify=function(){var a=Blockly.navigation.marker_.getCurNode(),b=Blockly.navigation.cursor_.getCurNode();if(!a)return Blockly.navigation.warn("Cannot insert with no marked node."),!1;if(!b)return Blockly.navigation.warn("Cannot insert with no cursor node."),!1;var c=a.getType(),d=b.getType();if(c==Blockly.ASTNode.types.FIELD)return Blockly.navigation.warn("Should not have been able to mark a field."),!1;if(c==Blockly.ASTNode.types.BLOCK)return Blockly.navigation.warn("Should not have been able to mark a block."),
|
||||
!1;if(c==Blockly.ASTNode.types.STACK)return Blockly.navigation.warn("Should not have been able to mark a stack."),!1;if(d==Blockly.ASTNode.types.FIELD)return Blockly.navigation.warn("Cannot attach a field to anything else."),!1;if(d==Blockly.ASTNode.types.WORKSPACE)return Blockly.navigation.warn("Cannot attach a workspace to anything else."),!1;var e=b.getLocation(),f=a.getLocation();if(a.isConnection()){if(b.isConnection())return Blockly.navigation.connect(e,f);if(d==Blockly.ASTNode.types.BLOCK||
|
||||
d==Blockly.ASTNode.types.STACK)return Blockly.navigation.insertBlock(e,f)}else if(c==Blockly.ASTNode.types.WORKSPACE){if(b.isConnection()){if(d==Blockly.ASTNode.types.INPUT||d==Blockly.ASTNode.types.NEXT)return Blockly.navigation.warn("Cannot move a next or input connection to the workspace."),!1;b=e.getSourceBlock()}else if(d==Blockly.ASTNode.types.BLOCK||d==Blockly.ASTNode.types.STACK)b=e;else return!1;if(b.isShadow())return Blockly.navigation.warn("Cannot move a shadow block to the workspace."),
|
||||
!1;b.getParent()&&b.unplug(!1);b.moveTo(a.getWsCoordinate());return!0}Blockly.navigation.warn("Unexpected state in Blockly.navigation.modify.");return!1};Blockly.navigation.connect=function(a,b){if(a){var c=a.getSourceBlock();b.type!=Blockly.PREVIOUS_STATEMENT&&b.type!=Blockly.OUTPUT_VALUE||c.positionNearConnection(a,b);try{return b.connect(a),!0}catch(d){Blockly.navigation.warn("Connection failed with error: "+d)}}return!1};
|
||||
Blockly.navigation.findBestConnection=function(a,b){if(!a||!b)return null;if(b.type===Blockly.PREVIOUS_STATEMENT)return a.nextConnection;if(b.type===Blockly.NEXT_STATEMENT)return a.previousConnection;if(b.type===Blockly.INPUT_VALUE)return a.outputConnection;if(b.type===Blockly.OUTPUT_VALUE)for(var c=0;c<a.inputList.length;c++){var d=a.inputList[c].connection;if(d.type===Blockly.INPUT_VALUE)return d}return null};
|
||||
Blockly.navigation.insertBlock=function(a,b){var c=Blockly.navigation.findBestConnection(a,b);c&&c.isConnected()&&!c.targetBlock().isShadow()?c.disconnect():c||Blockly.navigation.warn("This block can not be inserted at the marked location.");return Blockly.navigation.connect(c,b)};
|
||||
Blockly.navigation.disconnectBlocks=function(){var a=Blockly.navigation.cursor_.getCurNode();if(a.isConnection()){var b=a.getLocation();b.isConnected()?(a=b.isSuperior()?b:b.targetConnection,b=b.isSuperior()?b.targetConnection:b,b.getSourceBlock().isShadow()?Blockly.navigation.log("Cannot disconnect a shadow block"):(a.disconnect(),b.bumpAwayFrom_(a),a.getSourceBlock().getRootBlock().bringToFront(),a=Blockly.ASTNode.createConnectionNode(a),Blockly.navigation.cursor_.setLocation(a))):Blockly.navigation.log("Cannot disconnect unconnected connection")}else Blockly.navigation.log("Cannot disconnect blocks when the cursor is not on a connection")};
|
||||
Blockly.navigation.focusWorkspace=function(){var a=Blockly.navigation.cursor_,b=Blockly.getMainWorkspace().getToolbox()?!0:!1;Blockly.navigation.resetFlyout(b);Blockly.navigation.currentState_=Blockly.navigation.STATE_WS;Blockly.navigation.enableKeyboardAccessibility();if(Blockly.selected){b=Blockly.selected.previousConnection;var c=Blockly.selected.outputConnection;b=Blockly.ASTNode.createConnectionNode(b?b:c);a.setLocation(b);Blockly.selected.unselect()}else b=a.workspace_,c=new Blockly.utils.Coordinate(100,
|
||||
100),b=Blockly.ASTNode.createWorkspaceNode(b,c),a.setLocation(b)};Blockly.navigation.handleEnterForWS=function(){var a=Blockly.navigation.cursor_.getCurNode(),b=a.getType();b===Blockly.ASTNode.types.FIELD?a.getLocation().showEditor_():a.isConnection()||b==Blockly.ASTNode.types.WORKSPACE?Blockly.navigation.markAtCursor():b==Blockly.ASTNode.types.BLOCK?Blockly.navigation.warn("Cannot mark a block."):b==Blockly.ASTNode.types.STACK&&Blockly.navigation.warn("Cannot mark a stack.")};
|
||||
Blockly.navigation.onKeyPress=function(a){a=Blockly.user.keyMap.serializeKeyEvent(a);return(a=Blockly.user.keyMap.getActionByKeyCode(a))?(a.func.call(),!0):!1};Blockly.navigation.enableKeyboardAccessibility=function(){Blockly.keyboardAccessibilityMode=!0};Blockly.navigation.disableKeyboardAccessibility=function(){Blockly.keyboardAccessibilityMode=!1};Blockly.navigation.log=function(a){Blockly.navigation.loggingCallback?Blockly.navigation.loggingCallback("log",a):console.log(a)};
|
||||
Blockly.navigation.warn=function(a){Blockly.navigation.loggingCallback?Blockly.navigation.loggingCallback("warn",a):console.warn(a)};Blockly.navigation.error=function(a){Blockly.navigation.loggingCallback?Blockly.navigation.loggingCallback("error",a):console.error(a)};
|
||||
Blockly.navigation.ACTION_PREVIOUS=new Blockly.Action("previous","Goes to the previous location",function(){Blockly.navigation.currentState_===Blockly.navigation.STATE_WS?Blockly.navigation.cursor_.prev():Blockly.navigation.currentState_===Blockly.navigation.STATE_FLYOUT?Blockly.navigation.selectPreviousBlockInFlyout():Blockly.navigation.currentState_===Blockly.navigation.STATE_TOOLBOX&&Blockly.navigation.previousCategory()});
|
||||
Blockly.navigation.ACTION_OUT=new Blockly.Action("out","Goes out",function(){Blockly.navigation.currentState_===Blockly.navigation.STATE_WS?Blockly.navigation.cursor_.out():Blockly.navigation.currentState_===Blockly.navigation.STATE_FLYOUT?Blockly.navigation.focusToolbox():Blockly.navigation.currentState_===Blockly.navigation.STATE_TOOLBOX&&Blockly.navigation.outCategory()});
|
||||
Blockly.navigation.ACTION_NEXT=new Blockly.Action("next","Goes to the next location",function(){Blockly.navigation.currentState_===Blockly.navigation.STATE_WS?Blockly.navigation.cursor_.next():Blockly.navigation.currentState_===Blockly.navigation.STATE_FLYOUT?Blockly.navigation.selectNextBlockInFlyout():Blockly.navigation.currentState_===Blockly.navigation.STATE_TOOLBOX&&Blockly.navigation.nextCategory()});
|
||||
Blockly.navigation.ACTION_IN=new Blockly.Action("in","Goes in",function(){Blockly.navigation.currentState_===Blockly.navigation.STATE_WS?Blockly.navigation.cursor_["in"]():Blockly.navigation.currentState_===Blockly.navigation.STATE_TOOLBOX&&Blockly.navigation.inCategory()});Blockly.navigation.ACTION_INSERT=new Blockly.Action("insert","Tries to connect the current location to the marked location",function(){Blockly.navigation.currentState_===Blockly.navigation.STATE_WS&&Blockly.navigation.modify()});
|
||||
Blockly.navigation.ACTION_MARK=new Blockly.Action("mark","Marks the current location",function(){Blockly.navigation.currentState_===Blockly.navigation.STATE_WS?Blockly.navigation.handleEnterForWS():Blockly.navigation.currentState_===Blockly.navigation.STATE_FLYOUT&&Blockly.navigation.insertFromFlyout()});Blockly.navigation.ACTION_DISCONNECT=new Blockly.Action("disconnect","Disconnect the blocks",function(){Blockly.navigation.currentState_===Blockly.navigation.STATE_WS&&Blockly.navigation.disconnectBlocks()});
|
||||
Blockly.navigation.ACTION_TOOLBOX=new Blockly.Action("toolbox","Open the toolbox",function(){Blockly.getMainWorkspace().getToolbox()?Blockly.navigation.focusToolbox():Blockly.navigation.focusFlyout()});Blockly.navigation.ACTION_EXIT=new Blockly.Action("exit","Exit the toolbox",function(){Blockly.navigation.currentState_!==Blockly.navigation.STATE_TOOLBOX&&Blockly.navigation.currentState_!==Blockly.navigation.STATE_FLYOUT||Blockly.navigation.focusWorkspace()});Blockly.Names=function(a,b){this.variablePrefix_=b||"";this.reservedDict_=Object.create(null);if(a)for(var c=a.split(","),d=0;d<c.length;d++)this.reservedDict_[c[d]]=!0;this.reset()};Blockly.Names.DEVELOPER_VARIABLE_TYPE="DEVELOPER_VARIABLE";Blockly.Names.prototype.reset=function(){this.db_=Object.create(null);this.dbReverse_=Object.create(null);this.variableMap_=null};Blockly.Names.prototype.setVariableMap=function(a){this.variableMap_=a};
|
||||
Blockly.Names.prototype.getNameForUserVariable_=function(a){return this.variableMap_?(a=this.variableMap_.getVariableById(a))?a.name:null:(console.log("Deprecated call to Blockly.Names.prototype.getName without defining a variable map. To fix, add the folowing code in your generator's init() function:\nBlockly.YourGeneratorName.variableDB_.setVariableMap(workspace.getVariableMap());"),null)};
|
||||
Blockly.Names.prototype.getName=function(a,b){if(b==Blockly.Variables.NAME_TYPE){var c=this.getNameForUserVariable_(a);c&&(a=c)}c=a.toLowerCase()+"_"+b;var d=b==Blockly.Variables.NAME_TYPE||b==Blockly.Names.DEVELOPER_VARIABLE_TYPE?this.variablePrefix_:"";if(c in this.db_)return d+this.db_[c];var e=this.getDistinctName(a,b);this.db_[c]=e.substr(d.length);return e};
|
||||
Blockly.Names.prototype.getDistinctName=function(a,b){for(var c=this.safeName_(a),d="";this.dbReverse_[c+d]||c+d in this.reservedDict_;)d=d?d+1:2;c+=d;this.dbReverse_[c]=!0;return(b==Blockly.Variables.NAME_TYPE||b==Blockly.Names.DEVELOPER_VARIABLE_TYPE?this.variablePrefix_:"")+c};Blockly.Names.prototype.safeName_=function(a){a?(a=encodeURI(a.replace(/ /g,"_")).replace(/[^\w]/g,"_"),-1!="0123456789".indexOf(a[0])&&(a="my_"+a)):a=Blockly.Msg.UNNAMED_KEY||"unnamed";return a};
|
||||
@@ -1893,7 +1758,7 @@ Blockly.Flyout.prototype.addBlockListeners_=function(a,b,c){this.listeners_.push
|
||||
Blockly.Flyout.prototype.createBlock=function(a){var b=null;Blockly.Events.disable();var c=this.targetWorkspace_.getAllVariables();this.targetWorkspace_.setResizesEnabled(!1);try{b=this.placeNewBlock_(a),Blockly.hideChaff()}finally{Blockly.Events.enable()}a=Blockly.Variables.getAddedVariables(this.targetWorkspace_,c);if(Blockly.Events.isEnabled())for(Blockly.Events.setGroup(!0),Blockly.Events.fire(new Blockly.Events.Create(b)),c=0;c<a.length;c++)Blockly.Events.fire(new Blockly.Events.VarCreate(a[c]));
|
||||
this.autoClose?this.hide():this.filterForCapacity_();return b};Blockly.Flyout.prototype.initFlyoutButton_=function(a,b,c){var d=a.createDom();a.moveTo(b,c);a.show();this.listeners_.push(Blockly.bindEventWithChecks_(d,"mousedown",this,this.onMouseDown_));this.buttons_.push(a)};
|
||||
Blockly.Flyout.prototype.createRect_=function(a,b,c,d,e){b=Blockly.utils.dom.createSvgElement("rect",{"fill-opacity":0,x:b,y:c,height:d.height,width:d.width},null);b.tooltip=a;Blockly.Tooltip.bindMouseEvents(b);this.workspace_.getCanvas().insertBefore(b,a.getSvgRoot());a.flyoutRect_=b;return this.mats_[e]=b};
|
||||
Blockly.Flyout.prototype.moveRectToBlock_=function(a,b){var c=b.getHeightWidth();a.setAttribute("width",c.width);a.setAttribute("height",c.height);var d=b.startHat_?Blockly.BlockSvg.START_HAT_HEIGHT:0;d&&b.moveBy(0,d);d=b.outputConnection?Blockly.BlockSvg.TAB_WIDTH:0;var e=b.getRelativeToSurfaceXY();a.setAttribute("y",e.y);a.setAttribute("x",this.RTL?e.x-c.width+d:e.x-d)};
|
||||
Blockly.Flyout.prototype.moveRectToBlock_=function(a,b){var c=b.getHeightWidth();a.setAttribute("width",c.width);a.setAttribute("height",c.height);var d=b.getRelativeToSurfaceXY();a.setAttribute("y",d.y);a.setAttribute("x",this.RTL?d.x-c.width:d.x)};
|
||||
Blockly.Flyout.prototype.filterForCapacity_=function(){for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++)if(-1==this.permanentlyDisabled_.indexOf(c))for(var d=this.targetWorkspace_.isCapacityAvailable(Blockly.utils.getBlockTypeCounts(c));c;)c.setEnabled(d),c=c.getNextBlock()};Blockly.Flyout.prototype.reflow=function(){this.reflowWrapper_&&this.workspace_.removeChangeListener(this.reflowWrapper_);this.reflowInternal_();this.reflowWrapper_&&this.workspace_.addChangeListener(this.reflowWrapper_)};
|
||||
Blockly.Flyout.prototype.isScrollable=function(){return this.scrollbar_?this.scrollbar_.isVisible():!1};
|
||||
Blockly.Flyout.prototype.placeNewBlock_=function(a){var b=this.targetWorkspace_;if(!a.getSvgRoot())throw Error("oldBlock is not rendered.");var c=Blockly.Xml.blockToDom(a,!0);b.setResizesEnabled(!1);c=Blockly.Xml.domToBlock(c,b);if(!c.getSvgRoot())throw Error("block is not rendered.");var d=b.getOriginOffsetInPixels(),e=this.workspace_.getOriginOffsetInPixels();a=a.getRelativeToSurfaceXY();a.scale(this.workspace_.scale);a=Blockly.utils.Coordinate.sum(e,a);d=Blockly.utils.Coordinate.difference(a,d);
|
||||
@@ -1908,7 +1773,72 @@ Blockly.HorizontalFlyout.prototype.wheel_=function(a){var b=Blockly.utils.getScr
|
||||
Blockly.HorizontalFlyout.prototype.layout_=function(a,b){this.workspace_.scale=this.targetWorkspace_.scale;var c=this.MARGIN,d=this.RTL?c:c+Blockly.BlockSvg.TAB_WIDTH;this.RTL&&(a=a.reverse());for(var e=0,f;f=a[e];e++)if("block"==f.type){f=f.block;for(var g=f.getDescendants(!1),h=0,k;k=g[h];h++)k.isInFlyout=!0;f.render();g=f.getSvgRoot();h=f.getHeightWidth();k=f.outputConnection?Blockly.BlockSvg.TAB_WIDTH:0;k=this.RTL?d+h.width:d+k;f.moveBy(k,c);k=this.createRect_(f,k,c,h,e);d+=h.width+b[e];this.addBlockListeners_(g,
|
||||
f,k)}else"button"==f.type&&(this.initFlyoutButton_(f.button,d,c),d+=f.button.width+b[e])};Blockly.HorizontalFlyout.prototype.isDragTowardWorkspace=function(a){a=Math.atan2(a.y,a.x)/Math.PI*180;var b=this.dragAngleRange_;return a<90+b&&a>90-b||a>-90-b&&a<-90+b?!0:!1};
|
||||
Blockly.HorizontalFlyout.prototype.getClientRect=function(){if(!this.svgGroup_)return null;var a=this.svgGroup_.getBoundingClientRect(),b=a.top;return this.toolboxPosition_==Blockly.TOOLBOX_AT_TOP?new Blockly.utils.Rect(-1E9,b+a.height,-1E9,1E9):new Blockly.utils.Rect(b,-1E9,-1E9,1E9)};
|
||||
Blockly.HorizontalFlyout.prototype.reflowInternal_=function(){this.workspace_.scale=this.targetWorkspace_.scale;for(var a=0,b=this.workspace_.getTopBlocks(!1),c=0,d;d=b[c];c++)a=Math.max(a,d.getHeightWidth().height);a+=1.5*this.MARGIN;a*=this.workspace_.scale;a+=Blockly.Scrollbar.scrollbarThickness;if(this.height_!=a){for(c=0;d=b[c];c++)d.flyoutRect_&&this.moveRectToBlock_(d.flyoutRect_,d);this.height_=a;this.position()}};Blockly.VerticalFlyout=function(a){a.getMetrics=this.getMetrics_.bind(this);a.setMetrics=this.setMetrics_.bind(this);Blockly.VerticalFlyout.superClass_.constructor.call(this,a);this.horizontalLayout_=!1};goog.inherits(Blockly.VerticalFlyout,Blockly.Flyout);
|
||||
Blockly.HorizontalFlyout.prototype.reflowInternal_=function(){this.workspace_.scale=this.targetWorkspace_.scale;for(var a=0,b=this.workspace_.getTopBlocks(!1),c=0,d;d=b[c];c++)a=Math.max(a,d.getHeightWidth().height);a+=1.5*this.MARGIN;a*=this.workspace_.scale;a+=Blockly.Scrollbar.scrollbarThickness;if(this.height_!=a){for(c=0;d=b[c];c++)d.flyoutRect_&&this.moveRectToBlock_(d.flyoutRect_,d);this.height_=a;this.position()}};Blockly.utils.IdGenerator=function(){};Blockly.utils.IdGenerator.getInstance=function(){Blockly.utils.IdGenerator.instance_||(Blockly.utils.IdGenerator.instance_=new Blockly.utils.IdGenerator);return Blockly.utils.IdGenerator.instance_};Blockly.utils.IdGenerator.prototype.nextId_=0;Blockly.utils.IdGenerator.prototype.getNextUniqueId=function(){return"blockly:"+(this.nextId_++).toString(36)};Blockly.Component=function(){this.rightToLeft_=Blockly.Component.defaultRightToLeft_;this.id_=null;this.inDocument_=!1;this.childIndex_=this.children_=this.parent_=this.element_=null};Blockly.Component.prototype.idGenerator_=Blockly.utils.IdGenerator.getInstance();Blockly.Component.defaultRightToLeft_=!1;
|
||||
Blockly.Component.Error={NOT_SUPPORTED:"Method not supported",ALREADY_RENDERED:"Component already rendered",PARENT_UNABLE_TO_BE_SET:"Unable to set parent component",CHILD_INDEX_OUT_OF_BOUNDS:"Child component index out of bounds",NOT_OUR_CHILD:"Child is not in parent component",NOT_IN_DOCUMENT:"Operation not supported while component is not in document"};Blockly.Component.setDefaultRightToLeft=function(a){Blockly.Component.defaultRightToLeft_=a};
|
||||
Blockly.Component.prototype.getId=function(){return this.id_||(this.id_=this.idGenerator_.getNextUniqueId())};Blockly.Component.prototype.setId=function(a){this.parent_&&this.parent_.childIndex_&&(delete this.parent_.childIndex_[this.id_],this.parent_.childIndex_[a]=this);this.id_=a};Blockly.Component.prototype.getElement=function(){return this.element_};Blockly.Component.prototype.setElementInternal=function(a){this.element_=a};
|
||||
Blockly.Component.prototype.setParent=function(a){if(this==a)throw Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET);if(a&&this.parent_&&this.id_&&this.parent_.getChild(this.id_)&&this.parent_!=a)throw Error(Blockly.Component.Error.PARENT_UNABLE_TO_BE_SET);this.parent_=a};Blockly.Component.prototype.getParent=function(){return this.parent_};Blockly.Component.prototype.isInDocument=function(){return this.inDocument_};Blockly.Component.prototype.createDom=function(){this.element_=document.createElement("div")};
|
||||
Blockly.Component.prototype.render=function(a){this.render_(a)};Blockly.Component.prototype.renderBefore=function(a){this.render_(a.parentNode,a)};Blockly.Component.prototype.render_=function(a,b){if(this.inDocument_)throw Error(Blockly.Component.Error.ALREADY_RENDERED);this.element_||this.createDom();a?a.insertBefore(this.element_,b||null):document.body.appendChild(this.element_);this.parent_&&!this.parent_.isInDocument()||this.enterDocument()};
|
||||
Blockly.Component.prototype.enterDocument=function(){this.inDocument_=!0;this.forEachChild(function(a){!a.isInDocument()&&a.getElement()&&a.enterDocument()})};Blockly.Component.prototype.exitDocument=function(){this.forEachChild(function(a){a.isInDocument()&&a.exitDocument()});this.inDocument_=!1};Blockly.Component.prototype.dispose=function(){this.disposed_||(this.disposed_=!0,this.disposeInternal())};
|
||||
Blockly.Component.prototype.disposeInternal=function(){this.inDocument_&&this.exitDocument();this.forEachChild(function(a){a.dispose()});this.element_&&Blockly.utils.dom.removeNode(this.element_);this.parent_=this.element_=this.childIndex_=this.children_=null};Blockly.Component.prototype.makeId=function(a){return this.getId()+"."+a};Blockly.Component.prototype.makeIds=function(a){var b={},c;for(c in a)b[c]=this.makeId(a[c]);return b};
|
||||
Blockly.Component.prototype.addChild=function(a,b){this.addChildAt(a,this.getChildCount(),b)};
|
||||
Blockly.Component.prototype.addChildAt=function(a,b,c){if(a.inDocument_&&(c||!this.inDocument_))throw Error(Blockly.Component.Error.ALREADY_RENDERED);if(0>b||b>this.getChildCount())throw Error(Blockly.Component.Error.CHILD_INDEX_OUT_OF_BOUNDS);this.childIndex_&&this.children_||(this.childIndex_={},this.children_=[]);this.childIndex_[a.getId()]=a;if(a.getParent()==this){var d=this.children_.indexOf(a);-1<d&&this.children_.splice(d,1)}a.setParent(this);this.children_.splice(b,0,a);a.inDocument_&&this.inDocument_&&
|
||||
a.getParent()==this?(c=this.getContentElement(),b=c.childNodes[b]||null,b!=a.getElement()&&c.insertBefore(a.getElement(),b)):c?(this.element_||this.createDom(),b=this.getChildAt(b+1),a.render_(this.getContentElement(),b?b.element_:null)):this.inDocument_&&!a.inDocument_&&a.element_&&a.element_.parentNode&&a.element_.parentNode.nodeType==Blockly.utils.dom.Node.ELEMENT_NODE&&a.enterDocument()};Blockly.Component.prototype.getContentElement=function(){return this.element_};
|
||||
Blockly.Component.prototype.isRightToLeft=function(){null==this.rightToLeft_&&(this.rightToLeft_=Blockly.utils.style.isRightToLeft(this.inDocument_?this.element_:document.body));return this.rightToLeft_};Blockly.Component.prototype.setRightToLeft=function(a){if(this.inDocument_)throw Error(Blockly.Component.Error.ALREADY_RENDERED);this.rightToLeft_=a};Blockly.Component.prototype.hasChildren=function(){return!!this.children_&&0!=this.children_.length};
|
||||
Blockly.Component.prototype.getChildCount=function(){return this.children_?this.children_.length:0};Blockly.Component.prototype.getChildIds=function(){var a=[];this.forEachChild(function(b){a.push(b.getId())});return a};Blockly.Component.prototype.getChild=function(a){return this.childIndex_&&a?this.childIndex_[a]||null:null};Blockly.Component.prototype.getChildAt=function(a){return this.children_?this.children_[a]||null:null};
|
||||
Blockly.Component.prototype.forEachChild=function(a,b){if(this.children_)for(var c=0;c<this.children_.length;c++)a.call(b,this.children_[c],c)};Blockly.Component.prototype.indexOfChild=function(a){return this.children_&&a?this.children_.indexOf(a):-1};
|
||||
Blockly.Component.prototype.removeChild=function(a,b){if(a){var c="string"===typeof a||a instanceof String?String(a):a.getId();a=this.getChild(c);c&&a&&(delete this.childIndex_[c],c=this.children_.indexOf(a),-1<c&&this.children_.splice(c,1),b&&(a.exitDocument(),a.element_&&Blockly.utils.dom.removeNode(a.element_)),a.setParent(null))}if(!a)throw Error(Blockly.Component.Error.NOT_OUR_CHILD);return a};
|
||||
Blockly.Component.prototype.removeChildAt=function(a,b){return this.removeChild(this.getChildAt(a),b)};Blockly.Component.prototype.removeChildren=function(a){for(var b=[];this.hasChildren();)b.push(this.removeChildAt(0,a));return b};Blockly.utils.aria={};Blockly.utils.aria.ARIA_PREFIX_="aria-";Blockly.utils.aria.ROLE_ATTRIBUTE_="role";
|
||||
Blockly.utils.aria.Role={ALERT:"alert",ALERTDIALOG:"alertdialog",APPLICATION:"application",ARTICLE:"article",BANNER:"banner",BUTTON:"button",CHECKBOX:"checkbox",COLUMNHEADER:"columnheader",COMBOBOX:"combobox",COMPLEMENTARY:"complementary",CONTENTINFO:"contentinfo",DEFINITION:"definition",DIALOG:"dialog",DIRECTORY:"directory",DOCUMENT:"document",FORM:"form",GRID:"grid",GRIDCELL:"gridcell",GROUP:"group",HEADING:"heading",IMG:"img",LINK:"link",LIST:"list",LISTBOX:"listbox",LISTITEM:"listitem",LOG:"log",
|
||||
MAIN:"main",MARQUEE:"marquee",MATH:"math",MENU:"menu",MENUBAR:"menubar",MENUITEM:"menuitem",MENUITEMCHECKBOX:"menuitemcheckbox",MENUITEMRADIO:"menuitemradio",NAVIGATION:"navigation",NOTE:"note",OPTION:"option",PRESENTATION:"presentation",PROGRESSBAR:"progressbar",RADIO:"radio",RADIOGROUP:"radiogroup",REGION:"region",ROW:"row",ROWGROUP:"rowgroup",ROWHEADER:"rowheader",SCROLLBAR:"scrollbar",SEARCH:"search",SEPARATOR:"separator",SLIDER:"slider",SPINBUTTON:"spinbutton",STATUS:"status",TAB:"tab",TABLIST:"tablist",
|
||||
TABPANEL:"tabpanel",TEXTBOX:"textbox",TEXTINFO:"textinfo",TIMER:"timer",TOOLBAR:"toolbar",TOOLTIP:"tooltip",TREE:"tree",TREEGRID:"treegrid",TREEITEM:"treeitem"};
|
||||
Blockly.utils.aria.State={ACTIVEDESCENDANT:"activedescendant",ATOMIC:"atomic",AUTOCOMPLETE:"autocomplete",BUSY:"busy",CHECKED:"checked",COLINDEX:"colindex",CONTROLS:"controls",DESCRIBEDBY:"describedby",DISABLED:"disabled",DROPEFFECT:"dropeffect",EXPANDED:"expanded",FLOWTO:"flowto",GRABBED:"grabbed",HASPOPUP:"haspopup",HIDDEN:"hidden",INVALID:"invalid",LABEL:"label",LABELLEDBY:"labelledby",LEVEL:"level",LIVE:"live",MULTILINE:"multiline",MULTISELECTABLE:"multiselectable",ORIENTATION:"orientation",OWNS:"owns",
|
||||
POSINSET:"posinset",PRESSED:"pressed",READONLY:"readonly",RELEVANT:"relevant",REQUIRED:"required",ROWINDEX:"rowindex",SELECTED:"selected",SETSIZE:"setsize",SORT:"sort",VALUEMAX:"valuemax",VALUEMIN:"valuemin",VALUENOW:"valuenow",VALUETEXT:"valuetext"};Blockly.utils.aria.setRole=function(a,b){b?a.setAttribute(Blockly.utils.aria.ROLE_ATTRIBUTE_,b):Blockly.utils.aria.removeRole(a)};Blockly.utils.aria.getRole=function(a){return a.getAttribute(Blockly.utils.aria.ROLE_ATTRIBUTE_)||null};
|
||||
Blockly.utils.aria.removeRole=function(a){a.removeAttribute(Blockly.utils.aria.ROLE_ATTRIBUTE_)};Blockly.utils.aria.setState=function(a,b,c){Array.isArray(c)&&(c=c.join(" "));b=Blockly.utils.aria.getAriaAttributeName_(b);a.setAttribute(b,c)};Blockly.utils.aria.getAriaAttributeName_=function(a){return Blockly.utils.aria.ARIA_PREFIX_+a};Blockly.utils.KeyCodes={WIN_KEY_FF_LINUX:0,MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS_SIGN:43,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,FF_SEMICOLON:59,FF_EQUALS:61,FF_DASH:173,FF_HASH:163,QUESTION_MARK:63,AT_SIGN:64,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,
|
||||
N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SCROLL_LOCK:145,FIRST_MEDIA_KEY:166,LAST_MEDIA_KEY:183,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,
|
||||
PERIOD:190,SLASH:191,APOSTROPHE:192,TILDE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,MAC_WK_CMD_LEFT:91,MAC_WK_CMD_RIGHT:93,WIN_IME:229,VK_NONAME:252,PHANTOM:255};Blockly.tree={};Blockly.tree.BaseNode=function(a,b){Blockly.Component.call(this);this.config_=b;this.content_=a;this.expanded_=this.selected_=!1;this.toolTip_=null;this.isUserCollapsible_=!0;this.depth_=-1};goog.inherits(Blockly.tree.BaseNode,Blockly.Component);Blockly.tree.BaseNode.allNodes={};Blockly.tree.BaseNode.prototype.disposeInternal=function(){Blockly.tree.BaseNode.superClass_.disposeInternal.call(this);this.tree&&(this.tree=null);this.setElementInternal(null)};
|
||||
Blockly.tree.BaseNode.prototype.initAccessibility=function(){var a=this.getElement();if(a){var b=this.getLabelElement();b&&!b.id&&(b.id=this.getId()+".label");Blockly.utils.aria.setRole(a,Blockly.utils.aria.Role.TREEITEM);Blockly.utils.aria.setState(a,Blockly.utils.aria.State.SELECTED,!1);Blockly.utils.aria.setState(a,Blockly.utils.aria.State.LEVEL,this.getDepth());b&&Blockly.utils.aria.setState(a,Blockly.utils.aria.State.LABELLEDBY,b.id);(b=this.getIconElement())&&Blockly.utils.aria.setRole(b,Blockly.utils.aria.Role.PRESENTATION);
|
||||
(b=this.getExpandIconElement())&&Blockly.utils.aria.setRole(b,Blockly.utils.aria.Role.PRESENTATION);if(b=this.getChildrenElement())if(Blockly.utils.aria.setRole(b,Blockly.utils.aria.Role.GROUP),b.hasChildNodes())for(Blockly.utils.aria.setState(a,Blockly.utils.aria.State.EXPANDED,!1),a=this.getChildCount(),b=1;b<=a;b++){var c=this.getChildAt(b-1).getElement();Blockly.utils.aria.setState(c,Blockly.utils.aria.State.SETSIZE,a);Blockly.utils.aria.setState(c,Blockly.utils.aria.State.POSINSET,b)}}};
|
||||
Blockly.tree.BaseNode.prototype.createDom=function(){var a=document.createElement("div");a.appendChild(this.toDom());this.setElementInternal(a)};Blockly.tree.BaseNode.prototype.enterDocument=function(){Blockly.tree.BaseNode.superClass_.enterDocument.call(this);Blockly.tree.BaseNode.allNodes[this.getId()]=this;this.initAccessibility()};Blockly.tree.BaseNode.prototype.exitDocument=function(){Blockly.tree.BaseNode.superClass_.exitDocument.call(this);delete Blockly.tree.BaseNode.allNodes[this.getId()]};
|
||||
Blockly.tree.BaseNode.prototype.addChildAt=function(a,b){var c=this.getChildAt(b-1),d=this.getChildAt(b);Blockly.tree.BaseNode.superClass_.addChildAt.call(this,a,b);a.previousSibling_=c;a.nextSibling_=d;c?c.nextSibling_=a:this.firstChild_=a;d?d.previousSibling_=a:this.lastChild_=a;var e=this.getTree();e&&a.setTreeInternal(e);a.setDepth_(this.getDepth()+1);if(e=this.getElement())if(this.updateExpandIcon(),Blockly.utils.aria.setState(e,Blockly.utils.aria.State.EXPANDED,this.getExpanded()),this.getExpanded()){e=
|
||||
this.getChildrenElement();a.getElement()||a.createDom();var f=a.getElement(),g=d&&d.getElement();e.insertBefore(f,g);this.isInDocument()&&a.enterDocument();d||(c?c.updateExpandIcon():(Blockly.utils.style.setElementShown(e,!0),this.setExpanded(this.getExpanded())))}};Blockly.tree.BaseNode.prototype.add=function(a,b){a.getParent()&&a.getParent().removeChild(a);this.addChildAt(a,b?this.indexOfChild(b):this.getChildCount());return a};Blockly.tree.BaseNode.prototype.getTree=function(){return null};
|
||||
Blockly.tree.BaseNode.prototype.getDepth=function(){var a=this.depth_;0>a&&(a=this.computeDepth_(),this.setDepth_(a));return a};Blockly.tree.BaseNode.prototype.computeDepth_=function(){var a=this.getParent();return a?a.getDepth()+1:0};Blockly.tree.BaseNode.prototype.setDepth_=function(a){if(a!=this.depth_){this.depth_=a;var b=this.getRowElement();if(b){var c=this.getPixelIndent_()+"px";this.isRightToLeft()?b.style.paddingRight=c:b.style.paddingLeft=c}this.forEachChild(function(b){b.setDepth_(a+1)})}};
|
||||
Blockly.tree.BaseNode.prototype.contains=function(a){for(;a;){if(a==this)return!0;a=a.getParent()}return!1};Blockly.tree.BaseNode.prototype.getChildren=function(){var a=[];this.forEachChild(function(b){a.push(b)});return a};Blockly.tree.BaseNode.prototype.getFirstChild=function(){return this.getChildAt(0)};Blockly.tree.BaseNode.prototype.getLastChild=function(){return this.getChildAt(this.getChildCount()-1)};Blockly.tree.BaseNode.prototype.getPreviousSibling=function(){return this.previousSibling_};
|
||||
Blockly.tree.BaseNode.prototype.getNextSibling=function(){return this.nextSibling_};Blockly.tree.BaseNode.prototype.isLastSibling=function(){return!this.nextSibling_};Blockly.tree.BaseNode.prototype.isSelected=function(){return this.selected_};Blockly.tree.BaseNode.prototype.select=function(){var a=this.getTree();a&&a.setSelectedItem(this)};
|
||||
Blockly.tree.BaseNode.prototype.setSelectedInternal=function(a){if(this.selected_!=a){this.selected_=a;this.updateRow();var b=this.getElement();b&&(Blockly.utils.aria.setState(b,Blockly.utils.aria.State.SELECTED,a),a&&(a=this.getTree().getElement(),Blockly.utils.aria.setState(a,Blockly.utils.aria.State.ACTIVEDESCENDANT,this.getId())))}};Blockly.tree.BaseNode.prototype.getExpanded=function(){return this.expanded_};Blockly.tree.BaseNode.prototype.setExpandedInternal=function(a){this.expanded_=a};
|
||||
Blockly.tree.BaseNode.prototype.setExpanded=function(a){var b=a!=this.expanded_,c;this.expanded_=a;var d=this.getTree(),e=this.getElement();if(this.hasChildren()){if(!a&&d&&this.contains(d.getSelectedItem())&&this.select(),e){if(c=this.getChildrenElement())Blockly.utils.style.setElementShown(c,a),Blockly.utils.aria.setState(e,Blockly.utils.aria.State.EXPANDED,a),a&&this.isInDocument()&&!c.hasChildNodes()&&(this.forEachChild(function(a){c.appendChild(a.toDom())}),this.forEachChild(function(a){a.enterDocument()}));
|
||||
this.updateExpandIcon()}}else(c=this.getChildrenElement())&&Blockly.utils.style.setElementShown(c,!1);e&&this.updateIcon_();b&&(a?this.doNodeExpanded():this.doNodeCollapsed())};Blockly.tree.BaseNode.prototype.doNodeExpanded=function(){};Blockly.tree.BaseNode.prototype.doNodeCollapsed=function(){};Blockly.tree.BaseNode.prototype.toggle=function(){this.setExpanded(!this.getExpanded())};Blockly.tree.BaseNode.prototype.expand=function(){this.setExpanded(!0)};Blockly.tree.BaseNode.prototype.collapse=function(){this.setExpanded(!1)};
|
||||
Blockly.tree.BaseNode.prototype.collapseChildren=function(){this.forEachChild(function(a){a.collapseAll()})};Blockly.tree.BaseNode.prototype.collapseAll=function(){this.collapseChildren();this.collapse()};Blockly.tree.BaseNode.prototype.expandChildren=function(){this.forEachChild(function(a){a.expandAll()})};Blockly.tree.BaseNode.prototype.expandAll=function(){this.expandChildren();this.expand()};Blockly.tree.BaseNode.prototype.reveal=function(){var a=this.getParent();a&&(a.setExpanded(!0),a.reveal())};
|
||||
Blockly.tree.BaseNode.prototype.setIsUserCollapsible=function(a){(this.isUserCollapsible_=a)||this.expand();this.getElement()&&this.updateExpandIcon()};Blockly.tree.BaseNode.prototype.isUserCollapsible=function(){return this.isUserCollapsible_};
|
||||
Blockly.tree.BaseNode.prototype.toDom=function(){var a=this.config_.cssChildrenNoLines,b=this.getExpanded()&&this.hasChildren(),c=document.createElement("div");c.setAttribute("class",a||"");c.setAttribute("style",this.getLineStyle());b&&this.forEachChild(function(a){c.appendChild(a.toDom())});a=document.createElement("div");a.setAttribute("class",this.config_.cssItem||"");a.setAttribute("id",this.getId());a.appendChild(this.getRowDom());a.appendChild(c);return a};
|
||||
Blockly.tree.BaseNode.prototype.getPixelIndent_=function(){return Math.max(0,(this.getDepth()-1)*this.config_.indentWidth)};Blockly.tree.BaseNode.prototype.getRowDom=function(){var a="padding-"+(this.isRightToLeft()?"right":"left")+":"+this.getPixelIndent_()+"px",b=document.createElement("div");b.setAttribute("class",this.getRowClassName());b.setAttribute("style",a);b.appendChild(this.getExpandIconDom());b.appendChild(this.getIconDom());b.appendChild(this.getLabelDom());return b};
|
||||
Blockly.tree.BaseNode.prototype.getRowClassName=function(){var a="";this.isSelected()&&(a=" "+(this.config_.cssSelectedRow||""));return this.config_.cssTreeRow+a};Blockly.tree.BaseNode.prototype.getLabelDom=function(){var a=document.createElement("span");a.setAttribute("class",this.config_.cssItemLabel||"");a.setAttribute("title",this.getToolTip()||"");a.textContent=this.getText();return a};
|
||||
Blockly.tree.BaseNode.prototype.getIconDom=function(){var a=document.createElement("span");a.setAttribute("style","display: inline-block;");a.setAttribute("class",this.getCalculatedIconClass());return a};Blockly.tree.BaseNode.prototype.getCalculatedIconClass=function(){throw Error("unimplemented abstract method");};Blockly.tree.BaseNode.prototype.getExpandIconDom=function(){return document.createElement("span")};
|
||||
Blockly.tree.BaseNode.prototype.getExpandIconClass=function(){var a=this.config_;var b=a.cssTreeIcon+" "+a.cssExpandTreeIcon+" ";this.hasChildren();return b+=a.cssExpandTreeIconBlank};Blockly.tree.BaseNode.prototype.getLineStyle=function(){var a=this.getExpanded()&&this.hasChildren();return"background-position: "+this.getBackgroundPosition()+"; "+(a?"":"display: none")};
|
||||
Blockly.tree.BaseNode.prototype.getBackgroundPosition=function(){return(this.isLastSibling()?"-100":(this.getDepth()-1)*this.config_.indentWidth)+"px 0"};Blockly.tree.BaseNode.prototype.getElement=function(){var a=Blockly.tree.BaseNode.superClass_.getElement.call(this);a||(a=document.getElementById(this.getId()),this.setElementInternal(a));return a};Blockly.tree.BaseNode.prototype.getRowElement=function(){var a=this.getElement();return a?a.firstChild:null};
|
||||
Blockly.tree.BaseNode.prototype.getExpandIconElement=function(){var a=this.getRowElement();return a?a.firstChild:null};Blockly.tree.BaseNode.prototype.getIconElement=function(){var a=this.getRowElement();return a?a.childNodes[1]:null};Blockly.tree.BaseNode.prototype.getLabelElement=function(){var a=this.getRowElement();return a&&a.lastChild?a.lastChild.previousSibling:null};Blockly.tree.BaseNode.prototype.getAfterLabelElement=function(){var a=this.getRowElement();return a?a.lastChild:null};
|
||||
Blockly.tree.BaseNode.prototype.getChildrenElement=function(){var a=this.getElement();return a?a.lastChild:null};Blockly.tree.BaseNode.prototype.setIconClass=function(a){this.iconClass_=a;this.isInDocument()&&this.updateIcon_()};Blockly.tree.BaseNode.prototype.getIconClass=function(){return this.iconClass_};Blockly.tree.BaseNode.prototype.setExpandedIconClass=function(a){this.expandedIconClass_=a;this.isInDocument()&&this.updateIcon_()};Blockly.tree.BaseNode.prototype.getExpandedIconClass=function(){return this.expandedIconClass_};
|
||||
Blockly.tree.BaseNode.prototype.setText=function(a){this.content_=a};Blockly.tree.BaseNode.prototype.getText=function(){return this.content_};Blockly.tree.BaseNode.prototype.setToolTip=function(a){this.toolTip_=a;var b=this.getLabelElement();b&&(b.title=a)};Blockly.tree.BaseNode.prototype.getToolTip=function(){return this.toolTip_};Blockly.tree.BaseNode.prototype.updateRow=function(){var a=this.getRowElement();a&&(a.className=this.getRowClassName())};
|
||||
Blockly.tree.BaseNode.prototype.updateExpandIcon=function(){var a=this.getExpandIconElement();a&&(a.className=this.getExpandIconClass());if(a=this.getChildrenElement())a.style.backgroundPosition=this.getBackgroundPosition()};Blockly.tree.BaseNode.prototype.updateIcon_=function(){this.getIconElement().className=this.getCalculatedIconClass()};
|
||||
Blockly.tree.BaseNode.prototype.onMouseDown=function(a){"expand"==a.target.getAttribute("type")&&this.hasChildren()?this.isUserCollapsible_&&this.toggle():(this.select(),this.updateRow())};Blockly.tree.BaseNode.prototype.onClick_=function(a){a.preventDefault()};Blockly.tree.BaseNode.prototype.onDoubleClick_=function(a){"expand"==a.target.getAttribute("type")&&this.hasChildren()||this.isUserCollapsible_&&this.toggle()};
|
||||
Blockly.tree.BaseNode.prototype.onKeyDown=function(a){var b=!0;switch(a.keyCode){case Blockly.utils.KeyCodes.RIGHT:if(a.altKey)break;this.hasChildren()&&(this.getExpanded()?this.getFirstChild().select():this.setExpanded(!0));break;case Blockly.utils.KeyCodes.LEFT:if(a.altKey)break;if(this.hasChildren()&&this.getExpanded()&&this.isUserCollapsible_)this.setExpanded(!1);else{var c=this.getParent(),d=this.getTree();c&&c!=d&&c.select()}break;case Blockly.utils.KeyCodes.DOWN:(c=this.getNextShownNode())&&
|
||||
c.select();break;case Blockly.utils.KeyCodes.UP:(c=this.getPreviousShownNode())&&c.select();break;default:b=!1}b&&a.preventDefault();return b};Blockly.tree.BaseNode.prototype.getLastShownDescendant=function(){return this.getExpanded()&&this.hasChildren()?this.getLastChild().getLastShownDescendant():this};
|
||||
Blockly.tree.BaseNode.prototype.getNextShownNode=function(){if(this.hasChildren()&&this.getExpanded())return this.getFirstChild();for(var a=this,b;a!=this.getTree();){b=a.getNextSibling();if(null!=b)return b;a=a.getParent()}return null};Blockly.tree.BaseNode.prototype.getPreviousShownNode=function(){var a=this.getPreviousSibling();if(null!=a)return a.getLastShownDescendant();a=this.getParent();var b=this.getTree();return a==b||this==b?null:a};Blockly.tree.BaseNode.prototype.getConfig=function(){return this.config_};
|
||||
Blockly.tree.BaseNode.prototype.setTreeInternal=function(a){this.tree!=a&&(this.tree=a,this.forEachChild(function(b){b.setTreeInternal(a)}))};Blockly.tree.TreeNode=function(a,b,c){this.toolbox_=a;Blockly.tree.BaseNode.call(this,b,c)};goog.inherits(Blockly.tree.TreeNode,Blockly.tree.BaseNode);Blockly.tree.TreeNode.prototype.getTree=function(){if(this.tree)return this.tree;var a=this.getParent();return a&&(a=a.getTree())?(this.setTreeInternal(a),a):null};
|
||||
Blockly.tree.TreeNode.prototype.getCalculatedIconClass=function(){var a=this.getExpanded(),b=this.getExpandedIconClass();if(a&&b)return b;b=this.getIconClass();if(!a&&b)return b;b=this.getConfig();if(this.hasChildren()){if(a&&b.cssExpandedFolderIcon)return b.cssTreeIcon+" "+b.cssExpandedFolderIcon;if(!a&&b.cssCollapsedFolderIcon)return b.cssTreeIcon+" "+b.cssCollapsedFolderIcon}else if(b.cssFileIcon)return b.cssTreeIcon+" "+b.cssFileIcon;return""};
|
||||
Blockly.tree.TreeNode.prototype.onClick_=function(a){this.hasChildren()&&this.isUserCollapsible()?(this.toggle(),this.select()):this.isSelected()?this.getTree().setSelectedItem(null):this.select();this.updateRow()};Blockly.tree.TreeNode.prototype.onMouseDown=function(a){};
|
||||
Blockly.tree.TreeNode.prototype.onKeyDown=function(a){if(this.tree.toolbox_.horizontalLayout_){var b={},c=Blockly.utils.KeyCodes.DOWN,d=Blockly.utils.KeyCodes.UP;b[Blockly.utils.KeyCodes.RIGHT]=this.isRightToLeft()?d:c;b[Blockly.utils.KeyCodes.LEFT]=this.isRightToLeft()?c:d;b[Blockly.utils.KeyCodes.UP]=Blockly.utils.KeyCodes.LEFT;b[Blockly.utils.KeyCodes.DOWN]=Blockly.utils.KeyCodes.RIGHT;Object.defineProperties(a,{keyCode:{value:b[a.keyCode]||a.keyCode}})}return Blockly.tree.TreeNode.superClass_.onKeyDown.call(this,
|
||||
a)};Blockly.tree.TreeNode.prototype.onSizeChanged=function(a){this.onSizeChanged_=a};Blockly.tree.TreeNode.prototype.resizeToolbox_=function(){this.onSizeChanged_&&this.onSizeChanged_.call(this.toolbox_)};Blockly.tree.TreeNode.prototype.doNodeExpanded=Blockly.tree.TreeNode.prototype.resizeToolbox_;Blockly.tree.TreeNode.prototype.doNodeCollapsed=Blockly.tree.TreeNode.prototype.resizeToolbox_;Blockly.tree.TreeControl=function(a,b){this.toolbox_=a;Blockly.tree.BaseNode.call(this,"",b);this.setExpandedInternal(!0);this.setSelectedInternal(!0);this.selectedItem_=this};goog.inherits(Blockly.tree.TreeControl,Blockly.tree.BaseNode);Blockly.tree.TreeControl.prototype.getTree=function(){return this};Blockly.tree.TreeControl.prototype.getToolbox=function(){return this.toolbox_};Blockly.tree.TreeControl.prototype.getDepth=function(){return 0};Blockly.tree.TreeControl.prototype.reveal=function(){};
|
||||
Blockly.tree.TreeControl.prototype.handleFocus_=function(a){this.focused_=!0;a=this.getElement();Blockly.utils.dom.addClass(a,"focused");this.selectedItem_&&this.selectedItem_.select()};Blockly.tree.TreeControl.prototype.handleBlur_=function(a){this.focused_=!1;a=this.getElement();Blockly.utils.dom.removeClass(a,"focused")};Blockly.tree.TreeControl.prototype.hasFocus=function(){return this.focused_};Blockly.tree.TreeControl.prototype.getExpanded=function(){return!0};
|
||||
Blockly.tree.TreeControl.prototype.setExpanded=function(a){this.setExpandedInternal(a)};Blockly.tree.TreeControl.prototype.getIconElement=function(){var a=this.getRowElement();return a?a.firstChild:null};Blockly.tree.TreeControl.prototype.getExpandIconElement=function(){return null};Blockly.tree.TreeControl.prototype.updateExpandIcon=function(){};Blockly.tree.TreeControl.prototype.getRowClassName=function(){return Blockly.tree.TreeControl.superClass_.getRowClassName.call(this)+" "+this.getConfig().cssHideRoot};
|
||||
Blockly.tree.TreeControl.prototype.getCalculatedIconClass=function(){var a=this.getExpanded(),b=this.getExpandedIconClass();if(a&&b)return b;b=this.getIconClass();if(!a&&b)return b;b=this.getConfig();return a&&b.cssExpandedRootIcon?b.cssTreeIcon+" "+b.cssExpandedRootIcon:!a&&b.cssCollapsedRootIcon?b.cssTreeIcon+" "+b.cssCollapsedRootIcon:""};
|
||||
Blockly.tree.TreeControl.prototype.setSelectedItem=function(a){if(a!=this.selectedItem_&&(!this.onBeforeSelected_||this.onBeforeSelected_.call(this.toolbox_,a))){var b=this.getSelectedItem();this.selectedItem_&&this.selectedItem_.setSelectedInternal(!1);(this.selectedItem_=a)&&a.setSelectedInternal(!0);this.onAfterSelected_&&this.onAfterSelected_.call(this.toolbox_,b,a)}};Blockly.tree.TreeControl.prototype.onBeforeSelected=function(a){this.onBeforeSelected_=a};
|
||||
Blockly.tree.TreeControl.prototype.onAfterSelected=function(a){this.onAfterSelected_=a};Blockly.tree.TreeControl.prototype.getSelectedItem=function(){return this.selectedItem_};Blockly.tree.TreeControl.prototype.updateLinesAndExpandIcons_=function(){function a(b){var c=b.getChildrenElement();if(c){var d=b.getConfig().cssChildrenNoLines;c.className=d;if(c=b.getExpandIconElement())c.className=b.getExpandIconClass()}b.forEachChild(a)}a(this)};
|
||||
Blockly.tree.TreeControl.prototype.initAccessibility=function(){Blockly.tree.TreeControl.superClass_.initAccessibility.call(this);var a=this.getElement();Blockly.utils.aria.setRole(a,Blockly.utils.aria.Role.TREE);Blockly.utils.aria.setState(a,Blockly.utils.aria.State.LABELLEDBY,this.getLabelElement().id)};
|
||||
Blockly.tree.TreeControl.prototype.enterDocument=function(){Blockly.tree.TreeControl.superClass_.enterDocument.call(this);var a=this.getElement();a.className=this.getConfig().cssRoot;a.setAttribute("hideFocus","true");this.attachEvents_();this.initAccessibility()};Blockly.tree.TreeControl.prototype.exitDocument=function(){Blockly.tree.TreeControl.superClass_.exitDocument.call(this);this.detachEvents_()};
|
||||
Blockly.tree.TreeControl.prototype.attachEvents_=function(){var a=this.getElement();a.tabIndex=0;this.onFocusWrapper_=Blockly.bindEvent_(a,"focus",this,this.handleFocus_);this.onBlurWrapper_=Blockly.bindEvent_(a,"blur",this,this.handleBlur_);this.onMousedownWrapper_=Blockly.bindEventWithChecks_(a,"mousedown",this,this.handleMouseEvent_);this.onClickWrapper_=Blockly.bindEventWithChecks_(a,"click",this,this.handleMouseEvent_);this.onKeydownWrapper_=Blockly.bindEvent_(a,"keydown",this,this.handleKeyEvent_);
|
||||
Blockly.Touch.TOUCH_ENABLED&&(this.onTouchEndWrapper_=Blockly.bindEventWithChecks_(a,"touchend",this,this.handleTouchEvent_))};Blockly.tree.TreeControl.prototype.detachEvents_=function(){Blockly.unbindEvent_(this.onFocusWrapper_);Blockly.unbindEvent_(this.onBlurWrapper_);Blockly.unbindEvent_(this.onMousedownWrapper_);Blockly.unbindEvent_(this.onClickWrapper_);Blockly.unbindEvent_(this.onKeydownWrapper_);this.onTouchEndWrapper_&&Blockly.unbindEvent_(this.onTouchEndWrapper_)};
|
||||
Blockly.tree.TreeControl.prototype.handleMouseEvent_=function(a){var b=this.getNodeFromEvent_(a);if(b)switch(a.type){case "mousedown":b.onMouseDown(a);break;case "click":b.onClick_(a)}};Blockly.tree.TreeControl.prototype.handleTouchEvent_=function(a){var b=this.getNodeFromEvent_(a);b&&"touchend"===a.type&&setTimeout(function(){b.onClick_(a)},1)};Blockly.tree.TreeControl.prototype.handleKeyEvent_=function(a){var b=!1;(b=this.selectedItem_&&this.selectedItem_.onKeyDown(a)||b)&&a.preventDefault();return b};
|
||||
Blockly.tree.TreeControl.prototype.getNodeFromEvent_=function(a){for(var b=a.target;null!=b;){if(a=Blockly.tree.BaseNode.allNodes[b.id])return a;if(b==this.getElement())break;b=b.parentNode}return null};Blockly.tree.TreeControl.prototype.createNode=function(a){return new Blockly.tree.TreeNode(this.toolbox_,a||"",this.getConfig())};Blockly.VerticalFlyout=function(a){a.getMetrics=this.getMetrics_.bind(this);a.setMetrics=this.setMetrics_.bind(this);Blockly.VerticalFlyout.superClass_.constructor.call(this,a);this.horizontalLayout_=!1};goog.inherits(Blockly.VerticalFlyout,Blockly.Flyout);
|
||||
Blockly.VerticalFlyout.prototype.getMetrics_=function(){if(!this.isVisible())return null;try{var a=this.workspace_.getCanvas().getBBox()}catch(e){a={height:0,y:0,width:0,x:0}}var b=this.SCROLLBAR_PADDING,c=this.height_-2*this.SCROLLBAR_PADDING,d=this.width_;this.RTL||(d-=this.SCROLLBAR_PADDING);return{viewHeight:c,viewWidth:d,contentHeight:a.height*this.workspace_.scale+2*this.MARGIN,contentWidth:a.width*this.workspace_.scale+2*this.MARGIN,viewTop:-this.workspace_.scrollY+a.y,viewLeft:-this.workspace_.scrollX,
|
||||
contentTop:a.y,contentLeft:a.x,absoluteTop:b,absoluteLeft:0}};Blockly.VerticalFlyout.prototype.setMetrics_=function(a){var b=this.getMetrics_();b&&("number"==typeof a.y&&(this.workspace_.scrollY=-b.contentHeight*a.y),this.workspace_.translate(this.workspace_.scrollX+b.absoluteLeft,this.workspace_.scrollY+b.absoluteTop))};
|
||||
Blockly.VerticalFlyout.prototype.position=function(){if(this.isVisible()){var a=this.targetWorkspace_.getMetrics();a&&(this.height_=a.viewHeight,this.setBackgroundPath_(this.width_-this.CORNER_RADIUS,a.viewHeight-2*this.CORNER_RADIUS),this.positionAt_(this.width_,this.height_,this.targetWorkspace_.toolboxPosition==this.toolboxPosition_?a.toolboxWidth?this.toolboxPosition_==Blockly.TOOLBOX_AT_LEFT?a.toolboxWidth:a.viewWidth-this.width_:this.toolboxPosition_==Blockly.TOOLBOX_AT_LEFT?0:a.viewWidth:this.toolboxPosition_==
|
||||
@@ -1924,26 +1854,21 @@ d.moveBy(a/this.workspace_.scale-this.MARGIN-Blockly.BlockSvg.TAB_WIDTH-e,0)),d.
|
||||
this.horizontalLayout_&&(this.config_.cssTreeRow+=a.RTL?" blocklyHorizontalTreeRtl":" blocklyHorizontalTree",this.treeSeparatorConfig_.cssTreeRow="blocklyTreeSeparatorHorizontal "+(a.RTL?"blocklyHorizontalTreeRtl":"blocklyHorizontalTree"),this.config_.cssTreeIcon="")};Blockly.Toolbox.prototype.width=0;Blockly.Toolbox.prototype.height=0;Blockly.Toolbox.prototype.selectedOption_=null;Blockly.Toolbox.prototype.lastCategory_=null;
|
||||
Blockly.Toolbox.prototype.init=function(){var a=this.workspace_,b=this.workspace_.getParentSvg();this.HtmlDiv=document.createElement("div");this.HtmlDiv.className="blocklyToolboxDiv";this.HtmlDiv.setAttribute("dir",a.RTL?"RTL":"LTR");b.parentNode.insertBefore(this.HtmlDiv,b);Blockly.bindEventWithChecks_(this.HtmlDiv,"mousedown",this,function(a){Blockly.utils.isRightButton(a)||a.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0);Blockly.Touch.clearTouchIdentifier()},!1,!0);b={disabledPatternId:a.options.disabledPatternId,
|
||||
parentWorkspace:a,RTL:a.RTL,oneBasedIndex:a.options.oneBasedIndex,horizontalLayout:a.horizontalLayout,toolboxPosition:a.options.toolboxPosition};this.flyout_=null;this.flyout_=a.horizontalLayout?new Blockly.HorizontalFlyout(b):new Blockly.VerticalFlyout(b);Blockly.utils.dom.insertAfter(this.flyout_.createDom("svg"),this.workspace_.getParentSvg());this.flyout_.init(a);this.config_.cleardotPath=a.options.pathToMedia+"1x1.gif";this.config_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(a.RTL?"Rtl":
|
||||
"Ltr");this.tree_=b=new Blockly.Toolbox.TreeControl(this,this.config_);b.setShowRootNode(!1);b.setShowLines(!1);b.setShowExpandIcons(!1);b.setSelectedItem(null);a=this.populate_(a.options.languageTree);b.render(this.HtmlDiv);a&&b.setSelectedItem(a);this.addColour_();this.position()};Blockly.Toolbox.prototype.dispose=function(){this.flyout_.dispose();this.tree_.dispose();Blockly.utils.dom.removeNode(this.HtmlDiv);this.lastCategory_=this.workspace_=null};Blockly.Toolbox.prototype.getWidth=function(){return this.width};
|
||||
Blockly.Toolbox.prototype.getHeight=function(){return this.height};
|
||||
"Ltr");this.tree_=b=new Blockly.tree.TreeControl(this,this.config_);b.setSelectedItem(null);b.onBeforeSelected(this.handleBeforeTreeSelected_);b.onAfterSelected(this.handleAfterTreeSelected_);a=this.populate_(a.options.languageTree);b.render(this.HtmlDiv);a&&b.setSelectedItem(a);this.addColour_();this.position();this.horizontalLayout_&&Blockly.utils.aria.setState(this.tree_.getElement(),Blockly.utils.aria.State.ORIENTATION,"horizontal")};
|
||||
Blockly.Toolbox.prototype.handleBeforeTreeSelected_=function(a){if(a==this.tree_)return!1;this.lastCategory_&&(this.lastCategory_.getRowElement().style.backgroundColor="");if(a){var b=a.hexColour||"#57e";a.getRowElement().style.backgroundColor=b;this.addColour_(a)}return!0};
|
||||
Blockly.Toolbox.prototype.handleAfterTreeSelected_=function(a,b){b&&b.blocks&&b.blocks.length?(this.flyout_.show(b.blocks),this.lastCategory_!=b&&this.flyout_.scrollToStart()):this.flyout_.hide();if(a!=b&&a!=this){var c=new Blockly.Events.Ui(null,"category",a&&a.getText(),b&&b.getText());c.workspaceId=this.workspace_.id;Blockly.Events.fire(c)}b&&(this.lastCategory_=b)};Blockly.Toolbox.prototype.handleNodeSizeChanged_=function(){Blockly.svgResize(this.workspace_)};
|
||||
Blockly.Toolbox.prototype.dispose=function(){this.flyout_.dispose();this.tree_.dispose();Blockly.utils.dom.removeNode(this.HtmlDiv);this.lastCategory_=this.workspace_=null};Blockly.Toolbox.prototype.getWidth=function(){return this.width};Blockly.Toolbox.prototype.getHeight=function(){return this.height};
|
||||
Blockly.Toolbox.prototype.position=function(){var a=this.HtmlDiv;if(a){var b=this.workspace_.getParentSvg();b=Blockly.svgSize(b);this.horizontalLayout_?(a.style.left="0",a.style.height="auto",a.style.width=b.width+"px",this.height=a.offsetHeight,this.toolboxPosition==Blockly.TOOLBOX_AT_TOP?a.style.top="0":a.style.bottom="0"):(this.toolboxPosition==Blockly.TOOLBOX_AT_RIGHT?a.style.right="0":a.style.left="0",a.style.height=b.height+"px",this.width=a.offsetWidth);this.flyout_.position()}};
|
||||
Blockly.Toolbox.prototype.populate_=function(a){this.tree_.removeChildren();this.tree_.blocks=[];this.hasColours_=!1;a=this.syncTrees_(a,this.tree_,this.workspace_.options.pathToMedia);if(this.tree_.blocks.length)throw Error("Toolbox cannot have both blocks and categories in the root level.");this.workspace_.resizeContents();return a};
|
||||
Blockly.Toolbox.prototype.syncTrees_=function(a,b,c){for(var d=null,e=null,f=0,g;g=a.childNodes[f];f++)if(g.tagName)switch(g.tagName.toUpperCase()){case "CATEGORY":e=Blockly.utils.replaceMessageReferences(g.getAttribute("name"));var h=this.tree_.createNode(e);h.blocks=[];b.add(h);var k=g.getAttribute("custom");k?h.blocks=k:(k=this.syncTrees_(g,h,c))&&(d=k);k=g.getAttribute("categorystyle");var l=g.getAttribute("colour");l&&k?(h.hexColour="",console.warn('Toolbox category "'+e+'" can not have both a style and a colour')):
|
||||
k?this.setColourFromStyle_(k,h,e):this.setColour_(l,h,e);"true"==g.getAttribute("expanded")?(h.blocks.length&&(d=h),h.setExpanded(!0)):h.setExpanded(!1);e=g;break;case "SEP":if(e&&"CATEGORY"==e.tagName.toUpperCase()){b.add(new Blockly.Toolbox.TreeSeparator(this.treeSeparatorConfig_));break}case "BLOCK":case "SHADOW":case "LABEL":case "BUTTON":b.blocks.push(g),e=g}return d};
|
||||
Blockly.Toolbox.prototype.syncTrees_=function(a,b,c){for(var d=null,e=null,f=0,g;g=a.childNodes[f];f++)if(g.tagName)switch(g.tagName.toUpperCase()){case "CATEGORY":e=Blockly.utils.replaceMessageReferences(g.getAttribute("name"));var h=this.tree_.createNode(e);h.onSizeChanged(this.handleNodeSizeChanged_);h.blocks=[];b.add(h);var k=g.getAttribute("custom");k?h.blocks=k:(k=this.syncTrees_(g,h,c))&&(d=k);k=g.getAttribute("categorystyle");var l=g.getAttribute("colour");l&&k?(h.hexColour="",console.warn('Toolbox category "'+
|
||||
e+'" can not have both a style and a colour')):k?this.setColourFromStyle_(k,h,e):this.setColour_(l,h,e);"true"==g.getAttribute("expanded")?(h.blocks.length&&(d=h),h.setExpanded(!0)):h.setExpanded(!1);e=g;break;case "SEP":if(e&&"CATEGORY"==e.tagName.toUpperCase()){b.add(new Blockly.Toolbox.TreeSeparator(this.treeSeparatorConfig_));break}case "BLOCK":case "SHADOW":case "LABEL":case "BUTTON":b.blocks.push(g),e=g}return d};
|
||||
Blockly.Toolbox.prototype.setColour_=function(a,b,c){a=Blockly.utils.replaceMessageReferences(a);if(null===a||""===a)b.hexColour="";else{var d=Number(a);isNaN(d)?(d=Blockly.utils.colour.parse(a))?(b.hexColour=d,this.hasColours_=!0):(b.hexColour="",console.warn('Toolbox category "'+c+'" has unrecognized colour attribute: '+a)):(b.hexColour=Blockly.hueToHex(d),this.hasColours_=!0)}};
|
||||
Blockly.Toolbox.prototype.setColourFromStyle_=function(a,b,c){if((b.styleName=a)&&Blockly.getTheme()){var d=Blockly.getTheme().getCategoryStyle(a);d&&d.colour?this.setColour_(d.colour,b,c):console.warn('Style "'+a+'" must exist and contain a colour value')}};Blockly.Toolbox.prototype.updateColourFromTheme_=function(a){if(a=a||this.tree_){a=a.getChildren(!1);for(var b=0,c;c=a[b];b++)c.styleName&&(this.setColourFromStyle_(c.styleName,c,""),this.addColour_()),this.updateColourFromTheme_(c)}};
|
||||
Blockly.Toolbox.prototype.updateColourFromTheme=function(){var a=this.tree_;a&&(this.updateColourFromTheme_(a),this.updateSelectedItemColour_(a))};Blockly.Toolbox.prototype.updateSelectedItemColour_=function(a){var b=a.selectedItem_;if(b){var c=b.hexColour||"#57e";b.getRowElement().style.backgroundColor=c;a.toolbox_.addColour_(b)}};
|
||||
Blockly.Toolbox.prototype.updateColourFromTheme=function(){var a=this.tree_;a&&(this.updateColourFromTheme_(a),this.updateSelectedItemColour_(a))};Blockly.Toolbox.prototype.updateSelectedItemColour_=function(a){if(a=a.getSelectedItem()){var b=a.hexColour||"#57e";a.getRowElement().style.backgroundColor=b;this.addColour_(a)}};
|
||||
Blockly.Toolbox.prototype.addColour_=function(a){a=(a||this.tree_).getChildren(!1);for(var b=0,c;c=a[b];b++){var d=c.getRowElement();if(d){var e=this.hasColours_?"8px solid "+(c.hexColour||"#ddd"):"none";this.workspace_.RTL?d.style.borderRight=e:d.style.borderLeft=e}this.addColour_(c)}};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};Blockly.Toolbox.prototype.addStyle=function(a){Blockly.utils.dom.addClass(this.HtmlDiv,a)};
|
||||
Blockly.Toolbox.prototype.removeStyle=function(a){Blockly.utils.dom.removeClass(this.HtmlDiv,a)};
|
||||
Blockly.Toolbox.prototype.getClientRect=function(){if(!this.HtmlDiv)return null;var a=this.HtmlDiv.getBoundingClientRect(),b=a.top,c=b+a.height,d=a.left;a=d+a.width;return this.toolboxPosition==Blockly.TOOLBOX_AT_TOP?new Blockly.utils.Rect(-1E7,c,-1E7,1E7):this.toolboxPosition==Blockly.TOOLBOX_AT_BOTTOM?new Blockly.utils.Rect(b,1E7,-1E7,1E7):this.toolboxPosition==Blockly.TOOLBOX_AT_LEFT?new Blockly.utils.Rect(-1E7,1E7,-1E7,a):new Blockly.utils.Rect(-1E7,1E7,d,1E7)};
|
||||
Blockly.Toolbox.prototype.refreshSelection=function(){var a=this.tree_.getSelectedItem();a&&a.blocks&&this.flyout_.show(a.blocks)};Blockly.Toolbox.TreeControl=function(a,b){this.toolbox_=a;goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,b)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);
|
||||
Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);if(Blockly.Touch.TOUCH_ENABLED){var a=this.getElement();Blockly.bindEventWithChecks_(a,goog.events.EventType.TOUCHEND,this,this.handleTouchEvent_)}};Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(a){var b=this.getNodeFromEvent_(a);b&&a.type===goog.events.EventType.TOUCHEND&&setTimeout(function(){b.onClick_(a)},1)};
|
||||
Blockly.Toolbox.TreeControl.prototype.createNode=function(a){a=a?goog.html.SafeHtml.htmlEscape(a):goog.html.SafeHtml.EMPTY;return new Blockly.Toolbox.TreeNode(this.toolbox_,a,this.getConfig())};
|
||||
Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(a){var b=this.toolbox_;if(a!=this.selectedItem_&&a!=b.tree_){b.lastCategory_&&(b.lastCategory_.getRowElement().style.backgroundColor="");if(a){var c=a.hexColour||"#57e";a.getRowElement().style.backgroundColor=c;b.addColour_(a)}c=this.getSelectedItem();goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,a);a&&a.blocks&&a.blocks.length?(b.flyout_.show(a.blocks),b.lastCategory_!=a&&b.flyout_.scrollToStart()):b.flyout_.hide();c!=
|
||||
a&&c!=this&&(c=new Blockly.Events.Ui(null,"category",c&&c.getHtml(),a&&a.getHtml()),c.workspaceId=b.workspace_.id,Blockly.Events.fire(c));a&&(b.lastCategory_=a)}};Blockly.Toolbox.TreeNode=function(a,b,c){goog.ui.tree.TreeNode.call(this,b,c);a&&(b=function(){Blockly.svgResize(a.workspace_)},goog.events.listen(a.tree_,goog.ui.tree.BaseNode.EventType.EXPAND,b),goog.events.listen(a.tree_,goog.ui.tree.BaseNode.EventType.COLLAPSE,b))};goog.inherits(Blockly.Toolbox.TreeNode,goog.ui.tree.TreeNode);
|
||||
Blockly.Toolbox.TreeNode.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.create("span")};Blockly.Toolbox.TreeNode.prototype.onClick_=function(a){this.hasChildren()&&this.isUserCollapsible_?(this.toggle(),this.select()):this.isSelected()?this.getTree().setSelectedItem(null):this.select();this.updateRow()};Blockly.Toolbox.TreeNode.prototype.onMouseDown=function(a){};Blockly.Toolbox.TreeNode.prototype.onDoubleClick_=function(a){};
|
||||
Blockly.Toolbox.TreeNode.prototype.onKeyDown=function(a){if(this.tree.toolbox_.horizontalLayout_){var b={},c=goog.events.KeyCodes.DOWN,d=goog.events.KeyCodes.UP;b[goog.events.KeyCodes.RIGHT]=this.rightToLeft_?d:c;b[goog.events.KeyCodes.LEFT]=this.rightToLeft_?c:d;b[goog.events.KeyCodes.UP]=goog.events.KeyCodes.LEFT;b[goog.events.KeyCodes.DOWN]=goog.events.KeyCodes.RIGHT;a.keyCode=b[a.keyCode]||a.keyCode}return Blockly.Toolbox.TreeNode.superClass_.onKeyDown.call(this,a)};
|
||||
Blockly.Toolbox.TreeSeparator=function(a){Blockly.Toolbox.TreeNode.call(this,null,goog.html.SafeHtml.EMPTY,a)};goog.inherits(Blockly.Toolbox.TreeSeparator,Blockly.Toolbox.TreeNode);Blockly.Css={};Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed",DELETE:"handdelete"};Blockly.Css.currentCursor_="";Blockly.Css.injected_=!1;Blockly.Css.mediaPath_="";
|
||||
Blockly.Toolbox.prototype.refreshSelection=function(){var a=this.tree_.getSelectedItem();a&&a.blocks&&this.flyout_.show(a.blocks)};Blockly.Toolbox.TreeSeparator=function(a){Blockly.tree.TreeNode.call(this,null,"",a)};goog.inherits(Blockly.Toolbox.TreeSeparator,Blockly.tree.TreeNode);Blockly.Css={};Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed",DELETE:"handdelete"};Blockly.Css.currentCursor_="";Blockly.Css.injected_=!1;Blockly.Css.mediaPath_="";
|
||||
Blockly.Css.inject=function(a,b){if(!Blockly.Css.injected_){Blockly.Css.injected_=!0;var c=".blocklyDraggable {}\n";a&&(c+=Blockly.Css.CONTENT.join("\n"),Blockly.Css.CONTENT=null,Blockly.FieldDate&&(c+=Blockly.FieldDate.CSS.join("\n")));Blockly.Css.mediaPath_=b.replace(/[\\\/]$/,"");c=c.replace(/<<<PATH>>>/g,Blockly.Css.mediaPath_);var d=document.createElement("style");c=document.createTextNode(c);d.appendChild(c);document.head.insertBefore(d,document.head.firstChild)}};Blockly.Css.setCursor=function(a){console.warn("Deprecated call to Blockly.Css.setCursor. See https://github.com/google/blockly/issues/981 for context")};
|
||||
Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;","overflow: hidden;","position: absolute;","display: block;","}",".blocklyWidgetDiv {","display: none;","position: absolute;","z-index: 99999;","}",".injectionDiv {","height: 100%;","position: relative;","overflow: hidden;","touch-action: none","}",".blocklyNonSelectable {","user-select: none;","-moz-user-select: none;","-ms-user-select: none;","-webkit-user-select: none;","}",".blocklyWsDragSurface {","display: none;",
|
||||
"position: absolute;","top: 0;","left: 0;","}",".blocklyWsDragSurface.blocklyOverflowVisible {","overflow: visible;","}",".blocklyBlockDragSurface {","display: none;","position: absolute;","top: 0;","left: 0;","right: 0;","bottom: 0;","overflow: visible !important;","z-index: 50;","}",".blocklyBlockCanvas.blocklyCanvasTransitioning,",".blocklyBubbleCanvas.blocklyCanvasTransitioning {","transition: transform .5s;","}",".blocklyTooltipDiv {","background-color: #ffffc7;","border: 1px solid #ddc;","box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);",
|
||||
@@ -1980,13 +1905,15 @@ Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.o
|
||||
Blockly.WidgetDiv.positionInternal_=function(a,b,c){Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c+"px"};Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.calculateY_(a,b,c);a=Blockly.WidgetDiv.calculateX_(a,b,c,d);0>e?Blockly.WidgetDiv.positionInternal_(a,0,c.height+e):Blockly.WidgetDiv.positionInternal_(a,e,c.height)};
|
||||
Blockly.WidgetDiv.calculateX_=function(a,b,c,d){if(d)return b=Math.max(b.right-c.width,a.left),Math.min(b,a.right-c.width);b=Math.min(b.left,a.right-c.width);return Math.max(b,a.left)};Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.inject=function(a,b){Blockly.checkBlockColourConstants();"string"==typeof a&&(a=document.getElementById(a)||document.querySelector(a));if(!Blockly.utils.dom.containsNode(document,a))throw Error("Error: container is not in current document.");var c=new Blockly.Options(b||{}),d=document.createElement("div");d.className="injectionDiv";a.appendChild(d);var e=Blockly.createDom_(d,c),f=new Blockly.BlockDragSurfaceSvg(d);d=new Blockly.WorkspaceDragSurfaceSvg(d);e=Blockly.createMainWorkspace_(e,c,
|
||||
f,d);Blockly.setTheme(c.theme);Blockly.user.keyMap.setKeyMap(c.keyMap);Blockly.init_(e);Blockly.mainWorkspace=e;Blockly.svgResize(e);return e};
|
||||
Blockly.createDom_=function(a,b){a.setAttribute("dir","LTR");goog.ui.Component.setDefaultRightToLeft(b.RTL);Blockly.Css.inject(b.hasCss,b.pathToMedia);var c=Blockly.utils.dom.createSvgElement("svg",{xmlns:Blockly.utils.dom.SVG_NS,"xmlns:html":Blockly.utils.dom.HTML_NS,"xmlns:xlink":Blockly.utils.dom.XLINK_NS,version:"1.1","class":"blocklySvg"},a),d=Blockly.utils.dom.createSvgElement("defs",{},c),e=String(Math.random()).substring(2),f=Blockly.utils.dom.createSvgElement("filter",{id:"blocklyEmbossFilter"+
|
||||
e},d);Blockly.utils.dom.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:1,result:"blur"},f);var g=Blockly.utils.dom.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},f);Blockly.utils.dom.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},g);Blockly.utils.dom.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},f);Blockly.utils.dom.createSvgElement("feComposite",
|
||||
{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},f);b.embossFilterId=f.id;f=Blockly.utils.dom.createSvgElement("pattern",{id:"blocklyDisabledPattern"+e,patternUnits:"userSpaceOnUse",width:10,height:10},d);Blockly.utils.dom.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},f);Blockly.utils.dom.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},f);b.disabledPatternId=f.id;b.gridPattern=Blockly.Grid.createDom(e,b.gridOptions,d);return c};
|
||||
Blockly.createMainWorkspace_=function(a,b,c,d){b.parentWorkspace=null;var e=new Blockly.WorkspaceSvg(b,c,d);e.scale=b.zoomOptions.startScale;a.appendChild(e.createDom("blocklyMainBackground"));!b.hasCategories&&b.languageTree&&(c=e.addFlyout_("svg"),Blockly.utils.dom.insertAfter(c,a));b.hasTrashcan&&e.addTrashcan();b.zoomOptions&&b.zoomOptions.controls&&e.addZoomControls();Blockly.Navigation.setCursor(e.cursor);Blockly.Navigation.setMarker(e.marker);e.translate(0,0);Blockly.mainWorkspace=e;b.readOnly||
|
||||
e.isMovable()||e.addChangeListener(function(a){if(!e.isDragging()&&!e.isMovable()&&-1!=Blockly.Events.BUMP_EVENTS.indexOf(a.type)){var b=Object.create(null),c=e.getMetrics(),d=e.scale;b.viewLeft=c.viewLeft/d;b.viewTop=c.viewTop/d;b.viewRight=(c.viewLeft+c.viewWidth)/d;b.viewBottom=(c.viewTop+c.viewHeight)/d;e.isContentBounded()?(c=e.getBlocksBoundingBox(),b.contentLeft=c.left,b.contentTop=c.top,b.contentRight=c.right,b.contentBottom=c.bottom):(b.contentLeft=c.contentLeft/d,b.contentTop=c.contentTop/
|
||||
d,b.contentRight=(c.contentLeft+c.contentWidth)/d,b.contentBottom=(c.contentTop+c.contentHeight)/d);if(b.contentTop<b.viewTop||b.contentBottom>b.viewBottom||b.contentLeft<b.viewLeft||b.contentRight>b.viewRight){c=null;a&&(c=Blockly.Events.getGroup(),Blockly.Events.setGroup(a.group));switch(a.type){case Blockly.Events.BLOCK_CREATE:case Blockly.Events.BLOCK_MOVE:var f=e.getBlockById(a.blockId);f=f.getRootBlock();break;case Blockly.Events.COMMENT_CREATE:case Blockly.Events.COMMENT_MOVE:f=e.getCommentById(a.commentId)}if(f){d=
|
||||
f.getBoundingRectangle();var n=b.viewTop-d.top;0<n&&f.moveBy(0,n);n=b.viewBottom-d.bottom;0>n&&f.moveBy(0,n);n=b.viewLeft-d.left;0<n&&f.moveBy(n,0);b=b.viewRight-d.right;0>b&&f.moveBy(b,0)}a&&(a.group||console.log("WARNING: Moved object in bounds but there was no event group. This may break undo."),Blockly.Events.setGroup(c))}}});Blockly.svgResize(e);Blockly.WidgetDiv.createDom();Blockly.DropDownDiv.createDom();Blockly.Tooltip.createDom();return e};
|
||||
Blockly.createDom_=function(a,b){a.setAttribute("dir","LTR");goog.ui.Component.setDefaultRightToLeft(b.RTL);Blockly.Component.setDefaultRightToLeft(b.RTL);Blockly.Css.inject(b.hasCss,b.pathToMedia);var c=Blockly.utils.dom.createSvgElement("svg",{xmlns:Blockly.utils.dom.SVG_NS,"xmlns:html":Blockly.utils.dom.HTML_NS,"xmlns:xlink":Blockly.utils.dom.XLINK_NS,version:"1.1","class":"blocklySvg"},a),d=Blockly.utils.dom.createSvgElement("defs",{},c),e=String(Math.random()).substring(2),f=Blockly.utils.dom.createSvgElement("filter",
|
||||
{id:"blocklyEmbossFilter"+e},d);Blockly.utils.dom.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:1,result:"blur"},f);var g=Blockly.utils.dom.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},f);Blockly.utils.dom.createSvgElement("fePointLight",{x:-5E3,y:-1E4,z:2E4},g);Blockly.utils.dom.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},
|
||||
f);Blockly.utils.dom.createSvgElement("feComposite",{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},f);b.embossFilterId=f.id;f=Blockly.utils.dom.createSvgElement("pattern",{id:"blocklyDisabledPattern"+e,patternUnits:"userSpaceOnUse",width:10,height:10},d);Blockly.utils.dom.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},f);Blockly.utils.dom.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},f);b.disabledPatternId=f.id;b.gridPattern=Blockly.Grid.createDom(e,
|
||||
b.gridOptions,d);return c};
|
||||
Blockly.createMainWorkspace_=function(a,b,c,d){b.parentWorkspace=null;var e=new Blockly.WorkspaceSvg(b,c,d);e.scale=b.zoomOptions.startScale;a.appendChild(e.createDom("blocklyMainBackground"));!b.hasCategories&&b.languageTree&&(c=e.addFlyout_("svg"),Blockly.utils.dom.insertAfter(c,a));b.hasTrashcan&&e.addTrashcan();b.zoomOptions&&b.zoomOptions.controls&&e.addZoomControls();Blockly.navigation.setCursor(e.cursor);Blockly.navigation.setMarker(e.marker);e.translate(0,0);Blockly.mainWorkspace=e;b.readOnly||
|
||||
e.isMovable()||e.addChangeListener(function(a){if(!e.isDragging()&&!e.isMovable()&&-1!=Blockly.Events.BUMP_EVENTS.indexOf(a.type)){var b=Object.create(null),c=e.getMetrics(),d=e.scale;b.RTL=e.RTL;b.viewLeft=c.viewLeft/d;b.viewTop=c.viewTop/d;b.viewRight=(c.viewLeft+c.viewWidth)/d;b.viewBottom=(c.viewTop+c.viewHeight)/d;e.isContentBounded()?(c=e.getBlocksBoundingBox(),b.contentLeft=c.left,b.contentTop=c.top,b.contentRight=c.right,b.contentBottom=c.bottom):(b.contentLeft=c.contentLeft/d,b.contentTop=
|
||||
c.contentTop/d,b.contentRight=(c.contentLeft+c.contentWidth)/d,b.contentBottom=(c.contentTop+c.contentHeight)/d);if(b.contentTop<b.viewTop||b.contentBottom>b.viewBottom||b.contentLeft<b.viewLeft||b.contentRight>b.viewRight){c=null;a&&(c=Blockly.Events.getGroup(),Blockly.Events.setGroup(a.group));switch(a.type){case Blockly.Events.BLOCK_CREATE:case Blockly.Events.BLOCK_MOVE:var f=e.getBlockById(a.blockId);f=f.getRootBlock();break;case Blockly.Events.COMMENT_CREATE:case Blockly.Events.COMMENT_MOVE:f=
|
||||
e.getCommentById(a.commentId)}if(f){d=f.getBoundingRectangle();d.height=d.bottom-d.top;d.width=d.right-d.left;var n=b.viewTop,m=b.viewBottom-d.height;m=Math.max(n,m);n=Blockly.utils.math.clamp(n,d.top,m)-d.top;m=b.viewLeft;var p=b.viewRight-d.width;b.RTL?m=Math.min(p,m):p=Math.max(m,p);b=Blockly.utils.math.clamp(m,d.left,p)-d.left;f.moveBy(b,n)}a&&(a.group||console.log("WARNING: Moved object in bounds but there was no event group. This may break undo."),Blockly.Events.setGroup(c))}}});Blockly.svgResize(e);
|
||||
Blockly.WidgetDiv.createDom();Blockly.DropDownDiv.createDom();Blockly.Tooltip.createDom();return e};
|
||||
Blockly.init_=function(a){var b=a.options,c=a.getParentSvg();Blockly.bindEventWithChecks_(c.parentNode,"contextmenu",null,function(a){Blockly.utils.isTargetInput(a)||a.preventDefault()});c=Blockly.bindEventWithChecks_(window,"resize",null,function(){Blockly.hideChaff(!0);Blockly.svgResize(a)});a.setResizeHandlerWrapper(c);Blockly.inject.bindDocumentEvents_();b.languageTree&&(a.toolbox_?a.toolbox_.init(a):a.flyout_&&(a.flyout_.init(a),a.flyout_.show(b.languageTree.childNodes),a.flyout_.scrollToStart()));
|
||||
c=Blockly.Scrollbar.scrollbarThickness;b.hasTrashcan&&(c=a.trashcan.init(c));b.zoomOptions&&b.zoomOptions.controls&&a.zoomControls_.init(c);b.moveOptions&&b.moveOptions.scrollbars?(a.scrollbar=new Blockly.ScrollbarPair(a),a.scrollbar.resize()):a.setMetrics({x:.5,y:.5});b.hasSounds&&Blockly.inject.loadSounds_(b.pathToMedia,a)};
|
||||
Blockly.inject.bindDocumentEvents_=function(){Blockly.documentEventsBound_||(Blockly.bindEventWithChecks_(document,"scroll",null,function(){for(var a=Blockly.Workspace.getAll(),b=0,c;c=a[b];b++)c.updateInverseScreenCTM&&c.updateInverseScreenCTM()}),Blockly.bindEventWithChecks_(document,"keydown",null,Blockly.onKeyDown_),Blockly.bindEvent_(document,"touchend",null,Blockly.longStop_),Blockly.bindEvent_(document,"touchcancel",null,Blockly.longStop_),Blockly.utils.userAgent.IPAD&&Blockly.bindEventWithChecks_(window,
|
||||
@@ -1994,9 +1921,9 @@ Blockly.inject.bindDocumentEvents_=function(){Blockly.documentEventsBound_||(Blo
|
||||
Blockly.inject.loadSounds_=function(a,b){var c=b.getAudioManager();c.load([a+"click.mp3",a+"click.wav",a+"click.ogg"],"click");c.load([a+"disconnect.wav",a+"disconnect.mp3",a+"disconnect.ogg"],"disconnect");c.load([a+"delete.mp3",a+"delete.ogg",a+"delete.wav"],"delete");var d=[],e=function(){for(;d.length;)Blockly.unbindEvent_(d.pop());c.preload()};d.push(Blockly.bindEventWithChecks_(document,"mousemove",null,e,!0));d.push(Blockly.bindEventWithChecks_(document,"touchstart",null,e,!0))};
|
||||
Blockly.updateToolbox=function(a){console.warn("Deprecated call to Blockly.updateToolbox, use workspace.updateToolbox instead.");Blockly.getMainWorkspace().updateToolbox(a)};var CLOSURE_DEFINES={"goog.DEBUG":!1};Blockly.VERSION="2.20190722.0-develop";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.cursor=null;Blockly.keyboardAccessibilityMode=!1;Blockly.draggingConnections_=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.theme_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()};
|
||||
Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth;c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}};
|
||||
Blockly.onKeyDown_=function(a){var b=Blockly.mainWorkspace;if(!(b.options.readOnly||Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible())){var c=!1;if(27==a.keyCode)Blockly.hideChaff(),Blockly.keyboardAccessibilityMode&&Blockly.Navigation.navigate(a);else if(8==a.keyCode||46==a.keyCode){a.preventDefault();if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&
|
||||
Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(67==a.keyCode?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):88!=a.keyCode||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));86==a.keyCode?Blockly.clipboardXml_&&(a=Blockly.clipboardSource_,a.isFlyout&&(a=a.targetWorkspace),Blockly.clipboardTypeCounts_&&a.isCapacityAvailable(Blockly.clipboardTypeCounts_)&&(Blockly.Events.setGroup(!0),a.paste(Blockly.clipboardXml_),Blockly.Events.setGroup(!1))):90==a.keyCode&&
|
||||
(Blockly.hideChaff(),b.undo(a.shiftKey))}else if(Blockly.keyboardAccessibilityMode&&Blockly.Navigation.navigate(a))return;c&&!Blockly.selected.workspace.isFlyout&&(Blockly.Events.setGroup(!0),Blockly.hideChaff(),Blockly.selected.dispose(!0,!0),Blockly.Events.setGroup(!1))}};
|
||||
Blockly.onKeyDown_=function(a){var b=Blockly.mainWorkspace;if(!(b.options.readOnly||Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible())){var c=!1;if(27==a.keyCode){if(Blockly.hideChaff(),Blockly.keyboardAccessibilityMode)Blockly.navigation.onKeyPress(a)}else if(8==a.keyCode||46==a.keyCode){a.preventDefault();if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&
|
||||
Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(67==a.keyCode?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):88!=a.keyCode||Blockly.selected.workspace.isFlyout||(Blockly.copy_(Blockly.selected),c=!0));if(86==a.keyCode)Blockly.clipboardXml_&&(a=Blockly.clipboardSource_,a.isFlyout&&(a=a.targetWorkspace),Blockly.clipboardTypeCounts_&&a.isCapacityAvailable(Blockly.clipboardTypeCounts_)&&(Blockly.Events.setGroup(!0),a.paste(Blockly.clipboardXml_),Blockly.Events.setGroup(!1)));else if(90==
|
||||
a.keyCode)Blockly.hideChaff(),b.undo(a.shiftKey);else if(Blockly.keyboardAccessibilityMode&&Blockly.navigation.onKeyPress(a))return}else if(Blockly.keyboardAccessibilityMode&&Blockly.navigation.onKeyPress(a))return;c&&!Blockly.selected.workspace.isFlyout&&(Blockly.Events.setGroup(!0),Blockly.hideChaff(),Blockly.selected.dispose(!0,!0),Blockly.Events.setGroup(!1))}};
|
||||
Blockly.copy_=function(a){if(a.isComment)var b=a.toXmlWithXY();else{b=Blockly.Xml.blockToDom(a,!0);Blockly.Xml.deleteNext(b);var c=a.getRelativeToSurfaceXY();b.setAttribute("x",a.RTL?-c.x:c.x);b.setAttribute("y",c.y)}Blockly.clipboardXml_=b;Blockly.clipboardSource_=a.workspace;Blockly.clipboardTypeCounts_=a.isComment?null:Blockly.utils.getBlockTypeCounts(a,!0)};
|
||||
Blockly.duplicate_=function(a){var b=Blockly.clipboardXml_,c=Blockly.clipboardSource_;Blockly.copy_(a);a.workspace.paste(Blockly.clipboardXml_);Blockly.clipboardXml_=b;Blockly.clipboardSource_=c};Blockly.onContextMenu_=function(a){Blockly.utils.isTargetInput(a)||a.preventDefault()};
|
||||
Blockly.hideChaff=function(a){Blockly.Tooltip.hide();Blockly.WidgetDiv.hide();Blockly.DropDownDiv.hideWithoutAnimation();var b=Blockly.getMainWorkspace();b.trashcan&&b.trashcan.flyout_&&b.trashcan.flyout_.hide();a||b.toolbox_&&b.toolbox_.flyout_&&b.toolbox_.flyout_.autoClose&&b.toolbox_.clearSelection()};Blockly.addChangeListener=function(a){console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead.");return Blockly.getMainWorkspace().addChangeListener(a)};
|
||||
|
||||
+21
-21
File diff suppressed because one or more lines are too long
@@ -1210,6 +1210,9 @@ Blockly.tree.BaseNode.prototype.getPreviousShownNode = function() {
|
||||
}
|
||||
var parent = this.getParent();
|
||||
var tree = this.getTree();
|
||||
if (parent == tree) {
|
||||
return null;
|
||||
}
|
||||
// The root is the first node.
|
||||
if (this == tree) {
|
||||
return null;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
goog.provide('Blockly.inject');
|
||||
|
||||
goog.require('Blockly.BlockDragSurfaceSvg');
|
||||
goog.require('Blockly.Component');
|
||||
goog.require('Blockly.Css');
|
||||
goog.require('Blockly.DropDownDiv');
|
||||
goog.require('Blockly.Events');
|
||||
@@ -96,8 +97,11 @@ Blockly.createDom_ = function(container, options) {
|
||||
// out content in RTL mode. Therefore Blockly forces the use of LTR,
|
||||
// then manually positions content in RTL as needed.
|
||||
container.setAttribute('dir', 'LTR');
|
||||
// TODO(samelh): Remove this once we no longer need goog.ui.Component
|
||||
// Closure can be trusted to create HTML widgets with the proper direction.
|
||||
goog.ui.Component.setDefaultRightToLeft(options.RTL);
|
||||
// Set the default direction for Components to use.
|
||||
Blockly.Component.setDefaultRightToLeft(options.RTL);
|
||||
|
||||
// Load CSS.
|
||||
Blockly.Css.inject(options.hasCss, options.pathToMedia);
|
||||
|
||||
@@ -41,7 +41,7 @@ Blockly.navigation.marker_ = null;
|
||||
/**
|
||||
* The current selected category if the toolbox is open or
|
||||
* last selected category if focus is on a different element.
|
||||
* @type {goog.ui.tree.BaseNode}
|
||||
* @type {Blockly.tree.BaseNode}
|
||||
* @private
|
||||
*/
|
||||
Blockly.navigation.currentCategory_ = null;
|
||||
@@ -225,10 +225,10 @@ Blockly.navigation.outCategory = function() {
|
||||
} else {
|
||||
var parent = curCategory.getParent();
|
||||
var tree = curCategory.getTree();
|
||||
if (parent && (tree.getShowRootNode() || parent != tree)) {
|
||||
if (parent && parent != tree) {
|
||||
parent.select();
|
||||
|
||||
Blockly.navigation.currentCategory_ = /** @type {goog.ui.tree.BaseNode} */
|
||||
Blockly.navigation.currentCategory_ = /** @type {Blockly.tree.BaseNode} */
|
||||
(parent);
|
||||
}
|
||||
}
|
||||
|
||||
+89
-227
@@ -31,19 +31,15 @@ goog.require('Blockly.Events.Ui');
|
||||
goog.require('Blockly.Flyout');
|
||||
goog.require('Blockly.HorizontalFlyout');
|
||||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.tree.TreeControl');
|
||||
goog.require('Blockly.tree.TreeNode');
|
||||
goog.require('Blockly.utils');
|
||||
goog.require('Blockly.utils.aria');
|
||||
goog.require('Blockly.utils.colour');
|
||||
goog.require('Blockly.utils.dom');
|
||||
goog.require('Blockly.utils.Rect');
|
||||
goog.require('Blockly.VerticalFlyout');
|
||||
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.html.SafeHtml');
|
||||
goog.require('goog.ui.tree.BaseNode');
|
||||
goog.require('goog.ui.tree.TreeControl');
|
||||
goog.require('goog.ui.tree.TreeNode');
|
||||
|
||||
|
||||
/**
|
||||
* Class for a Toolbox.
|
||||
@@ -141,7 +137,7 @@ Blockly.Toolbox.prototype.selectedOption_ = null;
|
||||
|
||||
/**
|
||||
* The tree node most recently selected.
|
||||
* @type {goog.ui.tree.BaseNode}
|
||||
* @type {Blockly.tree.BaseNode}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.prototype.lastCategory_ = null;
|
||||
@@ -200,12 +196,11 @@ Blockly.Toolbox.prototype.init = function() {
|
||||
this.config_['cleardotPath'] = workspace.options.pathToMedia + '1x1.gif';
|
||||
this.config_['cssCollapsedFolderIcon'] =
|
||||
'blocklyTreeIconClosed' + (workspace.RTL ? 'Rtl' : 'Ltr');
|
||||
var tree = new Blockly.Toolbox.TreeControl(this, this.config_);
|
||||
var tree = new Blockly.tree.TreeControl(this, this.config_);
|
||||
this.tree_ = tree;
|
||||
tree.setShowRootNode(false);
|
||||
tree.setShowLines(false);
|
||||
tree.setShowExpandIcons(false);
|
||||
tree.setSelectedItem(null);
|
||||
tree.onBeforeSelected(this.handleBeforeTreeSelected_);
|
||||
tree.onAfterSelected(this.handleAfterTreeSelected_);
|
||||
var openNode = this.populate_(workspace.options.languageTree);
|
||||
tree.render(this.HtmlDiv);
|
||||
if (openNode) {
|
||||
@@ -213,6 +208,74 @@ Blockly.Toolbox.prototype.init = function() {
|
||||
}
|
||||
this.addColour_();
|
||||
this.position();
|
||||
|
||||
// Trees have an implicit orientation of vertical, so we only need to set this
|
||||
// when the toolbox is in horizontal mode.
|
||||
if (this.horizontalLayout_) {
|
||||
Blockly.utils.aria.setState(this.tree_.getElement(),
|
||||
Blockly.utils.aria.State.ORIENTATION, 'horizontal');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the before tree item selected action.
|
||||
* @param {Blockly.tree.BaseNode} node The newly selected node.
|
||||
* @returns {boolean} Whether or not to cancel selecting the node.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.prototype.handleBeforeTreeSelected_ = function(node) {
|
||||
if (node == this.tree_) {
|
||||
return false;
|
||||
}
|
||||
if (this.lastCategory_) {
|
||||
this.lastCategory_.getRowElement().style.backgroundColor = '';
|
||||
}
|
||||
if (node) {
|
||||
var hexColour = node.hexColour || '#57e';
|
||||
node.getRowElement().style.backgroundColor = hexColour;
|
||||
// Add colours to child nodes which may have been collapsed and thus
|
||||
// not rendered.
|
||||
this.addColour_(node);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the after tree item selected action.
|
||||
* @param {Blockly.tree.BaseNode} oldNode The previously selected node.
|
||||
* @param {Blockly.tree.BaseNode} newNode The newly selected node.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.prototype.handleAfterTreeSelected_ = function(oldNode, newNode) {
|
||||
if (newNode && newNode.blocks && newNode.blocks.length) {
|
||||
this.flyout_.show(newNode.blocks);
|
||||
// Scroll the flyout to the top if the category has changed.
|
||||
if (this.lastCategory_ != newNode) {
|
||||
this.flyout_.scrollToStart();
|
||||
}
|
||||
} else {
|
||||
// Hide the flyout.
|
||||
this.flyout_.hide();
|
||||
}
|
||||
if (oldNode != newNode && oldNode != this) {
|
||||
var event = new Blockly.Events.Ui(null, 'category',
|
||||
oldNode && oldNode.getText(), newNode && newNode.getText());
|
||||
event.workspaceId = this.workspace_.id;
|
||||
Blockly.Events.fire(event);
|
||||
}
|
||||
if (newNode) {
|
||||
this.lastCategory_ = newNode;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle a node sized changed event.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.prototype.handleNodeSizeChanged_ = function() {
|
||||
// Even though the div hasn't changed size, the visible workspace
|
||||
// surface of the workspace has, so we may need to reposition everything.
|
||||
Blockly.svgResize(this.workspace_);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -301,8 +364,8 @@ Blockly.Toolbox.prototype.populate_ = function(newTree) {
|
||||
/**
|
||||
* Sync trees of the toolbox.
|
||||
* @param {!Node} treeIn DOM tree of blocks.
|
||||
* @param {!Blockly.Toolbox.TreeControl} treeOut The TreeContorol object built
|
||||
* from treeIn.
|
||||
* @param {!Blockly.tree.BaseNode} treeOut The TreeControl or TreeNode
|
||||
* object built from treeIn.
|
||||
* @param {string} pathToMedia The path to the Blockly media directory.
|
||||
* @return {Node} Tree node to open at startup (or null).
|
||||
* @private
|
||||
@@ -322,6 +385,7 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) {
|
||||
var categoryName = Blockly.utils.replaceMessageReferences(
|
||||
childIn.getAttribute('name'));
|
||||
var childOut = this.tree_.createNode(categoryName);
|
||||
childOut.onSizeChanged(this.handleNodeSizeChanged_);
|
||||
childOut.blocks = [];
|
||||
treeOut.add(childOut);
|
||||
var custom = childIn.getAttribute('custom');
|
||||
@@ -385,7 +449,7 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) {
|
||||
* Sets the colour on the category.
|
||||
* @param {number|string} colourValue HSV hue value (0 to 360), #RRGGBB string,
|
||||
* or a message reference string pointing to one of those two values.
|
||||
* @param {Blockly.Toolbox.TreeNode} childOut The child to set the hexColour on.
|
||||
* @param {Blockly.tree.TreeNode} childOut The child to set the hexColour on.
|
||||
* @param {string} categoryName Name of the toolbox category.
|
||||
* @private
|
||||
*/
|
||||
@@ -420,7 +484,7 @@ Blockly.Toolbox.prototype.setColour_ = function(colourValue, childOut,
|
||||
* Retrieves and sets the colour for the category using the style name.
|
||||
* The category colour is set from the colour style attribute.
|
||||
* @param {string} styleName Name of the style.
|
||||
* @param {!Blockly.Toolbox.TreeNode} childOut The child to set the hexColour on.
|
||||
* @param {!Blockly.tree.TreeNode} childOut The child to set the hexColour on.
|
||||
* @param {string} categoryName Name of the toolbox category.
|
||||
*/
|
||||
Blockly.Toolbox.prototype.setColourFromStyle_ = function(
|
||||
@@ -439,7 +503,7 @@ Blockly.Toolbox.prototype.setColourFromStyle_ = function(
|
||||
|
||||
/**
|
||||
* Recursively updates all the category colours using the category style name.
|
||||
* @param {Blockly.Toolbox.TreeNode=} opt_tree Starting point of tree.
|
||||
* @param {Blockly.tree.BaseNode=} opt_tree Starting point of tree.
|
||||
* Defaults to the root node.
|
||||
* @private
|
||||
*/
|
||||
@@ -470,23 +534,23 @@ Blockly.Toolbox.prototype.updateColourFromTheme = function() {
|
||||
|
||||
/**
|
||||
* Updates the background colour of the selected category.
|
||||
* @param {!Blockly.Toolbox.TreeNode} tree Starting point of tree.
|
||||
* @param {!Blockly.tree.BaseNode} tree Starting point of tree.
|
||||
* Defaults to the root node.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.prototype.updateSelectedItemColour_ = function(tree) {
|
||||
var selectedItem = tree.selectedItem_;
|
||||
var selectedItem = tree.getSelectedItem();
|
||||
if (selectedItem) {
|
||||
var hexColour = selectedItem.hexColour || '#57e';
|
||||
selectedItem.getRowElement().style.backgroundColor = hexColour;
|
||||
tree.toolbox_.addColour_(selectedItem);
|
||||
this.addColour_(selectedItem);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Recursively add colours to this toolbox.
|
||||
* @param {Blockly.Toolbox.TreeNode=} opt_tree Starting point of tree.
|
||||
* @param {Blockly.tree.BaseNode=} opt_tree Starting point of tree.
|
||||
* Defaults to the root node.
|
||||
* @private
|
||||
*/
|
||||
@@ -581,215 +645,13 @@ Blockly.Toolbox.prototype.refreshSelection = function() {
|
||||
}
|
||||
};
|
||||
|
||||
// Extending Closure's Tree UI.
|
||||
|
||||
/**
|
||||
* Extension of a TreeControl object that uses a custom tree node.
|
||||
* @param {Blockly.Toolbox} toolbox The parent toolbox for this tree.
|
||||
* @param {Object} config The configuration for the tree. See
|
||||
* goog.ui.tree.TreeControl.DefaultConfig.
|
||||
* @constructor
|
||||
* @extends {goog.ui.tree.TreeControl}
|
||||
*/
|
||||
Blockly.Toolbox.TreeControl = function(toolbox, config) {
|
||||
this.toolbox_ = toolbox;
|
||||
goog.ui.tree.TreeControl.call(this, goog.html.SafeHtml.EMPTY, config);
|
||||
};
|
||||
goog.inherits(Blockly.Toolbox.TreeControl, goog.ui.tree.TreeControl);
|
||||
|
||||
/**
|
||||
* Adds touch handling to TreeControl.
|
||||
* @override
|
||||
*/
|
||||
Blockly.Toolbox.TreeControl.prototype.enterDocument = function() {
|
||||
Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);
|
||||
|
||||
// Add touch handler.
|
||||
if (Blockly.Touch.TOUCH_ENABLED) {
|
||||
var el = this.getElement();
|
||||
Blockly.bindEventWithChecks_(el, goog.events.EventType.TOUCHEND, this,
|
||||
this.handleTouchEvent_);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles touch events.
|
||||
* @param {!goog.events.BrowserEvent} e The browser event.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_ = function(e) {
|
||||
var node = this.getNodeFromEvent_(e);
|
||||
if (node && e.type === goog.events.EventType.TOUCHEND) {
|
||||
// Fire asynchronously since onMouseDown takes long enough that the browser
|
||||
// would fire the default mouse event before this method returns.
|
||||
setTimeout(function() {
|
||||
node.onClick_(e); // Same behaviour for click and touch.
|
||||
}, 1);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new tree node using a custom tree node.
|
||||
* @param {string=} opt_html The HTML content of the node label.
|
||||
* @return {!goog.ui.tree.TreeNode} The new item.
|
||||
* @override
|
||||
*/
|
||||
Blockly.Toolbox.TreeControl.prototype.createNode = function(opt_html) {
|
||||
var html = opt_html ?
|
||||
goog.html.SafeHtml.htmlEscape(opt_html) : goog.html.SafeHtml.EMPTY;
|
||||
return new Blockly.Toolbox.TreeNode(this.toolbox_, html, this.getConfig());
|
||||
};
|
||||
|
||||
/**
|
||||
* Display/hide the flyout when an item is selected.
|
||||
* @param {goog.ui.tree.BaseNode} node The item to select.
|
||||
* @override
|
||||
*/
|
||||
Blockly.Toolbox.TreeControl.prototype.setSelectedItem = function(node) {
|
||||
var toolbox = this.toolbox_;
|
||||
if (node == this.selectedItem_ || node == toolbox.tree_) {
|
||||
return;
|
||||
}
|
||||
if (toolbox.lastCategory_) {
|
||||
toolbox.lastCategory_.getRowElement().style.backgroundColor = '';
|
||||
}
|
||||
if (node) {
|
||||
var hexColour = node.hexColour || '#57e';
|
||||
node.getRowElement().style.backgroundColor = hexColour;
|
||||
// Add colours to child nodes which may have been collapsed and thus
|
||||
// not rendered.
|
||||
toolbox.addColour_(node);
|
||||
}
|
||||
var oldNode = this.getSelectedItem();
|
||||
goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this, node);
|
||||
if (node && node.blocks && node.blocks.length) {
|
||||
toolbox.flyout_.show(node.blocks);
|
||||
// Scroll the flyout to the top if the category has changed.
|
||||
if (toolbox.lastCategory_ != node) {
|
||||
toolbox.flyout_.scrollToStart();
|
||||
}
|
||||
} else {
|
||||
// Hide the flyout.
|
||||
toolbox.flyout_.hide();
|
||||
}
|
||||
if (oldNode != node && oldNode != this) {
|
||||
var event = new Blockly.Events.Ui(null, 'category',
|
||||
oldNode && oldNode.getHtml(), node && node.getHtml());
|
||||
event.workspaceId = toolbox.workspace_.id;
|
||||
Blockly.Events.fire(event);
|
||||
}
|
||||
if (node) {
|
||||
toolbox.lastCategory_ = node;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A single node in the tree, customized for Blockly's UI.
|
||||
* @param {Blockly.Toolbox} toolbox The parent toolbox for this tree.
|
||||
* @param {!goog.html.SafeHtml} html The HTML content of the node label.
|
||||
* @param {Object|undefined} config The configuration for the tree.
|
||||
* See goog.ui.tree.TreeControl.DefaultConfig.
|
||||
* If not specified, a default config will be used.
|
||||
* @constructor
|
||||
* @extends {goog.ui.tree.TreeNode}
|
||||
*/
|
||||
Blockly.Toolbox.TreeNode = function(toolbox, html, config) {
|
||||
goog.ui.tree.TreeNode.call(this, html, config);
|
||||
if (toolbox) {
|
||||
var resize = function() {
|
||||
// Even though the div hasn't changed size, the visible workspace
|
||||
// surface of the workspace has, so we may need to reposition everything.
|
||||
Blockly.svgResize(toolbox.workspace_);
|
||||
};
|
||||
// Fire a resize event since the toolbox may have changed width.
|
||||
goog.events.listen(toolbox.tree_,
|
||||
goog.ui.tree.BaseNode.EventType.EXPAND, resize);
|
||||
goog.events.listen(toolbox.tree_,
|
||||
goog.ui.tree.BaseNode.EventType.COLLAPSE, resize);
|
||||
}
|
||||
};
|
||||
goog.inherits(Blockly.Toolbox.TreeNode, goog.ui.tree.TreeNode);
|
||||
|
||||
/**
|
||||
* Suppress population of the +/- icon.
|
||||
* @return {!goog.html.SafeHtml} The source for the icon.
|
||||
* @override
|
||||
*/
|
||||
Blockly.Toolbox.TreeNode.prototype.getExpandIconSafeHtml = function() {
|
||||
return goog.html.SafeHtml.create('span');
|
||||
};
|
||||
|
||||
/**
|
||||
* Expand or collapse the node on mouse click.
|
||||
* @param {!goog.events.BrowserEvent} _e The browser event.
|
||||
* @override
|
||||
*/
|
||||
Blockly.Toolbox.TreeNode.prototype.onClick_ = function(_e) {
|
||||
// Expand icon.
|
||||
if (this.hasChildren() && this.isUserCollapsible_) {
|
||||
this.toggle();
|
||||
this.select();
|
||||
} else if (this.isSelected()) {
|
||||
this.getTree().setSelectedItem(null);
|
||||
} else {
|
||||
this.select();
|
||||
}
|
||||
this.updateRow();
|
||||
};
|
||||
|
||||
/**
|
||||
* Suppress the inherited mouse down behaviour.
|
||||
* @param {!goog.events.BrowserEvent} _e The browser event.
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.TreeNode.prototype.onMouseDown = function(_e) {
|
||||
// NOPE.
|
||||
};
|
||||
|
||||
/**
|
||||
* Suppress the inherited double-click behaviour.
|
||||
* @param {!goog.events.BrowserEvent} _e The browser event.
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.TreeNode.prototype.onDoubleClick_ = function(_e) {
|
||||
// NOP.
|
||||
};
|
||||
|
||||
/**
|
||||
* Remap event.keyCode in horizontalLayout so that arrow
|
||||
* keys work properly and call original onKeyDown handler.
|
||||
* @param {!goog.events.BrowserEvent} e The browser event.
|
||||
* @return {boolean} The handled value.
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
Blockly.Toolbox.TreeNode.prototype.onKeyDown = function(e) {
|
||||
if (this.tree.toolbox_.horizontalLayout_) {
|
||||
var map = {};
|
||||
var next = goog.events.KeyCodes.DOWN;
|
||||
var prev = goog.events.KeyCodes.UP;
|
||||
map[goog.events.KeyCodes.RIGHT] = this.rightToLeft_ ? prev : next;
|
||||
map[goog.events.KeyCodes.LEFT] = this.rightToLeft_ ? next : prev;
|
||||
map[goog.events.KeyCodes.UP] = goog.events.KeyCodes.LEFT;
|
||||
map[goog.events.KeyCodes.DOWN] = goog.events.KeyCodes.RIGHT;
|
||||
|
||||
var newKeyCode = map[e.keyCode];
|
||||
e.keyCode = newKeyCode || e.keyCode;
|
||||
}
|
||||
return Blockly.Toolbox.TreeNode.superClass_.onKeyDown.call(this, e);
|
||||
};
|
||||
|
||||
/**
|
||||
* A blank separator node in the tree.
|
||||
* @param {Object|undefined} config The configuration for the tree.
|
||||
* See goog.ui.tree.TreeControl.DefaultConfig
|
||||
* If not specified, a default config will be used.
|
||||
* @param {Blockly.tree.BaseNode.Config} config The configuration for the tree.
|
||||
* @constructor
|
||||
* @extends {Blockly.Toolbox.TreeNode}
|
||||
* @extends {Blockly.tree.TreeNode}
|
||||
*/
|
||||
Blockly.Toolbox.TreeSeparator = function(config) {
|
||||
Blockly.Toolbox.TreeNode.call(this, null, goog.html.SafeHtml.EMPTY, config);
|
||||
Blockly.tree.TreeNode.call(this, null, '', config);
|
||||
};
|
||||
goog.inherits(Blockly.Toolbox.TreeSeparator, Blockly.Toolbox.TreeNode);
|
||||
goog.inherits(Blockly.Toolbox.TreeSeparator, Blockly.tree.TreeNode);
|
||||
|
||||
+6
-63
@@ -31,12 +31,6 @@ gulp.rename = require('gulp-rename');
|
||||
gulp.insert = require('gulp-insert');
|
||||
gulp.umd = require('gulp-umd');
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var rimraf = require('rimraf');
|
||||
var execSync = require('child_process').execSync;
|
||||
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var rimraf = require('rimraf');
|
||||
@@ -135,6 +129,9 @@ gulp.task('typings', function (cb) {
|
||||
const tmpDir = './typings/tmp';
|
||||
const blocklySrcs = [
|
||||
"core/",
|
||||
"core/components",
|
||||
"core/components/tree",
|
||||
"core/keyboard_nav",
|
||||
"core/theme",
|
||||
"core/utils",
|
||||
"msg/"
|
||||
@@ -166,6 +163,9 @@ gulp.task('typings', function (cb) {
|
||||
'typings/parts/blockly-interfaces.d.ts',
|
||||
'typings/parts/goog-closure.d.ts',
|
||||
`${tmpDir}/core/**`,
|
||||
`${tmpDir}/core/components/**`,
|
||||
`${tmpDir}/core/components/tree/**`,
|
||||
`${tmpDir}/core/keyboard_nav/**`,
|
||||
`${tmpDir}/core/utils/**`,
|
||||
`${tmpDir}/core/theme/**`,
|
||||
`${tmpDir}/msg/**`
|
||||
@@ -562,63 +562,6 @@ gulp.task('release', gulp.series(['build', /*'typings',*/ function() {
|
||||
fs.mkdirSync(packageDistribution);
|
||||
}, 'package']));
|
||||
|
||||
// Generates the TypeScript definition file (d.ts) for Blockly.
|
||||
// As well as generating the typings of each of the files under core/ and msg/,
|
||||
// the script also pulls in a number of part files from typings/parts.
|
||||
// This includes the header (incl License), additional useful interfaces
|
||||
// including Blockly Options and Google Closure typings
|
||||
gulp.task('typings', function (cb) {
|
||||
const tmpDir = './typings/tmp';
|
||||
const blocklySrcs = [
|
||||
"core/",
|
||||
"core/keyboard_nav",
|
||||
"core/theme",
|
||||
"core/utils",
|
||||
"msg/"
|
||||
];
|
||||
// Clean directory if exists
|
||||
if (fs.existsSync(tmpDir)) {
|
||||
rimraf.sync(tmpDir);
|
||||
}
|
||||
fs.mkdirSync(tmpDir);
|
||||
|
||||
// Find all files that will be included in the typings file
|
||||
let files = [];
|
||||
blocklySrcs.forEach((src) => {
|
||||
files = files.concat(fs.readdirSync(src)
|
||||
.filter(fn => fn.endsWith('.js'))
|
||||
.map(fn => path.join(src, fn)));
|
||||
});
|
||||
|
||||
// Generate typings file for each file
|
||||
files.forEach((file) => {
|
||||
const typescriptFileName = `${path.join(tmpDir, file)}.d.ts`;
|
||||
const cmd = `node ./node_modules/typescript-closure-tools/definition-generator/src/main.js ${file} ${typescriptFileName}`;
|
||||
console.log(`Generating typings for ${file}`);
|
||||
execSync(cmd, { stdio: 'inherit' });
|
||||
});
|
||||
|
||||
const srcs = [
|
||||
'typings/parts/blockly-header.d.ts',
|
||||
'typings/parts/blockly-interfaces.d.ts',
|
||||
'typings/parts/goog-closure.d.ts',
|
||||
`${tmpDir}/core/**`,
|
||||
`${tmpDir}/core/utils/**`,
|
||||
`${tmpDir}/core/theme/**`,
|
||||
`${tmpDir}/core/keyboard_nav/**`,
|
||||
`${tmpDir}/msg/**`
|
||||
];
|
||||
return gulp.src(srcs)
|
||||
.pipe(gulp.concat('blockly.d.ts'))
|
||||
.pipe(gulp.dest('typings'))
|
||||
.on('end', function () {
|
||||
// Clean up tmp directory
|
||||
if (fs.existsSync(tmpDir)) {
|
||||
rimraf.sync(tmpDir);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// The default task concatenates files for Node.js, using English language
|
||||
// blocks and the JavaScript generator.
|
||||
gulp.task('default', gulp.series(['build', 'blockly_node_javascript_en']));
|
||||
|
||||
Vendored
+1407
-80
File diff suppressed because it is too large
Load Diff
Vendored
-9
@@ -83,15 +83,6 @@ declare namespace goog {
|
||||
}
|
||||
}
|
||||
|
||||
namespace ui.tree {
|
||||
class BaseNode {
|
||||
}
|
||||
class TreeControl__Class {
|
||||
}
|
||||
class TreeNode__Class {
|
||||
}
|
||||
}
|
||||
|
||||
namespace events {
|
||||
function listen(eventSource: Element | Listenable, eventType: EventType, listener: any, capturePhase?: boolean, handler?: Object): void;
|
||||
function unlistenByKey(key: any): void;
|
||||
|
||||
Reference in New Issue
Block a user