├── LICENSE.txt
├── bower.json
├── package.json
├── CONTRIBUTING.md
├── jquery.dynatable.css
├── README.md
├── PROPRIETARY_LICENSE.html
├── jquery.dynatable.js
└── vendor
└── jquery-1.7.2.min.js
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Dynatable: A funner, semantic, HTML5+JSON, interactive table plugin.
2 | Copyright (C) 2013 Steve Schwartz
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Affero General Public License as
6 | published by the Free Software Foundation, either version 3 of the
7 | License, or (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Affero General Public License for more details.
13 |
14 | You should have received a copy of the GNU Affero General Public License
15 | along with this program. If not, see http://www.gnu.org/licenses/.
16 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dynatable",
3 | "description": "A funner, semantic, HTML5+JSON, interactive table plugin.",
4 | "version": "0.3.1",
5 | "keywords": [
6 | "table",
7 | "datatables",
8 | "dynamic"
9 | ],
10 | "authors": [
11 | {
12 | "name": "Steve Schwartz",
13 | "email": "steve@alfajango.com",
14 | "homepage": "http://www.alfajango.com/blog"
15 | }
16 | ],
17 | "dependencies": {
18 | "jquery": ">=1.6"
19 | },
20 | "main": "jquery.dynatable.js",
21 | "repository" : [
22 | {
23 | "type": "git",
24 | "url": "https://github.com/alfajango/jquery-dynatable.git"
25 | }
26 | ],
27 | "license": [
28 | {
29 | "name": "AGPL",
30 | "url": "http://www.dynatable.com/license"
31 | },
32 | {
33 | "name": "Proprietary License",
34 | "url": "http://www.dynatable.com/license"
35 | }
36 | ],
37 | "homepage": "http://www.dynatable.com",
38 | "ignore": [
39 | "**/.*",
40 | "CONTRIBUTING.md",
41 | "node_modules",
42 | "vendor",
43 | "test",
44 | "tests"
45 | ]
46 | }
47 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Dynatable",
3 | "description": "A funner, semantic, HTML5+JSON, interactive table plugin.",
4 | "version": "0.3.1",
5 | "keywords": [
6 | "table",
7 | "datatables",
8 | "dynamic table"
9 | ],
10 | "maintainers": [
11 | {
12 | "name": "Steve Schwartz",
13 | "email": "steve@alfajango.com",
14 | "web": "http://www.alfajango.com/blog"
15 | }
16 | ],
17 | "contributors": [
18 | {
19 | "name": "Steve Schwartz",
20 | "email": "steve@alfajango.com",
21 | "web": "http://www.alfajango.com/blog"
22 | }
23 | ],
24 | "dependencies": {
25 | "jquery": "1.6"
26 | },
27 | "bugs": {
28 | "mail": "support@alfajango.com",
29 | "web": "https://github.com/alfajango/jquery-dynatable/issues"
30 | },
31 | "repositories" : [
32 | {
33 | "type": "git",
34 | "url": "https://github.com/alfajango/jquery-dynatable.git"
35 | }
36 | ],
37 | "licenses": [
38 | {
39 | "name": "AGPL",
40 | "url": "http://www.dynatable.com/license"
41 | },
42 | {
43 | "name": "Proprietary License",
44 | "url": "http://www.dynatable.com/license"
45 | }
46 | ],
47 | "homepage": "http://www.dynatable.com"
48 | }
49 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Dynatable is released under the Free Software Foundation's
4 | GNU Affero General Public License (AGPL).
5 |
6 | Contributors agree that any contributions are owned by the copyright holder
7 | and that contributors have absolutely no rights to their contributions.
8 |
9 | To get started, [sign the Contributor License
10 | Agreement](https://www.clahub.com/agreements/alfajango/jquery-dynatable).
11 |
12 | ## Tests
13 |
14 | Currently the testing process consists of opening [the Dynatable
15 | documentation](http://os.alfajango.com/dynatable)
16 | ([source code
17 | here](https://github.com/alfajango/alfajango.github.com/blob/master/_posts/2012-01-09-dynatable.md)) in
18 | each browser and making sure every example works. This is fine for the
19 | initial release, since it serves the dual purpose of helping us write
20 | the documentation and having a written functional use-case at once.
21 | However, one of the top priorities now is to automate each use-case in
22 | the docs as a test case within an automated test suite.
23 |
24 | If anyone out there thinks this sounds like fun, please contact me or
25 | even go ahead and create an issue/pull request. Otherwise, it will be at
26 | teh top of my priority list until I can get to it.
27 |
--------------------------------------------------------------------------------
/jquery.dynatable.css:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery Dynatable plugin 0.3.1
3 | *
4 | * Copyright (c) 2014 Steve Schwartz (JangoSteve)
5 | *
6 | * Dual licensed under the AGPL and Proprietary licenses:
7 | * http://www.dynatable.com/license/
8 | *
9 | * Date: Tue Jan 02 2014
10 | */
11 | th {
12 | background: #006a72;
13 | }
14 | th a {
15 | color: #fff;
16 | }
17 | th a:hover {
18 | color: #fff;
19 | text-decoration: underline;
20 | }
21 |
22 | .dynatable-search {
23 | float: right;
24 | margin-bottom: 10px;
25 | }
26 |
27 | .dynatable-pagination-links {
28 | float: right;
29 | }
30 |
31 | .dynatable-record-count {
32 | display: block;
33 | padding: 5px 0;
34 | }
35 |
36 | .dynatable-pagination-links span,
37 | .dynatable-pagination-links li {
38 | display: inline-block;
39 | }
40 |
41 | .dynatable-page-link,
42 | .dynatable-page-break {
43 | display: block;
44 | padding: 5px 7px;
45 | }
46 |
47 | .dynatable-page-link {
48 | cursor: pointer;
49 | }
50 |
51 | .dynatable-active-page,
52 | .dynatable-disabled-page {
53 | cursor: text;
54 | }
55 | .dynatable-active-page:hover,
56 | .dynatable-disabled-page:hover {
57 | text-decoration: none;
58 | }
59 |
60 | .dynatable-active-page {
61 | background: #006a72;
62 | border-radius: 5px;
63 | color: #fff;
64 | }
65 | .dynatable-active-page:hover {
66 | color: #fff;
67 | }
68 | .dynatable-disabled-page,
69 | .dynatable-disabled-page:hover {
70 | background: none;
71 | color: #999;
72 | }
73 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # jQuery Dynatable
2 |
3 | *A funner, semantic, HTML5+JSON, interactive table plugin.*
4 |
5 | See the [full documentation with demos](http://www.dynatable.com).
6 |
7 | ## Why?
8 |
9 | The purpose of Dynatable is to provide a simple, extensible API, which
10 | makes viewing and interacting with larger datasets easy. Dynatable
11 | provides a framework for implementing the most common elements out of
12 | the box, including sorting, searching and filtering. Above
13 | all, I wanted a clean and elegant API that is fun to use.
14 |
15 | ## Quickstart
16 |
17 | To install Dynatable:
18 |
19 | * [Download the latest release](http://jspkg.com/packages/dynatable)
20 |
21 | ## Support
22 |
23 | IRC: [Join us at #dynatable on freenode IRC](https://webchat.freenode.net/?channels=dynatable)
24 |
25 | Bugs and Feature Requests: [Search and open a Github Issue](https://github.com/alfajango/jquery-dynatable/issues)
26 |
27 | Debugging: [Fork and edit this template on JSFiddle](http://jsfiddle.net/ty3b7/)
28 |
29 | Questions: [Ask a question tagged with dynatable on
30 | StackOverflow](http://stackoverflow.com/questions/tagged/dynatable)
31 |
32 | ## TODO:
33 |
34 | * ~~Change `unfilter`s and `filter`s to `reader`s and `writer`s.~~
35 | * ~~Clean up defaults that are functions, by abstracting into internal
36 | named functions which can be re-used.~~
37 | * Change default sort functions to underscore-namespaced functions so as
38 | not to conflict with record attributes called e.g. `search`.
39 | * Update sort function implementation to be analogous to search function
40 | implementation (whereby if a sort function matching attribute name is
41 | present, it will be used for that attribute by default).
42 | * Namespace pushstate query parameters by dynatable instance id to
43 | simplify `refreshQueryString` function and prevent conflicts between
44 | multiple pushState-enabled instances on one page.
45 | * ~~Refactor using prototype to abstract dynatable-global functions to
46 | improve memory efficiency for multiple instances on one page.~~
47 | * Implement configurable sorting algorithm (see
48 | [JS Merge Sort](http://en.literateprograms.org/Merge_sort_%28JavaScript%29) and [Sorting Table](http://blog.vjeux.com/2010/javascript/javascript-sorting-table.html)).
49 | * ~~Change from Object.create method to constructor pattern to improve
50 | performances (see
51 | [benchmark](http://jsperf.com/object-create-vs-constructor-vs-object-literal/7)).~~
52 | * ~~Use for loops instead of $.each where possible to improve
53 | performance.~~
54 | * ~~Use strings and/or document fragments for writing to DOM, instead of
55 | jQuery, by default to improve writing performance.~~
56 | * Use templated strings to write pagination and other inputs.
57 | * Make class names for input elements configurable.
58 | * Use Chrome profiler to find any performance bottlenecks and fix.
59 | * Simplify API by separating internal-only and accessible model
60 | functions.
61 | * Move sorts and queries functions objects to defaults to make easier to
62 | customize and add to on instantiation (like filters and unfilters)
63 | * Try using CSS-only for ProcessingIndicator.position to avoid querying
64 | rendered DOM styling and speed up all operations that position the
65 | indicator (see [CSS absolute
66 | centering](http://codepen.io/shshaw/full/gEiDt)).
67 | * Add data-dynatable-attr="name" support for reading records from
68 | arbitrary markup (so that you don't need to write a custom rowReader
69 | function when starting with e.g. a stylized list).
70 | * Make sort function first lookup settings.sortTypes[attr], then look
71 | directly for sort sorts.functions[attr], and then finally
72 | sorts.guessType only if neither of the first two exist.
73 | * Add global remove/cleanup function (opposite of init) to allow
74 | removing dynatable via JS.
75 | * Support for Zepto?
76 |
77 | ## Tests
78 |
79 | Currently the testing process consists of opening [the Dynatable
80 | documentation](http://os.alfajango.com/dynatable)
81 | ([source code
82 | here](https://github.com/alfajango/alfajango.github.com/blob/master/_posts/2012-01-09-dynatable.md)) in
83 | each browser and making sure every example works. This is fine for the
84 | initial release, since it serves the dual purpose of helping us write
85 | the documentation and having a written functional use-case at once.
86 | However, one of the top priorities now is to automate each use-case in
87 | the docs as a test case within an automated test suite.
88 |
89 | If anyone out there thinks this sounds like fun, please contact me or
90 | even go ahead and create an issue/pull request. Otherwise, it will be at
91 | the top of my priority list until I can get to it.
92 |
93 | ## Contributing
94 |
95 | Please see the [Contributing Guidelines](https://github.com/JangoSteve/jquery-dynatable/blob/master/CONTRIBUTING.md).
96 |
97 | ## Author
98 |
99 | Steve Schwartz -
100 | [JangoSteve on Github](https://github.com/JangoSteve),
101 | [@jangosteve on Twitter](https://twitter.com/jangosteve)
102 |
103 | 
104 | [Alfa Jango Open Source](http://os.alfajango.com) -
105 | [@alfajango on Twitter](https://twitter.com/alfajango)
106 |
107 | ## Copyright and License
108 |
109 | Copyright 2014 Alfa Jango LLC.
110 |
111 | Dual licensed, released under the Free Software Foundation's
112 | GNU Affero General Public License (AGPL), or see [license
113 | information](http://www.dynatable.com/license) for proprietary or
114 | commercial applications.
115 |
116 | ## Miscellaneous
117 |
118 | ### Refactor performance benchmarks
119 |
120 | For version 0.1.0, Dynatable went through a refactor to use prototypal
121 | inheritence as a more memory-efficient foundation. Here are some
122 | off-the-cuff benchmarks I set up when doing this.
123 |
124 | The performance increase was modest, according to these benchmarks, but
125 | more importantly, the code became a bit cleaner and easier to work with.
126 |
127 | http://jsperf.com/dynatable-prototypal-refactor
128 |
129 | http://jsperf.com/dynatable-refactor/3
130 |
131 | Currently, there's still a bit of performance improvement to be gained
132 | by further grouping DOM reads and writes (though they're already mostly
133 | grouped together), and by using JS string concatenation instead of
134 | jQuery to build the HTML for rendering step.
135 |
136 | The new string concatenation has started to roll out in v0.2.
137 |
--------------------------------------------------------------------------------
/PROPRIETARY_LICENSE.html:
--------------------------------------------------------------------------------
1 |
2 |
Terms and conditions
3 |
4 |
5 |
6 | Preamble: This Agreement, signed on Dec 1, 2013 [hereinafter: Effective Date] governs the relationship between you, a private person or the organization on whose behalf you are undertaking the license described below, (hereinafter: Licensee) and Alfa Jango, LLC, a duly registered company in MI, United States whose principal place of business is 1327 Jones Drive, Suite 109, Ann Arbor, MI 48105, MI, United States (Hereinafter: Licensor). This Agreement sets the terms, rights, restrictions and obligations on using [Dynatable] (hereinafter: The Software) created and owned by Licensor, as detailed herein
7 |
8 |
9 | License Grant: Licensor hereby grants Licensee a Sublicensable, Assignable, Commercial, Royalty free, Including the rights to create but not distribute derivative works, Non-exclusive license, all with accordance with the terms set forth and other legal restrictions set forth in 3rd party software used while running Software.
10 |
11 |
12 | Limited: Licensee may use Software on a per-web-domain basis for the purpose of:
13 |
14 | Running Software on Licensee's Website[s] and Server[s];
15 | Allowing 3rd Parties to run Software on Licensee's Website[s] and Server[s];
16 | Publishing Software's output to Licensee and 3rd Parties;
17 | Distribute verbatim copies of Software's output (including compiled binaries);
18 | Modify Software to suit Licensee's needs and specifications.
19 |
20 | If Software is to be distributed as part of a downloadable, locally-running software application (herinafter: Distributed Package) which includes a copy of Software, outside of a webserver serving Software directly to the end-user's browser on a live-execution basis, the per-web-domain limitation of the purchased Software license will instead apply to the number of copies of the Distributed Package to be distributed. I.e. A 5-domain license would allow for five (5) copies of the Distributed Package to be distributed; likewise, an Unlimited license would allow for unlimited copies of the Distributed Package to be distributed.
21 |
22 | Binary Restricted: Licensee may sublicense Software as a part of a larger work containing more than Software, distributed solely in Object or Binary form under a personal, non-sublicensable, limited license. Such redistribution shall be limited to unlimited codebases.
23 |
24 | Assignable: Licensee may assign his rights and duties under this license as long as the party who Licensee assigns the license accepts the license in full, and provides Licensor with a written confirmation of Assignment
25 |
26 |
27 | Commercial, Royalty Free: Licensee may use Software for any purpose, including paid-services, without any royalties
28 |
29 |
30 | Including the Right to Create Derivative Works: Licensee may create derivative works based on Software, including amending Software's source code, modifying it, integrating it into a larger work or removing portions of Software, as long as no distribution of the derivative works is made
31 |
32 |
33 | Licensor shall retain full title in Trademarks, and any trademarks and tradenames contained, including Software's names, logos, and all other intellectual property. Unless specifically stated in this license, no license shall be made to use, associate or affiliate Software with Licensee in any manner. Licensee may not use Software's name, tradename, trademarks or logo when distributing derivative works of software to 3rd parties.
34 |
35 |
36 |
37 |
38 | Term & Termination: The Term of this license shall be until terminated. Licensor may terminate this Agreement, including Licensee's license in the case where Licensee :
39 |
40 |
41 | became insolvent or otherwise entered into any liquidation process; or
42 |
43 |
44 | exported The Software to any jurisdiction where licensor may not enforce his rights under this agreements in; or
45 |
46 |
47 | Licensee was in breach of any of this license's terms and conditions and such breach was not cured, immediately upon notification; or
48 |
49 |
50 | Licensee in breach of any of the terms of clause 2 to this license; or
51 |
52 |
53 | Licensee otherwise entered into any arrangement which caused Licensor to be unable to enforce his rights under this License.
54 |
55 |
56 |
57 | Payment: In consideration of the License granted under clause 2, Licensee shall pay Licensor a fee, via Credit-Card, PayPal or any other mean which Licensor may deem adequate. Failure to perform payment shall construe as material breach of this Agreement.
58 |
59 | Upgrades, Updates and Fixes: Licensor may provide Licensee, from time to time, with Upgrades, Updates or Fixes, as detailed herein and according to his sole discretion. Licensee hereby warrants to keep The Software up-to-date and install all relevant updates and fixes, and may, at his sole discretion, purchase upgrades, according to the rates set by Licensor. Licensor shall provide any update or Fix free of charge; however, nothing in this Agreement shall require Licensor to provide Updates or Fixes.
60 |
61 |
62 | Upgrades: for the purpose of this license, an Upgrade shall be a material amendment in The Software, which contains new features and or major performance improvements and shall be marked as a new version number. For example, should Licensee purchase The Software under version 1.X.X, an upgrade shall commence under number 2.0.0.
63 |
64 |
65 | Updates: for the purpose of this license, an update shall be a minor amendment in The Software, which may contain new features or minor improvements and shall be marked as a new sub-version number. For example, should Licensee purchase The Software under version 1.1.X, an upgrade shall commence under number 1.2.0.
66 |
67 |
68 | Fix: for the purpose of this license, a fix shall be a minor amendment in The Software, intended to remove bugs or alter minor features which impair the The Software's functionality. A fix shall be marked as a new sub-sub-version number. For example, should Licensee purchase Software under version 1.1.1, an upgrade shall commence under number 1.1.2.
69 |
70 |
71 |
72 |
73 | Support: Software is provided under an AS-IS basis and without any support, updates or maintenance. Nothing in this Agreement shall require Licensor to provide Licensee with support or fixes to any bug, failure, mis-performance or other defect in The Software.
74 |
75 |
76 | Bug Notification: Licensee may provide Licensor of details regarding any bug, defect or failure in The Software promptly and with no delay from such event; Licensee shall comply with Licensor's request for information regarding bugs, defects or failures and furnish him with information, screenshots and try to reproduce such bugs, defects or failures.
77 |
78 |
79 | Feature Request: Licensee may request additional features in Software, provided, however, that (i) Licensee shall waive any claim or right in such feature should feature be developed by Licensor; (ii) Licensee shall be prohibited from developing the feature, or disclose such feature request, or feature, to any 3rd party directly competing with Licensor or any 3rd party which may be, following the development of such feature, in direct competition with Licensor; (iii) Licensee warrants that feature does not infringe any 3rd party patent, trademark, trade-secret or any other intellectual property right; and (iv) Licensee developed, envisioned or created the feature solely by himself.
80 |
81 |
82 |
83 |
84 | Liability: To the extent permitted under Law, The Software is provided under an AS-IS basis. Licensor shall never, and without any limit, be liable for any damage, cost, expense or any other payment incurred by Licensee as a result of Software's actions, failure, bugs and/or any other interaction between The Software and Licensee's end-equipment, computers, other software or any 3rd party, end-equipment, computer or services. Moreover, Licensor shall never be liable for any defect in source code written by Licensee when relying on The Software or using The Software's source code.
85 |
86 |
87 | Warranty:
88 |
89 |
90 | Intellectual Property: Licensor hereby warrants that The Software does not violate or infringe any 3rd party claims in regards to intellectual property, patents and/or trademarks and that to the best of its knowledge no legal action has been taken against it for any infringement or violation of any 3rd party intellectual property rights.
91 |
92 |
93 | No-Warranty: The Software is provided without any warranty; Licensor hereby disclaims any warranty that The Software shall be error free, without defects or code which may cause damage to Licensee's computers or to Licensee, and that Software shall be functional. Licensee shall be solely liable to any damage, defect or loss incurred as a result of operating software and undertake the risks contained in running The Software on License's Server[s] and Website[s].
94 |
95 |
96 | Prior Inspection: Licensee hereby states that he inspected The Software thoroughly and found it satisfactory and adequate to his needs, that it does not interfere with his regular operation and that it does meet the standards and scope of his computer systems and architecture. Licensee found that The Software interacts with his development, website and server environment and that it does not infringe any of End User License Agreement of any software Licensee may use in performing his services. Licensee hereby waives any claims regarding The Software's incompatibility, performance, results and features, and warrants that he inspected the The Software.
97 |
98 |
99 |
100 |
101 | No Refunds: Licensee warrants that he inspected The Software according to clause 7(c) and that it is adequate to his needs. Accordingly, as The Software is intangible goods, Licensee shall not be, ever, entitled to any refund, rebate, compensation or restitution for any reason whatsoever, even if The Software contains material flaws.
102 |
103 |
104 | Indemnification: Licensee hereby warrants to hold Licensor harmless and indemnify Licensor for any lawsuit brought against it in regards to Licensee's use of The Software in means that violate, breach or otherwise circumvent this license, Licensor's intellectual property rights or Licensor's title in The Software. Licensor shall promptly notify Licensee in case of such legal action and request Licensee's consent prior to any settlement in relation to such lawsuit or claim.
105 |
106 |
107 | Governing Law, Jurisdiction: Licensee hereby agrees not to initiate class-action lawsuits against Licensor in relation to this license and to compensate Licensor for any legal fees, cost or attorney fees should any claim brought by Licensee against Licensor be denied, in part or in full.
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/jquery.dynatable.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery Dynatable plugin 0.3.1
3 | *
4 | * Copyright (c) 2014 Steve Schwartz (JangoSteve)
5 | *
6 | * Dual licensed under the AGPL and Proprietary licenses:
7 | * http://www.dynatable.com/license/
8 | *
9 | * Date: Tue Jan 02 2014
10 | */
11 | //
12 |
13 | (function($) {
14 | var defaults,
15 | mergeSettings,
16 | dt,
17 | Model,
18 | modelPrototypes = {
19 | dom: Dom,
20 | domColumns: DomColumns,
21 | records: Records,
22 | recordsCount: RecordsCount,
23 | processingIndicator: ProcessingIndicator,
24 | state: State,
25 | sorts: Sorts,
26 | sortsHeaders: SortsHeaders,
27 | queries: Queries,
28 | inputsSearch: InputsSearch,
29 | paginationPage: PaginationPage,
30 | paginationPerPage: PaginationPerPage,
31 | paginationLinks: PaginationLinks
32 | },
33 | utility,
34 | build,
35 | processAll,
36 | initModel,
37 | defaultRowWriter,
38 | defaultCellWriter,
39 | defaultAttributeWriter,
40 | defaultAttributeReader;
41 |
42 | //-----------------------------------------------------------------
43 | // Cached plugin global defaults
44 | //-----------------------------------------------------------------
45 |
46 | defaults = {
47 | features: {
48 | paginate: true,
49 | sort: true,
50 | pushState: true,
51 | search: true,
52 | recordCount: true,
53 | perPageSelect: true
54 | },
55 | table: {
56 | defaultColumnIdStyle: 'camelCase',
57 | columns: null,
58 | headRowSelector: 'thead tr', // or e.g. tr:first-child
59 | bodyRowSelector: 'tbody tr',
60 | headRowClass: null,
61 | copyHeaderAlignment: true,
62 | copyHeaderClass: false
63 | },
64 | inputs: {
65 | queries: null,
66 | sorts: null,
67 | multisort: ['ctrlKey', 'shiftKey', 'metaKey'],
68 | page: null,
69 | queryEvent: 'blur change',
70 | recordCountTarget: null,
71 | recordCountPlacement: 'after',
72 | paginationLinkTarget: null,
73 | paginationLinkPlacement: 'after',
74 | paginationClass: 'dynatable-pagination-links',
75 | paginationLinkClass: 'dynatable-page-link',
76 | paginationPrevClass: 'dynatable-page-prev',
77 | paginationNextClass: 'dynatable-page-next',
78 | paginationActiveClass: 'dynatable-active-page',
79 | paginationDisabledClass: 'dynatable-disabled-page',
80 | paginationPrev: 'Previous',
81 | paginationNext: 'Next',
82 | paginationGap: [1,2,2,1],
83 | searchTarget: null,
84 | searchPlacement: 'before',
85 | searchText: 'Search: ',
86 | perPageTarget: null,
87 | perPagePlacement: 'before',
88 | perPageText: 'Show: ',
89 | pageText: 'Pages: ',
90 | recordCountPageBoundTemplate: '{pageLowerBound} to {pageUpperBound} of',
91 | recordCountPageUnboundedTemplate: '{recordsShown} of',
92 | recordCountTotalTemplate: '{recordsQueryCount} {collectionName}',
93 | recordCountFilteredTemplate: ' (filtered from {recordsTotal} total records)',
94 | recordCountText: 'Showing',
95 | recordCountTextTemplate: '{text} {pageTemplate} {totalTemplate} {filteredTemplate}',
96 | recordCountTemplate: '{textTemplate} ',
97 | processingText: 'Processing...'
98 | },
99 | dataset: {
100 | ajax: false,
101 | ajaxUrl: null,
102 | ajaxCache: null,
103 | ajaxOnLoad: false,
104 | ajaxMethod: 'GET',
105 | ajaxDataType: 'json',
106 | totalRecordCount: null,
107 | queries: {},
108 | queryRecordCount: null,
109 | page: null,
110 | perPageDefault: 10,
111 | perPageOptions: [10,20,50,100],
112 | sorts: {},
113 | sortsKeys: [],
114 | sortTypes: {},
115 | records: null
116 | },
117 | writers: {
118 | _rowWriter: defaultRowWriter,
119 | _cellWriter: defaultCellWriter,
120 | _attributeWriter: defaultAttributeWriter
121 | },
122 | readers: {
123 | _rowReader: null,
124 | _attributeReader: defaultAttributeReader
125 | },
126 | params: {
127 | dynatable: 'dynatable',
128 | queries: 'queries',
129 | sorts: 'sorts',
130 | page: 'page',
131 | perPage: 'perPage',
132 | offset: 'offset',
133 | records: 'records',
134 | record: null,
135 | queryRecordCount: 'queryRecordCount',
136 | totalRecordCount: 'totalRecordCount'
137 | }
138 | };
139 |
140 | //-----------------------------------------------------------------
141 | // Each dynatable instance inherits from this,
142 | // set properties specific to instance
143 | //-----------------------------------------------------------------
144 |
145 | dt = {
146 | init: function(element, options) {
147 | this.settings = mergeSettings(options);
148 | this.element = element;
149 | this.$element = $(element);
150 |
151 | // All the setup that doesn't require element or options
152 | build.call(this);
153 |
154 | return this;
155 | },
156 |
157 | process: function(skipPushState) {
158 | processAll.call(this, skipPushState);
159 | }
160 | };
161 |
162 | //-----------------------------------------------------------------
163 | // Cached plugin global functions
164 | //-----------------------------------------------------------------
165 |
166 | mergeSettings = function(options) {
167 | var newOptions = $.extend(true, {}, defaults, options);
168 |
169 | // TODO: figure out a better way to do this.
170 | // Doing `extend(true)` causes any elements that are arrays
171 | // to merge the default and options arrays instead of overriding the defaults.
172 | if (options) {
173 | if (options.inputs) {
174 | if (options.inputs.multisort) {
175 | newOptions.inputs.multisort = options.inputs.multisort;
176 | }
177 | if (options.inputs.paginationGap) {
178 | newOptions.inputs.paginationGap = options.inputs.paginationGap;
179 | }
180 | }
181 | if (options.dataset && options.dataset.perPageOptions) {
182 | newOptions.dataset.perPageOptions = options.dataset.perPageOptions;
183 | }
184 | }
185 |
186 | return newOptions;
187 | };
188 |
189 | build = function() {
190 | this.$element.trigger('dynatable:preinit', this);
191 |
192 | for (model in modelPrototypes) {
193 | if (modelPrototypes.hasOwnProperty(model)) {
194 | var modelInstance = this[model] = new modelPrototypes[model](this, this.settings);
195 | if (modelInstance.initOnLoad()) {
196 | modelInstance.init();
197 | }
198 | }
199 | }
200 |
201 | this.$element.trigger('dynatable:init', this);
202 |
203 | if (!this.settings.dataset.ajax || (this.settings.dataset.ajax && this.settings.dataset.ajaxOnLoad) || this.settings.features.paginate || (this.settings.features.sort && !$.isEmptyObject(this.settings.dataset.sorts))) {
204 | this.process();
205 | }
206 | };
207 |
208 | processAll = function(skipPushState) {
209 | var data = {};
210 |
211 | this.$element.trigger('dynatable:beforeProcess', data);
212 |
213 | if (!$.isEmptyObject(this.settings.dataset.queries)) { data[this.settings.params.queries] = this.settings.dataset.queries; }
214 | // TODO: Wrap this in a try/rescue block to hide the processing indicator and indicate something went wrong if error
215 | this.processingIndicator.show();
216 |
217 | if (this.settings.features.sort && !$.isEmptyObject(this.settings.dataset.sorts)) { data[this.settings.params.sorts] = this.settings.dataset.sorts; }
218 | if (this.settings.features.paginate && this.settings.dataset.page) {
219 | var page = this.settings.dataset.page,
220 | perPage = this.settings.dataset.perPage;
221 | data[this.settings.params.page] = page;
222 | data[this.settings.params.perPage] = perPage;
223 | data[this.settings.params.offset] = (page - 1) * perPage;
224 | }
225 | if (this.settings.dataset.ajaxData) { $.extend(data, this.settings.dataset.ajaxData); }
226 |
227 | // If ajax, sends query to ajaxUrl with queries and sorts serialized and appended in ajax data
228 | // otherwise, executes queries and sorts on in-page data
229 | if (this.settings.dataset.ajax) {
230 | var _this = this;
231 | var options = {
232 | type: _this.settings.dataset.ajaxMethod,
233 | dataType: _this.settings.dataset.ajaxDataType,
234 | data: data,
235 | error: function(xhr, error) {
236 | _this.$element.trigger('dynatable:ajax:error', {xhr: xhr, error : error});
237 | },
238 | success: function(response) {
239 | _this.$element.trigger('dynatable:ajax:success', response);
240 | // Merge ajax results and meta-data into dynatables cached data
241 | _this.records.updateFromJson(response);
242 | // update table with new records
243 | _this.dom.update();
244 |
245 | if (!skipPushState && _this.state.initOnLoad()) {
246 | _this.state.push(data);
247 | }
248 | },
249 | complete: function() {
250 | _this.processingIndicator.hide();
251 | }
252 | };
253 | // Do not pass url to `ajax` options if blank
254 | if (this.settings.dataset.ajaxUrl) {
255 | options.url = this.settings.dataset.ajaxUrl;
256 |
257 | // If ajaxUrl is blank, then we're using the current page URL,
258 | // we need to strip out any query, sort, or page data controlled by dynatable
259 | // that may have been in URL when page loaded, so that it doesn't conflict with
260 | // what's passed in with the data ajax parameter
261 | } else {
262 | options.url = utility.refreshQueryString(window.location.href, {}, this.settings);
263 | }
264 | if (this.settings.dataset.ajaxCache !== null) { options.cache = this.settings.dataset.ajaxCache; }
265 |
266 | $.ajax(options);
267 | } else {
268 | this.records.resetOriginal();
269 | this.queries.run();
270 | if (this.settings.features.sort) {
271 | this.records.sort();
272 | }
273 | if (this.settings.features.paginate) {
274 | this.records.paginate();
275 | }
276 | this.dom.update();
277 | this.processingIndicator.hide();
278 |
279 | if (!skipPushState && this.state.initOnLoad()) {
280 | this.state.push(data);
281 | }
282 | }
283 |
284 | this.$element.addClass('dynatable-loaded');
285 | this.$element.trigger('dynatable:afterProcess', data);
286 | };
287 |
288 | function defaultRowWriter(rowIndex, record, columns, cellWriter) {
289 | var tr = '';
290 |
291 | // grab the record's attribute for each column
292 | for (var i = 0, len = columns.length; i < len; i++) {
293 | tr += cellWriter(columns[i], record);
294 | }
295 |
296 | return '' + tr + ' ';
297 | };
298 |
299 | function defaultCellWriter(column, record) {
300 | var html = column.attributeWriter(record),
301 | td = '' + html + ' ';
324 | };
325 |
326 | function defaultAttributeWriter(record) {
327 | // `this` is the column object in settings.columns
328 | // TODO: automatically convert common types, such as arrays and objects, to string
329 | return record[this.id];
330 | };
331 |
332 | function defaultAttributeReader(cell, record) {
333 | return $(cell).html();
334 | };
335 |
336 | //-----------------------------------------------------------------
337 | // Dynatable object model prototype
338 | // (all object models get these default functions)
339 | //-----------------------------------------------------------------
340 |
341 | Model = {
342 | initOnLoad: function() {
343 | return true;
344 | },
345 |
346 | init: function() {}
347 | };
348 |
349 | for (model in modelPrototypes) {
350 | if (modelPrototypes.hasOwnProperty(model)) {
351 | var modelPrototype = modelPrototypes[model];
352 | modelPrototype.prototype = Model;
353 | }
354 | }
355 |
356 | //-----------------------------------------------------------------
357 | // Dynatable object models
358 | //-----------------------------------------------------------------
359 |
360 | function Dom(obj, settings) {
361 | var _this = this;
362 |
363 | // update table contents with new records array
364 | // from query (whether ajax or not)
365 | this.update = function() {
366 | var rows = '',
367 | columns = settings.table.columns,
368 | rowWriter = settings.writers._rowWriter,
369 | cellWriter = settings.writers._cellWriter;
370 |
371 | obj.$element.trigger('dynatable:beforeUpdate', rows);
372 |
373 | // loop through records
374 | for (var i = 0, len = settings.dataset.records.length; i < len; i++) {
375 | var record = settings.dataset.records[i],
376 | tr = rowWriter(i, record, columns, cellWriter);
377 | rows += tr;
378 | }
379 |
380 | // Appended dynatable interactive elements
381 | if (settings.features.recordCount) {
382 | $('#dynatable-record-count-' + obj.element.id).replaceWith(obj.recordsCount.create());
383 | }
384 | if (settings.features.paginate) {
385 | $('#dynatable-pagination-links-' + obj.element.id).replaceWith(obj.paginationLinks.create());
386 | if (settings.features.perPageSelect) {
387 | $('#dynatable-per-page-' + obj.element.id).val(parseInt(settings.dataset.perPage));
388 | }
389 | }
390 |
391 | // Sort headers functionality
392 | if (settings.features.sort && columns) {
393 | obj.sortsHeaders.removeAllArrows();
394 | for (var i = 0, len = columns.length; i < len; i++) {
395 | var column = columns[i],
396 | sortedByColumn = utility.allMatch(settings.dataset.sorts, column.sorts, function(sorts, sort) { return sort in sorts; }),
397 | value = settings.dataset.sorts[column.sorts[0]];
398 |
399 | if (sortedByColumn) {
400 | obj.$element.find('[data-dynatable-column="' + column.id + '"]').find('.dynatable-sort-header').each(function(){
401 | if (value == 1) {
402 | obj.sortsHeaders.appendArrowUp($(this));
403 | } else {
404 | obj.sortsHeaders.appendArrowDown($(this));
405 | }
406 | });
407 | }
408 | }
409 | }
410 |
411 | // Query search functionality
412 | if (settings.inputs.queries || settings.features.search) {
413 | var allQueries = settings.inputs.queries || $();
414 | if (settings.features.search) {
415 | allQueries = allQueries.add('#dynatable-query-search-' + obj.element.id);
416 | }
417 |
418 | allQueries.each(function() {
419 | var $this = $(this),
420 | q = settings.dataset.queries[$this.data('dynatable-query')];
421 | $this.val(q || '');
422 | });
423 | }
424 |
425 | obj.$element.find(settings.table.bodyRowSelector).remove();
426 | obj.$element.append(rows);
427 |
428 | obj.$element.trigger('dynatable:afterUpdate', rows);
429 | };
430 | };
431 |
432 | function DomColumns(obj, settings) {
433 | var _this = this;
434 |
435 | this.initOnLoad = function() {
436 | return obj.$element.is('table');
437 | };
438 |
439 | this.init = function() {
440 | settings.table.columns = [];
441 | this.getFromTable();
442 | };
443 |
444 | // initialize table[columns] array
445 | this.getFromTable = function() {
446 | var $columns = obj.$element.find(settings.table.headRowSelector).children('th,td');
447 | if ($columns.length) {
448 | $columns.each(function(index){
449 | _this.add($(this), index, true);
450 | });
451 | } else {
452 | return $.error("Couldn't find any columns headers in '" + settings.table.headRowSelector + " th,td'. If your header row is different, specify the selector in the table: headRowSelector option.");
453 | }
454 | };
455 |
456 | this.add = function($column, position, skipAppend, skipUpdate) {
457 | var columns = settings.table.columns,
458 | label = $column.text(),
459 | id = $column.data('dynatable-column') || utility.normalizeText(label, settings.table.defaultColumnIdStyle),
460 | dataSorts = $column.data('dynatable-sorts'),
461 | sorts = dataSorts ? $.map(dataSorts.split(','), function(text) { return $.trim(text); }) : [id];
462 |
463 | // If the column id is blank, generate an id for it
464 | if ( !id ) {
465 | this.generate($column);
466 | id = $column.data('dynatable-column');
467 | }
468 | // Add column data to plugin instance
469 | columns.splice(position, 0, {
470 | index: position,
471 | label: label,
472 | id: id,
473 | attributeWriter: settings.writers[id] || settings.writers._attributeWriter,
474 | attributeReader: settings.readers[id] || settings.readers._attributeReader,
475 | sorts: sorts,
476 | hidden: $column.css('display') === 'none',
477 | textAlign: settings.table.copyHeaderAlignment && $column.css('text-align'),
478 | cssClass: settings.table.copyHeaderClass && $column.attr('class')
479 | });
480 |
481 | // Modify header cell
482 | $column
483 | .attr('data-dynatable-column', id)
484 | .addClass('dynatable-head');
485 | if (settings.table.headRowClass) { $column.addClass(settings.table.headRowClass); }
486 |
487 | // Append column header to table
488 | if (!skipAppend) {
489 | var domPosition = position + 1,
490 | $sibling = obj.$element.find(settings.table.headRowSelector)
491 | .children('th:nth-child(' + domPosition + '),td:nth-child(' + domPosition + ')').first(),
492 | columnsAfter = columns.slice(position + 1, columns.length);
493 |
494 | if ($sibling.length) {
495 | $sibling.before($column);
496 | // sibling column doesn't yet exist (maybe this is the last column in the header row)
497 | } else {
498 | obj.$element.find(settings.table.headRowSelector).append($column);
499 | }
500 |
501 | obj.sortsHeaders.attachOne($column.get());
502 |
503 | // increment the index of all columns after this one that was just inserted
504 | if (columnsAfter.length) {
505 | for (var i = 0, len = columnsAfter.length; i < len; i++) {
506 | columnsAfter[i].index += 1;
507 | }
508 | }
509 |
510 | if (!skipUpdate) {
511 | obj.dom.update();
512 | }
513 | }
514 |
515 | return dt;
516 | };
517 |
518 | this.remove = function(columnIndexOrId) {
519 | var columns = settings.table.columns,
520 | length = columns.length;
521 |
522 | if (typeof(columnIndexOrId) === "number") {
523 | var column = columns[columnIndexOrId];
524 | this.removeFromTable(column.id);
525 | this.removeFromArray(columnIndexOrId);
526 | } else {
527 | // Traverse columns array in reverse order so that subsequent indices
528 | // don't get messed up when we delete an item from the array in an iteration
529 | for (var i = columns.length - 1; i >= 0; i--) {
530 | var column = columns[i];
531 |
532 | if (column.id === columnIndexOrId) {
533 | this.removeFromTable(columnIndexOrId);
534 | this.removeFromArray(i);
535 | }
536 | }
537 | }
538 |
539 | obj.dom.update();
540 | };
541 |
542 | this.removeFromTable = function(columnId) {
543 | obj.$element.find(settings.table.headRowSelector).children('[data-dynatable-column="' + columnId + '"]').first()
544 | .remove();
545 | };
546 |
547 | this.removeFromArray = function(index) {
548 | var columns = settings.table.columns,
549 | adjustColumns;
550 | columns.splice(index, 1);
551 | adjustColumns = columns.slice(index, columns.length);
552 | for (var i = 0, len = adjustColumns.length; i < len; i++) {
553 | adjustColumns[i].index -= 1;
554 | }
555 | };
556 |
557 | this.generate = function($cell) {
558 | var cell = $cell === undefined ? $(' ') : $cell;
559 | return this.attachGeneratedAttributes(cell);
560 | };
561 |
562 | this.attachGeneratedAttributes = function($cell) {
563 | // Use increment to create unique column name that is the same each time the page is reloaded,
564 | // in order to avoid errors with mismatched attribute names when loading cached `dataset.records` array
565 | var increment = obj.$element.find(settings.table.headRowSelector).children('th[data-dynatable-generated]').length;
566 | return $cell
567 | .attr('data-dynatable-column', 'dynatable-generated-' + increment) //+ utility.randomHash(),
568 | .attr('data-dynatable-no-sort', 'true')
569 | .attr('data-dynatable-generated', increment);
570 | };
571 | };
572 |
573 | function Records(obj, settings) {
574 | var _this = this;
575 |
576 | this.initOnLoad = function() {
577 | return !settings.dataset.ajax;
578 | };
579 |
580 | this.init = function() {
581 | if (settings.dataset.records === null) {
582 | settings.dataset.records = this.getFromTable();
583 |
584 | if (!settings.dataset.queryRecordCount) {
585 | settings.dataset.queryRecordCount = this.count();
586 | }
587 |
588 | if (!settings.dataset.totalRecordCount){
589 | settings.dataset.totalRecordCount = settings.dataset.queryRecordCount;
590 | }
591 | }
592 |
593 | // Create cache of original full recordset (unpaginated and unqueried)
594 | settings.dataset.originalRecords = $.extend(true, [], settings.dataset.records);
595 | };
596 |
597 | // merge ajax response json with cached data including
598 | // meta-data and records
599 | this.updateFromJson = function(data) {
600 | var records;
601 | if (settings.params.records === "_root") {
602 | records = data;
603 | } else if (settings.params.records in data) {
604 | records = data[settings.params.records];
605 | }
606 | if (settings.params.record) {
607 | var len = records.length - 1;
608 | for (var i = 0; i < len; i++) {
609 | records[i] = records[i][settings.params.record];
610 | }
611 | }
612 | if (settings.params.queryRecordCount in data) {
613 | settings.dataset.queryRecordCount = data[settings.params.queryRecordCount];
614 | }
615 | if (settings.params.totalRecordCount in data) {
616 | settings.dataset.totalRecordCount = data[settings.params.totalRecordCount];
617 | }
618 | settings.dataset.records = records;
619 | };
620 |
621 | // For really advanced sorting,
622 | // see http://james.padolsey.com/javascript/sorting-elements-with-jquery/
623 | this.sort = function() {
624 | var sort = [].sort,
625 | sorts = settings.dataset.sorts,
626 | sortsKeys = settings.dataset.sortsKeys,
627 | sortTypes = settings.dataset.sortTypes;
628 |
629 | var sortFunction = function(a, b) {
630 | var comparison;
631 | if ($.isEmptyObject(sorts)) {
632 | comparison = obj.sorts.functions['originalPlacement'](a, b);
633 | } else {
634 | for (var i = 0, len = sortsKeys.length; i < len; i++) {
635 | var attr = sortsKeys[i],
636 | direction = sorts[attr],
637 | sortType = sortTypes[attr] || obj.sorts.guessType(a, b, attr);
638 | comparison = obj.sorts.functions[sortType](a, b, attr, direction);
639 | // Don't need to sort any further unless this sort is a tie between a and b,
640 | // so break the for loop unless tied
641 | if (comparison !== 0) { break; }
642 | }
643 | }
644 | return comparison;
645 | }
646 |
647 | return sort.call(settings.dataset.records, sortFunction);
648 | };
649 |
650 | this.paginate = function() {
651 | var bounds = this.pageBounds(),
652 | first = bounds[0], last = bounds[1];
653 | settings.dataset.records = settings.dataset.records.slice(first, last);
654 | };
655 |
656 | this.resetOriginal = function() {
657 | settings.dataset.records = settings.dataset.originalRecords || [];
658 | };
659 |
660 | this.pageBounds = function() {
661 | var page = settings.dataset.page || 1,
662 | first = (page - 1) * settings.dataset.perPage,
663 | last = Math.min(first + settings.dataset.perPage, settings.dataset.queryRecordCount);
664 | return [first,last];
665 | };
666 |
667 | // get initial recordset to populate table
668 | // if ajax, call ajaxUrl
669 | // otherwise, initialize from in-table records
670 | this.getFromTable = function() {
671 | var records = [],
672 | columns = settings.table.columns,
673 | tableRecords = obj.$element.find(settings.table.bodyRowSelector);
674 |
675 | tableRecords.each(function(index){
676 | var record = {};
677 | record['dynatable-original-index'] = index;
678 | $(this).find('th,td').each(function(index) {
679 | if (columns[index] === undefined) {
680 | // Header cell didn't exist for this column, so let's generate and append
681 | // a new header cell with a randomly generated name (so we can store and
682 | // retrieve the contents of this column for each record)
683 | obj.domColumns.add(obj.domColumns.generate(), columns.length, false, true); // don't skipAppend, do skipUpdate
684 | }
685 | var value = columns[index].attributeReader(this, record),
686 | attr = columns[index].id;
687 |
688 | // If value from table is HTML, let's get and cache the text equivalent for
689 | // the default string sorting, since it rarely makes sense for sort headers
690 | // to sort based on HTML tags.
691 | if (typeof(value) === "string" && value.match(/\s*\<.+\>/)) {
692 | if (! record['dynatable-sortable-text']) {
693 | record['dynatable-sortable-text'] = {};
694 | }
695 | record['dynatable-sortable-text'][attr] = $.trim($('
').html(value).text());
696 | }
697 |
698 | record[attr] = value;
699 | });
700 | // Allow configuration function which alters record based on attributes of
701 | // table row (e.g. from html5 data- attributes)
702 | if (typeof(settings.readers._rowReader) === "function") {
703 | settings.readers._rowReader(index, this, record);
704 | }
705 | records.push(record);
706 | });
707 | return records; // 1st row is header
708 | };
709 |
710 | // count records from table
711 | this.count = function() {
712 | return settings.dataset.records.length;
713 | };
714 | };
715 |
716 | function RecordsCount(obj, settings) {
717 | this.initOnLoad = function() {
718 | return settings.features.recordCount;
719 | };
720 |
721 | this.init = function() {
722 | this.attach();
723 | };
724 |
725 | this.create = function() {
726 | var pageTemplate = '',
727 | filteredTemplate = '',
728 | options = {
729 | elementId: obj.element.id,
730 | recordsShown: obj.records.count(),
731 | recordsQueryCount: settings.dataset.queryRecordCount,
732 | recordsTotal: settings.dataset.totalRecordCount,
733 | collectionName: settings.params.records === "_root" ? "records" : settings.params.records,
734 | text: settings.inputs.recordCountText
735 | };
736 |
737 | if (settings.features.paginate) {
738 |
739 | // If currently displayed records are a subset (page) of the entire collection
740 | if (options.recordsShown < options.recordsQueryCount) {
741 | var bounds = obj.records.pageBounds();
742 | options.pageLowerBound = bounds[0] + 1;
743 | options.pageUpperBound = bounds[1];
744 | pageTemplate = settings.inputs.recordCountPageBoundTemplate;
745 |
746 | // Else if currently displayed records are the entire collection
747 | } else if (options.recordsShown === options.recordsQueryCount) {
748 | pageTemplate = settings.inputs.recordCountPageUnboundedTemplate;
749 | }
750 | }
751 |
752 | // If collection for table is queried subset of collection
753 | if (options.recordsQueryCount < options.recordsTotal) {
754 | filteredTemplate = settings.inputs.recordCountFilteredTemplate;
755 | }
756 |
757 | // Populate templates with options
758 | options.pageTemplate = utility.template(pageTemplate, options);
759 | options.filteredTemplate = utility.template(filteredTemplate, options);
760 | options.totalTemplate = utility.template(settings.inputs.recordCountTotalTemplate, options);
761 | options.textTemplate = utility.template(settings.inputs.recordCountTextTemplate, options);
762 |
763 | return utility.template(settings.inputs.recordCountTemplate, options);
764 | };
765 |
766 | this.attach = function() {
767 | var $target = settings.inputs.recordCountTarget ? $(settings.inputs.recordCountTarget) : obj.$element;
768 | $target[settings.inputs.recordCountPlacement](this.create());
769 | };
770 | };
771 |
772 | function ProcessingIndicator(obj, settings) {
773 | this.init = function() {
774 | this.attach();
775 | };
776 |
777 | this.create = function() {
778 | var $processing = $('
', {
779 | html: '' + settings.inputs.processingText + ' ',
780 | id: 'dynatable-processing-' + obj.element.id,
781 | 'class': 'dynatable-processing',
782 | style: 'position: absolute; display: none;'
783 | });
784 |
785 | return $processing;
786 | };
787 |
788 | this.position = function() {
789 | var $processing = $('#dynatable-processing-' + obj.element.id),
790 | $span = $processing.children('span'),
791 | spanHeight = $span.outerHeight(),
792 | spanWidth = $span.outerWidth(),
793 | $covered = obj.$element,
794 | offset = $covered.offset(),
795 | height = $covered.outerHeight(), width = $covered.outerWidth();
796 |
797 | $processing
798 | .offset({left: offset.left, top: offset.top})
799 | .width(width)
800 | .height(height)
801 | $span
802 | .offset({left: offset.left + ( (width - spanWidth) / 2 ), top: offset.top + ( (height - spanHeight) / 2 )});
803 |
804 | return $processing;
805 | };
806 |
807 | this.attach = function() {
808 | obj.$element.before(this.create());
809 | };
810 |
811 | this.show = function() {
812 | $('#dynatable-processing-' + obj.element.id).show();
813 | this.position();
814 | };
815 |
816 | this.hide = function() {
817 | $('#dynatable-processing-' + obj.element.id).hide();
818 | };
819 | };
820 |
821 | function State(obj, settings) {
822 | this.initOnLoad = function() {
823 | // Check if pushState option is true, and if browser supports it
824 | return settings.features.pushState && history.pushState;
825 | };
826 |
827 | this.init = function() {
828 | window.onpopstate = function(event) {
829 | if (event.state && event.state.dynatable) {
830 | obj.state.pop(event);
831 | }
832 | }
833 | };
834 |
835 | this.push = function(data) {
836 | var urlString = window.location.search,
837 | urlOptions,
838 | path,
839 | params,
840 | hash,
841 | newParams,
842 | cacheStr,
843 | cache,
844 | // replaceState on initial load, then pushState after that
845 | firstPush = !(window.history.state && window.history.state.dynatable),
846 | pushFunction = firstPush ? 'replaceState' : 'pushState';
847 |
848 | if (urlString && /^\?/.test(urlString)) { urlString = urlString.substring(1); }
849 | $.extend(urlOptions, data);
850 |
851 | params = utility.refreshQueryString(urlString, data, settings);
852 | if (params) { params = '?' + params; }
853 | hash = window.location.hash;
854 | path = window.location.pathname;
855 |
856 | obj.$element.trigger('dynatable:push', data);
857 |
858 | cache = { dynatable: { dataset: settings.dataset } };
859 | if (!firstPush) { cache.dynatable.scrollTop = $(window).scrollTop(); }
860 | cacheStr = JSON.stringify(cache);
861 |
862 | // Mozilla has a 640k char limit on what can be stored in pushState.
863 | // See "limit" in https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#The_pushState().C2.A0method
864 | // and "dataStr.length" in http://wine.git.sourceforge.net/git/gitweb.cgi?p=wine/wine-gecko;a=patch;h=43a11bdddc5fc1ff102278a120be66a7b90afe28
865 | //
866 | // Likewise, other browsers may have varying (undocumented) limits.
867 | // Also, Firefox's limit can be changed in about:config as browser.history.maxStateObjectSize
868 | // Since we don't know what the actual limit will be in any given situation, we'll just try caching and rescue
869 | // any exceptions by retrying pushState without caching the records.
870 | //
871 | // I have absolutely no idea why perPageOptions suddenly becomes an array-like object instead of an array,
872 | // but just recently, this started throwing an error if I don't convert it:
873 | // 'Uncaught Error: DATA_CLONE_ERR: DOM Exception 25'
874 | cache.dynatable.dataset.perPageOptions = $.makeArray(cache.dynatable.dataset.perPageOptions);
875 |
876 | try {
877 | window.history[pushFunction](cache, "Dynatable state", path + params + hash);
878 | } catch(error) {
879 | // Make cached records = null, so that `pop` will rerun process to retrieve records
880 | cache.dynatable.dataset.records = null;
881 | cache.dynatable.dataset.originalRecords = null;
882 | try {
883 | window.history[pushFunction](cache, "Dynatable state", path + params + hash);
884 | } catch(error2) {
885 | console.error("Error pushing state to history, skipping.", error2);
886 | }
887 | }
888 | };
889 |
890 | this.pop = function(event) {
891 | if ( event.state.dynatable.dataset.originalRecords === null) {
892 | event.state.dynatable.dataset.originalRecords = settings.dataset.originalRecords;
893 | }
894 |
895 | var data = event.state.dynatable;
896 | settings.dataset = data.dataset;
897 |
898 | if (data.scrollTop) { $(window).scrollTop(data.scrollTop); }
899 |
900 | // If dataset.records is cached from pushState
901 | if ( data.dataset.records ) {
902 | obj.dom.update();
903 | } else {
904 | obj.process(true);
905 | }
906 | };
907 | };
908 |
909 | function Sorts(obj, settings) {
910 | this.initOnLoad = function() {
911 | return settings.features.sort;
912 | };
913 |
914 | this.init = function() {
915 | var sortsUrl = window.location.search.match(new RegExp(settings.params.sorts + '[^&=]*=[^&]*', 'g'));
916 | if (sortsUrl) {
917 | settings.dataset.sorts = utility.deserialize(sortsUrl)[settings.params.sorts];
918 | }
919 | if (!settings.dataset.sortsKeys.length) {
920 | settings.dataset.sortsKeys = utility.keysFromObject(settings.dataset.sorts);
921 | }
922 | };
923 |
924 | this.add = function(attr, direction) {
925 | var sortsKeys = settings.dataset.sortsKeys,
926 | index = $.inArray(attr, sortsKeys);
927 | settings.dataset.sorts[attr] = direction;
928 | obj.$element.trigger('dynatable:sorts:added', [attr, direction]);
929 | if (index === -1) { sortsKeys.push(attr); }
930 | return dt;
931 | };
932 |
933 | this.remove = function(attr) {
934 | var sortsKeys = settings.dataset.sortsKeys,
935 | index = $.inArray(attr, sortsKeys);
936 | delete settings.dataset.sorts[attr];
937 | obj.$element.trigger('dynatable:sorts:removed', attr);
938 | if (index !== -1) { sortsKeys.splice(index, 1); }
939 | return dt;
940 | };
941 |
942 | this.clear = function() {
943 | settings.dataset.sorts = {};
944 | settings.dataset.sortsKeys.length = 0;
945 | obj.$element.trigger('dynatable:sorts:cleared');
946 | };
947 |
948 | // Try to intelligently guess which sort function to use
949 | // based on the type of attribute values.
950 | // Consider using something more robust than `typeof` (http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/)
951 | this.guessType = function(a, b, attr) {
952 | var types = {
953 | string: 'string',
954 | number: 'number',
955 | 'boolean': 'number',
956 | object: 'number' // dates and null values are also objects, this works...
957 | },
958 | attrType = a[attr] ? typeof(a[attr]) : typeof(b[attr]),
959 | type = types[attrType] || 'number';
960 | return type;
961 | };
962 |
963 | // Built-in sort functions
964 | // (the most common use-cases I could think of)
965 | this.functions = {
966 | number: function(a, b, attr, direction) {
967 | return a[attr] === b[attr] ? 0 : (direction > 0 ? a[attr] - b[attr] : b[attr] - a[attr]);
968 | },
969 | string: function(a, b, attr, direction) {
970 | var aAttr = (a['dynatable-sortable-text'] && a['dynatable-sortable-text'][attr]) ? a['dynatable-sortable-text'][attr] : a[attr],
971 | bAttr = (b['dynatable-sortable-text'] && b['dynatable-sortable-text'][attr]) ? b['dynatable-sortable-text'][attr] : b[attr],
972 | comparison;
973 | aAttr = aAttr.toLowerCase();
974 | bAttr = bAttr.toLowerCase();
975 | comparison = aAttr === bAttr ? 0 : (direction > 0 ? aAttr > bAttr : bAttr > aAttr);
976 | // force false boolean value to -1, true to 1, and tie to 0
977 | return comparison === false ? -1 : (comparison - 0);
978 | },
979 | originalPlacement: function(a, b) {
980 | return a['dynatable-original-index'] - b['dynatable-original-index'];
981 | }
982 | };
983 | };
984 |
985 | // turn table headers into links which add sort to sorts array
986 | function SortsHeaders(obj, settings) {
987 | var _this = this;
988 |
989 | this.initOnLoad = function() {
990 | return settings.features.sort;
991 | };
992 |
993 | this.init = function() {
994 | this.attach();
995 | };
996 |
997 | this.create = function(cell) {
998 | var $cell = $(cell),
999 | $link = $(' ', {
1000 | 'class': 'dynatable-sort-header',
1001 | href: '#',
1002 | html: $cell.html()
1003 | }),
1004 | id = $cell.data('dynatable-column'),
1005 | column = utility.findObjectInArray(settings.table.columns, {id: id});
1006 |
1007 | $link.bind('click', function(e) {
1008 | _this.toggleSort(e, $link, column);
1009 | obj.process();
1010 |
1011 | e.preventDefault();
1012 | });
1013 |
1014 | if (this.sortedByColumn($link, column)) {
1015 | if (this.sortedByColumnValue(column) == 1) {
1016 | this.appendArrowUp($link);
1017 | } else {
1018 | this.appendArrowDown($link);
1019 | }
1020 | }
1021 |
1022 | return $link;
1023 | };
1024 |
1025 | this.removeAll = function() {
1026 | obj.$element.find(settings.table.headRowSelector).children('th,td').each(function(){
1027 | _this.removeAllArrows();
1028 | _this.removeOne(this);
1029 | });
1030 | };
1031 |
1032 | this.removeOne = function(cell) {
1033 | var $cell = $(cell),
1034 | $link = $cell.find('.dynatable-sort-header');
1035 | if ($link.length) {
1036 | var html = $link.html();
1037 | $link.remove();
1038 | $cell.html($cell.html() + html);
1039 | }
1040 | };
1041 |
1042 | this.attach = function() {
1043 | obj.$element.find(settings.table.headRowSelector).children('th,td').each(function(){
1044 | _this.attachOne(this);
1045 | });
1046 | };
1047 |
1048 | this.attachOne = function(cell) {
1049 | var $cell = $(cell);
1050 | if (!$cell.data('dynatable-no-sort')) {
1051 | $cell.html(this.create(cell));
1052 | }
1053 | };
1054 |
1055 | this.appendArrowUp = function($link) {
1056 | this.removeArrow($link);
1057 | $link.append(" ▲ ");
1058 | };
1059 |
1060 | this.appendArrowDown = function($link) {
1061 | this.removeArrow($link);
1062 | $link.append(" ▼ ");
1063 | };
1064 |
1065 | this.removeArrow = function($link) {
1066 | // Not sure why `parent()` is needed, the arrow should be inside the link from `append()` above
1067 | $link.find('.dynatable-arrow').remove();
1068 | };
1069 |
1070 | this.removeAllArrows = function() {
1071 | obj.$element.find('.dynatable-arrow').remove();
1072 | };
1073 |
1074 | this.toggleSort = function(e, $link, column) {
1075 | var sortedByColumn = this.sortedByColumn($link, column),
1076 | value = this.sortedByColumnValue(column);
1077 | // Clear existing sorts unless this is a multisort event
1078 | if (!settings.inputs.multisort || !utility.anyMatch(e, settings.inputs.multisort, function(evt, key) { return e[key]; })) {
1079 | this.removeAllArrows();
1080 | obj.sorts.clear();
1081 | }
1082 |
1083 | // If sorts for this column are already set
1084 | if (sortedByColumn) {
1085 | // If ascending, then make descending
1086 | if (value == 1) {
1087 | for (var i = 0, len = column.sorts.length; i < len; i++) {
1088 | obj.sorts.add(column.sorts[i], -1);
1089 | }
1090 | this.appendArrowDown($link);
1091 | // If descending, remove sort
1092 | } else {
1093 | for (var i = 0, len = column.sorts.length; i < len; i++) {
1094 | obj.sorts.remove(column.sorts[i]);
1095 | }
1096 | this.removeArrow($link);
1097 | }
1098 | // Otherwise, if not already set, set to ascending
1099 | } else {
1100 | for (var i = 0, len = column.sorts.length; i < len; i++) {
1101 | obj.sorts.add(column.sorts[i], 1);
1102 | }
1103 | this.appendArrowUp($link);
1104 | }
1105 | };
1106 |
1107 | this.sortedByColumn = function($link, column) {
1108 | return utility.allMatch(settings.dataset.sorts, column.sorts, function(sorts, sort) { return sort in sorts; });
1109 | };
1110 |
1111 | this.sortedByColumnValue = function(column) {
1112 | return settings.dataset.sorts[column.sorts[0]];
1113 | };
1114 | };
1115 |
1116 | function Queries(obj, settings) {
1117 | var _this = this;
1118 |
1119 | this.initOnLoad = function() {
1120 | return settings.inputs.queries || settings.features.search;
1121 | };
1122 |
1123 | this.init = function() {
1124 | var queriesUrl = window.location.search.match(new RegExp(settings.params.queries + '[^&=]*=[^&]*', 'g'));
1125 |
1126 | settings.dataset.queries = queriesUrl ? utility.deserialize(queriesUrl)[settings.params.queries] : {};
1127 | if (settings.dataset.queries === "") { settings.dataset.queries = {}; }
1128 |
1129 | if (settings.inputs.queries) {
1130 | this.setupInputs();
1131 | }
1132 | };
1133 |
1134 | this.add = function(name, value) {
1135 | // reset to first page since query will change records
1136 | if (settings.features.paginate) {
1137 | settings.dataset.page = 1;
1138 | }
1139 | settings.dataset.queries[name] = value;
1140 | obj.$element.trigger('dynatable:queries:added', [name, value]);
1141 | return dt;
1142 | };
1143 |
1144 | this.remove = function(name) {
1145 | delete settings.dataset.queries[name];
1146 | obj.$element.trigger('dynatable:queries:removed', name);
1147 | return dt;
1148 | };
1149 |
1150 | this.run = function() {
1151 | for (query in settings.dataset.queries) {
1152 | if (settings.dataset.queries.hasOwnProperty(query)) {
1153 | var value = settings.dataset.queries[query];
1154 | if (_this.functions[query] === undefined) {
1155 | // Try to lazily evaluate query from column names if not explicitly defined
1156 | var queryColumn = utility.findObjectInArray(settings.table.columns, {id: query});
1157 | if (queryColumn) {
1158 | _this.functions[query] = function(record, queryValue) {
1159 | return record[query] == queryValue;
1160 | };
1161 | } else {
1162 | $.error("Query named '" + query + "' called, but not defined in queries.functions");
1163 | continue; // to skip to next query
1164 | }
1165 | }
1166 | // collect all records that return true for query
1167 | settings.dataset.records = $.map(settings.dataset.records, function(record) {
1168 | return _this.functions[query](record, value) ? record : null;
1169 | });
1170 | }
1171 | }
1172 | settings.dataset.queryRecordCount = obj.records.count();
1173 | };
1174 |
1175 | // Shortcut for performing simple query from built-in search
1176 | this.runSearch = function(q) {
1177 | var origQueries = $.extend({}, settings.dataset.queries);
1178 | if (q) {
1179 | this.add('search', q);
1180 | } else {
1181 | this.remove('search');
1182 | }
1183 | if (!utility.objectsEqual(settings.dataset.queries, origQueries)) {
1184 | obj.process();
1185 | }
1186 | };
1187 |
1188 | this.setupInputs = function() {
1189 | settings.inputs.queries.each(function() {
1190 | var $this = $(this),
1191 | event = $this.data('dynatable-query-event') || settings.inputs.queryEvent,
1192 | query = $this.data('dynatable-query') || $this.attr('name') || this.id,
1193 | queryFunction = function(e) {
1194 | var q = $(this).val();
1195 | if (q === "") { q = undefined; }
1196 | if (q === settings.dataset.queries[query]) { return false; }
1197 | if (q) {
1198 | _this.add(query, q);
1199 | } else {
1200 | _this.remove(query);
1201 | }
1202 | obj.process();
1203 | e.preventDefault();
1204 | };
1205 |
1206 | $this
1207 | .attr('data-dynatable-query', query)
1208 | .bind(event, queryFunction)
1209 | .bind('keypress', function(e) {
1210 | if (e.which == 13) {
1211 | queryFunction.call(this, e);
1212 | }
1213 | });
1214 |
1215 | if (settings.dataset.queries[query]) { $this.val(decodeURIComponent(settings.dataset.queries[query])); }
1216 | });
1217 | };
1218 |
1219 | // Query functions for in-page querying
1220 | // each function should take a record and a value as input
1221 | // and output true of false as to whether the record is a match or not
1222 | this.functions = {
1223 | search: function(record, queryValue) {
1224 | var contains = false;
1225 | // Loop through each attribute of record
1226 | for (attr in record) {
1227 | if (record.hasOwnProperty(attr)) {
1228 | var attrValue = record[attr];
1229 | if (typeof(attrValue) === "string" && attrValue.toLowerCase().indexOf(queryValue.toLowerCase()) !== -1) {
1230 | contains = true;
1231 | // Don't need to keep searching attributes once found
1232 | break;
1233 | } else {
1234 | continue;
1235 | }
1236 | }
1237 | }
1238 | return contains;
1239 | }
1240 | };
1241 | };
1242 |
1243 | function InputsSearch(obj, settings) {
1244 | var _this = this;
1245 |
1246 | this.initOnLoad = function() {
1247 | return settings.features.search;
1248 | };
1249 |
1250 | this.init = function() {
1251 | this.attach();
1252 | };
1253 |
1254 | this.create = function() {
1255 | var $search = $(' ', {
1256 | type: 'search',
1257 | id: 'dynatable-query-search-' + obj.element.id,
1258 | 'data-dynatable-query': 'search',
1259 | value: settings.dataset.queries.search
1260 | }),
1261 | $searchSpan = $(' ', {
1262 | id: 'dynatable-search-' + obj.element.id,
1263 | 'class': 'dynatable-search',
1264 | text: settings.inputs.searchText
1265 | }).append($search);
1266 |
1267 | $search
1268 | .bind(settings.inputs.queryEvent, function() {
1269 | obj.queries.runSearch($(this).val());
1270 | })
1271 | .bind('keypress', function(e) {
1272 | if (e.which == 13) {
1273 | obj.queries.runSearch($(this).val());
1274 | e.preventDefault();
1275 | }
1276 | });
1277 | return $searchSpan;
1278 | };
1279 |
1280 | this.attach = function() {
1281 | var $target = settings.inputs.searchTarget ? $(settings.inputs.searchTarget) : obj.$element;
1282 | $target[settings.inputs.searchPlacement](this.create());
1283 | };
1284 | };
1285 |
1286 | // provide a public function for selecting page
1287 | function PaginationPage(obj, settings) {
1288 | this.initOnLoad = function() {
1289 | return settings.features.paginate;
1290 | };
1291 |
1292 | this.init = function() {
1293 | var pageUrl = window.location.search.match(new RegExp(settings.params.page + '=([^&]*)'));
1294 | // If page is present in URL parameters and pushState is enabled
1295 | // (meaning that it'd be possible for dynatable to have put the
1296 | // page parameter in the URL)
1297 | if (pageUrl && settings.features.pushState) {
1298 | this.set(pageUrl[1]);
1299 | } else {
1300 | this.set(1);
1301 | }
1302 | };
1303 |
1304 | this.set = function(page) {
1305 | var newPage = parseInt(page, 10);
1306 | settings.dataset.page = newPage;
1307 | obj.$element.trigger('dynatable:page:set', newPage);
1308 | }
1309 | };
1310 |
1311 | function PaginationPerPage(obj, settings) {
1312 | var _this = this;
1313 |
1314 | this.initOnLoad = function() {
1315 | return settings.features.paginate;
1316 | };
1317 |
1318 | this.init = function() {
1319 | var perPageUrl = window.location.search.match(new RegExp(settings.params.perPage + '=([^&]*)'));
1320 |
1321 | // If perPage is present in URL parameters and pushState is enabled
1322 | // (meaning that it'd be possible for dynatable to have put the
1323 | // perPage parameter in the URL)
1324 | if (perPageUrl && settings.features.pushState) {
1325 | // Don't reset page to 1 on init, since it might override page
1326 | // set on init from URL
1327 | this.set(perPageUrl[1], true);
1328 | } else {
1329 | this.set(settings.dataset.perPageDefault, true);
1330 | }
1331 |
1332 | if (settings.features.perPageSelect) {
1333 | this.attach();
1334 | }
1335 | };
1336 |
1337 | this.create = function() {
1338 | var $select = $('', {
1339 | id: 'dynatable-per-page-' + obj.element.id,
1340 | 'class': 'dynatable-per-page-select'
1341 | });
1342 |
1343 | for (var i = 0, len = settings.dataset.perPageOptions.length; i < len; i++) {
1344 | var number = settings.dataset.perPageOptions[i],
1345 | selected = settings.dataset.perPage == number ? 'selected="selected"' : '';
1346 | $select.append('' + number + ' ');
1347 | }
1348 |
1349 | $select.bind('change', function(e) {
1350 | _this.set($(this).val());
1351 | obj.process();
1352 | });
1353 |
1354 | return $(' ', {
1355 | 'class': 'dynatable-per-page'
1356 | }).append("" + settings.inputs.perPageText + " ").append($select);
1357 | };
1358 |
1359 | this.attach = function() {
1360 | var $target = settings.inputs.perPageTarget ? $(settings.inputs.perPageTarget) : obj.$element;
1361 | $target[settings.inputs.perPagePlacement](this.create());
1362 | };
1363 |
1364 | this.set = function(number, skipResetPage) {
1365 | var newPerPage = parseInt(number);
1366 | if (!skipResetPage) { obj.paginationPage.set(1); }
1367 | settings.dataset.perPage = newPerPage;
1368 | obj.$element.trigger('dynatable:perPage:set', newPerPage);
1369 | };
1370 | };
1371 |
1372 | // pagination links which update dataset.page attribute
1373 | function PaginationLinks(obj, settings) {
1374 | var _this = this;
1375 |
1376 | this.initOnLoad = function() {
1377 | return settings.features.paginate;
1378 | };
1379 |
1380 | this.init = function() {
1381 | this.attach();
1382 | };
1383 |
1384 | this.create = function() {
1385 | var pageLinks = '';
1435 |
1436 | // only bind page handler to non-active and non-disabled page links
1437 | var selector = '#dynatable-pagination-links-' + obj.element.id + ' a.' + pageLinkClass + ':not(.' + activePageClass + ',.' + disabledPageClass + ')';
1438 | // kill any existing delegated-bindings so they don't stack up
1439 | $(document).undelegate(selector, 'click.dynatable');
1440 | $(document).delegate(selector, 'click.dynatable', function(e) {
1441 | $this = $(this);
1442 | $this.closest(settings.inputs.paginationClass).find('.' + activePageClass).removeClass(activePageClass);
1443 | $this.addClass(activePageClass);
1444 |
1445 | obj.paginationPage.set($this.data('dynatable-page'));
1446 | obj.process();
1447 | e.preventDefault();
1448 | });
1449 |
1450 | return pageLinks;
1451 | };
1452 |
1453 | this.buildLink = function(page, label, linkClass, conditional, conditionalClass) {
1454 | var link = '' + label + ' ';
1463 | li += '>' + link + '';
1464 |
1465 | return li;
1466 | };
1467 |
1468 | this.attach = function() {
1469 | // append page links *after* delegate-event-binding so it doesn't need to
1470 | // find and select all page links to bind event
1471 | var $target = settings.inputs.paginationLinkTarget ? $(settings.inputs.paginationLinkTarget) : obj.$element;
1472 | $target[settings.inputs.paginationLinkPlacement](obj.paginationLinks.create());
1473 | };
1474 | };
1475 |
1476 | utility = dt.utility = {
1477 | normalizeText: function(text, style) {
1478 | text = this.textTransform[style](text);
1479 | return text;
1480 | },
1481 | textTransform: {
1482 | trimDash: function(text) {
1483 | return text.replace(/^\s+|\s+$/g, "").replace(/\s+/g, "-");
1484 | },
1485 | camelCase: function(text) {
1486 | text = this.trimDash(text);
1487 | return text
1488 | .replace(/(\-[a-zA-Z])/g, function($1){return $1.toUpperCase().replace('-','');})
1489 | .replace(/([A-Z])([A-Z]+)/g, function($1,$2,$3){return $2 + $3.toLowerCase();})
1490 | .replace(/^[A-Z]/, function($1){return $1.toLowerCase();});
1491 | },
1492 | dashed: function(text) {
1493 | text = this.trimDash(text);
1494 | return this.lowercase(text);
1495 | },
1496 | underscore: function(text) {
1497 | text = this.trimDash(text);
1498 | return this.lowercase(text.replace(/(-)/g, '_'));
1499 | },
1500 | lowercase: function(text) {
1501 | return text.replace(/([A-Z])/g, function($1){return $1.toLowerCase();});
1502 | }
1503 | },
1504 | // Deserialize params in URL to object
1505 | // see http://stackoverflow.com/questions/1131630/javascript-jquery-param-inverse-function/3401265#3401265
1506 | deserialize: function(query) {
1507 | if (!query) return {};
1508 | // modified to accept an array of partial URL strings
1509 | if (typeof(query) === "object") { query = query.join('&'); }
1510 |
1511 | var hash = {},
1512 | vars = query.split("&");
1513 |
1514 | for (var i = 0; i < vars.length; i++) {
1515 | var pair = vars[i].split("="),
1516 | k = decodeURIComponent(pair[0]),
1517 | v, m;
1518 |
1519 | if (!pair[1]) { continue };
1520 | v = decodeURIComponent(pair[1].replace(/\+/g, ' '));
1521 |
1522 | // modified to parse multi-level parameters (e.g. "hi[there][dude]=whatsup" => hi: {there: {dude: "whatsup"}})
1523 | while (m = k.match(/([^&=]+)\[([^&=]+)\]$/)) {
1524 | var origV = v;
1525 | k = m[1];
1526 | v = {};
1527 |
1528 | // If nested param ends in '][', then the regex above erroneously included half of a trailing '[]',
1529 | // which indicates the end-value is part of an array
1530 | if (m[2].substr(m[2].length-2) == '][') { // must use substr for IE to understand it
1531 | v[m[2].substr(0,m[2].length-2)] = [origV];
1532 | } else {
1533 | v[m[2]] = origV;
1534 | }
1535 | }
1536 |
1537 | // If it is the first entry with this name
1538 | if (typeof hash[k] === "undefined") {
1539 | if (k.substr(k.length-2) != '[]') { // not end with []. cannot use negative index as IE doesn't understand it
1540 | hash[k] = v;
1541 | } else {
1542 | hash[k] = [v];
1543 | }
1544 | // If subsequent entry with this name and not array
1545 | } else if (typeof hash[k] === "string") {
1546 | hash[k] = v; // replace it
1547 | // modified to add support for objects
1548 | } else if (typeof hash[k] === "object") {
1549 | hash[k] = $.extend({}, hash[k], v);
1550 | // If subsequent entry with this name and is array
1551 | } else {
1552 | hash[k].push(v);
1553 | }
1554 | }
1555 | return hash;
1556 | },
1557 | refreshQueryString: function(urlString, data, settings) {
1558 | var _this = this,
1559 | queryString = urlString.split('?'),
1560 | path = queryString.shift(),
1561 | urlOptions;
1562 |
1563 | urlOptions = this.deserialize(urlString);
1564 |
1565 | // Loop through each dynatable param and update the URL with it
1566 | for (attr in settings.params) {
1567 | if (settings.params.hasOwnProperty(attr)) {
1568 | var label = settings.params[attr];
1569 | // Skip over parameters matching attributes for disabled features (i.e. leave them untouched),
1570 | // because if the feature is turned off, then parameter name is a coincidence and it's unrelated to dynatable.
1571 | if (
1572 | (!settings.features.sort && attr == "sorts") ||
1573 | (!settings.features.paginate && _this.anyMatch(attr, ["page", "perPage", "offset"], function(attr, param) { return attr == param; }))
1574 | ) {
1575 | continue;
1576 | }
1577 |
1578 | // Delete page and offset from url params if on page 1 (default)
1579 | if ((attr === "page" || attr === "offset") && data["page"] === 1) {
1580 | if (urlOptions[label]) {
1581 | delete urlOptions[label];
1582 | }
1583 | continue;
1584 | }
1585 |
1586 | // Delete perPage from url params if default perPage value
1587 | if (attr === "perPage" && data[label] == settings.dataset.perPageDefault) {
1588 | if (urlOptions[label]) {
1589 | delete urlOptions[label];
1590 | }
1591 | continue;
1592 | }
1593 |
1594 | // For queries, we're going to handle each possible query parameter individually here instead of
1595 | // handling the entire queries object below, since we need to make sure that this is a query controlled by dynatable.
1596 | if (attr == "queries" && data[label]) {
1597 | var queries = settings.inputs.queries || [],
1598 | inputQueries = $.makeArray(queries.map(function() { return $(this).attr('name') }));
1599 |
1600 | if (settings.features.search) { inputQueries.push('search'); }
1601 |
1602 | for (var i = 0, len = inputQueries.length; i < len; i++) {
1603 | var attr = inputQueries[i];
1604 | if (data[label][attr]) {
1605 | if (typeof urlOptions[label] === 'undefined') { urlOptions[label] = {}; }
1606 | urlOptions[label][attr] = data[label][attr];
1607 | } else {
1608 | if (urlOptions && urlOptions[label] && urlOptions[label][attr]) { delete urlOptions[label][attr]; }
1609 | }
1610 | }
1611 | continue;
1612 | }
1613 |
1614 | // If we haven't returned true by now, then we actually want to update the parameter in the URL
1615 | if (data[label]) {
1616 | urlOptions[label] = data[label];
1617 | } else {
1618 | delete urlOptions[label];
1619 | }
1620 | }
1621 | }
1622 | return $.param(urlOptions);
1623 | },
1624 | // Get array of keys from object
1625 | // see http://stackoverflow.com/questions/208016/how-to-list-the-properties-of-a-javascript-object/208020#208020
1626 | keysFromObject: function(obj){
1627 | var keys = [];
1628 | for (var key in obj){
1629 | keys.push(key);
1630 | }
1631 | return keys;
1632 | },
1633 | // Find an object in an array of objects by attributes.
1634 | // E.g. find object with {id: 'hi', name: 'there'} in an array of objects
1635 | findObjectInArray: function(array, objectAttr) {
1636 | var _this = this,
1637 | foundObject;
1638 | for (var i = 0, len = array.length; i < len; i++) {
1639 | var item = array[i];
1640 | // For each object in array, test to make sure all attributes in objectAttr match
1641 | if (_this.allMatch(item, objectAttr, function(item, key, value) { return item[key] == value; })) {
1642 | foundObject = item;
1643 | break;
1644 | }
1645 | }
1646 | return foundObject;
1647 | },
1648 | // Return true if supplied test function passes for ALL items in an array
1649 | allMatch: function(item, arrayOrObject, test) {
1650 | // start off with true result by default
1651 | var match = true,
1652 | isArray = $.isArray(arrayOrObject);
1653 | // Loop through all items in array
1654 | $.each(arrayOrObject, function(key, value) {
1655 | var result = isArray ? test(item, value) : test(item, key, value);
1656 | // If a single item tests false, go ahead and break the array by returning false
1657 | // and return false as result,
1658 | // otherwise, continue with next iteration in loop
1659 | // (if we make it through all iterations without overriding match with false,
1660 | // then we can return the true result we started with by default)
1661 | if (!result) { return match = false; }
1662 | });
1663 | return match;
1664 | },
1665 | // Return true if supplied test function passes for ANY items in an array
1666 | anyMatch: function(item, arrayOrObject, test) {
1667 | var match = false,
1668 | isArray = $.isArray(arrayOrObject);
1669 |
1670 | $.each(arrayOrObject, function(key, value) {
1671 | var result = isArray ? test(item, value) : test(item, key, value);
1672 | if (result) {
1673 | // As soon as a match is found, set match to true, and return false to stop the `$.each` loop
1674 | match = true;
1675 | return false;
1676 | }
1677 | });
1678 | return match;
1679 | },
1680 | // Return true if two objects are equal
1681 | // (i.e. have the same attributes and attribute values)
1682 | objectsEqual: function(a, b) {
1683 | for (attr in a) {
1684 | if (a.hasOwnProperty(attr)) {
1685 | if (!b.hasOwnProperty(attr) || a[attr] !== b[attr]) {
1686 | return false;
1687 | }
1688 | }
1689 | }
1690 | for (attr in b) {
1691 | if (b.hasOwnProperty(attr) && !a.hasOwnProperty(attr)) {
1692 | return false;
1693 | }
1694 | }
1695 | return true;
1696 | },
1697 | // Taken from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/105074#105074
1698 | randomHash: function() {
1699 | return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
1700 | },
1701 | // Adapted from http://stackoverflow.com/questions/377961/efficient-javascript-string-replacement/378001#378001
1702 | template: function(str, data) {
1703 | return str.replace(/{(\w*)}/g, function(match, key) {
1704 | return data.hasOwnProperty(key) ? data[key] : "";
1705 | });
1706 | }
1707 | };
1708 |
1709 | //-----------------------------------------------------------------
1710 | // Build the dynatable plugin
1711 | //-----------------------------------------------------------------
1712 |
1713 | // Object.create support test, and fallback for browsers without it
1714 | if ( typeof Object.create !== "function" ) {
1715 | Object.create = function (o) {
1716 | function F() {}
1717 | F.prototype = o;
1718 | return new F();
1719 | };
1720 | }
1721 |
1722 | //-----------------------------------------------------------------
1723 | // Global dynatable plugin setting defaults
1724 | //-----------------------------------------------------------------
1725 |
1726 | $.dynatableSetup = function(options) {
1727 | defaults = mergeSettings(options);
1728 | };
1729 |
1730 | // Create dynatable plugin based on a defined object
1731 | $.dynatable = function( object ) {
1732 | $.fn['dynatable'] = function( options ) {
1733 | return this.each(function() {
1734 | if ( ! $.data( this, 'dynatable' ) ) {
1735 | $.data( this, 'dynatable', Object.create(object).init(this, options) );
1736 | }
1737 | });
1738 | };
1739 | };
1740 |
1741 | $.dynatable(dt);
1742 |
1743 | })(jQuery);
1744 |
--------------------------------------------------------------------------------
/vendor/jquery-1.7.2.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v1.7.2 jquery.com | jquery.org/license */
2 | (function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;ca ",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q=""+"",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="
",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(
3 | a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c ",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML=" ",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="
";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/ ]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*"," "],legend:[1,""," "],thead:[1,""],tr:[2,""],td:[3,""],col:[2,""],area:[1,""," "],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div","
"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f
4 | .clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>$2>");try{for(;d1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1>$2>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]===""&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/