jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
[ 39 ] Chapter 2 #messageList table { border-collapse:collapse; margin:10px 0; background-color:#666; } #messageList th, #messageList td { width:100px; padding:10px; color:#eee; text-align:left; border-bottom:1px solid #eee; } #messageList td { background-color:#ccc; color:#000; } #messageList th.sub { width:220px; } #messageList th.del { text-align:right; } #messageList table a { padding:0 7px 2px; float:right; background-color:#ea3c37; color:#fff; text-align:center; text-decoration:none; border:1px solid #990000; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; } .confirm { color:#eee; font-size:16px; } .confirm button { margin:0 10px; } .confirm a { font-size:12px; color:#ffcaca; } 4. Save this as fadeTo.css in the css folder. What just happened? The underlying HTML is relatively simple; we have an outer containing within which reside a HTML5 element and a . Each row of the corresponds to a received message. Don't forget to link to the fadeTo.css file in the of the new page, as we have in previous examples. As with previous examples, the CSS we use for this example is purely arbitrary and is used simply to make the example presentable. We use the CSS3 rounded corner style property again, to give a nice effect to the widget. Once again, these styles won't work in IE, but the worst that will happen is that it will have square corners. Time for action – adding the behavior Finally we can add the script that will make it all work. In the empty function at the bottom of the element, add the following: var messageList = document.getElementById("messageList"), messages = $("table", messageList), confirmDiv = $("", { "class": "confirm", text: "Really delete?"
Fading Animations }), remove = $("", { id: "delete", text: "Yes" }).appendTo(confirmDiv), cancel = $("", { href: "#", id: "cancel", text: "Cancel", title: "Cancel" }).appendTo(confirmDiv), deleteRow = function(e) { e.preventDefault(); $(this).closest("tr").fadeTo(400, 0.5, function() { $(this).addClass("pre-delete"); confirmDiv.clone().insertAfter(messages); messages.find("a").unbind(); }); }; messages.find("a").click(deleteRow); $("#delete, #cancel").live("click", function(e) { e.preventDefault(); if (this.id === "delete") { messages.find(".pre-delete").fadeTo(400, 0, function() { $(this).remove(); }); } else { messages.find(".pre-delete").removeClass(" pre-delete").fadeTo(400, 1, function() { var el = $(this); if (el.css("filter")) { el[0].style.removeAttribute("filter");; } }); } $(".confirm", messageList).remove(); messages.find("a").click(deleteRow); }); [ 40 ]
- Page 12: For Pat Spacagna, the greatest moth
- Page 15 and 16: Download from Wow! eBook Table of
- Page 17 and 18: Table of Contents Time for action -
- Page 19 and 20: Table of Contents jQuery and transf
- Page 21 and 22: Drawing to the canvas 309 Supportin
- Page 23 and 24: Preface What this book covers Chapt
- Page 25 and 26: Preface Have a go hero - heading Th
- Page 27 and 28: Preface Piracy Piracy of copyright
- Page 29 and 30: Introduction In addition to animate
- Page 31 and 32: Introduction When not to use animat
- Page 33 and 34: Introduction of the template file"
- Page 35 and 36: Introduction In the previous screen
- Page 37 and 38: Introduction Once our variables hav
- Page 40 and 41: 2 Fading Animations In this chapter
- Page 42 and 43: [ 21 ] Chapter 2 We can control the
- Page 44 and 45: The previous screenshot shows how t
- Page 46 and 47: [ 25 ] Chapter 2 Most of the styles
- Page 48 and 49: 2. What else can be passed into the
- Page 50 and 51: Time for action - creating the dial
- Page 52 and 53: [ 31 ] Chapter 2 For example, the a
- Page 54 and 55: Download from Wow! eBook The follo
- Page 56 and 57: [ 35 ] Chapter 2 The CSS is used mo
- Page 58 and 59: The fadeTo() method is used in the
- Page 62 and 63: [ 41 ] Chapter 2 What just happened
- Page 64 and 65: 2. What format can these arguments
- Page 66 and 67: } var el = $(this); if (el.css("fil
- Page 68 and 69: [ 47 ] Chapter 2 Usually these meth
- Page 70 and 71: Time for action - animations with s
- Page 72 and 73: Download from Wow! eBook [ 51 ] Ch
- Page 74 and 75: 2. Save the changes as toggle.html.
- Page 76 and 77: 3 Managing Animations Like most of
- Page 78 and 79: [ 57 ] Chapter 3 A custom queue tha
- Page 80 and 81: If we wish to see how many function
- Page 82 and 83: 2. What does the queue() method ret
- Page 84 and 85: [ 63 ] Chapter 3 The argument we su
- Page 86 and 87: [ 65 ] Chapter 3 We pass a callback
- Page 88 and 89: [ 67 ] Chapter 3 The first argument
- Page 90 and 91: Delaying queue execution [ 69 ] Cha
- Page 92 and 93: [ 71 ] Chapter 3 Also note that the
- Page 94 and 95: 4 Sliding Animations Another type o
- Page 96 and 97: Time for action - creating a slide-
- Page 98 and 99: [ 77 ] Chapter 4 header form input
- Page 100 and 101: Pop quiz - sliding elements down 1.
- Page 102 and 103: Download from Wow! eBook }); }); $
- Page 104 and 105: Toggling the slide [ 83 ] Chapter 4
- Page 106 and 107: [ 85 ] Chapter 4 } h2 { margin:0; p
- Page 108 and 109: [ 87 ] Chapter 4 The previous scree
[ 39 ]<br />
Chapter 2<br />
#messageList table {<br />
border-collapse:collapse; margin:10px 0; background-color:#666;<br />
}<br />
#messageList th, #messageList td {<br />
width:100px; padding:10px; color:#eee; text-align:left;<br />
border-bottom:1px solid #eee;<br />
}<br />
#messageList td { background-color:#ccc; color:#000; }<br />
#messageList th.sub { width:220px; }<br />
#messageList th.del { text-align:right; }<br />
#messageList table a {<br />
padding:0 7px 2px; float:right; background-color:#ea3c37;<br />
color:#fff; text-align:center; text-decoration:none;<br />
border:1px solid #990000; -moz-border-radius:5px;<br />
-webkit-border-radius:5px; border-radius:5px;<br />
}<br />
.confirm { color:#eee; font-size:16px; }<br />
.confirm button { margin:0 10px; }<br />
.confirm a { font-size:12px; color:#ffcaca; }<br />
4. Save this as fadeTo.css in the css folder.<br />
What just happened?<br />
The underlying HTML is relatively simple; we have an outer containing within which<br />
reside a HTML5 element and a . Each row <strong>of</strong> the corresponds<br />
to a received message. Don't forget to link to the fadeTo.css file in the <strong>of</strong> the new<br />
page, as we have in previous examples.<br />
As with previous examples, the CSS we use for this example is purely arbitrary and is used<br />
simply to make the example presentable. We use the CSS3 rounded corner style property<br />
again, to give a nice effect to the widget. Once again, these styles won't work in IE, but the<br />
worst that will happen is that it will have square corners.<br />
Time for action – adding the behavior<br />
Finally we can add the script that will make it all work. In the empty function at the bottom<br />
<strong>of</strong> the element, add the following:<br />
var messageList = document.getElementById("messageList"),<br />
messages = $("table", messageList),<br />
confirmDiv = $("", {<br />
"class": "confirm",<br />
text: "Really delete?"