Best Python code snippet using websmith_python
event.js
Source:event.js
...264 // Opera < 11 doesn't implement any interface we can use, so give it a pass265 ok( true, "isDefaultPrevented not supported by this browser, test skipped" );266 }267 });268 fakeClick( $anchor2 );269 $anchor2.unbind( "click" );270 $main.undelegate( "click" );271 $anchor2.click(function(e) {272 // Let the default action occur273 });274 $main.delegate("#foo", "click", function(e) {275 equals( e.isDefaultPrevented(), false, "isDefaultPrevented false passed to bubbled event" );276 });277 fakeClick( $anchor2 );278 $anchor2.unbind( "click" );279 $main.undelegate( "click" );280});281test("bind(), iframes", function() {282 // events don't work with iframes, see #939 - this test fails in IE because of contentDocument283 var doc = jQuery("#loadediframe").contents();284 jQuery("div", doc).bind("click", function() {285 ok( true, "Binding to element inside iframe" );286 }).click().unbind('click');287});288test("bind(), trigger change on select", function() {289 expect(5);290 var counter = 0;291 function selectOnChange(event) {...
events.spec.js
Source:events.spec.js
1import { patch } from 'web/runtime/patch'2import VNode from 'core/vdom/vnode'3describe('vdom events module', () => {4 it('should attach event handler to element', () => {5 const click = jasmine.createSpy()6 const vnode = new VNode('a', { on: { click }})7 const elm = patch(null, vnode)8 document.body.appendChild(elm)9 triggerEvent(elm, 'click')10 expect(click.calls.count()).toBe(1)11 })12 it('should not duplicate the same listener', () => {13 const click = jasmine.createSpy()14 const vnode1 = new VNode('a', { on: { click }})15 const vnode2 = new VNode('a', { on: { click }})16 const elm = patch(null, vnode1)17 patch(vnode1, vnode2)18 document.body.appendChild(elm)19 triggerEvent(elm, 'click')20 expect(click.calls.count()).toBe(1)21 })22 it('should update different listener', () => {23 const click = jasmine.createSpy()24 const click2 = jasmine.createSpy()25 const vnode1 = new VNode('a', { on: { click }})26 const vnode2 = new VNode('a', { on: { click: click2 }})27 const elm = patch(null, vnode1)28 document.body.appendChild(elm)29 triggerEvent(elm, 'click')30 expect(click.calls.count()).toBe(1)31 expect(click2.calls.count()).toBe(0)32 patch(vnode1, vnode2)33 triggerEvent(elm, 'click')34 expect(click.calls.count()).toBe(1)35 expect(click2.calls.count()).toBe(1)36 })37 it('should attach Array of multiple handlers', () => {38 const click = jasmine.createSpy()39 const vnode = new VNode('a', { on: { click: [click, click] }})40 const elm = patch(null, vnode)41 document.body.appendChild(elm)42 triggerEvent(elm, 'click')43 expect(click.calls.count()).toBe(2)44 })45 it('should update Array of multiple handlers', () => {46 const click = jasmine.createSpy()47 const click2 = jasmine.createSpy()48 const vnode1 = new VNode('a', { on: { click: [click, click2] }})49 const vnode2 = new VNode('a', { on: { click: [click] }})50 const elm = patch(null, vnode1)51 document.body.appendChild(elm)52 triggerEvent(elm, 'click')53 expect(click.calls.count()).toBe(1)54 expect(click2.calls.count()).toBe(1)55 patch(vnode1, vnode2)56 triggerEvent(elm, 'click')57 expect(click.calls.count()).toBe(2)58 expect(click2.calls.count()).toBe(1)59 })60 it('should remove handlers that are no longer present', () => {61 const click = jasmine.createSpy()62 const vnode1 = new VNode('a', { on: { click }})63 const vnode2 = new VNode('a', {})64 const elm = patch(null, vnode1)65 document.body.appendChild(elm)66 triggerEvent(elm, 'click')67 expect(click.calls.count()).toBe(1)68 patch(vnode1, vnode2)69 triggerEvent(elm, 'click')70 expect(click.calls.count()).toBe(1)71 })72 it('should remove Array handlers that are no longer present', () => {73 const click = jasmine.createSpy()74 const vnode1 = new VNode('a', { on: { click: [click, click] }})75 const vnode2 = new VNode('a', {})76 const elm = patch(null, vnode1)77 document.body.appendChild(elm)78 triggerEvent(elm, 'click')79 expect(click.calls.count()).toBe(2)80 patch(vnode1, vnode2)81 triggerEvent(elm, 'click')82 expect(click.calls.count()).toBe(2)83 })84 // #465085 it('should handle single -> array or array -> single handler changes', () => {86 const click = jasmine.createSpy()87 const click2 = jasmine.createSpy()88 const click3 = jasmine.createSpy()89 const vnode0 = new VNode('a', { on: { click: click }})90 const vnode1 = new VNode('a', { on: { click: [click, click2] }})91 const vnode2 = new VNode('a', { on: { click: click }})92 const vnode3 = new VNode('a', { on: { click: [click2, click3] }})93 const elm = patch(null, vnode0)94 document.body.appendChild(elm)95 triggerEvent(elm, 'click')96 expect(click.calls.count()).toBe(1)97 expect(click2.calls.count()).toBe(0)98 patch(vnode0, vnode1)99 triggerEvent(elm, 'click')100 expect(click.calls.count()).toBe(2)101 expect(click2.calls.count()).toBe(1)102 patch(vnode1, vnode2)103 triggerEvent(elm, 'click')104 expect(click.calls.count()).toBe(3)105 expect(click2.calls.count()).toBe(1)106 patch(vnode2, vnode3)107 triggerEvent(elm, 'click')108 expect(click.calls.count()).toBe(3)109 expect(click2.calls.count()).toBe(2)110 expect(click3.calls.count()).toBe(1)111 })...
min.js
Source:min.js
1$(document).ready(function(){2 // BOX 1 BUTTON FUNCTION3 $('#me1').click(function(){4 $(this).css("opacity","0");5 })6 $('#me1').click(function(){7 $('#me2').hide();8 })9 $('#me1').click(function(){10 $('#me3').css("display","block");11 })12 $('#me3').click(function(){13 $('#me1').css("opacity","1");14 })15 $('#me3').click(function(){16 $('#me2').show();17 })18 $('#me3').click(function(){19 $(this).hide();20 })21 $('#me2').click(function(){22 $('.box1').hide();23 })2425 // BOX 1 BUTTON FUNCTION26 $('#you1').click(function(){27 $(this).css("opacity","0");28 })29 $('#you1').click(function(){30 $('#you2').hide();31 })32 $('#you1').click(function(){33 $('#you3').css("display","block");34 })35 $('#you3').click(function(){36 $('#you1').css("opacity","1");37 })38 $('#you3').click(function(){39 $('#you2').show();40 })41 $('#you3').click(function(){42 $(this).hide();43 })44 $('#you2').click(function(){45 $('.box2').hide();46 })474849 // FRIEND REQUEST50 $('#me1').click(function(){51 $('#you4').css("display","block")52 })53 $('#me1').click(function(){54 $('#you5').css("display","block")55 })56 $('#me1').click(function(){57 $('#you1').hide()58 })59 $('#me1').click(function(){60 $('#you2').hide()61 })62 $('#me3').click(function(){63 $('#you4').hide();64 })65 $('#me3').click(function(){66 $('#you5').hide();67 })68 $('#me3').click(function(){69 $('#you1').show();70 })71 $('#me3').click(function(){72 $('#you2').show();73 })747576 $('#you1').click(function(){77 $('#me1').hide();78 })79 $('#you1').click(function(){80 $('#me2').hide();81 })82 $('#you1').click(function(){83 $('#me4').css("display","block")84 })85 $('#you1').click(function(){86 $('#me5').css("display","block")87 })88 $('#you3').click(function(){89 $('#me4').hide();90 })91 $('#you3').click(function(){92 $('#me5').hide();93 })94 $('#you3').click(function(){95 $('#me1').show();96 })97 $('#you3').click(function(){98 $('#me2').show();99 })100101// DELETE FRIEND102 $('#you5').click(function(){103 $('.box2').hide();104 })105 $('#me5').click(function(){106 $('.box1').hide();107 })108109110// CONFIRM111 $('#you4').click(function(){112 $('#me6').css("display","block")113 })114 $('#you4').click(function(){115 $('#me7').css("display","block")116 })117 $('#you4').click(function(){118 $('#me1').hide();119 })120 $('#you4').click(function(){121 $('#me3').hide();122 })123124125126 $('#me4').click(function(){127 $('#you6').css("display","block")128 })129 $('#me4').click(function(){130 $('#you7').css("display","block")131 })132 $('#me4').click(function(){133 $('#you1').hide();134 })135 $('#me4').click(function(){136 $('#you3').hide();137 })138139// CONFIRM MESSAGE ME140 $('#me4').click(function(){141 $(this).hide();142 })143 $('#me4').click(function(){144 $('#me5').hide();145 })146 $('#me4').click(function(){147 $('#me6').show();148 })149 $('#me4').click(function(){150 $('#me7').show();151 })152153154155 $('#you4').click(function(){156 $(this).hide();157 })158 $('#you4').click(function(){159 $('#you5').hide();160 })161 $('#you4').click(function(){162 $('#you6').show();163 })164 $('#you4').click(function(){165 $('#you7').show();166 });167168169// ALERT170 $('#me6').click(function(){171 alert("Coming Soon")172 })173 $('#you6').click(function(){174 alert("Coming Soon")175 })176177178
...
main.js
Source:main.js
1 /* global TweenMax, Power1, Power3, Power2 */2$('#contact-car').hide();3 $('#contact-bus').hide();4 $('#contact-bike').hide();5 $('#contact-phone').hide();6 $('#contact-mail').hide();7 $('#contact-carClick').removeClass("active");8 $('#contact-busClick').removeClass("active");9 $('#contact-bikeClick').removeClass("active");10 $('#contact-phoneClick').removeClass("active");11 $('#contact-mailClick').removeClass("active");12 $('#contact-map').show();13 $("#contact-mapClick").addClass("active");14// contact page toogles15$("#contact-carClick").click(function () {16 $('#contact-map').hide();17 $('#contact-bus').hide();18 $('#contact-bike').hide();19 $('#contact-phone').hide();20 $('#contact-mail').hide();21 $('#contact-mapClick').removeClass("active");22 $('#contact-busClick').removeClass("active");23 $('#contact-bikeClick').removeClass("active");24 $('#contact-phoneClick').removeClass("active");25 $('#contact-mailClick').removeClass("active");26 $('#contact-car').show();27 $("#contact-carClick").addClass("active");28});29$("#contact-mapClick").click(function () {30 $('#contact-car').hide();31 $('#contact-bus').hide();32 $('#contact-bike').hide();33 $('#contact-phone').hide();34 $('#contact-mail').hide();35 $('#contact-carClick').removeClass("active");36 $('#contact-busClick').removeClass("active");37 $('#contact-bikeClick').removeClass("active");38 $('#contact-phoneClick').removeClass("active");39 $('#contact-mailClick').removeClass("active");40 $('#contact-map').show();41 $("#contact-mapClick").addClass("active");42});43$("#contact-busClick").click(function () {44 $('#contact-map').hide();45 $('#contact-car').hide();46 $('#contact-bike').hide();47 $('#contact-phone').hide();48 $('#contact-mail').hide();49 $('#contact-mapClick').removeClass("active");50 $('#contact-carClick').removeClass("active");51 $('#contact-bikeClick').removeClass("active");52 $('#contact-phoneClick').removeClass("active");53 $('#contact-mailClick').removeClass("active");54 $('#contact-bus').show();55 $("#contact-busClick").addClass("active");56});57$("#contact-bikeClick").click(function () {58 $('#contact-map').hide();59 $('#contact-car').hide();60 $('#contact-bus').hide();61 $('#contact-phone').hide();62 $('#contact-mail').hide();63 $('#contact-mapClick').removeClass("active");64 $('#contact-carClick').removeClass("active");65 $('#contact-busClick').removeClass("active");66 $('#contact-phoneClick').removeClass("active");67 $('#contact-mailClick').removeClass("active");68 $('#contact-bike').show();69 $("#contact-bikeClick").addClass("active");70});71$("#contact-phoneClick").click(function () {72 $('#contact-map').hide();73 $('#contact-car').hide();74 $('#contact-bus').hide();75 $('#contact-bike').hide();76 $('#contact-mail').hide();77 $('#contact-mapClick').removeClass("active");78 $('#contact-carClick').removeClass("active");79 $('#contact-busClick').removeClass("active");80 $('#contact-bikeClick').removeClass("active");81 $('#contact-mailClick').removeClass("active");82 $('#contact-phone').show();83 $("#contact-phoneClick").addClass("active");84});85$("#contact-mailClick").click(function () {86 $('#contact-map').hide();87 $('#contact-car').hide();88 $('#contact-bus').hide();89 $('#contact-bike').hide();90 $('#contact-phone').hide();91 $('#contact-mapClick').removeClass("active");92 $('#contact-carClick').removeClass("active");93 $('#contact-busClick').removeClass("active");94 $('#contact-bikeClick').removeClass("active");95 $('#contact-phoneClick').removeClass("active");96 $('#contact-mail').show();97 $("#contact-mailClick").addClass("active");...
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!!