How to use down method in lisa

Best Python code snippet using lisa_python

_HasDropDown.js.uncompressed.js

Source:_HasDropDown.js.uncompressed.js Github

copy

Full Screen

1define("dijit/_HasDropDown", [2 "dojo/_base/declare", // declare3 "dojo/_base/Deferred",4 "dojo/_base/event", // event.stop5 "dojo/dom", // dom.isDescendant6 "dojo/dom-attr", // domAttr.set7 "dojo/dom-class", // domClass.add domClass.contains domClass.remove8 "dojo/dom-geometry", // domGeometry.marginBox domGeometry.position9 "dojo/dom-style", // domStyle.set10 "dojo/has", // has("touch")11 "dojo/keys", // keys.DOWN_ARROW keys.ENTER keys.ESCAPE12 "dojo/_base/lang", // lang.hitch lang.isFunction13 "dojo/on",14 "dojo/window", // winUtils.getBox15 "./registry", // registry.byNode()16 "./focus",17 "./popup",18 "./_FocusMixin"19], function(declare, Deferred, event,dom, domAttr, domClass, domGeometry, domStyle, has, keys, lang, on,20 winUtils, registry, focus, popup, _FocusMixin){21 // module:22 // dijit/_HasDropDown23 return declare("dijit._HasDropDown", _FocusMixin, {24 // summary:25 // Mixin for widgets that need drop down ability.26 // _buttonNode: [protected] DomNode27 // The button/icon/node to click to display the drop down.28 // Can be set via a data-dojo-attach-point assignment.29 // If missing, then either focusNode or domNode (if focusNode is also missing) will be used.30 _buttonNode: null,31 // _arrowWrapperNode: [protected] DomNode32 // Will set CSS class dijitUpArrow, dijitDownArrow, dijitRightArrow etc. on this node depending33 // on where the drop down is set to be positioned.34 // Can be set via a data-dojo-attach-point assignment.35 // If missing, then _buttonNode will be used.36 _arrowWrapperNode: null,37 // _popupStateNode: [protected] DomNode38 // The node to set the popupActive class on.39 // Can be set via a data-dojo-attach-point assignment.40 // If missing, then focusNode or _buttonNode (if focusNode is missing) will be used.41 _popupStateNode: null,42 // _aroundNode: [protected] DomNode43 // The node to display the popup around.44 // Can be set via a data-dojo-attach-point assignment.45 // If missing, then domNode will be used.46 _aroundNode: null,47 // dropDown: [protected] Widget48 // The widget to display as a popup. This widget *must* be49 // defined before the startup function is called.50 dropDown: null,51 // autoWidth: [protected] Boolean52 // Set to true to make the drop down at least as wide as this53 // widget. Set to false if the drop down should just be its54 // default width55 autoWidth: true,56 // forceWidth: [protected] Boolean57 // Set to true to make the drop down exactly as wide as this58 // widget. Overrides autoWidth.59 forceWidth: false,60 // maxHeight: [protected] Integer61 // The max height for our dropdown.62 // Any dropdown taller than this will have scrollbars.63 // Set to 0 for no max height, or -1 to limit height to available space in viewport64 maxHeight: 0,65 // dropDownPosition: [const] String[]66 // This variable controls the position of the drop down.67 // It's an array of strings with the following values:68 //69 // - before: places drop down to the left of the target node/widget, or to the right in70 // the case of RTL scripts like Hebrew and Arabic71 // - after: places drop down to the right of the target node/widget, or to the left in72 // the case of RTL scripts like Hebrew and Arabic73 // - above: drop down goes above target node74 // - below: drop down goes below target node75 //76 // The list is positions is tried, in order, until a position is found where the drop down fits77 // within the viewport.78 //79 dropDownPosition: ["below","above"],80 // _stopClickEvents: Boolean81 // When set to false, the click events will not be stopped, in82 // case you want to use them in your subclass83 _stopClickEvents: true,84 _onDropDownMouseDown: function(/*Event*/ e){85 // summary:86 // Callback when the user mousedown's on the arrow icon87 if(this.disabled || this.readOnly){ return; }88 // Prevent default to stop things like text selection, but don't stop propagation, so that:89 // 1. TimeTextBox etc. can focus the <input> on mousedown90 // 2. dropDownButtonActive class applied by _CssStateMixin (on button depress)91 // 3. user defined onMouseDown handler fires92 e.preventDefault();93 this._docHandler = this.connect(this.ownerDocument, "mouseup", "_onDropDownMouseUp");94 this.toggleDropDown();95 },96 _onDropDownMouseUp: function(/*Event?*/ e){97 // summary:98 // Callback when the user lifts their mouse after mouse down on the arrow icon.99 // If the drop down is a simple menu and the mouse is over the menu, we execute it, otherwise, we focus our100 // drop down widget. If the event is missing, then we are not101 // a mouseup event.102 //103 // This is useful for the common mouse movement pattern104 // with native browser `<select>` nodes:105 //106 // 1. mouse down on the select node (probably on the arrow)107 // 2. move mouse to a menu item while holding down the mouse button108 // 3. mouse up. this selects the menu item as though the user had clicked it.109 if(e && this._docHandler){110 this.disconnect(this._docHandler);111 }112 var dropDown = this.dropDown, overMenu = false;113 if(e && this._opened){114 // This code deals with the corner-case when the drop down covers the original widget,115 // because it's so large. In that case mouse-up shouldn't select a value from the menu.116 // Find out if our target is somewhere in our dropdown widget,117 // but not over our _buttonNode (the clickable node)118 var c = domGeometry.position(this._buttonNode, true);119 if(!(e.pageX >= c.x && e.pageX <= c.x + c.w) ||120 !(e.pageY >= c.y && e.pageY <= c.y + c.h)){121 var t = e.target;122 while(t && !overMenu){123 if(domClass.contains(t, "dijitPopup")){124 overMenu = true;125 }else{126 t = t.parentNode;127 }128 }129 if(overMenu){130 t = e.target;131 if(dropDown.onItemClick){132 var menuItem;133 while(t && !(menuItem = registry.byNode(t))){134 t = t.parentNode;135 }136 if(menuItem && menuItem.onClick && menuItem.getParent){137 menuItem.getParent().onItemClick(menuItem, e);138 }139 }140 return;141 }142 }143 }144 if(this._opened){145 if(dropDown.focus && dropDown.autoFocus !== false){146 // Focus the dropdown widget - do it on a delay so that we147 // don't steal back focus from the dropdown.148 this._focusDropDownTimer = this.defer(function(){149 dropDown.focus();150 delete this._focusDropDownTimer;151 });152 }153 }else{154 // The drop down arrow icon probably can't receive focus, but widget itself should get focus.155 // defer() needed to make it work on IE (test DateTextBox)156 this.defer("focus");157 }158 if(has("ios")){159 this._justGotMouseUp = true;160 this.defer(function(){161 this._justGotMouseUp = false;162 });163 }164 },165 _onDropDownClick: function(/*Event*/ e){166 if(has("touch") && !this._justGotMouseUp){167 // If there was no preceding mousedown/mouseup (like on android), then simulate them to168 // toggle the drop down.169 //170 // The if(has("touch") is necessary since IE and desktop safari get spurious onclick events171 // when there are nested tables (specifically, clicking on a table that holds a dijit/form/Select,172 // but not on the Select itself, causes an onclick event on the Select)173 this._onDropDownMouseDown(e);174 this._onDropDownMouseUp(e);175 }176 // The drop down was already opened on mousedown/keydown; just need to call stopEvent().177 if(this._stopClickEvents){178 event.stop(e);179 }180 },181 buildRendering: function(){182 this.inherited(arguments);183 this._buttonNode = this._buttonNode || this.focusNode || this.domNode;184 this._popupStateNode = this._popupStateNode || this.focusNode || this._buttonNode;185 // Add a class to the "dijitDownArrowButton" type class to _buttonNode so theme can set direction of arrow186 // based on where drop down will normally appear187 var defaultPos = {188 "after" : this.isLeftToRight() ? "Right" : "Left",189 "before" : this.isLeftToRight() ? "Left" : "Right",190 "above" : "Up",191 "below" : "Down",192 "left" : "Left",193 "right" : "Right"194 }[this.dropDownPosition[0]] || this.dropDownPosition[0] || "Down";195 domClass.add(this._arrowWrapperNode || this._buttonNode, "dijit" + defaultPos + "ArrowButton");196 },197 postCreate: function(){198 // summary:199 // set up nodes and connect our mouse and keyboard events200 this.inherited(arguments);201 this.own(202 on(this._buttonNode, "mousedown", lang.hitch(this, "_onDropDownMouseDown")),203 on(this._buttonNode, "click", lang.hitch(this, "_onDropDownClick")),204 on(this.focusNode, "keydown", lang.hitch(this, "_onKey")),205 on(this.focusNode, "keyup", lang.hitch(this, "_onKeyUp"))206 );207 },208 destroy: function(){209 if(this.dropDown){210 // Destroy the drop down, unless it's already been destroyed. This can happen because211 // the drop down is a direct child of <body> even though it's logically my child.212 if(!this.dropDown._destroyed){213 this.dropDown.destroyRecursive();214 }215 delete this.dropDown;216 }217 this.inherited(arguments);218 },219 _onKey: function(/*Event*/ e){220 // summary:221 // Callback when the user presses a key while focused on the button node222 if(this.disabled || this.readOnly){ return; }223 var d = this.dropDown, target = e.target;224 if(d && this._opened && d.handleKey){225 if(d.handleKey(e) === false){226 /* false return code means that the drop down handled the key */227 event.stop(e);228 return;229 }230 }231 if(d && this._opened && e.keyCode == keys.ESCAPE){232 this.closeDropDown();233 event.stop(e);234 }else if(!this._opened &&235 (e.keyCode == keys.DOWN_ARROW ||236 ( (e.keyCode == keys.ENTER || e.keyCode == dojo.keys.SPACE) &&237 //ignore enter and space if the event is for a text input238 ((target.tagName || "").toLowerCase() !== 'input' ||239 (target.type && target.type.toLowerCase() !== 'text'))))){240 // Toggle the drop down, but wait until keyup so that the drop down doesn't241 // get a stray keyup event, or in the case of key-repeat (because user held242 // down key for too long), stray keydown events243 this._toggleOnKeyUp = true;244 event.stop(e);245 }246 },247 _onKeyUp: function(){248 if(this._toggleOnKeyUp){249 delete this._toggleOnKeyUp;250 this.toggleDropDown();251 var d = this.dropDown; // drop down may not exist until toggleDropDown() call252 if(d && d.focus){253 this.defer(lang.hitch(d, "focus"), 1);254 }255 }256 },257 _onBlur: function(){258 // summary:259 // Called magically when focus has shifted away from this widget and it's dropdown260 // Don't focus on button if the user has explicitly focused on something else (happens261 // when user clicks another control causing the current popup to close)..262 // But if focus is inside of the drop down then reset focus to me, because IE doesn't like263 // it when you display:none a node with focus.264 var focusMe = focus.curNode && this.dropDown && dom.isDescendant(focus.curNode, this.dropDown.domNode);265 this.closeDropDown(focusMe);266 this.inherited(arguments);267 },268 isLoaded: function(){269 // summary:270 // Returns true if the dropdown exists and it's data is loaded. This can271 // be overridden in order to force a call to loadDropDown().272 // tags:273 // protected274 return true;275 },276 loadDropDown: function(/*Function*/ loadCallback){277 // summary:278 // Creates the drop down if it doesn't exist, loads the data279 // if there's an href and it hasn't been loaded yet, and then calls280 // the given callback.281 // tags:282 // protected283 // TODO: for 2.0, change API to return a Deferred, instead of calling loadCallback?284 loadCallback();285 },286 loadAndOpenDropDown: function(){287 // summary:288 // Creates the drop down if it doesn't exist, loads the data289 // if there's an href and it hasn't been loaded yet, and290 // then opens the drop down. This is basically a callback when the291 // user presses the down arrow button to open the drop down.292 // returns: Deferred293 // Deferred for the drop down widget that294 // fires when drop down is created and loaded295 // tags:296 // protected297 var d = new Deferred(),298 afterLoad = lang.hitch(this, function(){299 this.openDropDown();300 d.resolve(this.dropDown);301 });302 if(!this.isLoaded()){303 this.loadDropDown(afterLoad);304 }else{305 afterLoad();306 }307 return d;308 },309 toggleDropDown: function(){310 // summary:311 // Callback when the user presses the down arrow button or presses312 // the down arrow key to open/close the drop down.313 // Toggle the drop-down widget; if it is up, close it, if not, open it314 // tags:315 // protected316 if(this.disabled || this.readOnly){ return; }317 if(!this._opened){318 this.loadAndOpenDropDown();319 }else{320 this.closeDropDown();321 }322 },323 openDropDown: function(){324 // summary:325 // Opens the dropdown for this widget. To be called only when this.dropDown326 // has been created and is ready to display (ie, it's data is loaded).327 // returns:328 // return value of dijit/popup.open()329 // tags:330 // protected331 var dropDown = this.dropDown,332 ddNode = dropDown.domNode,333 aroundNode = this._aroundNode || this.domNode,334 self = this;335 // Prepare our popup's height and honor maxHeight if it exists.336 // TODO: isn't maxHeight dependent on the return value from dijit/popup.open(),337 // ie, dependent on how much space is available (BK)338 if(!this._preparedNode){339 this._preparedNode = true;340 // Check if we have explicitly set width and height on the dropdown widget dom node341 if(ddNode.style.width){342 this._explicitDDWidth = true;343 }344 if(ddNode.style.height){345 this._explicitDDHeight = true;346 }347 }348 // Code for resizing dropdown (height limitation, or increasing width to match my width)349 if(this.maxHeight || this.forceWidth || this.autoWidth){350 var myStyle = {351 display: "",352 visibility: "hidden"353 };354 if(!this._explicitDDWidth){355 myStyle.width = "";356 }357 if(!this._explicitDDHeight){358 myStyle.height = "";359 }360 domStyle.set(ddNode, myStyle);361 // Figure out maximum height allowed (if there is a height restriction)362 var maxHeight = this.maxHeight;363 if(maxHeight == -1){364 // limit height to space available in viewport either above or below my domNode365 // (whichever side has more room)366 var viewport = winUtils.getBox(this.ownerDocument),367 position = domGeometry.position(aroundNode, false);368 maxHeight = Math.floor(Math.max(position.y, viewport.h - (position.y + position.h)));369 }370 // Attach dropDown to DOM and make make visibility:hidden rather than display:none371 // so we call startup() and also get the size372 popup.moveOffScreen(dropDown);373 if(dropDown.startup && !dropDown._started){374 dropDown.startup(); // this has to be done after being added to the DOM375 }376 // Get size of drop down, and determine if vertical scroll bar needed. If no scroll bar needed,377 // use overflow:visible rather than overflow:hidden so off-by-one errors don't hide drop down border.378 var mb = domGeometry.getMarginSize(ddNode);379 var overHeight = (maxHeight && mb.h > maxHeight);380 domStyle.set(ddNode, {381 overflowX: "visible",382 overflowY: overHeight ? "auto" : "visible"383 });384 if(overHeight){385 mb.h = maxHeight;386 if("w" in mb){387 mb.w += 16; // room for vertical scrollbar388 }389 }else{390 delete mb.h;391 }392 // Adjust dropdown width to match or be larger than my width393 if(this.forceWidth){394 mb.w = aroundNode.offsetWidth;395 }else if(this.autoWidth){396 mb.w = Math.max(mb.w, aroundNode.offsetWidth);397 }else{398 delete mb.w;399 }400 // And finally, resize the dropdown to calculated height and width401 if(lang.isFunction(dropDown.resize)){402 dropDown.resize(mb);403 }else{404 domGeometry.setMarginBox(ddNode, mb);405 }406 }407 var retVal = popup.open({408 parent: this,409 popup: dropDown,410 around: aroundNode,411 orient: this.dropDownPosition,412 onExecute: function(){413 self.closeDropDown(true);414 },415 onCancel: function(){416 self.closeDropDown(true);417 },418 onClose: function(){419 domAttr.set(self._popupStateNode, "popupActive", false);420 domClass.remove(self._popupStateNode, "dijitHasDropDownOpen");421 self._set("_opened", false); // use set() because _CssStateMixin is watching422 }423 });424 domAttr.set(this._popupStateNode, "popupActive", "true");425 domClass.add(this._popupStateNode, "dijitHasDropDownOpen");426 this._set("_opened", true); // use set() because _CssStateMixin is watching427 this.domNode.setAttribute("aria-expanded", "true");428 429 return retVal;430 },431 closeDropDown: function(/*Boolean*/ focus){432 // summary:433 // Closes the drop down on this widget434 // focus:435 // If true, refocuses the button widget436 // tags:437 // protected438 if(this._focusDropDownTimer){439 this._focusDropDownTimer.remove();440 delete this._focusDropDownTimer;441 }442 if(this._opened){443 this.domNode.setAttribute("aria-expanded", "false");444 if(focus){ this.focus(); }445 popup.close(this.dropDown);446 this._opened = false;447 }448 }449 });...

Full Screen

Full Screen

_HasDropDown.js

Source:_HasDropDown.js Github

copy

Full Screen

1define([2 "dojo/_base/declare", // declare3 "dojo/_base/Deferred",4 "dojo/dom", // dom.isDescendant5 "dojo/dom-attr", // domAttr.set6 "dojo/dom-class", // domClass.add domClass.contains domClass.remove7 "dojo/dom-geometry", // domGeometry.marginBox domGeometry.position8 "dojo/dom-style", // domStyle.set9 "dojo/has", // has("touch")10 "dojo/keys", // keys.DOWN_ARROW keys.ENTER keys.ESCAPE11 "dojo/_base/lang", // lang.hitch lang.isFunction12 "dojo/on",13 "dojo/touch",14 "./registry", // registry.byNode()15 "./focus",16 "./popup",17 "./_FocusMixin"18], function(declare, Deferred, dom, domAttr, domClass, domGeometry, domStyle, has, keys, lang, on, touch,19 registry, focus, popup, _FocusMixin){20 // module:21 // dijit/_HasDropDown22 return declare("dijit._HasDropDown", _FocusMixin, {23 // summary:24 // Mixin for widgets that need drop down ability.25 // _buttonNode: [protected] DomNode26 // The button/icon/node to click to display the drop down.27 // Can be set via a data-dojo-attach-point assignment.28 // If missing, then either focusNode or domNode (if focusNode is also missing) will be used.29 _buttonNode: null,30 // _arrowWrapperNode: [protected] DomNode31 // Will set CSS class dijitUpArrow, dijitDownArrow, dijitRightArrow etc. on this node depending32 // on where the drop down is set to be positioned.33 // Can be set via a data-dojo-attach-point assignment.34 // If missing, then _buttonNode will be used.35 _arrowWrapperNode: null,36 // _popupStateNode: [protected] DomNode37 // The node to set the aria-expanded class on.38 // Also sets popupActive class but that will be removed in 2.0.39 // Can be set via a data-dojo-attach-point assignment.40 // If missing, then focusNode or _buttonNode (if focusNode is missing) will be used.41 _popupStateNode: null,42 // _aroundNode: [protected] DomNode43 // The node to display the popup around.44 // Can be set via a data-dojo-attach-point assignment.45 // If missing, then domNode will be used.46 _aroundNode: null,47 // dropDown: [protected] Widget48 // The widget to display as a popup. This widget *must* be49 // defined before the startup function is called.50 dropDown: null,51 // autoWidth: [protected] Boolean52 // Set to true to make the drop down at least as wide as this53 // widget. Set to false if the drop down should just be its54 // default width.55 autoWidth: true,56 // forceWidth: [protected] Boolean57 // Set to true to make the drop down exactly as wide as this58 // widget. Overrides autoWidth.59 forceWidth: false,60 // maxHeight: [protected] Integer61 // The max height for our dropdown.62 // Any dropdown taller than this will have scrollbars.63 // Set to 0 for no max height, or -1 to limit height to available space in viewport64 maxHeight: -1,65 // dropDownPosition: [const] String[]66 // This variable controls the position of the drop down.67 // It's an array of strings with the following values:68 //69 // - before: places drop down to the left of the target node/widget, or to the right in70 // the case of RTL scripts like Hebrew and Arabic71 // - after: places drop down to the right of the target node/widget, or to the left in72 // the case of RTL scripts like Hebrew and Arabic73 // - above: drop down goes above target node74 // - below: drop down goes below target node75 //76 // The list is positions is tried, in order, until a position is found where the drop down fits77 // within the viewport.78 //79 dropDownPosition: ["below", "above"],80 // _stopClickEvents: Boolean81 // When set to false, the click events will not be stopped, in82 // case you want to use them in your subclass83 _stopClickEvents: true,84 _onDropDownMouseDown: function(/*Event*/ e){85 // summary:86 // Callback when the user mousedown/touchstart on the arrow icon.87 if(this.disabled || this.readOnly){88 return;89 }90 // Prevent default to stop things like text selection, but don't stop propagation, so that:91 // 1. TimeTextBox etc. can focus the <input> on mousedown92 // 2. dropDownButtonActive class applied by _CssStateMixin (on button depress)93 // 3. user defined onMouseDown handler fires94 e.preventDefault();95 this._docHandler = this.own(on(this.ownerDocument, touch.release, lang.hitch(this, "_onDropDownMouseUp")))[0];96 this.toggleDropDown();97 },98 _onDropDownMouseUp: function(/*Event?*/ e){99 // summary:100 // Callback on mouseup/touchend after mousedown/touchstart on the arrow icon.101 // Note that this function is called regardless of what node the event occurred on (but only after102 // a mousedown/touchstart on the arrow).103 //104 // If the drop down is a simple menu and the cursor is over the menu, we execute it, otherwise, we focus our105 // drop down widget. If the event is missing, then we are not106 // a mouseup event.107 //108 // This is useful for the common mouse movement pattern109 // with native browser `<select>` nodes:110 //111 // 1. mouse down on the select node (probably on the arrow)112 // 2. move mouse to a menu item while holding down the mouse button113 // 3. mouse up. this selects the menu item as though the user had clicked it.114 if(e && this._docHandler){115 this._docHandler.remove();116 this._docHandler = null;117 }118 var dropDown = this.dropDown, overMenu = false;119 if(e && this._opened){120 // This code deals with the corner-case when the drop down covers the original widget,121 // because it's so large. In that case mouse-up shouldn't select a value from the menu.122 // Find out if our target is somewhere in our dropdown widget,123 // but not over our _buttonNode (the clickable node)124 var c = domGeometry.position(this._buttonNode, true);125 if(!(e.pageX >= c.x && e.pageX <= c.x + c.w) || !(e.pageY >= c.y && e.pageY <= c.y + c.h)){126 var t = e.target;127 while(t && !overMenu){128 if(domClass.contains(t, "dijitPopup")){129 overMenu = true;130 }else{131 t = t.parentNode;132 }133 }134 if(overMenu){135 t = e.target;136 if(dropDown.onItemClick){137 var menuItem;138 while(t && !(menuItem = registry.byNode(t))){139 t = t.parentNode;140 }141 if(menuItem && menuItem.onClick && menuItem.getParent){142 menuItem.getParent().onItemClick(menuItem, e);143 }144 }145 return;146 }147 }148 }149 if(this._opened){150 if(dropDown.focus && dropDown.autoFocus !== false){151 // Focus the dropdown widget - do it on a delay so that we152 // don't steal back focus from the dropdown.153 this._focusDropDownTimer = this.defer(function(){154 dropDown.focus();155 delete this._focusDropDownTimer;156 });157 }158 }else{159 // The drop down arrow icon probably can't receive focus, but widget itself should get focus.160 // defer() needed to make it work on IE (test DateTextBox)161 if(this.focus){162 this.defer("focus");163 }164 }165 },166 _onDropDownClick: function(/*Event*/ e){167 // The drop down was already opened on mousedown/keydown; just need to stop the event168 if(this._stopClickEvents){169 e.stopPropagation();170 e.preventDefault();171 }172 },173 buildRendering: function(){174 this.inherited(arguments);175 this._buttonNode = this._buttonNode || this.focusNode || this.domNode;176 this._popupStateNode = this._popupStateNode || this.focusNode || this._buttonNode;177 // Add a class to the "dijitDownArrowButton" type class to _buttonNode so theme can set direction of arrow178 // based on where drop down will normally appear179 var defaultPos = {180 "after": this.isLeftToRight() ? "Right" : "Left",181 "before": this.isLeftToRight() ? "Left" : "Right",182 "above": "Up",183 "below": "Down",184 "left": "Left",185 "right": "Right"186 }[this.dropDownPosition[0]] || this.dropDownPosition[0] || "Down";187 domClass.add(this._arrowWrapperNode || this._buttonNode, "dijit" + defaultPos + "ArrowButton");188 },189 postCreate: function(){190 // summary:191 // set up nodes and connect our mouse and keyboard events192 this.inherited(arguments);193 var keyboardEventNode = this.focusNode || this.domNode;194 this.own(195 on(this._buttonNode, touch.press, lang.hitch(this, "_onDropDownMouseDown")),196 on(this._buttonNode, "click", lang.hitch(this, "_onDropDownClick")),197 on(keyboardEventNode, "keydown", lang.hitch(this, "_onKey")),198 on(keyboardEventNode, "keyup", lang.hitch(this, "_onKeyUp"))199 );200 },201 destroy: function(){202 if(this.dropDown){203 // Destroy the drop down, unless it's already been destroyed. This can happen because204 // the drop down is a direct child of <body> even though it's logically my child.205 if(!this.dropDown._destroyed){206 this.dropDown.destroyRecursive();207 }208 delete this.dropDown;209 }210 this.inherited(arguments);211 },212 _onKey: function(/*Event*/ e){213 // summary:214 // Callback when the user presses a key while focused on the button node215 if(this.disabled || this.readOnly){216 return;217 }218 var d = this.dropDown, target = e.target;219 if(d && this._opened && d.handleKey){220 if(d.handleKey(e) === false){221 /* false return code means that the drop down handled the key */222 e.stopPropagation();223 e.preventDefault();224 return;225 }226 }227 if(d && this._opened && e.keyCode == keys.ESCAPE){228 this.closeDropDown();229 e.stopPropagation();230 e.preventDefault();231 }else if(!this._opened &&232 (e.keyCode == keys.DOWN_ARROW ||233 // ignore unmodified SPACE if _KeyNavMixin has active searching in progress234 ( (e.keyCode == keys.ENTER || (e.keyCode == keys.SPACE && (!this._searchTimer || (e.ctrlKey || e.altKey || e.metaKey)))) &&235 //ignore enter and space if the event is for a text input236 ((target.tagName || "").toLowerCase() !== 'input' ||237 (target.type && target.type.toLowerCase() !== 'text'))))){238 // Toggle the drop down, but wait until keyup so that the drop down doesn't239 // get a stray keyup event, or in the case of key-repeat (because user held240 // down key for too long), stray keydown events241 this._toggleOnKeyUp = true;242 e.stopPropagation();243 e.preventDefault();244 }245 },246 _onKeyUp: function(){247 if(this._toggleOnKeyUp){248 delete this._toggleOnKeyUp;249 this.toggleDropDown();250 var d = this.dropDown; // drop down may not exist until toggleDropDown() call251 if(d && d.focus){252 this.defer(lang.hitch(d, "focus"), 1);253 }254 }255 },256 _onBlur: function(){257 // summary:258 // Called magically when focus has shifted away from this widget and it's dropdown259 // Close dropdown but don't focus my <input>. User may have focused somewhere else (ex: clicked another260 // input), and even if they just clicked a blank area of the screen, focusing my <input> will unwantedly261 // popup the keyboard on mobile.262 this.closeDropDown(false);263 this.inherited(arguments);264 },265 isLoaded: function(){266 // summary:267 // Returns true if the dropdown exists and it's data is loaded. This can268 // be overridden in order to force a call to loadDropDown().269 // tags:270 // protected271 return true;272 },273 loadDropDown: function(/*Function*/ loadCallback){274 // summary:275 // Creates the drop down if it doesn't exist, loads the data276 // if there's an href and it hasn't been loaded yet, and then calls277 // the given callback.278 // tags:279 // protected280 // TODO: for 2.0, change API to return a Deferred, instead of calling loadCallback?281 loadCallback();282 },283 loadAndOpenDropDown: function(){284 // summary:285 // Creates the drop down if it doesn't exist, loads the data286 // if there's an href and it hasn't been loaded yet, and287 // then opens the drop down. This is basically a callback when the288 // user presses the down arrow button to open the drop down.289 // returns: Deferred290 // Deferred for the drop down widget that291 // fires when drop down is created and loaded292 // tags:293 // protected294 var d = new Deferred(),295 afterLoad = lang.hitch(this, function(){296 this.openDropDown();297 d.resolve(this.dropDown);298 });299 if(!this.isLoaded()){300 this.loadDropDown(afterLoad);301 }else{302 afterLoad();303 }304 return d;305 },306 toggleDropDown: function(){307 // summary:308 // Callback when the user presses the down arrow button or presses309 // the down arrow key to open/close the drop down.310 // Toggle the drop-down widget; if it is up, close it, if not, open it311 // tags:312 // protected313 if(this.disabled || this.readOnly){314 return;315 }316 if(!this._opened){317 this.loadAndOpenDropDown();318 }else{319 this.closeDropDown(true); // refocus button to avoid hiding node w/focus320 }321 },322 openDropDown: function(){323 // summary:324 // Opens the dropdown for this widget. To be called only when this.dropDown325 // has been created and is ready to display (ie, it's data is loaded).326 // returns:327 // return value of dijit/popup.open()328 // tags:329 // protected330 var dropDown = this.dropDown,331 ddNode = dropDown.domNode,332 aroundNode = this._aroundNode || this.domNode,333 self = this;334 var retVal = popup.open({335 parent: this,336 popup: dropDown,337 around: aroundNode,338 orient: this.dropDownPosition,339 maxHeight: this.maxHeight,340 onExecute: function(){341 self.closeDropDown(true);342 },343 onCancel: function(){344 self.closeDropDown(true);345 },346 onClose: function(){347 domAttr.set(self._popupStateNode, "popupActive", false);348 domClass.remove(self._popupStateNode, "dijitHasDropDownOpen");349 self._set("_opened", false); // use set() because _CssStateMixin is watching350 }351 });352 // Set width of drop down if necessary, so that dropdown width + width of scrollbar (from popup wrapper)353 // matches width of aroundNode354 if(this.forceWidth || (this.autoWidth && aroundNode.offsetWidth > dropDown._popupWrapper.offsetWidth)){355 var resizeArgs = {356 w: aroundNode.offsetWidth - (dropDown._popupWrapper.offsetWidth - dropDown.domNode.offsetWidth)357 };358 if(lang.isFunction(dropDown.resize)){359 dropDown.resize(resizeArgs);360 }else{361 domGeometry.setMarginBox(ddNode, resizeArgs);362 }363 }364 domAttr.set(this._popupStateNode, "popupActive", "true");365 domClass.add(this._popupStateNode, "dijitHasDropDownOpen");366 this._set("_opened", true); // use set() because _CssStateMixin is watching367 this._popupStateNode.setAttribute("aria-expanded", "true");368 this._popupStateNode.setAttribute("aria-owns", dropDown.id);369 // Set aria-labelledby on dropdown if it's not already set to something more meaningful370 if(ddNode.getAttribute("role") !== "presentation" && !ddNode.getAttribute("aria-labelledby")){371 ddNode.setAttribute("aria-labelledby", this.id);372 }373 return retVal;374 },375 closeDropDown: function(/*Boolean*/ focus){376 // summary:377 // Closes the drop down on this widget378 // focus:379 // If true, refocuses the button widget380 // tags:381 // protected382 if(this._focusDropDownTimer){383 this._focusDropDownTimer.remove();384 delete this._focusDropDownTimer;385 }386 if(this._opened){387 this._popupStateNode.setAttribute("aria-expanded", "false");388 if(focus){389 this.focus();390 }391 popup.close(this.dropDown);392 this._opened = false;393 }394 }395 });...

Full Screen

Full Screen

4.js

Source:4.js Github

copy

Full Screen

1document.addEventListener('touchmove', function(e) {2 e.preventDefault();3}, { passive: false });4document.body.addEventListener('touchstart', function(e){ e.preventDefault();});5var xDown = null; 6var yDown = null; 7var top = null;8var left = null;9let downed = false 10var bouncingPos =null;11var currentPos =0;12var incrementer =0;13var diff=null;14var xUp15var yUp16var divnumbers17var h18var w19$( document ).ready(function() { 20 h = window.innerHeight;21 w = window.innerWidth22})23var isMobile = false; //initiate as false24// device detection25if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 26 || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) { 27 isMobile = true;28 }29 if(isMobile){30 document.addEventListener('touchstart', function (e) {31 findphonexy('down', e)32 });33 document.addEventListener('touchmove', function (e) {34 findphonexy('move', e)35 });36 document.addEventListener('touchend', function (e) {37 findphonexy('up', e)38 });39 }40 else{41 document.addEventListener('mousedown', function (e) {42 findphonexy('down', e)43 });44 document.addEventListener('mousemove', function (e) {45 findphonexy('move', e)46 });47 document.addEventListener('mouseup', function (e) {48 findphonexy('up', e)49 });50 }51 52 var image53 var num54 var id55 var first_x = 056 divs = document.getElementsByClassName("boxes")57 function findphonexy(res, e) {58 if (res == 'down') { 59 $(".boxes").removeClass('animate')60 if(first_x == 0){61 if(isMobile){62 first_x = e.touches[0].clientY; 63 }else{64 first_x = e.pageY; 65 }66 }67 downed = true68 if(isMobile){69 xDown = e.touches[0].clientX; 70 }else{71 xDown = e.pageX; 72 }73 currentPos =0;74 incrementer =0;75 }76 divs = document.getElementsByClassName("boxes")77 for (i = 0; i < divs.length; i++) {78 divnumbers = divs[i].id.slice(-2); 79 divtop = divs[i].offsetTop80 if (res == 'move') { 81 if(isMobile){ 82 yDown = e.touches[0].clientY; 83 }else{84 yDown = e.pageY; 85 }86 divs = document.getElementsByClassName("whole")[0].getElementsByClassName("boxes")87 divs_back = document.getElementsByClassName("whole_back")[0].getElementsByClassName("boxes")88 89 if(yDown < 01 * 0.0182*h ){num = 01}90 else if(yDown < 02 * 0.0182*h ){num = 02}91 else if(yDown < 03 * 0.0182*h ){num = 03}92 else if(yDown < 04 * 0.0182*h ){num = 04}93 else if(yDown < 05 * 0.0182*h ){num = 05}94 else if(yDown < 06 * 0.0182*h ){num = 06}95 else if(yDown < 07 * 0.0182*h ){num = 07}96 else if(yDown < 08 * 0.0182*h ){num = 08}97 else if(yDown < 09 * 0.0182*h ){num = 09}98 else if(yDown < 10 * 0.0182*h ){num = 10}99 else if(yDown < 11 * 0.0182*h ){num = 11}100 else if(yDown < 12 * 0.0182*h ){num = 12}101 else if(yDown < 13 * 0.0182*h ){num = 13}102 else if(yDown < 14 * 0.0182*h ){num = 14}103 else if(yDown < 15 * 0.0182*h ){num = 15}104 else if(yDown < 16 * 0.0182*h ){num = 16}105 else if(yDown < 17 * 0.0182*h ){num = 17}106 else if(yDown < 18 * 0.0182*h ){num = 18}107 else if(yDown < 19 * 0.0182*h ){num = 19}108 else if(yDown < 20 * 0.0182*h ){num = 20}109 else if(yDown < 21 * 0.0182*h ){num = 21}110 else if(yDown < 22 * 0.0182*h ){num = 22}111 else if(yDown < 23 * 0.0182*h ){num = 23}112 else if(yDown < 24 * 0.0182*h ){num = 24}113 else if(yDown < 25 * 0.0182*h ){num = 25}114 else if(yDown < 26 * 0.0182*h ){num = 26}115 else if(yDown < 27 * 0.0182*h ){num = 27}116 else if(yDown < 28 * 0.0182*h ){num = 28}117 else if(yDown < 29 * 0.0182*h ){num = 29}118 else if(yDown < 30 * 0.0182*h ){num = 30}119 else if(yDown < 31 * 0.0182*h ){num = 31}120 else if(yDown < 32 * 0.0182*h ){num = 32}121 else if(yDown < 33 * 0.0182*h ){num = 33}122 else if(yDown < 34 * 0.0182*h ){num = 34}123 else if(yDown < 35 * 0.0182*h ){num = 35}124 else if(yDown < 36 * 0.0182*h ){num = 36}125 else if(yDown < 37 * 0.0182*h ){num = 37}126 else if(yDown < 38 * 0.0182*h ){num = 38}127 else if(yDown < 39 * 0.0182*h ){num = 39}128 else if(yDown < 40 * 0.0182*h ){num = 40}129 else if(yDown < 41 * 0.0182*h ){num = 41}130 else if(yDown < 42 * 0.0182*h ){num = 42}131 else if(yDown < 43 * 0.0182*h ){num = 43}132 else if(yDown < 44 * 0.0182*h ){num = 44}133 else if(yDown < 45 * 0.0182*h ){num = 45}134 else if(yDown < 46 * 0.0182*h ){num = 46}135 else if(yDown < 47 * 0.0182*h ){num = 47}136 else if(yDown < 48 * 0.0182*h ){num = 48}137 else if(yDown < 49 * 0.0182*h ){num = 49}138 else if(yDown < 50 * 0.0182*h ){num = 50}139 else if(yDown < 51 * 0.0182*h ){num = 51}140 else if(yDown < 52 * 0.0182*h ){num = 52}141 else if(yDown < 53 * 0.0182*h ){num = 53}142 else{num =54}143 if(downed){ 144 xabs = Math.abs(num-divnumbers)+1;145 var result = (185.5/370*w) - (185.5/370*w)/xabs*2146 var result_2 = 1/xabs*4147 if(result> 0&& result_2<1){148 {divs[i].style.transform = 'scaleX('+ (1 - 1/xabs*4) + ")"}149 if(!isMobile){150 {divs_back[i].style.transform = 'scaleX('+ ((1/xabs*4)+0.1) + ")"}151 }else{152 {divs_back[i].style.transform = 'scaleX('+ ((1/xabs*4)) + ")"}153 }154 }else{155 divs_back[i].style.transform = 'scaleX(1)'156 if(!isMobile){157 divs[i].style.transform = 'scaleX(0.1)'158 }else{159 divs[i].style.transform = 'scaleX(0)'160 }161 }162 }163 }164 }165 if (res == 'up' || res == "out") {166 $(".boxes").addClass('animate')167 $(".boxes").css({'transform': 'scaleX(1)'});168 downed = false169 }170} 171 ////////////////////////////////////////////////////////////////////////////////////////////////////////...

Full Screen

Full Screen

DropDownList.js

Source:DropDownList.js Github

copy

Full Screen

1/*==========================================================================*\2 | $Id: DropDownList.js,v 1.1 2011/05/02 19:31:53 aallowat Exp $3 |*-------------------------------------------------------------------------*|4 | Copyright (C) 2011 Virginia Tech5 |6 | This file is part of Web-CAT.7 |8 | Web-CAT is free software; you can redistribute it and/or modify9 | it under the terms of the GNU Affero General Public License as published10 | by the Free Software Foundation; either version 3 of the License, or11 | (at your option) any later version.12 |13 | Web-CAT is distributed in the hope that it will be useful,14 | but WITHOUT ANY WARRANTY; without even the implied warranty of15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 | GNU General Public License for more details.17 |18 | You should have received a copy of the GNU Affero General Public License19 | along with Web-CAT; if not, see <http://www.gnu.org/licenses/>.20\*==========================================================================*/21dojo.provide("webcat.DropDownList");22dojo.require("webcat.global");23// --------------------------------------------------------------24webcat.dropDownList = {25 _onScrollHooks: { },26 _animations: { },27 _closeTimeouts: { }28};29//--------------------------------------------------------------30webcat.dropDownList._isNodeInListOrMenu = function(node)31{32 while (node.tagName != 'BODY')33 {34 if (dojo.hasClass(node, 'WCDropDownList')35 || dojo.hasClass(node, 'WCDropDownListMenu'))36 {37 return true;38 }39 node = node.parentNode;40 }41 return false;42};43//--------------------------------------------------------------44webcat.dropDownList._repositionMenu = function(dropDown, menu)45{46 var ddCoords = dojo.position(dropDown);47 var menuBox = dojo.marginBox(menu);48 var menuPos = { l: ddCoords.x, t: ddCoords.y + ddCoords.h };49 if (menuPos.l + menuBox.w > dijit.getViewport().w)50 {51 var newLeft = ddCoords.x + ddCoords.w - menuBox.w;52 if (newLeft >= 0)53 {54 menuPos.l = newLeft;55 }56 }57 if (menuPos.t + menuBox.h > dijit.getViewport().h)58 {59 var newTop = ddCoords.y - menuBox.h;60 if (newTop >= 0)61 {62 menuPos.t = newTop;63 }64 }65 dojo.marginBox(menu, menuPos);66};67//--------------------------------------------------------------68webcat.dropDownList._closeOpenMenu = function(quickly)69{70 var menuId = webcat.dropDownList._openMenu;71 if (!menuId) return;72 var menu = dojo.byId(menuId);73 dojo.disconnect(webcat.dropDownList._onScrollHooks[menuId]);74 if (quickly)75 {76 dojo.style(menu, 'display', 'none');77 }78 else79 {80 webcat.dropDownList._animations[menuId] =81 dojo.fadeOut({82 node: menu,83 duration: 150,84 onEnd: function() { dojo.style(menu, 'display', 'none'); }85 }).play();86 }87 delete webcat.dropDownList._onScrollHooks[menuId];88 if (webcat.dropDownList._closeTimeouts[menuId])89 {90 clearTimeout(webcat.dropDownList._closeTimeouts[menuId]);91 delete webcat.dropDownList._closeTimeouts[menuId];92 }93 delete webcat.dropDownList._openMenu;94};95//--------------------------------------------------------------96webcat.dropDownList.showDropDown = function(event, dropDownId, menuId)97{98 var dropDown = dojo.byId(dropDownId);99 var menu = dojo.byId(menuId);100 if (webcat.dropDownList._openMenu == menuId)101 {102 webcat.dropDownList._repositionMenu(dropDown, menu);103 }104 else105 {106 webcat.dropDownList._closeOpenMenu(true);107 var timeout = webcat.dropDownList._closeTimeouts[menuId];108 if (timeout)109 {110 clearTimeout(timeout);111 delete webcat.dropDownList._closeTimeouts[menuId];112 }113 var anim = webcat.dropDownList._animations[menuId];114 if (anim)115 {116 anim.stop();117 delete webcat.dropDownList._animations[menuId];118 }119 dojo.style(menu, 'opacity', '1');120 dojo.style(menu, 'display', 'block');121 webcat.dropDownList._openMenu = menuId;122 webcat.dropDownList._repositionMenu(dropDown, menu);123 webcat.dropDownList._onScrollHooks[menuId] =124 dojo.connect(window, "onscroll", null, function() {125 webcat.dropDownList._repositionMenu(dropDown, menu);126 });127 }128};129//--------------------------------------------------------------130webcat.dropDownList.hideDropDown = function(event, dropDownId, menuId, force)131{132 if (menuId != webcat.dropDownList._openMenu)133 {134 return;135 }136 var dropDown = dojo.byId(dropDownId);137 var menu = dojo.byId(menuId);138 var stayOpen;139 if (!event)140 {141 stayOpen = false;142 }143 else144 {145 var reltg = (event.relatedTarget) ? event.relatedTarget : event.toElement;146 stayOpen = webcat.dropDownList._isNodeInListOrMenu(reltg);147 }148 if (force)149 {150 webcat.dropDownList._closeOpenMenu();151 }152 else if (!stayOpen)153 {154 webcat.dropDownList._closeTimeouts[menuId] = setTimeout(155 webcat.dropDownList._closeOpenMenu, 250);156 }157};158//--------------------------------------------------------------159webcat.dropDownList.updateSelection = function(selectionId, selectedNode)160{161 dojo.byId(selectionId).innerHTML = selectedNode.innerHTML;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful