diff --git a/PUBCODER.md b/PUBCODER.md new file mode 100644 index 0000000..4760a00 --- /dev/null +++ b/PUBCODER.md @@ -0,0 +1,5 @@ +# PubCoder samples + +This repository is home to the EPUB Scriptable Components (ESC) PubCoder branch. +Contained herein are a set of samples of Scriptable Components (SC) based upon the [ESC Packaging specification](http://www.idpf.org/epub/sc/pkg/) and [ESC Communication API specification](http://www.idpf.org/epub/sc/api/). + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring.epub b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring.epub new file mode 100644 index 0000000..b72686a Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring.epub differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/META-INF/container.xml b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/META-INF/container.xml new file mode 100755 index 0000000..affa714 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/1/page.xhtml b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/1/page.xhtml new file mode 100644 index 0000000..3ced7f3 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/1/page.xhtml @@ -0,0 +1,52 @@ + + + + + + + + + Scriptable Components Sample + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ +
+
+

Scriptable Components Samples

+
+ + + + + +
+
+ + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/1/styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/1/styles.css new file mode 100644 index 0000000..4159a41 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/1/styles.css @@ -0,0 +1,53 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#obj7132 { +position: absolute; +overflow: hidden; +top: 656px; +left: 0px; +width: 1025px; +height: 112px; +opacity: 1; +z-index: 1; +display:block; +pointer-events: auto; +} + +div#obj7129 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: none; +} +img#obj7129_img { + position: relative; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} + + + + + + + + + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/2/page.xhtml b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/2/page.xhtml new file mode 100644 index 0000000..609da1b --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/2/page.xhtml @@ -0,0 +1,60 @@ + + + + + + + + + Introduction + + + + + + + + + + + + +
+
+ + +
+
+ +
+
+

Scriptable Components embedded

+
+
+

In the following pages find embedded some samples of Scriptable Components.

+

 

+

In this EPUB you will find:

+

 

+

 

+

 

+

 

+

 

+

 

+

Image Gallery

+

 

+

Coloring Game

+
+ + + + + +
+
+ + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/2/styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/2/styles.css new file mode 100644 index 0000000..bcc7510 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/2/styles.css @@ -0,0 +1,86 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#obj7143 { +position: absolute; +overflow: hidden; +top: 11px; +left: 13px; +width: 998px; +height: 31px; +opacity: 1; +z-index: 2; +display:block; +pointer-events: auto; +} +div#obj7146 { +position: absolute; +overflow: hidden; +top: 86px; +left: 375px; +width: 302px; +height: 450px; +opacity: 1; +z-index: 3; +display:block; +pointer-events: auto; +} + +div#obj7139 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: none; +} +img#obj7139_img { + position: relative; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} + + + + + +div#obj7141 { +position: absolute; +overflow: hidden; +top: 50px; +left: 18px; +width: 988px; +height: 704px; +opacity: 0.8; +z-index: 1; +display:block; +pointer-events: none; +background-image: none; +border-color: #000000; +border-width: 0px; +border-style: solid; +border-radius: 20px; +-moz-border-radius: 20px; +-webkit-border-radius: 20px; +background-color: #FFFFFF; +background-repeat: repeat; +} + + + + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/3/page.xhtml b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/3/page.xhtml new file mode 100644 index 0000000..9a2ab23 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/3/page.xhtml @@ -0,0 +1,40 @@ + + + + + + + + + Image Gallery Sample + + + + + + + + + + + +
+
+ +
+ +
+ + + + + +
+
+ + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/3/styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/3/styles.css new file mode 100644 index 0000000..a8c323d --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/3/styles.css @@ -0,0 +1,35 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} + +div#obj7148 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: auto; +} + +#SC7148 { + width: 1024px; + height: 768px; +} + + + + + + + + + + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/4/page.xhtml b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/4/page.xhtml new file mode 100644 index 0000000..98b79bd --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/4/page.xhtml @@ -0,0 +1,40 @@ + + + + + + + + + Coloring Game Sample + + + + + + + + + + + +
+
+ +
+ +
+ + + + + +
+
+ + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/4/styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/4/styles.css new file mode 100644 index 0000000..abcd66e --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/4/styles.css @@ -0,0 +1,36 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} + +div#obj7150 { + position: absolute; + overflow: hidden; + top: 0px; + left: 0px; + width: 1024px; + height: 768px; + opacity: 1; + z-index: 0; + display:block; + pointer-events: auto; +} + +#SC7150 { + width: 1024px; + height: 768px; +} + + + + + + + + + + + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/cover.jpg b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/cover.jpg new file mode 100644 index 0000000..d268a07 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/cover.jpg differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/obj7129_image.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/obj7129_image.png new file mode 100644 index 0000000..bfca53d Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/obj7129_image.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/obj7139_image.jpeg b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/obj7139_image.jpeg new file mode 100644 index 0000000..b41c86b Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/assets/images/obj7139_image.jpeg differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/actions.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/actions.js new file mode 100644 index 0000000..5e53679 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/actions.js @@ -0,0 +1,93 @@ +var ua = navigator.userAgent.toLowerCase(); +var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); +var touchDownEvent; +var touchUpEvent; +var isMobile; +var orientationDevice = getOrientation(isAndroid); +var aigX = 0, aigY = 0; +/* + * + * Init Action Lists + * + * + */ +/* + * + * Init SCCounter + * + * + */ + +$(window).load(function(){ + /* + * + * Init SCAnimation + * + * + */ + + /* + * + * Init Shake + * + */ + window.addEventListener('shake', function () { + + }, false); + + /* + * + * Init Masked Images + * + */ + + /* + * + * Init SCPhotogallery + * + * + */ + + /* + * + * Init SCQuizMulti + * + * + */ + + /* + * + * Init SCDrawer + * + * + */ + +var drawerObj5675 = new Drawer('obj5675',"#FFFFFF"); + if(! navigator.userAgent.match(/PubCoderHelper/i)) { + /* + * + * Action Groups + * + */ + + + /* + * + * Events + * + */ + + + /* + * + * Trigger onShow events for objects already shown on stage + * + */ + setTimeout(function() { + +$("#obj5644").trigger('SCEventShow'); +$("#obj5645").trigger('SCEventShow'); +$("#obj5675").trigger('SCEventShow'); + }, 200) + } +}) \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/page.xhtml b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/page.xhtml new file mode 100644 index 0000000..1438786 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/page.xhtml @@ -0,0 +1,287 @@ + + + + + + + + + PubCoder Coloring Game + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ +
+
+

Coloring Game

+
+
+
+ + + Sorry, your device cannot display this game. + + + Sorry, your device cannot display this game. + +
+ + + + +
+
+ + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ +
+
+ + + + +
+ +
+ + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/styles.css new file mode 100644 index 0000000..659b084 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/1/styles.css @@ -0,0 +1,195 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#obj5645 { +position: absolute; +overflow: hidden; +top: 11px; +left: 14px; +width: 998px; +height: 31px; +opacity: 1; +z-index: 1; +display:block; +pointer-events: auto; +} + +div#obj5644 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: none; +} +img#obj5644_img { + position: relative; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} + + + + + + + + + + + +#obj5675{ + pointer-event: auto !important; + height: 604px; /* full height on page */ + width: 933px; /* full width on page */ + background-color: #F4F4F4; + border-color: #909090; + border-width: 1px; + border-style: solid; + border-radius: 6px; + -moz-border-radius: 6px; + -webkit-border-radius: 6px; + position: absolute; +overflow: hidden; +top: 77px; +left: 46px; +width: 933px; +height: 604px; +opacity: 1; +z-index: 2; +display:block; +pointer-events: auto; + /* override rotation value */ + transform:rotate(0deg) !important; + -ms-transform:rotate(0deg) !important; + -webkit-transform:rotate(0deg) !important; +} +#obj5675 .drawing-area{ + /*width and height must be the same as canvas */ + position:absolute; + width:929px; /* (full width on page) + (negative area/canvas offset) */ + height:424px; /* (full height on page) + (negative area/canvas offset) */ + top:80px; /* top area offset leaving space for tools, tool sizes and clear btn */ + left:2px; /* left offset leaving space for images and clear btn */ + z-index:12; /* this has to be smaller then drawing-area-touch zindex */ + overflow: hidden !important; +} +#obj5675 .drawing-area-touch{ + position:absolute; + width:929px; /* same as drawingarea */ + height:424px; /* same as drawingarea */ + top:80px; /* same as drawingarea */ + left:2px; /* same as drawingarea */ + z-index:22; /* this has to be greater then drawing-area zindex */ + overflow: hidden !important; +} +#obj5675 .drawing-tmp-area{ + position:absolute; + width:929px; /* same as drawingarea */ + height:424px; /* same as drawingarea */ + top:80px; /* same as drawingarea */ + left:2px; /* same as drawingarea */ + overflow: hidden !important; +} +#obj5675 .drawing-clear{ + position:absolute; + height: 60px; + width: 60px; + top:523px; + left:853px; + background-image: url(../../images/scdrawer-trash.png); + background-size: 60px 60px; + background-repeat: no-repeat; +} +#obj5675 .drawing-tools{ + position:absolute; + top:523px; + left:2px; /* same as drawingarea */ + display: inline-table; +} +#obj5675 .drawing-tools .tool{ + border : 1px solid white; + float: left; + clear: none; + width: 60px; + height: 60px; +} +#obj5675 .drawing-tools .tool.selected{ + border : 1px solid red; +} +#obj5675 .drawing-size{ + position: absolute; + top: 507px; + left: 740px; + display: inline-block; + max-height: 94px; + max-width: 98px; + height: 94px; + width: auto; + /*overflow: hidden;*/ +} +#obj5675 .drawing-size .sizeContainer{ + max-height: 94px; + height: 94px; + /*width: auto;*/ + min-width: 40px; + max-width: 98px; + display: inline-block; +} +#obj5675 .drawing-size .size{ + display: block; + width: 60px; + height: 60px; + background-color: #979797; + margin: 2px; + border-radius: 30px; + float: left; + clear: none; +} +#obj5675 .drawing-size .size.selected{ + background-color: #0A52A2; +} +#obj5675 .drawing-images{ + position: absolute; + display: inline; + top: 3px; + left: 5px; +} +#obj5675 .drawing-images .drawing-background{ + width: auto; + height: 70px; + margin-left: 10px; +} +#obj5675 .drawing-images .drawing-background-hidden{ + display:none; +} +#obj5675 .drawing-colors{ + position:absolute; + top:523px; + left:217px; + display: inline-block; + max-width: 621px; +} +#obj5675 .drawing-colors .color{ + border : 1px solid white; + heigth: 60px; + width: 60px; + float: left; + clear: none; +} +#obj5675 .drawing-colors .color.selected{ + border : 1px solid red; +} + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring1.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring1.png new file mode 100644 index 0000000..7339c60 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring1.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring2.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring2.png new file mode 100644 index 0000000..52eb825 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring2.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring3.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring3.png new file mode 100644 index 0000000..c38ea8a Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/coloring3.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/obj5644_image.jpeg b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/obj5644_image.jpeg new file mode 100644 index 0000000..b41c86b Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/assets/images/obj5644_image.jpeg differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/css/general.styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/css/general.styles.css new file mode 100644 index 0000000..1bd0457 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/css/general.styles.css @@ -0,0 +1,101 @@ +/* Font styles: */ +@charset "UTF-8"; + +/* Body style */ +body{ + padding:0; + margin:0; +} +/* Audio style */ +audio{ + z-index:-1; +} +/* Page style */ +div.SCPage { + width: 1024px; + height: 768px; + position: relative; + +} +div.SCOverlay { + position: absolute; + z-index: 2; + width: 1024px; + height: 768px; + overflow: hidden; + pointer-events: none; + +} +div.SCContent { + position: absolute; + z-index: 1; + width: 1024px; + height: 768px; +} +/* Navigation Style */ + +.SCRectangle { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} +/* Read Aloud Styles */ + +/* Custom CSS Styles */ +/* Start of Default SCText Styles */ +body { + font-family: helvetica, arial, sans-serif; +} +.SCText p, h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-regular", helvetica, arial, sans-serif; + margin: 0px; + padding: 0px; + line-height: 1.3; +} +.SCText p { + font-size: 13px; + font-weight: normal; +} +.SCText h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-weight: normal; +} +.SCText h1 { font-size: 40px; } +.SCText h2 { font-size: 36px; } +.SCText h3 { font-size: 24px; } +.SCText h4 { font-size: 18px; } +.SCText h5 { font-size: 16px; } +.SCText h6 { font-size: 14px; } +/* End of Default SCText Styles */ +/* Start of Style Formats defined manually */ +.SCText span.Float-Left { + float: left; +} +.SCText span.Float-Right { + float: right; +} +.SCText span.Vertical-Align-Middle { + display: inline-block; + vertical-align: middle; +} +.SCText span.Add-Margin { + margin: 10px; +} +.SCText span.Shadowed { + text-shadow: #000000 1px 1px 2px; +} + +.SCText span.Active-Text { + border-bottom: 1px dotted; +} +.SCText p.BigText { + font-size: 36px; +} + +/* End of Style Formats defined manually */ +h3 { + text-shadow: #fff 0px 0px 6px; +} +.SCText a { + color: inherit; +} \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/images/scdrawer-trash.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/images/scdrawer-trash.png new file mode 100644 index 0000000..2aefa6d Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/images/scdrawer-trash.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/js/drawer.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/js/drawer.js new file mode 100644 index 0000000..a448b91 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderColoringGame/js/drawer.js @@ -0,0 +1,355 @@ + var Trig = { + distanceBetween2Points: function ( point1, point2 ) { + + var dx = point2.x - point1.x; + var dy = point2.y - point1.y; + return Math.sqrt( Math.pow( dx, 2 ) + Math.pow( dy, 2 ) ); + }, + + angleBetween2Points: function ( point1, point2 ) { + + var dx = point2.x - point1.x; + var dy = point2.y - point1.y; + return Math.atan2( dx, dy ); + } + } + + var Sketcher = function(canvasID, brushImage, bgcolor) { + var sk = this; + + this.renderFunction = function(event){ + if(sk.curTool == 'marker') this.updateCanvasByLine(event); + else if(sk.curTool == 'crayon') this.updateCanvasByBrush(event); + else if(sk.curTool == 'eraser') this.updateCanvasByLineEraser(event); + else return; + } + + this.brush = undefined; + this.canvasID = canvasID; + this.drawer = $("#"+canvasID ); + this.canvas = $("#"+canvasID + " canvas.drawing-area"); + this.context = this.canvas[0].getContext("2d"); + this.context.strokeStyle = "#000000"; + this.context.lineJoin = "round"; + + this.canvas_touch = $("#"+canvasID + " canvas.drawing-area-touch"); + this.context_touch = this.canvas_touch[0].getContext("2d"); + + this.lastMousePoint = {x:0, y:0}; + this.curTool = 'marker'; + this.curColor = '#000000'; + this.curSize = $('.size.selected').attr("data-size")/1; + + //bgcolor + this.bgcolor = bgcolor; + + this.canvas_touch.bind( window.touchDownEvent, this.onCanvasMouseDown() ); + this.drawer.on( window.touchDownEvent, function(e){ e.preventDefault() }); + + this.drawer.find(".tool").on(window.touchDownEvent , function(e){ + sk.drawer.find(".tool").removeClass("selected"); + $(this).addClass("selected"); + if($(this).is(".tool-crayon")) sk.curTool = 'crayon'; + if($(this).is(".tool-marker")) sk.curTool = 'marker'; + if($(this).is(".tool-eraser")) sk.curTool = 'eraser'; + e.preventDefault(); + }); + + this.selectColor = function(){ + sk.drawer.find(".color").removeClass("selected"); + $(this).addClass("selected"); + sk.curColor = $(this).attr("data-color"); + }; + + + this.loadBrush = function(){ + this.brush = new Image(); + this.brush.src ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAABlBMVEX///////9VfPVsAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfeAhQKGhjvjaMMAAAFK0lEQVQ4yx3Ub0wTdxgH8O9dr/WAwo5asCLbrnCFFnUUBBTjtl9LMQWrlomKiEsBdZg5wxj+WxZzLcXVWrUoMqrMHQgEnBJ0kxdmIVdERZ0ONcvQ7AUQx9zcFlyWzBf7d+71kzzJ83yf5wOOf2YoraqV7eT3qAjiQ6jKGDC1gDVL4BiLRYi3HqlhUjkRRcsEnY3Oc3ck9LcTxJnZ3OHdtjjaL5pkWNIMtDAt2oQ2rxGwOGq0+1znb40eyw9YYT/NOH0nrjy/98icyKPYRE9w1VxkCpGFMuIqJvwjq56lnMl+t5xgvkaUzo/7PCF9thVIYgk1f3yYvlpVHCYQCqL/2DTG6sL2+/NkiCSObtKm1aSzzJUwMvKp7pllwoj/0OWwFTuLyO2J+34s/NhSyCMYIwepN4cqGtkGnsAfXaqLiv5WTYvnLxkhujGTyhF3sOE7DIdf/aSRXaaXTze4BQJO8L23KFb+UE/6YiYhPAnfiBdTi11sTZRDnM1YvfBMl86+SEvxOGXNecvRz7MDdd0yh05V2qTG2CtxzaGmMJx2T+HjG6Cvxf8kWaEl3mbh2HpXlmGdnoM5pN/E88dJnpj6Po90asXXEp/7sD/EbONQ3aiiWvfrqTK1zQu4qacLFtk+d91j+Pp6FBee1B3dtFGt1ncTGYjxM4InWeJobRhIUdca3QfPO3/ZnhgSUbCa2al19y/PfZbH8QiY/b7YpvFLZ/mf0wgisk4q0AcvCj1GJ4Fclkypjui66Ha30w0v/4VOn7nOa17ju0Mw1inQoZHeXep0EWHYE2ZE7hDXUcgaeOBU+c2tPfXbLXbL/R+A3taslObHr9iS57olHrOhbk9umVhbhCXNHNTbtDQ116x6ktihZNvxlb6AeJwSTXY7PBDs0ZXcbyIvxhx+Gajyzk/1HpbtaRA21qNhbIFBHSGzfS7zcoJvY63c8fQxzUFsgYjyMb35zxzTNUGVk+IBcwgWZ+UHCXn0urmD2CyVPBiyf+Lalh3Nl5EBUw17IJnzc455IuQDBjZzJtB3lnpQ4UElnyRO09RAf114pVJr3otEwZP0kDD76qFD1+j3U5yBmmi4ChBC561dHEixJbKMR9kF7V5WicHvlDP1QDM63rRr6tCCS5EGFUFnn7UpKWFqcQrTrQWS+xiNm/hLkHKddSMGXVxQ5fN7uzNeIxitFE1bxHLMCaQBeKlh6BZNsf6qIfq0kpiJZw1ZuRmMdFnNo8bicKqiQca6TnqVRwipQ+9cLtXl5bB7lH8YtnsSEOR9q2ZZgI+PvFH9pLPpIznjj1nUlxhb5KV+99nJvjaCNHbMaUT25olAVg+PSiPFViwBbfSca+NBs1neYPr0BkZn7uLRsuOJlbWWh2+PqiDDxGj2rB7c7+tud0c4kJatokzLM9VivwgUZXErT9Yniq/7z88fh8rSGGM2qgY4bc9F5XpKbd6j38RQFZ2dyoAXXLZIhoFda59JjCUQv7x+cq+Ou1nqGzEQbJValcYjO5J0B+sIHJNm3D3cteoEq5VElLA/9soubS0FVSgMx33ndWNd1t1CFmIYx81/E7a8VixSBJNeCNZX3hU0RZysJAEuY790ASGerOAGoWK3clE6L9yhsSiCqbLq/h1aXxJD+7t5RTBNRUPndCARBz9TnFAES61b0xdsfZrfrggWcbh83nPPy26tOcHDYYqt0BlFRbBPXwhW36EeiZuKbcss3aCoaIdx4JHPE2BeCPY2S2BwDxtE9/+C7SlOtmWqcsyYmCP/B/HdwNS6DfvtAAAAAElFTkSuQmCC"; + this.brush.onload = function(){ + sk.selectColor.apply(sk.drawer.find(".color.selected")); + $(".drawing-tmp-area").attr("width", sk.curSize).attr("height", sk.curSize); + var _canvas = $(".drawing-tmp-area")[0]; + + var _ctx = _canvas.getContext("2d"); + _ctx.strokeStyle = "#ffffff"; + + _ctx.clearRect(0, 0, sk.brush.width, sk.brush.height); + /* _ctx.arc(sk.curSize/2, sk.curSize/2, sk.curSize/2, 0, 2 * Math.PI, false); + _ctx.stroke(); + _ctx.clip(); + */ _ctx.drawImage(sk.brush, 0, 0); + + var _imageData = _ctx.getImageData(0, 0, sk.curSize, sk.curSize); + var colors = sk.hexToRgb(sk.curColor); + for (var i=0;i<_imageData.data.length;i+=4){ + if(_imageData.data[i+3] === 255 || _imageData.data[i+3] === 100){ + _imageData.data[i] = colors[0]; + _imageData.data[i+1] = colors[1]; + _imageData.data[i+2] = colors[2]; + _imageData.data[i+3] = colors[3]; + } + } + _ctx.putImageData(_imageData, 0,0); + _ctx.restore(); + sk.brush = new Image(); + sk.brush.src = _canvas.toDataURL(); + } + } + + this.drawer.find(".sizeContainer").on(window.touchDownEvent , function(e){ + e.preventDefault(); + sk.drawer.find(".size").removeClass("selected"); + $(this.children).addClass("selected"); + sk.curSize = $(this.children).attr("data-size"); + sk.loadBrush(); + }); + + $('.drawing-background-hidden').on(window.touchDownEvent , function(e){ + e.preventDefault(); + }) + + this.drawer.find(".drawing-background").on(window.touchDownEvent , function(e){ + e.preventDefault(); + sk.drawer.find(".drawing-background").removeClass("selected"); + $(this).addClass("selected"); + sk.drawSelectedImage(true); + }); + + this.drawSelectedImage = function(clear){ + if(clear) sk.clear(); + var imgName = sk.drawer.find(".drawing-background.selected").attr("id"); + if (typeof imgName != "undefined") { + var img = $("#" + imgName + "-hidden")[0]; + var maxwidth = sk.canvas_touch[0].width; + var maxheight = sk.canvas_touch[0].height; + var fW = maxwidth / img.width; + var fH = maxheight / img.height; + var f = (fW < fH ? fW : fH); + if (img.width <= maxwidth && img.height <= maxheight) f = 1; + var imgWidth = img.width*f; + var imgHeight = img.height*f; + var leftMargin = (maxwidth - imgWidth) / 2; + var topMargin = (maxheight - imgHeight) / 2; + sk.context_touch.drawImage(img, leftMargin, topMargin, imgWidth, imgHeight); + } + } + + + this.drawer.find(".color").on(window.touchDownEvent , function(e){ + sk.selectColor.apply(this); + sk.loadBrush(); + e.preventDefault(); + }); + + this.clear = function(event){ + if(event) + event.preventDefault(); + var c = sk.canvas_touch[0]; + sk.context_touch.clearRect( 0, 0, c.width, c.height ); + c = sk.canvas[0]; + sk.context.clearRect( 0, 0, c.width, c.height ); + var fillStyle = sk.context.fillStyle; + sk.context.fillStyle = bgcolor; + sk.context.fillRect( 0, 0, c.width, c.height ); + sk.context.fillStyle = fillStyle; + sk.drawSelectedImage(false); + } + + $(".drawing-clear").on(window.touchDownEvent, this.clear); + + this.loadBrush(); + this.clear(); + } + + Sketcher.prototype.onCanvasMouseDown = function () { + var self = this; + return function(event) { + self.mouseMoveHandler = self.onCanvasMouseMove(); + self.mouseUpHandler = self.onCanvasMouseUp(); + + $(document).bind( window.touchMoveEvent, self.mouseMoveHandler ); + $(document).bind( window.touchUpEvent, self.mouseUpHandler ); + + self.updateMousePosition( event ); + self.renderFunction( event ); + event.preventDefault(); + } + } + + Sketcher.prototype.hexToRgb = function(hex) { + if (hex.charAt(0) == "#") { + hex = hex.substr(1, hex.length-1); + var bigint = parseInt(hex, 16); + var r = (bigint >> 16) & 255; + var g = (bigint >> 8) & 255; + var b = bigint & 255; + return [r,g,b,100]; + } else if (hex.substr(0,5) == "rgba(") { + hex = hex.substr(5, hex.length-6); + var values = hex.split(","); + var r = parseInt(values[0]); + var g = parseInt(values[1]); + var b = parseInt(values[2]); + var a = values[3] * 100; + return [r,g,b,a]; + } + } + + Sketcher.prototype.onCanvasMouseMove = function () { + var self = this; + return function(event) { + self.renderFunction( event ); + event.preventDefault(); + return false; + } + } + + Sketcher.prototype.onCanvasMouseUp = function (event) { + var self = this; + return function(event) { + + $(document).unbind( window.touchMoveEvent, self.mouseMoveHandler ); + $(document).unbind( window.touchUpEvent, self.mouseUpHandler ); + + self.mouseMoveHandler = null; + self.mouseUpHandler = null; + event.preventDefault(); + } + } + + Sketcher.prototype.updateMousePosition = function (event) { + var target; + if ((typeof event.originalEvent !== "undefined") + && (typeof event.originalEvent.touches !== "undefined") + && (typeof event.originalEvent.touches[0] !== "undefined") ) { + target = event.originalEvent.touches[0]; + } + else { + target = event; + } + var offset = this.canvas.offset(); + this.lastMousePoint.x = target.pageX - offset.left; + this.lastMousePoint.y = target.pageY - offset.top; + event.preventDefault(); + + } + + Sketcher.prototype.updateCanvasByLine = function (event) { + //this.drawSelectedImage(true); + this.context.strokeStyle = this.curColor; + this.context.lineWidth = this.curSize; + this.context.beginPath(); + var prevMousePoint = this.lastMousePoint; + this.context.moveTo( this.lastMousePoint.x, this.lastMousePoint.y ); + this.updateMousePosition( event ); + if(prevMousePoint.x == this.lastMousePoint.x && prevMousePoint.y == this.lastMousePoint.y){ + this.context.lineTo( this.lastMousePoint.x +1, this.lastMousePoint.y +1 ); + }else{ + this.context.lineTo( this.lastMousePoint.x, this.lastMousePoint.y ); + } + this.context.closePath(); + this.context.stroke(); + event.preventDefault(); + } + +Sketcher.prototype.updateCanvasByLineEraser = function (event) { + //this.drawSelectedImage(true); + //this.context.strokeStyle = "#" + this.curColor; + this.context.strokeStyle = this.bgcolor; + this.context.lineWidth = this.curSize; + this.context.beginPath(); + var prevMousePoint = this.lastMousePoint; + this.context.moveTo( this.lastMousePoint.x, this.lastMousePoint.y ); + this.updateMousePosition( event ); + if(prevMousePoint.x == this.lastMousePoint.x && prevMousePoint.y == this.lastMousePoint.y){ + this.context.lineTo( this.lastMousePoint.x +1, this.lastMousePoint.y +1 ); + }else{ + this.context.lineTo( this.lastMousePoint.x, this.lastMousePoint.y ); + } + this.context.closePath(); + this.context.stroke(); + event.preventDefault(); + } + + Sketcher.prototype.updateCanvasByBrush = function (event) { + //this.drawSelectedImage(true); + var halfBrushW = this.curSize/2;//this.brush.width/2; + var halfBrushH = this.curSize/2;//this.brush.height/2; + + var start = { x:this.lastMousePoint.x, y: this.lastMousePoint.y }; + this.updateMousePosition( event ); + var end = { x:this.lastMousePoint.x, y: this.lastMousePoint.y }; + + var distance = parseInt( Trig.distanceBetween2Points( start, end ) ); + var angle = Trig.angleBetween2Points( start, end ); + + var x,y; + + for ( var z=0; (z<=distance || z==0); z++ ) + { + x = start.x + (Math.sin(angle) * z) - halfBrushW; + y = start.y + (Math.cos(angle) * z) - halfBrushH; + this.context.drawImage(this.brush, x, y); + } + event.preventDefault(); + } + +Drawer = function(objectID, bgcolor){ + initSizeBoxesAndImages(objectID); + var canvasID = objectID; + var brushImage = document.createElement('img'); + var s = new Sketcher(canvasID, brushImage, bgcolor); + setTimeout(function(){ + $("#"+objectID+" .drawing-background.selected").trigger(window.touchDownEvent); + $("#"+objectID+" .tool.selected").trigger(window.touchDownEvent); + $("#"+objectID+" .color.selected").trigger(window.touchDownEvent); + },200); +} + +function initSizeBoxesAndImages(objectID) { + $('#'+objectID+' .drawing-images').hide(); + $('#'+objectID+' .drawing-size').hide(); + setTimeout(function() { + var i = document.getElementById(objectID).getElementsByClassName('size').length; + i = i - 1; + var size = 0; + var sizeLabel = 0; + var reducingFactor = 0; + var containerHeight = $('#'+objectID+' .drawing-size > .sizeContainer').height(); // height == max-height + var containerWidth = $('#'+objectID+' .drawing-size > .sizeContainer').width(); // width == max-width + var customCSSstyle = 'margin-top:0px;position:relative;top:50%;transform:translateY(-50%);-ms-transform:translateY(-50%);-webkit-transform:translateY(-50%);'; + while (i > -1) { + size = document.getElementById(objectID).getElementsByClassName('size')[i].getAttribute('data-size'); + size = size - (size*reducingFactor/100); + if (size < (containerHeight - 5)) { + document.getElementById(objectID).getElementsByClassName('size')[i].setAttribute('style','height:'+size+'px;width:'+size+'px;border-radius:'+size+'px;'+customCSSstyle); + } + else { + sizeLabel = document.getElementById(objectID).getElementsByClassName('size')[i].getAttribute('data-size'); + size = containerHeight - 5; + document.getElementById(objectID).getElementsByClassName('size')[i].setAttribute('style','height:'+size+'px;width:'+size+'px;border-radius:'+size+'px;'+customCSSstyle); + document.getElementById(objectID).getElementsByClassName('size')[i].innerHTML=''+sizeLabel+''; + } + i = i - 1; + } + $('#'+objectID+' .drawing-size .sizeContainer .size > span').each(function() { + var spanH = $(this).height(); + var spanW = $(this).width(); + // containerHeight is set to maximum == containerWidth + var posH = (containerHeight - 5 - spanH) / 2; + var posW = (containerHeight - 5 - spanW) / 2; + $(this).css('top',posH+'px'); + $(this).css('left',posW+'px'); + }); + $('#'+objectID+' .drawing-size').show(); + }, 100); + setTimeout(function(){ + var imagesTotWidth = $('#'+objectID+' .drawing-images').width(); + var objTotWidth = $('#'+objectID).width(); + var imagesLeftVal = (objTotWidth - imagesTotWidth) / 2; + if (imagesLeftVal > 0) { + $('#'+objectID+' .drawing-images').css('left',imagesLeftVal+'px'); + } + $('#'+objectID+' .drawing-images').show(); + },100); +} \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/actions.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/actions.js new file mode 100644 index 0000000..723c922 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/actions.js @@ -0,0 +1,95 @@ +var ua = navigator.userAgent.toLowerCase(); +var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); +var touchDownEvent; +var touchUpEvent; +var isMobile; +var orientationDevice = getOrientation(isAndroid); +var aigX = 0, aigY = 0; +/* + * + * Init Action Lists + * + * + */ +/* + * + * Init SCCounter + * + * + */ + +$(window).load(function(){ + /* + * + * Init SCAnimation + * + * + */ + + /* + * + * Init Shake + * + */ + window.addEventListener('shake', function () { + + }, false); + + /* + * + * Init Masked Images + * + */ + + /* + * + * Init SCPhotogallery + * + * + */ + +SCPhotoGallery('#obj7096', 1024, 768, true, true, true, true); + /* + * + * Init SCQuizMulti + * + * + */ + + /* + * + * Init SCDrawer + * + * + */ + + if(! navigator.userAgent.match(/PubCoderHelper/i)) { + /* + * + * Action Groups + * + */ + + + /* + * + * Events + * + */ + + + /* + * + * Trigger onShow events for objects already shown on stage + * + */ + setTimeout(function() { + +$("#obj7086").trigger('SCEventShow'); +$("#obj7087").trigger('SCEventShow'); +$("#obj7090").trigger('SCEventShow'); +$("#obj7096").trigger('SCEventShow'); +$("#obj7108").trigger('SCEventShow'); + }, 200) + } +}) \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/page.xhtml b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/page.xhtml new file mode 100644 index 0000000..b4a5c34 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/page.xhtml @@ -0,0 +1,159 @@ + + + + + + + + + PubCoder Gallery Widget + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+ +
+
+

Image Gallery

+
+
+

Full-featured Example

+
+
+
+
+
+
+
+

Cars

+
+
+
+
+
+
+ +
Car 1
+
+
+
+
+ +
Car 2
+
+
+
+
+ +
Car 3
+
+
+
+
+ +
Car 4
+
+
+
+
+ +
Car 5
+
+
+
+
+ +
Car 6
+
+
+
+
+ +
Car 7
+
+
+
+
+ +
Car 8
+
+
+
+
+ +
Car 9
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + + + + +
+ +
+ +
+ +
+ + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/styles.css new file mode 100644 index 0000000..2074bd6 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/1/styles.css @@ -0,0 +1,143 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#obj7090 { +position: absolute; +overflow: hidden; +top: 11px; +left: 13px; +width: 998px; +height: 31px; +opacity: 1; +z-index: 2; +display:block; +pointer-events: auto; +} +div#obj7108 { +position: absolute; +overflow: hidden; +top: 55px; +left: 309px; +width: 366px; +height: 35px; +opacity: 1; +z-index: 4; +display:block; +pointer-events: auto; +} + +div#obj7086 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: none; +} +img#obj7086_img { + position: relative; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} + + + + + +div#obj7087 { +position: absolute; +overflow: hidden; +top: 50px; +left: 18px; +width: 988px; +height: 704px; +opacity: 0.8; +z-index: 1; +display:block; +pointer-events: none; +background-image: none; +border-color: #000000; +border-width: 0px; +border-style: solid; +border-radius: 20px; +-moz-border-radius: 20px; +-webkit-border-radius: 20px; +background-color: #FFFFFF; +background-repeat: repeat; +} + + + +#obj7096 { + position: absolute; +overflow: hidden; +top: 121px; +left: 137px; +width: 712px; +height: 528px; +opacity: 1; +z-index: 3; +display:block; +pointer-events: auto; + border-color: #FFFFFF; + border-style: solid; + border-width: 1px; +} +#obj7096_container { + background-color: #FFFFFF; +} +#obj7096 .swiper-container { + width: 712px; + height: 528px; +} +#obj7096_container { + display: none; +} +#obj7096 .paginationContainer { + width: 712px; + background: rgba(255,255,255,0.8666667); +} +#obj7096 figcaption { + display: block; +} +#obj7096 p.SCPhotoGalleryTitleDefault { + display: block; +} +#obj7096 .arrow-left { + display: block; +} +#obj7096 .arrow-right { + display: block; +} +#obj7096 .SCPhotoGalleryTitleDefault { + background: rgba(255,255,255,0.8666667); +} +#obj7096 .SCPhotoGalleryTitleDefault { + font-family: "Droid-Sans-700"; + color: #444444; + font-size: 35px; +} +#obj7096 figure figcaption { + background: rgba(255,255,255,0.8666667); +} +#obj7096 .SCPhotoGalleryCaptionDefault { + font-family: "Droid-Sans-700"; + color: #444444; + font-size: 12px; +} + + + + diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0464.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0464.JPG new file mode 100644 index 0000000..3416bbf Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0464.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0474.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0474.JPG new file mode 100644 index 0000000..8815454 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0474.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0477.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0477.JPG new file mode 100644 index 0000000..5fba53f Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0477.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0505.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0505.JPG new file mode 100644 index 0000000..656a2f1 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0505.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0516.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0516.JPG new file mode 100644 index 0000000..02a3f36 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0516.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0546.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0546.JPG new file mode 100644 index 0000000..a00c493 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0546.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0580.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0580.JPG new file mode 100644 index 0000000..773bf9a Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0580.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0595.JPG b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0595.JPG new file mode 100644 index 0000000..0ad94f6 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_0595.JPG differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_2505.jpg b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_2505.jpg new file mode 100644 index 0000000..a8d03ac Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/IMG_2505.jpg differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/obj7086_image.jpeg b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/obj7086_image.jpeg new file mode 100644 index 0000000..b41c86b Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/assets/images/obj7086_image.jpeg differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/css/general.styles.css b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/css/general.styles.css new file mode 100644 index 0000000..5e5cb0a --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/css/general.styles.css @@ -0,0 +1,373 @@ +/* Font styles: */ +@charset "UTF-8"; + +@font-face { +font-family: "Droid-Sans-700"; +src: url(../fonts/Droid-Sans-700.ttf); +} + +/* Body style */ +body{ + padding:0; + margin:0; +} +/* Audio style */ +audio{ + z-index:-1; +} +/* Page style */ +div.SCPage { + width: 1024px; + height: 768px; + position: relative; + +} +div.SCOverlay { + position: absolute; + z-index: 2; + width: 1024px; + height: 768px; + overflow: hidden; + pointer-events: none; + +} +div.SCContent { + position: absolute; + z-index: 1; + width: 1024px; + height: 768px; +} +/* Navigation Style */ + +.hidden +{ + display:none; +} +/* SCRectangle Style */ +.SCRectangle { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +/* SCPhotoGallery Styles */ +.SCPhotoGallery { + position: absolute; + display: none; + z-index: 1; + box-sizing: border-box; +} +.SCPhotoGallery .arrow-left { + background: url(../images/scphotogallery-prev.png) no-repeat; + background-size: 50px 50px; + position: absolute; + left: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; +} +.SCPhotoGallery .arrow-right { + background: url(../images/scphotogallery-next.png) no-repeat; + background-size: 50px 50px; + position: absolute; + right: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; +} +.SCPhotoGallery p.SCPhotoGalleryTitleDefault { + margin: 0; + padding: 6px; + position: absolute; + left: 0px; + top: 0px; + width: 100%; + z-index: 2; +} +.SCPhotoGallery p.SCPhotoGalleryTitleDefault span { + display:table-cell; + height: 45px; + vertical-align:middle; + display:table; +} +.SCPhotoGallery .icons { + position: absolute; + right: 0; + top: 3px; + z-index: 3; + display:block; +} +.SCPhotoGallery .icon-fullscreen { + position: relative; + right: 0px; + margin-right: 5px; + top: 0px; + float: right; + width: 50px; + height: 50px; + z-index: 4; + display:none; +} +.SCPhotoGallery .fullscreen-open { + background: url(../images/scphotogallery-fullscreen-open.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .fullscreen-close { + background: url(../images/scphotogallery-fullscreen-close.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .icon-index { + position: relative; + right: 0px; + margin-right: 5px; + top: 0px; + float: right; + width: 50px; + height: 50px; + z-index: 4; + display:none; +} +.SCPhotoGallery .index-open { + background: url(../images/scphotogallery-index-open.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .index-close { + background: url(../images/scphotogallery-index-close.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .swiper-container { + left: 0px; +} +.SCPhotoGallery .swiper-slide { + display: table; +} +.SCPhotoGallery figure { + width: 100%; + padding: 0; + margin: 0; + text-align: center; + display: table-cell; + vertical-align: middle; +} +.SCPhotoGallery .swiper-slide img { + vertical-align:middle; + max-width: 100%; + margin: auto; +} +.SCPhotoGallery figure img { + padding: 0; + margin: 0; + text-align: center; +} +.SCPhotoGallery figure figcaption { + margin: 0; + padding: 6px; + position: absolute; + bottom: 0px; +} +.swiper-container { + margin:0 auto; + position:relative; + overflow:hidden; + -webkit-backface-visibility:hidden; + -moz-backface-visibility:hidden; + -ms-backface-visibility:hidden; + -o-backface-visibility:hidden; + backface-visibility:hidden; + /* Fix of Webkit flickering */ + z-index:1; +} +.swiper-wrapper { + position:relative; + width:100%; + -webkit-transition-property:-webkit-transform, left, top; + -webkit-transition-duration:0s; + -webkit-transform:translate3d(0px,0,0); + -webkit-transition-timing-function:ease; + -moz-transition-property:-moz-transform, left, top; + -moz-transition-duration:0s; + -moz-transform:translate3d(0px,0,0); + -moz-transition-timing-function:ease; + -o-transition-property:-o-transform, left, top; + -o-transition-duration:0s; + -o-transform:translate3d(0px,0,0); + -o-transition-timing-function:ease; + -o-transform:translate(0px,0px); + -ms-transition-property:-ms-transform, left, top; + -ms-transition-duration:0s; + -ms-transform:translate3d(0px,0,0); + -ms-transition-timing-function:ease; + transition-property:transform, left, top; + transition-duration:0s; + transform:translate3d(0px,0,0); + transition-timing-function:ease; +} +.swiper-free-mode > .swiper-wrapper { + -webkit-transition-timing-function: ease-out; + -moz-transition-timing-function: ease-out; + -ms-transition-timing-function: ease-out; + -o-transition-timing-function: ease-out; + transition-timing-function: ease-out; + margin: 0 auto; +} +.swiper-slide { + float: left; +} +.swiper-wp8-horizontal { + -ms-touch-action: pan-y; +} +.swiper-wp8-vertical { + -ms-touch-action: pan-x; +} + .SCPhotoGallery .paginationContainer { + position: absolute; + bottom: -95px; + left: 0px; + height: 95px; + margin-top: 20px; + overflow: hidden; + z-index: 2; +} + .SCPhotoGallery .overflowContainer { + position: absolute; + bottom: 0px; + padding-left: 0px; + text-align: center; + height: 80px; + margin: 0px 55px 0px 55px; + display: inline; + overflow-y: hidden; + overflow-x: auto; +} +.SCPhotoGallery .pagination-arrow-left { + background: url(../images/scphotogallery-thumb-prev.png) no-repeat; + background-size: 50px 50px; + position: absolute; + left: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index:2; + display:none; +} +.SCPhotoGallery .pagination-arrow-right { + background: url(../images/scphotogallery-thumb-next.png) no-repeat; + background-size: 50px 50px; + position: absolute; + right: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index:2; + display:none; +} +.SCPhotoGallery .pagination { + position: relative; + text-align: center; + height: 60px; + white-space: nowrap; +} +.SCPhotoGallery .overflowContainer::-webkit-scrollbar { + display: none; +} +.SCPhotoGallery .pagination ul { + list-style: none; + margin: 0; + padding: 0; +} +.SCPhotoGallery .pagination li { + display: inline-block; + width: 80px; + height: 60px; + border-radius: 2px; + margin: 10px; + margin: 0 3px; + text-align: center; + cursor: pointer; + overflow: hidden; +} +.SCPhotoGallery .pagination li.active { + border: 2px solid yellow; + box-sizing: border-box; +} + +/* Custom CSS Styles */ +/* Start of Default SCText Styles */ +body { + font-family: helvetica, arial, sans-serif; +} +.SCText p, h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-regular", helvetica, arial, sans-serif; + margin: 0px; + padding: 0px; + line-height: 1.3; +} +.SCText p { + font-size: 13px; + font-weight: normal; +} +.SCText h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-weight: normal; +} +.SCText h1 { font-size: 40px; } +.SCText h2 { font-size: 36px; } +.SCText h3 { font-size: 24px; } +.SCText h4 { font-size: 18px; } +.SCText h5 { font-size: 16px; } +.SCText h6 { font-size: 14px; } +/* End of Default SCText Styles */ +/* Start of Style Formats defined manually */ +.SCText span.Float-Left { + float: left; +} +.SCText span.Float-Right { + float: right; +} +.SCText span.Vertical-Align-Middle { + display: inline-block; + vertical-align: middle; +} +.SCText span.Add-Margin { + margin: 10px; +} +.SCText span.Shadowed { + text-shadow: #000000 1px 1px 2px; +} +.SCText span.OverBlack { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-size: 13px; + font-weight: normal; + color: #FFFFFF; +} +.SCText span.OverWhite { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-size: 13px; + font-weight: normal; + color: #000000; +} +.SCText span.Active-Text { + border-bottom: 1px dotted; +} +.SCText p.BigText { + font-size: 36px; +} + +/* End of Style Formats defined manually */ +h3 { + text-shadow: #fff 0px 0px 6px; +} +.SCText a { + color: inherit; +} +.SCButton.DefaultButtonTitle { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif !important; + font-size: 13px !important; + font-weight: normal !important; +} \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/fonts/Droid-Sans-700.ttf b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/fonts/Droid-Sans-700.ttf new file mode 100644 index 0000000..942bbf5 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/fonts/Droid-Sans-700.ttf differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-fullscreen-close.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-fullscreen-close.png new file mode 100644 index 0000000..87617c2 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-fullscreen-close.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-fullscreen-open.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-fullscreen-open.png new file mode 100644 index 0000000..789ce87 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-fullscreen-open.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-index-close.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-index-close.png new file mode 100644 index 0000000..de3053c Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-index-close.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-index-open.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-index-open.png new file mode 100644 index 0000000..de3053c Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-index-open.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-next.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-next.png new file mode 100644 index 0000000..a0af4e1 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-next.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-prev.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-prev.png new file mode 100644 index 0000000..78fa58c Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-prev.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-thumb-next.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-thumb-next.png new file mode 100644 index 0000000..422fc6c Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-thumb-next.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-thumb-prev.png b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-thumb-prev.png new file mode 100644 index 0000000..4f7ebe6 Binary files /dev/null and b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/images/scphotogallery-thumb-prev.png differ diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/js/idangerous.swiper-2.3.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/js/idangerous.swiper-2.3.js new file mode 100644 index 0000000..7d65efb --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/js/idangerous.swiper-2.3.js @@ -0,0 +1,2479 @@ +/* + * Swiper 2.3 - Mobile Touch Slider + * http://www.idangero.us/sliders/swiper/ + * + * Copyright 2012-2013, Vladimir Kharlampidi + * The iDangero.us + * http://www.idangero.us/ + * + * Licensed under GPL & MIT + * + * Updated on: November 2, 2013 +*/ +var Swiper = function (selector, params) { + /*========================= + A little bit dirty but required part for IE8 and old FF support + ===========================*/ + if (document.body.__defineGetter__) { + if (HTMLElement) { + var element = HTMLElement.prototype; + if (element.__defineGetter__) { + element.__defineGetter__("outerHTML", function () { return new XMLSerializer().serializeToString(this); } ); + } + } + } + + if (!window.getComputedStyle) { + window.getComputedStyle = function (el, pseudo) { + this.el = el; + this.getPropertyValue = function (prop) { + var re = /(\-([a-z]){1})/g; + if (prop === 'float') prop = 'styleFloat'; + if (re.test(prop)) { + prop = prop.replace(re, function () { + return arguments[2].toUpperCase(); + }); + } + return el.currentStyle[prop] ? el.currentStyle[prop] : null; + } + return this; + } + } + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function(obj, start) { + for (var i = (start || 0), j = this.length; i < j; i++) { + if (this[i] === obj) { return i; } + } + return -1; + } + } + if (!document.querySelectorAll) { + if (!window.jQuery) return; + } + function $$(selector, context) { + if (document.querySelectorAll) + return (context || document).querySelectorAll(selector); + else + return jQuery(selector, context); + } + + /*========================= + Check for correct selector + ===========================*/ + if(typeof selector === 'undefined') return; + + if(!(selector.nodeType)){ + if ($$(selector).length === 0) return; + } + + /*========================= + _this + ===========================*/ + var _this = this; + + /*========================= + Default Flags and vars + ===========================*/ + _this.touches = { + start:0, + startX:0, + startY:0, + current:0, + currentX:0, + currentY:0, + diff:0, + abs:0 + }; + _this.positions = { + start:0, + abs:0, + diff:0, + current:0 + }; + _this.times = { + start:0, + end:0 + }; + + _this.id = (new Date()).getTime(); + _this.container = (selector.nodeType) ? selector : $$(selector)[0]; + _this.isTouched = false; + _this.isMoved = false; + _this.activeIndex = 0; + _this.centerIndex = 0; + _this.activeLoaderIndex = 0; + _this.activeLoopIndex = 0; + _this.previousIndex = null; + _this.velocity = 0; + _this.snapGrid = []; + _this.slidesGrid = []; + _this.imagesToLoad = []; + _this.imagesLoaded = 0; + _this.wrapperLeft=0; + _this.wrapperRight=0; + _this.wrapperTop=0; + _this.wrapperBottom=0; + var wrapper, slideSize, wrapperSize, direction, isScrolling, containerSize; + + /*========================= + Default Parameters + ===========================*/ + var defaults = { + mode : 'horizontal', // or 'vertical' + touchRatio : 1, + speed : 300, + freeMode : false, + freeModeFluid : false, + momentumRatio: 1, + momentumBounce: true, + momentumBounceRatio: 1, + slidesPerView : 1, + slidesPerGroup : 1, + simulateTouch : true, + followFinger : true, + shortSwipes : true, + moveStartThreshold:false, + autoplay: false, + onlyExternal : false, + createPagination : true, + pagination : false, + paginationElement: 'span', + paginationClickable: false, + paginationAsRange: true, + resistance : true, // or false or 100% + scrollContainer : false, + preventLinks : true, + noSwiping : false, // or class + noSwipingClass : 'swiper-no-swiping', //:) + initialSlide: 0, + keyboardControl: false, + mousewheelControl : false, + mousewheelDebounce: 600, + useCSS3Transforms : true, + // Autoplay + autoplay: false, + autoplayDisableOnInteraction: false, + //Loop mode + loop:false, + loopAdditionalSlides:0, + //Auto Height + calculateHeight: false, + //Images Preloader + updateOnImagesReady : true, + //Form elements + releaseFormElements : true, + //Watch for active slide, useful when use effects on different slide states + watchActiveIndex: false, + //Slides Visibility Fit + visibilityFullFit : false, + //Slides Offset + offsetPxBefore : 0, + offsetPxAfter : 0, + offsetSlidesBefore : 0, + offsetSlidesAfter : 0, + centeredSlides: false, + //Queue callbacks + queueStartCallbacks : false, + queueEndCallbacks : false, + //Auto Resize + autoResize : true, + resizeReInit : false, + //DOMAnimation + DOMAnimation : true, + //Slides Loader + loader: { + slides:[], //array with slides + slidesHTMLType:'inner', // or 'outer' + surroundGroups: 1, //keep preloaded slides groups around view + logic: 'reload', //or 'change' + loadAllSlides: false + }, + //Namespace + slideElement : 'div', + slideClass : 'swiper-slide', + slideActiveClass : 'swiper-slide-active', + slideVisibleClass : 'swiper-slide-visible', + wrapperClass : 'swiper-wrapper', + paginationElementClass: 'swiper-pagination-switch', + paginationActiveClass : 'swiper-active-switch', + paginationVisibleClass : 'swiper-visible-switch' + } + params = params || {}; + for (var prop in defaults) { + if (prop in params && typeof params[prop]==='object') { + for (var subProp in defaults[prop]) { + if (! (subProp in params[prop])) { + params[prop][subProp] = defaults[prop][subProp]; + } + } + } + else if (! (prop in params)) { + params[prop] = defaults[prop] + } + } + _this.params = params; + if (params.scrollContainer) { + params.freeMode = true; + params.freeModeFluid = true; + } + if (params.loop) { + params.resistance = '100%'; + } + var isH = params.mode==='horizontal'; + + /*========================= + Define Touch Events + ===========================*/ + + _this.touchEvents = { + touchStart : _this.support.touch || !params.simulateTouch ? 'touchstart' : (_this.browser.ie10 ? 'MSPointerDown' : 'mousedown'), + touchMove : _this.support.touch || !params.simulateTouch ? 'touchmove' : (_this.browser.ie10 ? 'MSPointerMove' : 'mousemove'), + touchEnd : _this.support.touch || !params.simulateTouch ? 'touchend' : (_this.browser.ie10 ? 'MSPointerUp' : 'mouseup') + }; + + /*========================= + Wrapper + ===========================*/ + for (var i = _this.container.childNodes.length - 1; i >= 0; i--) { + if (_this.container.childNodes[i].className) { + var _wrapperClasses = _this.container.childNodes[i].className.split(' ') + for (var j = 0; j < _wrapperClasses.length; j++) { + if (_wrapperClasses[j]===params.wrapperClass) { + wrapper = _this.container.childNodes[i]; + } + }; + } + }; + + _this.wrapper = wrapper; + /*========================= + Slide API + ===========================*/ + _this._extendSwiperSlide = function (el) { + el.append = function () { + if (params.loop) { + el.insertAfter(_this.slides.length-_this.loopedSlides); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + _this.wrapper.appendChild(el); + } + + _this.reInit(); + return el; + } + el.prepend = function () { + if (params.loop) { + _this.wrapper.insertBefore(el, _this.slides[_this.loopedSlides]); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + _this.wrapper.insertBefore(el, _this.wrapper.firstChild); + } + _this.reInit(); + return el; + } + el.insertAfter = function (index) { + if(typeof index === 'undefined') return false; + var beforeSlide; + + if (params.loop) { + beforeSlide = _this.slides[index + 1 + _this.loopedSlides]; + _this.wrapper.insertBefore(el, beforeSlide); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + beforeSlide = _this.slides[index + 1]; + _this.wrapper.insertBefore(el, beforeSlide) + } + _this.reInit(); + return el; + } + el.clone = function () { + return _this._extendSwiperSlide(el.cloneNode(true)) + } + el.remove = function () { + _this.wrapper.removeChild(el); + _this.reInit(); + } + el.html = function (html) { + if (typeof html === 'undefined') { + return el.innerHTML; + } + else { + el.innerHTML = html; + return el; + } + } + el.index = function () { + var index; + for (var i = _this.slides.length - 1; i >= 0; i--) { + if(el === _this.slides[i]) index = i; + } + return index; + } + el.isActive = function () { + if (el.index() === _this.activeIndex) return true; + else return false; + } + if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage={}; + el.getData = function (name) { + return el.swiperSlideDataStorage[name]; + } + el.setData = function (name, value) { + el.swiperSlideDataStorage[name] = value; + return el; + } + el.data = function (name, value) { + if (!value) { + return el.getAttribute('data-'+name); + } + else { + el.setAttribute('data-'+name,value); + return el; + } + } + el.getWidth = function (outer) { + return _this.h.getWidth(el, outer); + } + el.getHeight = function (outer) { + return _this.h.getHeight(el, outer); + } + el.getOffset = function() { + return _this.h.getOffset(el); + } + return el; + } + + //Calculate information about number of slides + _this.calcSlides = function (forceCalcSlides) { + var oldNumber = _this.slides ? _this.slides.length : false; + _this.slides = []; + _this.displaySlides = []; + for (var i = 0; i < _this.wrapper.childNodes.length; i++) { + if (_this.wrapper.childNodes[i].className) { + var _className = _this.wrapper.childNodes[i].className; + var _slideClasses = _className.split(' '); + for (var j = 0; j < _slideClasses.length; j++) { + if(_slideClasses[j]===params.slideClass) { + _this.slides.push(_this.wrapper.childNodes[i]); + } + } + } + } + for (i = _this.slides.length - 1; i >= 0; i--) { + _this._extendSwiperSlide(_this.slides[i]); + } + if (oldNumber===false) return; + if(oldNumber!==_this.slides.length || forceCalcSlides) { + // Number of slides has been changed + removeSlideEvents(); + addSlideEvents(); + _this.updateActiveSlide(); + if (_this.params.pagination) _this.createPagination(); + _this.callPlugins('numberOfSlidesChanged'); + } + } + + //Create Slide + _this.createSlide = function (html, slideClassList, el) { + var slideClassList = slideClassList || _this.params.slideClass; + var el = el||params.slideElement; + var newSlide = document.createElement(el); + newSlide.innerHTML = html||''; + newSlide.className = slideClassList; + return _this._extendSwiperSlide(newSlide); + } + + //Append Slide + _this.appendSlide = function (html, slideClassList, el) { + if (!html) return; + if (html.nodeType) { + return _this._extendSwiperSlide(html).append() + } + else { + return _this.createSlide(html, slideClassList, el).append() + } + } + _this.prependSlide = function (html, slideClassList, el) { + if (!html) return; + if (html.nodeType) { + return _this._extendSwiperSlide(html).prepend() + } + else { + return _this.createSlide(html, slideClassList, el).prepend() + } + } + _this.insertSlideAfter = function (index, html, slideClassList, el) { + if (typeof index === 'undefined') return false; + if (html.nodeType) { + return _this._extendSwiperSlide(html).insertAfter(index); + } + else { + return _this.createSlide(html, slideClassList, el).insertAfter(index); + } + } + _this.removeSlide = function (index) { + if (_this.slides[index]) { + if (params.loop) { + if (!_this.slides[index+_this.loopedSlides]) return false; + _this.slides[index+_this.loopedSlides].remove(); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else _this.slides[index].remove(); + return true; + } + else return false; + } + _this.removeLastSlide = function () { + if (_this.slides.length>0) { + if (params.loop) { + _this.slides[_this.slides.length - 1 - _this.loopedSlides].remove(); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else _this.slides[ (_this.slides.length-1) ].remove(); + return true; + } + else { + return false; + } + } + _this.removeAllSlides = function () { + for (var i = _this.slides.length - 1; i >= 0; i--) { + _this.slides[i].remove() + } + } + _this.getSlide = function (index) { + return _this.slides[index] + } + _this.getLastSlide = function () { + return _this.slides[ _this.slides.length-1 ] + } + _this.getFirstSlide = function () { + return _this.slides[0] + } + + //Currently Active Slide + _this.activeSlide = function () { + return _this.slides[_this.activeIndex] + } + + /*========================= + Plugins API + ===========================*/ + var _plugins = []; + for (var plugin in _this.plugins) { + if (params[plugin]) { + var p = _this.plugins[plugin](_this, params[plugin]); + if (p) _plugins.push( p ); + } + } + _this.callPlugins = function(method, args) { + if (!args) args = {} + for (var i=0; i<_plugins.length; i++) { + if (method in _plugins[i]) { + _plugins[i][method](args); + } + } + } + + /*========================= + WP8 Fix + ===========================*/ + if (_this.browser.ie10 && !params.onlyExternal) { + _this.wrapper.classList.add('swiper-wp8-' + (isH ? 'horizontal' : 'vertical')); + } + + /*========================= + Free Mode Class + ===========================*/ + if (params.freeMode) { + _this.container.className+=' swiper-free-mode'; + } + + /*================================================== + Init/Re-init/Resize Fix + ====================================================*/ + _this.initialized = false; + _this.init = function(force, forceCalcSlides) { + var _width = _this.h.getWidth(_this.container); + var _height = _this.h.getHeight(_this.container); + if (_width===_this.width && _height===_this.height && !force) return; + _this.width = _width; + _this.height = _height; + + containerSize = isH ? _width : _height; + var wrapper = _this.wrapper; + + if (force) { + _this.calcSlides(forceCalcSlides); + } + + if (params.slidesPerView==='auto') { + //Auto mode + var slidesWidth = 0; + var slidesHeight = 0; + + //Unset Styles + if (params.slidesOffset>0) { + wrapper.style.paddingLeft = ''; + wrapper.style.paddingRight = ''; + wrapper.style.paddingTop = ''; + wrapper.style.paddingBottom = ''; + } + wrapper.style.width = ''; + wrapper.style.height = ''; + if (params.offsetPxBefore>0) { + if (isH) _this.wrapperLeft = params.offsetPxBefore; + else _this.wrapperTop = params.offsetPxBefore; + } + if (params.offsetPxAfter>0) { + if (isH) _this.wrapperRight = params.offsetPxAfter; + else _this.wrapperBottom = params.offsetPxAfter; + } + + if (params.centeredSlides) { + if (isH) { + _this.wrapperLeft = (containerSize - this.slides[0].getWidth(true) )/2; + _this.wrapperRight = (containerSize - _this.slides[ _this.slides.length-1 ].getWidth(true))/2; + } + else { + _this.wrapperTop = (containerSize - _this.slides[0].getHeight(true))/2; + _this.wrapperBottom = (containerSize - _this.slides[ _this.slides.length-1 ].getHeight(true))/2; + } + } + + if (isH) { + if (_this.wrapperLeft>=0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; + if (_this.wrapperRight>=0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + } + else { + if (_this.wrapperTop>=0) wrapper.style.paddingTop = _this.wrapperTop+'px'; + if (_this.wrapperBottom>=0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + } + var slideLeft = 0; + var centeredSlideLeft=0; + _this.snapGrid = []; + _this.slidesGrid = []; + + var slideMaxHeight = 0; + for(var i = 0; i<_this.slides.length; i++) { + var slideWidth = _this.slides[i].getWidth(true); + var slideHeight = _this.slides[i].getHeight(true); + if (params.calculateHeight) { + slideMaxHeight = Math.max(slideMaxHeight, slideHeight) + } + var _slideSize = isH ? slideWidth : slideHeight; + if (params.centeredSlides) { + var nextSlideWidth = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getWidth(true); + var nextSlideHeight = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getHeight(true); + var nextSlideSize = isH ? nextSlideWidth : nextSlideHeight; + if (_slideSize>containerSize) { + for (var j=0; j<=Math.floor(_slideSize/(containerSize+_this.wrapperLeft)); j++) { + if (j === 0) _this.snapGrid.push(slideLeft+_this.wrapperLeft); + else _this.snapGrid.push(slideLeft+_this.wrapperLeft+containerSize*j); + } + _this.slidesGrid.push(slideLeft+_this.wrapperLeft); + } + else { + _this.snapGrid.push(centeredSlideLeft); + _this.slidesGrid.push(centeredSlideLeft); + } + + centeredSlideLeft += _slideSize/2 + nextSlideSize/2; + + } + else { + if (_slideSize>containerSize) { + for (var j=0; j<=Math.floor(_slideSize/containerSize); j++) { + _this.snapGrid.push(slideLeft+containerSize*j); + } + } + else { + _this.snapGrid.push(slideLeft); + } + _this.slidesGrid.push(slideLeft); + } + + slideLeft += _slideSize; + + slidesWidth += slideWidth; + slidesHeight += slideHeight; + } + if (params.calculateHeight) _this.height = slideMaxHeight; + if(isH) { + wrapperSize = slidesWidth + _this.wrapperRight + _this.wrapperLeft; + wrapper.style.width = (slidesWidth)+'px'; + wrapper.style.height = (_this.height)+'px'; + } + else { + wrapperSize = slidesHeight + _this.wrapperTop + _this.wrapperBottom; + wrapper.style.width = (_this.width)+'px'; + wrapper.style.height = (slidesHeight)+'px'; + } + + } + else if (params.scrollContainer) { + //Scroll Container + wrapper.style.width = ''; + wrapper.style.height = ''; + var wrapperWidth = _this.slides[0].getWidth(true); + var wrapperHeight = _this.slides[0].getHeight(true); + wrapperSize = isH ? wrapperWidth : wrapperHeight; + wrapper.style.width = wrapperWidth+'px'; + wrapper.style.height = wrapperHeight+'px'; + slideSize = isH ? wrapperWidth : wrapperHeight; + + } + else { + //For usual slides + if (params.calculateHeight) { + var slideMaxHeight = 0; + var wrapperHeight = 0; + //ResetWrapperSize + if (!isH) _this.container.style.height= ''; + wrapper.style.height=''; + + for (var i=0; i<_this.slides.length; i++) { + //ResetSlideSize + _this.slides[i].style.height=''; + slideMaxHeight = Math.max( _this.slides[i].getHeight(true), slideMaxHeight ); + if (!isH) wrapperHeight+=_this.slides[i].getHeight(true); + } + var slideHeight = slideMaxHeight; + _this.height = slideHeight; + + if (isH) wrapperHeight = slideHeight; + else containerSize = slideHeight, _this.container.style.height= containerSize+'px'; + } + else { + var slideHeight = isH ? _this.height : _this.height/params.slidesPerView; + var wrapperHeight = isH ? _this.height : _this.slides.length*slideHeight; + } + var slideWidth = isH ? _this.width/params.slidesPerView : _this.width; + var wrapperWidth = isH ? _this.slides.length*slideWidth : _this.width; + slideSize = isH ? slideWidth : slideHeight; + + if (params.offsetSlidesBefore>0) { + if (isH) _this.wrapperLeft = slideSize*params.offsetSlidesBefore; + else _this.wrapperTop = slideSize*params.offsetSlidesBefore; + } + if (params.offsetSlidesAfter>0) { + if (isH) _this.wrapperRight = slideSize*params.offsetSlidesAfter; + else _this.wrapperBottom = slideSize*params.offsetSlidesAfter; + } + if (params.offsetPxBefore>0) { + if (isH) _this.wrapperLeft = params.offsetPxBefore; + else _this.wrapperTop = params.offsetPxBefore; + } + if (params.offsetPxAfter>0) { + if (isH) _this.wrapperRight = params.offsetPxAfter; + else _this.wrapperBottom = params.offsetPxAfter; + } + if (params.centeredSlides) { + if (isH) { + _this.wrapperLeft = (containerSize - slideSize)/2; + _this.wrapperRight = (containerSize - slideSize)/2; + } + else { + _this.wrapperTop = (containerSize - slideSize)/2; + _this.wrapperBottom = (containerSize - slideSize)/2; + } + } + if (isH) { + if (_this.wrapperLeft>0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; + if (_this.wrapperRight>0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + } + else { + if (_this.wrapperTop>0) wrapper.style.paddingTop = _this.wrapperTop+'px'; + if (_this.wrapperBottom>0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + } + + wrapperSize = isH ? wrapperWidth + _this.wrapperRight + _this.wrapperLeft : wrapperHeight + _this.wrapperTop + _this.wrapperBottom; + wrapper.style.width = wrapperWidth+'px'; + wrapper.style.height = wrapperHeight+'px'; + var slideLeft = 0; + _this.snapGrid = []; + _this.slidesGrid = []; + for (var i=0; i<_this.slides.length; i++) { + _this.snapGrid.push(slideLeft); + _this.slidesGrid.push(slideLeft); + slideLeft+=slideSize; + _this.slides[i].style.width = slideWidth+'px'; + _this.slides[i].style.height = slideHeight+'px'; + } + + } + + if (!_this.initialized) { + _this.callPlugins('onFirstInit'); + if (params.onFirstInit) params.onFirstInit(_this); + } + else { + _this.callPlugins('onInit'); + if (params.onInit) params.onInit(_this); + } + _this.initialized = true; + } + + _this.reInit = function (forceCalcSlides) { + _this.init(true, forceCalcSlides); + } + + _this.resizeFix = function (reInit) { + _this.callPlugins('beforeResizeFix'); + + _this.init(params.resizeReInit || reInit); + + // swipe to active slide in fixed mode + if (!params.freeMode) { + _this.swipeTo((params.loop ? _this.activeLoopIndex : _this.activeIndex), 0, false); + } + + // move wrapper to the beginning in free mode + else if (_this.getWrapperTranslate() < -maxWrapperPosition()) { + _this.setWrapperTransition(0); + _this.setWrapperTranslate(-maxWrapperPosition()); + } + + _this.callPlugins('afterResizeFix'); + } + + /*========================================== + Max and Min Positions + ============================================*/ + function maxWrapperPosition() { + var a = (wrapperSize - containerSize); + if (params.freeMode) { + a = wrapperSize - containerSize; + } + // if (params.loop) a -= containerSize; + if (params.slidesPerView > _this.slides.length) a = 0; + if (a<0) a = 0; + return a; + } + function minWrapperPosition() { + var a = 0; + // if (params.loop) a = containerSize; + return a; + } + + /*========================================== + Event Listeners + ============================================*/ + function initEvents() { + var bind = _this.h.addEventListener; + + //Touch Events + if (!_this.browser.ie10) { + if (_this.support.touch) { + bind(_this.wrapper, 'touchstart', onTouchStart); + bind(_this.wrapper, 'touchmove', onTouchMove); + bind(_this.wrapper, 'touchend', onTouchEnd); + } + if (params.simulateTouch) { + bind(_this.wrapper, 'mousedown', onTouchStart); + bind(document, 'mousemove', onTouchMove); + bind(document, 'mouseup', onTouchEnd); + } + } + else { + bind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); + bind(document, _this.touchEvents.touchMove, onTouchMove); + bind(document, _this.touchEvents.touchEnd, onTouchEnd); + } + + //Resize Event + if (params.autoResize) { + bind(window, 'resize', _this.resizeFix); + } + //Slide Events + addSlideEvents(); + //Mousewheel + _this._wheelEvent = false; + if (params.mousewheelControl) { + if ( document.onmousewheel !== undefined ) { + _this._wheelEvent = "mousewheel"; + } + try { + WheelEvent("wheel"); + _this._wheelEvent = "wheel"; + } catch (e) {} + if ( !_this._wheelEvent ) { + _this._wheelEvent = "DOMMouseScroll"; + } + + if (_this._wheelEvent) { + bind(_this.container, _this._wheelEvent, handleMousewheel); + } + } + + //Keyboard + if (params.keyboardControl) { + bind(document, 'keydown', handleKeyboardKeys); + } + if (params.updateOnImagesReady) { + _this.imagesToLoad = $$('img', _this.container); + + for (var i=0; i<_this.imagesToLoad.length; i++) { + _loadImage(_this.imagesToLoad[i].getAttribute('src')) + } + } + function _loadImage(src) { + var image = new Image(); + image.onload = function(){ + _this.imagesLoaded++; + if (_this.imagesLoaded==_this.imagesToLoad.length) { + _this.reInit(); + if (params.onImagesReady) params.onImagesReady(_this); + } + } + image.src = src; + } + } + + //Remove Event Listeners + _this.destroy = function(removeResizeFix){ + var unbind = _this.h.removeEventListener; + + //Touch Events + if (!_this.browser.ie10) { + if (_this.support.touch) { + unbind(_this.wrapper, 'touchstart', onTouchStart); + unbind(_this.wrapper, 'touchmove', onTouchMove); + unbind(_this.wrapper, 'touchend', onTouchEnd); + } + if (params.simulateTouch) { + unbind(_this.wrapper, 'mousedown', onTouchStart); + unbind(document, 'mousemove', onTouchMove); + unbind(document, 'mouseup', onTouchEnd); + } + } + else { + unbind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); + unbind(document, _this.touchEvents.touchMove, onTouchMove); + unbind(document, _this.touchEvents.touchEnd, onTouchEnd); + } + + //Resize Event + if (params.autoResize) { + unbind(window, 'resize', _this.resizeFix); + } + + //Init Slide Events + removeSlideEvents(); + + //Pagination + if (params.paginationClickable) { + removePaginationEvents(); + } + + //Mousewheel + if (params.mousewheelControl && _this._wheelEvent) { + unbind(_this.container, _this._wheelEvent, handleMousewheel); + } + + //Keyboard + if (params.keyboardControl) { + unbind(document, 'keydown', handleKeyboardKeys); + } + + //Stop autoplay + if (params.autoplay) { + _this.stopAutoplay(); + } + _this.callPlugins('onDestroy'); + + //Destroy variable + _this = null; + } + function addSlideEvents() { + var bind = _this.h.addEventListener, + i; + + //Prevent Links Events + if (params.preventLinks) { + var links = $$('a', _this.container); + for (i=0; i=scrollLeft && point[0]<=scrollLeft+windowWidth && + point[1]>=scrollTop && point[1]<=scrollTop+windowHeight + ) { + inView = true; + } + + } + if (!inView) return; + } + if (isH) { + if (kc==37 || kc==39) { + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + } + if (kc == 39) _this.swipeNext(); + if (kc == 37) _this.swipePrev(); + } + else { + if (kc==38 || kc==40) { + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + } + if (kc == 40) _this.swipeNext(); + if (kc == 38) _this.swipePrev(); + } + } + + /*========================================== + Mousewheel Control + ============================================*/ + var allowScrollChange = true; + function handleMousewheel (e) { + var we = _this._wheelEvent; + var delta; + //Opera & IE + if (e.detail) delta = -e.detail; + //WebKits + else if (we == 'mousewheel') delta = e.wheelDelta; + //Old FireFox + else if (we == 'DOMMouseScroll') delta = -e.detail; + //New FireFox + else if (we == 'wheel') { + delta = Math.abs(e.deltaX)>Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY; + } + if (!params.freeMode) { + if(delta<0) _this.swipeNext(); + else _this.swipePrev(); + } + else { + //Freemode or scrollContainer: + var position = _this.getWrapperTranslate() + delta; + + if (position > 0) position = 0; + if (position < -maxWrapperPosition()) position = -maxWrapperPosition(); + + _this.setWrapperTransition(0); + _this.setWrapperTranslate(position); + _this.updateActiveSlide(position); + } + if (params.autoplay) _this.stopAutoplay(true); + + if(e.preventDefault) e.preventDefault(); + else e.returnValue = false; + return false; + } + + /*========================= + Grab Cursor + ===========================*/ + if (params.grabCursor) { + var containerStyle = _this.container.style; + containerStyle.cursor = 'move'; + containerStyle.cursor = 'grab'; + containerStyle.cursor = '-moz-grab'; + containerStyle.cursor = '-webkit-grab'; + } + + /*========================= + Slides Events Handlers + ===========================*/ + + _this.allowSlideClick = true; + function slideClick(event) { + //hack PubCoder + event.preventDefault(); + if (_this.allowSlideClick) { + setClickedSlide(event); + params.onSlideClick(_this, event); + } + } + + function slideTouch(event) { + setClickedSlide(event); + params.onSlideTouch(_this, event); + } + + function setClickedSlide(event) { + //hack PubCoder + event.preventDefault(); + // IE 6-8 support + if (!event.currentTarget) { + var element = event.srcElement; + do { + if (element.className.indexOf(params.slideClass) > -1) { + break; + } + } + while (element = element.parentNode); + _this.clickedSlide = element; + } + else { + _this.clickedSlide = event.currentTarget; + } + + _this.clickedSlideIndex = _this.slides.indexOf(_this.clickedSlide); + _this.clickedSlideLoopIndex = _this.clickedSlideIndex - (_this.loopedSlides || 0); + } + + _this.allowLinks = true; + function preventClick(e) { + if (!_this.allowLinks) { + if(e.preventDefault) e.preventDefault(); + else e.returnValue = false; + return false; + } + } + function releaseForms(e) { + if (e.stopPropagation) e.stopPropagation(); + else e.returnValue = false; + return false; + + } + + /*================================================== + Event Handlers + ====================================================*/ + var isTouchEvent = false; + var allowThresholdMove; + var allowMomentumBounce = true; + function onTouchStart(event) { + if (params.preventLinks) _this.allowLinks = true; + //Exit if slider is already was touched + if (_this.isTouched || params.onlyExternal) { + return false; + } + + if (params.noSwiping && (event.target || event.srcElement) && noSwipingSlide(event.target || event.srcElement)) return false; + allowMomentumBounce = false; + + //Check For Nested Swipers + _this.isTouched = true; + isTouchEvent = event.type=='touchstart'; + + if (!isTouchEvent || event.targetTouches.length == 1 ) { + _this.callPlugins('onTouchStartBegin'); + + if(!isTouchEvent) { + if(event.preventDefault) event.preventDefault(); + else event.returnValue = false; + } + + var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); + var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); + + //Start Touches to check the scrolling + _this.touches.startX = _this.touches.currentX = pageX; + _this.touches.startY = _this.touches.currentY = pageY; + + _this.touches.start = _this.touches.current = isH ? pageX : pageY; + + //Set Transition Time to 0 + _this.setWrapperTransition(0); + + //Get Start Translate Position + _this.positions.start = _this.positions.current = _this.getWrapperTranslate(); + + //Set Transform + _this.setWrapperTranslate(_this.positions.start); + + //TouchStartTime + _this.times.start = (new Date()).getTime(); + + //Unset Scrolling + isScrolling = undefined; + + //Set Treshold + if (params.moveStartThreshold>0) allowThresholdMove = false; + + //CallBack + if (params.onTouchStart) params.onTouchStart(_this); + _this.callPlugins('onTouchStartEnd'); + + } + } + var velocityPrevPosition, velocityPrevTime; + function onTouchMove(event) { + // If slider is not touched - exit + if (!_this.isTouched || params.onlyExternal) return; + if (isTouchEvent && event.type=='mousemove') return; + + var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); + var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); + + //check for scrolling + if ( typeof isScrolling === 'undefined' && isH) { + isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) > Math.abs( pageX - _this.touches.startX ) ); + } + if ( typeof isScrolling === 'undefined' && !isH) { + isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) < Math.abs( pageX - _this.touches.startX ) ); + } + if (isScrolling ) { + _this.isTouched = false; + return; + } + + //Check For Nested Swipers + if (event.assignedToSwiper) { + _this.isTouched = false; + return; + } + event.assignedToSwiper = true; + + //Block inner links + if (params.preventLinks) { + _this.allowLinks = false; + } + if (params.onSlideClick) { + _this.allowSlideClick = false; + } + + //Stop AutoPlay if exist + if (params.autoplay) { + _this.stopAutoplay(true); + } + if (!isTouchEvent || event.touches.length == 1) { + + //Moved Flag + if (!_this.isMoved) { + _this.callPlugins('onTouchMoveStart'); + + if (params.loop) { + _this.fixLoop(); + _this.positions.start = _this.getWrapperTranslate(); + } + if (params.onTouchMoveStart) params.onTouchMoveStart(_this); + } + _this.isMoved = true; + + // cancel event + if(event.preventDefault) event.preventDefault(); + else event.returnValue = false; + + _this.touches.current = isH ? pageX : pageY ; + + _this.positions.current = (_this.touches.current - _this.touches.start) * params.touchRatio + _this.positions.start; + + //Resistance Callbacks + if(_this.positions.current > 0 && params.onResistanceBefore) { + params.onResistanceBefore(_this, _this.positions.current); + } + if(_this.positions.current < -maxWrapperPosition() && params.onResistanceAfter) { + params.onResistanceAfter(_this, Math.abs(_this.positions.current + maxWrapperPosition())); + } + //Resistance + if (params.resistance && params.resistance!='100%') { + //Resistance for Negative-Back sliding + if(_this.positions.current > 0) { + var resistance = 1 - _this.positions.current/containerSize/2; + if (resistance < 0.5) + _this.positions.current = (containerSize/2); + else + _this.positions.current = _this.positions.current * resistance; + } + //Resistance for After-End Sliding + if ( _this.positions.current < -maxWrapperPosition() ) { + + var diff = (_this.touches.current - _this.touches.start)*params.touchRatio + (maxWrapperPosition()+_this.positions.start); + var resistance = (containerSize+diff)/(containerSize); + var newPos = _this.positions.current-diff*(1-resistance)/2; + var stopPos = -maxWrapperPosition() - containerSize/2; + + if (newPos < stopPos || resistance<=0) + _this.positions.current = stopPos; + else + _this.positions.current = newPos; + } + } + if (params.resistance && params.resistance=='100%') { + //Resistance for Negative-Back sliding + if(_this.positions.current > 0 && !(params.freeMode&&!params.freeModeFluid)) { + _this.positions.current = 0; + } + //Resistance for After-End Sliding + if ( (_this.positions.current) < -maxWrapperPosition() && !(params.freeMode&&!params.freeModeFluid)) { + _this.positions.current = -maxWrapperPosition(); + } + } + //Move Slides + if (!params.followFinger) return; + + if (!params.moveStartThreshold) { + _this.setWrapperTranslate(_this.positions.current); + } + else { + if ( Math.abs(_this.touches.current - _this.touches.start)>params.moveStartThreshold || allowThresholdMove) { + allowThresholdMove = true; + _this.setWrapperTranslate(_this.positions.current); + } + else { + _this.positions.current = _this.positions.start; + } + } + + if (params.freeMode || params.watchActiveIndex) { + _this.updateActiveSlide(_this.positions.current); + } + + //Grab Cursor + if (params.grabCursor) { + _this.container.style.cursor = 'move'; + _this.container.style.cursor = 'grabbing'; + _this.container.style.cursor = '-moz-grabbin'; + _this.container.style.cursor = '-webkit-grabbing'; + } + //Velocity + if (!velocityPrevPosition) velocityPrevPosition = _this.touches.current; + if (!velocityPrevTime) velocityPrevTime = (new Date).getTime(); + _this.velocity = (_this.touches.current - velocityPrevPosition)/((new Date).getTime() - velocityPrevTime)/2; + if (Math.abs(_this.touches.current - velocityPrevPosition)<2) _this.velocity=0; + velocityPrevPosition = _this.touches.current; + velocityPrevTime = (new Date).getTime(); + //Callbacks + _this.callPlugins('onTouchMoveEnd'); + if (params.onTouchMove) params.onTouchMove(_this); + + return false; + } + } + function onTouchEnd(event) { + //Check For scrolling + if (isScrolling) { + _this.swipeReset(); + } + // If slider is not touched exit + if ( params.onlyExternal || !_this.isTouched ) return; + _this.isTouched = false + + //Return Grab Cursor + if (params.grabCursor) { + _this.container.style.cursor = 'move'; + _this.container.style.cursor = 'grab'; + _this.container.style.cursor = '-moz-grab'; + _this.container.style.cursor = '-webkit-grab'; + } + + //Check for Current Position + if (!_this.positions.current && _this.positions.current!==0) { + _this.positions.current = _this.positions.start + } + + //For case if slider touched but not moved + if (params.followFinger) { + _this.setWrapperTranslate(_this.positions.current); + } + + // TouchEndTime + _this.times.end = (new Date()).getTime(); + + //Difference + _this.touches.diff = _this.touches.current - _this.touches.start + _this.touches.abs = Math.abs(_this.touches.diff) + + _this.positions.diff = _this.positions.current - _this.positions.start + _this.positions.abs = Math.abs(_this.positions.diff) + + var diff = _this.positions.diff ; + var diffAbs =_this.positions.abs ; + var timeDiff = _this.times.end - _this.times.start + + if(diffAbs < 5 && (timeDiff) < 300 && _this.allowLinks == false) { + if (!params.freeMode && diffAbs!=0) _this.swipeReset() + //Release inner links + if (params.preventLinks) { + _this.allowLinks = true; + } + if (params.onSlideClick) { + _this.allowSlideClick = true; + } + } + + setTimeout(function () { + //Release inner links + if (params.preventLinks) { + _this.allowLinks = true; + } + if (params.onSlideClick) { + _this.allowSlideClick = true; + } + }, 100); + + var maxPosition = maxWrapperPosition(); + + //Not moved or Prevent Negative Back Sliding/After-End Sliding + if (!_this.isMoved && params.freeMode) { + _this.isMoved = false; + if (params.onTouchEnd) params.onTouchEnd(_this); + _this.callPlugins('onTouchEnd'); + return; + } + if (!_this.isMoved || _this.positions.current > 0 || _this.positions.current < -maxPosition) { + _this.swipeReset(); + if (params.onTouchEnd) params.onTouchEnd(_this); + _this.callPlugins('onTouchEnd'); + return; + } + + _this.isMoved = false; + + //Free Mode + if (params.freeMode) { + if ( params.freeModeFluid ) { + var momentumDuration = 1000*params.momentumRatio; + var momentumDistance = _this.velocity*momentumDuration; + var newPosition = _this.positions.current + momentumDistance + var doBounce = false; + var afterBouncePosition; + var bounceAmount = Math.abs( _this.velocity )*20*params.momentumBounceRatio; + if (newPosition < -maxPosition) { + if (params.momentumBounce && _this.support.transitions) { + if (newPosition + maxPosition < -bounceAmount) newPosition = -maxPosition-bounceAmount; + afterBouncePosition = -maxPosition; + doBounce=true; + allowMomentumBounce = true; + } + else newPosition = -maxPosition; + } + if (newPosition > 0) { + if (params.momentumBounce && _this.support.transitions) { + if (newPosition>bounceAmount) newPosition = bounceAmount; + afterBouncePosition = 0 + doBounce = true; + allowMomentumBounce = true; + } + else newPosition = 0; + } + //Fix duration + if (_this.velocity!=0) momentumDuration = Math.abs((newPosition - _this.positions.current)/_this.velocity) + + _this.setWrapperTranslate(newPosition); + + _this.setWrapperTransition( momentumDuration ); + + if (params.momentumBounce && doBounce) { + _this.wrapperTransitionEnd(function () { + if (!allowMomentumBounce) return; + + if (params.onMomentumBounce) params.onMomentumBounce(_this); + + _this.setWrapperTranslate(afterBouncePosition); + _this.setWrapperTransition(300); + }) + } + + _this.updateActiveSlide(newPosition) + } + if (!params.freeModeFluid || timeDiff >= 300) _this.updateActiveSlide(_this.positions.current) + + if (params.onTouchEnd) params.onTouchEnd(_this) + _this.callPlugins('onTouchEnd'); + return; + } + + //Direction + direction = diff < 0 ? "toNext" : "toPrev" + + //Short Touches + if (direction=="toNext" && ( timeDiff <= 300 ) ) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + else _this.swipeNext(true); + } + + if (direction=="toPrev" && ( timeDiff <= 300 ) ) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + else _this.swipePrev(true); + } + + //Long Touches + var targetSlideSize = 0; + if(params.slidesPerView == 'auto') { + //Define current slide's width + var currentPosition = Math.abs(_this.getWrapperTranslate()); + var slidesOffset = 0; + var _slideSize; + for (var i=0; i<_this.slides.length; i++) { + _slideSize = isH ? _this.slides[i].getWidth(true) : _this.slides[i].getHeight(true); + slidesOffset+= _slideSize; + if (slidesOffset>currentPosition) { + targetSlideSize = _slideSize; + break; + } + } + if (targetSlideSize>containerSize) targetSlideSize = containerSize; + } + else { + targetSlideSize = slideSize * params.slidesPerView; + } + if (direction=="toNext" && ( timeDiff > 300 ) ) { + if (diffAbs >= targetSlideSize*0.5) { + _this.swipeNext(true) + } + else { + _this.swipeReset() + } + } + if (direction=="toPrev" && ( timeDiff > 300 ) ) { + if (diffAbs >= targetSlideSize*0.5) { + _this.swipePrev(true); + } + else { + _this.swipeReset() + } + } + if (params.onTouchEnd) params.onTouchEnd(_this) + _this.callPlugins('onTouchEnd'); + } + + + /*================================================== + noSwiping Bubble Check by Isaac Strack + ====================================================*/ + function noSwipingSlide(el){ + /*This function is specifically designed to check the parent elements for the noSwiping class, up to the wrapper. + We need to check parents because while onTouchStart bubbles, _this.isTouched is checked in onTouchStart, which stops the bubbling. + So, if a text box, for example, is the initial target, and the parent slide container has the noSwiping class, the _this.isTouched + check will never find it, and what was supposed to be noSwiping is able to be swiped. + This function will iterate up and check for the noSwiping class in parents, up through the wrapperClass.*/ + + // First we create a truthy variable, which is that swiping is allowd (noSwiping = false) + var noSwiping = false; + + // Now we iterate up (parentElements) until we reach the node with the wrapperClass. + do{ + + // Each time, we check to see if there's a 'swiper-no-swiping' class (noSwipingClass). + if (el.className.indexOf(params.noSwipingClass)>-1) + { + noSwiping = true; // If there is, we set noSwiping = true; + } + + el = el.parentElement; // now we iterate up (parent node) + + } while(!noSwiping && el.parentElement && el.className.indexOf(params.wrapperClass)==-1); // also include el.parentElement truthy, just in case. + + // because we didn't check the wrapper itself, we do so now, if noSwiping is false: + if (!noSwiping && el.className.indexOf(params.wrapperClass)>-1 && el.className.indexOf(params.noSwipingClass)>-1) + noSwiping = true; // if the wrapper has the noSwipingClass, we set noSwiping = true; + + return noSwiping; + } + + /*================================================== + Swipe Functions + ====================================================*/ + _this.swipeNext = function(internal){ + if (!internal && params.loop) _this.fixLoop(); + if (!internal && params.autoplay) _this.stopAutoplay(true); + _this.callPlugins('onSwipeNext'); + var currentPosition = _this.getWrapperTranslate(); + var newPosition = currentPosition; + if (params.slidesPerView=='auto') { + for (var i=0; i<_this.snapGrid.length; i++) { + if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + newPosition = -_this.snapGrid[i+1] + break; + } + } + } + else { + var groupSize = slideSize * params.slidesPerGroup; + newPosition = -(Math.floor(Math.abs(currentPosition)/Math.floor(groupSize))*groupSize + groupSize); + } + if (newPosition < - maxWrapperPosition()) { + newPosition = - maxWrapperPosition() + }; + + if (newPosition == currentPosition) return false; + + swipeToPosition(newPosition, 'next'); + return true + } + _this.swipePrev = function(internal){ + if (!internal && params.loop) _this.fixLoop(); + if (!internal && params.autoplay) _this.stopAutoplay(true); + _this.callPlugins('onSwipePrev'); + + var currentPosition = Math.ceil(_this.getWrapperTranslate()); + var newPosition; + if (params.slidesPerView=='auto') { + newPosition = 0; + for (var i=1; i<_this.snapGrid.length; i++) { + if (-currentPosition == _this.snapGrid[i]) { + newPosition = -_this.snapGrid[i-1] + break; + } + if (-currentPosition > _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + newPosition = -_this.snapGrid[i] + break; + } + } + } + else { + var groupSize = slideSize * params.slidesPerGroup; + newPosition = -(Math.ceil(-currentPosition/groupSize)-1)*groupSize; + } + + if (newPosition > 0) newPosition = 0; + + if (newPosition == currentPosition) return false; + swipeToPosition(newPosition, 'prev'); + return true; + + } + _this.swipeReset = function(){ + _this.callPlugins('onSwipeReset'); + var currentPosition = _this.getWrapperTranslate(); + var groupSize = slideSize * params.slidesPerGroup; + var newPosition; + var maxPosition = -maxWrapperPosition(); + if (params.slidesPerView=='auto') { + newPosition = 0; + for (var i=0; i<_this.snapGrid.length; i++) { + if (-currentPosition===_this.snapGrid[i]) return; + if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + if(_this.positions.diff>0) newPosition = -_this.snapGrid[i+1] + else newPosition = -_this.snapGrid[i] + break; + } + } + if (-currentPosition >= _this.snapGrid[_this.snapGrid.length-1]) newPosition = -_this.snapGrid[_this.snapGrid.length-1]; + if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition() + } + else { + newPosition = currentPosition<0 ? Math.round(currentPosition/groupSize)*groupSize : 0 + } + if (params.scrollContainer) { + newPosition = currentPosition<0 ? currentPosition : 0; + } + if (newPosition < -maxWrapperPosition()) { + newPosition = -maxWrapperPosition() + } + if (params.scrollContainer && (containerSize>slideSize)) { + newPosition = 0; + } + + if (newPosition == currentPosition) return false; + + swipeToPosition(newPosition, 'reset'); + return true; + } + + _this.swipeTo = function(index, speed, runCallbacks) { + index = parseInt(index, 10); + _this.callPlugins('onSwipeTo', {index:index, speed:speed}); + if (params.loop) index = index + _this.loopedSlides; + var currentPosition = _this.getWrapperTranslate(); + if (index > (_this.slides.length-1) || index < 0) return; + var newPosition + if (params.slidesPerView=='auto') { + newPosition = -_this.slidesGrid[ index ]; + } + else { + newPosition = -index*slideSize; + } + if (newPosition < - maxWrapperPosition()) { + newPosition = - maxWrapperPosition(); + }; + + if (newPosition == currentPosition) return false; + + runCallbacks = runCallbacks===false ? false : true; + swipeToPosition(newPosition, 'to', {index:index, speed:speed, runCallbacks:runCallbacks}); + return true; + } + + function swipeToPosition(newPosition, action, toOptions) { + var speed = (action=='to' && toOptions.speed >= 0) ? toOptions.speed : params.speed; + + if (_this.support.transitions || !params.DOMAnimation) { + _this.setWrapperTranslate(newPosition); + _this.setWrapperTransition(speed); + } + else { + //Try the DOM animation + var currentPosition = _this.getWrapperTranslate(); + var animationStep = Math.ceil( (newPosition - currentPosition)/speed*(1000/60) ); + var direction = currentPosition > newPosition ? 'toNext' : 'toPrev'; + var condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; + if (_this._DOMAnimating) return; + + anim(); + } + function anim(){ + currentPosition += animationStep; + condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; + if (condition) { + _this.setWrapperTranslate(Math.round(currentPosition)); + _this._DOMAnimating = true + window.setTimeout(function(){ + anim() + }, 1000 / 60) + } + else { + if (params.onSlideChangeEnd) params.onSlideChangeEnd(_this); + _this.setWrapperTranslate(newPosition); + _this._DOMAnimating = false; + } + } + + //Update Active Slide Index + _this.updateActiveSlide(newPosition); + + //Callbacks + if (params.onSlideNext && action=='next') { + params.onSlideNext(_this, newPosition); + } + if (params.onSlidePrev && action=='prev') { + params.onSlidePrev(_this, newPosition); + } + //"Reset" Callback + if (params.onSlideReset && action=='reset') { + params.onSlideReset(_this, newPosition); + } + + //"Next", "Prev" and "To" Callbacks + if (action=='next' || action=='prev' || (action=='to' && toOptions.runCallbacks==true)) + slideChangeCallbacks(); + } + /*================================================== + Transition Callbacks + ====================================================*/ + //Prevent Multiple Callbacks + _this._queueStartCallbacks = false; + _this._queueEndCallbacks = false; + function slideChangeCallbacks() { + //Transition Start Callback + _this.callPlugins('onSlideChangeStart'); + if (params.onSlideChangeStart) { + if (params.queueStartCallbacks && _this.support.transitions) { + if (_this._queueStartCallbacks) return; + _this._queueStartCallbacks = true; + params.onSlideChangeStart(_this) + _this.wrapperTransitionEnd(function(){ + _this._queueStartCallbacks = false; + }) + } + else params.onSlideChangeStart(_this) + } + //Transition End Callback + if (params.onSlideChangeEnd) { + if (_this.support.transitions) { + if (params.queueEndCallbacks) { + if (_this._queueEndCallbacks) return; + _this._queueEndCallbacks = true; + _this.wrapperTransitionEnd(params.onSlideChangeEnd) + } + else _this.wrapperTransitionEnd(params.onSlideChangeEnd) + } + else { + if (!params.DOMAnimation) { + setTimeout(function(){ + params.onSlideChangeEnd(_this) + },10) + } + } + } + } + + /*================================================== + Update Active Slide Index + ====================================================*/ + _this.updateActiveSlide = function(position) { + if (!_this.initialized) return; + if (_this.slides.length==0) return; + _this.previousIndex = _this.activeIndex; + if (typeof position=='undefined') position = _this.getWrapperTranslate(); + if (position>0) position=0; + + if (params.slidesPerView == 'auto') { + var slidesOffset = 0; + _this.activeIndex = _this.slidesGrid.indexOf(-position); + if (_this.activeIndex<0) { + for (var i=0; i<_this.slidesGrid.length-1; i++) { + if (-position>_this.slidesGrid[i] && -position<_this.slidesGrid[i+1]) { + break; + } + } + var leftDistance = Math.abs( _this.slidesGrid[i] + position ) + var rightDistance = Math.abs( _this.slidesGrid[i+1] + position ) + if (leftDistance<=rightDistance) _this.activeIndex = i; + else _this.activeIndex = i+1; + } + } + else { + _this.activeIndex = Math[params.visibilityFullFit ? 'ceil' : 'round']( -position/slideSize ); + } + + if (_this.activeIndex == _this.slides.length ) _this.activeIndex = _this.slides.length - 1; + if (_this.activeIndex < 0) _this.activeIndex = 0; + + // Check for slide + if (!_this.slides[_this.activeIndex]) return; + + // Calc Visible slides + _this.calcVisibleSlides(position); + + // Mark visible and active slides with additonal classes + var activeClassRegexp = new RegExp( "\\s*" + params.slideActiveClass ); + var inViewClassRegexp = new RegExp( "\\s*" + params.slideVisibleClass ); + + for (var i = 0; i < _this.slides.length; i++) { + _this.slides[ i ].className = _this.slides[ i ].className.replace( activeClassRegexp, '' ).replace( inViewClassRegexp, '' ); + if ( _this.visibleSlides.indexOf( _this.slides[ i ] )>=0 ) { + _this.slides[ i ].className += ' ' + params.slideVisibleClass; + } + + } + _this.slides[ _this.activeIndex ].className += ' ' + params.slideActiveClass; + + //Update loop index + if (params.loop) { + var ls = _this.loopedSlides; + _this.activeLoopIndex = _this.activeIndex - ls; + if (_this.activeLoopIndex >= _this.slides.length - ls*2 ) { + _this.activeLoopIndex = _this.slides.length - ls*2 - _this.activeLoopIndex; + } + if (_this.activeLoopIndex<0) { + _this.activeLoopIndex = _this.slides.length - ls*2 + _this.activeLoopIndex; + } + } + else { + _this.activeLoopIndex = _this.activeIndex; + } + //Update Pagination + if (params.pagination) { + _this.updatePagination(position); + } + } + /*================================================== + Pagination + ====================================================*/ + _this.createPagination = function (firstInit) { + if (params.paginationClickable && _this.paginationButtons) { + removePaginationEvents(); + } + _this.paginationContainer = params.pagination.nodeType ? params.pagination : $$(params.pagination)[0]; + if (params.createPagination) { + var paginationHTML = ""; + var numOfSlides = _this.slides.length; + var numOfButtons = numOfSlides; + if (params.loop) numOfButtons -= _this.loopedSlides*2 + for (var i = 0; i < numOfButtons; i++) { + paginationHTML += '<'+params.paginationElement+' class="'+params.paginationElementClass+'">' + } + _this.paginationContainer.innerHTML = paginationHTML; + } + _this.paginationButtons = $$('.'+params.paginationElementClass, _this.paginationContainer); + if (!firstInit) _this.updatePagination() + _this.callPlugins('onCreatePagination'); + if (params.paginationClickable) { + addPaginationEvents(); + } + } + function removePaginationEvents() { + var pagers = _this.paginationButtons; + for (var i=0; i=_this.slides.length-_this.loopedSlides*2) { + visIndex = _this.slides.length - _this.loopedSlides*2 - visIndex; + visIndex = Math.abs(visIndex) + } + visibleIndexes.push( visIndex ) + } + + for (i=0; i0) position = position+_this.wrapperLeft; + if (!isH && _this.wrapperTop>0) position = position+_this.wrapperTop; + + for (var i=0; i<_this.slides.length; i++) { + _slideLeft += _slideSize; + if (params.slidesPerView == 'auto') + _slideSize = isH ? _this.h.getWidth(_this.slides[i],true) : _this.h.getHeight(_this.slides[i],true); + else _slideSize = slideSize; + + _slideRight = _slideLeft + _slideSize; + var isVisibile = false; + if (params.visibilityFullFit) { + if (_slideLeft >= -position && _slideRight <= -position+containerSize) isVisibile = true; + if (_slideLeft <= -position && _slideRight >= -position+containerSize) isVisibile = true; + } + else { + + if (_slideRight > -position && _slideRight <= ((-position+containerSize))) isVisibile = true; + if (_slideLeft >= -position && _slideLeft < ((-position+containerSize))) isVisibile = true; + if (_slideLeft < -position && _slideRight > ((-position+containerSize))) isVisibile = true; + } + + if (isVisibile) visibleSlides.push(_this.slides[i]) + + } + if (visibleSlides.length==0) visibleSlides = [ _this.slides[ _this.activeIndex ] ] + + _this.visibleSlides = visibleSlides; + } + + /*========================================== + Autoplay + ============================================*/ + _this.autoPlayIntervalId = undefined; + _this.startAutoplay = function () { + if (typeof _this.autoPlayIntervalId !== 'undefined') return false; + if (!params.autoplay) return; + _this.autoPlayIntervalId = setInterval(function(){ + if (params.loop) _this.swipeNext(); + else if (!_this.swipeNext(true)) _this.swipeTo(0); + }, params.autoplay) + _this.callPlugins('onAutoplayStart'); + } + _this.stopAutoplay = function () { + if (_this.autoPlayIntervalId) clearInterval(_this.autoPlayIntervalId); + _this.autoPlayIntervalId = undefined; + _this.callPlugins('onAutoplayStop'); + } + /*================================================== + Loop + ====================================================*/ + _this.loopCreated = false; + _this.removeLoopedSlides = function(){ + if (_this.loopCreated) { + for (var i=0; i<_this.slides.length; i++) { + if (_this.slides[i].getData('looped')===true) _this.wrapper.removeChild(_this.slides[i]); + } + } + } + + _this.createLoop = function() { + if (_this.slides.length==0) return; + if (params.slidesPerView=='auto') { + _this.loopedSlides = params.loopedSlides; + } + else { + _this.loopedSlides = params.slidesPerView + params.loopAdditionalSlides; + } + + if (_this.loopedSlides > _this.slides.length) { + _this.loopedSlides = _this.slides.length; + } + + var slideFirstHTML = '', + slideLastHTML = '', + i; + var slidesSetFullHTML = ''; + /** + loopedSlides is too large if loopAdditionalSlides are set. + Need to divide the slides by maximum number of slides existing. + + @author Tomaz Lovrec + */ + var numSlides = _this.slides.length; + var fullSlideSets = Math.floor(_this.loopedSlides / numSlides); + var remainderSlides = _this.loopedSlides % numSlides; + // assemble full sets of slides + for (i = 0; i<(fullSlideSets*numSlides);i++) { + var j = i; + if (i >= numSlides) { + var over = Math.floor(i / numSlides); + j = i - (numSlides * over); + } + slidesSetFullHTML+=_this.slides[j].outerHTML; + } + // assemble remainder slides + // assemble remainder appended to existing slides + for(i = 0;i=_this.slides.length-_this.loopedSlides) _this.slides[i].setData('looped', true); + } + _this.callPlugins('onCreateLoop'); + + } + + _this.fixLoop = function() { + var newIndex; + //Fix For Negative Oversliding + if (_this.activeIndex < _this.loopedSlides) { + newIndex = _this.slides.length - _this.loopedSlides*3 + _this.activeIndex; + _this.swipeTo(newIndex, 0, false); + } + //Fix For Positive Oversliding + else if (_this.activeIndex > _this.slides.length - params.slidesPerView*2) { + newIndex = -_this.slides.length + _this.activeIndex + _this.loopedSlides + _this.swipeTo(newIndex, 0, false); + } + } + + /*================================================== + Slides Loader + ====================================================*/ + _this.loadSlides = function(){ + var slidesHTML = ''; + _this.activeLoaderIndex = 0; + var slides = params.loader.slides; + var slidesToLoad = params.loader.loadAllSlides ? slides.length : params.slidesPerView*(1+params.loader.surroundGroups); + for (var i=0; i< slidesToLoad; i++) { + if (params.loader.slidesHTMLType=='outer') slidesHTML+=slides[i]; + else { + slidesHTML+='<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + } + } + _this.wrapper.innerHTML = slidesHTML; + _this.calcSlides(true); + //Add permanent transitionEnd callback + if (!params.loader.loadAllSlides) { + _this.wrapperTransitionEnd(_this.reloadSlides, true); + } + } + + _this.reloadSlides = function(){ + var slides = params.loader.slides; + var newActiveIndex = parseInt(_this.activeSlide().data('swiperindex'),10) + if (newActiveIndex<0 || newActiveIndex>slides.length-1) return //<-- Exit + _this.activeLoaderIndex = newActiveIndex; + var firstIndex = Math.max(0, newActiveIndex - params.slidesPerView*params.loader.surroundGroups) + var lastIndex = Math.min(newActiveIndex+params.slidesPerView*(1+params.loader.surroundGroups)-1, slides.length-1) + //Update Transforms + if (newActiveIndex>0) { + var newTransform = -slideSize*(newActiveIndex-firstIndex) + _this.setWrapperTranslate(newTransform); + _this.setWrapperTransition(0); + } + //New Slides + if (params.loader.logic==='reload') { + _this.wrapper.innerHTML = ''; + var slidesHTML = ''; + for (var i = firstIndex; i<=lastIndex; i++) { + slidesHTML += params.loader.slidesHTMLType == 'outer' ? slides[i] : '<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + } + _this.wrapper.innerHTML = slidesHTML; + } + else { + var minExistIndex=1000; + var maxExistIndex=0; + for (var i=0; i<_this.slides.length; i++) { + var index = _this.slides[i].data('swiperindex'); + if (indexlastIndex) { + _this.wrapper.removeChild(_this.slides[i]); + } + else { + minExistIndex = Math.min(index, minExistIndex) + maxExistIndex = Math.max(index, maxExistIndex) + } + } + for (var i=firstIndex; i<=lastIndex; i++) { + if (imaxExistIndex) { + var newSlide = document.createElement(params.slideElement); + newSlide.className = params.slideClass; + newSlide.setAttribute('data-swiperindex',i); + newSlide.innerHTML = slides[i]; + _this.wrapper.appendChild(newSlide); + } + } + } + //reInit + _this.reInit(true); + } + + /*================================================== + Make Swiper + ====================================================*/ + function makeSwiper(){ + _this.calcSlides(); + if (params.loader.slides.length>0 && _this.slides.length==0) { + _this.loadSlides(); + } + if (params.loop) { + _this.createLoop(); + } + _this.init(); + initEvents(); + if (params.pagination) { + _this.createPagination(true); + } + + if (params.loop || params.initialSlide>0) { + _this.swipeTo( params.initialSlide, 0, false ); + } + else { + _this.updateActiveSlide(0); + } + if (params.autoplay) { + _this.startAutoplay(); + } + /** + * Set center slide index. + * + * @author Tomaz Lovrec + */ + _this.centerIndex = _this.activeIndex; + + // Callbacks + if (params.onSwiperCreated) params.onSwiperCreated(this); + _this.callPlugins('onSwiperCreated'); + } + + makeSwiper(); +} + +Swiper.prototype = { + plugins : {}, + + /*================================================== + Wrapper Operations + ====================================================*/ + wrapperTransitionEnd : function(callback, permanent) { + var a = this, + el = a.wrapper, + events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'], + i; + + function fireCallBack() { + callback(a); + if (a.params.queueEndCallbacks) a._queueEndCallbacks = false; + if (!permanent) { + for (i=0; i0) { + returnWidth = el.offsetWidth - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')); + } + if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')) + + return returnWidth; + }, + getHeight: function(el, outer) { + if (outer) return el.offsetHeight; + + var height = window.getComputedStyle(el, null).getPropertyValue('height') + var returnHeight = parseFloat(height); + //IE Fixes + if(isNaN(returnHeight) || height.indexOf('%')>0) { + returnHeight = el.offsetHeight - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')); + } + if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')) + return returnHeight; + }, + getOffset: function(el) { + var box = el.getBoundingClientRect(); + var body = document.body; + var clientTop = el.clientTop || body.clientTop || 0; + var clientLeft = el.clientLeft || body.clientLeft || 0; + var scrollTop = window.pageYOffset || el.scrollTop; + var scrollLeft = window.pageXOffset || el.scrollLeft; + if (document.documentElement && !window.pageYOffset) { + //IE7-8 + scrollTop = document.documentElement.scrollTop; + scrollLeft = document.documentElement.scrollLeft; + } + return { + top: box.top + scrollTop - clientTop, + left: box.left + scrollLeft - clientLeft + }; + }, + windowWidth : function() { + if (window.innerWidth) return window.innerWidth + else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; + }, + windowHeight : function() { + if (window.innerHeight) return window.innerHeight + else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; + }, + windowScroll : function() { + var left=0, top=0; + if (typeof pageYOffset != 'undefined') { + return { + left: window.pageXOffset, + top: window.pageYOffset + } + } + else if (document.documentElement) { + return { + left: document.documentElement.scrollLeft, + top: document.documentElement.scrollTop + } + } + }, + + addEventListener : function (el, event, listener, useCapture) { + if (typeof useCapture == 'undefined') { + useCapture = false; + } + + if (el.addEventListener) { + el.addEventListener(event, listener, useCapture); + } + else if (el.attachEvent) { + el.attachEvent('on' + event, listener); + } + }, + + removeEventListener : function (el, event, listener, useCapture) { + if (typeof useCapture == 'undefined') { + useCapture = false; + } + + if (el.removeEventListener) { + el.removeEventListener(event, listener, useCapture); + } + else if (el.detachEvent) { + el.detachEvent('on' + event, listener); + } + } + }, + setTransform : function (el, transform) { + var es = el.style + es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transform + }, + setTranslate : function (el, translate) { + var es = el.style + var pos = { + x : translate.x || 0, + y : translate.y || 0, + z : translate.z || 0 + }; + var transformString = this.support.transforms3d ? 'translate3d('+(pos.x)+'px,'+(pos.y)+'px,'+(pos.z)+'px)' : 'translate('+(pos.x)+'px,'+(pos.y)+'px)'; + es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transformString; + if (!this.support.transforms) { + es.left = pos.x+'px' + es.top = pos.y+'px' + } + }, + setTransition : function (el, duration) { + var es = el.style + es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = duration+'ms'; + }, + /*================================================== + Feature Detection + ====================================================*/ + support: { + + touch : (window.Modernizr && Modernizr.touch===true) || (function() { + return !!(("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch); + })(), + + transforms3d : (window.Modernizr && Modernizr.csstransforms3d===true) || (function() { + var div = document.createElement('div').style; + return ("webkitPerspective" in div || "MozPerspective" in div || "OPerspective" in div || "MsPerspective" in div || "perspective" in div); + })(), + + transforms : (window.Modernizr && Modernizr.csstransforms===true) || (function(){ + var div = document.createElement('div').style; + return ('transform' in div || 'WebkitTransform' in div || 'MozTransform' in div || 'msTransform' in div || 'MsTransform' in div || 'OTransform' in div); + })(), + + transitions : (window.Modernizr && Modernizr.csstransitions===true) || (function(){ + var div = document.createElement('div').style; + return ('transition' in div || 'WebkitTransition' in div || 'MozTransition' in div || 'msTransition' in div || 'MsTransition' in div || 'OTransition' in div); + })() + }, + + browser : { + + ie8 : (function(){ + var rv = -1; // Return value assumes failure. + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent; + var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv != -1 && rv < 9; + })(), + + ie10 : window.navigator.msPointerEnabled + } +} + +/*========================= + jQuery & Zepto Plugins + ===========================*/ +if (window.jQuery||window.Zepto) { + (function($){ + $.fn.swiper = function(params) { + var s = new Swiper($(this)[0], params) + $(this).data('swiper',s); + return s; + } + })(window.jQuery||window.Zepto) +} + +// component +if ( typeof( module ) !== 'undefined' ) +{ + module.exports = Swiper; +} diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/js/photogallery.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/js/photogallery.js new file mode 100644 index 0000000..d15db79 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/PubCoderImageGallery/js/photogallery.js @@ -0,0 +1,486 @@ +function SCPhotoGallery(objPhotoGallery, maxResolutionWidth, maxResolutionHeight, goFullScreen, withThumbnails, withCaption, withArrows) { + var hasTitle; + var titleCss = $(objPhotoGallery + ' .SCPhotoGalleryTitleDefault').css("display"); + if (titleCss == "none") + hasTitle = false; + else + hasTitle = true; + var isFullScreen = false; + var thumbnailsVisible = withThumbnails; + var SCphotoGalleryFullScreen; + var generalFadeIn = 100; + var zIndexContentOriginal = $('.SCPage .SCContent').css('z-index'); + var zIndexContentDestination = parseInt($('.SCPage .SCOverlay').css('z-index'),10) + 1; + positionImages(); + var mySwiper = new Swiper(objPhotoGallery + ' .swiper-container',{ + onImagesReady: function() { + checkArrows(mySwiper.activeIndex,mySwiper.slides.length); + if (!withArrows) + $(objPhotoGallery + ' .arrow-left,' + objPhotoGallery + ' .arrow-right').css("display","none"); + if (!withCaption) + $(objPhotoGallery+" figcaption").css("display","none"); + positionFigurePagination(); + $(objPhotoGallery+"_container").fadeIn(generalFadeIn,positionIcons()); + if (goFullScreen) { + $(objPhotoGallery + " .icon-fullscreen").fadeIn(generalFadeIn + 100); + } + if (withThumbnails) { + $(objPhotoGallery + " .icon-index").fadeIn(generalFadeIn + 100); + checkPagination(); + positionThumbnails(); + } + + }, + onSlideClick: function(event) { + if (goFullScreen) + toggleFullScreen(); + }, + onSlideChangeEnd: function() { + var activeIndex = mySwiper.activeIndex; + changeActiveThumb(activeIndex); + if (withArrows) + checkArrows(activeIndex,mySwiper.slides.length); + checkActiveThumb(activeIndex); + + } + }) + this.myObjPhotoGallery = objPhotoGallery; + + + + $(objPhotoGallery + ' .arrow-left').on(window.touchUpEvent, function(e){ + e.stopPropagation(); + e.preventDefault(); + mySwiper.swipePrev(); + }) + $(objPhotoGallery + ' .arrow-right').on(window.touchUpEvent, function(e){ + e.stopPropagation(); + e.preventDefault(); + mySwiper.swipeNext(); + }) + + $(objPhotoGallery + ' .pagination-arrow-left').on(window.touchUpEvent, function(e){ + e.stopPropagation(); + e.preventDefault(); + var widthPagination = $(objPhotoGallery + ' .pagination').css('width'); + movePagination("left",widthPagination); + }) + $(objPhotoGallery + ' .pagination-arrow-right').on(window.touchUpEvent, function(e){ + e.stopPropagation(); + e.preventDefault(); + var widthPagination = $(objPhotoGallery + ' .pagination').css('width'); + movePagination("right",widthPagination); + }) + + $(objPhotoGallery + ' .pagination li').on(window.touchUpEvent, function(e){ + e.stopPropagation(); + e.preventDefault(); + var index = $(this).parent().children().index(this); + changeActiveThumb(index); + mySwiper.swipeTo(index); + }) + + $(objPhotoGallery + ' .icon-fullscreen').on(window.touchUpEvent, function(e){ + e.stopPropagation(); + e.preventDefault(); + toggleFullScreen(); + }) + + $(objPhotoGallery + ' .icon-index').on(window.touchUpEvent, function(e){ + e.stopPropagation(); + e.preventDefault(); + togglePagination(thumbnailsVisible); + }) + + function movePagination(direction,pixels) { + var signDirection; + var widthPagination = $(objPhotoGallery + ' .pagination').css('width'); + if (direction == "left") + signDirection = "+"; + else + signDirection = "-"; + $(objPhotoGallery + ' .pagination').animate({left:'' + signDirection + '=' + pixels},300,'easieEaseInOut',function() { + var leftCss = getLeftDomValue(objPhotoGallery + ' .pagination'); + $(objPhotoGallery + ' .pagination').css('left',leftCss); + checkPagination(); + }); + } + + function checkArrows(index,totalSlides) { + if (index == 0) + $(objPhotoGallery + ' .arrow-left').css("display","none"); + else + $(objPhotoGallery + ' .arrow-left').css("display","block"); + if (index == totalSlides - 1) + $(objPhotoGallery + ' .arrow-right').css("display","none"); + else + $(objPhotoGallery + ' .arrow-right').css("display","block"); + } + + function checkActiveThumb(index,animation) { + if (animation == "undefined") + animation = 0; + setTimeout(function(){ + if ($(objPhotoGallery + ' .pagination').length > 0) { + var widthPagination = $(objPhotoGallery + ' .pagination').css('width'); + var positionLeftImg = $(objPhotoGallery + ' .pagination li img:eq(' + index + ')').position().left; + var overflowContainer = parseInt($(objPhotoGallery + ' .overflowContainer').css("width")); + var paginationLeft = getLeftDomValue(objPhotoGallery + ' .pagination'); + var sumPositionPagination = paginationLeft + positionLeftImg; + if (sumPositionPagination > overflowContainer) { + var offset = parseInt(sumPositionPagination/overflowContainer); + var pixels = parseInt(widthPagination) * offset; + movePagination("right",pixels); + } else if (sumPositionPagination < 0) + movePagination("left",widthPagination); + } + + },animation + 1) + } + + function positionImages(cssClass) { + var SwiperWidth = $(objPhotoGallery).outerWidth(); + var SwiperHeight = $(objPhotoGallery).outerHeight(); + $(objPhotoGallery + ' .swiper-slide img').each(function(i, obj){ + if (ratioSmallisHigher(this.naturalWidth, this.naturalHeight, SwiperWidth, SwiperHeight)) { + $(this).css("width",SwiperWidth + "px"); + } else { + $(this).css("height",SwiperHeight + "px"); + + } + }); + } + + function positionFigurePagination() { + //var paginationHeight = $(objPhotoGallery + ' .paginationContainer')[0].getBoundingClientRect().height; + var paginationHeight = 0; + var SCPhotoGalleryWidth = $(objPhotoGallery + '')[0].getBoundingClientRect().width; + var figcaptionPadding = parseInt($(objPhotoGallery + ' figcaption').css("padding"))*2-2; + + var paginationWidth = SCPhotoGalleryWidth - figcaptionPadding; + var overflowContainerWidth = SCPhotoGalleryWidth - 110; + $(objPhotoGallery + ' figure figcaption').css({"bottom":paginationHeight,"width":paginationWidth}); + $(objPhotoGallery + ' .overflowContainer').css("width",overflowContainerWidth); + } + + function positionIcons() { + var titleParagraphHeight; + try { + titleParagraphHeight = $(objPhotoGallery + ' p.SCPhotoGalleryTitleDefault.SCPhotoGalleryTitle')[0].getBoundingClientRect().height; + } + catch(err) { + titleParagraphHeight = 0; + } + setTimeout(function(){ + var titlePadding = $(objPhotoGallery + ' p.SCPhotoGalleryTitleDefault.SCPhotoGalleryTitle').css("padding"); + var titleHeight = parseInt(titlePadding)*2 + parseInt(titleParagraphHeight); + if (titleHeight != 0) { + var iconsHeight = $(objPhotoGallery + ' .icons')[0].getBoundingClientRect().height; + var topIcons = (titleHeight - iconsHeight)/2; + $(objPhotoGallery + ' .icons').css("top",topIcons + "px"); + } + },1); + } + + function toggleFullScreen() { + if (!isFullScreen) { + this.isFullScreenState = false; + var originalSwiperContainerHeight = $(objPhotoGallery + ' .swiper-container').outerHeight(); + var originalSwiperContainerWidth = $(objPhotoGallery + ' .swiper-container').outerWidth(); + var originalSCPhotoGalleryTop = parseInt($(objPhotoGallery).css("top")); + var originalSwiperContainerTop = 0; + var originalSwiperContainerLeft = $(objPhotoGallery + ' .swiper-container').offsetParent().css("left"); + var originalSCPhotoGalleryHeight = $(objPhotoGallery).outerHeight(); + originalZindex = $(this.myObjPhotoGallery).css('z-index'); + SCphotoGalleryFullScreen = new photoGallery(objPhotoGallery, + false, + withThumbnails, + maxResolutionWidth, + maxResolutionHeight, + originalSwiperContainerWidth, + originalSwiperContainerHeight, + originalSCPhotoGalleryHeight, + originalSCPhotoGalleryTop, + originalSwiperContainerTop, + originalSwiperContainerLeft, + originalZindex + ); + SCphotoGalleryFullScreen.launchAnimations(); + isFullScreen = true; + } else { + this.isFullScreenState = true; + SCphotoGalleryFullScreen.modeFullScreen = true; + SCphotoGalleryFullScreen.launchAnimations(); + } + } + + function togglePagination(isVisible) { + if (isVisible) { + $(objPhotoGallery + ' .paginationContainer').css("display","block"); + $(objPhotoGallery + ' .paginationContainer,' + objPhotoGallery + ' figcaption').animate({bottom: "+=95px"},100,'easieEaseOut'); + $(objPhotoGallery + " .icon-index").removeClass("index-open").addClass("index-close"); + thumbnailsVisible = false; + } else { + $(objPhotoGallery + ' .paginationContainer, ' + objPhotoGallery + ' figcaption').animate({bottom: "-=95px"},200,'easieEaseIn',function(){ $(objPhotoGallery + ' .paginationContainer').css("display","none") }); + $(objPhotoGallery + ' figcaption').animate({bottom: 0},200,'easieEaseIn'); + $(objPhotoGallery + " .icon-index").removeClass("index-close").addClass("index-open"); + thumbnailsVisible = true; + } + } + + + function checkPagination() { + if ($(objPhotoGallery + ' .pagination').length > 0) { + var photogalleryWidth = $(objPhotoGallery + ' .pagination').width(), paginationWidth = $(objPhotoGallery + ' .pagination')[0].scrollWidth; + if (paginationWidth > photogalleryWidth) { + var paginationLeft = getLeftDomValue(objPhotoGallery + ' .pagination'); + if (paginationLeft < 0) + showHidePaginationArrow('pagination-arrow-left','show'); + else + showHidePaginationArrow('pagination-arrow-left','hide'); + if (paginationWidth + paginationLeft > photogalleryWidth) + showHidePaginationArrow('pagination-arrow-right','show'); + else + showHidePaginationArrow('pagination-arrow-right','hide'); + } else { + showHidePaginationArrow('pagination-arrow-right','hide'); + showHidePaginationArrow('pagination-arrow-left','hide'); + } + } + + } + + + function positionThumbnails() { + $(objPhotoGallery + ' .pagination li img').each(function(i, obj){ + if (isWidthLongestSize($(this).width(), $(this).height())) + $(this).css("max-height","100%"); + else + $(this).css("max-width","100%"); + }); + } + + function getLeftDomValue(obj) { + var value, leftDomValue = $(obj).css('left'); + if (leftDomValue == 'auto') + value = 0; + else + value = leftDomValue; + return parseFloat(value); + + } + + function showHidePaginationArrow(directionDiv,action) { + var cssValue; + if (action == 'show') + cssValue = 'block'; + else + cssValue = 'none'; + $(objPhotoGallery + ' .' + directionDiv).css('display',cssValue); + } + + + + function changeActiveThumb(index){ + $(objPhotoGallery + ' .pagination li').each(function(i, obj){ + $(this).removeClass('active'); + }); + $(objPhotoGallery + ' .pagination li').eq(index).addClass('active'); + } + var photoGallery = function(ObjPhotoGallery,isFullScreen,withThumbnails,fullScreenWidth,fullScreenHeight,originalWidth,originalHeight,originalContainerHeight,originalTopSCphotoGallery,originalTopSwiperContainer,originalLeft,originalZindex) { + this.myObjPhotoGallery = ObjPhotoGallery, + this.modeFullScreen = isFullScreen, + this.withThumbnails = withThumbnails; + var swiperSlideVisible = document.getElementsByClassName('swiper-slide-visible')[0]; + this.imageVisibleHeight = swiperSlideVisible.getElementsByTagName('img')[0].naturalHeight, + this.imageVisibleWidth = swiperSlideVisible.getElementsByTagName('img')[0].naturalWidth, + this.activeIndex, + this.scaleVal, + this.destinationHeight, + this.destinationWidth, + this.originalWidth, + this.originalLeft, + this.originalTopSCphotoGallery, + this.originalTopSwiperContainer, + this.destinationTop, + this.destinationLeft, + this.originalContainerHeight, + this.originalZindex, + this.speedAnimation = 300; + if (originalWidth != '') + this.originalWidth = originalWidth; + if (originalHeight != '') + this.originalHeight = originalHeight; + if (originalTopSCphotoGallery != '') + this.originalTopSCphotoGallery = originalTopSCphotoGallery; + if (originalTopSwiperContainer != '') + this.originalTopSwiperContainer = originalTopSwiperContainer; + if (originalLeft != '') + this.originalLeft = originalLeft; + if (originalContainerHeight != '') + this.originalContainerHeight = originalContainerHeight; + if (originalZindex != '') + this.originalZindex = originalZindex; + var paginationBottom = parseInt($(myObjPhotoGallery + ' .paginationContainer').css("bottom")); + this.launchAnimations = function() { + + if (!this.modeFullScreen) { + $(this.myObjPhotoGallery).css('z-index','999'); + $('.SCPage .SCContent').css('z-index',zIndexContentDestination); + this.destinationHeight = fullScreenHeight, + this.destinationWidth = fullScreenWidth, + this.originalWidth = originalWidth, + this.destinationTop = 0, + this.destinationLeft = 0; + var classesToAnimateTogether = this.myObjPhotoGallery + ', ' + this.myObjPhotoGallery + ' .swiper-container, ' + this.myObjPhotoGallery + ' .swiper-slide-visible'; + } else { + $('.SCPage .SCContent').css('z-index',zIndexContentOriginal); + $(this.myObjPhotoGallery).css('z-index',this.originalZindex); + this.destinationHeight = this.originalHeight, + this.destinationWidth = this.originalWidth, + this.destinationTop = this.originalTopSwiperContainer, + this.destinationLeft = 0; + var classesToAnimateTogether = this.myObjPhotoGallery + ' .swiper-container,' + this.myObjPhotoGallery + ' .swiper-slide-visible'; + } + if (withCaption) + $('' + this.myObjPhotoGallery + ' figcaption').hide(); + $('' + this.myObjPhotoGallery + ' p.SCPhotoGalleryTitleDefault').hide(); + if (withThumbnails) + $('' + this.myObjPhotoGallery + ' .paginationContainer').hide(); + + if (this.modeFullScreen) { + $(this.myObjPhotoGallery).animate({top: this.originalTopSCphotoGallery, left: this.originalLeft, width: this.destinationWidth, height: this.originalContainerHeight},this.speedAnimation,'easieEaseIn'); + } + $(classesToAnimateTogether).animate({top: this.destinationTop, left: this.destinationLeft, width: this.destinationWidth, height: this.destinationHeight},this.speedAnimation,'easieEaseIn'); + if (this.modeFullScreen) + scaleVal = 1; + else { + var smallSlideWidth = $('' + this.myObjPhotoGallery + ' .swiper-slide')[0].getBoundingClientRect().width; + var visibileImageRect = $('' + this.myObjPhotoGallery + ' .swiper-slide-visible img')[0].getBoundingClientRect(); + var visibleImageWidth = visibileImageRect.width; + var visibleImageHeight = visibileImageRect.height; + //if (isWidthLongestSize(this.imageVisibleWidth, this.imageVisibleHeight)) + + if (ratioSmallisHigher(visibleImageWidth,visibleImageHeight,this.destinationWidth,this.destinationHeight)) { + scaleVal = this.destinationWidth/visibleImageWidth; + } else + scaleVal = this.destinationHeight/visibleImageHeight; + } + + showHideAllOtherImages("hide"); + $('' + this.myObjPhotoGallery + ' .swiper-slide-visible img').animate({scalex: '' + scaleVal + '', scaley: '' + scaleVal + ''},this.speedAnimation,'easieEaseInOut',completeAnimationOnImages(this.modeFullScreen, + this.destinationWidth, + this.destinationHeight, + this.originalWidth, + this.originalHeight, + mySwiper.activeIndex, + this.speedAnimation, + this.withThumbnails, + paginationBottom) + )} +} + + +function showHideAllOtherImages(what) { + var displayType; + if (what == "hide") + displayType = "none"; + else + displayType = "block"; + $(objPhotoGallery + ' .swiper-slide img').each(function(i, obj) { + if ( !$( this ).parent().parent().hasClass( "swiper-slide-visible" ) ) { + $(this).css("display",displayType); + } + }); +} + +function completeAnimationOnImages(modeFullScreen,destinationWidth,destinationHeight,originalWidth,originalHeight,activeIndex,speedAnimation,withThumbnails,paginationBottom) { +//all swiper slide at width and height + $(objPhotoGallery + ' .swiper-slide').css({width: destinationWidth, height: destinationHeight}); + var swiperWrapper = 0, scaleVal; + $(objPhotoGallery + ' .swiper-slide img').each(function(i, obj) { + swiperWrapper = swiperWrapper + destinationWidth; + if ( !$( this ).parent().parent().hasClass( "swiper-slide-visible" ) ) { + if (modeFullScreen) + scaleVal = 1; + else { + var thisWidth = $(this).outerWidth(); + var thisHeight = $(this).outerHeight(); + if (ratioSmallisHigher(thisWidth,thisHeight,destinationWidth,destinationHeight)) { + scaleVal = destinationWidth/thisWidth; + } else + scaleVal = destinationHeight/thisHeight; + } + $(this).animate({scalex: '' + scaleVal + '', scaley: '' + scaleVal + ''},1); + } +}); + showHideAllOtherImages("show"); + + //set new translateX var + var newTranslateX = activeIndex*destinationWidth; + var figCaptionPadding, figCaptionWidth, figCaptionBottom; + var marginLeftOverFlowContainer = parseInt($(objPhotoGallery + ' .overflowContainer').css("margin-left"))*2 + var destinationWidthOverflowContainer = destinationWidth - marginLeftOverFlowContainer; + figCaptionPadding = parseInt($(objPhotoGallery + ' figcaption').css("padding"))*2; + figCaptionWidth = destinationWidth - figCaptionPadding; + if (withThumbnails) + figCaptionBottom = $(objPhotoGallery + ' .paginationContainer').css('height'); + else + figCaptionBottom = 0; + $('' + objPhotoGallery + ' .swiper-wrapper').css({'width':swiperWrapper,'height':destinationHeight,'-webkit-transform':'translate3d(-' + newTranslateX + 'px, 0px, 0px)'}); + if (!modeFullScreen) { + if (hasTitle) + $(objPhotoGallery + ' p.SCPhotoGalleryTitleDefault').delay(speedAnimation).addClass('fullscreen'); + if (withThumbnails) { + $(objPhotoGallery + ' .paginationContainer').delay(speedAnimation).css('bottom',paginationBottom + 'px'); + } + if (hasTitle) + $(objPhotoGallery + ' p.SCPhotoGalleryTitleDefault').fadeIn(speedAnimation); + $(objPhotoGallery + " .icon-fullscreen").removeClass("fullscreen-open").addClass("fullscreen-close"); + } else { + isFullScreen = false; + if (hasTitle) + $(objPhotoGallery + ' p.SCPhotoGalleryTitleDefault').removeClass('fullscreen'); + + + $(objPhotoGallery + " .icon-fullscreen").removeClass("fullscreen-close").addClass("fullscreen-open"); + + + } + if (withThumbnails) { + var paginationHeight = parseInt($('' + objPhotoGallery + ' .paginationContainer').css("top")); + $(objPhotoGallery + ' figcaption').delay(speedAnimation).css({'position':'absolute','bottom':''+ paginationHeight + 'px','width':figCaptionWidth + 'px'}); + } + if (hasTitle) + $(objPhotoGallery + ' p.SCPhotoGalleryTitleDefault').fadeIn(speedAnimation); + if (withCaption) + $(objPhotoGallery + ' figcaption').fadeIn(speedAnimation); + if (withThumbnails) { + $(objPhotoGallery + ' .paginationContainer .overflowContainer').css('width',destinationWidthOverflowContainer); + var paginationLeft = getLeftDomValue(objPhotoGallery + ' .pagination'); + movePagination("right",paginationLeft); + $(objPhotoGallery + ' .paginationContainer').css('width',destinationWidth).fadeIn(speedAnimation,checkActiveThumb(mySwiper.activeIndex,speedAnimation)); + } + setTimeout(function(){ + mySwiper.reInit(); + checkPagination(); + },speedAnimation); + + } +} + +function isWidthLongestSize(width, height) { + var longestSize; + if (width/height > 1) + return true; + else + return false; +} + +function ratioSmallisHigher(widthImage, heightImage, widthDestination, heightDestination) { + if (widthImage/heightImage > widthDestination/heightDestination) { + return true; + } else { + return false; + } +} diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/general.functions.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/general.functions.js new file mode 100644 index 0000000..e7e4088 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/general.functions.js @@ -0,0 +1,493 @@ +window.tocIsVisible=false; +/* + * + * Init Touch Events + * + */ +if ((/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()))) { + window.touchDownEvent = "touchstart"; + window.touchUpEvent = "touchend"; + window.touchMoveEvent = "touchmove"; + if ((/android/i.test(navigator.userAgent.toLowerCase()))) { + window.pinchopen = "pinchout"; + window.pinchclose = "pinchin"; + } else { + window.pinchopen = "pinchopen"; + window.pinchclose = "pinchclose"; + } +} else { + window.touchDownEvent = "mousedown"; + window.touchUpEvent = "mouseup"; + window.touchMoveEvent = "mousemove"; + window.pinchopen = "dblclick"; + window.pinchclose = "dblclick"; +} + +$(document).ready(function(){ + $('img').on('dragstart', function(event) { event.preventDefault(); }); +}); + +/* + * + * Init Accelerometer + * + */ +window.onorientationchange = function() { + var newOrientation; + if (isAndroid) + newOrientation = Android.getRotation(); + else + newOrientation = window.orientation; + /*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the + left, or landscape mode with the screen turned to the right. */ + window.orientationDevice = switchOrientationName(newOrientation,isAndroid); +} +window.ondevicemotion = function(e) { + switch (window.orientationDevice) { + case 'landscapeButtonLeft': + window.aigX = e.accelerationIncludingGravity.x; + window.aigY = e.accelerationIncludingGravity.y; + break; + case 'portraitButtonBottom': + window.aigX = -e.accelerationIncludingGravity.y; + window.aigY = e.accelerationIncludingGravity.x; + break; + case 'landscapeButtonRight': + window.aigX = -e.accelerationIncludingGravity.x; + window.aigY = -e.accelerationIncludingGravity.y; + break; + case 'portraitButtonTop': + window.aigX = e.accelerationIncludingGravity.y; + window.aigY = -e.accelerationIncludingGravity.x; + break; + + } +} + +/* + * + * Define PubCoder namespace + * + */ +var PubCoder = { + Events: { + Shake: 'SCEventShake', + Show: 'SCEventShow', + SwipeDown: 'SCswipedown', + SwipeLeft: 'SCswipeleft', + SwipeRight: 'SCswiperight', + SwipeUp: 'SCswipeup', + PinchClose: window.pinchclose, + PinchOpen: window.pinchopen, + TouchDown: window.touchDownEvent, + TouchUp: window.touchUpEvent + }, + + callID: 0, + + call: function (methodName, methodParameters) { + PubCoder.callID++; + window.status = JSON.stringify ({"method" : methodName, "params" : methodParameters, "id" : PubCoder.callID} ); + window.status = ' '; + } +}; + +/* + * + * Utility Functions + * + */ + +function getBrowser() { + + var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; + var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ + var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; + // At least Safari 3+: "[object HTMLElementConstructor]" + var isChrome = !!window.chrome && !isOpera; // Chrome 1+ + var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 + var browser = ""; + if (isOpera) + browser = "opera"; + else if (isFirefox) + browser = "firefox"; + else if (isSafari) + browser = "safari"; + else if (isChrome) + browser = "chrome"; + else if (isIE) + browser = "explorer"; + + return browser; +} + +function setPrefixCss3() { + var prefix = ""; + if (getBrowser() == "firefox") + prefix ="-moz-"; + else + prefix ="-webkit-"; + return prefix; +} + + +function isLocationInElement (element, x, y) + { + var elmOffset = $(element).offset(); + if (x >= elmOffset.left && x <= (elmOffset.left + $(element).width()) && + y >= elmOffset.top && y <= (elmOffset.top + $(element).height())) + return true; + return false; + } + +function setNewPos(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element).offset(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } else if (actualPos + deltaMax >= max) { + if (dim == "x") + elementDim = $(element).width(); + else + elementDim = $(element).height(); + newX = max - relativePos - elementDim; + } else { + newX = newPos; + } + } else + newX = newPos; + return newX; +} + +function isLocationInElementDragDropOffset(element, x, y) + { + var elmOffset = $(element)[0].getBoundingClientRect(); + if (x >= elmOffset.left && x <= (elmOffset.left + elmOffset.width) && + y >= elmOffset.top && y <= (elmOffset.top + elmOffset.height)) + return true; + return false; + } + + function setNewPosDragDropOffset(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element)[0].getBoundingClientRect(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } + else if (actualPos + deltaMax >= max) { + if (dim == "x") { + elementDim = elmOffset.width; + } + else { + elementDim = elmOffset.height; + } + newX = max - relativePos - elementDim; + } + else { + newX = newPos; + } + } + else newX = newPos; + + return newX; +} + +//functions for gravity acceleration actions +function boundingBoxCheckX(posX, objectX, containerObject, ax, isBouncing){ + var minX = 0, maxX = 0, x = posX; + var containerNodeOffset = containerObject.offset(); + var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + + if (xmaxX-objectX) { + x = maxX-objectX; + + } + + return x; +} + +function isBoundingBoxCheckX(posX, objectX, containerObject){ +var minX = 0, maxX = 0, x = posX; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + +if (xmaxX-objectX) + return 2; + else + return 0; +} +function boundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + y = maxY-objectY; + +return y; +} + +function isBoundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + return 2; +else + return 0 +} + +//function used by rotate.scx +function rotate(objectId,timesRun,howManyTimes,rotationToDegrees,rotationSpeed,effectEasing,transformOriginX,transformOriginY,functionCompleted) { + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + + var rotationToDegreesString; + if (rotationToDegrees.indexOf("-") == -1) + rotationToDegreesString = "+=" + rotationToDegrees; + else + rotationToDegreesString = "-=" + rotationToDegrees.substr(1); + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + + $('#' + objectId).animate({rotate: '' + getScale(objectId) + 'deg'}, {queue: false, duration: 0}); + $('#' + objectId).animate({rotate: '' + rotationToDegreesString + 'deg'}, {queue: false, duration: rotationSpeed, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); +} + +function getScale(obj) { + var angle; + var el = document.getElementById(obj); + var st = window.getComputedStyle(el, null); + var tr = st.getPropertyValue("-webkit-transform") || + st.getPropertyValue("-moz-transform") || + st.getPropertyValue("-ms-transform") || + st.getPropertyValue("-o-transform") || + st.getPropertyValue("transform") || + "fail..."; + +if (st != null && tr != "none") { + + + var values = tr.split('(')[1]; + values = values.split(')')[0]; + values = values.split(','); + var a = values[0]; + var b = values[1]; + var c = values[2]; + var d = values[3]; + + var scale = Math.sqrt(a*a + b*b); + + var sin = b/scale; + angle = Math.round(Math.atan2(b, a) * (180/Math.PI)); +} else { + angle = 0; +} + return angle; +} + + + +//end functions used by rotate.scx +//functions used by scale.scx +function scale(objectId,timesRun,howManyTimes,scaleX,scaleY,effectDurationMS,effectEasing,transformOriginX,transformOriginY,ScaleModeString,functionCompleted) { + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + $('#' + objectId).animate({scalex: '' + ScaleModeString + scaleX + '', scaley: '' + ScaleModeString + scaleY + ''}, {queue: false, duration: effectDurationMS, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); + +} + +//end functions used by scale + +//functions for float +function getOrientation(isAndroid) { + var orientationName, orientationType; + if (isAndroid) + orientationType = Android.getRotation(); + else + orientationType = window.orientation; + orientationName = switchOrientationName(orientationType, isAndroid); + return orientationName; +} + +function switchOrientationName(orientation, isAndroid) { + var orientationDetected; + var orientationName; + orientationDetected = orientation; + if (orientation == 0 && isAndroid) + orientationDetected = 180; + else if (orientation == 90 && isAndroid) + orientationDetected = -90; + else if (orientation == 180 && isAndroid) + orientationDetected = 0; + else if (orientation == 270 && isAndroid) + orientationDetected = 90; + + var orientationName; + switch(orientationDetected) { + case 0: + orientationName = 'portraitButtonBottom'; + break; + case 90: + orientationName = 'landscapeButtonRight'; + break; + case -90: + orientationName = 'landscapeButtonLeft'; + break; + case 180: + orientationName = 'portraitButtonTop'; + break; + } + return orientationName; +} + +function toggleToc() { + var menuTocHeight = $("#SCNavigationToc").height(); + if (window.tocIsVisible) { + $("#SCNavigationToc").animate({bottom: -menuTocHeight},200,'easieEaseIn',function() { + $("#SCNavigationToc").css("display","none"); + }); + + window.tocIsVisible=false; + } + else + { + $("#SCNavigationToc").css("display","block"); + $("#SCNavigationToc").animate({bottom: 0},200,'easieEaseIn'); + window.tocIsVisible=true; + } +} +//end functions for float + +function showAssetsParity(option){ + if (option == 'even' || option == 'odd') { + $('*[data-pubcoder="' + option + '"]').css('display','block'); + } else { + $('*[data-pubcoder="odd"]').css('display','block'); + $('*[data-pubcoder="even"]').css('display','block'); + } +} + +//initAnimations +function initAnimation(obj,width,height,fps,countVar,isInfinite,howManyLoops,backToFirstFrame) +{ +var frameTime = 1000/fps; +var nextAnimationAfterLastLoop = howManyLoops + 1 +var lastLoop = howManyLoops; +$(obj).spritespin({ + + width : width, // width in pixels of the window/frame + height : height, // height in pixels of the window/frame + animate : false, + renderer: 'image', + loop: true, + frameTime: frameTime, + onFrame: function(e,data) { + var stopAtFrame = data.images.length - 1; + if (!isInfinite) { + var api = $(obj).spritespin('api'); + if (data.frame == 0) { + countVar++; + if (backToFirstFrame && countVar == nextAnimationAfterLastLoop) { + stopAnimation(api,obj); + countVar = 1; + } + } + if (data.frame == stopAtFrame && countVar == lastLoop) { + if (!backToFirstFrame) { + stopAnimation(api,obj); + countVar = 0; + } + } + } + } + }); +function stopAnimation(apiAnimation,object) + { + apiAnimation.stopAnimation(); + $(object).removeClass("playing"); + var objectStripped = object.substr(1); + $(object).trigger(objectStripped + "_animation_ended"); + } +} \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery-css-transform.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery-css-transform.js new file mode 100644 index 0000000..70a40f2 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery-css-transform.js @@ -0,0 +1,112 @@ +(function ($) { + // Monkey patch jQuery 1.3.1+ css() method to support CSS 'transform' + // property uniformly across Safari/Chrome/Webkit, Firefox 3.5+, IE 9+, and Opera 11+. + // 2009-2011 Zachary Johnson www.zachstronaut.com + // Updated 2011.05.04 (May the fourth be with you!) + function getTransformProperty(element) + { + // Try transform first for forward compatibility + // In some versions of IE9, it is critical for msTransform to be in + // this list before MozTranform. + var properties = ['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform']; + var p; + while (p = properties.shift()) + { + if (typeof element.style[p] != 'undefined') + { + return p; + } + } + + // Default to transform also + return 'transform'; + } + + var _propsObj = null; + + var proxied = $.fn.css; + $.fn.css = function (arg, val) + { + // Temporary solution for current 1.6.x incompatibility, while + // preserving 1.3.x compatibility, until I can rewrite using CSS Hooks + if (_propsObj === null) + { + if (typeof $.cssProps != 'undefined') + { + _propsObj = $.cssProps; + } + else if (typeof $.props != 'undefined') + { + _propsObj = $.props; + } + else + { + _propsObj = {} + } + } + + // Find the correct browser specific property and setup the mapping using + // $.props which is used internally by jQuery.attr() when setting CSS + // properties via either the css(name, value) or css(properties) method. + // The problem with doing this once outside of css() method is that you + // need a DOM node to find the right CSS property, and there is some risk + // that somebody would call the css() method before body has loaded or any + // DOM-is-ready events have fired. + if + ( + typeof _propsObj['transform'] == 'undefined' + && + ( + arg == 'transform' + || + ( + typeof arg == 'object' + && typeof arg['transform'] != 'undefined' + ) + ) + ) + { + _propsObj['transform'] = getTransformProperty(this.get(0)); + } + + // We force the property mapping here because jQuery.attr() does + // property mapping with jQuery.props when setting a CSS property, + // but curCSS() does *not* do property mapping when *getting* a + // CSS property. (It probably should since it manually does it + // for 'float' now anyway... but that'd require more testing.) + // + // But, only do the forced mapping if the correct CSS property + // is not 'transform' and is something else. + if (_propsObj['transform'] != 'transform') + { + // Call in form of css('transform' ...) + if (arg == 'transform') + { + arg = _propsObj['transform']; + + // User wants to GET the transform CSS, and in jQuery 1.4.3 + // calls to css() for transforms return a matrix rather than + // the actual string specified by the user... avoid that + // behavior and return the string by calling jQuery.style() + // directly + if (typeof val == 'undefined' && jQuery.style) + { + return jQuery.style(this.get(0), arg); + } + } + + // Call in form of css({'transform': ...}) + else if + ( + typeof arg == 'object' + && typeof arg['transform'] != 'undefined' + ) + { + arg[_propsObj['transform']] = arg['transform']; + delete arg['transform']; + } + } + + return proxied.apply(this, arguments); + }; +})(jQuery); \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery.easie-min.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery.easie-min.js new file mode 100755 index 0000000..797a892 --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery.easie-min.js @@ -0,0 +1 @@ +(function(a){"use strict";var b="easie",c="Ease",d=b+c+"In",e=b+c+"Out",f=b+c+"InOut",g=["Quad","Cubic","Quart","Quint","Sine","Expo","Circ"];a.easie=function(c,d,e,f,g,h){g=g||[b,c,d,e,f].join("-");if(!a.easing[g]||h){var k=i(function(a){return j(a,c,d,e,f,5)});a.easing[g]=function(a,b,c,d){return k.call(null,a)},a.easing[g].params=[c,d,e,f]}return g};var h=a.easie;h(0,0,1,1,b+"Linear"),h(.25,.1,.25,1,b+c),h(.42,0,1,1,d),h(0,0,.58,1,e),h(.42,0,.58,1,f),h(.55,.085,.68,.53,d+g[0]),h(.55,.055,.675,.19,d+g[1]),h(.895,.03,.685,.22,d+g[2]),h(.755,.05,.855,.06,d+g[3]),h(.47,0,.745,.715,d+g[4]),h(.95,.05,.795,.035,d+g[5]),h(.6,.04,.98,.335,d+g[6]),h(.25,.46,.45,.94,e+g[0]),h(.215,.61,.355,1,e+g[1]),h(.165,.84,.44,1,e+g[2]),h(.23,1,.32,1,e+g[3]),h(.39,.575,.565,1,e+g[4]),h(.19,1,.22,1,e+g[5]),h(.075,.82,.165,1,e+g[6]),h(.455,.03,.515,.955,f+g[0]),h(.645,.045,.355,1,f+g[1]),h(.77,0,.175,1,f+g[2]),h(.86,0,.07,1,f+g[3]),h(.445,.05,.55,.95,f+g[4]),h(1,0,0,1,f+g[5]),h(.785,.135,.15,.86,f+g[6]);function i(a,b){var c;b=b||101;var d=[];for(c=0;c=0?a:0-a}for(e=a,h=0;h<8;h++){f=m(e)-a;if(i(f)d)return d;while(cf?c=e:d=e,e=(d-c)*.5+c}return e}i=3*b,h=3*(d-b)-i,g=1-i-h,l=3*c,k=3*(e-c)-l,j=1-l-k;return q(a,p(f))}})(jQuery) \ No newline at end of file diff --git a/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery.js b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery.js new file mode 100755 index 0000000..ab8929e --- /dev/null +++ b/Samples/1-basic_component/embedded/PubCoder/Gallery&Coloring/OEBPS/components/shared/js/jquery.js @@ -0,0 +1,9267 @@ +/*! + * jQuery JavaScript Library v1.7.1 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Nov 21 21:11:03 2011 -0500 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context ? context.ownerDocument || context : document ); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.7.1", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.add( fn ); + + return this; + }, + + eq: function( i ) { + i = +i; + return i === -1 ? + this.slice( i ) : + this.slice( i, i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.fireWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).off( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery.Callbacks( "once memory" ); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array, i ) { + var len; + + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } + + len = array.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in array && array[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return ( new Date() ).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +return jQuery; + +})(); + + +// String to Object flags format cache +var flagsCache = {}; + +// Convert String-formatted flags into Object-formatted ones and store in cache +function createFlags( flags ) { + var object = flagsCache[ flags ] = {}, + i, length; + flags = flags.split( /\s+/ ); + for ( i = 0, length = flags.length; i < length; i++ ) { + object[ flags[i] ] = true; + } + return object; +} + +/* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * the callback list behaves + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible flags: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + var // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = [], + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Add one or several callbacks to the list + add = function( args ) { + var i, + length, + elem, + type, + actual; + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + // Inspect recursively + add( elem ); + } else if ( type === "function" ) { + // Add if not in unique mode and callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // firing was halted (stopOnFalse) + } else if ( memory && memory !== true ) { + firingStart = length; + fire( memory[ 0 ], memory[ 1 ] ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + var args = arguments, + argIndex = 0, + argLength = args.length; + for ( ; argIndex < argLength ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + break; + } + } + } + } + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + if ( list ) { + var i = 0, + length = list.length; + for ( ; i < length; i++ ) { + if ( fn === list[ i ] ) { + return true; + } + } + } + return false; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory || memory === true ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } else if ( !( flags.once && memory ) ) { + fire( context, args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!memory; + } + }; + + return self; +}; + + + + +var // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + + Deferred: function( func ) { + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList + }, + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + return this; + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; + } + } + return obj; + } + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = sliceDeferred.call( arguments, 0 ), + i = 0, + length = args.length, + pValues = new Array( length ), + count = length, + pCount = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(), + promise = deferred.promise(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + deferred.resolveWith( deferred, args ); + } + }; + } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } + if ( length > 1 ) { + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return promise; + } +}); + + + + +jQuery.support = (function() { + + var support, + all, + a, + select, + opt, + input, + marginDiv, + fragment, + tds, + events, + eventName, + i, + isSupported, + div = document.createElement( "div" ), + documentElement = document.documentElement; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
a"; + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute("href") === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + fragment.removeChild( input ); + fragment.appendChild( div ); + + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( window.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.style.width = "2px"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + }) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + fragment.removeChild( div ); + + // Null elements to avoid leaks in IE + fragment = select = opt = marginDiv = div = input = null; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + conMarginTop, ptlm, vb, style, html, + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + conMarginTop = 1; + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"; + vb = "visibility:hidden;border:0;"; + style = "style='" + ptlm + "border:5px solid #000;padding:0;'"; + html = "
" + + "" + + "
"; + + container = document.createElement("div"); + container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct the test element + div = document.createElement("div"); + container.appendChild( div ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = "
t
"; + tds = div.getElementsByTagName( "td" ); + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE <= 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + + // Figure out if the W3C box model works as expected + div.innerHTML = ""; + div.style.width = div.style.paddingLeft = "1px"; + jQuery.boxModel = support.boxModel = div.offsetWidth === 2; + + if ( typeof div.style.zoom !== "undefined" ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.style.cssText = ptlm + vb; + div.innerHTML = html; + + outer = div.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + body.removeChild( container ); + div = container = null; + + jQuery.extend( support, offsetSupport ); + }); + + return support; +})(); + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, + isEvents = name === "events"; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = ++jQuery.uuid; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + privateCache = thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ internalKey ] : internalKey; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the cache and need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ internalKey ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( internalKey ); + } else { + elem[ internalKey ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var parts, attr, name, + data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { + attr = this[0].attributes; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + jQuery._data( this[0], "parsedAttrs", true ); + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var self = jQuery( this ), + args = [ parts[0], value ]; + + self.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + self.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + jQuery.isNumeric( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery._data( elem, deferDataKey ); + if ( defer && + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.fire(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); + if ( count ) { + jQuery._data( elem, key, count ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + var q; + if ( elem ) { + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + hooks = {}; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue " + type + ".run", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + count++; + tmp.add( resolve ); + } + } + resolve(); + return defer.promise(); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = ( value || "" ).split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; + + if ( value && elem.nodeType === 1 ) { + attrNames = value.toLowerCase().split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ]; + + if ( name ) { + propName = jQuery.propFix[ name ] || name; + + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && propName in elem ) { + elem[ propName ] = false; + } + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.nodeValue = value + "" ); + } + }; + + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = "" + value ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); + + + + +var rformElems = /^(?:textarea|input|select)$/i, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /\bhover(\.\S+)?\b/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, + quickParse = function( selector ) { + var quick = rquickIs.exec( selector ); + if ( quick ) { + // 0 1 2 3 + // [ _, tag, id, class ] + quick[1] = ( quick[1] || "" ).toLowerCase(); + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); + } + return quick; + }, + quickIs = function( elem, m ) { + var attrs = elem.attributes || {}; + return ( + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && + (!m[2] || (attrs.id || {}).value === m[2]) && + (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) + ); + }, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = jQuery.trim( hoverHack(types) ).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + quick: quickParse( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, origType, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = jQuery.trim( hoverHack( types || "" ) ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = origType = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var type = event.type || event, + namespaces = [], + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; + old = null; + for ( ; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + // Note that this is a bare JS function and not a jQuery handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), + run_all = !event.exclusive && !event.namespace, + handlerQueue = [], + i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Determine handlers that should run if there are delegated events + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { + + // Pregenerate a single jQuery object for reuse with .is() + jqcur = jQuery(this); + jqcur.context = this.ownerDocument || this; + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + selMatch = {}; + matches = []; + jqcur[0] = cur; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = ( + handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) + ); + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { + event.metaKey = event.ctrlKey; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady + }, + + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + ret; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on.call( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + var handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( var type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + expando = "sizcache" + (Math.random() + '').replace('.', ''), + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rReturn = /\r\n/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context, seed ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set, seed ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set, i, len, match, type, left; + + if ( !expr ) { + return []; + } + + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + type, found, item, filter, left, + i, pass, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + filter = Expr.filter[ type ]; + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + pass = not ^ found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Utility function for retreiving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +var getText = Sizzle.getText = function( elem ) { + var i, node, + nodeType = elem.nodeType, + ret = ""; + + if ( nodeType ) { + if ( nodeType === 1 || nodeType === 9 ) { + // Use textContent || innerText for elements + if ( typeof elem.textContent === 'string' ) { + return elem.textContent; + } else if ( typeof elem.innerText === 'string' ) { + // Replace IE's carriage returns + return elem.innerText.replace( rReturn, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + } else { + + // If no nodeType, this is expected to be an array + for ( i = 0; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + if ( node.nodeType !== 8 ) { + ret += getText( node ); + } + } + } + return ret; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + first = match[2]; + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + doneName = match[0]; + parent = elem.parentNode; + + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent[ expando ] = doneName; + } + + diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + !type && Sizzle.attr ? + result != null : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context, seed ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet, seed ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array (deprecated as of jQuery 1.7) + if ( jQuery.isArray( selectors ) ) { + var level = 1; + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { + + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, slice.call( arguments ).join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} + + + + +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ +
+
+

Coloring Game

+
+
+
+ + + Sorry, your device cannot display this game. + + + Sorry, your device cannot display this game. + +
+ + + + +
+
+ + + + + + + + + +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ +
+
+ + + + +
+ +
+ + + + + diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/1/styles.css b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/1/styles.css new file mode 100644 index 0000000..659b084 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/1/styles.css @@ -0,0 +1,195 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#obj5645 { +position: absolute; +overflow: hidden; +top: 11px; +left: 14px; +width: 998px; +height: 31px; +opacity: 1; +z-index: 1; +display:block; +pointer-events: auto; +} + +div#obj5644 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: none; +} +img#obj5644_img { + position: relative; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} + + + + + + + + + + + +#obj5675{ + pointer-event: auto !important; + height: 604px; /* full height on page */ + width: 933px; /* full width on page */ + background-color: #F4F4F4; + border-color: #909090; + border-width: 1px; + border-style: solid; + border-radius: 6px; + -moz-border-radius: 6px; + -webkit-border-radius: 6px; + position: absolute; +overflow: hidden; +top: 77px; +left: 46px; +width: 933px; +height: 604px; +opacity: 1; +z-index: 2; +display:block; +pointer-events: auto; + /* override rotation value */ + transform:rotate(0deg) !important; + -ms-transform:rotate(0deg) !important; + -webkit-transform:rotate(0deg) !important; +} +#obj5675 .drawing-area{ + /*width and height must be the same as canvas */ + position:absolute; + width:929px; /* (full width on page) + (negative area/canvas offset) */ + height:424px; /* (full height on page) + (negative area/canvas offset) */ + top:80px; /* top area offset leaving space for tools, tool sizes and clear btn */ + left:2px; /* left offset leaving space for images and clear btn */ + z-index:12; /* this has to be smaller then drawing-area-touch zindex */ + overflow: hidden !important; +} +#obj5675 .drawing-area-touch{ + position:absolute; + width:929px; /* same as drawingarea */ + height:424px; /* same as drawingarea */ + top:80px; /* same as drawingarea */ + left:2px; /* same as drawingarea */ + z-index:22; /* this has to be greater then drawing-area zindex */ + overflow: hidden !important; +} +#obj5675 .drawing-tmp-area{ + position:absolute; + width:929px; /* same as drawingarea */ + height:424px; /* same as drawingarea */ + top:80px; /* same as drawingarea */ + left:2px; /* same as drawingarea */ + overflow: hidden !important; +} +#obj5675 .drawing-clear{ + position:absolute; + height: 60px; + width: 60px; + top:523px; + left:853px; + background-image: url(../../images/scdrawer-trash.png); + background-size: 60px 60px; + background-repeat: no-repeat; +} +#obj5675 .drawing-tools{ + position:absolute; + top:523px; + left:2px; /* same as drawingarea */ + display: inline-table; +} +#obj5675 .drawing-tools .tool{ + border : 1px solid white; + float: left; + clear: none; + width: 60px; + height: 60px; +} +#obj5675 .drawing-tools .tool.selected{ + border : 1px solid red; +} +#obj5675 .drawing-size{ + position: absolute; + top: 507px; + left: 740px; + display: inline-block; + max-height: 94px; + max-width: 98px; + height: 94px; + width: auto; + /*overflow: hidden;*/ +} +#obj5675 .drawing-size .sizeContainer{ + max-height: 94px; + height: 94px; + /*width: auto;*/ + min-width: 40px; + max-width: 98px; + display: inline-block; +} +#obj5675 .drawing-size .size{ + display: block; + width: 60px; + height: 60px; + background-color: #979797; + margin: 2px; + border-radius: 30px; + float: left; + clear: none; +} +#obj5675 .drawing-size .size.selected{ + background-color: #0A52A2; +} +#obj5675 .drawing-images{ + position: absolute; + display: inline; + top: 3px; + left: 5px; +} +#obj5675 .drawing-images .drawing-background{ + width: auto; + height: 70px; + margin-left: 10px; +} +#obj5675 .drawing-images .drawing-background-hidden{ + display:none; +} +#obj5675 .drawing-colors{ + position:absolute; + top:523px; + left:217px; + display: inline-block; + max-width: 621px; +} +#obj5675 .drawing-colors .color{ + border : 1px solid white; + heigth: 60px; + width: 60px; + float: left; + clear: none; +} +#obj5675 .drawing-colors .color.selected{ + border : 1px solid red; +} + diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring1.png b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring1.png new file mode 100644 index 0000000..7339c60 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring1.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring2.png b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring2.png new file mode 100644 index 0000000..52eb825 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring2.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring3.png b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring3.png new file mode 100644 index 0000000..c38ea8a Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/coloring3.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/obj5644_image.jpeg b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/obj5644_image.jpeg new file mode 100644 index 0000000..b41c86b Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/assets/images/obj5644_image.jpeg differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/content.opf b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/content.opf new file mode 100644 index 0000000..c0c9531 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/content.opf @@ -0,0 +1,53 @@ + + + + + scriptable-component + PubCoder Coloring Game + PubCoderColoringGame + urn:isbn:9781234567890 + A Scriptable Component + PubCoder Srl + 2015-05-11 + © 2015 PubCoder Srl + en + 1.0 + false + false + false + + 2015-05-11T08:46:47Z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/css/general.styles.css b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/css/general.styles.css new file mode 100644 index 0000000..1bd0457 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/css/general.styles.css @@ -0,0 +1,101 @@ +/* Font styles: */ +@charset "UTF-8"; + +/* Body style */ +body{ + padding:0; + margin:0; +} +/* Audio style */ +audio{ + z-index:-1; +} +/* Page style */ +div.SCPage { + width: 1024px; + height: 768px; + position: relative; + +} +div.SCOverlay { + position: absolute; + z-index: 2; + width: 1024px; + height: 768px; + overflow: hidden; + pointer-events: none; + +} +div.SCContent { + position: absolute; + z-index: 1; + width: 1024px; + height: 768px; +} +/* Navigation Style */ + +.SCRectangle { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} +/* Read Aloud Styles */ + +/* Custom CSS Styles */ +/* Start of Default SCText Styles */ +body { + font-family: helvetica, arial, sans-serif; +} +.SCText p, h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-regular", helvetica, arial, sans-serif; + margin: 0px; + padding: 0px; + line-height: 1.3; +} +.SCText p { + font-size: 13px; + font-weight: normal; +} +.SCText h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-weight: normal; +} +.SCText h1 { font-size: 40px; } +.SCText h2 { font-size: 36px; } +.SCText h3 { font-size: 24px; } +.SCText h4 { font-size: 18px; } +.SCText h5 { font-size: 16px; } +.SCText h6 { font-size: 14px; } +/* End of Default SCText Styles */ +/* Start of Style Formats defined manually */ +.SCText span.Float-Left { + float: left; +} +.SCText span.Float-Right { + float: right; +} +.SCText span.Vertical-Align-Middle { + display: inline-block; + vertical-align: middle; +} +.SCText span.Add-Margin { + margin: 10px; +} +.SCText span.Shadowed { + text-shadow: #000000 1px 1px 2px; +} + +.SCText span.Active-Text { + border-bottom: 1px dotted; +} +.SCText p.BigText { + font-size: 36px; +} + +/* End of Style Formats defined manually */ +h3 { + text-shadow: #fff 0px 0px 6px; +} +.SCText a { + color: inherit; +} \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/images/scdrawer-trash.png b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/images/scdrawer-trash.png new file mode 100644 index 0000000..2aefa6d Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/images/scdrawer-trash.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/drawer.js b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/drawer.js new file mode 100644 index 0000000..a448b91 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/drawer.js @@ -0,0 +1,355 @@ + var Trig = { + distanceBetween2Points: function ( point1, point2 ) { + + var dx = point2.x - point1.x; + var dy = point2.y - point1.y; + return Math.sqrt( Math.pow( dx, 2 ) + Math.pow( dy, 2 ) ); + }, + + angleBetween2Points: function ( point1, point2 ) { + + var dx = point2.x - point1.x; + var dy = point2.y - point1.y; + return Math.atan2( dx, dy ); + } + } + + var Sketcher = function(canvasID, brushImage, bgcolor) { + var sk = this; + + this.renderFunction = function(event){ + if(sk.curTool == 'marker') this.updateCanvasByLine(event); + else if(sk.curTool == 'crayon') this.updateCanvasByBrush(event); + else if(sk.curTool == 'eraser') this.updateCanvasByLineEraser(event); + else return; + } + + this.brush = undefined; + this.canvasID = canvasID; + this.drawer = $("#"+canvasID ); + this.canvas = $("#"+canvasID + " canvas.drawing-area"); + this.context = this.canvas[0].getContext("2d"); + this.context.strokeStyle = "#000000"; + this.context.lineJoin = "round"; + + this.canvas_touch = $("#"+canvasID + " canvas.drawing-area-touch"); + this.context_touch = this.canvas_touch[0].getContext("2d"); + + this.lastMousePoint = {x:0, y:0}; + this.curTool = 'marker'; + this.curColor = '#000000'; + this.curSize = $('.size.selected').attr("data-size")/1; + + //bgcolor + this.bgcolor = bgcolor; + + this.canvas_touch.bind( window.touchDownEvent, this.onCanvasMouseDown() ); + this.drawer.on( window.touchDownEvent, function(e){ e.preventDefault() }); + + this.drawer.find(".tool").on(window.touchDownEvent , function(e){ + sk.drawer.find(".tool").removeClass("selected"); + $(this).addClass("selected"); + if($(this).is(".tool-crayon")) sk.curTool = 'crayon'; + if($(this).is(".tool-marker")) sk.curTool = 'marker'; + if($(this).is(".tool-eraser")) sk.curTool = 'eraser'; + e.preventDefault(); + }); + + this.selectColor = function(){ + sk.drawer.find(".color").removeClass("selected"); + $(this).addClass("selected"); + sk.curColor = $(this).attr("data-color"); + }; + + + this.loadBrush = function(){ + this.brush = new Image(); + this.brush.src ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAABlBMVEX///////9VfPVsAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfeAhQKGhjvjaMMAAAFK0lEQVQ4yx3Ub0wTdxgH8O9dr/WAwo5asCLbrnCFFnUUBBTjtl9LMQWrlomKiEsBdZg5wxj+WxZzLcXVWrUoMqrMHQgEnBJ0kxdmIVdERZ0ONcvQ7AUQx9zcFlyWzBf7d+71kzzJ83yf5wOOf2YoraqV7eT3qAjiQ6jKGDC1gDVL4BiLRYi3HqlhUjkRRcsEnY3Oc3ck9LcTxJnZ3OHdtjjaL5pkWNIMtDAt2oQ2rxGwOGq0+1znb40eyw9YYT/NOH0nrjy/98icyKPYRE9w1VxkCpGFMuIqJvwjq56lnMl+t5xgvkaUzo/7PCF9thVIYgk1f3yYvlpVHCYQCqL/2DTG6sL2+/NkiCSObtKm1aSzzJUwMvKp7pllwoj/0OWwFTuLyO2J+34s/NhSyCMYIwepN4cqGtkGnsAfXaqLiv5WTYvnLxkhujGTyhF3sOE7DIdf/aSRXaaXTze4BQJO8L23KFb+UE/6YiYhPAnfiBdTi11sTZRDnM1YvfBMl86+SEvxOGXNecvRz7MDdd0yh05V2qTG2CtxzaGmMJx2T+HjG6Cvxf8kWaEl3mbh2HpXlmGdnoM5pN/E88dJnpj6Po90asXXEp/7sD/EbONQ3aiiWvfrqTK1zQu4qacLFtk+d91j+Pp6FBee1B3dtFGt1ncTGYjxM4InWeJobRhIUdca3QfPO3/ZnhgSUbCa2al19y/PfZbH8QiY/b7YpvFLZ/mf0wgisk4q0AcvCj1GJ4Fclkypjui66Ha30w0v/4VOn7nOa17ju0Mw1inQoZHeXep0EWHYE2ZE7hDXUcgaeOBU+c2tPfXbLXbL/R+A3taslObHr9iS57olHrOhbk9umVhbhCXNHNTbtDQ116x6ktihZNvxlb6AeJwSTXY7PBDs0ZXcbyIvxhx+Gajyzk/1HpbtaRA21qNhbIFBHSGzfS7zcoJvY63c8fQxzUFsgYjyMb35zxzTNUGVk+IBcwgWZ+UHCXn0urmD2CyVPBiyf+Lalh3Nl5EBUw17IJnzc455IuQDBjZzJtB3lnpQ4UElnyRO09RAf114pVJr3otEwZP0kDD76qFD1+j3U5yBmmi4ChBC561dHEixJbKMR9kF7V5WicHvlDP1QDM63rRr6tCCS5EGFUFnn7UpKWFqcQrTrQWS+xiNm/hLkHKddSMGXVxQ5fN7uzNeIxitFE1bxHLMCaQBeKlh6BZNsf6qIfq0kpiJZw1ZuRmMdFnNo8bicKqiQca6TnqVRwipQ+9cLtXl5bB7lH8YtnsSEOR9q2ZZgI+PvFH9pLPpIznjj1nUlxhb5KV+99nJvjaCNHbMaUT25olAVg+PSiPFViwBbfSca+NBs1neYPr0BkZn7uLRsuOJlbWWh2+PqiDDxGj2rB7c7+tud0c4kJatokzLM9VivwgUZXErT9Yniq/7z88fh8rSGGM2qgY4bc9F5XpKbd6j38RQFZ2dyoAXXLZIhoFda59JjCUQv7x+cq+Ou1nqGzEQbJValcYjO5J0B+sIHJNm3D3cteoEq5VElLA/9soubS0FVSgMx33ndWNd1t1CFmIYx81/E7a8VixSBJNeCNZX3hU0RZysJAEuY790ASGerOAGoWK3clE6L9yhsSiCqbLq/h1aXxJD+7t5RTBNRUPndCARBz9TnFAES61b0xdsfZrfrggWcbh83nPPy26tOcHDYYqt0BlFRbBPXwhW36EeiZuKbcss3aCoaIdx4JHPE2BeCPY2S2BwDxtE9/+C7SlOtmWqcsyYmCP/B/HdwNS6DfvtAAAAAElFTkSuQmCC"; + this.brush.onload = function(){ + sk.selectColor.apply(sk.drawer.find(".color.selected")); + $(".drawing-tmp-area").attr("width", sk.curSize).attr("height", sk.curSize); + var _canvas = $(".drawing-tmp-area")[0]; + + var _ctx = _canvas.getContext("2d"); + _ctx.strokeStyle = "#ffffff"; + + _ctx.clearRect(0, 0, sk.brush.width, sk.brush.height); + /* _ctx.arc(sk.curSize/2, sk.curSize/2, sk.curSize/2, 0, 2 * Math.PI, false); + _ctx.stroke(); + _ctx.clip(); + */ _ctx.drawImage(sk.brush, 0, 0); + + var _imageData = _ctx.getImageData(0, 0, sk.curSize, sk.curSize); + var colors = sk.hexToRgb(sk.curColor); + for (var i=0;i<_imageData.data.length;i+=4){ + if(_imageData.data[i+3] === 255 || _imageData.data[i+3] === 100){ + _imageData.data[i] = colors[0]; + _imageData.data[i+1] = colors[1]; + _imageData.data[i+2] = colors[2]; + _imageData.data[i+3] = colors[3]; + } + } + _ctx.putImageData(_imageData, 0,0); + _ctx.restore(); + sk.brush = new Image(); + sk.brush.src = _canvas.toDataURL(); + } + } + + this.drawer.find(".sizeContainer").on(window.touchDownEvent , function(e){ + e.preventDefault(); + sk.drawer.find(".size").removeClass("selected"); + $(this.children).addClass("selected"); + sk.curSize = $(this.children).attr("data-size"); + sk.loadBrush(); + }); + + $('.drawing-background-hidden').on(window.touchDownEvent , function(e){ + e.preventDefault(); + }) + + this.drawer.find(".drawing-background").on(window.touchDownEvent , function(e){ + e.preventDefault(); + sk.drawer.find(".drawing-background").removeClass("selected"); + $(this).addClass("selected"); + sk.drawSelectedImage(true); + }); + + this.drawSelectedImage = function(clear){ + if(clear) sk.clear(); + var imgName = sk.drawer.find(".drawing-background.selected").attr("id"); + if (typeof imgName != "undefined") { + var img = $("#" + imgName + "-hidden")[0]; + var maxwidth = sk.canvas_touch[0].width; + var maxheight = sk.canvas_touch[0].height; + var fW = maxwidth / img.width; + var fH = maxheight / img.height; + var f = (fW < fH ? fW : fH); + if (img.width <= maxwidth && img.height <= maxheight) f = 1; + var imgWidth = img.width*f; + var imgHeight = img.height*f; + var leftMargin = (maxwidth - imgWidth) / 2; + var topMargin = (maxheight - imgHeight) / 2; + sk.context_touch.drawImage(img, leftMargin, topMargin, imgWidth, imgHeight); + } + } + + + this.drawer.find(".color").on(window.touchDownEvent , function(e){ + sk.selectColor.apply(this); + sk.loadBrush(); + e.preventDefault(); + }); + + this.clear = function(event){ + if(event) + event.preventDefault(); + var c = sk.canvas_touch[0]; + sk.context_touch.clearRect( 0, 0, c.width, c.height ); + c = sk.canvas[0]; + sk.context.clearRect( 0, 0, c.width, c.height ); + var fillStyle = sk.context.fillStyle; + sk.context.fillStyle = bgcolor; + sk.context.fillRect( 0, 0, c.width, c.height ); + sk.context.fillStyle = fillStyle; + sk.drawSelectedImage(false); + } + + $(".drawing-clear").on(window.touchDownEvent, this.clear); + + this.loadBrush(); + this.clear(); + } + + Sketcher.prototype.onCanvasMouseDown = function () { + var self = this; + return function(event) { + self.mouseMoveHandler = self.onCanvasMouseMove(); + self.mouseUpHandler = self.onCanvasMouseUp(); + + $(document).bind( window.touchMoveEvent, self.mouseMoveHandler ); + $(document).bind( window.touchUpEvent, self.mouseUpHandler ); + + self.updateMousePosition( event ); + self.renderFunction( event ); + event.preventDefault(); + } + } + + Sketcher.prototype.hexToRgb = function(hex) { + if (hex.charAt(0) == "#") { + hex = hex.substr(1, hex.length-1); + var bigint = parseInt(hex, 16); + var r = (bigint >> 16) & 255; + var g = (bigint >> 8) & 255; + var b = bigint & 255; + return [r,g,b,100]; + } else if (hex.substr(0,5) == "rgba(") { + hex = hex.substr(5, hex.length-6); + var values = hex.split(","); + var r = parseInt(values[0]); + var g = parseInt(values[1]); + var b = parseInt(values[2]); + var a = values[3] * 100; + return [r,g,b,a]; + } + } + + Sketcher.prototype.onCanvasMouseMove = function () { + var self = this; + return function(event) { + self.renderFunction( event ); + event.preventDefault(); + return false; + } + } + + Sketcher.prototype.onCanvasMouseUp = function (event) { + var self = this; + return function(event) { + + $(document).unbind( window.touchMoveEvent, self.mouseMoveHandler ); + $(document).unbind( window.touchUpEvent, self.mouseUpHandler ); + + self.mouseMoveHandler = null; + self.mouseUpHandler = null; + event.preventDefault(); + } + } + + Sketcher.prototype.updateMousePosition = function (event) { + var target; + if ((typeof event.originalEvent !== "undefined") + && (typeof event.originalEvent.touches !== "undefined") + && (typeof event.originalEvent.touches[0] !== "undefined") ) { + target = event.originalEvent.touches[0]; + } + else { + target = event; + } + var offset = this.canvas.offset(); + this.lastMousePoint.x = target.pageX - offset.left; + this.lastMousePoint.y = target.pageY - offset.top; + event.preventDefault(); + + } + + Sketcher.prototype.updateCanvasByLine = function (event) { + //this.drawSelectedImage(true); + this.context.strokeStyle = this.curColor; + this.context.lineWidth = this.curSize; + this.context.beginPath(); + var prevMousePoint = this.lastMousePoint; + this.context.moveTo( this.lastMousePoint.x, this.lastMousePoint.y ); + this.updateMousePosition( event ); + if(prevMousePoint.x == this.lastMousePoint.x && prevMousePoint.y == this.lastMousePoint.y){ + this.context.lineTo( this.lastMousePoint.x +1, this.lastMousePoint.y +1 ); + }else{ + this.context.lineTo( this.lastMousePoint.x, this.lastMousePoint.y ); + } + this.context.closePath(); + this.context.stroke(); + event.preventDefault(); + } + +Sketcher.prototype.updateCanvasByLineEraser = function (event) { + //this.drawSelectedImage(true); + //this.context.strokeStyle = "#" + this.curColor; + this.context.strokeStyle = this.bgcolor; + this.context.lineWidth = this.curSize; + this.context.beginPath(); + var prevMousePoint = this.lastMousePoint; + this.context.moveTo( this.lastMousePoint.x, this.lastMousePoint.y ); + this.updateMousePosition( event ); + if(prevMousePoint.x == this.lastMousePoint.x && prevMousePoint.y == this.lastMousePoint.y){ + this.context.lineTo( this.lastMousePoint.x +1, this.lastMousePoint.y +1 ); + }else{ + this.context.lineTo( this.lastMousePoint.x, this.lastMousePoint.y ); + } + this.context.closePath(); + this.context.stroke(); + event.preventDefault(); + } + + Sketcher.prototype.updateCanvasByBrush = function (event) { + //this.drawSelectedImage(true); + var halfBrushW = this.curSize/2;//this.brush.width/2; + var halfBrushH = this.curSize/2;//this.brush.height/2; + + var start = { x:this.lastMousePoint.x, y: this.lastMousePoint.y }; + this.updateMousePosition( event ); + var end = { x:this.lastMousePoint.x, y: this.lastMousePoint.y }; + + var distance = parseInt( Trig.distanceBetween2Points( start, end ) ); + var angle = Trig.angleBetween2Points( start, end ); + + var x,y; + + for ( var z=0; (z<=distance || z==0); z++ ) + { + x = start.x + (Math.sin(angle) * z) - halfBrushW; + y = start.y + (Math.cos(angle) * z) - halfBrushH; + this.context.drawImage(this.brush, x, y); + } + event.preventDefault(); + } + +Drawer = function(objectID, bgcolor){ + initSizeBoxesAndImages(objectID); + var canvasID = objectID; + var brushImage = document.createElement('img'); + var s = new Sketcher(canvasID, brushImage, bgcolor); + setTimeout(function(){ + $("#"+objectID+" .drawing-background.selected").trigger(window.touchDownEvent); + $("#"+objectID+" .tool.selected").trigger(window.touchDownEvent); + $("#"+objectID+" .color.selected").trigger(window.touchDownEvent); + },200); +} + +function initSizeBoxesAndImages(objectID) { + $('#'+objectID+' .drawing-images').hide(); + $('#'+objectID+' .drawing-size').hide(); + setTimeout(function() { + var i = document.getElementById(objectID).getElementsByClassName('size').length; + i = i - 1; + var size = 0; + var sizeLabel = 0; + var reducingFactor = 0; + var containerHeight = $('#'+objectID+' .drawing-size > .sizeContainer').height(); // height == max-height + var containerWidth = $('#'+objectID+' .drawing-size > .sizeContainer').width(); // width == max-width + var customCSSstyle = 'margin-top:0px;position:relative;top:50%;transform:translateY(-50%);-ms-transform:translateY(-50%);-webkit-transform:translateY(-50%);'; + while (i > -1) { + size = document.getElementById(objectID).getElementsByClassName('size')[i].getAttribute('data-size'); + size = size - (size*reducingFactor/100); + if (size < (containerHeight - 5)) { + document.getElementById(objectID).getElementsByClassName('size')[i].setAttribute('style','height:'+size+'px;width:'+size+'px;border-radius:'+size+'px;'+customCSSstyle); + } + else { + sizeLabel = document.getElementById(objectID).getElementsByClassName('size')[i].getAttribute('data-size'); + size = containerHeight - 5; + document.getElementById(objectID).getElementsByClassName('size')[i].setAttribute('style','height:'+size+'px;width:'+size+'px;border-radius:'+size+'px;'+customCSSstyle); + document.getElementById(objectID).getElementsByClassName('size')[i].innerHTML=''+sizeLabel+''; + } + i = i - 1; + } + $('#'+objectID+' .drawing-size .sizeContainer .size > span').each(function() { + var spanH = $(this).height(); + var spanW = $(this).width(); + // containerHeight is set to maximum == containerWidth + var posH = (containerHeight - 5 - spanH) / 2; + var posW = (containerHeight - 5 - spanW) / 2; + $(this).css('top',posH+'px'); + $(this).css('left',posW+'px'); + }); + $('#'+objectID+' .drawing-size').show(); + }, 100); + setTimeout(function(){ + var imagesTotWidth = $('#'+objectID+' .drawing-images').width(); + var objTotWidth = $('#'+objectID).width(); + var imagesLeftVal = (objTotWidth - imagesTotWidth) / 2; + if (imagesLeftVal > 0) { + $('#'+objectID+' .drawing-images').css('left',imagesLeftVal+'px'); + } + $('#'+objectID+' .drawing-images').show(); + },100); +} \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/general.functions.js b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/general.functions.js new file mode 100644 index 0000000..e7e4088 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/general.functions.js @@ -0,0 +1,493 @@ +window.tocIsVisible=false; +/* + * + * Init Touch Events + * + */ +if ((/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()))) { + window.touchDownEvent = "touchstart"; + window.touchUpEvent = "touchend"; + window.touchMoveEvent = "touchmove"; + if ((/android/i.test(navigator.userAgent.toLowerCase()))) { + window.pinchopen = "pinchout"; + window.pinchclose = "pinchin"; + } else { + window.pinchopen = "pinchopen"; + window.pinchclose = "pinchclose"; + } +} else { + window.touchDownEvent = "mousedown"; + window.touchUpEvent = "mouseup"; + window.touchMoveEvent = "mousemove"; + window.pinchopen = "dblclick"; + window.pinchclose = "dblclick"; +} + +$(document).ready(function(){ + $('img').on('dragstart', function(event) { event.preventDefault(); }); +}); + +/* + * + * Init Accelerometer + * + */ +window.onorientationchange = function() { + var newOrientation; + if (isAndroid) + newOrientation = Android.getRotation(); + else + newOrientation = window.orientation; + /*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the + left, or landscape mode with the screen turned to the right. */ + window.orientationDevice = switchOrientationName(newOrientation,isAndroid); +} +window.ondevicemotion = function(e) { + switch (window.orientationDevice) { + case 'landscapeButtonLeft': + window.aigX = e.accelerationIncludingGravity.x; + window.aigY = e.accelerationIncludingGravity.y; + break; + case 'portraitButtonBottom': + window.aigX = -e.accelerationIncludingGravity.y; + window.aigY = e.accelerationIncludingGravity.x; + break; + case 'landscapeButtonRight': + window.aigX = -e.accelerationIncludingGravity.x; + window.aigY = -e.accelerationIncludingGravity.y; + break; + case 'portraitButtonTop': + window.aigX = e.accelerationIncludingGravity.y; + window.aigY = -e.accelerationIncludingGravity.x; + break; + + } +} + +/* + * + * Define PubCoder namespace + * + */ +var PubCoder = { + Events: { + Shake: 'SCEventShake', + Show: 'SCEventShow', + SwipeDown: 'SCswipedown', + SwipeLeft: 'SCswipeleft', + SwipeRight: 'SCswiperight', + SwipeUp: 'SCswipeup', + PinchClose: window.pinchclose, + PinchOpen: window.pinchopen, + TouchDown: window.touchDownEvent, + TouchUp: window.touchUpEvent + }, + + callID: 0, + + call: function (methodName, methodParameters) { + PubCoder.callID++; + window.status = JSON.stringify ({"method" : methodName, "params" : methodParameters, "id" : PubCoder.callID} ); + window.status = ' '; + } +}; + +/* + * + * Utility Functions + * + */ + +function getBrowser() { + + var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; + var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ + var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; + // At least Safari 3+: "[object HTMLElementConstructor]" + var isChrome = !!window.chrome && !isOpera; // Chrome 1+ + var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 + var browser = ""; + if (isOpera) + browser = "opera"; + else if (isFirefox) + browser = "firefox"; + else if (isSafari) + browser = "safari"; + else if (isChrome) + browser = "chrome"; + else if (isIE) + browser = "explorer"; + + return browser; +} + +function setPrefixCss3() { + var prefix = ""; + if (getBrowser() == "firefox") + prefix ="-moz-"; + else + prefix ="-webkit-"; + return prefix; +} + + +function isLocationInElement (element, x, y) + { + var elmOffset = $(element).offset(); + if (x >= elmOffset.left && x <= (elmOffset.left + $(element).width()) && + y >= elmOffset.top && y <= (elmOffset.top + $(element).height())) + return true; + return false; + } + +function setNewPos(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element).offset(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } else if (actualPos + deltaMax >= max) { + if (dim == "x") + elementDim = $(element).width(); + else + elementDim = $(element).height(); + newX = max - relativePos - elementDim; + } else { + newX = newPos; + } + } else + newX = newPos; + return newX; +} + +function isLocationInElementDragDropOffset(element, x, y) + { + var elmOffset = $(element)[0].getBoundingClientRect(); + if (x >= elmOffset.left && x <= (elmOffset.left + elmOffset.width) && + y >= elmOffset.top && y <= (elmOffset.top + elmOffset.height)) + return true; + return false; + } + + function setNewPosDragDropOffset(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element)[0].getBoundingClientRect(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } + else if (actualPos + deltaMax >= max) { + if (dim == "x") { + elementDim = elmOffset.width; + } + else { + elementDim = elmOffset.height; + } + newX = max - relativePos - elementDim; + } + else { + newX = newPos; + } + } + else newX = newPos; + + return newX; +} + +//functions for gravity acceleration actions +function boundingBoxCheckX(posX, objectX, containerObject, ax, isBouncing){ + var minX = 0, maxX = 0, x = posX; + var containerNodeOffset = containerObject.offset(); + var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + + if (xmaxX-objectX) { + x = maxX-objectX; + + } + + return x; +} + +function isBoundingBoxCheckX(posX, objectX, containerObject){ +var minX = 0, maxX = 0, x = posX; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + +if (xmaxX-objectX) + return 2; + else + return 0; +} +function boundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + y = maxY-objectY; + +return y; +} + +function isBoundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + return 2; +else + return 0 +} + +//function used by rotate.scx +function rotate(objectId,timesRun,howManyTimes,rotationToDegrees,rotationSpeed,effectEasing,transformOriginX,transformOriginY,functionCompleted) { + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + + var rotationToDegreesString; + if (rotationToDegrees.indexOf("-") == -1) + rotationToDegreesString = "+=" + rotationToDegrees; + else + rotationToDegreesString = "-=" + rotationToDegrees.substr(1); + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + + $('#' + objectId).animate({rotate: '' + getScale(objectId) + 'deg'}, {queue: false, duration: 0}); + $('#' + objectId).animate({rotate: '' + rotationToDegreesString + 'deg'}, {queue: false, duration: rotationSpeed, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); +} + +function getScale(obj) { + var angle; + var el = document.getElementById(obj); + var st = window.getComputedStyle(el, null); + var tr = st.getPropertyValue("-webkit-transform") || + st.getPropertyValue("-moz-transform") || + st.getPropertyValue("-ms-transform") || + st.getPropertyValue("-o-transform") || + st.getPropertyValue("transform") || + "fail..."; + +if (st != null && tr != "none") { + + + var values = tr.split('(')[1]; + values = values.split(')')[0]; + values = values.split(','); + var a = values[0]; + var b = values[1]; + var c = values[2]; + var d = values[3]; + + var scale = Math.sqrt(a*a + b*b); + + var sin = b/scale; + angle = Math.round(Math.atan2(b, a) * (180/Math.PI)); +} else { + angle = 0; +} + return angle; +} + + + +//end functions used by rotate.scx +//functions used by scale.scx +function scale(objectId,timesRun,howManyTimes,scaleX,scaleY,effectDurationMS,effectEasing,transformOriginX,transformOriginY,ScaleModeString,functionCompleted) { + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + $('#' + objectId).animate({scalex: '' + ScaleModeString + scaleX + '', scaley: '' + ScaleModeString + scaleY + ''}, {queue: false, duration: effectDurationMS, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); + +} + +//end functions used by scale + +//functions for float +function getOrientation(isAndroid) { + var orientationName, orientationType; + if (isAndroid) + orientationType = Android.getRotation(); + else + orientationType = window.orientation; + orientationName = switchOrientationName(orientationType, isAndroid); + return orientationName; +} + +function switchOrientationName(orientation, isAndroid) { + var orientationDetected; + var orientationName; + orientationDetected = orientation; + if (orientation == 0 && isAndroid) + orientationDetected = 180; + else if (orientation == 90 && isAndroid) + orientationDetected = -90; + else if (orientation == 180 && isAndroid) + orientationDetected = 0; + else if (orientation == 270 && isAndroid) + orientationDetected = 90; + + var orientationName; + switch(orientationDetected) { + case 0: + orientationName = 'portraitButtonBottom'; + break; + case 90: + orientationName = 'landscapeButtonRight'; + break; + case -90: + orientationName = 'landscapeButtonLeft'; + break; + case 180: + orientationName = 'portraitButtonTop'; + break; + } + return orientationName; +} + +function toggleToc() { + var menuTocHeight = $("#SCNavigationToc").height(); + if (window.tocIsVisible) { + $("#SCNavigationToc").animate({bottom: -menuTocHeight},200,'easieEaseIn',function() { + $("#SCNavigationToc").css("display","none"); + }); + + window.tocIsVisible=false; + } + else + { + $("#SCNavigationToc").css("display","block"); + $("#SCNavigationToc").animate({bottom: 0},200,'easieEaseIn'); + window.tocIsVisible=true; + } +} +//end functions for float + +function showAssetsParity(option){ + if (option == 'even' || option == 'odd') { + $('*[data-pubcoder="' + option + '"]').css('display','block'); + } else { + $('*[data-pubcoder="odd"]').css('display','block'); + $('*[data-pubcoder="even"]').css('display','block'); + } +} + +//initAnimations +function initAnimation(obj,width,height,fps,countVar,isInfinite,howManyLoops,backToFirstFrame) +{ +var frameTime = 1000/fps; +var nextAnimationAfterLastLoop = howManyLoops + 1 +var lastLoop = howManyLoops; +$(obj).spritespin({ + + width : width, // width in pixels of the window/frame + height : height, // height in pixels of the window/frame + animate : false, + renderer: 'image', + loop: true, + frameTime: frameTime, + onFrame: function(e,data) { + var stopAtFrame = data.images.length - 1; + if (!isInfinite) { + var api = $(obj).spritespin('api'); + if (data.frame == 0) { + countVar++; + if (backToFirstFrame && countVar == nextAnimationAfterLastLoop) { + stopAnimation(api,obj); + countVar = 1; + } + } + if (data.frame == stopAtFrame && countVar == lastLoop) { + if (!backToFirstFrame) { + stopAnimation(api,obj); + countVar = 0; + } + } + } + } + }); +function stopAnimation(apiAnimation,object) + { + apiAnimation.stopAnimation(); + $(object).removeClass("playing"); + var objectStripped = object.substr(1); + $(object).trigger(objectStripped + "_animation_ended"); + } +} \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/jquery.js b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/jquery.js new file mode 100755 index 0000000..ab8929e --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ColoringGame/PubCoderColoringGame/js/jquery.js @@ -0,0 +1,9267 @@ +/*! + * jQuery JavaScript Library v1.7.1 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Nov 21 21:11:03 2011 -0500 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context ? context.ownerDocument || context : document ); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.7.1", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.add( fn ); + + return this; + }, + + eq: function( i ) { + i = +i; + return i === -1 ? + this.slice( i ) : + this.slice( i, i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.fireWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).off( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery.Callbacks( "once memory" ); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array, i ) { + var len; + + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } + + len = array.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in array && array[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return ( new Date() ).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +return jQuery; + +})(); + + +// String to Object flags format cache +var flagsCache = {}; + +// Convert String-formatted flags into Object-formatted ones and store in cache +function createFlags( flags ) { + var object = flagsCache[ flags ] = {}, + i, length; + flags = flags.split( /\s+/ ); + for ( i = 0, length = flags.length; i < length; i++ ) { + object[ flags[i] ] = true; + } + return object; +} + +/* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * the callback list behaves + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible flags: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + var // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = [], + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Add one or several callbacks to the list + add = function( args ) { + var i, + length, + elem, + type, + actual; + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + // Inspect recursively + add( elem ); + } else if ( type === "function" ) { + // Add if not in unique mode and callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // firing was halted (stopOnFalse) + } else if ( memory && memory !== true ) { + firingStart = length; + fire( memory[ 0 ], memory[ 1 ] ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + var args = arguments, + argIndex = 0, + argLength = args.length; + for ( ; argIndex < argLength ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + break; + } + } + } + } + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + if ( list ) { + var i = 0, + length = list.length; + for ( ; i < length; i++ ) { + if ( fn === list[ i ] ) { + return true; + } + } + } + return false; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory || memory === true ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } else if ( !( flags.once && memory ) ) { + fire( context, args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!memory; + } + }; + + return self; +}; + + + + +var // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + + Deferred: function( func ) { + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList + }, + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + return this; + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; + } + } + return obj; + } + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = sliceDeferred.call( arguments, 0 ), + i = 0, + length = args.length, + pValues = new Array( length ), + count = length, + pCount = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(), + promise = deferred.promise(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + deferred.resolveWith( deferred, args ); + } + }; + } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } + if ( length > 1 ) { + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return promise; + } +}); + + + + +jQuery.support = (function() { + + var support, + all, + a, + select, + opt, + input, + marginDiv, + fragment, + tds, + events, + eventName, + i, + isSupported, + div = document.createElement( "div" ), + documentElement = document.documentElement; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
a"; + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute("href") === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + fragment.removeChild( input ); + fragment.appendChild( div ); + + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( window.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.style.width = "2px"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + }) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + fragment.removeChild( div ); + + // Null elements to avoid leaks in IE + fragment = select = opt = marginDiv = div = input = null; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + conMarginTop, ptlm, vb, style, html, + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + conMarginTop = 1; + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"; + vb = "visibility:hidden;border:0;"; + style = "style='" + ptlm + "border:5px solid #000;padding:0;'"; + html = "
" + + "" + + "
"; + + container = document.createElement("div"); + container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct the test element + div = document.createElement("div"); + container.appendChild( div ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = "
t
"; + tds = div.getElementsByTagName( "td" ); + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE <= 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + + // Figure out if the W3C box model works as expected + div.innerHTML = ""; + div.style.width = div.style.paddingLeft = "1px"; + jQuery.boxModel = support.boxModel = div.offsetWidth === 2; + + if ( typeof div.style.zoom !== "undefined" ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.style.cssText = ptlm + vb; + div.innerHTML = html; + + outer = div.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + body.removeChild( container ); + div = container = null; + + jQuery.extend( support, offsetSupport ); + }); + + return support; +})(); + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, + isEvents = name === "events"; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = ++jQuery.uuid; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + privateCache = thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ internalKey ] : internalKey; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the cache and need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ internalKey ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( internalKey ); + } else { + elem[ internalKey ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var parts, attr, name, + data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { + attr = this[0].attributes; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + jQuery._data( this[0], "parsedAttrs", true ); + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var self = jQuery( this ), + args = [ parts[0], value ]; + + self.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + self.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + jQuery.isNumeric( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery._data( elem, deferDataKey ); + if ( defer && + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.fire(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); + if ( count ) { + jQuery._data( elem, key, count ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + var q; + if ( elem ) { + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + hooks = {}; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue " + type + ".run", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + count++; + tmp.add( resolve ); + } + } + resolve(); + return defer.promise(); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = ( value || "" ).split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; + + if ( value && elem.nodeType === 1 ) { + attrNames = value.toLowerCase().split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ]; + + if ( name ) { + propName = jQuery.propFix[ name ] || name; + + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && propName in elem ) { + elem[ propName ] = false; + } + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.nodeValue = value + "" ); + } + }; + + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = "" + value ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); + + + + +var rformElems = /^(?:textarea|input|select)$/i, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /\bhover(\.\S+)?\b/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, + quickParse = function( selector ) { + var quick = rquickIs.exec( selector ); + if ( quick ) { + // 0 1 2 3 + // [ _, tag, id, class ] + quick[1] = ( quick[1] || "" ).toLowerCase(); + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); + } + return quick; + }, + quickIs = function( elem, m ) { + var attrs = elem.attributes || {}; + return ( + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && + (!m[2] || (attrs.id || {}).value === m[2]) && + (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) + ); + }, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = jQuery.trim( hoverHack(types) ).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + quick: quickParse( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, origType, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = jQuery.trim( hoverHack( types || "" ) ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = origType = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var type = event.type || event, + namespaces = [], + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; + old = null; + for ( ; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + // Note that this is a bare JS function and not a jQuery handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), + run_all = !event.exclusive && !event.namespace, + handlerQueue = [], + i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Determine handlers that should run if there are delegated events + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { + + // Pregenerate a single jQuery object for reuse with .is() + jqcur = jQuery(this); + jqcur.context = this.ownerDocument || this; + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + selMatch = {}; + matches = []; + jqcur[0] = cur; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = ( + handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) + ); + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { + event.metaKey = event.ctrlKey; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady + }, + + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + ret; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on.call( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + var handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( var type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + expando = "sizcache" + (Math.random() + '').replace('.', ''), + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rReturn = /\r\n/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context, seed ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set, seed ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set, i, len, match, type, left; + + if ( !expr ) { + return []; + } + + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + type, found, item, filter, left, + i, pass, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + filter = Expr.filter[ type ]; + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + pass = not ^ found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Utility function for retreiving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +var getText = Sizzle.getText = function( elem ) { + var i, node, + nodeType = elem.nodeType, + ret = ""; + + if ( nodeType ) { + if ( nodeType === 1 || nodeType === 9 ) { + // Use textContent || innerText for elements + if ( typeof elem.textContent === 'string' ) { + return elem.textContent; + } else if ( typeof elem.innerText === 'string' ) { + // Replace IE's carriage returns + return elem.innerText.replace( rReturn, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + } else { + + // If no nodeType, this is expected to be an array + for ( i = 0; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + if ( node.nodeType !== 8 ) { + ret += getText( node ); + } + } + } + return ret; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + first = match[2]; + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + doneName = match[0]; + parent = elem.parentNode; + + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent[ expando ] = doneName; + } + + diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + !type && Sizzle.attr ? + result != null : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context, seed ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet, seed ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array (deprecated as of jQuery 1.7) + if ( jQuery.isArray( selectors ) ) { + var level = 1; + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { + + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, slice.call( arguments ).join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} + + + + +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and + + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+ +
+
+

Image Gallery

+
+
+

Full-featured Example

+
+
+
+
+
+
+
+

Cars

+
+
+
+
+
+
+ +
Car 1
+
+
+
+
+ +
Car 2
+
+
+
+
+ +
Car 3
+
+
+
+
+ +
Car 4
+
+
+
+
+ +
Car 5
+
+
+
+
+ +
Car 6
+
+
+
+
+ +
Car 7
+
+
+
+
+ +
Car 8
+
+
+
+
+ +
Car 9
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + + + + +
+ +
+ +
+ +
+ + + + + diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/1/styles.css b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/1/styles.css new file mode 100644 index 0000000..2074bd6 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/1/styles.css @@ -0,0 +1,143 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#obj7090 { +position: absolute; +overflow: hidden; +top: 11px; +left: 13px; +width: 998px; +height: 31px; +opacity: 1; +z-index: 2; +display:block; +pointer-events: auto; +} +div#obj7108 { +position: absolute; +overflow: hidden; +top: 55px; +left: 309px; +width: 366px; +height: 35px; +opacity: 1; +z-index: 4; +display:block; +pointer-events: auto; +} + +div#obj7086 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: none; +} +img#obj7086_img { + position: relative; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} + + + + + +div#obj7087 { +position: absolute; +overflow: hidden; +top: 50px; +left: 18px; +width: 988px; +height: 704px; +opacity: 0.8; +z-index: 1; +display:block; +pointer-events: none; +background-image: none; +border-color: #000000; +border-width: 0px; +border-style: solid; +border-radius: 20px; +-moz-border-radius: 20px; +-webkit-border-radius: 20px; +background-color: #FFFFFF; +background-repeat: repeat; +} + + + +#obj7096 { + position: absolute; +overflow: hidden; +top: 121px; +left: 137px; +width: 712px; +height: 528px; +opacity: 1; +z-index: 3; +display:block; +pointer-events: auto; + border-color: #FFFFFF; + border-style: solid; + border-width: 1px; +} +#obj7096_container { + background-color: #FFFFFF; +} +#obj7096 .swiper-container { + width: 712px; + height: 528px; +} +#obj7096_container { + display: none; +} +#obj7096 .paginationContainer { + width: 712px; + background: rgba(255,255,255,0.8666667); +} +#obj7096 figcaption { + display: block; +} +#obj7096 p.SCPhotoGalleryTitleDefault { + display: block; +} +#obj7096 .arrow-left { + display: block; +} +#obj7096 .arrow-right { + display: block; +} +#obj7096 .SCPhotoGalleryTitleDefault { + background: rgba(255,255,255,0.8666667); +} +#obj7096 .SCPhotoGalleryTitleDefault { + font-family: "Droid-Sans-700"; + color: #444444; + font-size: 35px; +} +#obj7096 figure figcaption { + background: rgba(255,255,255,0.8666667); +} +#obj7096 .SCPhotoGalleryCaptionDefault { + font-family: "Droid-Sans-700"; + color: #444444; + font-size: 12px; +} + + + + diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0464.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0464.JPG new file mode 100644 index 0000000..3416bbf Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0464.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0474.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0474.JPG new file mode 100644 index 0000000..8815454 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0474.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0477.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0477.JPG new file mode 100644 index 0000000..5fba53f Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0477.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0505.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0505.JPG new file mode 100644 index 0000000..656a2f1 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0505.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0516.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0516.JPG new file mode 100644 index 0000000..02a3f36 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0516.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0546.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0546.JPG new file mode 100644 index 0000000..a00c493 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0546.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0580.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0580.JPG new file mode 100644 index 0000000..773bf9a Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0580.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0595.JPG b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0595.JPG new file mode 100644 index 0000000..0ad94f6 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_0595.JPG differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_2505.jpg b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_2505.jpg new file mode 100644 index 0000000..a8d03ac Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/IMG_2505.jpg differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/obj7086_image.jpeg b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/obj7086_image.jpeg new file mode 100644 index 0000000..b41c86b Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/assets/images/obj7086_image.jpeg differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/content.opf b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/content.opf new file mode 100644 index 0000000..f9e08b6 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/content.opf @@ -0,0 +1,74 @@ + + + + + scriptable-component + The PubCoder Feature Showcase + PubCoderImageGallery + urn:isbn:9781234567890 + A Scriptable Component + PubCoder Srl + 2015-05-07 + © 2015 PubCoder Srl + en + 1.0 + false + false + false + pre-paginated + landscape + none + 2015-05-07T08:46:47Z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/css/general.styles.css b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/css/general.styles.css new file mode 100644 index 0000000..5e5cb0a --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/css/general.styles.css @@ -0,0 +1,373 @@ +/* Font styles: */ +@charset "UTF-8"; + +@font-face { +font-family: "Droid-Sans-700"; +src: url(../fonts/Droid-Sans-700.ttf); +} + +/* Body style */ +body{ + padding:0; + margin:0; +} +/* Audio style */ +audio{ + z-index:-1; +} +/* Page style */ +div.SCPage { + width: 1024px; + height: 768px; + position: relative; + +} +div.SCOverlay { + position: absolute; + z-index: 2; + width: 1024px; + height: 768px; + overflow: hidden; + pointer-events: none; + +} +div.SCContent { + position: absolute; + z-index: 1; + width: 1024px; + height: 768px; +} +/* Navigation Style */ + +.hidden +{ + display:none; +} +/* SCRectangle Style */ +.SCRectangle { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +/* SCPhotoGallery Styles */ +.SCPhotoGallery { + position: absolute; + display: none; + z-index: 1; + box-sizing: border-box; +} +.SCPhotoGallery .arrow-left { + background: url(../images/scphotogallery-prev.png) no-repeat; + background-size: 50px 50px; + position: absolute; + left: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; +} +.SCPhotoGallery .arrow-right { + background: url(../images/scphotogallery-next.png) no-repeat; + background-size: 50px 50px; + position: absolute; + right: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; +} +.SCPhotoGallery p.SCPhotoGalleryTitleDefault { + margin: 0; + padding: 6px; + position: absolute; + left: 0px; + top: 0px; + width: 100%; + z-index: 2; +} +.SCPhotoGallery p.SCPhotoGalleryTitleDefault span { + display:table-cell; + height: 45px; + vertical-align:middle; + display:table; +} +.SCPhotoGallery .icons { + position: absolute; + right: 0; + top: 3px; + z-index: 3; + display:block; +} +.SCPhotoGallery .icon-fullscreen { + position: relative; + right: 0px; + margin-right: 5px; + top: 0px; + float: right; + width: 50px; + height: 50px; + z-index: 4; + display:none; +} +.SCPhotoGallery .fullscreen-open { + background: url(../images/scphotogallery-fullscreen-open.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .fullscreen-close { + background: url(../images/scphotogallery-fullscreen-close.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .icon-index { + position: relative; + right: 0px; + margin-right: 5px; + top: 0px; + float: right; + width: 50px; + height: 50px; + z-index: 4; + display:none; +} +.SCPhotoGallery .index-open { + background: url(../images/scphotogallery-index-open.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .index-close { + background: url(../images/scphotogallery-index-close.png) no-repeat; + background-size: 50px 50px; +} +.SCPhotoGallery .swiper-container { + left: 0px; +} +.SCPhotoGallery .swiper-slide { + display: table; +} +.SCPhotoGallery figure { + width: 100%; + padding: 0; + margin: 0; + text-align: center; + display: table-cell; + vertical-align: middle; +} +.SCPhotoGallery .swiper-slide img { + vertical-align:middle; + max-width: 100%; + margin: auto; +} +.SCPhotoGallery figure img { + padding: 0; + margin: 0; + text-align: center; +} +.SCPhotoGallery figure figcaption { + margin: 0; + padding: 6px; + position: absolute; + bottom: 0px; +} +.swiper-container { + margin:0 auto; + position:relative; + overflow:hidden; + -webkit-backface-visibility:hidden; + -moz-backface-visibility:hidden; + -ms-backface-visibility:hidden; + -o-backface-visibility:hidden; + backface-visibility:hidden; + /* Fix of Webkit flickering */ + z-index:1; +} +.swiper-wrapper { + position:relative; + width:100%; + -webkit-transition-property:-webkit-transform, left, top; + -webkit-transition-duration:0s; + -webkit-transform:translate3d(0px,0,0); + -webkit-transition-timing-function:ease; + -moz-transition-property:-moz-transform, left, top; + -moz-transition-duration:0s; + -moz-transform:translate3d(0px,0,0); + -moz-transition-timing-function:ease; + -o-transition-property:-o-transform, left, top; + -o-transition-duration:0s; + -o-transform:translate3d(0px,0,0); + -o-transition-timing-function:ease; + -o-transform:translate(0px,0px); + -ms-transition-property:-ms-transform, left, top; + -ms-transition-duration:0s; + -ms-transform:translate3d(0px,0,0); + -ms-transition-timing-function:ease; + transition-property:transform, left, top; + transition-duration:0s; + transform:translate3d(0px,0,0); + transition-timing-function:ease; +} +.swiper-free-mode > .swiper-wrapper { + -webkit-transition-timing-function: ease-out; + -moz-transition-timing-function: ease-out; + -ms-transition-timing-function: ease-out; + -o-transition-timing-function: ease-out; + transition-timing-function: ease-out; + margin: 0 auto; +} +.swiper-slide { + float: left; +} +.swiper-wp8-horizontal { + -ms-touch-action: pan-y; +} +.swiper-wp8-vertical { + -ms-touch-action: pan-x; +} + .SCPhotoGallery .paginationContainer { + position: absolute; + bottom: -95px; + left: 0px; + height: 95px; + margin-top: 20px; + overflow: hidden; + z-index: 2; +} + .SCPhotoGallery .overflowContainer { + position: absolute; + bottom: 0px; + padding-left: 0px; + text-align: center; + height: 80px; + margin: 0px 55px 0px 55px; + display: inline; + overflow-y: hidden; + overflow-x: auto; +} +.SCPhotoGallery .pagination-arrow-left { + background: url(../images/scphotogallery-thumb-prev.png) no-repeat; + background-size: 50px 50px; + position: absolute; + left: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index:2; + display:none; +} +.SCPhotoGallery .pagination-arrow-right { + background: url(../images/scphotogallery-thumb-next.png) no-repeat; + background-size: 50px 50px; + position: absolute; + right: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index:2; + display:none; +} +.SCPhotoGallery .pagination { + position: relative; + text-align: center; + height: 60px; + white-space: nowrap; +} +.SCPhotoGallery .overflowContainer::-webkit-scrollbar { + display: none; +} +.SCPhotoGallery .pagination ul { + list-style: none; + margin: 0; + padding: 0; +} +.SCPhotoGallery .pagination li { + display: inline-block; + width: 80px; + height: 60px; + border-radius: 2px; + margin: 10px; + margin: 0 3px; + text-align: center; + cursor: pointer; + overflow: hidden; +} +.SCPhotoGallery .pagination li.active { + border: 2px solid yellow; + box-sizing: border-box; +} + +/* Custom CSS Styles */ +/* Start of Default SCText Styles */ +body { + font-family: helvetica, arial, sans-serif; +} +.SCText p, h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-regular", helvetica, arial, sans-serif; + margin: 0px; + padding: 0px; + line-height: 1.3; +} +.SCText p { + font-size: 13px; + font-weight: normal; +} +.SCText h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-weight: normal; +} +.SCText h1 { font-size: 40px; } +.SCText h2 { font-size: 36px; } +.SCText h3 { font-size: 24px; } +.SCText h4 { font-size: 18px; } +.SCText h5 { font-size: 16px; } +.SCText h6 { font-size: 14px; } +/* End of Default SCText Styles */ +/* Start of Style Formats defined manually */ +.SCText span.Float-Left { + float: left; +} +.SCText span.Float-Right { + float: right; +} +.SCText span.Vertical-Align-Middle { + display: inline-block; + vertical-align: middle; +} +.SCText span.Add-Margin { + margin: 10px; +} +.SCText span.Shadowed { + text-shadow: #000000 1px 1px 2px; +} +.SCText span.OverBlack { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-size: 13px; + font-weight: normal; + color: #FFFFFF; +} +.SCText span.OverWhite { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-size: 13px; + font-weight: normal; + color: #000000; +} +.SCText span.Active-Text { + border-bottom: 1px dotted; +} +.SCText p.BigText { + font-size: 36px; +} + +/* End of Style Formats defined manually */ +h3 { + text-shadow: #fff 0px 0px 6px; +} +.SCText a { + color: inherit; +} +.SCButton.DefaultButtonTitle { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif !important; + font-size: 13px !important; + font-weight: normal !important; +} \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/fonts/Droid-Sans-700.ttf b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/fonts/Droid-Sans-700.ttf new file mode 100644 index 0000000..942bbf5 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/fonts/Droid-Sans-700.ttf differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-fullscreen-close.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-fullscreen-close.png new file mode 100644 index 0000000..87617c2 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-fullscreen-close.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-fullscreen-open.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-fullscreen-open.png new file mode 100644 index 0000000..789ce87 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-fullscreen-open.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-index-close.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-index-close.png new file mode 100644 index 0000000..de3053c Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-index-close.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-index-open.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-index-open.png new file mode 100644 index 0000000..de3053c Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-index-open.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-next.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-next.png new file mode 100644 index 0000000..a0af4e1 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-next.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-prev.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-prev.png new file mode 100644 index 0000000..78fa58c Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-prev.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-thumb-next.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-thumb-next.png new file mode 100644 index 0000000..422fc6c Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-thumb-next.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-thumb-prev.png b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-thumb-prev.png new file mode 100644 index 0000000..4f7ebe6 Binary files /dev/null and b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/images/scphotogallery-thumb-prev.png differ diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/general.functions.js b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/general.functions.js new file mode 100644 index 0000000..e7e4088 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/general.functions.js @@ -0,0 +1,493 @@ +window.tocIsVisible=false; +/* + * + * Init Touch Events + * + */ +if ((/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()))) { + window.touchDownEvent = "touchstart"; + window.touchUpEvent = "touchend"; + window.touchMoveEvent = "touchmove"; + if ((/android/i.test(navigator.userAgent.toLowerCase()))) { + window.pinchopen = "pinchout"; + window.pinchclose = "pinchin"; + } else { + window.pinchopen = "pinchopen"; + window.pinchclose = "pinchclose"; + } +} else { + window.touchDownEvent = "mousedown"; + window.touchUpEvent = "mouseup"; + window.touchMoveEvent = "mousemove"; + window.pinchopen = "dblclick"; + window.pinchclose = "dblclick"; +} + +$(document).ready(function(){ + $('img').on('dragstart', function(event) { event.preventDefault(); }); +}); + +/* + * + * Init Accelerometer + * + */ +window.onorientationchange = function() { + var newOrientation; + if (isAndroid) + newOrientation = Android.getRotation(); + else + newOrientation = window.orientation; + /*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the + left, or landscape mode with the screen turned to the right. */ + window.orientationDevice = switchOrientationName(newOrientation,isAndroid); +} +window.ondevicemotion = function(e) { + switch (window.orientationDevice) { + case 'landscapeButtonLeft': + window.aigX = e.accelerationIncludingGravity.x; + window.aigY = e.accelerationIncludingGravity.y; + break; + case 'portraitButtonBottom': + window.aigX = -e.accelerationIncludingGravity.y; + window.aigY = e.accelerationIncludingGravity.x; + break; + case 'landscapeButtonRight': + window.aigX = -e.accelerationIncludingGravity.x; + window.aigY = -e.accelerationIncludingGravity.y; + break; + case 'portraitButtonTop': + window.aigX = e.accelerationIncludingGravity.y; + window.aigY = -e.accelerationIncludingGravity.x; + break; + + } +} + +/* + * + * Define PubCoder namespace + * + */ +var PubCoder = { + Events: { + Shake: 'SCEventShake', + Show: 'SCEventShow', + SwipeDown: 'SCswipedown', + SwipeLeft: 'SCswipeleft', + SwipeRight: 'SCswiperight', + SwipeUp: 'SCswipeup', + PinchClose: window.pinchclose, + PinchOpen: window.pinchopen, + TouchDown: window.touchDownEvent, + TouchUp: window.touchUpEvent + }, + + callID: 0, + + call: function (methodName, methodParameters) { + PubCoder.callID++; + window.status = JSON.stringify ({"method" : methodName, "params" : methodParameters, "id" : PubCoder.callID} ); + window.status = ' '; + } +}; + +/* + * + * Utility Functions + * + */ + +function getBrowser() { + + var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; + var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ + var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; + // At least Safari 3+: "[object HTMLElementConstructor]" + var isChrome = !!window.chrome && !isOpera; // Chrome 1+ + var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 + var browser = ""; + if (isOpera) + browser = "opera"; + else if (isFirefox) + browser = "firefox"; + else if (isSafari) + browser = "safari"; + else if (isChrome) + browser = "chrome"; + else if (isIE) + browser = "explorer"; + + return browser; +} + +function setPrefixCss3() { + var prefix = ""; + if (getBrowser() == "firefox") + prefix ="-moz-"; + else + prefix ="-webkit-"; + return prefix; +} + + +function isLocationInElement (element, x, y) + { + var elmOffset = $(element).offset(); + if (x >= elmOffset.left && x <= (elmOffset.left + $(element).width()) && + y >= elmOffset.top && y <= (elmOffset.top + $(element).height())) + return true; + return false; + } + +function setNewPos(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element).offset(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } else if (actualPos + deltaMax >= max) { + if (dim == "x") + elementDim = $(element).width(); + else + elementDim = $(element).height(); + newX = max - relativePos - elementDim; + } else { + newX = newPos; + } + } else + newX = newPos; + return newX; +} + +function isLocationInElementDragDropOffset(element, x, y) + { + var elmOffset = $(element)[0].getBoundingClientRect(); + if (x >= elmOffset.left && x <= (elmOffset.left + elmOffset.width) && + y >= elmOffset.top && y <= (elmOffset.top + elmOffset.height)) + return true; + return false; + } + + function setNewPosDragDropOffset(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element)[0].getBoundingClientRect(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } + else if (actualPos + deltaMax >= max) { + if (dim == "x") { + elementDim = elmOffset.width; + } + else { + elementDim = elmOffset.height; + } + newX = max - relativePos - elementDim; + } + else { + newX = newPos; + } + } + else newX = newPos; + + return newX; +} + +//functions for gravity acceleration actions +function boundingBoxCheckX(posX, objectX, containerObject, ax, isBouncing){ + var minX = 0, maxX = 0, x = posX; + var containerNodeOffset = containerObject.offset(); + var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + + if (xmaxX-objectX) { + x = maxX-objectX; + + } + + return x; +} + +function isBoundingBoxCheckX(posX, objectX, containerObject){ +var minX = 0, maxX = 0, x = posX; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + +if (xmaxX-objectX) + return 2; + else + return 0; +} +function boundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + y = maxY-objectY; + +return y; +} + +function isBoundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + return 2; +else + return 0 +} + +//function used by rotate.scx +function rotate(objectId,timesRun,howManyTimes,rotationToDegrees,rotationSpeed,effectEasing,transformOriginX,transformOriginY,functionCompleted) { + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + + var rotationToDegreesString; + if (rotationToDegrees.indexOf("-") == -1) + rotationToDegreesString = "+=" + rotationToDegrees; + else + rotationToDegreesString = "-=" + rotationToDegrees.substr(1); + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + + $('#' + objectId).animate({rotate: '' + getScale(objectId) + 'deg'}, {queue: false, duration: 0}); + $('#' + objectId).animate({rotate: '' + rotationToDegreesString + 'deg'}, {queue: false, duration: rotationSpeed, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); +} + +function getScale(obj) { + var angle; + var el = document.getElementById(obj); + var st = window.getComputedStyle(el, null); + var tr = st.getPropertyValue("-webkit-transform") || + st.getPropertyValue("-moz-transform") || + st.getPropertyValue("-ms-transform") || + st.getPropertyValue("-o-transform") || + st.getPropertyValue("transform") || + "fail..."; + +if (st != null && tr != "none") { + + + var values = tr.split('(')[1]; + values = values.split(')')[0]; + values = values.split(','); + var a = values[0]; + var b = values[1]; + var c = values[2]; + var d = values[3]; + + var scale = Math.sqrt(a*a + b*b); + + var sin = b/scale; + angle = Math.round(Math.atan2(b, a) * (180/Math.PI)); +} else { + angle = 0; +} + return angle; +} + + + +//end functions used by rotate.scx +//functions used by scale.scx +function scale(objectId,timesRun,howManyTimes,scaleX,scaleY,effectDurationMS,effectEasing,transformOriginX,transformOriginY,ScaleModeString,functionCompleted) { + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + $('#' + objectId).animate({scalex: '' + ScaleModeString + scaleX + '', scaley: '' + ScaleModeString + scaleY + ''}, {queue: false, duration: effectDurationMS, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); + +} + +//end functions used by scale + +//functions for float +function getOrientation(isAndroid) { + var orientationName, orientationType; + if (isAndroid) + orientationType = Android.getRotation(); + else + orientationType = window.orientation; + orientationName = switchOrientationName(orientationType, isAndroid); + return orientationName; +} + +function switchOrientationName(orientation, isAndroid) { + var orientationDetected; + var orientationName; + orientationDetected = orientation; + if (orientation == 0 && isAndroid) + orientationDetected = 180; + else if (orientation == 90 && isAndroid) + orientationDetected = -90; + else if (orientation == 180 && isAndroid) + orientationDetected = 0; + else if (orientation == 270 && isAndroid) + orientationDetected = 90; + + var orientationName; + switch(orientationDetected) { + case 0: + orientationName = 'portraitButtonBottom'; + break; + case 90: + orientationName = 'landscapeButtonRight'; + break; + case -90: + orientationName = 'landscapeButtonLeft'; + break; + case 180: + orientationName = 'portraitButtonTop'; + break; + } + return orientationName; +} + +function toggleToc() { + var menuTocHeight = $("#SCNavigationToc").height(); + if (window.tocIsVisible) { + $("#SCNavigationToc").animate({bottom: -menuTocHeight},200,'easieEaseIn',function() { + $("#SCNavigationToc").css("display","none"); + }); + + window.tocIsVisible=false; + } + else + { + $("#SCNavigationToc").css("display","block"); + $("#SCNavigationToc").animate({bottom: 0},200,'easieEaseIn'); + window.tocIsVisible=true; + } +} +//end functions for float + +function showAssetsParity(option){ + if (option == 'even' || option == 'odd') { + $('*[data-pubcoder="' + option + '"]').css('display','block'); + } else { + $('*[data-pubcoder="odd"]').css('display','block'); + $('*[data-pubcoder="even"]').css('display','block'); + } +} + +//initAnimations +function initAnimation(obj,width,height,fps,countVar,isInfinite,howManyLoops,backToFirstFrame) +{ +var frameTime = 1000/fps; +var nextAnimationAfterLastLoop = howManyLoops + 1 +var lastLoop = howManyLoops; +$(obj).spritespin({ + + width : width, // width in pixels of the window/frame + height : height, // height in pixels of the window/frame + animate : false, + renderer: 'image', + loop: true, + frameTime: frameTime, + onFrame: function(e,data) { + var stopAtFrame = data.images.length - 1; + if (!isInfinite) { + var api = $(obj).spritespin('api'); + if (data.frame == 0) { + countVar++; + if (backToFirstFrame && countVar == nextAnimationAfterLastLoop) { + stopAnimation(api,obj); + countVar = 1; + } + } + if (data.frame == stopAtFrame && countVar == lastLoop) { + if (!backToFirstFrame) { + stopAnimation(api,obj); + countVar = 0; + } + } + } + } + }); +function stopAnimation(apiAnimation,object) + { + apiAnimation.stopAnimation(); + $(object).removeClass("playing"); + var objectStripped = object.substr(1); + $(object).trigger(objectStripped + "_animation_ended"); + } +} \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/idangerous.swiper-2.3.js b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/idangerous.swiper-2.3.js new file mode 100644 index 0000000..7d65efb --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/idangerous.swiper-2.3.js @@ -0,0 +1,2479 @@ +/* + * Swiper 2.3 - Mobile Touch Slider + * http://www.idangero.us/sliders/swiper/ + * + * Copyright 2012-2013, Vladimir Kharlampidi + * The iDangero.us + * http://www.idangero.us/ + * + * Licensed under GPL & MIT + * + * Updated on: November 2, 2013 +*/ +var Swiper = function (selector, params) { + /*========================= + A little bit dirty but required part for IE8 and old FF support + ===========================*/ + if (document.body.__defineGetter__) { + if (HTMLElement) { + var element = HTMLElement.prototype; + if (element.__defineGetter__) { + element.__defineGetter__("outerHTML", function () { return new XMLSerializer().serializeToString(this); } ); + } + } + } + + if (!window.getComputedStyle) { + window.getComputedStyle = function (el, pseudo) { + this.el = el; + this.getPropertyValue = function (prop) { + var re = /(\-([a-z]){1})/g; + if (prop === 'float') prop = 'styleFloat'; + if (re.test(prop)) { + prop = prop.replace(re, function () { + return arguments[2].toUpperCase(); + }); + } + return el.currentStyle[prop] ? el.currentStyle[prop] : null; + } + return this; + } + } + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function(obj, start) { + for (var i = (start || 0), j = this.length; i < j; i++) { + if (this[i] === obj) { return i; } + } + return -1; + } + } + if (!document.querySelectorAll) { + if (!window.jQuery) return; + } + function $$(selector, context) { + if (document.querySelectorAll) + return (context || document).querySelectorAll(selector); + else + return jQuery(selector, context); + } + + /*========================= + Check for correct selector + ===========================*/ + if(typeof selector === 'undefined') return; + + if(!(selector.nodeType)){ + if ($$(selector).length === 0) return; + } + + /*========================= + _this + ===========================*/ + var _this = this; + + /*========================= + Default Flags and vars + ===========================*/ + _this.touches = { + start:0, + startX:0, + startY:0, + current:0, + currentX:0, + currentY:0, + diff:0, + abs:0 + }; + _this.positions = { + start:0, + abs:0, + diff:0, + current:0 + }; + _this.times = { + start:0, + end:0 + }; + + _this.id = (new Date()).getTime(); + _this.container = (selector.nodeType) ? selector : $$(selector)[0]; + _this.isTouched = false; + _this.isMoved = false; + _this.activeIndex = 0; + _this.centerIndex = 0; + _this.activeLoaderIndex = 0; + _this.activeLoopIndex = 0; + _this.previousIndex = null; + _this.velocity = 0; + _this.snapGrid = []; + _this.slidesGrid = []; + _this.imagesToLoad = []; + _this.imagesLoaded = 0; + _this.wrapperLeft=0; + _this.wrapperRight=0; + _this.wrapperTop=0; + _this.wrapperBottom=0; + var wrapper, slideSize, wrapperSize, direction, isScrolling, containerSize; + + /*========================= + Default Parameters + ===========================*/ + var defaults = { + mode : 'horizontal', // or 'vertical' + touchRatio : 1, + speed : 300, + freeMode : false, + freeModeFluid : false, + momentumRatio: 1, + momentumBounce: true, + momentumBounceRatio: 1, + slidesPerView : 1, + slidesPerGroup : 1, + simulateTouch : true, + followFinger : true, + shortSwipes : true, + moveStartThreshold:false, + autoplay: false, + onlyExternal : false, + createPagination : true, + pagination : false, + paginationElement: 'span', + paginationClickable: false, + paginationAsRange: true, + resistance : true, // or false or 100% + scrollContainer : false, + preventLinks : true, + noSwiping : false, // or class + noSwipingClass : 'swiper-no-swiping', //:) + initialSlide: 0, + keyboardControl: false, + mousewheelControl : false, + mousewheelDebounce: 600, + useCSS3Transforms : true, + // Autoplay + autoplay: false, + autoplayDisableOnInteraction: false, + //Loop mode + loop:false, + loopAdditionalSlides:0, + //Auto Height + calculateHeight: false, + //Images Preloader + updateOnImagesReady : true, + //Form elements + releaseFormElements : true, + //Watch for active slide, useful when use effects on different slide states + watchActiveIndex: false, + //Slides Visibility Fit + visibilityFullFit : false, + //Slides Offset + offsetPxBefore : 0, + offsetPxAfter : 0, + offsetSlidesBefore : 0, + offsetSlidesAfter : 0, + centeredSlides: false, + //Queue callbacks + queueStartCallbacks : false, + queueEndCallbacks : false, + //Auto Resize + autoResize : true, + resizeReInit : false, + //DOMAnimation + DOMAnimation : true, + //Slides Loader + loader: { + slides:[], //array with slides + slidesHTMLType:'inner', // or 'outer' + surroundGroups: 1, //keep preloaded slides groups around view + logic: 'reload', //or 'change' + loadAllSlides: false + }, + //Namespace + slideElement : 'div', + slideClass : 'swiper-slide', + slideActiveClass : 'swiper-slide-active', + slideVisibleClass : 'swiper-slide-visible', + wrapperClass : 'swiper-wrapper', + paginationElementClass: 'swiper-pagination-switch', + paginationActiveClass : 'swiper-active-switch', + paginationVisibleClass : 'swiper-visible-switch' + } + params = params || {}; + for (var prop in defaults) { + if (prop in params && typeof params[prop]==='object') { + for (var subProp in defaults[prop]) { + if (! (subProp in params[prop])) { + params[prop][subProp] = defaults[prop][subProp]; + } + } + } + else if (! (prop in params)) { + params[prop] = defaults[prop] + } + } + _this.params = params; + if (params.scrollContainer) { + params.freeMode = true; + params.freeModeFluid = true; + } + if (params.loop) { + params.resistance = '100%'; + } + var isH = params.mode==='horizontal'; + + /*========================= + Define Touch Events + ===========================*/ + + _this.touchEvents = { + touchStart : _this.support.touch || !params.simulateTouch ? 'touchstart' : (_this.browser.ie10 ? 'MSPointerDown' : 'mousedown'), + touchMove : _this.support.touch || !params.simulateTouch ? 'touchmove' : (_this.browser.ie10 ? 'MSPointerMove' : 'mousemove'), + touchEnd : _this.support.touch || !params.simulateTouch ? 'touchend' : (_this.browser.ie10 ? 'MSPointerUp' : 'mouseup') + }; + + /*========================= + Wrapper + ===========================*/ + for (var i = _this.container.childNodes.length - 1; i >= 0; i--) { + if (_this.container.childNodes[i].className) { + var _wrapperClasses = _this.container.childNodes[i].className.split(' ') + for (var j = 0; j < _wrapperClasses.length; j++) { + if (_wrapperClasses[j]===params.wrapperClass) { + wrapper = _this.container.childNodes[i]; + } + }; + } + }; + + _this.wrapper = wrapper; + /*========================= + Slide API + ===========================*/ + _this._extendSwiperSlide = function (el) { + el.append = function () { + if (params.loop) { + el.insertAfter(_this.slides.length-_this.loopedSlides); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + _this.wrapper.appendChild(el); + } + + _this.reInit(); + return el; + } + el.prepend = function () { + if (params.loop) { + _this.wrapper.insertBefore(el, _this.slides[_this.loopedSlides]); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + _this.wrapper.insertBefore(el, _this.wrapper.firstChild); + } + _this.reInit(); + return el; + } + el.insertAfter = function (index) { + if(typeof index === 'undefined') return false; + var beforeSlide; + + if (params.loop) { + beforeSlide = _this.slides[index + 1 + _this.loopedSlides]; + _this.wrapper.insertBefore(el, beforeSlide); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + beforeSlide = _this.slides[index + 1]; + _this.wrapper.insertBefore(el, beforeSlide) + } + _this.reInit(); + return el; + } + el.clone = function () { + return _this._extendSwiperSlide(el.cloneNode(true)) + } + el.remove = function () { + _this.wrapper.removeChild(el); + _this.reInit(); + } + el.html = function (html) { + if (typeof html === 'undefined') { + return el.innerHTML; + } + else { + el.innerHTML = html; + return el; + } + } + el.index = function () { + var index; + for (var i = _this.slides.length - 1; i >= 0; i--) { + if(el === _this.slides[i]) index = i; + } + return index; + } + el.isActive = function () { + if (el.index() === _this.activeIndex) return true; + else return false; + } + if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage={}; + el.getData = function (name) { + return el.swiperSlideDataStorage[name]; + } + el.setData = function (name, value) { + el.swiperSlideDataStorage[name] = value; + return el; + } + el.data = function (name, value) { + if (!value) { + return el.getAttribute('data-'+name); + } + else { + el.setAttribute('data-'+name,value); + return el; + } + } + el.getWidth = function (outer) { + return _this.h.getWidth(el, outer); + } + el.getHeight = function (outer) { + return _this.h.getHeight(el, outer); + } + el.getOffset = function() { + return _this.h.getOffset(el); + } + return el; + } + + //Calculate information about number of slides + _this.calcSlides = function (forceCalcSlides) { + var oldNumber = _this.slides ? _this.slides.length : false; + _this.slides = []; + _this.displaySlides = []; + for (var i = 0; i < _this.wrapper.childNodes.length; i++) { + if (_this.wrapper.childNodes[i].className) { + var _className = _this.wrapper.childNodes[i].className; + var _slideClasses = _className.split(' '); + for (var j = 0; j < _slideClasses.length; j++) { + if(_slideClasses[j]===params.slideClass) { + _this.slides.push(_this.wrapper.childNodes[i]); + } + } + } + } + for (i = _this.slides.length - 1; i >= 0; i--) { + _this._extendSwiperSlide(_this.slides[i]); + } + if (oldNumber===false) return; + if(oldNumber!==_this.slides.length || forceCalcSlides) { + // Number of slides has been changed + removeSlideEvents(); + addSlideEvents(); + _this.updateActiveSlide(); + if (_this.params.pagination) _this.createPagination(); + _this.callPlugins('numberOfSlidesChanged'); + } + } + + //Create Slide + _this.createSlide = function (html, slideClassList, el) { + var slideClassList = slideClassList || _this.params.slideClass; + var el = el||params.slideElement; + var newSlide = document.createElement(el); + newSlide.innerHTML = html||''; + newSlide.className = slideClassList; + return _this._extendSwiperSlide(newSlide); + } + + //Append Slide + _this.appendSlide = function (html, slideClassList, el) { + if (!html) return; + if (html.nodeType) { + return _this._extendSwiperSlide(html).append() + } + else { + return _this.createSlide(html, slideClassList, el).append() + } + } + _this.prependSlide = function (html, slideClassList, el) { + if (!html) return; + if (html.nodeType) { + return _this._extendSwiperSlide(html).prepend() + } + else { + return _this.createSlide(html, slideClassList, el).prepend() + } + } + _this.insertSlideAfter = function (index, html, slideClassList, el) { + if (typeof index === 'undefined') return false; + if (html.nodeType) { + return _this._extendSwiperSlide(html).insertAfter(index); + } + else { + return _this.createSlide(html, slideClassList, el).insertAfter(index); + } + } + _this.removeSlide = function (index) { + if (_this.slides[index]) { + if (params.loop) { + if (!_this.slides[index+_this.loopedSlides]) return false; + _this.slides[index+_this.loopedSlides].remove(); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else _this.slides[index].remove(); + return true; + } + else return false; + } + _this.removeLastSlide = function () { + if (_this.slides.length>0) { + if (params.loop) { + _this.slides[_this.slides.length - 1 - _this.loopedSlides].remove(); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else _this.slides[ (_this.slides.length-1) ].remove(); + return true; + } + else { + return false; + } + } + _this.removeAllSlides = function () { + for (var i = _this.slides.length - 1; i >= 0; i--) { + _this.slides[i].remove() + } + } + _this.getSlide = function (index) { + return _this.slides[index] + } + _this.getLastSlide = function () { + return _this.slides[ _this.slides.length-1 ] + } + _this.getFirstSlide = function () { + return _this.slides[0] + } + + //Currently Active Slide + _this.activeSlide = function () { + return _this.slides[_this.activeIndex] + } + + /*========================= + Plugins API + ===========================*/ + var _plugins = []; + for (var plugin in _this.plugins) { + if (params[plugin]) { + var p = _this.plugins[plugin](_this, params[plugin]); + if (p) _plugins.push( p ); + } + } + _this.callPlugins = function(method, args) { + if (!args) args = {} + for (var i=0; i<_plugins.length; i++) { + if (method in _plugins[i]) { + _plugins[i][method](args); + } + } + } + + /*========================= + WP8 Fix + ===========================*/ + if (_this.browser.ie10 && !params.onlyExternal) { + _this.wrapper.classList.add('swiper-wp8-' + (isH ? 'horizontal' : 'vertical')); + } + + /*========================= + Free Mode Class + ===========================*/ + if (params.freeMode) { + _this.container.className+=' swiper-free-mode'; + } + + /*================================================== + Init/Re-init/Resize Fix + ====================================================*/ + _this.initialized = false; + _this.init = function(force, forceCalcSlides) { + var _width = _this.h.getWidth(_this.container); + var _height = _this.h.getHeight(_this.container); + if (_width===_this.width && _height===_this.height && !force) return; + _this.width = _width; + _this.height = _height; + + containerSize = isH ? _width : _height; + var wrapper = _this.wrapper; + + if (force) { + _this.calcSlides(forceCalcSlides); + } + + if (params.slidesPerView==='auto') { + //Auto mode + var slidesWidth = 0; + var slidesHeight = 0; + + //Unset Styles + if (params.slidesOffset>0) { + wrapper.style.paddingLeft = ''; + wrapper.style.paddingRight = ''; + wrapper.style.paddingTop = ''; + wrapper.style.paddingBottom = ''; + } + wrapper.style.width = ''; + wrapper.style.height = ''; + if (params.offsetPxBefore>0) { + if (isH) _this.wrapperLeft = params.offsetPxBefore; + else _this.wrapperTop = params.offsetPxBefore; + } + if (params.offsetPxAfter>0) { + if (isH) _this.wrapperRight = params.offsetPxAfter; + else _this.wrapperBottom = params.offsetPxAfter; + } + + if (params.centeredSlides) { + if (isH) { + _this.wrapperLeft = (containerSize - this.slides[0].getWidth(true) )/2; + _this.wrapperRight = (containerSize - _this.slides[ _this.slides.length-1 ].getWidth(true))/2; + } + else { + _this.wrapperTop = (containerSize - _this.slides[0].getHeight(true))/2; + _this.wrapperBottom = (containerSize - _this.slides[ _this.slides.length-1 ].getHeight(true))/2; + } + } + + if (isH) { + if (_this.wrapperLeft>=0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; + if (_this.wrapperRight>=0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + } + else { + if (_this.wrapperTop>=0) wrapper.style.paddingTop = _this.wrapperTop+'px'; + if (_this.wrapperBottom>=0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + } + var slideLeft = 0; + var centeredSlideLeft=0; + _this.snapGrid = []; + _this.slidesGrid = []; + + var slideMaxHeight = 0; + for(var i = 0; i<_this.slides.length; i++) { + var slideWidth = _this.slides[i].getWidth(true); + var slideHeight = _this.slides[i].getHeight(true); + if (params.calculateHeight) { + slideMaxHeight = Math.max(slideMaxHeight, slideHeight) + } + var _slideSize = isH ? slideWidth : slideHeight; + if (params.centeredSlides) { + var nextSlideWidth = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getWidth(true); + var nextSlideHeight = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getHeight(true); + var nextSlideSize = isH ? nextSlideWidth : nextSlideHeight; + if (_slideSize>containerSize) { + for (var j=0; j<=Math.floor(_slideSize/(containerSize+_this.wrapperLeft)); j++) { + if (j === 0) _this.snapGrid.push(slideLeft+_this.wrapperLeft); + else _this.snapGrid.push(slideLeft+_this.wrapperLeft+containerSize*j); + } + _this.slidesGrid.push(slideLeft+_this.wrapperLeft); + } + else { + _this.snapGrid.push(centeredSlideLeft); + _this.slidesGrid.push(centeredSlideLeft); + } + + centeredSlideLeft += _slideSize/2 + nextSlideSize/2; + + } + else { + if (_slideSize>containerSize) { + for (var j=0; j<=Math.floor(_slideSize/containerSize); j++) { + _this.snapGrid.push(slideLeft+containerSize*j); + } + } + else { + _this.snapGrid.push(slideLeft); + } + _this.slidesGrid.push(slideLeft); + } + + slideLeft += _slideSize; + + slidesWidth += slideWidth; + slidesHeight += slideHeight; + } + if (params.calculateHeight) _this.height = slideMaxHeight; + if(isH) { + wrapperSize = slidesWidth + _this.wrapperRight + _this.wrapperLeft; + wrapper.style.width = (slidesWidth)+'px'; + wrapper.style.height = (_this.height)+'px'; + } + else { + wrapperSize = slidesHeight + _this.wrapperTop + _this.wrapperBottom; + wrapper.style.width = (_this.width)+'px'; + wrapper.style.height = (slidesHeight)+'px'; + } + + } + else if (params.scrollContainer) { + //Scroll Container + wrapper.style.width = ''; + wrapper.style.height = ''; + var wrapperWidth = _this.slides[0].getWidth(true); + var wrapperHeight = _this.slides[0].getHeight(true); + wrapperSize = isH ? wrapperWidth : wrapperHeight; + wrapper.style.width = wrapperWidth+'px'; + wrapper.style.height = wrapperHeight+'px'; + slideSize = isH ? wrapperWidth : wrapperHeight; + + } + else { + //For usual slides + if (params.calculateHeight) { + var slideMaxHeight = 0; + var wrapperHeight = 0; + //ResetWrapperSize + if (!isH) _this.container.style.height= ''; + wrapper.style.height=''; + + for (var i=0; i<_this.slides.length; i++) { + //ResetSlideSize + _this.slides[i].style.height=''; + slideMaxHeight = Math.max( _this.slides[i].getHeight(true), slideMaxHeight ); + if (!isH) wrapperHeight+=_this.slides[i].getHeight(true); + } + var slideHeight = slideMaxHeight; + _this.height = slideHeight; + + if (isH) wrapperHeight = slideHeight; + else containerSize = slideHeight, _this.container.style.height= containerSize+'px'; + } + else { + var slideHeight = isH ? _this.height : _this.height/params.slidesPerView; + var wrapperHeight = isH ? _this.height : _this.slides.length*slideHeight; + } + var slideWidth = isH ? _this.width/params.slidesPerView : _this.width; + var wrapperWidth = isH ? _this.slides.length*slideWidth : _this.width; + slideSize = isH ? slideWidth : slideHeight; + + if (params.offsetSlidesBefore>0) { + if (isH) _this.wrapperLeft = slideSize*params.offsetSlidesBefore; + else _this.wrapperTop = slideSize*params.offsetSlidesBefore; + } + if (params.offsetSlidesAfter>0) { + if (isH) _this.wrapperRight = slideSize*params.offsetSlidesAfter; + else _this.wrapperBottom = slideSize*params.offsetSlidesAfter; + } + if (params.offsetPxBefore>0) { + if (isH) _this.wrapperLeft = params.offsetPxBefore; + else _this.wrapperTop = params.offsetPxBefore; + } + if (params.offsetPxAfter>0) { + if (isH) _this.wrapperRight = params.offsetPxAfter; + else _this.wrapperBottom = params.offsetPxAfter; + } + if (params.centeredSlides) { + if (isH) { + _this.wrapperLeft = (containerSize - slideSize)/2; + _this.wrapperRight = (containerSize - slideSize)/2; + } + else { + _this.wrapperTop = (containerSize - slideSize)/2; + _this.wrapperBottom = (containerSize - slideSize)/2; + } + } + if (isH) { + if (_this.wrapperLeft>0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; + if (_this.wrapperRight>0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + } + else { + if (_this.wrapperTop>0) wrapper.style.paddingTop = _this.wrapperTop+'px'; + if (_this.wrapperBottom>0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + } + + wrapperSize = isH ? wrapperWidth + _this.wrapperRight + _this.wrapperLeft : wrapperHeight + _this.wrapperTop + _this.wrapperBottom; + wrapper.style.width = wrapperWidth+'px'; + wrapper.style.height = wrapperHeight+'px'; + var slideLeft = 0; + _this.snapGrid = []; + _this.slidesGrid = []; + for (var i=0; i<_this.slides.length; i++) { + _this.snapGrid.push(slideLeft); + _this.slidesGrid.push(slideLeft); + slideLeft+=slideSize; + _this.slides[i].style.width = slideWidth+'px'; + _this.slides[i].style.height = slideHeight+'px'; + } + + } + + if (!_this.initialized) { + _this.callPlugins('onFirstInit'); + if (params.onFirstInit) params.onFirstInit(_this); + } + else { + _this.callPlugins('onInit'); + if (params.onInit) params.onInit(_this); + } + _this.initialized = true; + } + + _this.reInit = function (forceCalcSlides) { + _this.init(true, forceCalcSlides); + } + + _this.resizeFix = function (reInit) { + _this.callPlugins('beforeResizeFix'); + + _this.init(params.resizeReInit || reInit); + + // swipe to active slide in fixed mode + if (!params.freeMode) { + _this.swipeTo((params.loop ? _this.activeLoopIndex : _this.activeIndex), 0, false); + } + + // move wrapper to the beginning in free mode + else if (_this.getWrapperTranslate() < -maxWrapperPosition()) { + _this.setWrapperTransition(0); + _this.setWrapperTranslate(-maxWrapperPosition()); + } + + _this.callPlugins('afterResizeFix'); + } + + /*========================================== + Max and Min Positions + ============================================*/ + function maxWrapperPosition() { + var a = (wrapperSize - containerSize); + if (params.freeMode) { + a = wrapperSize - containerSize; + } + // if (params.loop) a -= containerSize; + if (params.slidesPerView > _this.slides.length) a = 0; + if (a<0) a = 0; + return a; + } + function minWrapperPosition() { + var a = 0; + // if (params.loop) a = containerSize; + return a; + } + + /*========================================== + Event Listeners + ============================================*/ + function initEvents() { + var bind = _this.h.addEventListener; + + //Touch Events + if (!_this.browser.ie10) { + if (_this.support.touch) { + bind(_this.wrapper, 'touchstart', onTouchStart); + bind(_this.wrapper, 'touchmove', onTouchMove); + bind(_this.wrapper, 'touchend', onTouchEnd); + } + if (params.simulateTouch) { + bind(_this.wrapper, 'mousedown', onTouchStart); + bind(document, 'mousemove', onTouchMove); + bind(document, 'mouseup', onTouchEnd); + } + } + else { + bind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); + bind(document, _this.touchEvents.touchMove, onTouchMove); + bind(document, _this.touchEvents.touchEnd, onTouchEnd); + } + + //Resize Event + if (params.autoResize) { + bind(window, 'resize', _this.resizeFix); + } + //Slide Events + addSlideEvents(); + //Mousewheel + _this._wheelEvent = false; + if (params.mousewheelControl) { + if ( document.onmousewheel !== undefined ) { + _this._wheelEvent = "mousewheel"; + } + try { + WheelEvent("wheel"); + _this._wheelEvent = "wheel"; + } catch (e) {} + if ( !_this._wheelEvent ) { + _this._wheelEvent = "DOMMouseScroll"; + } + + if (_this._wheelEvent) { + bind(_this.container, _this._wheelEvent, handleMousewheel); + } + } + + //Keyboard + if (params.keyboardControl) { + bind(document, 'keydown', handleKeyboardKeys); + } + if (params.updateOnImagesReady) { + _this.imagesToLoad = $$('img', _this.container); + + for (var i=0; i<_this.imagesToLoad.length; i++) { + _loadImage(_this.imagesToLoad[i].getAttribute('src')) + } + } + function _loadImage(src) { + var image = new Image(); + image.onload = function(){ + _this.imagesLoaded++; + if (_this.imagesLoaded==_this.imagesToLoad.length) { + _this.reInit(); + if (params.onImagesReady) params.onImagesReady(_this); + } + } + image.src = src; + } + } + + //Remove Event Listeners + _this.destroy = function(removeResizeFix){ + var unbind = _this.h.removeEventListener; + + //Touch Events + if (!_this.browser.ie10) { + if (_this.support.touch) { + unbind(_this.wrapper, 'touchstart', onTouchStart); + unbind(_this.wrapper, 'touchmove', onTouchMove); + unbind(_this.wrapper, 'touchend', onTouchEnd); + } + if (params.simulateTouch) { + unbind(_this.wrapper, 'mousedown', onTouchStart); + unbind(document, 'mousemove', onTouchMove); + unbind(document, 'mouseup', onTouchEnd); + } + } + else { + unbind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); + unbind(document, _this.touchEvents.touchMove, onTouchMove); + unbind(document, _this.touchEvents.touchEnd, onTouchEnd); + } + + //Resize Event + if (params.autoResize) { + unbind(window, 'resize', _this.resizeFix); + } + + //Init Slide Events + removeSlideEvents(); + + //Pagination + if (params.paginationClickable) { + removePaginationEvents(); + } + + //Mousewheel + if (params.mousewheelControl && _this._wheelEvent) { + unbind(_this.container, _this._wheelEvent, handleMousewheel); + } + + //Keyboard + if (params.keyboardControl) { + unbind(document, 'keydown', handleKeyboardKeys); + } + + //Stop autoplay + if (params.autoplay) { + _this.stopAutoplay(); + } + _this.callPlugins('onDestroy'); + + //Destroy variable + _this = null; + } + function addSlideEvents() { + var bind = _this.h.addEventListener, + i; + + //Prevent Links Events + if (params.preventLinks) { + var links = $$('a', _this.container); + for (i=0; i=scrollLeft && point[0]<=scrollLeft+windowWidth && + point[1]>=scrollTop && point[1]<=scrollTop+windowHeight + ) { + inView = true; + } + + } + if (!inView) return; + } + if (isH) { + if (kc==37 || kc==39) { + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + } + if (kc == 39) _this.swipeNext(); + if (kc == 37) _this.swipePrev(); + } + else { + if (kc==38 || kc==40) { + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + } + if (kc == 40) _this.swipeNext(); + if (kc == 38) _this.swipePrev(); + } + } + + /*========================================== + Mousewheel Control + ============================================*/ + var allowScrollChange = true; + function handleMousewheel (e) { + var we = _this._wheelEvent; + var delta; + //Opera & IE + if (e.detail) delta = -e.detail; + //WebKits + else if (we == 'mousewheel') delta = e.wheelDelta; + //Old FireFox + else if (we == 'DOMMouseScroll') delta = -e.detail; + //New FireFox + else if (we == 'wheel') { + delta = Math.abs(e.deltaX)>Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY; + } + if (!params.freeMode) { + if(delta<0) _this.swipeNext(); + else _this.swipePrev(); + } + else { + //Freemode or scrollContainer: + var position = _this.getWrapperTranslate() + delta; + + if (position > 0) position = 0; + if (position < -maxWrapperPosition()) position = -maxWrapperPosition(); + + _this.setWrapperTransition(0); + _this.setWrapperTranslate(position); + _this.updateActiveSlide(position); + } + if (params.autoplay) _this.stopAutoplay(true); + + if(e.preventDefault) e.preventDefault(); + else e.returnValue = false; + return false; + } + + /*========================= + Grab Cursor + ===========================*/ + if (params.grabCursor) { + var containerStyle = _this.container.style; + containerStyle.cursor = 'move'; + containerStyle.cursor = 'grab'; + containerStyle.cursor = '-moz-grab'; + containerStyle.cursor = '-webkit-grab'; + } + + /*========================= + Slides Events Handlers + ===========================*/ + + _this.allowSlideClick = true; + function slideClick(event) { + //hack PubCoder + event.preventDefault(); + if (_this.allowSlideClick) { + setClickedSlide(event); + params.onSlideClick(_this, event); + } + } + + function slideTouch(event) { + setClickedSlide(event); + params.onSlideTouch(_this, event); + } + + function setClickedSlide(event) { + //hack PubCoder + event.preventDefault(); + // IE 6-8 support + if (!event.currentTarget) { + var element = event.srcElement; + do { + if (element.className.indexOf(params.slideClass) > -1) { + break; + } + } + while (element = element.parentNode); + _this.clickedSlide = element; + } + else { + _this.clickedSlide = event.currentTarget; + } + + _this.clickedSlideIndex = _this.slides.indexOf(_this.clickedSlide); + _this.clickedSlideLoopIndex = _this.clickedSlideIndex - (_this.loopedSlides || 0); + } + + _this.allowLinks = true; + function preventClick(e) { + if (!_this.allowLinks) { + if(e.preventDefault) e.preventDefault(); + else e.returnValue = false; + return false; + } + } + function releaseForms(e) { + if (e.stopPropagation) e.stopPropagation(); + else e.returnValue = false; + return false; + + } + + /*================================================== + Event Handlers + ====================================================*/ + var isTouchEvent = false; + var allowThresholdMove; + var allowMomentumBounce = true; + function onTouchStart(event) { + if (params.preventLinks) _this.allowLinks = true; + //Exit if slider is already was touched + if (_this.isTouched || params.onlyExternal) { + return false; + } + + if (params.noSwiping && (event.target || event.srcElement) && noSwipingSlide(event.target || event.srcElement)) return false; + allowMomentumBounce = false; + + //Check For Nested Swipers + _this.isTouched = true; + isTouchEvent = event.type=='touchstart'; + + if (!isTouchEvent || event.targetTouches.length == 1 ) { + _this.callPlugins('onTouchStartBegin'); + + if(!isTouchEvent) { + if(event.preventDefault) event.preventDefault(); + else event.returnValue = false; + } + + var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); + var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); + + //Start Touches to check the scrolling + _this.touches.startX = _this.touches.currentX = pageX; + _this.touches.startY = _this.touches.currentY = pageY; + + _this.touches.start = _this.touches.current = isH ? pageX : pageY; + + //Set Transition Time to 0 + _this.setWrapperTransition(0); + + //Get Start Translate Position + _this.positions.start = _this.positions.current = _this.getWrapperTranslate(); + + //Set Transform + _this.setWrapperTranslate(_this.positions.start); + + //TouchStartTime + _this.times.start = (new Date()).getTime(); + + //Unset Scrolling + isScrolling = undefined; + + //Set Treshold + if (params.moveStartThreshold>0) allowThresholdMove = false; + + //CallBack + if (params.onTouchStart) params.onTouchStart(_this); + _this.callPlugins('onTouchStartEnd'); + + } + } + var velocityPrevPosition, velocityPrevTime; + function onTouchMove(event) { + // If slider is not touched - exit + if (!_this.isTouched || params.onlyExternal) return; + if (isTouchEvent && event.type=='mousemove') return; + + var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); + var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); + + //check for scrolling + if ( typeof isScrolling === 'undefined' && isH) { + isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) > Math.abs( pageX - _this.touches.startX ) ); + } + if ( typeof isScrolling === 'undefined' && !isH) { + isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) < Math.abs( pageX - _this.touches.startX ) ); + } + if (isScrolling ) { + _this.isTouched = false; + return; + } + + //Check For Nested Swipers + if (event.assignedToSwiper) { + _this.isTouched = false; + return; + } + event.assignedToSwiper = true; + + //Block inner links + if (params.preventLinks) { + _this.allowLinks = false; + } + if (params.onSlideClick) { + _this.allowSlideClick = false; + } + + //Stop AutoPlay if exist + if (params.autoplay) { + _this.stopAutoplay(true); + } + if (!isTouchEvent || event.touches.length == 1) { + + //Moved Flag + if (!_this.isMoved) { + _this.callPlugins('onTouchMoveStart'); + + if (params.loop) { + _this.fixLoop(); + _this.positions.start = _this.getWrapperTranslate(); + } + if (params.onTouchMoveStart) params.onTouchMoveStart(_this); + } + _this.isMoved = true; + + // cancel event + if(event.preventDefault) event.preventDefault(); + else event.returnValue = false; + + _this.touches.current = isH ? pageX : pageY ; + + _this.positions.current = (_this.touches.current - _this.touches.start) * params.touchRatio + _this.positions.start; + + //Resistance Callbacks + if(_this.positions.current > 0 && params.onResistanceBefore) { + params.onResistanceBefore(_this, _this.positions.current); + } + if(_this.positions.current < -maxWrapperPosition() && params.onResistanceAfter) { + params.onResistanceAfter(_this, Math.abs(_this.positions.current + maxWrapperPosition())); + } + //Resistance + if (params.resistance && params.resistance!='100%') { + //Resistance for Negative-Back sliding + if(_this.positions.current > 0) { + var resistance = 1 - _this.positions.current/containerSize/2; + if (resistance < 0.5) + _this.positions.current = (containerSize/2); + else + _this.positions.current = _this.positions.current * resistance; + } + //Resistance for After-End Sliding + if ( _this.positions.current < -maxWrapperPosition() ) { + + var diff = (_this.touches.current - _this.touches.start)*params.touchRatio + (maxWrapperPosition()+_this.positions.start); + var resistance = (containerSize+diff)/(containerSize); + var newPos = _this.positions.current-diff*(1-resistance)/2; + var stopPos = -maxWrapperPosition() - containerSize/2; + + if (newPos < stopPos || resistance<=0) + _this.positions.current = stopPos; + else + _this.positions.current = newPos; + } + } + if (params.resistance && params.resistance=='100%') { + //Resistance for Negative-Back sliding + if(_this.positions.current > 0 && !(params.freeMode&&!params.freeModeFluid)) { + _this.positions.current = 0; + } + //Resistance for After-End Sliding + if ( (_this.positions.current) < -maxWrapperPosition() && !(params.freeMode&&!params.freeModeFluid)) { + _this.positions.current = -maxWrapperPosition(); + } + } + //Move Slides + if (!params.followFinger) return; + + if (!params.moveStartThreshold) { + _this.setWrapperTranslate(_this.positions.current); + } + else { + if ( Math.abs(_this.touches.current - _this.touches.start)>params.moveStartThreshold || allowThresholdMove) { + allowThresholdMove = true; + _this.setWrapperTranslate(_this.positions.current); + } + else { + _this.positions.current = _this.positions.start; + } + } + + if (params.freeMode || params.watchActiveIndex) { + _this.updateActiveSlide(_this.positions.current); + } + + //Grab Cursor + if (params.grabCursor) { + _this.container.style.cursor = 'move'; + _this.container.style.cursor = 'grabbing'; + _this.container.style.cursor = '-moz-grabbin'; + _this.container.style.cursor = '-webkit-grabbing'; + } + //Velocity + if (!velocityPrevPosition) velocityPrevPosition = _this.touches.current; + if (!velocityPrevTime) velocityPrevTime = (new Date).getTime(); + _this.velocity = (_this.touches.current - velocityPrevPosition)/((new Date).getTime() - velocityPrevTime)/2; + if (Math.abs(_this.touches.current - velocityPrevPosition)<2) _this.velocity=0; + velocityPrevPosition = _this.touches.current; + velocityPrevTime = (new Date).getTime(); + //Callbacks + _this.callPlugins('onTouchMoveEnd'); + if (params.onTouchMove) params.onTouchMove(_this); + + return false; + } + } + function onTouchEnd(event) { + //Check For scrolling + if (isScrolling) { + _this.swipeReset(); + } + // If slider is not touched exit + if ( params.onlyExternal || !_this.isTouched ) return; + _this.isTouched = false + + //Return Grab Cursor + if (params.grabCursor) { + _this.container.style.cursor = 'move'; + _this.container.style.cursor = 'grab'; + _this.container.style.cursor = '-moz-grab'; + _this.container.style.cursor = '-webkit-grab'; + } + + //Check for Current Position + if (!_this.positions.current && _this.positions.current!==0) { + _this.positions.current = _this.positions.start + } + + //For case if slider touched but not moved + if (params.followFinger) { + _this.setWrapperTranslate(_this.positions.current); + } + + // TouchEndTime + _this.times.end = (new Date()).getTime(); + + //Difference + _this.touches.diff = _this.touches.current - _this.touches.start + _this.touches.abs = Math.abs(_this.touches.diff) + + _this.positions.diff = _this.positions.current - _this.positions.start + _this.positions.abs = Math.abs(_this.positions.diff) + + var diff = _this.positions.diff ; + var diffAbs =_this.positions.abs ; + var timeDiff = _this.times.end - _this.times.start + + if(diffAbs < 5 && (timeDiff) < 300 && _this.allowLinks == false) { + if (!params.freeMode && diffAbs!=0) _this.swipeReset() + //Release inner links + if (params.preventLinks) { + _this.allowLinks = true; + } + if (params.onSlideClick) { + _this.allowSlideClick = true; + } + } + + setTimeout(function () { + //Release inner links + if (params.preventLinks) { + _this.allowLinks = true; + } + if (params.onSlideClick) { + _this.allowSlideClick = true; + } + }, 100); + + var maxPosition = maxWrapperPosition(); + + //Not moved or Prevent Negative Back Sliding/After-End Sliding + if (!_this.isMoved && params.freeMode) { + _this.isMoved = false; + if (params.onTouchEnd) params.onTouchEnd(_this); + _this.callPlugins('onTouchEnd'); + return; + } + if (!_this.isMoved || _this.positions.current > 0 || _this.positions.current < -maxPosition) { + _this.swipeReset(); + if (params.onTouchEnd) params.onTouchEnd(_this); + _this.callPlugins('onTouchEnd'); + return; + } + + _this.isMoved = false; + + //Free Mode + if (params.freeMode) { + if ( params.freeModeFluid ) { + var momentumDuration = 1000*params.momentumRatio; + var momentumDistance = _this.velocity*momentumDuration; + var newPosition = _this.positions.current + momentumDistance + var doBounce = false; + var afterBouncePosition; + var bounceAmount = Math.abs( _this.velocity )*20*params.momentumBounceRatio; + if (newPosition < -maxPosition) { + if (params.momentumBounce && _this.support.transitions) { + if (newPosition + maxPosition < -bounceAmount) newPosition = -maxPosition-bounceAmount; + afterBouncePosition = -maxPosition; + doBounce=true; + allowMomentumBounce = true; + } + else newPosition = -maxPosition; + } + if (newPosition > 0) { + if (params.momentumBounce && _this.support.transitions) { + if (newPosition>bounceAmount) newPosition = bounceAmount; + afterBouncePosition = 0 + doBounce = true; + allowMomentumBounce = true; + } + else newPosition = 0; + } + //Fix duration + if (_this.velocity!=0) momentumDuration = Math.abs((newPosition - _this.positions.current)/_this.velocity) + + _this.setWrapperTranslate(newPosition); + + _this.setWrapperTransition( momentumDuration ); + + if (params.momentumBounce && doBounce) { + _this.wrapperTransitionEnd(function () { + if (!allowMomentumBounce) return; + + if (params.onMomentumBounce) params.onMomentumBounce(_this); + + _this.setWrapperTranslate(afterBouncePosition); + _this.setWrapperTransition(300); + }) + } + + _this.updateActiveSlide(newPosition) + } + if (!params.freeModeFluid || timeDiff >= 300) _this.updateActiveSlide(_this.positions.current) + + if (params.onTouchEnd) params.onTouchEnd(_this) + _this.callPlugins('onTouchEnd'); + return; + } + + //Direction + direction = diff < 0 ? "toNext" : "toPrev" + + //Short Touches + if (direction=="toNext" && ( timeDiff <= 300 ) ) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + else _this.swipeNext(true); + } + + if (direction=="toPrev" && ( timeDiff <= 300 ) ) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + else _this.swipePrev(true); + } + + //Long Touches + var targetSlideSize = 0; + if(params.slidesPerView == 'auto') { + //Define current slide's width + var currentPosition = Math.abs(_this.getWrapperTranslate()); + var slidesOffset = 0; + var _slideSize; + for (var i=0; i<_this.slides.length; i++) { + _slideSize = isH ? _this.slides[i].getWidth(true) : _this.slides[i].getHeight(true); + slidesOffset+= _slideSize; + if (slidesOffset>currentPosition) { + targetSlideSize = _slideSize; + break; + } + } + if (targetSlideSize>containerSize) targetSlideSize = containerSize; + } + else { + targetSlideSize = slideSize * params.slidesPerView; + } + if (direction=="toNext" && ( timeDiff > 300 ) ) { + if (diffAbs >= targetSlideSize*0.5) { + _this.swipeNext(true) + } + else { + _this.swipeReset() + } + } + if (direction=="toPrev" && ( timeDiff > 300 ) ) { + if (diffAbs >= targetSlideSize*0.5) { + _this.swipePrev(true); + } + else { + _this.swipeReset() + } + } + if (params.onTouchEnd) params.onTouchEnd(_this) + _this.callPlugins('onTouchEnd'); + } + + + /*================================================== + noSwiping Bubble Check by Isaac Strack + ====================================================*/ + function noSwipingSlide(el){ + /*This function is specifically designed to check the parent elements for the noSwiping class, up to the wrapper. + We need to check parents because while onTouchStart bubbles, _this.isTouched is checked in onTouchStart, which stops the bubbling. + So, if a text box, for example, is the initial target, and the parent slide container has the noSwiping class, the _this.isTouched + check will never find it, and what was supposed to be noSwiping is able to be swiped. + This function will iterate up and check for the noSwiping class in parents, up through the wrapperClass.*/ + + // First we create a truthy variable, which is that swiping is allowd (noSwiping = false) + var noSwiping = false; + + // Now we iterate up (parentElements) until we reach the node with the wrapperClass. + do{ + + // Each time, we check to see if there's a 'swiper-no-swiping' class (noSwipingClass). + if (el.className.indexOf(params.noSwipingClass)>-1) + { + noSwiping = true; // If there is, we set noSwiping = true; + } + + el = el.parentElement; // now we iterate up (parent node) + + } while(!noSwiping && el.parentElement && el.className.indexOf(params.wrapperClass)==-1); // also include el.parentElement truthy, just in case. + + // because we didn't check the wrapper itself, we do so now, if noSwiping is false: + if (!noSwiping && el.className.indexOf(params.wrapperClass)>-1 && el.className.indexOf(params.noSwipingClass)>-1) + noSwiping = true; // if the wrapper has the noSwipingClass, we set noSwiping = true; + + return noSwiping; + } + + /*================================================== + Swipe Functions + ====================================================*/ + _this.swipeNext = function(internal){ + if (!internal && params.loop) _this.fixLoop(); + if (!internal && params.autoplay) _this.stopAutoplay(true); + _this.callPlugins('onSwipeNext'); + var currentPosition = _this.getWrapperTranslate(); + var newPosition = currentPosition; + if (params.slidesPerView=='auto') { + for (var i=0; i<_this.snapGrid.length; i++) { + if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + newPosition = -_this.snapGrid[i+1] + break; + } + } + } + else { + var groupSize = slideSize * params.slidesPerGroup; + newPosition = -(Math.floor(Math.abs(currentPosition)/Math.floor(groupSize))*groupSize + groupSize); + } + if (newPosition < - maxWrapperPosition()) { + newPosition = - maxWrapperPosition() + }; + + if (newPosition == currentPosition) return false; + + swipeToPosition(newPosition, 'next'); + return true + } + _this.swipePrev = function(internal){ + if (!internal && params.loop) _this.fixLoop(); + if (!internal && params.autoplay) _this.stopAutoplay(true); + _this.callPlugins('onSwipePrev'); + + var currentPosition = Math.ceil(_this.getWrapperTranslate()); + var newPosition; + if (params.slidesPerView=='auto') { + newPosition = 0; + for (var i=1; i<_this.snapGrid.length; i++) { + if (-currentPosition == _this.snapGrid[i]) { + newPosition = -_this.snapGrid[i-1] + break; + } + if (-currentPosition > _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + newPosition = -_this.snapGrid[i] + break; + } + } + } + else { + var groupSize = slideSize * params.slidesPerGroup; + newPosition = -(Math.ceil(-currentPosition/groupSize)-1)*groupSize; + } + + if (newPosition > 0) newPosition = 0; + + if (newPosition == currentPosition) return false; + swipeToPosition(newPosition, 'prev'); + return true; + + } + _this.swipeReset = function(){ + _this.callPlugins('onSwipeReset'); + var currentPosition = _this.getWrapperTranslate(); + var groupSize = slideSize * params.slidesPerGroup; + var newPosition; + var maxPosition = -maxWrapperPosition(); + if (params.slidesPerView=='auto') { + newPosition = 0; + for (var i=0; i<_this.snapGrid.length; i++) { + if (-currentPosition===_this.snapGrid[i]) return; + if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + if(_this.positions.diff>0) newPosition = -_this.snapGrid[i+1] + else newPosition = -_this.snapGrid[i] + break; + } + } + if (-currentPosition >= _this.snapGrid[_this.snapGrid.length-1]) newPosition = -_this.snapGrid[_this.snapGrid.length-1]; + if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition() + } + else { + newPosition = currentPosition<0 ? Math.round(currentPosition/groupSize)*groupSize : 0 + } + if (params.scrollContainer) { + newPosition = currentPosition<0 ? currentPosition : 0; + } + if (newPosition < -maxWrapperPosition()) { + newPosition = -maxWrapperPosition() + } + if (params.scrollContainer && (containerSize>slideSize)) { + newPosition = 0; + } + + if (newPosition == currentPosition) return false; + + swipeToPosition(newPosition, 'reset'); + return true; + } + + _this.swipeTo = function(index, speed, runCallbacks) { + index = parseInt(index, 10); + _this.callPlugins('onSwipeTo', {index:index, speed:speed}); + if (params.loop) index = index + _this.loopedSlides; + var currentPosition = _this.getWrapperTranslate(); + if (index > (_this.slides.length-1) || index < 0) return; + var newPosition + if (params.slidesPerView=='auto') { + newPosition = -_this.slidesGrid[ index ]; + } + else { + newPosition = -index*slideSize; + } + if (newPosition < - maxWrapperPosition()) { + newPosition = - maxWrapperPosition(); + }; + + if (newPosition == currentPosition) return false; + + runCallbacks = runCallbacks===false ? false : true; + swipeToPosition(newPosition, 'to', {index:index, speed:speed, runCallbacks:runCallbacks}); + return true; + } + + function swipeToPosition(newPosition, action, toOptions) { + var speed = (action=='to' && toOptions.speed >= 0) ? toOptions.speed : params.speed; + + if (_this.support.transitions || !params.DOMAnimation) { + _this.setWrapperTranslate(newPosition); + _this.setWrapperTransition(speed); + } + else { + //Try the DOM animation + var currentPosition = _this.getWrapperTranslate(); + var animationStep = Math.ceil( (newPosition - currentPosition)/speed*(1000/60) ); + var direction = currentPosition > newPosition ? 'toNext' : 'toPrev'; + var condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; + if (_this._DOMAnimating) return; + + anim(); + } + function anim(){ + currentPosition += animationStep; + condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; + if (condition) { + _this.setWrapperTranslate(Math.round(currentPosition)); + _this._DOMAnimating = true + window.setTimeout(function(){ + anim() + }, 1000 / 60) + } + else { + if (params.onSlideChangeEnd) params.onSlideChangeEnd(_this); + _this.setWrapperTranslate(newPosition); + _this._DOMAnimating = false; + } + } + + //Update Active Slide Index + _this.updateActiveSlide(newPosition); + + //Callbacks + if (params.onSlideNext && action=='next') { + params.onSlideNext(_this, newPosition); + } + if (params.onSlidePrev && action=='prev') { + params.onSlidePrev(_this, newPosition); + } + //"Reset" Callback + if (params.onSlideReset && action=='reset') { + params.onSlideReset(_this, newPosition); + } + + //"Next", "Prev" and "To" Callbacks + if (action=='next' || action=='prev' || (action=='to' && toOptions.runCallbacks==true)) + slideChangeCallbacks(); + } + /*================================================== + Transition Callbacks + ====================================================*/ + //Prevent Multiple Callbacks + _this._queueStartCallbacks = false; + _this._queueEndCallbacks = false; + function slideChangeCallbacks() { + //Transition Start Callback + _this.callPlugins('onSlideChangeStart'); + if (params.onSlideChangeStart) { + if (params.queueStartCallbacks && _this.support.transitions) { + if (_this._queueStartCallbacks) return; + _this._queueStartCallbacks = true; + params.onSlideChangeStart(_this) + _this.wrapperTransitionEnd(function(){ + _this._queueStartCallbacks = false; + }) + } + else params.onSlideChangeStart(_this) + } + //Transition End Callback + if (params.onSlideChangeEnd) { + if (_this.support.transitions) { + if (params.queueEndCallbacks) { + if (_this._queueEndCallbacks) return; + _this._queueEndCallbacks = true; + _this.wrapperTransitionEnd(params.onSlideChangeEnd) + } + else _this.wrapperTransitionEnd(params.onSlideChangeEnd) + } + else { + if (!params.DOMAnimation) { + setTimeout(function(){ + params.onSlideChangeEnd(_this) + },10) + } + } + } + } + + /*================================================== + Update Active Slide Index + ====================================================*/ + _this.updateActiveSlide = function(position) { + if (!_this.initialized) return; + if (_this.slides.length==0) return; + _this.previousIndex = _this.activeIndex; + if (typeof position=='undefined') position = _this.getWrapperTranslate(); + if (position>0) position=0; + + if (params.slidesPerView == 'auto') { + var slidesOffset = 0; + _this.activeIndex = _this.slidesGrid.indexOf(-position); + if (_this.activeIndex<0) { + for (var i=0; i<_this.slidesGrid.length-1; i++) { + if (-position>_this.slidesGrid[i] && -position<_this.slidesGrid[i+1]) { + break; + } + } + var leftDistance = Math.abs( _this.slidesGrid[i] + position ) + var rightDistance = Math.abs( _this.slidesGrid[i+1] + position ) + if (leftDistance<=rightDistance) _this.activeIndex = i; + else _this.activeIndex = i+1; + } + } + else { + _this.activeIndex = Math[params.visibilityFullFit ? 'ceil' : 'round']( -position/slideSize ); + } + + if (_this.activeIndex == _this.slides.length ) _this.activeIndex = _this.slides.length - 1; + if (_this.activeIndex < 0) _this.activeIndex = 0; + + // Check for slide + if (!_this.slides[_this.activeIndex]) return; + + // Calc Visible slides + _this.calcVisibleSlides(position); + + // Mark visible and active slides with additonal classes + var activeClassRegexp = new RegExp( "\\s*" + params.slideActiveClass ); + var inViewClassRegexp = new RegExp( "\\s*" + params.slideVisibleClass ); + + for (var i = 0; i < _this.slides.length; i++) { + _this.slides[ i ].className = _this.slides[ i ].className.replace( activeClassRegexp, '' ).replace( inViewClassRegexp, '' ); + if ( _this.visibleSlides.indexOf( _this.slides[ i ] )>=0 ) { + _this.slides[ i ].className += ' ' + params.slideVisibleClass; + } + + } + _this.slides[ _this.activeIndex ].className += ' ' + params.slideActiveClass; + + //Update loop index + if (params.loop) { + var ls = _this.loopedSlides; + _this.activeLoopIndex = _this.activeIndex - ls; + if (_this.activeLoopIndex >= _this.slides.length - ls*2 ) { + _this.activeLoopIndex = _this.slides.length - ls*2 - _this.activeLoopIndex; + } + if (_this.activeLoopIndex<0) { + _this.activeLoopIndex = _this.slides.length - ls*2 + _this.activeLoopIndex; + } + } + else { + _this.activeLoopIndex = _this.activeIndex; + } + //Update Pagination + if (params.pagination) { + _this.updatePagination(position); + } + } + /*================================================== + Pagination + ====================================================*/ + _this.createPagination = function (firstInit) { + if (params.paginationClickable && _this.paginationButtons) { + removePaginationEvents(); + } + _this.paginationContainer = params.pagination.nodeType ? params.pagination : $$(params.pagination)[0]; + if (params.createPagination) { + var paginationHTML = ""; + var numOfSlides = _this.slides.length; + var numOfButtons = numOfSlides; + if (params.loop) numOfButtons -= _this.loopedSlides*2 + for (var i = 0; i < numOfButtons; i++) { + paginationHTML += '<'+params.paginationElement+' class="'+params.paginationElementClass+'">' + } + _this.paginationContainer.innerHTML = paginationHTML; + } + _this.paginationButtons = $$('.'+params.paginationElementClass, _this.paginationContainer); + if (!firstInit) _this.updatePagination() + _this.callPlugins('onCreatePagination'); + if (params.paginationClickable) { + addPaginationEvents(); + } + } + function removePaginationEvents() { + var pagers = _this.paginationButtons; + for (var i=0; i=_this.slides.length-_this.loopedSlides*2) { + visIndex = _this.slides.length - _this.loopedSlides*2 - visIndex; + visIndex = Math.abs(visIndex) + } + visibleIndexes.push( visIndex ) + } + + for (i=0; i0) position = position+_this.wrapperLeft; + if (!isH && _this.wrapperTop>0) position = position+_this.wrapperTop; + + for (var i=0; i<_this.slides.length; i++) { + _slideLeft += _slideSize; + if (params.slidesPerView == 'auto') + _slideSize = isH ? _this.h.getWidth(_this.slides[i],true) : _this.h.getHeight(_this.slides[i],true); + else _slideSize = slideSize; + + _slideRight = _slideLeft + _slideSize; + var isVisibile = false; + if (params.visibilityFullFit) { + if (_slideLeft >= -position && _slideRight <= -position+containerSize) isVisibile = true; + if (_slideLeft <= -position && _slideRight >= -position+containerSize) isVisibile = true; + } + else { + + if (_slideRight > -position && _slideRight <= ((-position+containerSize))) isVisibile = true; + if (_slideLeft >= -position && _slideLeft < ((-position+containerSize))) isVisibile = true; + if (_slideLeft < -position && _slideRight > ((-position+containerSize))) isVisibile = true; + } + + if (isVisibile) visibleSlides.push(_this.slides[i]) + + } + if (visibleSlides.length==0) visibleSlides = [ _this.slides[ _this.activeIndex ] ] + + _this.visibleSlides = visibleSlides; + } + + /*========================================== + Autoplay + ============================================*/ + _this.autoPlayIntervalId = undefined; + _this.startAutoplay = function () { + if (typeof _this.autoPlayIntervalId !== 'undefined') return false; + if (!params.autoplay) return; + _this.autoPlayIntervalId = setInterval(function(){ + if (params.loop) _this.swipeNext(); + else if (!_this.swipeNext(true)) _this.swipeTo(0); + }, params.autoplay) + _this.callPlugins('onAutoplayStart'); + } + _this.stopAutoplay = function () { + if (_this.autoPlayIntervalId) clearInterval(_this.autoPlayIntervalId); + _this.autoPlayIntervalId = undefined; + _this.callPlugins('onAutoplayStop'); + } + /*================================================== + Loop + ====================================================*/ + _this.loopCreated = false; + _this.removeLoopedSlides = function(){ + if (_this.loopCreated) { + for (var i=0; i<_this.slides.length; i++) { + if (_this.slides[i].getData('looped')===true) _this.wrapper.removeChild(_this.slides[i]); + } + } + } + + _this.createLoop = function() { + if (_this.slides.length==0) return; + if (params.slidesPerView=='auto') { + _this.loopedSlides = params.loopedSlides; + } + else { + _this.loopedSlides = params.slidesPerView + params.loopAdditionalSlides; + } + + if (_this.loopedSlides > _this.slides.length) { + _this.loopedSlides = _this.slides.length; + } + + var slideFirstHTML = '', + slideLastHTML = '', + i; + var slidesSetFullHTML = ''; + /** + loopedSlides is too large if loopAdditionalSlides are set. + Need to divide the slides by maximum number of slides existing. + + @author Tomaz Lovrec + */ + var numSlides = _this.slides.length; + var fullSlideSets = Math.floor(_this.loopedSlides / numSlides); + var remainderSlides = _this.loopedSlides % numSlides; + // assemble full sets of slides + for (i = 0; i<(fullSlideSets*numSlides);i++) { + var j = i; + if (i >= numSlides) { + var over = Math.floor(i / numSlides); + j = i - (numSlides * over); + } + slidesSetFullHTML+=_this.slides[j].outerHTML; + } + // assemble remainder slides + // assemble remainder appended to existing slides + for(i = 0;i=_this.slides.length-_this.loopedSlides) _this.slides[i].setData('looped', true); + } + _this.callPlugins('onCreateLoop'); + + } + + _this.fixLoop = function() { + var newIndex; + //Fix For Negative Oversliding + if (_this.activeIndex < _this.loopedSlides) { + newIndex = _this.slides.length - _this.loopedSlides*3 + _this.activeIndex; + _this.swipeTo(newIndex, 0, false); + } + //Fix For Positive Oversliding + else if (_this.activeIndex > _this.slides.length - params.slidesPerView*2) { + newIndex = -_this.slides.length + _this.activeIndex + _this.loopedSlides + _this.swipeTo(newIndex, 0, false); + } + } + + /*================================================== + Slides Loader + ====================================================*/ + _this.loadSlides = function(){ + var slidesHTML = ''; + _this.activeLoaderIndex = 0; + var slides = params.loader.slides; + var slidesToLoad = params.loader.loadAllSlides ? slides.length : params.slidesPerView*(1+params.loader.surroundGroups); + for (var i=0; i< slidesToLoad; i++) { + if (params.loader.slidesHTMLType=='outer') slidesHTML+=slides[i]; + else { + slidesHTML+='<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + } + } + _this.wrapper.innerHTML = slidesHTML; + _this.calcSlides(true); + //Add permanent transitionEnd callback + if (!params.loader.loadAllSlides) { + _this.wrapperTransitionEnd(_this.reloadSlides, true); + } + } + + _this.reloadSlides = function(){ + var slides = params.loader.slides; + var newActiveIndex = parseInt(_this.activeSlide().data('swiperindex'),10) + if (newActiveIndex<0 || newActiveIndex>slides.length-1) return //<-- Exit + _this.activeLoaderIndex = newActiveIndex; + var firstIndex = Math.max(0, newActiveIndex - params.slidesPerView*params.loader.surroundGroups) + var lastIndex = Math.min(newActiveIndex+params.slidesPerView*(1+params.loader.surroundGroups)-1, slides.length-1) + //Update Transforms + if (newActiveIndex>0) { + var newTransform = -slideSize*(newActiveIndex-firstIndex) + _this.setWrapperTranslate(newTransform); + _this.setWrapperTransition(0); + } + //New Slides + if (params.loader.logic==='reload') { + _this.wrapper.innerHTML = ''; + var slidesHTML = ''; + for (var i = firstIndex; i<=lastIndex; i++) { + slidesHTML += params.loader.slidesHTMLType == 'outer' ? slides[i] : '<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + } + _this.wrapper.innerHTML = slidesHTML; + } + else { + var minExistIndex=1000; + var maxExistIndex=0; + for (var i=0; i<_this.slides.length; i++) { + var index = _this.slides[i].data('swiperindex'); + if (indexlastIndex) { + _this.wrapper.removeChild(_this.slides[i]); + } + else { + minExistIndex = Math.min(index, minExistIndex) + maxExistIndex = Math.max(index, maxExistIndex) + } + } + for (var i=firstIndex; i<=lastIndex; i++) { + if (imaxExistIndex) { + var newSlide = document.createElement(params.slideElement); + newSlide.className = params.slideClass; + newSlide.setAttribute('data-swiperindex',i); + newSlide.innerHTML = slides[i]; + _this.wrapper.appendChild(newSlide); + } + } + } + //reInit + _this.reInit(true); + } + + /*================================================== + Make Swiper + ====================================================*/ + function makeSwiper(){ + _this.calcSlides(); + if (params.loader.slides.length>0 && _this.slides.length==0) { + _this.loadSlides(); + } + if (params.loop) { + _this.createLoop(); + } + _this.init(); + initEvents(); + if (params.pagination) { + _this.createPagination(true); + } + + if (params.loop || params.initialSlide>0) { + _this.swipeTo( params.initialSlide, 0, false ); + } + else { + _this.updateActiveSlide(0); + } + if (params.autoplay) { + _this.startAutoplay(); + } + /** + * Set center slide index. + * + * @author Tomaz Lovrec + */ + _this.centerIndex = _this.activeIndex; + + // Callbacks + if (params.onSwiperCreated) params.onSwiperCreated(this); + _this.callPlugins('onSwiperCreated'); + } + + makeSwiper(); +} + +Swiper.prototype = { + plugins : {}, + + /*================================================== + Wrapper Operations + ====================================================*/ + wrapperTransitionEnd : function(callback, permanent) { + var a = this, + el = a.wrapper, + events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'], + i; + + function fireCallBack() { + callback(a); + if (a.params.queueEndCallbacks) a._queueEndCallbacks = false; + if (!permanent) { + for (i=0; i0) { + returnWidth = el.offsetWidth - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')); + } + if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')) + + return returnWidth; + }, + getHeight: function(el, outer) { + if (outer) return el.offsetHeight; + + var height = window.getComputedStyle(el, null).getPropertyValue('height') + var returnHeight = parseFloat(height); + //IE Fixes + if(isNaN(returnHeight) || height.indexOf('%')>0) { + returnHeight = el.offsetHeight - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')); + } + if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')) + return returnHeight; + }, + getOffset: function(el) { + var box = el.getBoundingClientRect(); + var body = document.body; + var clientTop = el.clientTop || body.clientTop || 0; + var clientLeft = el.clientLeft || body.clientLeft || 0; + var scrollTop = window.pageYOffset || el.scrollTop; + var scrollLeft = window.pageXOffset || el.scrollLeft; + if (document.documentElement && !window.pageYOffset) { + //IE7-8 + scrollTop = document.documentElement.scrollTop; + scrollLeft = document.documentElement.scrollLeft; + } + return { + top: box.top + scrollTop - clientTop, + left: box.left + scrollLeft - clientLeft + }; + }, + windowWidth : function() { + if (window.innerWidth) return window.innerWidth + else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; + }, + windowHeight : function() { + if (window.innerHeight) return window.innerHeight + else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; + }, + windowScroll : function() { + var left=0, top=0; + if (typeof pageYOffset != 'undefined') { + return { + left: window.pageXOffset, + top: window.pageYOffset + } + } + else if (document.documentElement) { + return { + left: document.documentElement.scrollLeft, + top: document.documentElement.scrollTop + } + } + }, + + addEventListener : function (el, event, listener, useCapture) { + if (typeof useCapture == 'undefined') { + useCapture = false; + } + + if (el.addEventListener) { + el.addEventListener(event, listener, useCapture); + } + else if (el.attachEvent) { + el.attachEvent('on' + event, listener); + } + }, + + removeEventListener : function (el, event, listener, useCapture) { + if (typeof useCapture == 'undefined') { + useCapture = false; + } + + if (el.removeEventListener) { + el.removeEventListener(event, listener, useCapture); + } + else if (el.detachEvent) { + el.detachEvent('on' + event, listener); + } + } + }, + setTransform : function (el, transform) { + var es = el.style + es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transform + }, + setTranslate : function (el, translate) { + var es = el.style + var pos = { + x : translate.x || 0, + y : translate.y || 0, + z : translate.z || 0 + }; + var transformString = this.support.transforms3d ? 'translate3d('+(pos.x)+'px,'+(pos.y)+'px,'+(pos.z)+'px)' : 'translate('+(pos.x)+'px,'+(pos.y)+'px)'; + es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transformString; + if (!this.support.transforms) { + es.left = pos.x+'px' + es.top = pos.y+'px' + } + }, + setTransition : function (el, duration) { + var es = el.style + es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = duration+'ms'; + }, + /*================================================== + Feature Detection + ====================================================*/ + support: { + + touch : (window.Modernizr && Modernizr.touch===true) || (function() { + return !!(("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch); + })(), + + transforms3d : (window.Modernizr && Modernizr.csstransforms3d===true) || (function() { + var div = document.createElement('div').style; + return ("webkitPerspective" in div || "MozPerspective" in div || "OPerspective" in div || "MsPerspective" in div || "perspective" in div); + })(), + + transforms : (window.Modernizr && Modernizr.csstransforms===true) || (function(){ + var div = document.createElement('div').style; + return ('transform' in div || 'WebkitTransform' in div || 'MozTransform' in div || 'msTransform' in div || 'MsTransform' in div || 'OTransform' in div); + })(), + + transitions : (window.Modernizr && Modernizr.csstransitions===true) || (function(){ + var div = document.createElement('div').style; + return ('transition' in div || 'WebkitTransition' in div || 'MozTransition' in div || 'msTransition' in div || 'MsTransition' in div || 'OTransition' in div); + })() + }, + + browser : { + + ie8 : (function(){ + var rv = -1; // Return value assumes failure. + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent; + var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv != -1 && rv < 9; + })(), + + ie10 : window.navigator.msPointerEnabled + } +} + +/*========================= + jQuery & Zepto Plugins + ===========================*/ +if (window.jQuery||window.Zepto) { + (function($){ + $.fn.swiper = function(params) { + var s = new Swiper($(this)[0], params) + $(this).data('swiper',s); + return s; + } + })(window.jQuery||window.Zepto) +} + +// component +if ( typeof( module ) !== 'undefined' ) +{ + module.exports = Swiper; +} diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery-animate-css-rotate-scale.js b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery-animate-css-rotate-scale.js new file mode 100644 index 0000000..cb81071 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery-animate-css-rotate-scale.js @@ -0,0 +1,149 @@ +/*! +/** + * Monkey patch jQuery 1.3.1+ to add support for setting or animating CSS + * scale and rotation independently. + * https://github.com/zachstronaut/jquery-animate-css-rotate-scale + * Released under dual MIT/GPL license just like jQuery. + * 2009-2012 Zachary Johnson www.zachstronaut.com + */ +(function ($) { + // Updated 2010.11.06 + // Updated 2012.10.13 - Firefox 16 transform style returns a matrix rather than a string of transform functions. This broke the features of this jQuery patch in Firefox 16. It should be possible to parse the matrix for both scale and rotate (especially when scale is the same for both the X and Y axis), however the matrix does have disadvantages such as using its own units and also 45deg being indistinguishable from 45+360deg. To get around these issues, this patch tracks internally the scale, rotation, and rotation units for any elements that are .scale()'ed, .rotate()'ed, or animated. The major consequences of this are that 1. the scaled/rotated element will blow away any other transform rules applied to the same element (such as skew or translate), and 2. the scaled/rotated element is unaware of any preset scale or rotation initally set by page CSS rules. You will have to explicitly set the starting scale/rotation value. + + function initData($el) { + var _ARS_data = $el.data('_ARS_data'); + if (!_ARS_data) { + _ARS_data = { + rotateUnits: 'deg', + scalex: 1, + scaley: 1, + rotate: 0 + }; + + $el.data('_ARS_data', _ARS_data); + } + + return _ARS_data; + } + + function setTransform($el, data) { + $el.css('transform', 'rotate(' + data.rotate + data.rotateUnits + ') scalex(' + data.scalex + ') scaley(' + data.scaley + ')'); + } + + $.fn.rotate = function (val) { + var $self = $(this), m, data = initData($self); + + if (typeof val == 'undefined') { + return data.rotate + data.rotateUnits; + } + + m = val.toString().match(/^(-?\d+(\.\d+)?)(.+)?$/); + if (m) { + if (m[3]) { + data.rotateUnits = m[3]; + } + + data.rotate = m[1]; + + setTransform($self, data); + } + + return this; + }; + + // Note that scale is unitless. + $.fn.scalex = function (val) { + var $self = $(this), data = initData($self); + + if (typeof val == 'undefined') { + return data.scalex; + } + + data.scalex = val; + + setTransform($self, data); + + return this; + }; + + $.fn.scaley = function (val) { + var $self = $(this), data = initData($self); + + if (typeof val == 'undefined') { + return data.scaley; + } + + data.scaley = val; + + setTransform($self, data); + + return this; + }; + + // fx.cur() must be monkey patched because otherwise it would always + // return 0 for current rotate and scale values + var curProxied = $.fx.prototype.cur; + $.fx.prototype.cur = function () { + if (this.prop == 'rotate') { + return parseFloat($(this.elem).rotate()); + + } else if (this.prop == 'scalex') { + return parseFloat($(this.elem).scalex()); + } else if (this.prop == 'scaley') { + return parseFloat($(this.elem).scaley()); + } + + return curProxied.apply(this, arguments); + }; + + $.fx.step.rotate = function (fx) { + var data = initData($(fx.elem)); + $(fx.elem).rotate(fx.now + data.rotateUnits); + }; + + $.fx.step.scalex = function (fx) { + $(fx.elem).scalex(fx.now); + }; + $.fx.step.scaley = function (fx) { + $(fx.elem).scaley(fx.now); + }; + + + /* + + Starting on line 3905 of jquery-1.3.2.js we have this code: + + // We need to compute starting value + if ( unit != "px" ) { + self.style[ name ] = (end || 1) + unit; + start = ((end || 1) / e.cur(true)) * start; + self.style[ name ] = start + unit; + } + + This creates a problem where we cannot give units to our custom animation + because if we do then this code will execute and because self.style[name] + does not exist where name is our custom animation's name then e.cur(true) + will likely return zero and create a divide by zero bug which will set + start to NaN. + + The following monkey patch for animate() gets around this by storing the + units used in the rotation definition and then stripping the units off. + + */ + + var animateProxied = $.fn.animate; + $.fn.animate = function (prop) { + if (typeof prop['rotate'] != 'undefined') { + var $self, data, m = prop['rotate'].toString().match(/^(([+-]=)?(-?\d+(\.\d+)?))(.+)?$/); + if (m && m[5]) { + $self = $(this); + data = initData($self); + data.rotateUnits = m[5]; + } + + prop['rotate'] = m[1]; + } + + return animateProxied.apply(this, arguments); + }; +})(jQuery); \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery-css-transform.js b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery-css-transform.js new file mode 100644 index 0000000..70a40f2 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery-css-transform.js @@ -0,0 +1,112 @@ +(function ($) { + // Monkey patch jQuery 1.3.1+ css() method to support CSS 'transform' + // property uniformly across Safari/Chrome/Webkit, Firefox 3.5+, IE 9+, and Opera 11+. + // 2009-2011 Zachary Johnson www.zachstronaut.com + // Updated 2011.05.04 (May the fourth be with you!) + function getTransformProperty(element) + { + // Try transform first for forward compatibility + // In some versions of IE9, it is critical for msTransform to be in + // this list before MozTranform. + var properties = ['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform']; + var p; + while (p = properties.shift()) + { + if (typeof element.style[p] != 'undefined') + { + return p; + } + } + + // Default to transform also + return 'transform'; + } + + var _propsObj = null; + + var proxied = $.fn.css; + $.fn.css = function (arg, val) + { + // Temporary solution for current 1.6.x incompatibility, while + // preserving 1.3.x compatibility, until I can rewrite using CSS Hooks + if (_propsObj === null) + { + if (typeof $.cssProps != 'undefined') + { + _propsObj = $.cssProps; + } + else if (typeof $.props != 'undefined') + { + _propsObj = $.props; + } + else + { + _propsObj = {} + } + } + + // Find the correct browser specific property and setup the mapping using + // $.props which is used internally by jQuery.attr() when setting CSS + // properties via either the css(name, value) or css(properties) method. + // The problem with doing this once outside of css() method is that you + // need a DOM node to find the right CSS property, and there is some risk + // that somebody would call the css() method before body has loaded or any + // DOM-is-ready events have fired. + if + ( + typeof _propsObj['transform'] == 'undefined' + && + ( + arg == 'transform' + || + ( + typeof arg == 'object' + && typeof arg['transform'] != 'undefined' + ) + ) + ) + { + _propsObj['transform'] = getTransformProperty(this.get(0)); + } + + // We force the property mapping here because jQuery.attr() does + // property mapping with jQuery.props when setting a CSS property, + // but curCSS() does *not* do property mapping when *getting* a + // CSS property. (It probably should since it manually does it + // for 'float' now anyway... but that'd require more testing.) + // + // But, only do the forced mapping if the correct CSS property + // is not 'transform' and is something else. + if (_propsObj['transform'] != 'transform') + { + // Call in form of css('transform' ...) + if (arg == 'transform') + { + arg = _propsObj['transform']; + + // User wants to GET the transform CSS, and in jQuery 1.4.3 + // calls to css() for transforms return a matrix rather than + // the actual string specified by the user... avoid that + // behavior and return the string by calling jQuery.style() + // directly + if (typeof val == 'undefined' && jQuery.style) + { + return jQuery.style(this.get(0), arg); + } + } + + // Call in form of css({'transform': ...}) + else if + ( + typeof arg == 'object' + && typeof arg['transform'] != 'undefined' + ) + { + arg[_propsObj['transform']] = arg['transform']; + delete arg['transform']; + } + } + + return proxied.apply(this, arguments); + }; +})(jQuery); \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery.easie-min.js b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery.easie-min.js new file mode 100755 index 0000000..797a892 --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery.easie-min.js @@ -0,0 +1 @@ +(function(a){"use strict";var b="easie",c="Ease",d=b+c+"In",e=b+c+"Out",f=b+c+"InOut",g=["Quad","Cubic","Quart","Quint","Sine","Expo","Circ"];a.easie=function(c,d,e,f,g,h){g=g||[b,c,d,e,f].join("-");if(!a.easing[g]||h){var k=i(function(a){return j(a,c,d,e,f,5)});a.easing[g]=function(a,b,c,d){return k.call(null,a)},a.easing[g].params=[c,d,e,f]}return g};var h=a.easie;h(0,0,1,1,b+"Linear"),h(.25,.1,.25,1,b+c),h(.42,0,1,1,d),h(0,0,.58,1,e),h(.42,0,.58,1,f),h(.55,.085,.68,.53,d+g[0]),h(.55,.055,.675,.19,d+g[1]),h(.895,.03,.685,.22,d+g[2]),h(.755,.05,.855,.06,d+g[3]),h(.47,0,.745,.715,d+g[4]),h(.95,.05,.795,.035,d+g[5]),h(.6,.04,.98,.335,d+g[6]),h(.25,.46,.45,.94,e+g[0]),h(.215,.61,.355,1,e+g[1]),h(.165,.84,.44,1,e+g[2]),h(.23,1,.32,1,e+g[3]),h(.39,.575,.565,1,e+g[4]),h(.19,1,.22,1,e+g[5]),h(.075,.82,.165,1,e+g[6]),h(.455,.03,.515,.955,f+g[0]),h(.645,.045,.355,1,f+g[1]),h(.77,0,.175,1,f+g[2]),h(.86,0,.07,1,f+g[3]),h(.445,.05,.55,.95,f+g[4]),h(1,0,0,1,f+g[5]),h(.785,.135,.15,.86,f+g[6]);function i(a,b){var c;b=b||101;var d=[];for(c=0;c=0?a:0-a}for(e=a,h=0;h<8;h++){f=m(e)-a;if(i(f)d)return d;while(cf?c=e:d=e,e=(d-c)*.5+c}return e}i=3*b,h=3*(d-b)-i,g=1-i-h,l=3*c,k=3*(e-c)-l,j=1-l-k;return q(a,p(f))}})(jQuery) \ No newline at end of file diff --git a/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery.js b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery.js new file mode 100755 index 0000000..ab8929e --- /dev/null +++ b/Samples/1-basic_component/packaged/PubCoder/ImageGallery/PubCoderImageGallery/js/jquery.js @@ -0,0 +1,9267 @@ +/*! + * jQuery JavaScript Library v1.7.1 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Nov 21 21:11:03 2011 -0500 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context ? context.ownerDocument || context : document ); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.7.1", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.add( fn ); + + return this; + }, + + eq: function( i ) { + i = +i; + return i === -1 ? + this.slice( i ) : + this.slice( i, i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.fireWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).off( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery.Callbacks( "once memory" ); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array, i ) { + var len; + + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } + + len = array.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in array && array[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return ( new Date() ).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +return jQuery; + +})(); + + +// String to Object flags format cache +var flagsCache = {}; + +// Convert String-formatted flags into Object-formatted ones and store in cache +function createFlags( flags ) { + var object = flagsCache[ flags ] = {}, + i, length; + flags = flags.split( /\s+/ ); + for ( i = 0, length = flags.length; i < length; i++ ) { + object[ flags[i] ] = true; + } + return object; +} + +/* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * the callback list behaves + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible flags: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + var // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = [], + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Add one or several callbacks to the list + add = function( args ) { + var i, + length, + elem, + type, + actual; + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + // Inspect recursively + add( elem ); + } else if ( type === "function" ) { + // Add if not in unique mode and callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // firing was halted (stopOnFalse) + } else if ( memory && memory !== true ) { + firingStart = length; + fire( memory[ 0 ], memory[ 1 ] ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + var args = arguments, + argIndex = 0, + argLength = args.length; + for ( ; argIndex < argLength ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + break; + } + } + } + } + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + if ( list ) { + var i = 0, + length = list.length; + for ( ; i < length; i++ ) { + if ( fn === list[ i ] ) { + return true; + } + } + } + return false; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory || memory === true ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } else if ( !( flags.once && memory ) ) { + fire( context, args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!memory; + } + }; + + return self; +}; + + + + +var // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + + Deferred: function( func ) { + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList + }, + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + return this; + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; + } + } + return obj; + } + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = sliceDeferred.call( arguments, 0 ), + i = 0, + length = args.length, + pValues = new Array( length ), + count = length, + pCount = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(), + promise = deferred.promise(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + deferred.resolveWith( deferred, args ); + } + }; + } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } + if ( length > 1 ) { + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return promise; + } +}); + + + + +jQuery.support = (function() { + + var support, + all, + a, + select, + opt, + input, + marginDiv, + fragment, + tds, + events, + eventName, + i, + isSupported, + div = document.createElement( "div" ), + documentElement = document.documentElement; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
a"; + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute("href") === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + fragment.removeChild( input ); + fragment.appendChild( div ); + + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( window.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.style.width = "2px"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + }) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + fragment.removeChild( div ); + + // Null elements to avoid leaks in IE + fragment = select = opt = marginDiv = div = input = null; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + conMarginTop, ptlm, vb, style, html, + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + conMarginTop = 1; + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"; + vb = "visibility:hidden;border:0;"; + style = "style='" + ptlm + "border:5px solid #000;padding:0;'"; + html = "
" + + "" + + "
"; + + container = document.createElement("div"); + container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct the test element + div = document.createElement("div"); + container.appendChild( div ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = "
t
"; + tds = div.getElementsByTagName( "td" ); + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE <= 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + + // Figure out if the W3C box model works as expected + div.innerHTML = ""; + div.style.width = div.style.paddingLeft = "1px"; + jQuery.boxModel = support.boxModel = div.offsetWidth === 2; + + if ( typeof div.style.zoom !== "undefined" ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.style.cssText = ptlm + vb; + div.innerHTML = html; + + outer = div.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + body.removeChild( container ); + div = container = null; + + jQuery.extend( support, offsetSupport ); + }); + + return support; +})(); + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, + isEvents = name === "events"; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = ++jQuery.uuid; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + privateCache = thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ internalKey ] : internalKey; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the cache and need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ internalKey ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( internalKey ); + } else { + elem[ internalKey ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var parts, attr, name, + data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { + attr = this[0].attributes; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + jQuery._data( this[0], "parsedAttrs", true ); + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var self = jQuery( this ), + args = [ parts[0], value ]; + + self.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + self.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + jQuery.isNumeric( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery._data( elem, deferDataKey ); + if ( defer && + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.fire(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); + if ( count ) { + jQuery._data( elem, key, count ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + var q; + if ( elem ) { + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + hooks = {}; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue " + type + ".run", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + count++; + tmp.add( resolve ); + } + } + resolve(); + return defer.promise(); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = ( value || "" ).split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; + + if ( value && elem.nodeType === 1 ) { + attrNames = value.toLowerCase().split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ]; + + if ( name ) { + propName = jQuery.propFix[ name ] || name; + + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && propName in elem ) { + elem[ propName ] = false; + } + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.nodeValue = value + "" ); + } + }; + + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = "" + value ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); + + + + +var rformElems = /^(?:textarea|input|select)$/i, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /\bhover(\.\S+)?\b/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, + quickParse = function( selector ) { + var quick = rquickIs.exec( selector ); + if ( quick ) { + // 0 1 2 3 + // [ _, tag, id, class ] + quick[1] = ( quick[1] || "" ).toLowerCase(); + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); + } + return quick; + }, + quickIs = function( elem, m ) { + var attrs = elem.attributes || {}; + return ( + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && + (!m[2] || (attrs.id || {}).value === m[2]) && + (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) + ); + }, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = jQuery.trim( hoverHack(types) ).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + quick: quickParse( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, origType, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = jQuery.trim( hoverHack( types || "" ) ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = origType = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var type = event.type || event, + namespaces = [], + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; + old = null; + for ( ; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + // Note that this is a bare JS function and not a jQuery handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), + run_all = !event.exclusive && !event.namespace, + handlerQueue = [], + i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Determine handlers that should run if there are delegated events + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { + + // Pregenerate a single jQuery object for reuse with .is() + jqcur = jQuery(this); + jqcur.context = this.ownerDocument || this; + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + selMatch = {}; + matches = []; + jqcur[0] = cur; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = ( + handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) + ); + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { + event.metaKey = event.ctrlKey; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady + }, + + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + ret; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on.call( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + var handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( var type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + expando = "sizcache" + (Math.random() + '').replace('.', ''), + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rReturn = /\r\n/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context, seed ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set, seed ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set, i, len, match, type, left; + + if ( !expr ) { + return []; + } + + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + type, found, item, filter, left, + i, pass, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + filter = Expr.filter[ type ]; + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + pass = not ^ found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Utility function for retreiving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +var getText = Sizzle.getText = function( elem ) { + var i, node, + nodeType = elem.nodeType, + ret = ""; + + if ( nodeType ) { + if ( nodeType === 1 || nodeType === 9 ) { + // Use textContent || innerText for elements + if ( typeof elem.textContent === 'string' ) { + return elem.textContent; + } else if ( typeof elem.innerText === 'string' ) { + // Replace IE's carriage returns + return elem.innerText.replace( rReturn, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + } else { + + // If no nodeType, this is expected to be an array + for ( i = 0; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + if ( node.nodeType !== 8 ) { + ret += getText( node ); + } + } + } + return ret; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + first = match[2]; + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + doneName = match[0]; + parent = elem.parentNode; + + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent[ expando ] = doneName; + } + + diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + !type && Sizzle.attr ? + result != null : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context, seed ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet, seed ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array (deprecated as of jQuery 1.7) + if ( jQuery.isArray( selectors ) ) { + var level = 1; + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { + + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, slice.call( arguments ).join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} + + + + +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+
+

Quiz

+
+
+

Third quiz: the letters

+
+
+

Quiz result

+
+
+

First quiz: the fox

+
+
+

Second Quiz: the dog

+
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+
+ + + + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/2/styles.css b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/2/styles.css new file mode 100644 index 0000000..3a3d822 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/2/styles.css @@ -0,0 +1,211 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#obj7130 { +position: absolute; +overflow: hidden; +top: 11px; +left: 13px; +width: 998px; +height: 31px; +opacity: 1; +z-index: 1; +display:block; +pointer-events: auto; +} +div#obj7132 { +position: absolute; +overflow: hidden; +top: 389px; +left: 66px; +width: 366px; +height: 18px; +opacity: 1; +z-index: 2; +display:block; +pointer-events: auto; +} +div#obj7134 { +position: absolute; +overflow: hidden; +top: 389px; +left: 592px; +width: 366px; +height: 18px; +opacity: 1; +z-index: 3; +display:block; +pointer-events: auto; +} +div#obj7136 { +position: absolute; +overflow: hidden; +top: 77px; +left: 66px; +width: 366px; +height: 18px; +opacity: 1; +z-index: 4; +display:block; +pointer-events: auto; +} +div#obj7139 { +position: absolute; +overflow: hidden; +top: 77px; +left: 592px; +width: 366px; +height: 18px; +opacity: 1; +z-index: 5; +display:block; +pointer-events: auto; +} +div#obj7252 { +position: absolute; +overflow: hidden; +top: 409px; +left: 572px; +width: 407px; +height: 272px; +opacity: 1; +z-index: 13; +display:block; +pointer-events: auto; +font-family:inherit; + font-size:20px; + text-align:left; + border-color: #000000; + border-width: 0px; + border-style: solid; + border-radius: 8px; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + background-color: rgba(255,255,255,0.8666667); +} + + + +div#obj7129 { +position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 1024px; +height: 768px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: none; +} +img#obj7129_img { + position: relative; + top: 0px; + left: 0px; + width: 100%; + height: 100%; +} + + + + + + + + + + +div#obj7142 { + position: absolute; +overflow: hidden; +top: 97px; +left: 46px; +width: 407px; +height: 272px; +opacity: 1; +z-index: 6; +display:block; +pointer-events: auto; + font-family:inherit; + font-size:20px; + text-align:left; + border-color: #000000; + border-width: 0px; + border-style: solid; + border-radius: 8px; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + background-color: rgba(255,255,255,0.8666667); +} +div#obj7142 h1.title { + display: block; +} + +div#obj7151 { + position: absolute; +overflow: hidden; +top: 97px; +left: 572px; +width: 407px; +height: 272px; +opacity: 1; +z-index: 7; +display:block; +pointer-events: auto; + font-family:inherit; + font-size:20px; + text-align:left; + border-color: #000000; + border-width: 0px; + border-style: solid; + border-radius: 8px; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + background-color: rgba(255,255,255,0.8666667); +} +div#obj7151 h1.title { + display: block; +} + +div#obj7160 { + position: absolute; +overflow: hidden; +top: 409px; +left: 46px; +width: 407px; +height: 272px; +opacity: 1; +z-index: 8; +display:block; +pointer-events: auto; + font-family:inherit; + font-size:20px; + text-align:left; + border-color: #000000; + border-width: 0px; + border-style: solid; + border-radius: 8px; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + background-color: rgba(255,255,255,0.8666667); +} +div#obj7160 h1.title { + display: none; +} + +iframe { + overflow:hidden; +} + +iframe#SC7252, iframe#SC7142, iframe#SC7151, iframe#SC7160 { + width: 407px; + height: 272px; +} + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/cover.jpg b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/cover.jpg new file mode 100644 index 0000000..d268a07 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/cover.jpg differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/obj7129_image.jpeg b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/obj7129_image.jpeg new file mode 100644 index 0000000..b41c86b Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/obj7129_image.jpeg differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/obj7302_image.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/obj7302_image.png new file mode 100644 index 0000000..ad54870 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/assets/images/obj7302_image.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/actions.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/actions.js new file mode 100644 index 0000000..31b7c22 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/actions.js @@ -0,0 +1,97 @@ +var ua = navigator.userAgent.toLowerCase(); +var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); +var touchDownEvent; +var touchUpEvent; +var isMobile; +var orientationDevice = getOrientation(isAndroid); +var aigX = 0, aigY = 0; +/* + * + * Init Action Lists + * + * + */ +/* + * + * Init SCCounter + * + * + */ + +$(window).load(function(){ + /* + * + * Init SCAnimation + * + * + */ + + /* + * + * Init Shake + * + */ + window.addEventListener('shake', function () { + + }, false); + + /* + * + * Init Masked Images + * + */ + + /* + * + * Init SCPhotogallery + * + * + */ + + /* + * + * Init SCQuizMulti + * + * + */ + +var quizMultiObj7255 = new QuizMulti('#obj7255',{ +risposte : [[0,0,1,0],[0,0,1,0]] +,messaggioNonCompletato : "Missing Answers!" +,messaggioTutteCorrette: "Perfect!" +,countdown : false +,save : false +}); + /* + * + * Init SCDrawer + * + * + */ + + if(! navigator.userAgent.match(/PubCoderHelper/i)) { + /* + * + * Action Groups + * + */ + + + /* + * + * Events + * + */ + + + /* + * + * Trigger onShow events for objects already shown on stage + * + */ + setTimeout(function() { + +$("#obj7255").trigger('SCEventShow'); + }, 200) + } +}) \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/page.xhtml b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/page.xhtml new file mode 100644 index 0000000..1d15432 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/page.xhtml @@ -0,0 +1,196 @@ + + + + + + + + + 56 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+
+

+ Quiz +

+
+ + +
+
+

+ + Quiz + + 1 +

+
+ +
    + +
  1. +
    +

    Where does the fox jump?

    +
    +
      + +
    1. + + + +
    2. +
    3. + + + +
    4. +
    5. + + + +
    6. +
    7. + + + +
    8. +
    +
  2. +
  3. +
    +

    What color is the fox?

    +
    +
      + +
    1. + + + +
    2. +
    3. + + + +
    4. +
    5. + + + +
    6. +
    7. + + + +
    8. +
    +
  4. +
+
+
+
+
+ + +
+ +
+
+ + + + + +
+
+ + + + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/styles.css b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/styles.css new file mode 100644 index 0000000..794384c --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz1/styles.css @@ -0,0 +1,300 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + + + + + + + + + + + +div#obj7255 { + position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 407px; +height: 272px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: auto; + font-family:inherit; + font-size:20px; + text-align:left; + border-color: #000000; + border-width: 0px; + border-style: solid; + border-radius: 8px; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + background-color: rgba(255,255,255,0.8666667); +} +div#obj7255 h1.title { + display: block; +} +div#obj7255 .chapter_label { + font-family:inherit; + font-size:20px; + color: #000000; +} +div#obj7255 .chapter_number { + display: none; + text-align:center; + padding-left: 0px; + padding-right: 10px; +} +div#obj7255 .counter { + font-family:inherit; + font-size:20px; + color: #000000; +} +div#obj7255 .practice { + position: absolute; + top: 0px; + width: 407px; + height: 272px; +} +div#obj7255 .practicediv{ + width: calc(100% - 32px); + margin: 16px; + height: calc(272px - 16px); +} +div#obj7255 .practice > header{ + display:none; +} +div#obj7255 .practicelist{ + padding:0; +} +div#obj7255 .multiple-choice-problem{ + list-style-type: none; + visibility: hidden; +} +div#obj7255 .practicediv .choices{ + padding:0; +} +div#obj7255 .practicediv .choices li{ + margin-left: 60px; + margin-right: 60px; +} +div#obj7255 .practicediv .choices .choice-content { + margin-left: 6px; +} +/* BOTTONI */ +div#obj7255 .quiz-buttons{ + display: block; + position:relative; + z-index: 2; + bottom: 30px; + height: 30px; + width: 100%; + text-align: center; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7255 .swiper-container .quiz-buttons{ + display: inline-block; + position: relative; + bottom: 0px; + margin-top: calc(272px/6); + text-align: center; + height: 30px; +} +div#obj7255 button.quiz-button { + background: #ffffff; /* Old browsers */ + background: -moz-linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#f2f2f2)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* IE10+ */ + background: linear-gradient(to bottom, #ffffff 0%,#f2f2f2 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f2f2f2',GradientType=0 ); /* IE6-9 */ + border: 1px solid #979797; + border-radius: 6px; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7255 .messaggio-finale{ + width:80%; + margin:0 auto; + text-align: center; +} +div#obj7255 .conteggio-finale{ + width: 100%; + text-align: center; + margin-top: 1em; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7255 .conteggio-finale div{ + width: 22px; + text-align: center; +} +div#obj7255 .finale-quiz { + display: inline-block; + margin-right: 4px; + vertical-align: middle; +} +div#obj7255 .finale-quiz-choice-right{ + background-image : url("../shared/images/scquiz-check-right.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; +} +div#obj7255 .finale-quiz-choice-wrong{ + background-image : url("../shared/images/scquiz-check-wrong.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} +div#obj7255 .finale-quiz-choice-missed{ + background-image : url("../shared/images/scquiz-check-off.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} +div#obj7255 label.css-label{ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +div#obj7255 .arrow-left { + background: url(../shared/images/scquiz-prev.png) no-repeat; + background-size: 50px 50px; + position: absolute; + left: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; + display: none; +} +div#obj7255 .arrow-right { + background: url(../shared/images/scquiz-next.png) no-repeat; + background-size: 50px 50px; + position: absolute; + right: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; + display: none; +} +/* CHECKBOX UNCHECKED*/ +div#obj7255 input[type=checkbox].css-checkbox + label.css-label { + padding-left: 22px; + display: inline-block; + background-repeat: no-repeat; + background-position-x: 0px; + background-position-y: calc(30px/2 - 22px/2 - 1px); + min-height: 30px; + line-height: 30px; + vertical-align: top; + cursor: pointer; +} +div#obj7255 input[type=radio].css-checkbox + label.css-label { + padding-left: 22px; + display: inline-block; + background-repeat: no-repeat; + background-position-x: 0px; + background-position-y: calc(30px/2 - 22px/2 - 1px); + min-height: 30px; + line-height: 30px; + vertical-align: top; + cursor: pointer; +} +div#obj7255 input[type=checkbox].css-checkbox, +div#obj7255 input[type=radio].css-checkbox{ + display: none; +} +/* esempio di personalizzazione del tipo di elenco*/ +div#obj7255 .multiple-choice-problem .choices li{ + list-style-type:none; +} +/* CHECKBOX */ +div#obj7255 label.css-label.lb-checkbox{ + /*background-image : url(../shared/images/scquiz-check-off.png);*/ + background-image : url("../shared/images/scquiz-check-off.png"); + background-size: 22px 22px; +} +div#obj7255 input[type=checkbox].css-checkbox:checked + label.css-label.lb-checkbox{ + /*background-image : url(../shared/images/scquiz-check-on.png);*/ + background-image : url("../shared/images/scquiz-check-on.png"); + background-size: 22px 22px; +} +div#obj7255 .quiz-choice-wrong input[type=checkbox].css-checkbox + label.css-label.lb-checkbox{ + /*background-image : url(../shared/images/scquiz-check-wrong.png);*/ + background-image : url("../shared/images/scquiz-check-wrong.png"); + background-size: 22px 22px; +} +div#obj7255 .quiz-choice-right input[type=checkbox].css-checkbox + label.css-label.lb-checkbox { + /*background-image : url(../shared/images/scquiz-check-right.png);*/ + background-image : url("../shared/images/scquiz-check-right.png"); + background-size: 22px 22px; +} +div#obj7255 .quiz-choice-missed input[type=checkbox].css-checkbox + label.css-label.lb-checkbox { + /*background-image : url(../shared/images/scquiz-check-missed.png);*/ + background-image : url("../shared/images/scquiz-check-missed.png"); + background-size: 22px 22px; +} +/* RADIO */ +div#obj7255 label.css-label.lb-radio{ + /*background-image : url(../shared/images/scquiz-radio-off.png);*/ + background-image : url("../shared/images/scquiz-radio-off.png"); + background-size: 22px 22px; +} +div#obj7255 input[type=radio].css-checkbox:checked + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-on.png);*/ + background-image : url("../shared/images/scquiz-radio-on.png"); + background-size: 22px 22px; +} +div#obj7255 .quiz-choice-wrong input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-wrong.png);*/ + background-image : url("../shared/images/scquiz-radio-wrong.png"); + background-size: 22px 22px; +} +div#obj7255 .quiz-choice-right input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-right.png);*/ + background-image : url("../shared/images/scquiz-radio-right.png"); + background-size: 22px 22px; +} +div#obj7255 .quiz-choice-missed input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-missed.png);*/ + background-image : url("../shared/images/scquiz-radio-missed.png"); + background-size: 22px 22px; +} +/* FONTS */ +div#obj7255 div.question p { + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7255 span.choice-content { + font-family: inherit; + font-size: 20px; + color: #000000; +} + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/actions.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/actions.js new file mode 100644 index 0000000..3a76bc2 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/actions.js @@ -0,0 +1,97 @@ +var ua = navigator.userAgent.toLowerCase(); +var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); +var touchDownEvent; +var touchUpEvent; +var isMobile; +var orientationDevice = getOrientation(isAndroid); +var aigX = 0, aigY = 0; +/* + * + * Init Action Lists + * + * + */ +/* + * + * Init SCCounter + * + * + */ + +$(window).load(function(){ + /* + * + * Init SCAnimation + * + * + */ + + /* + * + * Init Shake + * + */ + window.addEventListener('shake', function () { + + }, false); + + /* + * + * Init Masked Images + * + */ + + /* + * + * Init SCPhotogallery + * + * + */ + + /* + * + * Init SCQuizMulti + * + * + */ + +var quizMultiObj7270 = new QuizMulti('#obj7270',{ +risposte : [[1,0,0,0],[0,0,1]] +,messaggioNonCompletato : "Missing Answers!" +,messaggioTutteCorrette: "Perfect!" +,countdown : false +,save : false +}); + /* + * + * Init SCDrawer + * + * + */ + + if(! navigator.userAgent.match(/PubCoderHelper/i)) { + /* + * + * Action Groups + * + */ + + + /* + * + * Events + * + */ + + + /* + * + * Trigger onShow events for objects already shown on stage + * + */ + setTimeout(function() { + +$("#obj7270").trigger('SCEventShow'); + }, 200) + } +}) \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/page.xhtml b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/page.xhtml new file mode 100644 index 0000000..cbb92b5 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/page.xhtml @@ -0,0 +1,197 @@ + + + + + + + + + Quiz 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ +
+
+

+ Quiz +

+
+ + +
+
+

+ + Quiz + + 1 +

+
+ +
    + +
  1. +
    +

    How is the dog?

    +
    +
      + +
    1. + + + +
    2. +
    3. + + + +
    4. +
    5. + + + +
    6. +
    7. + + + +
    8. +
    +
  2. +
  3. +
    +

    How is the dog related to the fox?

    +
    +
      + +
    1. + + + +
    2. +
    3. + + + +
    4. +
    5. + + + +
    6. +
    +
  4. +
+
+
+
+
+ + +
+ +
+
+ + + + + +
+ +
+ +
+ +
+ + + + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/styles.css b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/styles.css new file mode 100644 index 0000000..50b84b0 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz2/styles.css @@ -0,0 +1,291 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + + +div#obj7270 { + position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 407px; +height: 272px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: auto; + font-family:inherit; + font-size:20px; + text-align:left; + border-color: #000000; + border-width: 0px; + border-style: solid; + border-radius: 8px; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + background-color: rgba(255,255,255,0.8666667); +} +div#obj7270 h1.title { + display: block; +} +div#obj7270 .chapter_label { + font-family:inherit; + font-size:20px; + color: #000000; +} +div#obj7270 .chapter_number { + display: none; + text-align:center; + padding-left: 0px; + padding-right: 10px; +} +div#obj7270 .counter { + font-family:inherit; + font-size:20px; + color: #000000; +} +div#obj7270 .practice { + position: absolute; + top: 0px; + width: 407px; + height: 272px; +} +div#obj7270 .practicediv{ + width: calc(100% - 32px); + margin: 16px; + height: calc(272px - 16px); +} +div#obj7270 .practice > header{ + display:none; +} +div#obj7270 .practicelist{ + padding:0; +} +div#obj7270 .multiple-choice-problem{ + list-style-type: none; + visibility: hidden; +} +div#obj7270 .practicediv .choices{ + padding:0; +} +div#obj7270 .practicediv .choices li{ + margin-left: 60px; + margin-right: 60px; +} +div#obj7270 .practicediv .choices .choice-content { + margin-left: 6px; +} +/* BOTTONI */ +div#obj7270 .quiz-buttons{ + display: block; + position:relative; + z-index: 2; + bottom: 30px; + height: 30px; + width: 100%; + text-align: center; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7270 .swiper-container .quiz-buttons{ + display: inline-block; + position: relative; + bottom: 0px; + margin-top: calc(272px/6); + text-align: center; + height: 30px; +} +div#obj7270 button.quiz-button { + background: #ffffff; /* Old browsers */ + background: -moz-linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#f2f2f2)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* IE10+ */ + background: linear-gradient(to bottom, #ffffff 0%,#f2f2f2 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f2f2f2',GradientType=0 ); /* IE6-9 */ + border: 1px solid #979797; + border-radius: 6px; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7270 .messaggio-finale{ + width:80%; + margin:0 auto; + text-align: center; +} +div#obj7270 .conteggio-finale{ + width: 100%; + text-align: center; + margin-top: 1em; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7270 .conteggio-finale div{ + width: 22px; + text-align: center; +} +div#obj7270 .finale-quiz { + display: inline-block; + margin-right: 4px; + vertical-align: middle; +} +div#obj7270 .finale-quiz-choice-right{ + background-image : url("../shared/images/scquiz-check-right.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; +} +div#obj7270 .finale-quiz-choice-wrong{ + background-image : url("../shared/images/scquiz-check-wrong.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} +div#obj7270 .finale-quiz-choice-missed{ + background-image : url("../shared/images/scquiz-check-off.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} +div#obj7270 label.css-label{ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +div#obj7270 .arrow-left { + background: url(../shared/images/scquiz-prev.png) no-repeat; + background-size: 50px 50px; + position: absolute; + left: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; + display: none; +} +div#obj7270 .arrow-right { + background: url(../shared/images/scquiz-next.png) no-repeat; + background-size: 50px 50px; + position: absolute; + right: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; + display: none; +} +/* CHECKBOX UNCHECKED*/ +div#obj7270 input[type=checkbox].css-checkbox + label.css-label { + padding-left: 22px; + display: inline-block; + background-repeat: no-repeat; + background-position-x: 0px; + background-position-y: calc(30px/2 - 22px/2 - 1px); + min-height: 30px; + line-height: 30px; + vertical-align: top; + cursor: pointer; +} +div#obj7270 input[type=radio].css-checkbox + label.css-label { + padding-left: 22px; + display: inline-block; + background-repeat: no-repeat; + background-position-x: 0px; + background-position-y: calc(30px/2 - 22px/2 - 1px); + min-height: 30px; + line-height: 30px; + vertical-align: top; + cursor: pointer; +} +div#obj7270 input[type=checkbox].css-checkbox, +div#obj7270 input[type=radio].css-checkbox{ + display: none; +} +/* esempio di personalizzazione del tipo di elenco*/ +div#obj7270 .multiple-choice-problem .choices li{ + list-style-type:none; +} +/* CHECKBOX */ +div#obj7270 label.css-label.lb-checkbox{ + /*background-image : url(../../images/scquiz-check-off.png);*/ + background-image : url("../shared/images/scquiz-check-off.png"); + background-size: 22px 22px; +} +div#obj7270 input[type=checkbox].css-checkbox:checked + label.css-label.lb-checkbox{ + /*background-image : url(../../images/scquiz-check-on.png);*/ + background-image : url("../shared/images/scquiz-check-on.png"); + background-size: 22px 22px; +} +div#obj7270 .quiz-choice-wrong input[type=checkbox].css-checkbox + label.css-label.lb-checkbox{ + /*background-image : url(../../images/scquiz-check-wrong.png);*/ + background-image : url("../shared/images/scquiz-check-wrong.png"); + background-size: 22px 22px; +} +div#obj7270 .quiz-choice-right input[type=checkbox].css-checkbox + label.css-label.lb-checkbox { + /*background-image : url(../../images/scquiz-check-right.png);*/ + background-image : url("../shared/images/scquiz-check-right.png"); + background-size: 22px 22px; +} +div#obj7270 .quiz-choice-missed input[type=checkbox].css-checkbox + label.css-label.lb-checkbox { + /*background-image : url(../../images/scquiz-check-missed.png);*/ + background-image : url("../shared/images/scquiz-check-missed.png"); + background-size: 22px 22px; +} +/* RADIO */ +div#obj7270 label.css-label.lb-radio{ + /*background-image : url(../../images/scquiz-radio-off.png);*/ + background-image : url("../shared/images/scquiz-radio-off.png"); + background-size: 22px 22px; +} +div#obj7270 input[type=radio].css-checkbox:checked + label.css-label.lb-radio { + /*background-image : url(../../images/scquiz-radio-on.png);*/ + background-image : url("../shared/images/scquiz-radio-on.png"); + background-size: 22px 22px; +} +div#obj7270 .quiz-choice-wrong input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../../images/scquiz-radio-wrong.png);*/ + background-image : url("../shared/images/scquiz-radio-wrong.png"); + background-size: 22px 22px; +} +div#obj7270 .quiz-choice-right input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../../images/scquiz-radio-right.png);*/ + background-image : url("../shared/images/scquiz-radio-right.png"); + background-size: 22px 22px; +} +div#obj7270 .quiz-choice-missed input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../../images/scquiz-radio-missed.png);*/ + background-image : url("../shared/images/scquiz-radio-missed.png"); + background-size: 22px 22px; +} +/* FONTS */ +div#obj7270 div.question p { + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7270 span.choice-content { + font-family: inherit; + font-size: 20px; + color: #000000; +} + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/actions.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/actions.js new file mode 100644 index 0000000..80e2746 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/actions.js @@ -0,0 +1,97 @@ +var ua = navigator.userAgent.toLowerCase(); +var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile"); +var touchDownEvent; +var touchUpEvent; +var isMobile; +var orientationDevice = getOrientation(isAndroid); +var aigX = 0, aigY = 0; +/* + * + * Init Action Lists + * + * + */ +/* + * + * Init SCCounter + * + * + */ + +$(window).load(function(){ + /* + * + * Init SCAnimation + * + * + */ + + /* + * + * Init Shake + * + */ + window.addEventListener('shake', function () { + + }, false); + + /* + * + * Init Masked Images + * + */ + + /* + * + * Init SCPhotogallery + * + * + */ + + /* + * + * Init SCQuizMulti + * + * + */ + +var quizMultiObj7284 = new QuizMulti('#obj7284',{ +risposte : [[0,1,1]] +,messaggioNonCompletato : "Missing Answers!" +,messaggioTutteCorrette: "Perfect!" +,countdown : false +,save : false +}); + /* + * + * Init SCDrawer + * + * + */ + + if(! navigator.userAgent.match(/PubCoderHelper/i)) { + /* + * + * Action Groups + * + */ + + + /* + * + * Events + * + */ + + + /* + * + * Trigger onShow events for objects already shown on stage + * + */ + setTimeout(function() { + +$("#obj7284").trigger('SCEventShow'); + }, 200) + } +}) \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/page.xhtml b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/page.xhtml new file mode 100644 index 0000000..23a384a --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/page.xhtml @@ -0,0 +1,156 @@ + + + + + + + + + Quiz 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+
+

+ +

+
+ + +
+
+

+ + Quiz + + 1 +

+
+ +
    + +
  1. +
    +

    Why does the fox jump over the dog?

    +
    +
      + +
    1. + + + +
    2. +
    3. + + + +
    4. +
    5. + + + +
    6. +
    +
  2. +
+
+
+
+
+ + +
+ +
+
+ + + + + +
+ +
+ +
+ +
+ + + + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/styles.css b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/styles.css new file mode 100644 index 0000000..1179a18 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/Quiz3/styles.css @@ -0,0 +1,300 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + + + + + + + + + + + +div#obj7284 { + position: absolute; +overflow: hidden; +top: 0px; +left: 0px; +width: 407px; +height: 272px; +opacity: 1; +z-index: 0; +display:block; +pointer-events: auto; + font-family:inherit; + font-size:20px; + text-align:left; + border-color: #000000; + border-width: 0px; + border-style: solid; + border-radius: 8px; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + background-color: rgba(255,255,255,0.8666667); +} +div#obj7284 h1.title { + display: none; +} +div#obj7284 .chapter_label { + font-family:inherit; + font-size:20px; + color: #000000; +} +div#obj7284 .chapter_number { + display: none; + text-align:center; + padding-left: 0px; + padding-right: 10px; +} +div#obj7284 .counter { + font-family:inherit; + font-size:20px; + color: #000000; +} +div#obj7284 .practice { + position: absolute; + top: 0px; + width: 407px; + height: 272px; +} +div#obj7284 .practicediv{ + width: calc(100% - 32px); + margin: 16px; + height: calc(242px - 16px); +} +div#obj7284 .practice > header{ + display:none; +} +div#obj7284 .practicelist{ + padding:0; +} +div#obj7284 .multiple-choice-problem{ + list-style-type: none; + visibility: hidden; +} +div#obj7284 .practicediv .choices{ + padding:0; +} +div#obj7284 .practicediv .choices li{ + margin-left: 60px; + margin-right: 60px; +} +div#obj7284 .practicediv .choices .choice-content { + margin-left: 6px; +} +/* BOTTONI */ +div#obj7284 .quiz-buttons{ + display: block; + position:relative; + z-index: 2; + bottom: 30px; + height: 30px; + width: 100%; + text-align: center; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7284 .swiper-container .quiz-buttons{ + display: inline-block; + position: relative; + bottom: 0px; + margin-top: calc(272px/6); + text-align: center; + height: 30px; +} +div#obj7284 button.quiz-button { + background: #ffffff; /* Old browsers */ + background: -moz-linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#f2f2f2)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #ffffff 0%,#f2f2f2 100%); /* IE10+ */ + background: linear-gradient(to bottom, #ffffff 0%,#f2f2f2 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f2f2f2',GradientType=0 ); /* IE6-9 */ + border: 1px solid #979797; + border-radius: 6px; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7284 .messaggio-finale{ + width:80%; + margin:0 auto; + text-align: center; +} +div#obj7284 .conteggio-finale{ + width: 100%; + text-align: center; + margin-top: 1em; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7284 .conteggio-finale div{ + width: 22px; + text-align: center; +} +div#obj7284 .finale-quiz { + display: inline-block; + margin-right: 4px; + vertical-align: middle; +} +div#obj7284 .finale-quiz-choice-right{ + background-image : url("../shared/images/scquiz-check-right.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; +} +div#obj7284 .finale-quiz-choice-wrong{ + background-image : url("../shared/images/scquiz-check-wrong.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} +div#obj7284 .finale-quiz-choice-missed{ + background-image : url("../shared/images/scquiz-check-off.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} +div#obj7284 label.css-label{ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +div#obj7284 .arrow-left { + background: url(../shared/images/scquiz-prev.png) no-repeat; + background-size: 50px 50px; + position: absolute; + left: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; + display: none; +} +div#obj7284 .arrow-right { + background: url(../shared/images/scquiz-next.png) no-repeat; + background-size: 50px 50px; + position: absolute; + right: 5px; + top: 50%; + margin-top: -25px; + width: 50px; + height: 50px; + z-index: 2; + display: none; +} +/* CHECKBOX UNCHECKED*/ +div#obj7284 input[type=checkbox].css-checkbox + label.css-label { + padding-left: 22px; + display: inline-block; + background-repeat: no-repeat; + background-position-x: 0px; + background-position-y: calc(30px/2 - 22px/2 - 1px); + min-height: 30px; + line-height: 30px; + vertical-align: top; + cursor: pointer; +} +div#obj7284 input[type=radio].css-checkbox + label.css-label { + padding-left: 22px; + display: inline-block; + background-repeat: no-repeat; + background-position-x: 0px; + background-position-y: calc(30px/2 - 22px/2 - 1px); + min-height: 30px; + line-height: 30px; + vertical-align: top; + cursor: pointer; +} +div#obj7284 input[type=checkbox].css-checkbox, +div#obj7284 input[type=radio].css-checkbox{ + display: none; +} +/* esempio di personalizzazione del tipo di elenco*/ +div#obj7284 .multiple-choice-problem .choices li{ + list-style-type:none; +} +/* CHECKBOX */ +div#obj7284 label.css-label.lb-checkbox{ + /*background-image : url(../shared/images/scquiz-check-off.png);*/ + background-image : url("../shared/images/scquiz-check-off.png"); + background-size: 22px 22px; +} +div#obj7284 input[type=checkbox].css-checkbox:checked + label.css-label.lb-checkbox{ + /*background-image : url(../shared/images/scquiz-check-on.png);*/ + background-image : url("../shared/images/scquiz-check-on.png"); + background-size: 22px 22px; +} +div#obj7284 .quiz-choice-wrong input[type=checkbox].css-checkbox + label.css-label.lb-checkbox{ + /*background-image : url(../shared/images/scquiz-check-wrong.png);*/ + background-image : url("../shared/images/scquiz-check-wrong.png"); + background-size: 22px 22px; +} +div#obj7284 .quiz-choice-right input[type=checkbox].css-checkbox + label.css-label.lb-checkbox { + /*background-image : url(../shared/images/scquiz-check-right.png);*/ + background-image : url("../shared/images/scquiz-check-right.png"); + background-size: 22px 22px; +} +div#obj7284 .quiz-choice-missed input[type=checkbox].css-checkbox + label.css-label.lb-checkbox { + /*background-image : url(../shared/images/scquiz-check-missed.png);*/ + background-image : url("../shared/images/scquiz-check-missed.png"); + background-size: 22px 22px; +} +/* RADIO */ +div#obj7284 label.css-label.lb-radio{ + /*background-image : url(../shared/images/scquiz-radio-off.png);*/ + background-image : url("../shared/images/scquiz-radio-off.png"); + background-size: 22px 22px; +} +div#obj7284 input[type=radio].css-checkbox:checked + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-on.png);*/ + background-image : url("../shared/images/scquiz-radio-on.png"); + background-size: 22px 22px; +} +div#obj7284 .quiz-choice-wrong input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-wrong.png);*/ + background-image : url("../shared/images/scquiz-radio-wrong.png"); + background-size: 22px 22px; +} +div#obj7284 .quiz-choice-right input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-right.png);*/ + background-image : url("../shared/images/scquiz-radio-right.png"); + background-size: 22px 22px; +} +div#obj7284 .quiz-choice-missed input[type=radio].css-checkbox + label.css-label.lb-radio { + /*background-image : url(../shared/images/scquiz-radio-missed.png);*/ + background-image : url("../shared/images/scquiz-radio-missed.png"); + background-size: 22px 22px; +} +/* FONTS */ +div#obj7284 div.question p { + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#obj7284 span.choice-content { + font-family: inherit; + font-size: 20px; + color: #000000; +} + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/actions.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/actions.js new file mode 100644 index 0000000..2ad7b50 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/actions.js @@ -0,0 +1,16 @@ +window.onload = function() { + window.addEventListener('message', receiveMessage); + /* Insert your custom JavaScript code below */ + function receiveMessage(e) { + //if (e.data.topic == "PubCoderQuiz") { + $('#results').empty() + .append("
" + e.data.topicData.title + "
") + .append("
" + e.data.topicData.rightNum + "") + .append("
" + e.data.topicData.wrongNum + "") + .append("
" + e.data.topicData.missedNum + ""); + + + //} + } + +}; \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/page.xhtml b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/page.xhtml new file mode 100644 index 0000000..d711560 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/page.xhtml @@ -0,0 +1,101 @@ + + + + + + + + + Scriptable Components + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Results of excercieses
+ + + + + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/styles.css b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/styles.css new file mode 100644 index 0000000..555c2b9 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/QuizResult/styles.css @@ -0,0 +1,33 @@ +div.SCContent { + overflow-x: hidden; + overflow-y: hidden; +} +div.SCOverlay { + z-index: 2; +} + + +div#results { +top: 0px; +left: 0px; +width: 407px; +height: 272px; +padding-top: 100px; +text-align: center; +opacity: 1; +z-index: 0; +display:block; +pointer-events: auto; +} + + + + + + + + + + + + diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/css/general.styles.css b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/css/general.styles.css new file mode 100644 index 0000000..e34e65e --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/css/general.styles.css @@ -0,0 +1,269 @@ +/* Font styles: */ +@charset "UTF-8"; +@font-face { +font-family: "Cabin-Sketch-700"; +src: url(../fonts/Cabin-Sketch-700.ttf); +} +@font-face { +font-family: "Cabin-Sketch-regular"; +src: url(../fonts/Cabin-Sketch-regular.ttf); +} +@font-face { +font-family: "Calligraffitti-regular"; +src: url(../fonts/Calligraffitti-regular.ttf); +} +@font-face { +font-family: "Droid-Sans-700"; +src: url(../fonts/Droid-Sans-700.ttf); +} +@font-face { +font-family: "Droid-Sans-regular"; +src: url(../fonts/Droid-Sans-regular.ttf); +} +/* Body style */ +body{ + padding:0; + margin:0; +} +/* Audio style */ +audio{ + z-index:-1; +} +/* Page style */ +div.SCPage { + width: 1024px; + height: 768px; + position: relative; + +} +div.SCOverlay { + position: absolute; + z-index: 2; + width: 1024px; + height: 768px; + overflow: hidden; + pointer-events: none; + +} +div.SCContent { + position: absolute; + z-index: 1; + width: 1024px; + height: 768px; +} + +.hidden +{ + display:none; +} +/* SCRectangle Style */ +.SCRectangle { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} +/* Read Aloud Styles */ + +.swiper-container { + margin:0 auto; + position:relative; + overflow:hidden; + -webkit-backface-visibility:hidden; + -moz-backface-visibility:hidden; + -ms-backface-visibility:hidden; + -o-backface-visibility:hidden; + backface-visibility:hidden; + /* Fix of Webkit flickering */ + z-index:1; +} +.swiper-wrapper { + position:relative; + width:100%; + -webkit-transition-property:-webkit-transform, left, top; + -webkit-transition-duration:0s; + -webkit-transform:translate3d(0px,0,0); + -webkit-transition-timing-function:ease; + -moz-transition-property:-moz-transform, left, top; + -moz-transition-duration:0s; + -moz-transform:translate3d(0px,0,0); + -moz-transition-timing-function:ease; + -o-transition-property:-o-transform, left, top; + -o-transition-duration:0s; + -o-transform:translate3d(0px,0,0); + -o-transition-timing-function:ease; + -o-transform:translate(0px,0px); + -ms-transition-property:-ms-transform, left, top; + -ms-transition-duration:0s; + -ms-transform:translate3d(0px,0,0); + -ms-transition-timing-function:ease; + transition-property:transform, left, top; + transition-duration:0s; + transform:translate3d(0px,0,0); + transition-timing-function:ease; +} +.swiper-free-mode > .swiper-wrapper { + -webkit-transition-timing-function: ease-out; + -moz-transition-timing-function: ease-out; + -ms-transition-timing-function: ease-out; + -o-transition-timing-function: ease-out; + transition-timing-function: ease-out; + margin: 0 auto; +} +.swiper-slide { + float: left; +} +.swiper-wp8-horizontal { + -ms-touch-action: pan-y; +} +.swiper-wp8-vertical { + -ms-touch-action: pan-x; +} + +/* SCQuiz Styles */ +.SCQuiz ol { + margin: 0px; +} +.SCQuiz .question p { + margin-top: 0px; + margin-bottom: 0.5em; +} +.SCQuiz .practicediv { + margin: 0px; +} +.SCQuiz .title { + margin-bottom: 0.5em; +} +.SCAnimationFrame { + position: absolute; + top: 0px; + width: 100%; + height: 100%; +} +/* Custom CSS Styles */ +/* Start of Default SCText Styles */ +body { + font-family: helvetica, arial, sans-serif; +} +.SCText p, h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-regular", helvetica, arial, sans-serif; + margin: 0px; + padding: 0px; + line-height: 1.3; +} +.SCText p { + font-size: 13px; + font-weight: normal; +} +.SCText h1, h2, h3, h4, h5, h6 { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-weight: normal; +} +.SCText h1 { font-size: 40px; } +.SCText h2 { font-size: 36px; } +.SCText h3 { font-size: 24px; } +.SCText h4 { font-size: 18px; } +.SCText h5 { font-size: 16px; } +.SCText h6 { font-size: 14px; } +/* End of Default SCText Styles */ +/* Start of Style Formats defined manually */ +.SCText span.Float-Left { + float: left; +} +.SCText span.Float-Right { + float: right; +} +.SCText span.Vertical-Align-Middle { + display: inline-block; + vertical-align: middle; +} +.SCText span.Add-Margin { + margin: 10px; +} +.SCText span.Shadowed { + text-shadow: #000000 1px 1px 2px; +} +.SCText span.OverBlack { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-size: 13px; + font-weight: normal; + color: #FFFFFF; +} +.SCText span.OverWhite { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif; + font-size: 13px; + font-weight: normal; + color: #000000; +} +.SCText span.Active-Text { + border-bottom: 1px dotted; +} +.SCText p.BigText { + font-size: 36px; +} +.-epub-media-overlay-active, +span.-epub-media-overlay-active, +span.-epub-media-overlay-active > span { + border-radius: 6px; + transition: .1s ease-in-out; + -webkit-transition: .1s ease-in-out; + -moz-transition: .1s ease-in-out; + -o-transition: .1s ease-in-out; +} +/* End of Style Formats defined manually */ +h3 { + text-shadow: #fff 0px 0px 6px; +} +.SCText a { + color: inherit; +} +.SCButton.DefaultButtonTitle { + font-family: "Droid-Sans-700", helvetica, arial, sans-serif !important; + font-size: 13px !important; + font-weight: normal !important; +} + +div#results .messaggio-finale{ + width:80%; + margin:0 auto; + text-align: center; +} +div#results .conteggio-finale{ + width: 100%; + text-align: center; + margin-top: 1em; + font-family: inherit; + font-size: 20px; + color: #000000; +} +div#results .conteggio-finale div{ + width: 22px; + text-align: center; +} +div#results .finale-quiz { + display: inline-block; + margin-right: 4px; + vertical-align: middle; +} +div#results .finale-quiz-choice-right{ + background-image : url("../images/scquiz-check-right.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; +} +div#results .finale-quiz-choice-wrong{ + background-image : url("../images/scquiz-check-wrong.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} +div#results .finale-quiz-choice-missed{ + background-image : url("../images/scquiz-check-off.png"); + background-size: 22px 22px; + background-repeat: no-repeat; + width: 22px; + height: 22px; + margin-left: 20px; +} \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Cabin-Sketch-700.ttf b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Cabin-Sketch-700.ttf new file mode 100644 index 0000000..6a582a9 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Cabin-Sketch-700.ttf differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Cabin-Sketch-regular.ttf b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Cabin-Sketch-regular.ttf new file mode 100644 index 0000000..88a77aa Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Cabin-Sketch-regular.ttf differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Calligraffitti-regular.ttf b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Calligraffitti-regular.ttf new file mode 100644 index 0000000..e3cd435 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Calligraffitti-regular.ttf differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Droid-Sans-700.ttf b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Droid-Sans-700.ttf new file mode 100644 index 0000000..942bbf5 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Droid-Sans-700.ttf differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Droid-Sans-regular.ttf b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Droid-Sans-regular.ttf new file mode 100644 index 0000000..efd1f8b Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/fonts/Droid-Sans-regular.ttf differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-missed.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-missed.png new file mode 100644 index 0000000..b4e1f2c Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-missed.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-off.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-off.png new file mode 100644 index 0000000..878dbd2 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-off.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-on.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-on.png new file mode 100644 index 0000000..75dc42d Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-on.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-right.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-right.png new file mode 100644 index 0000000..14466ab Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-right.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-wrong.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-wrong.png new file mode 100644 index 0000000..38577b3 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-check-wrong.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-next.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-next.png new file mode 100644 index 0000000..a0af4e1 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-next.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-prev.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-prev.png new file mode 100644 index 0000000..78fa58c Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-prev.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-missed.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-missed.png new file mode 100644 index 0000000..d272978 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-missed.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-off.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-off.png new file mode 100644 index 0000000..6ff7a37 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-off.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-on.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-on.png new file mode 100644 index 0000000..87b8364 Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-on.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-right.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-right.png new file mode 100644 index 0000000..f44321c Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-right.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-wrong.png b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-wrong.png new file mode 100644 index 0000000..fe45b0c Binary files /dev/null and b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/images/scquiz-radio-wrong.png differ diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/SCPubSubAPI.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/SCPubSubAPI.js new file mode 100755 index 0000000..ae23628 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/SCPubSubAPI.js @@ -0,0 +1,551 @@ +/* + A sample implementation of the IDPF scripted + component prototocol. + + author: Greg Davis + company: Pearson + +*/ + +var psowapi = (function($){ + 'use strict'; + + var methods = { + initialize : function(){ + // set up the message listener here, needs to be done for widgets and pages + $(window).on("message", subpub.messageHandler) + + // assign an id here + this.widgetID = subpub.genUuid() + + // todo - possibly put a mutation observer in here to watch + // the DOM and respond to hide events with a stop request to any hidden widgets + + + // setup the publishable browser event stack + subpub.publishableBrowserEvents.forEach(function(eventName) { + subpub.eventPublishDictionary[eventName] = { + active: false, + publish: function (e) { + // publish the event to subscribers here + psowapi.publish(eventName, new psowapi.BrowserEvent(e)) + } + } + }) + + // setup the elements that we want to stop propagation on certain events + // right now, all inputs and textarea are being stopped to prevent bubbling + $(document).on({ + keypress : function(e){ e.stopPropagation() }, + keyup : function(e){ e.stopPropagation() }, + keydown : function(e){ e.stopPropagation() }, + click : function(e){ e.stopPropagation() }, + mousedown : function(e){ e.stopPropagation() }, + mouseup : function(e){ e.stopPropagation() }, + touch : function(e){ e.stopPropagation() }, + touchstart : function(e){ e.stopPropagation() }, + touchend : function(e){ e.stopPropagation() } + }, "input, textarea") + + // fire off the loading event - not working + //this.send(window.parent, "epubsc_load", "loading") + + // set up the ready event + if(window.parent != window){ + window.addEventListener("DOMContentLoaded", function(){ + psowapi.send(window.parent, "epubsc_ready", "ready") + + // subscribe to sysReady and add events as they come in + psowapi.subscribe(false, "epubsc_ready", function(e){ + // add subscribed events to all child windows + var source = e.source ? e.source : e.originalEvent.source, + subEvents = [] + + for (var key in psowapi.subscriptions){ + if (subpub.publishableBrowserEvents.indexOf(key) > -1){ + subEvents.push(key) + } + } + + for(var key in subEvents){ + var Event = subEvents[key] + psowapi.subscribe(source, Event, function(e){ + // trigger the event here to push it up the chain + $(window).trigger(Event) + }) + } + + }) + + }, false) + } + + // set up the unload event + if(window.parent != window){ + window.addEventListener("unload", function(){ + psowapi.send(window.parent, "epubsc_unload", document.URL) + }) + } + }, + + // sub-pub mechanisms here + // message constructor + Message : function(method, topic, message, bubbles){ + // this is a constructor, so when it's invoked as "new" this will refer + // only to the created object, not the whole PSO object + this.type = "epubsc_message" + this.method = method + this.timestamp = +new Date() // date string + this.id = subpub.genUuid() // unique id for the message + this.widgetId = psowapi.widgetID // unique id for the widget during this session + + // make the payload + this.topic = topic + this.topicData = message + + // not sure what this does, investigate... + this.widgetPath_ = []; + }, + + BrowserEvent : function(e){ + /* TODO: Decide if assigning undefined properties is bad. It means that + *this.hasOwnProperty(X) will be true even if e.hasOwnProperty(X) is + * false. + */ + this.type = e.type + this.screenX = e.screenX + this.screenY = e.screenY + this.button = e.button + + this.keyCode = e.keyCode + this.charCode = e.charCode + this.ctrlKey = e.ctrlKey + this.altKey = e.altKey + this.shiftKey = e.shiftKey + this.metaKey = e.metaKey + + /* TODO: Test this. */ + if (e.touches) + { + /* TODO: Decide if we want to rely on Array.prototype.map. If not, + * we should provide an implementation. + */ + this.touches = e.touches.map(function (coord) { + return {screenX: coord.screenX, screenY: coord.screenY} + }) + } + + this.state = e.state + this.defaultPrevented = e.defaultPrevented + }, + + subscriptions : {}, //object to store the subscriptions per window + + subscribers : {}, //object to store the subscribers to broadcast to + + requests : {}, //request objects stored until done + + subscribe : function(target, topic, handler){ + // subscribe to messages on certain topics + // post a message to the parent requesting a subscription + // so the parent knows to send messages to this window + // if no target is passed in, just add the handler + if(typeof target == "string"){ + // remap if the target is left out + handler = topic + topic = target + target = window.parent + } + + if(target){ + var payload = new psowapi.Message("epubsc_subscribe", topic) + + // stringify if the browser doesn't support objects + if(subpub.postmessage_usestring()){ + payload = JSON.stringify(payload) + } + + target.postMessage(payload, "*") + } + + // attach the handler here to be fired on receipt of the message + if(topic instanceof Array){ + for(var key in topic){ + var Topic = topic[key] + pushSub(Topic, handler) + } + } + else { + pushSub(topic, handler) + } + + function pushSub(topic, handler){ + if(psowapi.subscriptions[topic] && psowapi.subscriptions[topic].handlers){ + psowapi.subscriptions[topic].handlers.push(handler) + } else { + psowapi.subscriptions[topic] = {} + psowapi.subscriptions[topic].handlers = [] + psowapi.subscriptions[topic].handlers.push(handler) + } + } + }, + + unsubscribe : function(target, topic, handler){ + // remap if target is excluded + if(typeof target == "string"){ + // remap if the target is left out + handler = topic + topic = target + target = window.parent + } + + // unsubscribe from it + var payload = new psowapi.Message("epubsc_unsubscribe", topic) + + // stringify if the browser doesn't support objects + if(subpub.postmessage_usestring()){ + payload = JSON.stringify(payload) + } + + target.postMessage(payload, "*") + + for(var key in psowapi.subscriptions[topic].handlers){ + var Handler = psowapi.subscriptions[topic].handlers[key] + if(Handler == handler){ + delete psowapi.subscriptions[topic].handlers[key] + } + } + }, + + publish : function(topic, message){ + // publish messages to listeners + var payload = new psowapi.Message("epubsc_publish", topic, message), + isEvent = subpub.isEvent(topic) + + // stringify if the browser doesn't support objects + if(subpub.postmessage_usestring()){ + payload = JSON.stringify(payload) + } + + // loop through all subscribers and post a message + // if it's an event, only send to subscribers + if(psowapi.subscribers[topic]){ + var subscribedToParent = false + for(var key in psowapi.subscribers[topic].subscribers){ + var source = psowapi.subscribers[topic].subscribers[key].source + if(source != window.parent || isEvent){ + source.postMessage(payload, "*") + } + else { + subscribedToParent = true + } + } + if(subscribedToParent && !isEvent && window.parent != window){ + window.parent.postMessage(payload, "*") + } + } + }, + + send : function(target, topic, message){ + var payload = new psowapi.Message("epubsc_publish", topic, message) + // stringify if the browser doesn't support objects + if(subpub.postmessage_usestring()){ + payload = JSON.stringify(payload) + } + target.postMessage(payload, "*") + } + } + + // the internal methods for subpub + var subpub = { + messageHandler : function(e){ + // respond to messages here + if(e.data == undefined) e.data = e.originalEvent.data + // check to see if it's a string, then parse it (to support older systems that use JSON (< IE 9)) + if(typeof e.data == "string") { e.data = JSON.parse(e.data) } + console.log("psowapi recieved message - method: "+e.data.method+" - topic: "+e.data.topic) + // get the topic, then fire the position in + // descriptions that holds the handler + if(e.data.type == "epubsc_message") { + switch(e.data.method) { + case "epubsc_subscribe" : + subpub.subscriptionHandler(e) + break + case "epubsc_unsubscribe" : + subpub.unsubscribeHandler(e) + break + case "epubsc_publish" : + subpub.publishHandler(e) + break + case "pxelifecycle" : + subpub.publishHandler(e) + break + case "epubsc_send" : // not clear on how to respond to sent message... is it the same as publish? + subpub.sendHandler(e) + break + default : + console.log("psowapi: unknown method type") + break + } + } + + }, + + eventPublishDictionary : {}, + + /** + * An array of all publishable events. + */ + publishableBrowserEvents : [ + "click", "dblclick", "mousedown", "mouseup", "mousemove", + "keydown", "keypress", "keyup", + "touchstart", "touchend", "touchmove", "touchcancel", + "pointerdown", "pointerup", "pointercancel", "pointermove" + ], + + isEvent : function(topic){ + var isEvent = false + for(var key in subpub.publishableBrowserEvents){ + var Event = subpub.publishableBrowserEvents[key] + if(topic == Event){ + isEvent = true + } + } + return isEvent + }, + + subscriptionHandler : function(e){ + var source = e.source ? e.source : e.originalEvent.source + // check to see if it's an array of subscriptions + if(e.data.topic instanceof Array){ + for(var key in e.data.topic){ + subscribe(e, e.data.topic[key]) + } + } + else { + subscribe(e, e.data.topic) + } + + function subscribe(e, topic){ + // someone is asking to subscribe, handle it here on the receiver side + if(!psowapi.subscribers[topic]){ + psowapi.subscribers[topic] = { + subscribers : {} + } + } + // push the subscriber into the subscribers array for that topic + psowapi.subscribers[topic].subscribers[e.data.widgetId] = { + source : source + } + + // check to see if it's an event being asked for + for(var key in subpub.publishableBrowserEvents){ + var Event = subpub.publishableBrowserEvents[key] + if(topic == Event){ + // it's an event, set up the publishableBrowserEvents and put a listener on the DOM + // and bubble to any children + $("iframe").each(function(index, item){ + // this only happens if the iframe is ready, otherwise it happens on ready + psowapi.subscribe(item.contentWindow, topic, function(e){ + // trigger the event here to push it up the chain + $(window).trigger(Event) + }) + }) + + if (subpub.eventPublishDictionary[Event]){ + if (!subpub.eventPublishDictionary[Event].active){ + // add an event to the window and listen for it + window.addEventListener(Event, subpub.eventPublishDictionary[Event].publish, false) + subpub.eventPublishDictionary[Event].active = true + } + } + } + } + } + }, + unsubscribeHandler: function(e){ + if(e.data.topic instanceof Array){ + for(var key in e.data.topic){ + var topic = e.data.topic[key] + unsubscribe(e, topic) + } + } + else { + unsubscribe(e, e.data.topic) + } + + function unsubscribe(e, topic){ + if(psowapi.subscribers[e.data.topic] != undefined){ + delete psowapi.subscribers[e.data.topic].subscribers[e.data.widgetId] + // if there are no more subscribers, delete the whole topic + var size = 0 + for(var key in psowapi.subscribers[e.data.topic].subscribers){ + if(psowapi.subscribers[e.data.topic].subscribers.hasOwnProperty(key)) size++ + } + if(size === 0) delete psowapi.subscribers[e.data.topic] + + // look for event unsubscribes and take them off appropriately + for(var key in subpub.publishableBrowserEvents){ + var Event = subpub.publishableBrowserEvents[key] + if(topic == Event){ + // it's an event, set up the publishableBrowserEvents and take a listener off the DOM + // and bubble to any children + $("iframe").each(function(index, item){ + psowapi.unsubscribe(item.contentWindow, topic) + }) + + if (subpub.eventPublishDictionary[Event]){ + if (!subpub.eventPublishDictionary[Event].active){ + window.removeEventListener(Event) + subpub.eventPublishDictionary[Event].active = false + } + } + } + } + } + } + }, + publishHandler : function(e){ + var topic = e.data.topic + + // if it's a protected topic, handle it specially + for(var key in subpub.requests){ + var request = subpub.requests[key] + // ignore messages that have a attribute of msgOrigin to ignore key/pair of msgOrigin : pxelifecycle + // the PXE SDK bubbles messages that shouldn't be bubbled + if(topic == request && (e.data.msgOrigin == undefined)){ + subpub.requestHandler(e) + } + } + + // fire off the local handler here + if(psowapi.subscriptions[topic]){ + for(var key in psowapi.subscriptions[topic].handlers){ + var Handler = psowapi.subscriptions[topic].handlers[key] + Handler(e) + } + } + + // it should also be re-broadcast here to all other subscribers + // if it's parent isn't subscribed, you should always broadcast to the parent + // for re-broadcasting, you should always send to parent + // regardless of whether or not it's an event or regular topic + if(psowapi.subscribers[topic]){ + var subscribedToParent = false + for(var key in psowapi.subscribers[topic].subscribers){ + var source = psowapi.subscribers[topic].subscribers[key].source + if(source != window.parent){ + source.postMessage(e.data, "*") + } + else { + subscribedToParent = true + } + } + if(subscribedToParent && window.parent != window){ + window.parent.postMessage(e.data, "*") + } + } + + }, + sendHandler : function(e){ + // not sure if we need anything here yet... + }, + requests : [ + "epubsc_pause", "epubsc_resume" + ], + requestHandler : function(e){ + // protected names to help with API + switch(e.data.topic){ + case "epubsc_pause" : + // re-broadcast on pause to all children + // IDPF required + subpub.rebroadcast(e) + break + case "epubsc_resume" : + // re-broadcast on resume to all children + // IDPF required + subpub.rebroadcast(e) + break + default : + console.log("unsupported request type") + break + } + }, + rebroadcast : function(e){ + // used for pause and resume, blind re-broadcasting + if($("iframe").length > 0){ + $("iframe").each(function(index, item){ + // send it to each child widget if it's not itself + if($(item)[0].contentWindow != e.originalEvent.source){ + psowapi.send($(item)[0].contentWindow, e.data.topic) + } + }) + } + }, + deserializeParams : function(p){ + // strip out %20 from the URL + p = p.replace(/\%20/g, "") + var ret = {}, + seg = p.replace(/^\?/,'').split('&'), + len = seg.length, i = 0, s; + for (;i= 0; + var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ + var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; + // At least Safari 3+: "[object HTMLElementConstructor]" + var isChrome = !!window.chrome && !isOpera; // Chrome 1+ + var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 + var browser = ""; + if (isOpera) + browser = "opera"; + else if (isFirefox) + browser = "firefox"; + else if (isSafari) + browser = "safari"; + else if (isChrome) + browser = "chrome"; + else if (isIE) + browser = "explorer"; + + return browser; +} + +function setPrefixCss3() { + var prefix = ""; + if (getBrowser() == "firefox") + prefix ="-moz-"; + else + prefix ="-webkit-"; + return prefix; +} + + +function isLocationInElement (element, x, y) + { + var elmOffset = $(element).offset(); + if (x >= elmOffset.left && x <= (elmOffset.left + $(element).width()) && + y >= elmOffset.top && y <= (elmOffset.top + $(element).height())) + return true; + return false; + } + +function setNewPos(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element).offset(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } else if (actualPos + deltaMax >= max) { + if (dim == "x") + elementDim = $(element).width(); + else + elementDim = $(element).height(); + newX = max - relativePos - elementDim; + } else { + newX = newPos; + } + } else + newX = newPos; + return newX; +} + +function isLocationInElementDragDropOffset(element, x, y) + { + var elmOffset = $(element)[0].getBoundingClientRect(); + if (x >= elmOffset.left && x <= (elmOffset.left + elmOffset.width) && + y >= elmOffset.top && y <= (elmOffset.top + elmOffset.height)) + return true; + return false; + } + + function setNewPosDragDropOffset(min, max, deltaMin, deltaMax, initialPos, nodePos, relativePos, actualPos, element, dim) +{ + var newX, elementDim; + var newPos = initialPos - nodePos - relativePos + actualPos; + var elmOffset = $(element)[0].getBoundingClientRect(); + if (min != null) { + if (actualPos - deltaMin <= min) { + newX = min - relativePos; + } + else if (actualPos + deltaMax >= max) { + if (dim == "x") { + elementDim = elmOffset.width; + } + else { + elementDim = elmOffset.height; + } + newX = max - relativePos - elementDim; + } + else { + newX = newPos; + } + } + else newX = newPos; + + return newX; +} + +//functions for gravity acceleration actions +function boundingBoxCheckX(posX, objectX, containerObject, ax, isBouncing){ + var minX = 0, maxX = 0, x = posX; + var containerNodeOffset = containerObject.offset(); + var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + + if (xmaxX-objectX) { + x = maxX-objectX; + + } + + return x; +} + +function isBoundingBoxCheckX(posX, objectX, containerObject){ +var minX = 0, maxX = 0, x = posX; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minX = containerNodeOffset.left - generalContainerNodeOffset.left; + maxX = minX + containerObject.width(); + +if (xmaxX-objectX) + return 2; + else + return 0; +} +function boundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + y = maxY-objectY; + +return y; +} + +function isBoundingBoxCheckY(posY, objectY, containerObject){ +var minY = 0, maxY = 0, y = posY; +var containerNodeOffset = containerObject.offset(); +var generalContainerNodeOffset = $(".SCPage").offset(); + minY = containerNodeOffset.top - generalContainerNodeOffset.top; + maxY = minY + containerObject.height(); + +if (ymaxY-objectY) + return 2; +else + return 0 +} + +//function used by rotate.scx +function rotate(objectId,timesRun,howManyTimes,rotationToDegrees,rotationSpeed,effectEasing,transformOriginX,transformOriginY,functionCompleted) { + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + + var rotationToDegreesString; + if (rotationToDegrees.indexOf("-") == -1) + rotationToDegreesString = "+=" + rotationToDegrees; + else + rotationToDegreesString = "-=" + rotationToDegrees.substr(1); + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + + $('#' + objectId).animate({rotate: '' + getScale(objectId) + 'deg'}, {queue: false, duration: 0}); + $('#' + objectId).animate({rotate: '' + rotationToDegreesString + 'deg'}, {queue: false, duration: rotationSpeed, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); +} + +function getScale(obj) { + var angle; + var el = document.getElementById(obj); + var st = window.getComputedStyle(el, null); + var tr = st.getPropertyValue("-webkit-transform") || + st.getPropertyValue("-moz-transform") || + st.getPropertyValue("-ms-transform") || + st.getPropertyValue("-o-transform") || + st.getPropertyValue("transform") || + "fail..."; + +if (st != null && tr != "none") { + + + var values = tr.split('(')[1]; + values = values.split(')')[0]; + values = values.split(','); + var a = values[0]; + var b = values[1]; + var c = values[2]; + var d = values[3]; + + var scale = Math.sqrt(a*a + b*b); + + var sin = b/scale; + angle = Math.round(Math.atan2(b, a) * (180/Math.PI)); +} else { + angle = 0; +} + return angle; +} + + + +//end functions used by rotate.scx +//functions used by scale.scx +function scale(objectId,timesRun,howManyTimes,scaleX,scaleY,effectDurationMS,effectEasing,transformOriginX,transformOriginY,ScaleModeString,functionCompleted) { + switch(effectEasing) { + case "ease-in": + effectEasing = "easieEaseIn"; + break; + case "ease-out": + effectEasing = "easieEaseOut"; + break; + case "linear": + effectEasing = "easieLinear"; + break; + case "ease": + effectEasing = "easieEaseInOut"; + break; + case "bounce-in": + effectEasing = "easeInBounce"; + break; + case "bounce-out": + effectEasing = "easeOutBounce"; + break; + case "elastic-in": + effectEasing = "easeInElastic"; + break; + case "elastic-out": + effectEasing = "easeOutElastic"; + break; +} + $('#' + objectId).css(setPrefixCss3() + 'transform-origin','' + transformOriginX + ' ' + transformOriginY + ''); + $('#' + objectId).animate({scalex: '' + ScaleModeString + scaleX + '', scaley: '' + ScaleModeString + scaleY + ''}, {queue: false, duration: effectDurationMS, easing: effectEasing, complete: function(){ + if (timesRun == howManyTimes) { + functionCompleted(); + } + }}); + +} + +//end functions used by scale + +//functions for float +function getOrientation(isAndroid) { + var orientationName, orientationType; + if (isAndroid) + orientationType = Android.getRotation(); + else + orientationType = window.orientation; + orientationName = switchOrientationName(orientationType, isAndroid); + return orientationName; +} + +function switchOrientationName(orientation, isAndroid) { + var orientationDetected; + var orientationName; + orientationDetected = orientation; + if (orientation == 0 && isAndroid) + orientationDetected = 180; + else if (orientation == 90 && isAndroid) + orientationDetected = -90; + else if (orientation == 180 && isAndroid) + orientationDetected = 0; + else if (orientation == 270 && isAndroid) + orientationDetected = 90; + + var orientationName; + switch(orientationDetected) { + case 0: + orientationName = 'portraitButtonBottom'; + break; + case 90: + orientationName = 'landscapeButtonRight'; + break; + case -90: + orientationName = 'landscapeButtonLeft'; + break; + case 180: + orientationName = 'portraitButtonTop'; + break; + } + return orientationName; +} + +function toggleToc() { + var menuTocHeight = $("#SCNavigationToc").height(); + if (window.tocIsVisible) { + $("#SCNavigationToc").animate({bottom: -menuTocHeight},200,'easieEaseIn',function() { + $("#SCNavigationToc").css("display","none"); + }); + + window.tocIsVisible=false; + } + else + { + $("#SCNavigationToc").css("display","block"); + $("#SCNavigationToc").animate({bottom: 0},200,'easieEaseIn'); + window.tocIsVisible=true; + } +} +//end functions for float + +function showAssetsParity(option){ + if (option == 'even' || option == 'odd') { + $('*[data-pubcoder="' + option + '"]').css('display','block'); + } else { + $('*[data-pubcoder="odd"]').css('display','block'); + $('*[data-pubcoder="even"]').css('display','block'); + } +} + +//initAnimations +function initAnimation(obj,width,height,fps,countVar,isInfinite,howManyLoops,backToFirstFrame) +{ +var frameTime = 1000/fps; +var nextAnimationAfterLastLoop = howManyLoops + 1 +var lastLoop = howManyLoops; +$(obj).spritespin({ + + width : width, // width in pixels of the window/frame + height : height, // height in pixels of the window/frame + animate : false, + renderer: 'image', + loop: true, + frameTime: frameTime, + onFrame: function(e,data) { + var stopAtFrame = data.images.length - 1; + if (!isInfinite) { + var api = $(obj).spritespin('api'); + if (data.frame == 0) { + countVar++; + if (backToFirstFrame && countVar == nextAnimationAfterLastLoop) { + stopAnimation(api,obj); + countVar = 1; + } + } + if (data.frame == stopAtFrame && countVar == lastLoop) { + if (!backToFirstFrame) { + stopAnimation(api,obj); + countVar = 0; + } + } + } + } + }); +function stopAnimation(apiAnimation,object) + { + apiAnimation.stopAnimation(); + $(object).removeClass("playing"); + var objectStripped = object.substr(1); + $(object).trigger(objectStripped + "_animation_ended"); + } +} + +//pubsub general function: +function generateComponentID_() { + var d = new Date().getTime(); + var template = "xxxxxxxx-xxxx-Zxxx-yxxx-xxxxxxxxxxxx"; + return template.replace(/[xy]/g, function (c) { + var r = (d + Math.random() * 16) % 16 | 0; + d = Math.floor(d/16); + return (c == "x" ? r : (r & 0x7 | 0x8)).toString(16); + }); +} + +function generateMessageID_(windowvar) { + windowvar = windowvar + 1; + return windowvar; +} \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/idangerous.swiper-2.3.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/idangerous.swiper-2.3.js new file mode 100644 index 0000000..7d65efb --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/idangerous.swiper-2.3.js @@ -0,0 +1,2479 @@ +/* + * Swiper 2.3 - Mobile Touch Slider + * http://www.idangero.us/sliders/swiper/ + * + * Copyright 2012-2013, Vladimir Kharlampidi + * The iDangero.us + * http://www.idangero.us/ + * + * Licensed under GPL & MIT + * + * Updated on: November 2, 2013 +*/ +var Swiper = function (selector, params) { + /*========================= + A little bit dirty but required part for IE8 and old FF support + ===========================*/ + if (document.body.__defineGetter__) { + if (HTMLElement) { + var element = HTMLElement.prototype; + if (element.__defineGetter__) { + element.__defineGetter__("outerHTML", function () { return new XMLSerializer().serializeToString(this); } ); + } + } + } + + if (!window.getComputedStyle) { + window.getComputedStyle = function (el, pseudo) { + this.el = el; + this.getPropertyValue = function (prop) { + var re = /(\-([a-z]){1})/g; + if (prop === 'float') prop = 'styleFloat'; + if (re.test(prop)) { + prop = prop.replace(re, function () { + return arguments[2].toUpperCase(); + }); + } + return el.currentStyle[prop] ? el.currentStyle[prop] : null; + } + return this; + } + } + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function(obj, start) { + for (var i = (start || 0), j = this.length; i < j; i++) { + if (this[i] === obj) { return i; } + } + return -1; + } + } + if (!document.querySelectorAll) { + if (!window.jQuery) return; + } + function $$(selector, context) { + if (document.querySelectorAll) + return (context || document).querySelectorAll(selector); + else + return jQuery(selector, context); + } + + /*========================= + Check for correct selector + ===========================*/ + if(typeof selector === 'undefined') return; + + if(!(selector.nodeType)){ + if ($$(selector).length === 0) return; + } + + /*========================= + _this + ===========================*/ + var _this = this; + + /*========================= + Default Flags and vars + ===========================*/ + _this.touches = { + start:0, + startX:0, + startY:0, + current:0, + currentX:0, + currentY:0, + diff:0, + abs:0 + }; + _this.positions = { + start:0, + abs:0, + diff:0, + current:0 + }; + _this.times = { + start:0, + end:0 + }; + + _this.id = (new Date()).getTime(); + _this.container = (selector.nodeType) ? selector : $$(selector)[0]; + _this.isTouched = false; + _this.isMoved = false; + _this.activeIndex = 0; + _this.centerIndex = 0; + _this.activeLoaderIndex = 0; + _this.activeLoopIndex = 0; + _this.previousIndex = null; + _this.velocity = 0; + _this.snapGrid = []; + _this.slidesGrid = []; + _this.imagesToLoad = []; + _this.imagesLoaded = 0; + _this.wrapperLeft=0; + _this.wrapperRight=0; + _this.wrapperTop=0; + _this.wrapperBottom=0; + var wrapper, slideSize, wrapperSize, direction, isScrolling, containerSize; + + /*========================= + Default Parameters + ===========================*/ + var defaults = { + mode : 'horizontal', // or 'vertical' + touchRatio : 1, + speed : 300, + freeMode : false, + freeModeFluid : false, + momentumRatio: 1, + momentumBounce: true, + momentumBounceRatio: 1, + slidesPerView : 1, + slidesPerGroup : 1, + simulateTouch : true, + followFinger : true, + shortSwipes : true, + moveStartThreshold:false, + autoplay: false, + onlyExternal : false, + createPagination : true, + pagination : false, + paginationElement: 'span', + paginationClickable: false, + paginationAsRange: true, + resistance : true, // or false or 100% + scrollContainer : false, + preventLinks : true, + noSwiping : false, // or class + noSwipingClass : 'swiper-no-swiping', //:) + initialSlide: 0, + keyboardControl: false, + mousewheelControl : false, + mousewheelDebounce: 600, + useCSS3Transforms : true, + // Autoplay + autoplay: false, + autoplayDisableOnInteraction: false, + //Loop mode + loop:false, + loopAdditionalSlides:0, + //Auto Height + calculateHeight: false, + //Images Preloader + updateOnImagesReady : true, + //Form elements + releaseFormElements : true, + //Watch for active slide, useful when use effects on different slide states + watchActiveIndex: false, + //Slides Visibility Fit + visibilityFullFit : false, + //Slides Offset + offsetPxBefore : 0, + offsetPxAfter : 0, + offsetSlidesBefore : 0, + offsetSlidesAfter : 0, + centeredSlides: false, + //Queue callbacks + queueStartCallbacks : false, + queueEndCallbacks : false, + //Auto Resize + autoResize : true, + resizeReInit : false, + //DOMAnimation + DOMAnimation : true, + //Slides Loader + loader: { + slides:[], //array with slides + slidesHTMLType:'inner', // or 'outer' + surroundGroups: 1, //keep preloaded slides groups around view + logic: 'reload', //or 'change' + loadAllSlides: false + }, + //Namespace + slideElement : 'div', + slideClass : 'swiper-slide', + slideActiveClass : 'swiper-slide-active', + slideVisibleClass : 'swiper-slide-visible', + wrapperClass : 'swiper-wrapper', + paginationElementClass: 'swiper-pagination-switch', + paginationActiveClass : 'swiper-active-switch', + paginationVisibleClass : 'swiper-visible-switch' + } + params = params || {}; + for (var prop in defaults) { + if (prop in params && typeof params[prop]==='object') { + for (var subProp in defaults[prop]) { + if (! (subProp in params[prop])) { + params[prop][subProp] = defaults[prop][subProp]; + } + } + } + else if (! (prop in params)) { + params[prop] = defaults[prop] + } + } + _this.params = params; + if (params.scrollContainer) { + params.freeMode = true; + params.freeModeFluid = true; + } + if (params.loop) { + params.resistance = '100%'; + } + var isH = params.mode==='horizontal'; + + /*========================= + Define Touch Events + ===========================*/ + + _this.touchEvents = { + touchStart : _this.support.touch || !params.simulateTouch ? 'touchstart' : (_this.browser.ie10 ? 'MSPointerDown' : 'mousedown'), + touchMove : _this.support.touch || !params.simulateTouch ? 'touchmove' : (_this.browser.ie10 ? 'MSPointerMove' : 'mousemove'), + touchEnd : _this.support.touch || !params.simulateTouch ? 'touchend' : (_this.browser.ie10 ? 'MSPointerUp' : 'mouseup') + }; + + /*========================= + Wrapper + ===========================*/ + for (var i = _this.container.childNodes.length - 1; i >= 0; i--) { + if (_this.container.childNodes[i].className) { + var _wrapperClasses = _this.container.childNodes[i].className.split(' ') + for (var j = 0; j < _wrapperClasses.length; j++) { + if (_wrapperClasses[j]===params.wrapperClass) { + wrapper = _this.container.childNodes[i]; + } + }; + } + }; + + _this.wrapper = wrapper; + /*========================= + Slide API + ===========================*/ + _this._extendSwiperSlide = function (el) { + el.append = function () { + if (params.loop) { + el.insertAfter(_this.slides.length-_this.loopedSlides); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + _this.wrapper.appendChild(el); + } + + _this.reInit(); + return el; + } + el.prepend = function () { + if (params.loop) { + _this.wrapper.insertBefore(el, _this.slides[_this.loopedSlides]); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + _this.wrapper.insertBefore(el, _this.wrapper.firstChild); + } + _this.reInit(); + return el; + } + el.insertAfter = function (index) { + if(typeof index === 'undefined') return false; + var beforeSlide; + + if (params.loop) { + beforeSlide = _this.slides[index + 1 + _this.loopedSlides]; + _this.wrapper.insertBefore(el, beforeSlide); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else { + beforeSlide = _this.slides[index + 1]; + _this.wrapper.insertBefore(el, beforeSlide) + } + _this.reInit(); + return el; + } + el.clone = function () { + return _this._extendSwiperSlide(el.cloneNode(true)) + } + el.remove = function () { + _this.wrapper.removeChild(el); + _this.reInit(); + } + el.html = function (html) { + if (typeof html === 'undefined') { + return el.innerHTML; + } + else { + el.innerHTML = html; + return el; + } + } + el.index = function () { + var index; + for (var i = _this.slides.length - 1; i >= 0; i--) { + if(el === _this.slides[i]) index = i; + } + return index; + } + el.isActive = function () { + if (el.index() === _this.activeIndex) return true; + else return false; + } + if (!el.swiperSlideDataStorage) el.swiperSlideDataStorage={}; + el.getData = function (name) { + return el.swiperSlideDataStorage[name]; + } + el.setData = function (name, value) { + el.swiperSlideDataStorage[name] = value; + return el; + } + el.data = function (name, value) { + if (!value) { + return el.getAttribute('data-'+name); + } + else { + el.setAttribute('data-'+name,value); + return el; + } + } + el.getWidth = function (outer) { + return _this.h.getWidth(el, outer); + } + el.getHeight = function (outer) { + return _this.h.getHeight(el, outer); + } + el.getOffset = function() { + return _this.h.getOffset(el); + } + return el; + } + + //Calculate information about number of slides + _this.calcSlides = function (forceCalcSlides) { + var oldNumber = _this.slides ? _this.slides.length : false; + _this.slides = []; + _this.displaySlides = []; + for (var i = 0; i < _this.wrapper.childNodes.length; i++) { + if (_this.wrapper.childNodes[i].className) { + var _className = _this.wrapper.childNodes[i].className; + var _slideClasses = _className.split(' '); + for (var j = 0; j < _slideClasses.length; j++) { + if(_slideClasses[j]===params.slideClass) { + _this.slides.push(_this.wrapper.childNodes[i]); + } + } + } + } + for (i = _this.slides.length - 1; i >= 0; i--) { + _this._extendSwiperSlide(_this.slides[i]); + } + if (oldNumber===false) return; + if(oldNumber!==_this.slides.length || forceCalcSlides) { + // Number of slides has been changed + removeSlideEvents(); + addSlideEvents(); + _this.updateActiveSlide(); + if (_this.params.pagination) _this.createPagination(); + _this.callPlugins('numberOfSlidesChanged'); + } + } + + //Create Slide + _this.createSlide = function (html, slideClassList, el) { + var slideClassList = slideClassList || _this.params.slideClass; + var el = el||params.slideElement; + var newSlide = document.createElement(el); + newSlide.innerHTML = html||''; + newSlide.className = slideClassList; + return _this._extendSwiperSlide(newSlide); + } + + //Append Slide + _this.appendSlide = function (html, slideClassList, el) { + if (!html) return; + if (html.nodeType) { + return _this._extendSwiperSlide(html).append() + } + else { + return _this.createSlide(html, slideClassList, el).append() + } + } + _this.prependSlide = function (html, slideClassList, el) { + if (!html) return; + if (html.nodeType) { + return _this._extendSwiperSlide(html).prepend() + } + else { + return _this.createSlide(html, slideClassList, el).prepend() + } + } + _this.insertSlideAfter = function (index, html, slideClassList, el) { + if (typeof index === 'undefined') return false; + if (html.nodeType) { + return _this._extendSwiperSlide(html).insertAfter(index); + } + else { + return _this.createSlide(html, slideClassList, el).insertAfter(index); + } + } + _this.removeSlide = function (index) { + if (_this.slides[index]) { + if (params.loop) { + if (!_this.slides[index+_this.loopedSlides]) return false; + _this.slides[index+_this.loopedSlides].remove(); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else _this.slides[index].remove(); + return true; + } + else return false; + } + _this.removeLastSlide = function () { + if (_this.slides.length>0) { + if (params.loop) { + _this.slides[_this.slides.length - 1 - _this.loopedSlides].remove(); + _this.removeLoopedSlides(); + _this.calcSlides(); + _this.createLoop(); + } + else _this.slides[ (_this.slides.length-1) ].remove(); + return true; + } + else { + return false; + } + } + _this.removeAllSlides = function () { + for (var i = _this.slides.length - 1; i >= 0; i--) { + _this.slides[i].remove() + } + } + _this.getSlide = function (index) { + return _this.slides[index] + } + _this.getLastSlide = function () { + return _this.slides[ _this.slides.length-1 ] + } + _this.getFirstSlide = function () { + return _this.slides[0] + } + + //Currently Active Slide + _this.activeSlide = function () { + return _this.slides[_this.activeIndex] + } + + /*========================= + Plugins API + ===========================*/ + var _plugins = []; + for (var plugin in _this.plugins) { + if (params[plugin]) { + var p = _this.plugins[plugin](_this, params[plugin]); + if (p) _plugins.push( p ); + } + } + _this.callPlugins = function(method, args) { + if (!args) args = {} + for (var i=0; i<_plugins.length; i++) { + if (method in _plugins[i]) { + _plugins[i][method](args); + } + } + } + + /*========================= + WP8 Fix + ===========================*/ + if (_this.browser.ie10 && !params.onlyExternal) { + _this.wrapper.classList.add('swiper-wp8-' + (isH ? 'horizontal' : 'vertical')); + } + + /*========================= + Free Mode Class + ===========================*/ + if (params.freeMode) { + _this.container.className+=' swiper-free-mode'; + } + + /*================================================== + Init/Re-init/Resize Fix + ====================================================*/ + _this.initialized = false; + _this.init = function(force, forceCalcSlides) { + var _width = _this.h.getWidth(_this.container); + var _height = _this.h.getHeight(_this.container); + if (_width===_this.width && _height===_this.height && !force) return; + _this.width = _width; + _this.height = _height; + + containerSize = isH ? _width : _height; + var wrapper = _this.wrapper; + + if (force) { + _this.calcSlides(forceCalcSlides); + } + + if (params.slidesPerView==='auto') { + //Auto mode + var slidesWidth = 0; + var slidesHeight = 0; + + //Unset Styles + if (params.slidesOffset>0) { + wrapper.style.paddingLeft = ''; + wrapper.style.paddingRight = ''; + wrapper.style.paddingTop = ''; + wrapper.style.paddingBottom = ''; + } + wrapper.style.width = ''; + wrapper.style.height = ''; + if (params.offsetPxBefore>0) { + if (isH) _this.wrapperLeft = params.offsetPxBefore; + else _this.wrapperTop = params.offsetPxBefore; + } + if (params.offsetPxAfter>0) { + if (isH) _this.wrapperRight = params.offsetPxAfter; + else _this.wrapperBottom = params.offsetPxAfter; + } + + if (params.centeredSlides) { + if (isH) { + _this.wrapperLeft = (containerSize - this.slides[0].getWidth(true) )/2; + _this.wrapperRight = (containerSize - _this.slides[ _this.slides.length-1 ].getWidth(true))/2; + } + else { + _this.wrapperTop = (containerSize - _this.slides[0].getHeight(true))/2; + _this.wrapperBottom = (containerSize - _this.slides[ _this.slides.length-1 ].getHeight(true))/2; + } + } + + if (isH) { + if (_this.wrapperLeft>=0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; + if (_this.wrapperRight>=0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + } + else { + if (_this.wrapperTop>=0) wrapper.style.paddingTop = _this.wrapperTop+'px'; + if (_this.wrapperBottom>=0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + } + var slideLeft = 0; + var centeredSlideLeft=0; + _this.snapGrid = []; + _this.slidesGrid = []; + + var slideMaxHeight = 0; + for(var i = 0; i<_this.slides.length; i++) { + var slideWidth = _this.slides[i].getWidth(true); + var slideHeight = _this.slides[i].getHeight(true); + if (params.calculateHeight) { + slideMaxHeight = Math.max(slideMaxHeight, slideHeight) + } + var _slideSize = isH ? slideWidth : slideHeight; + if (params.centeredSlides) { + var nextSlideWidth = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getWidth(true); + var nextSlideHeight = i === _this.slides.length-1 ? 0 : _this.slides[i+1].getHeight(true); + var nextSlideSize = isH ? nextSlideWidth : nextSlideHeight; + if (_slideSize>containerSize) { + for (var j=0; j<=Math.floor(_slideSize/(containerSize+_this.wrapperLeft)); j++) { + if (j === 0) _this.snapGrid.push(slideLeft+_this.wrapperLeft); + else _this.snapGrid.push(slideLeft+_this.wrapperLeft+containerSize*j); + } + _this.slidesGrid.push(slideLeft+_this.wrapperLeft); + } + else { + _this.snapGrid.push(centeredSlideLeft); + _this.slidesGrid.push(centeredSlideLeft); + } + + centeredSlideLeft += _slideSize/2 + nextSlideSize/2; + + } + else { + if (_slideSize>containerSize) { + for (var j=0; j<=Math.floor(_slideSize/containerSize); j++) { + _this.snapGrid.push(slideLeft+containerSize*j); + } + } + else { + _this.snapGrid.push(slideLeft); + } + _this.slidesGrid.push(slideLeft); + } + + slideLeft += _slideSize; + + slidesWidth += slideWidth; + slidesHeight += slideHeight; + } + if (params.calculateHeight) _this.height = slideMaxHeight; + if(isH) { + wrapperSize = slidesWidth + _this.wrapperRight + _this.wrapperLeft; + wrapper.style.width = (slidesWidth)+'px'; + wrapper.style.height = (_this.height)+'px'; + } + else { + wrapperSize = slidesHeight + _this.wrapperTop + _this.wrapperBottom; + wrapper.style.width = (_this.width)+'px'; + wrapper.style.height = (slidesHeight)+'px'; + } + + } + else if (params.scrollContainer) { + //Scroll Container + wrapper.style.width = ''; + wrapper.style.height = ''; + var wrapperWidth = _this.slides[0].getWidth(true); + var wrapperHeight = _this.slides[0].getHeight(true); + wrapperSize = isH ? wrapperWidth : wrapperHeight; + wrapper.style.width = wrapperWidth+'px'; + wrapper.style.height = wrapperHeight+'px'; + slideSize = isH ? wrapperWidth : wrapperHeight; + + } + else { + //For usual slides + if (params.calculateHeight) { + var slideMaxHeight = 0; + var wrapperHeight = 0; + //ResetWrapperSize + if (!isH) _this.container.style.height= ''; + wrapper.style.height=''; + + for (var i=0; i<_this.slides.length; i++) { + //ResetSlideSize + _this.slides[i].style.height=''; + slideMaxHeight = Math.max( _this.slides[i].getHeight(true), slideMaxHeight ); + if (!isH) wrapperHeight+=_this.slides[i].getHeight(true); + } + var slideHeight = slideMaxHeight; + _this.height = slideHeight; + + if (isH) wrapperHeight = slideHeight; + else containerSize = slideHeight, _this.container.style.height= containerSize+'px'; + } + else { + var slideHeight = isH ? _this.height : _this.height/params.slidesPerView; + var wrapperHeight = isH ? _this.height : _this.slides.length*slideHeight; + } + var slideWidth = isH ? _this.width/params.slidesPerView : _this.width; + var wrapperWidth = isH ? _this.slides.length*slideWidth : _this.width; + slideSize = isH ? slideWidth : slideHeight; + + if (params.offsetSlidesBefore>0) { + if (isH) _this.wrapperLeft = slideSize*params.offsetSlidesBefore; + else _this.wrapperTop = slideSize*params.offsetSlidesBefore; + } + if (params.offsetSlidesAfter>0) { + if (isH) _this.wrapperRight = slideSize*params.offsetSlidesAfter; + else _this.wrapperBottom = slideSize*params.offsetSlidesAfter; + } + if (params.offsetPxBefore>0) { + if (isH) _this.wrapperLeft = params.offsetPxBefore; + else _this.wrapperTop = params.offsetPxBefore; + } + if (params.offsetPxAfter>0) { + if (isH) _this.wrapperRight = params.offsetPxAfter; + else _this.wrapperBottom = params.offsetPxAfter; + } + if (params.centeredSlides) { + if (isH) { + _this.wrapperLeft = (containerSize - slideSize)/2; + _this.wrapperRight = (containerSize - slideSize)/2; + } + else { + _this.wrapperTop = (containerSize - slideSize)/2; + _this.wrapperBottom = (containerSize - slideSize)/2; + } + } + if (isH) { + if (_this.wrapperLeft>0) wrapper.style.paddingLeft = _this.wrapperLeft+'px'; + if (_this.wrapperRight>0) wrapper.style.paddingRight = _this.wrapperRight+'px'; + } + else { + if (_this.wrapperTop>0) wrapper.style.paddingTop = _this.wrapperTop+'px'; + if (_this.wrapperBottom>0) wrapper.style.paddingBottom = _this.wrapperBottom+'px'; + } + + wrapperSize = isH ? wrapperWidth + _this.wrapperRight + _this.wrapperLeft : wrapperHeight + _this.wrapperTop + _this.wrapperBottom; + wrapper.style.width = wrapperWidth+'px'; + wrapper.style.height = wrapperHeight+'px'; + var slideLeft = 0; + _this.snapGrid = []; + _this.slidesGrid = []; + for (var i=0; i<_this.slides.length; i++) { + _this.snapGrid.push(slideLeft); + _this.slidesGrid.push(slideLeft); + slideLeft+=slideSize; + _this.slides[i].style.width = slideWidth+'px'; + _this.slides[i].style.height = slideHeight+'px'; + } + + } + + if (!_this.initialized) { + _this.callPlugins('onFirstInit'); + if (params.onFirstInit) params.onFirstInit(_this); + } + else { + _this.callPlugins('onInit'); + if (params.onInit) params.onInit(_this); + } + _this.initialized = true; + } + + _this.reInit = function (forceCalcSlides) { + _this.init(true, forceCalcSlides); + } + + _this.resizeFix = function (reInit) { + _this.callPlugins('beforeResizeFix'); + + _this.init(params.resizeReInit || reInit); + + // swipe to active slide in fixed mode + if (!params.freeMode) { + _this.swipeTo((params.loop ? _this.activeLoopIndex : _this.activeIndex), 0, false); + } + + // move wrapper to the beginning in free mode + else if (_this.getWrapperTranslate() < -maxWrapperPosition()) { + _this.setWrapperTransition(0); + _this.setWrapperTranslate(-maxWrapperPosition()); + } + + _this.callPlugins('afterResizeFix'); + } + + /*========================================== + Max and Min Positions + ============================================*/ + function maxWrapperPosition() { + var a = (wrapperSize - containerSize); + if (params.freeMode) { + a = wrapperSize - containerSize; + } + // if (params.loop) a -= containerSize; + if (params.slidesPerView > _this.slides.length) a = 0; + if (a<0) a = 0; + return a; + } + function minWrapperPosition() { + var a = 0; + // if (params.loop) a = containerSize; + return a; + } + + /*========================================== + Event Listeners + ============================================*/ + function initEvents() { + var bind = _this.h.addEventListener; + + //Touch Events + if (!_this.browser.ie10) { + if (_this.support.touch) { + bind(_this.wrapper, 'touchstart', onTouchStart); + bind(_this.wrapper, 'touchmove', onTouchMove); + bind(_this.wrapper, 'touchend', onTouchEnd); + } + if (params.simulateTouch) { + bind(_this.wrapper, 'mousedown', onTouchStart); + bind(document, 'mousemove', onTouchMove); + bind(document, 'mouseup', onTouchEnd); + } + } + else { + bind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); + bind(document, _this.touchEvents.touchMove, onTouchMove); + bind(document, _this.touchEvents.touchEnd, onTouchEnd); + } + + //Resize Event + if (params.autoResize) { + bind(window, 'resize', _this.resizeFix); + } + //Slide Events + addSlideEvents(); + //Mousewheel + _this._wheelEvent = false; + if (params.mousewheelControl) { + if ( document.onmousewheel !== undefined ) { + _this._wheelEvent = "mousewheel"; + } + try { + WheelEvent("wheel"); + _this._wheelEvent = "wheel"; + } catch (e) {} + if ( !_this._wheelEvent ) { + _this._wheelEvent = "DOMMouseScroll"; + } + + if (_this._wheelEvent) { + bind(_this.container, _this._wheelEvent, handleMousewheel); + } + } + + //Keyboard + if (params.keyboardControl) { + bind(document, 'keydown', handleKeyboardKeys); + } + if (params.updateOnImagesReady) { + _this.imagesToLoad = $$('img', _this.container); + + for (var i=0; i<_this.imagesToLoad.length; i++) { + _loadImage(_this.imagesToLoad[i].getAttribute('src')) + } + } + function _loadImage(src) { + var image = new Image(); + image.onload = function(){ + _this.imagesLoaded++; + if (_this.imagesLoaded==_this.imagesToLoad.length) { + _this.reInit(); + if (params.onImagesReady) params.onImagesReady(_this); + } + } + image.src = src; + } + } + + //Remove Event Listeners + _this.destroy = function(removeResizeFix){ + var unbind = _this.h.removeEventListener; + + //Touch Events + if (!_this.browser.ie10) { + if (_this.support.touch) { + unbind(_this.wrapper, 'touchstart', onTouchStart); + unbind(_this.wrapper, 'touchmove', onTouchMove); + unbind(_this.wrapper, 'touchend', onTouchEnd); + } + if (params.simulateTouch) { + unbind(_this.wrapper, 'mousedown', onTouchStart); + unbind(document, 'mousemove', onTouchMove); + unbind(document, 'mouseup', onTouchEnd); + } + } + else { + unbind(_this.wrapper, _this.touchEvents.touchStart, onTouchStart); + unbind(document, _this.touchEvents.touchMove, onTouchMove); + unbind(document, _this.touchEvents.touchEnd, onTouchEnd); + } + + //Resize Event + if (params.autoResize) { + unbind(window, 'resize', _this.resizeFix); + } + + //Init Slide Events + removeSlideEvents(); + + //Pagination + if (params.paginationClickable) { + removePaginationEvents(); + } + + //Mousewheel + if (params.mousewheelControl && _this._wheelEvent) { + unbind(_this.container, _this._wheelEvent, handleMousewheel); + } + + //Keyboard + if (params.keyboardControl) { + unbind(document, 'keydown', handleKeyboardKeys); + } + + //Stop autoplay + if (params.autoplay) { + _this.stopAutoplay(); + } + _this.callPlugins('onDestroy'); + + //Destroy variable + _this = null; + } + function addSlideEvents() { + var bind = _this.h.addEventListener, + i; + + //Prevent Links Events + if (params.preventLinks) { + var links = $$('a', _this.container); + for (i=0; i=scrollLeft && point[0]<=scrollLeft+windowWidth && + point[1]>=scrollTop && point[1]<=scrollTop+windowHeight + ) { + inView = true; + } + + } + if (!inView) return; + } + if (isH) { + if (kc==37 || kc==39) { + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + } + if (kc == 39) _this.swipeNext(); + if (kc == 37) _this.swipePrev(); + } + else { + if (kc==38 || kc==40) { + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + } + if (kc == 40) _this.swipeNext(); + if (kc == 38) _this.swipePrev(); + } + } + + /*========================================== + Mousewheel Control + ============================================*/ + var allowScrollChange = true; + function handleMousewheel (e) { + var we = _this._wheelEvent; + var delta; + //Opera & IE + if (e.detail) delta = -e.detail; + //WebKits + else if (we == 'mousewheel') delta = e.wheelDelta; + //Old FireFox + else if (we == 'DOMMouseScroll') delta = -e.detail; + //New FireFox + else if (we == 'wheel') { + delta = Math.abs(e.deltaX)>Math.abs(e.deltaY) ? - e.deltaX : - e.deltaY; + } + if (!params.freeMode) { + if(delta<0) _this.swipeNext(); + else _this.swipePrev(); + } + else { + //Freemode or scrollContainer: + var position = _this.getWrapperTranslate() + delta; + + if (position > 0) position = 0; + if (position < -maxWrapperPosition()) position = -maxWrapperPosition(); + + _this.setWrapperTransition(0); + _this.setWrapperTranslate(position); + _this.updateActiveSlide(position); + } + if (params.autoplay) _this.stopAutoplay(true); + + if(e.preventDefault) e.preventDefault(); + else e.returnValue = false; + return false; + } + + /*========================= + Grab Cursor + ===========================*/ + if (params.grabCursor) { + var containerStyle = _this.container.style; + containerStyle.cursor = 'move'; + containerStyle.cursor = 'grab'; + containerStyle.cursor = '-moz-grab'; + containerStyle.cursor = '-webkit-grab'; + } + + /*========================= + Slides Events Handlers + ===========================*/ + + _this.allowSlideClick = true; + function slideClick(event) { + //hack PubCoder + event.preventDefault(); + if (_this.allowSlideClick) { + setClickedSlide(event); + params.onSlideClick(_this, event); + } + } + + function slideTouch(event) { + setClickedSlide(event); + params.onSlideTouch(_this, event); + } + + function setClickedSlide(event) { + //hack PubCoder + event.preventDefault(); + // IE 6-8 support + if (!event.currentTarget) { + var element = event.srcElement; + do { + if (element.className.indexOf(params.slideClass) > -1) { + break; + } + } + while (element = element.parentNode); + _this.clickedSlide = element; + } + else { + _this.clickedSlide = event.currentTarget; + } + + _this.clickedSlideIndex = _this.slides.indexOf(_this.clickedSlide); + _this.clickedSlideLoopIndex = _this.clickedSlideIndex - (_this.loopedSlides || 0); + } + + _this.allowLinks = true; + function preventClick(e) { + if (!_this.allowLinks) { + if(e.preventDefault) e.preventDefault(); + else e.returnValue = false; + return false; + } + } + function releaseForms(e) { + if (e.stopPropagation) e.stopPropagation(); + else e.returnValue = false; + return false; + + } + + /*================================================== + Event Handlers + ====================================================*/ + var isTouchEvent = false; + var allowThresholdMove; + var allowMomentumBounce = true; + function onTouchStart(event) { + if (params.preventLinks) _this.allowLinks = true; + //Exit if slider is already was touched + if (_this.isTouched || params.onlyExternal) { + return false; + } + + if (params.noSwiping && (event.target || event.srcElement) && noSwipingSlide(event.target || event.srcElement)) return false; + allowMomentumBounce = false; + + //Check For Nested Swipers + _this.isTouched = true; + isTouchEvent = event.type=='touchstart'; + + if (!isTouchEvent || event.targetTouches.length == 1 ) { + _this.callPlugins('onTouchStartBegin'); + + if(!isTouchEvent) { + if(event.preventDefault) event.preventDefault(); + else event.returnValue = false; + } + + var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); + var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); + + //Start Touches to check the scrolling + _this.touches.startX = _this.touches.currentX = pageX; + _this.touches.startY = _this.touches.currentY = pageY; + + _this.touches.start = _this.touches.current = isH ? pageX : pageY; + + //Set Transition Time to 0 + _this.setWrapperTransition(0); + + //Get Start Translate Position + _this.positions.start = _this.positions.current = _this.getWrapperTranslate(); + + //Set Transform + _this.setWrapperTranslate(_this.positions.start); + + //TouchStartTime + _this.times.start = (new Date()).getTime(); + + //Unset Scrolling + isScrolling = undefined; + + //Set Treshold + if (params.moveStartThreshold>0) allowThresholdMove = false; + + //CallBack + if (params.onTouchStart) params.onTouchStart(_this); + _this.callPlugins('onTouchStartEnd'); + + } + } + var velocityPrevPosition, velocityPrevTime; + function onTouchMove(event) { + // If slider is not touched - exit + if (!_this.isTouched || params.onlyExternal) return; + if (isTouchEvent && event.type=='mousemove') return; + + var pageX = isTouchEvent ? event.targetTouches[0].pageX : (event.pageX || event.clientX); + var pageY = isTouchEvent ? event.targetTouches[0].pageY : (event.pageY || event.clientY); + + //check for scrolling + if ( typeof isScrolling === 'undefined' && isH) { + isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) > Math.abs( pageX - _this.touches.startX ) ); + } + if ( typeof isScrolling === 'undefined' && !isH) { + isScrolling = !!( isScrolling || Math.abs(pageY - _this.touches.startY) < Math.abs( pageX - _this.touches.startX ) ); + } + if (isScrolling ) { + _this.isTouched = false; + return; + } + + //Check For Nested Swipers + if (event.assignedToSwiper) { + _this.isTouched = false; + return; + } + event.assignedToSwiper = true; + + //Block inner links + if (params.preventLinks) { + _this.allowLinks = false; + } + if (params.onSlideClick) { + _this.allowSlideClick = false; + } + + //Stop AutoPlay if exist + if (params.autoplay) { + _this.stopAutoplay(true); + } + if (!isTouchEvent || event.touches.length == 1) { + + //Moved Flag + if (!_this.isMoved) { + _this.callPlugins('onTouchMoveStart'); + + if (params.loop) { + _this.fixLoop(); + _this.positions.start = _this.getWrapperTranslate(); + } + if (params.onTouchMoveStart) params.onTouchMoveStart(_this); + } + _this.isMoved = true; + + // cancel event + if(event.preventDefault) event.preventDefault(); + else event.returnValue = false; + + _this.touches.current = isH ? pageX : pageY ; + + _this.positions.current = (_this.touches.current - _this.touches.start) * params.touchRatio + _this.positions.start; + + //Resistance Callbacks + if(_this.positions.current > 0 && params.onResistanceBefore) { + params.onResistanceBefore(_this, _this.positions.current); + } + if(_this.positions.current < -maxWrapperPosition() && params.onResistanceAfter) { + params.onResistanceAfter(_this, Math.abs(_this.positions.current + maxWrapperPosition())); + } + //Resistance + if (params.resistance && params.resistance!='100%') { + //Resistance for Negative-Back sliding + if(_this.positions.current > 0) { + var resistance = 1 - _this.positions.current/containerSize/2; + if (resistance < 0.5) + _this.positions.current = (containerSize/2); + else + _this.positions.current = _this.positions.current * resistance; + } + //Resistance for After-End Sliding + if ( _this.positions.current < -maxWrapperPosition() ) { + + var diff = (_this.touches.current - _this.touches.start)*params.touchRatio + (maxWrapperPosition()+_this.positions.start); + var resistance = (containerSize+diff)/(containerSize); + var newPos = _this.positions.current-diff*(1-resistance)/2; + var stopPos = -maxWrapperPosition() - containerSize/2; + + if (newPos < stopPos || resistance<=0) + _this.positions.current = stopPos; + else + _this.positions.current = newPos; + } + } + if (params.resistance && params.resistance=='100%') { + //Resistance for Negative-Back sliding + if(_this.positions.current > 0 && !(params.freeMode&&!params.freeModeFluid)) { + _this.positions.current = 0; + } + //Resistance for After-End Sliding + if ( (_this.positions.current) < -maxWrapperPosition() && !(params.freeMode&&!params.freeModeFluid)) { + _this.positions.current = -maxWrapperPosition(); + } + } + //Move Slides + if (!params.followFinger) return; + + if (!params.moveStartThreshold) { + _this.setWrapperTranslate(_this.positions.current); + } + else { + if ( Math.abs(_this.touches.current - _this.touches.start)>params.moveStartThreshold || allowThresholdMove) { + allowThresholdMove = true; + _this.setWrapperTranslate(_this.positions.current); + } + else { + _this.positions.current = _this.positions.start; + } + } + + if (params.freeMode || params.watchActiveIndex) { + _this.updateActiveSlide(_this.positions.current); + } + + //Grab Cursor + if (params.grabCursor) { + _this.container.style.cursor = 'move'; + _this.container.style.cursor = 'grabbing'; + _this.container.style.cursor = '-moz-grabbin'; + _this.container.style.cursor = '-webkit-grabbing'; + } + //Velocity + if (!velocityPrevPosition) velocityPrevPosition = _this.touches.current; + if (!velocityPrevTime) velocityPrevTime = (new Date).getTime(); + _this.velocity = (_this.touches.current - velocityPrevPosition)/((new Date).getTime() - velocityPrevTime)/2; + if (Math.abs(_this.touches.current - velocityPrevPosition)<2) _this.velocity=0; + velocityPrevPosition = _this.touches.current; + velocityPrevTime = (new Date).getTime(); + //Callbacks + _this.callPlugins('onTouchMoveEnd'); + if (params.onTouchMove) params.onTouchMove(_this); + + return false; + } + } + function onTouchEnd(event) { + //Check For scrolling + if (isScrolling) { + _this.swipeReset(); + } + // If slider is not touched exit + if ( params.onlyExternal || !_this.isTouched ) return; + _this.isTouched = false + + //Return Grab Cursor + if (params.grabCursor) { + _this.container.style.cursor = 'move'; + _this.container.style.cursor = 'grab'; + _this.container.style.cursor = '-moz-grab'; + _this.container.style.cursor = '-webkit-grab'; + } + + //Check for Current Position + if (!_this.positions.current && _this.positions.current!==0) { + _this.positions.current = _this.positions.start + } + + //For case if slider touched but not moved + if (params.followFinger) { + _this.setWrapperTranslate(_this.positions.current); + } + + // TouchEndTime + _this.times.end = (new Date()).getTime(); + + //Difference + _this.touches.diff = _this.touches.current - _this.touches.start + _this.touches.abs = Math.abs(_this.touches.diff) + + _this.positions.diff = _this.positions.current - _this.positions.start + _this.positions.abs = Math.abs(_this.positions.diff) + + var diff = _this.positions.diff ; + var diffAbs =_this.positions.abs ; + var timeDiff = _this.times.end - _this.times.start + + if(diffAbs < 5 && (timeDiff) < 300 && _this.allowLinks == false) { + if (!params.freeMode && diffAbs!=0) _this.swipeReset() + //Release inner links + if (params.preventLinks) { + _this.allowLinks = true; + } + if (params.onSlideClick) { + _this.allowSlideClick = true; + } + } + + setTimeout(function () { + //Release inner links + if (params.preventLinks) { + _this.allowLinks = true; + } + if (params.onSlideClick) { + _this.allowSlideClick = true; + } + }, 100); + + var maxPosition = maxWrapperPosition(); + + //Not moved or Prevent Negative Back Sliding/After-End Sliding + if (!_this.isMoved && params.freeMode) { + _this.isMoved = false; + if (params.onTouchEnd) params.onTouchEnd(_this); + _this.callPlugins('onTouchEnd'); + return; + } + if (!_this.isMoved || _this.positions.current > 0 || _this.positions.current < -maxPosition) { + _this.swipeReset(); + if (params.onTouchEnd) params.onTouchEnd(_this); + _this.callPlugins('onTouchEnd'); + return; + } + + _this.isMoved = false; + + //Free Mode + if (params.freeMode) { + if ( params.freeModeFluid ) { + var momentumDuration = 1000*params.momentumRatio; + var momentumDistance = _this.velocity*momentumDuration; + var newPosition = _this.positions.current + momentumDistance + var doBounce = false; + var afterBouncePosition; + var bounceAmount = Math.abs( _this.velocity )*20*params.momentumBounceRatio; + if (newPosition < -maxPosition) { + if (params.momentumBounce && _this.support.transitions) { + if (newPosition + maxPosition < -bounceAmount) newPosition = -maxPosition-bounceAmount; + afterBouncePosition = -maxPosition; + doBounce=true; + allowMomentumBounce = true; + } + else newPosition = -maxPosition; + } + if (newPosition > 0) { + if (params.momentumBounce && _this.support.transitions) { + if (newPosition>bounceAmount) newPosition = bounceAmount; + afterBouncePosition = 0 + doBounce = true; + allowMomentumBounce = true; + } + else newPosition = 0; + } + //Fix duration + if (_this.velocity!=0) momentumDuration = Math.abs((newPosition - _this.positions.current)/_this.velocity) + + _this.setWrapperTranslate(newPosition); + + _this.setWrapperTransition( momentumDuration ); + + if (params.momentumBounce && doBounce) { + _this.wrapperTransitionEnd(function () { + if (!allowMomentumBounce) return; + + if (params.onMomentumBounce) params.onMomentumBounce(_this); + + _this.setWrapperTranslate(afterBouncePosition); + _this.setWrapperTransition(300); + }) + } + + _this.updateActiveSlide(newPosition) + } + if (!params.freeModeFluid || timeDiff >= 300) _this.updateActiveSlide(_this.positions.current) + + if (params.onTouchEnd) params.onTouchEnd(_this) + _this.callPlugins('onTouchEnd'); + return; + } + + //Direction + direction = diff < 0 ? "toNext" : "toPrev" + + //Short Touches + if (direction=="toNext" && ( timeDiff <= 300 ) ) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + else _this.swipeNext(true); + } + + if (direction=="toPrev" && ( timeDiff <= 300 ) ) { + if (diffAbs < 30 || !params.shortSwipes) _this.swipeReset() + else _this.swipePrev(true); + } + + //Long Touches + var targetSlideSize = 0; + if(params.slidesPerView == 'auto') { + //Define current slide's width + var currentPosition = Math.abs(_this.getWrapperTranslate()); + var slidesOffset = 0; + var _slideSize; + for (var i=0; i<_this.slides.length; i++) { + _slideSize = isH ? _this.slides[i].getWidth(true) : _this.slides[i].getHeight(true); + slidesOffset+= _slideSize; + if (slidesOffset>currentPosition) { + targetSlideSize = _slideSize; + break; + } + } + if (targetSlideSize>containerSize) targetSlideSize = containerSize; + } + else { + targetSlideSize = slideSize * params.slidesPerView; + } + if (direction=="toNext" && ( timeDiff > 300 ) ) { + if (diffAbs >= targetSlideSize*0.5) { + _this.swipeNext(true) + } + else { + _this.swipeReset() + } + } + if (direction=="toPrev" && ( timeDiff > 300 ) ) { + if (diffAbs >= targetSlideSize*0.5) { + _this.swipePrev(true); + } + else { + _this.swipeReset() + } + } + if (params.onTouchEnd) params.onTouchEnd(_this) + _this.callPlugins('onTouchEnd'); + } + + + /*================================================== + noSwiping Bubble Check by Isaac Strack + ====================================================*/ + function noSwipingSlide(el){ + /*This function is specifically designed to check the parent elements for the noSwiping class, up to the wrapper. + We need to check parents because while onTouchStart bubbles, _this.isTouched is checked in onTouchStart, which stops the bubbling. + So, if a text box, for example, is the initial target, and the parent slide container has the noSwiping class, the _this.isTouched + check will never find it, and what was supposed to be noSwiping is able to be swiped. + This function will iterate up and check for the noSwiping class in parents, up through the wrapperClass.*/ + + // First we create a truthy variable, which is that swiping is allowd (noSwiping = false) + var noSwiping = false; + + // Now we iterate up (parentElements) until we reach the node with the wrapperClass. + do{ + + // Each time, we check to see if there's a 'swiper-no-swiping' class (noSwipingClass). + if (el.className.indexOf(params.noSwipingClass)>-1) + { + noSwiping = true; // If there is, we set noSwiping = true; + } + + el = el.parentElement; // now we iterate up (parent node) + + } while(!noSwiping && el.parentElement && el.className.indexOf(params.wrapperClass)==-1); // also include el.parentElement truthy, just in case. + + // because we didn't check the wrapper itself, we do so now, if noSwiping is false: + if (!noSwiping && el.className.indexOf(params.wrapperClass)>-1 && el.className.indexOf(params.noSwipingClass)>-1) + noSwiping = true; // if the wrapper has the noSwipingClass, we set noSwiping = true; + + return noSwiping; + } + + /*================================================== + Swipe Functions + ====================================================*/ + _this.swipeNext = function(internal){ + if (!internal && params.loop) _this.fixLoop(); + if (!internal && params.autoplay) _this.stopAutoplay(true); + _this.callPlugins('onSwipeNext'); + var currentPosition = _this.getWrapperTranslate(); + var newPosition = currentPosition; + if (params.slidesPerView=='auto') { + for (var i=0; i<_this.snapGrid.length; i++) { + if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + newPosition = -_this.snapGrid[i+1] + break; + } + } + } + else { + var groupSize = slideSize * params.slidesPerGroup; + newPosition = -(Math.floor(Math.abs(currentPosition)/Math.floor(groupSize))*groupSize + groupSize); + } + if (newPosition < - maxWrapperPosition()) { + newPosition = - maxWrapperPosition() + }; + + if (newPosition == currentPosition) return false; + + swipeToPosition(newPosition, 'next'); + return true + } + _this.swipePrev = function(internal){ + if (!internal && params.loop) _this.fixLoop(); + if (!internal && params.autoplay) _this.stopAutoplay(true); + _this.callPlugins('onSwipePrev'); + + var currentPosition = Math.ceil(_this.getWrapperTranslate()); + var newPosition; + if (params.slidesPerView=='auto') { + newPosition = 0; + for (var i=1; i<_this.snapGrid.length; i++) { + if (-currentPosition == _this.snapGrid[i]) { + newPosition = -_this.snapGrid[i-1] + break; + } + if (-currentPosition > _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + newPosition = -_this.snapGrid[i] + break; + } + } + } + else { + var groupSize = slideSize * params.slidesPerGroup; + newPosition = -(Math.ceil(-currentPosition/groupSize)-1)*groupSize; + } + + if (newPosition > 0) newPosition = 0; + + if (newPosition == currentPosition) return false; + swipeToPosition(newPosition, 'prev'); + return true; + + } + _this.swipeReset = function(){ + _this.callPlugins('onSwipeReset'); + var currentPosition = _this.getWrapperTranslate(); + var groupSize = slideSize * params.slidesPerGroup; + var newPosition; + var maxPosition = -maxWrapperPosition(); + if (params.slidesPerView=='auto') { + newPosition = 0; + for (var i=0; i<_this.snapGrid.length; i++) { + if (-currentPosition===_this.snapGrid[i]) return; + if (-currentPosition >= _this.snapGrid[i] && -currentPosition<_this.snapGrid[i+1]) { + if(_this.positions.diff>0) newPosition = -_this.snapGrid[i+1] + else newPosition = -_this.snapGrid[i] + break; + } + } + if (-currentPosition >= _this.snapGrid[_this.snapGrid.length-1]) newPosition = -_this.snapGrid[_this.snapGrid.length-1]; + if (currentPosition <= -maxWrapperPosition()) newPosition = -maxWrapperPosition() + } + else { + newPosition = currentPosition<0 ? Math.round(currentPosition/groupSize)*groupSize : 0 + } + if (params.scrollContainer) { + newPosition = currentPosition<0 ? currentPosition : 0; + } + if (newPosition < -maxWrapperPosition()) { + newPosition = -maxWrapperPosition() + } + if (params.scrollContainer && (containerSize>slideSize)) { + newPosition = 0; + } + + if (newPosition == currentPosition) return false; + + swipeToPosition(newPosition, 'reset'); + return true; + } + + _this.swipeTo = function(index, speed, runCallbacks) { + index = parseInt(index, 10); + _this.callPlugins('onSwipeTo', {index:index, speed:speed}); + if (params.loop) index = index + _this.loopedSlides; + var currentPosition = _this.getWrapperTranslate(); + if (index > (_this.slides.length-1) || index < 0) return; + var newPosition + if (params.slidesPerView=='auto') { + newPosition = -_this.slidesGrid[ index ]; + } + else { + newPosition = -index*slideSize; + } + if (newPosition < - maxWrapperPosition()) { + newPosition = - maxWrapperPosition(); + }; + + if (newPosition == currentPosition) return false; + + runCallbacks = runCallbacks===false ? false : true; + swipeToPosition(newPosition, 'to', {index:index, speed:speed, runCallbacks:runCallbacks}); + return true; + } + + function swipeToPosition(newPosition, action, toOptions) { + var speed = (action=='to' && toOptions.speed >= 0) ? toOptions.speed : params.speed; + + if (_this.support.transitions || !params.DOMAnimation) { + _this.setWrapperTranslate(newPosition); + _this.setWrapperTransition(speed); + } + else { + //Try the DOM animation + var currentPosition = _this.getWrapperTranslate(); + var animationStep = Math.ceil( (newPosition - currentPosition)/speed*(1000/60) ); + var direction = currentPosition > newPosition ? 'toNext' : 'toPrev'; + var condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; + if (_this._DOMAnimating) return; + + anim(); + } + function anim(){ + currentPosition += animationStep; + condition = direction=='toNext' ? currentPosition > newPosition : currentPosition < newPosition; + if (condition) { + _this.setWrapperTranslate(Math.round(currentPosition)); + _this._DOMAnimating = true + window.setTimeout(function(){ + anim() + }, 1000 / 60) + } + else { + if (params.onSlideChangeEnd) params.onSlideChangeEnd(_this); + _this.setWrapperTranslate(newPosition); + _this._DOMAnimating = false; + } + } + + //Update Active Slide Index + _this.updateActiveSlide(newPosition); + + //Callbacks + if (params.onSlideNext && action=='next') { + params.onSlideNext(_this, newPosition); + } + if (params.onSlidePrev && action=='prev') { + params.onSlidePrev(_this, newPosition); + } + //"Reset" Callback + if (params.onSlideReset && action=='reset') { + params.onSlideReset(_this, newPosition); + } + + //"Next", "Prev" and "To" Callbacks + if (action=='next' || action=='prev' || (action=='to' && toOptions.runCallbacks==true)) + slideChangeCallbacks(); + } + /*================================================== + Transition Callbacks + ====================================================*/ + //Prevent Multiple Callbacks + _this._queueStartCallbacks = false; + _this._queueEndCallbacks = false; + function slideChangeCallbacks() { + //Transition Start Callback + _this.callPlugins('onSlideChangeStart'); + if (params.onSlideChangeStart) { + if (params.queueStartCallbacks && _this.support.transitions) { + if (_this._queueStartCallbacks) return; + _this._queueStartCallbacks = true; + params.onSlideChangeStart(_this) + _this.wrapperTransitionEnd(function(){ + _this._queueStartCallbacks = false; + }) + } + else params.onSlideChangeStart(_this) + } + //Transition End Callback + if (params.onSlideChangeEnd) { + if (_this.support.transitions) { + if (params.queueEndCallbacks) { + if (_this._queueEndCallbacks) return; + _this._queueEndCallbacks = true; + _this.wrapperTransitionEnd(params.onSlideChangeEnd) + } + else _this.wrapperTransitionEnd(params.onSlideChangeEnd) + } + else { + if (!params.DOMAnimation) { + setTimeout(function(){ + params.onSlideChangeEnd(_this) + },10) + } + } + } + } + + /*================================================== + Update Active Slide Index + ====================================================*/ + _this.updateActiveSlide = function(position) { + if (!_this.initialized) return; + if (_this.slides.length==0) return; + _this.previousIndex = _this.activeIndex; + if (typeof position=='undefined') position = _this.getWrapperTranslate(); + if (position>0) position=0; + + if (params.slidesPerView == 'auto') { + var slidesOffset = 0; + _this.activeIndex = _this.slidesGrid.indexOf(-position); + if (_this.activeIndex<0) { + for (var i=0; i<_this.slidesGrid.length-1; i++) { + if (-position>_this.slidesGrid[i] && -position<_this.slidesGrid[i+1]) { + break; + } + } + var leftDistance = Math.abs( _this.slidesGrid[i] + position ) + var rightDistance = Math.abs( _this.slidesGrid[i+1] + position ) + if (leftDistance<=rightDistance) _this.activeIndex = i; + else _this.activeIndex = i+1; + } + } + else { + _this.activeIndex = Math[params.visibilityFullFit ? 'ceil' : 'round']( -position/slideSize ); + } + + if (_this.activeIndex == _this.slides.length ) _this.activeIndex = _this.slides.length - 1; + if (_this.activeIndex < 0) _this.activeIndex = 0; + + // Check for slide + if (!_this.slides[_this.activeIndex]) return; + + // Calc Visible slides + _this.calcVisibleSlides(position); + + // Mark visible and active slides with additonal classes + var activeClassRegexp = new RegExp( "\\s*" + params.slideActiveClass ); + var inViewClassRegexp = new RegExp( "\\s*" + params.slideVisibleClass ); + + for (var i = 0; i < _this.slides.length; i++) { + _this.slides[ i ].className = _this.slides[ i ].className.replace( activeClassRegexp, '' ).replace( inViewClassRegexp, '' ); + if ( _this.visibleSlides.indexOf( _this.slides[ i ] )>=0 ) { + _this.slides[ i ].className += ' ' + params.slideVisibleClass; + } + + } + _this.slides[ _this.activeIndex ].className += ' ' + params.slideActiveClass; + + //Update loop index + if (params.loop) { + var ls = _this.loopedSlides; + _this.activeLoopIndex = _this.activeIndex - ls; + if (_this.activeLoopIndex >= _this.slides.length - ls*2 ) { + _this.activeLoopIndex = _this.slides.length - ls*2 - _this.activeLoopIndex; + } + if (_this.activeLoopIndex<0) { + _this.activeLoopIndex = _this.slides.length - ls*2 + _this.activeLoopIndex; + } + } + else { + _this.activeLoopIndex = _this.activeIndex; + } + //Update Pagination + if (params.pagination) { + _this.updatePagination(position); + } + } + /*================================================== + Pagination + ====================================================*/ + _this.createPagination = function (firstInit) { + if (params.paginationClickable && _this.paginationButtons) { + removePaginationEvents(); + } + _this.paginationContainer = params.pagination.nodeType ? params.pagination : $$(params.pagination)[0]; + if (params.createPagination) { + var paginationHTML = ""; + var numOfSlides = _this.slides.length; + var numOfButtons = numOfSlides; + if (params.loop) numOfButtons -= _this.loopedSlides*2 + for (var i = 0; i < numOfButtons; i++) { + paginationHTML += '<'+params.paginationElement+' class="'+params.paginationElementClass+'">' + } + _this.paginationContainer.innerHTML = paginationHTML; + } + _this.paginationButtons = $$('.'+params.paginationElementClass, _this.paginationContainer); + if (!firstInit) _this.updatePagination() + _this.callPlugins('onCreatePagination'); + if (params.paginationClickable) { + addPaginationEvents(); + } + } + function removePaginationEvents() { + var pagers = _this.paginationButtons; + for (var i=0; i=_this.slides.length-_this.loopedSlides*2) { + visIndex = _this.slides.length - _this.loopedSlides*2 - visIndex; + visIndex = Math.abs(visIndex) + } + visibleIndexes.push( visIndex ) + } + + for (i=0; i0) position = position+_this.wrapperLeft; + if (!isH && _this.wrapperTop>0) position = position+_this.wrapperTop; + + for (var i=0; i<_this.slides.length; i++) { + _slideLeft += _slideSize; + if (params.slidesPerView == 'auto') + _slideSize = isH ? _this.h.getWidth(_this.slides[i],true) : _this.h.getHeight(_this.slides[i],true); + else _slideSize = slideSize; + + _slideRight = _slideLeft + _slideSize; + var isVisibile = false; + if (params.visibilityFullFit) { + if (_slideLeft >= -position && _slideRight <= -position+containerSize) isVisibile = true; + if (_slideLeft <= -position && _slideRight >= -position+containerSize) isVisibile = true; + } + else { + + if (_slideRight > -position && _slideRight <= ((-position+containerSize))) isVisibile = true; + if (_slideLeft >= -position && _slideLeft < ((-position+containerSize))) isVisibile = true; + if (_slideLeft < -position && _slideRight > ((-position+containerSize))) isVisibile = true; + } + + if (isVisibile) visibleSlides.push(_this.slides[i]) + + } + if (visibleSlides.length==0) visibleSlides = [ _this.slides[ _this.activeIndex ] ] + + _this.visibleSlides = visibleSlides; + } + + /*========================================== + Autoplay + ============================================*/ + _this.autoPlayIntervalId = undefined; + _this.startAutoplay = function () { + if (typeof _this.autoPlayIntervalId !== 'undefined') return false; + if (!params.autoplay) return; + _this.autoPlayIntervalId = setInterval(function(){ + if (params.loop) _this.swipeNext(); + else if (!_this.swipeNext(true)) _this.swipeTo(0); + }, params.autoplay) + _this.callPlugins('onAutoplayStart'); + } + _this.stopAutoplay = function () { + if (_this.autoPlayIntervalId) clearInterval(_this.autoPlayIntervalId); + _this.autoPlayIntervalId = undefined; + _this.callPlugins('onAutoplayStop'); + } + /*================================================== + Loop + ====================================================*/ + _this.loopCreated = false; + _this.removeLoopedSlides = function(){ + if (_this.loopCreated) { + for (var i=0; i<_this.slides.length; i++) { + if (_this.slides[i].getData('looped')===true) _this.wrapper.removeChild(_this.slides[i]); + } + } + } + + _this.createLoop = function() { + if (_this.slides.length==0) return; + if (params.slidesPerView=='auto') { + _this.loopedSlides = params.loopedSlides; + } + else { + _this.loopedSlides = params.slidesPerView + params.loopAdditionalSlides; + } + + if (_this.loopedSlides > _this.slides.length) { + _this.loopedSlides = _this.slides.length; + } + + var slideFirstHTML = '', + slideLastHTML = '', + i; + var slidesSetFullHTML = ''; + /** + loopedSlides is too large if loopAdditionalSlides are set. + Need to divide the slides by maximum number of slides existing. + + @author Tomaz Lovrec + */ + var numSlides = _this.slides.length; + var fullSlideSets = Math.floor(_this.loopedSlides / numSlides); + var remainderSlides = _this.loopedSlides % numSlides; + // assemble full sets of slides + for (i = 0; i<(fullSlideSets*numSlides);i++) { + var j = i; + if (i >= numSlides) { + var over = Math.floor(i / numSlides); + j = i - (numSlides * over); + } + slidesSetFullHTML+=_this.slides[j].outerHTML; + } + // assemble remainder slides + // assemble remainder appended to existing slides + for(i = 0;i=_this.slides.length-_this.loopedSlides) _this.slides[i].setData('looped', true); + } + _this.callPlugins('onCreateLoop'); + + } + + _this.fixLoop = function() { + var newIndex; + //Fix For Negative Oversliding + if (_this.activeIndex < _this.loopedSlides) { + newIndex = _this.slides.length - _this.loopedSlides*3 + _this.activeIndex; + _this.swipeTo(newIndex, 0, false); + } + //Fix For Positive Oversliding + else if (_this.activeIndex > _this.slides.length - params.slidesPerView*2) { + newIndex = -_this.slides.length + _this.activeIndex + _this.loopedSlides + _this.swipeTo(newIndex, 0, false); + } + } + + /*================================================== + Slides Loader + ====================================================*/ + _this.loadSlides = function(){ + var slidesHTML = ''; + _this.activeLoaderIndex = 0; + var slides = params.loader.slides; + var slidesToLoad = params.loader.loadAllSlides ? slides.length : params.slidesPerView*(1+params.loader.surroundGroups); + for (var i=0; i< slidesToLoad; i++) { + if (params.loader.slidesHTMLType=='outer') slidesHTML+=slides[i]; + else { + slidesHTML+='<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + } + } + _this.wrapper.innerHTML = slidesHTML; + _this.calcSlides(true); + //Add permanent transitionEnd callback + if (!params.loader.loadAllSlides) { + _this.wrapperTransitionEnd(_this.reloadSlides, true); + } + } + + _this.reloadSlides = function(){ + var slides = params.loader.slides; + var newActiveIndex = parseInt(_this.activeSlide().data('swiperindex'),10) + if (newActiveIndex<0 || newActiveIndex>slides.length-1) return //<-- Exit + _this.activeLoaderIndex = newActiveIndex; + var firstIndex = Math.max(0, newActiveIndex - params.slidesPerView*params.loader.surroundGroups) + var lastIndex = Math.min(newActiveIndex+params.slidesPerView*(1+params.loader.surroundGroups)-1, slides.length-1) + //Update Transforms + if (newActiveIndex>0) { + var newTransform = -slideSize*(newActiveIndex-firstIndex) + _this.setWrapperTranslate(newTransform); + _this.setWrapperTransition(0); + } + //New Slides + if (params.loader.logic==='reload') { + _this.wrapper.innerHTML = ''; + var slidesHTML = ''; + for (var i = firstIndex; i<=lastIndex; i++) { + slidesHTML += params.loader.slidesHTMLType == 'outer' ? slides[i] : '<'+params.slideElement+' class="'+params.slideClass+'" data-swiperindex="'+i+'">'+slides[i]+''; + } + _this.wrapper.innerHTML = slidesHTML; + } + else { + var minExistIndex=1000; + var maxExistIndex=0; + for (var i=0; i<_this.slides.length; i++) { + var index = _this.slides[i].data('swiperindex'); + if (indexlastIndex) { + _this.wrapper.removeChild(_this.slides[i]); + } + else { + minExistIndex = Math.min(index, minExistIndex) + maxExistIndex = Math.max(index, maxExistIndex) + } + } + for (var i=firstIndex; i<=lastIndex; i++) { + if (imaxExistIndex) { + var newSlide = document.createElement(params.slideElement); + newSlide.className = params.slideClass; + newSlide.setAttribute('data-swiperindex',i); + newSlide.innerHTML = slides[i]; + _this.wrapper.appendChild(newSlide); + } + } + } + //reInit + _this.reInit(true); + } + + /*================================================== + Make Swiper + ====================================================*/ + function makeSwiper(){ + _this.calcSlides(); + if (params.loader.slides.length>0 && _this.slides.length==0) { + _this.loadSlides(); + } + if (params.loop) { + _this.createLoop(); + } + _this.init(); + initEvents(); + if (params.pagination) { + _this.createPagination(true); + } + + if (params.loop || params.initialSlide>0) { + _this.swipeTo( params.initialSlide, 0, false ); + } + else { + _this.updateActiveSlide(0); + } + if (params.autoplay) { + _this.startAutoplay(); + } + /** + * Set center slide index. + * + * @author Tomaz Lovrec + */ + _this.centerIndex = _this.activeIndex; + + // Callbacks + if (params.onSwiperCreated) params.onSwiperCreated(this); + _this.callPlugins('onSwiperCreated'); + } + + makeSwiper(); +} + +Swiper.prototype = { + plugins : {}, + + /*================================================== + Wrapper Operations + ====================================================*/ + wrapperTransitionEnd : function(callback, permanent) { + var a = this, + el = a.wrapper, + events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'], + i; + + function fireCallBack() { + callback(a); + if (a.params.queueEndCallbacks) a._queueEndCallbacks = false; + if (!permanent) { + for (i=0; i0) { + returnWidth = el.offsetWidth - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')); + } + if (outer) returnWidth += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-right')) + + return returnWidth; + }, + getHeight: function(el, outer) { + if (outer) return el.offsetHeight; + + var height = window.getComputedStyle(el, null).getPropertyValue('height') + var returnHeight = parseFloat(height); + //IE Fixes + if(isNaN(returnHeight) || height.indexOf('%')>0) { + returnHeight = el.offsetHeight - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) - parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')); + } + if (outer) returnHeight += parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue('padding-bottom')) + return returnHeight; + }, + getOffset: function(el) { + var box = el.getBoundingClientRect(); + var body = document.body; + var clientTop = el.clientTop || body.clientTop || 0; + var clientLeft = el.clientLeft || body.clientLeft || 0; + var scrollTop = window.pageYOffset || el.scrollTop; + var scrollLeft = window.pageXOffset || el.scrollLeft; + if (document.documentElement && !window.pageYOffset) { + //IE7-8 + scrollTop = document.documentElement.scrollTop; + scrollLeft = document.documentElement.scrollLeft; + } + return { + top: box.top + scrollTop - clientTop, + left: box.left + scrollLeft - clientLeft + }; + }, + windowWidth : function() { + if (window.innerWidth) return window.innerWidth + else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth; + }, + windowHeight : function() { + if (window.innerHeight) return window.innerHeight + else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight; + }, + windowScroll : function() { + var left=0, top=0; + if (typeof pageYOffset != 'undefined') { + return { + left: window.pageXOffset, + top: window.pageYOffset + } + } + else if (document.documentElement) { + return { + left: document.documentElement.scrollLeft, + top: document.documentElement.scrollTop + } + } + }, + + addEventListener : function (el, event, listener, useCapture) { + if (typeof useCapture == 'undefined') { + useCapture = false; + } + + if (el.addEventListener) { + el.addEventListener(event, listener, useCapture); + } + else if (el.attachEvent) { + el.attachEvent('on' + event, listener); + } + }, + + removeEventListener : function (el, event, listener, useCapture) { + if (typeof useCapture == 'undefined') { + useCapture = false; + } + + if (el.removeEventListener) { + el.removeEventListener(event, listener, useCapture); + } + else if (el.detachEvent) { + el.detachEvent('on' + event, listener); + } + } + }, + setTransform : function (el, transform) { + var es = el.style + es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transform + }, + setTranslate : function (el, translate) { + var es = el.style + var pos = { + x : translate.x || 0, + y : translate.y || 0, + z : translate.z || 0 + }; + var transformString = this.support.transforms3d ? 'translate3d('+(pos.x)+'px,'+(pos.y)+'px,'+(pos.z)+'px)' : 'translate('+(pos.x)+'px,'+(pos.y)+'px)'; + es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = transformString; + if (!this.support.transforms) { + es.left = pos.x+'px' + es.top = pos.y+'px' + } + }, + setTransition : function (el, duration) { + var es = el.style + es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = duration+'ms'; + }, + /*================================================== + Feature Detection + ====================================================*/ + support: { + + touch : (window.Modernizr && Modernizr.touch===true) || (function() { + return !!(("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch); + })(), + + transforms3d : (window.Modernizr && Modernizr.csstransforms3d===true) || (function() { + var div = document.createElement('div').style; + return ("webkitPerspective" in div || "MozPerspective" in div || "OPerspective" in div || "MsPerspective" in div || "perspective" in div); + })(), + + transforms : (window.Modernizr && Modernizr.csstransforms===true) || (function(){ + var div = document.createElement('div').style; + return ('transform' in div || 'WebkitTransform' in div || 'MozTransform' in div || 'msTransform' in div || 'MsTransform' in div || 'OTransform' in div); + })(), + + transitions : (window.Modernizr && Modernizr.csstransitions===true) || (function(){ + var div = document.createElement('div').style; + return ('transition' in div || 'WebkitTransition' in div || 'MozTransition' in div || 'msTransition' in div || 'MsTransition' in div || 'OTransition' in div); + })() + }, + + browser : { + + ie8 : (function(){ + var rv = -1; // Return value assumes failure. + if (navigator.appName == 'Microsoft Internet Explorer') { + var ua = navigator.userAgent; + var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat(RegExp.$1); + } + return rv != -1 && rv < 9; + })(), + + ie10 : window.navigator.msPointerEnabled + } +} + +/*========================= + jQuery & Zepto Plugins + ===========================*/ +if (window.jQuery||window.Zepto) { + (function($){ + $.fn.swiper = function(params) { + var s = new Swiper($(this)[0], params) + $(this).data('swiper',s); + return s; + } + })(window.jQuery||window.Zepto) +} + +// component +if ( typeof( module ) !== 'undefined' ) +{ + module.exports = Swiper; +} diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery-animate-css-rotate-scale.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery-animate-css-rotate-scale.js new file mode 100644 index 0000000..cb81071 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery-animate-css-rotate-scale.js @@ -0,0 +1,149 @@ +/*! +/** + * Monkey patch jQuery 1.3.1+ to add support for setting or animating CSS + * scale and rotation independently. + * https://github.com/zachstronaut/jquery-animate-css-rotate-scale + * Released under dual MIT/GPL license just like jQuery. + * 2009-2012 Zachary Johnson www.zachstronaut.com + */ +(function ($) { + // Updated 2010.11.06 + // Updated 2012.10.13 - Firefox 16 transform style returns a matrix rather than a string of transform functions. This broke the features of this jQuery patch in Firefox 16. It should be possible to parse the matrix for both scale and rotate (especially when scale is the same for both the X and Y axis), however the matrix does have disadvantages such as using its own units and also 45deg being indistinguishable from 45+360deg. To get around these issues, this patch tracks internally the scale, rotation, and rotation units for any elements that are .scale()'ed, .rotate()'ed, or animated. The major consequences of this are that 1. the scaled/rotated element will blow away any other transform rules applied to the same element (such as skew or translate), and 2. the scaled/rotated element is unaware of any preset scale or rotation initally set by page CSS rules. You will have to explicitly set the starting scale/rotation value. + + function initData($el) { + var _ARS_data = $el.data('_ARS_data'); + if (!_ARS_data) { + _ARS_data = { + rotateUnits: 'deg', + scalex: 1, + scaley: 1, + rotate: 0 + }; + + $el.data('_ARS_data', _ARS_data); + } + + return _ARS_data; + } + + function setTransform($el, data) { + $el.css('transform', 'rotate(' + data.rotate + data.rotateUnits + ') scalex(' + data.scalex + ') scaley(' + data.scaley + ')'); + } + + $.fn.rotate = function (val) { + var $self = $(this), m, data = initData($self); + + if (typeof val == 'undefined') { + return data.rotate + data.rotateUnits; + } + + m = val.toString().match(/^(-?\d+(\.\d+)?)(.+)?$/); + if (m) { + if (m[3]) { + data.rotateUnits = m[3]; + } + + data.rotate = m[1]; + + setTransform($self, data); + } + + return this; + }; + + // Note that scale is unitless. + $.fn.scalex = function (val) { + var $self = $(this), data = initData($self); + + if (typeof val == 'undefined') { + return data.scalex; + } + + data.scalex = val; + + setTransform($self, data); + + return this; + }; + + $.fn.scaley = function (val) { + var $self = $(this), data = initData($self); + + if (typeof val == 'undefined') { + return data.scaley; + } + + data.scaley = val; + + setTransform($self, data); + + return this; + }; + + // fx.cur() must be monkey patched because otherwise it would always + // return 0 for current rotate and scale values + var curProxied = $.fx.prototype.cur; + $.fx.prototype.cur = function () { + if (this.prop == 'rotate') { + return parseFloat($(this.elem).rotate()); + + } else if (this.prop == 'scalex') { + return parseFloat($(this.elem).scalex()); + } else if (this.prop == 'scaley') { + return parseFloat($(this.elem).scaley()); + } + + return curProxied.apply(this, arguments); + }; + + $.fx.step.rotate = function (fx) { + var data = initData($(fx.elem)); + $(fx.elem).rotate(fx.now + data.rotateUnits); + }; + + $.fx.step.scalex = function (fx) { + $(fx.elem).scalex(fx.now); + }; + $.fx.step.scaley = function (fx) { + $(fx.elem).scaley(fx.now); + }; + + + /* + + Starting on line 3905 of jquery-1.3.2.js we have this code: + + // We need to compute starting value + if ( unit != "px" ) { + self.style[ name ] = (end || 1) + unit; + start = ((end || 1) / e.cur(true)) * start; + self.style[ name ] = start + unit; + } + + This creates a problem where we cannot give units to our custom animation + because if we do then this code will execute and because self.style[name] + does not exist where name is our custom animation's name then e.cur(true) + will likely return zero and create a divide by zero bug which will set + start to NaN. + + The following monkey patch for animate() gets around this by storing the + units used in the rotation definition and then stripping the units off. + + */ + + var animateProxied = $.fn.animate; + $.fn.animate = function (prop) { + if (typeof prop['rotate'] != 'undefined') { + var $self, data, m = prop['rotate'].toString().match(/^(([+-]=)?(-?\d+(\.\d+)?))(.+)?$/); + if (m && m[5]) { + $self = $(this); + data = initData($self); + data.rotateUnits = m[5]; + } + + prop['rotate'] = m[1]; + } + + return animateProxied.apply(this, arguments); + }; +})(jQuery); \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery-css-transform.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery-css-transform.js new file mode 100644 index 0000000..70a40f2 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery-css-transform.js @@ -0,0 +1,112 @@ +(function ($) { + // Monkey patch jQuery 1.3.1+ css() method to support CSS 'transform' + // property uniformly across Safari/Chrome/Webkit, Firefox 3.5+, IE 9+, and Opera 11+. + // 2009-2011 Zachary Johnson www.zachstronaut.com + // Updated 2011.05.04 (May the fourth be with you!) + function getTransformProperty(element) + { + // Try transform first for forward compatibility + // In some versions of IE9, it is critical for msTransform to be in + // this list before MozTranform. + var properties = ['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform']; + var p; + while (p = properties.shift()) + { + if (typeof element.style[p] != 'undefined') + { + return p; + } + } + + // Default to transform also + return 'transform'; + } + + var _propsObj = null; + + var proxied = $.fn.css; + $.fn.css = function (arg, val) + { + // Temporary solution for current 1.6.x incompatibility, while + // preserving 1.3.x compatibility, until I can rewrite using CSS Hooks + if (_propsObj === null) + { + if (typeof $.cssProps != 'undefined') + { + _propsObj = $.cssProps; + } + else if (typeof $.props != 'undefined') + { + _propsObj = $.props; + } + else + { + _propsObj = {} + } + } + + // Find the correct browser specific property and setup the mapping using + // $.props which is used internally by jQuery.attr() when setting CSS + // properties via either the css(name, value) or css(properties) method. + // The problem with doing this once outside of css() method is that you + // need a DOM node to find the right CSS property, and there is some risk + // that somebody would call the css() method before body has loaded or any + // DOM-is-ready events have fired. + if + ( + typeof _propsObj['transform'] == 'undefined' + && + ( + arg == 'transform' + || + ( + typeof arg == 'object' + && typeof arg['transform'] != 'undefined' + ) + ) + ) + { + _propsObj['transform'] = getTransformProperty(this.get(0)); + } + + // We force the property mapping here because jQuery.attr() does + // property mapping with jQuery.props when setting a CSS property, + // but curCSS() does *not* do property mapping when *getting* a + // CSS property. (It probably should since it manually does it + // for 'float' now anyway... but that'd require more testing.) + // + // But, only do the forced mapping if the correct CSS property + // is not 'transform' and is something else. + if (_propsObj['transform'] != 'transform') + { + // Call in form of css('transform' ...) + if (arg == 'transform') + { + arg = _propsObj['transform']; + + // User wants to GET the transform CSS, and in jQuery 1.4.3 + // calls to css() for transforms return a matrix rather than + // the actual string specified by the user... avoid that + // behavior and return the string by calling jQuery.style() + // directly + if (typeof val == 'undefined' && jQuery.style) + { + return jQuery.style(this.get(0), arg); + } + } + + // Call in form of css({'transform': ...}) + else if + ( + typeof arg == 'object' + && typeof arg['transform'] != 'undefined' + ) + { + arg[_propsObj['transform']] = arg['transform']; + delete arg['transform']; + } + } + + return proxied.apply(this, arguments); + }; +})(jQuery); \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.SCswipe.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.SCswipe.js new file mode 100755 index 0000000..8648775 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.SCswipe.js @@ -0,0 +1,130 @@ +// jQuery.event.swipe +// 0.5 +// Stephen Band + +// Dependencies +// jQuery.event.move 1.2 + +// One of swipeleft, swiperight, swipeup or swipedown is triggered on +// moveend, when the move has covered a threshold ratio of the dimension +// of the target node, or has gone really fast. Threshold and velocity +// sensitivity changed with: +// +// jQuery.event.special.swipe.settings.threshold +// jQuery.event.special.swipe.settings.sensitivity + +(function (module) { +if (typeof define === 'function' && define.amd) { +// AMD. Register as an anonymous module. +define(['jquery'], module); +} else { +// Browser globals +module(jQuery); +} +})(function(jQuery, undefined){ +var add = jQuery.event.add, + +remove = jQuery.event.remove, + +// Just sugar, so we can have arguments in the same order as +// add and remove. +trigger = function(node, type, data) { +jQuery.event.trigger(type, data, node); +}, + +settings = { +// Ratio of distance over target finger must travel to be +// considered a swipe. +threshold: 0.1, +// Faster fingers can travel shorter distances to be considered +// swipes. 'sensitivity' controls how much. Bigger is shorter. +sensitivity: 6 +}; + +function moveend(e) { +var w, h, event; + +w = e.target.offsetWidth; +h = e.target.offsetHeight; + +// Copy over some useful properties from the move event +event = { +distX: e.distX, +distY: e.distY, +velocityX: e.velocityX, +velocityY: e.velocityY, +finger: e.finger +}; + +// Find out which of the four directions was swiped +if (e.distX > e.distY) { +if (e.distX > -e.distY) { +if (e.distX/w > settings.threshold || e.velocityX * e.distX/w * settings.sensitivity > 1) { +event.type = 'SCswiperight'; +trigger(e.currentTarget, event); +} +} +else { +if (-e.distY/h > settings.threshold || e.velocityY * e.distY/w * settings.sensitivity > 1) { +event.type = 'SCswipeup'; +trigger(e.currentTarget, event); +} +} +} +else { +if (e.distX > -e.distY) { +if (e.distY/h > settings.threshold || e.velocityY * e.distY/w * settings.sensitivity > 1) { +event.type = 'SCswipedown'; +trigger(e.currentTarget, event); +} +} +else { +if (-e.distX/w > settings.threshold || e.velocityX * e.distX/w * settings.sensitivity > 1) { +event.type = 'SCswipeleft'; +trigger(e.currentTarget, event); +} +} +} +} + +function getData(node) { +var data = jQuery.data(node, 'event_swipe'); + +if (!data) { +data = { count: 0 }; +jQuery.data(node, 'event_swipe', data); +} + +return data; +} + +jQuery.event.special.SCswipe = +jQuery.event.special.SCswipeleft = +jQuery.event.special.SCswiperight = +jQuery.event.special.SCswipeup = +jQuery.event.special.SCswipedown = { +setup: function( data, namespaces, eventHandle ) { +var data = getData(this); + +// If another swipe event is already setup, don't setup again. +if (data.count++ > 0) { return; } + +add(this, 'moveend', moveend); + +return true; +}, + +teardown: function() { +var data = getData(this); + +// If another swipe event is still setup, don't teardown. +if (--data.count > 0) { return; } + +remove(this, 'moveend', moveend); + +return true; +}, + +settings: settings +}; +}); \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.easie-min.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.easie-min.js new file mode 100755 index 0000000..797a892 --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.easie-min.js @@ -0,0 +1 @@ +(function(a){"use strict";var b="easie",c="Ease",d=b+c+"In",e=b+c+"Out",f=b+c+"InOut",g=["Quad","Cubic","Quart","Quint","Sine","Expo","Circ"];a.easie=function(c,d,e,f,g,h){g=g||[b,c,d,e,f].join("-");if(!a.easing[g]||h){var k=i(function(a){return j(a,c,d,e,f,5)});a.easing[g]=function(a,b,c,d){return k.call(null,a)},a.easing[g].params=[c,d,e,f]}return g};var h=a.easie;h(0,0,1,1,b+"Linear"),h(.25,.1,.25,1,b+c),h(.42,0,1,1,d),h(0,0,.58,1,e),h(.42,0,.58,1,f),h(.55,.085,.68,.53,d+g[0]),h(.55,.055,.675,.19,d+g[1]),h(.895,.03,.685,.22,d+g[2]),h(.755,.05,.855,.06,d+g[3]),h(.47,0,.745,.715,d+g[4]),h(.95,.05,.795,.035,d+g[5]),h(.6,.04,.98,.335,d+g[6]),h(.25,.46,.45,.94,e+g[0]),h(.215,.61,.355,1,e+g[1]),h(.165,.84,.44,1,e+g[2]),h(.23,1,.32,1,e+g[3]),h(.39,.575,.565,1,e+g[4]),h(.19,1,.22,1,e+g[5]),h(.075,.82,.165,1,e+g[6]),h(.455,.03,.515,.955,f+g[0]),h(.645,.045,.355,1,f+g[1]),h(.77,0,.175,1,f+g[2]),h(.86,0,.07,1,f+g[3]),h(.445,.05,.55,.95,f+g[4]),h(1,0,0,1,f+g[5]),h(.785,.135,.15,.86,f+g[6]);function i(a,b){var c;b=b||101;var d=[];for(c=0;c=0?a:0-a}for(e=a,h=0;h<8;h++){f=m(e)-a;if(i(f)d)return d;while(cf?c=e:d=e,e=(d-c)*.5+c}return e}i=3*b,h=3*(d-b)-i,g=1-i-h,l=3*c,k=3*(e-c)-l,j=1-l-k;return q(a,p(f))}})(jQuery) \ No newline at end of file diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.jgestures.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.jgestures.js new file mode 100755 index 0000000..febcbec --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.jgestures.js @@ -0,0 +1,1533 @@ +/*jslint undef: true, browser: true, continue: true, eqeq: true, vars: true, forin: true, white: true, newcap: false, nomen: true, plusplus: true, maxerr: 50, indent: 4 */ + +/** + * jGestures: a jQuery plugin for gesture events + * Copyright 2010-2011 Neue Digitale / Razorfish GmbH + * Copyright 2011-2012, Razorfish GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @fileOverview + * Razorfish GmbH javascript library: add touch events such as 'pinch', + * 'rotate', 'swipe', 'tap' and 'orientationchange' on capable user agents. + * For incapable devices there's a basic event substitution: a "tapone" event + * can be triggered by "clicking", a "swipeone" by performing a swipe-ish + * gesture using the mouse (buttondown - mousemove - buttonup). + * + * This is still a beta version, bugfixes and improvements appreciated. + * + * @author martin.krause@razorfish.de + * @version 0.90-shake + * + * @requires + * jQuery JavaScript Library v1.4.2 - http://jquery.com/ + * Copyright 2010, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * @example jQuery('#swipe').bind('swipeone',eventHandler); + * + * Notification on native events: + * On every native touchstart, touchend, gesturestart and gestureend-event, + * jgestures triggers a corresponding custom event + * ('jGestures.touchstart', 'jGestures.touchend;start', 'jGestures.touchend;processed', + * 'jGestures.gesturestart', 'jGestures.gestureend;start', 'jGestures.gestureend;processed') on the event-element. + * The eventhandler's second argument represents the original touch event (yes: including all touchpoints). + * Use this if you need very detailed control e.g. kinetic scrolling or implementing additional gestures. + * + * Every jGesture-eventhandler receives a custom object as second argument + * containing the original event (originalEvent property) and processed + * information (such as delta values and timesptamp). + * Example:{ + * type: eventtype e.g. "swipe","pinch", + * originalEvent: {DOM-Event}, + * // default: just one entry on the delta-array - the first touchpoint + * // the first touchpoint is the reference point for every gesture, + * // because moving touchpoints in various directions would result in + * // a gesture. + * // delta and direction details are just provided for touch not for gesture / motion events + * delta : [ + * { + * lastX:{Number} , // x-axis: relative to the last touchevent (e.g. touchmove!) + * lastY:{Number}, // y-axis: relative to the last touchevent (e.g. touchmove!) + * moved: {Number}, // distance: relative to the original touchpoint + * startX: {Number} , // relative to the original touchpoint + * startY: {Number} ,// relative to the original touchpoint + * } ], + * // based on the first touchpoint + * direction : { // relative to the last touchevent (e.g. touchmove!) + * vector: {Number}, // -1|+1, indicates the direction if necessary(pinch/rotate) + * orientation: {Number} // window.orientation: -90,0,90,180 || null (window.orienntation) + * lastX : {Number}, // -1,0,+1 || null (orientationchange) // relative to the last touchevent (e.g. touchmove!) + * lastY : {Number}, // -1,0,+1 || null (orientationchange)// relative to the last touchevent (e.g. touchmove!) + * startX: {Number} , // relative to the original touchpoint + * startY: {Number} ,// relative to the original touchpoint + * }, + * rotation: {Number} || null, // gestureonly: amount of rotation relative to the current position NOT the original + * scale: {Number} || null, // gestureonly: amount of scaling relative to the current position NOT the original + * duration: {Number}, // ms: relative to the original touchpoint + * description : {String} // details as String: {TYPE *}:{TOUCHES 1|2|3|4}:{X-AXIS 'right'|'left'|'steady'}:{Y-AXIS 'down'|'up'|'steady'} e.g. "swipe:1:left:steady" relative to the last touchpoint + * }; + * + * Available jGesture-events can be grouped into: + * + * + * Device events: + * The jGesture-Events in this group are triggered by the device. + * + * @event 'orientationchange' + * The device is turned clockwise or counterclockwise. This event is triggered + * by the device and might use an internal gyroscope. + * obj.description: + * orientationchange:landscape:clockwise:-90 + * orientationchange:portrait:default:0 + * orientationchange:landscape:counterclockwise|portrait:90 + * orientationchange:portrait:upsidedown:180 + * + * + * Move events: + * The jGesture-Events in this group are triggered during the touch/gesture + * execution whenever a touchpoint changes. + * In contrast to touchend/gestureend-events which are triggered after + * the touch/gesture has completed. + * + * @event 'pinch' + * Is triggered during a pinch gesture (two fingers moving away from or + * towards each other). + * obj.description: + * pinch:-1:close + * pinch:+1:open + * + * @event 'rotate' + * Is triggered during a rotation gesture (two fingers rotating clockwise + * or counterclockwise). + * obj.description: + * rotate:-1:counterclockwise + * rotate:+1:+clockwise + * + * @event 'swipemove' + * Is triggered during a swipe move gesture (finger(s) being moved around + * the device, e.g. dragging) + * obj.description: + * swipemove:1:left:down + * swipemove:1:left:up + * swipemove:1:left:steady + * swipemove:1:right:down + * swipemove:1:right:up + * swipemove:1:right:steady + * swipemove:2:left:down + * swipemove:2:left:up + * swipemove:2:left:steady + * swipemove:2:right:down + * swipemove:2:right:up + * swipemove:2:right:steady + * swipemove:2:left:down + * swipemove:3:left:up + * swipemove:3:left:steady + * swipemove:3:right:down + * swipemove:3:right:up + * swipemove:3:right:steady + * swipemove:3:left:down + * swipemove:4:left:up + * swipemove:4:left:steady + * swipemove:4:right:down + * swipemove:4:right:up + * swipemove:4:right:steady + * + * + * Toucheend events: + * The jGesture-Events in this group are triggered after the touch/gesture + * has completed. + * In contrast to touchmove-events which are triggered during the touch/gesture + * execution whenever a touchpoint changes. + * + * @event 'swipeone' + * Is triggered after a swipe move gesture with one touchpoint (one finger + * was moved around the device) + * obj.description: + * swipeone:1:left:down + * swipeone:1:left:up + * swipeone:1:left:steady + * swipeone:1:right:down + * swipeone:1:right:up + * swipeone:1:right:steady + * + * @event 'swipetwo' + * Is triggered after a swipe move gesture with two touchpoints (two fingers + * were moved around the device) + * obj.description: + * swipetwo:2:left:down + * swipetwo:2:left:up + * swipetwo:2:left:steady + * swipetwo:2:right:down + * swipetwo:2:right:up + * swipetwo:2:right:steady + * + * @event 'swipethree' + * Is triggered after a swipe move gesture with three touchpoints (three + * fingers were moved around the device) + * obj.description: + * swipethree:3:left:down + * swipethree:3:left:up + * swipethree:3:left:steady + * swipethree:3:right:down + * swipethree:3:right:up + * swipethree:3:right:steady + * + * @event 'swipefour' + * Is triggered after a swipe move gesture with four touchpoints (four + * fingers were moved around the device) + * obj.description: + * swipefour:4:left:down + * swipefour:4:left:up + * swipefour:4:left:steady + * swipefour:4:right:down + * swipefour:4:right:up + * swipefour:4:right:steady + * + * + * @event 'swipeup' + * Is triggered after an strict upwards swipe move gesture + * obj.description: + * swipe:1:steady:up + * swipe:2:steady:up + * swipe:3:steady:up + * swipe:4:steady:up + * + * @event 'swiperightup' + * Is triggered after a rightwards and upwards swipe move gesture + * obj.description: + * swipe:1:right:up + * swipe:2:right:up + * swipe:3:right:up + * swipe:4:right:up + * + * @event 'swiperight' + * Is triggered after a strict rightwards swipe move gesture + * obj.description: + * swipe:1:right:steady + * swipe:2:right:steady + * swipe:3:right:steady + * swipe:4:right:steady + * + * @event 'swiperightdown' + * Is triggered after a rightwards and downwards swipe move gesture + * obj.description: + * swipe:1:right:down + * swipe:2:right:down + * swipe:3:right:down + * swipe:4:right:down + * + * @event 'swipedown' + * Is triggered after a strict downwards swipe move gesture + * obj.description: + * swipe:1:steady:down + * swipe:2:steady:down + * swipe:3:steady:down + * swipe:4:steady:down + * + * @event 'swipeleftdown' + * Is triggered after a leftwards and downwards swipe move gesture + * obj.description: + * swipe:1:left:down + * swipe:2:left:down + * swipe:3:left:down + * swipe:4:left:down + * + * @event 'swipeleft' + * Is triggered after a strict leftwards swipe move gesture + * obj.description: + * swipe:1:left:steady + * swipe:2:left:steady + * swipe:3:left:steady + * swipe:4:left:steady + * + * @event 'swipeleftup' + * Is triggered after a leftwards and upwards swipe move gesture + * obj.description: + * swipe:1:left:up + * swipe:2:left:up + * swipe:3:left:up + * swipe:4:left:up + * + * @event 'tapone' + * Is triggered after a single (one finger) tap gesture + * obj.description: + * tapone + * + * @event 'taptwo' + * Is triggered after a double (two finger) tap gesture + * obj.description: + * taptwo + * * + * @event 'tapthree' + * Is triggered after a tripple (three finger) tap gesture + * obj.description: + * tapthree + * + * + * Gestureend events: + * A gesture is an interpretation of different touchpoints. + * The jGesture-Events in this group are triggered when a gesture has finished + * and the touchpoints are removed from the device. + * + * @event 'pinchopen' + * Is triggered when a pinchopen gesture (two fingers moving away from each + * other) occured and the touchpoints (fingers) are removed the device. + * obj.description: + * pinch:+1:open + * + * @event 'pinchclose' + * Is triggered when a pinchclose gesture (two fingers moving towards each + * other) occured and the touchpoints (fingers) are removed the device. + * obj.description: + * pinch:-1:close + * + * @event 'rotatecw' + * Is triggered when a clockwise rotation gesture (two fingers rotating + * clockwise) occured and the touchpoints (fingers) are removed the device. + * obj.description: + * rotate:+1:+clockwise + * + * @event 'rotateccw' + * Is triggered when a counterclockwise rotation gesture (two fingers + * rotating counterclockwise) occured and the touchpoints (fingers) are + * removed the device. + * obj.description: + * rotate:-1:+counterclockwise + * + * + * Motion events: + * A "motion event" is an interpretation of changes in space, e.g. a "shaking motion" + * consists of a specified number of acceleration changes in a given interval. + * For understanding "directions", place your mobile device on a table with the bottom + * (home button) close to you: + * - x-axis: horizontal left / right + * - y-axis: horizontal front / back (through the home button) + * - z-axis: vertical through your device + * + * Note: Devicemotion / deviceorientation don't send custom event (such as: jGestures.touchstart). + * Note: Devicemotion should be bound on the "window-element" - because the whole device moves + * + * @event 'shake' + * Is triggered when a shaking motion is detected + * obj.description: + * shake:leftright:x-axisfrontback:y-axis:updown:z-axis + * + * @event 'shakefrontback' + * Is triggered when a shaking motion is detected and the gesture can be interpreted as a mainly front-back movement. + * obj.description: + * shakefrontback:shakefrontback:y-axis + * + * @event 'shakeleftright' + * Is triggered when a shaking motion is detected and the gesture can be interpreted as a mainly left-right movement. + * Additional major movements are mentioned in the obj.description. + * obj.description: + * shakeleftright:leftright:x-axis + * + * @event 'shakeupdown' + * Is triggered when a shaking motion is detected and the gesture can be interpreted as a mainly up-down movement. + * Additional major movements are mentioned in the obj.description. + * obj.description: + * shake:shakeupdown:updown:z-axis + * + * @example + * .bind( eventType, [ eventData ], handler(eventObject) ) + * jQuery('body').bind('tapone',function(){alert(arguments[1].description);}) + * + */ + + (function($) { + + /** + * General thresholds. + */ + // @TODO: move to $...defaults + // @TODO: shake to defaults freeze etc + // change of x deg in y ms + + + $.jGestures = {}; + $.jGestures.defaults = {}; + $.jGestures.defaults.thresholdShake = { + requiredShakes : 10, + freezeShakes: 100, + frontback : { + sensitivity: 10 + }, + leftright : { + sensitivity: 10 + }, + updown : { + sensitivity: 10 + } + }; + + $.jGestures.defaults.thresholdPinchopen = 0.05; + $.jGestures.defaults.thresholdPinchmove = 0.05; + $.jGestures.defaults.thresholdPinch = 0.05; + $.jGestures.defaults.thresholdPinchclose = 0.05; + $.jGestures.defaults.thresholdRotatecw = 5; //deg + $.jGestures.defaults.thresholdRotateccw = 5; // deg + // a tap becomes a swipe if x/y values changes are above this threshold + $.jGestures.defaults.thresholdMove = 20; + $.jGestures.defaults.thresholdSwipe = 100; + // get capable user agents + $.jGestures.data = {}; + $.jGestures.data.capableDevicesInUserAgentString = ['iPad','iPhone','iPod','Mobile Safari']; // basic functionality such as swipe, pinch, rotate, tap should work on every mobile safari, e.g. GalaxyTab + $.jGestures.data.hasGestures = (function () { var _i; for(_i = 0; _i < $.jGestures.data.capableDevicesInUserAgentString.length; _i++ ) { if (navigator.userAgent.indexOf($.jGestures.data.capableDevicesInUserAgentString[_i]) !== -1 ) {return true;} } return false; } )(); + $.hasGestures = $.jGestures.data.hasGestures; + $.jGestures.events = { + touchstart : 'jGestures.touchstart', + touchendStart: 'jGestures.touchend;start', + touchendProcessed: 'jGestures.touchend;processed', + gesturestart: 'jGestures.gesturestart', + gestureendStart: 'jGestures.gestureend;start', + gestureendProcessed: 'jGestures.gestureend;processed' + }; + + jQuery + .each({ + // "first domevent necessary"_"touch event+counter" : "exposed as" + // event: orientationchange + orientationchange_orientationchange01: "orientationchange", + // event: gestures + gestureend_pinchopen01: "pinchopen", + gestureend_pinchclose01: "pinchclose", + gestureend_rotatecw01 : 'rotatecw', + gestureend_rotateccw01 : 'rotateccw', + // move events + gesturechange_pinch01: 'pinch', + gesturechange_rotate01: 'rotate', + touchstart_swipe13: 'swipemove', + // event: touches + touchstart_swipe01: "swipeone", + touchstart_swipe02: "swipetwo", + touchstart_swipe03: "swipethree", + touchstart_swipe04: "swipefour", + touchstart_swipe05: 'swipeup', + touchstart_swipe06: 'swiperightup', + touchstart_swipe07: 'swiperight', + touchstart_swipe08: 'swiperightdown', + touchstart_swipe09: 'swipedown', + touchstart_swipe10: 'swipeleftdown', + touchstart_swipe11: 'swipeleft', + touchstart_swipe12: 'swipeleftup', + touchstart_tap01: 'tapone', + touchstart_tap02: 'taptwo', + touchstart_tap03: 'tapthree', + touchstart_tap04: 'tapfour', + + devicemotion_shake01: 'shake', + devicemotion_shake02: 'shakefrontback', + devicemotion_shake03: 'shakeleftright', + devicemotion_shake04: 'shakeupdown' + + }, + + /** + * Add gesture events inside the jQuery.event.special namespace + */ + function( sInternal_, sPublicFN_ ) { + + // add as funciton to jQuery.event.special.sPublicFN_ + jQuery.event.special[ sPublicFN_ ] = { + + /** + * When the first event handler is bound, jQuery executes the setup function. + * This plugin just uses one eventhandler per element, regardless of the number of bound events. + * All Events are stored internally as properties on the dom-element using the $.data api. + * The setup-function adds the eventlistener, acting as a proxy function for the internal events. + * $.data.ojQueryGestures[_sDOMEvent ('tap') ] = {Boolean} + * @return {Void} + */ + setup: function () { + // split the arguments to necessary controll arguements + var _aSplit = sInternal_.split('_'); + var _sDOMEvent = _aSplit[0]; // + // get the associated gesture event and strip the counter: necessary for distinguisihng similliar events such as tapone-tapfour + var _sGestureEvent = _aSplit[1].slice(0,_aSplit[1].length-2); + var _$element = jQuery(this); + var _oDatajQueryGestures ; + var oObj; + // bind the event handler on the first $.bind() for a gestureend-event, set marker + if (!_$element.data('ojQueryGestures') || !_$element.data('ojQueryGestures')[_sDOMEvent]) { + // setup pseudo event + _oDatajQueryGestures = _$element.data('ojQueryGestures') || {}; + oObj = {}; + // marker for: domEvent being set on this element + // e.g.: $.data.oGestureInternals['touchstart'] = true; + // since they're grouped, i'm just marking the first one being added + oObj[_sDOMEvent] = true; + $.extend(true,_oDatajQueryGestures,oObj); + _$element.data('ojQueryGestures' ,_oDatajQueryGestures); + // add gesture events + if($.hasGestures) { + switch(_sGestureEvent) { + + // event: orientationchange + case 'orientationchange': + _$element.get(0).addEventListener('orientationchange', _onOrientationchange, false); + break; + + // event: + // - shake + // - tilt + case 'shake': + case 'shakefrontback': + case 'shakeleftright': + case 'shakeupdown': + case 'tilt': + //$.hasGyroscope = true //!window.DeviceOrientationEvent; + //_$element.get(0).addEventListener('devicemotion', _onDevicemotion, false); + //_$element.get(0).addEventListener('deviceorientation', _onDeviceorientation, false); + _$element.get(0).addEventListener('devicemotion', _onDevicemotion, false); + break; + + // event: + // - touchstart + // - touchmove + // - touchend + case 'tap': + case 'swipe': + case 'swipeup': + case 'swiperightup': + case 'swiperight': + case 'swiperightdown': + case 'swipedown': + case 'swipeleftdown': + case 'swipeleft': + _$element.get(0).addEventListener('touchstart', _onTouchstart, false); + break; + + // event: gestureend + case 'pinchopen': + case 'pinchclose' : + case 'rotatecw' : + case 'rotateccw' : + _$element.get(0).addEventListener('gesturestart', _onGesturestart, false); + _$element.get(0).addEventListener('gestureend', _onGestureend, false); + break; + + // event: gesturechange + case 'pinch': + case 'rotate': + _$element.get(0).addEventListener('gesturestart', _onGesturestart, false); + _$element.get(0).addEventListener('gesturechange', _onGesturechange, false); + break; + } + } + // create substitute for gesture events + else { + switch(_sGestureEvent) { + // event substitutes: + // - touchstart: mousedown + // - touchmove: none + // - touchend: mouseup + case 'tap': + case 'swipe': + // _$element.get(0).addEventListener('mousedown', _onTouchstart, false); + _$element.bind('mousedown', _onTouchstart); + break; + + // no substitution + case 'orientationchange': + case 'pinchopen': + case 'pinchclose' : + case 'rotatecw' : + case 'rotateccw' : + case 'pinch': + case 'rotate': + case 'shake': + case 'tilt': + + break; + } + } + + } + return false; + }, + + /** + * For every $.bind(GESTURE) the add-function will be called. + * Instead of binding an actual eventlister, the event is stored as $.data on the element. + * The handler will be triggered using $.triggerHandler(GESTURE) if the internal + * eventhandler (proxy being bound on setup()) detects a GESTURE event + * @param {Object} event_ jQuery-Event-Object being passed by $.bind() + * @return {Void} + */ + add : function(event_) { + // add pseudo event: properties on $.data + var _$element = jQuery(this); + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); +// _oDatajQueryGestures[event_.type] = { 'originalType' : event_.type , 'threshold' : event_.data.threshold, 'preventDefault' : event_.data.preventDefault } ; + _oDatajQueryGestures[event_.type] = { 'originalType' : event_.type } ; + return false; + }, + + /** + * For every $.unbind(GESTURE) the remove-function will be called. + * Instead of removing the actual eventlister, the event is removed from $.data on the element. + * @param {Object} event_ jQuery-Event-Object being passed by $.bind() + * @return {Void} + */ + remove : function(event_) { + // remove pseudo event: properties on $.data + var _$element = jQuery(this); + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + _oDatajQueryGestures[event_.type] = false; + _$element.data('ojQueryGestures' ,_oDatajQueryGestures ); + return false; + }, + + /** + * The last $.unbind()-call on the domElement triggers the teardown function + * removing the eventlistener + * @return {Void} + */ + // @TODO: maybe rework teardown to work with event type?! + teardown : function() { + // split the arguments to necessary controll arguements + var _aSplit = sInternal_.split('_'); + var _sDOMEvent = _aSplit[0]; // + // get the associated gesture event and strip the counter: necessary for distinguisihng similliar events such as tapone-tapfour + var _sGestureEvent = _aSplit[1].slice(0,_aSplit[1].length-2); + var _$element = jQuery(this); + var _oDatajQueryGestures; + var oObj; + // bind the event handler on the first $.bind() for a gestureend-event, set marker + if (!_$element.data('ojQueryGestures') || !_$element.data('ojQueryGestures')[_sDOMEvent]) { + // setup pseudo event + _oDatajQueryGestures = _$element.data('ojQueryGestures') || {}; + oObj = {}; + // remove marker for: domEvent being set on this element + oObj[_sDOMEvent] = false; + $.extend(true,_oDatajQueryGestures,oObj); + _$element.data('ojQueryGestures' ,_oDatajQueryGestures); + + // remove gesture events + if($.hasGestures) { + switch(_sGestureEvent) { + + // event: orientationchange + case 'orientationchange': + _$element.get(0).removeEventListener('orientationchange', _onOrientationchange, false); + break; + + case 'shake': + case 'shakefrontback': + case 'shakeleftright': + case 'shakeupdown': + case 'tilt': + _$element.get(0).removeEventListener('devicemotion', _onDevicemotion, false); + break; + + // event : + // - touchstart + // - touchmove + // - touchend + case 'tap': + case 'swipe': + case 'swipeup': + case 'swiperightup': + case 'swiperight': + case 'swiperightdown': + case 'swipedown': + case 'swipeleftdown': + case 'swipeleft': + case 'swipeleftup': + _$element.get(0).removeEventListener('touchstart', _onTouchstart, false); + _$element.get(0).removeEventListener('touchmove', _onTouchmove, false); + _$element.get(0).removeEventListener('touchend', _onTouchend, false); + break; + + // event: gestureend + case 'pinchopen': + case 'pinchclose' : + case 'rotatecw' : + case 'rotateccw' : + _$element.get(0).removeEventListener('gesturestart', _onGesturestart, false); + _$element.get(0).removeEventListener('gestureend', _onGestureend, false); + break; + + // event: gesturechange + case 'pinch': + case 'rotate': + _$element.get(0).removeEventListener('gesturestart', _onGesturestart, false); + _$element.get(0).removeEventListener('gesturechange', _onGesturechange, false); + break; + } + } + // remove substitute for gesture events + else { + switch(_sGestureEvent) { + // event substitutes: + // - touchstart: mousedown + // - touchmove: none + // - touchend: mouseup + case 'tap': + case 'swipe': +// _$element.get(0).removeEventListener('mousedown', _onTouchstart, false); +// _$element.get(0).removeEventListener('mousemove', _onTouchmove, false); +// _$element.get(0).removeEventListener('mouseup', _onTouchend, false); + _$element.unbind('mousedown', _onTouchstart); + _$element.unbind('mousemove', _onTouchmove); + _$element.unbind('mouseup', _onTouchend); + break; + + // no substitution + case 'orientationchange': + case 'pinchopen': + case 'pinchclose' : + case 'rotatecw' : + case 'rotateccw' : + case 'pinch': + case 'rotate': + case 'shake': + case 'tilt': + + break; + } + } + + } + return false; + } + + }; + }); + + /** + * Creates the object that ist passed as second argument to the $element.triggerHandler function. + * This object contains detailed informations about the gesture event. + * @param {Object} oOptions_ {type: {String}, touches: {String}, deltaY: {String},deltaX : {String}, startMove: {Object}, event:{DOM-Event}, timestamp:{String},vector: {Number}} + * @example _createOptions ( + * { + * type: 'swipemove', + * touches: '1', + * deltaY: _iDeltaY, + * deltaX : _iDeltaX, + * startMove: _oDatajQueryGestures.oStartTouch, + * event:event_, + * timestamp:_oEventData.timestamp, + * vector: -1 + * } + * ); + * @returns {Object} + * { + * type: eventtype e.g. "swipe","pinch", + * originalEvent: {DOM-Event}, + * // default: just one entry on the delta-array - the first touchpoint + * // the first touchpoint is the reference point for every gesture, + * // because moving touchpoints in various directions would result in + * // a gesture. + * // delta and direction details are just provided for touch not for gesture / motion events + * delta : [ + * { + * lastX:{Number} , // x-axis: relative to the last touchevent (e.g. touchmove!) + * lastY:{Number}, // y-axis: relative to the last touchevent (e.g. touchmove!) + * moved: {Number}, // distance: relative to the original touchpoint + * startX: {Number} , // relative to the original touchpoint + * startY: {Number} ,// relative to the original touchpoint + * } ], + * // based on the first touchpoint + * direction : { // relative to the last touchevent (e.g. touchmove!) + * vector: {Number}, // -1|+1, indicates the direction if necessary(pinch/rotate) + * orientation: {Number} // window.orientation: -90,0,90,180 || null (window.orienntation) + * lastX : {Number}, // -1,0,+1 relative to the last touchevent (e.g. touchmove!) + * lastY : {Number}, // -1,0,+1 relative to the last touchevent (e.g. touchmove!) + * startX: {Number} , //-1,0,+1 relative to the original touchpoint + * startY: {Number} ,// -1,0,+1 relative to the original touchpoint + * }, + * rotation: {Number} || null, // gestureonly: amount of rotation relative to the current position NOT the original + * scale: {Number} || null, // gestureonly: amount of scaling relative to the current position NOT the original + * duration: {Number}, // ms: relative to the original touchpoint + * description : {String} // details as String: {TYPE *}:{TOUCHES 1|2|3|4}:{X-AXIS 'right'|'left'|'steady'}:{Y-AXIS 'down'|'up'|'steady'} e.g. "swipe:1:left:steady" relative to the last touchpoint + * }; + */ + function _createOptions(oOptions_) { + // force properties + oOptions_.startMove = (oOptions_.startMove) ? oOptions_.startMove : {startX: null,startY:null,timestamp:null} ; + var _iNow = new Date().getTime(); + var _oDirection; + var _oDelta; + // calculate touch differences + if (oOptions_.touches) { + // store delta values + _oDelta = [ + { + lastX: oOptions_.deltaX , + lastY: oOptions_.deltaY, + moved: null, + startX: oOptions_.screenX - oOptions_.startMove.screenX , + startY: oOptions_.screenY - oOptions_.startMove.screenY + } + ]; + + _oDirection = { + vector: oOptions_.vector || null, + orientation : window.orientation || null, + lastX : ((_oDelta[0].lastX > 0) ? +1 : ( (_oDelta[0].lastX < 0) ? -1 : 0 ) ), + lastY : ((_oDelta[0].lastY > 0) ? +1 : ( (_oDelta[0].lastY < 0) ? -1 : 0 ) ), + startX : ((_oDelta[0].startX > 0) ? +1 : ( (_oDelta[0].startX < 0) ? -1 : 0 ) ), + startY : ((_oDelta[0].startY > 0) ? +1 : ( (_oDelta[0].startY < 0) ? -1 : 0 ) ) + }; + + // calculate distance traveled using the pythagorean theorem + _oDelta[0].moved = Math.sqrt(Math.pow(Math.abs(_oDelta[0].startX), 2) + Math.pow(Math.abs(_oDelta[0].startY), 2)); + + } + return { + type: oOptions_.type || null, + originalEvent: oOptions_.event || null, + delta : _oDelta || null, + direction : _oDirection || { orientation : window.orientation || null, vector: oOptions_.vector || null}, + duration: (oOptions_.duration) ? oOptions_.duration : ( oOptions_.startMove.timestamp ) ? _iNow - oOptions_.timestamp : null, + rotation: oOptions_.rotation || null, + scale: oOptions_.scale || null, + description : oOptions_.description || [ + oOptions_.type, + ':', + oOptions_.touches, + ':', + ((_oDelta[0].lastX != 0) ? ((_oDelta[0].lastX > 0) ? 'right' : 'left') : 'steady'), + ':', + ((_oDelta[0].lastY != 0) ? ( (_oDelta[0].lastY > 0) ? 'down' : 'up') :'steady') + ].join('') + }; + + } + + + + /** + * DOM-event handlers + */ + + /** + * Handler: orientationchange + * Triggers the bound orientationchange handler on the window element + * The "orientationchange" handler will receive an object with additional information + * about the event. + * { + * direction : { + * orientation: {-90|0|90|180} + * }, + * description : [ + * 'orientationchange:{landscape:clockwise:|portrait:default|landscape:counterclockwise|portrait:upsidedown}:{-90|0|90|180}' // e.g. 'orientation:landscape:clockwise:-90 + * } + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onOrientationchange(event_) { + + // window.orientation: -90,0,90,180 + var _aDict = ['landscape:clockwise:','portrait:default:','landscape:counterclockwise:','portrait:upsidedown:']; + + $(window).triggerHandler('orientationchange', + { + direction : {orientation: window.orientation}, + description : [ + 'orientationchange:', + _aDict[( (window.orientation / 90) +1)], + window.orientation + ].join('') + }); + } + + + /** + * Handler: devicemotion + * Calculates "motion events" such as shake, tilt, wiggle by observing "changes in space" + * For understanding "directions", place your mobile device on a table with the bottom + * (home button) close to you: + * - x-axis: horizontal left / right + * - y-axis: horizontal front / back (through the home button) + * - z-axis: vertical through your device + * @param {DOM-Event} event_ + * @returns {Object} + * { + * type: eventtype e.g. "shake", + * originalEvent: {DOM-Event}, + * // delta and direction details are just provided for touch not for gesture / motion events + * delta : null, + * direction :{ + * vector: null, + * orientation: -90,0,90,180 || null (window.orienntation) + * } + * rotation: {Number} , // amount of rotation relative to the current position NOT the original + * scale: {Number} , // amount of scaling relative to the current position NOT the original + * duration: {Number}, // ms: duration of the motion + * description : {String} // details as String: pinch:{'close'|'open'} e.g. "pinch:-1:close" || rotate:{'counterclockwise'|'clockwise'} e.g. "rotate:-1:counterclockwise" + * }; + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onDevicemotion(event_) { + + var _sType; + var _$element = jQuery(window); + //var _bHasGyroscope = $.hasGyroscope; + + // skip custom notification: devicemotion is triggered every 0.05s regardlesse of any gesture + + // get options + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + + var _oThreshold = $.jGestures.defaults.thresholdShake; + + // get last position or set initital values + var _oLastDevicePosition = _oDatajQueryGestures.oDeviceMotionLastDevicePosition || { + accelerationIncludingGravity : { + x: 0, + y: 0, + z: 0 + }, + shake : { + eventCount: 0, + intervalsPassed: 0, + intervalsFreeze: 0 + }, + shakeleftright : { + eventCount: 0, + intervalsPassed: 0, + intervalsFreeze: 0 + }, + shakefrontback : { + eventCount: 0, + intervalsPassed: 0, + intervalsFreeze: 0 + }, + shakeupdown : { + eventCount: 0, + intervalsPassed: 0, + intervalsFreeze: 0 + } + }; + + // cache current values + var _oCurrentDevicePosition = { + accelerationIncludingGravity : { + x: event_.accelerationIncludingGravity.x, + y: event_.accelerationIncludingGravity.y, + z: event_.accelerationIncludingGravity.z + }, + shake: { + eventCount: _oLastDevicePosition.shake.eventCount, + intervalsPassed: _oLastDevicePosition.shake.intervalsPassed, + intervalsFreeze: _oLastDevicePosition.shake.intervalsFreeze + }, + shakeleftright: { + eventCount: _oLastDevicePosition.shakeleftright.eventCount, + intervalsPassed: _oLastDevicePosition.shakeleftright.intervalsPassed, + intervalsFreeze: _oLastDevicePosition.shakeleftright.intervalsFreeze + }, + shakefrontback: { + eventCount: _oLastDevicePosition.shakefrontback.eventCount, + intervalsPassed: _oLastDevicePosition.shakefrontback.intervalsPassed, + intervalsFreeze: _oLastDevicePosition.shakefrontback.intervalsFreeze + }, + shakeupdown: { + eventCount: _oLastDevicePosition.shakeupdown.eventCount, + intervalsPassed: _oLastDevicePosition.shakeupdown.intervalsPassed, + intervalsFreeze: _oLastDevicePosition.shakeupdown.intervalsFreeze + } + + }; + + + // options + var _aType; + var _aDescription; + var _oObj; + + + // trigger events for all bound pseudo events on this element + for (_sType in _oDatajQueryGestures) { + // get current pseudo event + + + // trigger bound events on this element + switch(_sType) { + + case 'shake': + case 'shakeleftright': + case 'shakefrontback': + case 'shakeupdown': + + // options + _aType = []; + _aDescription = []; + + _aType.push(_sType); + + // freeze shake - prevent multiple shake events on one shaking motion (user won't stop shaking immediately) + if (++_oCurrentDevicePosition[_sType].intervalsFreeze > _oThreshold.freezeShakes && _oCurrentDevicePosition[_sType].intervalsFreeze < (2*_oThreshold.freezeShakes) ) { break; } + + // set control values + _oCurrentDevicePosition[_sType].intervalsFreeze = 0; + _oCurrentDevicePosition[_sType].intervalsPassed++; + + // check for shaking motions: massive acceleration changes in every direction + if ( ( _sType === 'shake' ||_sType === 'shakeleftright' ) && ( _oCurrentDevicePosition.accelerationIncludingGravity.x > _oThreshold.leftright.sensitivity || _oCurrentDevicePosition.accelerationIncludingGravity.x < (-1* _oThreshold.leftright.sensitivity) ) ) { + _aType.push('leftright'); + _aType.push('x-axis'); + } + + if ( ( _sType === 'shake' ||_sType === 'shakefrontback' ) && (_oCurrentDevicePosition.accelerationIncludingGravity.y > _oThreshold.frontback.sensitivity || _oCurrentDevicePosition.accelerationIncludingGravity.y < (-1 * _oThreshold.frontback.sensitivity) ) ) { + _aType.push('frontback'); + _aType.push('y-axis'); + } + + if ( ( _sType === 'shake' ||_sType === 'shakeupdown' ) && ( _oCurrentDevicePosition.accelerationIncludingGravity.z+9.81 > _oThreshold.updown.sensitivity || _oCurrentDevicePosition.accelerationIncludingGravity.z+9.81 < (-1 * _oThreshold.updown.sensitivity) ) ) { + _aType.push('updown'); + _aType.push('z-axis'); + } + + // at least one successful shaking event + if (_aType.length > 1) { + // minimum number of shaking motions during the defined "time" (messured by events - device event interval: 0.05s) + if (++_oCurrentDevicePosition[_sType].eventCount == _oThreshold.requiredShakes && (_oCurrentDevicePosition[_sType].intervalsPassed) < _oThreshold.freezeShakes ) { + // send event + _$element.triggerHandler(_sType, _createOptions ({type: _sType, description: _aType.join(':'), event:event_,duration:_oCurrentDevicePosition[_sType].intervalsPassed*5 }) ); + // reset + _oCurrentDevicePosition[_sType].eventCount = 0; + _oCurrentDevicePosition[_sType].intervalsPassed = 0; + // freeze shake + _oCurrentDevicePosition[_sType].intervalsFreeze = _oThreshold.freezeShakes+1; + } + // too slow, reset + else if (_oCurrentDevicePosition[_sType].eventCount == _oThreshold.requiredShakes && (_oCurrentDevicePosition[_sType].intervalsPassed) > _oThreshold.freezeShakes ) { + _oCurrentDevicePosition[_sType].eventCount = 0 ; + _oCurrentDevicePosition[_sType].intervalsPassed = 0; + } + } + break; + + } + + // refresh pseudo events + _oObj = {}; + _oObj.oDeviceMotionLastDevicePosition = _oCurrentDevicePosition; + _$element.data('ojQueryGestures',$.extend(true,_oDatajQueryGestures,_oObj)); + + } + } + + + /** + * Handler: touchstart or mousedown + * Setup pseudo-event by storing initial values such as : + * screenX : {Number} + * screenY : {Number} + * timestamp: {Number} + * on the pseudo gesture event and + * sets up additional eventlisteners for handling touchmove events. + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onTouchstart(event_) { + + // ignore bubbled handlers + // if ( event_.currentTarget !== event_.target ) { return; } + + var _$element = jQuery(event_.currentTarget); + // var _$element = jQuery(event_.target); + + // trigger custom notification + _$element.triggerHandler($.jGestures.events.touchstart,event_); + + + // set the necessary touch events + if($.hasGestures) { + event_.currentTarget.addEventListener('touchmove', _onTouchmove, false); + event_.currentTarget.addEventListener('touchend', _onTouchend, false); + } + // event substitution + else { +// event_.currentTarget.addEventListener('mousemove', _onTouchmove, false); +// event_.currentTarget.addEventListener('mouseup', _onTouchend, false); + _$element.bind('mousemove', _onTouchmove); + _$element.bind('mouseup', _onTouchend); + } + + // get stored pseudo event + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + + // var _oEventData = _oDatajQueryGestures[_sType]; + var _eventBase = (event_.touches) ? event_.touches[0] : event_; + // store current values for calculating relative values (changes between touchmoveevents) + var _oObj = {}; + _oObj.oLastSwipemove = { screenX : _eventBase.screenX, screenY : _eventBase.screenY, timestamp:new Date().getTime()}; + _oObj.oStartTouch = { screenX : _eventBase.screenX, screenY : _eventBase.screenY, timestamp:new Date().getTime()}; + + _$element.data('ojQueryGestures',$.extend(true,_oDatajQueryGestures,_oObj)); + } + + + /** + * Handler: touchmove or mousemove + * Calculates the x/y changes since the last event, + * compares it to $.jGestures.defaults.thresholdMove and triggers + * an swipemove event if the distance exceed the + * threshold. + * Custom-event argument object: + * {Object} + * { + * type: e.g. 'swipemove', + * ≈: {DOM-Event}, + * // default: just one entry on the delta-array - the first touchpoint + * // the first touchpoint is the reference point for every gesture, + * // because moving touchpoints in various directions would result in + * // a gesture. + * // delta and direction details are just provided for touch not for gesture / motion events + * delta : [ + * { + * lastX:{Number} , // x-axis: relative to the last touchevent (e.g. touchmove!) + * lastY:{Number}, // y-axis: relative to the last touchevent (e.g. touchmove!) + * moved: {Number}, // distance: relative to the original touchpoint + * startX: {Number} , // relative to the original touchpoint + * startY: {Number} ,// relative to the original touchpoint + * } ], + * // based on the first touchpoint + * direction : { // relative to the last touchevent (e.g. touchmove!) + * vector: {Number}, // -1|+1, indicates the direction if necessary(pinch/rotate) + * orientation: {Number} // window.orientation: -90,0,90,180 || null (window.orienntation) + * lastX : {Number}, // -1,0,+1 relative to the last touchevent (e.g. touchmove!) + * lastY : {Number}, // -1,0,+1 relative to the last touchevent (e.g. touchmove!) + * startX: {Number} , //-1,0,+1 relative to the original touchpoint + * startY: {Number} ,// -1,0,+1 relative to the original touchpoint + * }, + * rotation: null, // gestureonly: amount of rotation relative to the current position NOT the original + * scale: null, // gestureonly: amount of scaling relative to the current position NOT the original + * duration: {Number}, // ms: relative to the original touchpoint + * description : {String} // details as String: {TYPE *}:{TOUCHES 1|2|3|4}:{X-AXIS 'right'|'left'|'steady'}:{Y-AXIS 'down'|'up'|'steady'} e.g. "swipe:1:left:steady" relative to the last touchpoint + * }; + * + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onTouchmove(event_) { + + var _$element = jQuery(event_.currentTarget); + // var _$element = jQuery(event_.target); + + // get stored pseudo event + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + + var _bHasTouches = !!event_.touches; + var _iScreenX = (_bHasTouches) ? event_.changedTouches[0].screenX : event_.screenX; + var _iScreenY = (_bHasTouches) ? event_.changedTouches[0].screenY : event_.screenY; + + //relative to the last event + var _oEventData = _oDatajQueryGestures.oLastSwipemove; + var _iDeltaX = _iScreenX - _oEventData.screenX ; + var _iDeltaY = _iScreenY - _oEventData.screenY; + + var _oDetails; + + // there's a swipemove set (not the first occurance), trigger event + if (!!_oDatajQueryGestures.oLastSwipemove) { + // check + _oDetails = _createOptions({type: 'swipemove', touches: (_bHasTouches) ? event_.touches.length: '1', screenY: _iScreenY,screenX:_iScreenX ,deltaY: _iDeltaY,deltaX : _iDeltaX, startMove:_oEventData, event:event_, timestamp:_oEventData.timestamp}); + _$element.triggerHandler(_oDetails.type,_oDetails); + } + // store the new values + var _oObj = {}; + var _eventBase = (event_.touches) ? event_.touches[0] : event_; + _oObj.oLastSwipemove = { screenX : _eventBase.screenX, screenY : _eventBase.screenY, timestamp:new Date().getTime()}; + _$element.data('ojQueryGestures',$.extend(true,_oDatajQueryGestures,_oObj)); + } + + + /** + * Handler: touchend or mouseup + * Removes the additional handlers (move/end) + * Calculates the x/y changes since the touchstart event + * not in relation to the last move event. + * Triggers the + * swipeone|swipetwo|swipethree|swipefour| + * swipeup|swiperightup|swiperight|swiperightdown|swipedown| + * swipeleftdown|swipeleft|swipeleftup| + * tapone|taptwo|tapthree|tapfour + * event. + * {Object} + * { + * type: eventtype e.g. "swipeone","swipeleftdown", + * originalEvent: {DOM-Event}, + * // default: just one entry on the delta-array - the first touchpoint + * // the first touchpoint is the reference point for every gesture, + * // because moving touchpoints in various directions would result in + * // a gesture. + * // delta and direction details are just provided for touch not for gesture / motion events + * delta : [ + * { + * lastX:{Number} , // x-axis: relative to the last touchevent (e.g. touchmove!) + * lastY:{Number}, // y-axis: relative to the last touchevent (e.g. touchmove!) + * moved: {Number}, // distance: relative to the original touchpoint + * startX: {Number} , // relative to the original touchpoint + * startY: {Number} ,// relative to the original touchpoint + * } ], + * // based on the first touchpoint + * direction : { // relative to the last touchevent (e.g. touchmove!) + * vector: {Number}, // -1|+1, indicates the direction if necessary(pinch/rotate) + * orientation: {Number} // window.orientation: -90,0,90,180 || null (window.orienntation) + * lastX : {Number}, // -1,0,+1 relative to the last touchevent (e.g. touchmove!) + * lastY : {Number}, // -1,0,+1 relative to the last touchevent (e.g. touchmove!) + * startX: {Number} , //-1,0,+1 relative to the original touchpoint + * startY: {Number} ,// -1,0,+1 relative to the original touchpoint + * }, + * rotation: null, + * scale: null , + * duration: {Number}, // ms: relative to the original touchpoint + * description : {String} // details as String: {TYPE *}:{TOUCHES 1|2|3|4}:{X-AXIS 'right'|'left'|'steady'}:{Y-AXIS 'down'|'up'|'steady'} e.g. "swipe:1:left:steady" relative to the last touchpoint + * }; + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onTouchend(event_) { + + // ignore bubbled handlers + // if ( event_.currentTarget !== event_.target ) { return; } + + var _$element = jQuery(event_.currentTarget); + var _bHasTouches = !!event_.changedTouches; + var _iTouches = (_bHasTouches) ? event_.changedTouches.length : '1'; + var _iScreenX = (_bHasTouches) ? event_.changedTouches[0].screenX : event_.screenX; + var _iScreenY = (_bHasTouches) ? event_.changedTouches[0].screenY : event_.screenY; + + // trigger custom notification + _$element.triggerHandler($.jGestures.events.touchendStart,event_); + + // var _$element = jQuery(event_.target); + // remove events + if($.hasGestures) { + event_.currentTarget.removeEventListener('touchmove', _onTouchmove, false); + event_.currentTarget.removeEventListener('touchend', _onTouchend, false); + } + // event substitution + else { +// event_.currentTarget.removeEventListener('mousemove', _onTouchmove, false); +// event_.currentTarget.removeEventListener('mouseup', _onTouchend, false); + _$element.unbind('mousemove', _onTouchmove); + _$element.unbind('mouseup', _onTouchend); + } + // get all bound pseudo events + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + + // if the current change on the x/y position is above the defined threshold for moving an element set the moved flag + // to distinguish between a moving gesture and a shaking finger trying to tap + var _bHasMoved = ( + Math.abs(_oDatajQueryGestures.oStartTouch.screenX - _iScreenX) > $.jGestures.defaults.thresholdMove || + Math.abs(_oDatajQueryGestures.oStartTouch.screenY - _iScreenY) > $.jGestures.defaults.thresholdMove + ) ? true : false; + + // if the current change on the x/y position is above the defined threshold for swiping set the moved flag + // to indicate we're dealing with a swipe gesture + var _bHasSwipeGesture = ( + Math.abs(_oDatajQueryGestures.oStartTouch.screenX - _iScreenX) > $.jGestures.defaults.thresholdSwipe || + Math.abs(_oDatajQueryGestures.oStartTouch.screenY - _iScreenY) > $.jGestures.defaults.thresholdSwipe + ) ? true : false; + + + var _sType; + var _oEventData ; + + var _oDelta; + + // calculate distances in relation to the touchstart position not the last touchmove event! + var _iDeltaX; + var _iDeltaY; + var _oDetails; + + var _aDict = ['zero','one','two','three','four']; + + // swipe marker + var _bIsSwipe; + + + // trigger events for all bound pseudo events on this element + for (_sType in _oDatajQueryGestures) { + + // get current pseudo event + _oEventData = _oDatajQueryGestures.oStartTouch; + + _oDelta = {}; + _iScreenX = (_bHasTouches) ? event_.changedTouches[0].screenX : event_.screenX; + _iScreenY = (_bHasTouches) ? event_.changedTouches[0].screenY : event_.screenY; + // calculate distances in relation to the touchstart position not the last touchmove event! + _iDeltaX = _iScreenX - _oEventData.screenX ; + _iDeltaY = _iScreenY - _oEventData.screenY; + _oDetails = _createOptions({type: 'swipe', touches: _iTouches, screenY: _iScreenY,screenX:_iScreenX ,deltaY: _iDeltaY,deltaX : _iDeltaX, startMove:_oEventData, event:event_, timestamp: _oEventData.timestamp }); + + + // swipe marker + _bIsSwipe = false; + + // trigger bound events on this element + switch(_sType) { + case 'swipeone': + + if( _bHasTouches === false && _iTouches == 1 && _bHasMoved === false){ + // trigger tapone! + break; + } + if (_bHasTouches===false || ( _iTouches == 1 && _bHasMoved === true && _bHasSwipeGesture===true)) { + _bIsSwipe = true; + + _oDetails.type = ['swipe',_aDict[_iTouches]].join(''); + _$element.triggerHandler(_oDetails.type,_oDetails); + } + break; + + case 'swipetwo': + if (( _bHasTouches && _iTouches== 2 && _bHasMoved === true && _bHasSwipeGesture===true)) { + _bIsSwipe = true; + _oDetails.type = ['swipe',_aDict[_iTouches]].join(''); + _$element.triggerHandler(_oDetails.type,_oDetails); + } + break; + + case 'swipethree': + if ( ( _bHasTouches && _iTouches == 3 && _bHasMoved === true && _bHasSwipeGesture===true)) { + _bIsSwipe = true; + _oDetails.type = ['swipe',_aDict[_iTouches]].join(''); + _$element.triggerHandler(_oDetails.type,_oDetails); + } + break; + + case 'swipefour': + if ( ( _bHasTouches && _iTouches == 4 && _bHasMoved === true && _bHasSwipeGesture===true)) { + _bIsSwipe = true; + _oDetails.type = ['swipe',_aDict[_iTouches]].join(''); + _$element.triggerHandler(_oDetails.type,_oDetails); + } + break; + + case 'swipeup': + case 'swiperightup': + case 'swiperight': + case 'swiperightdown': + case 'swipedown': + case 'swipeleftdown': + case 'swipeleft': + case 'swipeleftup': + if ( _bHasTouches && _bHasMoved === true && _bHasSwipeGesture===true) { + _bIsSwipe = true; + _oDetails.type = [ + 'swipe', + ((_oDetails.delta[0].lastX != 0) ? ((_oDetails.delta[0].lastX > 0) ? 'right' : 'left') : ''), + ((_oDetails.delta[0].lastY != 0) ? ((_oDetails.delta[0].lastY > 0) ? 'down' : 'up') :'') + ].join(''); + _$element.triggerHandler(_oDetails.type, _oDetails); + } + break; + + case 'tapone': + case 'taptwo': + case 'tapthree': + case 'tapfour': + if (( /* _bHasTouches && */ _bHasMoved !== true && _bIsSwipe !==true) && (_aDict[_iTouches] ==_sType.slice(3)) ) { + _oDetails.description = ['tap',_aDict[_iTouches]].join(''); + _oDetails.type = ['tap',_aDict[_iTouches]].join(''); + _$element.triggerHandler(_oDetails.type,_oDetails); + } + break; + + } + + // refresh pseudo events + var _oObj = {}; +// _oObj[_sType] = false; +// _oObj.hasTouchmoved = false; + _$element.data('ojQueryGestures',$.extend(true,_oDatajQueryGestures,_oObj)); + _$element.data('ojQueryGestures',$.extend(true,_oDatajQueryGestures,_oObj)); + + } + _$element.triggerHandler($.jGestures.events.touchendProcessed,event_); + } + + + /** + * Handler: gesturestart + * Setup pseudo-event by storing initial values such as : + * timestamp: {Number} + * on the pseudo gesture event + * Since the gesture-event doesn't supply event.touches no tuchpoints will be calculated + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onGesturestart(event_) { + + // ignore bubbled handlers + // if ( event_.currentTarget !== event_.target ) { return; } + + var _$element = jQuery(event_.currentTarget); + // var _$element = jQuery(event_.target); + + // trigger custom notification + _$element.triggerHandler($.jGestures.events.gesturestart,event_); + + + // get stored pseudo event + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + + // var _oEventData = _oDatajQueryGestures[_sType]; + // store current values for calculating relative values (changes between touchmoveevents) + var _oObj = {}; + _oObj.oStartTouch = {timestamp:new Date().getTime()}; + _$element.data('ojQueryGestures',$.extend(true,_oDatajQueryGestures,_oObj)); + } + + /** + * Handler: gesturechange + * Read the event_.scale / event_.rotate values, + * an triggers a pinch|rotate event if necessary. + * Since the gesture-event doesn't supply event.touches no tuchpoints will be calculated + * @returns {Object} + * { + * type: eventtype e.g. "pinch","rotate", + * originalEvent: {DOM-Event}, + * // delta and direction details are just provided for touch not for gesture / motion events + * delta : null, + * direction : { + * vector: {Number}, // -1|+1, indicates the direction if necessary(pinch/rotate) + * orientation: {Number} // window.orientation: -90,0,90,180 || null (window.orienntation) + * }, + * rotation: {Number} , // amount of rotation relative to the current position NOT the original + * scale: {Number} , // amount of scaling relative to the current position NOT the original + * duration: {Number}, // ms: relative to the original touchpoint + * description : {String} // details as String: pinch:{'close'|'open'} e.g. "pinch:-1:close" || rotate:{'counterclockwise'|'clockwise'} e.g. "rotate:-1:counterclockwise" + * }; + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onGesturechange(event_) { + + // ignore bubbled handlers + // if ( event_.currentTarget !== event_.target ) { return; } + + var _$element = jQuery(event_.currentTarget); + // var _$element = jQuery(event_.target); + var _iDelta,_iDirection,_sDesc,_oDetails; + // get all pseudo events + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + + // trigger events for all bound pseudo events on this element + var _sType; + for (_sType in _oDatajQueryGestures) { + + // trigger a specific bound event + switch(_sType) { + + case 'pinch': + _iDelta = event_.scale; + if ( ( ( _iDelta < 1 ) && (_iDelta % 1) < (1 - $.jGestures.defaults.thresholdPinchclose) ) || ( ( _iDelta > 1 ) && (_iDelta % 1) > ($.jGestures.defaults.thresholdPinchopen) ) ) { + _iDirection = (_iDelta < 1 ) ? -1 : +1 ; + _oDetails = _createOptions({type: 'pinch', scale: _iDelta, touches: null,startMove:_oDatajQueryGestures.oStartTouch, event:event_, timestamp: _oDatajQueryGestures.oStartTouch.timestamp, vector:_iDirection, description: ['pinch:',_iDirection,':' , ( (_iDelta < 1 ) ? 'close' : 'open' )].join('') }); + _$element.triggerHandler(_oDetails.type, _oDetails); + } + break; + + case 'rotate': + _iDelta = event_.rotation; + if ( ( ( _iDelta < 1 ) && ( -1*(_iDelta) > $.jGestures.defaults.thresholdRotateccw ) ) || ( ( _iDelta > 1 ) && (_iDelta > $.jGestures.defaults.thresholdRotatecw) ) ) { + _iDirection = (_iDelta < 1 ) ? -1 : +1 ; + _oDetails = _createOptions({type: 'rotate', rotation: _iDelta, touches: null, startMove:_oDatajQueryGestures.oStartTouch, event:event_, timestamp: _oDatajQueryGestures.oStartTouch.timestamp, vector:_iDirection, description: ['rotate:',_iDirection,':' , ( (_iDelta < 1 ) ? 'counterclockwise' : 'clockwise' )].join('') }); + _$element.triggerHandler(_oDetails.type, _oDetails); + } + break; + + } + } + + } + + + /** + * Handler: gestureend + * Read the event_.scale / event_.rotate values, + * compares it to $.jGestures.defaults.threshold* and triggers + * a pinchclose|pinchclose|rotatecw|rotateccw event if the distance exceed the + * Since the gesture-event doesn't supply event.touches no tuchpoints will be calculated + * * Custom-event argument object: + * @returns {Object} + * { + * type: eventtype e.g. "pinchclose","pinchopen", "rotatecw", "rotateccw", + * originalEvent: {DOM-Event}, + * // delta and direction details are just provided for touch not for gesture / motion events + * delta : null, + * // based on the first touchpoint + * direction : { + * vector: {Number}, // -1|+1, indicates the direction if necessary(pinch/rotate) + * orientation: {Number} // window.orientation: -90,0,90,180 || null (window.orienntation) + * }, + * rotation: {Number} , // amount of rotation relative to the current position NOT the original + * scale: {Number} , // amount of scaling relative to the current position NOT the original + * duration: {Number}, // ms: relative to the original touchpoint + * description : {String} // details as String: pinch:{'close'|'open'} e.g. "pinch:-1:close" || rotate:{'counterclockwise'|'clockwise'} e.g. "rotate:-1:counterclockwise" + * }; + * @param {DOM-Event} event_ + * @return {Void} + */ + function _onGestureend(event_) { + // ignore bubbled handlers + // if ( event_.currentTarget !== event_.target ) { return; } + + var _$element = jQuery(event_.currentTarget); + // var _$element = jQuery(event_.target); + + // trigger custom notification + _$element.triggerHandler($.jGestures.events.gestureendStart,event_); + + var _iDelta; + var _oDatajQueryGestures = _$element.data('ojQueryGestures'); + + // trigger handler for every bound event + var _sType; + for (_sType in _oDatajQueryGestures) { + + switch(_sType) { + + case 'pinchclose': + _iDelta = event_.scale; + if (( _iDelta < 1 ) && (_iDelta % 1) < (1 - $.jGestures.defaults.thresholdPinchclose)) { + _$element.triggerHandler('pinchclose', _createOptions ({type: 'pinchclose', scale:_iDelta, vector: -1, touches: null, startMove: _oDatajQueryGestures.oStartTouch, event:event_, timestamp:_oDatajQueryGestures.oStartTouch.timestamp,description: 'pinch:-1:close' }) ); + } + break; + + case 'pinchopen': + _iDelta = event_.scale; + if ( ( _iDelta > 1 ) && (_iDelta % 1) > ($.jGestures.defaults.thresholdPinchopen) ) { + _$element.triggerHandler('pinchopen', _createOptions ({type: 'pinchopen', scale:_iDelta, vector: +1, touches: null, startMove: _oDatajQueryGestures.oStartTouch, event:event_, timestamp:_oDatajQueryGestures.oStartTouch.timestamp,description: 'pinch:+1:open'}) ); + } + break; + + case 'rotatecw': + _iDelta = event_.rotation; + if ( ( _iDelta > 1 ) && (_iDelta > $.jGestures.defaults.thresholdRotatecw) ) { + _$element.triggerHandler('rotatecw', _createOptions ({type: 'rotatecw', rotation:_iDelta, vector: +1, touches: null, startMove: _oDatajQueryGestures.oStartTouch, event:event_, timestamp:_oDatajQueryGestures.oStartTouch.timestamp,description: 'rotate:+1:clockwise'}) ); + } + break; + + case 'rotateccw': + _iDelta = event_.rotation; + if ( ( _iDelta < 1 ) && ( -1*(_iDelta) > $.jGestures.defaults.thresholdRotateccw ) ) { + _$element.triggerHandler('rotateccw', _createOptions ({type: 'rotateccw', rotation:_iDelta, vector: -1, touches: null, startMove: _oDatajQueryGestures.oStartTouch, event:event_, timestamp:_oDatajQueryGestures.oStartTouch.timestamp,description: 'rotate:-1:counterclockwise'}) ); + } + break; + + } + } + _$element.triggerHandler($.jGestures.events.gestureendProcessed,event_); + } + } +)(jQuery); diff --git a/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.js b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.js new file mode 100755 index 0000000..ab8929e --- /dev/null +++ b/Samples/3-messaging_component/embedded/PubCoder/Quizzes/OEBPS/components/PubCoder/shared/js/jquery.js @@ -0,0 +1,9267 @@ +/*! + * jQuery JavaScript Library v1.7.1 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Nov 21 21:11:03 2011 -0500 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context ? context.ownerDocument || context : document ); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.7.1", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.add( fn ); + + return this; + }, + + eq: function( i ) { + i = +i; + return i === -1 ? + this.slice( i ) : + this.slice( i, i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.fireWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).off( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery.Callbacks( "once memory" ); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array, i ) { + var len; + + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } + + len = array.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in array && array[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return ( new Date() ).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +return jQuery; + +})(); + + +// String to Object flags format cache +var flagsCache = {}; + +// Convert String-formatted flags into Object-formatted ones and store in cache +function createFlags( flags ) { + var object = flagsCache[ flags ] = {}, + i, length; + flags = flags.split( /\s+/ ); + for ( i = 0, length = flags.length; i < length; i++ ) { + object[ flags[i] ] = true; + } + return object; +} + +/* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * the callback list behaves + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible flags: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + var // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = [], + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Add one or several callbacks to the list + add = function( args ) { + var i, + length, + elem, + type, + actual; + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + // Inspect recursively + add( elem ); + } else if ( type === "function" ) { + // Add if not in unique mode and callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // firing was halted (stopOnFalse) + } else if ( memory && memory !== true ) { + firingStart = length; + fire( memory[ 0 ], memory[ 1 ] ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + var args = arguments, + argIndex = 0, + argLength = args.length; + for ( ; argIndex < argLength ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + break; + } + } + } + } + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + if ( list ) { + var i = 0, + length = list.length; + for ( ; i < length; i++ ) { + if ( fn === list[ i ] ) { + return true; + } + } + } + return false; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory || memory === true ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } else if ( !( flags.once && memory ) ) { + fire( context, args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!memory; + } + }; + + return self; +}; + + + + +var // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + + Deferred: function( func ) { + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList + }, + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + return this; + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; + } + } + return obj; + } + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = sliceDeferred.call( arguments, 0 ), + i = 0, + length = args.length, + pValues = new Array( length ), + count = length, + pCount = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(), + promise = deferred.promise(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + deferred.resolveWith( deferred, args ); + } + }; + } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } + if ( length > 1 ) { + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return promise; + } +}); + + + + +jQuery.support = (function() { + + var support, + all, + a, + select, + opt, + input, + marginDiv, + fragment, + tds, + events, + eventName, + i, + isSupported, + div = document.createElement( "div" ), + documentElement = document.documentElement; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
a"; + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute("href") === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + fragment.removeChild( input ); + fragment.appendChild( div ); + + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( window.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.style.width = "2px"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + }) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + fragment.removeChild( div ); + + // Null elements to avoid leaks in IE + fragment = select = opt = marginDiv = div = input = null; + + // Run tests that need a body at doc ready + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + conMarginTop, ptlm, vb, style, html, + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + conMarginTop = 1; + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"; + vb = "visibility:hidden;border:0;"; + style = "style='" + ptlm + "border:5px solid #000;padding:0;'"; + html = "
" + + "" + + "
"; + + container = document.createElement("div"); + container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct the test element + div = document.createElement("div"); + container.appendChild( div ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = "
t
"; + tds = div.getElementsByTagName( "td" ); + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE <= 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + + // Figure out if the W3C box model works as expected + div.innerHTML = ""; + div.style.width = div.style.paddingLeft = "1px"; + jQuery.boxModel = support.boxModel = div.offsetWidth === 2; + + if ( typeof div.style.zoom !== "undefined" ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.style.cssText = ptlm + vb; + div.innerHTML = html; + + outer = div.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + body.removeChild( container ); + div = container = null; + + jQuery.extend( support, offsetSupport ); + }); + + return support; +})(); + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, + isEvents = name === "events"; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = ++jQuery.uuid; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + privateCache = thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ internalKey ] : internalKey; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the cache and need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ internalKey ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( internalKey ); + } else { + elem[ internalKey ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var parts, attr, name, + data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { + attr = this[0].attributes; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + jQuery._data( this[0], "parsedAttrs", true ); + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var self = jQuery( this ), + args = [ parts[0], value ]; + + self.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + self.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + jQuery.isNumeric( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery._data( elem, deferDataKey ); + if ( defer && + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.fire(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); + if ( count ) { + jQuery._data( elem, key, count ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + var q; + if ( elem ) { + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + hooks = {}; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue " + type + ".run", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + count++; + tmp.add( resolve ); + } + } + resolve(); + return defer.promise(); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = ( value || "" ).split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; + + if ( value && elem.nodeType === 1 ) { + attrNames = value.toLowerCase().split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ]; + + if ( name ) { + propName = jQuery.propFix[ name ] || name; + + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && propName in elem ) { + elem[ propName ] = false; + } + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) +jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.nodeValue = value + "" ); + } + }; + + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = "" + value ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); + + + + +var rformElems = /^(?:textarea|input|select)$/i, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /\bhover(\.\S+)?\b/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, + quickParse = function( selector ) { + var quick = rquickIs.exec( selector ); + if ( quick ) { + // 0 1 2 3 + // [ _, tag, id, class ] + quick[1] = ( quick[1] || "" ).toLowerCase(); + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); + } + return quick; + }, + quickIs = function( elem, m ) { + var attrs = elem.attributes || {}; + return ( + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && + (!m[2] || (attrs.id || {}).value === m[2]) && + (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) + ); + }, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = jQuery.trim( hoverHack(types) ).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + quick: quickParse( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, origType, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = jQuery.trim( hoverHack( types || "" ) ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = origType = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var type = event.type || event, + namespaces = [], + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; + old = null; + for ( ; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + // Note that this is a bare JS function and not a jQuery handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), + run_all = !event.exclusive && !event.namespace, + handlerQueue = [], + i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Determine handlers that should run if there are delegated events + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { + + // Pregenerate a single jQuery object for reuse with .is() + jqcur = jQuery(this); + jqcur.context = this.ownerDocument || this; + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + selMatch = {}; + matches = []; + jqcur[0] = cur; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = ( + handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) + ); + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { + event.metaKey = event.ctrlKey; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady + }, + + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + ret; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on.call( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + var handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( var type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + expando = "sizcache" + (Math.random() + '').replace('.', ''), + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rReturn = /\r\n/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context, seed ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set, seed ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set, i, len, match, type, left; + + if ( !expr ) { + return []; + } + + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + type, found, item, filter, left, + i, pass, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + filter = Expr.filter[ type ]; + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + pass = not ^ found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Utility function for retreiving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +var getText = Sizzle.getText = function( elem ) { + var i, node, + nodeType = elem.nodeType, + ret = ""; + + if ( nodeType ) { + if ( nodeType === 1 || nodeType === 9 ) { + // Use textContent || innerText for elements + if ( typeof elem.textContent === 'string' ) { + return elem.textContent; + } else if ( typeof elem.innerText === 'string' ) { + // Replace IE's carriage returns + return elem.innerText.replace( rReturn, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + } else { + + // If no nodeType, this is expected to be an array + for ( i = 0; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + if ( node.nodeType !== 8 ) { + ret += getText( node ); + } + } + } + return ret; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + first = match[2]; + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + doneName = match[0]; + parent = elem.parentNode; + + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent[ expando ] = doneName; + } + + diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + !type && Sizzle.attr ? + result != null : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context, seed ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet, seed ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +Sizzle.selectors.attrMap = {}; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array (deprecated as of jQuery 1.7) + if ( jQuery.isArray( selectors ) ) { + var level = 1; + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { + + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, slice.call( arguments ).join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} + + + + +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and