X-Git-Url: http://git.samba.org/samba.git/?p=gd%2Fsamba%2F.git;a=blobdiff_plain;f=swat2%2Fstyle%2Fqooxdoo%2Fwidgets%2Fmanagers%2FQxSelectionManager.js;fp=swat2%2Fstyle%2Fqooxdoo%2Fwidgets%2Fmanagers%2FQxSelectionManager.js;h=9432d471cda3d191edfccc99d585d6c463affdd3;hp=0000000000000000000000000000000000000000;hb=7e671ae37f6c951d4db18c446eed52685200b2e0;hpb=acf11ddd5fbb9e4b0b780f4f95957d79fcc6fcf1 diff --git a/swat2/style/qooxdoo/widgets/managers/QxSelectionManager.js b/swat2/style/qooxdoo/widgets/managers/QxSelectionManager.js new file mode 100644 index 00000000000..9432d471cda --- /dev/null +++ b/swat2/style/qooxdoo/widgets/managers/QxSelectionManager.js @@ -0,0 +1,2 @@ +/* Copyright (c): 2002-2005 (Germany): United Internet, 1&1, GMX, Schlund+Partner, Alturo */ +function QxSelectionManager(vBoundedWidget){QxTarget.call(this);this._j5=new QxSelectionStorage();if(isValid(vBoundedWidget)){this.setBoundedWidget(vBoundedWidget);};};QxSelectionManager.extend(QxManager,"QxSelectionManager");QxSelectionManager.addProperty({name:"boundedWidget",type:Object});QxSelectionManager.addProperty({name:"multiSelection",type:Boolean,defaultValue:true});QxSelectionManager.addProperty({name:"dragSelection",type:Boolean,defaultValue:true});QxSelectionManager.addProperty({name:"canDeselect",type:Boolean,defaultValue:true});QxSelectionManager.addProperty({name:"fireChange",type:Boolean,defaultValue:true});QxSelectionManager.addProperty({name:"anchorItem",type:Object});QxSelectionManager.addProperty({name:"leadItem",type:Object});QxSelectionManager.addProperty({name:"multiColumnSupport",type:Boolean,defaultValue:false});proto._modifyAnchorItem=function(_b1,_b2,_b3,_b4){if(_b2){this.renderItemAnchorState(_b2,false);};if(_b1){this.renderItemAnchorState(_b1,true);};return true;};proto._modifyLeadItem=function(_b1,_b2,_b3,_b4){if(_b2){this._j10(_b2,false);};if(_b1){this._j10(_b1,true);};return true;};proto.getFirst=function(){var vItem=this.getBoundedWidget().getFirstChild();return this.getItemEnabled(vItem)?vItem:this.getNext(vItem);};proto.getLast=function(){var vItem=this.getBoundedWidget().getLastChild();return this.getItemEnabled(vItem)?vItem:this.getPrevious(vItem);};proto.getItems=function(){return this.getBoundedWidget().getChildren();};proto.getNextSibling=function(vItem){return vItem.getNextSibling();};proto.getPreviousSibling=function(vItem){return vItem.getPreviousSibling();};proto.getNext=function(vItem){while(vItem){vItem=this.getNextSibling(vItem);if(!vItem){break;};if(this.getItemEnabled(vItem)){return vItem;};};return null;};proto.getPrevious=function(vItem){while(vItem){vItem=this.getPreviousSibling(vItem);if(!vItem){break;};if(this.getItemEnabled(vItem)){return vItem;};};return null;};proto.isBefore=function(vItem1,vItem2){var cs=this.getItems();return cs.indexOf(vItem1)(this.getItemTop(oItem)-1)?this.getPrevious(oItem):this.getNext(oItem))||oItem);};if(!this.getItemSelected(oItem)){this._j9(oItem,true);};this._j5.add(oItem);this._addToCurrentSelection=true;}else if(this._j4&&bOver){if(oldLead){this._j6(currentAnchorItem,oldLead);};if(this.isBefore(currentAnchorItem,oItem)){if(this._addToCurrentSelection){this._j2(currentAnchorItem,oItem,false);}else {this._j6(currentAnchorItem,oItem);};}else {if(this._addToCurrentSelection){this._j2(oItem,currentAnchorItem,false);}else {this._j6(oItem,currentAnchorItem);};};this.scrollItemIntoView((this.getBoundedWidget().getScrollTop()>(this.getItemTop(oItem)-1)?this.getPrevious(oItem):this.getNext(oItem))||oItem);}else if(this.getMultiSelection()&&vCtrlKey&&!vShiftKey){if(!this._j4){this._addToCurrentSelection=!(this.getCanDeselect()&&this.getItemSelected(oItem));};this.setItemSelected(oItem,this._addToCurrentSelection);this.setAnchorItem(oItem);}else if(this.getMultiSelection()&&vCtrlKey&&vShiftKey){if(!this._j4){this._addToCurrentSelection=!(this.getCanDeselect()&&this.getItemSelected(oItem));};if(this._addToCurrentSelection){this._j2(currentAnchorItem,oItem,false);}else {this._j6(currentAnchorItem,oItem);};}else if(this.getMultiSelection()&&!vCtrlKey&&vShiftKey){if(this.getCanDeselect()){this._j2(currentAnchorItem,oItem,true);}else {if(oldLead){this._j6(currentAnchorItem,oldLead);};this._j2(currentAnchorItem,oItem,false);};};this.setFireChange(oldFireChange);if(oldFireChange&&this._j8(oldVal)){this._j1();};};proto.handleKeyDown=function(e){var oldVal=this._getChangeValue();var oldFireChange=this.getFireChange();this.setFireChange(false);if(e.getKeyCode()==65&&e.getCtrlKey()){if(this.getMultiSelection()){this._selectAll();this.setLeadItem(this.getFirst());};}else {var aIndex=this.getAnchorItem();var itemToSelect=this.getItemToSelect(e);if(itemToSelect&&this.getItemEnabled(itemToSelect)){this.setLeadItem(itemToSelect);this.scrollItemIntoView(itemToSelect);if(e.getShiftKey()&&this.getMultiSelection()){if(aIndex==null){this.setAnchorItem(itemToSelect);};this._j2(this.getAnchorItem(),itemToSelect,true);}else if(!e.getCtrlKey()){this._j7();this._j9(itemToSelect,true);this._j5.add(itemToSelect);this.setAnchorItem(itemToSelect);};};};e.setPreventDefault(true);e.setPropagationStopped(true);this.setFireChange(oldFireChange);if(oldFireChange&&this._j8(oldVal)){this._j1();};};proto.getItemToSelect=function(oKeyboardEvent){var e=oKeyboardEvent;if(e.getAltKey()){return null;};switch(e.getKeyCode()){case QxKeyEvent.keys.home:return this.getHome(this.getLeadItem());case QxKeyEvent.keys.end:return this.getEnd(this.getLeadItem());case QxKeyEvent.keys.down:return this.getDown(this.getLeadItem());case QxKeyEvent.keys.up:return this.getUp(this.getLeadItem());case QxKeyEvent.keys.left:return this.getLeft(this.getLeadItem());case QxKeyEvent.keys.right:return this.getRight(this.getLeadItem());case QxKeyEvent.keys.pageup:return this.getPageUp(this.getLeadItem());case QxKeyEvent.keys.pagedown:return this.getPageDown(this.getLeadItem());};return null;};proto._j1=function(){if(!this.getFireChange()){return;};this.dispatchEvent(new QxDataEvent("changeSelection",this.getSelectedItems()));};proto._j8=function(sOldValue){return sOldValue!=this._getChangeValue();};proto._getChangeValue=function(){return this._j5.getChangeValue();};proto.getHome=function(){return this.getFirst();};proto.getEnd=function(){return this.getLast();};proto.getDown=function(vItem){if(!vItem){return this.getFirst();};return this.getMultiColumnSupport()?(this.getUnder(vItem)||this.getLast()):this.getNext(vItem);};proto.getUp=function(vItem){if(!vItem){return this.getLast();};return this.getMultiColumnSupport()?(this.getAbove(vItem)||this.getFirst()):this.getPrevious(vItem);};proto.getLeft=function(vItem){if(!this.getMultiColumnSupport()){return null;};return !vItem?this.getLast():this.getPrevious(vItem);};proto.getRight=function(vItem){if(!this.getMultiColumnSupport()){return null;};return !vItem?this.getFirst():this.getNext(vItem);};proto.getAbove=function(vItem){throw new Error("getAbove():Not implemented yet");};proto.getUnder=function(vItem){throw new Error("getUnder():Not implemented yet");};proto.getPageUp=function(vItem){var vBound=this.getBoundedWidget();var vParentScrollTop=vBound.getScrollTop();var newItem;var nextItem=this.getLeadItem();if(!nextItem){nextItem=this.getFirst();};var tryLoops=0;while(tryLoops<2){while(nextItem&&(this.getItemTop(nextItem)-this.getItemHeight(nextItem)>=vParentScrollTop)){newItem=this.getUp(nextItem);if(newItem==null){break;};nextItem=newItem;};if(nextItem==null){tryLoops=2;break;};if(nextItem!=this.getLeadItem()){break;};vBound.setScrollTop(vParentScrollTop-vBound.getClientHeight()-this.getItemHeight(nextItem));vParentScrollTop=vBound.getScrollTop();tryLoops++;};return nextItem;};proto.getPageDown=function(vItem){var vBound=this.getBoundedWidget();var vParentScrollTop=vBound.getScrollTop();var vParentClientHeight=vBound.getClientHeight();var newItem;var nextItem=this.getLeadItem();if(!nextItem){nextItem=this.getFirst();};var tryLoops=0;while(tryLoops<2){while(nextItem&&((this.getItemTop(nextItem)+(2*this.getItemHeight(nextItem)))<=(vParentScrollTop+vParentClientHeight))){newItem=this.getDown(nextItem);if(newItem==null){break;};nextItem=newItem;};if(nextItem==null){tryLoops=2;break;};if(nextItem!=this.getLeadItem()){break;};vBound.setScrollTop(vParentScrollTop+vParentClientHeight-(2*this.getItemHeight(nextItem)));vParentScrollTop=vBound.getScrollTop();tryLoops++;};return nextItem;};proto.dispose=function(){if(this.getDisposed()){return;};if(this._j5){this._j5.dispose();this._j5=null;};return QxTarget.prototype.dispose.call(this);}; \ No newline at end of file