summaryrefslogtreecommitdiff
path: root/swat/style/qooxdoo/widgets/managers/QxSelectionManager.js
diff options
context:
space:
mode:
Diffstat (limited to 'swat/style/qooxdoo/widgets/managers/QxSelectionManager.js')
-rw-r--r--swat/style/qooxdoo/widgets/managers/QxSelectionManager.js2
1 files changed, 0 insertions, 2 deletions
diff --git a/swat/style/qooxdoo/widgets/managers/QxSelectionManager.js b/swat/style/qooxdoo/widgets/managers/QxSelectionManager.js
deleted file mode 100644
index 9432d471cd..0000000000
--- a/swat/style/qooxdoo/widgets/managers/QxSelectionManager.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/* 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)<cs.indexOf(vItem2);};proto.isEqual=function(vItem1,vItem2){return vItem1==vItem2;};proto.getItemHashCode=function(vItem){return vItem.toHash();};proto.scrollItemIntoView=function(vItem){vItem.scrollIntoView();};proto.getItemLeft=function(vItem){return vItem.getOffsetLeft();};proto.getItemTop=function(vItem){return vItem.getOffsetTop();};proto.getItemWidth=function(vItem){return vItem.getOffsetWidth();};proto.getItemHeight=function(vItem){return vItem.getOffsetHeight();};proto.getItemEnabled=function(vItem){return vItem.getEnabled();};proto.getItemClassName=function(vItem){return vItem.getCssClassName();};proto.setItemClassName=function(vItem,vClassName){return vItem.setCssClassName(vClassName);};proto.getItemBaseClassName=function(vItem){return vItem.classname;};proto._j3=function(vItem,vState,vIsState){var c=this.getItemClassName(vItem);var n=this.getItemBaseClassName(vItem)+"-"+vState;this.setItemClassName(vItem,vIsState?c.add(n," "):c.remove(n," "));};proto._j9=function(vItem,vIsSelected){this._j3(vItem,"Selected",vIsSelected);};proto.renderItemAnchorState=function(vItem,vIsAnchor){this._j3(vItem,"Anchor",vIsAnchor);};proto._j10=function(vItem,vIsLead){this._j3(vItem,"Lead",vIsLead);};proto.getItemSelected=function(vItem){return this._j5.contains(vItem);};proto.setItemSelected=function(vItem,vSelected){var hc=this.getItemHashCode(vItem);switch(this.getMultiSelection()){case true:if(!this.getItemEnabled(vItem)){return;};if(this.getItemSelected(vItem)==vSelected){return;};this._j9(vItem,vSelected);vSelected?this._j5.add(vItem):this._j5.remove(vItem);this._j1();break;case false:var item0=this.getSelectedItems()[0];if(vSelected){var old=item0;if(this.isEqual(vItem,old)){return;};if(old!=null){this._j9(old,false);};this._j9(vItem,true);this._j5.removeAll();this._j5.add(vItem);this._j1();}else {if(!this.isEqual(item0,vItem)){this._j9(vItem,false);this._j5.removeAll();this._j1();};};break;};};proto.getSelectedItems=function(){return this._j5.toArray();};proto.getSelectedItem=function(){return this._j5.getFirst();};proto.setSelectedItems=function(vItems){var oldVal=this._getChangeValue();var oldFireChange=this.getFireChange();this.setFireChange(false);this._j7();var vItem;var vItemLength=vItems.length;for(var i=0;i<vItemLength;i++){vItem=vItems[i];if(!this.getItemEnabled(vItem)){continue;};this._j5.add(vItem);this._j9(vItem,true);};this.setFireChange(oldFireChange);if(oldFireChange&&this._j8(oldVal)){this._j1();};};proto.setSelectedItem=function(vItem){if(!vItem){return;};if(!this.getItemEnabled(vItem)){return;};var oldVal=this._getChangeValue();var oldFireChange=this.getFireChange();this.setFireChange(false);this._j7();this._j5.add(vItem);this._j9(vItem,true);this.setFireChange(oldFireChange);if(oldFireChange&&this._j8(oldVal)){this._j1();};};proto.selectAll=function(){var oldVal=this._getChangeValue();var oldFireChange=this.getFireChange();this.setFireChange(false);this._selectAll();this.setFireChange(oldFireChange);if(oldFireChange&&this._j8(oldVal)){this._j1();};};proto._selectAll=function(){if(!this.getMultiSelection()){return;};var vItem;var vItems=this.getItems();var vItemsLength=vItems.length;this._j5.removeAll();for(var i=0;i<vItemsLength;i++){vItem=vItems[i];if(!this.getItemEnabled(vItem)){continue;};this._j5.add(vItem);this._j9(vItem,true);};return true;};proto.deselectAll=function(){var oldVal=this._getChangeValue();var oldFireChange=this.getFireChange();this.setFireChange(false);this._j7();this.setFireChange(oldFireChange);if(oldFireChange&&this._j8(oldVal))this._j1();};proto._j7=function(){var items=this._j5.toArray();for(var i=0;i<items.length;i++){this._j9(items[i],false);};this._j5.removeAll();return true;};proto.selectItemRange=function(vItem1,vItem2){var oldVal=this._getChangeValue();var oldFireChange=this.getFireChange();this.setFireChange(false);this._j2(vItem1,vItem2,true);this.setFireChange(oldFireChange);if(oldFireChange&&this._j8(oldVal)){this._j1();};};proto._j2=function(vItem1,vItem2,vDeselect){if(this.isBefore(vItem2,vItem1)){return this._j2(vItem2,vItem1,vDeselect);};if(vDeselect){this._j7();};var vCurrentItem=vItem1;while(vCurrentItem!=null){if(this.getItemEnabled(vCurrentItem)){this._j5.add(vCurrentItem);this._j9(vCurrentItem,true);};if(this.isEqual(vCurrentItem,vItem2)){break;};vCurrentItem=this.getNext(vCurrentItem);};return true;};proto._j6=function(vItem1,vItem2){if(this.isBefore(vItem2,vItem1)){return this._j6(vItem2,vItem1);};var vCurrentItem=vItem1;while(vCurrentItem!=null){this._j5.remove(vCurrentItem);this._j9(vCurrentItem,false);if(this.isEqual(vCurrentItem,vItem2)){break;};vCurrentItem=this.getNext(vCurrentItem);};};proto._j4=false;proto.handleMouseDown=function(vItem,e){if(e.isNotLeftButton()&&e.isNotRightButton()){return;};if(e.isRightButton()&&this.getItemSelected(vItem)){return;};if(e.getShiftKey()||this.getDragSelection()||(!this.getItemSelected(vItem)&&!e.getCtrlKey())){this._onmouseevent(vItem,e);}else {this.setLeadItem(vItem);};this._j4=this.getDragSelection();if(this._j4){this.getBoundedWidget().addEventListener("mouseup",this._ondragup,this);this.getBoundedWidget().setCapture(true);};};proto._ondragup=function(e){this.getBoundedWidget().removeEventListener("mouseup",this._ondragup,this);this.getBoundedWidget().setCapture(false);this._j4=false;};proto.handleMouseUp=function(vItem,e){if(e.isNotLeftButton()){return;};if(e.getCtrlKey()||this.getItemSelected(vItem)&&!this._j4){this._onmouseevent(vItem,e);};if(this._j4){this._j4=false;this.getBoundedWidget().setCapture(false);};};proto.handleMouseOver=function(oItem,e){if(! this.getDragSelection()||!this._j4){return;};this._onmouseevent(oItem,e,true);};proto.handleClick=function(vItem,e){};proto.handleDblClick=function(vItem,e){};proto._onmouseevent=function(oItem,e,bOver){if(!this.getItemEnabled(oItem)){return;};var oldVal=this._getChangeValue();var oldLead=this.getLeadItem();var oldFireChange=this.getFireChange();this.setFireChange(false);var selectedItems=this.getSelectedItems();var selectedCount=selectedItems.length;this.setLeadItem(oItem);var currentAnchorItem=this.getAnchorItem();var vCtrlKey=e.getCtrlKey();var vShiftKey=e.getShiftKey();if(!currentAnchorItem||selectedCount==0||(vCtrlKey&&!vShiftKey&&this.getMultiSelection()&&!this.getDragSelection())){this.setAnchorItem(oItem);currentAnchorItem=oItem;};if((!vCtrlKey&&!vShiftKey&&!this._j4||!this.getMultiSelection())){if(!this.getItemEnabled(oItem)){return;};this._j7();this.setAnchorItem(oItem);if(this._j4){this.scrollItemIntoView((this.getBoundedWidget().getScrollTop()>(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