Best JavaScript code snippet using tracetest
kendo.drawer.js
Source:kendo.drawer.js
1/** 2 * Kendo UI v2019.3.1023 (http://www.telerik.com/kendo-ui) 3 * Copyright 2019 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved. 4 * 5 * Kendo UI commercial licenses may be obtained at 6 * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete 7 * If you do not own a commercial license, this file shall be governed by the trial license terms. 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23*/24(function (f, define) {25 define('kendo.drawer', ['kendo.userevents'], f);26}(function () {27 var __meta__ = {28 id: 'drawer',29 name: 'Drawer',30 category: 'web',31 description: 'The Kendo Drawer widget provides slide to reveal sidebar',32 depends: ['userevents']33 };34 (function ($, undefined) {35 var kendo = window.kendo, ui = kendo.ui, Widget = ui.Widget, SHOW = 'show', HIDE = 'hide', ITEMCLICK = 'itemClick', PUSH = 'push', OVERLAY = 'overlay', LEFT = 'left', RIGHT = 'right';36 var Drawer = kendo.ui.Widget.extend({37 init: function (element, options) {38 var that = this;39 var userEvents;40 Widget.fn.init.call(this, element, options);41 options = that.options;42 that._element(element);43 that._wrapper(element);44 that.position();45 that._mode();46 if (options.mini) {47 that._miniMode();48 }49 that._initDrawerItems();50 if (options.mini && options.mode != PUSH) {51 that._setBodyOffset();52 }53 userEvents = this.userEvents = new kendo.UserEvents(options.mode != PUSH ? $(document.body) : this.drawerContainer, {54 fastTap: true,55 allowSelection: true56 });57 var tap = function (e) {58 if ($.contains(that.drawerItemsWrapper[0], e.event.target)) {59 that._itemClick(e);60 }61 if (that.visible && !that.trigger('hide', { sender: this })) {62 that.hide();63 e.preventDefault();64 }65 };66 if (this.options.swipeToOpen) {67 userEvents.bind('start', function (e) {68 that._start(e);69 });70 userEvents.bind('move', function (e) {71 that._update(e);72 });73 userEvents.bind('end', function (e) {74 that._end(e);75 });76 userEvents.bind('tap', tap);77 } else {78 userEvents.bind('press', tap);79 }80 if (options.minHeight && options.mode == PUSH) {81 that.drawerContainer.css('min-height', options.minHeight);82 }83 },84 _element: function () {85 var that = this;86 var element = that.element;87 var options = that.options;88 var contentElement = that.contentElement = element.children().first();89 that.drawerElement = $(options.template);90 contentElement.addClass('k-drawer-content');91 element.addClass('k-widget k-drawer');92 },93 _wrapper: function () {94 var options = this.options;95 var drawerElement = this.drawerElement;96 var element = this.element;97 var contentElement = this.contentElement;98 var drawerItemsWrapper = this.drawerItemsWrapper = drawerElement.wrap('<div class=\'k-drawer-items\'></div>').parent();99 var drawerWrapper = this.drawerWrapper = drawerItemsWrapper.wrap('<div class=\'k-drawer-wrapper\'></div>').parent();100 var drawerContainer = this.drawerContainer = element.wrap('<div class=\'k-drawer-container\'></div>').parent();101 if (options.mini) {102 if (options.mini.width) {103 drawerWrapper.width(options.mini.width);104 }105 } else {106 drawerWrapper.width(0);107 }108 if (options.mode === PUSH) {109 drawerContainer.append(contentElement);110 } else if (options.mode === OVERLAY) {111 drawerContainer.after(contentElement);112 $(document.body).prepend(drawerContainer);113 }114 element.append(drawerWrapper);115 },116 _setBodyOffset: function () {117 var overlayMiniOffset = this.element.outerWidth();118 if (this.leftPositioned) {119 $(document.body).css('padding-left', overlayMiniOffset);120 } else {121 $(document.body).css('padding-right', overlayMiniOffset);122 }123 },124 _initDrawerItems: function () {125 var drawerItemsWrapper = this.drawerItemsWrapper;126 var drawerItems = drawerItemsWrapper.find('[data-role=\'drawer-item\']');127 var separatorItems = drawerItemsWrapper.find('[data-role=\'drawer-separator\']');128 drawerItems.addClass('k-drawer-item');129 separatorItems.addClass('k-drawer-item k-drawer-separator');130 if (this._selectedItemIndex >= 0) {131 drawerItems.removeClass('k-state-selected');132 drawerItems.eq(this._selectedItemIndex).addClass('k-state-selected');133 }134 },135 _mode: function () {136 var options = this.options;137 var drawerContainer = this.drawerContainer;138 var overlayContainer;139 if (options.mode == PUSH) {140 drawerContainer.addClass('k-drawer-' + PUSH);141 } else {142 drawerContainer.addClass('k-drawer-' + OVERLAY);143 overlayContainer = this.overlayContainer = $('<div class="k-overlay"></div>');144 overlayContainer.hide();145 drawerContainer.prepend(overlayContainer);146 }147 },148 _miniMode: function () {149 var options = this.options;150 var drawerContainer = this.drawerContainer;151 var miniWidth = options.mini.width;152 var miniTemplate = this._miniTemplate = options.mini.template && $(options.mini.template);153 var drawerItemsWrapper = this.drawerItemsWrapper;154 var drawerWrapper = this.drawerWrapper;155 drawerContainer.addClass('k-drawer-mini');156 if (miniTemplate) {157 drawerItemsWrapper.html(miniTemplate);158 }159 if (miniWidth) {160 drawerWrapper.width(miniWidth);161 }162 this.minWidth = options.mini.width || this.drawerWrapper.width();163 },164 show: function () {165 var drawerWrapper = this.drawerWrapper;166 var drawerContainer = this.drawerContainer;167 var options = this.options;168 var isExpanded = drawerContainer.hasClass('k-drawer-expanded');169 var miniTemplate = this._miniTemplate;170 var drawerElement = this.drawerElement;171 var drawerItemsWrapper = this.drawerItemsWrapper;172 if (!isExpanded) {173 drawerContainer.addClass('k-drawer-expanded');174 this.visible = true;175 }176 if (miniTemplate) {177 drawerItemsWrapper.html(drawerElement);178 this._initDrawerItems();179 this._selectItem();180 }181 drawerWrapper.width(options.width);182 if (options.mode === OVERLAY) {183 this.overlayContainer.show();184 this.visible = true;185 }186 },187 hide: function () {188 var that = this;189 var drawerWrapper = that.drawerWrapper;190 var drawerContainer = that.drawerContainer;191 var options = this.options;192 var drawerItemsWrapper = this.drawerItemsWrapper;193 var miniTemplate = this._miniTemplate;194 var miniWidth = options.mini && options.mini.width;195 if (this._miniTemplate) {196 drawerItemsWrapper.html(miniTemplate);197 that._initDrawerItems();198 this._selectItem();199 }200 if (options.mini) {201 if (miniWidth) {202 drawerWrapper.width(miniWidth);203 } else {204 drawerWrapper.width('');205 }206 } else {207 drawerWrapper.width(0);208 }209 if (this.visible) {210 drawerContainer.removeClass('k-drawer-expanded');211 this.visible = false;212 }213 if (options.mode === OVERLAY) {214 this.overlayContainer.hide();215 }216 },217 position: function (value) {218 var that = this;219 var options = that.options;220 var position = value || options.position;221 var drawerContainer = that.drawerContainer;222 if (position == RIGHT) {223 drawerContainer.removeClass('k-drawer-' + LEFT);224 drawerContainer.addClass('k-drawer-' + RIGHT);225 } else {226 drawerContainer.removeClass('k-drawer-' + RIGHT);227 drawerContainer.addClass('k-drawer-' + LEFT);228 }229 this.leftPositioned = position === LEFT;230 },231 _start: function (e) {232 var that = this;233 var options = this.options;234 var drawerWrapper = this.drawerWrapper;235 var drawerItemsWrapper = this.drawerItemsWrapper;236 var userEvents = e.sender;237 if (Math.abs(e.x.velocity) < Math.abs(e.y.velocity) || kendo.triggeredByInput(e.event)) {238 userEvents.cancel();239 return;240 }241 if (this.drawerMini) {242 drawerItemsWrapper.html(that.drawerElement);243 }244 drawerWrapper.css('transition', 'none');245 if (options.mode != PUSH) {246 this.overlayContainer.show();247 }248 },249 _update: function (e) {250 var options = this.options;251 var mode = options.mode;252 if (mode == PUSH) {253 this._push(e);254 } else {255 this._overlay(e);256 }257 },258 _end: function (e) {259 var velocity = e.x.velocity;260 var options = this.options;261 var drawerWrapper = this.drawerWrapper;262 var elementWidth = drawerWrapper.width();263 var pastHalf = elementWidth > options.width / 2;264 var velocityThreshold = 0.8;265 var shouldShow;266 drawerWrapper.css('transition', 'all .3s ease-out');267 if (this.leftPositioned) {268 shouldShow = velocity > -velocityThreshold && (velocity > velocityThreshold || pastHalf);269 } else {270 shouldShow = velocity < velocityThreshold && (velocity < -velocityThreshold || pastHalf);271 }272 if (shouldShow) {273 if (this.trigger('show', { sender: this })) {274 e.preventDefault();275 this.hide();276 } else {277 this.show();278 }279 } else {280 if (this.trigger('hide', { sender: this })) {281 e.preventDefault();282 this.show();283 } else {284 this.hide();285 }286 }287 },288 _overlay: function (moveEventArgs) {289 var options = this.options;290 var minWidth = options.mini && options.mini.width || this.minWidth || 0;291 var drawerWrapper = this.drawerWrapper;292 var elementWidth = drawerWrapper.width();293 var limitedPosition;294 var updatedPosition;295 updatedPosition = elementWidth + (this.leftPositioned ? moveEventArgs.x.delta : -moveEventArgs.x.delta);296 limitedPosition = Math.min(Math.max(updatedPosition, minWidth), options.width);297 moveEventArgs.event.preventDefault();298 moveEventArgs.event.stopPropagation();299 drawerWrapper.width(limitedPosition);300 },301 _push: function (moveEventArgs) {302 var options = this.options;303 var minWidth = options.mini && options.mini.width || this.minWidth || 0;304 var drawerWrapper = this.drawerWrapper;305 var elementWidth = drawerWrapper.width();306 var limitedPosition;307 var updatedPosition;308 updatedPosition = elementWidth + (this.leftPositioned ? moveEventArgs.x.delta : -moveEventArgs.x.delta);309 limitedPosition = Math.min(Math.max(updatedPosition, minWidth), options.width);310 moveEventArgs.event.preventDefault();311 moveEventArgs.event.stopPropagation();312 drawerWrapper.width(limitedPosition);313 },314 _selectItem: function (item) {315 var selectedItemIndex;316 if (item) {317 item.addClass('k-state-selected');318 this.trigger('itemClick', {319 item: item,320 sender: this321 });322 this._selectedItemIndex = item.index();323 return;324 }325 selectedItemIndex = this._selectedItemIndex;326 if (selectedItemIndex) {327 this.drawerItemsWrapper.find('[data-role=\'drawer-item\']').eq(selectedItemIndex).addClass('k-state-selected');328 }329 },330 _itemClick: function (e) {331 var that = this;332 var item;333 if ($(e.event.target).find('.k-drawer-item').length > 0) {334 item = $(e.event.target).find('.k-drawer-item');335 } else if ($(e.event.target).closest('.k-drawer-item').length > 0) {336 item = $(e.event.target).closest('.k-drawer-item');337 } else if ($(e.event.target).hasClass('.k-drawer-item')) {338 item = $(e.event.target);339 }340 that.drawerItemsWrapper.find('.k-drawer-item').removeClass('k-state-selected');341 that._selectItem(item);342 },343 destroy: function () {344 var options = this.options;345 if (options.mode != PUSH) {346 if (this.leftPositioned) {347 $(document.body).css('padding-left', 0);348 } else {349 $(document.body).css('padding-right', 0);350 }351 }352 Widget.fn.destroy.call(this);353 this.userEvents.destroy();354 kendo.destroy(this.element);355 this.element = this.drawerWrapper = this.drawerElement = this.drawerContainer = this.drawerItemsWrapper = this._miniTemplate = null;356 },357 options: {358 name: 'Drawer',359 position: LEFT,360 mode: 'overlay',361 swipeToOpen: true,362 width: 280,363 mini: false,364 template: ''365 },366 events: [367 HIDE,368 SHOW,369 ITEMCLICK370 ]371 });372 kendo.ui.plugin(Drawer);373 }(window.kendo.jQuery));374 return window.kendo;375}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {376 (a3 || a2)();...
drawer-init.js
Source:drawer-init.js
2const DrawerInit = {3 init({ drawer, drawerContainer, menuBtn, closeBtn, menuList }) {4 this._eventMenuBtn({ menuBtn, drawer, drawerContainer, closeBtn });5 this._eventCloseBtn({ closeBtn, drawer, drawerContainer });6 this._eventDrawerContainer({ drawerContainer, closeBtn, drawer });7 this._eventMenuList({ menuList, closeBtn, drawer, drawerContainer });8 },9 _eventMenuBtn({ menuBtn, drawer, drawerContainer, closeBtn }) {10 menuBtn.addEventListener('click', (event) => {11 this._openDrawer({ drawer, drawerContainer, event, closeBtn });12 });13 },14 _eventCloseBtn({ closeBtn, drawer, drawerContainer }) {15 closeBtn.addEventListener('click', (e) => {16 e.preventDefault();17 this._closeDrawer({ closeBtn, drawer, drawerContainer });18 });19 },20 _eventDrawerContainer({ drawerContainer, closeBtn, drawer }) {21 drawerContainer.addEventListener('click', (e) => {22 if (e.target.classList.contains('drawer-container')) {23 e.preventDefault();24 this._closeDrawer({ closeBtn, drawer, drawerContainer });25 }26 });27 },28 _eventMenuList({ menuList, closeBtn, drawer, drawerContainer }) {29 menuList.forEach((menu) => {30 menu.addEventListener('click', () => {31 this._closeDrawer({ closeBtn, drawer, drawerContainer });32 });33 });34 },...
index.js
Source:index.js
1// import DrawerContainer from './drawerContainer'2// import DragContainer from './dragContainer'3// //4// const install = (Vue) => {5// Vue.component(DrawerContainer.name, DrawerContainer)6// Vue.component(DragContainer.name, DragContainer)7// }8// export default {9// install...
Using AI Code Generation
1var tracetest = require('tracetest');2var win = Ti.UI.createWindow({3});4var btn = Ti.UI.createButton({5});6btn.addEventListener('click', function() {7 tracetest.openDrawer();8});9win.add(btn);10win.open();11exports.openDrawer = function() {12 var drawer = Ti.UI.createDrawerLayout({13 leftView: Ti.UI.createView({14 }),15 centerView: Ti.UI.createView({16 })17 });18 drawer.open();19};
Using AI Code Generation
1var tracetest = require("tracetest");2console.log(tracetest.DrawerContainer);3var tracetest = require("tracetest");4console.log(tracetest.DrawerContainer);5var tracetest = require("tracetest");6console.log(tracetest.DrawerContainer);7var tracetest = require("tracetest");8console.log(tracetest.DrawerContainer);9var tracetest = require("tracetest");10console.log(tracetest.DrawerContainer);11var tracetest = require("tracetest");12console.log(tracetest.DrawerContainer);13var tracetest = require("tracetest");14console.log(tracetest.DrawerContainer);15var tracetest = require("tracetest");16console.log(tracetest.DrawerContainer);17var tracetest = require("tracetest");18console.log(tracetest.DrawerContainer);19var tracetest = require("tracetest");20console.log(tracetest.DrawerContainer);21var tracetest = require("tracetest");22console.log(tracetest.DrawerContainer);23var tracetest = require("tracetest");24console.log(tracetest.DrawerContainer);25var tracetest = require("tracetest");26console.log(tracetest.DrawerContainer);
Using AI Code Generation
1var drawer = new DrawerContainer();2drawer.open();3drawer.close();4drawer.open();5drawer.close();6drawer.open();7drawer.close();8drawer.open();9drawer.close();10function DrawerContainer() {11 this.open = function() {12 console.log("Drawer Opened");13 };14 this.close = function() {15 console.log("Drawer Closed");16 };17}18var drawer = new DrawerContainer();19drawer.open();20drawer.close();21drawer.open();22drawer.close();23drawer.open();24drawer.close();25drawer.open();26drawer.close();27function DrawerContainer() {28 this.open = function() {29 console.log("Drawer Opened");30 };31 this.close = function() {32 console.log("Drawer Closed");33 };34}35var drawer = new DrawerContainer();36drawer.open();37drawer.close();38drawer.open();39drawer.close();40drawer.open();41drawer.close();42drawer.open();43drawer.close();44function DrawerContainer() {45 this.open = function() {46 console.log("Drawer Opened");47 };48 this.close = function() {49 console.log("Drawer Closed");50 };51}52var drawer = new DrawerContainer();53drawer.open();54drawer.close();55drawer.open();56drawer.close();57drawer.open();58drawer.close();59drawer.open();60drawer.close();61function DrawerContainer() {62 this.open = function() {63 console.log("Drawer Opened");64 };65 this.close = function() {66 console.log("Drawer Closed");67 };68}69var drawer = new DrawerContainer();70drawer.open();71drawer.close();72drawer.open();73drawer.close();74drawer.open();75drawer.close();76drawer.open();77drawer.close();78function DrawerContainer() {79 this.open = function() {80 console.log("Drawer Opened");81 };82 this.close = function() {83 console.log("Drawer Closed");84 };85}86var drawer = new DrawerContainer();87drawer.open();88drawer.close();89drawer.open();90drawer.close();91drawer.open();92drawer.close();93drawer.open();94drawer.close();
Using AI Code Generation
1var tracetest = require('tracetest');2var drawerContainer = tracetest.createDrawerContainer();3drawerContainer.close();4exports.createDrawerContainer = function() {5 var drawerContainer = Ti.UI.createView({6 });7 drawerContainer.open = function() {8 console.log('drawerContainer.open was called');9 };10 drawerContainer.close = function() {11 console.log('drawerContainer.close was called');12 };13 drawerContainer.toggle = function() {14 console.log('drawerContainer.toggle was called');15 };16 return drawerContainer;17};
Using AI Code Generation
1var tracetest = require('tracetest');2var drawer = tracetest.DrawerContainer();3drawer.setDrawerCount(3);4drawer.setDrawerHeight(100);5drawer.setDrawerWidth(100);6drawer.setDrawerDepth(100);7drawer.setDrawerCount(5);8drawer.setDrawerHeight(50);9drawer.setDrawerWidth(50);10drawer.setDrawerDepth(50);11console.log(drawer.getDrawerCount());12console.log(drawer.getDrawerHeight());13console.log(drawer.getDrawerWidth());14console.log(drawer.getDrawerDepth());15drawer.printDrawerDimensions();16exports.DrawerContainer = function() {17 var drawerCount = 0;18 var drawerHeight = 0;19 var drawerWidth = 0;20 var drawerDepth = 0;21 return {22 setDrawerCount: function(count) {23 drawerCount = count;24 },25 setDrawerHeight: function(height) {26 drawerHeight = height;27 },28 setDrawerWidth: function(width) {29 drawerWidth = width;30 },31 setDrawerDepth: function(depth) {32 drawerDepth = depth;33 },34 getDrawerCount: function() {35 return drawerCount;36 },37 getDrawerHeight: function() {38 return drawerHeight;39 },40 getDrawerWidth: function() {41 return drawerWidth;42 },43 getDrawerDepth: function() {44 return drawerDepth;45 },46 printDrawerDimensions: function() {47 console.log("Drawer " + drawerCount + " " + drawerHeight + " " + drawerWidth + " " + drawerDepth);48 }49 };50};
Using AI Code Generation
1var drawerContainer = new DrawerContainer();2drawerContainer.setDrawerWidth(100);3drawerContainer.setDrawerHeight(50);4drawerContainer.setDrawerColor('red');5drawerContainer.setDrawerPosition(10, 10);6var DrawerContainer = function() {7 var drawerWidth = 0;8 var drawerHeight = 0;9 var drawerColor = 'black';10 var drawerPositionX = 0;11 var drawerPositionY = 0;12 this.setDrawerWidth = function(width) {13 drawerWidth = width;14 };15 this.setDrawerHeight = function(height) {16 drawerHeight = height;17 };18 this.setDrawerColor = function(color) {19 drawerColor = color;20 };21 this.setDrawerPosition = function(x, y) {22 drawerPositionX = x;23 drawerPositionY = y;24 };25};26test.js:2:6:var drawerContainer = new DrawerContainer(); 27test.js:3:6:drawerContainer.setDrawerWidth(100); 28test.js:4:6:drawerContainer.setDrawerHeight(50); 29test.js:5:6:drawerContainer.setDrawerColor('red'); 30test.js:6:6:drawerContainer.setDrawerPosition(10, 10); 31tracetest.js:2:6:var drawerWidth = 0; 32tracetest.js:3:6:var drawerHeight = 0; 33tracetest.js:4:6:var drawerColor = 'black'; 34tracetest.js:5:6:var drawerPositionX = 0; 35tracetest.js:6:6:var drawerPositionY = 0; 36tracetest.js:9:6:this.setDrawerWidth = function(width) { 37tracetest.js:10:8:drawerWidth = width; 38tracetest.js:12:6:this.setDrawerHeight = function(height) { 39tracetest.js:13:8:drawerHeight = height; 40tracetest.js:15:6:this.setDrawerColor = function(color) { 41tracetest.js:16:8:drawerColor = color; 42tracetest.js:18:6:this.setDrawerPosition = function(x, y) {
Using AI Code Generation
1var drawerContainer = require('tracetest');2var drawer = drawerContainer.createDrawer(100, 100);3drawer.open();4drawer.close();5drawer.open();6drawer.close();7drawer.open();8drawer.close();9var drawerContainer = require('tracetest');10var drawer = drawerContainer.createDrawer(100, 100);11drawer.open();12drawer.close();13drawer.open();14drawer.close();15drawer.open();16drawer.close();17[ERROR] TiExceptionHandler: (main) [0,
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!!