diff --git a/admin/.gitignore b/admin/.gitignore old mode 100644 new mode 100755 diff --git a/admin/_config.php b/admin/_config.php old mode 100644 new mode 100755 index 87bf0b071..b0bea2b3c --- a/admin/_config.php +++ b/admin/_config.php @@ -35,4 +35,5 @@ HtmlEditorConfig::get('cms')->insertButtonsBefore('advcode', 'ssimage', 'ssflash HtmlEditorConfig::get('cms')->insertButtonsAfter ('advcode', 'fullscreen', 'separator'); HtmlEditorConfig::get('cms')->removeButtons('tablecontrols'); -HtmlEditorConfig::get('cms')->addButtonsToLine(3, 'tablecontrols'); \ No newline at end of file +HtmlEditorConfig::get('cms')->addButtonsToLine(3, 'tablecontrols'); + diff --git a/admin/code/CMSBatchAction.php b/admin/code/CMSBatchAction.php old mode 100644 new mode 100755 diff --git a/admin/code/CMSBatchActionHandler.php b/admin/code/CMSBatchActionHandler.php old mode 100644 new mode 100755 diff --git a/admin/code/CMSMenu.php b/admin/code/CMSMenu.php old mode 100644 new mode 100755 diff --git a/admin/code/CMSMenuItem.php b/admin/code/CMSMenuItem.php old mode 100644 new mode 100755 diff --git a/admin/code/GroupImportForm.php b/admin/code/GroupImportForm.php old mode 100644 new mode 100755 diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php old mode 100644 new mode 100755 index b18083b37..69cc31f5e --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -20,29 +20,53 @@ class LeftAndMain extends Controller { */ static $url_base = "admin"; + /** + * The current url segment attached to the LeftAndMain instance + * + * @var string + */ static $url_segment; + /** + * @var string + */ static $url_rule = '/$Action/$ID/$OtherID'; + /** + * @var string + */ static $menu_title; + /** + * @var int + */ static $menu_priority = 0; + /** + * @var int + */ static $url_priority = 50; /** - * @var string A subclass of {@link DataObject}. - * Determines what is managed in this interface, - * through {@link getEditForm()} and other logic. + * A subclass of {@link DataObject}. + * + * Determines what is managed in this interface, through + * {@link getEditForm()} and other logic. + * + * @var string */ static $tree_class = null; /** - * The url used for the link in the Help tab in the backend - * Value can be overwritten if required in _config.php - */ + * The url used for the link in the Help tab in the backend + * + * @var string + */ static $help_link = 'http://userhelp.silverstripe.org'; + /** + * @var array + */ static $allowed_actions = array( 'index', 'savetreenode', @@ -62,7 +86,7 @@ class LeftAndMain extends Controller { ); /** - * Register additional requirements through the {@link Requirements class}. + * Register additional requirements through the {@link Requirements} class. * Used mainly to work around the missing "lazy loading" functionality * for getting css/javascript required after an ajax-call (e.g. loading the editform). * @@ -76,6 +100,7 @@ class LeftAndMain extends Controller { /** * @param Member $member + * * @return boolean */ function canView($member = null) { @@ -234,8 +259,9 @@ class LeftAndMain extends Controller { Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.AddForm.js'); Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Preview.js'); Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.BatchActions.js'); - - Requirements::themedCSS('typography'); + + // Handled by LeftAndMain.js + Requirements::block(SAPPHIRE_DIR . '/javascript/DateField.js'); foreach (self::$extra_requirements['javascript'] as $file) { Requirements::javascript($file[0]); @@ -311,6 +337,7 @@ class LeftAndMain extends Controller { return false; } + //------------------------------------------------------------------------------------------// // Main controllers @@ -363,14 +390,6 @@ class LeftAndMain extends Controller { return $content; } - /** - * @deprecated 2.4 Please use show() - */ - public function getitem($request) { - $form = $this->getEditForm($request->getVar('ID')); - return $form->formHtmlContent(); - } - //------------------------------------------------------------------------------------------// // Main UI components @@ -463,6 +482,8 @@ class LeftAndMain extends Controller { $className = $this->stat('tree_class'); if($className && $id instanceof $className) { return $id; + } else if($id == 'root') { + return singleton($className); } else if(is_numeric($id)) { return DataObject::get_by_id($className, $id); } else { @@ -755,7 +776,7 @@ class LeftAndMain extends Controller { if(is_object($id)) { $record = $id; } else { - $record = ($id && $id != "root") ? $this->getRecord($id) : null; + $record = $this->getRecord($id); if($record && !$record->canView()) return Security::permissionFailure($this); } @@ -1096,7 +1117,7 @@ class LeftAndMain extends Controller { * @return SiteConfig */ function SiteConfig() { - return SiteConfig::current_site_config(); + return (class_exists('SiteConfig')) ? SiteConfig::current_site_config() : null; } /** diff --git a/admin/code/LeftAndMainDecorator.php b/admin/code/LeftAndMainDecorator.php old mode 100644 new mode 100755 index 5e4263cb7..eb3480ce5 --- a/admin/code/LeftAndMainDecorator.php +++ b/admin/code/LeftAndMainDecorator.php @@ -7,10 +7,11 @@ abstract class LeftAndMainDecorator extends LeftAndMainExtension { public function __construct() { - user_error( - 'LeftAndMainDecorator is deprecated, please use LeftAndMainExtension instead.', - E_USER_NOTICE - ); + // TODO Re-enable before we release 3.0 beta, for now it "breaks" too many modules + // user_error( + // 'LeftAndMainDecorator is deprecated, please use LeftAndMainExtension instead.', + // E_USER_NOTICE + // ); parent::__construct(); } diff --git a/admin/code/LeftAndMainExtension.php b/admin/code/LeftAndMainExtension.php old mode 100644 new mode 100755 diff --git a/admin/code/MemberImportForm.php b/admin/code/MemberImportForm.php old mode 100644 new mode 100755 diff --git a/admin/code/SecurityAdmin.php b/admin/code/SecurityAdmin.php old mode 100644 new mode 100755 diff --git a/admin/config.rb b/admin/config.rb old mode 100644 new mode 100755 diff --git a/admin/css/_old/MemberImportForm.css b/admin/css/_old/MemberImportForm.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/ModelAdmin.css b/admin/css/_old/ModelAdmin.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/SecurityAdmin.css b/admin/css/_old/SecurityAdmin.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/cms_left.css b/admin/css/_old/cms_left.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/cms_right.css b/admin/css/_old/cms_right.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/layout.css b/admin/css/_old/layout.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/silverstripe.tabs.css b/admin/css/_old/silverstripe.tabs.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/typography.css b/admin/css/_old/typography.css old mode 100644 new mode 100755 diff --git a/admin/css/_old/unjquery.css b/admin/css/_old/unjquery.css old mode 100644 new mode 100755 diff --git a/admin/css/layout.css b/admin/css/layout.css new file mode 100755 index 000000000..4a4136147 --- /dev/null +++ b/admin/css/layout.css @@ -0,0 +1,43 @@ +/** This file defines the structural layout of the CMS interface. Ideally, you should be able to lay out the base elements of the CMS with only this file. Please put any presentational definitions (color, fonts, backgrounds, paddings) into _style.scss or _uitheme.scss instead. */ +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; } + +body { line-height: 1; color: black; background: white; } + +ol, ul { list-style: none; } + +table { border-collapse: separate; border-spacing: 0; vertical-align: middle; } + +caption, th, td { text-align: left; font-weight: normal; vertical-align: middle; } + +q, blockquote { quotes: "" ""; } +q:before, q:after, blockquote:before, blockquote:after { content: ""; } + +a img { border: none; } + +@charset "UTF-8"; +html, body { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } + +.cms-preview { width: 1px; overflow: hidden; } +.cms-preview .cms-preview-toggle { width: 10px; } +.cms-preview iframe { width: 100%; height: 100%; } + +.cms-container { height: 100%; } + +.cms-menu { width: 250px; overflow: auto; } + +.cms-preview, .cms-menu, .cms-content, .cms-content-header, .cms-content-tools, .cms-content-form { display: -moz-inline-box; -moz-box-orient: vertical; display: inline-block; vertical-align: middle; *vertical-align: auto; } +.cms-preview, .cms-menu, .cms-content, .cms-content-header, .cms-content-tools, .cms-content-form { *display: inline; } + +.cms-content-tools { width: 230px; padding: 10px; overflow: auto; } + +.cms-content-form { overflow: auto; } + +.cms-content-header { height: 40px; } +.cms-content-header h2 { width: 226px; } +.cms-content-header > div { width: 9999em; overflow: hidden; } + +.cms-content-actions { padding: 10px; } + +.cms-logo { height: 30px; overflow: hidden; vertical-align: middle; } + +.cms-login-status { height: 30px; overflow: hidden; vertical-align: middle; } diff --git a/admin/css/screen.css b/admin/css/screen.css old mode 100644 new mode 100755 index 57979bb5f..119229857 --- a/admin/css/screen.css +++ b/admin/css/screen.css @@ -1,443 +1,292 @@ -@charset "UTF-8"; /** This file is the central collection of included modules, links to custom SCSS files, and any global SCSS variable definitions. DO NOT ADD stylesheet rules to this file directly! Note: By prefixing files with an underscore, they won't create individual CSS files. */ -/* line 14, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/** ----------------------------- Core Compass Libraries ------------------------------ */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; } -/* line 17, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ body { line-height: 1; color: black; background: white; } -/* line 19, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ ol, ul { list-style: none; } -/* line 21, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ table { border-collapse: separate; border-spacing: 0; vertical-align: middle; } -/* line 23, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ caption, th, td { text-align: left; font-weight: normal; vertical-align: middle; } -/* line 25, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ q, blockquote { quotes: "" ""; } -/* line 96, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ q:before, q:after, blockquote:before, blockquote:after { content: ""; } -/* line 27, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ a img { border: none; } -/** This file only contains color definitions. Please put any further formatting into _style.scss. */ -/** This file defines the structural layout of the CMS interface. Ideally, you should be able to lay out the base elements of the CMS with only this file. Please put any presentational definitions (color, fonts, backgrounds, paddings) into _style.scss or _uitheme.scss instead. */ -/* line 9, ../scss/_layout.scss */ -html, body { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } - -/* line 17, ../scss/_layout.scss */ -.cms-preview { width: 1px; overflow: hidden; } -/* line 21, ../scss/_layout.scss */ -.cms-preview .cms-preview-toggle { width: 10px; } -/* line 25, ../scss/_layout.scss */ -.cms-preview iframe { width: 100%; height: 100%; } - -/* line 31, ../scss/_layout.scss */ -.cms-container { height: 100%; } - -/* line 35, ../scss/_layout.scss */ -.cms-menu { width: 250px; overflow: auto; } - -/* line 47, ../scss/_layout.scss */ -.cms-menu, .cms-content, .cms-content-header, .cms-content-tools, .cms-content-form { display: -moz-inline-box; -moz-box-orient: vertical; display: inline-block; vertical-align: middle; *vertical-align: auto; } -/* line 7, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/css3/_inline-block.scss */ -.cms-menu, .cms-content, .cms-content-header, .cms-content-tools, .cms-content-form { *display: inline; } - -/* line 51, ../scss/_layout.scss */ -.cms-content-tools { width: 250px; overflow: auto; } - -/* line 56, ../scss/_layout.scss */ -.cms-content-form { overflow: auto; } - -/* line 60, ../scss/_layout.scss */ -.cms-content-header { height: 40px; } -/* line 63, ../scss/_layout.scss */ -.cms-content-header h2 { width: 226px; } -/* line 67, ../scss/_layout.scss */ -.cms-content-header > div { width: 9999em; overflow: hidden; } - -/* line 73, ../scss/_layout.scss */ -.cms-content-actions { padding: 10px; } - -/* line 77, ../scss/_layout.scss */ -.cms-logo { height: 30px; overflow: hidden; vertical-align: middle; } - -/* line 83, ../scss/_layout.scss */ -.cms-login-status { height: 30px; overflow: hidden; vertical-align: middle; } - +@charset "UTF-8"; +/** ----------------------------- Theme ------------------------------ */ +/** This file contains the default theme definitions for the admin interface. @package sapphire @subpackage admin */ +/** ----------------------------------------------- Colours ------------------------------------------------ */ +/** ----------------------------------------------- Typography ------------------------------------------------ */ +/** ----------------------------------------------- Application Logo (CMS Logo) ------------------------------------------------ */ +/** ----------------------------- CMS Components ------------------------------ */ /** This file defines the jstree base styling (see http://jstree.com), as well as any customizations (see bottom of file). The styles are usually added through jstree.js on DOM load, but we need it earlier in order to correctly display the uninitialized tree. */ -/* line 10, ../scss/_tree.scss */ .jstree ul { display: block; margin: 0 0 0 0; padding: 0 0 0 0; list-style-type: none; } -/* line 16, ../scss/_tree.scss */ .jstree li { display: block; margin: 0 0 0 0; padding: 0 0 0 0; list-style-type: none; display: block; min-height: 18px; line-height: 18px; white-space: nowrap; margin-left: 18px; min-width: 18px; } -/* line 28, ../scss/_tree.scss */ .jstree ins { display: inline-block; text-decoration: none; width: 18px; height: 18px; margin: 0 0 0 0; padding: 0; } -/* line 36, ../scss/_tree.scss */ .jstree a { display: inline-block; line-height: 16px; height: 16px; color: black; white-space: nowrap; text-decoration: none; padding: 1px 2px; margin: 0; } -/* line 45, ../scss/_tree.scss */ .jstree a:focus { outline: none; } -/* line 49, ../scss/_tree.scss */ .jstree a > ins { height: 16px; width: 16px; } -/* line 53, ../scss/_tree.scss */ .jstree a > .jstree-icon { margin-right: 3px; } -/* line 61, ../scss/_tree.scss */ .jstree li.jstree-open > ul { display: block; } -/* line 64, ../scss/_tree.scss */ .jstree li.jstree-closed > ul { display: none; } -/* line 69, ../scss/_tree.scss */ .jstree li.disabled a { color: #aaaaaa; } -/* line 76, ../scss/_tree.scss */ .jstree-rtl a > .jstree-icon { margin-left: 3px; margin-right: 0; } -/* line 80, ../scss/_tree.scss */ .jstree-rtl li { margin-left: 0; margin-right: 18px; } -/* line 87, ../scss/_tree.scss */ .jstree-rtl > ul > li { margin-right: 0px; } -/* line 91, ../scss/_tree.scss */ .jstree > ul > li { margin-left: 0px; } -/* line 95, ../scss/_tree.scss */ #vakata-dragged { display: block; margin: 0 0 0 0; padding: 4px 4px 4px 24px; position: absolute; top: -2000px; line-height: 16px; z-index: 10000; } -/* line 104, ../scss/_tree.scss */ #vakata-contextmenu { display: block; visibility: hidden; left: 0; top: -200px; position: absolute; margin: 0; padding: 0; min-width: 180px; background: #ebebeb; border: 1px solid silver; z-index: 10000; *width: 180px; } -/* line 117, ../scss/_tree.scss */ #vakata-contextmenu ul { min-width: 180px; *width: 180px; } -/* line 120, ../scss/_tree.scss */ #vakata-contextmenu ul, #vakata-contextmenu li { margin: 0; padding: 0; list-style-type: none; display: block; } -/* line 126, ../scss/_tree.scss */ #vakata-contextmenu li { line-height: 20px; min-height: 20px; position: relative; padding: 0px; } -/* line 132, ../scss/_tree.scss */ #vakata-contextmenu li a { padding: 1px 6px; line-height: 17px; display: block; text-decoration: none; margin: 1px 1px 0 1px; } -/* line 139, ../scss/_tree.scss */ #vakata-contextmenu li ins { float: left; width: 16px; height: 16px; text-decoration: none; margin-right: 2px; } -/* line 146, ../scss/_tree.scss */ #vakata-contextmenu li a:hover, #vakata-contextmenu li.vakata-hover > a { background: gray; color: white; } -/* line 150, ../scss/_tree.scss */ #vakata-contextmenu li ul { display: none; position: absolute; top: -2px; left: 100%; background: #ebebeb; border: 1px solid gray; } -/* line 158, ../scss/_tree.scss */ #vakata-contextmenu .right { right: 100%; left: auto; } -/* line 162, ../scss/_tree.scss */ #vakata-contextmenu .bottom { bottom: -1px; top: auto; } -/* line 166, ../scss/_tree.scss */ #vakata-contextmenu li.vakata-separator { min-height: 0; height: 1px; line-height: 1px; font-size: 1px; overflow: hidden; margin: 0 2px; background: silver; /* border-top:1px solid #fefefe; */ padding: 0; } -/* line 176, ../scss/_tree.scss */ .jstree ul, .jstree li { display: block; margin: 0 0 0 0; padding: 0 0 0 0; list-style-type: none; } -/* line 182, ../scss/_tree.scss */ .jstree li { display: block; min-height: 18px; line-height: 18px; white-space: nowrap; margin-left: 18px; min-width: 18px; } -/* line 190, ../scss/_tree.scss */ .jstree-rtl li { margin-left: 0; margin-right: 18px; } -/* line 194, ../scss/_tree.scss */ .jstree > ul > li { margin-left: 0px; } -/* line 197, ../scss/_tree.scss */ .jstree-rtl > ul > li { margin-right: 0px; } -/* line 200, ../scss/_tree.scss */ .jstree ins { display: inline-block; text-decoration: none; width: 18px; height: 18px; margin: 0 0 0 0; padding: 0; } -/* line 208, ../scss/_tree.scss */ .jstree a { display: inline-block; line-height: 16px; height: 16px; color: black; white-space: nowrap; text-decoration: none; padding: 1px 2px; margin: 0; } -/* line 218, ../scss/_tree.scss */ .jstree a:focus { outline: none; } -/* line 221, ../scss/_tree.scss */ .jstree a > ins { height: 16px; width: 16px; } -/* line 225, ../scss/_tree.scss */ .jstree a > .jstree-icon { margin-right: 3px; } -/* line 228, ../scss/_tree.scss */ .jstree-rtl a > .jstree-icon { margin-left: 3px; margin-right: 0; } -/* line 232, ../scss/_tree.scss */ li.jstree-open > ul { display: block; } -/* line 235, ../scss/_tree.scss */ li.jstree-closed > ul { display: none; } -/* line 238, ../scss/_tree.scss */ #vakata-dragged ins { display: block; text-decoration: none; width: 16px; height: 16px; margin: 0 0 0 0; padding: 0; position: absolute; top: 4px; left: 4px; -moz-border-radius: 4px; border-radius: 4px; -webkit-border-radius: 4px; } -/* line 252, ../scss/_tree.scss */ #vakata-dragged .jstree-ok { background: green; } -/* line 255, ../scss/_tree.scss */ #vakata-dragged .jstree-invalid { background: red; } -/* line 258, ../scss/_tree.scss */ #jstree-marker { padding: 0; margin: 0; font-size: 12px; overflow: hidden; height: 12px; width: 8px; position: absolute; top: -30px; z-index: 10001; background-repeat: no-repeat; display: none; background-color: transparent; text-shadow: 1px 1px 1px white; color: black; line-height: 10px; } -/* line 275, ../scss/_tree.scss */ #jstree-marker-line { padding: 0; margin: 0; line-height: 0%; font-size: 1px; overflow: hidden; height: 1px; width: 100px; position: absolute; top: -30px; z-index: 10000; background-repeat: no-repeat; display: none; background-color: #456c43; cursor: pointer; border: 1px solid #eeeeee; border-left: 0; -moz-box-shadow: 0px 0px 2px #666; -webkit-box-shadow: 0px 0px 2px #666; box-shadow: 0px 0px 2px #666; -moz-border-radius: 1px; border-radius: 1px; -webkit-border-radius: 1px; } -/* line 299, ../scss/_tree.scss */ .jstree .jstree-real-checkbox { display: none; } -/* line 302, ../scss/_tree.scss */ .jstree-themeroller .ui-icon { overflow: visible; } -/* line 305, ../scss/_tree.scss */ .jstree-themeroller a { padding: 0 2px; } -/* line 308, ../scss/_tree.scss */ .jstree-themeroller .jstree-no-icon { display: none; } -/* line 311, ../scss/_tree.scss */ .jstree .jstree-wholerow-real { position: relative; z-index: 1; } -/* line 315, ../scss/_tree.scss */ .jstree .jstree-wholerow-real li { cursor: pointer; } -/* line 318, ../scss/_tree.scss */ .jstree .jstree-wholerow-real a { border-left-color: transparent !important; border-right-color: transparent !important; } -/* line 322, ../scss/_tree.scss */ .jstree .jstree-wholerow { position: relative; z-index: 0; height: 0; } -/* line 327, ../scss/_tree.scss */ .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { width: 100%; } -/* line 330, ../scss/_tree.scss */ .jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li, .jstree .jstree-wholerow a { margin: 0 !important; padding: 0 !important; } -/* line 334, ../scss/_tree.scss */ .jstree .jstree-wholerow, .jstree .jstree-wholerow ul, .jstree .jstree-wholerow li { background: transparent !important; } -/* line 337, ../scss/_tree.scss */ .jstree .jstree-wholerow ins, .jstree .jstree-wholerow span, .jstree .jstree-wholerow input { display: none !important; } -/* line 340, ../scss/_tree.scss */ .jstree .jstree-wholerow a, .jstree .jstree-wholerow a:hover { text-indent: -9999px !important; width: 100%; padding: 0 !important; border-right-width: 0px !important; border-left-width: 0px !important; } -/* line 347, ../scss/_tree.scss */ .jstree .jstree-wholerow-span { position: absolute; left: 0; margin: 0px; padding: 0; height: 18px; border-width: 0; padding: 0; z-index: 0; } -/* line 360, ../scss/_tree.scss */ .cms .jstree-apple.jstree-focused { background: none; } -/* line 363, ../scss/_tree.scss */ .cms .jstree-apple > ul { background: none; } -/* line 1, ../scss/_menu.scss */ -.cms-menu { z-index: 10; background-color: #ebeff1; -moz-box-shadow: #aaaaaa 3px 0 3px 0; -webkit-box-shadow: #aaaaaa 3px 0 3px 0; -o-box-shadow: #aaaaaa 3px 0 3px 0; box-shadow: #aaaaaa 3px 0 3px 0; } -/* line 6, ../scss/_menu.scss */ +/** Styles for the left hand side menu @package sapphire @subpackage admin */ +/** ------------------------------------------------------- CMS Menu Bar -------------------------------------------------------- */ +@charset "UTF-8"; +.cms-menu { z-index: 10; background: #c6d7df; border-right: 1px solid #8c99a1; width: 250px; overflow: auto; -moz-box-shadow: rgba(107, 120, 123, 0.5) 2px 0 6px 0; -webkit-box-shadow: rgba(107, 120, 123, 0.5) 2px 0 6px 0; -o-box-shadow: rgba(107, 120, 123, 0.5) 2px 0 6px 0; box-shadow: rgba(107, 120, 123, 0.5) 2px 0 6px 0; } .cms-menu a { text-decoration: none; } -/* line 12, ../scss/_menu.scss */ -.cms-menu-list li { background-color: #b0bfc6; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #b0bfc6), color-stop(100%, #758f9b)); background-image: -moz-linear-gradient(top, #b0bfc6 0%, #758f9b 100%); background-image: linear-gradient(top, #b0bfc6 0%, #758f9b 100%); border-bottom: 1px solid #aaaaaa; } -/* line 20, ../scss/_menu.scss */ -.cms-menu-list li a { display: block; height: 32px; vertical-align: middle; font-size: 14px; text-shadow: #aaaaaa 1px 1px 1px; color: #333333; padding: 5px; } -/* line 29, ../scss/_menu.scss */ -.cms-menu-list li a .icon { display: block; float: left; margin-right: 5px; background: url('../images/icons-32.png?1303890208') no-repeat; width: 32px; height: 32px; overflow: hidden; background-position: 0px 0px; } -/* line 37, ../scss/_menu.scss */ -.cms-menu-list li a .text { display: block; padding-top: 10px; } -/* line 43, ../scss/_menu.scss */ -.cms-menu-list li.current { background-color: #338dc1; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #338dc1), color-stop(100%, #1e5270)); background-image: -moz-linear-gradient(top, #338dc1 0%, #1e5270 100%); background-image: linear-gradient(top, #338dc1 0%, #1e5270 100%); } -/* line 50, ../scss/_menu.scss */ -.cms-menu-list li.current li { background-color: #2e7ead; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #2e7ead), color-stop(100%, #287099)); background-image: -moz-linear-gradient(top, #2e7ead 0%, #287099 100%); background-image: linear-gradient(top, #2e7ead 0%, #287099 100%); } -/* line 58, ../scss/_menu.scss */ -.cms-menu-list li.current a { color: white; text-shadow: #333333 1px 1px 1px; } -/* line 68, ../scss/_menu.scss */ -.cms-menu-list li li:first { -moz-box-shadow: #333333 0 4px 4px 0; -webkit-box-shadow: #333333 0 4px 4px 0; -o-box-shadow: #333333 0 4px 4px 0; box-shadow: #333333 0 4px 4px 0; } -/* line 72, ../scss/_menu.scss */ -.cms-menu-list li li a { font-size: 12px; text-shadow: #333333 1px 1px 1px; margin: 0; padding-left: 30px; color: white; } -/* line 80, ../scss/_menu.scss */ -.cms-menu-list li li.current a { font-weight: bold; } -/* line 87, ../scss/_menu.scss */ -.cms-menu-list li#Menu-CMSMain a .icon { background-position: 0px 0px; } -/* line 88, ../scss/_menu.scss */ -.cms-menu-list li#Menu-CMSMain.current a .icon, .cms-menu-list li#Menu-CMSMain a:hover .icon { background-position: -32px 0px; } -/* line 89, ../scss/_menu.scss */ -.cms-menu-list li#Menu-AssetAdmin a .icon { background-position: 0px -32px; } -/* line 90, ../scss/_menu.scss */ -.cms-menu-list li#Menu-AssetAdmin.current a .icon, .cms-menu-list li#Menu-AssetAdmin a:hover .icon { background-position: -32px -32px; } +.cms-menu-list li a { display: block; height: 30px; line-height: 30px; vertical-align: middle; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-shadow: #ced7dc 1px 1px 0; color: #1f1f1f; padding: 5px; background-color: #b0bec7; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #b0bec7), color-stop(100%, #98aab6)); background-image: -moz-linear-gradient(top, #b0bec7 0%, #98aab6 100%); background-image: linear-gradient(top, #b0bec7 0%, #98aab6 100%); border-top: 1px solid #ced7dc; border-bottom: 1px solid #748d9d; } +.cms-menu-list li a:hover { text-decoration: none; background-color: #b6c3cb; border-bottom: 1px solid #8399a7; color: #2c2c2c; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #bfcad2), color-stop(100%, #b0bec7)); background-image: -moz-linear-gradient(top, #bfcad2 0%, #b0bec7 100%); background-image: linear-gradient(top, #bfcad2 0%, #b0bec7 100%); } +.cms-menu-list li a:focus { border-top: 1px solid #a1b2bc; text-decoration: none; background-color: #a1b2bc; color: #393939; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #92a5b2), color-stop(100%, #a1b2bc)); background-image: -moz-linear-gradient(top, #92a5b2 0%, #a1b2bc 100%); background-image: linear-gradient(top, #92a5b2 0%, #a1b2bc 100%); } +.cms-menu-list li a .icon { display: block; float: left; margin-right: 4px; background: url('../images/icons-32.png') no-repeat; width: 32px; height: 32px; overflow: hidden; background-position: 0px 0px; } +.cms-menu-list li a .text { display: block; } +.cms-menu-list li.current a { color: white; text-shadow: #1e5270 0 -1px 0; border-top: 1px solid #55a4d2; border-bottom: 1px solid #1e5270; background-color: #338dc1; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #338dc1), color-stop(100%, #287099)); background-image: -moz-linear-gradient(top, #338dc1 0%, #287099 100%); background-image: linear-gradient(top, #338dc1 0%, #287099 100%); } +.cms-menu-list li.current ul { border-top: 1px solid #1e5270; } +.cms-menu-list li.current li { background-color: #287099; } +.cms-menu-list li.current li a { font-size: 11px; padding: 0 10px 0 36px; height: 32px; line-height: 32px; color: #e2f0f7; background: none; border-top: 1px solid #338dc1; border-bottom: 1px solid #1e5270; } +.cms-menu-list li.current li a.current, .cms-menu-list li.current li a:hover { background: #2e7ead; border-top: 1px solid #2e7ead; color: white; } +.cms-menu-list li.current li a:focus { background: #236184; border-top: 1px solid #1e5270; color: white; } +.cms-menu-list li.current li.current a { font-weight: bold; color: white; } +.cms-menu-list li.current li.first a { border-top: none; } /** This file defines common styles for form elements used throughout the CMS interface. It is an addition to the base styles defined in sapphire/css/Form.css. */ -/* line 9, ../scss/_forms.scss */ -.cms .field { display: block; padding: 10px 0; border-bottom: 1px solid #aaaaaa; } -/* line 14, ../scss/_forms.scss */ -.cms .field label { float: left; width: 10em; } -/* line 20, ../scss/_forms.scss */ -.cms .field .middleColumn { margin-left: 10em; } -/* line 23, ../scss/_forms.scss */ -.cms .field .middleColumn .field { display: inline; padding: 0; border: none; } -/* line 29, ../scss/_forms.scss */ -.cms .field .middleColumn label { float: none; width: auto; } -/* line 38, ../scss/_forms.scss */ -.cms form.nostyle .field { display: inline; padding: 0; border: 0; } -/* line 44, ../scss/_forms.scss */ -.cms form.nostyle label { float: none; width: auto; } -/* line 49, ../scss/_forms.scss */ -.cms form.nostyle .middleColumn { margin-left: 0; } -/* line 55, ../scss/_forms.scss */ -.cms .field.nolabel .middleColumn { margin-left: 0; } -/* line 60, ../scss/_forms.scss */ -.cms input, .cms textarea { -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #ebeff1), color-stop(50%, #ffffff), color-stop(100%, #ebeff1)); background-image: -moz-linear-gradient(top, #ebeff1 0%, #ffffff 50%, #ebeff1 100%); background-image: linear-gradient(top, #ebeff1 0%, #ffffff 50%, #ebeff1 100%); border: 1px solid #aaaaaa; padding: 3px; } -/* line 71, ../scss/_forms.scss */ -.cms input.loading { padding-left: 16px; background: #ebeff1 url(../../images/network-save.gif) no-repeat center left; } -/* line 79, ../scss/_forms.scss */ -.cms .ss-ui-button.ss-ui-action-constructive, .cms .ui-widget-content .ss-ui-button.ss-ui-action-constructive, .cms .ui-widget-header .ss-ui-button.ss-ui-action-constructive { background: none; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #77b53f), color-stop(100%, #456925)); background-image: -moz-linear-gradient(top, #77b53f 0%, #456925 100%); background-image: linear-gradient(top, #77b53f 0%, #456925 100%); color: white; } -/* line 90, ../scss/_forms.scss */ -.cms .ss-ui-button.ss-ui-action-destructive, .cms .ui-widget-content .ss-ui-button.ss-ui-action-destructive, .cms .ui-widget-header .ss-ui-button.ss-ui-action-destructive { color: red; } -/* line 96, ../scss/_forms.scss */ -.cms .ss-ui-button.ss-ui-action-minor, .cms .ui-widget-content .ss-ui-button.ss-ui-action-minor .ui-widget-header .ss-ui-button.ss-ui-action-minor { background: none; padding: 0; border: 0; color: #333333; text-decoration: underline; } -/* line 104, ../scss/_forms.scss */ -.cms .cms-edit-form { padding-bottom: 20px; } -/* line 108, ../scss/_forms.scss */ -.cms .cms-edit-form .Actions { text-align: right; } -/* line 115, ../scss/_forms.scss */ -.cms .cms-content-tools .field label { float: none; width: auto; } -/* line 120, ../scss/_forms.scss */ -.cms .cms-content-tools .field .middleColumn { margin-left: 0; } +.field { display: block; padding: 10px 0; border-bottom: 1px solid rgba(201, 205, 206, 0.8); } +.field label { float: left; width: 10em; } +.field .middleColumn { margin-left: 10em; } +.field .middleColumn .field { display: inline; padding: 0; border: none; } +.field .middleColumn label { float: none; width: auto; } + +form.nostyle .field { display: inline; padding: 0; border: 0; } +form.nostyle label { float: none; width: auto; } +form.nostyle .middleColumn { margin-left: 0; } + +.field.nolabel .middleColumn { margin-left: 0; } + +input, textarea { -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #eceff1), color-stop(50%, #ffffff), color-stop(100%, #eceff1)); background-image: -moz-linear-gradient(top, #eceff1 0%, #ffffff 50%, #eceff1 100%); background-image: linear-gradient(top, #eceff1 0%, #ffffff 50%, #eceff1 100%); border: 1px solid rgba(201, 205, 206, 0.8); padding: 3px; } + +input.loading, input.ui-state-default.loading, .ui-widget-content input.ui-state-default.loading, .ui-widget-header input.ui-state-default.loading { padding-left: 16px; background: #eceff1 url(../../images/network-save.gif) no-repeat center left; } + +.ss-ui-button.ss-ui-action-constructive, .ui-widget-content .ss-ui-button.ss-ui-action-constructive, .ui-widget-header .ss-ui-button.ss-ui-action-constructive { background: none; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #77b53f), color-stop(100%, #456925)); background-image: -moz-linear-gradient(top, #77b53f 0%, #456925 100%); background-image: linear-gradient(top, #77b53f 0%, #456925 100%); color: white; } + +.ss-ui-button.ss-ui-action-destructive, .ui-widget-content .ss-ui-button.ss-ui-action-destructive, .ui-widget-header .ss-ui-button.ss-ui-action-destructive { color: red; } + +.ss-ui-button.ss-ui-action-minor, .ui-widget-content .ss-ui-button.ss-ui-action-minor .ui-widget-header .ss-ui-button.ss-ui-action-minor { background: none; padding: 0; border: 0; color: #1f1f1f; text-decoration: underline; } + +.cms-edit-form { padding-bottom: 20px; } +.cms-edit-form .text input, .cms-edit-form textarea { width: 300px; } +.cms-edit-form .Actions { text-align: right; } + +.cms-content-tools .field label { float: none; width: auto; } +.cms-content-tools .field .middleColumn { margin-left: 0; } + +.field#ViewerGroups label, .field#EditorGroups label, .field#CreateTopLevelGroups label { display: none; } /** This file defines CMS-specific customizations to the jQuery UI theme. Every rule in this file should be wrapped in the '.cms' selector (to make it more specific), and contain ONLY overwritten jQuery UI rules (with 'ui-' prefix). This file should be fairly short, as we're using our own custom jQuery UI theme already. TODO Add theme reference Use _style.scss to add more generic style information, and read the jQuery UI theming API: http://jqueryui.com/docs/Theming/API */ -/* line 14, ../scss/_uitheme.scss */ .cms .ui-tabs { padding: 0; } -/* line 17, ../scss/_uitheme.scss */ .cms .ui-tabs .ui-widget-header { border: 0; background: none; } -/* line 24, ../scss/_uitheme.scss */ -.cms .ui-widget-content, .cms .ui-tabs .ui-tabs-panel { color: #444444; font-size: 1em; border: 0; background: #ebeff1; } -/* line 31, ../scss/_uitheme.scss */ -.cms .ui-widget-header { background: #ebeff1; border: 0; } -/* line 36, ../scss/_uitheme.scss */ +.cms .ui-widget-content, .cms .ui-tabs .ui-tabs-panel { color: #444444; font-size: 1em; border: 0; background: #eceff1; } +.cms .ui-widget-header { background: #eceff1; border: 0; padding: 0; } .cms .ss-ui-button { padding: 5px; text-decoration: none; } /** This file defines the 'theme' of the CMS: Colors, fonts, backgrounds, and detailed alignments. Together with _layout.css it provides the presentational backbone to the CMS. Ideally a developer should be able to exchange this file with his own theme easily. Please don't put any dimension, display or float information on major structural components like '.cms-container' or '.cms-header' in here, use the _layout.scss file instead. Use SCSS variable definitions in screen.css to avoid repeating styles like background colours or padding dimensions. See _colours.scss to get started. To avoid this file getting too large and complicated, it is encouraged to create new SCSS files for larger components like the CMS menu or tree (see _tree.scss and _menu.scss). */ -/* line 18, ../scss/_style.scss */ -body { font-size: 13px; font-family: Verdana, Arial, sans-serif; color: #444444; } -/* line 14, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body html, body body, body div, body span, body applet, body object, body iframe, body h1, body h2, body h3, body h4, body h5, body h6, body p, body blockquote, body pre, body a, body abbr, body acronym, body address, body big, body cite, body code, body del, body dfn, body em, body font, body img, body ins, body kbd, body q, body s, body samp, body small, body strike, body strong, body sub, body sup, body tt, body var, body dl, body dt, body dd, body ol, body ul, body li, body fieldset, body form, body label, body legend, body table, body caption, body tbody, body tfoot, body thead, body tr, body th, body td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; } -/* line 17, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body body { line-height: 1; color: black; background: white; } -/* line 19, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body ol, body ul { list-style: none; } -/* line 21, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body table { border-collapse: separate; border-spacing: 0; vertical-align: middle; } -/* line 23, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body caption, body th, body td { text-align: left; font-weight: normal; vertical-align: middle; } -/* line 25, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body q, body blockquote { quotes: "" ""; } -/* line 96, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body q:before, body q:after, body blockquote:before, body blockquote:after { content: ""; } -/* line 27, ../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.10.6/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ -body a img { border: none; } +/** ---------------------------------------------------- Core Styles ---------------------------------------------------- */ +html, body { width: 100%; height: 100%; overflow: hidden; font-size: 13px; font-family: Verdana, Arial, sans-serif; color: #444444; } +html html, html body, html div, html span, html applet, html object, html iframe, html h1, html h2, html h3, html h4, html h5, html h6, html p, html blockquote, html pre, html a, html abbr, html acronym, html address, html big, html cite, html code, html del, html dfn, html em, html font, html img, html ins, html kbd, html q, html s, html samp, html small, html strike, html strong, html sub, html sup, html tt, html var, html dl, html dt, html dd, html ol, html ul, html li, html fieldset, html form, html label, html legend, html table, html caption, html tbody, html tfoot, html thead, html tr, html th, html td, body html, body body, body div, body span, body applet, body object, body iframe, body h1, body h2, body h3, body h4, body h5, body h6, body p, body blockquote, body pre, body a, body abbr, body acronym, body address, body big, body cite, body code, body del, body dfn, body em, body font, body img, body ins, body kbd, body q, body s, body samp, body small, body strike, body strong, body sub, body sup, body tt, body var, body dl, body dt, body dd, body ol, body ul, body li, body fieldset, body form, body label, body legend, body table, body caption, body tbody, body tfoot, body thead, body tr, body th, body td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; } +html body, body body { line-height: 1; color: black; background: white; } +html ol, html ul, body ol, body ul { list-style: none; } +html table, body table { border-collapse: separate; border-spacing: 0; vertical-align: middle; } +html caption, html th, html td, body caption, body th, body td { text-align: left; font-weight: normal; vertical-align: middle; } +html q, html blockquote, body q, body blockquote { quotes: "" ""; } +html q:before, html q:after, html blockquote:before, html blockquote:after, body q:before, body q:after, body blockquote:before, body blockquote:after { content: ""; } +html a img, body a img { border: none; } -/* line 25, ../scss/_style.scss */ -body * { font-size: 13px; } +a { color: #3ebae0; text-decoration: none; } +a:hover, a:focus { text-decoration: underline; } -/* line 29, ../scss/_style.scss */ -body .ui-widget { font-size: 1em; } +body .ui-widget { font-size: 13px; } + +.cms-container { height: 100%; } + +.cms-preview, .cms-menu, .cms-content, .cms-content-header, .cms-content-tools, .cms-content-form { display: -moz-inline-box; -moz-box-orient: vertical; display: inline-block; vertical-align: middle; *vertical-align: auto; } +.cms-preview, .cms-menu, .cms-content, .cms-content-header, .cms-content-tools, .cms-content-form { *display: inline; } -/* line 33, ../scss/_style.scss */ strong { font-weight: bold; } -/* line 39, ../scss/_style.scss */ -.cms-content-header { background-color: #afbfc7; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #afbfc7), color-stop(100%, #91a7b2)); background-image: -moz-linear-gradient(top, #afbfc7 0%, #91a7b2 100%); background-image: linear-gradient(top, #afbfc7 0%, #91a7b2 100%); } -/* line 46, ../scss/_style.scss */ -.cms-content-header h2 { float: left; padding: 10px; font-size: 14px; font-weight: bold; } -/* line 53, ../scss/_style.scss */ +.cms-content-header { background-color: #b1bec6; padding: 8px; height: 32px; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #b1bec6), color-stop(100%, #94a5b0)); background-image: -moz-linear-gradient(top, #b1bec6 0%, #94a5b0 100%); background-image: linear-gradient(top, #b1bec6 0%, #94a5b0 100%); } +.cms-content-header h2 { float: left; padding: 8px; font-size: 14px; font-weight: bold; width: 230px; } +.cms-content-header > div { width: 9999em; overflow: hidden; } .cms-content-header .cms-content-header-tabs { float: left; } -/* line 60, ../scss/_style.scss */ .ui-tabs .cms-content-header .ui-tabs-nav li { height: 40px; } -/* line 63, ../scss/_style.scss */ -.ui-tabs .cms-content-header .ui-tabs-nav li a { font-weight: bold; font-size: 11px; padding-top: 1em; } -/* line 72, ../scss/_style.scss */ -.ui-tabs .cms-content-header .ui-state-default, .ui-tabs .cms-content-header .ui-widget-content .ui-state-default, .ui-tabs .cms-content-header .ui-widget-header .ui-state-default { background-color: #dddddd; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #dddddd), color-stop(100%, #b7b7b7)); background-image: -moz-linear-gradient(top, #dddddd 0%, #b7b7b7 100%); background-image: linear-gradient(top, #dddddd 0%, #b7b7b7 100%); } -/* line 82, ../scss/_style.scss */ -.ui-tabs .cms-content-header .ui-state-active, .ui-tabs .cms-content-header .ui-widget-content .ui-state-active, .ui-tabs .cms-content-header .ui-widget-header .ui-state-active { background: #ebeff1; } +.ui-tabs .cms-content-header .ui-tabs-nav li a { font-weight: bold; font-size: 11px; padding-top: 8px; } +.ui-tabs .cms-content-header .ui-state-default, .ui-tabs .cms-content-header .ui-widget-content .ui-state-default, .ui-tabs .cms-content-header .ui-widget-header .ui-state-default { background-color: #feffff; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #feffff), color-stop(100%, #d6d9da)); background-image: -moz-linear-gradient(top, #feffff 0%, #d6d9da 100%); background-image: linear-gradient(top, #feffff 0%, #d6d9da 100%); } +.ui-tabs .cms-content-header .ui-state-active, .ui-tabs .cms-content-header .ui-widget-content .ui-state-active, .ui-tabs .cms-content-header .ui-widget-header .ui-state-active { background: #eceff1; } -/* line 87, ../scss/_style.scss */ -.cms-content-tools { background-color: #dce3e6; } +.cms-content-tools { background-color: #dde3e6; padding: 10px; width: 230px; overflow: auto; } -/* line 93, ../scss/_style.scss */ -.cms-header { padding: 10px; background-color: #00111d; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #00111d), color-stop(50%, #003050), color-stop(100%, #00111d)); background-image: -moz-linear-gradient(top, #00111d 0%, #003050 50%, #00111d 100%); background-image: linear-gradient(top, #00111d 0%, #003050 50%, #00111d 100%); } -/* line 102, ../scss/_style.scss */ -.cms-header * { color: white; } +/** ------------------------------------------------------- Top Left Header and logo area -------------------------------------------------------- */ +.cms-header { background-color: #00111d; position: relative; padding: 16px 8px 8px; line-height: 24px; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%, #00111d), color-stop(50%, #003050), color-stop(100%, #00111d)); background-image: -moz-linear-gradient(top, #00111d 0%, #003050 50%, #00111d 100%); background-image: linear-gradient(top, #00111d 0%, #003050 50%, #00111d 100%); } +.cms-header span { color: white; white-space: no-wrap; text-overflow: ellipsis; display: block; } +.cms-header span a { color: #3ebae0; display: inline; } -/* line 109, ../scss/_style.scss */ +.cms-logo { border-bottom: 1px solid #03090c; height: 31px; overflow: hidden; padding: 0 4px; vertical-align: middle; } .cms-logo .version { display: none; } -/* line 113, ../scss/_style.scss */ -.cms-logo * { color: #3ebae0; } -/* line 117, ../scss/_style.scss */ -.cms-logo a { display: inline-block; height: 25px; width: 25px; float: left; margin-right: 10px; background: url(../images/logo_small.png) no-repeat; text-indent: -9999em; } +.cms-logo a { display: inline-block; height: 25px; width: 25px; float: left; margin-right: 10px; background: url('../images/logo_small.png?1305762003') no-repeat; text-indent: -9999em; } -/* line 130, ../scss/_style.scss */ -.cms-login-status .logout-link { display: inline-block; height: 25px; width: 25px; float: left; margin-right: 10px; background: url(../images/logout.png) no-repeat; text-indent: -9999em; } +.cms-login-status { border-top: 1px solid #19435c; height: 23px; padding: 8px 0 0 14px; overflow: hidden; line-height: 16px; font-size: 11px; } +.cms-login-status .logout-link { display: inline-block; height: 16px; width: 16px; float: left; margin-right: 10px; background: url(../images/logout.png) no-repeat; text-indent: -9999em; } -/* line 144, ../scss/_style.scss */ .ss-loading-screen, .ss-loading-screen .loading-logo { width: 100%; height: 100%; overflow: hidden; position: absolute; background: #fff; background: -moz-radial-gradient(50% 50% 180deg, circle cover, white, #efefef, #c7c7c7 100%); background: -webkit-gradient(radial, 50% 50%, 350, 50% 50%, 0, from(#e3e3e3), to(white)); z-index: 100000; margin: 0; padding: 0; } -/* line 159, ../scss/_style.scss */ .ss-loading-screen .loading-logo { background-url: url(../images/logo.gif); background-repeat: no-repeat; background-color: transparent; background-position: 50% 50%; } -/* line 165, ../scss/_style.scss */ .ss-loading-screen p { width: 100%; text-align: center; position: absolute; bottom: 80px; } -/* line 171, ../scss/_style.scss */ .ss-loading-screen p span.notice { display: inline-block; font-size: 14px; padding: 10px 20px; color: #dc7f00; border: none; -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; -ms-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; } -/* line 181, ../scss/_style.scss */ .ss-loading-screen .loading-animation { display: none; position: absolute; left: 49%; top: 75%; } +.cms-content-actions { padding: 8px; } + /** Messages (see sapphire/css/Form.css) */ -/* line 200, ../scss/_style.scss */ .message { margin: 1em 0; padding: 0.5em; font-weight: bold; border: 1px black solid; } -/* line 206, ../scss/_style.scss */ .message.notice { background-color: #ffbe66; border-color: #ff9300; } -/* line 211, ../scss/_style.scss */ .message.warning { background-color: #ffbe66; border-color: #ff9300; } -/* line 215, ../scss/_style.scss */ .message.error { background-color: #ffbe66; border-color: #ff9300; } -/* line 224, ../scss/_style.scss */ .ModelAdmin .cms-content-tools { width: 300px; } -/* line 229, ../scss/_style.scss */ .ModelAdmin .ResultAssemblyBlock { display: none; } -/* line 236, ../scss/_style.scss */ -.cms-page-add-form-dialog #PageType li { clear: left; height: 40px; border-bottom: 1px solid #333333; } -/* line 241, ../scss/_style.scss */ +.cms-page-add-form-dialog #PageType li { clear: left; height: 40px; border-bottom: 1px solid rgba(107, 120, 123, 0.5); } .cms-page-add-form-dialog #PageType li:hover, .cms-page-add-form-dialog #PageType li.selected { background-color: #ffff99; } -/* line 245, ../scss/_style.scss */ .cms-page-add-form-dialog #PageType li input, .cms-page-add-form-dialog #PageType li label, .cms-page-add-form-dialog #PageType li .icon, .cms-page-add-form-dialog #PageType li .title { float: left; } -/* line 249, ../scss/_style.scss */ .cms-page-add-form-dialog #PageType li .icon { width: 20px; } -/* line 253, ../scss/_style.scss */ .cms-page-add-form-dialog #PageType li .title { width: 100px; font-weight: bold; } -/* line 258, ../scss/_style.scss */ .cms-page-add-form-dialog #PageType li .description { font-style: italic; } -/* line 266, ../scss/_style.scss */ .cms-content-toolbar > * { display: inline-block; } -/* line 270, ../scss/_style.scss */ .cms-content-toolbar .cms-tree-view-modes * { display: inline-block; } -/* line 274, ../scss/_style.scss */ -.cms-content-toolbar .cms-content-batchactions form * { display: inline-block; } +.cms-content-toolbar .cms-content-batchactions form > * { display: inline-block; } + +.cms-preview { width: 1px; overflow: hidden; } +.cms-preview .cms-preview-toggle { width: 10px; } +.cms-preview iframe { width: 100%; height: 100%; } -/* line 280, ../scss/_style.scss */ .cms-preview-header { background-color: #FFBE66; padding: 10px; font-weight: bold; } -/* line 287, ../scss/_style.scss */ -.cms-preview { background-color: #b0bfc6; } -/* line 290, ../scss/_style.scss */ +form.member-profile-form #CsvFile .middleColumn { background: none !important; } +form.member-profile-form .advanced h4 { margin-bottom: .5em; } +form.member-profile-form .Actions { text-align: left; border: 0; } +form.member-profile-form input.customFormat { border: 1px solid #ccc !important; padding: 3px; margin-left: 2px; } +form.member-profile-form .formattingHelpToggle { font-size: 11px; padding: 3px; } +form.member-profile-form .formattingHelpText { margin: 5px auto; color: #333; padding: 5px 10px; width: 90%; background: #fff; border: 1px solid #ccc; } +form.member-profile-form .formattingHelpText ul { padding: 0; } +form.member-profile-form .formattingHelpText li { font-size: 11px; color: #333; margin-bottom: 2px; } + +.cms-content-form { overflow: auto; } + +.cms-preview { background-color: #b0bec7; } .cms-preview .cms-preview-toggle { cursor: pointer; } -/* line 293, ../scss/_style.scss */ .cms-preview .cms-preview-toggle a { color: white; font-weight: bold; text-decoration: none; } + +.cms-switch-view a { padding-right: 1em; } diff --git a/admin/images/arrow_refresh.gif b/admin/images/arrow_refresh.gif old mode 100644 new mode 100755 diff --git a/admin/images/icons-32.png b/admin/images/icons-32.png deleted file mode 100644 index a272cf47e..000000000 Binary files a/admin/images/icons-32.png and /dev/null differ diff --git a/admin/images/logo.gif b/admin/images/logo.gif old mode 100644 new mode 100755 diff --git a/admin/images/logo_small.png b/admin/images/logo_small.png old mode 100644 new mode 100755 diff --git a/admin/images/logout.png b/admin/images/logout.png old mode 100644 new mode 100755 index 0eaf7841b..a4555cc8e Binary files a/admin/images/logout.png and b/admin/images/logout.png differ diff --git a/admin/images/mainmenu/current.gif b/admin/images/mainmenu/current.gif old mode 100644 new mode 100755 diff --git a/admin/images/mainmenu/currentHover.gif b/admin/images/mainmenu/currentHover.gif old mode 100644 new mode 100755 diff --git a/admin/images/mainmenu/hover.gif b/admin/images/mainmenu/hover.gif old mode 100644 new mode 100755 diff --git a/admin/images/spinner.gif b/admin/images/spinner.gif old mode 100644 new mode 100755 diff --git a/admin/images/textures/footerBg.gif b/admin/images/textures/footerBg.gif old mode 100644 new mode 100755 diff --git a/admin/images/textures/mce_editor.gif b/admin/images/textures/mce_editor.gif old mode 100644 new mode 100755 diff --git a/admin/javascript/.DS_Store b/admin/javascript/.DS_Store old mode 100644 new mode 100755 diff --git a/admin/javascript/AssetTableField.js b/admin/javascript/AssetTableField.js old mode 100644 new mode 100755 diff --git a/admin/javascript/LeftAndMain.AddForm.js b/admin/javascript/LeftAndMain.AddForm.js old mode 100644 new mode 100755 index f65526d3c..896f0e47b --- a/admin/javascript/LeftAndMain.AddForm.js +++ b/admin/javascript/LeftAndMain.AddForm.js @@ -107,49 +107,46 @@ /** * Function: refresh + * This is called after each change event of PageType dropdown * * Parameters: * (DOMElement) selectedNode */ refresh: function(selectedNode) { - // Note: Uses siteTreeHints global + var tree = this.getTree(), selectedNode = selectedNode || $(tree).jstree('get_selected') origOptions = this.getOrigOptions(), - dropdown = this.find('select[name=PageType]'); + dropdown = this.find('select[name=PageType]'), + disallowed = [], + className = (selectedNode) ? selectedNode.getClassname() : null, + siteTreeHints = $.parseJSON($('#sitetree_ul').attr('data-hints')), + disableDropDown = true, + selectedOption = dropdown.val(); // Clear all existing ')); - } - } else { - // No tree node selected, reset to original elements - $.each(origOptions, function(i, optProps) { - if(optProps) dropdown.append($('')); - }); + //Use tree hints to find allowed children for this node + if (className && typeof siteTreeHints !== 'undefined') { + disallowed = siteTreeHints[className].disallowedChildren; } - // TODO Re-select the currently selected element + $.each(origOptions, function(i, optProps) { + if ($.inArray(i, disallowed) === -1 && optProps) { + dropdown.append($('')); + disableDropDown = false; + } + }); // Disable dropdown if no elements are selectable - if(allowed) dropdown.removeAttr('disabled'); + if (!disableDropDown) dropdown.removeAttr('disabled'); else dropdown.attr('disabled', 'disabled'); - + + //Re-select the currently selected element + if (selectedOption) dropdown.val(selectedOption); + // Set default child (optional) if(selectedNode.hints && selectedNode.hints.defaultChild) { dropdown.val(selectedNode.hints.defaultChild); diff --git a/admin/javascript/LeftAndMain.BatchActions.js b/admin/javascript/LeftAndMain.BatchActions.js old mode 100644 new mode 100755 diff --git a/admin/javascript/LeftAndMain.EditForm.js b/admin/javascript/LeftAndMain.EditForm.js old mode 100644 new mode 100755 diff --git a/admin/javascript/LeftAndMain.Preview.js b/admin/javascript/LeftAndMain.Preview.js old mode 100644 new mode 100755 index d238a6d4e..a6ab43c28 --- a/admin/javascript/LeftAndMain.Preview.js +++ b/admin/javascript/LeftAndMain.Preview.js @@ -2,6 +2,8 @@ $.entwine('ss', function($){ $('.LeftAndMain .cms-preview').entwine({ + SharedWidth: null, + onmatch: function() { var self = this, layoutContainer = this.parent(); // this.resizable({ @@ -11,6 +13,9 @@ // } // }); + // TODO Compute dynamically + this.setSharedWidth(500); + // Create layout and controls this.prepend('
<
'); this.find('iframe').addClass('center'); @@ -50,14 +55,13 @@ if(id && form.find(':input[name=ID]').val() != id) form.loadForm('admin/page/edit/show/' + id); }, - toggle: function() { + toggle: function(bool) { var self = this, width = this.width(), relayout = function() {$('.cms-container').layout({resize: false});}, minWidth = this.find('.cms-preview-toggle').width(), - wasCollapsed = (width <= minWidth), - sharedWidth = $('.cms-content').width() / 2, // half of content area by default - newWidth = wasCollapsed ? sharedWidth : minWidth, + wasCollapsed = (bool === true || bool === false) ? bool : (width <= minWidth), + newWidth = wasCollapsed ? this.getSharedWidth() : minWidth, newOverflow = wasCollapsed ? 'auto' : 'hidden'; this.css('overflow', newOverflow).width(newWidth); @@ -98,5 +102,14 @@ this.parents('.cms-preview').toggle(); } }); + + $('.LeftAndMain .cms-switch-view a').entwine({ + onclick: function(e) { + e.preventDefault(); + var preview = $('.cms-preview'); + preview.toggle(true); + preview.loadUrl($(e.target).attr('href')); + } + }); }); }(jQuery)); \ No newline at end of file diff --git a/admin/javascript/LeftAndMain.Tree.js b/admin/javascript/LeftAndMain.Tree.js index e5cf99189..dae05e6af 100755 --- a/admin/javascript/LeftAndMain.Tree.js +++ b/admin/javascript/LeftAndMain.Tree.js @@ -3,20 +3,24 @@ */ (function($) { - + $.entwine('ss', function($){ $('.cms-tree').entwine({ + + Hints: null, + onmatch: function() { this._super(); + this.setHints($.parseJSON(this.attr('data-hints'))); + /** * @todo Icon and page type hover support * @todo Sorting of sub nodes (originally placed in context menu) * @todo Refresh after language - - $itemList - -HTML; - } - - /** - * Save the results into the form - */ - function saveInto(DataObject $record) { - $fieldName = $this->name; - $saveDest = $record->$fieldName(); - - if($this->value) { - $items = preg_split("/ *, */", trim($this->value)); - } - - $saveDest->setByIDList($items); - } - - - /** - * Return the site tree - */ - function gettree() { - echo "
- - -
"; - - - $obj = singleton($this->sourceObject); - $obj->markPartialTree(10); - - $eval = '"
  • name . '-$child->ID\" class=\"$child->class closed" . ($child->isExpanded() ? "" : " unexpanded") . "\">" . $child->Title . ""'; - echo $obj->getChildrenAsUL("class=\"tree\"", $eval, null, true); - - } - -} - -?> diff --git a/integration/XML.php b/integration/XML.php deleted file mode 100755 index 77dacc922..000000000 --- a/integration/XML.php +++ /dev/null @@ -1,182 +0,0 @@ -Building XML parsers with the XML class - * - * To use the XML parser, you need to create a subclass. Then you define process_XXX functions to process different tags. The parser walks sequentially through the file and calls the process_XXX functions when it hits different tags. - * - * * **process_(tagname):** This will be called when the parser finds the start tag. It will be passed the attributes of the tag. - * * **process_(tagname)_end:** This will be called when the parser finds the closng tag. It will be passed the attributes and the content of the tag. - * - * * **process_tag :** This will be called if it is implemented and a method has not been created already for the tag being parsed. It is passed the tag name and attributes of the tag. - * - * * **process_tag_end:** This will be called if it is implemented and a method has not been created already for the tag being parsed. It is passed the tag name, the content of the tag and the attributes of the tag. - * - * - * The idea is that within this function, you build up $this->result with a useful representation of the XML data. It could be an array structure, an object, or something else. - * - * There are a couple of methods on the XML object that will help with - * - * * **$this->inContext('(tag)', '(tag).(class)'):** This will return true if the current tag has the specified tags as ancestors, in the order that you've specified. - * - * Finally, there are public methods that can be called on an instantiated XML subclass. This is how you will make use of your new parser. - * - * * **$parser->tidyXHTML($content):** This will run "tidy -asxhtml" on your content. This is useful if you're wanting to use the XML parser to parse HTML that may or may not be XML compliant. - * * **$parser->parse($content):** This will call the parser on the given XML content, and return the $this->result object that gets built. - * - * Example - * - * - * class DeliciousHtmlParser extends XML { - * protected $currentItem = 0; - * - * function process_li($attributes) { - * if($attributes['class'] == "post") { - * $this->currentItem = sizeof($this->parsed); - * } - * } - * - * function process_a_end($content, $attributes) { - * if($this->inContext('li.post','h4.desc')) { - * $this->parsed[$this->currentItem][link] = $attributes[href]; - * $this->parsed[$this->currentItem][title] = $content; - * - * } else if($this->inContext('li.post','div.meta') && $attributes['class'] == 'tag') { - * $this->parsed[$this->currentItem][tags][] = $content; - * } - * } - * } - * - * $html = file_get_contents("http://del.icio.us/$user/?setcount=100"); - * $parser = new DeliciousHtmlParser(); - * $tidyHtml = $parser->tidyXHTML($html); - * $result = $parser->parse($tidyHtml); - * - * - * @package sapphire - * @subpackage misc - */ -class XML extends Object { - protected $parser; - protected $context, $attributeStore; - protected $parsed; - protected $collatedText; - - - function tidyXHTML($content) { - $cleanFile = TEMP_FOLDER . "/cleaner.tmp"; - $fh = fopen($cleanFile,"wb"); - fwrite($fh, $content); - fclose($fh); - - if(file_exists($cleanFile)) { - $result = `tidy -asxhtml $cleanFile`; - unlink($cleanFile); - return $result; - } - } - - function parse($content, $recursive = false) { - $this->parser = xml_parser_create('UTF-8'); - - // Andrew keeps giving me the wrong FSKING encoding! :-P - $content = ereg_replace('encoding="[^"]+"','encoding="utf-8"', $content); - - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); - //xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - xml_set_object($this->parser, $this); - xml_set_element_handler($this->parser, "tag_open", "tag_close"); - xml_set_character_data_handler($this->parser, "cdata"); - - $this->parsed = null; - $this->context = array(); - $this->attributeStore = array(); - - xml_parse($this->parser, $content); - - // Handle a bad encoding type by forcing ISO-8859-15 - if(xml_get_error_code($this->parser) == 32 && !$recursive) { - $content = ereg_replace('encoding="[^"]+"','encoding="utf-8"', $content); - return $this->parse($content, true); - } - - if($err = xml_get_error_code($this->parser)) { - user_error("XML parser broke with error $err:" . xml_error_string($err), E_USER_ERROR); - } - - return $this->parsed; - } - - function inContext() { - $items = func_get_args(); - $i=0; - foreach($items as $item) { - while($i < sizeof($this->context)) { - if($this->context[$i] == $item) break; - $i++; - } - if($this->context[$i] != $item) return false; - } - return true; - } - - function stackActionFor($tag) { - for($i=sizeof($this->contextStack)-1;$i>=0;$i--) { - if($this->context[$i]['tag'] == $tag) return $this->contextStack[$i]['action']; - } - } - - function tag_open($parser, $tag, $attributes) { - // Strip namespaces out of tags and attributes - $tag = ereg_replace('[^:]+:','',$tag); - if($attributes) foreach($attributes as $k => $v) $newAttributes[ereg_replace('[^:]+:','',$k)] = $v; - $attributes = isset($newAttributes) ? $newAttributes : $attributes; - - - if(isset($attributes['class'])) { - $this->context[] = "$tag.{$attributes['class']}"; - } else { - $this->context[] = $tag; - } - $this->attributeStore[] = $attributes; - - $this->collatedText = ""; - - $tagProcessorFunc = "process_$tag"; - if($this->hasMethod($tagProcessorFunc)) { - $this->$tagProcessorFunc($attributes); - }elseif($this->hasMethod($tagProcessorFunc = "process_tag")){ - $this->$tagProcessorFunc($tag, $attributes); - } - - - if($attributes) foreach($attributes as $k => $v) { - $attProcessorFunc = "processatt_$k"; - if($this->hasMethod($attProcessorFunc)) { - $this->$attProcessorFunc($tag, $attributes); - } - } - } - - function tag_close($parser, $tag) { - $tag = ereg_replace('[^:]+:','',$tag); - - array_pop($this->context); - $attributes = array_pop($this->attributeStore); - - if(method_exists($this, $funcName = "process_{$tag}_end")) { - $this->$funcName($this->collatedText, $attributes); - }elseif(method_exists($this,$funcName = "process_tag_end")){ - // else run default method - $this->$funcName($tag,$this->collatedText, $attributes); - } - - $this->collatedText = ""; - } - - function cdata($parser, $cdata) { - $this->collatedText .= $cdata; - } -} \ No newline at end of file diff --git a/javascript/TreeDropdownField.js b/javascript/TreeDropdownField.js index f58ef2375..8cb5ffe20 100644 --- a/javascript/TreeDropdownField.js +++ b/javascript/TreeDropdownField.js @@ -77,11 +77,13 @@ .bind('select_node.jstree', function(e, data) { var node = data.rslt.obj, id = $(node).data('id'); if(self.getValue() == id) { - self.setValue(null); + self.data('metadata', null); self.setTitle(null); + self.setValue(null); } else { - self.setValue(id); + self.data('metadata', [$.extend({id: id}, $(node).getMetaData())]); self.setTitle(data.inst.get_text(node)); + self.setValue(id); } // Avoid auto-closing panel on first load @@ -132,6 +134,19 @@ return []; } }); + $('.TreeDropdownField .tree-holder li').entwine({ + /** + * Overload to return more data. The same data should be set on initial + * value through PHP as well (see TreeDropdownField->Field()). + * + * @return {object} + */ + getMetaData: function() { + var matches = this.attr('class').match(/class-([^\s]*)/i); + var klass = matches ? matches[1] : ''; + return {ClassName: klass}; + } + }); $('.TreeDropdownField *').entwine({ getField: function() { return this.parents('.TreeDropdownField:first'); @@ -219,6 +234,9 @@ self.setTitle($.map(nodes, function(el, i) { return data.inst.get_text(el); })); + self.data('metadata', $.map(nodes, function(el, i) { + return {id: $(el).data('id'), metadata: $(el).getMetaData()}; + })); }); } diff --git a/model/DataObject.php b/model/DataObject.php index 644a19327..1ede8ab46 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -988,7 +988,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * - All relevant tables will be updated. * - $this->onBeforeWrite() gets called beforehand. * - Extensions such as Versioned will ammend the database-write to ensure that a version is saved. - * - Calls to {@link DataObjectLog} can be used to see everything that's been changed. * * @uses DataExtension->augmentWrite() * @@ -1130,13 +1129,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } DB::manipulate($manipulation); - - if(isset($isNewRecord) && $isNewRecord) { - DataObjectLog::addedObject($this); - } else { - DataObjectLog::changedObject($this); - } - $this->onAfterWrite(); $this->changed = null; @@ -1227,8 +1219,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $this->OldID = $this->ID; $this->ID = 0; - - DataObjectLog::deletedObject($this); } /** diff --git a/model/DataObjectDecorator.php b/model/DataObjectDecorator.php index 01ed429e2..e241ff2d3 100755 --- a/model/DataObjectDecorator.php +++ b/model/DataObjectDecorator.php @@ -7,10 +7,11 @@ abstract class DataObjectDecorator extends DataExtension { public function __construct() { - user_error( - 'DataObjectDecorator is deprecated, please use DataExtension instead.', - E_USER_NOTICE - ); + // TODO Re-enable before we release 3.0 beta, for now it "breaks" too many modules + // user_error( + // 'DataObjectDecorator is deprecated, please use DataExtension instead.', + // E_USER_NOTICE + // ); parent::__construct(); } diff --git a/model/DataObjectLog.php b/model/DataObjectLog.php deleted file mode 100755 index 30b336304..000000000 --- a/model/DataObjectLog.php +++ /dev/null @@ -1,113 +0,0 @@ -class][] = $object; - } - } - - /** - * Add this DataObject as deleted in the log. - * @param DataObject $object - */ - static function deletedObject($object) { - if(self::$enabled) { - self::$deleted[$object->class][] = $object; - } - } - - /** - * Add this DataObject as changed in the log. - * @param DataObject $object - */ - static function changedObject($object) { - if(self::$enabled) { - self::$changed[$object->class][] = $object; - } - } - - /** - * Get all DataObjects that have been added this session that are of - * the class or a subclass of the class provided. - * @param string $className The class name. - * @return array - */ - static function getAdded($className) { - return self::getByClass($className, self::$added); - } - - /** - * Get all DataObjects that have been deleted this session that are of - * the class or a subclass of the class provided. - * @param string $className The class name. - * @return array - */ - static function getDeleted($className) { - return self::getByClass($className, self::$deleted); - } - - /** - * Get all DataObjects that have been changed this session that are of - * the class or a subclass of the class provided. - * @param string $className The class name. - * @return array - */ - static function getChanged($className) { - return self::getByClass($className, self::$changed); - } - - /** - * Get all DataObjects in the given set that are of the class or a - * subclass of the class provided. - * @param string $className The class name. - * @param array $set The set to search in. - * @return array - */ - static function getByClass($className, $set) { - $allClasses = ClassInfo::subclassesFor($className); - foreach($allClasses as $subClass) { - if(isset($set[$subClass])) { - foreach($set[$subClass] as $page) { - $result[$page->ID] = $page; - } - } - } - return isset($result) ? $result : null; - } -} - -?> \ No newline at end of file diff --git a/model/Database.php b/model/Database.php index 0ff12451e..5706cd7bc 100755 --- a/model/Database.php +++ b/model/Database.php @@ -707,15 +707,13 @@ abstract class SS_Database { * Convert a SQLQuery object into a SQL statement */ public function sqlQueryToString(SQLQuery $sqlQuery) { - if (!$sqlQuery->from) return ''; $distinct = $sqlQuery->distinct ? "DISTINCT " : ""; if($sqlQuery->delete) { $text = "DELETE "; } else if($sqlQuery->select) { $text = "SELECT $distinct" . implode(", ", $sqlQuery->select); } - $text .= " FROM " . implode(" ", $sqlQuery->from); - + if($sqlQuery->from) $text .= " FROM " . implode(" ", $sqlQuery->from); if($sqlQuery->where) $text .= " WHERE (" . $sqlQuery->getFilter(). ")"; if($sqlQuery->groupby) $text .= " GROUP BY " . implode(", ", $sqlQuery->groupby); if($sqlQuery->having) $text .= " HAVING ( " . implode(" ) AND ( ", $sqlQuery->having) . " )"; diff --git a/security/Member.php b/security/Member.php index 074c4adcc..da1ee41d2 100644 --- a/security/Member.php +++ b/security/Member.php @@ -1114,17 +1114,7 @@ class Member extends DataObject { $password->setCanBeEmpty(true); if(!$this->ID) $password->showOnClick = false; $mainFields->replaceField('Password', $password); - - $mainFields->insertBefore( - new HeaderField('MemberDetailsHeader',_t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')), - 'FirstName' - ); - - $mainFields->insertBefore( - new HeaderField('MemberUserDetailsHeader',_t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')), - 'Email' - ); - + $mainFields->replaceField('Locale', new DropdownField( "Locale", _t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), @@ -1563,9 +1553,7 @@ class Member_GroupSet extends ManyManyList { class Member_ProfileForm extends Form { function __construct($controller, $name, $member) { - Requirements::clear(); - Requirements::css(CMS_DIR . '/css/typography.css'); - Requirements::css(SAPPHIRE_DIR . "/css/Form.css"); + Requirements::block(SAPPHIRE_DIR . '/admin/css/layout.css'); $fields = $member->getCMSFields(); $fields->push(new HiddenField('ID','ID',$member->ID)); @@ -1578,6 +1566,7 @@ class Member_ProfileForm extends Form { parent::__construct($controller, $name, $fields, $actions, $validator); + $this->addExtraClass('member-profile-form'); $this->loadDataFrom($member); } @@ -1802,7 +1791,6 @@ class Member_Validator extends RequiredFields { class Member_DatetimeOptionsetField extends OptionsetField { function Field() { - Requirements::css(SAPPHIRE_DIR . '/css/MemberDatetimeOptionsetField.css'); Requirements::javascript(THIRDPARTY_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/MemberDatetimeOptionsetField.js'); diff --git a/tests/api/RestfulServerTest.php b/tests/api/RestfulServerTest.php index fc57b7f4d..6147343f6 100644 --- a/tests/api/RestfulServerTest.php +++ b/tests/api/RestfulServerTest.php @@ -360,17 +360,22 @@ class RestfulServerTest extends SapphireTest { public function testJSONDataFormatter() { $formatter = new JSONDataFormatter(); - $single_do = $this->objFromFixture('Member', 'editor'); + $editor = $this->objFromFixture('Member', 'editor'); + $user = $this->objFromFixture('Member', 'user'); $this->assertEquals( - $formatter->convertDataObject($single_do, array("FirstName", "Email")), + $formatter->convertDataObject($editor, array("FirstName", "Email")), '{"FirstName":"Editor","Email":"editor@test.com"}', "Correct JSON formatting with field subset"); - $set = DataObject::get("Member"); + $set = DataObject::get( + "Member", + sprintf('"Member"."ID" IN (%s)', implode(',', array($editor->ID, $user->ID))), + '"Email" ASC' // for sorting for postgres + ); $this->assertEquals( $formatter->convertDataObjectSet($set, array("FirstName", "Email")), - '{"totalSize":null,"items":[{"FirstName":"Editor","Email":"editor@test.com"},{"FirstName":"User","Email":"user@test.com"},{"FirstName":"ADMIN","Email":"ADMIN@example.org"}]}', + '{"totalSize":null,"items":[{"FirstName":"Editor","Email":"editor@test.com"},{"FirstName":"User","Email":"user@test.com"}]}', "Correct JSON formatting on a dataobjectset with field filter"); } diff --git a/tests/core/manifest/ClassManifestTest.php b/tests/core/manifest/ClassManifestTest.php index 701aa8cac..6fa4fe836 100644 --- a/tests/core/manifest/ClassManifestTest.php +++ b/tests/core/manifest/ClassManifestTest.php @@ -105,6 +105,12 @@ class ClassManifestTest extends SapphireTest { $this->assertEquals($expect, $this->manifest->getConfigs()); $this->assertEquals($expect, $this->manifestTests->getConfigs()); } + + public function testGetModules() { + $expect = array("module" => "{$this->base}/module"); + $this->assertEquals($expect, $this->manifest->getModules()); + $this->assertEquals($expect, $this->manifestTests->getModules()); + } public function testTestManifestIncludesTestClasses() { $this->assertNotContains('testclassa', array_keys($this->manifest->getClasses())); diff --git a/tests/core/manifest/TokenisedRegularExpressionTest.php b/tests/core/manifest/TokenisedRegularExpressionTest.php index 473b5710b..509c1e211 100644 --- a/tests/core/manifest/TokenisedRegularExpressionTest.php +++ b/tests/core/manifest/TokenisedRegularExpressionTest.php @@ -43,6 +43,10 @@ implements InterfaceA, InterfaceB { } +interface InterfaceC extends InterfaceA, InterfaceB { +} +interface InterfaceD extends InterfaceA, InterfaceB, InterfaceC { +} ?> PHP ); @@ -88,8 +92,8 @@ PHP if($matches) foreach($matches as $match) $interfaces[$match['interfaceName']] = $match; $this->assertArrayHasKey('InterfaceA', $interfaces); - $this->assertArrayHasKey('InterfaceB', $interfaces); - $this->assertEquals('Something', $interfaces['InterfaceB']['extends']); + $this->assertArrayHasKey('InterfaceC', $interfaces); + $this->assertArrayHasKey('InterfaceD', $interfaces); } } \ No newline at end of file diff --git a/tests/forms/CheckboxFieldTest.php b/tests/forms/CheckboxFieldTest.php index fa455c69e..a17305d0f 100644 --- a/tests/forms/CheckboxFieldTest.php +++ b/tests/forms/CheckboxFieldTest.php @@ -40,8 +40,8 @@ class CheckboxFieldTest extends SapphireTest { $field = new CheckboxField('IsChecked', 'Checked'); $field->setValue(null); - /* dataValue() for the field is 0 */ - $this->assertEquals($field->dataValue(), 0, 'dataValue() returns a 0'); + /* dataValue() for the field is null */ + $this->assertEquals($field->dataValue(), null, 'dataValue() returns a 0'); /* Value() returns 0 as well */ $this->assertEquals($field->Value(), 0, 'Value() returns a 0'); @@ -52,8 +52,8 @@ class CheckboxFieldTest extends SapphireTest { $field = new CheckboxField('IsChecked', 'Checked'); $field->setValue(false); - /* dataValue() for the field is 0 */ - $this->assertEquals($field->dataValue(), 0, 'dataValue() returns a 0'); + /* dataValue() for the field is null */ + $this->assertEquals($field->dataValue(), null, 'dataValue() returns a 0'); /* Value() returns 0 as well */ $this->assertEquals($field->Value(), 0, 'Value() returns a 0'); @@ -63,8 +63,8 @@ class CheckboxFieldTest extends SapphireTest { /* Create the field, but don't set any value on it */ $field = new CheckboxField('IsChecked', 'Checked'); - /* dataValue() for the field is 0 */ - $this->assertEquals($field->dataValue(), 0, 'dataValue() returns a 0'); + /* dataValue() for the field is null */ + $this->assertEquals($field->dataValue(), null, 'dataValue() returns a 0'); /* Value() returns 0 as well */ $this->assertEquals($field->Value(), 0, 'Value() returns a 0'); diff --git a/tests/model/DataObjectTest.php b/tests/model/DataObjectTest.php index fa1f0b8b8..e53ffdac7 100755 --- a/tests/model/DataObjectTest.php +++ b/tests/model/DataObjectTest.php @@ -765,20 +765,21 @@ class DataObjectTest extends SapphireTest { } function testNewClassInstance() { - $dataObject = $this->objFromFixture('DataObjectTest_TeamComment', 'comment1'); - $changedDO = $dataObject->newClassInstance('File'); + $dataObject = $this->objFromFixture('DataObjectTest_Team', 'team1'); + $changedDO = $dataObject->newClassInstance('DataObjectTest_SubTeam'); $changedFields = $changedDO->getChangedFields(); // Don't write the record, it will reset changed fields - $this->assertType('File', $changedDO); - $this->assertEquals($changedDO->ClassName, 'File'); + $this->assertType('DataObjectTest_SubTeam', $changedDO); + $this->assertEquals($changedDO->ClassName, 'DataObjectTest_SubTeam'); $this->assertContains('ClassName', array_keys($changedFields)); - $this->assertEquals($changedFields['ClassName']['before'], 'DataObjectTest_TeamComment'); - $this->assertEquals($changedFields['ClassName']['after'], 'File'); - + $this->assertEquals($changedFields['ClassName']['before'], 'DataObjectTest_Team'); + $this->assertEquals($changedFields['ClassName']['after'], 'DataObjectTest_SubTeam'); + $changedDO->write(); - $this->assertType('File', $changedDO); - $this->assertEquals($changedDO->ClassName, 'File'); + + $this->assertType('DataObjectTest_SubTeam', $changedDO); + $this->assertEquals($changedDO->ClassName, 'DataObjectTest_SubTeam'); } function testManyManyExtraFields() { diff --git a/tests/model/DbDatetimeTest.php b/tests/model/DbDatetimeTest.php index 012a96f6b..471e9e76d 100644 --- a/tests/model/DbDatetimeTest.php +++ b/tests/model/DbDatetimeTest.php @@ -54,8 +54,8 @@ class DbDatetimeTest extends FunctionalTest { function testCorrectNow() { if($this->supportDbDatetime) { - $query = 'SELECT ' . $this->adapter->formattedDatetimeClause('now', '%U'); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->formattedDatetimeClause('now', '%U')); + $result = $query->execute()->value(); $this->assertRegExp('/^\d*$/', (string) $result); $this->assertTrue($result>0); } @@ -63,16 +63,16 @@ class DbDatetimeTest extends FunctionalTest { function testDbDatetimeFormat() { if($this->supportDbDatetime) { - $query = 'SELECT ' . $this->adapter->formattedDatetimeClause('1973-10-14 10:30:00', '%H:%i, %d/%m/%Y'); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->formattedDatetimeClause('1973-10-14 10:30:00', '%H:%i, %d/%m/%Y')); + $result = $query->execute()->value(); $this->matchesRoughly($result, date('H:i, d/m/Y', strtotime('1973-10-14 10:30:00')), 'nice literal time'); - $query = 'SELECT ' . $this->adapter->formattedDatetimeClause('now', '%d'); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->formattedDatetimeClause('now', '%d')); + $result = $query->execute()->value(); $this->matchesRoughly($result, date('d', $this->getDbNow()), 'todays day'); - $query = 'SELECT ' . $this->adapter->formattedDatetimeClause('"Created"', '%U') . ' AS test FROM "DbDateTimeTest_Team"'; - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->formattedDatetimeClause('"Created"', '%U') . ' AS test FROM "DbDateTimeTest_Team"'); + $result = $query->execute()->value(); $this->matchesRoughly($result, strtotime(DataObject::get_one('DbDateTimeTest_Team')->Created), 'fixture ->Created as timestamp'); } @@ -81,16 +81,19 @@ class DbDatetimeTest extends FunctionalTest { function testDbDatetimeInterval() { if($this->supportDbDatetime) { - $query = 'SELECT ' . $this->adapter->datetimeIntervalClause('1973-10-14 10:30:00', '+18 Years'); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->datetimeIntervalClause('1973-10-14 10:30:00', '+18 Years')); + $result = $query->execute()->value(); $this->matchesRoughly($result, '1991-10-14 10:30:00', 'add 18 years'); - $query = 'SELECT ' . $this->adapter->datetimeIntervalClause('now', '+1 Day'); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->datetimeIntervalClause('now', '+1 Day')); + $result = $query->execute()->value(); $this->matchesRoughly($result, date('Y-m-d H:i:s', strtotime('+1 Day', $this->getDbNow())), 'tomorrow'); - $query = 'SELECT ' . $this->adapter->datetimeIntervalClause('"Created"', '-15 Minutes') . ' AS "test" FROM "DbDateTimeTest_Team" LIMIT 1'; - $result = DB::query($query)->value(); + $query = new SQLQuery(); + $query->select($this->adapter->datetimeIntervalClause('"Created"', '-15 Minutes') . ' AS "test"') + ->from("DbDateTimeTest_Team") + ->limit(1); + $result = $query->execute()->value(); $this->matchesRoughly($result, date('Y-m-d H:i:s', strtotime(Dataobject::get_one('DbDateTimeTest_Team')->Created) - 900), '15 Minutes before creating fixture'); } @@ -99,20 +102,24 @@ class DbDatetimeTest extends FunctionalTest { function testDbDatetimeDifference() { if($this->supportDbDatetime) { - $query = 'SELECT ' . $this->adapter->datetimeDifferenceClause('1974-10-14 10:30:00', '1973-10-14 10:30:00'); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->datetimeDifferenceClause('1974-10-14 10:30:00', '1973-10-14 10:30:00')); + $result = $query->execute()->value(); $this->matchesRoughly($result/86400, 365, '1974 - 1973 = 365 * 86400 sec'); - $query = 'SELECT ' . $this->adapter->datetimeDifferenceClause(date('Y-m-d H:i:s', strtotime('-15 seconds')), 'now'); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->datetimeDifferenceClause(date('Y-m-d H:i:s', strtotime('-15 seconds')), 'now')); + $result = $query->execute()->value(); $this->matchesRoughly($result, -15, '15 seconds ago - now'); - $query = 'SELECT ' . $this->adapter->datetimeDifferenceClause('now', $this->adapter->datetimeIntervalClause('now', '+45 Minutes')); - $result = DB::query($query)->value(); + $query = new SQLQuery($this->adapter->datetimeDifferenceClause('now', $this->adapter->datetimeIntervalClause('now', '+45 Minutes'))); + $result = $query->execute()->value(); $this->matchesRoughly($result, -45 * 60, 'now - 45 minutes ahead'); - $query = 'SELECT ' . $this->adapter->datetimeDifferenceClause('"LastEdited"', '"Created"') . ' AS "test" FROM "DbDateTimeTest_Team" LIMIT 1'; - $result = DB::query($query)->value(); + $query = new SQLQuery(); + $query->select($this->adapter->datetimeDifferenceClause('"LastEdited"', '"Created"') . ' AS "test"') + ->from("DbDateTimeTest_Team") + ->limit(1); + + $result = $query->execute()->value(); $lastedited = Dataobject::get_one('DbDateTimeTest_Team')->LastEdited; $created = Dataobject::get_one('DbDateTimeTest_Team')->Created; $this->matchesRoughly($result, strtotime($lastedited) - strtotime($created), 'age of HomePage record in seconds since unix epoc'); diff --git a/thirdparty/jquery-entwine/.piston.yml b/thirdparty/jquery-entwine/.piston.yml index 461035058..370568d3e 100644 --- a/thirdparty/jquery-entwine/.piston.yml +++ b/thirdparty/jquery-entwine/.piston.yml @@ -1,7 +1,7 @@ --- format: 1 handler: - commit: b0b8d4f3417db927eae24510f9a45dfe38bb7d37 + commit: dd1b1d3c0958aa12990cba80a9b9d429a7e89bee branch: master lock: false repository_class: Piston::Git::Repository diff --git a/thirdparty/jquery-entwine/build.sh b/thirdparty/jquery-entwine/build.sh index efd44f095..018d60532 100755 --- a/thirdparty/jquery-entwine/build.sh +++ b/thirdparty/jquery-entwine/build.sh @@ -29,6 +29,8 @@ do \ echo >> $FILE done +cp $FILE "dist/jquery.concrete-dist.js" + # cp LICENSE /tmp/ # cp $FILE /tmp/ diff --git a/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js b/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js index b003b64d2..6df3e75f1 100644 --- a/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js +++ b/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js @@ -749,7 +749,12 @@ Sizzle is good for finding elements for a selector, but not so good for telling /* src/jquery.entwine.js */ -var console; +try { + console.log; +} +catch (e) { + window.console = undefined; +} (function($) { @@ -1186,10 +1191,24 @@ var console; (function($) { - /* If we are any browser other than IE or Safari, we don't have to do anything special to handle - * onchange delegation */ - $.support.bubblingChange = !($.browser.msie || $.browser.safari); - + /** Taken from jQuery 1.5.2 for backwards compatibility */ + if ($.support.changeBubbles == undefined) { + $.support.changeBubbles = true; + + var el = document.createElement("div"); + eventName = "onchange"; + + if (el.attachEvent) { + var isSupported = (eventName in el); + if (!isSupported) { + el.setAttribute(eventName, "return;"); + isSupported = typeof el[eventName] === "function"; + } + + $.support.changeBubbles = isSupported; + } + } + /* Return true if node b is the same as, or is a descendant of, node a */ if (document.compareDocumentPosition) { var is_or_contains = function(a, b) { @@ -1250,46 +1269,104 @@ var console; build_change_proxy: function(name) { var one = this.one(name, 'func'); - - var prxy = function(e) { - var el = e.target; - // If this is a keydown event, only worry about the enter key, since browsers only trigger onchange on enter or focus loss - if (e.type === 'keydown' && e.keyCode !== 13) return; - // Make sure this is event is for an input type we're interested in - if (el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' && el.tagName !== 'SELECT') return; - - var $el = $(el), nowVal, oldVal = $el.data('changeVal'); - - // Detect changes on checkboxes & radiobuttons, which have different value logic. We don't use el.value, since el is part - // of a set, and we only want to raise onchange once for a single user action. - if (el.type == 'checkbox' || el.type == 'radio') { - if (!el.disabled && e.type === 'click') { - nowVal = el.checked; - // If radio, we get two changes - the activation, and the deactivation. We only want to fire one change though - if ((el.type === 'checkbox' || nowVal === true) && oldVal !== nowVal) e.type = 'change'; + + /* + This change bubble emulation code is taken mostly from jQuery 1.6 - unfortunately we can't easily reuse any of + it without duplication, so we'll have to re-migrate any bugfixes + */ + + // Get the value of an item. Isn't supposed to be interpretable, just stable for some value, and different + // once the value changes + var getVal = function( elem ) { + var type = elem.type, val = elem.value; + + if (type === "radio" || type === "checkbox") { + val = elem.checked; + } + else if (type === "select-multiple") { + val = ""; + if (elem.selectedIndex > -1) { + val = jQuery.map(elem.options, function(elem){ return elem.selected; }).join("-"); } } - // Detect changes on other input types. In this case value is OK. - else { - nowVal = el.value; - if (oldVal !== undefined && oldVal !== nowVal) e.type = 'change'; + else if (jQuery.nodeName(elem, "select")) { + val = elem.selectedIndex; } - - // Save the current value for next time - if (nowVal !== undefined) $el.data('changeVal', nowVal); - - // And if we decided that a change happened, do the actual triggering - if (e.type == 'change') { - while (el && el.nodeType == 1 && !e.isPropagationStopped()) { - var ret = one(el, arguments); + + return val; + }; + + // Test if a node name is a form input + var rformElems = /^(?:textarea|input|select)$/i; + + // Check if this event is a change, and bubble the change event if it is + var testChange = function(e) { + var elem = e.target, data, val; + + if (!rformElems.test(elem.nodeName) || elem.readOnly) return; + + data = jQuery.data(elem, "_entwine_change_data"); + val = getVal(elem); + + // the current data will be also retrieved by beforeactivate + if (e.type !== "focusout" || elem.type !== "radio") { + jQuery.data(elem, "_entwine_change_data", val); + } + + if (data === undefined || val === data) return; + + if (data != null || val) { + e.type = "change"; + + while (elem && elem.nodeType == 1 && !e.isPropagationStopped()) { + var ret = one(elem, arguments); if (ret !== undefined) e.result = ret; if (ret === false) { e.preventDefault(); e.stopPropagation(); } - - el = el.parentNode; + + elem = elem.parentNode; } } }; - + + // The actual proxy - responds to several events, some of which triger a change check, some + // of which just store the value for future change checks + var prxy = function(e) { + var event = e.type, elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + switch (event) { + case 'focusout': + case 'beforedeactivate': + testChange.apply(this, arguments); + break; + + case 'click': + if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { + testChange.apply(this, arguments); + } + break; + + // Change has to be called before submit + // Keydown will be called before keypress, which is used in submit-event delegation + case 'keydown': + if ( + (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || + type === "select-multiple" + ) { + testChange.apply(this, arguments); + } + break; + + // Beforeactivate happens also before the previous element is blurred + // with this event you can't trigger a change event, but you can store + // information + case 'focusin': + case 'beforeactivate': + jQuery.data( elem, "_entwine_change_data", getVal(elem) ); + break; + } + } + return prxy; }, @@ -1310,9 +1387,9 @@ var console; event = 'mouseout'; break; case 'onchange': - if (!$.support.bubblingChange) { + if (!$.support.changeBubbles) { proxies[name] = this.build_change_proxy(name); - event = 'click focusin focusout keydown'; + event = 'click keydown focusin focusout beforeactivate beforedeactivate'; } break; case 'onsubmit': @@ -1325,8 +1402,8 @@ var console; // If none of the special handlers created a proxy, use the generic proxy if (!proxies[name]) proxies[name] = this.build_event_proxy(name); - - $(document).bind(event+'.entwine', proxies[name]); + + $(document).bind(event.replace(/(\s+|$)/g, '.entwine$1'), proxies[name]); } } }); @@ -1550,7 +1627,7 @@ var console; var getterName = 'get'+k; var setterName = 'set'+k; - this.bind_proxy(selector, getterName, function() { return this.entwineData(k) || v ; }); + this.bind_proxy(selector, getterName, function() { var r = this.entwineData(k); return r === undefined ? v : r; }); this.bind_proxy(selector, setterName, function(v){ return this.entwineData(k, v); }); // Get the get and set proxies we just created diff --git a/thirdparty/jquery-entwine/spec/SpecRunner.html b/thirdparty/jquery-entwine/spec/SpecRunner.html index 6e7159279..7257037e8 100644 --- a/thirdparty/jquery-entwine/spec/SpecRunner.html +++ b/thirdparty/jquery-entwine/spec/SpecRunner.html @@ -2,15 +2,31 @@ "http://www.w3.org/TR/html4/loose.dtd"> - Jasmine Test Runner - - - + Jasmine Test Runner + + + + - + + + + @@ -22,22 +38,40 @@ - - - + + + + + + - diff --git a/thirdparty/jquery-entwine/spec/spec.entwine.events.js b/thirdparty/jquery-entwine/spec/spec.entwine.events.js index fa044ad95..8ccb43496 100644 --- a/thirdparty/jquery-entwine/spec/spec.entwine.events.js +++ b/thirdparty/jquery-entwine/spec/spec.entwine.events.js @@ -110,7 +110,53 @@ describe( 'Entwine', function() { expect(data.cheese).toEqual( 'burger'); }); }); - + + describe( 'calls onchange on checkboxes properly', function() { + beforeEach(function() { + $('#dom_test').html(''); + }); + + it( 'calls onchange', function() { + var a = 0; + + $('#i').entwine({onchange: function(){ a += 1; }}); + + // Can't just "click()" - it's not the same as an actual click event + $('#i').trigger('focusin'); $('#i')[0].click(); + expect(a).toEqual(1); + }); + + it( 'calls onchange only once per change', function() { + var a = 0; + + $('#i').entwine({onchange: function(){ a += 1; }}); + + $('#i').trigger('focusin'); $('#i')[0].click(); + expect(a).toEqual(1); + + $('#i').trigger('focusout'); $('#i').trigger('focusin'); $('#i').trigger('focusout'); + expect(a).toEqual(1); + + $('#i')[0].click(); + expect(a).toEqual(2); + + }); + + it( 'calls onchange even if checked attribute altered in mean time', function() { + var a = 0; + + $('#i').entwine({onchange: function(){ a += 1; }}); + + $('#i').trigger('focusin'); $('#i')[0].click(); + expect(a).toEqual(1); + + $('#i').removeAttr('checked'); + + $('#i').trigger('focusin'); $('#i')[0].click(); + expect(a).toEqual(2); + }); + }); + }); }); \ No newline at end of file diff --git a/thirdparty/jquery-entwine/spec/spec.entwine.properties.js b/thirdparty/jquery-entwine/spec/spec.entwine.properties.js index a8b9089dd..312ae1788 100644 --- a/thirdparty/jquery-entwine/spec/spec.entwine.properties.js +++ b/thirdparty/jquery-entwine/spec/spec.entwine.properties.js @@ -33,6 +33,16 @@ describe('Entwine', function() { }); expect($('.a').getFoo()).toEqual(1); }); + it('can override a default value with a true-ish value', function() { + $('#a').entwine({ Foo: 1 }); + $('#a').setFoo(2); + expect($('.a').getFoo()).toEqual(2); + }); + it('can override a default value with a false-ish value', function() { + $('#a').entwine({ Foo: 1 }); + $('#a').setFoo(0); + expect($('.a').getFoo()).toEqual(0); + }); it('should manage proprties in namespaces without clashing', function() { $('#a').entwine({ Foo: 1 diff --git a/thirdparty/jquery-entwine/src/jquery.entwine.events.js b/thirdparty/jquery-entwine/src/jquery.entwine.events.js index 037d1d4ce..e23428299 100644 --- a/thirdparty/jquery-entwine/src/jquery.entwine.events.js +++ b/thirdparty/jquery-entwine/src/jquery.entwine.events.js @@ -1,9 +1,23 @@ (function($) { - /* If we are any browser other than IE or Safari, we don't have to do anything special to handle - * onchange delegation */ - $.support.bubblingChange = !($.browser.msie || $.browser.safari); - + /** Taken from jQuery 1.5.2 for backwards compatibility */ + if ($.support.changeBubbles == undefined) { + $.support.changeBubbles = true; + + var el = document.createElement("div"); + eventName = "onchange"; + + if (el.attachEvent) { + var isSupported = (eventName in el); + if (!isSupported) { + el.setAttribute(eventName, "return;"); + isSupported = typeof el[eventName] === "function"; + } + + $.support.changeBubbles = isSupported; + } + } + /* Return true if node b is the same as, or is a descendant of, node a */ if (document.compareDocumentPosition) { var is_or_contains = function(a, b) { @@ -64,46 +78,104 @@ build_change_proxy: function(name) { var one = this.one(name, 'func'); - - var prxy = function(e) { - var el = e.target; - // If this is a keydown event, only worry about the enter key, since browsers only trigger onchange on enter or focus loss - if (e.type === 'keydown' && e.keyCode !== 13) return; - // Make sure this is event is for an input type we're interested in - if (el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' && el.tagName !== 'SELECT') return; - - var $el = $(el), nowVal, oldVal = $el.data('changeVal'); - - // Detect changes on checkboxes & radiobuttons, which have different value logic. We don't use el.value, since el is part - // of a set, and we only want to raise onchange once for a single user action. - if (el.type == 'checkbox' || el.type == 'radio') { - if (!el.disabled && e.type === 'click') { - nowVal = el.checked; - // If radio, we get two changes - the activation, and the deactivation. We only want to fire one change though - if ((el.type === 'checkbox' || nowVal === true) && oldVal !== nowVal) e.type = 'change'; + + /* + This change bubble emulation code is taken mostly from jQuery 1.6 - unfortunately we can't easily reuse any of + it without duplication, so we'll have to re-migrate any bugfixes + */ + + // Get the value of an item. Isn't supposed to be interpretable, just stable for some value, and different + // once the value changes + var getVal = function( elem ) { + var type = elem.type, val = elem.value; + + if (type === "radio" || type === "checkbox") { + val = elem.checked; + } + else if (type === "select-multiple") { + val = ""; + if (elem.selectedIndex > -1) { + val = jQuery.map(elem.options, function(elem){ return elem.selected; }).join("-"); } } - // Detect changes on other input types. In this case value is OK. - else { - nowVal = el.value; - if (oldVal !== undefined && oldVal !== nowVal) e.type = 'change'; + else if (jQuery.nodeName(elem, "select")) { + val = elem.selectedIndex; } - - // Save the current value for next time - if (nowVal !== undefined) $el.data('changeVal', nowVal); - - // And if we decided that a change happened, do the actual triggering - if (e.type == 'change') { - while (el && el.nodeType == 1 && !e.isPropagationStopped()) { - var ret = one(el, arguments); + + return val; + }; + + // Test if a node name is a form input + var rformElems = /^(?:textarea|input|select)$/i; + + // Check if this event is a change, and bubble the change event if it is + var testChange = function(e) { + var elem = e.target, data, val; + + if (!rformElems.test(elem.nodeName) || elem.readOnly) return; + + data = jQuery.data(elem, "_entwine_change_data"); + val = getVal(elem); + + // the current data will be also retrieved by beforeactivate + if (e.type !== "focusout" || elem.type !== "radio") { + jQuery.data(elem, "_entwine_change_data", val); + } + + if (data === undefined || val === data) return; + + if (data != null || val) { + e.type = "change"; + + while (elem && elem.nodeType == 1 && !e.isPropagationStopped()) { + var ret = one(elem, arguments); if (ret !== undefined) e.result = ret; if (ret === false) { e.preventDefault(); e.stopPropagation(); } - - el = el.parentNode; + + elem = elem.parentNode; } } }; - + + // The actual proxy - responds to several events, some of which triger a change check, some + // of which just store the value for future change checks + var prxy = function(e) { + var event = e.type, elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + switch (event) { + case 'focusout': + case 'beforedeactivate': + testChange.apply(this, arguments); + break; + + case 'click': + if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { + testChange.apply(this, arguments); + } + break; + + // Change has to be called before submit + // Keydown will be called before keypress, which is used in submit-event delegation + case 'keydown': + if ( + (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || + type === "select-multiple" + ) { + testChange.apply(this, arguments); + } + break; + + // Beforeactivate happens also before the previous element is blurred + // with this event you can't trigger a change event, but you can store + // information + case 'focusin': + case 'beforeactivate': + jQuery.data( elem, "_entwine_change_data", getVal(elem) ); + break; + } + } + return prxy; }, @@ -124,9 +196,9 @@ event = 'mouseout'; break; case 'onchange': - if (!$.support.bubblingChange) { + if (!$.support.changeBubbles) { proxies[name] = this.build_change_proxy(name); - event = 'click focusin focusout keydown'; + event = 'click keydown focusin focusout beforeactivate beforedeactivate'; } break; case 'onsubmit': @@ -139,8 +211,8 @@ // If none of the special handlers created a proxy, use the generic proxy if (!proxies[name]) proxies[name] = this.build_event_proxy(name); - - $(document).bind(event+'.entwine', proxies[name]); + + $(document).bind(event.replace(/(\s+|$)/g, '.entwine$1'), proxies[name]); } } }); diff --git a/thirdparty/jquery-entwine/src/jquery.entwine.js b/thirdparty/jquery-entwine/src/jquery.entwine.js index 93118e62b..98667d7ea 100644 --- a/thirdparty/jquery-entwine/src/jquery.entwine.js +++ b/thirdparty/jquery-entwine/src/jquery.entwine.js @@ -1,4 +1,9 @@ -var console; +try { + console.log; +} +catch (e) { + window.console = undefined; +} (function($) { diff --git a/thirdparty/jquery-entwine/src/jquery.entwine.properties.js b/thirdparty/jquery-entwine/src/jquery.entwine.properties.js index 03bdef831..eaffce4be 100644 --- a/thirdparty/jquery-entwine/src/jquery.entwine.properties.js +++ b/thirdparty/jquery-entwine/src/jquery.entwine.properties.js @@ -58,7 +58,7 @@ var getterName = 'get'+k; var setterName = 'set'+k; - this.bind_proxy(selector, getterName, function() { return this.entwineData(k) || v ; }); + this.bind_proxy(selector, getterName, function() { var r = this.entwineData(k); return r === undefined ? v : r; }); this.bind_proxy(selector, setterName, function(v){ return this.entwineData(k, v); }); // Get the get and set proxies we just created diff --git a/thirdparty/jquery-entwine/vendor/jquery-1.5.js b/thirdparty/jquery-entwine/vendor/jquery-1.5.2.js similarity index 89% rename from thirdparty/jquery-entwine/vendor/jquery-1.5.js rename to thirdparty/jquery-entwine/vendor/jquery-1.5.2.js index 5c99a8d4a..ae0234d2b 100644 --- a/thirdparty/jquery-entwine/vendor/jquery-1.5.js +++ b/thirdparty/jquery-entwine/vendor/jquery-1.5.2.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v1.5 + * jQuery JavaScript Library v1.5.2 * http://jquery.com/ * * Copyright 2011, John Resig @@ -11,7 +11,7 @@ * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * - * Date: Mon Jan 31 08:31:29 2011 -0500 + * Date: Thu Mar 31 15:28:23 2011 -0400 */ (function( window, undefined ) { @@ -69,15 +69,9 @@ var jQuery = function( selector, context ) { // For matching the engine and version of the browser browserMatch, - // Has the ready events already been bound? - readyBound = false, - // The deferred used on DOM ready readyList, - // Promise methods - promiseMethods = "then done fail isResolved isRejected promise".split( " " ), - // The ready event handler DOMContentLoaded, @@ -202,7 +196,7 @@ jQuery.fn = jQuery.prototype = { selector: "", // The current version of jQuery being used - jquery: "1.5", + jquery: "1.5.2", // The default length of a jQuery object is 0 length: 0, @@ -313,7 +307,7 @@ jQuery.fn = jQuery.prototype = { jQuery.fn.init.prototype = jQuery.fn; jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, + var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, @@ -427,11 +421,11 @@ jQuery.extend({ }, bindReady: function() { - if ( readyBound ) { + if ( readyList ) { return; } - readyBound = true; + readyList = jQuery._Deferred(); // Catch cases where $(document).ready() is called after the // browser event has already occurred. @@ -585,10 +579,8 @@ jQuery.extend({ if ( data && rnotwhite.test(data) ) { // Inspired by code by Andrea Giammarchi // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html - var head = document.getElementsByTagName("head")[0] || document.documentElement, - script = document.createElement("script"); - - script.type = "text/javascript"; + var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement, + script = document.createElement( "script" ); if ( jQuery.support.scriptEval() ) { script.appendChild( document.createTextNode( data ) ); @@ -813,155 +805,6 @@ jQuery.extend({ return (new Date()).getTime(); }, - // Create a simple deferred (one callbacks list) - _Deferred: function() { - var // callbacks list - callbacks = [], - // stored [ context , args ] - fired, - // to avoid firing when already doing so - firing, - // flag to know if the deferred has been cancelled - cancelled, - // the deferred itself - deferred = { - - // done( f1, f2, ...) - done: function() { - if ( !cancelled ) { - var args = arguments, - i, - length, - elem, - type, - _fired; - if ( fired ) { - _fired = fired; - fired = 0; - } - for ( i = 0, length = args.length; i < length; i++ ) { - elem = args[ i ]; - type = jQuery.type( elem ); - if ( type === "array" ) { - deferred.done.apply( deferred, elem ); - } else if ( type === "function" ) { - callbacks.push( elem ); - } - } - if ( _fired ) { - deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); - } - } - return this; - }, - - // resolve with given context and args - resolveWith: function( context, args ) { - if ( !cancelled && !fired && !firing ) { - firing = 1; - try { - while( callbacks[ 0 ] ) { - callbacks.shift().apply( context, args ); - } - } - finally { - fired = [ context, args ]; - firing = 0; - } - } - return this; - }, - - // resolve with this as context and given arguments - resolve: function() { - deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments ); - return this; - }, - - // Has this deferred been resolved? - isResolved: function() { - return !!( firing || fired ); - }, - - // Cancel - cancel: function() { - cancelled = 1; - callbacks = []; - return this; - } - }; - - return deferred; - }, - - // Full fledged deferred (two callbacks list) - Deferred: function( func ) { - var deferred = jQuery._Deferred(), - failDeferred = jQuery._Deferred(), - promise; - // Add errorDeferred methods, then and promise - jQuery.extend( deferred, { - then: function( doneCallbacks, failCallbacks ) { - deferred.done( doneCallbacks ).fail( failCallbacks ); - return this; - }, - fail: failDeferred.done, - rejectWith: failDeferred.resolveWith, - reject: failDeferred.resolve, - isRejected: failDeferred.isResolved, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj , i /* internal */ ) { - if ( obj == null ) { - if ( promise ) { - return promise; - } - promise = obj = {}; - } - i = promiseMethods.length; - while( i-- ) { - obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ]; - } - return obj; - } - } ); - // Make sure only one callback list will be used - deferred.then( failDeferred.cancel, deferred.cancel ); - // Unexpose cancel - delete deferred.cancel; - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - return deferred; - }, - - // Deferred helper - when: function( object ) { - var args = arguments, - length = args.length, - deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ? - object : - jQuery.Deferred(), - promise = deferred.promise(), - resolveArray; - - if ( length > 1 ) { - resolveArray = new Array( length ); - jQuery.each( args, function( index, element ) { - jQuery.when( element ).then( function( value ) { - resolveArray[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value; - if( ! --length ) { - deferred.resolveWith( promise, resolveArray ); - } - }, deferred.reject ); - } ); - } else if ( deferred !== object ) { - deferred.resolve( object ); - } - return promise; - }, - // Use of jQuery.browser is frowned upon. // More details: http://docs.jquery.com/Utilities/jQuery.browser uaMatch: function( ua ) { @@ -1000,9 +843,6 @@ jQuery.extend({ browser: {} }); -// Create readyList deferred -readyList = jQuery._Deferred(); - // Populate the class2type map jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { class2type[ "[object " + name + "]" ] = name.toLowerCase(); @@ -1071,11 +911,183 @@ function doScrollCheck() { } // Expose jQuery to the global object -return (window.jQuery = window.$ = jQuery); +return jQuery; })(); +var // Promise methods + promiseMethods = "then done fail isResolved isRejected promise".split( " " ), + // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + // Create a simple deferred (one callbacks list) + _Deferred: function() { + var // callbacks list + callbacks = [], + // stored [ context , args ] + fired, + // to avoid firing when already doing so + firing, + // flag to know if the deferred has been cancelled + cancelled, + // the deferred itself + deferred = { + + // done( f1, f2, ...) + done: function() { + if ( !cancelled ) { + var args = arguments, + i, + length, + elem, + type, + _fired; + if ( fired ) { + _fired = fired; + fired = 0; + } + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + deferred.done.apply( deferred, elem ); + } else if ( type === "function" ) { + callbacks.push( elem ); + } + } + if ( _fired ) { + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); + } + } + return this; + }, + + // resolve with given context and args + resolveWith: function( context, args ) { + if ( !cancelled && !fired && !firing ) { + // make sure args are available (#8421) + args = args || []; + firing = 1; + try { + while( callbacks[ 0 ] ) { + callbacks.shift().apply( context, args ); + } + } + finally { + fired = [ context, args ]; + firing = 0; + } + } + return this; + }, + + // resolve with this as context and given arguments + resolve: function() { + deferred.resolveWith( this, arguments ); + return this; + }, + + // Has this deferred been resolved? + isResolved: function() { + return !!( firing || fired ); + }, + + // Cancel + cancel: function() { + cancelled = 1; + callbacks = []; + return this; + } + }; + + return deferred; + }, + + // Full fledged deferred (two callbacks list) + Deferred: function( func ) { + var deferred = jQuery._Deferred(), + failDeferred = jQuery._Deferred(), + promise; + // Add errorDeferred methods, then and promise + jQuery.extend( deferred, { + then: function( doneCallbacks, failCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ); + return this; + }, + fail: failDeferred.done, + rejectWith: failDeferred.resolveWith, + reject: failDeferred.resolve, + isRejected: failDeferred.isResolved, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + if ( promise ) { + return promise; + } + promise = obj = {}; + } + var i = promiseMethods.length; + while( i-- ) { + obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; + } + return obj; + } + } ); + // Make sure only one callback list will be used + deferred.done( failDeferred.cancel ).fail( deferred.cancel ); + // Unexpose cancel + delete deferred.cancel; + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = arguments, + i = 0, + length = args.length, + count = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + // Strange bug in FF4: + // Values changed onto the arguments object sometimes end up as undefined values + // outside the $.when method. Cloning the object into a fresh array solves the issue + deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); + } + }; + } + if ( length > 1 ) { + for( ; i < length; i++ ) { + if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return deferred.promise(); + } +}); + + + + (function() { jQuery.support = {}; @@ -1088,7 +1100,8 @@ return (window.jQuery = window.$ = jQuery); var all = div.getElementsByTagName("*"), a = div.getElementsByTagName("a")[0], select = document.createElement("select"), - opt = select.appendChild( document.createElement("option") ); + opt = select.appendChild( document.createElement("option") ), + input = div.getElementsByTagName("input")[0]; // Can't get basic test support if ( !all || !all.length || !a ) { @@ -1127,7 +1140,7 @@ return (window.jQuery = window.$ = jQuery); // Make sure that if no value is specified for a checkbox // that it defaults to "on". // (WebKit defaults to "" instead) - checkOn: div.getElementsByTagName("input")[0].value === "on", + 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) @@ -1137,48 +1150,50 @@ return (window.jQuery = window.$ = jQuery); deleteExpando: true, optDisabled: false, checkClone: false, - _scriptEval: null, noCloneEvent: true, + noCloneChecked: true, boxModel: null, inlineBlockNeedsLayout: false, shrinkWrapBlocks: false, - reliableHiddenOffsets: true + reliableHiddenOffsets: true, + reliableMarginRight: true }; + input.checked = true; + jQuery.support.noCloneChecked = input.cloneNode( true ).checked; + // Make sure that the options inside disabled selects aren't marked as disabled // (WebKit marks them as diabled) select.disabled = true; jQuery.support.optDisabled = !opt.disabled; + var _scriptEval = null; jQuery.support.scriptEval = function() { - if ( jQuery.support._scriptEval === null ) { + if ( _scriptEval === null ) { var root = document.documentElement, script = document.createElement("script"), id = "script" + jQuery.now(); - script.type = "text/javascript"; + // Make sure that the execution of code works by injecting a script + // tag with appendChild/createTextNode + // (IE doesn't support this, fails, and uses .text instead) try { script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); } catch(e) {} root.insertBefore( script, root.firstChild ); - // Make sure that the execution of code works by injecting a script - // tag with appendChild/createTextNode - // (IE doesn't support this, fails, and uses .text instead) if ( window[ id ] ) { - jQuery.support._scriptEval = true; + _scriptEval = true; delete window[ id ]; } else { - jQuery.support._scriptEval = false; + _scriptEval = false; } root.removeChild( script ); - // release memory in IE - root = script = id = null; } - return jQuery.support._scriptEval; + return _scriptEval; }; // Test to see if it's possible to delete an expando from an element @@ -1190,7 +1205,7 @@ return (window.jQuery = window.$ = jQuery); jQuery.support.deleteExpando = false; } - if ( div.attachEvent && div.fireEvent ) { + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { div.attachEvent("onclick", function click() { // Cloning a node shouldn't copy over any // bound event handlers (IE does this) @@ -1260,6 +1275,17 @@ return (window.jQuery = window.$ = jQuery); jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; 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 ( document.defaultView && document.defaultView.getComputedStyle ) { + div.style.width = "1px"; + div.style.marginRight = "0"; + jQuery.support.reliableMarginRight = ( parseInt(document.defaultView.getComputedStyle(div, null).marginRight, 10) || 0 ) === 0; + } + body.removeChild( div ).style.display = "none"; div = tds = null; }); @@ -1283,8 +1309,6 @@ return (window.jQuery = window.$ = jQuery); el.setAttribute(eventName, "return;"); isSupported = typeof el[eventName] === "function"; } - el = null; - return isSupported; }; @@ -1321,7 +1345,7 @@ jQuery.extend({ hasData: function( elem ) { elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !jQuery.isEmptyObject(elem); + return !!elem && !isEmptyDataObject( elem ); }, data: function( elem, name, data, pvt /* Internal Use Only */ ) { @@ -1361,11 +1385,18 @@ jQuery.extend({ if ( !cache[ id ] ) { cache[ id ] = {}; + + // TODO: This is a hack for 1.5 ONLY. 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" ) { + if ( typeof name === "object" || typeof name === "function" ) { if ( pvt ) { cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); } else { @@ -1427,7 +1458,7 @@ jQuery.extend({ // If there is no data left in the cache, we want to continue // and let the cache object itself get destroyed - if ( !jQuery.isEmptyObject(thisCache) ) { + if ( !isEmptyDataObject(thisCache) ) { return; } } @@ -1439,7 +1470,7 @@ jQuery.extend({ // Don't destroy the parent cache unless the internal data object // had been the only thing left in it - if ( !jQuery.isEmptyObject(cache[ id ]) ) { + if ( !isEmptyDataObject(cache[ id ]) ) { return; } } @@ -1460,6 +1491,13 @@ jQuery.extend({ // data if it existed if ( internalCache ) { cache[ id ] = {}; + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery + // metadata on plain JS objects when the object is serialized using + // JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + cache[ id ][ internalKey ] = internalCache; // Otherwise, we need to eliminate the expando on the node to avoid @@ -1588,6 +1626,19 @@ function dataAttr( elem, key, data ) { return data; } +// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON +// property to be considered empty objects; this property always exists in +// order to make sure JSON.stringify does not expose internal metadata +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + @@ -1888,6 +1939,11 @@ jQuery.fn.extend({ } } + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + return values; } @@ -2081,8 +2137,7 @@ var rnamespaces = /\.(.*)$/, rescape = /[^\w\s.|`]/g, fcleanup = function( nm ) { return nm.replace(rescape, "\\$&"); - }, - eventKey = "events"; + }; /* * A number of helper functions used for managing events. @@ -2098,17 +2153,22 @@ jQuery.event = { return; } - // For whatever reason, IE has trouble passing the window object - // around, causing it to be cloned in the process - if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { - elem = window; + // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6) + // Minor release fix for bug #8018 + try { + // For whatever reason, IE has trouble passing the window object + // around, causing it to be cloned in the process + if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { + elem = window; + } } + catch ( e ) {} if ( handler === false ) { handler = returnFalse; } else if ( !handler ) { // Fixes bug #7229. Fix recommended by jdalton - return; + return; } var handleObjIn, handleObj; @@ -2132,31 +2192,18 @@ jQuery.event = { return; } - var events = elemData[ eventKey ], + var events = elemData.events, eventHandle = elemData.handle; - if ( typeof events === "function" ) { - // On plain objects events is a fn that holds the the data - // which prevents this data from being JSON serialized - // the function does not need to be called, it just contains the data - eventHandle = events.handle; - events = events.events; - - } else if ( !events ) { - if ( !elem.nodeType ) { - // On plain objects, create a fn that acts as the holder - // of the values to avoid JSON serialization of event data - elemData[ eventKey ] = elemData = function(){}; - } - + if ( !events ) { elemData.events = events = {}; } if ( !eventHandle ) { - elemData.handle = eventHandle = function() { + elemData.handle = eventHandle = function( e ) { // Handle the second event of a trigger and when // an event is called after a page has unloaded - return typeof jQuery !== "undefined" && !jQuery.event.triggered ? + return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? jQuery.event.handle.apply( eventHandle.elem, arguments ) : undefined; }; @@ -2249,17 +2296,12 @@ jQuery.event = { var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, elemData = jQuery.hasData( elem ) && jQuery._data( elem ), - events = elemData && elemData[ eventKey ]; + events = elemData && elemData.events; if ( !elemData || !events ) { return; } - if ( typeof events === "function" ) { - elemData = events; - events = events.events; - } - // types is actually an event object here if ( types && types.type ) { handler = types.handler; @@ -2359,10 +2401,7 @@ jQuery.event = { delete elemData.events; delete elemData.handle; - if ( typeof elemData === "function" ) { - jQuery.removeData( elem, eventKey, true ); - - } else if ( jQuery.isEmptyObject( elemData ) ) { + if ( jQuery.isEmptyObject( elemData ) ) { jQuery.removeData( elem, undefined, true ); } } @@ -2403,7 +2442,7 @@ jQuery.event = { // points to jQuery.expando var internalKey = jQuery.expando, internalCache = this[ internalKey ]; - if ( internalCache && internalCache.events && internalCache.events[type] ) { + if ( internalCache && internalCache.events && internalCache.events[ type ] ) { jQuery.event.trigger( event, data, internalCache.handle.elem ); } }); @@ -2429,9 +2468,7 @@ jQuery.event = { event.currentTarget = elem; // Trigger the event, it is assumed that "handle" is a function - var handle = elem.nodeType ? - jQuery._data( elem, "handle" ) : - (jQuery._data( elem, eventKey ) || {}).handle; + var handle = jQuery._data( elem, "handle" ); if ( handle ) { handle.apply( elem, data ); @@ -2473,7 +2510,7 @@ jQuery.event = { target[ "on" + targetType ] = null; } - jQuery.event.triggered = true; + jQuery.event.triggered = event.type; target[ targetType ](); } @@ -2484,7 +2521,7 @@ jQuery.event = { target[ "on" + targetType ] = old; } - jQuery.event.triggered = false; + jQuery.event.triggered = undefined; } } }, @@ -2509,11 +2546,7 @@ jQuery.event = { event.namespace = event.namespace || namespace_sort.join("."); - events = jQuery._data(this, eventKey); - - if ( typeof events === "function" ) { - events = events.events; - } + events = jQuery._data(this, "events"); handlers = (events || {})[ event.type ]; @@ -2680,7 +2713,7 @@ jQuery.Event = function( src ) { // 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 || + this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; // Event type @@ -2755,6 +2788,12 @@ var withinElement = function( event ) { // Firefox sometimes assigns relatedTarget a XUL element // which we cannot access the parentNode property of try { + + // Chrome does something similar, the parentNode property + // can be accessed but is null. + if ( parent && parent !== document && !parent.parentNode ) { + return; + } // Traverse up the tree while ( parent && parent !== this ) { parent = parent.parentNode; @@ -2805,8 +2844,7 @@ if ( !jQuery.support.submitBubbles ) { type = elem.type; if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { - e.liveFired = undefined; - return trigger( "submit", this, arguments ); + trigger( "submit", this, arguments ); } }); @@ -2815,8 +2853,7 @@ if ( !jQuery.support.submitBubbles ) { type = elem.type; if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { - e.liveFired = undefined; - return trigger( "submit", this, arguments ); + trigger( "submit", this, arguments ); } }); @@ -2879,7 +2916,7 @@ if ( !jQuery.support.changeBubbles ) { if ( data != null || val ) { e.type = "change"; e.liveFired = undefined; - return jQuery.event.trigger( e, arguments[1], elem ); + jQuery.event.trigger( e, arguments[1], elem ); } }; @@ -2893,7 +2930,7 @@ if ( !jQuery.support.changeBubbles ) { var elem = e.target, type = elem.type; if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { - return testChange.call( this, e ); + testChange.call( this, e ); } }, @@ -2905,7 +2942,7 @@ if ( !jQuery.support.changeBubbles ) { if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || type === "select-multiple" ) { - return testChange.call( this, e ); + testChange.call( this, e ); } }, @@ -2944,26 +2981,50 @@ if ( !jQuery.support.changeBubbles ) { } function trigger( type, elem, args ) { - args[0].type = type; - return jQuery.event.handle.apply( elem, args ); + // 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. + // Don't pass args or remember liveFired; they apply to the donor event. + var event = jQuery.extend( {}, args[ 0 ] ); + event.type = type; + event.originalEvent = {}; + event.liveFired = undefined; + jQuery.event.handle.call( elem, event ); + if ( event.isDefaultPrevented() ) { + args[ 0 ].preventDefault(); + } } // Create "bubbling" focus and blur events if ( document.addEventListener ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0; + jQuery.event.special[ fix ] = { setup: function() { - this.addEventListener( orig, handler, true ); - }, - teardown: function() { - this.removeEventListener( orig, handler, true ); + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } } }; - function handler( e ) { - e = jQuery.event.fix( e ); + function handler( donor ) { + // Donor event is always a native one; fix it and switch its type. + // Let focusin/out handler cancel the donor focus/blur event. + var e = jQuery.event.fix( donor ); e.type = fix; - return jQuery.event.handle.call( this, e ); + e.originalEvent = {}; + jQuery.event.trigger( e, null, e.target ); + if ( e.isDefaultPrevented() ) { + donor.preventDefault(); + } } }); } @@ -3148,11 +3209,7 @@ function liveHandler( event ) { var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, elems = [], selectors = [], - events = jQuery._data( this, eventKey ); - - if ( typeof events === "function" ) { - events = events.events; - } + events = jQuery._data( this, "events" ); // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { @@ -3186,7 +3243,7 @@ function liveHandler( event ) { for ( j = 0; j < live.length; j++ ) { handleObj = live[j]; - if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { elem = close.elem; related = null; @@ -3269,7 +3326,9 @@ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[ done = 0, toString = Object.prototype.toString, hasDuplicate = false, - baseHasDuplicate = true; + baseHasDuplicate = true, + rBackslash = /\\/g, + rNonWord = /\W/; // Here we check if the JavaScript engine is using some sort of // optimization where it does not always call our comparision @@ -3468,7 +3527,7 @@ Sizzle.find = function( expr, context, isXML ) { match.splice( 1, 1 ); if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace(/\\/g, ""); + match[1] = (match[1] || "").replace( rBackslash, "" ); set = Expr.find[ type ]( match, context, isXML ); if ( set != null ) { @@ -3607,13 +3666,16 @@ var Expr = Sizzle.selectors = { 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 && !/\W/.test( part ), + isTag = isPartStr && !rNonWord.test( part ), isPartStrNotTag = isPartStr && !isTag; if ( isTag ) { @@ -3641,7 +3703,7 @@ var Expr = Sizzle.selectors = { i = 0, l = checkSet.length; - if ( isPartStr && !/\W/.test( part ) ) { + if ( isPartStr && !rNonWord.test( part ) ) { part = part.toLowerCase(); for ( ; i < l; i++ ) { @@ -3675,7 +3737,7 @@ var Expr = Sizzle.selectors = { doneName = done++, checkFn = dirCheck; - if ( typeof part === "string" && !/\W/.test(part) ) { + if ( typeof part === "string" && !rNonWord.test( part ) ) { part = part.toLowerCase(); nodeCheck = part; checkFn = dirNodeCheck; @@ -3689,7 +3751,7 @@ var Expr = Sizzle.selectors = { doneName = done++, checkFn = dirCheck; - if ( typeof part === "string" && !/\W/.test( part ) ) { + if ( typeof part === "string" && !rNonWord.test( part ) ) { part = part.toLowerCase(); nodeCheck = part; checkFn = dirNodeCheck; @@ -3732,7 +3794,7 @@ var Expr = Sizzle.selectors = { }, preFilter: { CLASS: function( match, curLoop, inplace, result, not, isXML ) { - match = " " + match[1].replace(/\\/g, "") + " "; + match = " " + match[1].replace( rBackslash, "" ) + " "; if ( isXML ) { return match; @@ -3755,11 +3817,11 @@ var Expr = Sizzle.selectors = { }, ID: function( match ) { - return match[1].replace(/\\/g, ""); + return match[1].replace( rBackslash, "" ); }, TAG: function( match, curLoop ) { - return match[1].toLowerCase(); + return match[1].replace( rBackslash, "" ).toLowerCase(); }, CHILD: function( match ) { @@ -3790,14 +3852,14 @@ var Expr = Sizzle.selectors = { }, ATTR: function( match, curLoop, inplace, result, not, isXML ) { - var name = match[1] = match[1].replace(/\\/g, ""); + 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(/\\/g, ""); + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); if ( match[2] === "~=" ) { match[4] = " " + match[4] + " "; @@ -3852,7 +3914,9 @@ var Expr = Sizzle.selectors = { selected: function( elem ) { // Accessing this property makes selected-by-default // options in Safari work properly - elem.parentNode.selectedIndex; + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } return elem.selected === true; }, @@ -3874,8 +3938,12 @@ var Expr = Sizzle.selectors = { }, text: function( elem ) { - return "text" === elem.type; + 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 "text" === type && ( attr === type || attr === null ); }, + radio: function( elem ) { return "radio" === elem.type; }, @@ -4407,7 +4475,8 @@ if ( document.querySelectorAll ) { // 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 old = context.getAttribute( "id" ), + var oldContext = context, + old = context.getAttribute( "id" ), nid = old || id, hasParent = context.parentNode, relativeHierarchySelector = /^\s*[+~]/.test( query ); @@ -4429,7 +4498,7 @@ if ( document.querySelectorAll ) { } catch(pseudoError) { } finally { if ( !old ) { - context.removeAttribute( "id" ); + oldContext.removeAttribute( "id" ); } } } @@ -4449,19 +4518,23 @@ if ( document.querySelectorAll ) { (function(){ var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector, - 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; - } + 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']"); @@ -4469,7 +4542,15 @@ if ( document.querySelectorAll ) { if ( !Sizzle.isXML( node ) ) { try { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { - return matches.call( node, 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) {} } @@ -4845,11 +4926,11 @@ jQuery.each({ }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { var ret = jQuery.map( this, fn, until ), - // The variable 'args' was introduced in - // https://github.com/jquery/jquery/commit/52a0238 - // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. - // http://code.google.com/p/v8/issues/detail?id=1050 - args = slice.call(arguments); + // The variable 'args' was introduced in + // https://github.com/jquery/jquery/commit/52a0238 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. + // http://code.google.com/p/v8/issues/detail?id=1050 + args = slice.call(arguments); if ( !runtil.test( name ) ) { selector = until; @@ -4959,7 +5040,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rtbody = /", "" ], @@ -5111,7 +5192,7 @@ jQuery.fn.extend({ } if ( elem.parentNode ) { - elem.parentNode.removeChild( elem ); + elem.parentNode.removeChild( elem ); } } } @@ -5136,7 +5217,7 @@ jQuery.fn.extend({ }, clone: function( dataAndEvents, deepDataAndEvents ) { - dataAndEvents = dataAndEvents == null ? true : dataAndEvents; + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; return this.map( function () { @@ -5213,7 +5294,9 @@ jQuery.fn.extend({ } }); } else { - return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); + return this.length ? + this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : + this; } }, @@ -5305,8 +5388,8 @@ function cloneCopyEvent( src, dest ) { } var internalKey = jQuery.expando, - oldData = jQuery.data( src ), - curData = jQuery.data( dest, oldData ); + oldData = jQuery.data( src ), + curData = jQuery.data( dest, oldData ); // Switch to use the internal data object, if it exists, for the next // stage of data copying @@ -5320,7 +5403,7 @@ function cloneCopyEvent( src, dest ) { for ( var type in events ) { for ( var i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ], events[ type ][ i ].data ); + jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); } } } @@ -5441,6 +5524,18 @@ jQuery.each({ }; }); +function getAll( elem ) { + if ( "getElementsByTagName" in elem ) { + return elem.getElementsByTagName( "*" ); + + } else if ( "querySelectorAll" in elem ) { + return elem.querySelectorAll( "*" ); + + } else { + return []; + } +} + jQuery.extend({ clone: function( elem, dataAndEvents, deepDataAndEvents ) { var clone = elem.cloneNode(true), @@ -5448,17 +5543,20 @@ jQuery.extend({ destElements, i; - if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { + if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { // IE copies events bound via attachEvent when using cloneNode. // Calling detachEvent on the clone will also remove the events // from the original. In order to get around this, we use some // proprietary methods to clear the events. Thanks to MooTools // guys for this hotness. + cloneFixAttributes( elem, clone ); + // Using Sizzle here is crazy slow, so we use getElementsByTagName // instead - srcElements = elem.getElementsByTagName("*"); - destElements = clone.getElementsByTagName("*"); + srcElements = getAll( elem ); + destElements = getAll( clone ); // Weird iteration because IE will replace the length property // with an element if you are cloning the body and one of the @@ -5466,30 +5564,25 @@ jQuery.extend({ for ( i = 0; srcElements[i]; ++i ) { cloneFixAttributes( srcElements[i], destElements[i] ); } - - cloneFixAttributes( elem, clone ); } // Copy the events from the original to the clone if ( dataAndEvents ) { - cloneCopyEvent( elem, clone ); - if ( deepDataAndEvents && "getElementsByTagName" in elem ) { + if ( deepDataAndEvents ) { + srcElements = getAll( elem ); + destElements = getAll( clone ); - srcElements = elem.getElementsByTagName("*"); - destElements = clone.getElementsByTagName("*"); - - if ( srcElements.length ) { - for ( i = 0; srcElements[i]; ++i ) { - cloneCopyEvent( srcElements[i], destElements[i] ); - } + for ( i = 0; srcElements[i]; ++i ) { + cloneCopyEvent( srcElements[i], destElements[i] ); } } } + // Return the cloned set return clone; - }, +}, clean: function( elems, context, fragment, scripts ) { context = context || document; @@ -5650,7 +5743,8 @@ function evalScript( i, elem ) { var ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, rdashAlpha = /-([a-z])/ig, - rupper = /([A-Z])/g, + // fixed for IE9, see #8346 + rupper = /([A-Z]|^ms)/g, rnumpx = /^-?\d+(?:px)?$/i, rnum = /^-?\d/, @@ -5887,6 +5981,28 @@ if ( !jQuery.support.opacity ) { }; } +jQuery(function() { + // This hook cannot be added until DOM ready because the support test + // for it is not run until after DOM ready + if ( !jQuery.support.reliableMarginRight ) { + jQuery.cssHooks.marginRight = { + get: function( elem, computed ) { + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + // Work around by temporarily setting element display to inline-block + var ret; + jQuery.swap( elem, { "display": "inline-block" }, function() { + if ( computed ) { + ret = curCSS( elem, "margin-right", "marginRight" ); + } else { + ret = elem.style.marginRight; + } + }); + return ret; + } + }; + } +}); + if ( document.defaultView && document.defaultView.getComputedStyle ) { getComputedStyle = function( elem, newName, name ) { var ret, defaultView, computedStyle; @@ -5910,7 +6026,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { if ( document.documentElement.currentStyle ) { currentStyle = function( elem, name ) { - var left, + var left, ret = elem.currentStyle && elem.currentStyle[ name ], rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ], style = elem.style; @@ -5988,8 +6104,10 @@ var r20 = /%20/g, rbracket = /\[\]$/, rCRLF = /\r?\n/g, rhash = /#.*$/, - rheaders = /^(.*?):\s*(.*?)\r?$/mg, // IE leaves an \r character at EOL + rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, + // #7653, #8125, #8152: local protocol detection + rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/, rnoContent = /^(?:GET|HEAD)$/, rprotocol = /^\/\//, rquery = /\?/, @@ -5997,7 +6115,11 @@ var r20 = /%20/g, rselectTextarea = /^(?:select|textarea)/i, rspacesAjax = /\s+/, rts = /([?&])_=[^&]*/, - rurl = /^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/, + rucHeaders = /(^|\-)([a-z])/g, + rucHeadersFunc = function( _, $1, $2 ) { + return $1 + $2.toUpperCase(); + }, + rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, // Keep a copy of the old load method _load = jQuery.fn.load, @@ -6018,7 +6140,28 @@ var r20 = /%20/g, * 2) the catchall symbol "*" can be used * 3) selection will start with transport dataType and THEN go to "*" if needed */ - transports = {}; + transports = {}, + + // Document location + ajaxLocation, + + // Document location segments + ajaxLocParts; + +// #8138, IE may throw an exception when accessing +// a field from document.location if document.domain has been set +try { + ajaxLocation = document.location.href; +} catch( e ) { + // Use the href attribute of an A element + // since IE will modify it given document.location + ajaxLocation = document.createElement( "a" ); + ajaxLocation.href = ""; + ajaxLocation = ajaxLocation.href; +} + +// Segment location into parts +ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport function addToPrefiltersOrTransports( structure ) { @@ -6057,7 +6200,7 @@ function addToPrefiltersOrTransports( structure ) { } //Base inspection function for prefilters and transports -function inspectPrefiltersOrTransports( structure, options, originalOptions, jXHR, +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, dataType /* internal */, inspected /* internal */ ) { dataType = dataType || options.dataTypes[ 0 ]; @@ -6072,16 +6215,16 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH selection; for(; i < length && ( executeOnly || !selection ); i++ ) { - selection = list[ i ]( options, originalOptions, jXHR ); + selection = list[ i ]( options, originalOptions, jqXHR ); // If we got redirected to another dataType - // we try there if not done already + // we try there if executing only and not done already if ( typeof selection === "string" ) { - if ( inspected[ selection ] ) { + if ( !executeOnly || inspected[ selection ] ) { selection = undefined; } else { options.dataTypes.unshift( selection ); selection = inspectPrefiltersOrTransports( - structure, options, originalOptions, jXHR, selection, inspected ); + structure, options, originalOptions, jqXHR, selection, inspected ); } } } @@ -6089,7 +6232,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH // we try the catchall dataType if not done already if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { selection = inspectPrefiltersOrTransports( - structure, options, originalOptions, jXHR, "*", inspected ); + structure, options, originalOptions, jqXHR, "*", inspected ); } // unnecessary when only executing (prefilters) // but it'll be ignored by the caller in that case @@ -6121,7 +6264,7 @@ jQuery.fn.extend({ if ( jQuery.isFunction( params ) ) { // We assume that it's the callback callback = params; - params = null; + params = undefined; // Otherwise, build a param string } else if ( typeof params === "object" ) { @@ -6139,14 +6282,14 @@ jQuery.fn.extend({ dataType: "html", data: params, // Complete callback (responseText is used internally) - complete: function( jXHR, status, responseText ) { - // Store the response as specified by the jXHR object - responseText = jXHR.responseText; + complete: function( jqXHR, status, responseText ) { + // Store the response as specified by the jqXHR object + responseText = jqXHR.responseText; // If successful, inject the HTML into all the matched elements - if ( jXHR.isResolved() ) { + if ( jqXHR.isResolved() ) { // #4825: Get the actual response in case // a dataFilter is present in ajaxSettings - jXHR.done(function( r ) { + jqXHR.done(function( r ) { responseText = r; }); // See if a selector was specified @@ -6165,7 +6308,7 @@ jQuery.fn.extend({ } if ( callback ) { - self.each( callback, [ responseText, status, jXHR ] ); + self.each( callback, [ responseText, status, jqXHR ] ); } } }); @@ -6213,7 +6356,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) { if ( jQuery.isFunction( data ) ) { type = type || callback; callback = data; - data = null; + data = undefined; } return jQuery.ajax({ @@ -6229,22 +6372,39 @@ jQuery.each( [ "get", "post" ], function( i, method ) { jQuery.extend({ getScript: function( url, callback ) { - return jQuery.get( url, null, callback, "script" ); + return jQuery.get( url, undefined, callback, "script" ); }, getJSON: function( url, data, callback ) { return jQuery.get( url, data, callback, "json" ); }, - ajaxSetup: function( settings ) { - jQuery.extend( true, jQuery.ajaxSettings, settings ); - if ( settings.context ) { - jQuery.ajaxSettings.context = settings.context; + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + ajaxSetup: function ( target, settings ) { + if ( !settings ) { + // Only one parameter, we extend ajaxSettings + settings = target; + target = jQuery.extend( true, jQuery.ajaxSettings, settings ); + } else { + // target was provided, we extend into it + jQuery.extend( true, target, jQuery.ajaxSettings, settings ); } + // Flatten fields we don't want deep extended + for( var field in { context: 1, url: 1 } ) { + if ( field in settings ) { + target[ field ] = settings[ field ]; + } else if( field in jQuery.ajaxSettings ) { + target[ field ] = jQuery.ajaxSettings[ field ]; + } + } + return target; }, ajaxSettings: { - url: location.href, + url: ajaxLocation, + isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), global: true, type: "GET", contentType: "application/x-www-form-urlencoded", @@ -6259,7 +6419,6 @@ jQuery.extend({ cache: null, traditional: false, headers: {}, - crossDomain: null, */ accepts: { @@ -6306,9 +6465,8 @@ jQuery.extend({ // Main method ajax: function( url, options ) { - // If options is not an object, - // we simulate pre-1.5 signature - if ( typeof options !== "object" ) { + // If url is an object, simulate pre-1.5 signature + if ( typeof url === "object" ) { options = url; url = undefined; } @@ -6317,19 +6475,22 @@ jQuery.extend({ options = options || {}; var // Create the final options object - s = jQuery.extend( true, {}, jQuery.ajaxSettings, options ), - // Callbacks contexts - // We force the original context if it exists - // or take it from jQuery.ajaxSettings otherwise - // (plain objects used as context get extended) - callbackContext = - ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s, - globalEventContext = callbackContext === s ? jQuery.event : jQuery( callbackContext ), + s = jQuery.ajaxSetup( {}, options ), + // Callbacks context + callbackContext = s.context || s, + // Context for global events + // It's the callbackContext if one was provided in the options + // and if it's a DOM node or a jQuery collection + globalEventContext = callbackContext !== s && + ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? + jQuery( callbackContext ) : jQuery.event, // Deferreds deferred = jQuery.Deferred(), completeDeferred = jQuery._Deferred(), // Status-dependent callbacks statusCode = s.statusCode || {}, + // ifModified key + ifModifiedKey, // Headers (they are sent all at once) requestHeaders = {}, // Response headers @@ -6340,22 +6501,22 @@ jQuery.extend({ // timeout handle timeoutTimer, // Cross-domain detection vars - loc = document.location, - protocol = loc.protocol || "http:", parts, - // The jXHR state + // The jqXHR state state = 0, + // To know if global events are to be dispatched + fireGlobals, // Loop variable i, // Fake xhr - jXHR = { + jqXHR = { readyState: 0, // Caches the header setRequestHeader: function( name, value ) { - if ( state === 0 ) { - requestHeaders[ name.toLowerCase() ] = value; + if ( !state ) { + requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value; } return this; }, @@ -6377,7 +6538,15 @@ jQuery.extend({ } match = responseHeaders[ key.toLowerCase() ]; } - return match || null; + return match === undefined ? null : match; + }, + + // Overrides response content-type header + overrideMimeType: function( type ) { + if ( !state ) { + s.mimeType = type; + } + return this; }, // Cancel the request @@ -6394,7 +6563,7 @@ jQuery.extend({ // Callback for when everything is done // It is defined here because jslint complains if it is declared // at the end of the function (which would be more logical and readable) - function done( status, statusText, responses, headers) { + function done( status, statusText, responses, headers ) { // Called once if ( state === 2 ) { @@ -6410,19 +6579,19 @@ jQuery.extend({ } // Dereference transport for early garbage collection - // (no matter how long the jXHR object will be used) + // (no matter how long the jqXHR object will be used) transport = undefined; // Cache response headers responseHeadersString = headers || ""; // Set readyState - jXHR.readyState = status ? 4 : 0; + jqXHR.readyState = status ? 4 : 0; var isSuccess, success, error, - response = responses ? ajaxHandleResponses( s, jXHR, responses ) : undefined, + response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, lastModified, etag; @@ -6432,11 +6601,11 @@ jQuery.extend({ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. if ( s.ifModified ) { - if ( ( lastModified = jXHR.getResponseHeader( "Last-Modified" ) ) ) { - jQuery.lastModified[ s.url ] = lastModified; + if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { + jQuery.lastModified[ ifModifiedKey ] = lastModified; } - if ( ( etag = jXHR.getResponseHeader( "Etag" ) ) ) { - jQuery.etag[ s.url ] = etag; + if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { + jQuery.etag[ ifModifiedKey ] = etag; } } @@ -6463,7 +6632,7 @@ jQuery.extend({ // We extract error from statusText // then normalize statusText and status for non-aborts error = statusText; - if( status ) { + if( !statusText || status ) { statusText = "error"; if ( status < 0 ) { status = 0; @@ -6472,30 +6641,30 @@ jQuery.extend({ } // Set data for the fake xhr object - jXHR.status = status; - jXHR.statusText = statusText; + jqXHR.status = status; + jqXHR.statusText = statusText; // Success/Error if ( isSuccess ) { - deferred.resolveWith( callbackContext, [ success, statusText, jXHR ] ); + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); } else { - deferred.rejectWith( callbackContext, [ jXHR, statusText, error ] ); + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); } // Status-dependent callbacks - jXHR.statusCode( statusCode ); + jqXHR.statusCode( statusCode ); statusCode = undefined; - if ( s.global ) { + if ( fireGlobals ) { globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), - [ jXHR, s, isSuccess ? success : error ] ); + [ jqXHR, s, isSuccess ? success : error ] ); } // Complete - completeDeferred.resolveWith( callbackContext, [ jXHR, statusText ] ); + completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] ); - if ( s.global ) { - globalEventContext.trigger( "ajaxComplete", [ jXHR, s] ); + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] ); // Handle the global AJAX counter if ( !( --jQuery.active ) ) { jQuery.event.trigger( "ajaxStop" ); @@ -6504,13 +6673,13 @@ jQuery.extend({ } // Attach deferreds - deferred.promise( jXHR ); - jXHR.success = jXHR.done; - jXHR.error = jXHR.fail; - jXHR.complete = completeDeferred.done; + deferred.promise( jqXHR ); + jqXHR.success = jqXHR.done; + jqXHR.error = jqXHR.fail; + jqXHR.complete = completeDeferred.done; // Status-dependent callbacks - jXHR.statusCode = function( map ) { + jqXHR.statusCode = function( map ) { if ( map ) { var tmp; if ( state < 2 ) { @@ -6518,8 +6687,8 @@ jQuery.extend({ statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; } } else { - tmp = map[ jXHR.status ]; - jXHR.then( tmp, tmp ); + tmp = map[ jqXHR.status ]; + jqXHR.then( tmp, tmp ); } } return this; @@ -6528,18 +6697,18 @@ jQuery.extend({ // Remove hash character (#7531: and string promotion) // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) // We also use the url parameter if available - s.url = ( "" + ( url || s.url ) ).replace( rhash, "" ).replace( rprotocol, protocol + "//" ); + s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); // Extract dataTypes list s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax ); // Determine if a cross-domain request is in order - if ( !s.crossDomain ) { + if ( s.crossDomain == null ) { parts = rurl.exec( s.url.toLowerCase() ); s.crossDomain = !!( parts && - ( parts[ 1 ] != protocol || parts[ 2 ] != loc.hostname || + ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != - ( loc.port || ( protocol === "http:" ? 80 : 443 ) ) ) + ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) ); } @@ -6549,7 +6718,15 @@ jQuery.extend({ } // Apply prefilters - inspectPrefiltersOrTransports( prefilters, s, options, jXHR ); + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); + + // If request was aborted inside a prefiler, stop there + if ( state === 2 ) { + return false; + } + + // We can fire global events as of now if asked to + fireGlobals = s.global; // Uppercase the type s.type = s.type.toUpperCase(); @@ -6558,7 +6735,7 @@ jQuery.extend({ s.hasContent = !rnoContent.test( s.type ); // Watch for a new set of requests - if ( s.global && jQuery.active++ === 0 ) { + if ( fireGlobals && jQuery.active++ === 0 ) { jQuery.event.trigger( "ajaxStart" ); } @@ -6570,6 +6747,9 @@ jQuery.extend({ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; } + // Get ifModifiedKey before adding the anti-cache parameter + ifModifiedKey = s.url; + // Add anti-cache in url if needed if ( s.cache === false ) { @@ -6584,77 +6764,77 @@ jQuery.extend({ // Set the correct header, if data is being sent if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { - requestHeaders[ "content-type" ] = s.contentType; + requestHeaders[ "Content-Type" ] = s.contentType; } // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. if ( s.ifModified ) { - if ( jQuery.lastModified[ s.url ] ) { - requestHeaders[ "if-modified-since" ] = jQuery.lastModified[ s.url ]; + ifModifiedKey = ifModifiedKey || s.url; + if ( jQuery.lastModified[ ifModifiedKey ] ) { + requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ]; } - if ( jQuery.etag[ s.url ] ) { - requestHeaders[ "if-none-match" ] = jQuery.etag[ s.url ]; + if ( jQuery.etag[ ifModifiedKey ] ) { + requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ]; } } // Set the Accepts header for the server, depending on the dataType - requestHeaders.accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? + requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : s.accepts[ "*" ]; // Check for headers option for ( i in s.headers ) { - requestHeaders[ i.toLowerCase() ] = s.headers[ i ]; + jqXHR.setRequestHeader( i, s.headers[ i ] ); } // Allow custom headers/mimetypes and early abort - if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jXHR, s ) === false || state === 2 ) ) { + if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { // Abort if not done already - done( 0, "abort" ); - // Return false - jXHR = false; + jqXHR.abort(); + return false; + } + + // Install callbacks on deferreds + for ( i in { success: 1, error: 1, complete: 1 } ) { + jqXHR[ i ]( s[ i ] ); + } + + // Get transport + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); + + // If no transport, we auto-abort + if ( !transport ) { + done( -1, "No Transport" ); } else { - - // Install callbacks on deferreds - for ( i in { success: 1, error: 1, complete: 1 } ) { - jXHR[ i ]( s[ i ] ); + jqXHR.readyState = 1; + // Send global event + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); + } + // Timeout + if ( s.async && s.timeout > 0 ) { + timeoutTimer = setTimeout( function(){ + jqXHR.abort( "timeout" ); + }, s.timeout ); } - // Get transport - transport = inspectPrefiltersOrTransports( transports, s, options, jXHR ); - - // If no transport, we auto-abort - if ( !transport ) { - done( -1, "No Transport" ); - } else { - // Set state as sending - state = jXHR.readyState = 1; - // Send global event - if ( s.global ) { - globalEventContext.trigger( "ajaxSend", [ jXHR, s ] ); - } - // Timeout - if ( s.async && s.timeout > 0 ) { - timeoutTimer = setTimeout( function(){ - jXHR.abort( "timeout" ); - }, s.timeout ); - } - - try { - transport.send( requestHeaders, done ); - } catch (e) { - // Propagate exception as error if not done - if ( status < 2 ) { - done( -1, e ); - // Simply rethrow otherwise - } else { - jQuery.error( e ); - } + try { + state = 1; + transport.send( requestHeaders, done ); + } catch (e) { + // Propagate exception as error if not done + if ( status < 2 ) { + done( -1, e ); + // Simply rethrow otherwise + } else { + jQuery.error( e ); } } } - return jXHR; + + return jqXHR; }, // Serialize an array of form elements or a set of @@ -6673,7 +6853,7 @@ jQuery.extend({ } // If an array was passed in, assume that it is an array of form elements. - if ( jQuery.isArray( a ) || a.jquery ) { + if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { // Serialize the form elements jQuery.each( a, function() { add( this.name, this.value ); @@ -6720,9 +6900,9 @@ function buildParams( prefix, obj, traditional, add ) { // Serialize object item. } else { - jQuery.each( obj, function( k, v ) { - buildParams( prefix + "[" + k + "]", v, traditional, add ); - }); + for ( var name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); + } } } else { @@ -6749,7 +6929,7 @@ jQuery.extend({ * - finds the right dataType (mediates between content-type and expected dataType) * - returns the corresponding response */ -function ajaxHandleResponses( s, jXHR, responses ) { +function ajaxHandleResponses( s, jqXHR, responses ) { var contents = s.contents, dataTypes = s.dataTypes, @@ -6762,7 +6942,7 @@ function ajaxHandleResponses( s, jXHR, responses ) { // Fill responseXXX fields for( type in responseFields ) { if ( type in responses ) { - jXHR[ responseFields[type] ] = responses[ type ]; + jqXHR[ responseFields[type] ] = responses[ type ]; } } @@ -6770,7 +6950,7 @@ function ajaxHandleResponses( s, jXHR, responses ) { while( dataTypes[ 0 ] === "*" ) { dataTypes.shift(); if ( ct === undefined ) { - ct = jXHR.getResponseHeader( "content-type" ); + ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); } } @@ -6822,8 +7002,9 @@ function ajaxConvert( s, response ) { } var dataTypes = s.dataTypes, - converters = s.converters, + converters = {}, i, + key, length = dataTypes.length, tmp, // Current and previous dataTypes @@ -6840,6 +7021,16 @@ function ajaxConvert( s, response ) { // For each dataType in the chain for( i = 1; i < length; i++ ) { + // Create converters map + // with lowercased keys + if ( i === 1 ) { + for( key in s.converters ) { + if( typeof key === "string" ) { + converters[ key.toLowerCase() ] = s.converters[ key ]; + } + } + } + // Get the dataTypes prev = current; current = dataTypes[ i ]; @@ -6891,7 +7082,7 @@ function ajaxConvert( s, response ) { var jsc = jQuery.now(), - jsre = /(\=)\?(&|$)|()\?\?()/i; + jsre = /(\=)\?(&|$)|\?\?/i; // Default jsonp settings jQuery.ajaxSetup({ @@ -6902,9 +7093,9 @@ jQuery.ajaxSetup({ }); // Detect, normalize options and install callbacks for jsonp requests -jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString /* internal */ ) { +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { - dataIsString = ( typeof s.data === "string" ); + var dataIsString = ( typeof s.data === "string" ); if ( s.dataTypes[ 0 ] === "jsonp" || originalSettings.jsonpCallback || @@ -6918,7 +7109,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString previous = window[ jsonpCallback ], url = s.url, data = s.data, - replace = "$1" + jsonpCallback + "$2"; + replace = "$1" + jsonpCallback + "$2", + cleanUp = function() { + // Set callback back to previous value + window[ jsonpCallback ] = previous; + // Call if it was a function and we have a response + if ( responseContainer && jQuery.isFunction( previous ) ) { + window[ jsonpCallback ]( responseContainer[ 0 ] ); + } + }; if ( s.jsonp !== false ) { url = url.replace( jsre, replace ); @@ -6936,32 +7135,17 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString s.url = url; s.data = data; + // Install callback window[ jsonpCallback ] = function( response ) { responseContainer = [ response ]; }; - s.complete = [ function() { - - // Set callback back to previous value - window[ jsonpCallback ] = previous; - - // Call if it was a function and we have a response - if ( previous) { - if ( responseContainer && jQuery.isFunction( previous ) ) { - window[ jsonpCallback ] ( responseContainer[ 0 ] ); - } - } else { - // else, more memory leak avoidance - try{ - delete window[ jsonpCallback ]; - } catch( e ) {} - } - - }, s.complete ]; + // Install cleanUp function + jqXHR.then( cleanUp, cleanUp ); // Use data converter to retrieve json after script execution s.converters["script json"] = function() { - if ( ! responseContainer ) { + if ( !responseContainer ) { jQuery.error( jsonpCallback + " was not called" ); } return responseContainer[ 0 ]; @@ -6981,10 +7165,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString // Install script dataType jQuery.ajaxSetup({ accepts: { - script: "text/javascript, application/javascript" + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" }, contents: { - script: /javascript/ + script: /javascript|ecmascript/ }, converters: { "text script": function( text ) { @@ -7012,7 +7196,7 @@ jQuery.ajaxTransport( "script", function(s) { if ( s.crossDomain ) { var script, - head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement; + head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; return { @@ -7067,18 +7251,36 @@ jQuery.ajaxTransport( "script", function(s) { -var // Next active xhr id +var // #5280: next active xhr id and list of active xhrs' callbacks xhrId = jQuery.now(), - - // active xhrs - xhrs = {}, - - // #5280: see below - xhrUnloadAbortInstalled, + xhrCallbacks, // XHR used to determine supports properties testXHR; +// #5280: Internet Explorer will keep connections alive if we don't abort on unload +function xhrOnUnloadAbort() { + jQuery( window ).unload(function() { + // Abort all pending requests + for ( var key in xhrCallbacks ) { + xhrCallbacks[ key ]( 0, 1 ); + } + }); +} + +// Functions to create xhrs +function createStandardXHR() { + try { + return new window.XMLHttpRequest(); + } catch( e ) {} +} + +function createActiveXHR() { + try { + return new window.ActiveXObject( "Microsoft.XMLHTTP" ); + } catch( e ) {} +} + // Create the request object // (This is still attached to ajaxSettings for backward compatibility) jQuery.ajaxSettings.xhr = window.ActiveXObject ? @@ -7089,27 +7291,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ? * we need a fallback. */ function() { - if ( window.location.protocol !== "file:" ) { - try { - return new window.XMLHttpRequest(); - } catch( xhrError ) {} - } - - try { - return new window.ActiveXObject("Microsoft.XMLHTTP"); - } catch( activeError ) {} + return !this.isLocal && createStandardXHR() || createActiveXHR(); } : // For all other browsers, use the standard XMLHttpRequest object - function() { - return new window.XMLHttpRequest(); - }; + createStandardXHR; // Test if we can create an xhr object -try { - testXHR = jQuery.ajaxSettings.xhr(); -} catch( xhrCreationException ) {} - -//Does this browser support XHR requests? +testXHR = jQuery.ajaxSettings.xhr(); jQuery.support.ajax = !!testXHR; // Does this browser support crossDomain XHR requests @@ -7130,26 +7318,10 @@ if ( jQuery.support.ajax ) { return { send: function( headers, complete ) { - // #5280: we need to abort on unload or IE will keep connections alive - if ( !xhrUnloadAbortInstalled ) { - - xhrUnloadAbortInstalled = 1; - - jQuery(window).bind( "unload", function() { - - // Abort all pending requests - jQuery.each( xhrs, function( _, xhr ) { - if ( xhr.onreadystatechange ) { - xhr.onreadystatechange( 1 ); - } - } ); - - } ); - } - // Get a new xhr var xhr = s.xhr(), - handle; + handle, + i; // Open the socket // Passing null username, generates a login popup on Opera (#2865) @@ -7159,19 +7331,32 @@ if ( jQuery.support.ajax ) { xhr.open( s.type, s.url, s.async ); } - // Requested-With header - // Not set for crossDomain requests with no content - // (see why at http://trac.dojotoolkit.org/ticket/9486) - // Won't change header if already provided - if ( !( s.crossDomain && !s.hasContent ) && !headers["x-requested-with"] ) { - headers[ "x-requested-with" ] = "XMLHttpRequest"; + // Apply custom fields if provided + if ( s.xhrFields ) { + for ( i in s.xhrFields ) { + xhr[ i ] = s.xhrFields[ i ]; + } + } + + // Override mime type if needed + if ( s.mimeType && xhr.overrideMimeType ) { + xhr.overrideMimeType( s.mimeType ); + } + + // X-Requested-With header + // For cross-domain requests, seeing as conditions for a preflight are + // akin to a jigsaw puzzle, we simply never set it to be sure. + // (it can always be set on a per-request basis or even using ajaxSetup) + // For same-domain requests, won't change header if already provided. + if ( !s.crossDomain && !headers["X-Requested-With"] ) { + headers[ "X-Requested-With" ] = "XMLHttpRequest"; } // Need an extra try/catch for cross domain requests in Firefox 3 try { - jQuery.each( headers, function( key, value ) { - xhr.setRequestHeader( key, value ); - } ); + for ( i in headers ) { + xhr.setRequestHeader( i, headers[ i ] ); + } } catch( _ ) {} // Do send the request @@ -7182,74 +7367,78 @@ if ( jQuery.support.ajax ) { // Listener callback = function( _, isAbort ) { - // Was never called and is aborted or complete - if ( callback && ( isAbort || xhr.readyState === 4 ) ) { + var status, + statusText, + responseHeaders, + responses, + xml; - // Only called once - callback = 0; + // Firefox throws exceptions when accessing properties + // of an xhr when a network error occured + // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) + try { - // Do not keep as active anymore - if ( handle ) { - xhr.onreadystatechange = jQuery.noop; - delete xhrs[ handle ]; - } + // Was never called and is aborted or complete + if ( callback && ( isAbort || xhr.readyState === 4 ) ) { - // If it's an abort - if ( isAbort ) { - // Abort it manually if needed - if ( xhr.readyState !== 4 ) { - xhr.abort(); + // Only called once + callback = undefined; + + // Do not keep as active anymore + if ( handle ) { + xhr.onreadystatechange = jQuery.noop; + delete xhrCallbacks[ handle ]; } - } else { - // Get info - var status = xhr.status, - statusText, - responseHeaders = xhr.getAllResponseHeaders(), - responses = {}, + + // If it's an abort + if ( isAbort ) { + // Abort it manually if needed + if ( xhr.readyState !== 4 ) { + xhr.abort(); + } + } else { + status = xhr.status; + responseHeaders = xhr.getAllResponseHeaders(); + responses = {}; xml = xhr.responseXML; - // Construct response list - if ( xml && xml.documentElement /* #4958 */ ) { - responses.xml = xml; + // Construct response list + if ( xml && xml.documentElement /* #4958 */ ) { + responses.xml = xml; + } + responses.text = xhr.responseText; + + // Firefox throws an exception when accessing + // statusText for faulty cross-domain requests + try { + statusText = xhr.statusText; + } catch( e ) { + // We normalize with Webkit giving an empty statusText + statusText = ""; + } + + // Filter status for non standard behaviors + + // If the request is local and we have data: assume a success + // (success with no data won't get notified, that's the best we + // can do given current implementations) + if ( !status && s.isLocal && !s.crossDomain ) { + status = responses.text ? 200 : 404; + // IE - #1450: sometimes returns 1223 when it should be 204 + } else if ( status === 1223 ) { + status = 204; + } } - responses.text = xhr.responseText; - - // Firefox throws an exception when accessing - // statusText for faulty cross-domain requests - try { - statusText = xhr.statusText; - } catch( e ) { - // We normalize with Webkit giving an empty statusText - statusText = ""; - } - - // Filter status for non standard behaviours - status = - // Opera returns 0 when it should be 304 - // Webkit returns 0 for failing cross-domain no matter the real status - status === 0 ? - ( - // Webkit, Firefox: filter out faulty cross-domain requests - !s.crossDomain || statusText ? - ( - // Opera: filter out real aborts #6060 - responseHeaders ? - 304 : - 0 - ) : - // We assume 302 but could be anything cross-domain related - 302 - ) : - ( - // IE sometimes returns 1223 when it should be 204 (see #1450) - status == 1223 ? - 204 : - status - ); - - // Call complete - complete( status, statusText, responses, responseHeaders ); } + } catch( firefoxAccessException ) { + if ( !isAbort ) { + complete( -1, firefoxAccessException ); + } + } + + // Call complete if needed + if ( responses ) { + complete( status, statusText, responses, responseHeaders ); } }; @@ -7259,10 +7448,15 @@ if ( jQuery.support.ajax ) { if ( !s.async || xhr.readyState === 4 ) { callback(); } else { - // Add to list of active xhrs + // Create the active xhrs callbacks list if needed + // and attach the unload handler + if ( !xhrCallbacks ) { + xhrCallbacks = {}; + xhrOnUnloadAbort(); + } + // Add to list of active xhrs callbacks handle = xhrId++; - xhrs[ handle ] = xhr; - xhr.onreadystatechange = callback; + xhr.onreadystatechange = xhrCallbacks[ handle ] = callback; } }, @@ -7464,11 +7658,11 @@ jQuery.fn.extend({ } else { var parts = rfxnum.exec(val), - start = e.cur() || 0; + start = e.cur(); if ( parts ) { var end = parseFloat( parts[2] ), - unit = parts[3] || "px"; + unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" ); // We need to compute starting value if ( unit !== "px" ) { @@ -7615,8 +7809,12 @@ jQuery.fx.prototype = { return this.elem[ this.prop ]; } - var r = parseFloat( jQuery.css( this.elem, this.prop ) ); - return r || 0; + var parsed, + r = jQuery.css( this.elem, this.prop ); + // Empty strings, null, undefined and "auto" are converted to 0, + // complex values such as "rotate(1rad)" are returned as is, + // simple values such as "10px" are parsed to Float. + return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed; }, // Start an animation from one number to another @@ -7627,7 +7825,7 @@ jQuery.fx.prototype = { this.startTime = jQuery.now(); this.start = from; this.end = to; - this.unit = unit || this.unit || "px"; + this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); this.now = this.start; this.pos = this.state = 0; @@ -7840,8 +8038,8 @@ if ( "getBoundingClientRect" in document.documentElement ) { win = getWindow(doc), clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, - scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ), - scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft), + scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop, + scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft, top = box.top + scrollTop - clientTop, left = box.left + scrollLeft - clientLeft; @@ -7954,7 +8152,6 @@ jQuery.offset = { this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); body.removeChild( container ); - body = container = innerDiv = checkDiv = table = td = null; jQuery.offset.initialize = jQuery.noop; }, @@ -7984,10 +8181,10 @@ jQuery.offset = { curOffset = curElem.offset(), curCSSTop = jQuery.css( elem, "top" ), curCSSLeft = jQuery.css( elem, "left" ), - calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), + calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1, props = {}, curPosition = {}, curTop, curLeft; - // need to be able to calculate position if either top or left is auto and position is absolute + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed if ( calculatePosition ) { curPosition = curElem.position(); } @@ -8078,7 +8275,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) { if ( win ) { win.scrollTo( !i ? val : jQuery(win).scrollLeft(), - i ? val : jQuery(win).scrollTop() + i ? val : jQuery(win).scrollTop() ); } else { @@ -8173,4 +8370,5 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { }); +window.jQuery = window.$ = jQuery; })(window); diff --git a/thirdparty/jquery-entwine/vendor/jquery-1.6.js b/thirdparty/jquery-entwine/vendor/jquery-1.6.js new file mode 100644 index 000000000..9a13ab960 --- /dev/null +++ b/thirdparty/jquery-entwine/vendor/jquery-1.6.js @@ -0,0 +1,8865 @@ +/*! + * jQuery JavaScript Library v1.6 + * 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 May 2 13:50:00 2011 -0400 + */ +(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 + // (both of which we optimize for) + 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+$/, + + // Check for digits + rdigit = /\d/, + + // 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.]+))?/, + + // 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.6", + + // 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.done( fn ); + + return this; + }, + + eq: function( 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.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery._Deferred(); + + // 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; + }, + + isNaN: function( obj ) { + return obj == null || !rdigit.test( obj ) || isNaN( 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; + } + + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + 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 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 + // (xml & tmp used internally) + parseXML: function( data , xml , tmp ) { + + 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 ); + } + + tmp = xml.documentElement; + + if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) { + 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 ); + } + }, + + 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' + // The extra typeof function check is to prevent crashes + // in Safari 2 (See: #3039) + // 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 ) { + + if ( indexOf ) { + return indexOf.call( array, elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( 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 be optionally by executed if its 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(); +} + +// Expose jQuery to the global object +return jQuery; + +})(); + + +var // Promise methods + promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ), + // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + // Create a simple deferred (one callbacks list) + _Deferred: function() { + var // callbacks list + callbacks = [], + // stored [ context , args ] + fired, + // to avoid firing when already doing so + firing, + // flag to know if the deferred has been cancelled + cancelled, + // the deferred itself + deferred = { + + // done( f1, f2, ...) + done: function() { + if ( !cancelled ) { + var args = arguments, + i, + length, + elem, + type, + _fired; + if ( fired ) { + _fired = fired; + fired = 0; + } + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + deferred.done.apply( deferred, elem ); + } else if ( type === "function" ) { + callbacks.push( elem ); + } + } + if ( _fired ) { + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); + } + } + return this; + }, + + // resolve with given context and args + resolveWith: function( context, args ) { + if ( !cancelled && !fired && !firing ) { + // make sure args are available (#8421) + args = args || []; + firing = 1; + try { + while( callbacks[ 0 ] ) { + callbacks.shift().apply( context, args ); + } + } + finally { + fired = [ context, args ]; + firing = 0; + } + } + return this; + }, + + // resolve with this as context and given arguments + resolve: function() { + deferred.resolveWith( this, arguments ); + return this; + }, + + // Has this deferred been resolved? + isResolved: function() { + return !!( firing || fired ); + }, + + // Cancel + cancel: function() { + cancelled = 1; + callbacks = []; + return this; + } + }; + + return deferred; + }, + + // Full fledged deferred (two callbacks list) + Deferred: function( func ) { + var deferred = jQuery._Deferred(), + failDeferred = jQuery._Deferred(), + promise; + // Add errorDeferred methods, then and promise + jQuery.extend( deferred, { + then: function( doneCallbacks, failCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ); + return this; + }, + always: function() { + return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments ); + }, + fail: failDeferred.done, + rejectWith: failDeferred.resolveWith, + reject: failDeferred.resolve, + isRejected: failDeferred.isResolved, + pipe: function( fnDone, fnFail ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject ); + } else { + newDefer[ action ]( 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 ) { + if ( promise ) { + return promise; + } + promise = obj = {}; + } + var i = promiseMethods.length; + while( i-- ) { + obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; + } + return obj; + } + }); + // Make sure only one callback list will be used + deferred.done( failDeferred.cancel ).fail( deferred.cancel ); + // Unexpose cancel + delete deferred.cancel; + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = arguments, + i = 0, + length = args.length, + count = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + // Strange bug in FF4: + // Values changed onto the arguments object sometimes end up as undefined values + // outside the $.when method. Cloning the object into a fresh array solves the issue + deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); + } + }; + } + if ( length > 1 ) { + for( ; i < length; i++ ) { + if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return deferred.promise(); + } +}); + + + +jQuery.support = (function() { + + var div = document.createElement( "div" ), + all, + a, + select, + opt, + input, + marginDiv, + support, + fragment, + body, + bodyStyle, + tds, + events, + eventName, + i, + isSupported; + + // 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", + + // 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 click() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + div.detachEvent( "onclick", click ); + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains it's 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.firstChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + div.innerHTML = ""; + + // Figure out if the W3C box model works as expected + div.style.width = div.style.paddingLeft = "1px"; + + // We use our own, invisible, body + body = document.createElement( "body" ); + bodyStyle = { + visibility: "hidden", + width: 0, + height: 0, + border: 0, + margin: 0, + // Set background to avoid IE crashes when removing (#9028) + background: "none" + }; + for ( i in bodyStyle ) { + body.style[ i ] = bodyStyle[ i ]; + } + body.appendChild( div ); + document.documentElement.appendChild( body ); + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + support.boxModel = div.offsetWidth === 2; + + if ( "zoom" in div.style ) { + // 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.innerHTML = "
    t
    "; + tds = div.getElementsByTagName( "td" ); + + // 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) + 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 ); + 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 ( document.defaultView && document.defaultView.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0; + } + + // Remove the body element we added + body.innerHTML = ""; + document.documentElement.removeChild( body ); + + // Technique from Juriy Zaytsev + // http://thinkweb2.com/projects/prototype/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; + } + } + + return support; +})(); + +// Keep track of boxModel +jQuery.boxModel = jQuery.support.boxModel; + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([a-z])([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 internalKey = jQuery.expando, getByName = typeof name === "string", thisCache, + + // 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[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; + + // 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 || (pvt && id && !cache[ id ][ internalKey ])) && 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[ jQuery.expando ] = id = ++jQuery.uuid; + } else { + id = jQuery.expando; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // TODO: This is a hack for 1.5 ONLY. 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 ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); + } else { + cache[ id ] = jQuery.extend(cache[ id ], name); + } + } + + thisCache = cache[ id ]; + + // Internal jQuery data is stored in a separate object inside the object's data + // cache in order to avoid key collisions between internal data and user-defined + // data + if ( pvt ) { + if ( !thisCache[ internalKey ] ) { + thisCache[ internalKey ] = {}; + } + + thisCache = thisCache[ internalKey ]; + } + + if ( data !== undefined ) { + thisCache[ name ] = data; + } + + // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should + // not attempt to inspect the internal events object using jQuery.data, as this + // internal data object is undocumented and subject to change. + if ( name === "events" && !thisCache[name] ) { + return thisCache[ internalKey ] && thisCache[ internalKey ].events; + } + + return getByName ? thisCache[ name ] : thisCache; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var 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[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; + + if ( thisCache ) { + delete thisCache[ name ]; + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !isEmptyDataObject(thisCache) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( pvt ) { + delete cache[ id ][ internalKey ]; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + var internalCache = cache[ id ][ internalKey ]; + + // 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 + if ( jQuery.support.deleteExpando || cache != window ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the entire user cache at once because it's faster than + // iterating through each key, but we need to continue to persist internal + // data if it existed + if ( internalCache ) { + cache[ id ] = {}; + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery + // metadata on plain JS objects when the object is serialized using + // JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + + cache[ id ][ internalKey ] = internalCache; + + // Otherwise, we need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + } else 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[ jQuery.expando ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( jQuery.expando ); + } else { + elem[ jQuery.expando ] = 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 data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 ) { + var attr = this[0].attributes, name; + 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 ] ); + } + } + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + var 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 $this = jQuery( this ), + args = [ parts[0], value ]; + + $this.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + $this.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 ) { + name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + !jQuery.isNaN( 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; +} + +// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON +// property to be considered empty objects; this property always exists in +// order to make sure JSON.stringify does not expose internal metadata +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + 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, undefined, true ); + if ( defer && + ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && + ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { + // 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, undefined, true ) && + !jQuery.data( elem, markDataKey, undefined, true ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.resolve(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = (type || "fx") + "mark"; + jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true ); + } + }, + + _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, undefined, true) || 1 ) - 1 ); + if ( count ) { + jQuery.data( elem, key, count, true ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + if ( elem ) { + type = (type || "fx") + "queue"; + var q = jQuery.data( elem, type, undefined, true ); + // 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), true ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + defer; + + // 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"); + } + + fn.call(elem, function() { + jQuery.dequeue(elem, type); + }); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue", 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() { + var elem = this; + setTimeout(function() { + jQuery.dequeue( elem, type ); + }, time ); + }); + }, + 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"; + 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._Deferred(), true ) )) { + count++; + tmp.done( 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, + rspecial = /^(?:data-|aria-)/, + rinvalidChar = /\:/, + formHook; + +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 ) { + 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 ) { + if ( jQuery.isFunction( value ) ) { + return this.each(function(i) { + var self = jQuery(this); + self.addClass( value.call(this, i, self.attr("class") || "") ); + }); + } + + if ( value && typeof value === "string" ) { + var classNames = (value || "").split( rspace ); + + for ( var i = 0, l = this.length; i < l; i++ ) { + var elem = this[i]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className ) { + elem.className = value; + + } else { + var className = " " + elem.className + " ", + setClass = elem.className; + + for ( var c = 0, cl = classNames.length; c < cl; c++ ) { + if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { + setClass += " " + classNames[c]; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + if ( jQuery.isFunction(value) ) { + return this.each(function(i) { + var self = jQuery(this); + self.removeClass( value.call(this, i, self.attr("class")) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + var classNames = (value || "").split( rspace ); + + for ( var i = 0, l = this.length; i < l; i++ ) { + var elem = this[i]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + var className = (" " + elem.className + " ").replace(rclass, " "); + for ( var 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) { + var self = jQuery(this); + self.toggleClass( value.call(this, i, self.attr("class"), 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 + " "; + for ( var i = 0, l = this.length; i < l; i++ ) { + if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, + 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; + } + + return (elem.value || "").replace(rreturn, ""); + } + + return undefined; + } + + var 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 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 + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var 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 + }, + + attrFix: { + // Always normalize to ensure hook usage + tabindex: "tabIndex", + readonly: "readOnly" + }, + + attr: function( elem, name, value, pass ) { + var nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + var ret, hooks, + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // Normalize the name if needed + name = notxml && jQuery.attrFix[ name ] || name; + + // Get the appropriate hook, or the formHook + // if getSetAttribute is not supported and we have form objects in IE6/7 + hooks = jQuery.attrHooks[ name ] || + ( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ? + formHook : + undefined ); + + if ( value !== undefined ) { + + if ( value === null || (value === false && !rspecial.test( name )) ) { + jQuery.removeAttr( elem, name ); + return undefined; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + + // Set boolean attributes to the same name + if ( value === true && !rspecial.test( name ) ) { + value = name; + } + + elem.setAttribute( name, "" + value ); + return value; + } + + } else { + + if ( hooks && "get" in hooks && notxml ) { + return hooks.get( elem, name ); + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + } + }, + + removeAttr: function( elem, name ) { + if ( elem.nodeType === 1 ) { + name = jQuery.attrFix[ name ] || name; + + if ( jQuery.support.getSetAttribute ) { + // Use removeAttribute in browsers that support it + elem.removeAttribute( name ); + } else { + jQuery.attr( elem, name, "" ); + elem.removeAttributeNode( elem.getAttributeNode( name ) ); + } + } + }, + + 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.getAttribute("value"); + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + 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; + } + } + }, + + propFix: {}, + + prop: function( elem, name, value ) { + var nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + var ret, hooks, + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // Try to normalize/fix the name + name = notxml && 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 )) !== undefined ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: {} +}); + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !jQuery.support.getSetAttribute ) { + jQuery.attrFix = jQuery.extend( jQuery.attrFix, { + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder" + }); + + // Use this for any attribute on a form in IE6/7 + formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + if ( name === "value" && !jQuery.nodeName( elem, "button" ) ) { + return elem.getAttribute( name ); + } + ret = elem.getAttributeNode( name ); + // Return undefined if not specified instead of empty string + return ret && ret.specified ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Check form objects in IE (multiple bugs related) + // Only use nodeValue if the attribute node exists on the form + var ret = elem.getAttributeNode( name ); + if ( ret ) { + ret.nodeValue = value; + return value; + } + } + }; + + // 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; + } + } + }); + }); +} + + +// 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; + } + } + } + }); +} + +// 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 hasOwn = Object.prototype.hasOwnProperty, + rnamespaces = /\.(.*)$/, + rformElems = /^(?:textarea|input|select)$/i, + rperiod = /\./g, + rspaces = / /g, + rescape = /[^\w\s.|`]/g, + fcleanup = function( nm ) { + return nm.replace(rescape, "\\$&"); + }; + +/* + * A number of helper functions used for managing events. + * Many of the ideas behind this code originated from + * Dean Edwards' addEvent library. + */ +jQuery.event = { + + // Bind an event to an element + // Original by Dean Edwards + add: function( elem, types, handler, data ) { + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + if ( handler === false ) { + handler = returnFalse; + } else if ( !handler ) { + // Fixes bug #7229. Fix recommended by jdalton + return; + } + + var handleObjIn, handleObj; + + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the function being executed has a unique ID + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure + var elemData = jQuery._data( elem ); + + // If no elemData is found then we must be trying to bind to one of the + // banned noData elements + if ( !elemData ) { + return; + } + + var events = elemData.events, + eventHandle = elemData.handle; + + if ( !events ) { + elemData.events = events = {}; + } + + 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.handle.apply( eventHandle.elem, arguments ) : + undefined; + }; + } + + // Add elem as a property of the handle function + // This is to prevent a memory leak with non-native events in IE. + eventHandle.elem = elem; + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = types.split(" "); + + var type, i = 0, namespaces; + + while ( (type = types[ i++ ]) ) { + handleObj = handleObjIn ? + jQuery.extend({}, handleObjIn) : + { handler: handler, data: data }; + + // Namespaced event handlers + if ( type.indexOf(".") > -1 ) { + namespaces = type.split("."); + type = namespaces.shift(); + handleObj.namespace = namespaces.slice(0).sort().join("."); + + } else { + namespaces = []; + handleObj.namespace = ""; + } + + handleObj.type = type; + if ( !handleObj.guid ) { + handleObj.guid = handler.guid; + } + + // Get the current list of functions bound to this event + var handlers = events[ type ], + special = jQuery.event.special[ type ] || {}; + + // Init the event handler queue + if ( !handlers ) { + handlers = events[ type ] = []; + + // Check for a special event handler + // 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 the function to the element's handler list + handlers.push( handleObj ); + + // Keep track of which events have 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, pos ) { + // don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + if ( handler === false ) { + handler = returnFalse; + } + + var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, + elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + events = elemData && elemData.events; + + if ( !elemData || !events ) { + return; + } + + // types is actually an event object here + if ( types && types.type ) { + handler = types.handler; + types = types.type; + } + + // Unbind all events for the element + if ( !types || typeof types === "string" && types.charAt(0) === "." ) { + types = types || ""; + + for ( type in events ) { + jQuery.event.remove( elem, type + types ); + } + + return; + } + + // Handle multiple events separated by a space + // jQuery(...).unbind("mouseover mouseout", fn); + types = types.split(" "); + + while ( (type = types[ i++ ]) ) { + origType = type; + handleObj = null; + all = type.indexOf(".") < 0; + namespaces = []; + + if ( !all ) { + // Namespaced event handlers + namespaces = type.split("."); + type = namespaces.shift(); + + namespace = new RegExp("(^|\\.)" + + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + eventType = events[ type ]; + + if ( !eventType ) { + continue; + } + + if ( !handler ) { + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( all || namespace.test( handleObj.namespace ) ) { + jQuery.event.remove( elem, origType, handleObj.handler, j ); + eventType.splice( j--, 1 ); + } + } + + continue; + } + + special = jQuery.event.special[ type ] || {}; + + for ( j = pos || 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( handler.guid === handleObj.guid ) { + // remove the given handler for the given type + if ( all || namespace.test( handleObj.namespace ) ) { + if ( pos == null ) { + eventType.splice( j--, 1 ); + } + + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + + if ( pos != null ) { + break; + } + } + } + + // remove generic event handler if no more handlers exist + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + ret = null; + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + var handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + delete elemData.events; + delete elemData.handle; + + if ( jQuery.isEmptyObject( elemData ) ) { + jQuery.removeData( elem, undefined, 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 ) { + // Event object or event type + var type = event.type || event, + namespaces = [], + exclusive; + + 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.exclusive = exclusive; + event.namespace = namespaces.join("."); + event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); + + // triggerHandler() and global events don't bubble or run the default action + if ( onlyHandlers || !elem ) { + event.preventDefault(); + event.stopPropagation(); + } + + // Handle a global trigger + if ( !elem ) { + // TODO: Stop taunting the data cache; remove global events and always attach to document + jQuery.each( jQuery.cache, function() { + // internalKey variable is just used to make it easier to find + // and potentially change this stuff later; currently it just + // points to jQuery.expando + var internalKey = jQuery.expando, + internalCache = this[ internalKey ]; + if ( internalCache && internalCache.events && internalCache.events[ type ] ) { + jQuery.event.trigger( event, data, internalCache.handle.elem ); + } + }); + return; + } + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + event.target = elem; + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + var cur = elem, + // IE doesn't like method names with a colon (#3533, #8272) + ontype = type.indexOf(":") < 0 ? "on" + type : ""; + + // Fire event on the current element, then bubble up the DOM tree + do { + var handle = jQuery._data( cur, "handle" ); + + event.currentTarget = cur; + if ( handle ) { + handle.apply( cur, data ); + } + + // Trigger an inline bound script + if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { + event.result = false; + event.preventDefault(); + } + + // Bubble up to document, then to window + cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window; + } while ( cur && !event.isPropagationStopped() ); + + // If nobody prevented the default action, do it now + if ( !event.isDefaultPrevented() ) { + var old, + special = jQuery.event.special[ type ] || {}; + + if ( (!special._default || special._default.call( elem.ownerDocument, event ) === 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. + // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch. + try { + if ( ontype && elem[ type ] ) { + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + jQuery.event.triggered = type; + elem[ type ](); + } + } catch ( ieError ) {} + + if ( old ) { + elem[ ontype ] = old; + } + + jQuery.event.triggered = undefined; + } + } + + return event.result; + }, + + handle: function( event ) { + event = jQuery.event.fix( event || window.event ); + // Snapshot the handlers list since a called handler may add/remove events. + var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), + run_all = !event.exclusive && !event.namespace, + args = Array.prototype.slice.call( arguments, 0 ); + + // Use the fix-ed Event rather than the (read-only) native event + args[0] = event; + event.currentTarget = this; + + for ( var j = 0, l = handlers.length; j < l; j++ ) { + var handleObj = handlers[ j ]; + + // Triggered event must 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event. + if ( run_all || event.namespace_re.test( handleObj.namespace ) ) { + // Pass in a reference to the handler function itself + // So that we can later remove it + event.handler = handleObj.handler; + event.data = handleObj.data; + event.handleObj = handleObj; + + var ret = handleObj.handler.apply( this, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + return event.result; + }, + + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // store a copy of the original event object + // and "clone" to set read-only properties + var originalEvent = event; + event = jQuery.Event( originalEvent ); + + for ( var i = this.props.length, prop; i; ) { + prop = this.props[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary + if ( !event.target ) { + // Fixes #1925 where srcElement might not be defined either + event.target = event.srcElement || document; + } + + // check if target is a textnode (safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && event.fromElement ) { + event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; + } + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && event.clientX != null ) { + var eventDocument = event.target.ownerDocument || document, + doc = eventDocument.documentElement, + body = eventDocument.body; + + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); + } + + // Add which for key events + if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { + event.which = event.charCode != null ? event.charCode : event.keyCode; + } + + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) + if ( !event.metaKey && event.ctrlKey ) { + event.metaKey = event.ctrlKey; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && event.button !== undefined ) { + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); + } + + return event; + }, + + // Deprecated, use jQuery.guid instead + guid: 1E8, + + // Deprecated, use jQuery.proxy instead + proxy: jQuery.proxy, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady, + teardown: jQuery.noop + }, + + live: { + add: function( handleObj ) { + jQuery.event.add( this, + liveConvert( handleObj.origType, handleObj.selector ), + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); + }, + + remove: function( handleObj ) { + jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); + } + }, + + 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; + } + } + } + } +}; + +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.preventDefault ) { + 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 ); + } + + // timeStamp is buggy for some events on Firefox(#3843) + // So we won't rely on the native value + this.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 +}; + +// Checks if an event happened on an element within another element +// Used in jQuery.event.special.mouseenter and mouseleave handlers +var withinElement = function( event ) { + // Check if mouse(over|out) are still within the same parent element + var parent = event.relatedTarget; + + // Firefox sometimes assigns relatedTarget a XUL element + // which we cannot access the parentNode property of + try { + + // Chrome does something similar, the parentNode property + // can be accessed but is null. + if ( parent && parent !== document && !parent.parentNode ) { + return; + } + // Traverse up the tree + while ( parent && parent !== this ) { + parent = parent.parentNode; + } + + if ( parent !== this ) { + // set the correct event type + event.type = event.data; + + // handle event if we actually just moused on to a non sub-element + jQuery.event.handle.apply( this, arguments ); + } + + // assuming we've left the element since we most likely mousedover a xul element + } catch(e) { } +}, + +// In case of event delegation, we only need to rename the event.type, +// liveHandler will take care of the rest. +delegate = function( event ) { + event.type = event.data; + jQuery.event.handle.apply( this, arguments ); +}; + +// Create mouseenter and mouseleave events +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + setup: function( data ) { + jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); + }, + teardown: function( data ) { + jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); + } + }; +}); + +// submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function( data, namespaces ) { + if ( !jQuery.nodeName( this, "form" ) ) { + jQuery.event.add(this, "click.specialSubmit", function( e ) { + var elem = e.target, + type = elem.type; + + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { + trigger( "submit", this, arguments ); + } + }); + + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { + var elem = e.target, + type = elem.type; + + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { + trigger( "submit", this, arguments ); + } + }); + + } else { + return false; + } + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialSubmit" ); + } + }; + +} + +// change delegation, happens here so we have bind. +if ( !jQuery.support.changeBubbles ) { + + var changeFilters, + + getVal = function( elem ) { + var type = elem.type, val = elem.value; + + if ( type === "radio" || type === "checkbox" ) { + val = elem.checked; + + } else if ( type === "select-multiple" ) { + val = elem.selectedIndex > -1 ? + jQuery.map( elem.options, function( elem ) { + return elem.selected; + }).join("-") : + ""; + + } else if ( jQuery.nodeName( elem, "select" ) ) { + val = elem.selectedIndex; + } + + return val; + }, + + testChange = function testChange( e ) { + var elem = e.target, data, val; + + if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { + return; + } + + data = jQuery._data( elem, "_change_data" ); + val = getVal(elem); + + // the current data will be also retrieved by beforeactivate + if ( e.type !== "focusout" || elem.type !== "radio" ) { + jQuery._data( elem, "_change_data", val ); + } + + if ( data === undefined || val === data ) { + return; + } + + if ( data != null || val ) { + e.type = "change"; + e.liveFired = undefined; + jQuery.event.trigger( e, arguments[1], elem ); + } + }; + + jQuery.event.special.change = { + filters: { + focusout: testChange, + + beforedeactivate: testChange, + + click: function( e ) { + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { + testChange.call( this, e ); + } + }, + + // Change has to be called before submit + // Keydown will be called before keypress, which is used in submit-event delegation + keydown: function( e ) { + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || + type === "select-multiple" ) { + testChange.call( this, e ); + } + }, + + // Beforeactivate happens also before the previous element is blurred + // with this event you can't trigger a change event, but you can store + // information + beforeactivate: function( e ) { + var elem = e.target; + jQuery._data( elem, "_change_data", getVal(elem) ); + } + }, + + setup: function( data, namespaces ) { + if ( this.type === "file" ) { + return false; + } + + for ( var type in changeFilters ) { + jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); + } + + return rformElems.test( this.nodeName ); + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialChange" ); + + return rformElems.test( this.nodeName ); + } + }; + + changeFilters = jQuery.event.special.change.filters; + + // Handle when the input is .focus()'d + changeFilters.focus = changeFilters.beforeactivate; +} + +function trigger( type, elem, args ) { + // 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. + // Don't pass args or remember liveFired; they apply to the donor event. + var event = jQuery.extend( {}, args[ 0 ] ); + event.type = type; + event.originalEvent = {}; + event.liveFired = undefined; + jQuery.event.handle.call( elem, event ); + if ( event.isDefaultPrevented() ) { + args[ 0 ].preventDefault(); + } +} + +// 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; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + + function handler( donor ) { + // Donor event is always a native one; fix it and switch its type. + // Let focusin/out handler cancel the donor focus/blur event. + var e = jQuery.event.fix( donor ); + e.type = fix; + e.originalEvent = {}; + jQuery.event.trigger( e, null, e.target ); + if ( e.isDefaultPrevented() ) { + donor.preventDefault(); + } + } + }); +} + +jQuery.each(["bind", "one"], function( i, name ) { + jQuery.fn[ name ] = function( type, data, fn ) { + var handler; + + // Handle object literals + if ( typeof type === "object" ) { + for ( var key in type ) { + this[ name ](key, data, type[key], fn); + } + return this; + } + + if ( arguments.length === 2 || data === false ) { + fn = data; + data = undefined; + } + + if ( name === "one" ) { + handler = function( event ) { + jQuery( this ).unbind( event, handler ); + return fn.apply( this, arguments ); + }; + handler.guid = fn.guid || jQuery.guid++; + } else { + handler = fn; + } + + if ( type === "unload" && name !== "one" ) { + this.one( type, data, fn ); + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.add( this[i], type, handler, data ); + } + } + + return this; + }; +}); + +jQuery.fn.extend({ + unbind: function( type, fn ) { + // Handle object literals + if ( typeof type === "object" && !type.preventDefault ) { + for ( var key in type ) { + this.unbind(key, type[key]); + } + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.remove( this[i], type, fn ); + } + } + + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.live( types, data, fn, selector ); + }, + + undelegate: function( selector, types, fn ) { + if ( arguments.length === 0 ) { + return this.unbind( "live" ); + + } else { + return this.die( types, null, fn, selector ); + } + }, + + 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 ); + } +}); + +var liveMap = { + focus: "focusin", + blur: "focusout", + mouseenter: "mouseover", + mouseleave: "mouseout" +}; + +jQuery.each(["live", "die"], function( i, name ) { + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { + var type, i = 0, match, namespaces, preType, + selector = origSelector || this.selector, + context = origSelector ? this : jQuery( this.context ); + + if ( typeof types === "object" && !types.preventDefault ) { + for ( var key in types ) { + context[ name ]( key, data, types[key], selector ); + } + + return this; + } + + if ( name === "die" && !types && + origSelector && origSelector.charAt(0) === "." ) { + + context.unbind( origSelector ); + + return this; + } + + if ( data === false || jQuery.isFunction( data ) ) { + fn = data || returnFalse; + data = undefined; + } + + types = (types || "").split(" "); + + while ( (type = types[ i++ ]) != null ) { + match = rnamespaces.exec( type ); + namespaces = ""; + + if ( match ) { + namespaces = match[0]; + type = type.replace( rnamespaces, "" ); + } + + if ( type === "hover" ) { + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); + continue; + } + + preType = type; + + if ( liveMap[ type ] ) { + types.push( liveMap[ type ] + namespaces ); + type = type + namespaces; + + } else { + type = (liveMap[ type ] || type) + namespaces; + } + + if ( name === "live" ) { + // bind live handler + for ( var j = 0, l = context.length; j < l; j++ ) { + jQuery.event.add( context[j], "live." + liveConvert( type, selector ), + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); + } + + } else { + // unbind live handler + context.unbind( "live." + liveConvert( type, selector ), fn ); + } + } + + return this; + }; +}); + +function liveHandler( event ) { + var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, + elems = [], + selectors = [], + events = jQuery._data( this, "events" ); + + // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) + if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { + return; + } + + if ( event.namespace ) { + namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + event.liveFired = this; + + var live = events.live.slice(0); + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { + selectors.push( handleObj.selector ); + + } else { + live.splice( j--, 1 ); + } + } + + match = jQuery( event.target ).closest( selectors, event.currentTarget ); + + for ( i = 0, l = match.length; i < l; i++ ) { + close = match[i]; + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { + elem = close.elem; + related = null; + + // Those two events require additional checking + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { + event.type = handleObj.preType; + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; + + // Make sure not to accidentally match a child element with the same selector + if ( related && jQuery.contains( elem, related ) ) { + related = elem; + } + } + + if ( !related || related !== elem ) { + elems.push({ elem: elem, handleObj: handleObj, level: close.level }); + } + } + } + } + + for ( i = 0, l = elems.length; i < l; i++ ) { + match = elems[i]; + + if ( maxLevel && match.level > maxLevel ) { + break; + } + + event.currentTarget = match.elem; + event.data = match.handleObj.data; + event.handleObj = match.handleObj; + + ret = match.handleObj.origHandler.apply( match.elem, arguments ); + + if ( ret === false || event.isPropagationStopped() ) { + maxLevel = match.level; + + if ( ret === false ) { + stop = false; + } + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + + return stop; +} + +function liveConvert( type, selector ) { + return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&"); +} + +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").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.bind( name, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } +}); + + + +/*! + * 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, + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/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 ); + + } 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 ); + } + } + + } 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; + + if ( !expr ) { + return []; + } + + for ( var i = 0, l = Expr.order.length; i < l; i++ ) { + var match, + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + var 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, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( var type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + var found, item, + 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 ( var i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + var 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 "Syntax error, unrecognized expression: " + msg; +}; + +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 ) { + return elem.nodeName.toLowerCase() === "input" && "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 || Sizzle.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 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": + var first = match[2], + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + var doneName = match[0], + parent = elem.parentNode; + + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { + var count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent.sizcache = doneName; + } + + var 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.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = 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 === "=" ? + 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 ) { + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // If the nodes are siblings (or identical) we can do a quick check + } else 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; + }; +} + +// Utility function for retreiving the text value of an array of DOM nodes +Sizzle.getText = function( elems ) { + var ret = "", elem; + + for ( var i = 0; elems[i]; i++ ) { + elem = elems[i]; + + // Get the text from text nodes and CDATA nodes + if ( elem.nodeType === 3 || elem.nodeType === 4 ) { + ret += elem.nodeValue; + + // Traverse everything else, except comment nodes + } else if ( elem.nodeType !== 8 ) { + ret += Sizzle.getText( elem.childNodes ); + } + } + + return ret; +}; + +// 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.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem.sizcache = 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.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem.sizcache = 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 ) { + 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 ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +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" ? + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array + if ( jQuery.isArray( selectors ) ) { + var match, selector, + matches = {}, + level = 1; + + if ( cur && selectors.length ) { + for ( i = 0, l = selectors.length; i < l; i++ ) { + selector = selectors[i]; + + if ( !matches[ selector ] ) { + matches[ selector ] = POS.test( selector ) ? + jQuery( selector, context || this.context ) : + selector; + } + } + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( selector in matches ) { + match = matches[ selector ]; + + if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) { + ret.push({ selector: selector, 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 ) { + if ( !elem || typeof elem === "string" ) { + return jQuery.inArray( this[0], + // If it receives a string, the selector is used + // If it receives nothing, the siblings are used + elem ? jQuery( elem ) : this.parent().children() ); + } + // 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 ), + // The variable 'args' was introduced in + // https://github.com/jquery/jquery/commit/52a0238 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. + // http://code.google.com/p/v8/issues/detail?id=1050 + args = slice.call(arguments); + + 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, args.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; + }); +} + + + + +var 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, "", "" ] + }; + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and