From b697daa59739e86657ab5b5a83782f75428ec31d Mon Sep 17 00:00:00 2001 From: vivid Date: Wed, 25 May 2016 14:39:10 +0900 Subject: [PATCH] force dropdown position once --- dist/entry.css | 2 ++ dist/entry.js | 30 ++++++---------- dist/entry.min.js | 8 ++--- src/css/components/block.less | 2 ++ src/workspace/field/dropdown.js | 47 ++++++++++++-------------- src/workspace/field/dropdownDynamic.js | 2 -- 6 files changed, 41 insertions(+), 50 deletions(-) diff --git a/dist/entry.css b/dist/entry.css index dd4847c281..e232e2c627 100644 --- a/dist/entry.css +++ b/dist/entry.css @@ -601,6 +601,8 @@ svg .svgBlockGroup text { color: #000; z-index: 1001; overflow: auto; + left: 0; + top: 0; } .entry-widget-dropdown .rect { height: 20px; diff --git a/dist/entry.js b/dist/entry.js index 46affece3c..43997ebd4a 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -16841,27 +16841,21 @@ Entry.Utils.inherit(Entry.Field, Entry.FieldDropdown); }); })(h, f); } - this._position(!0); - this.optionGroup.css("width", this.optionGroup.width() + 3); this._position(); }; - b._position = function(a) { - if (a) { - a = {x:0, y:0}; + b._position = function() { + var a = this.getAbsolutePosFromDocument(); + a.y += this.box.height / 2; + var b = $(document).height(), d = this.optionGroup.height(); + if (b < a.y + d) { + a.x += this.box.width + 1; + var b = this.getAbsolutePosFromBoard(), e = this._blockView.getBoard().svgDom.height(), e = e - (e - b.y); + e - 20 < d && this.optionGroup.height(e - e % 20); + a.y -= this.optionGroup.height(); } else { - a = this.getAbsolutePosFromDocument(); - a.y += this.box.height / 2; - var b = $(document).height(), d = this.optionGroup.height(); - if (b < a.y + d) { - a.x += this.box.width + 1; - var b = this.getAbsolutePosFromBoard(), e = this._blockView.getBoard().svgDom.height(), e = e - (e - b.y); - e - 20 < d && this.optionGroup.height(e - e % 20); - a.y -= this.optionGroup.height(); - } else { - a.x += this.box.width / 2 - this.optionGroup.width() / 2; - } + a.x += this.box.width / 2 - this.optionGroup.width() / 2; } - this.optionGroup.css({left:a.x, top:a.y}); + this.optionGroup.css({left:a.x, top:a.y, width:this.optionGroup.width() + 3}); }; b.applyValue = function(a) { this.value != a && this.setValue(a); @@ -16933,8 +16927,6 @@ Entry.Utils.inherit(Entry.FieldDropdown, Entry.FieldDropdownDynamic); }); })(g, e); } - this._position(!0); - this.optionGroup.css("width", this.optionGroup.width() + 3); this._position(); }; })(Entry.FieldDropdownDynamic.prototype); diff --git a/dist/entry.min.js b/dist/entry.min.js index 03bdaaf324..15eb112ae7 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -1946,12 +1946,12 @@ Entry.FieldColor.getWidgetColorList=function(){return["#FFFFFF #CCCCCC #C0C0C0 # (function(b){b.renderStart=function(){this.svgGroup&&$(this.svgGroup).remove();this instanceof Entry.FieldDropdownDynamic&&this._updateValue();var a=this._blockView;this.svgGroup=a.contentSvgGroup.elem("g",{class:"entry-field-dropdown"});this.textElement=this.svgGroup.elem("text",{x:2});this.textElement.textContent=this.getTextByValue(this.getValue());var b=this.textElement.getBBox();this.textElement.attr({style:"white-space: pre; font-size:"+this._FONT_SIZE+"px",y:.25*b.height});b=this.textElement.getComputedTextLength()+ 16;this._noArrow&&(b-=12);var d=this._CONTENT_HEIGHT;this._header=this.svgGroup.elem("rect",{width:b,height:d,y:-d/2,rx:this._ROUND,ry:this._ROUND,fill:"#fff","fill-opacity":.4});this.svgGroup.appendChild(this.textElement);this._noArrow||(a=this._arrowColor||a._schema.color,this._arrow=this.svgGroup.elem("polygon",{points:"0,-2.1 6.4,-2.1 3.2,2.1",fill:a,stroke:a,transform:"translate("+(b-11)+",0)"}));this._bindRenderOptions();this.box.set({x:0,y:0,width:b,height:d})};b.resize=function(){var a=this.textElement.getComputedTextLength()+ 18;this._noArrow?a-=14:this._arrow.attr({transform:"translate("+(a-11)+",0)"});this._header.attr({width:a});this.box.set({width:a});this._block.view.alignContent()};b.renderOptions=function(){var a=this;this._attachDisposeEvent();this.optionGroup=Entry.Dom("ul",{class:"entry-widget-dropdown",parent:$("body")});this.optionGroup.bind("mousedown touchstart",function(a){a.stopPropagation()});for(var b=this._contents.options,b=this._contents.options,d=0,e=b.length;d