Skip to content

Effects Tests: Add shake visual test and Correct scale visual test #1328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions tests/visual/effects/scale.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<script src="../../../external/jquery/jquery.js"></script>
<script src="../../../ui/effect.js"></script>
<script src="../../../ui/effect-scale.js"></script>
<script src="../../../ui/effect-size.js"></script>
<script>
$(function() {
var test = $( "#testBox" ),
opts = $( ".arg" ),
optsRev = $( opts.get().reverse() ),
doer = $( "#doAnim" ),
current = $( "#current" ),
cleanStyle = test[0].style,
total = 1;

opts.each(function() {
Expand All @@ -34,45 +34,50 @@
optsRev.each(function() {
var cur = this.selectedIndex,
next = cur + direction,
len = this.options.length;
len = this.options.length,
newIndex = ( next + len ) % len;

this.selectedIndex = ( next + len ) % len;
this.selectedIndex = newIndex;

if ( ( next+len ) % len === next ) return false;
if ( newIndex === next ) {
return false;
}
});
doAnim();
}


function doAnim() {
var cur = 0;
opts.each(function() {
cur *= this.options.length
cur *= this.options.length;
cur += this.selectedIndex;
});
cur++;
current.text( "Configuration: " + cur + " of " + total );
run.apply(test, opts.map(function() {
return $(this).val();
}).get());
run.apply( test, opts.map(function() {
return $( this ).val();
}).get() );
}

function run( position, v, h, vo, ho ) {
var el = this,
style = el[0].style,
style = el[ 0 ].style,
effect = {
effect: "scale",
mode: "effect",
percent: 200,
origin: [ vo, ho ],
duration: 500
};
el.stop(true, true);

el.stop( true, true );

if ( typeof style === "object" ) {
style.cssText = "";
} else {
el[0].style = "";
el[ 0 ].style = "";
}

el.css( "position", position )
.css( h, 5 )
.css( v, 5 )
Expand All @@ -95,6 +100,9 @@
border: 10px solid #fff;
margin: 10px;
padding: 10px;
position: absolute;
left: 5px;
top: 5px;
}
label {
display: block;
Expand All @@ -111,6 +119,7 @@
</style>
</head>
<body>

<div id="testArea">
<div id="testBox">
</div>
Expand Down Expand Up @@ -154,4 +163,6 @@
<button id="doAnim">Run Animation</button>
<button id="cycleNext">Forward</button>
</div>

</body>
</html>
99 changes: 99 additions & 0 deletions tests/visual/effects/shake.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Effects Test Suite</title>
<link rel="stylesheet" href="effects.css">
<script src="../../../external/jquery/jquery.js"></script>
<script src="../../../ui/effect.js"></script>
<script src="../../../ui/effect-scale.js"></script>
<script src="../../../ui/effect-shake.js"></script>
<script>
$(function() {
$( "#btn" ).click(function() {
$( ".shake" ).effect( "shake", {
duration: +$( "#duration" ).val(),
mode: "toggle"
});
});
});
</script>
<style>
#inputbox {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdent all the rules and the closing tag.

background: green;
}
#selectbox {
background: red;
}
#divbox {
background: yellow;
}
#inputbox_abs {
background: orange;
position: absolute;
top: 500px;
left: 300px;
}
#divbox_abs {
background: purple;
position: absolute;
top: 500px;
left: 500px;
}
div.shake {
background: lightblue;
}

.margin {
margin: 3px;
}
.border {
border: 1px solid black;
}
.padding {
padding: 10px;
}
</style>
</head>
<body>

<p>WHAT: A set of elements with various box-model properties, using the shake effect to toggle.</p>
<p>EXPECTED: When clicking "Toggle", all elements should not change dimension nor position, aside from the expected shake animation, which should take the number of milliseconds specified to complete. At the end of the animation, all elements should hide.</p>
<p>EXPECTED: Clicking "Toggle" a second time reverses the animation, first showing all elements at their original dimensions, and restoring them to their original state.</p>

<button id="btn">Toggle</button>
<input id="duration" value="1000">
<div id="divbox">
<div class="shake margin">test</div>
<div class="shake border">test</div>
<div class="shake padding margin">test</div>
</div>
<div id="inputbox" class="margin">
<div class="shake margin">test</div>
<div class="shake margin border">test</div>
<div class="shake padding">test</div>
<input type="text" class="shake" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No closing slash.

</div>
<div id="selectbox">
<div class="shake">test</div>
<div class="shake">test</div>
<div class="shake">test</div>
<select class="shake">
<option value="a">a</option>
<option value="abcdef">abcdef</option>
</select>
</div>
<div id="inputbox_abs" class="margin">
<div class="shake margin">test</div>
<div class="shake margin border">test</div>
<div class="shake padding">test</div>
<input type="text" class="shake" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No closing slash.

</div>
<div id="divbox_abs" class="margin">
<div class="shake margin">test</div>
<div class="shake margin border">test</div>
<div class="shake padding">test</div>
</div>

</body>
</html>
1 change: 1 addition & 0 deletions tests/visual/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h2>Effects</h2>
<ul>
<li><a href="effects/all.html">All</a></li>
<li><a href="effects/scale.html">Scale</a></li>
<li><a href="effects/shake.html">Shake</a></li>
</ul>

<h2>Menu</h2>
Expand Down