diff --git a/dist/entry.js b/dist/entry.js index 193897cd23..a804d402df 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -21962,7 +21962,12 @@ Entry.Field = function() { b.destroyOption = function() { this.documentDownEvent && (Entry.documentMousedown.detach(this.documentDownEvent), delete this.documentDownEvent); this.disposeEvent && (Entry.disposeEvent.detach(this.disposeEvent), delete this.documentDownEvent); - this.optionGroup && (this.optionGroup.remove(), delete this.optionGroup); + if (this.optionGroup) { + var a = this.optionGroup.blur; + a && Entry.Utils.isFunction(a) && this.optionGroup.blur(); + this.optionGroup.remove(); + delete this.optionGroup; + } this.command(); }; b._attachDisposeEvent = function(a) { diff --git a/dist/entry.min.js b/dist/entry.min.js index ac98cdd573..405ebbdad8 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -2493,12 +2493,12 @@ this.svgGroup.appendChild(a);this.updatePos();this.block.getThread().view.setHas fill:"#000000"});this.tspans=this.text.split("\n").map(function(a){var b=this.textElement.elem("tspan").attr({dy:"1.2em",x:"0","class":"extension sideTagTspan"});b.textContent=a;return b}.bind(this))};b.updatePos=function(){this.positionX=8*-(this.blockView.block.pointer().length-2);this.svgGroup.attr("transform","translate("+this.positionX+",0)");this.textElement.attr({y:this.height/2-12*(this.tspans.length-1)-2});var a=this.textElement.getBoundingClientRect();this.tspans.map(function(b){b.attr({x:-a.width- 14})})}})(Entry.ExtSideTag.prototype);Entry.Field=function(){}; (function(b){b.TEXT_LIMIT_LENGTH=20;b.destroy=function(){$(this.svgGroup).unbind("mouseup touchend");this.destroyOption()};b.command=function(){this._startValue&&(this._startValue===this.getValue()||this._blockView.isInBlockMenu||Entry.do("setFieldValue",this._block,this,this.pointer(),this._startValue,this.getValue()));delete this._startValue};b.destroyOption=function(){this.documentDownEvent&&(Entry.documentMousedown.detach(this.documentDownEvent),delete this.documentDownEvent);this.disposeEvent&& -(Entry.disposeEvent.detach(this.disposeEvent),delete this.documentDownEvent);this.optionGroup&&(this.optionGroup.remove(),delete this.optionGroup);this.command()};b._attachDisposeEvent=function(a){var b=this;b.disposeEvent=Entry.disposeEvent.attach(b,a||function(){b.destroyOption()})};b.align=function(a,b,c){var e=this.svgGroup;this._position&&(this._position.x&&(a=this._position.x),this._position.y&&(b=this._position.y));var f="translate("+a+","+b+")";void 0===c||c?e.animate({transform:f},300,mina.easeinout): -e.attr({transform:f});this.box.set({x:a,y:b})};b.getAbsolutePosFromBoard=function(){var a=this._block.view,b=a.getContentPos(),a=a.getAbsoluteCoordinate();return{x:a.x+this.box.x+b.x,y:a.y+this.box.y+b.y}};b.getAbsolutePosFromDocument=function(){var a=this._block.view,b=a.getContentPos(),c=a.getAbsoluteCoordinate(),a=a.getBoard().svgDom.offset();return{x:c.x+this.box.x+b.x+a.left,y:c.y+this.box.y+b.y+a.top}};b.getRelativePos=function(){var a=this._block.view.getContentPos(),b=this.box;return{x:b.x+ -a.x,y:b.y+a.y}};b.truncate=function(){var a=String(this.getValue()),b=this.TEXT_LIMIT_LENGTH,c=a.substring(0,b);a.length>b&&(c+="...");return c};b.appendSvgOptionGroup=function(){return this._block.view.getBoard().svgGroup.elem("g")};b.getValue=function(){var a=this._block.params[this._index];if(this._contents&&this._contents.reference&&this._contents.reference.length){var b=this._contents.reference.concat();"%"===b[0][0]&&(a=this._block.params[parseInt(b.shift().substr(1))-1]);return a?a.getDataByPointer(b): -a}return a};b.setValue=function(a,b){if(this.value!=a){this.value=a;if(this._contents&&this._contents.reference&&this._contents.reference.length){var c=this._contents.reference.concat(),e=c.pop(),f=this._block.params[this._index];c.length&&"%"===c[0][0]&&(f=this._block.params[parseInt(c.shift().substr(1))-1]);c.length&&(f=f.getDataByPointer(c));f.params[e]=a}else this._block.params[this._index]=a;b&&this._blockView.reDraw()}};b._isEditable=function(){if(Entry.ContextMenu.visible||this._block.view.dragMode== -Entry.DRAG_MODE_DRAG)return!1;var a=this._block.view,b=a.getBoard();if(!0===b.disableMouseEvent)return!1;var c=b.workspace.selectedBlockView;if(!c||b!=c.getBoard())return!1;b=a.getSvgRoot();return b==c.svgGroup||$(b).has($(a.svgGroup))};b._selectBlockView=function(){var a=this._block.view;a.getBoard().setSelectedBlock(a)};b._bindRenderOptions=function(){var a=this;$(this.svgGroup).bind("mouseup touchend",function(b){a._isEditable()&&(a.destroyOption(),a._startValue=a.getValue(),a.renderOptions())})}; -b.pointer=function(a){a=a||[];a.unshift(this._index);a.unshift(Entry.PARAM);return this._block.pointer(a)};b.getFontSize=function(a){return a=a||this._blockView.getSkeleton().fontSize||12};b.getContentHeight=function(){return Entry.isMobile()?22:16}})(Entry.Field.prototype);Entry.FieldAngle=function(b,a,d){this._block=a.block;this._blockView=a;this.box=new Entry.BoxModel;this.svgGroup=null;this.position=b.position;this._contents=b;this._index=d;b=this.getValue();this.setValue(this.modValue(void 0!==b?b:90));this._CONTENT_HEIGHT=this.getContentHeight();this.renderStart()};Entry.Utils.inherit(Entry.Field,Entry.FieldAngle); +(Entry.disposeEvent.detach(this.disposeEvent),delete this.documentDownEvent);if(this.optionGroup){var a=this.optionGroup.blur;a&&Entry.Utils.isFunction(a)&&this.optionGroup.blur();this.optionGroup.remove();delete this.optionGroup}this.command()};b._attachDisposeEvent=function(a){var b=this;b.disposeEvent=Entry.disposeEvent.attach(b,a||function(){b.destroyOption()})};b.align=function(a,b,c){var e=this.svgGroup;this._position&&(this._position.x&&(a=this._position.x),this._position.y&&(b=this._position.y)); +var f="translate("+a+","+b+")";void 0===c||c?e.animate({transform:f},300,mina.easeinout):e.attr({transform:f});this.box.set({x:a,y:b})};b.getAbsolutePosFromBoard=function(){var a=this._block.view,b=a.getContentPos(),a=a.getAbsoluteCoordinate();return{x:a.x+this.box.x+b.x,y:a.y+this.box.y+b.y}};b.getAbsolutePosFromDocument=function(){var a=this._block.view,b=a.getContentPos(),c=a.getAbsoluteCoordinate(),a=a.getBoard().svgDom.offset();return{x:c.x+this.box.x+b.x+a.left,y:c.y+this.box.y+b.y+a.top}}; +b.getRelativePos=function(){var a=this._block.view.getContentPos(),b=this.box;return{x:b.x+a.x,y:b.y+a.y}};b.truncate=function(){var a=String(this.getValue()),b=this.TEXT_LIMIT_LENGTH,c=a.substring(0,b);a.length>b&&(c+="...");return c};b.appendSvgOptionGroup=function(){return this._block.view.getBoard().svgGroup.elem("g")};b.getValue=function(){var a=this._block.params[this._index];if(this._contents&&this._contents.reference&&this._contents.reference.length){var b=this._contents.reference.concat(); +"%"===b[0][0]&&(a=this._block.params[parseInt(b.shift().substr(1))-1]);return a?a.getDataByPointer(b):a}return a};b.setValue=function(a,b){if(this.value!=a){this.value=a;if(this._contents&&this._contents.reference&&this._contents.reference.length){var c=this._contents.reference.concat(),e=c.pop(),f=this._block.params[this._index];c.length&&"%"===c[0][0]&&(f=this._block.params[parseInt(c.shift().substr(1))-1]);c.length&&(f=f.getDataByPointer(c));f.params[e]=a}else this._block.params[this._index]=a; +b&&this._blockView.reDraw()}};b._isEditable=function(){if(Entry.ContextMenu.visible||this._block.view.dragMode==Entry.DRAG_MODE_DRAG)return!1;var a=this._block.view,b=a.getBoard();if(!0===b.disableMouseEvent)return!1;var c=b.workspace.selectedBlockView;if(!c||b!=c.getBoard())return!1;b=a.getSvgRoot();return b==c.svgGroup||$(b).has($(a.svgGroup))};b._selectBlockView=function(){var a=this._block.view;a.getBoard().setSelectedBlock(a)};b._bindRenderOptions=function(){var a=this;$(this.svgGroup).bind("mouseup touchend", +function(b){a._isEditable()&&(a.destroyOption(),a._startValue=a.getValue(),a.renderOptions())})};b.pointer=function(a){a=a||[];a.unshift(this._index);a.unshift(Entry.PARAM);return this._block.pointer(a)};b.getFontSize=function(a){return a=a||this._blockView.getSkeleton().fontSize||12};b.getContentHeight=function(){return Entry.isMobile()?22:16}})(Entry.Field.prototype);Entry.FieldAngle=function(b,a,d){this._block=a.block;this._blockView=a;this.box=new Entry.BoxModel;this.svgGroup=null;this.position=b.position;this._contents=b;this._index=d;b=this.getValue();this.setValue(this.modValue(void 0!==b?b:90));this._CONTENT_HEIGHT=this.getContentHeight();this.renderStart()};Entry.Utils.inherit(Entry.Field,Entry.FieldAngle); (function(b){b.renderStart=function(){this.svgGroup&&$(this.svgGroup).remove();this.svgGroup=this._blockView.contentSvgGroup.elem("g",{class:"entry-input-field"});this.textElement=this.svgGroup.elem("text",{x:4,y:4,"font-size":"11px"});this.textElement.textContent=this.getText();var a=this.getTextWidth(),b=this._CONTENT_HEIGHT,c=this.position&&this.position.y?this.position.y:0;this._header=this.svgGroup.elem("rect",{x:0,y:c-b/2,rx:3,ry:3,width:a,height:b,rx:3,ry:3,fill:"#fff","fill-opacity":.4}); this.svgGroup.appendChild(this.textElement);this._bindRenderOptions();this.box.set({x:0,y:0,width:a,height:b})};b.renderOptions=function(){var a=this;this._attachDisposeEvent(function(){a.applyValue();a.destroyOption()});this.optionGroup=Entry.Dom("input",{class:"entry-widget-input-field",parent:$("body")});this.optionGroup.val(this.value);this.optionGroup.on("mousedown touchstart",function(a){a.stopPropagation()});this.optionGroup.on("keyup",function(b){var d=b.keyCode||b.which;a.applyValue(b);-1< [13,27].indexOf(d)&&a.destroyOption()});var b=this.getAbsolutePosFromDocument();b.y-=this.box.height/2;this.optionGroup.css({height:this._CONTENT_HEIGHT,left:b.x,top:b.y,width:a.box.width});this.svgOptionGroup=this.appendSvgOptionGroup();this.svgOptionGroup.elem("circle",{x:0,y:0,r:49,class:"entry-field-angle-circle"});$(this.svgOptionGroup).on("mousedown touchstart",function(b){b.stopPropagation();a._updateByCoord(b)});this._dividerGroup=this.svgOptionGroup.elem("g");for(b=0;360>b;b+=15)this._dividerGroup.elem("line", diff --git a/src/workspace/field/field.js b/src/workspace/field/field.js index b0265e2f73..11c37a516d 100644 --- a/src/workspace/field/field.js +++ b/src/workspace/field/field.js @@ -45,6 +45,9 @@ Entry.Field = function() {}; } if (this.optionGroup) { + var blur = this.optionGroup.blur; + if (blur && Entry.Utils.isFunction(blur)) + this.optionGroup.blur(); this.optionGroup.remove(); delete this.optionGroup; }