⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guicomponents.js

📁 在流览器上仿CS界面的JAVASCRIPT脚本
💻 JS
📖 第 1 页 / 共 5 页
字号:
this._dispatchChange();};_p._dispatchChange=function(){if(!this._fireChange)return;this.dispatchEvent(new BiEvent("change"));};_p._hasChanged=function(sOldValue){return sOldValue!=this._getChangeValue();};_p._getChangeValue=function(){var sb=[];for(var hc in this._selectedItems)
sb.push(hc);sb.sort();return sb.join(",");};_p.dispose=function(){if(this._disposed)return;BiEventTarget.prototype.dispose.call(this);this._owner=null;for(var hc in this._selectedItems){delete this._selectedItems[hc];}};_p.getHome=function(oItem)
{return this.getFirst();};_p.getCtrlHome=function(oItem)
{return this.getFirst();};_p.getEnd=function(oItem)
{return this.getLast();};_p.getCtrlEnd=function(oItem)
{return this.getLast();};_p.getDown=function(oItem)
{return!oItem?this.getFirst():this.getNext(oItem);};_p.getUp=function(oItem)
{return!oItem?this.getLast():this.getPrevious(oItem);};_p.getLeft=function(oItem)
{return oItem;};_p.getRight=function(oItem)
{return oItem;};_p.getPageUp=function(oItem)
{var vpTop=this._owner.getScrollTop();var next;if(!this._leadItem)
next=this.getFirst();else next=this._leadItem;var tries=0;while(tries<2)
{while(next&&(this.getItemTop(next)-this.getItemHeight(next)>=vpTop))
next=this.getUp(next);if(next==null)
{tries=2;break;}
if(next!=this._leadItem)
break;this._owner.setScrollTop(vpTop-this._owner.getClientHeight()-this.getItemHeight(next));vpTop=this._owner.getScrollTop();tries++;}
return next;};_p.getPageDown=function(oItem)
{var vpTop=this._owner.getScrollTop();var vpHeight=this._owner.getClientHeight();var next;if(!this._leadItem)
next=this.getLast();else next=this._leadItem;var tries=0;while(tries<2){while(next&&(this.getItemTop(next)+2*this.getItemHeight(next)<=vpTop+vpHeight))
next=this.getDown(next);if(next==null){tries=2;break;}
if(next!=this._leadItem)
break;this._owner.setScrollTop(vpTop+vpHeight-2*this.getItemHeight(next));vpTop=this._owner.getScrollTop();tries++;}
return next;};_p.getItemToSelect=function(oKeyboardEvent){var e=oKeyboardEvent;if(e.getAltKey())
return null;switch(e.getKeyCode()){case BiKeyboardEvent.HOME:if(e.getCtrlKey())
return this.getCtrlHome(this._leadItem);return this.getHome(this._leadItem);case BiKeyboardEvent.END:if(e.getCtrlKey())
return this.getCtrlEnd(this._leadItem);return this.getEnd(this._leadItem);case BiKeyboardEvent.DOWN:return this.getDown(this._leadItem);case BiKeyboardEvent.UP:return this.getUp(this._leadItem);case BiKeyboardEvent.LEFT:return this.getLeft(this._leadItem);case BiKeyboardEvent.RIGHT:return this.getRight(this._leadItem);case BiKeyboardEvent.PAGE_UP:return this.getPageUp(this._leadItem);case BiKeyboardEvent.PAGE_DOWN:return this.getPageDown(this._leadItem);}
return null;};function BiList(){BiComponent.call(this);this.setCssClassName("bi-list");this.setTabIndex(1);this.setHideFocus(true);this._selectionModel=new BiListSelectionModel(this);this.addEventListener("mousedown",this._onmousevent);this.addEventListener("mouseup",this._onmousevent);this.addEventListener("click",this._onmousevent);this.addEventListener("dblclick",this._onmousevent);this.addEventListener("keydown",this._onkeydown);this.addEventListener("keypress",this._onKeyPress);this.addEventListener("focus",this._onfocuschange);this.addEventListener("blur",this._onfocuschange);this._selectionModel.addEventListener("change",function(e){this.dispatchEvent(new BiEvent("change"));if(this._command)
this._command.setUserValue(this.getUserValue());},this);}
var _p=BiList.prototype=new BiComponent;_p._className="BiList";_p._lastKeyPress=0;_p._accumulatedKeys="";_p.getSelectedItem=function(){return this.getSelectedItems()[0];};_p.getSelectedItems=function(){return this._selectionModel.getSelectedItems();};_p.getValue=_p.getUserValue=function(){var si=this.getSelectedItem();if(si)return si.getUserValue();return null;};_p.getValues=_p.getUserValues=function(){var sis=this.getSelectedItems();var l=sis.length;var res=new Array(l);for(var i=0;i<l;i++)
res[i]=sis[i].getUserValue();return res;};_p.setValue=_p.setUserValue=function(v)
{var item=this.findUserValueExact(v);if(item)
{this._selectionModel._deselectAll();item.setSelected(true);this._selectionModel.setAnchorItem(item);this._selectionModel.setLeadItem(item);}};BiList.prototype.getSelectionModel=function(){return this._selectionModel;};BiList.prototype.setSelectionModel=function(v){this._selectionModel=v;};_p.add=function(oChild,oBefore){var b=oChild.getSelected();BiComponent.prototype.add.call(this,oChild,oBefore);if(b)
{this._selectionModel.setItemSelected(oChild,false);this._selectionModel.setItemSelected(oChild,true);}};_p.remove=function(oChild){var b=oChild.getSelected();var sm=this._selectionModel;var next;if(sm._leadItem==oChild||sm._anchorItem==oChild)
{next=oChild.getNextSibling()||oChild.getPreviousSibling();if(sm._leadItem==oChild)
sm.setLeadItem(next);if(sm._anchorItem==oChild)
sm.setAnchorItem(next);}
BiComponent.prototype.remove.call(this,oChild);if(b)
{sm.setItemSelected(oChild,false);oChild.setSelected(true);}};_p.removeAll=function()
{var sm=this.getSelectionModel();sm.deselectAll();sm.setAnchorItem(null);sm.setLeadItem(null);var cs=this.getChildren();var l=cs.length;for(var i=0;i<l;i++)
{BiComponent.prototype.remove.call(this,cs[i]);cs[i].dispose();}};_p.setMultipleSelection=function(b){this._selectionModel.setMultipleSelection(b);};_p.getMultipleSelection=function(){return this._selectionModel.getMultipleSelection();};_p.findString=function(sText,nStartIndex){return this._findItem(sText,nStartIndex||0,"String");};_p.findStringExact=function(sText,nStartIndex){return this._findItem(sText,nStartIndex||0,"StringExact");};_p._findItem=function(oUserValue,nStartIndex,sType){var i;var items=this.getChildren();if(nStartIndex==null){var si=this.getSelectedItem();nStartIndex=items.indexOf(si);if(nStartIndex== -1)
nStartIndex=0;}
var methodName="matches"+sType;for(i=nStartIndex;i<items.length;i++){if(items[i][methodName](oUserValue))
return items[i];}
for(i=0;i<nStartIndex;i++){if(items[i][methodName](oUserValue))
return items[i];}
return null;};_p.findValueExact=_p.findUserValueExact=function(oUserValue,nStartIndex){var items=this.getChildren();if(isNaN(nStartIndex))
nStartIndex=0;for(var i=nStartIndex;i<items.length;i++){if(items[i].getUserValue()==oUserValue)
return items[i];}
return null;};_p._onmousevent=function(e){var item=e.getTarget();while(item!=null&&item.getParent()!=this)
item=item.getParent();if(item!=null){switch(e.getType()){case"mousedown":this._selectionModel.handleMouseDown(item,e);break;case"mouseup":this._selectionModel.handleMouseUp(item,e);break;case"click":this._selectionModel.handleClick(item,e);break;case"dblclick":this._selectionModel.handleDblClick(item,e);break;}}};_p._onfocuschange=function(e){var items=this.getSelectedItems();for(var i=0;i<items.length;i++)
items[i]._updateClassName();if(this._selectionModel._leadItem)
this._selectionModel._leadItem._updateClassName();};_p._onkeydown=function(e){var kc=e.getKeyCode();if(kc==BiKeyboardEvent.ENTER&&!e.getAltKey()){var items=this.getSelectedItems();for(var i=0;i<items.length;i++)
items[i]._dispatchAction();}
else this._selectionModel.handleKeyDown(e);};_p._onKeyPress=function(e){if(new Date-this._lastKeyPress>1000){this._accumulatedKeys="";}
this._accumulatedKeys+=String.fromCharCode(e.getKeyCode());var item=this._findItem(this._accumulatedKeys,null,"String");if(item){var oldVal=this._selectionModel._getChangeValue();var oldFireChange=this._selectionModel._fireChange;this._selectionModel._fireChange=false;this._selectionModel._deselectAll();this._selectionModel.setItemSelected(item,true);this._selectionModel.setAnchorItem(item);this._selectionModel.setLeadItem(item);item.scrollIntoView();this._selectionModel._fireChange=oldFireChange;if(this._selectionModel._fireChange&&this._selectionModel._hasChanged(oldVal))
this._selectionModel._dispatchChange();}
this._lastKeyPress=(new Date).valueOf();e.preventDefault();};_p.dispose=function()
{if(this._disposed)return;BiComponent.prototype.dispose.call(this);this._selectionModel.dispose();this._selectionModel=null;if(this._dataSource)
{this._dataSource.dispose();this._dataSource=null;}};_p._syncWithCommmand=function()
{if(this._command)
{this.setEnabled(this._command.getEnabled());this.setUserValue(this._command.getUserValue());}};function BiListItem(sText,oUserValue){BiLabel.call(this,sText);if(oUserValue!=null)this._userValue=oUserValue;this.setCssClassName("bi-list-item");this.addEventListener("dblclick",this._onDblClick);}
_p=BiListItem.prototype=new BiLabel;_p._className="BiListItem";_p._selected=false;_p._anchor=false;_p._lead=false;_p._userValue=null;_p.setSelected=function(bSelected){if(this._selected!=bSelected){var p;if((p=this.getParent())!=null){p._selectionModel.setItemSelected(this,bSelected);}
this._setSelected(bSelected);}};BiListItem.prototype.getSelected=function(){return this._selected;};BiListItem.prototype.getUserValue=function(){return this._userValue;};_p.setUserValue=function(v)
{if(this._userValue!=v)
{this._userValue=v;if(this._command)
this._command.setUserValue(v);}};_p.getValue=_p.getUserValue;_p.setValue=_p.setUserValue;_p._setSelected=function(bSelected){this._selected=bSelected;this._updateClassName();};_p._setAnchor=function(bAnchor){this._anchor=bAnchor;this._updateClassName();};_p._setLead=function(bLead){this._lead=bLead;this._updateClassName();};_p._updateClassName=function(){var f=this._parent&&this._parent.getFocused();this.setCssClassName("bi-list-item"+(this._selected&&f?" selected-focused":"")+(this._selected&&!f?" selected":"")+(this._lead&&f?" lead-focused":"")+(this._lead&&!f?" lead":"")+(this._anchor?" anchor":""));};_p.getIndex=function(){var p;if((p=this.getParent())!=null)
return p.getChildren().indexOf(this);return-1;};_p.matchesString=function(sText){return sText!=""&&this.getText().toLowerCase().indexOf(sText.toLowerCase())==0;};_p.matchesStringExact=function(sText){return sText!=""&&this.getText().toLowerCase()==String(sText).toLowerCase();};_p._onDblClick=function(e)
{var p=this.getParent();if(p&&p.getIsEnabled())
this._dispatchAction()};_p._dispatchAction=function()
{if(this.getIsEnabled())
{this.dispatchEvent(new BiEvent("action"));if(this._command)
this._command.execute();}};_p.dispose=function(){if(this._disposed)return;BiLabel.prototype.dispose.call(this);this._userValue=null;};_p._syncWithCommmand=function()
{if(this._command)
{this.setEnabled(this._command.getEnabled());this.setUserValue(this._command.getUserValue());}};function BiListSelectionModel(oList)
{BiSelectionModel.call(this,oList);};var _p=BiListSelectionModel.prototype=new BiSelectionModel;_p._className="BiListSelectionModel";_p.isBefore=function(oItem1,oItem2)
{return oItem1.getIndex()<oItem2.getIndex();};_p.getItemSelected=function(oItem)
{return oItem._selected;};_p.updateItemSelectionState=function(oItem,bSelected)
{oItem._setSelected(bSelected);};_p.updateItemAnchorState=function(oItem,bAnchor)
{oItem._setAnchor(bAnchor);};_p.updateItemLeadState=function(oItem,bLead)
{oItem._setLead(bLead);};function BiComboBox(oItems){BiComponent.call(this);this.setCssClassName("bi-combo-box");this.setSize(100,22);this.setHideFocus(true);this._popup=new BiPopup;this._popup._lazyCreate=true;this._popup.positionRelativeToComponent(this,"vertical");this._list=new BiList
this._list.setCssClassName("bi-combo-box-list");this._list.setTabIndex(-1);this._list.setMultipleSelection(false);this._list.setLocation(0,0);this._list.setRight(0);this._list.setBottom(0);this._button=new BiButton;this._button.setTabIndex(-1);this._button.setFont(new BiFont(1));this._button.setIcon(new BiImage(BiComboBox.BUTTON_IMAGE,7,4));this._button.setWidth(16);this._button.setTop(0);this._button.setBottom(0);this._label=new BiLabel;this._label.setTop(1);this._label.setBottom(1);this._textField=new BiTextField;this._textField.setTop(1);this._textField.setBottom(1);this._textField.setVisible(false);this._textField.setStyleProperty("display","none");this._positionComponents();this._label.setLabelFor(this._textField);BiComponent.prototype.add.call(this,this._popup,null,true);this._popup.add(this._list);BiComponent.prototype.add.call(this,this._label,null,true);BiComponent.prototype.add.call(this,this._button,null,true);BiComponent.prototype.add.call(this,this._textField,null,true);this.setTabIndex(1);this.addEventListener("mousedown",this._onMouseDown,this);this._popup.addEventListener("hide",this._onPopupHide,this);this._popup.addEventListener("show",this._onPopupShow,this);this._list.addEventListener("mouseup",this._onListMouseUp,this);this.addEventListener("keydown",this._onKeyDown,this);this.addEventListener("keypress",this._onKeyPress,this);this._textField.addEventListener("textchanged",this._onTextChanged,this);this.addEventListener("focus",this._onFocus,this);this.addEventListener("blur",this._onBlur,this);this._popup.setMaximumHeight(300);this._popup.getPreferredWidth=BiComboBox._popupPreferredWidth;this._popup.getPreferredHeight=BiComboBox._popupPreferredHeight;if(oItems){for(var i=0;i<oItems.length;i++)
this.add(new BiComboBoxItem(String(oItems[i])));}}
BiComboBox.BUTTON_IMAGE=application.getPath()+"images/arrow.down.gif";var _p=BiComboBox.prototype=new BiComponent;_p._className="BiComboBox";_p._selectedItem=null;_p._editable=false;_p._typedMatch=null;_p._acceptsEnter=true;_p._acceptsEsc=true;_p._invalidMessage="";_p._validator=null;BiComboBox.prototype.getPopup=function(){return this._popup;};BiComboBox.prototype.getTextField=function(){return this._textField;};BiComboBox._popupPreferredWidth=function(){if(this._preferredWidth)
return this._preferredWidth;return this._parent._getListPreferredWidth();};BiComboBox._popupPreferredHeight=function(){if(this._preferredHeight)
return this._preferredHeight;return Math.min(this.getMaximumHeight(),Math.max(20,this._parent._getListPreferredHeight()));};_p.add=function(oChild,oBefore,bAnonymous){this._list.add(oChild,oBefore,bAnonymous);if(oChild.getSelected())
this._updateSelected();};_p.remove=function(oChild){var b=oChild.getSelected();this._list.remove(oChild);if(b)this._updateSelected();};_p.removeAll=function()
{this._list.removeAll();this._updateSelected();};_p.getChildren=function(){return this._list.getChildren();};_p.hasChildren=function(){return this._list.hasChildren();};_p.getFirstChild=function(){return this._list.getFirstChild();};_p.getLastChild=function(){return this._list.getLastChild();};_p._ensurePopupAdded=functi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -