How to use click method in Robotframework-anywherelibrary

Best Python code snippet using robotframework-anywherelibrary

event.js

Source:event.js Github

copy

Full Screen

2test("null or undefined handler", function() {3 expect(2);4 // Supports Fixes bug #72295 try {6 jQuery("#firstp").click(null);7 ok(true, "Passing a null handler will not throw an exception");8 } catch (e) {}9 try {10 jQuery("#firstp").click(undefined);11 ok(true, "Passing an undefined handler will not throw an exception");12 } catch (e) {}13});14test("bind(), with data", function() {15 expect(3);16 var handler = function(event) {17 ok( event.data, "bind() with data, check passed data exists" );18 equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );19 };20 jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);21 ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );22});23test("click(), with data", function() {24 expect(3);25 var handler = function(event) {26 ok( event.data, "bind() with data, check passed data exists" );27 equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );28 };29 jQuery("#firstp").click({foo: "bar"}, handler).click().unbind("click", handler);30 ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );31});32test("bind(), with data, trigger with data", function() {33 expect(4);34 var handler = function(event, data) {35 ok( event.data, "check passed data exists" );36 equals( event.data.foo, "bar", "Check value of passed data" );37 ok( data, "Check trigger data" );38 equals( data.bar, "foo", "Check value of trigger data" );39 };40 jQuery("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]).unbind("click", handler);41});42test("bind(), multiple events at once", function() {43 expect(2);44 var clickCounter = 0,45 mouseoverCounter = 0;46 var handler = function(event) {47 if (event.type == "click")48 clickCounter += 1;49 else if (event.type == "mouseover")50 mouseoverCounter += 1;51 };52 jQuery("#firstp").bind("click mouseover", handler).trigger("click").trigger("mouseover");53 equals( clickCounter, 1, "bind() with multiple events at once" );54 equals( mouseoverCounter, 1, "bind() with multiple events at once" );55});56test("bind(), multiple events at once and namespaces", function() {57 expect(7);58 var cur, obj = {};59 var div = jQuery("<div/>").bind("focusin.a", function(e) {60 equals( e.type, cur, "Verify right single event was fired." );61 });62 cur = "focusin";63 div.trigger("focusin.a");64 // manually clean up detached elements65 div.remove();66 div = jQuery("<div/>").bind("click mouseover", obj, function(e) {67 equals( e.type, cur, "Verify right multi event was fired." );68 equals( e.data, obj, "Make sure the data came in correctly." );69 });70 cur = "click";71 div.trigger("click");72 cur = "mouseover";73 div.trigger("mouseover");74 // manually clean up detached elements75 div.remove();76 div = jQuery("<div/>").bind("focusin.a focusout.b", function(e) {77 equals( e.type, cur, "Verify right multi event was fired." );78 });79 cur = "focusin";80 div.trigger("focusin.a");81 cur = "focusout";82 div.trigger("focusout.b");83 // manually clean up detached elements84 div.remove();85});86test("bind(), namespace with special add", function() {87 expect(24);88 var div = jQuery("<div/>").bind("test", function(e) {89 ok( true, "Test event fired." );90 });91 var i = 0;92 jQuery.event.special.test = {93 _default: function(e) {94 equals( this, document, "Make sure we're at the top of the chain." );95 equals( e.type, "test", "And that we're still dealing with a test event." );96 equals( e.target, div[0], "And that the target is correct." );97 },98 setup: function(){},99 teardown: function(){100 ok(true, "Teardown called.");101 },102 add: function( handleObj ) {103 var handler = handleObj.handler;104 handleObj.handler = function(e) {105 e.xyz = ++i;106 handler.apply( this, arguments );107 };108 },109 remove: function() {110 ok(true, "Remove called.");111 }112 };113 div.bind("test.a", {x: 1}, function(e) {114 ok( !!e.xyz, "Make sure that the data is getting passed through." );115 equals( e.data.x, 1, "Make sure data is attached properly." );116 });117 div.bind("test.b", {x: 2}, function(e) {118 ok( !!e.xyz, "Make sure that the data is getting passed through." );119 equals( e.data.x, 2, "Make sure data is attached properly." );120 });121 // Should trigger 5122 div.trigger("test");123 // Should trigger 2124 div.trigger("test.a");125 // Should trigger 2126 div.trigger("test.b");127 // Should trigger 4128 div.unbind("test");129 div = jQuery("<div/>").bind("test", function(e) {130 ok( true, "Test event fired." );131 });132 // Should trigger 2133 div.appendTo("#main").remove();134 delete jQuery.event.special.test;135});136test("bind(), no data", function() {137 expect(1);138 var handler = function(event) {139 ok ( !event.data, "Check that no data is added to the event object" );140 };141 jQuery("#firstp").bind("click", handler).trigger("click");142});143test("bind/one/unbind(Object)", function(){144 expect(6);145 var clickCounter = 0, mouseoverCounter = 0;146 function handler(event) {147 if (event.type == "click")148 clickCounter++;149 else if (event.type == "mouseover")150 mouseoverCounter++;151 };152 function handlerWithData(event) {153 if (event.type == "click")154 clickCounter += event.data;155 else if (event.type == "mouseover")156 mouseoverCounter += event.data;157 };158 function trigger(){159 $elem.trigger("click").trigger("mouseover");160 }161 var $elem = jQuery("#firstp")162 // Regular bind163 .bind({164 click:handler,165 mouseover:handler166 })167 // Bind with data168 .one({169 click:handlerWithData,170 mouseover:handlerWithData171 }, 2 );172 trigger();173 equals( clickCounter, 3, "bind(Object)" );174 equals( mouseoverCounter, 3, "bind(Object)" );175 trigger();176 equals( clickCounter, 4, "bind(Object)" );177 equals( mouseoverCounter, 4, "bind(Object)" );178 jQuery("#firstp").unbind({179 click:handler,180 mouseover:handler181 });182 trigger();183 equals( clickCounter, 4, "bind(Object)" );184 equals( mouseoverCounter, 4, "bind(Object)" );185});186test("live/die(Object), delegate/undelegate(String, Object)", function() {187 expect(6);188 var clickCounter = 0, mouseoverCounter = 0,189 $p = jQuery("#firstp"), $a = $p.find("a:first");190 var events = {191 click: function( event ) {192 clickCounter += ( event.data || 1 );193 },194 mouseover: function( event ) {195 mouseoverCounter += ( event.data || 1 );196 }197 };198 function trigger() {199 $a.trigger("click").trigger("mouseover");200 }201 $a.live( events );202 $p.delegate( "a", events, 2 );203 trigger();204 equals( clickCounter, 3, "live/delegate" );205 equals( mouseoverCounter, 3, "live/delegate" );206 $p.undelegate( "a", events );207 trigger();208 equals( clickCounter, 4, "undelegate" );209 equals( mouseoverCounter, 4, "undelegate" );210 $a.die( events );211 trigger();212 equals( clickCounter, 4, "die" );213 equals( mouseoverCounter, 4, "die" );214});215test("live/delegate immediate propagation", function() {216 expect(2);217 var $p = jQuery("#firstp"), $a = $p.find("a:first"), lastClick;218 lastClick = "";219 $a.live( "click", function(e) {220 lastClick = "click1";221 e.stopImmediatePropagation();222 });223 $a.live( "click", function(e) {224 lastClick = "click2";225 });226 $a.trigger( "click" );227 equals( lastClick, "click1", "live stopImmediatePropagation" );228 $a.die( "click" );229 lastClick = "";230 $p.delegate( "a", "click", function(e) {231 lastClick = "click1";232 e.stopImmediatePropagation();233 });234 $p.delegate( "a", "click", function(e) {235 lastClick = "click2";236 });237 $a.trigger( "click" );238 equals( lastClick, "click1", "delegate stopImmediatePropagation" );239 $p.undelegate( "click" );240});241test("bind/delegate bubbling, isDefaultPrevented", function() {242 expect(2);243 var $anchor2 = jQuery( "#anchor2" ),244 $main = jQuery( "#main" ),245 fakeClick = function($jq) {246 // Use a native click so we don't get jQuery simulated bubbling247 if ( document.createEvent ) {248 var e = document.createEvent( 'MouseEvents' );249 e.initEvent( "click", true, true );250 $jq[0].dispatchEvent(e);251 }252 else if ( $jq[0].click ) {253 $jq[0].click(); // IE254 }255 };256 $anchor2.click(function(e) {257 e.preventDefault();258 });259 $main.delegate("#foo", "click", function(e) {260 var orig = e.originalEvent;261 if ( typeof(orig.defaultPrevented) === "boolean" || typeof(orig.returnValue) === "boolean" || orig.getPreventDefault ) {262 equals( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );263 } else {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) {292 equals( event.data, counter++, "Event.data is not a global event object" );293 };294 jQuery("#form select").each(function(i){295 jQuery(this).bind('change', i, selectOnChange);296 }).trigger('change');297});298test("bind(), namespaced events, cloned events", 18, function() {299 var firstp = jQuery( "#firstp" );300 firstp.bind("custom.test",function(e){301 ok(false, "Custom event triggered");302 });303 firstp.bind("click",function(e){304 ok(true, "Normal click triggered");305 equal( e.type + e.namespace, "click", "Check that only click events trigger this fn" );306 });307 firstp.bind("click.test",function(e){308 var check = "click";309 ok( true, "Namespaced click triggered" );310 if ( e.namespace ) {311 check += "test";312 }313 equal( e.type + e.namespace, check, "Check that only click/click.test events trigger this fn" );314 });315 //clone(true) element to verify events are cloned correctly316 firstp = firstp.add( firstp.clone( true ).attr( "id", "firstp2" ).insertBefore( firstp ) );317 // Trigger both bound fn (8)318 firstp.trigger("click");319 // Trigger one bound fn (4)320 firstp.trigger("click.test");321 // Remove only the one fn322 firstp.unbind("click.test");323 // Trigger the remaining fn (4)324 firstp.trigger("click");325 // Remove the remaining namespaced fn326 firstp.unbind(".test");327 // Try triggering the custom event (0)328 firstp.trigger("custom");329 // using contents will get comments regular, text, and comment nodes330 jQuery("#nonnodes").contents().bind("tester", function () {331 equals(this.nodeType, 1, "Check node,textnode,comment bind just does real nodes" );332 }).trigger("tester");333 // Make sure events stick with appendTo'd elements (which are cloned) #2027334 jQuery("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("#main");335 ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );336});337test("bind(), multi-namespaced events", function() {338 expect(6);339 var order = [340 "click.test.abc",341 "click.test.abc",342 "click.test",343 "click.test.abc",344 "click.test",345 "custom.test2"346 ];347 function check(name, msg){348 same(name, order.shift(), msg);349 }350 jQuery("#firstp").bind("custom.test",function(e){351 check("custom.test", "Custom event triggered");352 });353 jQuery("#firstp").bind("custom.test2",function(e){354 check("custom.test2", "Custom event triggered");355 });356 jQuery("#firstp").bind("click.test",function(e){357 check("click.test", "Normal click triggered");358 });359 jQuery("#firstp").bind("click.test.abc",function(e){360 check("click.test.abc", "Namespaced click triggered");361 });362 // Those would not trigger/unbind (#5303)363 jQuery("#firstp").trigger("click.a.test");364 jQuery("#firstp").unbind("click.a.test");365 // Trigger both bound fn (1)366 jQuery("#firstp").trigger("click.test.abc");367 // Trigger one bound fn (1)368 jQuery("#firstp").trigger("click.abc");369 // Trigger two bound fn (2)370 jQuery("#firstp").trigger("click.test");371 // Remove only the one fn372 jQuery("#firstp").unbind("click.abc");373 // Trigger the remaining fn (1)374 jQuery("#firstp").trigger("click");375 // Remove the remaining fn376 jQuery("#firstp").unbind(".test");377 // Trigger the remaining fn (1)378 jQuery("#firstp").trigger("custom");379});380test("bind(), with same function", function() {381 expect(2)382 var count = 0, func = function(){383 count++;384 };385 jQuery("#liveHandlerOrder").bind("foo.bar", func).bind("foo.zar", func);386 jQuery("#liveHandlerOrder").trigger("foo.bar");387 equals(count, 1, "Verify binding function with multiple namespaces." );388 jQuery("#liveHandlerOrder").unbind("foo.bar", func).unbind("foo.zar", func);389 jQuery("#liveHandlerOrder").trigger("foo.bar");390 equals(count, 1, "Verify that removing events still work." );391});392test("bind(), make sure order is maintained", function() {393 expect(1);394 var elem = jQuery("#firstp"), log = [], check = [];395 for ( var i = 0; i < 100; i++ ) (function(i){396 elem.bind( "click", function(){397 log.push( i );398 });399 check.push( i );400 })(i);401 elem.trigger("click");402 equals( log.join(","), check.join(","), "Make sure order was maintained." );403 elem.unbind("click");404});405test("bind(), with different this object", function() {406 expect(4);407 var thisObject = { myThis: true },408 data = { myData: true },409 handler1 = function( event ) {410 equals( this, thisObject, "bind() with different this object" );411 },412 handler2 = function( event ) {413 equals( this, thisObject, "bind() with different this object and data" );414 equals( event.data, data, "bind() with different this object and data" );415 };416 jQuery("#firstp")417 .bind("click", jQuery.proxy(handler1, thisObject)).click().unbind("click", handler1)418 .bind("click", data, jQuery.proxy(handler2, thisObject)).click().unbind("click", handler2);419 ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using different this object and data." );420});421test("bind(name, false), unbind(name, false)", function() {422 expect(3);423 var main = 0;424 jQuery("#main").bind("click", function(e){ main++; });425 jQuery("#ap").trigger("click");426 equals( main, 1, "Verify that the trigger happened correctly." );427 main = 0;428 jQuery("#ap").bind("click", false);429 jQuery("#ap").trigger("click");430 equals( main, 0, "Verify that no bubble happened." );431 main = 0;432 jQuery("#ap").unbind("click", false);433 jQuery("#ap").trigger("click");434 equals( main, 1, "Verify that the trigger happened correctly." );435 // manually clean up events from elements outside the fixture436 jQuery("#main").unbind("click");437});438test("bind()/trigger()/unbind() on plain object", function() {439 expect( 7 );440 var obj = {};441 // Make sure it doesn't complain when no events are found442 jQuery(obj).trigger("test");443 // Make sure it doesn't complain when no events are found444 jQuery(obj).unbind("test");445 jQuery(obj).bind({446 test: function() {447 ok( true, "Custom event run." );448 },449 submit: function() {450 ok( true, "Custom submit event run." );451 }452 });453 var events = jQuery._data(obj, "events");454 ok( events, "Object has events bound." );455 equals( obj.events, undefined, "Events object on plain objects is not events" );456 equals( obj.test, undefined, "Make sure that test event is not on the plain object." );457 equals( obj.handle, undefined, "Make sure that the event handler is not on the plain object." );458 // Should trigger 1459 jQuery(obj).trigger("test");460 jQuery(obj).trigger("submit");461 jQuery(obj).unbind("test");462 jQuery(obj).unbind("submit");463 // Should trigger 0464 jQuery(obj).trigger("test");465 // Make sure it doesn't complain when no events are found466 jQuery(obj).unbind("test");467 equals( obj && obj[ jQuery.expando ] &&468 obj[ jQuery.expando ][ jQuery.expando ] &&469 obj[ jQuery.expando ][ jQuery.expando ].events, undefined, "Make sure events object is removed" );470});471test("unbind(type)", function() {472 expect( 0 );473 var $elem = jQuery("#firstp"),474 message;475 function error(){476 ok( false, message );477 }478 message = "unbind passing function";479 $elem.bind('error1', error).unbind('error1',error).triggerHandler('error1');480 message = "unbind all from event";481 $elem.bind('error1', error).unbind('error1').triggerHandler('error1');482 message = "unbind all";483 $elem.bind('error1', error).unbind().triggerHandler('error1');484 message = "unbind many with function";485 $elem.bind('error1 error2',error)486 .unbind('error1 error2', error )487 .trigger('error1').triggerHandler('error2');488 message = "unbind many"; // #3538489 $elem.bind('error1 error2',error)490 .unbind('error1 error2')491 .trigger('error1').triggerHandler('error2');492 message = "unbind without a type or handler";493 $elem.bind("error1 error2.test",error)494 .unbind()495 .trigger("error1").triggerHandler("error2");496});497test("unbind(eventObject)", function() {498 expect(4);499 var $elem = jQuery("#firstp"),500 num;501 function assert( expected ){502 num = 0;503 $elem.trigger('foo').triggerHandler('bar');504 equals( num, expected, "Check the right handlers are triggered" );505 }506 $elem507 // This handler shouldn't be unbound508 .bind('foo', function(){509 num += 1;510 })511 .bind('foo', function(e){512 $elem.unbind( e )513 num += 2;514 })515 // Neither this one516 .bind('bar', function(){517 num += 4;518 });519 assert( 7 );520 assert( 5 );521 $elem.unbind('bar');522 assert( 1 );523 $elem.unbind();524 assert( 0 );525});526test("hover()", function() {527 var times = 0,528 handler1 = function( event ) { ++times; },529 handler2 = function( event ) { ++times; };530 jQuery("#firstp")531 .hover(handler1, handler2)532 .mouseenter().mouseleave()533 .unbind("mouseenter", handler1)534 .unbind("mouseleave", handler2)535 .hover(handler1)536 .mouseenter().mouseleave()537 .unbind("mouseenter mouseleave", handler1)538 .mouseenter().mouseleave();539 equals( times, 4, "hover handlers fired" );540});541test("trigger() shortcuts", function() {542 expect(6);543 var elem = jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL');544 elem.find('a').bind('click', function() {545 var close = jQuery('spanx', this); // same with jQuery(this).find('span');546 equals( close.length, 0, "Context element does not exist, length must be zero" );547 ok( !close[0], "Context element does not exist, direct access to element must return undefined" );548 return false;549 }).click();550 // manually clean up detached elements551 elem.remove();552 jQuery("#check1").click(function() {553 ok( true, "click event handler for checkbox gets fired twice, see #815" );554 }).click();555 var counter = 0;556 jQuery('#firstp')[0].onclick = function(event) {557 counter++;558 };559 jQuery('#firstp').click();560 equals( counter, 1, "Check that click, triggers onclick event handler also" );561 var clickCounter = 0;562 jQuery('#simon1')[0].onclick = function(event) {563 clickCounter++;564 };565 jQuery('#simon1').click();566 equals( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );567 elem = jQuery('<img />').load(function(){568 ok( true, "Trigger the load event, using the shortcut .load() (#2819)");569 }).load();570 // manually clean up detached elements571 elem.remove();572});573test("trigger() bubbling", function() {574 expect(14);575 var doc = 0, html = 0, body = 0, main = 0, ap = 0;576 jQuery(document).bind("click", function(e){ if ( e.target !== document) { doc++; } });577 jQuery("html").bind("click", function(e){ html++; });578 jQuery("body").bind("click", function(e){ body++; });579 jQuery("#main").bind("click", function(e){ main++; });580 jQuery("#ap").bind("click", function(){ ap++; return false; });581 jQuery("html").trigger("click");582 equals( doc, 1, "HTML bubble" );583 equals( html, 1, "HTML bubble" );584 jQuery("body").trigger("click");585 equals( doc, 2, "Body bubble" );586 equals( html, 2, "Body bubble" );587 equals( body, 1, "Body bubble" );588 jQuery("#main").trigger("click");589 equals( doc, 3, "Main bubble" );590 equals( html, 3, "Main bubble" );591 equals( body, 2, "Main bubble" );592 equals( main, 1, "Main bubble" );593 jQuery("#ap").trigger("click");594 equals( doc, 3, "ap bubble" );595 equals( html, 3, "ap bubble" );596 equals( body, 2, "ap bubble" );597 equals( main, 1, "ap bubble" );598 equals( ap, 1, "ap bubble" );599 // manually clean up events from elements outside the fixture600 jQuery(document).unbind("click");601 jQuery("html, body, #main").unbind("click");602});603test("trigger(type, [data], [fn])", function() {604 expect(14);605 var handler = function(event, a, b, c) {606 equals( event.type, "click", "check passed data" );607 equals( a, 1, "check passed data" );608 equals( b, "2", "check passed data" );609 equals( c, "abc", "check passed data" );610 return "test";611 };612 var $elem = jQuery("#firstp");613 // Simulate a "native" click614 $elem[0].click = function(){615 ok( true, "Native call was triggered" );616 };617 // Triggers handlrs and native618 // Trigger 5619 $elem.bind("click", handler).trigger("click", [1, "2", "abc"]);620 // Simulate a "native" click621 $elem[0].click = function(){622 ok( false, "Native call was triggered" );623 };624 // Trigger only the handlers (no native)625 // Triggers 5626 equals( $elem.triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" );627 var pass = true;628 try {629 jQuery('#form input:first').hide().trigger('focus');630 } catch(e) {631 pass = false;632 }633 ok( pass, "Trigger focus on hidden element" );634 pass = true;635 try {636 jQuery('#main table:first').bind('test:test', function(){}).trigger('test:test');637 } catch (e) {638 pass = false;639 }640 ok( pass, "Trigger on a table with a colon in the even type, see #3533" );641 var form = jQuery("<form action=''></form>").appendTo("body");642 // Make sure it can be prevented locally643 form.submit(function(){644 ok( true, "Local bind still works." );645 return false;646 });647 // Trigger 1648 form.trigger("submit");649 form.unbind("submit");650 jQuery(document).submit(function(){651 ok( true, "Make sure bubble works up to document." );652 return false;653 });654 // Trigger 1655 form.trigger("submit");656 jQuery(document).unbind("submit");657 form.remove();658});659test("jQuery.Event.currentTarget", function(){660});661test("trigger(eventObject, [data], [fn])", function() {662 expect(25);663 var $parent = jQuery('<div id="par" />').hide().appendTo('body'),664 $child = jQuery('<p id="child">foo</p>').appendTo( $parent );665 var event = jQuery.Event("noNew");666 ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" );667 equals( event.type, "noNew", "Verify its type" );668 equals( event.isDefaultPrevented(), false, "Verify isDefaultPrevented" );669 equals( event.isPropagationStopped(), false, "Verify isPropagationStopped" );670 equals( event.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );671 event.preventDefault();672 equals( event.isDefaultPrevented(), true, "Verify isDefaultPrevented" );673 event.stopPropagation();674 equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );675 event.isPropagationStopped = function(){ return false };676 event.stopImmediatePropagation();677 equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );678 equals( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );679 $parent.bind('foo',function(e){680 // Tries bubbling681 equals( e.type, 'foo', 'Verify event type when passed passing an event object' );682 equals( e.target.id, 'child', 'Verify event.target when passed passing an event object' );683 equals( e.currentTarget.id, 'par', 'Verify event.target when passed passing an event object' );684 equals( e.secret, 'boo!', 'Verify event object\'s custom attribute when passed passing an event object' );685 });686 // test with an event object687 event = new jQuery.Event("foo");688 event.secret = 'boo!';689 $child.trigger(event);690 // test with a literal object691 $child.trigger({type:'foo', secret:'boo!'});692 $parent.unbind();693 function error(){694 ok( false, "This assertion shouldn't be reached");695 }696 $parent.bind('foo', error );697 $child.bind('foo',function(e, a, b, c ){698 equals( arguments.length, 4, "Check arguments length");699 equals( a, 1, "Check first custom argument");700 equals( b, 2, "Check second custom argument");701 equals( c, 3, "Check third custom argument");702 equals( e.isDefaultPrevented(), false, "Verify isDefaultPrevented" );703 equals( e.isPropagationStopped(), false, "Verify isPropagationStopped" );704 equals( e.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );705 // Skips both errors706 e.stopImmediatePropagation();707 return "result";708 });709 // We should add this back in when we want to test the order710 // in which event handlers are iterated.711 //$child.bind('foo', error );712 event = new jQuery.Event("foo");713 $child.trigger( event, [1,2,3] ).unbind();714 equals( event.result, "result", "Check event.result attribute");715 // Will error if it bubbles716 $child.triggerHandler('foo');717 $child.unbind();718 $parent.unbind().remove();719});720test("jQuery.Event.currentTarget", function(){721 expect(1);722 var counter = 0,723 $elem = jQuery('<button>a</button>').click(function(e){724 equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" );725 });726 // Fake event727 $elem.trigger('click');728 // Cleanup729 $elem.unbind();730});731test("toggle(Function, Function, ...)", function() {732 expect(16);733 var count = 0,734 fn1 = function(e) { count++; },735 fn2 = function(e) { count--; },736 preventDefault = function(e) { e.preventDefault() },737 link = jQuery('#mark');738 link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();739 equals( count, 1, "Check for toggle(fn, fn)" );740 jQuery("#firstp").toggle(function () {741 equals(arguments.length, 4, "toggle correctly passes through additional triggered arguments, see #1701" )742 }, function() {}).trigger("click", [ 1, 2, 3 ]);743 var first = 0;744 jQuery("#simon1").one("click", function() {745 ok( true, "Execute event only once" );746 jQuery(this).toggle(function() {747 equals( first++, 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );748 }, function() {749 equals( first, 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );750 });751 return false;752 }).click().click().click();753 var turn = 0;754 var fns = [755 function(){756 turn = 1;757 },758 function(){759 turn = 2;760 },761 function(){762 turn = 3;763 }764 ];765 var $div = jQuery("<div>&nbsp;</div>").toggle( fns[0], fns[1], fns[2] );766 $div.click();767 equals( turn, 1, "Trying toggle with 3 functions, attempt 1 yields 1");768 $div.click();769 equals( turn, 2, "Trying toggle with 3 functions, attempt 2 yields 2");770 $div.click();771 equals( turn, 3, "Trying toggle with 3 functions, attempt 3 yields 3");772 $div.click();773 equals( turn, 1, "Trying toggle with 3 functions, attempt 4 yields 1");774 $div.click();775 equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");776 $div.unbind('click',fns[0]);777 var data = jQuery._data( $div[0], 'events' );778 ok( !data, "Unbinding one function from toggle unbinds them all");779 // manually clean up detached elements780 $div.remove();781 // Test Multi-Toggles782 var a = [], b = [];783 $div = jQuery("<div/>");784 $div.toggle(function(){ a.push(1); }, function(){ a.push(2); });785 $div.click();786 same( a, [1], "Check that a click worked." );787 $div.toggle(function(){ b.push(1); }, function(){ b.push(2); });788 $div.click();789 same( a, [1,2], "Check that a click worked with a second toggle." );790 same( b, [1], "Check that a click worked with a second toggle." );791 $div.click();792 same( a, [1,2,1], "Check that a click worked with a second toggle, second click." );793 same( b, [1,2], "Check that a click worked with a second toggle, second click." );794 // manually clean up detached elements795 $div.remove();796});797test(".live()/.die()", function() {798 expect(66);799 var submit = 0, div = 0, livea = 0, liveb = 0;800 jQuery("div").live("submit", function(){ submit++; return false; });801 jQuery("div").live("click", function(){ div++; });802 jQuery("div#nothiddendiv").live("click", function(){ livea++; });803 jQuery("div#nothiddendivchild").live("click", function(){ liveb++; });804 // Nothing should trigger on the body805 jQuery("body").trigger("click");806 equals( submit, 0, "Click on body" );807 equals( div, 0, "Click on body" );808 equals( livea, 0, "Click on body" );809 equals( liveb, 0, "Click on body" );810 // This should trigger two events811 submit = 0, div = 0, livea = 0, liveb = 0;812 jQuery("div#nothiddendiv").trigger("click");813 equals( submit, 0, "Click on div" );814 equals( div, 1, "Click on div" );815 equals( livea, 1, "Click on div" );816 equals( liveb, 0, "Click on div" );817 // This should trigger three events (w/ bubbling)818 submit = 0, div = 0, livea = 0, liveb = 0;819 jQuery("div#nothiddendivchild").trigger("click");820 equals( submit, 0, "Click on inner div" );821 equals( div, 2, "Click on inner div" );822 equals( livea, 1, "Click on inner div" );823 equals( liveb, 1, "Click on inner div" );824 // This should trigger one submit825 submit = 0, div = 0, livea = 0, liveb = 0;826 jQuery("div#nothiddendivchild").trigger("submit");827 equals( submit, 1, "Submit on div" );828 equals( div, 0, "Submit on div" );829 equals( livea, 0, "Submit on div" );830 equals( liveb, 0, "Submit on div" );831 // Make sure no other events were removed in the process832 submit = 0, div = 0, livea = 0, liveb = 0;833 jQuery("div#nothiddendivchild").trigger("click");834 equals( submit, 0, "die Click on inner div" );835 equals( div, 2, "die Click on inner div" );836 equals( livea, 1, "die Click on inner div" );837 equals( liveb, 1, "die Click on inner div" );838 // Now make sure that the removal works839 submit = 0, div = 0, livea = 0, liveb = 0;840 jQuery("div#nothiddendivchild").die("click");841 jQuery("div#nothiddendivchild").trigger("click");842 equals( submit, 0, "die Click on inner div" );843 equals( div, 2, "die Click on inner div" );844 equals( livea, 1, "die Click on inner div" );845 equals( liveb, 0, "die Click on inner div" );846 // Make sure that the click wasn't removed too early847 submit = 0, div = 0, livea = 0, liveb = 0;848 jQuery("div#nothiddendiv").trigger("click");849 equals( submit, 0, "die Click on inner div" );850 equals( div, 1, "die Click on inner div" );851 equals( livea, 1, "die Click on inner div" );852 equals( liveb, 0, "die Click on inner div" );853 // Make sure that stopPropgation doesn't stop live events854 submit = 0, div = 0, livea = 0, liveb = 0;855 jQuery("div#nothiddendivchild").live("click", function(e){ liveb++; e.stopPropagation(); });856 jQuery("div#nothiddendivchild").trigger("click");857 equals( submit, 0, "stopPropagation Click on inner div" );858 equals( div, 1, "stopPropagation Click on inner div" );859 equals( livea, 0, "stopPropagation Click on inner div" );860 equals( liveb, 1, "stopPropagation Click on inner div" );861 // Make sure click events only fire with primary click862 submit = 0, div = 0, livea = 0, liveb = 0;863 var event = jQuery.Event("click");864 event.button = 1;865 jQuery("div#nothiddendiv").trigger(event);866 equals( livea, 0, "live secondary click" );867 jQuery("div#nothiddendivchild").die("click");868 jQuery("div#nothiddendiv").die("click");869 jQuery("div").die("click");870 jQuery("div").die("submit");871 // Test binding with a different context872 var clicked = 0, container = jQuery('#main')[0];873 jQuery("#foo", container).live("click", function(e){ clicked++; });874 jQuery("div").trigger('click');875 jQuery("#foo").trigger('click');876 jQuery("#main").trigger('click');877 jQuery("body").trigger('click');878 equals( clicked, 2, "live with a context" );879 // Make sure the event is actually stored on the context880 ok( jQuery._data(container, "events").live, "live with a context" );881 // Test unbinding with a different context882 jQuery("#foo", container).die("click");883 jQuery("#foo").trigger('click');884 equals( clicked, 2, "die with a context");885 // Test binding with event data886 jQuery("#foo").live("click", true, function(e){ equals( e.data, true, "live with event data" ); });887 jQuery("#foo").trigger("click").die("click");888 // Test binding with trigger data889 jQuery("#foo").live("click", function(e, data){ equals( data, true, "live with trigger data" ); });890 jQuery("#foo").trigger("click", true).die("click");891 // Test binding with different this object892 jQuery("#foo").live("click", jQuery.proxy(function(e){ equals( this.foo, "bar", "live with event scope" ); }, { foo: "bar" }));893 jQuery("#foo").trigger("click").die("click");894 // Test binding with different this object, event data, and trigger data895 jQuery("#foo").live("click", true, jQuery.proxy(function(e, data){896 equals( e.data, true, "live with with different this object, event data, and trigger data" );897 equals( this.foo, "bar", "live with with different this object, event data, and trigger data" );898 equals( data, true, "live with with different this object, event data, and trigger data")899 }, { foo: "bar" }));900 jQuery("#foo").trigger("click", true).die("click");901 // Verify that return false prevents default action902 jQuery("#anchor2").live("click", function(){ return false; });903 var hash = window.location.hash;904 jQuery("#anchor2").trigger("click");905 equals( window.location.hash, hash, "return false worked" );906 jQuery("#anchor2").die("click");907 // Verify that .preventDefault() prevents default action908 jQuery("#anchor2").live("click", function(e){ e.preventDefault(); });909 var hash = window.location.hash;910 jQuery("#anchor2").trigger("click");911 equals( window.location.hash, hash, "e.preventDefault() worked" );912 jQuery("#anchor2").die("click");913 // Test binding the same handler to multiple points914 var called = 0;915 function callback(){ called++; return false; }916 jQuery("#nothiddendiv").live("click", callback);917 jQuery("#anchor2").live("click", callback);918 jQuery("#nothiddendiv").trigger("click");919 equals( called, 1, "Verify that only one click occurred." );920 called = 0;921 jQuery("#anchor2").trigger("click");922 equals( called, 1, "Verify that only one click occurred." );923 // Make sure that only one callback is removed924 jQuery("#anchor2").die("click", callback);925 called = 0;926 jQuery("#nothiddendiv").trigger("click");927 equals( called, 1, "Verify that only one click occurred." );928 called = 0;929 jQuery("#anchor2").trigger("click");930 equals( called, 0, "Verify that no click occurred." );931 // Make sure that it still works if the selector is the same,932 // but the event type is different933 jQuery("#nothiddendiv").live("foo", callback);934 // Cleanup935 jQuery("#nothiddendiv").die("click", callback);936 called = 0;937 jQuery("#nothiddendiv").trigger("click");938 equals( called, 0, "Verify that no click occurred." );939 called = 0;940 jQuery("#nothiddendiv").trigger("foo");941 equals( called, 1, "Verify that one foo occurred." );942 // Cleanup943 jQuery("#nothiddendiv").die("foo", callback);944 // Make sure we don't loose the target by DOM modifications945 // after the bubble already reached the liveHandler946 var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);947 jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); });948 jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} });949 jQuery("#nothiddendiv span").click();950 equals( jQuery("#nothiddendiv span").length, 0, "Verify that first handler occurred and modified the DOM." );951 equals( livec, 1, "Verify that second handler occurred even with nuked target." );952 // Cleanup953 jQuery("#nothiddendivchild").die("click");954 // Verify that .live() ocurs and cancel buble in the same order as955 // we would expect .bind() and .click() without delegation956 var lived = 0, livee = 0;957 // bind one pair in one order958 jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; });959 jQuery('span#liveSpan1').live('click', function(){ livee++; });960 jQuery('span#liveSpan1 a').click();961 equals( lived, 1, "Verify that only one first handler occurred." );962 equals( livee, 0, "Verify that second handler doesn't." );963 // and one pair in inverse964 jQuery('span#liveSpan2').live('click', function(){ livee++; });965 jQuery('span#liveSpan2 a').live('click', function(){ lived++; return false; });966 lived = 0;967 livee = 0;968 jQuery('span#liveSpan2 a').click();969 equals( lived, 1, "Verify that only one first handler occurred." );970 equals( livee, 0, "Verify that second handler doesn't." );971 // Cleanup972 jQuery("span#liveSpan1 a").die("click")973 jQuery("span#liveSpan1").die("click");974 jQuery("span#liveSpan2 a").die("click");975 jQuery("span#liveSpan2").die("click");976 // Test this, target and currentTarget are correct977 jQuery('span#liveSpan1').live('click', function(e){978 equals( this.id, 'liveSpan1', 'Check the this within a live handler' );979 equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a live handler' );980 equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a live handler' );981 });982 jQuery('span#liveSpan1 a').click();983 jQuery('span#liveSpan1').die('click');984 // Work with deep selectors985 livee = 0;986 function clickB(){ livee++; }987 jQuery("#nothiddendiv div").live("click", function(){ livee++; });988 jQuery("#nothiddendiv div").live("click", clickB);989 jQuery("#nothiddendiv div").live("mouseover", function(){ livee++; });990 equals( livee, 0, "No clicks, deep selector." );991 livee = 0;992 jQuery("#nothiddendivchild").trigger("click");993 equals( livee, 2, "Click, deep selector." );994 livee = 0;995 jQuery("#nothiddendivchild").trigger("mouseover");996 equals( livee, 1, "Mouseover, deep selector." );997 jQuery("#nothiddendiv div").die("mouseover");998 livee = 0;999 jQuery("#nothiddendivchild").trigger("click");1000 equals( livee, 2, "Click, deep selector." );1001 livee = 0;1002 jQuery("#nothiddendivchild").trigger("mouseover");1003 equals( livee, 0, "Mouseover, deep selector." );1004 jQuery("#nothiddendiv div").die("click", clickB);1005 livee = 0;1006 jQuery("#nothiddendivchild").trigger("click");1007 equals( livee, 1, "Click, deep selector." );1008 jQuery("#nothiddendiv div").die("click");1009 jQuery("#nothiddendiv div").live("blur", function(){1010 ok( true, "Live div trigger blur." );1011 });1012 jQuery("#nothiddendiv div").trigger("blur");1013 jQuery("#nothiddendiv div").die("blur");1014});1015test("die all bound events", function(){1016 expect(1);1017 var count = 0;1018 var div = jQuery("div#nothiddendivchild");1019 div.live("click submit", function(){ count++; });1020 div.die();1021 div.trigger("click");1022 div.trigger("submit");1023 equals( count, 0, "Make sure no events were triggered." );1024});1025test("live with multiple events", function(){1026 expect(1);1027 var count = 0;1028 var div = jQuery("div#nothiddendivchild");1029 div.live("click submit", function(){ count++; });1030 div.trigger("click");1031 div.trigger("submit");1032 equals( count, 2, "Make sure both the click and submit were triggered." );1033 // manually clean up events from elements outside the fixture1034 div.die();1035});1036test("live with namespaces", function(){1037 expect(12);1038 var count1 = 0, count2 = 0;1039 jQuery("#liveSpan1").live("foo.bar", function(e){1040 count1++;1041 });1042 jQuery("#liveSpan1").live("foo.zed", function(e){1043 count2++;1044 });1045 jQuery("#liveSpan1").trigger("foo.bar");1046 equals( count1, 1, "Got live foo.bar" );1047 equals( count2, 0, "Got live foo.bar" );1048 count1 = 0, count2 = 0;1049 jQuery("#liveSpan1").trigger("foo.zed");1050 equals( count1, 0, "Got live foo.zed" );1051 equals( count2, 1, "Got live foo.zed" );1052 //remove one1053 count1 = 0, count2 = 0;1054 jQuery("#liveSpan1").die("foo.zed");1055 jQuery("#liveSpan1").trigger("foo.bar");1056 equals( count1, 1, "Got live foo.bar after dieing foo.zed" );1057 equals( count2, 0, "Got live foo.bar after dieing foo.zed" );1058 count1 = 0, count2 = 0;1059 jQuery("#liveSpan1").trigger("foo.zed");1060 equals( count1, 0, "Got live foo.zed" );1061 equals( count2, 0, "Got live foo.zed" );1062 //remove the other1063 jQuery("#liveSpan1").die("foo.bar");1064 count1 = 0, count2 = 0;1065 jQuery("#liveSpan1").trigger("foo.bar");1066 equals( count1, 0, "Did not respond to foo.bar after dieing it" );1067 equals( count2, 0, "Did not respond to foo.bar after dieing it" );1068 jQuery("#liveSpan1").trigger("foo.zed");1069 equals( count1, 0, "Did not trigger foo.zed again" );1070 equals( count2, 0, "Did not trigger foo.zed again" );1071});1072test("live with change", function(){1073 expect(8);1074 var selectChange = 0, checkboxChange = 0;1075 var select = jQuery("select[name='S1']")1076 select.live("change", function() {1077 selectChange++;1078 });1079 var checkbox = jQuery("#check2"),1080 checkboxFunction = function(){1081 checkboxChange++;1082 }1083 checkbox.live("change", checkboxFunction);1084 // test click on select1085 // second click that changed it1086 selectChange = 0;1087 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1088 select.trigger("change");1089 equals( selectChange, 1, "Change on click." );1090 // test keys on select1091 selectChange = 0;1092 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1093 select.trigger("change");1094 equals( selectChange, 1, "Change on keyup." );1095 // test click on checkbox1096 checkbox.trigger("change");1097 equals( checkboxChange, 1, "Change on checkbox." );1098 // test blur/focus on text1099 var text = jQuery("#name"), textChange = 0, oldTextVal = text.val();1100 text.live("change", function() {1101 textChange++;1102 });1103 text.val(oldTextVal+"foo");1104 text.trigger("change");1105 equals( textChange, 1, "Change on text input." );1106 text.val(oldTextVal);1107 text.die("change");1108 // test blur/focus on password1109 var password = jQuery("#name"), passwordChange = 0, oldPasswordVal = password.val();1110 password.live("change", function() {1111 passwordChange++;1112 });1113 password.val(oldPasswordVal + "foo");1114 password.trigger("change");1115 equals( passwordChange, 1, "Change on password input." );1116 password.val(oldPasswordVal);1117 password.die("change");1118 // make sure die works1119 // die all changes1120 selectChange = 0;1121 select.die("change");1122 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1123 select.trigger("change");1124 equals( selectChange, 0, "Die on click works." );1125 selectChange = 0;1126 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1127 select.trigger("change");1128 equals( selectChange, 0, "Die on keyup works." );1129 // die specific checkbox1130 checkbox.die("change", checkboxFunction);1131 checkbox.trigger("change");1132 equals( checkboxChange, 1, "Die on checkbox." );1133});1134test("live with submit", function() {1135 expect(5);1136 var count1 = 0, count2 = 0;1137 jQuery("#testForm").live("submit", function(ev) {1138 count1++;1139 ev.preventDefault();1140 });1141 jQuery("body").live("submit", function(ev) {1142 count2++;1143 ev.preventDefault();1144 });1145 jQuery("#testForm input[name=sub1]").submit();1146 equals( count1, 1, "Verify form submit." );1147 equals( count2, 1, "Verify body submit." );1148 jQuery("#testForm input[name=sub1]").live("click", function(ev) {1149 ok( true, "cancelling submit still calls click handler" );1150 });1151 jQuery("#testForm input[name=sub1]")[0].click();1152 equals( count1, 2, "Verify form submit." );1153 equals( count2, 2, "Verify body submit." );1154 jQuery("#testForm").die("submit");1155 jQuery("#testForm input[name=sub1]").die("click");1156 jQuery("body").die("submit");1157});1158test("live with special events", function() {1159 expect(13);1160 jQuery.event.special.foo = {1161 setup: function( data, namespaces, handler ) {1162 ok( true, "Setup run." );1163 },1164 teardown: function( namespaces ) {1165 ok( true, "Teardown run." );1166 },1167 add: function( handleObj ) {1168 ok( true, "Add run." );1169 },1170 remove: function( handleObj ) {1171 ok( true, "Remove run." );1172 },1173 _default: function( event ) {1174 ok( true, "Default run." );1175 }1176 };1177 // Run: setup, add1178 jQuery("#liveSpan1").live("foo.a", function(e){1179 ok( true, "Handler 1 run." );1180 });1181 // Run: add1182 jQuery("#liveSpan1").live("foo.b", function(e){1183 ok( true, "Handler 2 run." );1184 });1185 // Run: Handler 1, Handler 2, Default1186 jQuery("#liveSpan1").trigger("foo");1187 // Run: Handler 1, Default1188 // TODO: Namespace doesn't trigger default (?)1189 jQuery("#liveSpan1").trigger("foo.a");1190 // Run: remove1191 jQuery("#liveSpan1").die("foo.a");1192 // Run: Handler 2, Default1193 jQuery("#liveSpan1").trigger("foo");1194 // Run: remove, teardown1195 jQuery("#liveSpan1").die("foo");1196 delete jQuery.event.special.foo;1197});1198test(".delegate()/.undelegate()", function() {1199 expect(65);1200 var submit = 0, div = 0, livea = 0, liveb = 0;1201 jQuery("#body").delegate("div", "submit", function(){ submit++; return false; });1202 jQuery("#body").delegate("div", "click", function(){ div++; });1203 jQuery("#body").delegate("div#nothiddendiv", "click", function(){ livea++; });1204 jQuery("#body").delegate("div#nothiddendivchild", "click", function(){ liveb++; });1205 // Nothing should trigger on the body1206 jQuery("body").trigger("click");1207 equals( submit, 0, "Click on body" );1208 equals( div, 0, "Click on body" );1209 equals( livea, 0, "Click on body" );1210 equals( liveb, 0, "Click on body" );1211 // This should trigger two events1212 submit = 0, div = 0, livea = 0, liveb = 0;1213 jQuery("div#nothiddendiv").trigger("click");1214 equals( submit, 0, "Click on div" );1215 equals( div, 1, "Click on div" );1216 equals( livea, 1, "Click on div" );1217 equals( liveb, 0, "Click on div" );1218 // This should trigger three events (w/ bubbling)1219 submit = 0, div = 0, livea = 0, liveb = 0;1220 jQuery("div#nothiddendivchild").trigger("click");1221 equals( submit, 0, "Click on inner div" );1222 equals( div, 2, "Click on inner div" );1223 equals( livea, 1, "Click on inner div" );1224 equals( liveb, 1, "Click on inner div" );1225 // This should trigger one submit1226 submit = 0, div = 0, livea = 0, liveb = 0;1227 jQuery("div#nothiddendivchild").trigger("submit");1228 equals( submit, 1, "Submit on div" );1229 equals( div, 0, "Submit on div" );1230 equals( livea, 0, "Submit on div" );1231 equals( liveb, 0, "Submit on div" );1232 // Make sure no other events were removed in the process1233 submit = 0, div = 0, livea = 0, liveb = 0;1234 jQuery("div#nothiddendivchild").trigger("click");1235 equals( submit, 0, "undelegate Click on inner div" );1236 equals( div, 2, "undelegate Click on inner div" );1237 equals( livea, 1, "undelegate Click on inner div" );1238 equals( liveb, 1, "undelegate Click on inner div" );1239 // Now make sure that the removal works1240 submit = 0, div = 0, livea = 0, liveb = 0;1241 jQuery("#body").undelegate("div#nothiddendivchild", "click");1242 jQuery("div#nothiddendivchild").trigger("click");1243 equals( submit, 0, "undelegate Click on inner div" );1244 equals( div, 2, "undelegate Click on inner div" );1245 equals( livea, 1, "undelegate Click on inner div" );1246 equals( liveb, 0, "undelegate Click on inner div" );1247 // Make sure that the click wasn't removed too early1248 submit = 0, div = 0, livea = 0, liveb = 0;1249 jQuery("div#nothiddendiv").trigger("click");1250 equals( submit, 0, "undelegate Click on inner div" );1251 equals( div, 1, "undelegate Click on inner div" );1252 equals( livea, 1, "undelegate Click on inner div" );1253 equals( liveb, 0, "undelegate Click on inner div" );1254 // Make sure that stopPropgation doesn't stop live events1255 submit = 0, div = 0, livea = 0, liveb = 0;1256 jQuery("#body").delegate("div#nothiddendivchild", "click", function(e){ liveb++; e.stopPropagation(); });1257 jQuery("div#nothiddendivchild").trigger("click");1258 equals( submit, 0, "stopPropagation Click on inner div" );1259 equals( div, 1, "stopPropagation Click on inner div" );1260 equals( livea, 0, "stopPropagation Click on inner div" );1261 equals( liveb, 1, "stopPropagation Click on inner div" );1262 // Make sure click events only fire with primary click1263 submit = 0, div = 0, livea = 0, liveb = 0;1264 var event = jQuery.Event("click");1265 event.button = 1;1266 jQuery("div#nothiddendiv").trigger(event);1267 equals( livea, 0, "delegate secondary click" );1268 jQuery("#body").undelegate("div#nothiddendivchild", "click");1269 jQuery("#body").undelegate("div#nothiddendiv", "click");1270 jQuery("#body").undelegate("div", "click");1271 jQuery("#body").undelegate("div", "submit");1272 // Test binding with a different context1273 var clicked = 0, container = jQuery('#main')[0];1274 jQuery("#main").delegate("#foo", "click", function(e){ clicked++; });1275 jQuery("div").trigger('click');1276 jQuery("#foo").trigger('click');1277 jQuery("#main").trigger('click');1278 jQuery("body").trigger('click');1279 equals( clicked, 2, "delegate with a context" );1280 // Make sure the event is actually stored on the context1281 ok( jQuery._data(container, "events").live, "delegate with a context" );1282 // Test unbinding with a different context1283 jQuery("#main").undelegate("#foo", "click");1284 jQuery("#foo").trigger('click');1285 equals( clicked, 2, "undelegate with a context");1286 // Test binding with event data1287 jQuery("#body").delegate("#foo", "click", true, function(e){ equals( e.data, true, "delegate with event data" ); });1288 jQuery("#foo").trigger("click");1289 jQuery("#body").undelegate("#foo", "click");1290 // Test binding with trigger data1291 jQuery("#body").delegate("#foo", "click", function(e, data){ equals( data, true, "delegate with trigger data" ); });1292 jQuery("#foo").trigger("click", true);1293 jQuery("#body").undelegate("#foo", "click");1294 // Test binding with different this object1295 jQuery("#body").delegate("#foo", "click", jQuery.proxy(function(e){ equals( this.foo, "bar", "delegate with event scope" ); }, { foo: "bar" }));1296 jQuery("#foo").trigger("click");1297 jQuery("#body").undelegate("#foo", "click");1298 // Test binding with different this object, event data, and trigger data1299 jQuery("#body").delegate("#foo", "click", true, jQuery.proxy(function(e, data){1300 equals( e.data, true, "delegate with with different this object, event data, and trigger data" );1301 equals( this.foo, "bar", "delegate with with different this object, event data, and trigger data" );1302 equals( data, true, "delegate with with different this object, event data, and trigger data")1303 }, { foo: "bar" }));1304 jQuery("#foo").trigger("click", true);1305 jQuery("#body").undelegate("#foo", "click");1306 // Verify that return false prevents default action1307 jQuery("#body").delegate("#anchor2", "click", function(){ return false; });1308 var hash = window.location.hash;1309 jQuery("#anchor2").trigger("click");1310 equals( window.location.hash, hash, "return false worked" );1311 jQuery("#body").undelegate("#anchor2", "click");1312 // Verify that .preventDefault() prevents default action1313 jQuery("#body").delegate("#anchor2", "click", function(e){ e.preventDefault(); });1314 var hash = window.location.hash;1315 jQuery("#anchor2").trigger("click");1316 equals( window.location.hash, hash, "e.preventDefault() worked" );1317 jQuery("#body").undelegate("#anchor2", "click");1318 // Test binding the same handler to multiple points1319 var called = 0;1320 function callback(){ called++; return false; }1321 jQuery("#body").delegate("#nothiddendiv", "click", callback);1322 jQuery("#body").delegate("#anchor2", "click", callback);1323 jQuery("#nothiddendiv").trigger("click");1324 equals( called, 1, "Verify that only one click occurred." );1325 called = 0;1326 jQuery("#anchor2").trigger("click");1327 equals( called, 1, "Verify that only one click occurred." );1328 // Make sure that only one callback is removed1329 jQuery("#body").undelegate("#anchor2", "click", callback);1330 called = 0;1331 jQuery("#nothiddendiv").trigger("click");1332 equals( called, 1, "Verify that only one click occurred." );1333 called = 0;1334 jQuery("#anchor2").trigger("click");1335 equals( called, 0, "Verify that no click occurred." );1336 // Make sure that it still works if the selector is the same,1337 // but the event type is different1338 jQuery("#body").delegate("#nothiddendiv", "foo", callback);1339 // Cleanup1340 jQuery("#body").undelegate("#nothiddendiv", "click", callback);1341 called = 0;1342 jQuery("#nothiddendiv").trigger("click");1343 equals( called, 0, "Verify that no click occurred." );1344 called = 0;1345 jQuery("#nothiddendiv").trigger("foo");1346 equals( called, 1, "Verify that one foo occurred." );1347 // Cleanup1348 jQuery("#body").undelegate("#nothiddendiv", "foo", callback);1349 // Make sure we don't loose the target by DOM modifications1350 // after the bubble already reached the liveHandler1351 var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);1352 jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(''); });1353 jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ if(e.target) {livec++;} });1354 jQuery("#nothiddendiv span").click();1355 equals( jQuery("#nothiddendiv span").length, 0, "Verify that first handler occurred and modified the DOM." );1356 equals( livec, 1, "Verify that second handler occurred even with nuked target." );1357 // Cleanup1358 jQuery("#body").undelegate("#nothiddendivchild", "click");1359 // Verify that .live() ocurs and cancel buble in the same order as1360 // we would expect .bind() and .click() without delegation1361 var lived = 0, livee = 0;1362 // bind one pair in one order1363 jQuery("#body").delegate('span#liveSpan1 a', 'click', function(){ lived++; return false; });1364 jQuery("#body").delegate('span#liveSpan1', 'click', function(){ livee++; });1365 jQuery('span#liveSpan1 a').click();1366 equals( lived, 1, "Verify that only one first handler occurred." );1367 equals( livee, 0, "Verify that second handler doesn't." );1368 // and one pair in inverse1369 jQuery("#body").delegate('span#liveSpan2', 'click', function(){ livee++; });1370 jQuery("#body").delegate('span#liveSpan2 a', 'click', function(){ lived++; return false; });1371 lived = 0;1372 livee = 0;1373 jQuery('span#liveSpan2 a').click();1374 equals( lived, 1, "Verify that only one first handler occurred." );1375 equals( livee, 0, "Verify that second handler doesn't." );1376 // Cleanup1377 jQuery("#body").undelegate("click");1378 // Test this, target and currentTarget are correct1379 jQuery("#body").delegate('span#liveSpan1', 'click', function(e){1380 equals( this.id, 'liveSpan1', 'Check the this within a delegate handler' );1381 equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a delegate handler' );1382 equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a delegate handler' );1383 });1384 jQuery('span#liveSpan1 a').click();1385 jQuery("#body").undelegate('span#liveSpan1', 'click');1386 // Work with deep selectors1387 livee = 0;1388 function clickB(){ livee++; }1389 jQuery("#body").delegate("#nothiddendiv div", "click", function(){ livee++; });1390 jQuery("#body").delegate("#nothiddendiv div", "click", clickB);1391 jQuery("#body").delegate("#nothiddendiv div", "mouseover", function(){ livee++; });1392 equals( livee, 0, "No clicks, deep selector." );1393 livee = 0;1394 jQuery("#nothiddendivchild").trigger("click");1395 equals( livee, 2, "Click, deep selector." );1396 livee = 0;1397 jQuery("#nothiddendivchild").trigger("mouseover");1398 equals( livee, 1, "Mouseover, deep selector." );1399 jQuery("#body").undelegate("#nothiddendiv div", "mouseover");1400 livee = 0;1401 jQuery("#nothiddendivchild").trigger("click");1402 equals( livee, 2, "Click, deep selector." );1403 livee = 0;1404 jQuery("#nothiddendivchild").trigger("mouseover");1405 equals( livee, 0, "Mouseover, deep selector." );1406 jQuery("#body").undelegate("#nothiddendiv div", "click", clickB);1407 livee = 0;1408 jQuery("#nothiddendivchild").trigger("click");1409 equals( livee, 1, "Click, deep selector." );1410 jQuery("#body").undelegate("#nothiddendiv div", "click");1411});1412test("undelegate all bound events", function(){1413 expect(1);1414 var count = 0;1415 var div = jQuery("#body");1416 div.delegate("div#nothiddendivchild", "click submit", function(){ count++; });1417 div.undelegate();1418 jQuery("div#nothiddendivchild").trigger("click");1419 jQuery("div#nothiddendivchild").trigger("submit");1420 equals( count, 0, "Make sure no events were triggered." );1421});1422test("delegate with multiple events", function(){1423 expect(1);1424 var count = 0;1425 var div = jQuery("#body");1426 div.delegate("div#nothiddendivchild", "click submit", function(){ count++; });1427 jQuery("div#nothiddendivchild").trigger("click");1428 jQuery("div#nothiddendivchild").trigger("submit");1429 equals( count, 2, "Make sure both the click and submit were triggered." );1430 jQuery("#body").undelegate();1431});1432test("delegate with change", function(){1433 expect(8);1434 var selectChange = 0, checkboxChange = 0;1435 var select = jQuery("select[name='S1']");1436 jQuery("#body").delegate("select[name='S1']", "change", function() {1437 selectChange++;1438 });1439 var checkbox = jQuery("#check2"),1440 checkboxFunction = function(){1441 checkboxChange++;1442 }1443 jQuery("#body").delegate("#check2", "change", checkboxFunction);1444 // test click on select1445 // second click that changed it1446 selectChange = 0;1447 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1448 select.trigger("change");1449 equals( selectChange, 1, "Change on click." );1450 // test keys on select1451 selectChange = 0;1452 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1453 select.trigger("change");1454 equals( selectChange, 1, "Change on keyup." );1455 // test click on checkbox1456 checkbox.trigger("change");1457 equals( checkboxChange, 1, "Change on checkbox." );1458 // test blur/focus on text1459 var text = jQuery("#name"), textChange = 0, oldTextVal = text.val();1460 jQuery("#body").delegate("#name", "change", function() {1461 textChange++;1462 });1463 text.val(oldTextVal+"foo");1464 text.trigger("change");1465 equals( textChange, 1, "Change on text input." );1466 text.val(oldTextVal);1467 jQuery("#body").die("change");1468 // test blur/focus on password1469 var password = jQuery("#name"), passwordChange = 0, oldPasswordVal = password.val();1470 jQuery("#body").delegate("#name", "change", function() {1471 passwordChange++;1472 });1473 password.val(oldPasswordVal + "foo");1474 password.trigger("change");1475 equals( passwordChange, 1, "Change on password input." );1476 password.val(oldPasswordVal);1477 jQuery("#body").undelegate("#name", "change");1478 // make sure die works1479 // die all changes1480 selectChange = 0;1481 jQuery("#body").undelegate("select[name='S1']", "change");1482 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1483 select.trigger("change");1484 equals( selectChange, 0, "Die on click works." );1485 selectChange = 0;1486 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;1487 select.trigger("change");1488 equals( selectChange, 0, "Die on keyup works." );1489 // die specific checkbox1490 jQuery("#body").undelegate("#check2", "change", checkboxFunction);1491 checkbox.trigger("change");1492 equals( checkboxChange, 1, "Die on checkbox." );1493});1494test("delegate with submit", function() {1495 var count1 = 0, count2 = 0;1496 jQuery("#body").delegate("#testForm", "submit", function(ev) {1497 count1++;1498 ev.preventDefault();1499 });1500 jQuery(document).delegate("body", "submit", function(ev) {1501 count2++;1502 ev.preventDefault();1503 });1504 jQuery("#testForm input[name=sub1]").submit();1505 equals( count1, 1, "Verify form submit." );1506 equals( count2, 1, "Verify body submit." );1507 jQuery("#body").undelegate();1508 jQuery(document).undelegate();1509});1510test("Non DOM element events", function() {1511 expect(1);1512 var o = {};1513 jQuery(o).bind('nonelementobj', function(e) {1514 ok( true, "Event on non-DOM object triggered" );1515 });1516 jQuery(o).trigger('nonelementobj');1517});1518test("window resize", function() {1519 expect(2);1520 jQuery(window).unbind();1521 jQuery(window).bind("resize", function(){1522 ok( true, "Resize event fired." );1523 }).resize().unbind("resize");1524 ok( !jQuery._data(window, "__events__"), "Make sure all the events are gone." );1525});1526/*1527test("jQuery(function($) {})", function() {1528 stop();1529 jQuery(function($) {1530 equals(jQuery, $, "ready doesn't provide an event object, instead it provides a reference to the jQuery function, see http://docs.jquery.com/Events/ready#fn");1531 start();1532 });1533});1534test("event properties", function() {1535 stop();1536 jQuery("#simon1").click(function(event) {1537 ok( event.timeStamp, "assert event.timeStamp is present" );1538 start();1539 }).click();1540});...

Full Screen

Full Screen

events.spec.js

Source:events.spec.js Github

copy

Full Screen

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 })...

Full Screen

Full Screen

min.js

Source:min.js Github

copy

Full Screen

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 ...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...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");...

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 Robotframework-anywherelibrary 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