1 $(document).ready( function () {
4 asyncTest( "Auto-initialization", function () {
5 $.testHelper.pageSequence( [
7 var plain = $("#pop_plain"),
8 plainBtn = $("#btn_plain"),
9 horizontal = $("#pop_horizontal"),
10 horizontalBtn = $("#btn_horizontal"),
11 buttons = $("#pop_buttons"),
12 buttonsBtn = $("#btn_buttons"),
13 notCtxpopup = $("#pop_not"),
14 notCtxpopupBtn = $("#btn_not");
16 ok( plain.data( "ctxpopup" ), "should Normal type ctxpopup created" );
17 ok( horizontal.data( "ctxpopup" ), "should Horizontal type ctxpopup created" );
18 ok( buttons.data( "ctxpopup" ), "should Button type ctxpopup created" );
19 ok( !notCtxpopup.data( "ctxpopup" ), "should wihthout arrow ctxpopup not created" );
29 // ctxpopup shares code with popupwindow so only tests ctxpopup specific codes
30 asyncTest( "Open and Placements", function () {
31 $.testHelper.pageSequence( [
33 var plain = $("#pop_plain").ctxpopup(),
34 horizontal = $("#pop_horizontal").ctxpopup(),
35 buttons = $("#pop_buttons").ctxpopup();
37 function placementsTest( popup ) {
38 var width = $(window).width(),
39 height = $(window).height(),
42 parents = popup.parents(".ui-popupwindow"),
49 popup.bind( "popupafterclose", function () {
50 // tests event trigger
52 if ( closed == open ) {
53 equal( closed, open, "should 'popupafterclose' triggered." );
58 while ( y <= height ) {
59 while ( x <= width ) {
60 popup.popupwindow( "open", x, y );
62 popPos = parents.position();
64 width: parents.width(),
65 height: parents.height()
68 if ( popPos.left < 0 || popPos.top < 0 || popPos.left > (width - popDim.width) || popPos.top > (height - popDim.height) ) {
69 throw "Pop up occured at wrong position: (" + parseInt(popPos.left, 10) + "," + parseInt(popPos.top, 10) + "," + popDim.width + "," + popDim.height + ")";
72 popup.popupwindow( "close" );
75 y += height / segment;
78 setTimeout( function() {
80 throw " Error, popupafterclose event was not triggering ";
87 { name: "Plain", popup: plain },
88 { name: "Horizontal", popup: horizontal },
89 { name: "Buttons", popup: buttons }
92 for ( var i = 0; i < testee.length; i++ ) {
93 ok( placementsTest( testee[i].popup ), "should " + testee[i].name + " pop up within window area" );