Debian Codegraph @

docs/example-parsers-globalize.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Parsers Globalize</title>
6
7 <!-- jQuery -->
8 <script src="js/jquery-latest.min.js"></script>
9
10 <!-- Demo stuff -->
11 <link rel="stylesheet" href="css/jq.css">
12 <link href="css/prettify.css" rel="stylesheet">
13 <script src="js/prettify.js"></script>
14 <script src="js/docs.js"></script>
15
16 <!-- Tablesorter: required -->
17 <link rel="stylesheet" href="../css/theme.blue.css">
18 <style>th { width: 25%; }</style>
19 <script src="../js/jquery.tablesorter.js"></script>
20 <script src="../js/parsers/parser-globalize.js"></script>
21
22 <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.3/cldr.min.js"></script>
23 <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.3/cldr/event.min.js"></script>
24 <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.3/cldr/supplemental.min.js"></script>
25 <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.3/cldr/unresolved.min.js"></script>
26 <script src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.0.0/globalize.min.js"></script>
27 <script src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.0.0/globalize/number.min.js"></script>
28 <script src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.0.0/globalize/date.js"></script>
29
30 <script id="js">$(function () {
31
32 // data loaded from CLDR (https://github.com/unicode-cldr)
33 Globalize.load(data);
34 // set up Globalize language per column (only using "en" {English} in this demo)
35 var en = Globalize('en');
36
37 $('table').tablesorter({
38 theme: 'blue',
39 widthFixed: true,
40 // globalize options
41 globalize: {
42 // in v2.24.1, use Globalize to cache the object; lang should only contain the string
43 1: { lang : 'en', Globalize : en },
44 3: { lang : 'en', Globalize : en, raw: 'MMM d, y G' }
45 },
46 headers: {
47 1: { sorter: 'globalize-number' },
48 3: { sorter: 'globalize-date' }
49 }
50 });
51
52 // *** FOR DEMO ONLY ***
53 // add parsed values to Globalize numeric & date columns
54 addParsedValues( $( 'table' ), [ 1, 3 ] );
55
56 });
57 </script>
58 <script>
59 /* only a small portion of the CLDR JavaScript Library
60 (https://github.com/unicode-cldr) is included below */
61 var data = {
62 "main": {
63 "en": {
64 "identity": {
65 "version": {
66 "_cldrVersion": "25",
67 "_number": "$Revision: 91 $"
68 },
69 "generation": {
70 "_date": "$Date: 2014-03-13 22:27:12 -0500 (Thu, 13 Mar 2014) $"
71 },
72 "language": "en"
73 },
74 "dates": {
75 "calendars": {
76 "gregorian": {
77 "months": {
78 "format": {
79 "abbreviated": {
80 "1": "Jan",
81 "2": "Feb",
82 "3": "Mar",
83 "4": "Apr",
84 "5": "May",
85 "6": "Jun",
86 "7": "Jul",
87 "8": "Aug",
88 "9": "Sep",
89 "10": "Oct",
90 "11": "Nov",
91 "12": "Dec"
92 }
93 }
94 },
95 "dayPeriods": {
96 "format": {
97 "wide": {
98 "am": "AM",
99 "am-alt-variant": "am",
100 "noon": "noon",
101 "pm": "PM",
102 "pm-alt-variant": "pm"
103 }
104 }
105 },
106 "eras": {
107 "eraAbbr": {
108 "0": "BC",
109 "0-alt-variant": "BCE",
110 "1": "AD",
111 "1-alt-variant": "CE"
112 }
113 },
114 "dateFormats": {
115 "medium": "MMM d, y"
116 },
117 "timeFormats": {
118 "medium": "h:mm:ss a",
119 },
120 "dateTimeFormats": {
121 "medium": "{1}, {0}",
122 "availableFormats": {
123 "E": "ccc",
124 "EHm": "E HH:mm",
125 "EHms": "E HH:mm:ss",
126 "Ed": "d E",
127 "Ehm": "E h:mm a",
128 "Ehms": "E h:mm:ss a",
129 "Gy": "y G",
130 "GyMMM": "MMM y G",
131 "GyMMMEd": "E, MMM d, y G",
132 "GyMMMd": "MMM d, y G",
133 "H": "HH",
134 "Hm": "HH:mm",
135 "Hms": "HH:mm:ss",
136 "M": "L",
137 "MEd": "E, M/d",
138 "MMM": "LLL",
139 "MMMEd": "E, MMM d",
140 "MMMd": "MMM d",
141 "Md": "M/d",
142 "d": "d",
143 "h": "h a",
144 "hm": "h:mm a",
145 "hms": "h:mm:ss a",
146 "ms": "mm:ss",
147 "y": "y",
148 "yM": "M/y",
149 "yMEd": "E, M/d/y",
150 "yMMM": "MMM y",
151 "yMMMEd": "E, MMM d, y",
152 "yMMMd": "MMM d, y",
153 "yMd": "M/d/y",
154 "yQQQ": "QQQ y",
155 "yQQQQ": "QQQQ y"
156 }
157 }
158 }
159 },
160 "fields": {
161 "second": {
162 "displayName": "Second",
163 "relative-type-0": "now",
164 "relativeTime-type-future": {
165 "relativeTimePattern-count-one": "in {0} second",
166 "relativeTimePattern-count-other": "in {0} seconds"
167 },
168 "relativeTime-type-past": {
169 "relativeTimePattern-count-one": "{0} second ago",
170 "relativeTimePattern-count-other": "{0} seconds ago"
171 }
172 }
173 }
174 },
175 "numbers": {
176 "currencies": {
177 "USD": {
178 "symbol": "$"
179 }
180 },
181 "defaultNumberingSystem": "latn",
182 "symbols-numberSystem-latn": {
183 "decimal": ".",
184 "exponential": "E",
185 "group": ",",
186 "infinity": "∞",
187 "minusSign": "-",
188 "nan": "NaN",
189 "percentSign": "%",
190 "perMille": "‰",
191 "plusSign": "+",
192 "timeSeparator": ":"
193 },
194 "decimalFormats-numberSystem-latn": {
195 "standard": "#,##0.###"
196 },
197 "currencyFormats-numberSystem-latn": {
198 "currencySpacing": {
199 "beforeCurrency": {
200 "currencyMatch": "[:^S:]",
201 "surroundingMatch": "[:digit:]",
202 "insertBetween": " "
203 },
204 "afterCurrency": {
205 "currencyMatch": "[:^S:]",
206 "surroundingMatch": "[:digit:]",
207 "insertBetween": " "
208 }
209 },
210 "standard": "¤#,##0.00"
211 }
212 }
213 }
214 },
215 "supplemental": {
216 "version": {
217 "_cldrVersion": "25",
218 "_number": "$Revision: 91 $"
219 },
220 "currencyData": {
221 "fractions": {
222 "DEFAULT": {
223 "_rounding": "0",
224 "_digits": "2"
225 }
226 }
227 },
228 "timeData": {
229 "001": {
230 "_allowed": "H h",
231 "_preferred": "H"
232 }
233 },
234 "likelySubtags": {
235 "en": "en-Latn-US",
236 },
237 "plurals-type-cardinal": {
238 "en": {
239 "pluralRule-count-one": "i = 1 and v = 0 @integer 1",
240 "pluralRule-count-other": " @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …"
241 }
242 }
243 }
244 };
245 </script>
246 </head>
247 <body>
248 <div id="banner">
249 <h1>table<em>sorter</em></h1>
250 <h2>Parsers Globalize</h2>
251 <h3>Flexible client-side table sorting</h3>
252 <a href="index.html">Back to documentation</a>
253 </div>
254 <div id="main">
255
256 <p class="tip">
257 <em>NOTE!</em>
258 </p>
259 <ul>
260 <li>In <span class="version updated">v2.24.1</span>,
261 <ul>
262 <li>An internal change made it necessary to change the <code>lang</code> option to only hold a string of the set language.</li>
263 <li>To cache the Globalize object, save it as a <code>Globalize</code> option (see code example below).</li>
264 </ul>
265 </li>
266 <li><a href="https://github.com/jquery/globalize">jQuery Globalize</a> supports the parsing of locale specific data, including <a href="https://github.com/jquery/globalize/blob/master/doc/api/number/number-parser.md">numerous number formats</a> (including Arabic, Chinese &amp; Japanese) and <a href="https://github.com/jquery/globalize/blob/master/doc/api/date/date-parser.md">custom date formats</a>.</li>
267 <li>This is a very basic example using English only. For another example, see the <a href="example-parsers-dates.html">weekday &amp; month parsers</a>.</li>
268 <li>For more details on how to set up Globalize, see the <a href="example-widget-grouping.html#globalization">Grouping widget documentation about Globalization</a>.</li>
269 </ul>
270
271 <h1>Demo</h1>
272 <div id="demo"><button type="button" class="toggleparsedvalue">toggle</button> parsed values within the column
273
274 <table class="tablesorter">
275 <thead>
276 <tr><th>AlphaNumeric</th><th>Numeric (Globalize)</th><th>Animals</th><th>Date (Globalize)</th>
277 </tr>
278 </thead>
279 <tbody>
280 <tr><td>abc 123</td><td>12,735.00</td><td>Koala</td><td>Jan 22, 2015 AD</td></tr>
281 <tr><td>abc 1</td><td>65.34</td><td>Ox</td><td>Mar 30, 2015 AD</td></tr>
282 <tr><td>abc 9</td><td>∞</td><td>Girafee</td><td>Dec 31, 2014 AD</td></tr>
283 <tr><td>zyx 24</td><td>-∞</td><td>Bison</td><td>Apr 13, 2015 AD</td></tr>
284 <tr><td>abc 11</td><td>0.44</td><td>Chimp</td><td>Oct 31, 2015 AD</td></tr>
285 <tr><td>abc 2</td><td>5.6</td><td>Elephant</td><td>May 3, 2015 AD</td></tr>
286 <tr><td>abc 9</td><td>1,345,155</td><td>Lion</td><td>Jun 30, 2014 AD</td></tr>
287 <tr><td>ABC 10</td><td>2,875.33</td><td>Zebra</td><td>Feb 14, 2015 AD</td></tr>
288 <tr><td>zyx 1</td><td>99.9</td><td>Koala</td><td>Mar 20, 2015 AD</td></tr>
289 <tr><td>zyx 12</td><td>1.2</td><td>Llama</td><td>Mar 2, 2015 AD</td></tr>
290 </tbody>
291 </table>
292 </div>
293
294 <h1>Javascript</h1>
295 <div id="javascript">
296 <pre class="prettyprint lang-javascript"></pre>
297 </div>
298 <h1>HTML</h1>
299 <div id="html">
300 <pre class="prettyprint lang-html"></pre>
301 </div>
302
303 </div>
304
305 </body>
306 </html>