Best JavaScript code snippet using root
agile.exlist.js
Source:agile.exlist.js
1//å表æ©å±2(function($) {34 ExList = {};56 function _controller(getli, option) {78 var $selector_li = null;910 function _init() {11 $selector_li = getli();1213 _init_dom();14 }1516 var swipe_option_width = null;1718 var exlist_left_div_width = null;1920 var status_code = {21 'left': 0,22 'normal': 1,23 'right': 224 };2526 var status = status_code.normal;2728 function _init_dom() {29 $selector_li.addClass('swipe_block');3031 $selector_li.each(function() {32 if ($(this).find('.swipe_option').length == 0) {33 $(this).append('<div class="swipe_option"></div>');34 }35 if ($(this).find('.exlist_left_div').length == 0) {36 $(this).append('<div class="exlist_left_div"></div>');37 }38 });3940 $selector_li.find('.swipe_option').html(option.rightContent);4142 $selector_li.find('.exlist_left_div').html(option.leftContent);4344 swipe_option_width = $selector_li.children('.swipe_option').css('width');4546 exlist_left_div_width = $selector_li.children('.exlist_left_div').css('width');4748 $selector_li.children('.swipe_option').css('right', '-' + swipe_option_width);4950 $selector_li.children('.exlist_left_div').css('left', '-' + exlist_left_div_width);5152 $selector_li.off('swipeleft').on('swipeleft', swipeleft);53 }5455 function fallback_swipeleft(e) {56 $selector_li.parent().find('li').animate({57 left: '0px'58 }, 100);59 status = status_code.normal;60 $selector_li.off('swipeleft').on('swipeleft', swipeleft);61 }6263 function swipeleft(e) {64 var _li_element = $(e.currentTarget);6566 fallback_swipeleft();6768 _li_element.animate({69 left: '-' + swipe_option_width70 }, 100);7172 $selector_li.parent().find('li').children(':not(.swipe_option)').off('tap', fallback_swipeleft).on('tap', fallback_swipeleft);7374 _li_element.off('swiperight', fallback_swipeleft).on('swiperight', fallback_swipeleft);7576 _li_element.children(':not(.swipe_option)').off('tap').on('tap', function() {77 _li_element.animate({78 left: '0px'79 }, 100);80 _li_element.children(':not(.swipe_option)').off('tap');81 return false;82 });8384 _li_element.children('.swipe_option').off('tap').on('tap', function(e) {85 option.swipeOptionOnTap && option.swipeOptionOnTap(_li_element, $(e.target));86 return false;87 });8889 status = status_code.right;90 }9192 function _showLeft() {93 $selector_li.animate({94 left: exlist_left_div_width95 }, 100);96 $selector_li.off('swipeleft');97 $selector_li.parent().find('li').children(':not(.swipe_option)').off('tap', fallback_swipeleft);98 status = status_code.left;99 }100101 function _hideLeft() {102 $selector_li.animate({103 left: '0px'104 }, 100);105 $selector_li.off('swipeleft').on('swipeleft', swipeleft);106 status = status_code.normal;107 }108109 function _refresh() {110 _init();111 }112113 _init();114115 return {116 showLeft: _showLeft,117 hideLeft: _hideLeft,118 refresh: _refresh,119 hideOne: function(el) {120 var _el = $(el);121 _el.animate({122 left: '0px'123 }, 100);124 }125 };126 }127128 ExList.liController = function($selector, opt) {129 return (function($selector, opt) {130 var option = {131 leftContent: '<div style="width:100%;height:100%;padding: 12px;"><input class="exlist_checkbox" type="checkbox"/></div>',132 rightContent: '<div style="width:100%;height:100%;background-color: #FF2D2D;text-align: center;padding: 12px;color: #FFFFFF;">å é¤</div>'133 };134135 $.extend(option, opt);136137 return _controller(function() {138 var _$selector = $($selector);139 return _$selector;140 }, option);141142 })($selector, opt);143 };144145 ExList.ulController = function($selector, opt) {146147 return (function($selector, opt) {148 var option = {149 leftContent: '<div style="width:100%;height:100%;padding: 12px;"><input class="exlist_checkbox" type="checkbox"/></div>',150 rightContent: '<div style="width:100%;height:100%;background-color: #FF2D2D;text-align: center;padding: 12px;color: #FFFFFF;">å é¤</div>'151 };152153 $.extend(option, opt);154155 return _controller(function() {156 var _$selector = $($selector);157 return _$selector.find('li');158 }, option);159160 })($selector, opt);161 };162163 A.register('ExList', ExList);
...
binding_tests_core.js
Source:binding_tests_core.js
1test( "Unbinding swipeleft leaves swiperight handler alone", function() {2 var dummy = function() {},3 swipeLength = function() {4 var swipe = $._data( document, "events" ).swipe;5 return swipe ? swipe.length : 0;6 },7 initialSwipeLength = swipeLength();8 $( document ).on( "swipeleft swiperight", ".ui-page", dummy );9 deepEqual( swipeLength(), initialSwipeLength + 2,10 "Two swipe handlers are present after attaching swipeleft and swiperight" );11 $( document ).off( "swipeleft", ".ui-page", dummy );12 deepEqual( swipeLength(), initialSwipeLength + 1,13 "One swipe handler is present after detaching swipeleft" );14 $( document ).on( "swipeleft", ".ui-page", dummy );15 deepEqual( swipeLength(), initialSwipeLength + 2,16 "Two swipe handlers are present after reattaching swipeleft" );17 $( document ).off( "swiperight", ".ui-page", dummy );18 deepEqual( swipeLength(), initialSwipeLength + 1,19 "One swipe handler is present after detaching swiperight" );20 $( document ).on( "swiperight", ".ui-page", dummy );21 deepEqual( swipeLength(), initialSwipeLength + 2,22 "Two swipe handlers are present after reattaching swiperight" );23 $( document ).off( "swipeleft swiperight", ".ui-page", dummy );24 deepEqual( swipeLength(), initialSwipeLength,25 "No swipe handlers are present after detaching both swipeleft and swiperight" );...
Using AI Code Generation
1var root = UIATarget.localTarget().frontMostApp().mainWindow();2root.swipeLeft();3root.swipeRight();4root.swipeUp();5root.swipeDown();6root.tap();7root.doubleTap();8root.twoFingerTap();9root.tapWithOptions({tapOffset:{x:0.50, y:0.50}});10root.doubleTapWithOptions({tapOffset:{x:0.50, y:0.50}});11root.twoFingerTapWithOptions({tapOffset:{x:0.50, y:0.50}});12root.pinchClose();13root.pinchOpen();14root.rotateWithOptions({startOffset:{x:0.50, y:0.50}, endOffset:{x:0.50, y:0.50}, duration:0.50});15root.dragInsideWithOptions({startOffset:{x:0.50, y:0.50}, endOffset:{x:0.50, y:0.50}});16root.dragOutsideWithOptions({startOffset:{x:0.50, y:0.50}, endOffset:{x:0.50, y:0.50}});17root.scrollToVisible();18root.scrollDown();19root.scrollUp();20root.scrollLeft();21root.scrollRight();22root.logElementTree();
Using AI Code Generation
1$.rootView.swipeLeft(function(e) {2 Ti.API.info("swipeLeft");3});4$.rootView.swipeRight(function(e) {5 Ti.API.info("swipeRight");6});7$.rootView.swipeUp(function(e) {8 Ti.API.info("swipeUp");9});10$.rootView.swipeDown(function(e) {11 Ti.API.info("swipeDown");12});13$.rootView.swipe(function(e) {14 Ti.API.info("swipe");15});16$.view1.swipeLeft(function(e) {17 Ti.API.info("swipeLeft");18});19$.view1.swipeRight(function(e) {20 Ti.API.info("swipeRight");21});22$.view1.swipeUp(function(e) {23 Ti.API.info("swipeUp");24});25$.view1.swipeDown(function(e) {26 Ti.API.info("swipeDown");27});28$.view1.swipe(function(e) {29 Ti.API.info("swipe");30});31$.view2.swipeLeft(function(e) {32 Ti.API.info("swipeLeft");33});34$.view2.swipeRight(function(e) {35 Ti.API.info("swipeRight");36});37$.view2.swipeUp(function(e) {38 Ti.API.info("swipeUp");39});40$.view2.swipeDown(function(e) {41 Ti.API.info("swipeDown");42});43$.view2.swipe(function(e) {44 Ti.API.info("swipe");45});46$.view3.swipeLeft(function(e) {47 Ti.API.info("swipeLeft");48});49$.view3.swipeRight(function(e) {
Using AI Code Generation
1var win = Ti.UI.createWindow({2});3var view = Ti.UI.createView({4});5win.add(view);6win.open();7view.addEventListener('swipe', function (e) {8 Ti.API.info('swipe event fired');9});10view.addEventListener('swipeLeft', function (e) {11 Ti.API.info('swipeLeft event fired');12});13view.addEventListener('swipeRight', function (e) {14 Ti.API.info('swipeRight event fired');15});16view.addEventListener('swipeUp', function (e) {17 Ti.API.info('swipeUp event fired');18});19view.addEventListener('swipeDown', function (e) {20 Ti.API.info('swipeDown event fired');21});
Using AI Code Generation
1var root = element(by.css('body'));2root.swipeLeft();3var root = element(by.css('body'));4root.swipeRight();5var root = element(by.css('body'));6root.swipeUp();7var root = element(by.css('body'));8root.swipeDown();9var root = element(by.css('body'));10root.tap();11var root = element(by.css('body'));12root.doubleTap();13var root = element(by.css('body'));14root.longPress();15var root = element(by.css('body'));16root.touchAndHold();17var root = element(by.css('body'));18root.release();19var root = element(by.css('body'));20root.performTouchAction();21var root = element(by.css('body'));22root.performMultiAction();23var root = element(by.css('body'));24root.getLocation();25var root = element(by.css('body'));26root.getSize();
Using AI Code Generation
1var win = Ti.UI.createWindow({2});3var view = Ti.UI.createView({4});5win.add(view);6win.addEventListener('swipe', function(e) {7 Ti.API.info('swipe');8});9view.addEventListener('swipe', function(e) {10 Ti.API.info('swipe on view');11});12win.open();
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!!