Best JavaScript code snippet using best
ui.list.edit.decorator.switchable.js
Source:ui.list.edit.decorator.switchable.js
1/**2 * DevExtreme (ui/list/ui.list.edit.decorator.switchable.js)3 * Version: 19.1.74 * Build date: Fri Oct 11 20195 *6 * Copyright (c) 2012 - 2019 Developer Express Inc. ALL RIGHTS RESERVED7 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/8 */9"use strict";10var $ = require("../../core/renderer"),11 eventsEngine = require("../../events/core/events_engine"),12 noop = require("../../core/utils/common").noop,13 EditDecorator = require("./ui.list.edit.decorator"),14 abstract = EditDecorator.abstract,15 eventUtils = require("../../events/utils"),16 pointerEvents = require("../../events/pointer"),17 feedbackEvents = require("../../events/core/emitter.feedback");18var LIST_EDIT_DECORATOR = "dxListEditDecorator",19 POINTER_DOWN_EVENT_NAME = eventUtils.addNamespace(pointerEvents.down, LIST_EDIT_DECORATOR),20 ACTIVE_EVENT_NAME = eventUtils.addNamespace(feedbackEvents.active, LIST_EDIT_DECORATOR),21 LIST_ITEM_CONTENT_CLASS = "dx-list-item-content",22 SWITCHABLE_DELETE_READY_CLASS = "dx-list-switchable-delete-ready",23 SWITCHABLE_MENU_SHIELD_POSITIONING_CLASS = "dx-list-switchable-menu-shield-positioning",24 SWITCHABLE_DELETE_TOP_SHIELD_CLASS = "dx-list-switchable-delete-top-shield",25 SWITCHABLE_DELETE_BOTTOM_SHIELD_CLASS = "dx-list-switchable-delete-bottom-shield",26 SWITCHABLE_MENU_ITEM_SHIELD_POSITIONING_CLASS = "dx-list-switchable-menu-item-shield-positioning",27 SWITCHABLE_DELETE_ITEM_CONTENT_SHIELD_CLASS = "dx-list-switchable-delete-item-content-shield",28 SWITCHABLE_DELETE_BUTTON_CONTAINER_CLASS = "dx-list-switchable-delete-button-container";29var SwitchableEditDecorator = EditDecorator.inherit({30 _init: function() {31 this._$topShield = $("<div>").addClass(SWITCHABLE_DELETE_TOP_SHIELD_CLASS);32 this._$bottomShield = $("<div>").addClass(SWITCHABLE_DELETE_BOTTOM_SHIELD_CLASS);33 this._$itemContentShield = $("<div>").addClass(SWITCHABLE_DELETE_ITEM_CONTENT_SHIELD_CLASS);34 eventsEngine.on(this._$topShield, POINTER_DOWN_EVENT_NAME, this._cancelDeleteReadyItem.bind(this));35 eventsEngine.on(this._$bottomShield, POINTER_DOWN_EVENT_NAME, this._cancelDeleteReadyItem.bind(this));36 this._list.$element().append(this._$topShield.toggle(false)).append(this._$bottomShield.toggle(false))37 },38 handleClick: function() {39 return this._cancelDeleteReadyItem()40 },41 _cancelDeleteReadyItem: function() {42 if (!this._$readyToDeleteItem) {43 return false44 }45 this._cancelDelete(this._$readyToDeleteItem);46 return true47 },48 _cancelDelete: function($itemElement) {49 this._toggleDeleteReady($itemElement, false)50 },51 _toggleDeleteReady: function($itemElement, readyToDelete) {52 if (void 0 === readyToDelete) {53 readyToDelete = !this._isReadyToDelete($itemElement)54 }55 this._toggleShields($itemElement, readyToDelete);56 this._toggleScrolling(readyToDelete);57 this._cacheReadyToDeleteItem($itemElement, readyToDelete);58 this._animateToggleDelete($itemElement, readyToDelete)59 },60 _isReadyToDelete: function($itemElement) {61 return $itemElement.hasClass(SWITCHABLE_DELETE_READY_CLASS)62 },63 _toggleShields: function($itemElement, enabled) {64 this._list.$element().toggleClass(SWITCHABLE_MENU_SHIELD_POSITIONING_CLASS, enabled);65 this._$topShield.toggle(enabled);66 this._$bottomShield.toggle(enabled);67 if (enabled) {68 this._updateShieldsHeight($itemElement)69 }70 this._toggleContentShield($itemElement, enabled)71 },72 _updateShieldsHeight: function($itemElement) {73 var $list = this._list.$element(),74 listTopOffset = $list.offset().top,75 listHeight = $list.outerHeight(),76 itemTopOffset = $itemElement.offset().top,77 itemHeight = $itemElement.outerHeight(),78 dirtyTopShieldHeight = itemTopOffset - listTopOffset,79 dirtyBottomShieldHeight = listHeight - itemHeight - dirtyTopShieldHeight;80 this._$topShield.height(Math.max(dirtyTopShieldHeight, 0));81 this._$bottomShield.height(Math.max(dirtyBottomShieldHeight, 0))82 },83 _toggleContentShield: function($itemElement, enabled) {84 if (enabled) {85 $itemElement.find("." + LIST_ITEM_CONTENT_CLASS).first().append(this._$itemContentShield)86 } else {87 this._$itemContentShield.detach()88 }89 },90 _toggleScrolling: function(readyToDelete) {91 var scrollView = this._list.$element().dxScrollView("instance");92 if (readyToDelete) {93 scrollView.on("start", this._cancelScrolling)94 } else {95 scrollView.off("start", this._cancelScrolling)96 }97 },98 _cancelScrolling: function(args) {99 args.event.cancel = true100 },101 _cacheReadyToDeleteItem: function($itemElement, cache) {102 if (cache) {103 this._$readyToDeleteItem = $itemElement104 } else {105 delete this._$readyToDeleteItem106 }107 },108 _animateToggleDelete: function($itemElement, readyToDelete) {109 if (readyToDelete) {110 this._enablePositioning($itemElement);111 this._prepareDeleteReady($itemElement);112 this._animatePrepareDeleteReady($itemElement);113 eventsEngine.off($itemElement, pointerEvents.up)114 } else {115 this._forgetDeleteReady($itemElement);116 this._animateForgetDeleteReady($itemElement).done(this._disablePositioning.bind(this, $itemElement))117 }118 },119 _enablePositioning: function($itemElement) {120 $itemElement.addClass(SWITCHABLE_MENU_ITEM_SHIELD_POSITIONING_CLASS);121 eventsEngine.on($itemElement, ACTIVE_EVENT_NAME, noop);122 eventsEngine.one($itemElement, pointerEvents.up, this._disablePositioning.bind(this, $itemElement))123 },124 _disablePositioning: function($itemElement) {125 $itemElement.removeClass(SWITCHABLE_MENU_ITEM_SHIELD_POSITIONING_CLASS);126 eventsEngine.off($itemElement, ACTIVE_EVENT_NAME)127 },128 _prepareDeleteReady: function($itemElement) {129 $itemElement.addClass(SWITCHABLE_DELETE_READY_CLASS)130 },131 _forgetDeleteReady: function($itemElement) {132 $itemElement.removeClass(SWITCHABLE_DELETE_READY_CLASS)133 },134 _animatePrepareDeleteReady: abstract,135 _animateForgetDeleteReady: abstract,136 _getDeleteButtonContainer: function($itemElement) {137 $itemElement = $itemElement || this._$readyToDeleteItem;138 return $itemElement.children("." + SWITCHABLE_DELETE_BUTTON_CONTAINER_CLASS)139 },140 _deleteItem: function($itemElement) {141 $itemElement = $itemElement || this._$readyToDeleteItem;142 this._getDeleteButtonContainer($itemElement).detach();143 if ($itemElement.is(".dx-state-disabled, .dx-state-disabled *")) {144 return145 }146 this._list.deleteItem($itemElement).always(this._cancelDelete.bind(this, $itemElement))147 },148 _isRtlEnabled: function() {149 return this._list.option("rtlEnabled")150 },151 dispose: function() {152 if (this._$topShield) {153 this._$topShield.remove()154 }155 if (this._$bottomShield) {156 this._$bottomShield.remove()157 }158 this.callBase.apply(this, arguments)159 }160});...
customSelect.js
Source:customSelect.js
1/*2 * To change this template, choose Tools | Templates3 * and open the template in the editor.4 *5 * viban terence6 * 20.12.20107 */8var customSelect = new Select();9function Select(){10 var idSel;11 var idList;12 var listElements;13 var scrollbar;14 var scrollbarVar;15 var boxes= new Array('listBoxDay', 'listBoxMonth', 'listBoxYear', 'listBoxSex', 'listBoxCountry');16 this.init = function(){17 var arrowElements = $$('.arrowSelectInactive');18 var selectedItems= $$('.itemSelected');19 var listboxes = $$('.listBox');20 this.eventClick = this.toggleDropDown.bindAsEventListener(this);21 this.eventSelect = this.SelectOption.bindAsEventListener(this);22 this.eventMouseOver = this.onMouseOverCustomSelect.bindAsEventListener(this);23 this.eventMouseOut = this.onMouseOutCustomSelect.bindAsEventListener(this);24 this.eventOnBlur = this.onBlur.bindAsEventListener(this);25 selectedItems.each(function(item){26 var itemElement = $(item);27 if(itemElement){28 customSelect.registerToggleEvent(itemElement);29 }30 });31 arrowElements.each(function(item){32 var itemElement = $(item);33 if(itemElement){34 customSelect.registerToggleEvent(itemElement);35 }36 });37 }38 this.registerEventListerners = function(element){39 Event.observe(element, "mouseover", this.eventMouseOver);40 Event.observe(element, "mouseout", this.eventMouseOut);41 Event.observe(element, "click", this.eventSelect);42 }43 this.UnregisterEventListerners = function(element){44 Event.stopObserving(element, "mouseover", this.eventMouseOver);45 Event.stopObserving(element, "mouseout", this.eventMouseOut);46 Event.stopObserving(element, "click", this.eventSelect);47 }48 this.registerToggleEvent = function(element){49 Event.observe(element, "click", this.eventClick);50 }51 this.UnregisterToggleEvent = function(element){52 Event.stopObserving(element, "click", this.eventClick);53 }54 this.registerOnEvent = function(element){55 Event.observe(element, "blur", this.eventOnBlur);56 }57 this.UnregisterOnEvent = function(element){58 Event.stopObserving(element, "blur", this.eventOnBlur);59 }60 this.toggleDropDown = function(e){61 var eventTriggerElement = Event.element(e);62 var classNames = eventTriggerElement.classNames();63 var listBox;64 var selBox;65 var scroll;66 67 classNames.each(function(item){68 if(item.indexOf('idList_') != -1){69 listBox = item.substr(7);70 }else if(item.indexOf('idSel_') != -1){71 selBox = item.substr(6);72 }73 });74 75 idList = $(listBox);76 idSel= $(selBox);77 78 boxes.each(function(item){79 if(item != listBox){80 var itemElement = $(item);81 if(itemElement){82 itemElement.removeClassName('arrowDown');83 itemElement.addClassName('arrowUp');84 }85 }86 });87 if(idList){88 if(idList.hasClassName('arrowDown')){89 idList.removeClassName('arrowDown');90 idList.addClassName('arrowUp');91 }else{92 if(listBox.indexOf('Day') != -1){93 misc.testForScrollbar('listDayBox');94 }else if(listBox.indexOf('Month') != -1){95 misc.testForScrollbar('listMonthBox');96 }else if(listBox.indexOf('Year') != -1){97 misc.testForScrollbar('listYearBox');98 }else if(listBox.indexOf('Country') != -1){99 misc.testForScrollbar('listCountryBox');100 }101 idList.removeClassName('arrowUp');102 idList.addClassName('arrowDown');103 listElements = $$('li.' + listBox + '_options');104 listElements.each(function(item){105 var itemElement = $(item);106 if(itemElement){107 customSelect.registerEventListerners(itemElement);108 }109 });110 }111 } 112 }113 this.SelectOption = function(e){114 var eventTriggerElement = Event.element(e);115 116 listElements.each(function(item){117 var itemElement = $(item);118 if(itemElement.hasClassName('selectedItem')){119 itemElement.removeClassName('selectedItem');120 }121 });122 if(!eventTriggerElement.hasClassName('selectedItem')){123 eventTriggerElement.addClassName('selectedItem');124 }125 126 var content = eventTriggerElement.innerHTML;127 128 idSel.innerHTML = content;129 idList.removeClassName('arrowDown');130 if(scrollbar){131 scrollbar.removeClassName('arrowDown');132 scrollbar.addClassName('arrowUp');133 }134 idList.addClassName('arrowUp');135 }136 this.onMouseOverCustomSelect = function(e){137 var eventTriggerElement = Event.element(e);138 eventTriggerElement.addClassName('customSelectOver');139 }140 this.onMouseOutCustomSelect = function(e){141 var eventTriggerElement = Event.element(e);142 eventTriggerElement.removeClassName('customSelectOver');143 }144 this.onBlur = function(e){145 var eventTriggerElement = Event.element(e);146 }147 this.destroyEventListerners = function(){148 var arrowElements = $$('.arrowSelectInactive');149 var selectedItems= $$('.itemSelected');150 var listboxes = $$('.listBox');151 boxes.each(function(item){152 var itemElement = $(item);153 if(itemElement){154 if(itemElement.hasClassName('arrowDown')){155 itemElement.removeClassName('arrowDown');156 itemElement.addClassName('arrowUp');157 }158 }159 });160 selectedItems.each(function(item){161 var itemElement = $(item);162 if(itemElement){163 customSelect.UnregisterToggleEvent(itemElement);164 }165 });166 arrowElements.each(function(item){167 var itemElement = $(item);168 if(itemElement){169 customSelect.UnregisterToggleEvent(itemElement);170 }171 });172 }...
Using AI Code Generation
1var request = require('request');2request(url, function (error, response, body) {3 if (!error && response.statusCode == 200) {4 }5});6var request = require('request');7request(url, function (error, response, body) {8 if (!error && response.statusCode == 200) {9 }10});11var request = require('request');12request(url, function (error, response, body) {13 if (!error && response.statusCode == 200) {14 }15});16var request = require('request');17request(url, function (error, response, body) {18 if (!error && response.statusCode == 200) {19 }20});21var request = require('request');22request(url, function (error, response, body) {23 if (!error && response.statusCode == 200) {24 }25});26var request = require('request');
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!