1// Dynamically load VSIndexedDBHelper from the path defined in window.VS_INDEXEDDB_HELPER_PATH 2// We use this instead of a static import because rails fingerprints assets 3// so we need to allow flexibility in loading the module path dynamically 4// based on the runtime environment or configuration (e.g., window.VIEWSPACE_VIDEOS_PATH). 5let VSIndexedDBHelper; 6const loadVSIndexedDBHelper = async () => { 7 if (!VSIndexedDBHelper) { 8 console.debug('Attempting to dynamically load VSIndexedDBHelper from path:', window.VS_INDEXEDDB_HELPER_PATH); 9 try { 10 const module = await import(window.VS_INDEXEDDB_HELPER_PATH); 11 // Be tolerant: module may export the class as default, as a named export, or export an object containing it. 12 const candidate = module.default || module.VSIndexedDBHelper || module; 13 // If the candidate is a module namespace object, try to pick a property that looks like the helper 14 if (candidate && typeof candidate === 'object' && candidate.VSIndexedDBHelper) { 15 VSIndexedDBHelper = candidate.VSIndexedDBHelper; 16 } else { 17 VSIndexedDBHelper = candidate; 18 } 19 console.debug('Successfully loaded VSIndexedDBHelper:', VSIndexedDBHelper); 20 } catch (error) { 21 console.error('Failed to load VSIndexedDBHelper:', error); 22 throw error; 23 } 24 } 25 return VSIndexedDBHelper; 26}; 27 28function setupViewspaceEventSync() { 29 const safeUpload = () => { 30 console.debug('In safeUpload...'); 31 const inst = window.vse; 32 if (inst && typeof inst.uploadUnsyncedEvents === 'function') { 33 return inst.uploadUnsyncedEvents(); 34 } else { 35 console.warn('ViewspaceEvents instance not ready yet; skipping upload trigger.'); 36 } 37 };
38 // 1. Periodic sync 39 const uploadInterval = 3 * 60 * 1000; // 3 minutes in milliseconds, as of 2025-07-01 avg. duration of videos is 163s 40 setInterval(() => { 41 console.log('Periodic sync, uploading unsynced events...', { interval: uploadInterval, nextRun: new Date(Date.now() + uploadInterval) }); 42 safeUpload(); 43 }, uploadInterval); 44 45 // 2. On page unload 46 // When does beforeunload fire? 47 // - The user closes the browser tab or window. 48 // - The user navigates to a different URL (by clicking a link, entering a new address, or using bookmarks). 49 // - The user reloads the page (F5, Ctrl+R, or the browser reload button). 50 // - The user submits a form that causes a navigation. 51 // - The user uses browser navigation buttons (back/forward). 52 window.addEventListener('beforeunload', () => { 53 console.debug('Page unload detected, uploading unsynced events...'); 54 safeUpload(); 55 }); 56 57 // 3. On network reconnect 58 window.addEventListener('online', () => { 59 console.debug('Network reconnected, uploading unsynced events...'); 60 safeUpload(); 61 }); 62 63 // 4. (Optional) On tab visibility change (when user returns to tab) 64 document.addEventListener('visibilitychange', () => { 65 if (document.visibilityState === 'visible') { 66 console.debug('Tab became visible, uploading unsynced events...'); 67 safeUpload(); 68 } 69 }); 70} 71 72function initializeViewspaceEvents() { 73 window.waitForGlobal('VIEWSPACE_VISIT_ID', 100, 15000) 74 .then(() => { 75 window.vse = new ViewspaceEvents(window.VIEWSPACE_VISIT_ID, window.VIEWSPACE_USER_ID); 76 return window.vse.init(); 77 }) 78 .then(() => { 79 console.log('ViewspaceEvents initialized successfully (as window.vse):', window.vse); 80 81 window.vseErrors = new ViewspaceErrorEvents(window.vse); 82 window.vseErrors.initialize(); 83 try { setupViewspaceEventSync(); } catch (e) { console.warn('setupViewspaceEventSync failed:', e); } 84 }) 85 .catch(e => { 86 console.error('Failed to initialize ViewspaceEvents after waiting for VIEWSPACE_VISIT_ID:', e); 87 }); 88} 89 90// --- ViewspaceErrorEvents Class --- 91class ViewspaceErrorEvents { 92 static MAX_STACK_LENGTH = 2000; 93 94 // --- Static Methods (alphabetical) --- 95 96 static eventTimestampToISO(event) { 97 if (event && typeof event.timeStamp === 'number' && window.performance) { 98 let origin = (typeof performance.timeOrigin === 'number') 99 ? performance.timeOrigin 100 : (performance.timing && performance.timing.navigationStart) ? performance.timing.navigationStart : null; 101 if (origin) { 102 return new Date(origin + event.timeStamp).toISOString(); 103 } 104 } 105 return undefined; 106 } 107 108 constructor(vseInstance) { 109 this.vseInstance = vseInstance; 110 this._errorHandler = null; 111 this._unhandledRejectionHandler = null; 112 } 113 114 initialize() { 115 // Remove previous handlers if any (store on instance) 116 if (this._errorHandler) window.removeEventListener('error', this._errorHandler); 117 if (this._unhandledRejectionHandler) window.removeEventListener('unhandledrejection', this._unhandledRejectionHandler); 118 119 this._errorHandler = (event) => { 120 let name = 'Uncaught error'; 121 let reason = event.error ? event.error.toString() : null; 122 let stack = event.error && event.error.stack ? event.error.stack : null; 123 let time = ViewspaceErrorEvents.eventTimestampToISO(event); 124 this.vseInstance.recordErrorEvent({ name, reason, stack, time }); 125 }; 126 this._unhandledRejectionHandler = (event) => { 127 let name = 'Unhandled promise rejection'; 128 let reason = event.reason ? event.reason.toString() : null; 129 let stack = event.reason && event.reason.stack ? event.reason.stack : null; 130 let time = ViewspaceErrorEvents.eventTimestampToISO(event); 131 this.vseInstance.recordErrorEvent({ name, reason, stack, time }); 132 }; 133 window.addEventListener('error', this._errorHandler); 134 window.addEventListener('unhandledrejection', this._unhandledRejectionHandler); 135 } 136} 137 138// --- ViewspaceEvents Class --- 139class ViewspaceEvents { 140 // --- Static Properties --- 141 static DB_NAME = 'viewspace_events'; 142 static EVENT_STORE = 'events';
143 static EVENT_STORE_SCHEMAS = { 144 1: { [ViewspaceEvents.EVENT_STORE]: 'id,visit_id,user_id,name,properties,time' }, 145 2: { [ViewspaceEvents.EVENT_STORE]: '++id,visit_id,user_id,name,properties,time,synced' }, 146 3: { [ViewspaceEvents.EVENT_STORE]: '++id,visit_id,user_id,name,time' } 147 }; 148 static LATEST_SCHEMA_VERSION = 3; 149 static MAX_BATCH_BYTES = 300 * 1024; 150 static MAX_BATCH_COUNT = 500; 151 static MAX_STACK_LENGTH = 2000; 152 static MIN_BATCH_COUNT = 1; 153 static _ipPromise = null; 154 155 // --- Static Methods (alphabetical) --- 156 157 /** 158 * Convert event.timeStamp to ISO string using timeOrigin or navigationStart 159 * @param {Event} event 160 * @returns {string|undefined} 161 */ 162 static eventTimestampToISO(event) { 163 if (event && typeof event.timeStamp === 'number' && window.performance) { 164 let origin = (typeof performance.timeOrigin === 'number') 165 ? performance.timeOrigin 166 : (performance.timing && performance.timing.navigationStart) ? performance.timing.navigationStart : null; 167 if (origin) { 168 return new Date(origin + event.timeStamp).toISOString(); 169 } 170 } 171 return undefined; 172 } 173 174 /** 175 * Fetch the user's public IP address (IPv4 or IPv6) 176 * Uses a public API (ipify.org). Returns a promise that resolves to the IP string or null. 177 */ 178 static fetchIpAddress() { 179 if (!ViewspaceEvents._ipPromise) { 180 const metaIp = (() => { 181 const meta = document.querySelector('meta[name="request-ip"]'); 182 if (!meta) return null; 183 const value = meta.getAttribute('content'); 184 if (typeof value !== 'string') return null; 185 const sanitized = value.trim(); 186 if (sanitized.length === 0) return null; 187 if (sanitized === 'null' || sanitized === 'undefined') return null; 188 return sanitized; 189 })(); 190 191 if (metaIp) { 192 ViewspaceEvents._ipPromise = Promise.resolve(metaIp); 193 } else { 194 ViewspaceEvents._ipPromise = fetch('https://api.ipify.org?format=json') 195 .then(r => r.ok ? r.json() : null) 196 .then(data => (data && data.ip) ? data.ip : null) 197 .catch(() => null); 198 } 199 } 200 return ViewspaceEvents._ipPromise; 201 } 202 203 static normalizeEventName(name) { 204 if (name === undefined || name === null) return name; 205 const raw = String(name).trim(); 206 if (!raw) return raw; 207 208 let snake = raw 209 .replace(/([a-z0-9])([A-Z])/g, '$1_$2') 210 .replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, '$1_$2') 211 .replace(/[\s\-]+/g, '_') 212 .replace(/[^A-Za-z0-9_]+/g, '_') 213 .replace(/__+/g, '_') 214 .replace(/^_|_$/g, '') 215 .toLowerCase(); 216 217 const singleLetterSegmentPattern = /_([a-z])_([a-z]+)/; 218 while (singleLetterSegmentPattern.test(snake)) { 219 snake = snake.replace(singleLetterSegmentPattern, '_$1$2'); 220 } 221 222 return snake; 223 } 224 225 // Why: Migration logic should be isolated for readability and auditing. 226 // How: Read all rows, strip id, clear table, bulk add back. 227 static async migrateIdToAuto(tx) { 228 const table = tx.table(ViewspaceEvents.EVENT_STORE); 229 const rows = await table.toArray(); 230 if (!rows.length) return; 231 const verdict = ViewspaceEvents.needSchemaMigration(rows); 232 if (!verdict.needs) { 233 console.debug('Migration skipped: events ids already numeric and unique; no rewrite needed.'); 234 return; // No-op: schema change doesn't require data rewrite 235 } 236 console.warn('Running migration v1->v2 for events: converting id to auto-increment (++id). Rewriting rows...', { 237 store: ViewspaceEvents.EVENT_STORE, 238 reason: verdict.reason || 'ids missing/invalid or duplicates detected', 239 total_rows: rows.length 240 }); 241 const sanitized = rows.map(({ id, ...rest }) => rest); 242 await table.clear(); 243 await table.bulkAdd(sanitized); 244 } 245 246 // Why: Keep a single, testable place to decide if data rewrite is necessary. 247 // How: Require numeric, finite, unique ids to skip migration. 248 static needSchemaMigration(rows) { 249 if (!rows || rows.length === 0) return { needs: false, reason: null }; 250 251 const seen = new Set(); 252 for (const r of rows) { 253 const id = r && r.id; 254 if (typeof id !== 'number' || !Number.isFinite(id)) {
255 return { needs: true, reason: 'invalid_or_missing_id' }; 256 } 257 const key = `n:${id}`; 258 if (seen.has(key)) { 259 return { needs: true, reason: 'duplicate_id' }; 260 } 261 seen.add(key); 262 } 263 return { needs: false, reason: null }; 264 } 265 266 /** 267 * Gather extra debugging/browser info for all events 268 * @returns {Object} 269 */ 270 static requestInfo() { 271 return { 272 referrer: document.referrer, 273 url: window.location.href, 274 user_agent: navigator.userAgent, 275 platform: navigator.platform, 276 language: navigator.language, 277 cookies_enabled: navigator.cookieEnabled, 278 online: navigator.onLine, 279 viewport: { width: window.innerWidth, height: window.innerHeight }, 280 // Add more fields as needed 281 }; 282 } 283 284 static versionsConfig() { 285 return [ 286 { version: 1, stores: ViewspaceEvents.EVENT_STORE_SCHEMAS[1] }, 287 { 288 version: 2, 289 stores: ViewspaceEvents.EVENT_STORE_SCHEMAS[2], 290 upgrade: ViewspaceEvents.migrateIdToAuto 291 }, 292 { 293 version: 3, 294 stores: ViewspaceEvents.EVENT_STORE_SCHEMAS[3], 295 upgrade: () => {} 296 } 297 ]; 298 } 299 300 // --- Instance Properties --- 301 _uploadQueue = Promise.resolve(); 302 303 constructor(visit_id, user_id) { 304 this.visit_id = visit_id; 305 this.user_id = user_id; 306 } 307 308 // --- Instance Methods (alphabetical) --- 309 310 /** 311 * Delete events in IndexedDB by their IDs 312 * @param {Array<number>} ids - Array of event IDs to delete 313 * @returns {Promise<number>} Number of deleted events (may be 0 if none matched) 314 */ 315 async deleteEvents(ids) { 316 if (!Array.isArray(ids) || ids.length === 0) return 0; 317 if (!(await this.ensureDbHelper())) return 0; 318 319 const toDelete = this.dbHelper.db[ViewspaceEvents.EVENT_STORE].where('id').anyOf(ids); 320 console.debug(`Deleting (${ids.length}) events from IndexedDB`, { ids }); 321 return toDelete.delete(); 322 } 323 324 /** 325 * Robustly ensure dbHelper and dbHelper.db are initialized and ready. 326 * Returns true if ready, otherwise returns false (never throws). 327 */ 328 async ensureDbHelper() { 329 if (this.dbHelper && this.dbHelper.db) return true; 330 331 try { 332 await this.init(); 333 } catch (e) { 334 console.warn('ViewspaceEvents: failed to init dbHelper', e); 335 return false; 336 } 337 if (!this.dbHelper || !this.dbHelper.db) return false; 338 339 return true; 340 } 341 342 /** 343 * Fetch all unsynced events from IndexedDB 344 * @returns {Promise<Array>} Array of unsynced event objects 345 */ 346 async fetchUnsyncedEvents() { 347 console.debug('in fetchUnsyncedEvents'); 348 if (!(await this.ensureDbHelper())) return []; 349 return await this.dbHelper.db[ViewspaceEvents.EVENT_STORE].toArray(); 350 } 351 352 async init() { 353 try { 354 const latestSchema = ViewspaceEvents.EVENT_STORE_SCHEMAS[ViewspaceEvents.LATEST_SCHEMA_VERSION]; 355 console.debug('Initializing IndexedDB with versioned schemas for events...', { 356 latestVersion: ViewspaceEvents.LATEST_SCHEMA_VERSION, 357 latestSchema 358 }); 359 const Helper = await loadVSIndexedDBHelper(); 360 const versions = ViewspaceEvents.versionsConfig(); 361 this.dbHelper = new Helper(ViewspaceEvents.DB_NAME, versions); 362 await this.dbHelper.init(); 363 console.debug('IndexedDB initialized successfully:', this.dbHelper); 364 } catch (error) { 365 console.error('Failed to initialize IndexedDB in ViewspaceEvents:', error); 366 throw error; 367 } 368 } 369 370 async listStoredEvents({ limit = 50 } = {}) { 371 if (!(await this.ensureDbHelper())) { 372 console.warn('ViewspaceEvents.listStoredEvents: database not available'); 373 return []; 374 } 375 376 const table = this.dbHelper.db[ViewspaceEvents.EVENT_STORE]; 377 const total = await table.count(); 378 const events = await table.orderBy('id').reverse().limit(limit).toArray(); 379 380 console.groupCollapsed('DEBUG: ViewspaceEvents.listStoredEvents'); 381 console.info('Total stored events:', total); 382 console.info(`Showing latest ${events.length} events (limit: ${limit})`); 383 if (events.length) { 384 console.table(events.map(({ id, name, time, visit_id, user_id }) => ({ id, name, time, visit_id, user_id }))); 385 } 386 console.debug('Full event payloads:', events); 387 console.groupEnd(); 388 389 return events; 390 } 391 392 /** 393 * Record an error event in IndexedDB 394 * @param {Object} params 395 * @param {string} params.name 396 * @param {string} params.reason 397 * @param {Object} params.data 398 * @param {string} params.stack 399 * @param {string} params.time - ISO8601 timestamp 400 * @returns {Promise} 401 */ 402 async recordErrorEvent({ name, reason, data, stack, time }) { 403 try { 404 if (!(await this.ensureDbHelper())) return; 405 let truncatedStack = stack; 406 if (truncatedStack && truncatedStack.length > ViewspaceEvents.MAX_STACK_LENGTH) { 407 truncatedStack = truncatedStack.slice(0, ViewspaceEvents.MAX_STACK_LENGTH) + '\n... [truncated]'; 408 } 409 return this.recordEvent({ 410 visit_id: this.visit_id, 411 user_id: this.user_id, 412 name: 'error', 413 properties: { name, reason, data, stack: truncatedStack }, 414 time: time || new Date().toISOString() 415 }); 416 } catch (err) { 417 console.warn('ViewspaceEvents: recordErrorEvent failed', err); 418 } 419 } 420 421 /** 422 * Record an event in IndexedDB 423 * @param {Object} event - Event data 424 * @param {number|null} [event.visit_id] - Optional, defaults to instance value 425 * @param {number|null} [event.user_id] - Optional, defaults to instance value 426 * @param {string} event.name 427 * @param {Object} event.properties 428 * @param {string} event.time - ISO8601 timestamp 429 * @returns {Promise} 430 */ 431 async recordEvent({ visit_id = this.visit_id, user_id = this.user_id, name, properties = {}, time = null }) { 432 if (!(await this.ensureDbHelper())) return; 433 434 const normalizedName = ViewspaceEvents.normalizeEventName(name); 435 if (!normalizedName) { 436 console.warn('ViewspaceEvents: recordEvent called without a valid event name; skipping.', { originalName: name }); 437 return; 438 } 439 if (normalizedName !== name) { 440 console.debug('Normalized Viewspace event name.', { originalName: name, normalizedName }); 441 } 442 443 let ip = await ViewspaceEvents.fetchIpAddress(); 444 // Always include requestInfo in properties 445 let propertiesWithMeta = { 446 ...properties, 447 ip_address: ip, 448 request_info: ViewspaceEvents.requestInfo() 449 }; 450 451 console.debug('Recording event:', { user_id, name, visit_id, properties: propertiesWithMeta, time }); 452 try { 453 const eventRecord = { 454 visit_id, 455 user_id, 456 name: normalizedName, 457 properties: propertiesWithMeta, 458 time: time || new Date().toISOString() 459 }; 460 return await this.dbHelper.put(eventRecord, ViewspaceEvents.EVENT_STORE); 461 } catch (error) { 462 console.error('Failed to save event:', error); 463 throw error; 464 } 465 } 466 467 /** 468 * Record a playlist_completed event after the final video in the playlist ends 469 * @param {Object} params 470 * @param {string|number} params.playlist_id 471 * @param {number|null} [params.video_count] 472 * @param {string|number|null} [params.last_video_id] 473 * @param {string|null} [params.last_video_name] 474 * @param {number|null} [params.duration_seconds] Total playback duration for the playlist in seconds 475 * @returns {Promise} 476 */ 477 async recordPlaylistCompleted({ 478 playlist_id, 479 video_count = null, 480 last_video_id = null, 481 last_video_name = null, 482 duration_seconds = null 483 }) { 484 if (!(await this.ensureDbHelper())) return; 485 486 const properties = { 487 playlist_id, 488 video_count, 489 last_video_id, 490 last_video_name, 491 duration_seconds, 492 user_id: this.user_id 493 }; 494 495 return this.recordEvent({ 496 visit_id: this.visit_id, 497 user_id: this.user_id, 498 name: 'playlist_completed', 499 properties, 500 time: new Date().toISOString() 501 }); 502 } 503 504 /** 505 * Record a playlist_start event when playback begins for the first playlist video 506 * @param {Object} params 507 * @param {string|number|null} params.playlist_id 508 * @param {string|number|null} [params.start_video_id] 509 * @param {string|null} [params.start_video_name] 510 * @param {number|null} [params.video_count] 511 * @returns {Promise} 512 */ 513 async recordPlaylistStarted({ 514 playlist_id = null, 515 start_video_id = null, 516 start_video_name = null, 517 video_count = null 518 }) { 519 if (!(await this.ensureDbHelper())) return; 520 521 const properties = { 522 playlist_id, 523 start_video_id, 524 start_video_name, 525 video_count, 526 }; 527 528 return this.recordEvent({ 529 visit_id: this.visit_id, 530 user_id: this.user_id, 531 name: 'playlist_start', 532 properties, 533 time: new Date().toISOString() 534 }); 535 } 536 537 /** 538 * Record a video_completed event when playback finishes 539 * @param {Object} params 540 * @param {string|number} params.video_id 541 * @param {string|null} [params.indexeddb_key] 542 * @param {string|number|null} params.playlist_id 543 * @param {number|null} [params.duration_seconds] 544 * @param {boolean} [params.is_interstitial] 545 * @param {string|null} [params.video_name] 546 * @returns {Promise} 547 */ 548 async recordVideoCompleted({ 549 video_id, 550 indexeddb_key = null, 551 playlist_id = null, 552 duration_seconds = null, 553 is_interstitial = false, 554 video_name = null 555 }) { 556 if (!(await this.ensureDbHelper())) return; 557 558 const properties = { 559 video_id, 560 duration_seconds, 561 indexeddb_key, 562 is_interstitial, 563 playlist_id, 564 video_name, 565 }; 566 567 return this.recordEvent({ 568 visit_id: this.visit_id, 569 user_id: this.user_id, 570 name: 'video_completed', 571 properties, 572 time: new Date().toISOString() 573 }); 574 } 575 576 /** 577 * Record a video_downloaded event when the video blob is stored to IndexedDB 578 * @param {Object} params 579 * @param {string|number} params.video_id - logical video id or key 580 * @param {string} [params.key] - storage key inside IndexedDB (often same as video_id) 581 * @param {number|null} [params.size_bytes] - size in bytes of the stored blob 582 * @param {string|null} [params.source_url] 583 * @param {string|null} [params.video_name] 584 * @returns {Promise} 585 */ 586 async recordVideoDownloaded({ video_id, indexeddb_key = null, size_bytes = null, source_url = null, video_name = null }) { 587 if (!(await this.ensureDbHelper())) return; 588 589 const properties = { 590 video_id, 591 indexeddb_key, 592 size_bytes, 593 source_url, 594 video_name, 595 }; 596 597 return this.recordEvent({ 598 visit_id: this.visit_id, 599 user_id: this.user_id, 600 name: 'video_downloaded', 601 properties, 602 time: new Date().toISOString() 603 }); 604 } 605 606 /** 607 * Record a video_start event in IndexedDB 608 * @param {Object} params 609 * @param {string|number} params.video_id 610 * @param {string} params.video_name 611 * @param {string|null} [params.indexeddb_key] 612 * @param {number|null} [params.user_id] 613 * @param {number|null} [params.visit_id] 614 * @param {Object} [params.extra_properties] 615 * @returns {Promise} 616 */ 617 async recordVideoPlayed({ video_id, indexeddb_key = null, video_name, user_id = this.user_id, visit_id = this.visit_id, extra_properties = {} }) { 618 if (!(await this.ensureDbHelper())) return; 619 return this.recordEvent({ 620 visit_id, 621 user_id, 622 name: 'video_start', 623 properties: { video_id, indexeddb_key, video_name, ...extra_properties }, 624 time: new Date().toISOString() 625 }); 626 } 627 628 /** 629 * Upload unsynced events to the Ahoy endpoint and delete them on success 630 * Implements idempotency: events are only deleted locally after a successful
631 * server response. If deletion fails, events will be retried on next sync. 632 * 633 * Server should handle duplicate event IDs gracefully (idempotent processing). 634 * 635 * @param {string} [endpoint='/ahoy/events'] - API endpoint to POST events 636 * @param {string} [visit_token] - Ahoy visit token 637 * @param {string} [visitor_token] - Ahoy visitor token 638 * @returns {Promise<{success: boolean, uploaded: number, error?: any}>} 639 */ 640 async uploadEvent(event, endpoint, visit_token, visitor_token, headers) { 641 const normalizedName = ViewspaceEvents.normalizeEventName(event.name) || event.name; 642 643 const payload = { 644 visit_token, 645 visitor_token, 646 events: [{ id: event.id, name: normalizedName, properties: event.properties, time: event.time }] 647 }; 648 try { 649 const response = await fetch(endpoint, { method: 'POST', headers, body: JSON.stringify(payload) }); 650 if (response.ok) { 651 return { success: true }; 652 } else { 653 console.warn('Failed to upload event.', { id: event.id, status: response.status, endpoint }); 654 return { success: false, error: new Error(`HTTP ${response.status}`) }; 655 } 656 } catch (err) { 657 console.error('Failed to upload event.', { id: event.id, error: err, endpoint }); 658 return { success: false, error: err }; 659 } 660 } 661 662 async uploadUnsyncedEvents(endpoint = '/ahoy/events', visit_token = null, visitor_token = null) { 663 this._uploadQueue = this._uploadQueue.then(() => this._doUploadUnsyncedEvents(endpoint, visit_token, visitor_token)); 664 return this._uploadQueue; 665 } 666 667 async _doUploadUnsyncedEvents(endpoint = '/ahoy/events', visit_token = null, visitor_token = null) { 668 console.debug('In _doUploadUnsyncedEvents (single-row mode).', { endpoint, visit_token, visitor_token }); 669 const unsynced = await this.fetchUnsyncedEvents(); 670 console.log(`Uploading (${unsynced.length}) unsynced Events to ${endpoint}:`, { count: unsynced.length, endpoint }); 671 if (!unsynced.length) return { success: true, uploaded: 0 }; 672 673 visit_token = visit_token || window.AHOY_VISIT_TOKEN || localStorage.getItem('ahoy_visit_token'); 674 visitor_token = visitor_token || window.AHOY_VISITOR_TOKEN || localStorage.getItem('ahoy_visitor_token'); 675 const headers = { 676 'Content-Type': 'application/json', 677 'Accept': 'application/json', 678 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content, 679 }; 680 681 let totalUploaded = 0; 682 for (const event of unsynced) { 683 const result = await this.uploadEvent(event, endpoint, visit_token, visitor_token, headers); 684 if (!result.success) { 685 console.error('Failed to upload event:', { id: event.id, error: result.error, result: result }); 686 return { success: false, uploaded: totalUploaded, error: result.error }; 687 } 688 console.debug('Successfully uploaded event. Deleting local entry.', { id: event.id, result: result }); 689 await this.deleteEvents([event.id]); 690 totalUploaded += 1; 691 } 692 return { success: true, uploaded: totalUploaded }; 693 } 694} 695 696// --- Entry Point --- 697 698initializeViewspaceEvents(); 699/*! 700 * jQuery JavaScript Library v3.7.0 701 * https://jquery.com/ 702 * 703 * Copyright OpenJS Foundation and other contributors 704 * Released under the MIT license 705 * https://jquery.org/license 706 * 707 * Date: 2023-05-11T18:29Z 708 */ 709( function( global, factory ) { 710 711 "use strict"; 712 713 if ( typeof module === "object" && typeof module.exports === "object" ) { 714 715 // For CommonJS and CommonJS-like environments where a proper `window` 716 // is present, execute the factory and get jQuery. 717 // For environments that do not have a `window` with a `document` 718 // (such as Node.js), expose a factory as module.exports. 719 // This accentuates the need for the creation of a real `window`. 720 // e.g. var jQuery = require("jquery")(window); 721 // See ticket trac-14549 for more info. 722 module.exports = global.document ? 723 factory( global, true ) : 724 function( w ) { 725 if ( !w.document ) { 726 throw new Error( "jQuery requires a window with a document" ); 727 } 728 return factory( w ); 729 }; 730 } else { 731 factory( global ); 732 } 733 734// Pass this if window is not defined yet 735} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 736 737// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 738// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode 739// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), str
vendor: 9,010 bytes, lines 739-1114
739ict mode should be common 740// enough that all such attempts are guarded in a try block. 741"use strict"; 742 743var arr = []; 744 745var getProto = Object.getPrototypeOf; 746 747var slice = arr.slice; 748 749var flat = arr.flat ? function( array ) { 750 return arr.flat.call( array ); 751} : function( array ) { 752 return arr.concat.apply( [], array ); 753}; 754 755 756var push = arr.push; 757 758var indexOf = arr.indexOf; 759 760var class2type = {}; 761 762var toString = class2type.toString; 763 764var hasOwn = class2type.hasOwnProperty; 765 766var fnToString = hasOwn.toString; 767 768var ObjectFunctionString = fnToString.call( Object ); 769 770var support = {}; 771 772var isFunction = function isFunction( obj ) { 773 774 // Support: Chrome <=57, Firefox <=52 775 // In some browsers, typeof returns "function" for HTML <object> elements 776 // (i.e., `typeof document.createElement( "object" ) === "function"`). 777 // We don't want to classify *any* DOM node as a function. 778 // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 779 // Plus for old WebKit, typeof returns "function" for HTML collections 780 // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) 781 return typeof obj === "function" && typeof obj.nodeType !== "number" && 782 typeof obj.item !== "function"; 783 }; 784 785 786var isWindow = function isWindow( obj ) { 787 return obj != null && obj === obj.window; 788 }; 789 790 791var document = window.document; 792 793 794 795 var preservedScriptAttributes = { 796 type: true, 797 src: true, 798 nonce: true, 799 noModule: true 800 }; 801 802 function DOMEval( code, node, doc ) { 803 doc = doc || document; 804 805 var i, val, 806 script = doc.createElement( "script" ); 807 808 script.text = code; 809 if ( node ) { 810 for ( i in preservedScriptAttributes ) { 811 812 // Support: Firefox 64+, Edge 18+ 813 // Some browsers don't support the "nonce" property on scripts. 814 // On the other hand, just using `getAttribute` is not enough as 815 // the `nonce` attribute is reset to an empty string whenever it 816 // becomes browsing-context connected. 817 // See https://github.com/whatwg/html/issues/2369 818 // See https://html.spec.whatwg.org/#nonce-attributes 819 // The `node.getAttribute` check was added for the sake of 820 // `jQuery.globalEval` so that it can fake a nonce-containing node 821 // via an object. 822 val = node[ i ] || node.getAttribute && node.getAttribute( i ); 823 if ( val ) { 824 script.setAttribute( i, val ); 825 } 826 } 827 } 828 doc.head.appendChild( script ).parentNode.removeChild( script ); 829 } 830 831 832function toType( obj ) { 833 if ( obj == null ) { 834 return obj + ""; 835 } 836 837 // Support: Android <=2.3 only (functionish RegExp) 838 return typeof obj === "object" || typeof obj === "function" ? 839 class2type[ toString.call( obj ) ] || "object" : 840 typeof obj; 841} 842/* global Symbol */ 843// Defining this global in .eslintrc.json would create a danger of using the global 844// unguarded in another place, it seems safer to define global only for this module 845 846 847 848var version = "3.7.0", 849 850 rhtmlSuffix = /HTML$/i, 851 852 // Define a local copy of jQuery 853 jQuery = function( selector, context ) { 854 855 // The jQuery object is actually just the init constructor 'enhanced' 856 // Need init if jQuery is called (just allow error to be thrown if not included) 857 return new jQuery.fn.init( selector, context ); 858 }; 859 860jQuery.fn = jQuery.prototype = { 861 862 // The current version of jQuery being used 863 jquery: version, 864 865 constructor: jQuery, 866 867 // The default length of a jQuery object is 0 868 length: 0, 869 870 toArray: function() { 871 return slice.call( this ); 872 }, 873 874 // Get the Nth element in the matched element set OR 875 // Get the whole matched element set as a clean array 876 get: function( num ) { 877 878 // Return all the elements in a clean array 879 if ( num == null ) { 880 return slice.call( this ); 881 } 882 883 // Return just the one element from the set 884 return num < 0 ? this[ num + this.length ] : this[ num ]; 885 }, 886 887 // Take an array of elements and push it onto the stack 888 // (returning the new matched element set) 889 pushStack: function( elems ) { 890 891 // Build a new jQuery matched element set 892 var ret = jQuery.merge( this.constructor(), elems ); 893 894 // Add the old object onto the stack (as a reference) 895 ret.prevObject = this; 896 897 // Return the newly-formed element set 898 return ret; 899 }, 900 901 // Execute a callback for every element in the matched set. 902 each: function( callback ) { 903 return jQuery.each( this, callback ); 904 }, 905 906 map: function( callback ) { 907 return this.pushStack( jQuery.map( this, function( elem, i ) { 908 return callback.call( elem, i, elem ); 909 } ) ); 910 }, 911 912 slice: function() { 913 return this.pushStack( slice.apply( this, arguments ) ); 914 }, 915 916 first: function() { 917 return this.eq( 0 ); 918 }, 919 920 last: function() { 921 return this.eq( -1 ); 922 }, 923 924 even: function() { 925 return this.pushStack( jQuery.grep( this, function( _elem, i ) { 926 return ( i + 1 ) % 2; 927 } ) ); 928 }, 929 930 odd: function() { 931 return this.pushStack( jQuery.grep( this, function( _elem, i ) { 932 return i % 2; 933 } ) ); 934 }, 935 936 eq: function( i ) { 937 var len = this.length, 938 j = +i + ( i < 0 ? len : 0 ); 939 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 940 }, 941 942 end: function() { 943 return this.prevObject || this.constructor(); 944 }, 945 946 // For internal use only. 947 // Behaves like an Array's method, not like a jQuery method. 948 push: push, 949 sort: arr.sort, 950 splice: arr.splice 951}; 952 953jQuery.extend = jQuery.fn.extend = function() { 954 var options, name, src, copy, copyIsArray, clone, 955 target = arguments[ 0 ] || {}, 956 i = 1, 957 length = arguments.length, 958 deep = false; 959 960 // Handle a deep copy situation 961 if ( typeof target === "boolean" ) { 962 deep = target; 963 964 // Skip the boolean and the target 965 target = arguments[ i ] || {}; 966 i++; 967 } 968 969 // Handle case when target is a string or something (possible in deep copy) 970 if ( typeof target !== "object" && !isFunction( target ) ) { 971 target = {}; 972 } 973 974 // Extend jQuery itself if only one argument is passed 975 if ( i === length ) { 976 target = this; 977 i--; 978 } 979 980 for ( ; i < length; i++ ) { 981 982 // Only deal with non-null/undefined values 983 if ( ( options = arguments[ i ] ) != null ) { 984 985 // Extend the base object 986 for ( name in options ) { 987 copy = options[ name ]; 988 989 // Prevent Object.prototype pollution 990 // Prevent never-ending loop 991 if ( name === "__proto__" || target === copy ) { 992 continue; 993 } 994 995 // Recurse if we're merging plain objects or arrays 996 if ( deep && copy && ( jQuery.isPlainObject( copy ) || 997 ( copyIsArray = Array.isArray( copy ) ) ) ) { 998 src = target[ name ]; 999 1000 // Ensure proper type for the source value 1001 if ( copyIsArray && !Array.isArray( src ) ) { 1002 clone = []; 1003 } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { 1004 clone = {}; 1005 } else { 1006 clone = src; 1007 } 1008 copyIsArray = false; 1009 1010 // Never move original objects, clone them 1011 target[ name ] = jQuery.extend( deep, clone, copy ); 1012 1013 // Don't bring in undefined values 1014 } else if ( copy !== undefined ) { 1015 target[ name ] = copy; 1016 } 1017 } 1018 } 1019 } 1020 1021 // Return the modified object 1022 return target; 1023}; 1024 1025jQuery.extend( { 1026 1027 // Unique for each copy of jQuery on the page 1028 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 1029 1030 // Assume jQuery is ready without the ready module 1031 isReady: true, 1032 1033 error: function( msg ) { 1034 throw new Error( msg ); 1035 }, 1036 1037 noop: function() {}, 1038 1039 isPlainObject: function( obj ) { 1040 var proto, Ctor; 1041 1042 // Detect obvious negatives 1043 // Use toString instead of jQuery.type to catch host objects 1044 if ( !obj || toString.call( obj ) !== "[object Object]" ) { 1045 return false; 1046 } 1047 1048 proto = getProto( obj ); 1049 1050 // Objects with no prototype (e.g., `Object.create( null )`) are plain 1051 if ( !proto ) { 1052 return true; 1053 } 1054 1055 // Objects with prototype are plain iff they were constructed by a global Object function 1056 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; 1057 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; 1058 }, 1059 1060 isEmptyObject: function( obj ) { 1061 var name; 1062 1063 for ( name in obj ) { 1064 return false; 1065 } 1066 return true; 1067 }, 1068 1069 // Evaluates a script in a provided context; falls back to the global one 1070 // if not specified. 1071 globalEval: function( code, options, doc ) { 1072 DOMEval( code, { nonce: options && options.nonce }, doc ); 1073 }, 1074 1075 each: function( obj, callback ) { 1076 var length, i = 0; 1077 1078 if ( isArrayLike( obj ) ) { 1079 length = obj.length; 1080 for ( ; i < length; i++ ) { 1081 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 1082 break; 1083 } 1084 } 1085 } else { 1086 for ( i in obj ) { 1087 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 1088 break; 1089 } 1090 } 1091 } 1092 1093 return obj; 1094 }, 1095 1096 1097 // Retrieve the text value of an array of DOM nodes 1098 text: function( elem ) { 1099 var node, 1100 ret = "", 1101 i = 0, 1102 nodeType = elem.nodeType; 1103 1104 if ( !nodeType ) { 1105 1106 // If no nodeType, this is expected to be an array 1107 while ( ( node = elem[ i++ ] ) ) { 1108 1109 // Do not traverse comment nodes 1110 ret += jQuery.text( node ); 1111 } 1112 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 1113 return elem.textContent; 1114 } else
vendor: 19,662 bytes, lines 1114-1827
1114if ( nodeType === 3 || nodeType === 4 ) { 1115 return elem.nodeValue; 1116 } 1117 1118 // Do not include comment or processing instruction nodes 1119 1120 return ret; 1121 }, 1122 1123 // results is for internal usage only 1124 makeArray: function( arr, results ) { 1125 var ret = results || []; 1126 1127 if ( arr != null ) { 1128 if ( isArrayLike( Object( arr ) ) ) { 1129 jQuery.merge( ret, 1130 typeof arr === "string" ? 1131 [ arr ] : arr 1132 ); 1133 } else { 1134 push.call( ret, arr ); 1135 } 1136 } 1137 1138 return ret; 1139 }, 1140 1141 inArray: function( elem, arr, i ) { 1142 return arr == null ? -1 : indexOf.call( arr, elem, i ); 1143 }, 1144 1145 isXMLDoc: function( elem ) { 1146 var namespace = elem && elem.namespaceURI, 1147 docElem = elem && ( elem.ownerDocument || elem ).documentElement; 1148 1149 // Assume HTML when documentElement doesn't yet exist, such as inside 1150 // document fragments. 1151 return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" ); 1152 }, 1153 1154 // Support: Android <=4.0 only, PhantomJS 1 only 1155 // push.apply(_, arraylike) throws on ancient WebKit 1156 merge: function( first, second ) { 1157 var len = +second.length, 1158 j = 0, 1159 i = first.length; 1160 1161 for ( ; j < len; j++ ) { 1162 first[ i++ ] = second[ j ]; 1163 } 1164 1165 first.length = i; 1166 1167 return first; 1168 }, 1169 1170 grep: function( elems, callback, invert ) { 1171 var callbackInverse, 1172 matches = [], 1173 i = 0, 1174 length = elems.length, 1175 callbackExpect = !invert; 1176 1177 // Go through the array, only saving the items 1178 // that pass the validator function 1179 for ( ; i < length; i++ ) { 1180 callbackInverse = !callback( elems[ i ], i ); 1181 if ( callbackInverse !== callbackExpect ) { 1182 matches.push( elems[ i ] ); 1183 } 1184 } 1185 1186 return matches; 1187 }, 1188 1189 // arg is for internal usage only 1190 map: function( elems, callback, arg ) { 1191 var length, value, 1192 i = 0, 1193 ret = []; 1194 1195 // Go through the array, translating each of the items to their new values 1196 if ( isArrayLike( elems ) ) { 1197 length = elems.length; 1198 for ( ; i < length; i++ ) { 1199 value = callback( elems[ i ], i, arg ); 1200 1201 if ( value != null ) { 1202 ret.push( value ); 1203 } 1204 } 1205 1206 // Go through every key on the object, 1207 } else { 1208 for ( i in elems ) { 1209 value = callback( elems[ i ], i, arg ); 1210 1211 if ( value != null ) { 1212 ret.push( value ); 1213 } 1214 } 1215 } 1216 1217 // Flatten any nested arrays 1218 return flat( ret ); 1219 }, 1220 1221 // A global GUID counter for objects 1222 guid: 1, 1223 1224 // jQuery.support is not used in Core but other projects attach their 1225 // properties to it so it needs to exist. 1226 support: support 1227} ); 1228 1229if ( typeof Symbol === "function" ) { 1230 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; 1231} 1232 1233// Populate the class2type map 1234jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 1235 function( _i, name ) { 1236 class2type[ "[object " + name + "]" ] = name.toLowerCase(); 1237 } ); 1238 1239function isArrayLike( obj ) { 1240 1241 // Support: real iOS 8.2 only (not reproducible in simulator) 1242 // `in` check used to prevent JIT error (gh-2145) 1243 // hasOwn isn't used here due to false negatives 1244 // regarding Nodelist length in IE 1245 var length = !!obj && "length" in obj && obj.length, 1246 type = toType( obj ); 1247 1248 if ( isFunction( obj ) || isWindow( obj ) ) { 1249 return false; 1250 } 1251 1252 return type === "array" || length === 0 || 1253 typeof length === "number" && length > 0 && ( length - 1 ) in obj; 1254} 1255 1256 1257function nodeName( elem, name ) { 1258 1259 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 1260 1261} 1262var pop = arr.pop; 1263 1264 1265var sort = arr.sort; 1266 1267 1268var splice = arr.splice; 1269 1270 1271var whitespace = "[\\x20\\t\\r\\n\\f]"; 1272 1273 1274var rtrimCSS = new RegExp( 1275 "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", 1276 "g" 1277); 1278 1279 1280 1281 1282// Note: an element does not contain itself 1283jQuery.contains = function( a, b ) { 1284 var bup = b && b.parentNode; 1285 1286 return a === bup || !!( bup && bup.nodeType === 1 && ( 1287 1288 // Support: IE 9 - 11+ 1289 // IE doesn't have `contains` on SVG. 1290 a.contains ? 1291 a.contains( bup ) : 1292 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 1293 ) ); 1294}; 1295 1296 1297 1298 1299// CSS string/identifier serialization 1300// https://drafts.csswg.org/cssom/#common-serializing-idioms 1301var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g; 1302 1303function fcssescape( ch, asCodePoint ) { 1304 if ( asCodePoint ) { 1305 1306 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 1307 if ( ch === "\0" ) { 1308 return "\uFFFD"; 1309 } 1310 1311 // Control characters and (dependent upon position) numbers get escaped as code points 1312 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 1313 } 1314 1315 // Other potentially-special ASCII characters get backslash-escaped 1316 return "\\" + ch; 1317} 1318 1319jQuery.escapeSelector = function( sel ) { 1320 return ( sel + "" ).replace( rcssescape, fcssescape ); 1321}; 1322 1323 1324 1325 1326var preferredDoc = document, 1327 pushNative = push; 1328 1329( function() { 1330 1331var i, 1332 Expr, 1333 outermostContext, 1334 sortInput, 1335 hasDuplicate, 1336 push = pushNative, 1337 1338 // Local document vars 1339 document, 1340 documentElement, 1341 documentIsHTML, 1342 rbuggyQSA, 1343 matches, 1344 1345 // Instance-specific data 1346 expando = jQuery.expando, 1347 dirruns = 0, 1348 done = 0, 1349 classCache = createCache(), 1350 tokenCache = createCache(), 1351 compilerCache = createCache(), 1352 nonnativeSelectorCache = createCache(), 1353 sortOrder = function( a, b ) { 1354 if ( a === b ) { 1355 hasDuplicate = true; 1356 } 1357 return 0; 1358 }, 1359 1360 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" + 1361 "loop|multiple|open|readonly|required|scoped", 1362 1363 // Regular expressions 1364 1365 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram 1366 identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + 1367 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", 1368 1369 // Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors 1370 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 1371 1372 // Operator (capture 2) 1373 "*([*^$|!~]?=)" + whitespace + 1374 1375 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" 1376 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + 1377 whitespace + "*\\]", 1378 1379 pseudos = ":(" + identifier + ")(?:\\((" + 1380 1381 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 1382 // 1. quoted (capture 3; capture 4 or capture 5) 1383 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 1384 1385 // 2. simple (capture 6) 1386 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 1387 1388 // 3. anything else (capture 2) 1389 ".*" + 1390 ")\\)|)", 1391 1392 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 1393 rwhitespace = new RegExp( whitespace + "+", "g" ), 1394 1395 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 1396 rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + 1397 whitespace + "*" ), 1398 rdescend = new RegExp( whitespace + "|>" ), 1399 1400 rpseudo = new RegExp( pseudos ), 1401 ridentifier = new RegExp( "^" + identifier + "$" ), 1402 1403 matchExpr = { 1404 ID: new RegExp( "^#(" + identifier + ")" ), 1405 CLASS: new RegExp( "^\\.(" + identifier + ")" ), 1406 TAG: new RegExp( "^(" + identifier + "|[*])" ), 1407 ATTR: new RegExp( "^" + attributes ), 1408 PSEUDO: new RegExp( "^" + pseudos ), 1409 CHILD: new RegExp( 1410 "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + 1411 whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + 1412 whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 1413 bool: new RegExp( "^(?:" + booleans + ")$", "i" ), 1414 1415 // For use in libraries implementing .is() 1416 // We use this for POS matching in `select` 1417 needsContext: new RegExp( "^" + whitespace + 1418 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + 1419 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 1420 }, 1421 1422 rinputs = /^(?:input|select|textarea|button)$/i, 1423 rheader = /^h\d$/i, 1424 1425 // Easily-parseable/retrievable ID or TAG or CLASS selectors 1426 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 1427 1428 rsibling = /[+~]/, 1429 1430 // CSS escapes 1431 // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters 1432 runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + 1433 "?|\\\\([^\\r\\n\\f])", "g" ), 1434 funescape = function( escape, nonHex ) { 1435 var high = "0x" + escape.slice( 1 ) - 0x10000; 1436 1437 if ( nonHex ) { 1438 1439 // Strip the backslash prefix from a non-hex escape sequence 1440 return nonHex; 1441 } 1442 1443 // Replace a hexadecimal escape sequence with the encoded Unicode code point 1444 // Support: IE <=11+ 1445 // For values outside the Basic Multilingual Plane (BMP), manually construct a 1446 // surrogate pair 1447 return high < 0 ? 1448 String.fromCharCode( high + 0x10000 ) : 1449 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 1450 }, 1451 1452 // Used for iframes; see `setDocument`. 1453 // Support: IE 9 - 11+, Edge 12 - 18+ 1454 // Removing the function wrapper causes a "Permission Denied" 1455 // error in IE/Edge. 1456 unloadHandler = function() { 1457 setDocument(); 1458 }, 1459 1460 inDisabledFieldset = addCombinator( 1461 function( elem ) { 1462 return elem.disabled === true && nodeName( elem, "fieldset" ); 1463 }, 1464 { dir: "parentNode", next: "legend" } 1465 ); 1466 1467// Support: IE <=9 only 1468// Accessing document.activeElement can throw unexpectedly 1469// https://bugs.jquery.com/ticket/13393 1470function safeActiveElement() { 1471 try { 1472 return document.activeElement; 1473 } catch ( err ) { } 1474} 1475 1476// Optimize for push.apply( _, NodeList ) 1477try { 1478 push.apply( 1479 ( arr = slice.call( preferredDoc.childNodes ) ), 1480 preferredDoc.childNodes 1481 ); 1482 1483 // Support: Android <=4.0 1484 // Detect silently failing push.apply 1485 // eslint-disable-next-line no-unused-expressions 1486 arr[ preferredDoc.childNodes.length ].nodeType; 1487} catch ( e ) { 1488 push = { 1489 apply: function( target, els ) { 1490 pushNative.apply( target, slice.call( els ) ); 1491 }, 1492 call: function( target ) { 1493 pushNative.apply( target, slice.call( arguments, 1 ) ); 1494 } 1495 }; 1496} 1497 1498function find( selector, context, results, seed ) { 1499 var m, i, elem, nid, match, groups, newSelector, 1500 newContext = context && context.ownerDocument, 1501 1502 // nodeType defaults to 9, since context defaults to document 1503 nodeType = context ? context.nodeType : 9; 1504 1505 results = results || []; 1506 1507 // Return early from calls with invalid selector or context 1508 if ( typeof selector !== "string" || !selector || 1509 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 1510 1511 return results; 1512 } 1513 1514 // Try to shortcut find operations (as opposed to filters) in HTML documents 1515 if ( !seed ) { 1516 setDocument( context ); 1517 context = context || document; 1518 1519 if ( documentIsHTML ) { 1520 1521 // If the selector is sufficiently simple, try using a "get*By*" DOM method 1522 // (excepting DocumentFragment context, where the methods don't exist) 1523 if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { 1524 1525 // ID selector 1526 if ( ( m = match[ 1 ] ) ) { 1527 1528 // Document context 1529 if ( nodeType === 9 ) { 1530 if ( ( elem = context.getElementById( m ) ) ) { 1531 1532 // Support: IE 9 only 1533 // getElementById can match elements by name instead of ID 1534 if ( elem.id === m ) { 1535 push.call( results, elem ); 1536 return results; 1537 } 1538 } else { 1539 return results; 1540 } 1541 1542 // Element context 1543 } else { 1544 1545 // Support: IE 9 only 1546 // getElementById can match elements by name instead of ID 1547 if ( newContext && ( elem = newContext.getElementById( m ) ) && 1548 find.contains( context, elem ) && 1549 elem.id === m ) { 1550 1551 push.call( results, elem ); 1552 return results; 1553 } 1554 } 1555 1556 // Type selector 1557 } else if ( match[ 2 ] ) { 1558 push.apply( results, context.getElementsByTagName( selector ) ); 1559 return results; 1560 1561 // Class selector 1562 } else if ( ( m = match[ 3 ] ) && context.getElementsByClassName ) { 1563 push.apply( results, context.getElementsByClassName( m ) ); 1564 return results; 1565 } 1566 } 1567 1568 // Take advantage of querySelectorAll 1569 if ( !nonnativeSelectorCache[ selector + " " ] && 1570 ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) ) { 1571 1572 newSelector = selector; 1573 newContext = context; 1574 1575 // qSA considers elements outside a scoping root when evaluating child or 1576 // descendant combinators, which is not what we want. 1577 // In such cases, we work around the behavior by prefixing every selector in the 1578 // list with an ID selector referencing the scope context. 1579 // The technique has to be used as well when a leading combinator is used 1580 // as such selectors are not recognized by querySelectorAll. 1581 // Thanks to Andrew Dupont for this technique. 1582 if ( nodeType === 1 && 1583 ( rdescend.test( selector ) || rleadingCombinator.test( selector ) ) ) { 1584 1585 // Expand context for sibling selectors 1586 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 1587 context; 1588 1589 // We can use :scope instead of the ID hack if the browser 1590 // supports it & if we're not changing the context. 1591 // Support: IE 11+, Edge 17 - 18+ 1592 // IE/Edge sometimes throw a "Permission denied" error when 1593 // strict-comparing two documents; shallow comparisons work. 1594 // eslint-disable-next-line eqeqeq 1595 if ( newContext != context || !support.scope ) { 1596 1597 // Capture the context ID, setting it first if necessary 1598 if ( ( nid = context.getAttribute( "id" ) ) ) { 1599 nid = jQuery.escapeSelector( nid ); 1600 } else { 1601 context.setAttribute( "id", ( nid = expando ) ); 1602 } 1603 } 1604 1605 // Prefix every selector in the list 1606 groups = tokenize( selector ); 1607 i = groups.length; 1608 while ( i-- ) { 1609 groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + 1610 toSelector( groups[ i ] ); 1611 } 1612 newSelector = groups.join( "," ); 1613 } 1614 1615 try { 1616 push.apply( results, 1617 newContext.querySelectorAll( newSelector ) 1618 ); 1619 return results; 1620 } catch ( qsaError ) { 1621 nonnativeSelectorCache( selector, true ); 1622 } finally { 1623 if ( nid === expando ) { 1624 context.removeAttribute( "id" ); 1625 } 1626 } 1627 } 1628 } 1629 } 1630 1631 // All others 1632 return select( selector.replace( rtrimCSS, "$1" ), context, results, seed ); 1633} 1634 1635/** 1636 * Create key-value caches of limited size 1637 * @returns {function(string, object)} Returns the Object data after storing it on itself with 1638 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 1639 * deleting the oldest entry 1640 */ 1641function createCache() { 1642 var keys = []; 1643 1644 function cache( key, value ) { 1645 1646 // Use (key + " ") to avoid collision with native prototype properties 1647 // (see https://github.com/jquery/sizzle/issues/157) 1648 if ( keys.push( key + " " ) > Expr.cacheLength ) { 1649 1650 // Only keep the most recent entries 1651 delete cache[ keys.shift() ]; 1652 } 1653 return ( cache[ key + " " ] = value ); 1654 } 1655 return cache; 1656} 1657 1658/** 1659 * Mark a function for special use by jQuery selector module 1660 * @param {Function} fn The function to mark 1661 */ 1662function markFunction( fn ) { 1663 fn[ expando ] = true; 1664 return fn; 1665} 1666 1667/** 1668 * Support testing using an element 1669 * @param {Function} fn Passed the created element and returns a boolean result 1670 */ 1671function assert( fn ) { 1672 var el = document.createElement( "fieldset" ); 1673 1674 try { 1675 return !!fn( el ); 1676 } catch ( e ) { 1677 return false; 1678 } finally { 1679 1680 // Remove from its parent by default 1681 if ( el.parentNode ) { 1682 el.parentNode.removeChild( el ); 1683 } 1684 1685 // release memory in IE 1686 el = null; 1687 } 1688} 1689 1690/** 1691 * Returns a function to use in pseudos for input types 1692 * @param {String} type 1693 */ 1694function createInputPseudo( type ) { 1695 return function( elem ) { 1696 return nodeName( elem, "input" ) && elem.type === type; 1697 }; 1698} 1699 1700/** 1701 * Returns a function to use in pseudos for buttons 1702 * @param {String} type 1703 */ 1704function createButtonPseudo( type ) { 1705 return function( elem ) { 1706 return ( nodeName( elem, "input" ) || nodeName( elem, "button" ) ) && 1707 elem.type === type; 1708 }; 1709} 1710 1711/** 1712 * Returns a function to use in pseudos for :enabled/:disabled 1713 * @param {Boolean} disabled true for :disabled; false for :enabled 1714 */ 1715function createDisabledPseudo( disabled ) { 1716 1717 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable 1718 return function( elem ) { 1719 1720 // Only certain elements can match :enabled or :disabled 1721 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled 1722 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled 1723 if ( "form" in elem ) { 1724 1725 // Check for inherited disabledness on relevant non-disabled elements: 1726 // * listed form-associated elements in a disabled fieldset 1727 // https://html.spec.whatwg.org/multipage/forms.html#category-listed 1728 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled 1729 // * option elements in a disabled optgroup 1730 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled 1731 // All such elements have a "form" property. 1732 if ( elem.parentNode && elem.disabled === false ) { 1733 1734 // Option elements defer to a parent optgroup if present 1735 if ( "label" in elem ) { 1736 if ( "label" in elem.parentNode ) { 1737 return elem.parentNode.disabled === disabled; 1738 } else { 1739 return elem.disabled === disabled; 1740 } 1741 } 1742 1743 // Support: IE 6 - 11+ 1744 // Use the isDisabled shortcut property to check for disabled fieldset ancestors 1745 return elem.isDisabled === disabled || 1746 1747 // Where there is no isDisabled, check manually 1748 elem.isDisabled !== !disabled && 1749 inDisabledFieldset( elem ) === disabled; 1750 } 1751 1752 return elem.disabled === disabled; 1753 1754 // Try to winnow out elements that can't be disabled before trusting the disabled property. 1755 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't 1756 // even exist on them, let alone have a boolean value. 1757 } else if ( "label" in elem ) { 1758 return elem.disabled === disabled; 1759 } 1760 1761 // Remaining elements are neither :enabled nor :disabled 1762 return false; 1763 }; 1764} 1765 1766/** 1767 * Returns a function to use in pseudos for positionals 1768 * @param {Function} fn 1769 */ 1770function createPositionalPseudo( fn ) { 1771 return markFunction( function( argument ) { 1772 argument = +argument; 1773 return markFunction( function( seed, matches ) { 1774 var j, 1775 matchIndexes = fn( [], seed.length, argument ), 1776 i = matchIndexes.length; 1777 1778 // Match elements found at the specified indexes 1779 while ( i-- ) { 1780 if ( seed[ ( j = matchIndexes[ i ] ) ] ) { 1781 seed[ j ] = !( matches[ j ] = seed[ j ] ); 1782 } 1783 } 1784 } ); 1785 } ); 1786} 1787 1788/** 1789 * Checks a node for validity as a jQuery selector context 1790 * @param {Element|Object=} context 1791 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 1792 */ 1793function testContext( context ) { 1794 return context && typeof context.getElementsByTagName !== "undefined" && context; 1795} 1796 1797/** 1798 * Sets document-related variables once based on the current document 1799 * @param {Element|Object} [node] An element or document object to use to set the document 1800 * @returns {Object} Returns the current document 1801 */ 1802function setDocument( node ) { 1803 var subWindow, 1804 doc = node ? node.ownerDocument || node : preferredDoc; 1805 1806 // Return early if doc is invalid or already selected 1807 // Support: IE 11+, Edge 17 - 18+ 1808 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1809 // two documents; shallow comparisons work. 1810 // eslint-disable-next-line eqeqeq 1811 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { 1812 return document; 1813 } 1814 1815 // Update global variables 1816 document = doc; 1817 documentElement = document.documentElement; 1818 documentIsHTML = !jQuery.isXMLDoc( document ); 1819 1820 // Support: iOS 7 only, IE 9 - 11+ 1821 // Older browsers didn't support unprefixed `matches`. 1822 matches = documentElement.matches || 1823 documentElement.webkitMatchesSelector || 1824 documentElement.msMatchesSelector; 1825 1826 // Support: IE 9 - 11+, Edge 12 - 18+ 1827 // Accessing iframe documents after unload throws "permission denied" errors
1827 (see trac-13936) 1828 // Support: IE 11+, Edge 17 - 18+ 1829 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 1830 // two documents; shallow comparisons work. 1831 // eslint-disable-next-line eqeqeq 1832 if (
vendor: 44,049 bytes, lines 1832-3395
1832preferredDoc != document && 1833 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { 1834 1835 // Support: IE 9 - 11+, Edge 12 - 18+ 1836 subWindow.addEventListener( "unload", unloadHandler ); 1837 } 1838 1839 // Support: IE <10 1840 // Check if getElementById returns elements by name 1841 // The broken getElementById methods don't pick up programmatically-set names, 1842 // so use a roundabout getElementsByName test 1843 support.getById = assert( function( el ) { 1844 documentElement.appendChild( el ).id = jQuery.expando; 1845 return !document.getElementsByName || 1846 !document.getElementsByName( jQuery.expando ).length; 1847 } ); 1848 1849 // Support: IE 9 only 1850 // Check to see if it's possible to do matchesSelector 1851 // on a disconnected node. 1852 support.disconnectedMatch = assert( function( el ) { 1853 return matches.call( el, "*" ); 1854 } ); 1855 1856 // Support: IE 9 - 11+, Edge 12 - 18+ 1857 // IE/Edge don't support the :scope pseudo-class. 1858 support.scope = assert( function() { 1859 return document.querySelectorAll( ":scope" ); 1860 } ); 1861 1862 // Support: Chrome 105 - 111 only, Safari 15.4 - 16.3 only 1863 // Make sure the `:has()` argument is parsed unforgivingly. 1864 // We include `*` in the test to detect buggy implementations that are 1865 // _selectively_ forgiving (specifically when the list includes at least 1866 // one valid selector). 1867 // Note that we treat complete lack of support for `:has()` as if it were 1868 // spec-compliant support, which is fine because use of `:has()` in such 1869 // environments will fail in the qSA path and fall back to jQuery traversal 1870 // anyway. 1871 support.cssHas = assert( function() { 1872 try { 1873 document.querySelector( ":has(*,:jqfake)" ); 1874 return false; 1875 } catch ( e ) { 1876 return true; 1877 } 1878 } ); 1879 1880 // ID filter and find 1881 if ( support.getById ) { 1882 Expr.filter.ID = function( id ) { 1883 var attrId = id.replace( runescape, funescape ); 1884 return function( elem ) { 1885 return elem.getAttribute( "id" ) === attrId; 1886 }; 1887 }; 1888 Expr.find.ID = function( id, context ) { 1889 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1890 var elem = context.getElementById( id ); 1891 return elem ? [ elem ] : []; 1892 } 1893 }; 1894 } else { 1895 Expr.filter.ID = function( id ) { 1896 var attrId = id.replace( runescape, funescape ); 1897 return function( elem ) { 1898 var node = typeof elem.getAttributeNode !== "undefined" && 1899 elem.getAttributeNode( "id" ); 1900 return node && node.value === attrId; 1901 }; 1902 }; 1903 1904 // Support: IE 6 - 7 only 1905 // getElementById is not reliable as a find shortcut 1906 Expr.find.ID = function( id, context ) { 1907 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1908 var node, i, elems, 1909 elem = context.getElementById( id ); 1910 1911 if ( elem ) { 1912 1913 // Verify the id attribute 1914 node = elem.getAttributeNode( "id" ); 1915 if ( node && node.value === id ) { 1916 return [ elem ]; 1917 } 1918 1919 // Fall back on getElementsByName 1920 elems = context.getElementsByName( id ); 1921 i = 0; 1922 while ( ( elem = elems[ i++ ] ) ) { 1923 node = elem.getAttributeNode( "id" ); 1924 if ( node && node.value === id ) { 1925 return [ elem ]; 1926 } 1927 } 1928 } 1929 1930 return []; 1931 } 1932 }; 1933 } 1934 1935 // Tag 1936 Expr.find.TAG = function( tag, context ) { 1937 if ( typeof context.getElementsByTagName !== "undefined" ) { 1938 return context.getElementsByTagName( tag ); 1939 1940 // DocumentFragment nodes don't have gEBTN 1941 } else { 1942 return context.querySelectorAll( tag ); 1943 } 1944 }; 1945 1946 // Class 1947 Expr.find.CLASS = function( className, context ) { 1948 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 1949 return context.getElementsByClassName( className ); 1950 } 1951 }; 1952 1953 /* QSA/matchesSelector 1954 ---------------------------------------------------------------------- */ 1955 1956 // QSA and matchesSelector support 1957 1958 rbuggyQSA = []; 1959 1960 // Build QSA regex 1961 // Regex strategy adopted from Diego Perini 1962 assert( function( el ) { 1963 1964 var input; 1965 1966 documentElement.appendChild( el ).innerHTML = 1967 "<a id='" + expando + "' href='' disabled='disabled'></a>" + 1968 "<select id='" + expando + "-\r\\' disabled='disabled'>" + 1969 "<option selected=''></option></select>"; 1970 1971 // Support: iOS <=7 - 8 only 1972 // Boolean attributes and "value" are not treated correctly in some XML documents 1973 if ( !el.querySelectorAll( "[selected]" ).length ) { 1974 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 1975 } 1976 1977 // Support: iOS <=7 - 8 only 1978 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 1979 rbuggyQSA.push( "~=" ); 1980 } 1981 1982 // Support: iOS 8 only 1983 // https://bugs.webkit.org/show_bug.cgi?id=136851 1984 // In-page `selector#id sibling-combinator selector` fails 1985 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { 1986 rbuggyQSA.push( ".#.+[+~]" ); 1987 } 1988 1989 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+ 1990 // In some of the document kinds, these selectors wouldn't work natively. 1991 // This is probably OK but for backwards compatibility we want to maintain 1992 // handling them through jQuery traversal in jQuery 3.x. 1993 if ( !el.querySelectorAll( ":checked" ).length ) { 1994 rbuggyQSA.push( ":checked" ); 1995 } 1996 1997 // Support: Windows 8 Native Apps 1998 // The type and name attributes are restricted during .innerHTML assignment 1999 input = document.createElement( "input" ); 2000 input.setAttribute( "type", "hidden" ); 2001 el.appendChild( input ).setAttribute( "name", "D" ); 2002 2003 // Support: IE 9 - 11+ 2004 // IE's :disabled selector does not pick up the children of disabled fieldsets 2005 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+ 2006 // In some of the document kinds, these selectors wouldn't work natively. 2007 // This is probably OK but for backwards compatibility we want to maintain 2008 // handling them through jQuery traversal in jQuery 3.x. 2009 documentElement.appendChild( el ).disabled = true; 2010 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { 2011 rbuggyQSA.push( ":enabled", ":disabled" ); 2012 } 2013 2014 // Support: IE 11+, Edge 15 - 18+ 2015 // IE 11/Edge don't find elements on a `[name='']` query in some cases. 2016 // Adding a temporary attribute to the document before the selection works 2017 // around the issue. 2018 // Interestingly, IE 10 & older don't seem to have the issue. 2019 input = document.createElement( "input" ); 2020 input.setAttribute( "name", "" ); 2021 el.appendChild( input ); 2022 if ( !el.querySelectorAll( "[name='']" ).length ) { 2023 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + 2024 whitespace + "*(?:''|\"\")" ); 2025 } 2026 } ); 2027 2028 if ( !support.cssHas ) { 2029 2030 // Support: Chrome 105 - 110+, Safari 15.4 - 16.3+ 2031 // Our regular `try-catch` mechanism fails to detect natively-unsupported 2032 // pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`) 2033 // in browsers that parse the `:has()` argument as a forgiving selector list. 2034 // https://drafts.csswg.org/selectors/#relational now requires the argument 2035 // to be parsed unforgivingly, but browsers have not yet fully adjusted. 2036 rbuggyQSA.push( ":has" ); 2037 } 2038 2039 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); 2040 2041 /* Sorting 2042 ---------------------------------------------------------------------- */ 2043 2044 // Document order sorting 2045 sortOrder = function( a, b ) { 2046 2047 // Flag for duplicate removal 2048 if ( a === b ) { 2049 hasDuplicate = true; 2050 return 0; 2051 } 2052 2053 // Sort on method existence if only one input has compareDocumentPosition 2054 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 2055 if ( compare ) { 2056 return compare; 2057 } 2058 2059 // Calculate position if both inputs belong to the same document 2060 // Support: IE 11+, Edge 17 - 18+ 2061 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 2062 // two documents; shallow comparisons work. 2063 // eslint-disable-next-line eqeqeq 2064 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? 2065 a.compareDocumentPosition( b ) : 2066 2067 // Otherwise we know they are disconnected 2068 1; 2069 2070 // Disconnected nodes 2071 if ( compare & 1 || 2072 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { 2073 2074 // Choose the first element that is related to our preferred document 2075 // Support: IE 11+, Edge 17 - 18+ 2076 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 2077 // two documents; shallow comparisons work. 2078 // eslint-disable-next-line eqeqeq 2079 if ( a === document || a.ownerDocument == preferredDoc && 2080 find.contains( preferredDoc, a ) ) { 2081 return -1; 2082 } 2083 2084 // Support: IE 11+, Edge 17 - 18+ 2085 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 2086 // two documents; shallow comparisons work. 2087 // eslint-disable-next-line eqeqeq 2088 if ( b === document || b.ownerDocument == preferredDoc && 2089 find.contains( preferredDoc, b ) ) { 2090 return 1; 2091 } 2092 2093 // Maintain original order 2094 return sortInput ? 2095 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : 2096 0; 2097 } 2098 2099 return compare & 4 ? -1 : 1; 2100 }; 2101 2102 return document; 2103} 2104 2105find.matches = function( expr, elements ) { 2106 return find( expr, null, null, elements ); 2107}; 2108 2109find.matchesSelector = function( elem, expr ) { 2110 setDocument( elem ); 2111 2112 if ( documentIsHTML && 2113 !nonnativeSelectorCache[ expr + " " ] && 2114 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 2115 2116 try { 2117 var ret = matches.call( elem, expr ); 2118 2119 // IE 9's matchesSelector returns false on disconnected nodes 2120 if ( ret || support.disconnectedMatch || 2121 2122 // As well, disconnected nodes are said to be in a document 2123 // fragment in IE 9 2124 elem.document && elem.document.nodeType !== 11 ) { 2125 return ret; 2126 } 2127 } catch ( e ) { 2128 nonnativeSelectorCache( expr, true ); 2129 } 2130 } 2131 2132 return find( expr, document, null, [ elem ] ).length > 0; 2133}; 2134 2135find.contains = function( context, elem ) { 2136 2137 // Set document vars if needed 2138 // Support: IE 11+, Edge 17 - 18+ 2139 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 2140 // two documents; shallow comparisons work. 2141 // eslint-disable-next-line eqeqeq 2142 if ( ( context.ownerDocument || context ) != document ) { 2143 setDocument( context ); 2144 } 2145 return jQuery.contains( context, elem ); 2146}; 2147 2148 2149find.attr = function( elem, name ) { 2150 2151 // Set document vars if needed 2152 // Support: IE 11+, Edge 17 - 18+ 2153 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 2154 // two documents; shallow comparisons work. 2155 // eslint-disable-next-line eqeqeq 2156 if ( ( elem.ownerDocument || elem ) != document ) { 2157 setDocument( elem ); 2158 } 2159 2160 var fn = Expr.attrHandle[ name.toLowerCase() ], 2161 2162 // Don't get fooled by Object.prototype properties (see trac-13807) 2163 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 2164 fn( elem, name, !documentIsHTML ) : 2165 undefined; 2166 2167 if ( val !== undefined ) { 2168 return val; 2169 } 2170 2171 return elem.getAttribute( name ); 2172}; 2173 2174find.error = function( msg ) { 2175 throw new Error( "Syntax error, unrecognized expression: " + msg ); 2176}; 2177 2178/** 2179 * Document sorting and removing duplicates 2180 * @param {ArrayLike} results 2181 */ 2182jQuery.uniqueSort = function( results ) { 2183 var elem, 2184 duplicates = [], 2185 j = 0, 2186 i = 0; 2187 2188 // Unless we *know* we can detect duplicates, assume their presence 2189 // 2190 // Support: Android <=4.0+ 2191 // Testing for detecting duplicates is unpredictable so instead assume we can't 2192 // depend on duplicate detection in all browsers without a stable sort. 2193 hasDuplicate = !support.sortStable; 2194 sortInput = !support.sortStable && slice.call( results, 0 ); 2195 sort.call( results, sortOrder ); 2196 2197 if ( hasDuplicate ) { 2198 while ( ( elem = results[ i++ ] ) ) { 2199 if ( elem === results[ i ] ) { 2200 j = duplicates.push( i ); 2201 } 2202 } 2203 while ( j-- ) { 2204 splice.call( results, duplicates[ j ], 1 ); 2205 } 2206 } 2207 2208 // Clear input after sorting to release objects 2209 // See https://github.com/jquery/sizzle/pull/225 2210 sortInput = null; 2211 2212 return results; 2213}; 2214 2215jQuery.fn.uniqueSort = function() { 2216 return this.pushStack( jQuery.uniqueSort( slice.apply( this ) ) ); 2217}; 2218 2219Expr = jQuery.expr = { 2220 2221 // Can be adjusted by the user 2222 cacheLength: 50, 2223 2224 createPseudo: markFunction, 2225 2226 match: matchExpr, 2227 2228 attrHandle: {}, 2229 2230 find: {}, 2231 2232 relative: { 2233 ">": { dir: "parentNode", first: true }, 2234 " ": { dir: "parentNode" }, 2235 "+": { dir: "previousSibling", first: true }, 2236 "~": { dir: "previousSibling" } 2237 }, 2238 2239 preFilter: { 2240 ATTR: function( match ) { 2241 match[ 1 ] = match[ 1 ].replace( runescape, funescape ); 2242 2243 // Move the given value to match[3] whether quoted or unquoted 2244 match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" ) 2245 .replace( runescape, funescape ); 2246 2247 if ( match[ 2 ] === "~=" ) { 2248 match[ 3 ] = " " + match[ 3 ] + " "; 2249 } 2250 2251 return match.slice( 0, 4 ); 2252 }, 2253 2254 CHILD: function( match ) { 2255 2256 /* matches from matchExpr["CHILD"] 2257 1 type (only|nth|...) 2258 2 what (child|of-type) 2259 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 2260 4 xn-component of xn+y argument ([+-]?\d*n|) 2261 5 sign of xn-component 2262 6 x of xn-component 2263 7 sign of y-component 2264 8 y of y-component 2265 */ 2266 match[ 1 ] = match[ 1 ].toLowerCase(); 2267 2268 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { 2269 2270 // nth-* requires argument 2271 if ( !match[ 3 ] ) { 2272 find.error( match[ 0 ] ); 2273 } 2274 2275 // numeric x and y parameters for Expr.filter.CHILD 2276 // remember that false/true cast respectively to 0/1 2277 match[ 4 ] = +( match[ 4 ] ? 2278 match[ 5 ] + ( match[ 6 ] || 1 ) : 2279 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) 2280 ); 2281 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); 2282 2283 // other types prohibit arguments 2284 } else if ( match[ 3 ] ) { 2285 find.error( match[ 0 ] ); 2286 } 2287 2288 return match; 2289 }, 2290 2291 PSEUDO: function( match ) { 2292 var excess, 2293 unquoted = !match[ 6 ] && match[ 2 ]; 2294 2295 if ( matchExpr.CHILD.test( match[ 0 ] ) ) { 2296 return null; 2297 } 2298 2299 // Accept quoted arguments as-is 2300 if ( match[ 3 ] ) { 2301 match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; 2302 2303 // Strip excess characters from unquoted arguments 2304 } else if ( unquoted && rpseudo.test( unquoted ) && 2305 2306 // Get excess from tokenize (recursively) 2307 ( excess = tokenize( unquoted, true ) ) && 2308 2309 // advance to the next closing parenthesis 2310 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { 2311 2312 // excess is a negative index 2313 match[ 0 ] = match[ 0 ].slice( 0, excess ); 2314 match[ 2 ] = unquoted.slice( 0, excess ); 2315 } 2316 2317 // Return only captures needed by the pseudo filter method (type and argument) 2318 return match.slice( 0, 3 ); 2319 } 2320 }, 2321 2322 filter: { 2323 2324 TAG: function( nodeNameSelector ) { 2325 var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 2326 return nodeNameSelector === "*" ? 2327 function() { 2328 return true; 2329 } : 2330 function( elem ) { 2331 return nodeName( elem, expectedNodeName ); 2332 }; 2333 }, 2334 2335 CLASS: function( className ) { 2336 var pattern = classCache[ className + " " ]; 2337 2338 return pattern || 2339 ( pattern = new RegExp( "(^|" + whitespace + ")" + className + 2340 "(" + whitespace + "|$)" ) ) && 2341 classCache( className, function( elem ) { 2342 return pattern.test( 2343 typeof elem.className === "string" && elem.className || 2344 typeof elem.getAttribute !== "undefined" && 2345 elem.getAttribute( "class" ) || 2346 "" 2347 ); 2348 } ); 2349 }, 2350 2351 ATTR: function( name, operator, check ) { 2352 return function( elem ) { 2353 var result = find.attr( elem, name ); 2354 2355 if ( result == null ) { 2356 return operator === "!="; 2357 } 2358 if ( !operator ) { 2359 return true; 2360 } 2361 2362 result += ""; 2363 2364 if ( operator === "=" ) { 2365 return result === check; 2366 } 2367 if ( operator === "!=" ) { 2368 return result !== check; 2369 } 2370 if ( operator === "^=" ) { 2371 return check && result.indexOf( check ) === 0; 2372 } 2373 if ( operator === "*=" ) { 2374 return check && result.indexOf( check ) > -1; 2375 } 2376 if ( operator === "$=" ) { 2377 return check && result.slice( -check.length ) === check; 2378 } 2379 if ( operator === "~=" ) { 2380 return ( " " + result.replace( rwhitespace, " " ) + " " ) 2381 .indexOf( check ) > -1; 2382 } 2383 if ( operator === "|=" ) { 2384 return result === check || result.slice( 0, check.length + 1 ) === check + "-"; 2385 } 2386 2387 return false; 2388 }; 2389 }, 2390 2391 CHILD: function( type, what, _argument, first, last ) { 2392 var simple = type.slice( 0, 3 ) !== "nth", 2393 forward = type.slice( -4 ) !== "last", 2394 ofType = what === "of-type"; 2395 2396 return first === 1 && last === 0 ? 2397 2398 // Shortcut for :nth-*(n) 2399 function( elem ) { 2400 return !!elem.parentNode; 2401 } : 2402 2403 function( elem, _context, xml ) { 2404 var cache, outerCache, node, nodeIndex, start, 2405 dir = simple !== forward ? "nextSibling" : "previousSibling", 2406 parent = elem.parentNode, 2407 name = ofType && elem.nodeName.toLowerCase(), 2408 useCache = !xml && !ofType, 2409 diff = false; 2410 2411 if ( parent ) { 2412 2413 // :(first|last|only)-(child|of-type) 2414 if ( simple ) { 2415 while ( dir ) { 2416 node = elem; 2417 while ( ( node = node[ dir ] ) ) { 2418 if ( ofType ? 2419 nodeName( node, name ) : 2420 node.nodeType === 1 ) { 2421 2422 return false; 2423 } 2424 } 2425 2426 // Reverse direction for :only-* (if we haven't yet done so) 2427 start = dir = type === "only" && !start && "nextSibling"; 2428 } 2429 return true; 2430 } 2431 2432 start = [ forward ? parent.firstChild : parent.lastChild ]; 2433 2434 // non-xml :nth-child(...) stores cache data on `parent` 2435 if ( forward && useCache ) { 2436 2437 // Seek `elem` from a previously-cached index 2438 outerCache = parent[ expando ] || ( parent[ expando ] = {} ); 2439 cache = outerCache[ type ] || []; 2440 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 2441 diff = nodeIndex && cache[ 2 ]; 2442 node = nodeIndex && parent.childNodes[ nodeIndex ]; 2443 2444 while ( ( node = ++nodeIndex && node && node[ dir ] || 2445 2446 // Fallback to seeking `elem` from the start 2447 ( diff = nodeIndex = 0 ) || start.pop() ) ) { 2448 2449 // When found, cache indexes on `parent` and break 2450 if ( node.nodeType === 1 && ++diff && node === elem ) { 2451 outerCache[ type ] = [ dirruns, nodeIndex, diff ]; 2452 break; 2453 } 2454 } 2455 2456 } else { 2457 2458 // Use previously-cached element index if available 2459 if ( useCache ) { 2460 outerCache = elem[ expando ] || ( elem[ expando ] = {} ); 2461 cache = outerCache[ type ] || []; 2462 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 2463 diff = nodeIndex; 2464 } 2465 2466 // xml :nth-child(...) 2467 // or :nth-last-child(...) or :nth(-last)?-of-type(...) 2468 if ( diff === false ) { 2469 2470 // Use the same loop as above to seek `elem` from the start 2471 while ( ( node = ++nodeIndex && node && node[ dir ] || 2472 ( diff = nodeIndex = 0 ) || start.pop() ) ) { 2473 2474 if ( ( ofType ? 2475 nodeName( node, name ) : 2476 node.nodeType === 1 ) && 2477 ++diff ) { 2478 2479 // Cache the index of each encountered element 2480 if ( useCache ) { 2481 outerCache = node[ expando ] || 2482 ( node[ expando ] = {} ); 2483 outerCache[ type ] = [ dirruns, diff ]; 2484 } 2485 2486 if ( node === elem ) { 2487 break; 2488 } 2489 } 2490 } 2491 } 2492 } 2493 2494 // Incorporate the offset, then check against cycle size 2495 diff -= last; 2496 return diff === first || ( diff % first === 0 && diff / first >= 0 ); 2497 } 2498 }; 2499 }, 2500 2501 PSEUDO: function( pseudo, argument ) { 2502 2503 // pseudo-class names are case-insensitive 2504 // https://www.w3.org/TR/selectors/#pseudo-classes 2505 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 2506 // Remember that setFilters inherits from pseudos 2507 var args, 2508 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 2509 find.error( "unsupported pseudo: " + pseudo ); 2510 2511 // The user may use createPseudo to indicate that 2512 // arguments are needed to create the filter function 2513 // just as jQuery does 2514 if ( fn[ expando ] ) { 2515 return fn( argument ); 2516 } 2517 2518 // But maintain support for old signatures 2519 if ( fn.length > 1 ) { 2520 args = [ pseudo, pseudo, "", argument ]; 2521 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 2522 markFunction( function( seed, matches ) { 2523 var idx, 2524 matched = fn( seed, argument ), 2525 i = matched.length; 2526 while ( i-- ) { 2527 idx = indexOf.call( seed, matched[ i ] ); 2528 seed[ idx ] = !( matches[ idx ] = matched[ i ] ); 2529 } 2530 } ) : 2531 function( elem ) { 2532 return fn( elem, 0, args ); 2533 }; 2534 } 2535 2536 return fn; 2537 } 2538 }, 2539 2540 pseudos: { 2541 2542 // Potentially complex pseudos 2543 not: markFunction( function( selector ) { 2544 2545 // Trim the selector passed to compile 2546 // to avoid treating leading and trailing 2547 // spaces as combinators 2548 var input = [], 2549 results = [], 2550 matcher = compile( selector.replace( rtrimCSS, "$1" ) ); 2551 2552 return matcher[ expando ] ? 2553 markFunction( function( seed, matches, _context, xml ) { 2554 var elem, 2555 unmatched = matcher( seed, null, xml, [] ), 2556 i = seed.length; 2557 2558 // Match elements unmatched by `matcher` 2559 while ( i-- ) { 2560 if ( ( elem = unmatched[ i ] ) ) { 2561 seed[ i ] = !( matches[ i ] = elem ); 2562 } 2563 } 2564 } ) : 2565 function( elem, _context, xml ) { 2566 input[ 0 ] = elem; 2567 matcher( input, null, xml, results ); 2568 2569 // Don't keep the element 2570 // (see https://github.com/jquery/sizzle/issues/299) 2571 input[ 0 ] = null; 2572 return !results.pop(); 2573 }; 2574 } ), 2575 2576 has: markFunction( function( selector ) { 2577 return function( elem ) { 2578 return find( selector, elem ).length > 0; 2579 }; 2580 } ), 2581 2582 contains: markFunction( function( text ) { 2583 text = text.replace( runescape, funescape ); 2584 return function( elem ) { 2585 return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1; 2586 }; 2587 } ), 2588 2589 // "Whether an element is represented by a :lang() selector 2590 // is based solely on the element's language value 2591 // being equal to the identifier C, 2592 // or beginning with the identifier C immediately followed by "-". 2593 // The matching of C against the element's language value is performed case-insensitively. 2594 // The identifier C does not have to be a valid language name." 2595 // https://www.w3.org/TR/selectors/#lang-pseudo 2596 lang: markFunction( function( lang ) { 2597 2598 // lang value must be a valid identifier 2599 if ( !ridentifier.test( lang || "" ) ) { 2600 find.error( "unsupported lang: " + lang ); 2601 } 2602 lang = lang.replace( runescape, funescape ).toLowerCase(); 2603 return function( elem ) { 2604 var elemLang; 2605 do { 2606 if ( ( elemLang = documentIsHTML ? 2607 elem.lang : 2608 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { 2609 2610 elemLang = elemLang.toLowerCase(); 2611 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 2612 } 2613 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); 2614 return false; 2615 }; 2616 } ), 2617 2618 // Miscellaneous 2619 target: function( elem ) { 2620 var hash = window.location && window.location.hash; 2621 return hash && hash.slice( 1 ) === elem.id; 2622 }, 2623 2624 root: function( elem ) { 2625 return elem === documentElement; 2626 }, 2627 2628 focus: function( elem ) { 2629 return elem === safeActiveElement() && 2630 document.hasFocus() && 2631 !!( elem.type || elem.href || ~elem.tabIndex ); 2632 }, 2633 2634 // Boolean properties 2635 enabled: createDisabledPseudo( false ), 2636 disabled: createDisabledPseudo( true ), 2637 2638 checked: function( elem ) { 2639 2640 // In CSS3, :checked should return both checked and selected elements 2641 // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 2642 return ( nodeName( elem, "input" ) && !!elem.checked ) || 2643 ( nodeName( elem, "option" ) && !!elem.selected ); 2644 }, 2645 2646 selected: function( elem ) { 2647 2648 // Support: IE <=11+ 2649 // Accessing the selectedIndex property 2650 // forces the browser to treat the default option as 2651 // selected when in an optgroup. 2652 if ( elem.parentNode ) { 2653 // eslint-disable-next-line no-unused-expressions 2654 elem.parentNode.selectedIndex; 2655 } 2656 2657 return elem.selected === true; 2658 }, 2659 2660 // Contents 2661 empty: function( elem ) { 2662 2663 // https://www.w3.org/TR/selectors/#empty-pseudo 2664 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 2665 // but not by others (comment: 8; processing instruction: 7; etc.) 2666 // nodeType < 6 works because attributes (2) do not appear as children 2667 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 2668 if ( elem.nodeType < 6 ) { 2669 return false; 2670 } 2671 } 2672 return true; 2673 }, 2674 2675 parent: function( elem ) { 2676 return !Expr.pseudos.empty( elem ); 2677 }, 2678 2679 // Element/input types 2680 header: function( elem ) { 2681 return rheader.test( elem.nodeName ); 2682 }, 2683 2684 input: function( elem ) { 2685 return rinputs.test( elem.nodeName ); 2686 }, 2687 2688 button: function( elem ) { 2689 return nodeName( elem, "input" ) && elem.type === "button" || 2690 nodeName( elem, "button" ); 2691 }, 2692 2693 text: function( elem ) { 2694 var attr; 2695 return nodeName( elem, "input" ) && elem.type === "text" && 2696 2697 // Support: IE <10 only 2698 // New HTML5 attribute values (e.g., "search") appear 2699 // with elem.type === "text" 2700 ( ( attr = elem.getAttribute( "type" ) ) == null || 2701 attr.toLowerCase() === "text" ); 2702 }, 2703 2704 // Position-in-collection 2705 first: createPositionalPseudo( function() { 2706 return [ 0 ]; 2707 } ), 2708 2709 last: createPositionalPseudo( function( _matchIndexes, length ) { 2710 return [ length - 1 ]; 2711 } ), 2712 2713 eq: createPositionalPseudo( function( _matchIndexes, length, argument ) { 2714 return [ argument < 0 ? argument + length : argument ]; 2715 } ), 2716 2717 even: createPositionalPseudo( function( matchIndexes, length ) { 2718 var i = 0; 2719 for ( ; i < length; i += 2 ) { 2720 matchIndexes.push( i ); 2721 } 2722 return matchIndexes; 2723 } ), 2724 2725 odd: createPositionalPseudo( function( matchIndexes, length ) { 2726 var i = 1; 2727 for ( ; i < length; i += 2 ) { 2728 matchIndexes.push( i ); 2729 } 2730 return matchIndexes; 2731 } ), 2732 2733 lt: createPositionalPseudo( function( matchIndexes, length, argument ) { 2734 var i; 2735 2736 if ( argument < 0 ) { 2737 i = argument + length; 2738 } else if ( argument > length ) { 2739 i = length; 2740 } else { 2741 i = argument; 2742 } 2743 2744 for ( ; --i >= 0; ) { 2745 matchIndexes.push( i ); 2746 } 2747 return matchIndexes; 2748 } ), 2749 2750 gt: createPositionalPseudo( function( matchIndexes, length, argument ) { 2751 var i = argument < 0 ? argument + length : argument; 2752 for ( ; ++i < length; ) { 2753 matchIndexes.push( i ); 2754 } 2755 return matchIndexes; 2756 } ) 2757 } 2758}; 2759 2760Expr.pseudos.nth = Expr.pseudos.eq; 2761 2762// Add button/input type pseudos 2763for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 2764 Expr.pseudos[ i ] = createInputPseudo( i ); 2765} 2766for ( i in { submit: true, reset: true } ) { 2767 Expr.pseudos[ i ] = createButtonPseudo( i ); 2768} 2769 2770// Easy API for creating new setFilters 2771function setFilters() {} 2772setFilters.prototype = Expr.filters = Expr.pseudos; 2773Expr.setFilters = new setFilters(); 2774 2775function tokenize( selector, parseOnly ) { 2776 var matched, match, tokens, type, 2777 soFar, groups, preFilters, 2778 cached = tokenCache[ selector + " " ]; 2779 2780 if ( cached ) { 2781 return parseOnly ? 0 : cached.slice( 0 ); 2782 } 2783 2784 soFar = selector; 2785 groups = []; 2786 preFilters = Expr.preFilter; 2787 2788 while ( soFar ) { 2789 2790 // Comma and first run 2791 if ( !matched || ( match = rcomma.exec( soFar ) ) ) { 2792 if ( match ) { 2793 2794 // Don't consume trailing commas as valid 2795 soFar = soFar.slice( match[ 0 ].length ) || soFar; 2796 } 2797 groups.push( ( tokens = [] ) ); 2798 } 2799 2800 matched = false; 2801 2802 // Combinators 2803 if ( ( match = rleadingCombinator.exec( soFar ) ) ) { 2804 matched = match.shift(); 2805 tokens.push( { 2806 value: matched, 2807 2808 // Cast descendant combinators to space 2809 type: match[ 0 ].replace( rtrimCSS, " " ) 2810 } ); 2811 soFar = soFar.slice( matched.length ); 2812 } 2813 2814 // Filters 2815 for ( type in Expr.filter ) { 2816 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || 2817 ( match = preFilters[ type ]( match ) ) ) ) { 2818 matched = match.shift(); 2819 tokens.push( { 2820 value: matched, 2821 type: type, 2822 matches: match 2823 } ); 2824 soFar = soFar.slice( matched.length ); 2825 } 2826 } 2827 2828 if ( !matched ) { 2829 break; 2830 } 2831 } 2832 2833 // Return the length of the invalid excess 2834 // if we're just parsing 2835 // Otherwise, throw an error or return tokens 2836 if ( parseOnly ) { 2837 return soFar.length; 2838 } 2839 2840 return soFar ? 2841 find.error( selector ) : 2842 2843 // Cache the tokens 2844 tokenCache( selector, groups ).slice( 0 ); 2845} 2846 2847function toSelector( tokens ) { 2848 var i = 0, 2849 len = tokens.length, 2850 selector = ""; 2851 for ( ; i < len; i++ ) { 2852 selector += tokens[ i ].value; 2853 } 2854 return selector; 2855} 2856 2857function addCombinator( matcher, combinator, base ) { 2858 var dir = combinator.dir, 2859 skip = combinator.next, 2860 key = skip || dir, 2861 checkNonElements = base && key === "parentNode", 2862 doneName = done++; 2863 2864 return combinator.first ? 2865 2866 // Check against closest ancestor/preceding element 2867 function( elem, context, xml ) { 2868 while ( ( elem = elem[ dir ] ) ) { 2869 if ( elem.nodeType === 1 || checkNonElements ) { 2870 return matcher( elem, context, xml ); 2871 } 2872 } 2873 return false; 2874 } : 2875 2876 // Check against all ancestor/preceding elements 2877 function( elem, context, xml ) { 2878 var oldCache, outerCache, 2879 newCache = [ dirruns, doneName ]; 2880 2881 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 2882 if ( xml ) { 2883 while ( ( elem = elem[ dir ] ) ) { 2884 if ( elem.nodeType === 1 || checkNonElements ) { 2885 if ( matcher( elem, context, xml ) ) { 2886 return true; 2887 } 2888 } 2889 } 2890 } else { 2891 while ( ( elem = elem[ dir ] ) ) { 2892 if ( elem.nodeType === 1 || checkNonElements ) { 2893 outerCache = elem[ expando ] || ( elem[ expando ] = {} ); 2894 2895 if ( skip && nodeName( elem, skip ) ) { 2896 elem = elem[ dir ] || elem; 2897 } else if ( ( oldCache = outerCache[ key ] ) && 2898 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 2899 2900 // Assign to newCache so results back-propagate to previous elements 2901 return ( newCache[ 2 ] = oldCache[ 2 ] ); 2902 } else { 2903 2904 // Reuse newcache so results back-propagate to previous elements 2905 outerCache[ key ] = newCache; 2906 2907 // A match means we're done; a fail means we have to keep checking 2908 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { 2909 return true; 2910 } 2911 } 2912 } 2913 } 2914 } 2915 return false; 2916 }; 2917} 2918 2919function elementMatcher( matchers ) { 2920 return matchers.length > 1 ? 2921 function( elem, context, xml ) { 2922 var i = matchers.length; 2923 while ( i-- ) { 2924 if ( !matchers[ i ]( elem, context, xml ) ) { 2925 return false; 2926 } 2927 } 2928 return true; 2929 } : 2930 matchers[ 0 ]; 2931} 2932 2933function multipleContexts( selector, contexts, results ) { 2934 var i = 0, 2935 len = contexts.length; 2936 for ( ; i < len; i++ ) { 2937 find( selector, contexts[ i ], results ); 2938 } 2939 return results; 2940} 2941 2942function condense( unmatched, map, filter, context, xml ) { 2943 var elem, 2944 newUnmatched = [], 2945 i = 0, 2946 len = unmatched.length, 2947 mapped = map != null; 2948 2949 for ( ; i < len; i++ ) { 2950 if ( ( elem = unmatched[ i ] ) ) { 2951 if ( !filter || filter( elem, context, xml ) ) { 2952 newUnmatched.push( elem ); 2953 if ( mapped ) { 2954 map.push( i ); 2955 } 2956 } 2957 } 2958 } 2959 2960 return newUnmatched; 2961} 2962 2963function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 2964 if ( postFilter && !postFilter[ expando ] ) { 2965 postFilter = setMatcher( postFilter ); 2966 } 2967 if ( postFinder && !postFinder[ expando ] ) { 2968 postFinder = setMatcher( postFinder, postSelector ); 2969 } 2970 return markFunction( function( seed, results, context, xml ) { 2971 var temp, i, elem, matcherOut, 2972 preMap = [], 2973 postMap = [], 2974 preexisting = results.length, 2975 2976 // Get initial elements from seed or context 2977 elems = seed || 2978 multipleContexts( selector || "*", 2979 context.nodeType ? [ context ] : context, [] ), 2980 2981 // Prefilter to get matcher input, preserving a map for seed-results synchronization 2982 matcherIn = preFilter && ( seed || !selector ) ? 2983 condense( elems, preMap, preFilter, context, xml ) : 2984 elems; 2985 2986 if ( matcher ) { 2987 2988 // If we have a postFinder, or filtered seed, or non-seed postFilter 2989 // or preexisting results, 2990 matcherOut = postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 2991 2992 // ...intermediate processing is necessary 2993 [] : 2994 2995 // ...otherwise use results directly 2996 results; 2997 2998 // Find primary matches 2999 matcher( matcherIn, matcherOut, context, xml ); 3000 } else { 3001 matcherOut = matcherIn; 3002 } 3003 3004 // Apply postFilter 3005 if ( postFilter ) { 3006 temp = condense( matcherOut, postMap ); 3007 postFilter( temp, [], context, xml ); 3008 3009 // Un-match failing elements by moving them back to matcherIn 3010 i = temp.length; 3011 while ( i-- ) { 3012 if ( ( elem = temp[ i ] ) ) { 3013 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); 3014 } 3015 } 3016 } 3017 3018 if ( seed ) { 3019 if ( postFinder || preFilter ) { 3020 if ( postFinder ) { 3021 3022 // Get the final matcherOut by condensing this intermediate into postFinder contexts 3023 temp = []; 3024 i = matcherOut.length; 3025 while ( i-- ) { 3026 if ( ( elem = matcherOut[ i ] ) ) { 3027 3028 // Restore matcherIn since elem is not yet a final match 3029 temp.push( ( matcherIn[ i ] = elem ) ); 3030 } 3031 } 3032 postFinder( null, ( matcherOut = [] ), temp, xml ); 3033 } 3034 3035 // Move matched elements from seed to results to keep them synchronized 3036 i = matcherOut.length; 3037 while ( i-- ) { 3038 if ( ( elem = matcherOut[ i ] ) && 3039 ( temp = postFinder ? indexOf.call( seed, elem ) : preMap[ i ] ) > -1 ) { 3040 3041 seed[ temp ] = !( results[ temp ] = elem ); 3042 } 3043 } 3044 } 3045 3046 // Add elements to results, through postFinder if defined 3047 } else { 3048 matcherOut = condense( 3049 matcherOut === results ? 3050 matcherOut.splice( preexisting, matcherOut.length ) : 3051 matcherOut 3052 ); 3053 if ( postFinder ) { 3054 postFinder( null, results, matcherOut, xml ); 3055 } else { 3056 push.apply( results, matcherOut ); 3057 } 3058 } 3059 } ); 3060} 3061 3062function matcherFromTokens( tokens ) { 3063 var checkContext, matcher, j, 3064 len = tokens.length, 3065 leadingRelative = Expr.relative[ tokens[ 0 ].type ], 3066 implicitRelative = leadingRelative || Expr.relative[ " " ], 3067 i = leadingRelative ? 1 : 0, 3068 3069 // The foundational matcher ensures that elements are reachable from top-level context(s) 3070 matchContext = addCombinator( function( elem ) { 3071 return elem === checkContext; 3072 }, implicitRelative, true ), 3073 matchAnyContext = addCombinator( function( elem ) { 3074 return indexOf.call( checkContext, elem ) > -1; 3075 }, implicitRelative, true ), 3076 matchers = [ function( elem, context, xml ) { 3077 3078 // Support: IE 11+, Edge 17 - 18+ 3079 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 3080 // two documents; shallow comparisons work. 3081 // eslint-disable-next-line eqeqeq 3082 var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || ( 3083 ( checkContext = context ).nodeType ? 3084 matchContext( elem, context, xml ) : 3085 matchAnyContext( elem, context, xml ) ); 3086 3087 // Avoid hanging onto element 3088 // (see https://github.com/jquery/sizzle/issues/299) 3089 checkContext = null; 3090 return ret; 3091 } ]; 3092 3093 for ( ; i < len; i++ ) { 3094 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { 3095 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; 3096 } else { 3097 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); 3098 3099 // Return special upon seeing a positional matcher 3100 if ( matcher[ expando ] ) { 3101 3102 // Find the next relative operator (if any) for proper handling 3103 j = ++i; 3104 for ( ; j < len; j++ ) { 3105 if ( Expr.relative[ tokens[ j ].type ] ) { 3106 break; 3107 } 3108 } 3109 return setMatcher( 3110 i > 1 && elementMatcher( matchers ), 3111 i > 1 && toSelector( 3112 3113 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 3114 tokens.slice( 0, i - 1 ) 3115 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) 3116 ).replace( rtrimCSS, "$1" ), 3117 matcher, 3118 i < j && matcherFromTokens( tokens.slice( i, j ) ), 3119 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), 3120 j < len && toSelector( tokens ) 3121 ); 3122 } 3123 matchers.push( matcher ); 3124 } 3125 } 3126 3127 return elementMatcher( matchers ); 3128} 3129 3130function matcherFromGroupMatchers( elementMatchers, setMatchers ) { 3131 var bySet = setMatchers.length > 0, 3132 byElement = elementMatchers.length > 0, 3133 superMatcher = function( seed, context, xml, results, outermost ) { 3134 var elem, j, matcher, 3135 matchedCount = 0, 3136 i = "0", 3137 unmatched = seed && [], 3138 setMatched = [], 3139 contextBackup = outermostContext, 3140 3141 // We must always have either seed elements or outermost context 3142 elems = seed || byElement && Expr.find.TAG( "*", outermost ), 3143 3144 // Use integer dirruns iff this is the outermost matcher 3145 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), 3146 len = elems.length; 3147 3148 if ( outermost ) { 3149 3150 // Support: IE 11+, Edge 17 - 18+ 3151 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 3152 // two documents; shallow comparisons work. 3153 // eslint-disable-next-line eqeqeq 3154 outermostContext = context == document || context || outermost; 3155 } 3156 3157 // Add elements passing elementMatchers directly to results 3158 // Support: iOS <=7 - 9 only 3159 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching 3160 // elements by id. (see trac-14142) 3161 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { 3162 if ( byElement && elem ) { 3163 j = 0; 3164 3165 // Support: IE 11+, Edge 17 - 18+ 3166 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing 3167 // two documents; shallow comparisons work. 3168 // eslint-disable-next-line eqeqeq 3169 if ( !context && elem.ownerDocument != document ) { 3170 setDocument( elem ); 3171 xml = !documentIsHTML; 3172 } 3173 while ( ( matcher = elementMatchers[ j++ ] ) ) { 3174 if ( matcher( elem, context || document, xml ) ) { 3175 push.call( results, elem ); 3176 break; 3177 } 3178 } 3179 if ( outermost ) { 3180 dirruns = dirrunsUnique; 3181 } 3182 } 3183 3184 // Track unmatched elements for set filters 3185 if ( bySet ) { 3186 3187 // They will have gone through all possible matchers 3188 if ( ( elem = !matcher && elem ) ) { 3189 matchedCount--; 3190 } 3191 3192 // Lengthen the array for every element, matched or not 3193 if ( seed ) { 3194 unmatched.push( elem ); 3195 } 3196 } 3197 } 3198 3199 // `i` is now the count of elements visited above, and adding it to `matchedCount` 3200 // makes the latter nonnegative. 3201 matchedCount += i; 3202 3203 // Apply set filters to unmatched elements 3204 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 3205 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 3206 // no element matchers and no seed. 3207 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 3208 // case, which will result in a "00" `matchedCount` that differs from `i` but is also 3209 // numerically zero. 3210 if ( bySet && i !== matchedCount ) { 3211 j = 0; 3212 while ( ( matcher = setMatchers[ j++ ] ) ) { 3213 matcher( unmatched, setMatched, context, xml ); 3214 } 3215 3216 if ( seed ) { 3217 3218 // Reintegrate element matches to eliminate the need for sorting 3219 if ( matchedCount > 0 ) { 3220 while ( i-- ) { 3221 if ( !( unmatched[ i ] || setMatched[ i ] ) ) { 3222 setMatched[ i ] = pop.call( results ); 3223 } 3224 } 3225 } 3226 3227 // Discard index placeholder values to get only actual matches 3228 setMatched = condense( setMatched ); 3229 } 3230 3231 // Add matches to results 3232 push.apply( results, setMatched ); 3233 3234 // Seedless set matches succeeding multiple successful matchers stipulate sorting 3235 if ( outermost && !seed && setMatched.length > 0 && 3236 ( matchedCount + setMatchers.length ) > 1 ) { 3237 3238 jQuery.uniqueSort( results ); 3239 } 3240 } 3241 3242 // Override manipulation of globals by nested matchers 3243 if ( outermost ) { 3244 dirruns = dirrunsUnique; 3245 outermostContext = contextBackup; 3246 } 3247 3248 return unmatched; 3249 }; 3250 3251 return bySet ? 3252 markFunction( superMatcher ) : 3253 superMatcher; 3254} 3255 3256function compile( selector, match /* Internal Use Only */ ) { 3257 var i, 3258 setMatchers = [], 3259 elementMatchers = [], 3260 cached = compilerCache[ selector + " " ]; 3261 3262 if ( !cached ) { 3263 3264 // Generate a function of recursive functions that can be used to check each element 3265 if ( !match ) { 3266 match = tokenize( selector ); 3267 } 3268 i = match.length; 3269 while ( i-- ) { 3270 cached = matcherFromTokens( match[ i ] ); 3271 if ( cached[ expando ] ) { 3272 setMatchers.push( cached ); 3273 } else { 3274 elementMatchers.push( cached ); 3275 } 3276 } 3277 3278 // Cache the compiled function 3279 cached = compilerCache( selector, 3280 matcherFromGroupMatchers( elementMatchers, setMatchers ) ); 3281 3282 // Save selector and tokenization 3283 cached.selector = selector; 3284 } 3285 return cached; 3286} 3287 3288/** 3289 * A low-level selection function that works with jQuery's compiled 3290 * selector functions 3291 * @param {String|Function} selector A selector or a pre-compiled 3292 * selector function built with jQuery selector compile 3293 * @param {Element} context 3294 * @param {Array} [results] 3295 * @param {Array} [seed] A set of elements to match against 3296 */ 3297function select( selector, context, results, seed ) { 3298 var i, tokens, token, type, find, 3299 compiled = typeof selector === "function" && selector, 3300 match = !seed && tokenize( ( selector = compiled.selector || selector ) ); 3301 3302 results = results || []; 3303 3304 // Try to minimize operations if there is only one selector in the list and no seed 3305 // (the latter of which guarantees us context) 3306 if ( match.length === 1 ) { 3307 3308 // Reduce context if the leading compound selector is an ID 3309 tokens = match[ 0 ] = match[ 0 ].slice( 0 ); 3310 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && 3311 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { 3312 3313 context = ( Expr.find.ID( 3314 token.matches[ 0 ].replace( runescape, funescape ), 3315 context 3316 ) || [] )[ 0 ]; 3317 if ( !context ) { 3318 return results; 3319 3320 // Precompiled matchers will still verify ancestry, so step up a level 3321 } else if ( compiled ) { 3322 context = context.parentNode; 3323 } 3324 3325 selector = selector.slice( tokens.shift().value.length ); 3326 } 3327 3328 // Fetch a seed set for right-to-left matching 3329 i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length; 3330 while ( i-- ) { 3331 token = tokens[ i ]; 3332 3333 // Abort if we hit a combinator 3334 if ( Expr.relative[ ( type = token.type ) ] ) { 3335 break; 3336 } 3337 if ( ( find = Expr.find[ type ] ) ) { 3338 3339 // Search, expanding context for leading sibling combinators 3340 if ( ( seed = find( 3341 token.matches[ 0 ].replace( runescape, funescape ), 3342 rsibling.test( tokens[ 0 ].type ) && 3343 testContext( context.parentNode ) || context 3344 ) ) ) { 3345 3346 // If seed is empty or no tokens remain, we can return early 3347 tokens.splice( i, 1 ); 3348 selector = seed.length && toSelector( tokens ); 3349 if ( !selector ) { 3350 push.apply( results, seed ); 3351 return results; 3352 } 3353 3354 break; 3355 } 3356 } 3357 } 3358 } 3359 3360 // Compile and execute a filtering function if one is not provided 3361 // Provide `match` to avoid retokenization if we modified the selector above 3362 ( compiled || compile( selector, match ) )( 3363 seed, 3364 context, 3365 !documentIsHTML, 3366 results, 3367 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 3368 ); 3369 return results; 3370} 3371 3372// One-time assignments 3373 3374// Support: Android <=4.0 - 4.1+ 3375// Sort stability 3376support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; 3377 3378// Initialize against the default document 3379setDocument(); 3380 3381// Support: Android <=4.0 - 4.1+ 3382// Detached nodes confoundingly follow *each other* 3383support.sortDetached = assert( function( el ) { 3384 3385 // Should return 1, but returns 4 (following) 3386 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; 3387} ); 3388 3389jQuery.find = find; 3390 3391// Deprecated 3392jQuery.expr[ ":" ] = jQuery.expr.pseudos; 3393jQuery.unique = jQuery.uniqueSort; 3394 3395// These have always been private, but they used to be documented
3395 3396// as part of Sizzle so let's maintain them in the 3.x line 3397// for backwards compatibility purposes. 3398find.compile = compile; 3399find.select = select; 3400find.setDocument = setDocument
vendor: 12,898 bytes, lines 3400-3916
3400; 3401 3402find.escape = jQuery.escapeSelector; 3403find.getText = jQuery.text; 3404find.isXML = jQuery.isXMLDoc; 3405find.selectors = jQuery.expr; 3406find.support = jQuery.support; 3407find.uniqueSort = jQuery.uniqueSort; 3408 3409 /* eslint-enable */ 3410 3411} )(); 3412 3413 3414var dir = function( elem, dir, until ) { 3415 var matched = [], 3416 truncate = until !== undefined; 3417 3418 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 3419 if ( elem.nodeType === 1 ) { 3420 if ( truncate && jQuery( elem ).is( until ) ) { 3421 break; 3422 } 3423 matched.push( elem ); 3424 } 3425 } 3426 return matched; 3427}; 3428 3429 3430var siblings = function( n, elem ) { 3431 var matched = []; 3432 3433 for ( ; n; n = n.nextSibling ) { 3434 if ( n.nodeType === 1 && n !== elem ) { 3435 matched.push( n ); 3436 } 3437 } 3438 3439 return matched; 3440}; 3441 3442 3443var rneedsContext = jQuery.expr.match.needsContext; 3444 3445var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); 3446 3447 3448 3449// Implement the identical functionality for filter and not 3450function winnow( elements, qualifier, not ) { 3451 if ( isFunction( qualifier ) ) { 3452 return jQuery.grep( elements, function( elem, i ) { 3453 return !!qualifier.call( elem, i, elem ) !== not; 3454 } ); 3455 } 3456 3457 // Single element 3458 if ( qualifier.nodeType ) { 3459 return jQuery.grep( elements, function( elem ) { 3460 return ( elem === qualifier ) !== not; 3461 } ); 3462 } 3463 3464 // Arraylike of elements (jQuery, arguments, Array) 3465 if ( typeof qualifier !== "string" ) { 3466 return jQuery.grep( elements, function( elem ) { 3467 return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 3468 } ); 3469 } 3470 3471 // Filtered directly for both simple and complex selectors 3472 return jQuery.filter( qualifier, elements, not ); 3473} 3474 3475jQuery.filter = function( expr, elems, not ) { 3476 var elem = elems[ 0 ]; 3477 3478 if ( not ) { 3479 expr = ":not(" + expr + ")"; 3480 } 3481 3482 if ( elems.length === 1 && elem.nodeType === 1 ) { 3483 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; 3484 } 3485 3486 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 3487 return elem.nodeType === 1; 3488 } ) ); 3489}; 3490 3491jQuery.fn.extend( { 3492 find: function( selector ) { 3493 var i, ret, 3494 len = this.length, 3495 self = this; 3496 3497 if ( typeof selector !== "string" ) { 3498 return this.pushStack( jQuery( selector ).filter( function() { 3499 for ( i = 0; i < len; i++ ) { 3500 if ( jQuery.contains( self[ i ], this ) ) { 3501 return true; 3502 } 3503 } 3504 } ) ); 3505 } 3506 3507 ret = this.pushStack( [] ); 3508 3509 for ( i = 0; i < len; i++ ) { 3510 jQuery.find( selector, self[ i ], ret ); 3511 } 3512 3513 return len > 1 ? jQuery.uniqueSort( ret ) : ret; 3514 }, 3515 filter: function( selector ) { 3516 return this.pushStack( winnow( this, selector || [], false ) ); 3517 }, 3518 not: function( selector ) { 3519 return this.pushStack( winnow( this, selector || [], true ) ); 3520 }, 3521 is: function( selector ) { 3522 return !!winnow( 3523 this, 3524 3525 // If this is a positional/relative selector, check membership in the returned set 3526 // so $("p:first").is("p:last") won't return true for a doc with two "p". 3527 typeof selector === "string" && rneedsContext.test( selector ) ? 3528 jQuery( selector ) : 3529 selector || [], 3530 false 3531 ).length; 3532 } 3533} ); 3534 3535 3536// Initialize a jQuery object 3537 3538 3539// A central reference to the root jQuery(document) 3540var rootjQuery, 3541 3542 // A simple way to check for HTML strings 3543 // Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521) 3544 // Strict HTML recognition (trac-11290: must start with <) 3545 // Shortcut simple #id case for speed 3546 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, 3547 3548 init = jQuery.fn.init = function( selector, context, root ) { 3549 var match, elem; 3550 3551 // HANDLE: $(""), $(null), $(undefined), $(false) 3552 if ( !selector ) { 3553 return this; 3554 } 3555 3556 // Method init() accepts an alternate rootjQuery 3557 // so migrate can support jQuery.sub (gh-2101) 3558 root = root || rootjQuery; 3559 3560 // Handle HTML strings 3561 if ( typeof selector === "string" ) { 3562 if ( selector[ 0 ] === "<" && 3563 selector[ selector.length - 1 ] === ">" && 3564 selector.length >= 3 ) { 3565 3566 // Assume that strings that start and end with <> are HTML and skip the regex check 3567 match = [ null, selector, null ]; 3568 3569 } else { 3570 match = rquickExpr.exec( selector ); 3571 } 3572 3573 // Match html or make sure no context is specified for #id 3574 if ( match && ( match[ 1 ] || !context ) ) { 3575 3576 // HANDLE: $(html) -> $(array) 3577 if ( match[ 1 ] ) { 3578 context = context instanceof jQuery ? context[ 0 ] : context; 3579 3580 // Option to run scripts is true for back-compat 3581 // Intentionally let the error be thrown if parseHTML is not present 3582 jQuery.merge( this, jQuery.parseHTML( 3583 match[ 1 ], 3584 context && context.nodeType ? context.ownerDocument || context : document, 3585 true 3586 ) ); 3587 3588 // HANDLE: $(html, props) 3589 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 3590 for ( match in context ) { 3591 3592 // Properties of context are called as methods if possible 3593 if ( isFunction( this[ match ] ) ) { 3594 this[ match ]( context[ match ] ); 3595 3596 // ...and otherwise set as attributes 3597 } else { 3598 this.attr( match, context[ match ] ); 3599 } 3600 } 3601 } 3602 3603 return this; 3604 3605 // HANDLE: $(#id) 3606 } else { 3607 elem = document.getElementById( match[ 2 ] ); 3608 3609 if ( elem ) { 3610 3611 // Inject the element directly into the jQuery object 3612 this[ 0 ] = elem; 3613 this.length = 1; 3614 } 3615 return this; 3616 } 3617 3618 // HANDLE: $(expr, $(...)) 3619 } else if ( !context || context.jquery ) { 3620 return ( context || root ).find( selector ); 3621 3622 // HANDLE: $(expr, context) 3623 // (which is just equivalent to: $(context).find(expr) 3624 } else { 3625 return this.constructor( context ).find( selector ); 3626 } 3627 3628 // HANDLE: $(DOMElement) 3629 } else if ( selector.nodeType ) { 3630 this[ 0 ] = selector; 3631 this.length = 1; 3632 return this; 3633 3634 // HANDLE: $(function) 3635 // Shortcut for document ready 3636 } else if ( isFunction( selector ) ) { 3637 return root.ready !== undefined ? 3638 root.ready( selector ) : 3639 3640 // Execute immediately if ready is not present 3641 selector( jQuery ); 3642 } 3643 3644 return jQuery.makeArray( selector, this ); 3645 }; 3646 3647// Give the init function the jQuery prototype for later instantiation 3648init.prototype = jQuery.fn; 3649 3650// Initialize central reference 3651rootjQuery = jQuery( document ); 3652 3653 3654var rparentsprev = /^(?:parents|prev(?:Until|All))/, 3655 3656 // Methods guaranteed to produce a unique set when starting from a unique set 3657 guaranteedUnique = { 3658 children: true, 3659 contents: true, 3660 next: true, 3661 prev: true 3662 }; 3663 3664jQuery.fn.extend( { 3665 has: function( target ) { 3666 var targets = jQuery( target, this ), 3667 l = targets.length; 3668 3669 return this.filter( function() { 3670 var i = 0; 3671 for ( ; i < l; i++ ) { 3672 if ( jQuery.contains( this, targets[ i ] ) ) { 3673 return true; 3674 } 3675 } 3676 } ); 3677 }, 3678 3679 closest: function( selectors, context ) { 3680 var cur, 3681 i = 0, 3682 l = this.length, 3683 matched = [], 3684 targets = typeof selectors !== "string" && jQuery( selectors ); 3685 3686 // Positional selectors never match, since there's no _selection_ context 3687 if ( !rneedsContext.test( selectors ) ) { 3688 for ( ; i < l; i++ ) { 3689 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 3690 3691 // Always skip document fragments 3692 if ( cur.nodeType < 11 && ( targets ? 3693 targets.index( cur ) > -1 : 3694 3695 // Don't pass non-elements to jQuery#find 3696 cur.nodeType === 1 && 3697 jQuery.find.matchesSelector( cur, selectors ) ) ) { 3698 3699 matched.push( cur ); 3700 break; 3701 } 3702 } 3703 } 3704 } 3705 3706 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 3707 }, 3708 3709 // Determine the position of an element within the set 3710 index: function( elem ) { 3711 3712 // No argument, return index in parent 3713 if ( !elem ) { 3714 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 3715 } 3716 3717 // Index in selector 3718 if ( typeof elem === "string" ) { 3719 return indexOf.call( jQuery( elem ), this[ 0 ] ); 3720 } 3721 3722 // Locate the position of the desired element 3723 return indexOf.call( this, 3724 3725 // If it receives a jQuery object, the first element is used 3726 elem.jquery ? elem[ 0 ] : elem 3727 ); 3728 }, 3729 3730 add: function( selector, context ) { 3731 return this.pushStack( 3732 jQuery.uniqueSort( 3733 jQuery.merge( this.get(), jQuery( selector, context ) ) 3734 ) 3735 ); 3736 }, 3737 3738 addBack: function( selector ) { 3739 return this.add( selector == null ? 3740 this.prevObject : this.prevObject.filter( selector ) 3741 ); 3742 } 3743} ); 3744 3745function sibling( cur, dir ) { 3746 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 3747 return cur; 3748} 3749 3750jQuery.each( { 3751 parent: function( elem ) { 3752 var parent = elem.parentNode; 3753 return parent && parent.nodeType !== 11 ? parent : null; 3754 }, 3755 parents: function( elem ) { 3756 return dir( elem, "parentNode" ); 3757 }, 3758 parentsUntil: function( elem, _i, until ) { 3759 return dir( elem, "parentNode", until ); 3760 }, 3761 next: function( elem ) { 3762 return sibling( elem, "nextSibling" ); 3763 }, 3764 prev: function( elem ) { 3765 return sibling( elem, "previousSibling" ); 3766 }, 3767 nextAll: function( elem ) { 3768 return dir( elem, "nextSibling" ); 3769 }, 3770 prevAll: function( elem ) { 3771 return dir( elem, "previousSibling" ); 3772 }, 3773 nextUntil: function( elem, _i, until ) { 3774 return dir( elem, "nextSibling", until ); 3775 }, 3776 prevUntil: function( elem, _i, until ) { 3777 return dir( elem, "previousSibling", until ); 3778 }, 3779 siblings: function( elem ) { 3780 return siblings( ( elem.parentNode || {} ).firstChild, elem ); 3781 }, 3782 children: function( elem ) { 3783 return siblings( elem.firstChild ); 3784 }, 3785 contents: function( elem ) { 3786 if ( elem.contentDocument != null && 3787 3788 // Support: IE 11+ 3789 // <object> elements with no `data` attribute has an object 3790 // `contentDocument` with a `null` prototype. 3791 getProto( elem.contentDocument ) ) { 3792 3793 return elem.contentDocument; 3794 } 3795 3796 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only 3797 // Treat the template element as a regular one in browsers that 3798 // don't support it. 3799 if ( nodeName( elem, "template" ) ) { 3800 elem = elem.content || elem; 3801 } 3802 3803 return jQuery.merge( [], elem.childNodes ); 3804 } 3805}, function( name, fn ) { 3806 jQuery.fn[ name ] = function( until, selector ) { 3807 var matched = jQuery.map( this, fn, until ); 3808 3809 if ( name.slice( -5 ) !== "Until" ) { 3810 selector = until; 3811 } 3812 3813 if ( selector && typeof selector === "string" ) { 3814 matched = jQuery.filter( selector, matched ); 3815 } 3816 3817 if ( this.length > 1 ) { 3818 3819 // Remove duplicates 3820 if ( !guaranteedUnique[ name ] ) { 3821 jQuery.uniqueSort( matched ); 3822 } 3823 3824 // Reverse order for parents* and prev-derivatives 3825 if ( rparentsprev.test( name ) ) { 3826 matched.reverse(); 3827 } 3828 } 3829 3830 return this.pushStack( matched ); 3831 }; 3832} ); 3833var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); 3834 3835 3836 3837// Convert String-formatted options into Object-formatted ones 3838function createOptions( options ) { 3839 var object = {}; 3840 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { 3841 object[ flag ] = true; 3842 } ); 3843 return object; 3844} 3845 3846/* 3847 * Create a callback list using the following parameters: 3848 * 3849 * options: an optional list of space-separated options that will change how 3850 * the callback list behaves or a more traditional option object 3851 * 3852 * By default a callback list will act like an event callback list and can be 3853 * "fired" multiple times. 3854 * 3855 * Possible options: 3856 * 3857 * once: will ensure the callback list can only be fired once (like a Deferred) 3858 * 3859 * memory: will keep track of previous values and will call any callback added 3860 * after the list has been fired right away with the latest "memorized" 3861 * values (like a Deferred) 3862 * 3863 * unique: will ensure a callback can only be added once (no duplicate in the list) 3864 * 3865 * stopOnFalse: interrupt callings when a callback returns false 3866 * 3867 */ 3868jQuery.Callbacks = function( options ) { 3869 3870 // Convert options from String-formatted to Object-formatted if needed 3871 // (we check in cache first) 3872 options = typeof options === "string" ? 3873 createOptions( options ) : 3874 jQuery.extend( {}, options ); 3875 3876 var // Flag to know if list is currently firing 3877 firing, 3878 3879 // Last fire value for non-forgettable lists 3880 memory, 3881 3882 // Flag to know if list was already fired 3883 fired, 3884 3885 // Flag to prevent firing 3886 locked, 3887 3888 // Actual callback list 3889 list = [], 3890 3891 // Queue of execution data for repeatable lists 3892 queue = [], 3893 3894 // Index of currently firing callback (modified by add/remove as needed) 3895 firingIndex = -1, 3896 3897 // Fire callbacks 3898 fire = function() { 3899 3900 // Enforce single-firing 3901 locked = locked || options.once; 3902 3903 // Execute callbacks for all pending executions, 3904 // respecting firingIndex overrides and runtime changes 3905 fired = firing = true; 3906 for ( ; queue.length; firingIndex = -1 ) { 3907 memory = queue.shift(); 3908 while ( ++firingIndex < list.length ) { 3909 3910 // Run callback and check for early termination 3911 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 3912 options.stopOnFalse ) { 3913 3914 // Jump to end and forget the data so .add doesn't re-fire 3915 firingIndex = list.length; 3916 memory = false;
vendor: 4,918 bytes, lines 3917-4126
3917 } 3918 } 3919 } 3920 3921 // Forget the data if we're done with it 3922 if ( !options.memory ) { 3923 memory = false; 3924 } 3925 3926 firing = false; 3927 3928 // Clean up if we're done firing for good 3929 if ( locked ) { 3930 3931 // Keep an empty list if we have data for future add calls 3932 if ( memory ) { 3933 list = []; 3934 3935 // Otherwise, this object is spent 3936 } else { 3937 list = ""; 3938 } 3939 } 3940 }, 3941 3942 // Actual Callbacks object 3943 self = { 3944 3945 // Add a callback or a collection of callbacks to the list 3946 add: function() { 3947 if ( list ) { 3948 3949 // If we have memory from a past run, we should fire after adding 3950 if ( memory && !firing ) { 3951 firingIndex = list.length - 1; 3952 queue.push( memory ); 3953 } 3954 3955 ( function add( args ) { 3956 jQuery.each( args, function( _, arg ) { 3957 if ( isFunction( arg ) ) { 3958 if ( !options.unique || !self.has( arg ) ) { 3959 list.push( arg ); 3960 } 3961 } else if ( arg && arg.length && toType( arg ) !== "string" ) { 3962 3963 // Inspect recursively 3964 add( arg ); 3965 } 3966 } ); 3967 } )( arguments ); 3968 3969 if ( memory && !firing ) { 3970 fire(); 3971 } 3972 } 3973 return this; 3974 }, 3975 3976 // Remove a callback from the list 3977 remove: function() { 3978 jQuery.each( arguments, function( _, arg ) { 3979 var index; 3980 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 3981 list.splice( index, 1 ); 3982 3983 // Handle firing indexes 3984 if ( index <= firingIndex ) { 3985 firingIndex--; 3986 } 3987 } 3988 } ); 3989 return this; 3990 }, 3991 3992 // Check if a given callback is in the list. 3993 // If no argument is given, return whether or not list has callbacks attached. 3994 has: function( fn ) { 3995 return fn ? 3996 jQuery.inArray( fn, list ) > -1 : 3997 list.length > 0; 3998 }, 3999 4000 // Remove all callbacks from the list 4001 empty: function() { 4002 if ( list ) { 4003 list = []; 4004 } 4005 return this; 4006 }, 4007 4008 // Disable .fire and .add 4009 // Abort any current/pending executions 4010 // Clear all callbacks and values 4011 disable: function() { 4012 locked = queue = []; 4013 list = memory = ""; 4014 return this; 4015 }, 4016 disabled: function() { 4017 return !list; 4018 }, 4019 4020 // Disable .fire 4021 // Also disable .add unless we have memory (since it would have no effect) 4022 // Abort any pending executions 4023 lock: function() { 4024 locked = queue = []; 4025 if ( !memory && !firing ) { 4026 list = memory = ""; 4027 } 4028 return this; 4029 }, 4030 locked: function() { 4031 return !!locked; 4032 }, 4033 4034 // Call all callbacks with the given context and arguments 4035 fireWith: function( context, args ) { 4036 if ( !locked ) { 4037 args = args || []; 4038 args = [ context, args.slice ? args.slice() : args ]; 4039 queue.push( args ); 4040 if ( !firing ) { 4041 fire(); 4042 } 4043 } 4044 return this; 4045 }, 4046 4047 // Call all the callbacks with the given arguments 4048 fire: function() { 4049 self.fireWith( this, arguments ); 4050 return this; 4051 }, 4052 4053 // To know if the callbacks have already been called at least once 4054 fired: function() { 4055 return !!fired; 4056 } 4057 }; 4058 4059 return self; 4060}; 4061 4062 4063function Identity( v ) { 4064 return v; 4065} 4066function Thrower( ex ) { 4067 throw ex; 4068} 4069 4070function adoptValue( value, resolve, reject, noValue ) { 4071 var method; 4072 4073 try { 4074 4075 // Check for promise aspect first to privilege synchronous behavior 4076 if ( value && isFunction( ( method = value.promise ) ) ) { 4077 method.call( value ).done( resolve ).fail( reject ); 4078 4079 // Other thenables 4080 } else if ( value && isFunction( ( method = value.then ) ) ) { 4081 method.call( value, resolve, reject ); 4082 4083 // Other non-thenables 4084 } else { 4085 4086 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: 4087 // * false: [ value ].slice( 0 ) => resolve( value ) 4088 // * true: [ value ].slice( 1 ) => resolve() 4089 resolve.apply( undefined, [ value ].slice( noValue ) ); 4090 } 4091 4092 // For Promises/A+, convert exceptions into rejections 4093 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in 4094 // Deferred#then to conditionally suppress rejection. 4095 } catch ( value ) { 4096 4097 // Support: Android 4.0 only 4098 // Strict mode functions invoked without .call/.apply get global-object context 4099 reject.apply( undefined, [ value ] ); 4100 } 4101} 4102 4103jQuery.extend( { 4104 4105 Deferred: function( func ) { 4106 var tuples = [ 4107 4108 // action, add listener, callbacks, 4109 // ... .then handlers, argument index, [final state] 4110 [ "notify", "progress", jQuery.Callbacks( "memory" ), 4111 jQuery.Callbacks( "memory" ), 2 ], 4112 [ "resolve", "done", jQuery.Callbacks( "once memory" ), 4113 jQuery.Callbacks( "once memory" ), 0, "resolved" ], 4114 [ "reject", "fail", jQuery.Callbacks( "once memory" ), 4115 jQuery.Callbacks( "once memory" ), 1, "rejected" ] 4116 ], 4117 state = "pending", 4118 promise = { 4119 state: function() { 4120 return state; 4121 }, 4122 always: function() { 4123 deferred.done( arguments ).fail( arguments ); 4124 return this; 4125 }, 4126 "catch": function( fn ) {
vendor: 67,037 bytes, lines 4127-6614
4127 return promise.then( null, fn ); 4128 }, 4129 4130 // Keep pipe for back-compat 4131 pipe: function( /* fnDone, fnFail, fnProgress */ ) { 4132 var fns = arguments; 4133 4134 return jQuery.Deferred( function( newDefer ) { 4135 jQuery.each( tuples, function( _i, tuple ) { 4136 4137 // Map tuples (progress, done, fail) to arguments (done, fail, progress) 4138 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; 4139 4140 // deferred.progress(function() { bind to newDefer or newDefer.notify }) 4141 // deferred.done(function() { bind to newDefer or newDefer.resolve }) 4142 // deferred.fail(function() { bind to newDefer or newDefer.reject }) 4143 deferred[ tuple[ 1 ] ]( function() { 4144 var returned = fn && fn.apply( this, arguments ); 4145 if ( returned && isFunction( returned.promise ) ) { 4146 returned.promise() 4147 .progress( newDefer.notify ) 4148 .done( newDefer.resolve ) 4149 .fail( newDefer.reject ); 4150 } else { 4151 newDefer[ tuple[ 0 ] + "With" ]( 4152 this, 4153 fn ? [ returned ] : arguments 4154 ); 4155 } 4156 } ); 4157 } ); 4158 fns = null; 4159 } ).promise(); 4160 }, 4161 then: function( onFulfilled, onRejected, onProgress ) { 4162 var maxDepth = 0; 4163 function resolve( depth, deferred, handler, special ) { 4164 return function() { 4165 var that = this, 4166 args = arguments, 4167 mightThrow = function() { 4168 var returned, then; 4169 4170 // Support: Promises/A+ section 2.3.3.3.3 4171 // https://promisesaplus.com/#point-59 4172 // Ignore double-resolution attempts 4173 if ( depth < maxDepth ) { 4174 return; 4175 } 4176 4177 returned = handler.apply( that, args ); 4178 4179 // Support: Promises/A+ section 2.3.1 4180 // https://promisesaplus.com/#point-48 4181 if ( returned === deferred.promise() ) { 4182 throw new TypeError( "Thenable self-resolution" ); 4183 } 4184 4185 // Support: Promises/A+ sections 2.3.3.1, 3.5 4186 // https://promisesaplus.com/#point-54 4187 // https://promisesaplus.com/#point-75 4188 // Retrieve `then` only once 4189 then = returned && 4190 4191 // Support: Promises/A+ section 2.3.4 4192 // https://promisesaplus.com/#point-64 4193 // Only check objects and functions for thenability 4194 ( typeof returned === "object" || 4195 typeof returned === "function" ) && 4196 returned.then; 4197 4198 // Handle a returned thenable 4199 if ( isFunction( then ) ) { 4200 4201 // Special processors (notify) just wait for resolution 4202 if ( special ) { 4203 then.call( 4204 returned, 4205 resolve( maxDepth, deferred, Identity, special ), 4206 resolve( maxDepth, deferred, Thrower, special ) 4207 ); 4208 4209 // Normal processors (resolve) also hook into progress 4210 } else { 4211 4212 // ...and disregard older resolution values 4213 maxDepth++; 4214 4215 then.call( 4216 returned, 4217 resolve( maxDepth, deferred, Identity, special ), 4218 resolve( maxDepth, deferred, Thrower, special ), 4219 resolve( maxDepth, deferred, Identity, 4220 deferred.notifyWith ) 4221 ); 4222 } 4223 4224 // Handle all other returned values 4225 } else { 4226 4227 // Only substitute handlers pass on context 4228 // and multiple values (non-spec behavior) 4229 if ( handler !== Identity ) { 4230 that = undefined; 4231 args = [ returned ]; 4232 } 4233 4234 // Process the value(s) 4235 // Default process is resolve 4236 ( special || deferred.resolveWith )( that, args ); 4237 } 4238 }, 4239 4240 // Only normal processors (resolve) catch and reject exceptions 4241 process = special ? 4242 mightThrow : 4243 function() { 4244 try { 4245 mightThrow(); 4246 } catch ( e ) { 4247 4248 if ( jQuery.Deferred.exceptionHook ) { 4249 jQuery.Deferred.exceptionHook( e, 4250 process.error ); 4251 } 4252 4253 // Support: Promises/A+ section 2.3.3.3.4.1 4254 // https://promisesaplus.com/#point-61 4255 // Ignore post-resolution exceptions 4256 if ( depth + 1 >= maxDepth ) { 4257 4258 // Only substitute handlers pass on context 4259 // and multiple values (non-spec behavior) 4260 if ( handler !== Thrower ) { 4261 that = undefined; 4262 args = [ e ]; 4263 } 4264 4265 deferred.rejectWith( that, args ); 4266 } 4267 } 4268 }; 4269 4270 // Support: Promises/A+ section 2.3.3.3.1 4271 // https://promisesaplus.com/#point-57 4272 // Re-resolve promises immediately to dodge false rejection from 4273 // subsequent errors 4274 if ( depth ) { 4275 process(); 4276 } else { 4277 4278 // Call an optional hook to record the error, in case of exception 4279 // since it's otherwise lost when execution goes async 4280 if ( jQuery.Deferred.getErrorHook ) { 4281 process.error = jQuery.Deferred.getErrorHook(); 4282 4283 // The deprecated alias of the above. While the name suggests 4284 // returning the stack, not an error instance, jQuery just passes 4285 // it directly to `console.warn` so both will work; an instance 4286 // just better cooperates with source maps. 4287 } else if ( jQuery.Deferred.getStackHook ) { 4288 process.error = jQuery.Deferred.getStackHook(); 4289 } 4290 window.setTimeout( process ); 4291 } 4292 }; 4293 } 4294 4295 return jQuery.Deferred( function( newDefer ) { 4296 4297 // progress_handlers.add( ... ) 4298 tuples[ 0 ][ 3 ].add( 4299 resolve( 4300 0, 4301 newDefer, 4302 isFunction( onProgress ) ? 4303 onProgress : 4304 Identity, 4305 newDefer.notifyWith 4306 ) 4307 ); 4308 4309 // fulfilled_handlers.add( ... ) 4310 tuples[ 1 ][ 3 ].add( 4311 resolve( 4312 0, 4313 newDefer, 4314 isFunction( onFulfilled ) ? 4315 onFulfilled : 4316 Identity 4317 ) 4318 ); 4319 4320 // rejected_handlers.add( ... ) 4321 tuples[ 2 ][ 3 ].add( 4322 resolve( 4323 0, 4324 newDefer, 4325 isFunction( onRejected ) ? 4326 onRejected : 4327 Thrower 4328 ) 4329 ); 4330 } ).promise(); 4331 }, 4332 4333 // Get a promise for this deferred 4334 // If obj is provided, the promise aspect is added to the object 4335 promise: function( obj ) { 4336 return obj != null ? jQuery.extend( obj, promise ) : promise; 4337 } 4338 }, 4339 deferred = {}; 4340 4341 // Add list-specific methods 4342 jQuery.each( tuples, function( i, tuple ) { 4343 var list = tuple[ 2 ], 4344 stateString = tuple[ 5 ]; 4345 4346 // promise.progress = list.add 4347 // promise.done = list.add 4348 // promise.fail = list.add 4349 promise[ tuple[ 1 ] ] = list.add; 4350 4351 // Handle state 4352 if ( stateString ) { 4353 list.add( 4354 function() { 4355 4356 // state = "resolved" (i.e., fulfilled) 4357 // state = "rejected" 4358 state = stateString; 4359 }, 4360 4361 // rejected_callbacks.disable 4362 // fulfilled_callbacks.disable 4363 tuples[ 3 - i ][ 2 ].disable, 4364 4365 // rejected_handlers.disable 4366 // fulfilled_handlers.disable 4367 tuples[ 3 - i ][ 3 ].disable, 4368 4369 // progress_callbacks.lock 4370 tuples[ 0 ][ 2 ].lock, 4371 4372 // progress_handlers.lock 4373 tuples[ 0 ][ 3 ].lock 4374 ); 4375 } 4376 4377 // progress_handlers.fire 4378 // fulfilled_handlers.fire 4379 // rejected_handlers.fire 4380 list.add( tuple[ 3 ].fire ); 4381 4382 // deferred.notify = function() { deferred.notifyWith(...) } 4383 // deferred.resolve = function() { deferred.resolveWith(...) } 4384 // deferred.reject = function() { deferred.rejectWith(...) } 4385 deferred[ tuple[ 0 ] ] = function() { 4386 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); 4387 return this; 4388 }; 4389 4390 // deferred.notifyWith = list.fireWith 4391 // deferred.resolveWith = list.fireWith 4392 // deferred.rejectWith = list.fireWith 4393 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 4394 } ); 4395 4396 // Make the deferred a promise 4397 promise.promise( deferred ); 4398 4399 // Call given func if any 4400 if ( func ) { 4401 func.call( deferred, deferred ); 4402 } 4403 4404 // All done! 4405 return deferred; 4406 }, 4407 4408 // Deferred helper 4409 when: function( singleValue ) { 4410 var 4411 4412 // count of uncompleted subordinates 4413 remaining = arguments.length, 4414 4415 // count of unprocessed arguments 4416 i = remaining, 4417 4418 // subordinate fulfillment data 4419 resolveContexts = Array( i ), 4420 resolveValues = slice.call( arguments ), 4421 4422 // the primary Deferred 4423 primary = jQuery.Deferred(), 4424 4425 // subordinate callback factory 4426 updateFunc = function( i ) { 4427 return function( value ) { 4428 resolveContexts[ i ] = this; 4429 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 4430 if ( !( --remaining ) ) { 4431 primary.resolveWith( resolveContexts, resolveValues ); 4432 } 4433 }; 4434 }; 4435 4436 // Single- and empty arguments are adopted like Promise.resolve 4437 if ( remaining <= 1 ) { 4438 adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject, 4439 !remaining ); 4440 4441 // Use .then() to unwrap secondary thenables (cf. gh-3000) 4442 if ( primary.state() === "pending" || 4443 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { 4444 4445 return primary.then(); 4446 } 4447 } 4448 4449 // Multiple arguments are aggregated like Promise.all array elements 4450 while ( i-- ) { 4451 adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject ); 4452 } 4453 4454 return primary.promise(); 4455 } 4456} ); 4457 4458 4459// These usually indicate a programmer mistake during development, 4460// warn about them ASAP rather than swallowing them by default. 4461var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; 4462 4463// If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error 4464// captured before the async barrier to get the original error cause 4465// which may otherwise be hidden. 4466jQuery.Deferred.exceptionHook = function( error, asyncError ) { 4467 4468 // Support: IE 8 - 9 only 4469 // Console exists when dev tools are open, which can happen at any time 4470 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { 4471 window.console.warn( "jQuery.Deferred exception: " + error.message, 4472 error.stack, asyncError ); 4473 } 4474}; 4475 4476 4477 4478 4479jQuery.readyException = function( error ) { 4480 window.setTimeout( function() { 4481 throw error; 4482 } ); 4483}; 4484 4485 4486 4487 4488// The deferred used on DOM ready 4489var readyList = jQuery.Deferred(); 4490 4491jQuery.fn.ready = function( fn ) { 4492 4493 readyList 4494 .then( fn ) 4495 4496 // Wrap jQuery.readyException in a function so that the lookup 4497 // happens at the time of error handling instead of callback 4498 // registration. 4499 .catch( function( error ) { 4500 jQuery.readyException( error ); 4501 } ); 4502 4503 return this; 4504}; 4505 4506jQuery.extend( { 4507 4508 // Is the DOM ready to be used? Set to true once it occurs. 4509 isReady: false, 4510 4511 // A counter to track how many items to wait for before 4512 // the ready event fires. See trac-6781 4513 readyWait: 1, 4514 4515 // Handle when the DOM is ready 4516 ready: function( wait ) { 4517 4518 // Abort if there are pending holds or we're already ready 4519 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 4520 return; 4521 } 4522 4523 // Remember that the DOM is ready 4524 jQuery.isReady = true; 4525 4526 // If a normal DOM Ready event fired, decrement, and wait if need be 4527 if ( wait !== true && --jQuery.readyWait > 0 ) { 4528 return; 4529 } 4530 4531 // If there are functions bound, to execute 4532 readyList.resolveWith( document, [ jQuery ] ); 4533 } 4534} ); 4535 4536jQuery.ready.then = readyList.then; 4537 4538// The ready event handler and self cleanup method 4539function completed() { 4540 document.removeEventListener( "DOMContentLoaded", completed ); 4541 window.removeEventListener( "load", completed ); 4542 jQuery.ready(); 4543} 4544 4545// Catch cases where $(document).ready() is called 4546// after the browser event has already occurred. 4547// Support: IE <=9 - 10 only 4548// Older IE sometimes signals "interactive" too soon 4549if ( document.readyState === "complete" || 4550 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 4551 4552 // Handle it asynchronously to allow scripts the opportunity to delay ready 4553 window.setTimeout( jQuery.ready ); 4554 4555} else { 4556 4557 // Use the handy event callback 4558 document.addEventListener( "DOMContentLoaded", completed ); 4559 4560 // A fallback to window.onload, that will always work 4561 window.addEventListener( "load", completed ); 4562} 4563 4564 4565 4566 4567// Multifunctional method to get and set values of a collection 4568// The value/s can optionally be executed if it's a function 4569var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 4570 var i = 0, 4571 len = elems.length, 4572 bulk = key == null; 4573 4574 // Sets many values 4575 if ( toType( key ) === "object" ) { 4576 chainable = true; 4577 for ( i in key ) { 4578 access( elems, fn, i, key[ i ], true, emptyGet, raw ); 4579 } 4580 4581 // Sets one value 4582 } else if ( value !== undefined ) { 4583 chainable = true; 4584 4585 if ( !isFunction( value ) ) { 4586 raw = true; 4587 } 4588 4589 if ( bulk ) { 4590 4591 // Bulk operations run against the entire set 4592 if ( raw ) { 4593 fn.call( elems, value ); 4594 fn = null; 4595 4596 // ...except when executing function values 4597 } else { 4598 bulk = fn; 4599 fn = function( elem, _key, value ) { 4600 return bulk.call( jQuery( elem ), value ); 4601 }; 4602 } 4603 } 4604 4605 if ( fn ) { 4606 for ( ; i < len; i++ ) { 4607 fn( 4608 elems[ i ], key, raw ? 4609 value : 4610 value.call( elems[ i ], i, fn( elems[ i ], key ) ) 4611 ); 4612 } 4613 } 4614 } 4615 4616 if ( chainable ) { 4617 return elems; 4618 } 4619 4620 // Gets 4621 if ( bulk ) { 4622 return fn.call( elems ); 4623 } 4624 4625 return len ? fn( elems[ 0 ], key ) : emptyGet; 4626}; 4627 4628 4629// Matches dashed string for camelizing 4630var rmsPrefix = /^-ms-/, 4631 rdashAlpha = /-([a-z])/g; 4632 4633// Used by camelCase as callback to replace() 4634function fcamelCase( _all, letter ) { 4635 return letter.toUpperCase(); 4636} 4637 4638// Convert dashed to camelCase; used by the css and data modules 4639// Support: IE <=9 - 11, Edge 12 - 15 4640// Microsoft forgot to hump their vendor prefix (trac-9572) 4641function camelCase( string ) { 4642 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 4643} 4644var acceptData = function( owner ) { 4645 4646 // Accepts only: 4647 // - Node 4648 // - Node.ELEMENT_NODE 4649 // - Node.DOCUMENT_NODE 4650 // - Object 4651 // - Any 4652 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 4653}; 4654 4655 4656 4657 4658function Data() { 4659 this.expando = jQuery.expando + Data.uid++; 4660} 4661 4662Data.uid = 1; 4663 4664Data.prototype = { 4665 4666 cache: function( owner ) { 4667 4668 // Check if the owner object already has a cache 4669 var value = owner[ this.expando ]; 4670 4671 // If not, create one 4672 if ( !value ) { 4673 value = {}; 4674 4675 // We can accept data for non-element nodes in modern browsers, 4676 // but we should not, see trac-8335. 4677 // Always return an empty object. 4678 if ( acceptData( owner ) ) { 4679 4680 // If it is a node unlikely to be stringify-ed or looped over 4681 // use plain assignment 4682 if ( owner.nodeType ) { 4683 owner[ this.expando ] = value; 4684 4685 // Otherwise secure it in a non-enumerable property 4686 // configurable must be true to allow the property to be 4687 // deleted when data is removed 4688 } else { 4689 Object.defineProperty( owner, this.expando, { 4690 value: value, 4691 configurable: true 4692 } ); 4693 } 4694 } 4695 } 4696 4697 return value; 4698 }, 4699 set: function( owner, data, value ) { 4700 var prop, 4701 cache = this.cache( owner ); 4702 4703 // Handle: [ owner, key, value ] args 4704 // Always use camelCase key (gh-2257) 4705 if ( typeof data === "string" ) { 4706 cache[ camelCase( data ) ] = value; 4707 4708 // Handle: [ owner, { properties } ] args 4709 } else { 4710 4711 // Copy the properties one-by-one to the cache object 4712 for ( prop in data ) { 4713 cache[ camelCase( prop ) ] = data[ prop ]; 4714 } 4715 } 4716 return cache; 4717 }, 4718 get: function( owner, key ) { 4719 return key === undefined ? 4720 this.cache( owner ) : 4721 4722 // Always use camelCase key (gh-2257) 4723 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; 4724 }, 4725 access: function( owner, key, value ) { 4726 4727 // In cases where either: 4728 // 4729 // 1. No key was specified 4730 // 2. A string key was specified, but no value provided 4731 // 4732 // Take the "read" path and allow the get method to determine 4733 // which value to return, respectively either: 4734 // 4735 // 1. The entire cache object 4736 // 2. The data stored at the key 4737 // 4738 if ( key === undefined || 4739 ( ( key && typeof key === "string" ) && value === undefined ) ) { 4740 4741 return this.get( owner, key ); 4742 } 4743 4744 // When the key is not a string, or both a key and value 4745 // are specified, set or extend (existing objects) with either: 4746 // 4747 // 1. An object of properties 4748 // 2. A key and value 4749 // 4750 this.set( owner, key, value ); 4751 4752 // Since the "set" path can have two possible entry points 4753 // return the expected data based on which path was taken[*] 4754 return value !== undefined ? value : key; 4755 }, 4756 remove: function( owner, key ) { 4757 var i, 4758 cache = owner[ this.expando ]; 4759 4760 if ( cache === undefined ) { 4761 return; 4762 } 4763 4764 if ( key !== undefined ) { 4765 4766 // Support array or space separated string of keys 4767 if ( Array.isArray( key ) ) { 4768 4769 // If key is an array of keys... 4770 // We always set camelCase keys, so remove that. 4771 key = key.map( camelCase ); 4772 } else { 4773 key = camelCase( key ); 4774 4775 // If a key with the spaces exists, use it. 4776 // Otherwise, create an array by matching non-whitespace 4777 key = key in cache ? 4778 [ key ] : 4779 ( key.match( rnothtmlwhite ) || [] ); 4780 } 4781 4782 i = key.length; 4783 4784 while ( i-- ) { 4785 delete cache[ key[ i ] ]; 4786 } 4787 } 4788 4789 // Remove the expando if there's no more data 4790 if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 4791 4792 // Support: Chrome <=35 - 45 4793 // Webkit & Blink performance suffers when deleting properties 4794 // from DOM nodes, so set to undefined instead 4795 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) 4796 if ( owner.nodeType ) { 4797 owner[ this.expando ] = undefined; 4798 } else { 4799 delete owner[ this.expando ]; 4800 } 4801 } 4802 }, 4803 hasData: function( owner ) { 4804 var cache = owner[ this.expando ]; 4805 return cache !== undefined && !jQuery.isEmptyObject( cache ); 4806 } 4807}; 4808var dataPriv = new Data(); 4809 4810var dataUser = new Data(); 4811 4812 4813 4814// Implementation Summary 4815// 4816// 1. Enforce API surface and semantic compatibility with 1.9.x branch 4817// 2. Improve the module's maintainability by reducing the storage 4818// paths to a single mechanism. 4819// 3. Use the same single mechanism to support "private" and "user" data. 4820// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 4821// 5. Avoid exposing implementation details on user objects (eg. expando properties) 4822// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 4823 4824var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 4825 rmultiDash = /[A-Z]/g; 4826 4827function getData( data ) { 4828 if ( data === "true" ) { 4829 return true; 4830 } 4831 4832 if ( data === "false" ) { 4833 return false; 4834 } 4835 4836 if ( data === "null" ) { 4837 return null; 4838 } 4839 4840 // Only convert to a number if it doesn't change the string 4841 if ( data === +data + "" ) { 4842 return +data; 4843 } 4844 4845 if ( rbrace.test( data ) ) { 4846 return JSON.parse( data ); 4847 } 4848 4849 return data; 4850} 4851 4852function dataAttr( elem, key, data ) { 4853 var name; 4854 4855 // If nothing was found internally, try to fetch any 4856 // data from the HTML5 data-* attribute 4857 if ( data === undefined && elem.nodeType === 1 ) { 4858 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 4859 data = elem.getAttribute( name ); 4860 4861 if ( typeof data === "string" ) { 4862 try { 4863 data = getData( data ); 4864 } catch ( e ) {} 4865 4866 // Make sure we set the data so it isn't changed later 4867 dataUser.set( elem, key, data ); 4868 } else { 4869 data = undefined; 4870 } 4871 } 4872 return data; 4873} 4874 4875jQuery.extend( { 4876 hasData: function( elem ) { 4877 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 4878 }, 4879 4880 data: function( elem, name, data ) { 4881 return dataUser.access( elem, name, data ); 4882 }, 4883 4884 removeData: function( elem, name ) { 4885 dataUser.remove( elem, name ); 4886 }, 4887 4888 // TODO: Now that all calls to _data and _removeData have been replaced 4889 // with direct calls to dataPriv methods, these can be deprecated. 4890 _data: function( elem, name, data ) { 4891 return dataPriv.access( elem, name, data ); 4892 }, 4893 4894 _removeData: function( elem, name ) { 4895 dataPriv.remove( elem, name ); 4896 } 4897} ); 4898 4899jQuery.fn.extend( { 4900 data: function( key, value ) { 4901 var i, name, data, 4902 elem = this[ 0 ], 4903 attrs = elem && elem.attributes; 4904 4905 // Gets all values 4906 if ( key === undefined ) { 4907 if ( this.length ) { 4908 data = dataUser.get( elem ); 4909 4910 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 4911 i = attrs.length; 4912 while ( i-- ) { 4913 4914 // Support: IE 11 only 4915 // The attrs elements can be null (trac-14894) 4916 if ( attrs[ i ] ) { 4917 name = attrs[ i ].name; 4918 if ( name.indexOf( "data-" ) === 0 ) { 4919 name = camelCase( name.slice( 5 ) ); 4920 dataAttr( elem, name, data[ name ] ); 4921 } 4922 } 4923 } 4924 dataPriv.set( elem, "hasDataAttrs", true ); 4925 } 4926 } 4927 4928 return data; 4929 } 4930 4931 // Sets multiple values 4932 if ( typeof key === "object" ) { 4933 return this.each( function() { 4934 dataUser.set( this, key ); 4935 } ); 4936 } 4937 4938 return access( this, function( value ) { 4939 var data; 4940 4941 // The calling jQuery object (element matches) is not empty 4942 // (and therefore has an element appears at this[ 0 ]) and the 4943 // `value` parameter was not undefined. An empty jQuery object 4944 // will result in `undefined` for elem = this[ 0 ] which will 4945 // throw an exception if an attempt to read a data cache is made. 4946 if ( elem && value === undefined ) { 4947 4948 // Attempt to get data from the cache 4949 // The key will always be camelCased in Data 4950 data = dataUser.get( elem, key ); 4951 if ( data !== undefined ) { 4952 return data; 4953 } 4954 4955 // Attempt to "discover" the data in 4956 // HTML5 custom data-* attrs 4957 data = dataAttr( elem, key ); 4958 if ( data !== undefined ) { 4959 return data; 4960 } 4961 4962 // We tried really hard, but the data doesn't exist. 4963 return; 4964 } 4965 4966 // Set the data... 4967 this.each( function() { 4968 4969 // We always store the camelCased key 4970 dataUser.set( this, key, value ); 4971 } ); 4972 }, null, value, arguments.length > 1, null, true ); 4973 }, 4974 4975 removeData: function( key ) { 4976 return this.each( function() { 4977 dataUser.remove( this, key ); 4978 } ); 4979 } 4980} ); 4981 4982 4983jQuery.extend( { 4984 queue: function( elem, type, data ) { 4985 var queue; 4986 4987 if ( elem ) { 4988 type = ( type || "fx" ) + "queue"; 4989 queue = dataPriv.get( elem, type ); 4990 4991 // Speed up dequeue by getting out quickly if this is just a lookup 4992 if ( data ) { 4993 if ( !queue || Array.isArray( data ) ) { 4994 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 4995 } else { 4996 queue.push( data ); 4997 } 4998 } 4999 return queue || []; 5000 } 5001 }, 5002 5003 dequeue: function( elem, type ) { 5004 type = type || "fx"; 5005 5006 var queue = jQuery.queue( elem, type ), 5007 startLength = queue.length, 5008 fn = queue.shift(), 5009 hooks = jQuery._queueHooks( elem, type ), 5010 next = function() { 5011 jQuery.dequeue( elem, type ); 5012 }; 5013 5014 // If the fx queue is dequeued, always remove the progress sentinel 5015 if ( fn === "inprogress" ) { 5016 fn = queue.shift(); 5017 startLength--; 5018 } 5019 5020 if ( fn ) { 5021 5022 // Add a progress sentinel to prevent the fx queue from being 5023 // automatically dequeued 5024 if ( type === "fx" ) { 5025 queue.unshift( "inprogress" ); 5026 } 5027 5028 // Clear up the last queue stop function 5029 delete hooks.stop; 5030 fn.call( elem, next, hooks ); 5031 } 5032 5033 if ( !startLength && hooks ) { 5034 hooks.empty.fire(); 5035 } 5036 }, 5037 5038 // Not public - generate a queueHooks object, or return the current one 5039 _queueHooks: function( elem, type ) { 5040 var key = type + "queueHooks"; 5041 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 5042 empty: jQuery.Callbacks( "once memory" ).add( function() { 5043 dataPriv.remove( elem, [ type + "queue", key ] ); 5044 } ) 5045 } ); 5046 } 5047} ); 5048 5049jQuery.fn.extend( { 5050 queue: function( type, data ) { 5051 var setter = 2; 5052 5053 if ( typeof type !== "string" ) { 5054 data = type; 5055 type = "fx"; 5056 setter--; 5057 } 5058 5059 if ( arguments.length < setter ) { 5060 return jQuery.queue( this[ 0 ], type ); 5061 } 5062 5063 return data === undefined ? 5064 this : 5065 this.each( function() { 5066 var queue = jQuery.queue( this, type, data ); 5067 5068 // Ensure a hooks for this queue 5069 jQuery._queueHooks( this, type ); 5070 5071 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 5072 jQuery.dequeue( this, type ); 5073 } 5074 } ); 5075 }, 5076 dequeue: function( type ) { 5077 return this.each( function() { 5078 jQuery.dequeue( this, type ); 5079 } ); 5080 }, 5081 clearQueue: function( type ) { 5082 return this.queue( type || "fx", [] ); 5083 }, 5084 5085 // Get a promise resolved when queues of a certain type 5086 // are emptied (fx is the type by default) 5087 promise: function( type, obj ) { 5088 var tmp, 5089 count = 1, 5090 defer = jQuery.Deferred(), 5091 elements = this, 5092 i = this.length, 5093 resolve = function() { 5094 if ( !( --count ) ) { 5095 defer.resolveWith( elements, [ elements ] ); 5096 } 5097 }; 5098 5099 if ( typeof type !== "string" ) { 5100 obj = type; 5101 type = undefined; 5102 } 5103 type = type || "fx"; 5104 5105 while ( i-- ) { 5106 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 5107 if ( tmp && tmp.empty ) { 5108 count++; 5109 tmp.empty.add( resolve ); 5110 } 5111 } 5112 resolve(); 5113 return defer.promise( obj ); 5114 } 5115} ); 5116var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 5117 5118var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 5119 5120 5121var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 5122 5123var documentElement = document.documentElement; 5124 5125 5126 5127 var isAttached = function( elem ) { 5128 return jQuery.contains( elem.ownerDocument, elem ); 5129 }, 5130 composed = { composed: true }; 5131 5132 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only 5133 // Check attachment across shadow DOM boundaries when possible (gh-3504) 5134 // Support: iOS 10.0-10.2 only 5135 // Early iOS 10 versions support `attachShadow` but not `getRootNode`, 5136 // leading to errors. We need to check for `getRootNode`. 5137 if ( documentElement.getRootNode ) { 5138 isAttached = function( elem ) { 5139 return jQuery.contains( elem.ownerDocument, elem ) || 5140 elem.getRootNode( composed ) === elem.ownerDocument; 5141 }; 5142 } 5143var isHiddenWithinTree = function( elem, el ) { 5144 5145 // isHiddenWithinTree might be called from jQuery#filter function; 5146 // in that case, element will be second argument 5147 elem = el || elem; 5148 5149 // Inline style trumps all 5150 return elem.style.display === "none" || 5151 elem.style.display === "" && 5152 5153 // Otherwise, check computed style 5154 // Support: Firefox <=43 - 45 5155 // Disconnected elements can have computed display: none, so first confirm that elem is 5156 // in the document. 5157 isAttached( elem ) && 5158 5159 jQuery.css( elem, "display" ) === "none"; 5160 }; 5161 5162 5163 5164function adjustCSS( elem, prop, valueParts, tween ) { 5165 var adjusted, scale, 5166 maxIterations = 20, 5167 currentValue = tween ? 5168 function() { 5169 return tween.cur(); 5170 } : 5171 function() { 5172 return jQuery.css( elem, prop, "" ); 5173 }, 5174 initial = currentValue(), 5175 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 5176 5177 // Starting value computation is required for potential unit mismatches 5178 initialInUnit = elem.nodeType && 5179 ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 5180 rcssNum.exec( jQuery.css( elem, prop ) ); 5181 5182 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 5183 5184 // Support: Firefox <=54 5185 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) 5186 initial = initial / 2; 5187 5188 // Trust units reported by jQuery.css 5189 unit = unit || initialInUnit[ 3 ]; 5190 5191 // Iteratively approximate from a nonzero starting point 5192 initialInUnit = +initial || 1; 5193 5194 while ( maxIterations-- ) { 5195 5196 // Evaluate and update our best guess (doubling guesses that zero out). 5197 // Finish if the scale equals or crosses 1 (making the old*new product non-positive). 5198 jQuery.style( elem, prop, initialInUnit + unit ); 5199 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { 5200 maxIterations = 0; 5201 } 5202 initialInUnit = initialInUnit / scale; 5203 5204 } 5205 5206 initialInUnit = initialInUnit * 2; 5207 jQuery.style( elem, prop, initialInUnit + unit ); 5208 5209 // Make sure we update the tween properties later on 5210 valueParts = valueParts || []; 5211 } 5212 5213 if ( valueParts ) { 5214 initialInUnit = +initialInUnit || +initial || 0; 5215 5216 // Apply relative offset (+=/-=) if specified 5217 adjusted = valueParts[ 1 ] ? 5218 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 5219 +valueParts[ 2 ]; 5220 if ( tween ) { 5221 tween.unit = unit; 5222 tween.start = initialInUnit; 5223 tween.end = adjusted; 5224 } 5225 } 5226 return adjusted; 5227} 5228 5229 5230var defaultDisplayMap = {}; 5231 5232function getDefaultDisplay( elem ) { 5233 var temp, 5234 doc = elem.ownerDocument, 5235 nodeName = elem.nodeName, 5236 display = defaultDisplayMap[ nodeName ]; 5237 5238 if ( display ) { 5239 return display; 5240 } 5241 5242 temp = doc.body.appendChild( doc.createElement( nodeName ) ); 5243 display = jQuery.css( temp, "display" ); 5244 5245 temp.parentNode.removeChild( temp ); 5246 5247 if ( display === "none" ) { 5248 display = "block"; 5249 } 5250 defaultDisplayMap[ nodeName ] = display; 5251 5252 return display; 5253} 5254 5255function showHide( elements, show ) { 5256 var display, elem, 5257 values = [], 5258 index = 0, 5259 length = elements.length; 5260 5261 // Determine new display value for elements that need to change 5262 for ( ; index < length; index++ ) { 5263 elem = elements[ index ]; 5264 if ( !elem.style ) { 5265 continue; 5266 } 5267 5268 display = elem.style.display; 5269 if ( show ) { 5270 5271 // Since we force visibility upon cascade-hidden elements, an immediate (and slow) 5272 // check is required in this first loop unless we have a nonempty display value (either 5273 // inline or about-to-be-restored) 5274 if ( display === "none" ) { 5275 values[ index ] = dataPriv.get( elem, "display" ) || null; 5276 if ( !values[ index ] ) { 5277 elem.style.display = ""; 5278 } 5279 } 5280 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { 5281 values[ index ] = getDefaultDisplay( elem ); 5282 } 5283 } else { 5284 if ( display !== "none" ) { 5285 values[ index ] = "none"; 5286 5287 // Remember what we're overwriting 5288 dataPriv.set( elem, "display", display ); 5289 } 5290 } 5291 } 5292 5293 // Set the display of the elements in a second loop to avoid constant reflow 5294 for ( index = 0; index < length; index++ ) { 5295 if ( values[ index ] != null ) { 5296 elements[ index ].style.display = values[ index ]; 5297 } 5298 } 5299 5300 return elements; 5301} 5302 5303jQuery.fn.extend( { 5304 show: function() { 5305 return showHide( this, true ); 5306 }, 5307 hide: function() { 5308 return showHide( this ); 5309 }, 5310 toggle: function( state ) { 5311 if ( typeof state === "boolean" ) { 5312 return state ? this.show() : this.hide(); 5313 } 5314 5315 return this.each( function() { 5316 if ( isHiddenWithinTree( this ) ) { 5317 jQuery( this ).show(); 5318 } else { 5319 jQuery( this ).hide(); 5320 } 5321 } ); 5322 } 5323} ); 5324var rcheckableType = ( /^(?:checkbox|radio)$/i ); 5325 5326var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); 5327 5328var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); 5329 5330 5331 5332( function() { 5333 var fragment = document.createDocumentFragment(), 5334 div = fragment.appendChild( document.createElement( "div" ) ), 5335 input = document.createElement( "input" ); 5336 5337 // Support: Android 4.0 - 4.3 only 5338 // Check state lost if the name is set (trac-11217) 5339 // Support: Windows Web Apps (WWA) 5340 // `name` and `type` must use .setAttribute for WWA (trac-14901) 5341 input.setAttribute( "type", "radio" ); 5342 input.setAttribute( "checked", "checked" ); 5343 input.setAttribute( "name", "t" ); 5344 5345 div.appendChild( input ); 5346 5347 // Support: Android <=4.1 only 5348 // Older WebKit doesn't clone checked state correctly in fragments 5349 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 5350 5351 // Support: IE <=11 only 5352 // Make sure textarea (and checkbox) defaultValue is properly cloned 5353 div.innerHTML = "<textarea>x</textarea>"; 5354 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 5355 5356 // Support: IE <=9 only 5357 // IE <=9 replaces <option> tags with their contents when inserted outside of 5358 // the select element. 5359 div.innerHTML = "<option></option>"; 5360 support.option = !!div.lastChild; 5361} )(); 5362 5363 5364// We have to close these tags to support XHTML (trac-13200) 5365var wrapMap = { 5366 5367 // XHTML parsers do not magically insert elements in the 5368 // same way that tag soup parsers do. So we cannot shorten 5369 // this by omitting <tbody> or other required elements. 5370 thead: [ 1, "<table>", "</table>" ], 5371 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], 5372 tr: [ 2, "<table><tbody>", "</tbody></table>" ], 5373 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 5374 5375 _default: [ 0, "", "" ] 5376}; 5377 5378wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 5379wrapMap.th = wrapMap.td; 5380 5381// Support: IE <=9 only 5382if ( !support.option ) { 5383 wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ]; 5384} 5385 5386 5387function getAll( context, tag ) { 5388 5389 // Support: IE <=9 - 11 only 5390 // Use typeof to avoid zero-argument method invocation on host objects (trac-15151) 5391 var ret; 5392 5393 if ( typeof context.getElementsByTagName !== "undefined" ) { 5394 ret = context.getElementsByTagName( tag || "*" ); 5395 5396 } else if ( typeof context.querySelectorAll !== "undefined" ) { 5397 ret = context.querySelectorAll( tag || "*" ); 5398 5399 } else { 5400 ret = []; 5401 } 5402 5403 if ( tag === undefined || tag && nodeName( context, tag ) ) { 5404 return jQuery.merge( [ context ], ret ); 5405 } 5406 5407 return ret; 5408} 5409 5410 5411// Mark scripts as having already been evaluated 5412function setGlobalEval( elems, refElements ) { 5413 var i = 0, 5414 l = elems.length; 5415 5416 for ( ; i < l; i++ ) { 5417 dataPriv.set( 5418 elems[ i ], 5419 "globalEval", 5420 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 5421 ); 5422 } 5423} 5424 5425 5426var rhtml = /<|&#?\w+;/; 5427 5428function buildFragment( elems, context, scripts, selection, ignored ) { 5429 var elem, tmp, tag, wrap, attached, j, 5430 fragment = context.createDocumentFragment(), 5431 nodes = [], 5432 i = 0, 5433 l = elems.length; 5434 5435 for ( ; i < l; i++ ) { 5436 elem = elems[ i ]; 5437 5438 if ( elem || elem === 0 ) { 5439 5440 // Add nodes directly 5441 if ( toType( elem ) === "object" ) { 5442 5443 // Support: Android <=4.0 only, PhantomJS 1 only 5444 // push.apply(_, arraylike) throws on ancient WebKit 5445 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 5446 5447 // Convert non-html into a text node 5448 } else if ( !rhtml.test( elem ) ) { 5449 nodes.push( context.createTextNode( elem ) ); 5450 5451 // Convert html into DOM nodes 5452 } else { 5453 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 5454 5455 // Deserialize a standard representation 5456 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 5457 wrap = wrapMap[ tag ] || wrapMap._default; 5458 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 5459 5460 // Descend through wrappers to the right content 5461 j = wrap[ 0 ]; 5462 while ( j-- ) { 5463 tmp = tmp.lastChild; 5464 } 5465 5466 // Support: Android <=4.0 only, PhantomJS 1 only 5467 // push.apply(_, arraylike) throws on ancient WebKit 5468 jQuery.merge( nodes, tmp.childNodes ); 5469 5470 // Remember the top-level container 5471 tmp = fragment.firstChild; 5472 5473 // Ensure the created nodes are orphaned (trac-12392) 5474 tmp.textContent = ""; 5475 } 5476 } 5477 } 5478 5479 // Remove wrapper from fragment 5480 fragment.textContent = ""; 5481 5482 i = 0; 5483 while ( ( elem = nodes[ i++ ] ) ) { 5484 5485 // Skip elements already in the context collection (trac-4087) 5486 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 5487 if ( ignored ) { 5488 ignored.push( elem ); 5489 } 5490 continue; 5491 } 5492 5493 attached = isAttached( elem ); 5494 5495 // Append to fragment 5496 tmp = getAll( fragment.appendChild( elem ), "script" ); 5497 5498 // Preserve script evaluation history 5499 if ( attached ) { 5500 setGlobalEval( tmp ); 5501 } 5502 5503 // Capture executables 5504 if ( scripts ) { 5505 j = 0; 5506 while ( ( elem = tmp[ j++ ] ) ) { 5507 if ( rscriptType.test( elem.type || "" ) ) { 5508 scripts.push( elem ); 5509 } 5510 } 5511 } 5512 } 5513 5514 return fragment; 5515} 5516 5517 5518var rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 5519 5520function returnTrue() { 5521 return true; 5522} 5523 5524function returnFalse() { 5525 return false; 5526} 5527 5528function on( elem, types, selector, data, fn, one ) { 5529 var origFn, type; 5530 5531 // Types can be a map of types/handlers 5532 if ( typeof types === "object" ) { 5533 5534 // ( types-Object, selector, data ) 5535 if ( typeof selector !== "string" ) { 5536 5537 // ( types-Object, data ) 5538 data = data || selector; 5539 selector = undefined; 5540 } 5541 for ( type in types ) { 5542 on( elem, type, selector, data, types[ type ], one ); 5543 } 5544 return elem; 5545 } 5546 5547 if ( data == null && fn == null ) { 5548 5549 // ( types, fn ) 5550 fn = selector; 5551 data = selector = undefined; 5552 } else if ( fn == null ) { 5553 if ( typeof selector === "string" ) { 5554 5555 // ( types, selector, fn ) 5556 fn = data; 5557 data = undefined; 5558 } else { 5559 5560 // ( types, data, fn ) 5561 fn = data; 5562 data = selector; 5563 selector = undefined; 5564 } 5565 } 5566 if ( fn === false ) { 5567 fn = returnFalse; 5568 } else if ( !fn ) { 5569 return elem; 5570 } 5571 5572 if ( one === 1 ) { 5573 origFn = fn; 5574 fn = function( event ) { 5575 5576 // Can use an empty set, since event contains the info 5577 jQuery().off( event ); 5578 return origFn.apply( this, arguments ); 5579 }; 5580 5581 // Use same guid so caller can remove using origFn 5582 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 5583 } 5584 return elem.each( function() { 5585 jQuery.event.add( this, types, fn, data, selector ); 5586 } ); 5587} 5588 5589/* 5590 * Helper functions for managing events -- not part of the public interface. 5591 * Props to Dean Edwards' addEvent library for many of the ideas. 5592 */ 5593jQuery.event = { 5594 5595 global: {}, 5596 5597 add: function( elem, types, handler, data, selector ) { 5598 5599 var handleObjIn, eventHandle, tmp, 5600 events, t, handleObj, 5601 special, handlers, type, namespaces, origType, 5602 elemData = dataPriv.get( elem ); 5603 5604 // Only attach events to objects that accept data 5605 if ( !acceptData( elem ) ) { 5606 return; 5607 } 5608 5609 // Caller can pass in an object of custom data in lieu of the handler 5610 if ( handler.handler ) { 5611 handleObjIn = handler; 5612 handler = handleObjIn.handler; 5613 selector = handleObjIn.selector; 5614 } 5615 5616 // Ensure that invalid selectors throw exceptions at attach time 5617 // Evaluate against documentElement in case elem is a non-element node (e.g., document) 5618 if ( selector ) { 5619 jQuery.find.matchesSelector( documentElement, selector ); 5620 } 5621 5622 // Make sure that the handler has a unique ID, used to find/remove it later 5623 if ( !handler.guid ) { 5624 handler.guid = jQuery.guid++; 5625 } 5626 5627 // Init the element's event structure and main handler, if this is the first 5628 if ( !( events = elemData.events ) ) { 5629 events = elemData.events = Object.create( null ); 5630 } 5631 if ( !( eventHandle = elemData.handle ) ) { 5632 eventHandle = elemData.handle = function( e ) { 5633 5634 // Discard the second event of a jQuery.event.trigger() and 5635 // when an event is called after a page has unloaded 5636 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? 5637 jQuery.event.dispatch.apply( elem, arguments ) : undefined; 5638 }; 5639 } 5640 5641 // Handle multiple events separated by a space 5642 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 5643 t = types.length; 5644 while ( t-- ) { 5645 tmp = rtypenamespace.exec( types[ t ] ) || []; 5646 type = origType = tmp[ 1 ]; 5647 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 5648 5649 // There *must* be a type, no attaching namespace-only handlers 5650 if ( !type ) { 5651 continue; 5652 } 5653 5654 // If event changes its type, use the special event handlers for the changed type 5655 special = jQuery.event.special[ type ] || {}; 5656 5657 // If selector defined, determine special event api type, otherwise given type 5658 type = ( selector ? special.delegateType : special.bindType ) || type; 5659 5660 // Update special based on newly reset type 5661 special = jQuery.event.special[ type ] || {}; 5662 5663 // handleObj is passed to all event handlers 5664 handleObj = jQuery.extend( { 5665 type: type, 5666 origType: origType, 5667 data: data, 5668 handler: handler, 5669 guid: handler.guid, 5670 selector: selector, 5671 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 5672 namespace: namespaces.join( "." ) 5673 }, handleObjIn ); 5674 5675 // Init the event handler queue if we're the first 5676 if ( !( handlers = events[ type ] ) ) { 5677 handlers = events[ type ] = []; 5678 handlers.delegateCount = 0; 5679 5680 // Only use addEventListener if the special events handler returns false 5681 if ( !special.setup || 5682 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 5683 5684 if ( elem.addEventListener ) { 5685 elem.addEventListener( type, eventHandle ); 5686 } 5687 } 5688 } 5689 5690 if ( special.add ) { 5691 special.add.call( elem, handleObj ); 5692 5693 if ( !handleObj.handler.guid ) { 5694 handleObj.handler.guid = handler.guid; 5695 } 5696 } 5697 5698 // Add to the element's handler list, delegates in front 5699 if ( selector ) { 5700 handlers.splice( handlers.delegateCount++, 0, handleObj ); 5701 } else { 5702 handlers.push( handleObj ); 5703 } 5704 5705 // Keep track of which events have ever been used, for event optimization 5706 jQuery.event.global[ type ] = true; 5707 } 5708 5709 }, 5710 5711 // Detach an event or set of events from an element 5712 remove: function( elem, types, handler, selector, mappedTypes ) { 5713 5714 var j, origCount, tmp, 5715 events, t, handleObj, 5716 special, handlers, type, namespaces, origType, 5717 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); 5718 5719 if ( !elemData || !( events = elemData.events ) ) { 5720 return; 5721 } 5722 5723 // Once for each type.namespace in types; type may be omitted 5724 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; 5725 t = types.length; 5726 while ( t-- ) { 5727 tmp = rtypenamespace.exec( types[ t ] ) || []; 5728 type = origType = tmp[ 1 ]; 5729 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 5730 5731 // Unbind all events (on this namespace, if provided) for the element 5732 if ( !type ) { 5733 for ( type in events ) { 5734 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 5735 } 5736 continue; 5737 } 5738 5739 special = jQuery.event.special[ type ] || {}; 5740 type = ( selector ? special.delegateType : special.bindType ) || type; 5741 handlers = events[ type ] || []; 5742 tmp = tmp[ 2 ] && 5743 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 5744 5745 // Remove matching events 5746 origCount = j = handlers.length; 5747 while ( j-- ) { 5748 handleObj = handlers[ j ]; 5749 5750 if ( ( mappedTypes || origType === handleObj.origType ) && 5751 ( !handler || handler.guid === handleObj.guid ) && 5752 ( !tmp || tmp.test( handleObj.namespace ) ) && 5753 ( !selector || selector === handleObj.selector || 5754 selector === "**" && handleObj.selector ) ) { 5755 handlers.splice( j, 1 ); 5756 5757 if ( handleObj.selector ) { 5758 handlers.delegateCount--; 5759 } 5760 if ( special.remove ) { 5761 special.remove.call( elem, handleObj ); 5762 } 5763 } 5764 } 5765 5766 // Remove generic event handler if we removed something and no more handlers exist 5767 // (avoids potential for endless recursion during removal of special event handlers) 5768 if ( origCount && !handlers.length ) { 5769 if ( !special.teardown || 5770 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 5771 5772 jQuery.removeEvent( elem, type, elemData.handle ); 5773 } 5774 5775 delete events[ type ]; 5776 } 5777 } 5778 5779 // Remove data and the expando if it's no longer used 5780 if ( jQuery.isEmptyObject( events ) ) { 5781 dataPriv.remove( elem, "handle events" ); 5782 } 5783 }, 5784 5785 dispatch: function( nativeEvent ) { 5786 5787 var i, j, ret, matched, handleObj, handlerQueue, 5788 args = new Array( arguments.length ), 5789 5790 // Make a writable jQuery.Event from the native event object 5791 event = jQuery.event.fix( nativeEvent ), 5792 5793 handlers = ( 5794 dataPriv.get( this, "events" ) || Object.create( null ) 5795 )[ event.type ] || [], 5796 special = jQuery.event.special[ event.type ] || {}; 5797 5798 // Use the fix-ed jQuery.Event rather than the (read-only) native event 5799 args[ 0 ] = event; 5800 5801 for ( i = 1; i < arguments.length; i++ ) { 5802 args[ i ] = arguments[ i ]; 5803 } 5804 5805 event.delegateTarget = this; 5806 5807 // Call the preDispatch hook for the mapped type, and let it bail if desired 5808 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 5809 return; 5810 } 5811 5812 // Determine handlers 5813 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 5814 5815 // Run delegates first; they may want to stop propagation beneath us 5816 i = 0; 5817 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 5818 event.currentTarget = matched.elem; 5819 5820 j = 0; 5821 while ( ( handleObj = matched.handlers[ j++ ] ) && 5822 !event.isImmediatePropagationStopped() ) { 5823 5824 // If the event is namespaced, then each handler is only invoked if it is 5825 // specially universal or its namespaces are a superset of the event's. 5826 if ( !event.rnamespace || handleObj.namespace === false || 5827 event.rnamespace.test( handleObj.namespace ) ) { 5828 5829 event.handleObj = handleObj; 5830 event.data = handleObj.data; 5831 5832 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 5833 handleObj.handler ).apply( matched.elem, args ); 5834 5835 if ( ret !== undefined ) { 5836 if ( ( event.result = ret ) === false ) { 5837 event.preventDefault(); 5838 event.stopPropagation(); 5839 } 5840 } 5841 } 5842 } 5843 } 5844 5845 // Call the postDispatch hook for the mapped type 5846 if ( special.postDispatch ) { 5847 special.postDispatch.call( this, event ); 5848 } 5849 5850 return event.result; 5851 }, 5852 5853 handlers: function( event, handlers ) { 5854 var i, handleObj, sel, matchedHandlers, matchedSelectors, 5855 handlerQueue = [], 5856 delegateCount = handlers.delegateCount, 5857 cur = event.target; 5858 5859 // Find delegate handlers 5860 if ( delegateCount && 5861 5862 // Support: IE <=9 5863 // Black-hole SVG <use> instance trees (trac-13180) 5864 cur.nodeType && 5865 5866 // Support: Firefox <=42 5867 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) 5868 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click 5869 // Support: IE 11 only 5870 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) 5871 !( event.type === "click" && event.button >= 1 ) ) { 5872 5873 for ( ; cur !== this; cur = cur.parentNode || this ) { 5874 5875 // Don't check non-elements (trac-13208) 5876 // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764) 5877 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { 5878 matchedHandlers = []; 5879 matchedSelectors = {}; 5880 for ( i = 0; i < delegateCount; i++ ) { 5881 handleObj = handlers[ i ]; 5882 5883 // Don't conflict with Object.prototype properties (trac-13203) 5884 sel = handleObj.selector + " "; 5885 5886 if ( matchedSelectors[ sel ] === undefined ) { 5887 matchedSelectors[ sel ] = handleObj.needsContext ? 5888 jQuery( sel, this ).index( cur ) > -1 : 5889 jQuery.find( sel, this, null, [ cur ] ).length; 5890 } 5891 if ( matchedSelectors[ sel ] ) { 5892 matchedHandlers.push( handleObj ); 5893 } 5894 } 5895 if ( matchedHandlers.length ) { 5896 handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); 5897 } 5898 } 5899 } 5900 } 5901 5902 // Add the remaining (directly-bound) handlers 5903 cur = this; 5904 if ( delegateCount < handlers.length ) { 5905 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); 5906 } 5907 5908 return handlerQueue; 5909 }, 5910 5911 addProp: function( name, hook ) { 5912 Object.defineProperty( jQuery.Event.prototype, name, { 5913 enumerable: true, 5914 configurable: true, 5915 5916 get: isFunction( hook ) ? 5917 function() { 5918 if ( this.originalEvent ) { 5919 return hook( this.originalEvent ); 5920 } 5921 } : 5922 function() { 5923 if ( this.originalEvent ) { 5924 return this.originalEvent[ name ]; 5925 } 5926 }, 5927 5928 set: function( value ) { 5929 Object.defineProperty( this, name, { 5930 enumerable: true, 5931 configurable: true, 5932 writable: true, 5933 value: value 5934 } ); 5935 } 5936 } ); 5937 }, 5938 5939 fix: function( originalEvent ) { 5940 return originalEvent[ jQuery.expando ] ? 5941 originalEvent : 5942 new jQuery.Event( originalEvent ); 5943 }, 5944 5945 special: { 5946 load: { 5947 5948 // Prevent triggered image.load events from bubbling to window.load 5949 noBubble: true 5950 }, 5951 click: { 5952 5953 // Utilize native event to ensure correct state for checkable inputs 5954 setup: function( data ) { 5955 5956 // For mutual compressibility with _default, replace `this` access with a local var. 5957 // `|| data` is dead code meant only to preserve the variable through minification. 5958 var el = this || data; 5959 5960 // Claim the first handler 5961 if ( rcheckableType.test( el.type ) && 5962 el.click && nodeName( el, "input" ) ) { 5963 5964 // dataPriv.set( el, "click", ... ) 5965 leverageNative( el, "click", true ); 5966 } 5967 5968 // Return false to allow normal processing in the caller 5969 return false; 5970 }, 5971 trigger: function( data ) { 5972 5973 // For mutual compressibility with _default, replace `this` access with a local var. 5974 // `|| data` is dead code meant only to preserve the variable through minification. 5975 var el = this || data; 5976 5977 // Force setup before triggering a click 5978 if ( rcheckableType.test( el.type ) && 5979 el.click && nodeName( el, "input" ) ) { 5980 5981 leverageNative( el, "click" ); 5982 } 5983 5984 // Return non-false to allow normal event-path propagation 5985 return true; 5986 }, 5987 5988 // For cross-browser consistency, suppress native .click() on links 5989 // Also prevent it if we're currently inside a leveraged native-event stack 5990 _default: function( event ) { 5991 var target = event.target; 5992 return rcheckableType.test( target.type ) && 5993 target.click && nodeName( target, "input" ) && 5994 dataPriv.get( target, "click" ) || 5995 nodeName( target, "a" ); 5996 } 5997 }, 5998 5999 beforeunload: { 6000 postDispatch: function( event ) { 6001 6002 // Support: Firefox 20+ 6003 // Firefox doesn't alert if the returnValue field is not set. 6004 if ( event.result !== undefined && event.originalEvent ) { 6005 event.originalEvent.returnValue = event.result; 6006 } 6007 } 6008 } 6009 } 6010}; 6011 6012// Ensure the presence of an event listener that handles manually-triggered 6013// synthetic events by interrupting progress until reinvoked in response to 6014// *native* events that it fires directly, ensuring that state changes have 6015// already occurred before other listeners are invoked. 6016function leverageNative( el, type, isSetup ) { 6017 6018 // Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add 6019 if ( !isSetup ) { 6020 if ( dataPriv.get( el, type ) === undefined ) { 6021 jQuery.event.add( el, type, returnTrue ); 6022 } 6023 return; 6024 } 6025 6026 // Register the controller as a special universal handler for all event namespaces 6027 dataPriv.set( el, type, false ); 6028 jQuery.event.add( el, type, { 6029 namespace: false, 6030 handler: function( event ) { 6031 var result, 6032 saved = dataPriv.get( this, type ); 6033 6034 if ( ( event.isTrigger & 1 ) && this[ type ] ) { 6035 6036 // Interrupt processing of the outer synthetic .trigger()ed event 6037 if ( !saved ) { 6038 6039 // Store arguments for use when handling the inner native event 6040 // There will always be at least one argument (an event object), so this array 6041 // will not be confused with a leftover capture object. 6042 saved = slice.call( arguments ); 6043 dataPriv.set( this, type, saved ); 6044 6045 // Trigger the native event and capture its result 6046 this[ type ](); 6047 result = dataPriv.get( this, type ); 6048 dataPriv.set( this, type, false ); 6049 6050 if ( saved !== result ) { 6051 6052 // Cancel the outer synthetic event 6053 event.stopImmediatePropagation(); 6054 event.preventDefault(); 6055 6056 return result; 6057 } 6058 6059 // If this is an inner synthetic event for an event with a bubbling surrogate 6060 // (focus or blur), assume that the surrogate already propagated from triggering 6061 // the native event and prevent that from happening again here. 6062 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the 6063 // bubbling surrogate propagates *after* the non-bubbling base), but that seems 6064 // less bad than duplication. 6065 } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { 6066 event.stopPropagation(); 6067 } 6068 6069 // If this is a native event triggered above, everything is now in order 6070 // Fire an inner synthetic event with the original arguments 6071 } else if ( saved ) { 6072 6073 // ...and capture the result 6074 dataPriv.set( this, type, jQuery.event.trigger( 6075 saved[ 0 ], 6076 saved.slice( 1 ), 6077 this 6078 ) ); 6079 6080 // Abort handling of the native event by all jQuery handlers while allowing 6081 // native handlers on the same element to run. On target, this is achieved 6082 // by stopping immediate propagation just on the jQuery event. However, 6083 // the native event is re-wrapped by a jQuery one on each level of the 6084 // propagation so the only way to stop it for jQuery is to stop it for 6085 // everyone via native `stopPropagation()`. This is not a problem for 6086 // focus/blur which don't bubble, but it does also stop click on checkboxes 6087 // and radios. We accept this limitation. 6088 event.stopPropagation(); 6089 event.isImmediatePropagationStopped = returnTrue; 6090 } 6091 } 6092 } ); 6093} 6094 6095jQuery.removeEvent = function( elem, type, handle ) { 6096 6097 // This "if" is needed for plain objects 6098 if ( elem.removeEventListener ) { 6099 elem.removeEventListener( type, handle ); 6100 } 6101}; 6102 6103jQuery.Event = function( src, props ) { 6104 6105 // Allow instantiation without the 'new' keyword 6106 if ( !( this instanceof jQuery.Event ) ) { 6107 return new jQuery.Event( src, props ); 6108 } 6109 6110 // Event object 6111 if ( src && src.type ) { 6112 this.originalEvent = src; 6113 this.type = src.type; 6114 6115 // Events bubbling up the document may have been marked as prevented 6116 // by a handler lower down the tree; reflect the correct value. 6117 this.isDefaultPrevented = src.defaultPrevented || 6118 src.defaultPrevented === undefined && 6119 6120 // Support: Android <=2.3 only 6121 src.returnValue === false ? 6122 returnTrue : 6123 returnFalse; 6124 6125 // Create target properties 6126 // Support: Safari <=6 - 7 only 6127 // Target should not be a text node (trac-504, trac-13143) 6128 this.target = ( src.target && src.target.nodeType === 3 ) ? 6129 src.target.parentNode : 6130 src.target; 6131 6132 this.currentTarget = src.currentTarget; 6133 this.relatedTarget = src.relatedTarget; 6134 6135 // Event type 6136 } else { 6137 this.type = src; 6138 } 6139 6140 // Put explicitly provided properties onto the event object 6141 if ( props ) { 6142 jQuery.extend( this, props ); 6143 } 6144 6145 // Create a timestamp if incoming event doesn't have one 6146 this.timeStamp = src && src.timeStamp || Date.now(); 6147 6148 // Mark it as fixed 6149 this[ jQuery.expando ] = true; 6150}; 6151 6152// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 6153// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 6154jQuery.Event.prototype = { 6155 constructor: jQuery.Event, 6156 isDefaultPrevented: returnFalse, 6157 isPropagationStopped: returnFalse, 6158 isImmediatePropagationStopped: returnFalse, 6159 isSimulated: false, 6160 6161 preventDefault: function() { 6162 var e = this.originalEvent; 6163 6164 this.isDefaultPrevented = returnTrue; 6165 6166 if ( e && !this.isSimulated ) { 6167 e.preventDefault(); 6168 } 6169 }, 6170 stopPropagation: function() { 6171 var e = this.originalEvent; 6172 6173 this.isPropagationStopped = returnTrue; 6174 6175 if ( e && !this.isSimulated ) { 6176 e.stopPropagation(); 6177 } 6178 }, 6179 stopImmediatePropagation: function() { 6180 var e = this.originalEvent; 6181 6182 this.isImmediatePropagationStopped = returnTrue; 6183 6184 if ( e && !this.isSimulated ) { 6185 e.stopImmediatePropagation(); 6186 } 6187 6188 this.stopPropagation(); 6189 } 6190}; 6191 6192// Includes all common event props including KeyEvent and MouseEvent specific props 6193jQuery.each( { 6194 altKey: true, 6195 bubbles: true, 6196 cancelable: true, 6197 changedTouches: true, 6198 ctrlKey: true, 6199 detail: true, 6200 eventPhase: true, 6201 metaKey: true, 6202 pageX: true, 6203 pageY: true, 6204 shiftKey: true, 6205 view: true, 6206 "char": true, 6207 code: true, 6208 charCode: true, 6209 key: true, 6210 keyCode: true, 6211 button: true, 6212 buttons: true, 6213 clientX: true, 6214 clientY: true, 6215 offsetX: true, 6216 offsetY: true, 6217 pointerId: true, 6218 pointerType: true, 6219 screenX: true, 6220 screenY: true, 6221 targetTouches: true, 6222 toElement: true, 6223 touches: true, 6224 which: true 6225}, jQuery.event.addProp ); 6226 6227jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { 6228 6229 function focusMappedHandler( nativeEvent ) { 6230 if ( document.documentMode ) { 6231 6232 // Support: IE 11+ 6233 // Attach a single focusin/focusout handler on the document while someone wants 6234 // focus/blur. This is because the former are synchronous in IE while the latter 6235 // are async. In other browsers, all those handlers are invoked synchronously. 6236 6237 // `handle` from private data would already wrap the event, but we need 6238 // to change the `type` here. 6239 var handle = dataPriv.get( this, "handle" ), 6240 event = jQuery.event.fix( nativeEvent ); 6241 event.type = nativeEvent.type === "focusin" ? "focus" : "blur"; 6242 event.isSimulated = true; 6243 6244 // First, handle focusin/focusout 6245 handle( nativeEvent ); 6246 6247 // ...then, handle focus/blur 6248 // 6249 // focus/blur don't bubble while focusin/focusout do; simulate the former by only 6250 // invoking the handler at the lower level. 6251 if ( event.target === event.currentTarget ) { 6252 6253 // The setup part calls `leverageNative`, which, in turn, calls 6254 // `jQuery.event.add`, so event handle will already have been set 6255 // by this point. 6256 handle( event ); 6257 } 6258 } else { 6259 6260 // For non-IE browsers, attach a single capturing handler on the document 6261 // while someone wants focusin/focusout. 6262 jQuery.event.simulate( delegateType, nativeEvent.target, 6263 jQuery.event.fix( nativeEvent ) ); 6264 } 6265 } 6266 6267 jQuery.event.special[ type ] = { 6268 6269 // Utilize native event if possible so blur/focus sequence is correct 6270 setup: function() { 6271 6272 var attaches; 6273 6274 // Claim the first handler 6275 // dataPriv.set( this, "focus", ... ) 6276 // dataPriv.set( this, "blur", ... ) 6277 leverageNative( this, type, true ); 6278 6279 if ( document.documentMode ) { 6280 6281 // Support: IE 9 - 11+ 6282 // We use the same native handler for focusin & focus (and focusout & blur) 6283 // so we need to coordinate setup & teardown parts between those events. 6284 // Use `delegateType` as the key as `type` is already used by `leverageNative`. 6285 attaches = dataPriv.get( this, delegateType ); 6286 if ( !attaches ) { 6287 this.addEventListener( delegateType, focusMappedHandler ); 6288 } 6289 dataPriv.set( this, delegateType, ( attaches || 0 ) + 1 ); 6290 } else { 6291 6292 // Return false to allow normal processing in the caller 6293 return false; 6294 } 6295 }, 6296 trigger: function() { 6297 6298 // Force setup before trigger 6299 leverageNative( this, type ); 6300 6301 // Return non-false to allow normal event-path propagation 6302 return true; 6303 }, 6304 6305 teardown: function() { 6306 var attaches; 6307 6308 if ( document.documentMode ) { 6309 attaches = dataPriv.get( this, delegateType ) - 1; 6310 if ( !attaches ) { 6311 this.removeEventListener( delegateType, focusMappedHandler ); 6312 dataPriv.remove( this, delegateType ); 6313 } else { 6314 dataPriv.set( this, delegateType, attaches ); 6315 } 6316 } else { 6317 6318 // Return false to indicate standard teardown should be applied 6319 return false; 6320 } 6321 }, 6322 6323 // Suppress native focus or blur if we're currently inside 6324 // a leveraged native-event stack 6325 _default: function( event ) { 6326 return dataPriv.get( event.target, type ); 6327 }, 6328 6329 delegateType: delegateType 6330 }; 6331 6332 // Support: Firefox <=44 6333 // Firefox doesn't have focus(in | out) events 6334 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 6335 // 6336 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 6337 // focus(in | out) events fire after focus & blur events, 6338 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 6339 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 6340 // 6341 // Support: IE 9 - 11+ 6342 // To preserve relative focusin/focus & focusout/blur event order guaranteed on the 3.x branch, 6343 // attach a single handler for both events in IE. 6344 jQuery.event.special[ delegateType ] = { 6345 setup: function() { 6346 6347 // Handle: regular nodes (via `this.ownerDocument`), window 6348 // (via `this.document`) & document (via `this`). 6349 var doc = this.ownerDocument || this.document || this, 6350 dataHolder = document.documentMode ? this : doc, 6351 attaches = dataPriv.get( dataHolder, delegateType ); 6352 6353 // Support: IE 9 - 11+ 6354 // We use the same native handler for focusin & focus (and focusout & blur) 6355 // so we need to coordinate setup & teardown parts between those events. 6356 // Use `delegateType` as the key as `type` is already used by `leverageNative`. 6357 if ( !attaches ) { 6358 if ( document.documentMode ) { 6359 this.addEventListener( delegateType, focusMappedHandler ); 6360 } else { 6361 doc.addEventListener( type, focusMappedHandler, true ); 6362 } 6363 } 6364 dataPriv.set( dataHolder, delegateType, ( attaches || 0 ) + 1 ); 6365 }, 6366 teardown: function() { 6367 var doc = this.ownerDocument || this.document || this, 6368 dataHolder = document.documentMode ? this : doc, 6369 attaches = dataPriv.get( dataHolder, delegateType ) - 1; 6370 6371 if ( !attaches ) { 6372 if ( document.documentMode ) { 6373 this.removeEventListener( delegateType, focusMappedHandler ); 6374 } else { 6375 doc.removeEventListener( type, focusMappedHandler, true ); 6376 } 6377 dataPriv.remove( dataHolder, delegateType ); 6378 } else { 6379 dataPriv.set( dataHolder, delegateType, attaches ); 6380 } 6381 } 6382 }; 6383} ); 6384 6385// Create mouseenter/leave events using mouseover/out and event-time checks 6386// so that event delegation works in jQuery. 6387// Do the same for pointerenter/pointerleave and pointerover/pointerout 6388// 6389// Support: Safari 7 only 6390// Safari sends mouseenter too often; see: 6391// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 6392// for the description of the bug (it existed in older Chrome versions as well). 6393jQuery.each( { 6394 mouseenter: "mouseover", 6395 mouseleave: "mouseout", 6396 pointerenter: "pointerover", 6397 pointerleave: "pointerout" 6398}, function( orig, fix ) { 6399 jQuery.event.special[ orig ] = { 6400 delegateType: fix, 6401 bindType: fix, 6402 6403 handle: function( event ) { 6404 var ret, 6405 target = this, 6406 related = event.relatedTarget, 6407 handleObj = event.handleObj; 6408 6409 // For mouseenter/leave call the handler if related is outside the target. 6410 // NB: No relatedTarget if the mouse left/entered the browser window 6411 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 6412 event.type = handleObj.origType; 6413 ret = handleObj.handler.apply( this, arguments ); 6414 event.type = fix; 6415 } 6416 return ret; 6417 } 6418 }; 6419} ); 6420 6421jQuery.fn.extend( { 6422 6423 on: function( types, selector, data, fn ) { 6424 return on( this, types, selector, data, fn ); 6425 }, 6426 one: function( types, selector, data, fn ) { 6427 return on( this, types, selector, data, fn, 1 ); 6428 }, 6429 off: function( types, selector, fn ) { 6430 var handleObj, type; 6431 if ( types && types.preventDefault && types.handleObj ) { 6432 6433 // ( event ) dispatched jQuery.Event 6434 handleObj = types.handleObj; 6435 jQuery( types.delegateTarget ).off( 6436 handleObj.namespace ? 6437 handleObj.origType + "." + handleObj.namespace : 6438 handleObj.origType, 6439 handleObj.selector, 6440 handleObj.handler 6441 ); 6442 return this; 6443 } 6444 if ( typeof types === "object" ) { 6445 6446 // ( types-object [, selector] ) 6447 for ( type in types ) { 6448 this.off( type, selector, types[ type ] ); 6449 } 6450 return this; 6451 } 6452 if ( selector === false || typeof selector === "function" ) { 6453 6454 // ( types [, fn] ) 6455 fn = selector; 6456 selector = undefined; 6457 } 6458 if ( fn === false ) { 6459 fn = returnFalse; 6460 } 6461 return this.each( function() { 6462 jQuery.event.remove( this, types, fn, selector ); 6463 } ); 6464 } 6465} ); 6466 6467 6468var 6469 6470 // Support: IE <=10 - 11, Edge 12 - 13 only 6471 // In IE/Edge using regex groups here causes severe slowdowns. 6472 // See https://connect.microsoft.com/IE/feedback/details/1736512/ 6473 rnoInnerhtml = /<script|<style|<link/i, 6474 6475 // checked="checked" or checked 6476 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 6477 6478 rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g; 6479 6480// Prefer a tbody over its parent table for containing new rows 6481function manipulationTarget( elem, content ) { 6482 if ( nodeName( elem, "table" ) && 6483 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { 6484 6485 return jQuery( elem ).children( "tbody" )[ 0 ] || elem; 6486 } 6487 6488 return elem; 6489} 6490 6491// Replace/restore the type attribute of script elements for safe DOM manipulation 6492function disableScript( elem ) { 6493 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; 6494 return elem; 6495} 6496function restoreScript( elem ) { 6497 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { 6498 elem.type = elem.type.slice( 5 ); 6499 } else { 6500 elem.removeAttribute( "type" ); 6501 } 6502 6503 return elem; 6504} 6505 6506function cloneCopyEvent( src, dest ) { 6507 var i, l, type, pdataOld, udataOld, udataCur, events; 6508 6509 if ( dest.nodeType !== 1 ) { 6510 return; 6511 } 6512 6513 // 1. Copy private data: events, handlers, etc. 6514 if ( dataPriv.hasData( src ) ) { 6515 pdataOld = dataPriv.get( src ); 6516 events = pdataOld.events; 6517 6518 if ( events ) { 6519 dataPriv.remove( dest, "handle events" ); 6520 6521 for ( type in events ) { 6522 for ( i = 0, l = events[ type ].length; i < l; i++ ) { 6523 jQuery.event.add( dest, type, events[ type ][ i ] ); 6524 } 6525 } 6526 } 6527 } 6528 6529 // 2. Copy user data 6530 if ( dataUser.hasData( src ) ) { 6531 udataOld = dataUser.access( src ); 6532 udataCur = jQuery.extend( {}, udataOld ); 6533 6534 dataUser.set( dest, udataCur ); 6535 } 6536} 6537 6538// Fix IE bugs, see support tests 6539function fixInput( src, dest ) { 6540 var nodeName = dest.nodeName.toLowerCase(); 6541 6542 // Fails to persist the checked state of a cloned checkbox or radio button. 6543 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 6544 dest.checked = src.checked; 6545 6546 // Fails to return the selected option to the default selected state when cloning options 6547 } else if ( nodeName === "input" || nodeName === "textarea" ) { 6548 dest.defaultValue = src.defaultValue; 6549 } 6550} 6551 6552function domManip( collection, args, callback, ignored ) { 6553 6554 // Flatten any nested arrays 6555 args = flat( args ); 6556 6557 var fragment, first, scripts, hasScripts, node, doc, 6558 i = 0, 6559 l = collection.length, 6560 iNoClone = l - 1, 6561 value = args[ 0 ], 6562 valueIsFunction = isFunction( value ); 6563 6564 // We can't cloneNode fragments that contain checked, in WebKit 6565 if ( valueIsFunction || 6566 ( l > 1 && typeof value === "string" && 6567 !support.checkClone && rchecked.test( value ) ) ) { 6568 return collection.each( function( index ) { 6569 var self = collection.eq( index ); 6570 if ( valueIsFunction ) { 6571 args[ 0 ] = value.call( this, index, self.html() ); 6572 } 6573 domManip( self, args, callback, ignored ); 6574 } ); 6575 } 6576 6577 if ( l ) { 6578 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 6579 first = fragment.firstChild; 6580 6581 if ( fragment.childNodes.length === 1 ) { 6582 fragment = first; 6583 } 6584 6585 // Require either new content or an interest in ignored elements to invoke the callback 6586 if ( first || ignored ) { 6587 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 6588 hasScripts = scripts.length; 6589 6590 // Use the original fragment for the last item 6591 // instead of the first because it can end up 6592 // being emptied incorrectly in certain situations (trac-8070). 6593 for ( ; i < l; i++ ) { 6594 node = fragment; 6595 6596 if ( i !== iNoClone ) { 6597 node = jQuery.clone( node, true, true ); 6598 6599 // Keep references to cloned scripts for later restoration 6600 if ( hasScripts ) { 6601 6602 // Support: Android <=4.0 only, PhantomJS 1 only 6603 // push.apply(_, arraylike) throws on ancient WebKit 6604 jQuery.merge( scripts, getAll( node, "script" ) ); 6605 } 6606 } 6607 6608 callback.call( collection[ i ], node, i ); 6609 } 6610 6611 if ( hasScripts ) { 6612 doc = scripts[ scripts.length - 1 ].ownerDocument; 6613 6614 // Re
vendor: 2,059 bytes, lines 6614-6686
6614enable scripts 6615 jQuery.map( scripts, restoreScript ); 6616 6617 // Evaluate executable scripts on first document insertion 6618 for ( i = 0; i < hasScripts; i++ ) { 6619 node = scripts[ i ]; 6620 if ( rscriptType.test( node.type || "" ) && 6621 !dataPriv.access( node, "globalEval" ) && 6622 jQuery.contains( doc, node ) ) { 6623 6624 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { 6625 6626 // Optional AJAX dependency, but won't run scripts if not present 6627 if ( jQuery._evalUrl && !node.noModule ) { 6628 jQuery._evalUrl( node.src, { 6629 nonce: node.nonce || node.getAttribute( "nonce" ) 6630 }, doc ); 6631 } 6632 } else { 6633 6634 // Unwrap a CDATA section containing script contents. This shouldn't be 6635 // needed as in XML documents they're already not visible when 6636 // inspecting element contents and in HTML documents they have no 6637 // meaning but we're preserving that logic for backwards compatibility. 6638 // This will be removed completely in 4.0. See gh-4904. 6639 DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); 6640 } 6641 } 6642 } 6643 } 6644 } 6645 } 6646 6647 return collection; 6648} 6649 6650function remove( elem, selector, keepData ) { 6651 var node, 6652 nodes = selector ? jQuery.filter( selector, elem ) : elem, 6653 i = 0; 6654 6655 for ( ; ( node = nodes[ i ] ) != null; i++ ) { 6656 if ( !keepData && node.nodeType === 1 ) { 6657 jQuery.cleanData( getAll( node ) ); 6658 } 6659 6660 if ( node.parentNode ) { 6661 if ( keepData && isAttached( node ) ) { 6662 setGlobalEval( getAll( node, "script" ) ); 6663 } 6664 node.parentNode.removeChild( node ); 6665 } 6666 } 6667 6668 return elem; 6669} 6670 6671jQuery.extend( { 6672 htmlPrefilter: function( html ) { 6673 return html; 6674 }, 6675 6676 clone: function( elem, dataAndEvents, deepDataAndEvents ) { 6677 var i, l, srcElements, destElements, 6678 clone = elem.cloneNode( true ), 6679 inPage = isAttached( elem ); 6680 6681 // Fix IE cloning issues 6682 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && 6683 !jQuery.isXMLDoc( elem ) ) { 6684 6685 // We eschew jQuery#find here for performance reasons: 6686 //
vendor: 2,516 bytes, lines 6686-6783
6686 https://jsperf.com/getall-vs-sizzle/2 6687 destElements = getAll( clone ); 6688 srcElements = getAll( elem ); 6689 6690 for ( i = 0, l = srcElements.length; i < l; i++ ) { 6691 fixInput( srcElements[ i ], destElements[ i ] ); 6692 } 6693 } 6694 6695 // Copy the events from the original to the clone 6696 if ( dataAndEvents ) { 6697 if ( deepDataAndEvents ) { 6698 srcElements = srcElements || getAll( elem ); 6699 destElements = destElements || getAll( clone ); 6700 6701 for ( i = 0, l = srcElements.length; i < l; i++ ) { 6702 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); 6703 } 6704 } else { 6705 cloneCopyEvent( elem, clone ); 6706 } 6707 } 6708 6709 // Preserve script evaluation history 6710 destElements = getAll( clone, "script" ); 6711 if ( destElements.length > 0 ) { 6712 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 6713 } 6714 6715 // Return the cloned set 6716 return clone; 6717 }, 6718 6719 cleanData: function( elems ) { 6720 var data, elem, type, 6721 special = jQuery.event.special, 6722 i = 0; 6723 6724 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { 6725 if ( acceptData( elem ) ) { 6726 if ( ( data = elem[ dataPriv.expando ] ) ) { 6727 if ( data.events ) { 6728 for ( type in data.events ) { 6729 if ( special[ type ] ) { 6730 jQuery.event.remove( elem, type ); 6731 6732 // This is a shortcut to avoid jQuery.event.remove's overhead 6733 } else { 6734 jQuery.removeEvent( elem, type, data.handle ); 6735 } 6736 } 6737 } 6738 6739 // Support: Chrome <=35 - 45+ 6740 // Assign undefined instead of using delete, see Data#remove 6741 elem[ dataPriv.expando ] = undefined; 6742 } 6743 if ( elem[ dataUser.expando ] ) { 6744 6745 // Support: Chrome <=35 - 45+ 6746 // Assign undefined instead of using delete, see Data#remove 6747 elem[ dataUser.expando ] = undefined; 6748 } 6749 } 6750 } 6751 } 6752} ); 6753 6754jQuery.fn.extend( { 6755 detach: function( selector ) { 6756 return remove( this, selector, true ); 6757 }, 6758 6759 remove: function( selector ) { 6760 return remove( this, selector ); 6761 }, 6762 6763 text: function( value ) { 6764 return access( this, function( value ) { 6765 return value === undefined ? 6766 jQuery.text( this ) : 6767 this.empty().each( function() { 6768 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6769 this.textContent = value; 6770 } 6771 } ); 6772 }, null, value, arguments.length ); 6773 }, 6774 6775 append: function() { 6776 return domManip( this, arguments, function( elem ) { 6777 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6778 var target = manipulationTarget( this, elem ); 6779 target.appendChild( elem ); 6780 } 6781 } ); 6782 }, 6783
vendor: 7,872 bytes, lines 6784-7071
6784 prepend: function() { 6785 return domManip( this, arguments, function( elem ) { 6786 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 6787 var target = manipulationTarget( this, elem ); 6788 target.insertBefore( elem, target.firstChild ); 6789 } 6790 } ); 6791 }, 6792 6793 before: function() { 6794 return domManip( this, arguments, function( elem ) { 6795 if ( this.parentNode ) { 6796 this.parentNode.insertBefore( elem, this ); 6797 } 6798 } ); 6799 }, 6800 6801 after: function() { 6802 return domManip( this, arguments, function( elem ) { 6803 if ( this.parentNode ) { 6804 this.parentNode.insertBefore( elem, this.nextSibling ); 6805 } 6806 } ); 6807 }, 6808 6809 empty: function() { 6810 var elem, 6811 i = 0; 6812 6813 for ( ; ( elem = this[ i ] ) != null; i++ ) { 6814 if ( elem.nodeType === 1 ) { 6815 6816 // Prevent memory leaks 6817 jQuery.cleanData( getAll( elem, false ) ); 6818 6819 // Remove any remaining nodes 6820 elem.textContent = ""; 6821 } 6822 } 6823 6824 return this; 6825 }, 6826 6827 clone: function( dataAndEvents, deepDataAndEvents ) { 6828 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 6829 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 6830 6831 return this.map( function() { 6832 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 6833 } ); 6834 }, 6835 6836 html: function( value ) { 6837 return access( this, function( value ) { 6838 var elem = this[ 0 ] || {}, 6839 i = 0, 6840 l = this.length; 6841 6842 if ( value === undefined && elem.nodeType === 1 ) { 6843 return elem.innerHTML; 6844 } 6845 6846 // See if we can take a shortcut and just use innerHTML 6847 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 6848 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 6849 6850 value = jQuery.htmlPrefilter( value ); 6851 6852 try { 6853 for ( ; i < l; i++ ) { 6854 elem = this[ i ] || {}; 6855 6856 // Remove element nodes and prevent memory leaks 6857 if ( elem.nodeType === 1 ) { 6858 jQuery.cleanData( getAll( elem, false ) ); 6859 elem.innerHTML = value; 6860 } 6861 } 6862 6863 elem = 0; 6864 6865 // If using innerHTML throws an exception, use the fallback method 6866 } catch ( e ) {} 6867 } 6868 6869 if ( elem ) { 6870 this.empty().append( value ); 6871 } 6872 }, null, value, arguments.length ); 6873 }, 6874 6875 replaceWith: function() { 6876 var ignored = []; 6877 6878 // Make the changes, replacing each non-ignored context element with the new content 6879 return domManip( this, arguments, function( elem ) { 6880 var parent = this.parentNode; 6881 6882 if ( jQuery.inArray( this, ignored ) < 0 ) { 6883 jQuery.cleanData( getAll( this ) ); 6884 if ( parent ) { 6885 parent.replaceChild( elem, this ); 6886 } 6887 } 6888 6889 // Force callback invocation 6890 }, ignored ); 6891 } 6892} ); 6893 6894jQuery.each( { 6895 appendTo: "append", 6896 prependTo: "prepend", 6897 insertBefore: "before", 6898 insertAfter: "after", 6899 replaceAll: "replaceWith" 6900}, function( name, original ) { 6901 jQuery.fn[ name ] = function( selector ) { 6902 var elems, 6903 ret = [], 6904 insert = jQuery( selector ), 6905 last = insert.length - 1, 6906 i = 0; 6907 6908 for ( ; i <= last; i++ ) { 6909 elems = i === last ? this : this.clone( true ); 6910 jQuery( insert[ i ] )[ original ]( elems ); 6911 6912 // Support: Android <=4.0 only, PhantomJS 1 only 6913 // .get() because push.apply(_, arraylike) throws on ancient WebKit 6914 push.apply( ret, elems.get() ); 6915 } 6916 6917 return this.pushStack( ret ); 6918 }; 6919} ); 6920var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 6921 6922var rcustomProp = /^--/; 6923 6924 6925var getStyles = function( elem ) { 6926 6927 // Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150) 6928 // IE throws on elements created in popups 6929 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 6930 var view = elem.ownerDocument.defaultView; 6931 6932 if ( !view || !view.opener ) { 6933 view = window; 6934 } 6935 6936 return view.getComputedStyle( elem ); 6937 }; 6938 6939var swap = function( elem, options, callback ) { 6940 var ret, name, 6941 old = {}; 6942 6943 // Remember the old values, and insert the new ones 6944 for ( name in options ) { 6945 old[ name ] = elem.style[ name ]; 6946 elem.style[ name ] = options[ name ]; 6947 } 6948 6949 ret = callback.call( elem ); 6950 6951 // Revert the old values 6952 for ( name in options ) { 6953 elem.style[ name ] = old[ name ]; 6954 } 6955 6956 return ret; 6957}; 6958 6959 6960var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); 6961 6962 6963 6964( function() { 6965 6966 // Executing both pixelPosition & boxSizingReliable tests require only one layout 6967 // so they're executed at the same time to save the second computation. 6968 function computeStyleTests() { 6969 6970 // This is a singleton, we need to execute it only once 6971 if ( !div ) { 6972 return; 6973 } 6974 6975 container.style.cssText = "position:absolute;left:-11111px;width:60px;" + 6976 "margin-top:1px;padding:0;border:0"; 6977 div.style.cssText = 6978 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + 6979 "margin:auto;border:1px;padding:1px;" + 6980 "width:60%;top:1%"; 6981 documentElement.appendChild( container ).appendChild( div ); 6982 6983 var divStyle = window.getComputedStyle( div ); 6984 pixelPositionVal = divStyle.top !== "1%"; 6985 6986 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 6987 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; 6988 6989 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 6990 // Some styles come back with percentage values, even though they shouldn't 6991 div.style.right = "60%"; 6992 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; 6993 6994 // Support: IE 9 - 11 only 6995 // Detect misreporting of content dimensions for box-sizing:border-box elements 6996 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; 6997 6998 // Support: IE 9 only 6999 // Detect overflow:scroll screwiness (gh-3699) 7000 // Support: Chrome <=64 7001 // Don't get tricked when zoom affects offsetWidth (gh-4029) 7002 div.style.position = "absolute"; 7003 scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; 7004 7005 documentElement.removeChild( container ); 7006 7007 // Nullify the div so it wouldn't be stored in the memory and 7008 // it will also be a sign that checks already performed 7009 div = null; 7010 } 7011 7012 function roundPixelMeasures( measure ) { 7013 return Math.round( parseFloat( measure ) ); 7014 } 7015 7016 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, 7017 reliableTrDimensionsVal, reliableMarginLeftVal, 7018 container = document.createElement( "div" ), 7019 div = document.createElement( "div" ); 7020 7021 // Finish early in limited (non-browser) environments 7022 if ( !div.style ) { 7023 return; 7024 } 7025 7026 // Support: IE <=9 - 11 only 7027 // Style of cloned element affects source element cloned (trac-8908) 7028 div.style.backgroundClip = "content-box"; 7029 div.cloneNode( true ).style.backgroundClip = ""; 7030 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 7031 7032 jQuery.extend( support, { 7033 boxSizingReliable: function() { 7034 computeStyleTests(); 7035 return boxSizingReliableVal; 7036 }, 7037 pixelBoxStyles: function() { 7038 computeStyleTests(); 7039 return pixelBoxStylesVal; 7040 }, 7041 pixelPosition: function() { 7042 computeStyleTests(); 7043 return pixelPositionVal; 7044 }, 7045 reliableMarginLeft: function() { 7046 computeStyleTests(); 7047 return reliableMarginLeftVal; 7048 }, 7049 scrollboxSize: function() { 7050 computeStyleTests(); 7051 return scrollboxSizeVal; 7052 }, 7053 7054 // Support: IE 9 - 11+, Edge 15 - 18+ 7055 // IE/Edge misreport `getComputedStyle` of table rows with width/height 7056 // set in CSS while `offset*` properties report correct values. 7057 // Behavior in IE 9 is more subtle than in newer versions & it passes 7058 // some versions of this test; make sure not to make it pass there! 7059 // 7060 // Support: Firefox 70+ 7061 // Only Firefox includes border widths 7062 // in computed dimensions. (gh-4529) 7063 reliableTrDimensions: function() { 7064 var table, tr, trChild, trStyle; 7065 if ( reliableTrDimensionsVal == null ) { 7066 table = document.createElement( "table" ); 7067 tr = document.createElement( "tr" ); 7068 trChild = document.createElement( "div" ); 7069 7070 table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; 7071 tr.style.cssText = "bo
7071rder:1px solid"; 7072 7073 // Support: Chrome 86+ 7074 // Height set through cssText does not get applied. 7075 // Computed height then comes back as 0. 7076 tr.style.height = "1px"; 7077 trChild.style.height = "9px"; 7078 7079 // Support: Android 8 Chrome 86+ 7080 // In our bodyBackground.html iframe, 7081 // display for all div elements is set to "inline", 7082 // which causes a problem only in Android 8 Chrome 86. 7083 // Ensuring the div is display: block
vendor: 50,104 bytes, lines 7083-8998
7083 7084 // gets around this issue. 7085 trChild.style.display = "block"; 7086 7087 documentElement 7088 .appendChild( table ) 7089 .appendChild( tr ) 7090 .appendChild( trChild ); 7091 7092 trStyle = window.getComputedStyle( tr ); 7093 reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + 7094 parseInt( trStyle.borderTopWidth, 10 ) + 7095 parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; 7096 7097 documentElement.removeChild( table ); 7098 } 7099 return reliableTrDimensionsVal; 7100 } 7101 } ); 7102} )(); 7103 7104 7105function curCSS( elem, name, computed ) { 7106 var width, minWidth, maxWidth, ret, 7107 isCustomProp = rcustomProp.test( name ), 7108 7109 // Support: Firefox 51+ 7110 // Retrieving style before computed somehow 7111 // fixes an issue with getting wrong values 7112 // on detached elements 7113 style = elem.style; 7114 7115 computed = computed || getStyles( elem ); 7116 7117 // getPropertyValue is needed for: 7118 // .css('filter') (IE 9 only, trac-12537) 7119 // .css('--customProperty) (gh-3144) 7120 if ( computed ) { 7121 7122 // Support: IE <=9 - 11+ 7123 // IE only supports `"float"` in `getPropertyValue`; in computed styles 7124 // it's only available as `"cssFloat"`. We no longer modify properties 7125 // sent to `.css()` apart from camelCasing, so we need to check both. 7126 // Normally, this would create difference in behavior: if 7127 // `getPropertyValue` returns an empty string, the value returned 7128 // by `.css()` would be `undefined`. This is usually the case for 7129 // disconnected elements. However, in IE even disconnected elements 7130 // with no styles return `"none"` for `getPropertyValue( "float" )` 7131 ret = computed.getPropertyValue( name ) || computed[ name ]; 7132 7133 if ( isCustomProp && ret ) { 7134 7135 // Support: Firefox 105+, Chrome <=105+ 7136 // Spec requires trimming whitespace for custom properties (gh-4926). 7137 // Firefox only trims leading whitespace. Chrome just collapses 7138 // both leading & trailing whitespace to a single space. 7139 // 7140 // Fall back to `undefined` if empty string returned. 7141 // This collapses a missing definition with property defined 7142 // and set to an empty string but there's no standard API 7143 // allowing us to differentiate them without a performance penalty 7144 // and returning `undefined` aligns with older jQuery. 7145 // 7146 // rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED 7147 // as whitespace while CSS does not, but this is not a problem 7148 // because CSS preprocessing replaces them with U+000A LINE FEED 7149 // (which *is* CSS whitespace) 7150 // https://www.w3.org/TR/css-syntax-3/#input-preprocessing 7151 ret = ret.replace( rtrimCSS, "$1" ) || undefined; 7152 } 7153 7154 if ( ret === "" && !isAttached( elem ) ) { 7155 ret = jQuery.style( elem, name ); 7156 } 7157 7158 // A tribute to the "awesome hack by Dean Edwards" 7159 // Android Browser returns percentage for some values, 7160 // but width seems to be reliably pixels. 7161 // This is against the CSSOM draft spec: 7162 // https://drafts.csswg.org/cssom/#resolved-values 7163 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { 7164 7165 // Remember the original values 7166 width = style.width; 7167 minWidth = style.minWidth; 7168 maxWidth = style.maxWidth; 7169 7170 // Put in the new values to get a computed value out 7171 style.minWidth = style.maxWidth = style.width = ret; 7172 ret = computed.width; 7173 7174 // Revert the changed values 7175 style.width = width; 7176 style.minWidth = minWidth; 7177 style.maxWidth = maxWidth; 7178 } 7179 } 7180 7181 return ret !== undefined ? 7182 7183 // Support: IE <=9 - 11 only 7184 // IE returns zIndex value as an integer. 7185 ret + "" : 7186 ret; 7187} 7188 7189 7190function addGetHookIf( conditionFn, hookFn ) { 7191 7192 // Define the hook, we'll check on the first run if it's really needed. 7193 return { 7194 get: function() { 7195 if ( conditionFn() ) { 7196 7197 // Hook not needed (or it's not possible to use it due 7198 // to missing dependency), remove it. 7199 delete this.get; 7200 return; 7201 } 7202 7203 // Hook needed; redefine it so that the support test is not executed again. 7204 return ( this.get = hookFn ).apply( this, arguments ); 7205 } 7206 }; 7207} 7208 7209 7210var cssPrefixes = [ "Webkit", "Moz", "ms" ], 7211 emptyStyle = document.createElement( "div" ).style, 7212 vendorProps = {}; 7213 7214// Return a vendor-prefixed property or undefined 7215function vendorPropName( name ) { 7216 7217 // Check for vendor prefixed names 7218 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 7219 i = cssPrefixes.length; 7220 7221 while ( i-- ) { 7222 name = cssPrefixes[ i ] + capName; 7223 if ( name in emptyStyle ) { 7224 return name; 7225 } 7226 } 7227} 7228 7229// Return a potentially-mapped jQuery.cssProps or vendor prefixed property 7230function finalPropName( name ) { 7231 var final = jQuery.cssProps[ name ] || vendorProps[ name ]; 7232 7233 if ( final ) { 7234 return final; 7235 } 7236 if ( name in emptyStyle ) { 7237 return name; 7238 } 7239 return vendorProps[ name ] = vendorPropName( name ) || name; 7240} 7241 7242 7243var 7244 7245 // Swappable if display is none or starts with table 7246 // except "table", "table-cell", or "table-caption" 7247 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display 7248 rdisplayswap = /^(none|table(?!-c[ea]).+)/, 7249 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 7250 cssNormalTransform = { 7251 letterSpacing: "0", 7252 fontWeight: "400" 7253 }; 7254 7255function setPositiveNumber( _elem, value, subtract ) { 7256 7257 // Any relative (+/-) values have already been 7258 // normalized at this point 7259 var matches = rcssNum.exec( value ); 7260 return matches ? 7261 7262 // Guard against undefined "subtract", e.g., when used as in cssHooks 7263 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : 7264 value; 7265} 7266 7267function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { 7268 var i = dimension === "width" ? 1 : 0, 7269 extra = 0, 7270 delta = 0, 7271 marginDelta = 0; 7272 7273 // Adjustment may not be necessary 7274 if ( box === ( isBorderBox ? "border" : "content" ) ) { 7275 return 0; 7276 } 7277 7278 for ( ; i < 4; i += 2 ) { 7279 7280 // Both box models exclude margin 7281 // Count margin delta separately to only add it after scroll gutter adjustment. 7282 // This is needed to make negative margins work with `outerHeight( true )` (gh-3982). 7283 if ( box === "margin" ) { 7284 marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); 7285 } 7286 7287 // If we get here with a content-box, we're seeking "padding" or "border" or "margin" 7288 if ( !isBorderBox ) { 7289 7290 // Add padding 7291 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 7292 7293 // For "border" or "margin", add border 7294 if ( box !== "padding" ) { 7295 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 7296 7297 // But still keep track of it otherwise 7298 } else { 7299 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 7300 } 7301 7302 // If we get here with a border-box (content + padding + border), we're seeking "content" or 7303 // "padding" or "margin" 7304 } else { 7305 7306 // For "content", subtract padding 7307 if ( box === "content" ) { 7308 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 7309 } 7310 7311 // For "content" or "padding", subtract border 7312 if ( box !== "margin" ) { 7313 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 7314 } 7315 } 7316 } 7317 7318 // Account for positive content-box scroll gutter when requested by providing computedVal 7319 if ( !isBorderBox && computedVal >= 0 ) { 7320 7321 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border 7322 // Assuming integer scroll gutter, subtract the rest and round down 7323 delta += Math.max( 0, Math.ceil( 7324 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 7325 computedVal - 7326 delta - 7327 extra - 7328 0.5 7329 7330 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter 7331 // Use an explicit zero to avoid NaN (gh-3964) 7332 ) ) || 0; 7333 } 7334 7335 return delta + marginDelta; 7336} 7337 7338function getWidthOrHeight( elem, dimension, extra ) { 7339 7340 // Start with computed style 7341 var styles = getStyles( elem ), 7342 7343 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). 7344 // Fake content-box until we know it's needed to know the true value. 7345 boxSizingNeeded = !support.boxSizingReliable() || extra, 7346 isBorderBox = boxSizingNeeded && 7347 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 7348 valueIsBorderBox = isBorderBox, 7349 7350 val = curCSS( elem, dimension, styles ), 7351 offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); 7352 7353 // Support: Firefox <=54 7354 // Return a confounding non-pixel value or feign ignorance, as appropriate. 7355 if ( rnumnonpx.test( val ) ) { 7356 if ( !extra ) { 7357 return val; 7358 } 7359 val = "auto"; 7360 } 7361 7362 7363 // Support: IE 9 - 11 only 7364 // Use offsetWidth/offsetHeight for when box sizing is unreliable. 7365 // In those cases, the computed value can be trusted to be border-box. 7366 if ( ( !support.boxSizingReliable() && isBorderBox || 7367 7368 // Support: IE 10 - 11+, Edge 15 - 18+ 7369 // IE/Edge misreport `getComputedStyle` of table rows with width/height 7370 // set in CSS while `offset*` properties report correct values. 7371 // Interestingly, in some cases IE 9 doesn't suffer from this issue. 7372 !support.reliableTrDimensions() && nodeName( elem, "tr" ) || 7373 7374 // Fall back to offsetWidth/offsetHeight when value is "auto" 7375 // This happens for inline elements with no explicit setting (gh-3571) 7376 val === "auto" || 7377 7378 // Support: Android <=4.1 - 4.3 only 7379 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) 7380 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && 7381 7382 // Make sure the element is visible & connected 7383 elem.getClientRects().length ) { 7384 7385 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; 7386 7387 // Where available, offsetWidth/offsetHeight approximate border box dimensions. 7388 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the 7389 // retrieved value as a content box dimension. 7390 valueIsBorderBox = offsetProp in elem; 7391 if ( valueIsBorderBox ) { 7392 val = elem[ offsetProp ]; 7393 } 7394 } 7395 7396 // Normalize "" and auto 7397 val = parseFloat( val ) || 0; 7398 7399 // Adjust for the element's box model 7400 return ( val + 7401 boxModelAdjustment( 7402 elem, 7403 dimension, 7404 extra || ( isBorderBox ? "border" : "content" ), 7405 valueIsBorderBox, 7406 styles, 7407 7408 // Provide the current computed size to request scroll gutter calculation (gh-3589) 7409 val 7410 ) 7411 ) + "px"; 7412} 7413 7414jQuery.extend( { 7415 7416 // Add in style property hooks for overriding the default 7417 // behavior of getting and setting a style property 7418 cssHooks: { 7419 opacity: { 7420 get: function( elem, computed ) { 7421 if ( computed ) { 7422 7423 // We should always get a number back from opacity 7424 var ret = curCSS( elem, "opacity" ); 7425 return ret === "" ? "1" : ret; 7426 } 7427 } 7428 } 7429 }, 7430 7431 // Don't automatically add "px" to these possibly-unitless properties 7432 cssNumber: { 7433 animationIterationCount: true, 7434 aspectRatio: true, 7435 borderImageSlice: true, 7436 columnCount: true, 7437 flexGrow: true, 7438 flexShrink: true, 7439 fontWeight: true, 7440 gridArea: true, 7441 gridColumn: true, 7442 gridColumnEnd: true, 7443 gridColumnStart: true, 7444 gridRow: true, 7445 gridRowEnd: true, 7446 gridRowStart: true, 7447 lineHeight: true, 7448 opacity: true, 7449 order: true, 7450 orphans: true, 7451 scale: true, 7452 widows: true, 7453 zIndex: true, 7454 zoom: true, 7455 7456 // SVG-related 7457 fillOpacity: true, 7458 floodOpacity: true, 7459 stopOpacity: true, 7460 strokeMiterlimit: true, 7461 strokeOpacity: true 7462 }, 7463 7464 // Add in properties whose names you wish to fix before 7465 // setting or getting the value 7466 cssProps: {}, 7467 7468 // Get and set the style property on a DOM Node 7469 style: function( elem, name, value, extra ) { 7470 7471 // Don't set styles on text and comment nodes 7472 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 7473 return; 7474 } 7475 7476 // Make sure that we're working with the right name 7477 var ret, type, hooks, 7478 origName = camelCase( name ), 7479 isCustomProp = rcustomProp.test( name ), 7480 style = elem.style; 7481 7482 // Make sure that we're working with the right name. We don't 7483 // want to query the value if it is a CSS custom property 7484 // since they are user-defined. 7485 if ( !isCustomProp ) { 7486 name = finalPropName( origName ); 7487 } 7488 7489 // Gets hook for the prefixed version, then unprefixed version 7490 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 7491 7492 // Check if we're setting a value 7493 if ( value !== undefined ) { 7494 type = typeof value; 7495 7496 // Convert "+=" or "-=" to relative numbers (trac-7345) 7497 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 7498 value = adjustCSS( elem, name, ret ); 7499 7500 // Fixes bug trac-9237 7501 type = "number"; 7502 } 7503 7504 // Make sure that null and NaN values aren't set (trac-7116) 7505 if ( value == null || value !== value ) { 7506 return; 7507 } 7508 7509 // If a number was passed in, add the unit (except for certain CSS properties) 7510 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append 7511 // "px" to a few hardcoded values. 7512 if ( type === "number" && !isCustomProp ) { 7513 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 7514 } 7515 7516 // background-* props affect original clone's values 7517 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 7518 style[ name ] = "inherit"; 7519 } 7520 7521 // If a hook was provided, use that value, otherwise just set the specified value 7522 if ( !hooks || !( "set" in hooks ) || 7523 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 7524 7525 if ( isCustomProp ) { 7526 style.setProperty( name, value ); 7527 } else { 7528 style[ name ] = value; 7529 } 7530 } 7531 7532 } else { 7533 7534 // If a hook was provided get the non-computed value from there 7535 if ( hooks && "get" in hooks && 7536 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 7537 7538 return ret; 7539 } 7540 7541 // Otherwise just get the value from the style object 7542 return style[ name ]; 7543 } 7544 }, 7545 7546 css: function( elem, name, extra, styles ) { 7547 var val, num, hooks, 7548 origName = camelCase( name ), 7549 isCustomProp = rcustomProp.test( name ); 7550 7551 // Make sure that we're working with the right name. We don't 7552 // want to modify the value if it is a CSS custom property 7553 // since they are user-defined. 7554 if ( !isCustomProp ) { 7555 name = finalPropName( origName ); 7556 } 7557 7558 // Try prefixed name followed by the unprefixed name 7559 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 7560 7561 // If a hook was provided get the computed value from there 7562 if ( hooks && "get" in hooks ) { 7563 val = hooks.get( elem, true, extra ); 7564 } 7565 7566 // Otherwise, if a way to get the computed value exists, use that 7567 if ( val === undefined ) { 7568 val = curCSS( elem, name, styles ); 7569 } 7570 7571 // Convert "normal" to computed value 7572 if ( val === "normal" && name in cssNormalTransform ) { 7573 val = cssNormalTransform[ name ]; 7574 } 7575 7576 // Make numeric if forced or a qualifier was provided and val looks numeric 7577 if ( extra === "" || extra ) { 7578 num = parseFloat( val ); 7579 return extra === true || isFinite( num ) ? num || 0 : val; 7580 } 7581 7582 return val; 7583 } 7584} ); 7585 7586jQuery.each( [ "height", "width" ], function( _i, dimension ) { 7587 jQuery.cssHooks[ dimension ] = { 7588 get: function( elem, computed, extra ) { 7589 if ( computed ) { 7590 7591 // Certain elements can have dimension info if we invisibly show them 7592 // but it must have a current display style that would benefit 7593 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 7594 7595 // Support: Safari 8+ 7596 // Table columns in Safari have non-zero offsetWidth & zero 7597 // getBoundingClientRect().width unless display is changed. 7598 // Support: IE <=11 only 7599 // Running getBoundingClientRect on a disconnected node 7600 // in IE throws an error. 7601 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? 7602 swap( elem, cssShow, function() { 7603 return getWidthOrHeight( elem, dimension, extra ); 7604 } ) : 7605 getWidthOrHeight( elem, dimension, extra ); 7606 } 7607 }, 7608 7609 set: function( elem, value, extra ) { 7610 var matches, 7611 styles = getStyles( elem ), 7612 7613 // Only read styles.position if the test has a chance to fail 7614 // to avoid forcing a reflow. 7615 scrollboxSizeBuggy = !support.scrollboxSize() && 7616 styles.position === "absolute", 7617 7618 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) 7619 boxSizingNeeded = scrollboxSizeBuggy || extra, 7620 isBorderBox = boxSizingNeeded && 7621 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 7622 subtract = extra ? 7623 boxModelAdjustment( 7624 elem, 7625 dimension, 7626 extra, 7627 isBorderBox, 7628 styles 7629 ) : 7630 0; 7631 7632 // Account for unreliable border-box dimensions by comparing offset* to computed and 7633 // faking a content-box to get border and padding (gh-3699) 7634 if ( isBorderBox && scrollboxSizeBuggy ) { 7635 subtract -= Math.ceil( 7636 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - 7637 parseFloat( styles[ dimension ] ) - 7638 boxModelAdjustment( elem, dimension, "border", false, styles ) - 7639 0.5 7640 ); 7641 } 7642 7643 // Convert to pixels if value adjustment is needed 7644 if ( subtract && ( matches = rcssNum.exec( value ) ) && 7645 ( matches[ 3 ] || "px" ) !== "px" ) { 7646 7647 elem.style[ dimension ] = value; 7648 value = jQuery.css( elem, dimension ); 7649 } 7650 7651 return setPositiveNumber( elem, value, subtract ); 7652 } 7653 }; 7654} ); 7655 7656jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 7657 function( elem, computed ) { 7658 if ( computed ) { 7659 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || 7660 elem.getBoundingClientRect().left - 7661 swap( elem, { marginLeft: 0 }, function() { 7662 return elem.getBoundingClientRect().left; 7663 } ) 7664 ) + "px"; 7665 } 7666 } 7667); 7668 7669// These hooks are used by animate to expand properties 7670jQuery.each( { 7671 margin: "", 7672 padding: "", 7673 border: "Width" 7674}, function( prefix, suffix ) { 7675 jQuery.cssHooks[ prefix + suffix ] = { 7676 expand: function( value ) { 7677 var i = 0, 7678 expanded = {}, 7679 7680 // Assumes a single number if not a string 7681 parts = typeof value === "string" ? value.split( " " ) : [ value ]; 7682 7683 for ( ; i < 4; i++ ) { 7684 expanded[ prefix + cssExpand[ i ] + suffix ] = 7685 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 7686 } 7687 7688 return expanded; 7689 } 7690 }; 7691 7692 if ( prefix !== "margin" ) { 7693 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 7694 } 7695} ); 7696 7697jQuery.fn.extend( { 7698 css: function( name, value ) { 7699 return access( this, function( elem, name, value ) { 7700 var styles, len, 7701 map = {}, 7702 i = 0; 7703 7704 if ( Array.isArray( name ) ) { 7705 styles = getStyles( elem ); 7706 len = name.length; 7707 7708 for ( ; i < len; i++ ) { 7709 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 7710 } 7711 7712 return map; 7713 } 7714 7715 return value !== undefined ? 7716 jQuery.style( elem, name, value ) : 7717 jQuery.css( elem, name ); 7718 }, name, value, arguments.length > 1 ); 7719 } 7720} ); 7721 7722 7723function Tween( elem, options, prop, end, easing ) { 7724 return new Tween.prototype.init( elem, options, prop, end, easing ); 7725} 7726jQuery.Tween = Tween; 7727 7728Tween.prototype = { 7729 constructor: Tween, 7730 init: function( elem, options, prop, end, easing, unit ) { 7731 this.elem = elem; 7732 this.prop = prop; 7733 this.easing = easing || jQuery.easing._default; 7734 this.options = options; 7735 this.start = this.now = this.cur(); 7736 this.end = end; 7737 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 7738 }, 7739 cur: function() { 7740 var hooks = Tween.propHooks[ this.prop ]; 7741 7742 return hooks && hooks.get ? 7743 hooks.get( this ) : 7744 Tween.propHooks._default.get( this ); 7745 }, 7746 run: function( percent ) { 7747 var eased, 7748 hooks = Tween.propHooks[ this.prop ]; 7749 7750 if ( this.options.duration ) { 7751 this.pos = eased = jQuery.easing[ this.easing ]( 7752 percent, this.options.duration * percent, 0, 1, this.options.duration 7753 ); 7754 } else { 7755 this.pos = eased = percent; 7756 } 7757 this.now = ( this.end - this.start ) * eased + this.start; 7758 7759 if ( this.options.step ) { 7760 this.options.step.call( this.elem, this.now, this ); 7761 } 7762 7763 if ( hooks && hooks.set ) { 7764 hooks.set( this ); 7765 } else { 7766 Tween.propHooks._default.set( this ); 7767 } 7768 return this; 7769 } 7770}; 7771 7772Tween.prototype.init.prototype = Tween.prototype; 7773 7774Tween.propHooks = { 7775 _default: { 7776 get: function( tween ) { 7777 var result; 7778 7779 // Use a property on the element directly when it is not a DOM element, 7780 // or when there is no matching style property that exists. 7781 if ( tween.elem.nodeType !== 1 || 7782 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 7783 return tween.elem[ tween.prop ]; 7784 } 7785 7786 // Passing an empty string as a 3rd parameter to .css will automatically 7787 // attempt a parseFloat and fallback to a string if the parse fails. 7788 // Simple values such as "10px" are parsed to Float; 7789 // complex values such as "rotate(1rad)" are returned as-is. 7790 result = jQuery.css( tween.elem, tween.prop, "" ); 7791 7792 // Empty strings, null, undefined and "auto" are converted to 0. 7793 return !result || result === "auto" ? 0 : result; 7794 }, 7795 set: function( tween ) { 7796 7797 // Use step hook for back compat. 7798 // Use cssHook if its there. 7799 // Use .style if available and use plain properties where available. 7800 if ( jQuery.fx.step[ tween.prop ] ) { 7801 jQuery.fx.step[ tween.prop ]( tween ); 7802 } else if ( tween.elem.nodeType === 1 && ( 7803 jQuery.cssHooks[ tween.prop ] || 7804 tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { 7805 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 7806 } else { 7807 tween.elem[ tween.prop ] = tween.now; 7808 } 7809 } 7810 } 7811}; 7812 7813// Support: IE <=9 only 7814// Panic based approach to setting things on disconnected nodes 7815Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 7816 set: function( tween ) { 7817 if ( tween.elem.nodeType && tween.elem.parentNode ) { 7818 tween.elem[ tween.prop ] = tween.now; 7819 } 7820 } 7821}; 7822 7823jQuery.easing = { 7824 linear: function( p ) { 7825 return p; 7826 }, 7827 swing: function( p ) { 7828 return 0.5 - Math.cos( p * Math.PI ) / 2; 7829 }, 7830 _default: "swing" 7831}; 7832 7833jQuery.fx = Tween.prototype.init; 7834 7835// Back compat <1.8 extension point 7836jQuery.fx.step = {}; 7837 7838 7839 7840 7841var 7842 fxNow, inProgress, 7843 rfxtypes = /^(?:toggle|show|hide)$/, 7844 rrun = /queueHooks$/; 7845 7846function schedule() { 7847 if ( inProgress ) { 7848 if ( document.hidden === false && window.requestAnimationFrame ) { 7849 window.requestAnimationFrame( schedule ); 7850 } else { 7851 window.setTimeout( schedule, jQuery.fx.interval ); 7852 } 7853 7854 jQuery.fx.tick(); 7855 } 7856} 7857 7858// Animations created synchronously will run synchronously 7859function createFxNow() { 7860 window.setTimeout( function() { 7861 fxNow = undefined; 7862 } ); 7863 return ( fxNow = Date.now() ); 7864} 7865 7866// Generate parameters to create a standard animation 7867function genFx( type, includeWidth ) { 7868 var which, 7869 i = 0, 7870 attrs = { height: type }; 7871 7872 // If we include width, step value is 1 to do all cssExpand values, 7873 // otherwise step value is 2 to skip over Left and Right 7874 includeWidth = includeWidth ? 1 : 0; 7875 for ( ; i < 4; i += 2 - includeWidth ) { 7876 which = cssExpand[ i ]; 7877 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 7878 } 7879 7880 if ( includeWidth ) { 7881 attrs.opacity = attrs.width = type; 7882 } 7883 7884 return attrs; 7885} 7886 7887function createTween( value, prop, animation ) { 7888 var tween, 7889 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 7890 index = 0, 7891 length = collection.length; 7892 for ( ; index < length; index++ ) { 7893 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 7894 7895 // We're done with this property 7896 return tween; 7897 } 7898 } 7899} 7900 7901function defaultPrefilter( elem, props, opts ) { 7902 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, 7903 isBox = "width" in props || "height" in props, 7904 anim = this, 7905 orig = {}, 7906 style = elem.style, 7907 hidden = elem.nodeType && isHiddenWithinTree( elem ), 7908 dataShow = dataPriv.get( elem, "fxshow" ); 7909 7910 // Queue-skipping animations hijack the fx hooks 7911 if ( !opts.queue ) { 7912 hooks = jQuery._queueHooks( elem, "fx" ); 7913 if ( hooks.unqueued == null ) { 7914 hooks.unqueued = 0; 7915 oldfire = hooks.empty.fire; 7916 hooks.empty.fire = function() { 7917 if ( !hooks.unqueued ) { 7918 oldfire(); 7919 } 7920 }; 7921 } 7922 hooks.unqueued++; 7923 7924 anim.always( function() { 7925 7926 // Ensure the complete handler is called before this completes 7927 anim.always( function() { 7928 hooks.unqueued--; 7929 if ( !jQuery.queue( elem, "fx" ).length ) { 7930 hooks.empty.fire(); 7931 } 7932 } ); 7933 } ); 7934 } 7935 7936 // Detect show/hide animations 7937 for ( prop in props ) { 7938 value = props[ prop ]; 7939 if ( rfxtypes.test( value ) ) { 7940 delete props[ prop ]; 7941 toggle = toggle || value === "toggle"; 7942 if ( value === ( hidden ? "hide" : "show" ) ) { 7943 7944 // Pretend to be hidden if this is a "show" and 7945 // there is still data from a stopped show/hide 7946 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 7947 hidden = true; 7948 7949 // Ignore all other no-op show/hide data 7950 } else { 7951 continue; 7952 } 7953 } 7954 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 7955 } 7956 } 7957 7958 // Bail out if this is a no-op like .hide().hide() 7959 propTween = !jQuery.isEmptyObject( props ); 7960 if ( !propTween && jQuery.isEmptyObject( orig ) ) { 7961 return; 7962 } 7963 7964 // Restrict "overflow" and "display" styles during box animations 7965 if ( isBox && elem.nodeType === 1 ) { 7966 7967 // Support: IE <=9 - 11, Edge 12 - 15 7968 // Record all 3 overflow attributes because IE does not infer the shorthand 7969 // from identically-valued overflowX and overflowY and Edge just mirrors 7970 // the overflowX value there. 7971 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 7972 7973 // Identify a display type, preferring old show/hide data over the CSS cascade 7974 restoreDisplay = dataShow && dataShow.display; 7975 if ( restoreDisplay == null ) { 7976 restoreDisplay = dataPriv.get( elem, "display" ); 7977 } 7978 display = jQuery.css( elem, "display" ); 7979 if ( display === "none" ) { 7980 if ( restoreDisplay ) { 7981 display = restoreDisplay; 7982 } else { 7983 7984 // Get nonempty value(s) by temporarily forcing visibility 7985 showHide( [ elem ], true ); 7986 restoreDisplay = elem.style.display || restoreDisplay; 7987 display = jQuery.css( elem, "display" ); 7988 showHide( [ elem ] ); 7989 } 7990 } 7991 7992 // Animate inline elements as inline-block 7993 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { 7994 if ( jQuery.css( elem, "float" ) === "none" ) { 7995 7996 // Restore the original display value at the end of pure show/hide animations 7997 if ( !propTween ) { 7998 anim.done( function() { 7999 style.display = restoreDisplay; 8000 } ); 8001 if ( restoreDisplay == null ) { 8002 display = style.display; 8003 restoreDisplay = display === "none" ? "" : display; 8004 } 8005 } 8006 style.display = "inline-block"; 8007 } 8008 } 8009 } 8010 8011 if ( opts.overflow ) { 8012 style.overflow = "hidden"; 8013 anim.always( function() { 8014 style.overflow = opts.overflow[ 0 ]; 8015 style.overflowX = opts.overflow[ 1 ]; 8016 style.overflowY = opts.overflow[ 2 ]; 8017 } ); 8018 } 8019 8020 // Implement show/hide animations 8021 propTween = false; 8022 for ( prop in orig ) { 8023 8024 // General show/hide setup for this element animation 8025 if ( !propTween ) { 8026 if ( dataShow ) { 8027 if ( "hidden" in dataShow ) { 8028 hidden = dataShow.hidden; 8029 } 8030 } else { 8031 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); 8032 } 8033 8034 // Store hidden/visible for toggle so `.stop().toggle()` "reverses" 8035 if ( toggle ) { 8036 dataShow.hidden = !hidden; 8037 } 8038 8039 // Show elements before animating them 8040 if ( hidden ) { 8041 showHide( [ elem ], true ); 8042 } 8043 8044 /* eslint-disable no-loop-func */ 8045 8046 anim.done( function() { 8047 8048 /* eslint-enable no-loop-func */ 8049 8050 // The final step of a "hide" animation is actually hiding the element 8051 if ( !hidden ) { 8052 showHide( [ elem ] ); 8053 } 8054 dataPriv.remove( elem, "fxshow" ); 8055 for ( prop in orig ) { 8056 jQuery.style( elem, prop, orig[ prop ] ); 8057 } 8058 } ); 8059 } 8060 8061 // Per-property setup 8062 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 8063 if ( !( prop in dataShow ) ) { 8064 dataShow[ prop ] = propTween.start; 8065 if ( hidden ) { 8066 propTween.end = propTween.start; 8067 propTween.start = 0; 8068 } 8069 } 8070 } 8071} 8072 8073function propFilter( props, specialEasing ) { 8074 var index, name, easing, value, hooks; 8075 8076 // camelCase, specialEasing and expand cssHook pass 8077 for ( index in props ) { 8078 name = camelCase( index ); 8079 easing = specialEasing[ name ]; 8080 value = props[ index ]; 8081 if ( Array.isArray( value ) ) { 8082 easing = value[ 1 ]; 8083 value = props[ index ] = value[ 0 ]; 8084 } 8085 8086 if ( index !== name ) { 8087 props[ name ] = value; 8088 delete props[ index ]; 8089 } 8090 8091 hooks = jQuery.cssHooks[ name ]; 8092 if ( hooks && "expand" in hooks ) { 8093 value = hooks.expand( value ); 8094 delete props[ name ]; 8095 8096 // Not quite $.extend, this won't overwrite existing keys. 8097 // Reusing 'index' because we have the correct "name" 8098 for ( index in value ) { 8099 if ( !( index in props ) ) { 8100 props[ index ] = value[ index ]; 8101 specialEasing[ index ] = easing; 8102 } 8103 } 8104 } else { 8105 specialEasing[ name ] = easing; 8106 } 8107 } 8108} 8109 8110function Animation( elem, properties, options ) { 8111 var result, 8112 stopped, 8113 index = 0, 8114 length = Animation.prefilters.length, 8115 deferred = jQuery.Deferred().always( function() { 8116 8117 // Don't match elem in the :animated selector 8118 delete tick.elem; 8119 } ), 8120 tick = function() { 8121 if ( stopped ) { 8122 return false; 8123 } 8124 var currentTime = fxNow || createFxNow(), 8125 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 8126 8127 // Support: Android 2.3 only 8128 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497) 8129 temp = remaining / animation.duration || 0, 8130 percent = 1 - temp, 8131 index = 0, 8132 length = animation.tweens.length; 8133 8134 for ( ; index < length; index++ ) { 8135 animation.tweens[ index ].run( percent ); 8136 } 8137 8138 deferred.notifyWith( elem, [ animation, percent, remaining ] ); 8139 8140 // If there's more to do, yield 8141 if ( percent < 1 && length ) { 8142 return remaining; 8143 } 8144 8145 // If this was an empty animation, synthesize a final progress notification 8146 if ( !length ) { 8147 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 8148 } 8149 8150 // Resolve the animation and report its conclusion 8151 deferred.resolveWith( elem, [ animation ] ); 8152 return false; 8153 }, 8154 animation = deferred.promise( { 8155 elem: elem, 8156 props: jQuery.extend( {}, properties ), 8157 opts: jQuery.extend( true, { 8158 specialEasing: {}, 8159 easing: jQuery.easing._default 8160 }, options ), 8161 originalProperties: properties, 8162 originalOptions: options, 8163 startTime: fxNow || createFxNow(), 8164 duration: options.duration, 8165 tweens: [], 8166 createTween: function( prop, end ) { 8167 var tween = jQuery.Tween( elem, animation.opts, prop, end, 8168 animation.opts.specialEasing[ prop ] || animation.opts.easing ); 8169 animation.tweens.push( tween ); 8170 return tween; 8171 }, 8172 stop: function( gotoEnd ) { 8173 var index = 0, 8174 8175 // If we are going to the end, we want to run all the tweens 8176 // otherwise we skip this part 8177 length = gotoEnd ? animation.tweens.length : 0; 8178 if ( stopped ) { 8179 return this; 8180 } 8181 stopped = true; 8182 for ( ; index < length; index++ ) { 8183 animation.tweens[ index ].run( 1 ); 8184 } 8185 8186 // Resolve when we played the last frame; otherwise, reject 8187 if ( gotoEnd ) { 8188 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 8189 deferred.resolveWith( elem, [ animation, gotoEnd ] ); 8190 } else { 8191 deferred.rejectWith( elem, [ animation, gotoEnd ] ); 8192 } 8193 return this; 8194 } 8195 } ), 8196 props = animation.props; 8197 8198 propFilter( props, animation.opts.specialEasing ); 8199 8200 for ( ; index < length; index++ ) { 8201 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 8202 if ( result ) { 8203 if ( isFunction( result.stop ) ) { 8204 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 8205 result.stop.bind( result ); 8206 } 8207 return result; 8208 } 8209 } 8210 8211 jQuery.map( props, createTween, animation ); 8212 8213 if ( isFunction( animation.opts.start ) ) { 8214 animation.opts.start.call( elem, animation ); 8215 } 8216 8217 // Attach callbacks from options 8218 animation 8219 .progress( animation.opts.progress ) 8220 .done( animation.opts.done, animation.opts.complete ) 8221 .fail( animation.opts.fail ) 8222 .always( animation.opts.always ); 8223 8224 jQuery.fx.timer( 8225 jQuery.extend( tick, { 8226 elem: elem, 8227 anim: animation, 8228 queue: animation.opts.queue 8229 } ) 8230 ); 8231 8232 return animation; 8233} 8234 8235jQuery.Animation = jQuery.extend( Animation, { 8236 8237 tweeners: { 8238 "*": [ function( prop, value ) { 8239 var tween = this.createTween( prop, value ); 8240 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 8241 return tween; 8242 } ] 8243 }, 8244 8245 tweener: function( props, callback ) { 8246 if ( isFunction( props ) ) { 8247 callback = props; 8248 props = [ "*" ]; 8249 } else { 8250 props = props.match( rnothtmlwhite ); 8251 } 8252 8253 var prop, 8254 index = 0, 8255 length = props.length; 8256 8257 for ( ; index < length; index++ ) { 8258 prop = props[ index ]; 8259 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 8260 Animation.tweeners[ prop ].unshift( callback ); 8261 } 8262 }, 8263 8264 prefilters: [ defaultPrefilter ], 8265 8266 prefilter: function( callback, prepend ) { 8267 if ( prepend ) { 8268 Animation.prefilters.unshift( callback ); 8269 } else { 8270 Animation.prefilters.push( callback ); 8271 } 8272 } 8273} ); 8274 8275jQuery.speed = function( speed, easing, fn ) { 8276 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 8277 complete: fn || !fn && easing || 8278 isFunction( speed ) && speed, 8279 duration: speed, 8280 easing: fn && easing || easing && !isFunction( easing ) && easing 8281 }; 8282 8283 // Go to the end state if fx are off 8284 if ( jQuery.fx.off ) { 8285 opt.duration = 0; 8286 8287 } else { 8288 if ( typeof opt.duration !== "number" ) { 8289 if ( opt.duration in jQuery.fx.speeds ) { 8290 opt.duration = jQuery.fx.speeds[ opt.duration ]; 8291 8292 } else { 8293 opt.duration = jQuery.fx.speeds._default; 8294 } 8295 } 8296 } 8297 8298 // Normalize opt.queue - true/undefined/null -> "fx" 8299 if ( opt.queue == null || opt.queue === true ) { 8300 opt.queue = "fx"; 8301 } 8302 8303 // Queueing 8304 opt.old = opt.complete; 8305 8306 opt.complete = function() { 8307 if ( isFunction( opt.old ) ) { 8308 opt.old.call( this ); 8309 } 8310 8311 if ( opt.queue ) { 8312 jQuery.dequeue( this, opt.queue ); 8313 } 8314 }; 8315 8316 return opt; 8317}; 8318 8319jQuery.fn.extend( { 8320 fadeTo: function( speed, to, easing, callback ) { 8321 8322 // Show any hidden elements after setting opacity to 0 8323 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() 8324 8325 // Animate to the value specified 8326 .end().animate( { opacity: to }, speed, easing, callback ); 8327 }, 8328 animate: function( prop, speed, easing, callback ) { 8329 var empty = jQuery.isEmptyObject( prop ), 8330 optall = jQuery.speed( speed, easing, callback ), 8331 doAnimation = function() { 8332 8333 // Operate on a copy of prop so per-property easing won't be lost 8334 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 8335 8336 // Empty animations, or finishing resolves immediately 8337 if ( empty || dataPriv.get( this, "finish" ) ) { 8338 anim.stop( true ); 8339 } 8340 }; 8341 8342 doAnimation.finish = doAnimation; 8343 8344 return empty || optall.queue === false ? 8345 this.each( doAnimation ) : 8346 this.queue( optall.queue, doAnimation ); 8347 }, 8348 stop: function( type, clearQueue, gotoEnd ) { 8349 var stopQueue = function( hooks ) { 8350 var stop = hooks.stop; 8351 delete hooks.stop; 8352 stop( gotoEnd ); 8353 }; 8354 8355 if ( typeof type !== "string" ) { 8356 gotoEnd = clearQueue; 8357 clearQueue = type; 8358 type = undefined; 8359 } 8360 if ( clearQueue ) { 8361 this.queue( type || "fx", [] ); 8362 } 8363 8364 return this.each( function() { 8365 var dequeue = true, 8366 index = type != null && type + "queueHooks", 8367 timers = jQuery.timers, 8368 data = dataPriv.get( this ); 8369 8370 if ( index ) { 8371 if ( data[ index ] && data[ index ].stop ) { 8372 stopQueue( data[ index ] ); 8373 } 8374 } else { 8375 for ( index in data ) { 8376 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 8377 stopQueue( data[ index ] ); 8378 } 8379 } 8380 } 8381 8382 for ( index = timers.length; index--; ) { 8383 if ( timers[ index ].elem === this && 8384 ( type == null || timers[ index ].queue === type ) ) { 8385 8386 timers[ index ].anim.stop( gotoEnd ); 8387 dequeue = false; 8388 timers.splice( index, 1 ); 8389 } 8390 } 8391 8392 // Start the next in the queue if the last step wasn't forced. 8393 // Timers currently will call their complete callbacks, which 8394 // will dequeue but only if they were gotoEnd. 8395 if ( dequeue || !gotoEnd ) { 8396 jQuery.dequeue( this, type ); 8397 } 8398 } ); 8399 }, 8400 finish: function( type ) { 8401 if ( type !== false ) { 8402 type = type || "fx"; 8403 } 8404 return this.each( function() { 8405 var index, 8406 data = dataPriv.get( this ), 8407 queue = data[ type + "queue" ], 8408 hooks = data[ type + "queueHooks" ], 8409 timers = jQuery.timers, 8410 length = queue ? queue.length : 0; 8411 8412 // Enable finishing flag on private data 8413 data.finish = true; 8414 8415 // Empty the queue first 8416 jQuery.queue( this, type, [] ); 8417 8418 if ( hooks && hooks.stop ) { 8419 hooks.stop.call( this, true ); 8420 } 8421 8422 // Look for any active animations, and finish them 8423 for ( index = timers.length; index--; ) { 8424 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 8425 timers[ index ].anim.stop( true ); 8426 timers.splice( index, 1 ); 8427 } 8428 } 8429 8430 // Look for any animations in the old queue and finish them 8431 for ( index = 0; index < length; index++ ) { 8432 if ( queue[ index ] && queue[ index ].finish ) { 8433 queue[ index ].finish.call( this ); 8434 } 8435 } 8436 8437 // Turn off finishing flag 8438 delete data.finish; 8439 } ); 8440 } 8441} ); 8442 8443jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { 8444 var cssFn = jQuery.fn[ name ]; 8445 jQuery.fn[ name ] = function( speed, easing, callback ) { 8446 return speed == null || typeof speed === "boolean" ? 8447 cssFn.apply( this, arguments ) : 8448 this.animate( genFx( name, true ), speed, easing, callback ); 8449 }; 8450} ); 8451 8452// Generate shortcuts for custom animations 8453jQuery.each( { 8454 slideDown: genFx( "show" ), 8455 slideUp: genFx( "hide" ), 8456 slideToggle: genFx( "toggle" ), 8457 fadeIn: { opacity: "show" }, 8458 fadeOut: { opacity: "hide" }, 8459 fadeToggle: { opacity: "toggle" } 8460}, function( name, props ) { 8461 jQuery.fn[ name ] = function( speed, easing, callback ) { 8462 return this.animate( props, speed, easing, callback ); 8463 }; 8464} ); 8465 8466jQuery.timers = []; 8467jQuery.fx.tick = function() { 8468 var timer, 8469 i = 0, 8470 timers = jQuery.timers; 8471 8472 fxNow = Date.now(); 8473 8474 for ( ; i < timers.length; i++ ) { 8475 timer = timers[ i ]; 8476 8477 // Run the timer and safely remove it when done (allowing for external removal) 8478 if ( !timer() && timers[ i ] === timer ) { 8479 timers.splice( i--, 1 ); 8480 } 8481 } 8482 8483 if ( !timers.length ) { 8484 jQuery.fx.stop(); 8485 } 8486 fxNow = undefined; 8487}; 8488 8489jQuery.fx.timer = function( timer ) { 8490 jQuery.timers.push( timer ); 8491 jQuery.fx.start(); 8492}; 8493 8494jQuery.fx.interval = 13; 8495jQuery.fx.start = function() { 8496 if ( inProgress ) { 8497 return; 8498 } 8499 8500 inProgress = true; 8501 schedule(); 8502}; 8503 8504jQuery.fx.stop = function() { 8505 inProgress = null; 8506}; 8507 8508jQuery.fx.speeds = { 8509 slow: 600, 8510 fast: 200, 8511 8512 // Default speed 8513 _default: 400 8514}; 8515 8516 8517// Based off of the plugin by Clint Helfers, with permission. 8518jQuery.fn.delay = function( time, type ) { 8519 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 8520 type = type || "fx"; 8521 8522 return this.queue( type, function( next, hooks ) { 8523 var timeout = window.setTimeout( next, time ); 8524 hooks.stop = function() { 8525 window.clearTimeout( timeout ); 8526 }; 8527 } ); 8528}; 8529 8530 8531( function() { 8532 var input = document.createElement( "input" ), 8533 select = document.createElement( "select" ), 8534 opt = select.appendChild( document.createElement( "option" ) ); 8535 8536 input.type = "checkbox"; 8537 8538 // Support: Android <=4.3 only 8539 // Default value for a checkbox should be "on" 8540 support.checkOn = input.value !== ""; 8541 8542 // Support: IE <=11 only 8543 // Must access selectedIndex to make default options select 8544 support.optSelected = opt.selected; 8545 8546 // Support: IE <=11 only 8547 // An input loses its value after becoming a radio 8548 input = document.createElement( "input" ); 8549 input.value = "t"; 8550 input.type = "radio"; 8551 support.radioValue = input.value === "t"; 8552} )(); 8553 8554 8555var boolHook, 8556 attrHandle = jQuery.expr.attrHandle; 8557 8558jQuery.fn.extend( { 8559 attr: function( name, value ) { 8560 return access( this, jQuery.attr, name, value, arguments.length > 1 ); 8561 }, 8562 8563 removeAttr: function( name ) { 8564 return this.each( function() { 8565 jQuery.removeAttr( this, name ); 8566 } ); 8567 } 8568} ); 8569 8570jQuery.extend( { 8571 attr: function( elem, name, value ) { 8572 var ret, hooks, 8573 nType = elem.nodeType; 8574 8575 // Don't get/set attributes on text, comment and attribute nodes 8576 if ( nType === 3 || nType === 8 || nType === 2 ) { 8577 return; 8578 } 8579 8580 // Fallback to prop when attributes are not supported 8581 if ( typeof elem.getAttribute === "undefined" ) { 8582 return jQuery.prop( elem, name, value ); 8583 } 8584 8585 // Attribute hooks are determined by the lowercase version 8586 // Grab necessary hook if one is defined 8587 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 8588 hooks = jQuery.attrHooks[ name.toLowerCase() ] || 8589 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 8590 } 8591 8592 if ( value !== undefined ) { 8593 if ( value === null ) { 8594 jQuery.removeAttr( elem, name ); 8595 return; 8596 } 8597 8598 if ( hooks && "set" in hooks && 8599 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 8600 return ret; 8601 } 8602 8603 elem.setAttribute( name, value + "" ); 8604 return value; 8605 } 8606 8607 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 8608 return ret; 8609 } 8610 8611 ret = jQuery.find.attr( elem, name ); 8612 8613 // Non-existent attributes return null, we normalize to undefined 8614 return ret == null ? undefined : ret; 8615 }, 8616 8617 attrHooks: { 8618 type: { 8619 set: function( elem, value ) { 8620 if ( !support.radioValue && value === "radio" && 8621 nodeName( elem, "input" ) ) { 8622 var val = elem.value; 8623 elem.setAttribute( "type", value ); 8624 if ( val ) { 8625 elem.value = val; 8626 } 8627 return value; 8628 } 8629 } 8630 } 8631 }, 8632 8633 removeAttr: function( elem, value ) { 8634 var name, 8635 i = 0, 8636 8637 // Attribute names can contain non-HTML whitespace characters 8638 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 8639 attrNames = value && value.match( rnothtmlwhite ); 8640 8641 if ( attrNames && elem.nodeType === 1 ) { 8642 while ( ( name = attrNames[ i++ ] ) ) { 8643 elem.removeAttribute( name ); 8644 } 8645 } 8646 } 8647} ); 8648 8649// Hooks for boolean attributes 8650boolHook = { 8651 set: function( elem, value, name ) { 8652 if ( value === false ) { 8653 8654 // Remove boolean attributes when set to false 8655 jQuery.removeAttr( elem, name ); 8656 } else { 8657 elem.setAttribute( name, name ); 8658 } 8659 return name; 8660 } 8661}; 8662 8663jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { 8664 var getter = attrHandle[ name ] || jQuery.find.attr; 8665 8666 attrHandle[ name ] = function( elem, name, isXML ) { 8667 var ret, handle, 8668 lowercaseName = name.toLowerCase(); 8669 8670 if ( !isXML ) { 8671 8672 // Avoid an infinite loop by temporarily removing this function from the getter 8673 handle = attrHandle[ lowercaseName ]; 8674 attrHandle[ lowercaseName ] = ret; 8675 ret = getter( elem, name, isXML ) != null ? 8676 lowercaseName : 8677 null; 8678 attrHandle[ lowercaseName ] = handle; 8679 } 8680 return ret; 8681 }; 8682} ); 8683 8684 8685 8686 8687var rfocusable = /^(?:input|select|textarea|button)$/i, 8688 rclickable = /^(?:a|area)$/i; 8689 8690jQuery.fn.extend( { 8691 prop: function( name, value ) { 8692 return access( this, jQuery.prop, name, value, arguments.length > 1 ); 8693 }, 8694 8695 removeProp: function( name ) { 8696 return this.each( function() { 8697 delete this[ jQuery.propFix[ name ] || name ]; 8698 } ); 8699 } 8700} ); 8701 8702jQuery.extend( { 8703 prop: function( elem, name, value ) { 8704 var ret, hooks, 8705 nType = elem.nodeType; 8706 8707 // Don't get/set properties on text, comment and attribute nodes 8708 if ( nType === 3 || nType === 8 || nType === 2 ) { 8709 return; 8710 } 8711 8712 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 8713 8714 // Fix name and attach hooks 8715 name = jQuery.propFix[ name ] || name; 8716 hooks = jQuery.propHooks[ name ]; 8717 } 8718 8719 if ( value !== undefined ) { 8720 if ( hooks && "set" in hooks && 8721 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 8722 return ret; 8723 } 8724 8725 return ( elem[ name ] = value ); 8726 } 8727 8728 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 8729 return ret; 8730 } 8731 8732 return elem[ name ]; 8733 }, 8734 8735 propHooks: { 8736 tabIndex: { 8737 get: function( elem ) { 8738 8739 // Support: IE <=9 - 11 only 8740 // elem.tabIndex doesn't always return the 8741 // correct value when it hasn't been explicitly set 8742 // Use proper attribute retrieval (trac-12072) 8743 var tabindex = jQuery.find.attr( elem, "tabindex" ); 8744 8745 if ( tabindex ) { 8746 return parseInt( tabindex, 10 ); 8747 } 8748 8749 if ( 8750 rfocusable.test( elem.nodeName ) || 8751 rclickable.test( elem.nodeName ) && 8752 elem.href 8753 ) { 8754 return 0; 8755 } 8756 8757 return -1; 8758 } 8759 } 8760 }, 8761 8762 propFix: { 8763 "for": "htmlFor", 8764 "class": "className" 8765 } 8766} ); 8767 8768// Support: IE <=11 only 8769// Accessing the selectedIndex property 8770// forces the browser to respect setting selected 8771// on the option 8772// The getter ensures a default option is selected 8773// when in an optgroup 8774// eslint rule "no-unused-expressions" is disabled for this code 8775// since it considers such accessions noop 8776if ( !support.optSelected ) { 8777 jQuery.propHooks.selected = { 8778 get: function( elem ) { 8779 8780 /* eslint no-unused-expressions: "off" */ 8781 8782 var parent = elem.parentNode; 8783 if ( parent && parent.parentNode ) { 8784 parent.parentNode.selectedIndex; 8785 } 8786 return null; 8787 }, 8788 set: function( elem ) { 8789 8790 /* eslint no-unused-expressions: "off" */ 8791 8792 var parent = elem.parentNode; 8793 if ( parent ) { 8794 parent.selectedIndex; 8795 8796 if ( parent.parentNode ) { 8797 parent.parentNode.selectedIndex; 8798 } 8799 } 8800 } 8801 }; 8802} 8803 8804jQuery.each( [ 8805 "tabIndex", 8806 "readOnly", 8807 "maxLength", 8808 "cellSpacing", 8809 "cellPadding", 8810 "rowSpan", 8811 "colSpan", 8812 "useMap", 8813 "frameBorder", 8814 "contentEditable" 8815], function() { 8816 jQuery.propFix[ this.toLowerCase() ] = this; 8817} ); 8818 8819 8820 8821 8822 // Strip and collapse whitespace according to HTML spec 8823 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace 8824 function stripAndCollapse( value ) { 8825 var tokens = value.match( rnothtmlwhite ) || []; 8826 return tokens.join( " " ); 8827 } 8828 8829 8830function getClass( elem ) { 8831 return elem.getAttribute && elem.getAttribute( "class" ) || ""; 8832} 8833 8834function classesToArray( value ) { 8835 if ( Array.isArray( value ) ) { 8836 return value; 8837 } 8838 if ( typeof value === "string" ) { 8839 return value.match( rnothtmlwhite ) || []; 8840 } 8841 return []; 8842} 8843 8844jQuery.fn.extend( { 8845 addClass: function( value ) { 8846 var classNames, cur, curValue, className, i, finalValue; 8847 8848 if ( isFunction( value ) ) { 8849 return this.each( function( j ) { 8850 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 8851 } ); 8852 } 8853 8854 classNames = classesToArray( value ); 8855 8856 if ( classNames.length ) { 8857 return this.each( function() { 8858 curValue = getClass( this ); 8859 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 8860 8861 if ( cur ) { 8862 for ( i = 0; i < classNames.length; i++ ) { 8863 className = classNames[ i ]; 8864 if ( cur.indexOf( " " + className + " " ) < 0 ) { 8865 cur += className + " "; 8866 } 8867 } 8868 8869 // Only assign if different to avoid unneeded rendering. 8870 finalValue = stripAndCollapse( cur ); 8871 if ( curValue !== finalValue ) { 8872 this.setAttribute( "class", finalValue ); 8873 } 8874 } 8875 } ); 8876 } 8877 8878 return this; 8879 }, 8880 8881 removeClass: function( value ) { 8882 var classNames, cur, curValue, className, i, finalValue; 8883 8884 if ( isFunction( value ) ) { 8885 return this.each( function( j ) { 8886 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 8887 } ); 8888 } 8889 8890 if ( !arguments.length ) { 8891 return this.attr( "class", "" ); 8892 } 8893 8894 classNames = classesToArray( value ); 8895 8896 if ( classNames.length ) { 8897 return this.each( function() { 8898 curValue = getClass( this ); 8899 8900 // This expression is here for better compressibility (see addClass) 8901 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); 8902 8903 if ( cur ) { 8904 for ( i = 0; i < classNames.length; i++ ) { 8905 className = classNames[ i ]; 8906 8907 // Remove *all* instances 8908 while ( cur.indexOf( " " + className + " " ) > -1 ) { 8909 cur = cur.replace( " " + className + " ", " " ); 8910 } 8911 } 8912 8913 // Only assign if different to avoid unneeded rendering. 8914 finalValue = stripAndCollapse( cur ); 8915 if ( curValue !== finalValue ) { 8916 this.setAttribute( "class", finalValue ); 8917 } 8918 } 8919 } ); 8920 } 8921 8922 return this; 8923 }, 8924 8925 toggleClass: function( value, stateVal ) { 8926 var classNames, className, i, self, 8927 type = typeof value, 8928 isValidValue = type === "string" || Array.isArray( value ); 8929 8930 if ( isFunction( value ) ) { 8931 return this.each( function( i ) { 8932 jQuery( this ).toggleClass( 8933 value.call( this, i, getClass( this ), stateVal ), 8934 stateVal 8935 ); 8936 } ); 8937 } 8938 8939 if ( typeof stateVal === "boolean" && isValidValue ) { 8940 return stateVal ? this.addClass( value ) : this.removeClass( value ); 8941 } 8942 8943 classNames = classesToArray( value ); 8944 8945 return this.each( function() { 8946 if ( isValidValue ) { 8947 8948 // Toggle individual class names 8949 self = jQuery( this ); 8950 8951 for ( i = 0; i < classNames.length; i++ ) { 8952 className = classNames[ i ]; 8953 8954 // Check each className given, space separated list 8955 if ( self.hasClass( className ) ) { 8956 self.removeClass( className ); 8957 } else { 8958 self.addClass( className ); 8959 } 8960 } 8961 8962 // Toggle whole class name 8963 } else if ( value === undefined || type === "boolean" ) { 8964 className = getClass( this ); 8965 if ( className ) { 8966 8967 // Store className if set 8968 dataPriv.set( this, "__className__", className ); 8969 } 8970 8971 // If the element has a class name or if we're passed `false`, 8972 // then remove the whole classname (if there was one, the above saved it). 8973 // Otherwise bring back whatever was previously saved (if anything), 8974 // falling back to the empty string if nothing was stored. 8975 if ( this.setAttribute ) { 8976 this.setAttribute( "class", 8977 className || value === false ? 8978 "" : 8979 dataPriv.get( this, "__className__" ) || "" 8980 ); 8981 } 8982 } 8983 } ); 8984 }, 8985 8986 hasClass: function( selector ) { 8987 var className, elem, 8988 i = 0; 8989 8990 className = " " + selector + " "; 8991 while ( ( elem = this[ i++ ] ) ) { 8992 if ( elem.nodeType === 1 && 8993 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { 8994 return true; 8995 } 8996 } 8997 8998 return false;
vendor: 1,385 bytes, lines 8999-9068
8999 } 9000} ); 9001 9002 9003 9004 9005var rreturn = /\r/g; 9006 9007jQuery.fn.extend( { 9008 val: function( value ) { 9009 var hooks, ret, valueIsFunction, 9010 elem = this[ 0 ]; 9011 9012 if ( !arguments.length ) { 9013 if ( elem ) { 9014 hooks = jQuery.valHooks[ elem.type ] || 9015 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 9016 9017 if ( hooks && 9018 "get" in hooks && 9019 ( ret = hooks.get( elem, "value" ) ) !== undefined 9020 ) { 9021 return ret; 9022 } 9023 9024 ret = elem.value; 9025 9026 // Handle most common string cases 9027 if ( typeof ret === "string" ) { 9028 return ret.replace( rreturn, "" ); 9029 } 9030 9031 // Handle cases where value is null/undef or number 9032 return ret == null ? "" : ret; 9033 } 9034 9035 return; 9036 } 9037 9038 valueIsFunction = isFunction( value ); 9039 9040 return this.each( function( i ) { 9041 var val; 9042 9043 if ( this.nodeType !== 1 ) { 9044 return; 9045 } 9046 9047 if ( valueIsFunction ) { 9048 val = value.call( this, i, jQuery( this ).val() ); 9049 } else { 9050 val = value; 9051 } 9052 9053 // Treat null/undefined as ""; convert numbers to string 9054 if ( val == null ) { 9055 val = ""; 9056 9057 } else if ( typeof val === "number" ) { 9058 val += ""; 9059 9060 } else if ( Array.isArray( val ) ) { 9061 val = jQuery.map( val, function( value ) { 9062 return value == null ? "" : value + ""; 9063 } ); 9064 } 9065 9066 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 9067 9068 // If set returns undefined, fall back to normal setting
vendor: 43,419 bytes, lines 9069-10758
9069 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 9070 this.value = val; 9071 } 9072 } ); 9073 } 9074} ); 9075 9076jQuery.extend( { 9077 valHooks: { 9078 option: { 9079 get: function( elem ) { 9080 9081 var val = jQuery.find.attr( elem, "value" ); 9082 return val != null ? 9083 val : 9084 9085 // Support: IE <=10 - 11 only 9086 // option.text throws exceptions (trac-14686, trac-14858) 9087 // Strip and collapse whitespace 9088 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 9089 stripAndCollapse( jQuery.text( elem ) ); 9090 } 9091 }, 9092 select: { 9093 get: function( elem ) { 9094 var value, option, i, 9095 options = elem.options, 9096 index = elem.selectedIndex, 9097 one = elem.type === "select-one", 9098 values = one ? null : [], 9099 max = one ? index + 1 : options.length; 9100 9101 if ( index < 0 ) { 9102 i = max; 9103 9104 } else { 9105 i = one ? index : 0; 9106 } 9107 9108 // Loop through all the selected options 9109 for ( ; i < max; i++ ) { 9110 option = options[ i ]; 9111 9112 // Support: IE <=9 only 9113 // IE8-9 doesn't update selected after form reset (trac-2551) 9114 if ( ( option.selected || i === index ) && 9115 9116 // Don't return options that are disabled or in a disabled optgroup 9117 !option.disabled && 9118 ( !option.parentNode.disabled || 9119 !nodeName( option.parentNode, "optgroup" ) ) ) { 9120 9121 // Get the specific value for the option 9122 value = jQuery( option ).val(); 9123 9124 // We don't need an array for one selects 9125 if ( one ) { 9126 return value; 9127 } 9128 9129 // Multi-Selects return an array 9130 values.push( value ); 9131 } 9132 } 9133 9134 return values; 9135 }, 9136 9137 set: function( elem, value ) { 9138 var optionSet, option, 9139 options = elem.options, 9140 values = jQuery.makeArray( value ), 9141 i = options.length; 9142 9143 while ( i-- ) { 9144 option = options[ i ]; 9145 9146 /* eslint-disable no-cond-assign */ 9147 9148 if ( option.selected = 9149 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 9150 ) { 9151 optionSet = true; 9152 } 9153 9154 /* eslint-enable no-cond-assign */ 9155 } 9156 9157 // Force browsers to behave consistently when non-matching value is set 9158 if ( !optionSet ) { 9159 elem.selectedIndex = -1; 9160 } 9161 return values; 9162 } 9163 } 9164 } 9165} ); 9166 9167// Radios and checkboxes getter/setter 9168jQuery.each( [ "radio", "checkbox" ], function() { 9169 jQuery.valHooks[ this ] = { 9170 set: function( elem, value ) { 9171 if ( Array.isArray( value ) ) { 9172 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 9173 } 9174 } 9175 }; 9176 if ( !support.checkOn ) { 9177 jQuery.valHooks[ this ].get = function( elem ) { 9178 return elem.getAttribute( "value" ) === null ? "on" : elem.value; 9179 }; 9180 } 9181} ); 9182 9183 9184 9185 9186// Return jQuery for attributes-only inclusion 9187var location = window.location; 9188 9189var nonce = { guid: Date.now() }; 9190 9191var rquery = ( /\?/ ); 9192 9193 9194 9195// Cross-browser xml parsing 9196jQuery.parseXML = function( data ) { 9197 var xml, parserErrorElem; 9198 if ( !data || typeof data !== "string" ) { 9199 return null; 9200 } 9201 9202 // Support: IE 9 - 11 only 9203 // IE throws on parseFromString with invalid input. 9204 try { 9205 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 9206 } catch ( e ) {} 9207 9208 parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; 9209 if ( !xml || parserErrorElem ) { 9210 jQuery.error( "Invalid XML: " + ( 9211 parserErrorElem ? 9212 jQuery.map( parserErrorElem.childNodes, function( el ) { 9213 return el.textContent; 9214 } ).join( "\n" ) : 9215 data 9216 ) ); 9217 } 9218 return xml; 9219}; 9220 9221 9222var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, 9223 stopPropagationCallback = function( e ) { 9224 e.stopPropagation(); 9225 }; 9226 9227jQuery.extend( jQuery.event, { 9228 9229 trigger: function( event, data, elem, onlyHandlers ) { 9230 9231 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, 9232 eventPath = [ elem || document ], 9233 type = hasOwn.call( event, "type" ) ? event.type : event, 9234 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 9235 9236 cur = lastElement = tmp = elem = elem || document; 9237 9238 // Don't do events on text and comment nodes 9239 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 9240 return; 9241 } 9242 9243 // focus/blur morphs to focusin/out; ensure we're not firing them right now 9244 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 9245 return; 9246 } 9247 9248 if ( type.indexOf( "." ) > -1 ) { 9249 9250 // Namespaced trigger; create a regexp to match event type in handle() 9251 namespaces = type.split( "." ); 9252 type = namespaces.shift(); 9253 namespaces.sort(); 9254 } 9255 ontype = type.indexOf( ":" ) < 0 && "on" + type; 9256 9257 // Caller can pass in a jQuery.Event object, Object, or just an event type string 9258 event = event[ jQuery.expando ] ? 9259 event : 9260 new jQuery.Event( type, typeof event === "object" && event ); 9261 9262 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 9263 event.isTrigger = onlyHandlers ? 2 : 3; 9264 event.namespace = namespaces.join( "." ); 9265 event.rnamespace = event.namespace ? 9266 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 9267 null; 9268 9269 // Clean up the event in case it is being reused 9270 event.result = undefined; 9271 if ( !event.target ) { 9272 event.target = elem; 9273 } 9274 9275 // Clone any incoming data and prepend the event, creating the handler arg list 9276 data = data == null ? 9277 [ event ] : 9278 jQuery.makeArray( data, [ event ] ); 9279 9280 // Allow special events to draw outside the lines 9281 special = jQuery.event.special[ type ] || {}; 9282 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 9283 return; 9284 } 9285 9286 // Determine event propagation path in advance, per W3C events spec (trac-9951) 9287 // Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724) 9288 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { 9289 9290 bubbleType = special.delegateType || type; 9291 if ( !rfocusMorph.test( bubbleType + type ) ) { 9292 cur = cur.parentNode; 9293 } 9294 for ( ; cur; cur = cur.parentNode ) { 9295 eventPath.push( cur ); 9296 tmp = cur; 9297 } 9298 9299 // Only add window if we got to document (e.g., not plain obj or detached DOM) 9300 if ( tmp === ( elem.ownerDocument || document ) ) { 9301 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 9302 } 9303 } 9304 9305 // Fire handlers on the event path 9306 i = 0; 9307 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 9308 lastElement = cur; 9309 event.type = i > 1 ? 9310 bubbleType : 9311 special.bindType || type; 9312 9313 // jQuery handler 9314 handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] && 9315 dataPriv.get( cur, "handle" ); 9316 if ( handle ) { 9317 handle.apply( cur, data ); 9318 } 9319 9320 // Native handler 9321 handle = ontype && cur[ ontype ]; 9322 if ( handle && handle.apply && acceptData( cur ) ) { 9323 event.result = handle.apply( cur, data ); 9324 if ( event.result === false ) { 9325 event.preventDefault(); 9326 } 9327 } 9328 } 9329 event.type = type; 9330 9331 // If nobody prevented the default action, do it now 9332 if ( !onlyHandlers && !event.isDefaultPrevented() ) { 9333 9334 if ( ( !special._default || 9335 special._default.apply( eventPath.pop(), data ) === false ) && 9336 acceptData( elem ) ) { 9337 9338 // Call a native DOM method on the target with the same name as the event. 9339 // Don't do default actions on window, that's where global variables be (trac-6170) 9340 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { 9341 9342 // Don't re-trigger an onFOO event when we call its FOO() method 9343 tmp = elem[ ontype ]; 9344 9345 if ( tmp ) { 9346 elem[ ontype ] = null; 9347 } 9348 9349 // Prevent re-triggering of the same event, since we already bubbled it above 9350 jQuery.event.triggered = type; 9351 9352 if ( event.isPropagationStopped() ) { 9353 lastElement.addEventListener( type, stopPropagationCallback ); 9354 } 9355 9356 elem[ type ](); 9357 9358 if ( event.isPropagationStopped() ) { 9359 lastElement.removeEventListener( type, stopPropagationCallback ); 9360 } 9361 9362 jQuery.event.triggered = undefined; 9363 9364 if ( tmp ) { 9365 elem[ ontype ] = tmp; 9366 } 9367 } 9368 } 9369 } 9370 9371 return event.result; 9372 }, 9373 9374 // Piggyback on a donor event to simulate a different one 9375 // Used only for `focus(in | out)` events 9376 simulate: function( type, elem, event ) { 9377 var e = jQuery.extend( 9378 new jQuery.Event(), 9379 event, 9380 { 9381 type: type, 9382 isSimulated: true 9383 } 9384 ); 9385 9386 jQuery.event.trigger( e, null, elem ); 9387 } 9388 9389} ); 9390 9391jQuery.fn.extend( { 9392 9393 trigger: function( type, data ) { 9394 return this.each( function() { 9395 jQuery.event.trigger( type, data, this ); 9396 } ); 9397 }, 9398 triggerHandler: function( type, data ) { 9399 var elem = this[ 0 ]; 9400 if ( elem ) { 9401 return jQuery.event.trigger( type, data, elem, true ); 9402 } 9403 } 9404} ); 9405 9406 9407var 9408 rbracket = /\[\]$/, 9409 rCRLF = /\r?\n/g, 9410 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 9411 rsubmittable = /^(?:input|select|textarea|keygen)/i; 9412 9413function buildParams( prefix, obj, traditional, add ) { 9414 var name; 9415 9416 if ( Array.isArray( obj ) ) { 9417 9418 // Serialize array item. 9419 jQuery.each( obj, function( i, v ) { 9420 if ( traditional || rbracket.test( prefix ) ) { 9421 9422 // Treat each array item as a scalar. 9423 add( prefix, v ); 9424 9425 } else { 9426 9427 // Item is non-scalar (array or object), encode its numeric index. 9428 buildParams( 9429 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 9430 v, 9431 traditional, 9432 add 9433 ); 9434 } 9435 } ); 9436 9437 } else if ( !traditional && toType( obj ) === "object" ) { 9438 9439 // Serialize object item. 9440 for ( name in obj ) { 9441 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 9442 } 9443 9444 } else { 9445 9446 // Serialize scalar item. 9447 add( prefix, obj ); 9448 } 9449} 9450 9451// Serialize an array of form elements or a set of 9452// key/values into a query string 9453jQuery.param = function( a, traditional ) { 9454 var prefix, 9455 s = [], 9456 add = function( key, valueOrFunction ) { 9457 9458 // If value is a function, invoke it and use its return value 9459 var value = isFunction( valueOrFunction ) ? 9460 valueOrFunction() : 9461 valueOrFunction; 9462 9463 s[ s.length ] = encodeURIComponent( key ) + "=" + 9464 encodeURIComponent( value == null ? "" : value ); 9465 }; 9466 9467 if ( a == null ) { 9468 return ""; 9469 } 9470 9471 // If an array was passed in, assume that it is an array of form elements. 9472 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 9473 9474 // Serialize the form elements 9475 jQuery.each( a, function() { 9476 add( this.name, this.value ); 9477 } ); 9478 9479 } else { 9480 9481 // If traditional, encode the "old" way (the way 1.3.2 or older 9482 // did it), otherwise encode params recursively. 9483 for ( prefix in a ) { 9484 buildParams( prefix, a[ prefix ], traditional, add ); 9485 } 9486 } 9487 9488 // Return the resulting serialization 9489 return s.join( "&" ); 9490}; 9491 9492jQuery.fn.extend( { 9493 serialize: function() { 9494 return jQuery.param( this.serializeArray() ); 9495 }, 9496 serializeArray: function() { 9497 return this.map( function() { 9498 9499 // Can add propHook for "elements" to filter or add form elements 9500 var elements = jQuery.prop( this, "elements" ); 9501 return elements ? jQuery.makeArray( elements ) : this; 9502 } ).filter( function() { 9503 var type = this.type; 9504 9505 // Use .is( ":disabled" ) so that fieldset[disabled] works 9506 return this.name && !jQuery( this ).is( ":disabled" ) && 9507 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 9508 ( this.checked || !rcheckableType.test( type ) ); 9509 } ).map( function( _i, elem ) { 9510 var val = jQuery( this ).val(); 9511 9512 if ( val == null ) { 9513 return null; 9514 } 9515 9516 if ( Array.isArray( val ) ) { 9517 return jQuery.map( val, function( val ) { 9518 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 9519 } ); 9520 } 9521 9522 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 9523 } ).get(); 9524 } 9525} ); 9526 9527 9528var 9529 r20 = /%20/g, 9530 rhash = /#.*$/, 9531 rantiCache = /([?&])_=[^&]*/, 9532 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, 9533 9534 // trac-7653, trac-8125, trac-8152: local protocol detection 9535 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 9536 rnoContent = /^(?:GET|HEAD)$/, 9537 rprotocol = /^\/\//, 9538 9539 /* Prefilters 9540 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 9541 * 2) These are called: 9542 * - BEFORE asking for a transport 9543 * - AFTER param serialization (s.data is a string if s.processData is true) 9544 * 3) key is the dataType 9545 * 4) the catchall symbol "*" can be used 9546 * 5) execution will start with transport dataType and THEN continue down to "*" if needed 9547 */ 9548 prefilters = {}, 9549 9550 /* Transports bindings 9551 * 1) key is the dataType 9552 * 2) the catchall symbol "*" can be used 9553 * 3) selection will start with transport dataType and THEN go to "*" if needed 9554 */ 9555 transports = {}, 9556 9557 // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression 9558 allTypes = "*/".concat( "*" ), 9559 9560 // Anchor tag for parsing the document origin 9561 originAnchor = document.createElement( "a" ); 9562 9563originAnchor.href = location.href; 9564 9565// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 9566function addToPrefiltersOrTransports( structure ) { 9567 9568 // dataTypeExpression is optional and defaults to "*" 9569 return function( dataTypeExpression, func ) { 9570 9571 if ( typeof dataTypeExpression !== "string" ) { 9572 func = dataTypeExpression; 9573 dataTypeExpression = "*"; 9574 } 9575 9576 var dataType, 9577 i = 0, 9578 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; 9579 9580 if ( isFunction( func ) ) { 9581 9582 // For each dataType in the dataTypeExpression 9583 while ( ( dataType = dataTypes[ i++ ] ) ) { 9584 9585 // Prepend if requested 9586 if ( dataType[ 0 ] === "+" ) { 9587 dataType = dataType.slice( 1 ) || "*"; 9588 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 9589 9590 // Otherwise append 9591 } else { 9592 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 9593 } 9594 } 9595 } 9596 }; 9597} 9598 9599// Base inspection function for prefilters and transports 9600function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 9601 9602 var inspected = {}, 9603 seekingTransport = ( structure === transports ); 9604 9605 function inspect( dataType ) { 9606 var selected; 9607 inspected[ dataType ] = true; 9608 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 9609 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 9610 if ( typeof dataTypeOrTransport === "string" && 9611 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 9612 9613 options.dataTypes.unshift( dataTypeOrTransport ); 9614 inspect( dataTypeOrTransport ); 9615 return false; 9616 } else if ( seekingTransport ) { 9617 return !( selected = dataTypeOrTransport ); 9618 } 9619 } ); 9620 return selected; 9621 } 9622 9623 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 9624} 9625 9626// A special extend for ajax options 9627// that takes "flat" options (not to be deep extended) 9628// Fixes trac-9887 9629function ajaxExtend( target, src ) { 9630 var key, deep, 9631 flatOptions = jQuery.ajaxSettings.flatOptions || {}; 9632 9633 for ( key in src ) { 9634 if ( src[ key ] !== undefined ) { 9635 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 9636 } 9637 } 9638 if ( deep ) { 9639 jQuery.extend( true, target, deep ); 9640 } 9641 9642 return target; 9643} 9644 9645/* Handles responses to an ajax request: 9646 * - finds the right dataType (mediates between content-type and expected dataType) 9647 * - returns the corresponding response 9648 */ 9649function ajaxHandleResponses( s, jqXHR, responses ) { 9650 9651 var ct, type, finalDataType, firstDataType, 9652 contents = s.contents, 9653 dataTypes = s.dataTypes; 9654 9655 // Remove auto dataType and get content-type in the process 9656 while ( dataTypes[ 0 ] === "*" ) { 9657 dataTypes.shift(); 9658 if ( ct === undefined ) { 9659 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 9660 } 9661 } 9662 9663 // Check if we're dealing with a known content-type 9664 if ( ct ) { 9665 for ( type in contents ) { 9666 if ( contents[ type ] && contents[ type ].test( ct ) ) { 9667 dataTypes.unshift( type ); 9668 break; 9669 } 9670 } 9671 } 9672 9673 // Check to see if we have a response for the expected dataType 9674 if ( dataTypes[ 0 ] in responses ) { 9675 finalDataType = dataTypes[ 0 ]; 9676 } else { 9677 9678 // Try convertible dataTypes 9679 for ( type in responses ) { 9680 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 9681 finalDataType = type; 9682 break; 9683 } 9684 if ( !firstDataType ) { 9685 firstDataType = type; 9686 } 9687 } 9688 9689 // Or just use first one 9690 finalDataType = finalDataType || firstDataType; 9691 } 9692 9693 // If we found a dataType 9694 // We add the dataType to the list if needed 9695 // and return the corresponding response 9696 if ( finalDataType ) { 9697 if ( finalDataType !== dataTypes[ 0 ] ) { 9698 dataTypes.unshift( finalDataType ); 9699 } 9700 return responses[ finalDataType ]; 9701 } 9702} 9703 9704/* Chain conversions given the request and the original response 9705 * Also sets the responseXXX fields on the jqXHR instance 9706 */ 9707function ajaxConvert( s, response, jqXHR, isSuccess ) { 9708 var conv2, current, conv, tmp, prev, 9709 converters = {}, 9710 9711 // Work with a copy of dataTypes in case we need to modify it for conversion 9712 dataTypes = s.dataTypes.slice(); 9713 9714 // Create converters map with lowercased keys 9715 if ( dataTypes[ 1 ] ) { 9716 for ( conv in s.converters ) { 9717 converters[ conv.toLowerCase() ] = s.converters[ conv ]; 9718 } 9719 } 9720 9721 current = dataTypes.shift(); 9722 9723 // Convert to each sequential dataType 9724 while ( current ) { 9725 9726 if ( s.responseFields[ current ] ) { 9727 jqXHR[ s.responseFields[ current ] ] = response; 9728 } 9729 9730 // Apply the dataFilter if provided 9731 if ( !prev && isSuccess && s.dataFilter ) { 9732 response = s.dataFilter( response, s.dataType ); 9733 } 9734 9735 prev = current; 9736 current = dataTypes.shift(); 9737 9738 if ( current ) { 9739 9740 // There's only work to do if current dataType is non-auto 9741 if ( current === "*" ) { 9742 9743 current = prev; 9744 9745 // Convert response if prev dataType is non-auto and differs from current 9746 } else if ( prev !== "*" && prev !== current ) { 9747 9748 // Seek a direct converter 9749 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 9750 9751 // If none found, seek a pair 9752 if ( !conv ) { 9753 for ( conv2 in converters ) { 9754 9755 // If conv2 outputs current 9756 tmp = conv2.split( " " ); 9757 if ( tmp[ 1 ] === current ) { 9758 9759 // If prev can be converted to accepted input 9760 conv = converters[ prev + " " + tmp[ 0 ] ] || 9761 converters[ "* " + tmp[ 0 ] ]; 9762 if ( conv ) { 9763 9764 // Condense equivalence converters 9765 if ( conv === true ) { 9766 conv = converters[ conv2 ]; 9767 9768 // Otherwise, insert the intermediate dataType 9769 } else if ( converters[ conv2 ] !== true ) { 9770 current = tmp[ 0 ]; 9771 dataTypes.unshift( tmp[ 1 ] ); 9772 } 9773 break; 9774 } 9775 } 9776 } 9777 } 9778 9779 // Apply converter (if not an equivalence) 9780 if ( conv !== true ) { 9781 9782 // Unless errors are allowed to bubble, catch and return them 9783 if ( conv && s.throws ) { 9784 response = conv( response ); 9785 } else { 9786 try { 9787 response = conv( response ); 9788 } catch ( e ) { 9789 return { 9790 state: "parsererror", 9791 error: conv ? e : "No conversion from " + prev + " to " + current 9792 }; 9793 } 9794 } 9795 } 9796 } 9797 } 9798 } 9799 9800 return { state: "success", data: response }; 9801} 9802 9803jQuery.extend( { 9804 9805 // Counter for holding the number of active queries 9806 active: 0, 9807 9808 // Last-Modified header cache for next request 9809 lastModified: {}, 9810 etag: {}, 9811 9812 ajaxSettings: { 9813 url: location.href, 9814 type: "GET", 9815 isLocal: rlocalProtocol.test( location.protocol ), 9816 global: true, 9817 processData: true, 9818 async: true, 9819 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 9820 9821 /* 9822 timeout: 0, 9823 data: null, 9824 dataType: null, 9825 username: null, 9826 password: null, 9827 cache: null, 9828 throws: false, 9829 traditional: false, 9830 headers: {}, 9831 */ 9832 9833 accepts: { 9834 "*": allTypes, 9835 text: "text/plain", 9836 html: "text/html", 9837 xml: "application/xml, text/xml", 9838 json: "application/json, text/javascript" 9839 }, 9840 9841 contents: { 9842 xml: /\bxml\b/, 9843 html: /\bhtml/, 9844 json: /\bjson\b/ 9845 }, 9846 9847 responseFields: { 9848 xml: "responseXML", 9849 text: "responseText", 9850 json: "responseJSON" 9851 }, 9852 9853 // Data converters 9854 // Keys separate source (or catchall "*") and destination types with a single space 9855 converters: { 9856 9857 // Convert anything to text 9858 "* text": String, 9859 9860 // Text to html (true = no transformation) 9861 "text html": true, 9862 9863 // Evaluate text as a json expression 9864 "text json": JSON.parse, 9865 9866 // Parse text as xml 9867 "text xml": jQuery.parseXML 9868 }, 9869 9870 // For options that shouldn't be deep extended: 9871 // you can add your own custom options here if 9872 // and when you create one that shouldn't be 9873 // deep extended (see ajaxExtend) 9874 flatOptions: { 9875 url: true, 9876 context: true 9877 } 9878 }, 9879 9880 // Creates a full fledged settings object into target 9881 // with both ajaxSettings and settings fields. 9882 // If target is omitted, writes into ajaxSettings. 9883 ajaxSetup: function( target, settings ) { 9884 return settings ? 9885 9886 // Building a settings object 9887 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 9888 9889 // Extending ajaxSettings 9890 ajaxExtend( jQuery.ajaxSettings, target ); 9891 }, 9892 9893 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 9894 ajaxTransport: addToPrefiltersOrTransports( transports ), 9895 9896 // Main method 9897 ajax: function( url, options ) { 9898 9899 // If url is an object, simulate pre-1.5 signature 9900 if ( typeof url === "object" ) { 9901 options = url; 9902 url = undefined; 9903 } 9904 9905 // Force options to be an object 9906 options = options || {}; 9907 9908 var transport, 9909 9910 // URL without anti-cache param 9911 cacheURL, 9912 9913 // Response headers 9914 responseHeadersString, 9915 responseHeaders, 9916 9917 // timeout handle 9918 timeoutTimer, 9919 9920 // Url cleanup var 9921 urlAnchor, 9922 9923 // Request state (becomes false upon send and true upon completion) 9924 completed, 9925 9926 // To know if global events are to be dispatched 9927 fireGlobals, 9928 9929 // Loop variable 9930 i, 9931 9932 // uncached part of the url 9933 uncached, 9934 9935 // Create the final options object 9936 s = jQuery.ajaxSetup( {}, options ), 9937 9938 // Callbacks context 9939 callbackContext = s.context || s, 9940 9941 // Context for global events is callbackContext if it is a DOM node or jQuery collection 9942 globalEventContext = s.context && 9943 ( callbackContext.nodeType || callbackContext.jquery ) ? 9944 jQuery( callbackContext ) : 9945 jQuery.event, 9946 9947 // Deferreds 9948 deferred = jQuery.Deferred(), 9949 completeDeferred = jQuery.Callbacks( "once memory" ), 9950 9951 // Status-dependent callbacks 9952 statusCode = s.statusCode || {}, 9953 9954 // Headers (they are sent all at once) 9955 requestHeaders = {}, 9956 requestHeadersNames = {}, 9957 9958 // Default abort message 9959 strAbort = "canceled", 9960 9961 // Fake xhr 9962 jqXHR = { 9963 readyState: 0, 9964 9965 // Builds headers hashtable if needed 9966 getResponseHeader: function( key ) { 9967 var match; 9968 if ( completed ) { 9969 if ( !responseHeaders ) { 9970 responseHeaders = {}; 9971 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 9972 responseHeaders[ match[ 1 ].toLowerCase() + " " ] = 9973 ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) 9974 .concat( match[ 2 ] ); 9975 } 9976 } 9977 match = responseHeaders[ key.toLowerCase() + " " ]; 9978 } 9979 return match == null ? null : match.join( ", " ); 9980 }, 9981 9982 // Raw string 9983 getAllResponseHeaders: function() { 9984 return completed ? responseHeadersString : null; 9985 }, 9986 9987 // Caches the header 9988 setRequestHeader: function( name, value ) { 9989 if ( completed == null ) { 9990 name = requestHeadersNames[ name.toLowerCase() ] = 9991 requestHeadersNames[ name.toLowerCase() ] || name; 9992 requestHeaders[ name ] = value; 9993 } 9994 return this; 9995 }, 9996 9997 // Overrides response content-type header 9998 overrideMimeType: function( type ) { 9999 if ( completed == null ) { 10000 s.mimeType = type; 10001 } 10002 return this; 10003 }, 10004 10005 // Status-dependent callbacks 10006 statusCode: function( map ) { 10007 var code; 10008 if ( map ) { 10009 if ( completed ) { 10010 10011 // Execute the appropriate callbacks 10012 jqXHR.always( map[ jqXHR.status ] ); 10013 } else { 10014 10015 // Lazy-add the new callbacks in a way that preserves old ones 10016 for ( code in map ) { 10017 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 10018 } 10019 } 10020 } 10021 return this; 10022 }, 10023 10024 // Cancel the request 10025 abort: function( statusText ) { 10026 var finalText = statusText || strAbort; 10027 if ( transport ) { 10028 transport.abort( finalText ); 10029 } 10030 done( 0, finalText ); 10031 return this; 10032 } 10033 }; 10034 10035 // Attach deferreds 10036 deferred.promise( jqXHR ); 10037 10038 // Add protocol if not provided (prefilters might expect it) 10039 // Handle falsy url in the settings object (trac-10093: consistency with old signature) 10040 // We also use the url parameter if available 10041 s.url = ( ( url || s.url || location.href ) + "" ) 10042 .replace( rprotocol, location.protocol + "//" ); 10043 10044 // Alias method option to type as per ticket trac-12004 10045 s.type = options.method || options.type || s.method || s.type; 10046 10047 // Extract dataTypes list 10048 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; 10049 10050 // A cross-domain request is in order when the origin doesn't match the current origin. 10051 if ( s.crossDomain == null ) { 10052 urlAnchor = document.createElement( "a" ); 10053 10054 // Support: IE <=8 - 11, Edge 12 - 15 10055 // IE throws exception on accessing the href property if url is malformed, 10056 // e.g. http://example.com:80x/ 10057 try { 10058 urlAnchor.href = s.url; 10059 10060 // Support: IE <=8 - 11 only 10061 // Anchor's host property isn't correctly set when s.url is relative 10062 urlAnchor.href = urlAnchor.href; 10063 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== 10064 urlAnchor.protocol + "//" + urlAnchor.host; 10065 } catch ( e ) { 10066 10067 // If there is an error parsing the URL, assume it is crossDomain, 10068 // it can be rejected by the transport if it is invalid 10069 s.crossDomain = true; 10070 } 10071 } 10072 10073 // Convert data if not already a string 10074 if ( s.data && s.processData && typeof s.data !== "string" ) { 10075 s.data = jQuery.param( s.data, s.traditional ); 10076 } 10077 10078 // Apply prefilters 10079 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 10080 10081 // If request was aborted inside a prefilter, stop there 10082 if ( completed ) { 10083 return jqXHR; 10084 } 10085 10086 // We can fire global events as of now if asked to 10087 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118) 10088 fireGlobals = jQuery.event && s.global; 10089 10090 // Watch for a new set of requests 10091 if ( fireGlobals && jQuery.active++ === 0 ) { 10092 jQuery.event.trigger( "ajaxStart" ); 10093 } 10094 10095 // Uppercase the type 10096 s.type = s.type.toUpperCase(); 10097 10098 // Determine if request has content 10099 s.hasContent = !rnoContent.test( s.type ); 10100 10101 // Save the URL in case we're toying with the If-Modified-Since 10102 // and/or If-None-Match header later on 10103 // Remove hash to simplify url manipulation 10104 cacheURL = s.url.replace( rhash, "" ); 10105 10106 // More options handling for requests with no content 10107 if ( !s.hasContent ) { 10108 10109 // Remember the hash so we can put it back 10110 uncached = s.url.slice( cacheURL.length ); 10111 10112 // If data is available and should be processed, append data to url 10113 if ( s.data && ( s.processData || typeof s.data === "string" ) ) { 10114 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; 10115 10116 // trac-9682: remove data so that it's not used in an eventual retry 10117 delete s.data; 10118 } 10119 10120 // Add or update anti-cache param if needed 10121 if ( s.cache === false ) { 10122 cacheURL = cacheURL.replace( rantiCache, "$1" ); 10123 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + 10124 uncached; 10125 } 10126 10127 // Put hash and anti-cache on the URL that will be requested (gh-1732) 10128 s.url = cacheURL + uncached; 10129 10130 // Change '%20' to '+' if this is encoded form body content (gh-2658) 10131 } else if ( s.data && s.processData && 10132 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { 10133 s.data = s.data.replace( r20, "+" ); 10134 } 10135 10136 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 10137 if ( s.ifModified ) { 10138 if ( jQuery.lastModified[ cacheURL ] ) { 10139 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 10140 } 10141 if ( jQuery.etag[ cacheURL ] ) { 10142 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 10143 } 10144 } 10145 10146 // Set the correct header, if data is being sent 10147 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 10148 jqXHR.setRequestHeader( "Content-Type", s.contentType ); 10149 } 10150 10151 // Set the Accepts header for the server, depending on the dataType 10152 jqXHR.setRequestHeader( 10153 "Accept", 10154 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 10155 s.accepts[ s.dataTypes[ 0 ] ] + 10156 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 10157 s.accepts[ "*" ] 10158 ); 10159 10160 // Check for headers option 10161 for ( i in s.headers ) { 10162 jqXHR.setRequestHeader( i, s.headers[ i ] ); 10163 } 10164 10165 // Allow custom headers/mimetypes and early abort 10166 if ( s.beforeSend && 10167 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { 10168 10169 // Abort if not done already and return 10170 return jqXHR.abort(); 10171 } 10172 10173 // Aborting is no longer a cancellation 10174 strAbort = "abort"; 10175 10176 // Install callbacks on deferreds 10177 completeDeferred.add( s.complete ); 10178 jqXHR.done( s.success ); 10179 jqXHR.fail( s.error ); 10180 10181 // Get transport 10182 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 10183 10184 // If no transport, we auto-abort 10185 if ( !transport ) { 10186 done( -1, "No Transport" ); 10187 } else { 10188 jqXHR.readyState = 1; 10189 10190 // Send global event 10191 if ( fireGlobals ) { 10192 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 10193 } 10194 10195 // If request was aborted inside ajaxSend, stop there 10196 if ( completed ) { 10197 return jqXHR; 10198 } 10199 10200 // Timeout 10201 if ( s.async && s.timeout > 0 ) { 10202 timeoutTimer = window.setTimeout( function() { 10203 jqXHR.abort( "timeout" ); 10204 }, s.timeout ); 10205 } 10206 10207 try { 10208 completed = false; 10209 transport.send( requestHeaders, done ); 10210 } catch ( e ) { 10211 10212 // Rethrow post-completion exceptions 10213 if ( completed ) { 10214 throw e; 10215 } 10216 10217 // Propagate others as results 10218 done( -1, e ); 10219 } 10220 } 10221 10222 // Callback for when everything is done 10223 function done( status, nativeStatusText, responses, headers ) { 10224 var isSuccess, success, error, response, modified, 10225 statusText = nativeStatusText; 10226 10227 // Ignore repeat invocations 10228 if ( completed ) { 10229 return; 10230 } 10231 10232 completed = true; 10233 10234 // Clear timeout if it exists 10235 if ( timeoutTimer ) { 10236 window.clearTimeout( timeoutTimer ); 10237 } 10238 10239 // Dereference transport for early garbage collection 10240 // (no matter how long the jqXHR object will be used) 10241 transport = undefined; 10242 10243 // Cache response headers 10244 responseHeadersString = headers || ""; 10245 10246 // Set readyState 10247 jqXHR.readyState = status > 0 ? 4 : 0; 10248 10249 // Determine if successful 10250 isSuccess = status >= 200 && status < 300 || status === 304; 10251 10252 // Get response data 10253 if ( responses ) { 10254 response = ajaxHandleResponses( s, jqXHR, responses ); 10255 } 10256 10257 // Use a noop converter for missing script but not if jsonp 10258 if ( !isSuccess && 10259 jQuery.inArray( "script", s.dataTypes ) > -1 && 10260 jQuery.inArray( "json", s.dataTypes ) < 0 ) { 10261 s.converters[ "text script" ] = function() {}; 10262 } 10263 10264 // Convert no matter what (that way responseXXX fields are always set) 10265 response = ajaxConvert( s, response, jqXHR, isSuccess ); 10266 10267 // If successful, handle type chaining 10268 if ( isSuccess ) { 10269 10270 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 10271 if ( s.ifModified ) { 10272 modified = jqXHR.getResponseHeader( "Last-Modified" ); 10273 if ( modified ) { 10274 jQuery.lastModified[ cacheURL ] = modified; 10275 } 10276 modified = jqXHR.getResponseHeader( "etag" ); 10277 if ( modified ) { 10278 jQuery.etag[ cacheURL ] = modified; 10279 } 10280 } 10281 10282 // if no content 10283 if ( status === 204 || s.type === "HEAD" ) { 10284 statusText = "nocontent"; 10285 10286 // if not modified 10287 } else if ( status === 304 ) { 10288 statusText = "notmodified"; 10289 10290 // If we have data, let's convert it 10291 } else { 10292 statusText = response.state; 10293 success = response.data; 10294 error = response.error; 10295 isSuccess = !error; 10296 } 10297 } else { 10298 10299 // Extract error from statusText and normalize for non-aborts 10300 error = statusText; 10301 if ( status || !statusText ) { 10302 statusText = "error"; 10303 if ( status < 0 ) { 10304 status = 0; 10305 } 10306 } 10307 } 10308 10309 // Set data for the fake xhr object 10310 jqXHR.status = status; 10311 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 10312 10313 // Success/Error 10314 if ( isSuccess ) { 10315 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 10316 } else { 10317 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 10318 } 10319 10320 // Status-dependent callbacks 10321 jqXHR.statusCode( statusCode ); 10322 statusCode = undefined; 10323 10324 if ( fireGlobals ) { 10325 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 10326 [ jqXHR, s, isSuccess ? success : error ] ); 10327 } 10328 10329 // Complete 10330 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 10331 10332 if ( fireGlobals ) { 10333 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 10334 10335 // Handle the global AJAX counter 10336 if ( !( --jQuery.active ) ) { 10337 jQuery.event.trigger( "ajaxStop" ); 10338 } 10339 } 10340 } 10341 10342 return jqXHR; 10343 }, 10344 10345 getJSON: function( url, data, callback ) { 10346 return jQuery.get( url, data, callback, "json" ); 10347 }, 10348 10349 getScript: function( url, callback ) { 10350 return jQuery.get( url, undefined, callback, "script" ); 10351 } 10352} ); 10353 10354jQuery.each( [ "get", "post" ], function( _i, method ) { 10355 jQuery[ method ] = function( url, data, callback, type ) { 10356 10357 // Shift arguments if data argument was omitted 10358 if ( isFunction( data ) ) { 10359 type = type || callback; 10360 callback = data; 10361 data = undefined; 10362 } 10363 10364 // The url can be an options object (which then must have .url) 10365 return jQuery.ajax( jQuery.extend( { 10366 url: url, 10367 type: method, 10368 dataType: type, 10369 data: data, 10370 success: callback 10371 }, jQuery.isPlainObject( url ) && url ) ); 10372 }; 10373} ); 10374 10375jQuery.ajaxPrefilter( function( s ) { 10376 var i; 10377 for ( i in s.headers ) { 10378 if ( i.toLowerCase() === "content-type" ) { 10379 s.contentType = s.headers[ i ] || ""; 10380 } 10381 } 10382} ); 10383 10384 10385jQuery._evalUrl = function( url, options, doc ) { 10386 return jQuery.ajax( { 10387 url: url, 10388 10389 // Make this explicit, since user can override this through ajaxSetup (trac-11264) 10390 type: "GET", 10391 dataType: "script", 10392 cache: true, 10393 async: false, 10394 global: false, 10395 10396 // Only evaluate the response if it is successful (gh-4126) 10397 // dataFilter is not invoked for failure responses, so using it instead 10398 // of the default converter is kludgy but it works. 10399 converters: { 10400 "text script": function() {} 10401 }, 10402 dataFilter: function( response ) { 10403 jQuery.globalEval( response, options, doc ); 10404 } 10405 } ); 10406}; 10407 10408 10409jQuery.fn.extend( { 10410 wrapAll: function( html ) { 10411 var wrap; 10412 10413 if ( this[ 0 ] ) { 10414 if ( isFunction( html ) ) { 10415 html = html.call( this[ 0 ] ); 10416 } 10417 10418 // The elements to wrap the target around 10419 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 10420 10421 if ( this[ 0 ].parentNode ) { 10422 wrap.insertBefore( this[ 0 ] ); 10423 } 10424 10425 wrap.map( function() { 10426 var elem = this; 10427 10428 while ( elem.firstElementChild ) { 10429 elem = elem.firstElementChild; 10430 } 10431 10432 return elem; 10433 } ).append( this ); 10434 } 10435 10436 return this; 10437 }, 10438 10439 wrapInner: function( html ) { 10440 if ( isFunction( html ) ) { 10441 return this.each( function( i ) { 10442 jQuery( this ).wrapInner( html.call( this, i ) ); 10443 } ); 10444 } 10445 10446 return this.each( function() { 10447 var self = jQuery( this ), 10448 contents = self.contents(); 10449 10450 if ( contents.length ) { 10451 contents.wrapAll( html ); 10452 10453 } else { 10454 self.append( html ); 10455 } 10456 } ); 10457 }, 10458 10459 wrap: function( html ) { 10460 var htmlIsFunction = isFunction( html ); 10461 10462 return this.each( function( i ) { 10463 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); 10464 } ); 10465 }, 10466 10467 unwrap: function( selector ) { 10468 this.parent( selector ).not( "body" ).each( function() { 10469 jQuery( this ).replaceWith( this.childNodes ); 10470 } ); 10471 return this; 10472 } 10473} ); 10474 10475 10476jQuery.expr.pseudos.hidden = function( elem ) { 10477 return !jQuery.expr.pseudos.visible( elem ); 10478}; 10479jQuery.expr.pseudos.visible = function( elem ) { 10480 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); 10481}; 10482 10483 10484 10485 10486jQuery.ajaxSettings.xhr = function() { 10487 try { 10488 return new window.XMLHttpRequest(); 10489 } catch ( e ) {} 10490}; 10491 10492var xhrSuccessStatus = { 10493 10494 // File protocol always yields status code 0, assume 200 10495 0: 200, 10496 10497 // Support: IE <=9 only 10498 // trac-1450: sometimes IE returns 1223 when it should be 204 10499 1223: 204 10500 }, 10501 xhrSupported = jQuery.ajaxSettings.xhr(); 10502 10503support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 10504support.ajax = xhrSupported = !!xhrSupported; 10505 10506jQuery.ajaxTransport( function( options ) { 10507 var callback, errorCallback; 10508 10509 // Cross domain only allowed if supported through XMLHttpRequest 10510 if ( support.cors || xhrSupported && !options.crossDomain ) { 10511 return { 10512 send: function( headers, complete ) { 10513 var i, 10514 xhr = options.xhr(); 10515 10516 xhr.open( 10517 options.type, 10518 options.url, 10519 options.async, 10520 options.username, 10521 options.password 10522 ); 10523 10524 // Apply custom fields if provided 10525 if ( options.xhrFields ) { 10526 for ( i in options.xhrFields ) { 10527 xhr[ i ] = options.xhrFields[ i ]; 10528 } 10529 } 10530 10531 // Override mime type if needed 10532 if ( options.mimeType && xhr.overrideMimeType ) { 10533 xhr.overrideMimeType( options.mimeType ); 10534 } 10535 10536 // X-Requested-With header 10537 // For cross-domain requests, seeing as conditions for a preflight are 10538 // akin to a jigsaw puzzle, we simply never set it to be sure. 10539 // (it can always be set on a per-request basis or even using ajaxSetup) 10540 // For same-domain requests, won't change header if already provided. 10541 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 10542 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 10543 } 10544 10545 // Set headers 10546 for ( i in headers ) { 10547 xhr.setRequestHeader( i, headers[ i ] ); 10548 } 10549 10550 // Callback 10551 callback = function( type ) { 10552 return function() { 10553 if ( callback ) { 10554 callback = errorCallback = xhr.onload = 10555 xhr.onerror = xhr.onabort = xhr.ontimeout = 10556 xhr.onreadystatechange = null; 10557 10558 if ( type === "abort" ) { 10559 xhr.abort(); 10560 } else if ( type === "error" ) { 10561 10562 // Support: IE <=9 only 10563 // On a manual native abort, IE9 throws 10564 // errors on any property access that is not readyState 10565 if ( typeof xhr.status !== "number" ) { 10566 complete( 0, "error" ); 10567 } else { 10568 complete( 10569 10570 // File: protocol always yields status 0; see trac-8605, trac-14207 10571 xhr.status, 10572 xhr.statusText 10573 ); 10574 } 10575 } else { 10576 complete( 10577 xhrSuccessStatus[ xhr.status ] || xhr.status, 10578 xhr.statusText, 10579 10580 // Support: IE <=9 only 10581 // IE9 has no XHR2 but throws on binary (trac-11426) 10582 // For XHR2 non-text, let the caller handle it (gh-2498) 10583 ( xhr.responseType || "text" ) !== "text" || 10584 typeof xhr.responseText !== "string" ? 10585 { binary: xhr.response } : 10586 { text: xhr.responseText }, 10587 xhr.getAllResponseHeaders() 10588 ); 10589 } 10590 } 10591 }; 10592 }; 10593 10594 // Listen to events 10595 xhr.onload = callback(); 10596 errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); 10597 10598 // Support: IE 9 only 10599 // Use onreadystatechange to replace onabort 10600 // to handle uncaught aborts 10601 if ( xhr.onabort !== undefined ) { 10602 xhr.onabort = errorCallback; 10603 } else { 10604 xhr.onreadystatechange = function() { 10605 10606 // Check readyState before timeout as it changes 10607 if ( xhr.readyState === 4 ) { 10608 10609 // Allow onerror to be called first, 10610 // but that will not handle a native abort 10611 // Also, save errorCallback to a variable 10612 // as xhr.onerror cannot be accessed 10613 window.setTimeout( function() { 10614 if ( callback ) { 10615 errorCallback(); 10616 } 10617 } ); 10618 } 10619 }; 10620 } 10621 10622 // Create the abort callback 10623 callback = callback( "abort" ); 10624 10625 try { 10626 10627 // Do send the request (this may raise an exception) 10628 xhr.send( options.hasContent && options.data || null ); 10629 } catch ( e ) { 10630 10631 // trac-14683: Only rethrow if this hasn't been notified as an error yet 10632 if ( callback ) { 10633 throw e; 10634 } 10635 } 10636 }, 10637 10638 abort: function() { 10639 if ( callback ) { 10640 callback(); 10641 } 10642 } 10643 }; 10644 } 10645} ); 10646 10647 10648 10649 10650// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) 10651jQuery.ajaxPrefilter( function( s ) { 10652 if ( s.crossDomain ) { 10653 s.contents.script = false; 10654 } 10655} ); 10656 10657// Install script dataType 10658jQuery.ajaxSetup( { 10659 accepts: { 10660 script: "text/javascript, application/javascript, " + 10661 "application/ecmascript, application/x-ecmascript" 10662 }, 10663 contents: { 10664 script: /\b(?:java|ecma)script\b/ 10665 }, 10666 converters: { 10667 "text script": function( text ) { 10668 jQuery.globalEval( text ); 10669 return text; 10670 } 10671 } 10672} ); 10673 10674// Handle cache's special case and crossDomain 10675jQuery.ajaxPrefilter( "script", function( s ) { 10676 if ( s.cache === undefined ) { 10677 s.cache = false; 10678 } 10679 if ( s.crossDomain ) { 10680 s.type = "GET"; 10681 } 10682} ); 10683 10684// Bind script tag hack transport 10685jQuery.ajaxTransport( "script", function( s ) { 10686 10687 // This transport only deals with cross domain or forced-by-attrs requests 10688 if ( s.crossDomain || s.scriptAttrs ) { 10689 var script, callback; 10690 return { 10691 send: function( _, complete ) { 10692 script = jQuery( "<script>" ) 10693 .attr( s.scriptAttrs || {} ) 10694 .prop( { charset: s.scriptCharset, src: s.url } ) 10695 .on( "load error", callback = function( evt ) { 10696 script.remove(); 10697 callback = null; 10698 if ( evt ) { 10699 complete( evt.type === "error" ? 404 : 200, evt.type ); 10700 } 10701 } ); 10702 10703 // Use native DOM manipulation to avoid our domManip AJAX trickery 10704 document.head.appendChild( script[ 0 ] ); 10705 }, 10706 abort: function() { 10707 if ( callback ) { 10708 callback(); 10709 } 10710 } 10711 }; 10712 } 10713} ); 10714 10715 10716 10717 10718var oldCallbacks = [], 10719 rjsonp = /(=)\?(?=&|$)|\?\?/; 10720 10721// Default jsonp settings 10722jQuery.ajaxSetup( { 10723 jsonp: "callback", 10724 jsonpCallback: function() { 10725 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) ); 10726 this[ callback ] = true; 10727 return callback; 10728 } 10729} ); 10730 10731// Detect, normalize options and install callbacks for jsonp requests 10732jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 10733 10734 var callbackName, overwritten, responseContainer, 10735 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 10736 "url" : 10737 typeof s.data === "string" && 10738 ( s.contentType || "" ) 10739 .indexOf( "application/x-www-form-urlencoded" ) === 0 && 10740 rjsonp.test( s.data ) && "data" 10741 ); 10742 10743 // Handle iff the expected data type is "jsonp" or we have a parameter to set 10744 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 10745 10746 // Get callback name, remembering preexisting value associated with it 10747 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? 10748 s.jsonpCallback() : 10749 s.jsonpCallback; 10750 10751 // Insert callback into url or form data 10752 if ( jsonProp ) { 10753 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 10754 } else if ( s.jsonp !== false ) { 10755 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 10756 } 10757 10758 // Use data converter to retrieve json after script execution
vendor: 2,987 bytes, lines 10759-10868
10759 s.converters[ "script json" ] = function() { 10760 if ( !responseContainer ) { 10761 jQuery.error( callbackName + " was not called" ); 10762 } 10763 return responseContainer[ 0 ]; 10764 }; 10765 10766 // Force json dataType 10767 s.dataTypes[ 0 ] = "json"; 10768 10769 // Install callback 10770 overwritten = window[ callbackName ]; 10771 window[ callbackName ] = function() { 10772 responseContainer = arguments; 10773 }; 10774 10775 // Clean-up function (fires after converters) 10776 jqXHR.always( function() { 10777 10778 // If previous value didn't exist - remove it 10779 if ( overwritten === undefined ) { 10780 jQuery( window ).removeProp( callbackName ); 10781 10782 // Otherwise restore preexisting value 10783 } else { 10784 window[ callbackName ] = overwritten; 10785 } 10786 10787 // Save back as free 10788 if ( s[ callbackName ] ) { 10789 10790 // Make sure that re-using the options doesn't screw things around 10791 s.jsonpCallback = originalSettings.jsonpCallback; 10792 10793 // Save the callback name for future use 10794 oldCallbacks.push( callbackName ); 10795 } 10796 10797 // Call if it was a function and we have a response 10798 if ( responseContainer && isFunction( overwritten ) ) { 10799 overwritten( responseContainer[ 0 ] ); 10800 } 10801 10802 responseContainer = overwritten = undefined; 10803 } ); 10804 10805 // Delegate to script 10806 return "script"; 10807 } 10808} ); 10809 10810 10811 10812 10813// Support: Safari 8 only 10814// In Safari 8 documents created via document.implementation.createHTMLDocument 10815// collapse sibling forms: the second one becomes a child of the first one. 10816// Because of that, this security measure has to be disabled in Safari 8. 10817// https://bugs.webkit.org/show_bug.cgi?id=137337 10818support.createHTMLDocument = ( function() { 10819 var body = document.implementation.createHTMLDocument( "" ).body; 10820 body.innerHTML = "<form></form><form></form>"; 10821 return body.childNodes.length === 2; 10822} )(); 10823 10824 10825// Argument "data" should be string of html 10826// context (optional): If specified, the fragment will be created in this context, 10827// defaults to document 10828// keepScripts (optional): If true, will include scripts passed in the html string 10829jQuery.parseHTML = function( data, context, keepScripts ) { 10830 if ( typeof data !== "string" ) { 10831 return []; 10832 } 10833 if ( typeof context === "boolean" ) { 10834 keepScripts = context; 10835 context = false; 10836 } 10837 10838 var base, parsed, scripts; 10839 10840 if ( !context ) { 10841 10842 // Stop scripts or inline event handlers from being executed immediately 10843 // by using document.implementation 10844 if ( support.createHTMLDocument ) { 10845 context = document.implementation.createHTMLDocument( "" ); 10846 10847 // Set the base href for the created document 10848 // so any parsed elements with URLs 10849 // are based on the document's URL (gh-2965) 10850 base = context.createElement( "base" ); 10851 base.href = document.location.href; 10852 context.head.appendChild( base ); 10853 } else { 10854 context = document; 10855 } 10856 } 10857 10858 parsed = rsingleTag.exec( data ); 10859 scripts = !keepScripts && []; 10860 10861 // Single tag 10862 if ( parsed ) { 10863 return [ context.createElement( parsed[ 1 ] ) ]; 10864 } 10865 10866 parsed = buildFragment( [ data ], context, scripts ); 10867 10868 if ( scripts && scripts.length ) {
vendor: 10,712 bytes, lines 10869-11251
10869 jQuery( scripts ).remove(); 10870 } 10871 10872 return jQuery.merge( [], parsed.childNodes ); 10873}; 10874 10875 10876/** 10877 * Load a url into a page 10878 */ 10879jQuery.fn.load = function( url, params, callback ) { 10880 var selector, type, response, 10881 self = this, 10882 off = url.indexOf( " " ); 10883 10884 if ( off > -1 ) { 10885 selector = stripAndCollapse( url.slice( off ) ); 10886 url = url.slice( 0, off ); 10887 } 10888 10889 // If it's a function 10890 if ( isFunction( params ) ) { 10891 10892 // We assume that it's the callback 10893 callback = params; 10894 params = undefined; 10895 10896 // Otherwise, build a param string 10897 } else if ( params && typeof params === "object" ) { 10898 type = "POST"; 10899 } 10900 10901 // If we have elements to modify, make the request 10902 if ( self.length > 0 ) { 10903 jQuery.ajax( { 10904 url: url, 10905 10906 // If "type" variable is undefined, then "GET" method will be used. 10907 // Make value of this field explicit since 10908 // user can override it through ajaxSetup method 10909 type: type || "GET", 10910 dataType: "html", 10911 data: params 10912 } ).done( function( responseText ) { 10913 10914 // Save response for use in complete callback 10915 response = arguments; 10916 10917 self.html( selector ? 10918 10919 // If a selector was specified, locate the right elements in a dummy div 10920 // Exclude scripts to avoid IE 'Permission Denied' errors 10921 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 10922 10923 // Otherwise use the full result 10924 responseText ); 10925 10926 // If the request succeeds, this function gets "data", "status", "jqXHR" 10927 // but they are ignored because response was set above. 10928 // If it fails, this function gets "jqXHR", "status", "error" 10929 } ).always( callback && function( jqXHR, status ) { 10930 self.each( function() { 10931 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 10932 } ); 10933 } ); 10934 } 10935 10936 return this; 10937}; 10938 10939 10940 10941 10942jQuery.expr.pseudos.animated = function( elem ) { 10943 return jQuery.grep( jQuery.timers, function( fn ) { 10944 return elem === fn.elem; 10945 } ).length; 10946}; 10947 10948 10949 10950 10951jQuery.offset = { 10952 setOffset: function( elem, options, i ) { 10953 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 10954 position = jQuery.css( elem, "position" ), 10955 curElem = jQuery( elem ), 10956 props = {}; 10957 10958 // Set position first, in-case top/left are set even on static elem 10959 if ( position === "static" ) { 10960 elem.style.position = "relative"; 10961 } 10962 10963 curOffset = curElem.offset(); 10964 curCSSTop = jQuery.css( elem, "top" ); 10965 curCSSLeft = jQuery.css( elem, "left" ); 10966 calculatePosition = ( position === "absolute" || position === "fixed" ) && 10967 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; 10968 10969 // Need to be able to calculate position if either 10970 // top or left is auto and position is either absolute or fixed 10971 if ( calculatePosition ) { 10972 curPosition = curElem.position(); 10973 curTop = curPosition.top; 10974 curLeft = curPosition.left; 10975 10976 } else { 10977 curTop = parseFloat( curCSSTop ) || 0; 10978 curLeft = parseFloat( curCSSLeft ) || 0; 10979 } 10980 10981 if ( isFunction( options ) ) { 10982 10983 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 10984 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 10985 } 10986 10987 if ( options.top != null ) { 10988 props.top = ( options.top - curOffset.top ) + curTop; 10989 } 10990 if ( options.left != null ) { 10991 props.left = ( options.left - curOffset.left ) + curLeft; 10992 } 10993 10994 if ( "using" in options ) { 10995 options.using.call( elem, props ); 10996 10997 } else { 10998 curElem.css( props ); 10999 } 11000 } 11001}; 11002 11003jQuery.fn.extend( { 11004 11005 // offset() relates an element's border box to the document origin 11006 offset: function( options ) { 11007 11008 // Preserve chaining for setter 11009 if ( arguments.length ) { 11010 return options === undefined ? 11011 this : 11012 this.each( function( i ) { 11013 jQuery.offset.setOffset( this, options, i ); 11014 } ); 11015 } 11016 11017 var rect, win, 11018 elem = this[ 0 ]; 11019 11020 if ( !elem ) { 11021 return; 11022 } 11023 11024 // Return zeros for disconnected and hidden (display: none) elements (gh-2310) 11025 // Support: IE <=11 only 11026 // Running getBoundingClientRect on a 11027 // disconnected node in IE throws an error 11028 if ( !elem.getClientRects().length ) { 11029 return { top: 0, left: 0 }; 11030 } 11031 11032 // Get document-relative position by adding viewport scroll to viewport-relative gBCR 11033 rect = elem.getBoundingClientRect(); 11034 win = elem.ownerDocument.defaultView; 11035 return { 11036 top: rect.top + win.pageYOffset, 11037 left: rect.left + win.pageXOffset 11038 }; 11039 }, 11040 11041 // position() relates an element's margin box to its offset parent's padding box 11042 // This corresponds to the behavior of CSS absolute positioning 11043 position: function() { 11044 if ( !this[ 0 ] ) { 11045 return; 11046 } 11047 11048 var offsetParent, offset, doc, 11049 elem = this[ 0 ], 11050 parentOffset = { top: 0, left: 0 }; 11051 11052 // position:fixed elements are offset from the viewport, which itself always has zero offset 11053 if ( jQuery.css( elem, "position" ) === "fixed" ) { 11054 11055 // Assume position:fixed implies availability of getBoundingClientRect 11056 offset = elem.getBoundingClientRect(); 11057 11058 } else { 11059 offset = this.offset(); 11060 11061 // Account for the *real* offset parent, which can be the document or its root element 11062 // when a statically positioned element is identified 11063 doc = elem.ownerDocument; 11064 offsetParent = elem.offsetParent || doc.documentElement; 11065 while ( offsetParent && 11066 ( offsetParent === doc.body || offsetParent === doc.documentElement ) && 11067 jQuery.css( offsetParent, "position" ) === "static" ) { 11068 11069 offsetParent = offsetParent.parentNode; 11070 } 11071 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) { 11072 11073 // Incorporate borders into its offset, since they are outside its content origin 11074 parentOffset = jQuery( offsetParent ).offset(); 11075 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ); 11076 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ); 11077 } 11078 } 11079 11080 // Subtract parent offsets and element margins 11081 return { 11082 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 11083 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 11084 }; 11085 }, 11086 11087 // This method will return documentElement in the following cases: 11088 // 1) For the element inside the iframe without offsetParent, this method will return 11089 // documentElement of the parent window 11090 // 2) For the hidden or detached element 11091 // 3) For body or html element, i.e. in case of the html node - it will return itself 11092 // 11093 // but those exceptions were never presented as a real life use-cases 11094 // and might be considered as more preferable results. 11095 // 11096 // This logic, however, is not guaranteed and can change at any point in the future 11097 offsetParent: function() { 11098 return this.map( function() { 11099 var offsetParent = this.offsetParent; 11100 11101 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { 11102 offsetParent = offsetParent.offsetParent; 11103 } 11104 11105 return offsetParent || documentElement; 11106 } ); 11107 } 11108} ); 11109 11110// Create scrollLeft and scrollTop methods 11111jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 11112 var top = "pageYOffset" === prop; 11113 11114 jQuery.fn[ method ] = function( val ) { 11115 return access( this, function( elem, method, val ) { 11116 11117 // Coalesce documents and windows 11118 var win; 11119 if ( isWindow( elem ) ) { 11120 win = elem; 11121 } else if ( elem.nodeType === 9 ) { 11122 win = elem.defaultView; 11123 } 11124 11125 if ( val === undefined ) { 11126 return win ? win[ prop ] : elem[ method ]; 11127 } 11128 11129 if ( win ) { 11130 win.scrollTo( 11131 !top ? val : win.pageXOffset, 11132 top ? val : win.pageYOffset 11133 ); 11134 11135 } else { 11136 elem[ method ] = val; 11137 } 11138 }, method, val, arguments.length ); 11139 }; 11140} ); 11141 11142// Support: Safari <=7 - 9.1, Chrome <=37 - 49 11143// Add the top/left cssHooks using jQuery.fn.position 11144// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 11145// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347 11146// getComputedStyle returns percent when specified for top/left/bottom/right; 11147// rather than make the css module depend on the offset module, just check for it here 11148jQuery.each( [ "top", "left" ], function( _i, prop ) { 11149 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 11150 function( elem, computed ) { 11151 if ( computed ) { 11152 computed = curCSS( elem, prop ); 11153 11154 // If curCSS returns percentage, fallback to offset 11155 return rnumnonpx.test( computed ) ? 11156 jQuery( elem ).position()[ prop ] + "px" : 11157 computed; 11158 } 11159 } 11160 ); 11161} ); 11162 11163 11164// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 11165jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 11166 jQuery.each( { 11167 padding: "inner" + name, 11168 content: type, 11169 "": "outer" + name 11170 }, function( defaultExtra, funcName ) { 11171 11172 // Margin is only for outerHeight, outerWidth 11173 jQuery.fn[ funcName ] = function( margin, value ) { 11174 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 11175 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 11176 11177 return access( this, function( elem, type, value ) { 11178 var doc; 11179 11180 if ( isWindow( elem ) ) { 11181 11182 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) 11183 return funcName.indexOf( "outer" ) === 0 ? 11184 elem[ "inner" + name ] : 11185 elem.document.documentElement[ "client" + name ]; 11186 } 11187 11188 // Get document width or height 11189 if ( elem.nodeType === 9 ) { 11190 doc = elem.documentElement; 11191 11192 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 11193 // whichever is greatest 11194 return Math.max( 11195 elem.body[ "scroll" + name ], doc[ "scroll" + name ], 11196 elem.body[ "offset" + name ], doc[ "offset" + name ], 11197 doc[ "client" + name ] 11198 ); 11199 } 11200 11201 return value === undefined ? 11202 11203 // Get width or height on the element, requesting but not forcing parseFloat 11204 jQuery.css( elem, type, extra ) : 11205 11206 // Set width or height on the element 11207 jQuery.style( elem, type, value, extra ); 11208 }, type, chainable ? margin : undefined, chainable ); 11209 }; 11210 } ); 11211} ); 11212 11213 11214jQuery.each( [ 11215 "ajaxStart", 11216 "ajaxStop", 11217 "ajaxComplete", 11218 "ajaxError", 11219 "ajaxSuccess", 11220 "ajaxSend" 11221], function( _i, type ) { 11222 jQuery.fn[ type ] = function( fn ) { 11223 return this.on( type, fn ); 11224 }; 11225} ); 11226 11227 11228 11229 11230jQuery.fn.extend( { 11231 11232 bind: function( types, data, fn ) { 11233 return this.on( types, null, data, fn ); 11234 }, 11235 unbind: function( types, fn ) { 11236 return this.off( types, null, fn ); 11237 }, 11238 11239 delegate: function( selector, types, data, fn ) { 11240 return this.on( types, selector, data, fn ); 11241 }, 11242 undelegate: function( selector, types, fn ) { 11243 11244 // ( namespace ) or ( selector, types [, fn] ) 11245 return arguments.length === 1 ? 11246 this.off( selector, "**" ) : 11247 this.off( types, selector || "**", fn ); 11248 }, 11249 11250 hover: function( fnOver, fnOut ) { 11251 return this
vendor: 2,565 bytes, lines 11251-11343
11251.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 11252 } 11253} ); 11254 11255jQuery.each( 11256 ( "blur focus focusin focusout resize scroll click dblclick " + 11257 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 11258 "change select submit keydown keypress keyup contextmenu" ).split( " " ), 11259 function( _i, name ) { 11260 11261 // Handle event binding 11262 jQuery.fn[ name ] = function( data, fn ) { 11263 return arguments.length > 0 ? 11264 this.on( name, null, data, fn ) : 11265 this.trigger( name ); 11266 }; 11267 } 11268); 11269 11270 11271 11272 11273// Support: Android <=4.0 only 11274// Make sure we trim BOM and NBSP 11275// Require that the "whitespace run" starts from a non-whitespace 11276// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position. 11277var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g; 11278 11279// Bind a function to a context, optionally partially applying any 11280// arguments. 11281// jQuery.proxy is deprecated to promote standards (specifically Function#bind) 11282// However, it is not slated for removal any time soon 11283jQuery.proxy = function( fn, context ) { 11284 var tmp, args, proxy; 11285 11286 if ( typeof context === "string" ) { 11287 tmp = fn[ context ]; 11288 context = fn; 11289 fn = tmp; 11290 } 11291 11292 // Quick check to determine if target is callable, in the spec 11293 // this throws a TypeError, but we will just return undefined. 11294 if ( !isFunction( fn ) ) { 11295 return undefined; 11296 } 11297 11298 // Simulated bind 11299 args = slice.call( arguments, 2 ); 11300 proxy = function() { 11301 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 11302 }; 11303 11304 // Set the guid of unique handler to the same of original handler, so it can be removed 11305 proxy.guid = fn.guid = fn.guid || jQuery.guid++; 11306 11307 return proxy; 11308}; 11309 11310jQuery.holdReady = function( hold ) { 11311 if ( hold ) { 11312 jQuery.readyWait++; 11313 } else { 11314 jQuery.ready( true ); 11315 } 11316}; 11317jQuery.isArray = Array.isArray; 11318jQuery.parseJSON = JSON.parse; 11319jQuery.nodeName = nodeName; 11320jQuery.isFunction = isFunction; 11321jQuery.isWindow = isWindow; 11322jQuery.camelCase = camelCase; 11323jQuery.type = toType; 11324 11325jQuery.now = Date.now; 11326 11327jQuery.isNumeric = function( obj ) { 11328 11329 // As of jQuery 3.0, isNumeric is limited to 11330 // strings and numbers (primitives or objects) 11331 // that can be coerced to finite numbers (gh-2662) 11332 var type = jQuery.type( obj ); 11333 return ( type === "number" || type === "string" ) && 11334 11335 // parseFloat NaNs numeric-cast false positives ("") 11336 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 11337 // subtraction forces infinities to NaN 11338 !isNaN( obj - parseFloat( obj ) ); 11339}; 11340 11341jQuery.trim = function( text ) { 11342 return text == null ? 11343 "" :
11344 ( text + "" ).replace( rtrim, "$1" ); 11345}; 11346 11347 11348 11349// Register as a named AMD module, since jQuery can be concatenated with other 11350// files that may use define, but not via a proper concatenation script that 11351// understands anonymous AMD modules. A named AMD is safest and most robust 11352// way to register. Lowercase jquery is used because AMD module names are 11353// derived from file names, and jQuery is normally delivered in a lowercase 11354// file name. Do this after creating the global so that if an AMD module wants 11355// to call noConflict to hide this version of jQuery, it will work. 11356 11357// Note that for maximum portability, libraries that are not jQuery should 11358// declare themselves as anonymous modules, and avoid setting a global if an 11359// AMD loader is present. jQuery is a special case. For more information, see 11360// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 11361 11362if ( typeof define === "function" && define.amd ) { 11363 define( "jquery", [], function() { 11364 return jQuery; 11365 } ); 11366} 11367 11368 11369 11370 11371var 11372 11373 // Map over jQuery in case of overwrite 11374 _jQuery = window.jQuery, 11375 11376 // Map over the $ in case of overwrite 11377 _$ = window.$; 11378 11379jQuery.noConflict = function( deep ) { 11380 if ( window.$ === jQuery ) { 11381 window.$ = _$; 11382 } 11383 11384 if ( deep && window.jQuery === jQuery ) { 11385 window.jQuery = _jQuery; 11386 } 11387 11388 return jQuery; 11389}; 11390 11391// Expose jQuery and $ identifiers, even in AMD 11392// (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557) 11393// and CommonJS for browser emulators (trac-13566) 11394if ( typeof noGlobal === "undefined" ) { 11395 window.jQuery = window.$ = jQuery; 11396} 11397 11398 11399 11400 11401return jQuery; 11402} ); 11403( function( factory ) { 11404 "use strict"; 11405 11406 if ( typeof define === "function" && define.amd ) { 11407 11408 // AMD. Register as an anonymous module. 11409 define( [ "jquery" ], factory ); 11410 } else { 11411 11412 // Browser globals 11413 factory( jQuery ); 11414 } 11415} )( function( $ ) { 11416"use strict"; 11417 11418$.ui = $.ui || {}; 11419 11420return $.ui.version = "1.14.1"; 11421 11422} ); 11423 11424 11425/*! 11426 * jQuery UI Widget 1.14.1 11427 * https://jqueryui.com 11428 * 11429 * Copyright OpenJS Foundation and other contributors 11430 * Released under the MIT license. 11431 * https://jquery.org/license 11432 */ 11433 11434//>>label: Widget 11435//>>group: Core 11436//>>description: Provides a factory for creating stateful widgets with a common API. 11437//>>docs: https://api.jqueryui.com/jQuery.widget/ 11438//>>demos: https://jqueryui.com/widget/ 11439 11440( function( factory ) { 11441 "use strict"; 11442 11443 if ( typeof define === "function" && define.amd ) { 11444 11445 // AMD. Register as an anonymous module. 11446 define( [ "jquery", "./version" ], factory ); 11447 } else { 11448 11449 // Browser globals 11450 factory( jQuery ); 11451 } 11452} )( function( $ ) { 11453"use strict"; 11454 11455var widgetUuid = 0; 11456var widgetHasOwnProperty = Array.prototype.hasOwnProperty; 11457var widgetSlice = Array.prototype.slice; 11458 11459$.cleanData = ( function( orig ) { 11460 return function( elems ) { 11461 var events, elem, i; 11462 for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { 11463 11464 // Only trigger remove when necessary to save time 11465 events = $._data( elem, "events" ); 11466 if ( events && events.remove ) { 11467 $( elem ).triggerHandler( "remove" ); 11468 } 11469 } 11470 orig( elems ); 11471 }; 11472} )( $.cleanData ); 11473 11474$.widget = function( name, base, prototype ) { 11475 var existingConstructor, constructor, basePrototype; 11476 11477 // ProxiedPrototype allows the provided prototype to remain unmodified 11478 // so that it can be used as a mixin for multiple widgets (#8876) 11479 var proxiedPrototype = {}; 11480 11481 var namespace = name.split( "." )[ 0 ]; 11482 name = name.split( "." )[ 1 ]; 11483 if ( name === "__proto__" || name === "constructor" ) { 11484 return $.error( "Invalid widget name: " + name ); 11485 }
vendor: 7,262 bytes, lines 11485-11746
11485 11486 var fullName = namespace + "-" + name; 11487 11488 if ( !prototype ) { 11489 prototype = base; 11490 base = $.Widget; 11491 } 11492 11493 if ( Array.isArray( prototype ) ) { 11494 prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); 11495 } 11496 11497 // Create selector for plugin 11498 $.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) { 11499 return !!$.data( elem, fullName ); 11500 }; 11501 11502 $[ namespace ] = $[ namespace ] || {}; 11503 existingConstructor = $[ namespace ][ name ]; 11504 constructor = $[ namespace ][ name ] = function( options, element ) { 11505 11506 // Allow instantiation without "new" keyword 11507 if ( !this || !this._createWidget ) { 11508 return new constructor( options, element ); 11509 } 11510 11511 // Allow instantiation without initializing for simple inheritance 11512 // must use "new" keyword (the code above always passes args) 11513 if ( arguments.length ) { 11514 this._createWidget( options, element ); 11515 } 11516 }; 11517 11518 // Extend with the existing constructor to carry over any static properties 11519 $.extend( constructor, existingConstructor, { 11520 version: prototype.version, 11521 11522 // Copy the object used to create the prototype in case we need to 11523 // redefine the widget later 11524 _proto: $.extend( {}, prototype ), 11525 11526 // Track widgets that inherit from this widget in case this widget is 11527 // redefined after a widget inherits from it 11528 _childConstructors: [] 11529 } ); 11530 11531 basePrototype = new base(); 11532 11533 // We need to make the options hash a property directly on the new instance 11534 // otherwise we'll modify the options hash on the prototype that we're 11535 // inheriting from 11536 basePrototype.options = $.widget.extend( {}, basePrototype.options ); 11537 $.each( prototype, function( prop, value ) { 11538 if ( typeof value !== "function" ) { 11539 proxiedPrototype[ prop ] = value; 11540 return; 11541 } 11542 proxiedPrototype[ prop ] = ( function() { 11543 function _super() { 11544 return base.prototype[ prop ].apply( this, arguments ); 11545 } 11546 11547 function _superApply( args ) { 11548 return base.prototype[ prop ].apply( this, args ); 11549 } 11550 11551 return function() { 11552 var __super = this._super; 11553 var __superApply = this._superApply; 11554 var returnValue; 11555 11556 this._super = _super; 11557 this._superApply = _superApply; 11558 11559 returnValue = value.apply( this, arguments ); 11560 11561 this._super = __super; 11562 this._superApply = __superApply; 11563 11564 return returnValue; 11565 }; 11566 } )(); 11567 } ); 11568 constructor.prototype = $.widget.extend( basePrototype, { 11569 11570 // TODO: remove support for widgetEventPrefix 11571 // always use the name + a colon as the prefix, e.g., draggable:start 11572 // don't prefix for widgets that aren't DOM-based 11573 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name 11574 }, proxiedPrototype, { 11575 constructor: constructor, 11576 namespace: namespace, 11577 widgetName: name, 11578 widgetFullName: fullName 11579 } ); 11580 11581 // If this widget is being redefined then we need to find all widgets that 11582 // are inheriting from it and redefine all of them so that they inherit from 11583 // the new version of this widget. We're essentially trying to replace one 11584 // level in the prototype chain. 11585 if ( existingConstructor ) { 11586 $.each( existingConstructor._childConstructors, function( i, child ) { 11587 var childPrototype = child.prototype; 11588 11589 // Redefine the child widget using the same prototype that was 11590 // originally used, but inherit from the new version of the base 11591 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, 11592 child._proto ); 11593 } ); 11594 11595 // Remove the list of existing child constructors from the old constructor 11596 // so the old child constructors can be garbage collected 11597 delete existingConstructor._childConstructors; 11598 } else { 11599 base._childConstructors.push( constructor ); 11600 } 11601 11602 $.widget.bridge( name, constructor ); 11603 11604 return constructor; 11605}; 11606 11607$.widget.extend = function( target ) { 11608 var input = widgetSlice.call( arguments, 1 ); 11609 var inputIndex = 0; 11610 var inputLength = input.length; 11611 var key; 11612 var value; 11613 11614 for ( ; inputIndex < inputLength; inputIndex++ ) { 11615 for ( key in input[ inputIndex ] ) { 11616 value = input[ inputIndex ][ key ]; 11617 if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) { 11618 11619 // Clone objects 11620 if ( $.isPlainObject( value ) ) { 11621 target[ key ] = $.isPlainObject( target[ key ] ) ? 11622 $.widget.extend( {}, target[ key ], value ) : 11623 11624 // Don't extend strings, arrays, etc. with objects 11625 $.widget.extend( {}, value ); 11626 11627 // Copy everything else by reference 11628 } else { 11629 target[ key ] = value; 11630 } 11631 } 11632 } 11633 } 11634 return target; 11635}; 11636 11637$.widget.bridge = function( name, object ) { 11638 var fullName = object.prototype.widgetFullName || name; 11639 $.fn[ name ] = function( options ) { 11640 var isMethodCall = typeof options === "string"; 11641 var args = widgetSlice.call( arguments, 1 ); 11642 var returnValue = this; 11643 11644 if ( isMethodCall ) { 11645 11646 // If this is an empty collection, we need to have the instance method 11647 // return undefined instead of the jQuery instance 11648 if ( !this.length && options === "instance" ) { 11649 returnValue = undefined; 11650 } else { 11651 this.each( function() { 11652 var methodValue; 11653 var instance = $.data( this, fullName ); 11654 11655 if ( options === "instance" ) { 11656 returnValue = instance; 11657 return false; 11658 } 11659 11660 if ( !instance ) { 11661 return $.error( "cannot call methods on " + name + 11662 " prior to initialization; " + 11663 "attempted to call method '" + options + "'" ); 11664 } 11665 11666 if ( typeof instance[ options ] !== "function" || 11667 options.charAt( 0 ) === "_" ) { 11668 return $.error( "no such method '" + options + "' for " + name + 11669 " widget instance" ); 11670 } 11671 11672 methodValue = instance[ options ].apply( instance, args ); 11673 11674 if ( methodValue !== instance && methodValue !== undefined ) { 11675 returnValue = methodValue && methodValue.jquery ? 11676 returnValue.pushStack( methodValue.get() ) : 11677 methodValue; 11678 return false; 11679 } 11680 } ); 11681 } 11682 } else { 11683 11684 // Allow multiple hashes to be passed on init 11685 if ( args.length ) { 11686 options = $.widget.extend.apply( null, [ options ].concat( args ) ); 11687 } 11688 11689 this.each( function() { 11690 var instance = $.data( this, fullName ); 11691 if ( instance ) { 11692 instance.option( options || {} ); 11693 if ( instance._init ) { 11694 instance._init(); 11695 } 11696 } else { 11697 $.data( this, fullName, new object( options, this ) ); 11698 } 11699 } ); 11700 } 11701 11702 return returnValue; 11703 }; 11704}; 11705 11706$.Widget = function( /* options, element */ ) {}; 11707$.Widget._childConstructors = []; 11708 11709$.Widget.prototype = { 11710 widgetName: "widget", 11711 widgetEventPrefix: "", 11712 defaultElement: "<div>", 11713 11714 options: { 11715 classes: {}, 11716 disabled: false, 11717 11718 // Callbacks 11719 create: null 11720 }, 11721 11722 _createWidget: function( options, element ) { 11723 element = $( element || this.defaultElement || this )[ 0 ]; 11724 this.element = $( element ); 11725 this.uuid = widgetUuid++; 11726 this.eventNamespace = "." + this.widgetName + this.uuid; 11727 11728 this.bindings = $(); 11729 this.hoverable = $(); 11730 this.focusable = $(); 11731 this.classesElementLookup = {}; 11732 11733 if ( element !== this ) { 11734 $.data( element, this.widgetFullName, this ); 11735 this._on( true, this.element, { 11736 remove: function( event ) { 11737 if ( event.target === element ) { 11738 this.destroy(); 11739 } 11740 } 11741 } ); 11742 this.document = $( element.style ? 11743 11744 // Element within the document 11745 element.ownerDocument : 11746
vendor: 11,507 bytes, lines 11747-12180
11747 // Element is window or document 11748 element.document || element ); 11749 this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); 11750 } 11751 11752 this.options = $.widget.extend( {}, 11753 this.options, 11754 this._getCreateOptions(), 11755 options ); 11756 11757 this._create(); 11758 11759 if ( this.options.disabled ) { 11760 this._setOptionDisabled( this.options.disabled ); 11761 } 11762 11763 this._trigger( "create", null, this._getCreateEventData() ); 11764 this._init(); 11765 }, 11766 11767 _getCreateOptions: function() { 11768 return {}; 11769 }, 11770 11771 _getCreateEventData: $.noop, 11772 11773 _create: $.noop, 11774 11775 _init: $.noop, 11776 11777 destroy: function() { 11778 var that = this; 11779 11780 this._destroy(); 11781 $.each( this.classesElementLookup, function( key, value ) { 11782 that._removeClass( value, key ); 11783 } ); 11784 11785 // We can probably remove the unbind calls in 2.0 11786 // all event bindings should go through this._on() 11787 this.element 11788 .off( this.eventNamespace ) 11789 .removeData( this.widgetFullName ); 11790 this.widget() 11791 .off( this.eventNamespace ) 11792 .removeAttr( "aria-disabled" ); 11793 11794 // Clean up events and states 11795 this.bindings.off( this.eventNamespace ); 11796 }, 11797 11798 _destroy: $.noop, 11799 11800 widget: function() { 11801 return this.element; 11802 }, 11803 11804 option: function( key, value ) { 11805 var options = key; 11806 var parts; 11807 var curOption; 11808 var i; 11809 11810 if ( arguments.length === 0 ) { 11811 11812 // Don't return a reference to the internal hash 11813 return $.widget.extend( {}, this.options ); 11814 } 11815 11816 if ( typeof key === "string" ) { 11817 11818 // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 11819 options = {}; 11820 parts = key.split( "." ); 11821 key = parts.shift(); 11822 if ( parts.length ) { 11823 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); 11824 for ( i = 0; i < parts.length - 1; i++ ) { 11825 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; 11826 curOption = curOption[ parts[ i ] ]; 11827 } 11828 key = parts.pop(); 11829 if ( arguments.length === 1 ) { 11830 return curOption[ key ] === undefined ? null : curOption[ key ]; 11831 } 11832 curOption[ key ] = value; 11833 } else { 11834 if ( arguments.length === 1 ) { 11835 return this.options[ key ] === undefined ? null : this.options[ key ]; 11836 } 11837 options[ key ] = value; 11838 } 11839 } 11840 11841 this._setOptions( options ); 11842 11843 return this; 11844 }, 11845 11846 _setOptions: function( options ) { 11847 var key; 11848 11849 for ( key in options ) { 11850 this._setOption( key, options[ key ] ); 11851 } 11852 11853 return this; 11854 }, 11855 11856 _setOption: function( key, value ) { 11857 if ( key === "classes" ) { 11858 this._setOptionClasses( value ); 11859 } 11860 11861 this.options[ key ] = value; 11862 11863 if ( key === "disabled" ) { 11864 this._setOptionDisabled( value ); 11865 } 11866 11867 return this; 11868 }, 11869 11870 _setOptionClasses: function( value ) { 11871 var classKey, elements, currentElements; 11872 11873 for ( classKey in value ) { 11874 currentElements = this.classesElementLookup[ classKey ]; 11875 if ( value[ classKey ] === this.options.classes[ classKey ] || 11876 !currentElements || 11877 !currentElements.length ) { 11878 continue; 11879 } 11880 11881 // We are doing this to create a new jQuery object because the _removeClass() call 11882 // on the next line is going to destroy the reference to the current elements being 11883 // tracked. We need to save a copy of this collection so that we can add the new classes 11884 // below. 11885 elements = $( currentElements.get() ); 11886 this._removeClass( currentElements, classKey ); 11887 11888 // We don't use _addClass() here, because that uses this.options.classes 11889 // for generating the string of classes. We want to use the value passed in from 11890 // _setOption(), this is the new value of the classes option which was passed to 11891 // _setOption(). We pass this value directly to _classes(). 11892 elements.addClass( this._classes( { 11893 element: elements, 11894 keys: classKey, 11895 classes: value, 11896 add: true 11897 } ) ); 11898 } 11899 }, 11900 11901 _setOptionDisabled: function( value ) { 11902 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); 11903 11904 // If the widget is becoming disabled, then nothing is interactive 11905 if ( value ) { 11906 this._removeClass( this.hoverable, null, "ui-state-hover" ); 11907 this._removeClass( this.focusable, null, "ui-state-focus" ); 11908 } 11909 }, 11910 11911 enable: function() { 11912 return this._setOptions( { disabled: false } ); 11913 }, 11914 11915 disable: function() { 11916 return this._setOptions( { disabled: true } ); 11917 }, 11918 11919 _classes: function( options ) { 11920 var full = []; 11921 var that = this; 11922 11923 options = $.extend( { 11924 element: this.element, 11925 classes: this.options.classes || {} 11926 }, options ); 11927 11928 function bindRemoveEvent() { 11929 var nodesToBind = []; 11930 11931 options.element.each( function( _, element ) { 11932 var isTracked = $.map( that.classesElementLookup, function( elements ) { 11933 return elements; 11934 } ) 11935 .some( function( elements ) { 11936 return elements.is( element ); 11937 } ); 11938 11939 if ( !isTracked ) { 11940 nodesToBind.push( element ); 11941 } 11942 } ); 11943 11944 that._on( $( nodesToBind ), { 11945 remove: "_untrackClassesElement" 11946 } ); 11947 } 11948 11949 function processClassString( classes, checkOption ) { 11950 var current, i; 11951 for ( i = 0; i < classes.length; i++ ) { 11952 current = that.classesElementLookup[ classes[ i ] ] || $(); 11953 if ( options.add ) { 11954 bindRemoveEvent(); 11955 current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) ); 11956 } else { 11957 current = $( current.not( options.element ).get() ); 11958 } 11959 that.classesElementLookup[ classes[ i ] ] = current; 11960 full.push( classes[ i ] ); 11961 if ( checkOption && options.classes[ classes[ i ] ] ) { 11962 full.push( options.classes[ classes[ i ] ] ); 11963 } 11964 } 11965 } 11966 11967 if ( options.keys ) { 11968 processClassString( options.keys.match( /\S+/g ) || [], true ); 11969 } 11970 if ( options.extra ) { 11971 processClassString( options.extra.match( /\S+/g ) || [] ); 11972 } 11973 11974 return full.join( " " ); 11975 }, 11976 11977 _untrackClassesElement: function( event ) { 11978 var that = this; 11979 $.each( that.classesElementLookup, function( key, value ) { 11980 if ( $.inArray( event.target, value ) !== -1 ) { 11981 that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); 11982 } 11983 } ); 11984 11985 this._off( $( event.target ) ); 11986 }, 11987 11988 _removeClass: function( element, keys, extra ) { 11989 return this._toggleClass( element, keys, extra, false ); 11990 }, 11991 11992 _addClass: function( element, keys, extra ) { 11993 return this._toggleClass( element, keys, extra, true ); 11994 }, 11995 11996 _toggleClass: function( element, keys, extra, add ) { 11997 add = ( typeof add === "boolean" ) ? add : extra; 11998 var shift = ( typeof element === "string" || element === null ), 11999 options = { 12000 extra: shift ? keys : extra, 12001 keys: shift ? element : keys, 12002 element: shift ? this.element : element, 12003 add: add 12004 }; 12005 options.element.toggleClass( this._classes( options ), add ); 12006 return this; 12007 }, 12008 12009 _on: function( suppressDisabledCheck, element, handlers ) { 12010 var delegateElement; 12011 var instance = this; 12012 12013 // No suppressDisabledCheck flag, shuffle arguments 12014 if ( typeof suppressDisabledCheck !== "boolean" ) { 12015 handlers = element; 12016 element = suppressDisabledCheck; 12017 suppressDisabledCheck = false; 12018 } 12019 12020 // No element argument, shuffle and use this.element 12021 if ( !handlers ) { 12022 handlers = element; 12023 element = this.element; 12024 delegateElement = this.widget(); 12025 } else { 12026 element = delegateElement = $( element ); 12027 this.bindings = this.bindings.add( element ); 12028 } 12029 12030 $.each( handlers, function( event, handler ) { 12031 function handlerProxy() { 12032 12033 // Allow widgets to customize the disabled handling 12034 // - disabled as an array instead of boolean 12035 // - disabled class as method for disabling individual parts 12036 if ( !suppressDisabledCheck && 12037 ( instance.options.disabled === true || 12038 $( this ).hasClass( "ui-state-disabled" ) ) ) { 12039 return; 12040 } 12041 return ( typeof handler === "string" ? instance[ handler ] : handler ) 12042 .apply( instance, arguments ); 12043 } 12044 12045 // Copy the guid so direct unbinding works 12046 if ( typeof handler !== "string" ) { 12047 handlerProxy.guid = handler.guid = 12048 handler.guid || handlerProxy.guid || $.guid++; 12049 } 12050 12051 var match = event.match( /^([\w:-]*)\s*(.*)$/ ); 12052 var eventName = match[ 1 ] + instance.eventNamespace; 12053 var selector = match[ 2 ]; 12054 12055 if ( selector ) { 12056 delegateElement.on( eventName, selector, handlerProxy ); 12057 } else { 12058 element.on( eventName, handlerProxy ); 12059 } 12060 } ); 12061 }, 12062 12063 _off: function( element, eventName ) { 12064 eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + 12065 this.eventNamespace; 12066 element.off( eventName ); 12067 12068 // Clear the stack to avoid memory leaks (#10056) 12069 this.bindings = $( this.bindings.not( element ).get() ); 12070 this.focusable = $( this.focusable.not( element ).get() ); 12071 this.hoverable = $( this.hoverable.not( element ).get() ); 12072 }, 12073 12074 _delay: function( handler, delay ) { 12075 function handlerProxy() { 12076 return ( typeof handler === "string" ? instance[ handler ] : handler ) 12077 .apply( instance, arguments ); 12078 } 12079 var instance = this; 12080 return setTimeout( handlerProxy, delay || 0 ); 12081 }, 12082 12083 _hoverable: function( element ) { 12084 this.hoverable = this.hoverable.add( element ); 12085 this._on( element, { 12086 mouseenter: function( event ) { 12087 this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); 12088 }, 12089 mouseleave: function( event ) { 12090 this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); 12091 } 12092 } ); 12093 }, 12094 12095 _focusable: function( element ) { 12096 this.focusable = this.focusable.add( element ); 12097 this._on( element, { 12098 focusin: function( event ) { 12099 this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); 12100 }, 12101 focusout: function( event ) { 12102 this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); 12103 } 12104 } ); 12105 }, 12106 12107 _trigger: function( type, event, data ) { 12108 var prop, orig; 12109 var callback = this.options[ type ]; 12110 12111 data = data || {}; 12112 event = $.Event( event ); 12113 event.type = ( type === this.widgetEventPrefix ? 12114 type : 12115 this.widgetEventPrefix + type ).toLowerCase(); 12116 12117 // The original event may come from any element 12118 // so we need to reset the target on the new event 12119 event.target = this.element[ 0 ]; 12120 12121 // Copy original event properties over to the new event 12122 orig = event.originalEvent; 12123 if ( orig ) { 12124 for ( prop in orig ) { 12125 if ( !( prop in event ) ) { 12126 event[ prop ] = orig[ prop ]; 12127 } 12128 } 12129 } 12130 12131 this.element.trigger( event, data ); 12132 return !( typeof callback === "function" && 12133 callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || 12134 event.isDefaultPrevented() ); 12135 } 12136}; 12137 12138$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { 12139 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { 12140 if ( typeof options === "string" ) { 12141 options = { effect: options }; 12142 } 12143 12144 var hasOptions; 12145 var effectName = !options ? 12146 method : 12147 options === true || typeof options === "number" ? 12148 defaultEffect : 12149 options.effect || defaultEffect; 12150 12151 options = options || {}; 12152 if ( typeof options === "number" ) { 12153 options = { duration: options }; 12154 } else if ( options === true ) { 12155 options = {}; 12156 } 12157 12158 hasOptions = !$.isEmptyObject( options ); 12159 options.complete = callback; 12160 12161 if ( options.delay ) { 12162 element.delay( options.delay ); 12163 } 12164 12165 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 12166 element[ method ]( options ); 12167 } else if ( effectName !== method && element[ effectName ] ) { 12168 element[ effectName ]( options.duration, options.easing, callback ); 12169 } else { 12170 element.queue( function( next ) { 12171 $( this )[ method ](); 12172 if ( callback ) { 12173 callback.call( element[ 0 ] ); 12174 } 12175 next(); 12176 } ); 12177 } 12178 }; 12179} ); 12180
vendor: 9,810 bytes, lines 12181-12603
12181return $.widget; 12182 12183} ); 12184 12185 12186 12187/*! 12188 * jQuery UI Mouse 1.14.1 12189 * https://jqueryui.com 12190 * 12191 * Copyright OpenJS Foundation and other contributors 12192 * Released under the MIT license. 12193 * https://jquery.org/license 12194 */ 12195 12196//>>label: Mouse 12197//>>group: Widgets 12198//>>description: Abstracts mouse-based interactions to assist in creating certain widgets. 12199//>>docs: https://api.jqueryui.com/mouse/ 12200 12201( function( factory ) { 12202 "use strict"; 12203 12204 if ( typeof define === "function" && define.amd ) { 12205 12206 // AMD. Register as an anonymous module. 12207 define( [ 12208 "jquery", 12209 "../version", 12210 "../widget" 12211 ], factory ); 12212 } else { 12213 12214 // Browser globals 12215 factory( jQuery ); 12216 } 12217} )( function( $ ) { 12218"use strict"; 12219 12220var mouseHandled = false; 12221$( document ).on( "mouseup", function() { 12222 mouseHandled = false; 12223} ); 12224 12225return $.widget( "ui.mouse", { 12226 version: "1.14.1", 12227 options: { 12228 cancel: "input, textarea, button, select, option", 12229 distance: 1, 12230 delay: 0 12231 }, 12232 _mouseInit: function() { 12233 var that = this; 12234 12235 this.element 12236 .on( "mousedown." + this.widgetName, function( event ) { 12237 return that._mouseDown( event ); 12238 } ) 12239 .on( "click." + this.widgetName, function( event ) { 12240 if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) { 12241 $.removeData( event.target, that.widgetName + ".preventClickEvent" ); 12242 event.stopImmediatePropagation(); 12243 return false; 12244 } 12245 } ); 12246 12247 this.started = false; 12248 }, 12249 12250 // TODO: make sure destroying one instance of mouse doesn't mess with 12251 // other instances of mouse 12252 _mouseDestroy: function() { 12253 this.element.off( "." + this.widgetName ); 12254 if ( this._mouseMoveDelegate ) { 12255 this.document 12256 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 12257 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 12258 } 12259 }, 12260 12261 _mouseDown: function( event ) { 12262 12263 // don't let more than one widget handle mouseStart 12264 if ( mouseHandled ) { 12265 return; 12266 } 12267 12268 this._mouseMoved = false; 12269 12270 // We may have missed mouseup (out of window) 12271 if ( this._mouseStarted ) { 12272 this._mouseUp( event ); 12273 } 12274 12275 this._mouseDownEvent = event; 12276 12277 var that = this, 12278 btnIsLeft = event.which === 1, 12279 elIsCancel = typeof this.options.cancel === "string" ? 12280 $( event.target ).closest( this.options.cancel ).length : 12281 false; 12282 if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { 12283 return true; 12284 } 12285 12286 this.mouseDelayMet = !this.options.delay; 12287 if ( !this.mouseDelayMet ) { 12288 this._mouseDelayTimer = setTimeout( function() { 12289 that.mouseDelayMet = true; 12290 }, this.options.delay ); 12291 } 12292 12293 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 12294 this._mouseStarted = ( this._mouseStart( event ) !== false ); 12295 if ( !this._mouseStarted ) { 12296 event.preventDefault(); 12297 return true; 12298 } 12299 } 12300 12301 // Click event may never have fired (Gecko & Opera) 12302 if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) { 12303 $.removeData( event.target, this.widgetName + ".preventClickEvent" ); 12304 } 12305 12306 // These delegates are required to keep context 12307 this._mouseMoveDelegate = function( event ) { 12308 return that._mouseMove( event ); 12309 }; 12310 this._mouseUpDelegate = function( event ) { 12311 return that._mouseUp( event ); 12312 }; 12313 12314 this.document 12315 .on( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 12316 .on( "mouseup." + this.widgetName, this._mouseUpDelegate ); 12317 12318 event.preventDefault(); 12319 12320 mouseHandled = true; 12321 return true; 12322 }, 12323 12324 _mouseMove: function( event ) { 12325 12326 // Only check for mouseups outside the document if you've moved inside the document 12327 // at least once. 12328 if ( this._mouseMoved && !event.which ) { 12329 12330 // Support: Safari <=8 - 9 12331 // Safari sets which to 0 if you press any of the following keys 12332 // during a drag (#14461) 12333 if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || 12334 event.originalEvent.metaKey || event.originalEvent.shiftKey ) { 12335 this.ignoreMissingWhich = true; 12336 } else if ( !this.ignoreMissingWhich ) { 12337 return this._mouseUp( event ); 12338 } 12339 } 12340 12341 if ( event.which || event.button ) { 12342 this._mouseMoved = true; 12343 } 12344 12345 if ( this._mouseStarted ) { 12346 this._mouseDrag( event ); 12347 return event.preventDefault(); 12348 } 12349 12350 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 12351 this._mouseStarted = 12352 ( this._mouseStart( this._mouseDownEvent, event ) !== false ); 12353 if ( this._mouseStarted ) { 12354 this._mouseDrag( event ); 12355 } else { 12356 this._mouseUp( event ); 12357 } 12358 } 12359 12360 return !this._mouseStarted; 12361 }, 12362 12363 _mouseUp: function( event ) { 12364 this.document 12365 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 12366 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 12367 12368 if ( this._mouseStarted ) { 12369 this._mouseStarted = false; 12370 12371 if ( event.target === this._mouseDownEvent.target ) { 12372 $.data( event.target, this.widgetName + ".preventClickEvent", true ); 12373 } 12374 12375 this._mouseStop( event ); 12376 } 12377 12378 if ( this._mouseDelayTimer ) { 12379 clearTimeout( this._mouseDelayTimer ); 12380 delete this._mouseDelayTimer; 12381 } 12382 12383 this.ignoreMissingWhich = false; 12384 mouseHandled = false; 12385 event.preventDefault(); 12386 }, 12387 12388 _mouseDistanceMet: function( event ) { 12389 return ( Math.max( 12390 Math.abs( this._mouseDownEvent.pageX - event.pageX ), 12391 Math.abs( this._mouseDownEvent.pageY - event.pageY ) 12392 ) >= this.options.distance 12393 ); 12394 }, 12395 12396 _mouseDelayMet: function( /* event */ ) { 12397 return this.mouseDelayMet; 12398 }, 12399 12400 // These are placeholder methods, to be overriden by extending plugin 12401 _mouseStart: function( /* event */ ) {}, 12402 _mouseDrag: function( /* event */ ) {}, 12403 _mouseStop: function( /* event */ ) {}, 12404 _mouseCapture: function( /* event */ ) { 12405 return true; 12406 } 12407} ); 12408 12409} ); 12410 12411 12412/*! 12413 * jQuery UI Keycode 1.14.1 12414 * https://jqueryui.com 12415 * 12416 * Copyright OpenJS Foundation and other contributors 12417 * Released under the MIT license. 12418 * https://jquery.org/license 12419 */ 12420 12421//>>label: Keycode 12422//>>group: Core 12423//>>description: Provide keycodes as keynames 12424//>>docs: https://api.jqueryui.com/jQuery.ui.keyCode/ 12425 12426( function( factory ) { 12427 "use strict"; 12428 12429 if ( typeof define === "function" && define.amd ) { 12430 12431 // AMD. Register as an anonymous module. 12432 define( [ "jquery", "./version" ], factory ); 12433 } else { 12434 12435 // Browser globals 12436 factory( jQuery ); 12437 } 12438} )( function( $ ) { 12439"use strict"; 12440 12441return $.ui.keyCode = { 12442 BACKSPACE: 8, 12443 COMMA: 188, 12444 DELETE: 46, 12445 DOWN: 40, 12446 END: 35, 12447 ENTER: 13, 12448 ESCAPE: 27, 12449 HOME: 36, 12450 LEFT: 37, 12451 PAGE_DOWN: 34, 12452 PAGE_UP: 33, 12453 PERIOD: 190, 12454 RIGHT: 39, 12455 SPACE: 32, 12456 TAB: 9, 12457 UP: 38 12458}; 12459 12460} ); 12461 12462 12463 12464 12465 12466/*! 12467 * jQuery UI Slider 1.14.1 12468 * https://jqueryui.com 12469 * 12470 * Copyright OpenJS Foundation and other contributors 12471 * Released under the MIT license. 12472 * https://jquery.org/license 12473 */ 12474 12475//>>label: Slider 12476//>>group: Widgets 12477//>>description: Displays a flexible slider with ranges and accessibility via keyboard. 12478//>>docs: https://api.jqueryui.com/slider/ 12479//>>demos: https://jqueryui.com/slider/ 12480//>>css.structure: ../../themes/base/core.css 12481//>>css.structure: ../../themes/base/slider.css 12482//>>css.theme: ../../themes/base/theme.css 12483 12484( function( factory ) { 12485 "use strict"; 12486 12487 if ( typeof define === "function" && define.amd ) { 12488 12489 // AMD. Register as an anonymous module. 12490 define( [ 12491 "jquery", 12492 "./mouse", 12493 "../keycode", 12494 "../version", 12495 "../widget" 12496 ], factory ); 12497 } else { 12498 12499 // Browser globals 12500 factory( jQuery ); 12501 } 12502} )( function( $ ) { 12503"use strict"; 12504 12505return $.widget( "ui.slider", $.ui.mouse, { 12506 version: "1.14.1", 12507 widgetEventPrefix: "slide", 12508 12509 options: { 12510 animate: false, 12511 classes: { 12512 "ui-slider": "ui-corner-all", 12513 "ui-slider-handle": "ui-corner-all", 12514 12515 // Note: ui-widget-header isn't the most fittingly semantic framework class for this 12516 // element, but worked best visually with a variety of themes 12517 "ui-slider-range": "ui-corner-all ui-widget-header" 12518 }, 12519 distance: 0, 12520 max: 100, 12521 min: 0, 12522 orientation: "horizontal", 12523 range: false, 12524 step: 1, 12525 value: 0, 12526 values: null, 12527 12528 // Callbacks 12529 change: null, 12530 slide: null, 12531 start: null, 12532 stop: null 12533 }, 12534 12535 // Number of pages in a slider 12536 // (how many times can you page up/down to go through the whole range) 12537 numPages: 5, 12538 12539 _create: function() { 12540 this._keySliding = false; 12541 this._mouseSliding = false; 12542 this._animateOff = true; 12543 this._handleIndex = null; 12544 this._detectOrientation(); 12545 this._mouseInit(); 12546 this._calculateNewMax(); 12547 12548 this._addClass( "ui-slider ui-slider-" + this.orientation, 12549 "ui-widget ui-widget-content" ); 12550 12551 this._refresh(); 12552 12553 this._animateOff = false; 12554 }, 12555 12556 _refresh: function() { 12557 this._createRange(); 12558 this._createHandles(); 12559 this._setupEvents(); 12560 this._refreshValue(); 12561 }, 12562 12563 _createHandles: function() { 12564 var i, handleCount, 12565 options = this.options, 12566 existingHandles = this.element.find( ".ui-slider-handle" ), 12567 handle = "<span tabindex='0'></span>", 12568 handles = []; 12569 12570 handleCount = ( options.values && options.values.length ) || 1; 12571 12572 if ( existingHandles.length > handleCount ) { 12573 existingHandles.slice( handleCount ).remove(); 12574 existingHandles = existingHandles.slice( 0, handleCount ); 12575 } 12576 12577 for ( i = existingHandles.length; i < handleCount; i++ ) { 12578 handles.push( handle ); 12579 } 12580 12581 this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) ); 12582 12583 this._addClass( this.handles, "ui-slider-handle", "ui-state-default" ); 12584 12585 this.handle = this.handles.eq( 0 ); 12586 12587 this.handles.each( function( i ) { 12588 $( this ) 12589 .data( "ui-slider-handle-index", i ) 12590 .attr( "tabIndex", 0 ); 12591 } ); 12592 }, 12593 12594 _createRange: function() { 12595 var options = this.options; 12596 12597 if ( options.range ) { 12598 if ( options.range === true ) { 12599 if ( !options.values ) { 12600 options.values = [ this._valueMin(), this._valueMin() ]; 12601 } else if ( options.values.length && options.values.length !== 2 ) { 12602 options.values = [ options.values[ 0 ], options.values[ 0 ] ]; 12603 } else if ( Array
vendor: 6,343 bytes, lines 12603-12849
12603.isArray( options.values ) ) { 12604 options.values = options.values.slice( 0 ); 12605 } 12606 } 12607 12608 if ( !this.range || !this.range.length ) { 12609 this.range = $( "<div>" ) 12610 .appendTo( this.element ); 12611 12612 this._addClass( this.range, "ui-slider-range" ); 12613 } else { 12614 this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" ); 12615 12616 // Handle range switching from true to min/max 12617 this.range.css( { 12618 "left": "", 12619 "bottom": "" 12620 } ); 12621 } 12622 if ( options.range === "min" || options.range === "max" ) { 12623 this._addClass( this.range, "ui-slider-range-" + options.range ); 12624 } 12625 } else { 12626 if ( this.range ) { 12627 this.range.remove(); 12628 } 12629 this.range = null; 12630 } 12631 }, 12632 12633 _setupEvents: function() { 12634 this._off( this.handles ); 12635 this._on( this.handles, this._handleEvents ); 12636 this._hoverable( this.handles ); 12637 this._focusable( this.handles ); 12638 }, 12639 12640 _destroy: function() { 12641 this.handles.remove(); 12642 if ( this.range ) { 12643 this.range.remove(); 12644 } 12645 12646 this._mouseDestroy(); 12647 }, 12648 12649 _mouseCapture: function( event ) { 12650 var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle, 12651 that = this, 12652 o = this.options; 12653 12654 if ( o.disabled ) { 12655 return false; 12656 } 12657 12658 this.elementSize = { 12659 width: this.element.outerWidth(), 12660 height: this.element.outerHeight() 12661 }; 12662 this.elementOffset = this.element.offset(); 12663 12664 position = { x: event.pageX, y: event.pageY }; 12665 normValue = this._normValueFromMouse( position ); 12666 distance = this._valueMax() - this._valueMin() + 1; 12667 this.handles.each( function( i ) { 12668 var thisDistance = Math.abs( normValue - that.values( i ) ); 12669 if ( ( distance > thisDistance ) || 12670 ( distance === thisDistance && 12671 ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) { 12672 distance = thisDistance; 12673 closestHandle = $( this ); 12674 index = i; 12675 } 12676 } ); 12677 12678 allowed = this._start( event, index ); 12679 if ( allowed === false ) { 12680 return false; 12681 } 12682 this._mouseSliding = true; 12683 12684 this._handleIndex = index; 12685 12686 this._addClass( closestHandle, null, "ui-state-active" ); 12687 closestHandle.trigger( "focus" ); 12688 12689 offset = closestHandle.offset(); 12690 mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" ); 12691 this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { 12692 left: event.pageX - offset.left - ( closestHandle.width() / 2 ), 12693 top: event.pageY - offset.top - 12694 ( closestHandle.height() / 2 ) - 12695 ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) - 12696 ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) + 12697 ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 ) 12698 }; 12699 12700 if ( !this.handles.hasClass( "ui-state-hover" ) ) { 12701 this._slide( event, index, normValue ); 12702 } 12703 this._animateOff = true; 12704 return true; 12705 }, 12706 12707 _mouseStart: function() { 12708 return true; 12709 }, 12710 12711 _mouseDrag: function( event ) { 12712 var position = { x: event.pageX, y: event.pageY }, 12713 normValue = this._normValueFromMouse( position ); 12714 12715 this._slide( event, this._handleIndex, normValue ); 12716 12717 return false; 12718 }, 12719 12720 _mouseStop: function( event ) { 12721 this._removeClass( this.handles, null, "ui-state-active" ); 12722 this._mouseSliding = false; 12723 12724 this._stop( event, this._handleIndex ); 12725 this._change( event, this._handleIndex ); 12726 12727 this._handleIndex = null; 12728 this._clickOffset = null; 12729 this._animateOff = false; 12730 12731 return false; 12732 }, 12733 12734 _detectOrientation: function() { 12735 this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal"; 12736 }, 12737 12738 _normValueFromMouse: function( position ) { 12739 var pixelTotal, 12740 pixelMouse, 12741 percentMouse, 12742 valueTotal, 12743 valueMouse; 12744 12745 if ( this.orientation === "horizontal" ) { 12746 pixelTotal = this.elementSize.width; 12747 pixelMouse = position.x - this.elementOffset.left - 12748 ( this._clickOffset ? this._clickOffset.left : 0 ); 12749 } else { 12750 pixelTotal = this.elementSize.height; 12751 pixelMouse = position.y - this.elementOffset.top - 12752 ( this._clickOffset ? this._clickOffset.top : 0 ); 12753 } 12754 12755 percentMouse = ( pixelMouse / pixelTotal ); 12756 if ( percentMouse > 1 ) { 12757 percentMouse = 1; 12758 } 12759 if ( percentMouse < 0 ) { 12760 percentMouse = 0; 12761 } 12762 if ( this.orientation === "vertical" ) { 12763 percentMouse = 1 - percentMouse; 12764 } 12765 12766 valueTotal = this._valueMax() - this._valueMin(); 12767 valueMouse = this._valueMin() + percentMouse * valueTotal; 12768 12769 return this._trimAlignValue( valueMouse ); 12770 }, 12771 12772 _uiHash: function( index, value, values ) { 12773 var uiHash = { 12774 handle: this.handles[ index ], 12775 handleIndex: index, 12776 value: value !== undefined ? value : this.value() 12777 }; 12778 12779 if ( this._hasMultipleValues() ) { 12780 uiHash.value = value !== undefined ? value : this.values( index ); 12781 uiHash.values = values || this.values(); 12782 } 12783 12784 return uiHash; 12785 }, 12786 12787 _hasMultipleValues: function() { 12788 return this.options.values && this.options.values.length; 12789 }, 12790 12791 _start: function( event, index ) { 12792 return this._trigger( "start", event, this._uiHash( index ) ); 12793 }, 12794 12795 _slide: function( event, index, newVal ) { 12796 var allowed, otherVal, 12797 currentValue = this.value(), 12798 newValues = this.values(); 12799 12800 if ( this._hasMultipleValues() ) { 12801 otherVal = this.values( index ? 0 : 1 ); 12802 currentValue = this.values( index ); 12803 12804 if ( this.options.values.length === 2 && this.options.range === true ) { 12805 newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal ); 12806 } 12807 12808 newValues[ index ] = newVal; 12809 } 12810 12811 if ( newVal === currentValue ) { 12812 return; 12813 } 12814 12815 allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) ); 12816 12817 // A slide can be canceled by returning false from the slide callback 12818 if ( allowed === false ) { 12819 return; 12820 } 12821 12822 if ( this._hasMultipleValues() ) { 12823 this.values( index, newVal ); 12824 } else { 12825 this.value( newVal ); 12826 } 12827 }, 12828 12829 _stop: function( event, index ) { 12830 this._trigger( "stop", event, this._uiHash( index ) ); 12831 }, 12832 12833 _change: function( event, index ) { 12834 if ( !this._keySliding && !this._mouseSliding ) { 12835 12836 //store the last changed value index for reference when handles overlap 12837 this._lastChangedValue = index; 12838 this._trigger( "change", event, this._uiHash( index ) ); 12839 } 12840 }, 12841 12842 value: function( newValue ) { 12843 if ( arguments.length ) { 12844 this.options.value = this._trimAlignValue( newValue ); 12845 this._refreshValue(); 12846 this._change( null, 0 ); 12847 return; 12848 } 12849
vendor: 4,358 bytes, lines 12850-13022
12850 return this._value(); 12851 }, 12852 12853 values: function( index, newValue ) { 12854 var vals, 12855 newValues, 12856 i; 12857 12858 if ( arguments.length > 1 ) { 12859 this.options.values[ index ] = this._trimAlignValue( newValue ); 12860 this._refreshValue(); 12861 this._change( null, index ); 12862 return; 12863 } 12864 12865 if ( arguments.length ) { 12866 if ( Array.isArray( arguments[ 0 ] ) ) { 12867 vals = this.options.values; 12868 newValues = arguments[ 0 ]; 12869 for ( i = 0; i < vals.length; i += 1 ) { 12870 vals[ i ] = this._trimAlignValue( newValues[ i ] ); 12871 this._change( null, i ); 12872 } 12873 this._refreshValue(); 12874 } else { 12875 if ( this._hasMultipleValues() ) { 12876 return this._values( index ); 12877 } else { 12878 return this.value(); 12879 } 12880 } 12881 } else { 12882 return this._values(); 12883 } 12884 }, 12885 12886 _setOption: function( key, value ) { 12887 var i, 12888 valsLength = 0; 12889 12890 if ( key === "range" && this.options.range === true ) { 12891 if ( value === "min" ) { 12892 this.options.value = this._values( 0 ); 12893 this.options.values = null; 12894 } else if ( value === "max" ) { 12895 this.options.value = this._values( this.options.values.length - 1 ); 12896 this.options.values = null; 12897 } 12898 } 12899 12900 if ( Array.isArray( this.options.values ) ) { 12901 valsLength = this.options.values.length; 12902 } 12903 12904 this._super( key, value ); 12905 12906 switch ( key ) { 12907 case "orientation": 12908 this._detectOrientation(); 12909 this._removeClass( "ui-slider-horizontal ui-slider-vertical" ) 12910 ._addClass( "ui-slider-" + this.orientation ); 12911 this._refreshValue(); 12912 if ( this.options.range ) { 12913 this._refreshRange( value ); 12914 } 12915 12916 // Reset positioning from previous orientation 12917 this.handles.css( value === "horizontal" ? "bottom" : "left", "" ); 12918 break; 12919 case "value": 12920 this._animateOff = true; 12921 this._refreshValue(); 12922 this._change( null, 0 ); 12923 this._animateOff = false; 12924 break; 12925 case "values": 12926 this._animateOff = true; 12927 this._refreshValue(); 12928 12929 // Start from the last handle to prevent unreachable handles (#9046) 12930 for ( i = valsLength - 1; i >= 0; i-- ) { 12931 this._change( null, i ); 12932 } 12933 this._animateOff = false; 12934 break; 12935 case "step": 12936 case "min": 12937 case "max": 12938 this._animateOff = true; 12939 this._calculateNewMax(); 12940 this._refreshValue(); 12941 this._animateOff = false; 12942 break; 12943 case "range": 12944 this._animateOff = true; 12945 this._refresh(); 12946 this._animateOff = false; 12947 break; 12948 } 12949 }, 12950 12951 _setOptionDisabled: function( value ) { 12952 this._super( value ); 12953 12954 this._toggleClass( null, "ui-state-disabled", !!value ); 12955 }, 12956 12957 //internal value getter 12958 // _value() returns value trimmed by min and max, aligned by step 12959 _value: function() { 12960 var val = this.options.value; 12961 val = this._trimAlignValue( val ); 12962 12963 return val; 12964 }, 12965 12966 //internal values getter 12967 // _values() returns array of values trimmed by min and max, aligned by step 12968 // _values( index ) returns single value trimmed by min and max, aligned by step 12969 _values: function( index ) { 12970 var val, 12971 vals, 12972 i; 12973 12974 if ( arguments.length ) { 12975 val = this.options.values[ index ]; 12976 val = this._trimAlignValue( val ); 12977 12978 return val; 12979 } else if ( this._hasMultipleValues() ) { 12980 12981 // .slice() creates a copy of the array 12982 // this copy gets trimmed by min and max and then returned 12983 vals = this.options.values.slice(); 12984 for ( i = 0; i < vals.length; i += 1 ) { 12985 vals[ i ] = this._trimAlignValue( vals[ i ] ); 12986 } 12987 12988 return vals; 12989 } else { 12990 return []; 12991 } 12992 }, 12993 12994 // Returns the step-aligned value that val is closest to, between (inclusive) min and max 12995 _trimAlignValue: function( val ) { 12996 if ( val <= this._valueMin() ) { 12997 return this._valueMin(); 12998 } 12999 if ( val >= this._valueMax() ) { 13000 return this._valueMax(); 13001 } 13002 var step = ( this.options.step > 0 ) ? this.options.step : 1, 13003 valModStep = ( val - this._valueMin() ) % step, 13004 alignValue = val - valModStep; 13005 13006 if ( Math.abs( valModStep ) * 2 >= step ) { 13007 alignValue += ( valModStep > 0 ) ? step : ( -step ); 13008 } 13009 13010 // Since JavaScript has problems with large floats, round 13011 // the final value to 5 digits after the decimal point (see #4124) 13012 return parseFloat( alignValue.toFixed( 5 ) ); 13013 }, 13014 13015 _calculateNewMax: function() { 13016 var max = this.options.max, 13017 min = this._valueMin(), 13018 step = this.options.step, 13019 aboveMin = Math.round( ( max - min ) / step ) * step; 13020 max = aboveMin + min; 13021 if ( max > this.options.max ) { 13022
vendor: 5,564 bytes, lines 13023-13219
13023 //If max is not divisible by step, rounding off may increase its value 13024 max -= step; 13025 } 13026 this.max = parseFloat( max.toFixed( this._precision() ) ); 13027 }, 13028 13029 _precision: function() { 13030 var precision = this._precisionOf( this.options.step ); 13031 if ( this.options.min !== null ) { 13032 precision = Math.max( precision, this._precisionOf( this.options.min ) ); 13033 } 13034 return precision; 13035 }, 13036 13037 _precisionOf: function( num ) { 13038 var str = num.toString(), 13039 decimal = str.indexOf( "." ); 13040 return decimal === -1 ? 0 : str.length - decimal - 1; 13041 }, 13042 13043 _valueMin: function() { 13044 return this.options.min; 13045 }, 13046 13047 _valueMax: function() { 13048 return this.max; 13049 }, 13050 13051 _refreshRange: function( orientation ) { 13052 if ( orientation === "vertical" ) { 13053 this.range.css( { "width": "", "left": "" } ); 13054 } 13055 if ( orientation === "horizontal" ) { 13056 this.range.css( { "height": "", "bottom": "" } ); 13057 } 13058 }, 13059 13060 _refreshValue: function() { 13061 var lastValPercent, valPercent, value, valueMin, valueMax, 13062 oRange = this.options.range, 13063 o = this.options, 13064 that = this, 13065 animate = ( !this._animateOff ) ? o.animate : false, 13066 _set = {}; 13067 13068 if ( this._hasMultipleValues() ) { 13069 this.handles.each( function( i ) { 13070 valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() - 13071 that._valueMin() ) * 100; 13072 _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; 13073 $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); 13074 if ( that.options.range === true ) { 13075 if ( that.orientation === "horizontal" ) { 13076 if ( i === 0 ) { 13077 that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 13078 left: valPercent + "%" 13079 }, o.animate ); 13080 } 13081 if ( i === 1 ) { 13082 that.range[ animate ? "animate" : "css" ]( { 13083 width: ( valPercent - lastValPercent ) + "%" 13084 }, { 13085 queue: false, 13086 duration: o.animate 13087 } ); 13088 } 13089 } else { 13090 if ( i === 0 ) { 13091 that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 13092 bottom: ( valPercent ) + "%" 13093 }, o.animate ); 13094 } 13095 if ( i === 1 ) { 13096 that.range[ animate ? "animate" : "css" ]( { 13097 height: ( valPercent - lastValPercent ) + "%" 13098 }, { 13099 queue: false, 13100 duration: o.animate 13101 } ); 13102 } 13103 } 13104 } 13105 lastValPercent = valPercent; 13106 } ); 13107 } else { 13108 value = this.value(); 13109 valueMin = this._valueMin(); 13110 valueMax = this._valueMax(); 13111 valPercent = ( valueMax !== valueMin ) ? 13112 ( value - valueMin ) / ( valueMax - valueMin ) * 100 : 13113 0; 13114 _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; 13115 this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); 13116 13117 if ( oRange === "min" && this.orientation === "horizontal" ) { 13118 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 13119 width: valPercent + "%" 13120 }, o.animate ); 13121 } 13122 if ( oRange === "max" && this.orientation === "horizontal" ) { 13123 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 13124 width: ( 100 - valPercent ) + "%" 13125 }, o.animate ); 13126 } 13127 if ( oRange === "min" && this.orientation === "vertical" ) { 13128 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 13129 height: valPercent + "%" 13130 }, o.animate ); 13131 } 13132 if ( oRange === "max" && this.orientation === "vertical" ) { 13133 this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { 13134 height: ( 100 - valPercent ) + "%" 13135 }, o.animate ); 13136 } 13137 } 13138 }, 13139 13140 _handleEvents: { 13141 keydown: function( event ) { 13142 var allowed, curVal, newVal, step, 13143 index = $( event.target ).data( "ui-slider-handle-index" ); 13144 13145 switch ( event.keyCode ) { 13146 case $.ui.keyCode.HOME: 13147 case $.ui.keyCode.END: 13148 case $.ui.keyCode.PAGE_UP: 13149 case $.ui.keyCode.PAGE_DOWN: 13150 case $.ui.keyCode.UP: 13151 case $.ui.keyCode.RIGHT: 13152 case $.ui.keyCode.DOWN: 13153 case $.ui.keyCode.LEFT: 13154 event.preventDefault(); 13155 if ( !this._keySliding ) { 13156 this._keySliding = true; 13157 this._addClass( $( event.target ), null, "ui-state-active" ); 13158 allowed = this._start( event, index ); 13159 if ( allowed === false ) { 13160 return; 13161 } 13162 } 13163 break; 13164 } 13165 13166 step = this.options.step; 13167 if ( this._hasMultipleValues() ) { 13168 curVal = newVal = this.values( index ); 13169 } else { 13170 curVal = newVal = this.value(); 13171 } 13172 13173 switch ( event.keyCode ) { 13174 case $.ui.keyCode.HOME: 13175 newVal = this._valueMin(); 13176 break; 13177 case $.ui.keyCode.END: 13178 newVal = this._valueMax(); 13179 break; 13180 case $.ui.keyCode.PAGE_UP: 13181 newVal = this._trimAlignValue( 13182 curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages ) 13183 ); 13184 break; 13185 case $.ui.keyCode.PAGE_DOWN: 13186 newVal = this._trimAlignValue( 13187 curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) ); 13188 break; 13189 case $.ui.keyCode.UP: 13190 case $.ui.keyCode.RIGHT: 13191 if ( curVal === this._valueMax() ) { 13192 return; 13193 } 13194 newVal = this._trimAlignValue( curVal + step ); 13195 break; 13196 case $.ui.keyCode.DOWN: 13197 case $.ui.keyCode.LEFT: 13198 if ( curVal === this._valueMin() ) { 13199 return; 13200 } 13201 newVal = this._trimAlignValue( curVal - step ); 13202 break; 13203 } 13204 13205 this._slide( event, index, newVal ); 13206 }, 13207 keyup: function( event ) { 13208 var index = $( event.target ).data( "ui-slider-handle-index" ); 13209 13210 if ( this._keySliding ) { 13211 this._keySliding = false; 13212 this._stop( event, index ); 13213 this._change( event, index ); 13214 this._removeClass( $( event.target ), null, "ui-state-active" ); 13215 } 13216 } 13217 } 13218} ); 13219
13220} ); 13221// See https://github.com/jquery-ui-rails/jquery-ui-rails#require-specific-modules 13222// The jQuery UI code weighs 51KB (minified + gzipped) and takes a while to execute, so for production apps it's recommended to only include the modules that your application actually uses. Dependencies are automatically resolved. Simply pick one or more modules from the asset list below. 13223 13224 13225// Section: Interactions >>>>>>>>>>>>>>>>>>>>>>> 13226 13227// require jquery-ui/widgets/mouse 13228// require jquery-ui/widgets/draggable 13229// require jquery-ui/widgets/droppable 13230// require jquery-ui/widgets/resizable 13231// require jquery-ui/widgets/selectable 13232// require jquery-ui/widgets/sortable 13233 13234// Section: Widgets >>>>>>>>>>>>>>>>>>>>>>>>>>>>> 13235// require jquery-ui/widgets/accordion 13236// require jquery-ui/widgets/autocomplete 13237// require jquery-ui/widgets/button 13238// require jquery-ui/widgets/datepicker 13239// require jquery-ui/widgets/dialog 13240// require jquery-ui/widgets/menu 13241// require jquery-ui/widgets/progressbar 13242// require jquery-ui/widgets/selectmenu 13243 13244// require jquery-ui/widgets/spinner 13245// require jquery-ui/widgets/tabs 13246// require jquery-ui/widgets/tooltip 13247 13248// Section: Events 13249// require jquery-ui/effect 13250// require jquery-ui/effects/effect-blind 13251// require jquery-ui/effects/effect-bounce 13252// require jquery-ui/effects/effect-clip 13253// require jquery-ui/effects/effect-drop 13254// require jquery-ui/effects/effect-explode 13255// require jquery-ui/effects/effect-fade 13256// require jquery-ui/effects/effect-fold 13257// require jquery-ui/effects/effect-highlight 13258// require jquery-ui/effects/effect-puff 13259// require jquery-ui/effects/effect-pulsate 13260// require jquery-ui/effects/effect-scale 13261// require jquery-ui/effects/effect-shake 13262// require jquery-ui/effects/effect-size 13263// require jquery-ui/effects/effect-slide 13264// require jquery-ui/effects/effect-transfer; 13265/* jshint node: true */ 13266 13267/** 13268 * Unobtrusive scripting adapter for jQuery 13269 * https://github.com/rails/jquery-ujs 13270 * 13271 * Requires jQuery 1.8.0 or later. 13272 * 13273 * Released under the MIT license 13274 * 13275 */ 13276 13277(function() { 13278 'use strict'; 13279 13280 var jqueryUjsInit = function($, undefined) { 13281 13282 // Cut down on the number of issues from people inadvertently including jquery_ujs twice 13283 // by detecting and raising an error when it happens. 13284 if ( $.rails !== undefined ) { 13285 $.error('jquery-ujs has already been loaded!'); 13286 } 13287 13288 // Shorthand to make it a little easier to call public rails functions from within rails.js 13289 var rails; 13290 var $document = $(document); 13291 13292 $.rails = rails = { 13293 // Link elements bound by jquery-ujs 13294 linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]', 13295 13296 // Button elements bound by jquery-ujs 13297 buttonClickSelector: 'button[data-remote]:not([form]):not(form button), button[data-confirm]:not([form]):not(form button)', 13298 13299 // Select elements bound by jquery-ujs 13300 inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]', 13301 13302 // Form elements bound by jquery-ujs 13303 formSubmitSelector: 'form:not([data-turbo=true])', 13304 13305 // Form input elements bound by jquery-ujs 13306 formInputClickSelector: 'form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])', 13307 13308 // Form input elements disabled during form submission 13309 disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled', 13310 13311 // Form input elements re-enabled after form submission 13312 enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled', 13313 13314 // Form required input elements 13315 requiredInputSelector: 'input[name][required]:not([disabled]), textarea[name][required]:not([disabled])', 13316 13317 // Form file input elements 13318 fileInputSelector: 'input[name][type=file]:not([disabled])', 13319 13320 // Link onClick disable selector with possible reenable after remote submission 13321 linkDisableSelector: 'a[data-disable-with], a[data-disable]', 13322 13323 // Button onClick disable selector with possible reenable after remote submission 13324 buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]', 13325 13326 // Up-to-date Cross-Site Request Forgery token 13327 csrfToken: function() { 13328 return $('meta[name=csrf-token]').attr('content'); 13329 }, 13330 13331 // URL param that must contain the CSRF token
13332 csrfParam: function() { 13333 return $('meta[name=csrf-param]').attr('content'); 13334 }, 13335 13336 // Make sure that every Ajax request sends the CSRF token 13337 CSRFProtection: function(xhr) { 13338 var token = rails.csrfToken(); 13339 if (token) xhr.setRequestHeader('X-CSRF-Token', token); 13340 }, 13341 13342 // Make sure that all forms have actual up-to-date tokens (cached forms contain old ones) 13343 refreshCSRFTokens: function(){ 13344 $('form input[name="' + rails.csrfParam() + '"]').val(rails.csrfToken()); 13345 }, 13346 13347 // Triggers an event on an element and returns false if the event result is false 13348 fire: function(obj, name, data) { 13349 var event = $.Event(name); 13350 obj.trigger(event, data); 13351 return event.result !== false; 13352 }, 13353 13354 // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm 13355 confirm: function(message) { 13356 return confirm(message); 13357 }, 13358 13359 // Default ajax function, may be overridden with custom function in $.rails.ajax 13360 ajax: function(options) { 13361 return $.ajax(options); 13362 }, 13363 13364 // Default way to get an element's href. May be overridden at $.rails.href. 13365 href: function(element) { 13366 return element[0].href; 13367 }, 13368 13369 // Checks "data-remote" if true to handle the request through a XHR request. 13370 isRemote: function(element) { 13371 return element.data('remote') !== undefined && element.data('remote') !== false; 13372 }, 13373 13374 // Submits "remote" forms and links with ajax 13375 handleRemote: function(element) { 13376 var method, url, data, withCredentials, dataType, options; 13377 13378 if (rails.fire(element, 'ajax:before')) { 13379 withCredentials = element.data('with-credentials') || null; 13380 dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType); 13381 13382 if (element.is('form')) { 13383 method = element.data('ujs:submit-button-formmethod') || element.attr('method'); 13384 url = element.data('ujs:submit-button-formaction') || element.attr('action'); 13385 data = $(element[0]).serializeArray(); 13386 // memoized value from clicked submit button 13387 var button = element.data('ujs:submit-button'); 13388 if (button) { 13389 data.push(button); 13390 element.data('ujs:submit-button', null); 13391 } 13392 element.data('ujs:submit-button-formmethod', null); 13393 element.data('ujs:submit-button-formaction', null); 13394 } else if (element.is(rails.inputChangeSelector)) { 13395 method = element.data('method'); 13396 url = element.data('url'); 13397 data = element.serialize(); 13398 if (element.data('params')) data = data + '&' + element.data('params'); 13399 } else if (element.is(rails.buttonClickSelector)) { 13400 method = element.data('method') || 'get'; 13401 url = element.data('url'); 13402 data = element.serialize(); 13403 if (element.data('params')) data = data + '&' + element.data('params'); 13404 } else { 13405 method = element.data('method'); 13406 url = rails.href(element); 13407 data = element.data('params') || null; 13408 } 13409 13410 options = { 13411 type: method || 'GET', data: data, dataType: dataType, 13412 // stopping the "ajax:beforeSend" event will cancel the ajax request 13413 beforeSend: function(xhr, settings) { 13414 if (settings.dataType === undefined) { 13415 xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script); 13416 } 13417 if (rails.fire(element, 'ajax:beforeSend', [xhr, settings])) { 13418 element.trigger('ajax:send', xhr); 13419 } else { 13420 return false; 13421 } 13422 }, 13423 success: function(data, status, xhr) { 13424 element.trigger('ajax:success', [data, status, xhr]); 13425 }, 13426 complete: function(xhr, status) { 13427 element.trigger('ajax:complete', [xhr, status]); 13428 }, 13429 error: function(xhr, status, error) { 13430 element.trigger('ajax:error', [xhr, status, error]); 13431 }, 13432 crossDomain: rails.isCrossDomain(url) 13433 }; 13434 13435 // There is no withCredentials for IE6-8 when 13436 // "Enable native XMLHTTP support" is disabled 13437 if (withCredentials) { 13438 options.xhrFields = { 13439 withCredentials: withCredentials 13440 }; 13441 } 13442 13443 // Only pass url to `ajax` options if not blank 13444 if (url) { options.url = url; } 13445 13446 return rails.ajax(options); 13447 } else { 13448 return false;
13449 } 13450 }, 13451 13452 // Determines if the request is a cross domain request. 13453 isCrossDomain: function(url) { 13454 var originAnchor = document.createElement('a'); 13455 originAnchor.href = location.href; 13456 var urlAnchor = document.createElement('a'); 13457 13458 try { 13459 urlAnchor.href = url; 13460 // This is a workaround to a IE bug. 13461 urlAnchor.href = urlAnchor.href; 13462 13463 // If URL protocol is false or is a string containing a single colon 13464 // *and* host are false, assume it is not a cross-domain request 13465 // (should only be the case for IE7 and IE compatibility mode). 13466 // Otherwise, evaluate protocol and host of the URL against the origin 13467 // protocol and host. 13468 return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) || 13469 (originAnchor.protocol + '//' + originAnchor.host === 13470 urlAnchor.protocol + '//' + urlAnchor.host)); 13471 } catch (e) { 13472 // If there is an error parsing the URL, assume it is crossDomain. 13473 return true; 13474 } 13475 }, 13476 13477 // Handles "data-method" on links such as: 13478 // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a> 13479 handleMethod: function(link) { 13480 var href = rails.href(link), 13481 method = link.data('method'), 13482 target = link.attr('target'), 13483 csrfToken = rails.csrfToken(), 13484 csrfParam = rails.csrfParam(), 13485 form = $('<form method="post" action="' + href + '"></form>'), 13486 metadataInput = '<input name="_method" value="' + method + '" type="hidden" />'; 13487 13488 if (csrfParam !== undefined && csrfToken !== undefined && !rails.isCrossDomain(href)) { 13489 metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />'; 13490 } 13491 13492 if (target) { form.attr('target', target); } 13493 13494 form.hide().append(metadataInput).appendTo('body'); 13495 form.submit(); 13496 }, 13497 13498 // Helper function that returns form elements that match the specified CSS selector 13499 // If form is actually a "form" element this will return associated elements outside the from that have 13500 // the html form attribute set 13501 formElements: function(form, selector) { 13502 return form.is('form') ? $(form[0].elements).filter(selector) : form.find(selector); 13503 }, 13504 13505 /* Disables form elements: 13506 - Caches element value in 'ujs:enable-with' data store 13507 - Replaces element text with value of 'data-disable-with' attribute 13508 - Sets disabled property to true 13509 */ 13510 disableFormElements: function(form) { 13511 rails.formElements(form, rails.disableSelector).each(function() { 13512 rails.disableFormElement($(this)); 13513 }); 13514 }, 13515 13516 disableFormElement: function(element) { 13517 var method, replacement; 13518 13519 method = element.is('button') ? 'html' : 'val'; 13520 replacement = element.data('disable-with'); 13521 13522 if (replacement !== undefined) { 13523 element.data('ujs:enable-with', element[method]()); 13524 element[method](replacement); 13525 } 13526 13527 element.prop('disabled', true); 13528 element.data('ujs:disabled', true); 13529 }, 13530 13531 /* Re-enables disabled form elements: 13532 - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`) 13533 - Sets disabled property to false 13534 */ 13535 enableFormElements: function(form) { 13536 rails.formElements(form, rails.enableSelector).each(function() { 13537 rails.enableFormElement($(this)); 13538 }); 13539 }, 13540 13541 enableFormElement: function(element) { 13542 var method = element.is('button') ? 'html' : 'val'; 13543 if (element.data('ujs:enable-with') !== undefined) { 13544 element[method](element.data('ujs:enable-with')); 13545 element.removeData('ujs:enable-with'); // clean up cache 13546 } 13547 element.prop('disabled', false); 13548 element.removeData('ujs:disabled'); 13549 }, 13550 13551 /* For 'data-confirm' attribute: 13552 - Fires `confirm` event 13553 - Shows the confirmation dialog 13554 - Fires the `confirm:complete` event 13555 13556 Returns `true` if no function stops the chain and user chose yes; `false` otherwise. 13557 Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog. 13558 Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
13559 return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog. 13560 */ 13561 allowAction: function(element) { 13562 var message = element.data('confirm'), 13563 answer = false, callback; 13564 if (!message) { return true; } 13565 13566 if (rails.fire(element, 'confirm')) { 13567 try { 13568 answer = rails.confirm(message); 13569 } catch (e) { 13570 (console.error || console.log).call(console, e.stack || e); 13571 } 13572 callback = rails.fire(element, 'confirm:complete', [answer]); 13573 } 13574 return answer && callback; 13575 }, 13576 13577 // Helper function which checks for blank inputs in a form that match the specified CSS selector 13578 blankInputs: function(form, specifiedSelector, nonBlank) { 13579 var foundInputs = $(), 13580 input, 13581 valueToCheck, 13582 radiosForNameWithNoneSelected, 13583 radioName, 13584 selector = specifiedSelector || 'input,textarea', 13585 requiredInputs = form.find(selector), 13586 checkedRadioButtonNames = {}; 13587 13588 requiredInputs.each(function() { 13589 input = $(this); 13590 if (input.is('input[type=radio]')) { 13591 13592 // Don't count unchecked required radio as blank if other radio with same name is checked, 13593 // regardless of whether same-name radio input has required attribute or not. The spec 13594 // states https://www.w3.org/TR/html5/forms.html#the-required-attribute 13595 radioName = input.attr('name'); 13596 13597 // Skip if we've already seen the radio with this name. 13598 if (!checkedRadioButtonNames[radioName]) { 13599 13600 // If none checked 13601 if (form.find('input[type=radio]:checked[name="' + radioName + '"]').length === 0) { 13602 radiosForNameWithNoneSelected = form.find( 13603 'input[type=radio][name="' + radioName + '"]'); 13604 foundInputs = foundInputs.add(radiosForNameWithNoneSelected); 13605 } 13606 13607 // We only need to check each name once. 13608 checkedRadioButtonNames[radioName] = radioName; 13609 } 13610 } else { 13611 valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : !!input.val(); 13612 if (valueToCheck === nonBlank) { 13613 foundInputs = foundInputs.add(input); 13614 } 13615 } 13616 }); 13617 return foundInputs.length ? foundInputs : false; 13618 }, 13619 13620 // Helper function which checks for non-blank inputs in a form that match the specified CSS selector 13621 nonBlankInputs: function(form, specifiedSelector) { 13622 return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank 13623 }, 13624 13625 // Helper function, needed to provide consistent behavior in IE 13626 stopEverything: function(e) { 13627 $(e.target).trigger('ujs:everythingStopped'); 13628 e.stopImmediatePropagation(); 13629 return false; 13630 }, 13631 13632 // Replace element's html with the 'data-disable-with' after storing original html 13633 // and prevent clicking on it 13634 disableElement: function(element) { 13635 var replacement = element.data('disable-with'); 13636 13637 if (replacement !== undefined) { 13638 element.data('ujs:enable-with', element.html()); // store enabled state 13639 element.html(replacement); 13640 } 13641 13642 element.on('click.railsDisable', function(e) { // prevent further clicking 13643 return rails.stopEverything(e); 13644 }); 13645 element.data('ujs:disabled', true); 13646 }, 13647 13648 // Restore element to its original state which was disabled by 'disableElement' above 13649 enableElement: function(element) { 13650 if (element.data('ujs:enable-with') !== undefined) { 13651 element.html(element.data('ujs:enable-with')); // set to old enabled state 13652 element.removeData('ujs:enable-with'); // clean up cache 13653 } 13654 element.off('click.railsDisable'); // enable element 13655 element.removeData('ujs:disabled'); 13656 } 13657 }; 13658 13659 if (rails.fire($document, 'rails:attachBindings')) { 13660 13661 $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }}); 13662 13663 // This event works the same as the load event, except that it fires every 13664 // time the page is loaded. 13665 // 13666 // See https://github.com/rails/jquery-ujs/issues/357 13667 // See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching 13668 $(window).on('pageshow.rails', function () { 13669 $($.rails.enableSelector).each(function () { 13670 var element = $(this); 13671 13672 if (element.data('ujs:disabled')) { 13673 $.rails.enableFormElement(element); 13674 } 13675 }); 13676 13677 $($.rails.linkDisableSelector).each(function () { 13678 var element = $(this); 13679 13680 if (element.data('ujs:disabled')) { 13681 $.rails.enableElement(element); 13682 } 13683 }); 13684 }); 13685 13686 $document.on('ajax:complete', rails.linkDisableSelector, function() { 13687 rails.enableElement($(this)); 13688 }); 13689 13690 $document.on('ajax:complete', rails.buttonDisableSelector, function() { 13691 rails.enableFormElement($(this)); 13692 }); 13693 13694 $document.on('click.rails', rails.linkClickSelector, function(e) { 13695 var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey; 13696 if (!rails.allowAction(link)) return rails.stopEverything(e); 13697 13698 if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link); 13699 13700 if (rails.isRemote(link)) { 13701 if (metaClick && (!method || method === 'GET') && !data) { return true; } 13702 13703 var handleRemote = rails.handleRemote(link); 13704 // Response from rails.handleRemote() will either be false or a deferred object promise. 13705 if (handleRemote === false) { 13706 rails.enableElement(link); 13707 } else { 13708 handleRemote.fail( function() { rails.enableElement(link); } ); 13709 } 13710 return false;
13711 13712 } else if (method) { 13713 rails.handleMethod(link); 13714 return false; 13715 } 13716 }); 13717 13718 $document.on('click.rails', rails.buttonClickSelector, function(e) { 13719 var button = $(this); 13720 13721 if (!rails.allowAction(button) || !rails.isRemote(button)) return rails.stopEverything(e); 13722 13723 if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button); 13724 13725 var handleRemote = rails.handleRemote(button); 13726 // Response from rails.handleRemote() will either be false or a deferred object promise. 13727 if (handleRemote === false) { 13728 rails.enableFormElement(button); 13729 } else { 13730 handleRemote.fail( function() { rails.enableFormElement(button); } ); 13731 } 13732 return false; 13733 }); 13734 13735 $document.on('change.rails', rails.inputChangeSelector, function(e) { 13736 var link = $(this); 13737 if (!rails.allowAction(link) || !rails.isRemote(link)) return rails.stopEverything(e); 13738 13739 rails.handleRemote(link); 13740 return false; 13741 }); 13742 13743 $document.on('submit.rails', rails.formSubmitSelector, function(e) { 13744 var form = $(this), 13745 remote = rails.isRemote(form), 13746 blankRequiredInputs, 13747 nonBlankFileInputs; 13748 13749 if (!rails.allowAction(form)) return rails.stopEverything(e); 13750 13751 // Skip other logic when required values are missing or file upload is present 13752 if (form.attr('novalidate') === undefined) { 13753 if (form.data('ujs:formnovalidate-button') === undefined) { 13754 blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector, false); 13755 if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) { 13756 return rails.stopEverything(e); 13757 } 13758 } else { 13759 // Clear the formnovalidate in case the next button click is not on a formnovalidate button 13760 // Not strictly necessary to do here, since it is also reset on each button click, but just to be certain 13761 form.data('ujs:formnovalidate-button', undefined); 13762 } 13763 } 13764 13765 if (remote) { 13766 nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector); 13767 if (nonBlankFileInputs) { 13768 // Slight timeout so that the submit button gets properly serialized 13769 // (make it easy for event handler to serialize form without disabled values) 13770 setTimeout(function(){ rails.disableFormElements(form); }, 13); 13771 var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]); 13772 13773 // Re-enable form elements if event bindings return false (canceling normal form submission) 13774 if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); } 13775 13776 return aborted; 13777 } 13778 13779 rails.handleRemote(form); 13780 return false; 13781 13782 } else { 13783 // Slight timeout so that the submit button gets properly serialized 13784 setTimeout(function(){ rails.disableFormElements(form); }, 13); 13785 } 13786 }); 13787 13788 $document.on('click.rails', rails.formInputClickSelector, function(event) { 13789 var button = $(this); 13790 13791 if (!rails.allowAction(button)) return rails.stopEverything(event); 13792 13793 // Register the pressed submit button 13794 var name = button.attr('name'), 13795 data = name ? {name:name, value:button.val()} : null; 13796 13797 var form = button.closest('form'); 13798 if (form.length === 0) { 13799 form = $('#' + button.attr('form')); 13800 } 13801 form.data('ujs:submit-button', data); 13802 13803 // Save attributes from button 13804 form.data('ujs:formnovalidate-button', button.attr('formnovalidate')); 13805 form.data('ujs:submit-button-formaction', button.attr('formaction')); 13806 form.data('ujs:submit-button-formmethod', button.attr('formmethod')); 13807 }); 13808 13809 $document.on('ajax:send.rails', rails.formSubmitSelector, function(event) { 13810 if (this === event.target) rails.disableFormElements($(this)); 13811 }); 13812 13813 $document.on('ajax:complete.rails', rails.formSubmitSelector, function(event) { 13814 if (this === event.target) rails.enableFormElements($(this)); 13815 }); 13816 13817 $(function(){ 13818 rails.refreshCSRFTokens(); 13819 }); 13820 } 13821 13822 }; 13823 13824 if (window.jQuery) { 13825 jqueryUjsInit(jQuery); 13826 } else if (typeof exports === 'object' && typeof module === 'object') { 13827 module.exports = jqueryUjsInit; 13828 } 13829})(); 13830/*! 13831 * jQuery UI Touch Punch 0.2.3 13832 * 13833 * Copyright 2011–2014, Dave Furfero 13834 * Dual licensed under the MIT or GPL Version 2 licenses. 13835 * 13836 * Depends: 13837 * jquery.ui.widget.js 13838 * jquery.ui.mouse.js 13839 */ 13840(function ($) { 13841 13842 // Detect touch support 13843 $.support.touch = 'ontouchend' in document; 13844 13845 // Ignore browsers without touch support 13846 if (!$.support.touch) { 13847 return; 13848 } 13849 13850 var mouseProto = $.ui.mouse.prototype, 13851 _mouseInit = mouseProto._mouseInit, 13852 _mouseDestroy = mouseProto._mouseDestroy, 13853 touchHandled; 13854 13855 /** 13856 * Simulate a mouse event based on a corresponding touch event 13857 * @param {Object} event A touch event 13858 * @param {String} simulatedType The corresponding mouse event 13859 */ 13860 function simulateMouseEvent(event, simulatedType) { 13861 13862 // Ignore multi-touch events 13863 if (event.originalEvent.touches.length > 1) { 13864 return; 13865 } 13866 13867 if (event.cancelable) { 13868 event.preventDefault(); 13869 } 13870 13871 var touch = event.originalEvent.changedTouches[0], 13872 simulatedEvent = document.createEvent('MouseEvents'); 13873 13874 // Initialize the simulated mouse event using the touch event's co
13874ordinates 13875 simulatedEvent.initMouseEvent( 13876 simulatedType, // type 13877 true, // bubbles 13878 true, // cancelable 13879 window, // view 13880 1, // detail 13881 touch.screenX, // screenX 13882 touch.screenY, // screenY 13883 touch.clientX, // clientX 13884 touch.clientY, // clientY 13885 false, // ctrlKey 13886 false, // altKey 13887 false, // shiftKey 13888 false, // metaKey 13889 0, // button 13890 null // relatedTarget 13891 ); 13892 13893 // Dispatch the simulated event to the target element 13894 event.target.dispatchEvent(simulatedEvent); 13895 } 13896 13897 /** 13898 * Handle the jQuery UI widget's touchstart events 13899 * @param {Object} event The widget element's touchstart event 13900 */ 13901 mouseProto._touchStart = function (event) { 13902 13903 var self = this; 13904 13905 // Ignore the event if another widget is already being handled 13906 if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) { 13907 return; 13908 } 13909 13910 // Set the flag to prevent other widgets from inheriting the touch event 13911 touchHandled = true; 13912 13913 // Track movement to determine if interaction was a click 13914 self._touchMoved = false; 13915 13916 // Simulate the mouseover event 13917 simulateMouseEvent(event, 'mouseover'); 13918 13919 // Simulate the mousemove event 13920 simulateMouseEvent(event, 'mousemove'); 13921 13922 // Simulate the mousedown event 13923 simulateMouseEvent(event, 'mousedown'); 13924 }; 13925 13926 /** 13927 * Handle the jQuery UI widget's touchmove events 13928 * @param {Object} event The document's touchmove event 13929 */ 13930 mouseProto._touchMove = function (event) { 13931 13932 // Ignore event if not handled 13933 if (!touchHandled) { 13934 return; 13935 } 13936 13937 // Interaction was not a click 13938 this._touchMoved = true; 13939 13940 // Simulate the mousemove event 13941 simulateMouseEvent(event, 'mousemove'); 13942 }; 13943 13944 /** 13945 * Handle the jQuery UI widget's touchend events 13946 * @param {Object} event The document's touchend event 13947 */ 13948 mouseProto._touchEnd = function (event) { 13949 13950 // Ignore event if not handled 13951 if (!touchHandled) { 13952 return; 13953 } 13954 13955 // Simulate the mouseup event 13956 simulateMouseEvent(event, 'mouseup'); 13957 13958 // Simulate the mouseout event 13959 simulateMouseEvent(event, 'mouseout'); 13960 13961 // If the touch interaction did not move, it should trigger a click 13962 if (!this._touchMoved) { 13963 13964 // Simulate the click event 13965 simulateMouseEvent(event, 'click'); 13966 } 13967 13968 // Unset the flag to allow other widgets to inherit the touch event 13969 touchHandled = false; 13970 }; 13971 13972 /** 13973 * A duck punch of the $.ui.mouse _mouseInit method to support touch events. 13974 * This method extends the widget with bound touch event handlers that 13975 * translate touch events to mouse events and pass them to the widget's 13976 * original mouse event handling methods. 13977 */ 13978 mouseProto._mouseInit = function () { 13979 13980 var self = this; 13981 13982 // Delegate the touch handlers to the widget's element 13983 self.element.bind({ 13984 touchstart: $.proxy(self, '_touchStart'), 13985 touchmove: $.proxy(self, '_touchMove'), 13986 touchend: $.proxy(self, '_touchEnd') 13987 }); 13988 13989 // Call the original $.ui.mouse init method 13990 _mouseInit.call(self); 13991 }; 13992 13993 /** 13994 * Remove the touch event handlers 13995 */ 13996 mouseProto._mouseDestroy = function () { 13997 13998 var self = this; 13999 14000 // Delegate the touch handlers to the widget's element 14001 self.element.unbind({ 14002 touchstart: $.proxy(self, '_touchStart'), 14003 touchmove: $.proxy(self, '_touchMove'), 14004 touchend: $.proxy(self, '_touchEnd') 14005 }); 14006 14007 // Call the original $.ui.mouse destroy method 14008 _mouseDestroy.call(self); 14009 }; 14010 14011})(jQuery); 14012/* ======================================================================== 14013 * Bootstrap: alert.js v3.4.1 14014 * https://getbootstrap.com/docs/3.4/javascript/#alerts 14015 * ======================================================================== 14016 * Copyright 2011-2019 Twitter, Inc. 14017 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 14018 * ======================================================================== */ 14019 14020 14021+function ($) { 14022 'use strict'; 14023 14024 // ALERT CLASS DEFINITION 14025 // ====================== 14026 14027 var dismiss = '[data-dismiss="alert"]' 14028 var Alert = function (el) { 14029 $(el).on('click', dismiss, this.close) 14030 } 14031 14032 Alert.VERSION = '3.4.1' 14033 14034 Alert.TRANSITION_DURATION = 150 14035 14036 Alert.prototype.close = function (e) { 14037 var $this = $(this) 14038 var selector = $this.attr('data-target') 14039 14040 if (!selector) { 14041 selector = $this.attr('href') 14042 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 14043 } 14044 14045 selector = selector === '#' ? [] : selector 14046 var $parent = $(document).find(selector) 14047 14048 if (e) e.preventDefault() 14049 14050 if (!$parent.length) { 14051 $parent = $this.closest('.alert') 14052 } 14053 14054 $parent.trigger(e = $.Event('close.bs.alert')) 14055 14056 if (e.isDefaultPrevented()) return 14057 14058 $parent.removeClass('in') 14059 14060 function removeElement() { 14061 // detach from parent, fire event then clean up data 14062 $parent.detach().trigger('closed.bs.alert').remove() 14063 } 14064 14065 $.support.transition && $parent.hasClass('fade') ? 14066 $parent 14067 .one('bsTransitionEnd', removeElement) 14068 .emulateTransitionEnd(Alert.TRANSITION_DURATION) : 14069 removeElement() 14070 } 14071 14072 14073 // ALERT PLUGIN DEFINITION 14074 // ======================= 14075 14076 function Plugin(option) { 14077 return this.each(function () { 14078 var $this = $(this) 14079 var data = $this.data('bs.alert') 14080
vendor: 49,880 bytes, lines 14081-15726
14081 if (!data) $this.data('bs.alert', (data = new Alert(this))) 14082 if (typeof option == 'string') data[option].call($this) 14083 }) 14084 } 14085 14086 var old = $.fn.alert 14087 14088 $.fn.alert = Plugin 14089 $.fn.alert.Constructor = Alert 14090 14091 14092 // ALERT NO CONFLICT 14093 // ================= 14094 14095 $.fn.alert.noConflict = function () { 14096 $.fn.alert = old 14097 return this 14098 } 14099 14100 14101 // ALERT DATA-API 14102 // ============== 14103 14104 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) 14105 14106}(jQuery); 14107/* ======================================================================== 14108 * Bootstrap: button.js v3.4.1 14109 * https://getbootstrap.com/docs/3.4/javascript/#buttons 14110 * ======================================================================== 14111 * Copyright 2011-2019 Twitter, Inc. 14112 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 14113 * ======================================================================== */ 14114 14115 14116+function ($) { 14117 'use strict'; 14118 14119 // BUTTON PUBLIC CLASS DEFINITION 14120 // ============================== 14121 14122 var Button = function (element, options) { 14123 this.$element = $(element) 14124 this.options = $.extend({}, Button.DEFAULTS, options) 14125 this.isLoading = false 14126 } 14127 14128 Button.VERSION = '3.4.1' 14129 14130 Button.DEFAULTS = { 14131 loadingText: 'loading...' 14132 } 14133 14134 Button.prototype.setState = function (state) { 14135 var d = 'disabled' 14136 var $el = this.$element 14137 var val = $el.is('input') ? 'val' : 'html' 14138 var data = $el.data() 14139 14140 state += 'Text' 14141 14142 if (data.resetText == null) $el.data('resetText', $el[val]()) 14143 14144 // push to event loop to allow forms to submit 14145 setTimeout($.proxy(function () { 14146 $el[val](data[state] == null ? this.options[state] : data[state]) 14147 14148 if (state == 'loadingText') { 14149 this.isLoading = true 14150 $el.addClass(d).attr(d, d).prop(d, true) 14151 } else if (this.isLoading) { 14152 this.isLoading = false 14153 $el.removeClass(d).removeAttr(d).prop(d, false) 14154 } 14155 }, this), 0) 14156 } 14157 14158 Button.prototype.toggle = function () { 14159 var changed = true 14160 var $parent = this.$element.closest('[data-toggle="buttons"]') 14161 14162 if ($parent.length) { 14163 var $input = this.$element.find('input') 14164 if ($input.prop('type') == 'radio') { 14165 if ($input.prop('checked')) changed = false 14166 $parent.find('.active').removeClass('active') 14167 this.$element.addClass('active') 14168 } else if ($input.prop('type') == 'checkbox') { 14169 if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false 14170 this.$element.toggleClass('active') 14171 } 14172 $input.prop('checked', this.$element.hasClass('active')) 14173 if (changed) $input.trigger('change') 14174 } else { 14175 this.$element.attr('aria-pressed', !this.$element.hasClass('active')) 14176 this.$element.toggleClass('active') 14177 } 14178 } 14179 14180 14181 // BUTTON PLUGIN DEFINITION 14182 // ======================== 14183 14184 function Plugin(option) { 14185 return this.each(function () { 14186 var $this = $(this) 14187 var data = $this.data('bs.button') 14188 var options = typeof option == 'object' && option 14189 14190 if (!data) $this.data('bs.button', (data = new Button(this, options))) 14191 14192 if (option == 'toggle') data.toggle() 14193 else if (option) data.setState(option) 14194 }) 14195 } 14196 14197 var old = $.fn.button 14198 14199 $.fn.button = Plugin 14200 $.fn.button.Constructor = Button 14201 14202 14203 // BUTTON NO CONFLICT 14204 // ================== 14205 14206 $.fn.button.noConflict = function () { 14207 $.fn.button = old 14208 return this 14209 } 14210 14211 14212 // BUTTON DATA-API 14213 // =============== 14214 14215 $(document) 14216 .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { 14217 var $btn = $(e.target).closest('.btn') 14218 Plugin.call($btn, 'toggle') 14219 if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) { 14220 // Prevent double click on radios, and the double selections (so cancellation) on checkboxes 14221 e.preventDefault() 14222 // The target component still receive the focus 14223 if ($btn.is('input,button')) $btn.trigger('focus') 14224 else $btn.find('input:visible,button:visible').first().trigger('focus') 14225 } 14226 }) 14227 .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { 14228 $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type)) 14229 }) 14230 14231}(jQuery); 14232/* ======================================================================== 14233 * Bootstrap: collapse.js v3.4.1 14234 * https://getbootstrap.com/docs/3.4/javascript/#collapse 14235 * ======================================================================== 14236 * Copyright 2011-2019 Twitter, Inc. 14237 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 14238 * ======================================================================== */ 14239 14240/* jshint latedef: false */ 14241 14242+function ($) { 14243 'use strict'; 14244 14245 // COLLAPSE PUBLIC CLASS DEFINITION 14246 // ================================ 14247 14248 var Collapse = function (element, options) { 14249 this.$element = $(element) 14250 this.options = $.extend({}, Collapse.DEFAULTS, options) 14251 this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' + 14252 '[data-toggle="collapse"][data-target="#' + element.id + '"]') 14253 this.transitioning = null 14254 14255 if (this.options.parent) { 14256 this.$parent = this.getParent() 14257 } else { 14258 this.addAriaAndCollapsedClass(this.$element, this.$trigger) 14259 } 14260 14261 if (this.options.toggle) this.toggle() 14262 } 14263 14264 Collapse.VERSION = '3.4.1' 14265 14266 Collapse.TRANSITION_DURATION = 350 14267 14268 Collapse.DEFAULTS = { 14269 toggle: true 14270 } 14271 14272 Collapse.prototype.dimension = function () { 14273 var hasWidth = this.$element.hasClass('width') 14274 return hasWidth ? 'width' : 'height' 14275 } 14276 14277 Collapse.prototype.show = function () { 14278 if (this.transitioning || this.$element.hasClass('in')) return 14279 14280 var activesData 14281 var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') 14282 14283 if (actives && actives.length) { 14284 activesData = actives.data('bs.collapse') 14285 if (activesData && activesData.transitioning) return 14286 } 14287 14288 var startEvent = $.Event('show.bs.collapse') 14289 this.$element.trigger(startEvent) 14290 if (startEvent.isDefaultPrevented()) return 14291 14292 if (actives && actives.length) { 14293 Plugin.call(actives, 'hide') 14294 activesData || actives.data('bs.collapse', null) 14295 } 14296 14297 var dimension = this.dimension() 14298 14299 this.$element 14300 .removeClass('collapse') 14301 .addClass('collapsing')[dimension](0) 14302 .attr('aria-expanded', true) 14303 14304 this.$trigger 14305 .removeClass('collapsed') 14306 .attr('aria-expanded', true) 14307 14308 this.transitioning = 1 14309 14310 var complete = function () { 14311 this.$element 14312 .removeClass('collapsing') 14313 .addClass('collapse in')[dimension]('') 14314 this.transitioning = 0 14315 this.$element 14316 .trigger('shown.bs.collapse') 14317 } 14318 14319 if (!$.support.transition) return complete.call(this) 14320 14321 var scrollSize = $.camelCase(['scroll', dimension].join('-')) 14322 14323 this.$element 14324 .one('bsTransitionEnd', $.proxy(complete, this)) 14325 .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) 14326 } 14327 14328 Collapse.prototype.hide = function () { 14329 if (this.transitioning || !this.$element.hasClass('in')) return 14330 14331 var startEvent = $.Event('hide.bs.collapse') 14332 this.$element.trigger(startEvent) 14333 if (startEvent.isDefaultPrevented()) return 14334 14335 var dimension = this.dimension() 14336 14337 this.$element[dimension](this.$element[dimension]())[0].offsetHeight 14338 14339 this.$element 14340 .addClass('collapsing') 14341 .removeClass('collapse in') 14342 .attr('aria-expanded', false) 14343 14344 this.$trigger 14345 .addClass('collapsed') 14346 .attr('aria-expanded', false) 14347 14348 this.transitioning = 1 14349 14350 var complete = function () { 14351 this.transitioning = 0 14352 this.$element 14353 .removeClass('collapsing') 14354 .addClass('collapse') 14355 .trigger('hidden.bs.collapse') 14356 } 14357 14358 if (!$.support.transition) return complete.call(this) 14359 14360 this.$element 14361 [dimension](0) 14362 .one('bsTransitionEnd', $.proxy(complete, this)) 14363 .emulateTransitionEnd(Collapse.TRANSITION_DURATION) 14364 } 14365 14366 Collapse.prototype.toggle = function () { 14367 this[this.$element.hasClass('in') ? 'hide' : 'show']() 14368 } 14369 14370 Collapse.prototype.getParent = function () { 14371 return $(document).find(this.options.parent) 14372 .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]') 14373 .each($.proxy(function (i, element) { 14374 var $element = $(element) 14375 this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element) 14376 }, this)) 14377 .end() 14378 } 14379 14380 Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) { 14381 var isOpen = $element.hasClass('in') 14382 14383 $element.attr('aria-expanded', isOpen) 14384 $trigger 14385 .toggleClass('collapsed', !isOpen) 14386 .attr('aria-expanded', isOpen) 14387 } 14388 14389 function getTargetFromTrigger($trigger) { 14390 var href 14391 var target = $trigger.attr('data-target') 14392 || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 14393 14394 return $(document).find(target) 14395 } 14396 14397 14398 // COLLAPSE PLUGIN DEFINITION 14399 // ========================== 14400 14401 function Plugin(option) { 14402 return this.each(function () { 14403 var $this = $(this) 14404 var data = $this.data('bs.collapse') 14405 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) 14406 14407 if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false 14408 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) 14409 if (typeof option == 'string') data[option]() 14410 }) 14411 } 14412 14413 var old = $.fn.collapse 14414 14415 $.fn.collapse = Plugin 14416 $.fn.collapse.Constructor = Collapse 14417 14418 14419 // COLLAPSE NO CONFLICT 14420 // ==================== 14421 14422 $.fn.collapse.noConflict = function () { 14423 $.fn.collapse = old 14424 return this 14425 } 14426 14427 14428 // COLLAPSE DATA-API 14429 // ================= 14430 14431 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { 14432 var $this = $(this) 14433 14434 if (!$this.attr('data-target')) e.preventDefault() 14435 14436 var $target = getTargetFromTrigger($this) 14437 var data = $target.data('bs.collapse') 14438 var option = data ? 'toggle' : $this.data() 14439 14440 Plugin.call($target, option) 14441 }) 14442 14443}(jQuery); 14444/* ======================================================================== 14445 * Bootstrap: dropdown.js v3.4.1 14446 * https://getbootstrap.com/docs/3.4/javascript/#dropdowns 14447 * ======================================================================== 14448 * Copyright 2011-2019 Twitter, Inc. 14449 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 14450 * ======================================================================== */ 14451 14452 14453+function ($) { 14454 'use strict'; 14455 14456 // DROPDOWN CLASS DEFINITION 14457 // ========================= 14458 14459 var backdrop = '.dropdown-backdrop' 14460 var toggle = '[data-toggle="dropdown"]' 14461 var Dropdown = function (element) { 14462 $(element).on('click.bs.dropdown', this.toggle) 14463 } 14464 14465 Dropdown.VERSION = '3.4.1' 14466 14467 function getParent($this) { 14468 var selector = $this.attr('data-target') 14469 14470 if (!selector) { 14471 selector = $this.attr('href') 14472 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 14473 } 14474 14475 var $parent = selector !== '#' ? $(document).find(selector) : null 14476 14477 return $parent && $parent.length ? $parent : $this.parent() 14478 } 14479 14480 function clearMenus(e) { 14481 if (e && e.which === 3) return 14482 $(backdrop).remove() 14483 $(toggle).each(function () { 14484 var $this = $(this) 14485 var $parent = getParent($this) 14486 var relatedTarget = { relatedTarget: this } 14487 14488 if (!$parent.hasClass('open')) return 14489 14490 if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return 14491 14492 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) 14493 14494 if (e.isDefaultPrevented()) return 14495 14496 $this.attr('aria-expanded', 'false') 14497 $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget)) 14498 }) 14499 } 14500 14501 Dropdown.prototype.toggle = function (e) { 14502 var $this = $(this) 14503 14504 if ($this.is('.disabled, :disabled')) return 14505 14506 var $parent = getParent($this) 14507 var isActive = $parent.hasClass('open') 14508 14509 clearMenus() 14510 14511 if (!isActive) { 14512 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { 14513 // if mobile we use a backdrop because click events don't delegate 14514 $(document.createElement('div')) 14515 .addClass('dropdown-backdrop') 14516 .insertAfter($(this)) 14517 .on('click', clearMenus) 14518 } 14519 14520 var relatedTarget = { relatedTarget: this } 14521 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)) 14522 14523 if (e.isDefaultPrevented()) return 14524 14525 $this 14526 .trigger('focus') 14527 .attr('aria-expanded', 'true') 14528 14529 $parent 14530 .toggleClass('open') 14531 .trigger($.Event('shown.bs.dropdown', relatedTarget)) 14532 } 14533 14534 return false 14535 } 14536 14537 Dropdown.prototype.keydown = function (e) { 14538 if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return 14539 14540 var $this = $(this) 14541 14542 e.preventDefault() 14543 e.stopPropagation() 14544 14545 if ($this.is('.disabled, :disabled')) return 14546 14547 var $parent = getParent($this) 14548 var isActive = $parent.hasClass('open') 14549 14550 if (!isActive && e.which != 27 || isActive && e.which == 27) { 14551 if (e.which == 27) $parent.find(toggle).trigger('focus') 14552 return $this.trigger('click') 14553 } 14554 14555 var desc = ' li:not(.disabled):visible a' 14556 var $items = $parent.find('.dropdown-menu' + desc) 14557 14558 if (!$items.length) return 14559 14560 var index = $items.index(e.target) 14561 14562 if (e.which == 38 && index > 0) index-- // up 14563 if (e.which == 40 && index < $items.length - 1) index++ // down 14564 if (!~index) index = 0 14565 14566 $items.eq(index).trigger('focus') 14567 } 14568 14569 14570 // DROPDOWN PLUGIN DEFINITION 14571 // ========================== 14572 14573 function Plugin(option) { 14574 return this.each(function () { 14575 var $this = $(this) 14576 var data = $this.data('bs.dropdown') 14577 14578 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) 14579 if (typeof option == 'string') data[option].call($this) 14580 }) 14581 } 14582 14583 var old = $.fn.dropdown 14584 14585 $.fn.dropdown = Plugin 14586 $.fn.dropdown.Constructor = Dropdown 14587 14588 14589 // DROPDOWN NO CONFLICT 14590 // ==================== 14591 14592 $.fn.dropdown.noConflict = function () { 14593 $.fn.dropdown = old 14594 return this 14595 } 14596 14597 14598 // APPLY TO STANDARD DROPDOWN ELEMENTS 14599 // =================================== 14600 14601 $(document) 14602 .on('click.bs.dropdown.data-api', clearMenus) 14603 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) 14604 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) 14605 .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown) 14606 .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown) 14607 14608}(jQuery); 14609/* ======================================================================== 14610 * Bootstrap: modal.js v3.4.1 14611 * https://getbootstrap.com/docs/3.4/javascript/#modals 14612 * ======================================================================== 14613 * Copyright 2011-2019 Twitter, Inc. 14614 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 14615 * ======================================================================== */ 14616 14617 14618+function ($) { 14619 'use strict'; 14620 14621 // MODAL CLASS DEFINITION 14622 // ====================== 14623 14624 var Modal = function (element, options) { 14625 this.options = options 14626 this.$body = $(document.body) 14627 this.$element = $(element) 14628 this.$dialog = this.$element.find('.modal-dialog') 14629 this.$backdrop = null 14630 this.isShown = null 14631 this.originalBodyPad = null 14632 this.scrollbarWidth = 0 14633 this.ignoreBackdropClick = false 14634 this.fixedContent = '.navbar-fixed-top, .navbar-fixed-bottom' 14635 14636 if (this.options.remote) { 14637 this.$element 14638 .find('.modal-content') 14639 .load(this.options.remote, $.proxy(function () { 14640 this.$element.trigger('loaded.bs.modal') 14641 }, this)) 14642 } 14643 } 14644 14645 Modal.VERSION = '3.4.1' 14646 14647 Modal.TRANSITION_DURATION = 300 14648 Modal.BACKDROP_TRANSITION_DURATION = 150 14649 14650 Modal.DEFAULTS = { 14651 backdrop: true, 14652 keyboard: true, 14653 show: true 14654 } 14655 14656 Modal.prototype.toggle = function (_relatedTarget) { 14657 return this.isShown ? this.hide() : this.show(_relatedTarget) 14658 } 14659 14660 Modal.prototype.show = function (_relatedTarget) { 14661 var that = this 14662 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 14663 14664 this.$element.trigger(e) 14665 14666 if (this.isShown || e.isDefaultPrevented()) return 14667 14668 this.isShown = true 14669 14670 this.checkScrollbar() 14671 this.setScrollbar() 14672 this.$body.addClass('modal-open') 14673 14674 this.escape() 14675 this.resize() 14676 14677 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 14678 14679 this.$dialog.on('mousedown.dismiss.bs.modal', function () { 14680 that.$element.one('mouseup.dismiss.bs.modal', function (e) { 14681 if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true 14682 }) 14683 }) 14684 14685 this.backdrop(function () { 14686 var transition = $.support.transition && that.$element.hasClass('fade') 14687 14688 if (!that.$element.parent().length) { 14689 that.$element.appendTo(that.$body) // don't move modals dom position 14690 } 14691 14692 that.$element 14693 .show() 14694 .scrollTop(0) 14695 14696 that.adjustDialog() 14697 14698 if (transition) { 14699 that.$element[0].offsetWidth // force reflow 14700 } 14701 14702 that.$element.addClass('in') 14703 14704 that.enforceFocus() 14705 14706 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 14707 14708 transition ? 14709 that.$dialog // wait for modal to slide in 14710 .one('bsTransitionEnd', function () { 14711 that.$element.trigger('focus').trigger(e) 14712 }) 14713 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 14714 that.$element.trigger('focus').trigger(e) 14715 }) 14716 } 14717 14718 Modal.prototype.hide = function (e) { 14719 if (e) e.preventDefault() 14720 14721 e = $.Event('hide.bs.modal') 14722 14723 this.$element.trigger(e) 14724 14725 if (!this.isShown || e.isDefaultPrevented()) return 14726 14727 this.isShown = false 14728 14729 this.escape() 14730 this.resize() 14731 14732 $(document).off('focusin.bs.modal') 14733 14734 this.$element 14735 .removeClass('in') 14736 .off('click.dismiss.bs.modal') 14737 .off('mouseup.dismiss.bs.modal') 14738 14739 this.$dialog.off('mousedown.dismiss.bs.modal') 14740 14741 $.support.transition && this.$element.hasClass('fade') ? 14742 this.$element 14743 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 14744 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 14745 this.hideModal() 14746 } 14747 14748 Modal.prototype.enforceFocus = function () { 14749 $(document) 14750 .off('focusin.bs.modal') // guard against infinite focus loop 14751 .on('focusin.bs.modal', $.proxy(function (e) { 14752 if (document !== e.target && 14753 this.$element[0] !== e.target && 14754 !this.$element.has(e.target).length) { 14755 this.$element.trigger('focus') 14756 } 14757 }, this)) 14758 } 14759 14760 Modal.prototype.escape = function () { 14761 if (this.isShown && this.options.keyboard) { 14762 this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { 14763 e.which == 27 && this.hide() 14764 }, this)) 14765 } else if (!this.isShown) { 14766 this.$element.off('keydown.dismiss.bs.modal') 14767 } 14768 } 14769 14770 Modal.prototype.resize = function () { 14771 if (this.isShown) { 14772 $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) 14773 } else { 14774 $(window).off('resize.bs.modal') 14775 } 14776 } 14777 14778 Modal.prototype.hideModal = function () { 14779 var that = this 14780 this.$element.hide() 14781 this.backdrop(function () { 14782 that.$body.removeClass('modal-open') 14783 that.resetAdjustments() 14784 that.resetScrollbar() 14785 that.$element.trigger('hidden.bs.modal') 14786 }) 14787 } 14788 14789 Modal.prototype.removeBackdrop = function () { 14790 this.$backdrop && this.$backdrop.remove() 14791 this.$backdrop = null 14792 } 14793 14794 Modal.prototype.backdrop = function (callback) { 14795 var that = this 14796 var animate = this.$element.hasClass('fade') ? 'fade' : '' 14797 14798 if (this.isShown && this.options.backdrop) { 14799 var doAnimate = $.support.transition && animate 14800 14801 this.$backdrop = $(document.createElement('div')) 14802 .addClass('modal-backdrop ' + animate) 14803 .appendTo(this.$body) 14804 14805 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { 14806 if (this.ignoreBackdropClick) { 14807 this.ignoreBackdropClick = false 14808 return 14809 } 14810 if (e.target !== e.currentTarget) return 14811 this.options.backdrop == 'static' 14812 ? this.$element[0].focus() 14813 : this.hide() 14814 }, this)) 14815 14816 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 14817 14818 this.$backdrop.addClass('in') 14819 14820 if (!callback) return 14821 14822 doAnimate ? 14823 this.$backdrop 14824 .one('bsTransitionEnd', callback) 14825 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 14826 callback() 14827 14828 } else if (!this.isShown && this.$backdrop) { 14829 this.$backdrop.removeClass('in') 14830 14831 var callbackRemove = function () { 14832 that.removeBackdrop() 14833 callback && callback() 14834 } 14835 $.support.transition && this.$element.hasClass('fade') ? 14836 this.$backdrop 14837 .one('bsTransitionEnd', callbackRemove) 14838 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 14839 callbackRemove() 14840 14841 } else if (callback) { 14842 callback() 14843 } 14844 } 14845 14846 // these following methods are used to handle overflowing modals 14847 14848 Modal.prototype.handleUpdate = function () { 14849 this.adjustDialog() 14850 } 14851 14852 Modal.prototype.adjustDialog = function () { 14853 var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight 14854 14855 this.$element.css({ 14856 paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', 14857 paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' 14858 }) 14859 } 14860 14861 Modal.prototype.resetAdjustments = function () { 14862 this.$element.css({ 14863 paddingLeft: '', 14864 paddingRight: '' 14865 }) 14866 } 14867 14868 Modal.prototype.checkScrollbar = function () { 14869 var fullWindowWidth = window.innerWidth 14870 if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 14871 var documentElementRect = document.documentElement.getBoundingClientRect() 14872 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left) 14873 } 14874 this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth 14875 this.scrollbarWidth = this.measureScrollbar() 14876 } 14877 14878 Modal.prototype.setScrollbar = function () { 14879 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 14880 this.originalBodyPad = document.body.style.paddingRight || '' 14881 var scrollbarWidth = this.scrollbarWidth 14882 if (this.bodyIsOverflowing) { 14883 this.$body.css('padding-right', bodyPad + scrollbarWidth) 14884 $(this.fixedContent).each(function (index, element) { 14885 var actualPadding = element.style.paddingRight 14886 var calculatedPadding = $(element).css('padding-right') 14887 $(element) 14888 .data('padding-right', actualPadding) 14889 .css('padding-right', parseFloat(calculatedPadding) + scrollbarWidth + 'px') 14890 }) 14891 } 14892 } 14893 14894 Modal.prototype.resetScrollbar = function () { 14895 this.$body.css('padding-right', this.originalBodyPad) 14896 $(this.fixedContent).each(function (index, element) { 14897 var padding = $(element).data('padding-right') 14898 $(element).removeData('padding-right') 14899 element.style.paddingRight = padding ? padding : '' 14900 }) 14901 } 14902 14903 Modal.prototype.measureScrollbar = function () { // thx walsh 14904 var scrollDiv = document.createElement('div') 14905 scrollDiv.className = 'modal-scrollbar-measure' 14906 this.$body.append(scrollDiv) 14907 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 14908 this.$body[0].removeChild(scrollDiv) 14909 return scrollbarWidth 14910 } 14911 14912 14913 // MODAL PLUGIN DEFINITION 14914 // ======================= 14915 14916 function Plugin(option, _relatedTarget) { 14917 return this.each(function () { 14918 var $this = $(this) 14919 var data = $this.data('bs.modal') 14920 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 14921 14922 if (!data) $this.data('bs.modal', (data = new Modal(this, options))) 14923 if (typeof option == 'string') data[option](_relatedTarget) 14924 else if (options.show) data.show(_relatedTarget) 14925 }) 14926 } 14927 14928 var old = $.fn.modal 14929 14930 $.fn.modal = Plugin 14931 $.fn.modal.Constructor = Modal 14932 14933 14934 // MODAL NO CONFLICT 14935 // ================= 14936 14937 $.fn.modal.noConflict = function () { 14938 $.fn.modal = old 14939 return this 14940 } 14941 14942 14943 // MODAL DATA-API 14944 // ============== 14945 14946 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 14947 var $this = $(this) 14948 var href = $this.attr('href') 14949 var target = $this.attr('data-target') || 14950 (href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 14951 14952 var $target = $(document).find(target) 14953 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 14954 14955 if ($this.is('a')) e.preventDefault() 14956 14957 $target.one('show.bs.modal', function (showEvent) { 14958 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown 14959 $target.one('hidden.bs.modal', function () { 14960 $this.is(':visible') && $this.trigger('focus') 14961 }) 14962 }) 14963 Plugin.call($target, option, this) 14964 }) 14965 14966}(jQuery); 14967/* ======================================================================== 14968 * Bootstrap: tooltip.js v3.4.1 14969 * https://getbootstrap.com/docs/3.4/javascript/#tooltip 14970 * Inspired by the original jQuery.tipsy by Jason Frame 14971 * ======================================================================== 14972 * Copyright 2011-2019 Twitter, Inc. 14973 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 14974 * ======================================================================== */ 14975 14976+function ($) { 14977 'use strict'; 14978 14979 var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'] 14980 14981 var uriAttrs = [ 14982 'background', 14983 'cite', 14984 'href', 14985 'itemtype', 14986 'longdesc', 14987 'poster', 14988 'src', 14989 'xlink:href' 14990 ] 14991 14992 var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i 14993 14994 var DefaultWhitelist = { 14995 // Global attributes allowed on any supplied element below. 14996 '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], 14997 a: ['target', 'href', 'title', 'rel'], 14998 area: [], 14999 b: [], 15000 br: [], 15001 col: [], 15002 code: [], 15003 div: [], 15004 em: [], 15005 hr: [], 15006 h1: [], 15007 h2: [], 15008 h3: [], 15009 h4: [], 15010 h5: [], 15011 h6: [], 15012 i: [], 15013 img: ['src', 'alt', 'title', 'width', 'height'], 15014 li: [], 15015 ol: [], 15016 p: [], 15017 pre: [], 15018 s: [], 15019 small: [], 15020 span: [], 15021 sub: [], 15022 sup: [], 15023 strong: [], 15024 u: [], 15025 ul: [] 15026 } 15027 15028 /** 15029 * A pattern that recognizes a commonly useful subset of URLs that are safe. 15030 * 15031 * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts 15032 */ 15033 var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi 15034 15035 /** 15036 * A pattern that matches safe data URLs. Only matches image, video and audio types. 15037 * 15038 * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts 15039 */ 15040 var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i 15041 15042 function allowedAttribute(attr, allowedAttributeList) { 15043 var attrName = attr.nodeName.toLowerCase() 15044 15045 if ($.inArray(attrName, allowedAttributeList) !== -1) { 15046 if ($.inArray(attrName, uriAttrs) !== -1) { 15047 return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)) 15048 } 15049 15050 return true 15051 } 15052 15053 var regExp = $(allowedAttributeList).filter(function (index, value) { 15054 return value instanceof RegExp 15055 }) 15056 15057 // Check if a regular expression validates the attribute. 15058 for (var i = 0, l = regExp.length; i < l; i++) { 15059 if (attrName.match(regExp[i])) { 15060 return true 15061 } 15062 } 15063 15064 return false 15065 } 15066 15067 function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { 15068 if (unsafeHtml.length === 0) { 15069 return unsafeHtml 15070 } 15071 15072 if (sanitizeFn && typeof sanitizeFn === 'function') { 15073 return sanitizeFn(unsafeHtml) 15074 } 15075 15076 // IE 8 and below don't support createHTMLDocument 15077 if (!document.implementation || !document.implementation.createHTMLDocument) { 15078 return unsafeHtml 15079 } 15080 15081 var createdDocument = document.implementation.createHTMLDocument('sanitization') 15082 createdDocument.body.innerHTML = unsafeHtml 15083 15084 var whitelistKeys = $.map(whiteList, function (el, i) { return i }) 15085 var elements = $(createdDocument.body).find('*') 15086 15087 for (var i = 0, len = elements.length; i < len; i++) { 15088 var el = elements[i] 15089 var elName = el.nodeName.toLowerCase() 15090 15091 if ($.inArray(elName, whitelistKeys) === -1) { 15092 el.parentNode.removeChild(el) 15093 15094 continue 15095 } 15096 15097 var attributeList = $.map(el.attributes, function (el) { return el }) 15098 var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []) 15099 15100 for (var j = 0, len2 = attributeList.length; j < len2; j++) { 15101 if (!allowedAttribute(attributeList[j], whitelistedAttributes)) { 15102 el.removeAttribute(attributeList[j].nodeName) 15103 } 15104 } 15105 } 15106 15107 return createdDocument.body.innerHTML 15108 } 15109 15110 // TOOLTIP PUBLIC CLASS DEFINITION 15111 // =============================== 15112 15113 var Tooltip = function (element, options) { 15114 this.type = null 15115 this.options = null 15116 this.enabled = null 15117 this.timeout = null 15118 this.hoverState = null 15119 this.$element = null 15120 this.inState = null 15121 15122 this.init('tooltip', element, options) 15123 } 15124 15125 Tooltip.VERSION = '3.4.1' 15126 15127 Tooltip.TRANSITION_DURATION = 150 15128 15129 Tooltip.DEFAULTS = { 15130 animation: true, 15131 placement: 'top', 15132 selector: false, 15133 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', 15134 trigger: 'hover focus', 15135 title: '', 15136 delay: 0, 15137 html: false, 15138 container: false, 15139 viewport: { 15140 selector: 'body', 15141 padding: 0 15142 }, 15143 sanitize : true, 15144 sanitizeFn : null, 15145 whiteList : DefaultWhitelist 15146 } 15147 15148 Tooltip.prototype.init = function (type, element, options) { 15149 this.enabled = true 15150 this.type = type 15151 this.$element = $(element) 15152 this.options = this.getOptions(options) 15153 this.$viewport = this.options.viewport && $(document).find($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport)) 15154 this.inState = { click: false, hover: false, focus: false } 15155 15156 if (this.$element[0] instanceof document.constructor && !this.options.selector) { 15157 throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!') 15158 } 15159 15160 var triggers = this.options.trigger.split(' ') 15161 15162 for (var i = triggers.length; i--;) { 15163 var trigger = triggers[i] 15164 15165 if (trigger == 'click') { 15166 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) 15167 } else if (trigger != 'manual') { 15168 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin' 15169 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout' 15170 15171 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) 15172 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) 15173 } 15174 } 15175 15176 this.options.selector ? 15177 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : 15178 this.fixTitle() 15179 } 15180 15181 Tooltip.prototype.getDefaults = function () { 15182 return Tooltip.DEFAULTS 15183 } 15184 15185 Tooltip.prototype.getOptions = function (options) { 15186 var dataAttributes = this.$element.data() 15187 15188 for (var dataAttr in dataAttributes) { 15189 if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) { 15190 delete dataAttributes[dataAttr] 15191 } 15192 } 15193 15194 options = $.extend({}, this.getDefaults(), dataAttributes, options) 15195 15196 if (options.delay && typeof options.delay == 'number') { 15197 options.delay = { 15198 show: options.delay, 15199 hide: options.delay 15200 } 15201 } 15202 15203 if (options.sanitize) { 15204 options.template = sanitizeHtml(options.template, options.whiteList, options.sanitizeFn) 15205 } 15206 15207 return options 15208 } 15209 15210 Tooltip.prototype.getDelegateOptions = function () { 15211 var options = {} 15212 var defaults = this.getDefaults() 15213 15214 this._options && $.each(this._options, function (key, value) { 15215 if (defaults[key] != value) options[key] = value 15216 }) 15217 15218 return options 15219 } 15220 15221 Tooltip.prototype.enter = function (obj) { 15222 var self = obj instanceof this.constructor ? 15223 obj : $(obj.currentTarget).data('bs.' + this.type) 15224 15225 if (!self) { 15226 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 15227 $(obj.currentTarget).data('bs.' + this.type, self) 15228 } 15229 15230 if (obj instanceof $.Event) { 15231 self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true 15232 } 15233 15234 if (self.tip().hasClass('in') || self.hoverState == 'in') { 15235 self.hoverState = 'in' 15236 return 15237 } 15238 15239 clearTimeout(self.timeout) 15240 15241 self.hoverState = 'in' 15242 15243 if (!self.options.delay || !self.options.delay.show) return self.show() 15244 15245 self.timeout = setTimeout(function () { 15246 if (self.hoverState == 'in') self.show() 15247 }, self.options.delay.show) 15248 } 15249 15250 Tooltip.prototype.isInStateTrue = function () { 15251 for (var key in this.inState) { 15252 if (this.inState[key]) return true 15253 } 15254 15255 return false 15256 } 15257 15258 Tooltip.prototype.leave = function (obj) { 15259 var self = obj instanceof this.constructor ? 15260 obj : $(obj.currentTarget).data('bs.' + this.type) 15261 15262 if (!self) { 15263 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 15264 $(obj.currentTarget).data('bs.' + this.type, self) 15265 } 15266 15267 if (obj instanceof $.Event) { 15268 self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false 15269 } 15270 15271 if (self.isInStateTrue()) return 15272 15273 clearTimeout(self.timeout) 15274 15275 self.hoverState = 'out' 15276 15277 if (!self.options.delay || !self.options.delay.hide) return self.hide() 15278 15279 self.timeout = setTimeout(function () { 15280 if (self.hoverState == 'out') self.hide() 15281 }, self.options.delay.hide) 15282 } 15283 15284 Tooltip.prototype.show = function () { 15285 var e = $.Event('show.bs.' + this.type) 15286 15287 if (this.hasContent() && this.enabled) { 15288 this.$element.trigger(e) 15289 15290 var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0]) 15291 if (e.isDefaultPrevented() || !inDom) return 15292 var that = this 15293 15294 var $tip = this.tip() 15295 15296 var tipId = this.getUID(this.type) 15297 15298 this.setContent() 15299 $tip.attr('id', tipId) 15300 this.$element.attr('aria-describedby', tipId) 15301 15302 if (this.options.animation) $tip.addClass('fade') 15303 15304 var placement = typeof this.options.placement == 'function' ? 15305 this.options.placement.call(this, $tip[0], this.$element[0]) : 15306 this.options.placement 15307 15308 var autoToken = /\s?auto?\s?/i 15309 var autoPlace = autoToken.test(placement) 15310 if (autoPlace) placement = placement.replace(autoToken, '') || 'top' 15311 15312 $tip 15313 .detach() 15314 .css({ top: 0, left: 0, display: 'block' }) 15315 .addClass(placement) 15316 .data('bs.' + this.type, this) 15317 15318 this.options.container ? $tip.appendTo($(document).find(this.options.container)) : $tip.insertAfter(this.$element) 15319 this.$element.trigger('inserted.bs.' + this.type) 15320 15321 var pos = this.getPosition() 15322 var actualWidth = $tip[0].offsetWidth 15323 var actualHeight = $tip[0].offsetHeight 15324 15325 if (autoPlace) { 15326 var orgPlacement = placement 15327 var viewportDim = this.getPosition(this.$viewport) 15328 15329 placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' : 15330 placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' : 15331 placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' : 15332 placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' : 15333 placement 15334 15335 $tip 15336 .removeClass(orgPlacement) 15337 .addClass(placement) 15338 } 15339 15340 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) 15341 15342 this.applyPlacement(calculatedOffset, placement) 15343 15344 var complete = function () { 15345 var prevHoverState = that.hoverState 15346 that.$element.trigger('shown.bs.' + that.type) 15347 that.hoverState = null 15348 15349 if (prevHoverState == 'out') that.leave(that) 15350 } 15351 15352 $.support.transition && this.$tip.hasClass('fade') ? 15353 $tip 15354 .one('bsTransitionEnd', complete) 15355 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : 15356 complete() 15357 } 15358 } 15359 15360 Tooltip.prototype.applyPlacement = function (offset, placement) { 15361 var $tip = this.tip() 15362 var width = $tip[0].offsetWidth 15363 var height = $tip[0].offsetHeight 15364 15365 // manually read margins because getBoundingClientRect includes difference 15366 var marginTop = parseInt($tip.css('margin-top'), 10) 15367 var marginLeft = parseInt($tip.css('margin-left'), 10) 15368 15369 // we must check for NaN for ie 8/9 15370 if (isNaN(marginTop)) marginTop = 0 15371 if (isNaN(marginLeft)) marginLeft = 0 15372 15373 offset.top += marginTop 15374 offset.left += marginLeft 15375 15376 // $.fn.offset doesn't round pixel values 15377 // so we use setOffset directly with our own function B-0 15378 $.offset.setOffset($tip[0], $.extend({ 15379 using: function (props) { 15380 $tip.css({ 15381 top: Math.round(props.top), 15382 left: Math.round(props.left) 15383 }) 15384 } 15385 }, offset), 0) 15386 15387 $tip.addClass('in') 15388 15389 // check to see if placing tip in new offset caused the tip to resize itself 15390 var actualWidth = $tip[0].offsetWidth 15391 var actualHeight = $tip[0].offsetHeight 15392 15393 if (placement == 'top' && actualHeight != height) { 15394 offset.top = offset.top + height - actualHeight 15395 } 15396 15397 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight) 15398 15399 if (delta.left) offset.left += delta.left 15400 else offset.top += delta.top 15401 15402 var isVertical = /top|bottom/.test(placement) 15403 var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight 15404 var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight' 15405 15406 $tip.offset(offset) 15407 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical) 15408 } 15409 15410 Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) { 15411 this.arrow() 15412 .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%') 15413 .css(isVertical ? 'top' : 'left', '') 15414 } 15415 15416 Tooltip.prototype.setContent = function () { 15417 var $tip = this.tip() 15418 var title = this.getTitle() 15419 15420 if (this.options.html) { 15421 if (this.options.sanitize) { 15422 title = sanitizeHtml(title, this.options.whiteList, this.options.sanitizeFn) 15423 } 15424 15425 $tip.find('.tooltip-inner').html(title) 15426 } else { 15427 $tip.find('.tooltip-inner').text(title) 15428 } 15429 15430 $tip.removeClass('fade in top bottom left right') 15431 } 15432 15433 Tooltip.prototype.hide = function (callback) { 15434 var that = this 15435 var $tip = $(this.$tip) 15436 var e = $.Event('hide.bs.' + this.type) 15437 15438 function complete() { 15439 if (that.hoverState != 'in') $tip.detach() 15440 if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary. 15441 that.$element 15442 .removeAttr('aria-describedby') 15443 .trigger('hidden.bs.' + that.type) 15444 } 15445 callback && callback() 15446 } 15447 15448 this.$element.trigger(e) 15449 15450 if (e.isDefaultPrevented()) return 15451 15452 $tip.removeClass('in') 15453 15454 $.support.transition && $tip.hasClass('fade') ? 15455 $tip 15456 .one('bsTransitionEnd', complete) 15457 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : 15458 complete() 15459 15460 this.hoverState = null 15461 15462 return this 15463 } 15464 15465 Tooltip.prototype.fixTitle = function () { 15466 var $e = this.$element 15467 if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') { 15468 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '') 15469 } 15470 } 15471 15472 Tooltip.prototype.hasContent = function () { 15473 return this.getTitle() 15474 } 15475 15476 Tooltip.prototype.getPosition = function ($element) { 15477 $element = $element || this.$element 15478 15479 var el = $element[0] 15480 var isBody = el.tagName == 'BODY' 15481 15482 var elRect = el.getBoundingClientRect() 15483 if (elRect.width == null) { 15484 // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093 15485 elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top }) 15486 } 15487 var isSvg = window.SVGElement && el instanceof window.SVGElement 15488 // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3. 15489 // See https://github.com/twbs/bootstrap/issues/20280 15490 var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset()) 15491 var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() } 15492 var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null 15493 15494 return $.extend({}, elRect, scroll, outerDims, elOffset) 15495 } 15496 15497 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { 15498 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : 15499 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : 15500 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : 15501 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } 15502 15503 } 15504 15505 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) { 15506 var delta = { top: 0, left: 0 } 15507 if (!this.$viewport) return delta 15508 15509 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0 15510 var viewportDimensions = this.getPosition(this.$viewport) 15511 15512 if (/right|left/.test(placement)) { 15513 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll 15514 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight 15515 if (topEdgeOffset < viewportDimensions.top) { // top overflow 15516 delta.top = viewportDimensions.top - topEdgeOffset 15517 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow 15518 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset 15519 } 15520 } else { 15521 var leftEdgeOffset = pos.left - viewportPadding 15522 var rightEdgeOffset = pos.left + viewportPadding + actualWidth 15523 if (leftEdgeOffset < viewportDimensions.left) { // left overflow 15524 delta.left = viewportDimensions.left - leftEdgeOffset 15525 } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow 15526 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset 15527 } 15528 } 15529 15530 return delta 15531 } 15532 15533 Tooltip.prototype.getTitle = function () { 15534 var title 15535 var $e = this.$element 15536 var o = this.options 15537 15538 title = $e.attr('data-original-title') 15539 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) 15540 15541 return title 15542 } 15543 15544 Tooltip.prototype.getUID = function (prefix) { 15545 do prefix += ~~(Math.random() * 1000000) 15546 while (document.getElementById(prefix)) 15547 return prefix 15548 } 15549 15550 Tooltip.prototype.tip = function () { 15551 if (!this.$tip) { 15552 this.$tip = $(this.options.template) 15553 if (this.$tip.length != 1) { 15554 throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!') 15555 } 15556 } 15557 return this.$tip 15558 } 15559 15560 Tooltip.prototype.arrow = function () { 15561 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')) 15562 } 15563 15564 Tooltip.prototype.enable = function () { 15565 this.enabled = true 15566 } 15567 15568 Tooltip.prototype.disable = function () { 15569 this.enabled = false 15570 } 15571 15572 Tooltip.prototype.toggleEnabled = function () { 15573 this.enabled = !this.enabled 15574 } 15575 15576 Tooltip.prototype.toggle = function (e) { 15577 var self = this 15578 if (e) { 15579 self = $(e.currentTarget).data('bs.' + this.type) 15580 if (!self) { 15581 self = new this.constructor(e.currentTarget, this.getDelegateOptions()) 15582 $(e.currentTarget).data('bs.' + this.type, self) 15583 } 15584 } 15585 15586 if (e) { 15587 self.inState.click = !self.inState.click 15588 if (self.isInStateTrue()) self.enter(self) 15589 else self.leave(self) 15590 } else { 15591 self.tip().hasClass('in') ? self.leave(self) : self.enter(self) 15592 } 15593 } 15594 15595 Tooltip.prototype.destroy = function () { 15596 var that = this 15597 clearTimeout(this.timeout) 15598 this.hide(function () { 15599 that.$element.off('.' + that.type).removeData('bs.' + that.type) 15600 if (that.$tip) { 15601 that.$tip.detach() 15602 } 15603 that.$tip = null 15604 that.$arrow = null 15605 that.$viewport = null 15606 that.$element = null 15607 }) 15608 } 15609 15610 Tooltip.prototype.sanitizeHtml = function (unsafeHtml) { 15611 return sanitizeHtml(unsafeHtml, this.options.whiteList, this.options.sanitizeFn) 15612 } 15613 15614 // TOOLTIP PLUGIN DEFINITION 15615 // ========================= 15616 15617 function Plugin(option) { 15618 return this.each(function () { 15619 var $this = $(this) 15620 var data = $this.data('bs.tooltip') 15621 var options = typeof option == 'object' && option 15622 15623 if (!data && /destroy|hide/.test(option)) return 15624 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options))) 15625 if (typeof option == 'string') data[option]() 15626 }) 15627 } 15628 15629 var old = $.fn.tooltip 15630 15631 $.fn.tooltip = Plugin 15632 $.fn.tooltip.Constructor = Tooltip 15633 15634 15635 // TOOLTIP NO CONFLICT 15636 // =================== 15637 15638 $.fn.tooltip.noConflict = function () { 15639 $.fn.tooltip = old 15640 return this 15641 } 15642 15643}(jQuery); 15644/* ======================================================================== 15645 * Bootstrap: transition.js v3.4.1 15646 * https://getbootstrap.com/docs/3.4/javascript/#transitions 15647 * ======================================================================== 15648 * Copyright 2011-2019 Twitter, Inc. 15649 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 15650 * ======================================================================== */ 15651 15652 15653+function ($) { 15654 'use strict'; 15655 15656 // CSS TRANSITION SUPPORT (Shoutout: https://modernizr.com/) 15657 // ============================================================ 15658 15659 function transitionEnd() { 15660 var el = document.createElement('bootstrap') 15661 15662 var transEndEventNames = { 15663 WebkitTransition : 'webkitTransitionEnd', 15664 MozTransition : 'transitionend', 15665 OTransition : 'oTransitionEnd otransitionend', 15666 transition : 'transitionend' 15667 } 15668 15669 for (var name in transEndEventNames) { 15670 if (el.style[name] !== undefined) { 15671 return { end: transEndEventNames[name] } 15672 } 15673 } 15674 15675 return false // explicit for ie8 ( ._.) 15676 } 15677 15678 // https://blog.alexmaccaw.com/css-transitions 15679 $.fn.emulateTransitionEnd = function (duration) { 15680 var called = false 15681 var $el = this 15682 $(this).one('bsTransitionEnd', function () { called = true }) 15683 var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 15684 setTimeout(callback, duration) 15685 return this 15686 } 15687 15688 $(function () { 15689 $.support.transition = transitionEnd() 15690 15691 if (!$.support.transition) return 15692 15693 $.event.special.bsTransitionEnd = { 15694 bindType: $.support.transition.end, 15695 delegateType: $.support.transition.end, 15696 handle: function (e) { 15697 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) 15698 } 15699 } 15700 }) 15701 15702}(jQuery); 15703// We can require bootstrap-sprockets to require ALL bootstrap, but we only use a portion of bootstrap, so we require individual files 15704// NOTE: // require is a COMMENT 15705// //= enables the file 15706// dropdown is required for navbar 15707 15708// require bootstrap-sprockets 15709 15710// require bootstrap/affix 15711 15712 15713// require bootstrap/carousel 15714 15715 15716 15717// require bootstrap/popover 15718// require bootstrap/scrollspy 15719// require bootstrap/tab 15720 15721; 15722/* 15723Turbolinks 5.2.0 15724Copyright © 2018 Basecamp, LLC 15725 */ 15726(function(){var t=this;(function(){(function(){this.Turbolinks={supported:function(){return null!=window.history.pushState&&null!=window.requestAnimationFrame&&null!=window.addEventListener}(),visit:function(t,r){return e.controller.visit(t,r)},clearCache:function(){return e.controller.clearCache()},setProgressBarDelay:function(t){return e.controller.setProgressBarDelay(t)}}}).call(this)}).call(t);var e=t.Turbolinks;(function(){(function(){var t,r,n,o=[].slice;e.copyObject=function(t){var e,r,n;r={};for(e in t)n=t[e],r[e]=n;return r},e.closest=function(e,r){return t.call(e,r)},t=function(){var t,e;return t=document.documentElement,null!=(e=t.closest)?e:function(t){var e;
15726for(e=this;e;){if(e.nodeType===Node.ELEMENT_NODE&&r.call(e,t))return e;e=e.parentNode}}}(),e.defer=function(t){return setTimeout(t,1)},e.throttle=function(t){var e;return e=null,function(){var r;return r=1<=arguments.length?o.call(arguments,0):[],null!=e?e:e=requestAnimationFrame(function(n){return function(){return e=null,t.apply(n,r)}}(this))}},e.dispatch=function(t,e){var r,o,i,s,a,u;return a=null!=e?e:{},u=a.target,r=a.cancelable,o=a.data,i=document.createEvent("Events"),i.initEvent(t,!0,r===!0),i.data=null!=o?o:{},i.cancelable&&!n&&(s=i.preventDefault,i.preventDefault=function(){return this.defaultPrevented||Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}}),s.call(this)}),(null!=u?u:document).dispatchEvent(i),i},n=function(){var t;return t=document.createEvent("Events"),t.initEvent("test",!0,!0),t.preventDefault(),t.defaultPrevented}(),e.match=function(t,e){return r.call(t,e)},r=function(){var t,e,r,n;return t=document.documentElement,null!=(e=null!=(r=null!=(n=t.matchesSelector)?n:t.webkitMatchesSelector)?r:t.msMatchesSelector)?e:t.mozMatchesSelector}(),e.uuid=function(){var t,e,r;for(r="",t=e=1;36>=e;t=++e)r+=9===t||14===t||19===t||24===t?"-":15===t?"4":20===t?(Math.floor(4*Math.random())+8).toString(16):Math.floor(15*Math.random()).toString(16);return r}}).call(this),function(){e.Location=function(){function t(t){var e,r;null==t&&(t=""),r=document.createElement("a"),r.href=t.toString(),this.absoluteURL=r.href,e=r.hash.length,2>e?this.requestURL=this.absoluteURL:(this.requestURL=this.absoluteURL.slice(0,-e),this.anchor=r.hash.slice(1))}var e,r,n,o;return t.wrap=function(t){return t instanceof this?t:new this(t)},t.prototype.getOrigin=function(){return this.absoluteURL.split("/",3).join("/")},t.prototype.getPath=function(){var t,e;return null!=(t=null!=(e=this.requestURL.match(/\/\/[^\/]*(\/[^?;]*)/))?e[1]:void 0)?t:"/"},t.prototype.getPathComponents=function(){return this.getPath().split("/").slice(1)},t.prototype.getLastPathComponent=function(){return this.getPathComponents().slice(-1)[0]},t.prototype.getExtension=function(){var t,e;return null!=(t=null!=(e=this.getLastPathComponent().match(/\.[^.]*$/))?e[0]:void 0)?t:""},t.prototype.isHTML=function(){return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/)},t.prototype.isPrefixedBy=function(t){var e;return e=r(t),this.isEqualTo(t)||o(this.absoluteURL,e)},t.prototype.isEqualTo=function(t){return this.absoluteURL===(null!=t?t.absoluteURL:void 0)},t.prototype.toCacheKey=function(){return this.requestURL},t.prototype.toJSON=function(){return this.absoluteURL},t.prototype.toString=function(){return this.absoluteURL},t.prototype.valueOf=function(){return this.absoluteURL},r=function(t){return e(t.getOrigin()+t.getPath())},e=function(t){return n(t,"/")?t:t+"/"},o=function(t,e){return t.slice(0,e.length)===e},n=function(t,e){return t.slice(-e.length)===e},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.HttpRequest=function(){function r(r,n,o){this.delegate=r,this.requestCanceled=t(this.requestCanceled,this),this.requestTimedOut=t(this.requestTimedOut,this),this.requestFailed=t(this.requestFailed,this),this.requestLoaded=t(this.requestLoaded,this),this.requestProgressed=t(this.requestProgressed,this),this.url=e.Location.wrap(n).requestURL,this.referrer=e.Location.wrap(o).absoluteURL,this.createXHR()}return r.NETWORK_FAILURE=0,r.TIMEOUT_FAILURE=-1,r.timeout=60,r.prototype.send=function(){var t;return this.xhr&&!this.sent?(this.notifyApplicationBeforeRequestStart(),this.setProgress(0),this.xhr.send(),this.sent=!0,"function"==typeof(t=this.delegate).requestStarted?t.requestStarted():void 0):void 0},r.prototype.cancel=function(){return this.xhr&&this.sent?this.xhr.abort():void 0},r.prototype.requestProgressed=function(t){return t.lengthComputable?this.setProgress(t.loaded/t.total):void 0},r.prototype.requestLoaded=function(){return this.endRequest(function(t){return function(){var e;return 200<=(e=t.xhr.status)&&300>e?t.delegate.requestCompletedWithResponse(t.xhr.responseText,t.xhr.getResponseHeader("Turbolinks-Location")):(t.failed=!0,t.delegate.requestFailedWithStatusCode(t.xhr.status,t.xhr.responseText))}}(this))},r.prototype.requestFailed=function(){return this.endRequest(function(t){return function(){return t.failed=!0,t.delegate.requestFailedWithStatusCode(t.constructor.NETWORK_FAILURE)}}(this))},r.prototype.requestTimedOut=function(){return this.endRequest(function(t){return function(){return t.failed=!0,t.delegate.requestFailedWithStatusCode(t.constructor.TIMEOUT_FAILURE)}}(this))},r.prototype.requestCanceled=function(){return this.endRequest()},r.prototype.notifyApplicationBeforeRequestStart=function(){return e.dispatch("turbolinks:request-start",{data:{url:this.url,xhr:this.xhr}})},r.prototype.notifyApplicationAfterRequestEnd=function(){return e.dispatch("turbolinks:request-end",{data:{url:this.url,xhr:this.xhr}})},r.prototype.createXHR=function(){return this.xhr=new XMLHttpRequest,this.xhr.open("GET",this.url,!0),this.xhr.timeout=1e3*this.constructor.timeout,this.xhr.setRequestHeader("Accept","text/html, application/xhtml+xml"),this.xhr.setRequestHeader("Turbolinks-Referrer",this.referrer),this.xhr.onprogress=this.requestProgressed,this.xhr.onload=this.requestLoaded,this.xhr.onerror=this.requestFailed,this.xhr.ontimeout=this.requestTimedOut,this.xhr.onabort=this.requestCanceled},r.prototype.endRequest=function(t){return this.xhr?(this.notifyApplicationAfterRequestEnd(),null!=t&&t.call(this),this.destroy()):void 0},r.prototype.setProgress=function(t){var e;return this.progress=t,"function"==typeof(e=this.delegate).requestProgressed?e.requestProgressed(this.progress):void 0},r.prototype.destroy=function(){var t;return this.setProgress(1),"function"==typeof(t=this.delegate).requestFinished&&t.requestFinished(),this.delegate=null,this.xhr=null},r}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.ProgressBar=function(){function e(){this.trickle=t(this.trickle,this),this.stylesheetElement=this.createStylesheetElement(),this.progressElement=this.createProgressElement()}var r;return r=300,e.defaultCSS=".turbolinks-progress-bar {\n position: fixed;\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n background: #0076ff;\n z-index: 9999;\n transition: width "+r+"ms ease-out, opacity "+r/2+"ms "+r/2+"ms ease-in;\n transform: translate3d(0, 0, 0);\n}",e.prototype.show=function(){return this.visible?void 0:(this.visible=!0,this.installStylesheetElement(),this.installProgressElement(),this.startTrickling())},e.prototype.hide=function(){return this.visible&&!this.hiding?(this.hiding=!0,this.fadeProgressElement(function(t){return function(){return t.uninstallProgressElement(),t.stopTrickling(),t.visible=!1,t.hiding=!1}}(this))):void 0},e.prototype.setValue=function(t){return this.value=t,this.refresh()},e.prototype.installStylesheetElement=function(){return document.head.insertBefore(this.stylesheetElement,document.head.firstChild)},e.prototype.installProgressElement=function(){return this.progressElement.style.width=0,this.progressElement.style.opacity=1,document.documentElement.insertBefore(this.progressElement,document.body),this.refresh()},e.prototype.fadeProgressElement=function(t){return this.progressElement.style.opacity=0,setTimeout(t,1.5*r)},e.prototype.uninstallProgressElement=function(){return this.progressElement.parentNode?document.documentElement.removeChild(this.progressElement):void 0},e.prototype.startTrickling=function(){return null!=this.trickleInterval?this.trickleInterval:this.trickleInterval=setInterval(this.trickle,r)},e.prototype.stopTrickling=function(){return clearInterval(this.trickleInterval),this.trickleInterval=null},e.prototype.trickle=function(){return this.setValue(this.value+Math.random()/100)},e.prototype.refresh=function(){return requestAnimationFrame(function(t){return function(){return t.progressElement.style.width=10+90*t.value+"%"}}(this))},e.prototype.createStylesheetElement=function(){var t;return t=document.createElement("style"),t.type="text/css",t.textContent=this.constructor.defaultCSS,t},e.prototype.createProgressElement=function(){var t;return t=document.createElement("div"),t.className="turbolinks-progress-bar",t},e}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.BrowserAdapter=function(){function r(r){this.controller=r,this.showProgressBar=t(this.showProgressBar,this),this.progressBar=new e.ProgressBar}var n,o,i;return i=e.HttpRequest,n=i.NETWORK_FAILURE,o=i.TIMEOUT_FAILURE,r.prototype.visitProposedToLocationWithAction=function(t,e){return this.controller.startVisitToLocationWithAction(t,e)},r.prototype.visitStarted=function(t){return t.issueRequest(),t.changeHistory(),t.loadCachedSnapshot()},r.prototype.visitRequestStarted=function(t){return this.progressBar.setValue(0),t.hasCachedSnapshot()||"restore"!==t.action?this.showProgressBarAfterDelay():this.showProgressBar()},r.prototype.visitRequestProgressed=function(t){return this.progressBar.setValue(t.progress)},r.prototype.visitRequestCompleted=function(t){return t.loadResponse()},r.prototype.visitRequestFailedWithStatusCode=function(t,e){switch(e){case n:case o:return this.reload();default:return t.loadResponse()}},r.prototype.visitRequestFinished=function(t){return this.hideProgressBar()},r.prototype.visitCompleted=function(t){return t.followRedirect()},r.prototype.pageInvalidated=function(){return this.reload()},r.prototype.showProgressBarAfterDelay=function(){return this.progressBarTimeout=setTimeout(this.showProgressBar,this.controller.progressBarDelay)},r.prototype.showProgressBar=function(){return this.progressBar.show()},r.prototype.hideProgressBar=function(){return this.progressBar.hide(),clearTimeout(this.progressBarTimeout)},r.prototype.reload=function(){return window.location.reload()},r}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.History=function(){function r(e){this.delegate=e,this.onPageLoad=t(this.onPageLoad,this),this.onPopState=t(this.onPopState,this)}return r.prototype.start=function(){return this.started?void 0:(addEventListener("popstate",this.onPopState,!1),addEventListener("load",this.onPageLoad,!1),this.started=!0)},r.prototype.stop=function(){return this.started?(removeEventListener("popstate",this.onPopState,!1),removeEventListener("load",this.onPageLoad,!1),this.started=!1):void 0},r.prototype.push=function(t,r){return t=e.Location.wrap(t),this.update("push",t,r)},r.prototype.replace=function(t,r){return t=e.Location.wrap(t),this.update("replace",t,r)},r.prototype.onPopState=function(t){var r,n,o,i;return this.shouldHandlePopState()&&(i=null!=(n=t.state)?n.turbolinks:void 0)?(r=e.Location.wrap(window.location),o=i.restorationIdentifier,this.delegate.historyPoppedToLocationWithRestorationIdentifier(r,o)):void 0},r.prototype.onPageLoad=function(t){return e.defer(function(t){return function(){return t.pageLoaded=!0}}(this))},r.prototype.shouldHandlePopState=function(){return this.pageIsLoaded()},r.prototype.pageIsLoaded=function(){return this.pageLoaded||"complete"===document.readyState},r.prototype.update=function(t,e,r){var n;return n={turbolinks:{restorationIdentifier:r}},history[t+"State"](n,null,e)},r}()}.call(this),function(){e.HeadDetails=function(){function t(t){var e,r,n,s,a,u;for(this.elements={},n=0,a=t.length;a>n;n++)u=t[n],u.nodeType===Node.ELEMENT_NODE&&(s=u.outerHTML,r=null!=(e=this.elements)[s]?e[s]:e[s]={type:i(u),tracked:o(u),elements:[]},r.elements.push(u))}var e,r,n,o,i;return t.fromHeadElement=function(t){var e;return new this(null!=(e=null!=t?t.childNodes:void 0)?e:[])},t.prototype.hasElementWithKey=function(t){return t in this.elements},t.prototype.getTrackedElementSignature=function(){var t,e;return function(){var r,n;r=this.elements,n=[];for(t in r)e=r[t].tracked,e&&n.push(t);return n}.call(this).join("")},t.prototype.getScriptElementsNotInDetails=function(t){return this.getElementsMatchingTypeNotInDetails("script",t)},t.prototype.getStylesheetElementsNotInDetails=function(t){return this.getElementsMatchingTypeNotInDetails("stylesheet",t)},t.prototype.getElementsMatchingTypeNotInDetails=function(t,e){var r,n,o,i,s,a;o=this.elements,s=[];for(n in o)i=o[n],a=i.type,r=i.elements,a!==t||e.hasElementWithKey(n)||s.push(r[0]);return s},t.prototype.getProvisionalElements=function(){var t,e,r,n,o,i,s;r=[],n=this.elements;for(e in n)o=n[e],s=o.type,i=o.tracked,t=o.elements,null!=s||i?t.length>1&&r.push.apply(r,t.slice(1)):r.push.apply(r,t);return r},t.prototype.getMetaValue=function(t){var e;return null!=(e=this.findMetaElementByName(t))?e.getAttribute("content"):void 0},t.prototype.findMetaElementByName=function(t){var r,n,o,i;r=void 0,i=this.elements;for(o in i)n=i[o].elements,e(n[0],t)&&(r=n[0]);return r},i=function(t){return r(t)?"script":n(t)?"stylesheet":void 0},o=function(t){return"reload"===t.getAttribute("data-turbolinks-track")},r=function(t){var e;return e=t.tagName.toLowerCase(),"script"===e},n=function(t){var e;return e=t.tagName.toLowerCase(),"style"===e||"link"===e&&"stylesheet"===t.getAttribute("rel")},e=function(t,e){var r;return r=t.tagName.toLowerCase(),"meta"===r&&t.getAttribute("name")===e},t}()}.call(this),function(){e.Snapshot=function(){function t(t,e){this.headDetails=t,this.bodyElement=e}return t.wrap=function(t){return t instanceof this?t:"string"==typeof t?this.fromHTMLString(t):this.fromHTMLElement(t)},t.fromHTMLString=function(t){var e;return e=document.createElement("html"),e.innerHTML=t,this.fromHTMLElement(e)},t.fromHTMLElement=function(t){var r,n,o,i;return o=t.querySelector("head"),r=null!=(i=t.querySelector("body"))?i:document.createElement("body"),n=e.HeadDetails.fromHeadElement(o),new this(n,r)},t.prototype.clone=function(){return new this.constructor(this.headDetails,this.bodyElement.cloneNode(!0))},t.prototype.getRootLocation=function(){var t,r;return r=null!=(t=this.getSetting("root"))?t:"/",new e.Location(r)}
15726,t.prototype.getCacheControlValue=function(){return this.getSetting("cache-control")},t.prototype.getElementForAnchor=function(t){try{return this.bodyElement.querySelector("[id='"+t+"'], a[name='"+t+"']")}catch(e){}},t.prototype.getPermanentElements=function(){return this.bodyElement.querySelectorAll("[id][data-turbolinks-permanent]")},t.prototype.getPermanentElementById=function(t){return this.bodyElement.querySelector("#"+t+"[data-turbolinks-permanent]")},t.prototype.getPermanentElementsPresentInSnapshot=function(t){var e,r,n,o,i;for(o=this.getPermanentElements(),i=[],r=0,n=o.length;n>r;r++)e=o[r],t.getPermanentElementById(e.id)&&i.push(e);return i},t.prototype.findFirstAutofocusableElement=function(){return this.bodyElement.querySelector("[autofocus]")},t.prototype.hasAnchor=function(t){return null!=this.getElementForAnchor(t)},t.prototype.isPreviewable=function(){return"no-preview"!==this.getCacheControlValue()},t.prototype.isCacheable=function(){return"no-cache"!==this.getCacheControlValue()},t.prototype.isVisitable=function(){return"reload"!==this.getSetting("visit-control")},t.prototype.getSetting=function(t){return this.headDetails.getMetaValue("turbolinks-"+t)},t}()}.call(this),function(){var t=[].slice;e.Renderer=function(){function e(){}var r;return e.render=function(){var e,r,n,o;return n=arguments[0],r=arguments[1],e=3<=arguments.length?t.call(arguments,2):[],o=function(t,e,r){r.prototype=t.prototype;var n=new r,o=t.apply(n,e);return Object(o)===o?o:n}(this,e,function(){}),o.delegate=n,o.render(r),o},e.prototype.renderView=function(t){return this.delegate.viewWillRender(this.newBody),t(),this.delegate.viewRendered(this.newBody)},e.prototype.invalidateView=function(){return this.delegate.viewInvalidated()},e.prototype.createScriptElement=function(t){var e;return"false"===t.getAttribute("data-turbolinks-eval")?t:(e=document.createElement("script"),e.textContent=t.textContent,e.async=!1,r(e,t),e)},r=function(t,e){var r,n,o,i,s,a,u;for(i=e.attributes,a=[],r=0,n=i.length;n>r;r++)s=i[r],o=s.name,u=s.value,a.push(t.setAttribute(o,u));return a},e}()}.call(this),function(){var t,r,n=function(t,e){function r(){this.constructor=t}for(var n in e)o.call(e,n)&&(t[n]=e[n]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},o={}.hasOwnProperty;e.SnapshotRenderer=function(e){function o(t,e,r){this.currentSnapshot=t,this.newSnapshot=e,this.isPreview=r,this.currentHeadDetails=this.currentSnapshot.headDetails,this.newHeadDetails=this.newSnapshot.headDetails,this.currentBody=this.currentSnapshot.bodyElement,this.newBody=this.newSnapshot.bodyElement}return n(o,e),o.prototype.render=function(t){return this.shouldRender()?(this.mergeHead(),this.renderView(function(e){return function(){return e.replaceBody(),e.isPreview||e.focusFirstAutofocusableElement(),t()}}(this))):this.invalidateView()},o.prototype.mergeHead=function(){return this.copyNewHeadStylesheetElements(),this.copyNewHeadScriptElements(),this.removeCurrentHeadProvisionalElements(),this.copyNewHeadProvisionalElements()},o.prototype.replaceBody=function(){var t;return t=this.relocateCurrentBodyPermanentElements(),this.activateNewBodyScriptElements(),this.assignNewBody(),this.replacePlaceholderElementsWithClonedPermanentElements(t)},o.prototype.shouldRender=function(){return this.newSnapshot.isVisitable()&&this.trackedElementsAreIdentical()},o.prototype.trackedElementsAreIdentical=function(){return this.currentHeadDetails.getTrackedElementSignature()===this.newHeadDetails.getTrackedElementSignature()},o.prototype.copyNewHeadStylesheetElements=function(){var t,e,r,n,o;for(n=this.getNewHeadStylesheetElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.appendChild(t));return o},o.prototype.copyNewHeadScriptElements=function(){var t,e,r,n,o;for(n=this.getNewHeadScriptElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.appendChild(this.createScriptElement(t)));return o},o.prototype.removeCurrentHeadProvisionalElements=function(){var t,e,r,n,o;for(n=this.getCurrentHeadProvisionalElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.removeChild(t));return o},o.prototype.copyNewHeadProvisionalElements=function(){var t,e,r,n,o;for(n=this.getNewHeadProvisionalElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.appendChild(t));return o},o.prototype.relocateCurrentBodyPermanentElements=function(){var e,n,o,i,s,a,u;for(a=this.getCurrentBodyPermanentElements(),u=[],e=0,n=a.length;n>e;
15726e++)i=a[e],s=t(i),o=this.newSnapshot.getPermanentElementById(i.id),r(i,s.element),r(o,i),u.push(s);return u},o.prototype.replacePlaceholderElementsWithClonedPermanentElements=function(t){var e,n,o,i,s,a,u;for(u=[],o=0,i=t.length;i>o;o++)a=t[o],n=a.element,s=a.permanentElement,e=s.cloneNode(!0),u.push(r(n,e));return u},o.prototype.activateNewBodyScriptElements=function(){var t,e,n,o,i,s;for(i=this.getNewBodyScriptElements(),s=[],e=0,o=i.length;o>e;e++)n=i[e],t=this.createScriptElement(n),s.push(r(n,t));return s},o.prototype.assignNewBody=function(){return document.body=this.newBody},o.prototype.focusFirstAutofocusableElement=function(){var t;return null!=(t=this.newSnapshot.findFirstAutofocusableElement())?t.focus():void 0},o.prototype.getNewHeadStylesheetElements=function(){return this.newHeadDetails.getStylesheetElementsNotInDetails(this.currentHeadDetails)},o.prototype.getNewHeadScriptElements=function(){return this.newHeadDetails.getScriptElementsNotInDetails(this.currentHeadDetails)},o.prototype.getCurrentHeadProvisionalElements=function(){return this.currentHeadDetails.getProvisionalElements()},o.prototype.getNewHeadProvisionalElements=function(){return this.newHeadDetails.getProvisionalElements()},o.prototype.getCurrentBodyPermanentElements=function(){return this.currentSnapshot.getPermanentElementsPresentInSnapshot(this.newSnapshot)},o.prototype.getNewBodyScriptElements=function(){return this.newBody.querySelectorAll("script")},o}(e.Renderer),t=function(t){var e;return e=document.createElement("meta"),e.setAttribute("name","turbolinks-permanent-placeholder"),e.setAttribute("content",t.id),{element:e,permanentElement:t}},r=function(t,e){var r;return(r=t.parentNode)?r.replaceChild(e,t):void 0}}.call(this),function(){var t=function(t,e){function n(){this.constructor=t}for(var o in e)r.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},r={}.hasOwnProperty;e.ErrorRenderer=function(e){function r(t){var e;e=document.createElement("html"),e.innerHTML=t,this.newHead=e.querySelector("head"),this.newBody=e.querySelector("body")}return t(r,e),r.prototype.render=function(t){return this.renderView(function(e){return function(){return e.replaceHeadAndBody(),e.activateBodyScriptElements(),t()}}(this))},r.prototype.replaceHeadAndBody=function(){var t,e;return e=document.head,t=document.body,e.parentNode.replaceChild(this.newHead,e),t.parentNode.replaceChild(this.newBody,t)},r.prototype.activateBodyScriptElements=function(){var t,e,r,n,o,i;for(n=this.getScriptElements(),i=[],e=0,r=n.length;r>e;e++)o=n[e],t=this.createScriptElement(o),i.push(o.parentNode.replaceChild(t,o));return i},r.prototype.getScriptElements=function(){return document.documentElement.querySelectorAll("script")},r}(e.Renderer)}.call(this),function(){e.View=function(){function t(t){this.delegate=t,this.htmlElement=document.documentElement}return t.prototype.getRootLocation=function(){return this.getSnapshot().getRootLocation()},t.prototype.getElementForAnchor=function(t){return this.getSnapshot().getElementForAnchor(t)},t.prototype.getSnapshot=function(){return e.Snapshot.fromHTMLElement(this.htmlElement)},t.prototype.render=function(t,e){var r,n,o;return o=t.snapshot,r=t.error,n=t.isPreview,this.markAsPreview(n),null!=o?this.renderSnapshot(o,n,e):this.renderError(r,e)},t.prototype.markAsPreview=function(t){return t?this.htmlElement.setAttribute("data-turbolinks-preview",""):this.htmlElement.removeAttribute("data-turbolinks-preview")},t.prototype.renderSnapshot=function(t,r,n){return e.SnapshotRenderer.render(this.delegate,n,this.getSnapshot(),e.Snapshot.wrap(t),r)},t.prototype.renderError=function(t,r){return e.ErrorRenderer.render(this.delegate,r,t)},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.ScrollManager=function(){function r(r){this.delegate=r,this.onScroll=t(this.onScroll,this),this.onScroll=e.throttle(this.onScroll)}return r.prototype.start=function(){return this.started?void 0:(addEventListener("scroll",this.onScroll,!1),this.onScroll(),this.started=!0)},r.prototype.stop=function(){return this.started?(removeEventListener("scroll",this.onScroll,!1),this.started=!1):void 0},r.prototype.scrollToElement=function(t){return t.scrollIntoView()},r.prototype.scrollToPosition=function(t){var e,r;return e=t.x,r=t.y,window.scrollTo(e,r)},r.prototype.onScroll=function(t){return this.updatePosition({x:window.pageXOffset,y:window.pageYOffset})},r.prototype.updatePosition=function(t){var e;
15726return this.position=t,null!=(e=this.delegate)?e.scrollPositionChanged(this.position):void 0},r}()}.call(this),function(){e.SnapshotCache=function(){function t(t){this.size=t,this.keys=[],this.snapshots={}}var r;return t.prototype.has=function(t){var e;return e=r(t),e in this.snapshots},t.prototype.get=function(t){var e;if(this.has(t))return e=this.read(t),this.touch(t),e},t.prototype.put=function(t,e){return this.write(t,e),this.touch(t),e},t.prototype.read=function(t){var e;return e=r(t),this.snapshots[e]},t.prototype.write=function(t,e){var n;return n=r(t),this.snapshots[n]=e},t.prototype.touch=function(t){var e,n;return n=r(t),e=this.keys.indexOf(n),e>-1&&this.keys.splice(e,1),this.keys.unshift(n),this.trim()},t.prototype.trim=function(){var t,e,r,n,o;for(n=this.keys.splice(this.size),o=[],t=0,r=n.length;r>t;t++)e=n[t],o.push(delete this.snapshots[e]);return o},r=function(t){return e.Location.wrap(t).toCacheKey()},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.Visit=function(){function r(r,n,o){this.controller=r,this.action=o,this.performScroll=t(this.performScroll,this),this.identifier=e.uuid(),this.location=e.Location.wrap(n),this.adapter=this.controller.adapter,this.state="initialized",this.timingMetrics={}}var n;return r.prototype.start=function(){return"initialized"===this.state?(this.recordTimingMetric("visitStart"),this.state="started",this.adapter.visitStarted(this)):void 0},r.prototype.cancel=function(){var t;return"started"===this.state?(null!=(t=this.request)&&t.cancel(),this.cancelRender(),this.state="canceled"):void 0},r.prototype.complete=function(){var t;return"started"===this.state?(this.recordTimingMetric("visitEnd"),this.state="completed","function"==typeof(t=this.adapter).visitCompleted&&t.visitCompleted(this),this.controller.visitCompleted(this)):void 0},r.prototype.fail=function(){var t;return"started"===this.state?(this.state="failed","function"==typeof(t=this.adapter).visitFailed?t.visitFailed(this):void 0):void 0},r.prototype.changeHistory=function(){var t,e;return this.historyChanged?void 0:(t=this.location.isEqualTo(this.referrer)?"replace":this.action,e=n(t),this.controller[e](this.location,this.restorationIdentifier),this.historyChanged=!0)},r.prototype.issueRequest=function(){return this.shouldIssueRequest()&&null==this.request?(this.progress=0,this.request=new e.HttpRequest(this,this.location,this.referrer),this.request.send()):void 0},r.prototype.getCachedSnapshot=function(){var t;return!(t=this.controller.getCachedSnapshotForLocation(this.location))||null!=this.location.anchor&&!t.hasAnchor(this.location.anchor)||"restore"!==this.action&&!t.isPreviewable()?void 0:t},r.prototype.hasCachedSnapshot=function(){return null!=this.getCachedSnapshot()},r.prototype.loadCachedSnapshot=function(){var t,e;return(e=this.getCachedSnapshot())?(t=this.shouldIssueRequest(),this.render(function(){var r;return this.cacheSnapshot(),this.controller.render({snapshot:e,isPreview:t},this.performScroll),"function"==typeof(r=this.adapter).visitRendered&&r.visitRendered(this),t?void 0:this.complete()})):void 0},r.prototype.loadResponse=function(){return null!=this.response?this.render(function(){var t,e;return this.cacheSnapshot(),this.request.failed?(this.controller.render({error:this.response},this.performScroll),"function"==typeof(t=this.adapter).visitRendered&&t.visitRendered(this),this.fail()):(this.controller.render({snapshot:this.response},this.performScroll),"function"==typeof(e=this.adapter).visitRendered&&e.visitRendered(this),this.complete())}):void 0},r.prototype.followRedirect=function(){return this.redirectedToLocation&&!this.followedRedirect?(this.location=this.redirectedToLocation,this.controller.replaceHistoryWithLocationAndRestorationIdentifier(this.redirectedToLocation,this.restorationIdentifier),this.followedRedirect=!0):void 0},r.prototype.requestStarted=function(){var t;return this.recordTimingMetric("requestStart"),"function"==typeof(t=this.adapter).visitRequestStarted?t.visitRequestStarted(this):void 0},r.prototype.requestProgressed=function(t){var e;return this.progress=t,"function"==typeof(e=this.adapter).visitRequestProgressed?e.visitRequestProgressed(this):void 0},r.prototype.requestCompletedWithResponse=function(t,r){return this.response=t,null!=r&&(this.redirectedToLocation=e.Location.wrap(r)),this.adapter.visitRequestCompleted(this)},r.prototype.requestFailedWithStatusCode=function(t,e){return this.response=e,this.adapter.visitRequestFailedWithStatusCode(this,t)},r.prototype.requestFinished=function(){var t;return this.recordTimingMetric("requestEnd"),"function"==typeof(t=this.adapter).visitRequestFinished?t.visitRequestFinished(this):void 0},r.prototype.performScroll=function(){return this.scrolled?void 0:("restore"===this.action?this.scrollToRestoredPosition()||this.scrollToTop():this.scrollToAnchor()||this.scrollToTop(),this.scrolled=!0)},r.prototype.scrollToRestoredPosition=function(){var t,e;return t=null!=(e=this.restorationData)?e.scrollPosition:void 0,null!=t?(this.controller.scrollToPosition(t),!0):void 0},r.prototype.scrollToAnchor=function(){return null!=this.location.anchor?(this.controller.scrollToAnchor(this.location.anchor),!0):void 0},r.prototype.scrollToTop=function(){return this.controller.scrollToPosition({x:0,y:0})},r.prototype.recordTimingMetric=function(t){var e;return null!=(e=this.timingMetrics)[t]?e[t]:e[t]=(new Date).getTime()},r.prototype.getTimingMetrics=function(){return e.copyObject(this.timingMetrics)},n=function(t){switch(t){case"replace":return"replaceHistoryWithLocationAndRestorationIdentifier";case"advance":case"restore":return"pushHistoryWithLocationAndRestorationIdentifier"}},r.prototype.shouldIssueRequest=function(){return"restore"===this.action?!this.hasCachedSnapshot():!0},r.prototype.cacheSnapshot=function(){return this.snapshotCached?void 0:(this.controller.cacheSnapshot(),this.snapshotCached=!0)},r.prototype.render=function(t){return this.cancelRender(),this.frame=requestAnimationFrame(function(e){return function(){return e.frame=null,t.call(e)}}(this))},r.prototype.cancelRender=function(){return this.frame?cancelAnimationFrame(this.frame):void 0},r}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.Controller=function(){function r(){this.clickBubbled=t(this.clickBubbled,this),this.clickCaptured=t(this.clickCaptured,this),this.pageLoaded=t(this.pageLoaded,this),this.history=new e.History(this),this.view=new e.View(this),this.scrollManager=new e.ScrollManager(this),this.restorationData={},this.clearCache(),this.setProgressBarDelay(500)}
15726return r.prototype.start=function(){return e.supported&&!this.started?(addEventListener("click",this.clickCaptured,!0),addEventListener("DOMContentLoaded",this.pageLoaded,!1),this.scrollManager.start(),this.startHistory(),this.started=!0,this.enabled=!0):void 0},r.prototype.disable=function(){return this.enabled=!1},r.prototype.stop=function(){return this.started?(removeEventListener("click",this.clickCaptured,!0),removeEventListener("DOMContentLoaded",this.pageLoaded,!1),this.scrollManager.stop(),this.stopHistory(),this.started=!1):void 0},r.prototype.clearCache=function(){return this.cache=new e.SnapshotCache(10)},r.prototype.visit=function(t,r){var n,o;return null==r&&(r={}),t=e.Location.wrap(t),this.applicationAllowsVisitingLocation(t)?this.locationIsVisitable(t)?(n=null!=(o=r.action)?o:"advance",this.adapter.visitProposedToLocationWithAction(t,n)):window.location=t:void 0},r.prototype.startVisitToLocationWithAction=function(t,r,n){var o;return e.supported?(o=this.getRestorationDataForIdentifier(n),this.startVisit(t,r,{restorationData:o})):window.location=t},r.prototype.setProgressBarDelay=function(t){return this.progressBarDelay=t},r.prototype.startHistory=function(){return this.location=e.Location.wrap(window.location),this.restorationIdentifier=e.uuid(),this.history.start(),this.history.replace(this.location,this.restorationIdentifier)},r.prototype.stopHistory=function(){return this.history.stop()},r.prototype.pushHistoryWithLocationAndRestorationIdentifier=function(t,r){return this.restorationIdentifier=r,this.location=e.Location.wrap(t),this.history.push(this.location,this.restorationIdentifier)},r.prototype.replaceHistoryWithLocationAndRestorationIdentifier=function(t,r){return this.restorationIdentifier=r,this.location=e.Location.wrap(t),this.history.replace(this.location,this.restorationIdentifier)},r.prototype.historyPoppedToLocationWithRestorationIdentifier=function(t,r){var n;return this.restorationIdentifier=r,this.enabled?(n=this.getRestorationDataForIdentifier(this.restorationIdentifier),this.startVisit(t,"restore",{restorationIdentifier:this.restorationIdentifier,restorationData:n,historyChanged:!0}),this.location=e.Location.wrap(t)):this.adapter.pageInvalidated()},r.prototype.getCachedSnapshotForLocation=function(t){var e;return null!=(e=this.cache.get(t))?e.clone():void 0},r.prototype.shouldCacheSnapshot=function(){return this.view.getSnapshot().isCacheable(); 15727},r.prototype.cacheSnapshot=function(){var t,r;return this.shouldCacheSnapshot()?(this.notifyApplicationBeforeCachingSnapshot(),r=this.view.getSnapshot(),t=this.lastRenderedLocation,e.defer(function(e){return function(){return e.cache.put(t,r.clone())}}(this))):void 0},r.prototype.scrollToAnchor=function(t){var e;return(e=this.view.getElementForAnchor(t))?this.scrollToElement(e):this.scrollToPosition({x:0,y:0})},r.prototype.scrollToElement=function(t){return this.scrollManager.scrollToElement(t)},r.prototype.scrollToPosition=function(t){return this.scrollManager.scrollToPosition(t)},r.prototype.scrollPositionChanged=function(t){var e;return e=this.getCurrentRestorationData(),e.scrollPosition=t},r.prototype.render=function(t,e){return this.view.render(t,e)},r.prototype.viewInvalidated=function(){return this.adapter.pageInvalidated()},r.prototype.viewWillRender=function(t){return this.notifyApplicationBeforeRender(t)},r.prototype.viewRendered=function(){return this.lastRenderedLocation=this.currentVisit.location,this.notifyApplicationAfterRender()},r.prototype.pageLoaded=function(){return this.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()},r.prototype.clickCaptured=function(){return removeEventListener("click",this.clickBubbled,!1),addEventListener("click",this.clickBubbled,!1)},r.prototype.clickBubbled=function(t){var e,r,n;return this.enabled&&this.clickEventIsSignificant(t)&&(r=this.getVisitableLinkForNode(t.target))&&(n=this.getVisitableLocationForLink(r))&&this.applicationAllowsFollowingLinkToLocation(r,n)?(t.preventDefault(),e=this.getActionForLink(r),this.visit(n,{action:e})):void 0},r.prototype.applicationAllowsFollowingLinkToLocation=function(t,e){var r;return r=this.notifyApplicationAfterClickingLinkToLocation(t,e),!r.defaultPrevented},r.prototype.applicationAllowsVisitingLocation=function(t){var e;return e=this.notifyApplicationBeforeVisitingLocation(t),!e.defaultPrevented},r.prototype.notifyApplicationAfterClickingLinkToLocation=function(t,r){return e.dispatch("turbolinks:click",{target:t,data:{url:r.absoluteURL},cancelable:!0})},r.prototype.notifyApplicationBeforeVisitingLocation=function(t){return e.dispatch("turbolinks:before-visit",{data:{url:t.absoluteURL},cancelable:!0})},r.prototype.notifyApplicationAfterVisitingLocation=function(t){return e.dispatch("turbolinks:visit",{data:{url:t.absoluteURL}})},r.prototype.notifyApplicationBeforeCachingSnapshot=function(){return e.dispatch("turbolinks:before-cache")},r.prototype.notifyApplicationBeforeRender=function(t){return e.dispatch("turbolinks:before-render",{data:{newBody:t}})},r.prototype.notifyApplicationAfterRender=function(){return e.dispatch("turbolinks:render")},r.prototype.notifyApplicationAfterPageLoad=function(t){return null==t&&(t={}),e.dispatch("turbolinks:load",{data:{url:this.location.absoluteURL,timing:t}})},r.prototype.startVisit=function(t,e,r){var n;return null!=(n=this.currentVisit)&&n.cancel(),this.currentVisit=this.createVisit(t,e,r),this.currentVisit.start(),this.notifyApplicationAfterVisitingLocation(t)},r.prototype.createVisit=function(t,r,n){var o,i,s,a,u;return i=null!=n?n:{},a=i.restorationIdentifier,s=i.restorationData,o=i.historyChanged,u=new e.Visit(this,t,r),u.restorationIdentifier=null!=a?a:e.uuid(),u.restorationData=e.copyObject(s),u.historyChanged=o,u.referrer=this.location,u},r.prototype.visitCompleted=function(t){return this.notifyApplicationAfterPageLoad(t.getTimingMetrics())},r.prototype.clickEventIsSignificant=function(t){return!(t.defaultPrevented||t.target.isContentEditable||t.which>1||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)},r.prototype.getVisitableLinkForNode=function(t){return this.nodeIsVisitable(t)?e.closest(t,"a[href]:not([target]):not([download])"):void 0},r.prototype.getVisitableLocationForLink=function(t){var r;return r=new e.Location(t.getAttribute("href")),this.locationIsVisitable(r)?r:void 0},r.prototype.getActionForLink=function(t){var e;return null!=(e=t.getAttribute("data-turbolinks-action"))?e:"advance"},r.prototype.nodeIsVisitable=function(t){var r;return(r=e.closest(t,"[data-turbolinks]"))?"false"!==r.getAttribute("data-turbolinks"):!0},r.prototype.locationIsVisitable=function(t){return t.isPrefixedBy(this.view.getRootLocation())&&t.isHTML()},r.prototype.getCurrentRestorationData=function(){return this.getRestorationDataForIdentifier(this.restorationIdentifier)},r.prototype.getRestorationDataForIdentifier=function(t){var e;return null!=(e=this.restorationData)[t]?e[t]:e[t]={}},r}()}.call(this),function(){!function(){var t,e;if((t=e=document.currentScript)&&!e.hasAttribute("data-turbolinks-suppress-warning"))for(;t=t.parentNode;)if(t===document.body)return console.warn("You are loading Turbolinks from a <script> element inside the <body> element. This is probably not what you meant to do!\n\nLoad your application\u2019s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.\n\nFor more information, see: https://github.com/turbolinks/turbolinks#working-with-script-elements\n\n\u2014\u2014\nSuppress this warning by adding a `data-turbolinks-suppress-warning` attribute to: %s",e.outerHTML)}()}.call(this),function(){var t,r,n;e.start=function(){return r()?(null==e.controller&&(e.controller=t()),e.controller.start()):void 0},r=function(){return null==window.Turbolinks&&(window.Turbolinks=e),n()},t=function(){var t;return t=new e.Controller,t.adapter=new e.BrowserAdapter(t),t},n=function(){return window.Turbolinks===e},n()&&e.start()}.call(this)}).call(this),"object"==typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd&&define(e)}).call(this); 15728/*! 15729 * Select2 4.0.13
vendor: 17,402 bytes, lines 15729-16228
15729 15730 * https://select2.github.io 15731 * 15732 * Released under the MIT license 15733 * https://github.com/select2/select2/blob/master/LICENSE.md 15734 */ 15735;(function (factory) { 15736 if (typeof define === 'function' && define.amd) { 15737 // AMD. Register as an anonymous module. 15738 define(['jquery'], factory); 15739 } else if (typeof module === 'object' && module.exports) { 15740 // Node/CommonJS 15741 module.exports = function (root, jQuery) { 15742 if (jQuery === undefined) { 15743 // require('jQuery') returns a factory that requires window to 15744 // build a jQuery instance, we normalize how we use modules 15745 // that require this pattern but the window provided is a noop 15746 // if it's defined (how jquery works) 15747 if (typeof window !== 'undefined') { 15748 jQuery = require('jquery'); 15749 } 15750 else { 15751 jQuery = require('jquery')(root); 15752 } 15753 } 15754 factory(jQuery); 15755 return jQuery; 15756 }; 15757 } else { 15758 // Browser globals 15759 factory(jQuery); 15760 } 15761} (function (jQuery) { 15762 // This is needed so we can catch the AMD loader configuration and use it 15763 // The inner file should be wrapped (by `banner.start.js`) in a function that 15764 // returns the AMD loader references. 15765 var S2 =(function () { 15766 // Restore the Select2 AMD loader so it can be used 15767 // Needed mostly in the language files, where the loader is not inserted 15768 if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) { 15769 var S2 = jQuery.fn.select2.amd; 15770 } 15771var S2;(function () { if (!S2 || !S2.requirejs) { 15772if (!S2) { S2 = {}; } else { require = S2; } 15773/** 15774 * @license almond 0.3.3 Copyright jQuery Foundation and other contributors. 15775 * Released under MIT license, http://github.com/requirejs/almond/LICENSE 15776 */ 15777//Going sloppy to avoid 'use strict' string cost, but strict practices should 15778//be followed. 15779/*global setTimeout: false */ 15780 15781var requirejs, require, define; 15782(function (undef) { 15783 var main, req, makeMap, handlers, 15784 defined = {}, 15785 waiting = {}, 15786 config = {}, 15787 defining = {}, 15788 hasOwn = Object.prototype.hasOwnProperty, 15789 aps = [].slice, 15790 jsSuffixRegExp = /\.js$/; 15791 15792 function hasProp(obj, prop) { 15793 return hasOwn.call(obj, prop); 15794 } 15795 15796 /** 15797 * Given a relative module name, like ./something, normalize it to 15798 * a real name that can be mapped to a path. 15799 * @param {String} name the relative name 15800 * @param {String} baseName a real name that the name arg is relative 15801 * to. 15802 * @returns {String} normalized name 15803 */ 15804 function normalize(name, baseName) { 15805 var nameParts, nameSegment, mapValue, foundMap, lastIndex, 15806 foundI, foundStarMap, starI, i, j, part, normalizedBaseParts, 15807 baseParts = baseName && baseName.split("/"), 15808 map = config.map, 15809 starMap = (map && map['*']) || {}; 15810 15811 //Adjust any relative paths. 15812 if (name) { 15813 name = name.split('/'); 15814 lastIndex = name.length - 1; 15815 15816 // If wanting node ID compatibility, strip .js from end 15817 // of IDs. Have to do this here, and not in nameToUrl 15818 // because node allows either .js or non .js to map 15819 // to same file. 15820 if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { 15821 name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); 15822 } 15823 15824 // Starts with a '.' so need the baseName 15825 if (name[0].charAt(0) === '.' && baseParts) { 15826 //Convert baseName to array, and lop off the last part, 15827 //so that . matches that 'directory' and not name of the baseName's 15828 //module. For instance, baseName of 'one/two/three', maps to 15829 //'one/two/three.js', but we want the directory, 'one/two' for 15830 //this normalization. 15831 normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); 15832 name = normalizedBaseParts.concat(name); 15833 } 15834 15835 //start trimDots 15836 for (i = 0; i < name.length; i++) { 15837 part = name[i]; 15838 if (part === '.') { 15839 name.splice(i, 1); 15840 i -= 1; 15841 } else if (part === '..') { 15842 // If at the start, or previous value is still .., 15843 // keep them so that when converted to a path it may 15844 // still work when converted to a path, even though 15845 // as an ID it is less than ideal. In larger point 15846 // releases, may be better to just kick out an error. 15847 if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') { 15848 continue; 15849 } else if (i > 0) { 15850 name.splice(i - 1, 2); 15851 i -= 2; 15852 } 15853 } 15854 } 15855 //end trimDots 15856 15857 name = name.join('/'); 15858 } 15859 15860 //Apply map config if available. 15861 if ((baseParts || starMap) && map) { 15862 nameParts = name.split('/'); 15863 15864 for (i = nameParts.length; i > 0; i -= 1) { 15865 nameSegment = nameParts.slice(0, i).join("/"); 15866 15867 if (baseParts) { 15868 //Find the longest baseName segment match in the config. 15869 //So, do joins on the biggest to smallest lengths of baseParts. 15870 for (j = baseParts.length; j > 0; j -= 1) { 15871 mapValue = map[baseParts.slice(0, j).join('/')]; 15872 15873 //baseName segment has config, find if it has one for 15874 //this name. 15875 if (mapValue) { 15876 mapValue = mapValue[nameSegment]; 15877 if (mapValue) { 15878 //Match, update name to the new value. 15879 foundMap = mapValue; 15880 foundI = i; 15881 break; 15882 } 15883 } 15884 } 15885 } 15886 15887 if (foundMap) { 15888 break; 15889 } 15890 15891 //Check for a star map match, but just hold on to it, 15892 //if there is a shorter segment match later in a matching 15893 //config, then favor over this star map. 15894 if (!foundStarMap && starMap && starMap[nameSegment]) { 15895 foundStarMap = starMap[nameSegment]; 15896 starI = i; 15897 } 15898 } 15899 15900 if (!foundMap && foundStarMap) { 15901 foundMap = foundStarMap; 15902 foundI = starI; 15903 } 15904 15905 if (foundMap) { 15906 nameParts.splice(0, foundI, foundMap); 15907 name = nameParts.join('/'); 15908 } 15909 } 15910 15911 return name; 15912 } 15913 15914 function makeRequire(relName, forceSync) { 15915 return function () { 15916 //A version of a require function that passes a moduleName 15917 //value for items that may need to 15918 //look up paths relative to the moduleName 15919 var args = aps.call(arguments, 0); 15920 15921 //If first arg is not require('string'), and there is only 15922 //one arg, it is the array form without a callback. Insert 15923 //a null so that the following concat is correct. 15924 if (typeof args[0] !== 'string' && args.length === 1) { 15925 args.push(null); 15926 } 15927 return req.apply(undef, args.concat([relName, forceSync])); 15928 }; 15929 } 15930 15931 function makeNormalize(relName) { 15932 return function (name) { 15933 return normalize(name, relName); 15934 }; 15935 } 15936 15937 function makeLoad(depName) { 15938 return function (value) { 15939 defined[depName] = value; 15940 }; 15941 } 15942 15943 function callDep(name) { 15944 if (hasProp(waiting, name)) { 15945 var args = waiting[name]; 15946 delete waiting[name]; 15947 defining[name] = true; 15948 main.apply(undef, args); 15949 } 15950 15951 if (!hasProp(defined, name) && !hasProp(defining, name)) { 15952 throw new Error('No ' + name); 15953 } 15954 return defined[name]; 15955 } 15956 15957 //Turns a plugin!resource to [plugin, resource] 15958 //with the plugin being undefined if the name 15959 //did not have a plugin prefix. 15960 function splitPrefix(name) { 15961 var prefix, 15962 index = name ? name.indexOf('!') : -1; 15963 if (index > -1) { 15964 prefix = name.substring(0, index); 15965 name = name.substring(index + 1, name.length); 15966 } 15967 return [prefix, name]; 15968 } 15969 15970 //Creates a parts array for a relName where first part is plugin ID, 15971 //second part is resource ID. Assumes relName has already been normalized. 15972 function makeRelParts(relName) { 15973 return relName ? splitPrefix(relName) : []; 15974 } 15975 15976 /** 15977 * Makes a name map, normalizing the name, and using a plugin 15978 * for normalization if necessary. Grabs a ref to plugin 15979 * too, as an optimization. 15980 */ 15981 makeMap = function (name, relParts) { 15982 var plugin, 15983 parts = splitPrefix(name), 15984 prefix = parts[0], 15985 relResourceName = relParts[1]; 15986 15987 name = parts[1]; 15988 15989 if (prefix) { 15990 prefix = normalize(prefix, relResourceName); 15991 plugin = callDep(prefix); 15992 } 15993 15994 //Normalize according 15995 if (prefix) { 15996 if (plugin && plugin.normalize) { 15997 name = plugin.normalize(name, makeNormalize(relResourceName)); 15998 } else { 15999 name = normalize(name, relResourceName); 16000 } 16001 } else { 16002 name = normalize(name, relResourceName); 16003 parts = splitPrefix(name); 16004 prefix = parts[0]; 16005 name = parts[1]; 16006 if (prefix) { 16007 plugin = callDep(prefix); 16008 } 16009 } 16010 16011 //Using ridiculous property names for space reasons 16012 return { 16013 f: prefix ? prefix + '!' + name : name, //fullName 16014 n: name, 16015 pr: prefix, 16016 p: plugin 16017 }; 16018 }; 16019 16020 function makeConfig(name) { 16021 return function () { 16022 return (config && config.config && config.config[name]) || {}; 16023 }; 16024 } 16025 16026 handlers = { 16027 require: function (name) { 16028 return makeRequire(name); 16029 }, 16030 exports: function (name) { 16031 var e = defined[name]; 16032 if (typeof e !== 'undefined') { 16033 return e; 16034 } else { 16035 return (defined[name] = {}); 16036 } 16037 }, 16038 module: function (name) { 16039 return { 16040 id: name, 16041 uri: '', 16042 exports: defined[name], 16043 config: makeConfig(name) 16044 }; 16045 } 16046 }; 16047 16048 main = function (name, deps, callback, relName) { 16049 var cjsModule, depName, ret, map, i, relParts, 16050 args = [], 16051 callbackType = typeof callback, 16052 usingExports; 16053 16054 //Use name if no relName 16055 relName = relName || name; 16056 relParts = makeRelParts(relName); 16057 16058 //Call the callback to define the module, if necessary. 16059 if (callbackType === 'undefined' || callbackType === 'function') { 16060 //Pull out the defined dependencies and pass the ordered 16061 //values to the callback. 16062 //Default to [require, exports, module] if no deps 16063 deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps; 16064 for (i = 0; i < deps.length; i += 1) { 16065 map = makeMap(deps[i], relParts); 16066 depName = map.f; 16067 16068 //Fast path CommonJS standard dependencies. 16069 if (depName === "require") { 16070 args[i] = handlers.require(name); 16071 } else if (depName === "exports") { 16072 //CommonJS module spec 1.1 16073 args[i] = handlers.exports(name); 16074 usingExports = true; 16075 } else if (depName === "module") { 16076 //CommonJS module spec 1.1 16077 cjsModule = args[i] = handlers.module(name); 16078 } else if (hasProp(defined, depName) || 16079 hasProp(waiting, depName) || 16080 hasProp(defining, depName)) { 16081 args[i] = callDep(depName); 16082 } else if (map.p) { 16083 map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {}); 16084 args[i] = defined[depName]; 16085 } else { 16086 throw new Error(name + ' missing ' + depName); 16087 } 16088 } 16089 16090 ret = callback ? callback.apply(defined[name], args) : undefined; 16091 16092 if (name) { 16093 //If setting exports via "module" is in play, 16094 //favor that over return value and exports. After that, 16095 //favor a non-undefined return value over exports use. 16096 if (cjsModule && cjsModule.exports !== undef && 16097 cjsModule.exports !== defined[name]) { 16098 defined[name] = cjsModule.exports; 16099 } else if (ret !== undef || !usingExports) { 16100 //Use the return value from the function. 16101 defined[name] = ret; 16102 } 16103 } 16104 } else if (name) { 16105 //May just be an object definition for the module. Only 16106 //worry about defining if have a module name. 16107 defined[name] = callback; 16108 } 16109 }; 16110 16111 requirejs = require = req = function (deps, callback, relName, forceSync, alt) { 16112 if (typeof deps === "string") { 16113 if (handlers[deps]) { 16114 //callback in this case is really relName 16115 return handlers[deps](callback); 16116 } 16117 //Just return the module wanted. In this scenario, the 16118 //deps arg is the module name, and second arg (if passed) 16119 //is just the relName. 16120 //Normalize module name, if it contains . or .. 16121 return callDep(makeMap(deps, makeRelParts(callback)).f); 16122 } else if (!deps.splice) { 16123 //deps is a config object, not an array. 16124 config = deps; 16125 if (config.deps) { 16126 req(config.deps, config.callback); 16127 } 16128 if (!callback) { 16129 return; 16130 } 16131 16132 if (callback.splice) { 16133 //callback is an array, which means it is a dependency list. 16134 //Adjust args if there are dependencies 16135 deps = callback; 16136 callback = relName; 16137 relName = null; 16138 } else { 16139 deps = undef; 16140 } 16141 } 16142 16143 //Support require(['a']) 16144 callback = callback || function () {}; 16145 16146 //If relName is a function, it is an errback handler, 16147 //so remove it. 16148 if (typeof relName === 'function') { 16149 relName = forceSync; 16150 forceSync = alt; 16151 } 16152 16153 //Simulate async callback; 16154 if (forceSync) { 16155 main(undef, deps, callback, relName); 16156 } else { 16157 //Using a non-zero value because of concern for what old browsers 16158 //do, and latest browsers "upgrade" to 4 if lower value is used: 16159 //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout: 16160 //If want a value immediately, use require('id') instead -- something 16161 //that works in almond on the global level, but not guaranteed and 16162 //unlikely to work in other AMD implementations. 16163 setTimeout(function () { 16164 main(undef, deps, callback, relName); 16165 }, 4); 16166 } 16167 16168 return req; 16169 }; 16170 16171 /** 16172 * Just drops the config on the floor, but returns req in case 16173 * the config return value is used. 16174 */ 16175 req.config = function (cfg) { 16176 return req(cfg); 16177 }; 16178 16179 /** 16180 * Expose module registry for debugging and tooling 16181 */ 16182 requirejs._defined = defined; 16183 16184 define = function (name, deps, callback) { 16185 if (typeof name !== 'string') { 16186 throw new Error('See almond README: incorrect module build, no module name'); 16187 } 16188 16189 //This module may not have dependencies 16190 if (!deps.splice) { 16191 //deps is not an array, so probably means 16192 //an object literal or factory function for 16193 //the value. Adjust args. 16194 callback = deps; 16195 deps = []; 16196 } 16197 16198 if (!hasProp(defined, name) && !hasProp(waiting, name)) { 16199 waiting[name] = [name, deps, callback]; 16200 } 16201 }; 16202 16203 define.amd = { 16204 jQuery: true 16205 }; 16206}()); 16207 16208S2.requirejs = requirejs;S2.require = require;S2.define = define; 16209} 16210}()); 16211S2.define("almond", function(){}); 16212 16213/* global jQuery:false, $:false */ 16214S2.define('jquery',[],function () { 16215 var _$ = jQuery || $; 16216 16217 if (_$ == null && console && console.error) { 16218 console.error( 16219 'Select2: An instance of jQuery or a jQuery-compatible library was not ' + 16220 'found. Make sure that you are including jQuery before Select2 on your ' + 16221 'web page.' 16222 ); 16223 } 16224 16225 return _$; 16226}); 16227 16228S2.define('select2/utils',[
vendor: 5,112 bytes, lines 16229-16441
16229 'jquery' 16230], function ($) { 16231 var Utils = {}; 16232 16233 Utils.Extend = function (ChildClass, SuperClass) { 16234 var __hasProp = {}.hasOwnProperty; 16235 16236 function BaseConstructor () { 16237 this.constructor = ChildClass; 16238 } 16239 16240 for (var key in SuperClass) { 16241 if (__hasProp.call(SuperClass, key)) { 16242 ChildClass[key] = SuperClass[key]; 16243 } 16244 } 16245 16246 BaseConstructor.prototype = SuperClass.prototype; 16247 ChildClass.prototype = new BaseConstructor(); 16248 ChildClass.__super__ = SuperClass.prototype; 16249 16250 return ChildClass; 16251 }; 16252 16253 function getMethods (theClass) { 16254 var proto = theClass.prototype; 16255 16256 var methods = []; 16257 16258 for (var methodName in proto) { 16259 var m = proto[methodName]; 16260 16261 if (typeof m !== 'function') { 16262 continue; 16263 } 16264 16265 if (methodName === 'constructor') { 16266 continue; 16267 } 16268 16269 methods.push(methodName); 16270 } 16271 16272 return methods; 16273 } 16274 16275 Utils.Decorate = function (SuperClass, DecoratorClass) { 16276 var decoratedMethods = getMethods(DecoratorClass); 16277 var superMethods = getMethods(SuperClass); 16278 16279 function DecoratedClass () { 16280 var unshift = Array.prototype.unshift; 16281 16282 var argCount = DecoratorClass.prototype.constructor.length; 16283 16284 var calledConstructor = SuperClass.prototype.constructor; 16285 16286 if (argCount > 0) { 16287 unshift.call(arguments, SuperClass.prototype.constructor); 16288 16289 calledConstructor = DecoratorClass.prototype.constructor; 16290 } 16291 16292 calledConstructor.apply(this, arguments); 16293 } 16294 16295 DecoratorClass.displayName = SuperClass.displayName; 16296 16297 function ctr () { 16298 this.constructor = DecoratedClass; 16299 } 16300 16301 DecoratedClass.prototype = new ctr(); 16302 16303 for (var m = 0; m < superMethods.length; m++) { 16304 var superMethod = superMethods[m]; 16305 16306 DecoratedClass.prototype[superMethod] = 16307 SuperClass.prototype[superMethod]; 16308 } 16309 16310 var calledMethod = function (methodName) { 16311 // Stub out the original method if it's not decorating an actual method 16312 var originalMethod = function () {}; 16313 16314 if (methodName in DecoratedClass.prototype) { 16315 originalMethod = DecoratedClass.prototype[methodName]; 16316 } 16317 16318 var decoratedMethod = DecoratorClass.prototype[methodName]; 16319 16320 return function () { 16321 var unshift = Array.prototype.unshift; 16322 16323 unshift.call(arguments, originalMethod); 16324 16325 return decoratedMethod.apply(this, arguments); 16326 }; 16327 }; 16328 16329 for (var d = 0; d < decoratedMethods.length; d++) { 16330 var decoratedMethod = decoratedMethods[d]; 16331 16332 DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod); 16333 } 16334 16335 return DecoratedClass; 16336 }; 16337 16338 var Observable = function () { 16339 this.listeners = {}; 16340 }; 16341 16342 Observable.prototype.on = function (event, callback) { 16343 this.listeners = this.listeners || {}; 16344 16345 if (event in this.listeners) { 16346 this.listeners[event].push(callback); 16347 } else { 16348 this.listeners[event] = [callback]; 16349 } 16350 }; 16351 16352 Observable.prototype.trigger = function (event) { 16353 var slice = Array.prototype.slice; 16354 var params = slice.call(arguments, 1); 16355 16356 this.listeners = this.listeners || {}; 16357 16358 // Params should always come in as an array 16359 if (params == null) { 16360 params = []; 16361 } 16362 16363 // If there are no arguments to the event, use a temporary object 16364 if (params.length === 0) { 16365 params.push({}); 16366 } 16367 16368 // Set the `_type` of the first object to the event 16369 params[0]._type = event; 16370 16371 if (event in this.listeners) { 16372 this.invoke(this.listeners[event], slice.call(arguments, 1)); 16373 } 16374 16375 if ('*' in this.listeners) { 16376 this.invoke(this.listeners['*'], arguments); 16377 } 16378 }; 16379 16380 Observable.prototype.invoke = function (listeners, params) { 16381 for (var i = 0, len = listeners.length; i < len; i++) { 16382 listeners[i].apply(this, params); 16383 } 16384 }; 16385 16386 Utils.Observable = Observable; 16387 16388 Utils.generateChars = function (length) { 16389 var chars = ''; 16390 16391 for (var i = 0; i < length; i++) { 16392 var randomChar = Math.floor(Math.random() * 36); 16393 chars += randomChar.toString(36); 16394 } 16395 16396 return chars; 16397 }; 16398 16399 Utils.bind = function (func, context) { 16400 return function () { 16401 func.apply(context, arguments); 16402 }; 16403 }; 16404 16405 Utils._convertData = function (data) { 16406 for (var originalKey in data) { 16407 var keys = originalKey.split('-'); 16408 16409 var dataLevel = data; 16410 16411 if (keys.length === 1) { 16412 continue; 16413 } 16414 16415 for (var k = 0; k < keys.length; k++) { 16416 var key = keys[k]; 16417 16418 // Lowercase the first letter 16419 // By default, dash-separated becomes camelCase 16420 key = key.substring(0, 1).toLowerCase() + key.substring(1); 16421 16422 if (!(key in dataLevel)) { 16423 dataLevel[key] = {}; 16424 } 16425 16426 if (k == keys.length - 1) { 16427 dataLevel[key] = data[originalKey]; 16428 } 16429 16430 dataLevel = dataLevel[key]; 16431 } 16432 16433 delete data[originalKey]; 16434 } 16435 16436 return data; 16437 }; 16438 16439 Utils.hasScroll = function (index, el) { 16440 // Adapted from the function created by @ShadowScripter 16441 // and adapted by @BillBarry on the Stack Exchange Code Review website.
16442 // The original code can be found at 16443 // http://codereview.stackexchange.com/q/13338 16444 // and was designed to be used with the Sizzle selector engine. 16445 16446 var $el = $(el); 16447 var overflowX = el.style.overflowX; 16448 var overflowY = el.style.overflowY; 16449 16450 //Check both x and y declarations 16451 if (overflowX === overflowY && 16452 (overflowY === 'hidden' || overflowY === 'visible')) { 16453 return false; 16454 } 16455 16456 if (overflowX === 'scroll' || overflowY === 'scroll') { 16457 return true; 16458 } 16459 16460 return ($el.innerHeight() < el.scrollHeight || 16461 $el.innerWidth() < el.scrollWidth); 16462 }; 16463 16464 Utils.escapeMarkup = function (markup) { 16465 var replaceMap = { 16466 '\\': '\', 16467 '&': '&', 16468 '<': '<', 16469 '>': '>', 16470 '"': '"', 16471 '\'': ''', 16472 '/': '/' 16473 }; 16474 16475 // Do not try to escape the markup if it's not a string 16476 if (typeof markup !== 'string') { 16477 return markup; 16478 } 16479 16480 return String(markup).replace(/[&<>"'\/\\]/g, function (match) { 16481 return replaceMap[match]; 16482 }); 16483 }; 16484 16485 // Append an array of jQuery nodes to a given element. 16486 Utils.appendMany = function ($element, $nodes) { 16487 // jQuery 1.7.x does not support $.fn.append() with an array 16488 // Fall back to a jQuery object collection using $.fn.add() 16489 if ($.fn.jquery.substr(0, 3) === '1.7') { 16490 var $jqNodes = $(); 16491 16492 $.map($nodes, function (node) { 16493 $jqNodes = $jqNodes.add(node); 16494 }); 16495 16496 $nodes = $jqNodes; 16497 } 16498 16499 $element.append($nodes); 16500 }; 16501 16502 // Cache objects in Utils.__cache instead of $.data (see #4346) 16503 Utils.__cache = {}; 16504 16505 var id = 0; 16506 Utils.GetUniqueElementId = function (element) { 16507 // Get a unique element Id. If element has no id, 16508 // creates a new unique number, stores it in the id 16509 // attribute and returns the new id. 16510 // If an id already exists, it simply returns it. 16511 16512 var select2Id = element.getAttribute('data-select2-id'); 16513 if (select2Id == null) { 16514 // If element has id, use it. 16515 if (element.id) { 16516 select2Id = element.id; 16517 element.setAttribute('data-select2-id', select2Id); 16518 } else { 16519 element.setAttribute('data-select2-id', ++id); 16520 select2Id = id.toString(); 16521 } 16522 } 16523 return select2Id; 16524 }; 16525 16526 Utils.StoreData = function (element, name, value) { 16527 // Stores an item in the cache for a specified element. 16528 // name is the cache key. 16529 var id = Utils.GetUniqueElementId(element); 16530 if (!Utils.__cache[id]) { 16531 Utils.__cache[id] = {}; 16532 } 16533 16534 Utils.__cache[id][name] = value; 16535 }; 16536 16537 Utils.GetData = function (element, name) { 16538 // Retrieves a value from the cache by its key (name) 16539 // name is optional. If no name specified, return 16540 // all cache items for the specified element. 16541 // and for a specified element. 16542 var id = Utils.GetUniqueElementId(element); 16543 if (name) { 16544 if (Utils.__cache[id]) { 16545 if (Utils.__cache[id][name] != null) { 16546 return Utils.__cache[id][name]; 16547 } 16548 return $(element).data(name); // Fallback to HTML5 data attribs. 16549 } 16550 return $(element).data(name); // Fallback to HTML5 data attribs. 16551 } else { 16552 return Utils.__cache[id]; 16553 } 16554 }; 16555 16556 Utils.RemoveData = function (element) { 16557 // Removes all cached items for a specified element. 16558 var id = Utils.GetUniqueElementId(element); 16559 if (Utils.__cache[id] != null) { 16560 delete Utils.__cache[id]; 16561 } 16562 16563 element.removeAttribute('data-select2-id'); 16564 }; 16565 16566 return Utils; 16567}); 16568 16569S2.define('select2/results',[ 16570 'jquery', 16571 './utils' 16572], function ($, Utils) { 16573 function Results ($element, options, dataAdapter) { 16574 this.$element = $element; 16575 this.data = dataAdapter; 16576 this.options = options; 16577 16578 Results.__super__.constructor.call(this); 16579 } 16580 16581 Utils.Extend(Results, Utils.Observable); 16582 16583 Results.prototype.render = function () { 16584 var $results = $( 16585 '<ul class="select2-results__options" role="listbox"></ul>' 16586 ); 16587 16588 if (this.options.get('multiple')) { 16589 $results.attr('aria-multiselectable', 'true'); 16590 } 16591 16592 this.$results = $results; 16593 16594 return $results; 16595 }; 16596 16597 Results.prototype.clear = function () { 16598 this.$results.empty(); 16599 }; 16600 16601 Results.prototype.displayMessage = function (params) { 16602 var escapeMarkup = this.options.get('escapeMarkup'); 16603 16604 this.clear(); 16605 this.hideLoading(); 16606 16607 var $message = $( 16608 '<li role="alert" aria-live="assertive"' + 16609 ' class="select2-results__option"></li>' 16610 ); 16611 16612 var message = this.options.get('translations').get(params.message); 16613 16614 $message.append( 16615 escapeMarkup( 16616 message(params.args) 16617 ) 16618 ); 16619 16620 $message[0].className += ' select2-results__message';
vendor: 114,012 bytes, lines 16621-21355
16621 16622 this.$results.append($message); 16623 }; 16624 16625 Results.prototype.hideMessages = function () { 16626 this.$results.find('.select2-results__message').remove(); 16627 }; 16628 16629 Results.prototype.append = function (data) { 16630 this.hideLoading(); 16631 16632 var $options = []; 16633 16634 if (data.results == null || data.results.length === 0) { 16635 if (this.$results.children().length === 0) { 16636 this.trigger('results:message', { 16637 message: 'noResults' 16638 }); 16639 } 16640 16641 return; 16642 } 16643 16644 data.results = this.sort(data.results); 16645 16646 for (var d = 0; d < data.results.length; d++) { 16647 var item = data.results[d]; 16648 16649 var $option = this.option(item); 16650 16651 $options.push($option); 16652 } 16653 16654 this.$results.append($options); 16655 }; 16656 16657 Results.prototype.position = function ($results, $dropdown) { 16658 var $resultsContainer = $dropdown.find('.select2-results'); 16659 $resultsContainer.append($results); 16660 }; 16661 16662 Results.prototype.sort = function (data) { 16663 var sorter = this.options.get('sorter'); 16664 16665 return sorter(data); 16666 }; 16667 16668 Results.prototype.highlightFirstItem = function () { 16669 var $options = this.$results 16670 .find('.select2-results__option[aria-selected]'); 16671 16672 var $selected = $options.filter('[aria-selected=true]'); 16673 16674 // Check if there are any selected options 16675 if ($selected.length > 0) { 16676 // If there are selected options, highlight the first 16677 $selected.first().trigger('mouseenter'); 16678 } else { 16679 // If there are no selected options, highlight the first option 16680 // in the dropdown 16681 $options.first().trigger('mouseenter'); 16682 } 16683 16684 this.ensureHighlightVisible(); 16685 }; 16686 16687 Results.prototype.setClasses = function () { 16688 var self = this; 16689 16690 this.data.current(function (selected) { 16691 var selectedIds = $.map(selected, function (s) { 16692 return s.id.toString(); 16693 }); 16694 16695 var $options = self.$results 16696 .find('.select2-results__option[aria-selected]'); 16697 16698 $options.each(function () { 16699 var $option = $(this); 16700 16701 var item = Utils.GetData(this, 'data'); 16702 16703 // id needs to be converted to a string when comparing 16704 var id = '' + item.id; 16705 16706 if ((item.element != null && item.element.selected) || 16707 (item.element == null && $.inArray(id, selectedIds) > -1)) { 16708 $option.attr('aria-selected', 'true'); 16709 } else { 16710 $option.attr('aria-selected', 'false'); 16711 } 16712 }); 16713 16714 }); 16715 }; 16716 16717 Results.prototype.showLoading = function (params) { 16718 this.hideLoading(); 16719 16720 var loadingMore = this.options.get('translations').get('searching'); 16721 16722 var loading = { 16723 disabled: true, 16724 loading: true, 16725 text: loadingMore(params) 16726 }; 16727 var $loading = this.option(loading); 16728 $loading.className += ' loading-results'; 16729 16730 this.$results.prepend($loading); 16731 }; 16732 16733 Results.prototype.hideLoading = function () { 16734 this.$results.find('.loading-results').remove(); 16735 }; 16736 16737 Results.prototype.option = function (data) { 16738 var option = document.createElement('li'); 16739 option.className = 'select2-results__option'; 16740 16741 var attrs = { 16742 'role': 'option', 16743 'aria-selected': 'false' 16744 }; 16745 16746 var matches = window.Element.prototype.matches || 16747 window.Element.prototype.msMatchesSelector || 16748 window.Element.prototype.webkitMatchesSelector; 16749 16750 if ((data.element != null && matches.call(data.element, ':disabled')) || 16751 (data.element == null && data.disabled)) { 16752 delete attrs['aria-selected']; 16753 attrs['aria-disabled'] = 'true'; 16754 } 16755 16756 if (data.id == null) { 16757 delete attrs['aria-selected']; 16758 } 16759 16760 if (data._resultId != null) { 16761 option.id = data._resultId; 16762 } 16763 16764 if (data.title) { 16765 option.title = data.title; 16766 } 16767 16768 if (data.children) { 16769 attrs.role = 'group'; 16770 attrs['aria-label'] = data.text; 16771 delete attrs['aria-selected']; 16772 } 16773 16774 for (var attr in attrs) { 16775 var val = attrs[attr]; 16776 16777 option.setAttribute(attr, val); 16778 } 16779 16780 if (data.children) { 16781 var $option = $(option); 16782 16783 var label = document.createElement('strong'); 16784 label.className = 'select2-results__group'; 16785 16786 var $label = $(label); 16787 this.template(data, label); 16788 16789 var $children = []; 16790 16791 for (var c = 0; c < data.children.length; c++) { 16792 var child = data.children[c]; 16793 16794 var $child = this.option(child); 16795 16796 $children.push($child); 16797 } 16798 16799 var $childrenContainer = $('<ul></ul>', { 16800 'class': 'select2-results__options select2-results__options--nested' 16801 }); 16802 16803 $childrenContainer.append($children); 16804 16805 $option.append(label); 16806 $option.append($childrenContainer); 16807 } else { 16808 this.template(data, option); 16809 } 16810 16811 Utils.StoreData(option, 'data', data); 16812 16813 return option; 16814 }; 16815 16816 Results.prototype.bind = function (container, $container) { 16817 var self = this; 16818 16819 var id = container.id + '-results'; 16820 16821 this.$results.attr('id', id); 16822 16823 container.on('results:all', function (params) { 16824 self.clear(); 16825 self.append(params.data); 16826 16827 if (container.isOpen()) { 16828 self.setClasses(); 16829 self.highlightFirstItem(); 16830 } 16831 }); 16832 16833 container.on('results:append', function (params) { 16834 self.append(params.data); 16835 16836 if (container.isOpen()) { 16837 self.setClasses(); 16838 } 16839 }); 16840 16841 container.on('query', function (params) { 16842 self.hideMessages(); 16843 self.showLoading(params); 16844 }); 16845 16846 container.on('select', function () { 16847 if (!container.isOpen()) { 16848 return; 16849 } 16850 16851 self.setClasses(); 16852 16853 if (self.options.get('scrollAfterSelect')) { 16854 self.highlightFirstItem(); 16855 } 16856 }); 16857 16858 container.on('unselect', function () { 16859 if (!container.isOpen()) { 16860 return; 16861 } 16862 16863 self.setClasses(); 16864 16865 if (self.options.get('scrollAfterSelect')) { 16866 self.highlightFirstItem(); 16867 } 16868 }); 16869 16870 container.on('open', function () { 16871 // When the dropdown is open, aria-expended="true" 16872 self.$results.attr('aria-expanded', 'true'); 16873 self.$results.attr('aria-hidden', 'false'); 16874 16875 self.setClasses(); 16876 self.ensureHighlightVisible(); 16877 }); 16878 16879 container.on('close', function () { 16880 // When the dropdown is closed, aria-expended="false" 16881 self.$results.attr('aria-expanded', 'false'); 16882 self.$results.attr('aria-hidden', 'true'); 16883 self.$results.removeAttr('aria-activedescendant'); 16884 }); 16885 16886 container.on('results:toggle', function () { 16887 var $highlighted = self.getHighlightedResults(); 16888 16889 if ($highlighted.length === 0) { 16890 return; 16891 } 16892 16893 $highlighted.trigger('mouseup'); 16894 }); 16895 16896 container.on('results:select', function () { 16897 var $highlighted = self.getHighlightedResults(); 16898 16899 if ($highlighted.length === 0) { 16900 return; 16901 } 16902 16903 var data = Utils.GetData($highlighted[0], 'data'); 16904 16905 if ($highlighted.attr('aria-selected') == 'true') { 16906 self.trigger('close', {}); 16907 } else { 16908 self.trigger('select', { 16909 data: data 16910 }); 16911 } 16912 }); 16913 16914 container.on('results:previous', function () { 16915 var $highlighted = self.getHighlightedResults(); 16916 16917 var $options = self.$results.find('[aria-selected]'); 16918 16919 var currentIndex = $options.index($highlighted); 16920 16921 // If we are already at the top, don't move further 16922 // If no options, currentIndex will be -1 16923 if (currentIndex <= 0) { 16924 return; 16925 } 16926 16927 var nextIndex = currentIndex - 1; 16928 16929 // If none are highlighted, highlight the first 16930 if ($highlighted.length === 0) { 16931 nextIndex = 0; 16932 } 16933 16934 var $next = $options.eq(nextIndex); 16935 16936 $next.trigger('mouseenter'); 16937 16938 var currentOffset = self.$results.offset().top; 16939 var nextTop = $next.offset().top; 16940 var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset); 16941 16942 if (nextIndex === 0) { 16943 self.$results.scrollTop(0); 16944 } else if (nextTop - currentOffset < 0) { 16945 self.$results.scrollTop(nextOffset); 16946 } 16947 }); 16948 16949 container.on('results:next', function () { 16950 var $highlighted = self.getHighlightedResults(); 16951 16952 var $options = self.$results.find('[aria-selected]'); 16953 16954 var currentIndex = $options.index($highlighted); 16955 16956 var nextIndex = currentIndex + 1; 16957 16958 // If we are at the last option, stay there 16959 if (nextIndex >= $options.length) { 16960 return; 16961 } 16962 16963 var $next = $options.eq(nextIndex); 16964 16965 $next.trigger('mouseenter'); 16966 16967 var currentOffset = self.$results.offset().top + 16968 self.$results.outerHeight(false); 16969 var nextBottom = $next.offset().top + $next.outerHeight(false); 16970 var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset; 16971 16972 if (nextIndex === 0) { 16973 self.$results.scrollTop(0); 16974 } else if (nextBottom > currentOffset) { 16975 self.$results.scrollTop(nextOffset); 16976 } 16977 }); 16978 16979 container.on('results:focus', function (params) { 16980 params.element.addClass('select2-results__option--highlighted'); 16981 }); 16982 16983 container.on('results:message', function (params) { 16984 self.displayMessage(params); 16985 }); 16986 16987 if ($.fn.mousewheel) { 16988 this.$results.on('mousewheel', function (e) { 16989 var top = self.$results.scrollTop(); 16990 16991 var bottom = self.$results.get(0).scrollHeight - top + e.deltaY; 16992 16993 var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0; 16994 var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height(); 16995 16996 if (isAtTop) { 16997 self.$results.scrollTop(0); 16998 16999 e.preventDefault(); 17000 e.stopPropagation(); 17001 } else if (isAtBottom) { 17002 self.$results.scrollTop( 17003 self.$results.get(0).scrollHeight - self.$results.height() 17004 ); 17005 17006 e.preventDefault(); 17007 e.stopPropagation(); 17008 } 17009 }); 17010 } 17011 17012 this.$results.on('mouseup', '.select2-results__option[aria-selected]', 17013 function (evt) { 17014 var $this = $(this); 17015 17016 var data = Utils.GetData(this, 'data'); 17017 17018 if ($this.attr('aria-selected') === 'true') { 17019 if (self.options.get('multiple')) { 17020 self.trigger('unselect', { 17021 originalEvent: evt, 17022 data: data 17023 }); 17024 } else { 17025 self.trigger('close', {}); 17026 } 17027 17028 return; 17029 } 17030 17031 self.trigger('select', { 17032 originalEvent: evt, 17033 data: data 17034 }); 17035 }); 17036 17037 this.$results.on('mouseenter', '.select2-results__option[aria-selected]', 17038 function (evt) { 17039 var data = Utils.GetData(this, 'data'); 17040 17041 self.getHighlightedResults() 17042 .removeClass('select2-results__option--highlighted'); 17043 17044 self.trigger('results:focus', { 17045 data: data, 17046 element: $(this) 17047 }); 17048 }); 17049 }; 17050 17051 Results.prototype.getHighlightedResults = function () { 17052 var $highlighted = this.$results 17053 .find('.select2-results__option--highlighted'); 17054 17055 return $highlighted; 17056 }; 17057 17058 Results.prototype.destroy = function () { 17059 this.$results.remove(); 17060 }; 17061 17062 Results.prototype.ensureHighlightVisible = function () { 17063 var $highlighted = this.getHighlightedResults(); 17064 17065 if ($highlighted.length === 0) { 17066 return; 17067 } 17068 17069 var $options = this.$results.find('[aria-selected]'); 17070 17071 var currentIndex = $options.index($highlighted); 17072 17073 var currentOffset = this.$results.offset().top; 17074 var nextTop = $highlighted.offset().top; 17075 var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset); 17076 17077 var offsetDelta = nextTop - currentOffset; 17078 nextOffset -= $highlighted.outerHeight(false) * 2; 17079 17080 if (currentIndex <= 2) { 17081 this.$results.scrollTop(0); 17082 } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) { 17083 this.$results.scrollTop(nextOffset); 17084 } 17085 }; 17086 17087 Results.prototype.template = function (result, container) { 17088 var template = this.options.get('templateResult'); 17089 var escapeMarkup = this.options.get('escapeMarkup'); 17090 17091 var content = template(result, container); 17092 17093 if (content == null) { 17094 container.style.display = 'none'; 17095 } else if (typeof content === 'string') { 17096 container.innerHTML = escapeMarkup(content); 17097 } else { 17098 $(container).append(content); 17099 } 17100 }; 17101 17102 return Results; 17103}); 17104 17105S2.define('select2/keys',[ 17106 17107], function () { 17108 var KEYS = { 17109 BACKSPACE: 8, 17110 TAB: 9, 17111 ENTER: 13, 17112 SHIFT: 16, 17113 CTRL: 17, 17114 ALT: 18, 17115 ESC: 27, 17116 SPACE: 32, 17117 PAGE_UP: 33, 17118 PAGE_DOWN: 34, 17119 END: 35, 17120 HOME: 36, 17121 LEFT: 37, 17122 UP: 38, 17123 RIGHT: 39, 17124 DOWN: 40, 17125 DELETE: 46 17126 }; 17127 17128 return KEYS; 17129}); 17130 17131S2.define('select2/selection/base',[ 17132 'jquery', 17133 '../utils', 17134 '../keys' 17135], function ($, Utils, KEYS) { 17136 function BaseSelection ($element, options) { 17137 this.$element = $element; 17138 this.options = options; 17139 17140 BaseSelection.__super__.constructor.call(this); 17141 } 17142 17143 Utils.Extend(BaseSelection, Utils.Observable); 17144 17145 BaseSelection.prototype.render = function () { 17146 var $selection = $( 17147 '<span class="select2-selection" role="combobox" ' + 17148 ' aria-haspopup="true" aria-expanded="false">' + 17149 '</span>' 17150 ); 17151 17152 this._tabindex = 0; 17153 17154 if (Utils.GetData(this.$element[0], 'old-tabindex') != null) { 17155 this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex'); 17156 } else if (this.$element.attr('tabindex') != null) { 17157 this._tabindex = this.$element.attr('tabindex'); 17158 } 17159 17160 $selection.attr('title', this.$element.attr('title')); 17161 $selection.attr('tabindex', this._tabindex); 17162 $selection.attr('aria-disabled', 'false'); 17163 17164 this.$selection = $selection; 17165 17166 return $selection; 17167 }; 17168 17169 BaseSelection.prototype.bind = function (container, $container) { 17170 var self = this; 17171 17172 var resultsId = container.id + '-results'; 17173 17174 this.container = container; 17175 17176 this.$selection.on('focus', function (evt) { 17177 self.trigger('focus', evt); 17178 }); 17179 17180 this.$selection.on('blur', function (evt) { 17181 self._handleBlur(evt); 17182 }); 17183 17184 this.$selection.on('keydown', function (evt) { 17185 self.trigger('keypress', evt); 17186 17187 if (evt.which === KEYS.SPACE) { 17188 evt.preventDefault(); 17189 } 17190 }); 17191 17192 container.on('results:focus', function (params) { 17193 self.$selection.attr('aria-activedescendant', params.data._resultId); 17194 }); 17195 17196 container.on('selection:update', function (params) { 17197 self.update(params.data); 17198 }); 17199 17200 container.on('open', function () { 17201 // When the dropdown is open, aria-expanded="true" 17202 self.$selection.attr('aria-expanded', 'true'); 17203 self.$selection.attr('aria-owns', resultsId); 17204 17205 self._attachCloseHandler(container); 17206 }); 17207 17208 container.on('close', function () { 17209 // When the dropdown is closed, aria-expanded="false" 17210 self.$selection.attr('aria-expanded', 'false'); 17211 self.$selection.removeAttr('aria-activedescendant'); 17212 self.$selection.removeAttr('aria-owns'); 17213 17214 self.$selection.trigger('focus'); 17215 17216 self._detachCloseHandler(container); 17217 }); 17218 17219 container.on('enable', function () { 17220 self.$selection.attr('tabindex', self._tabindex); 17221 self.$selection.attr('aria-disabled', 'false'); 17222 }); 17223 17224 container.on('disable', function () { 17225 self.$selection.attr('tabindex', '-1'); 17226 self.$selection.attr('aria-disabled', 'true'); 17227 }); 17228 }; 17229 17230 BaseSelection.prototype._handleBlur = function (evt) { 17231 var self = this; 17232 17233 // This needs to be delayed as the active element is the body when the tab 17234 // key is pressed, possibly along with others. 17235 window.setTimeout(function () { 17236 // Don't trigger `blur` if the focus is still in the selection 17237 if ( 17238 (document.activeElement == self.$selection[0]) || 17239 ($.contains(self.$selection[0], document.activeElement)) 17240 ) { 17241 return; 17242 } 17243 17244 self.trigger('blur', evt); 17245 }, 1); 17246 }; 17247 17248 BaseSelection.prototype._attachCloseHandler = function (container) { 17249 17250 $(document.body).on('mousedown.select2.' + container.id, function (e) { 17251 var $target = $(e.target); 17252 17253 var $select = $target.closest('.select2'); 17254 17255 var $all = $('.select2.select2-container--open'); 17256 17257 $all.each(function () { 17258 if (this == $select[0]) { 17259 return; 17260 } 17261 17262 var $element = Utils.GetData(this, 'element'); 17263 17264 $element.select2('close'); 17265 }); 17266 }); 17267 }; 17268 17269 BaseSelection.prototype._detachCloseHandler = function (container) { 17270 $(document.body).off('mousedown.select2.' + container.id); 17271 }; 17272 17273 BaseSelection.prototype.position = function ($selection, $container) { 17274 var $selectionContainer = $container.find('.selection'); 17275 $selectionContainer.append($selection); 17276 }; 17277 17278 BaseSelection.prototype.destroy = function () { 17279 this._detachCloseHandler(this.container); 17280 }; 17281 17282 BaseSelection.prototype.update = function (data) { 17283 throw new Error('The `update` method must be defined in child classes.'); 17284 }; 17285 17286 /** 17287 * Helper method to abstract the "enabled" (not "disabled") state of this 17288 * object. 17289 * 17290 * @return {true} if the instance is not disabled. 17291 * @return {false} if the instance is disabled. 17292 */ 17293 BaseSelection.prototype.isEnabled = function () { 17294 return !this.isDisabled(); 17295 }; 17296 17297 /** 17298 * Helper method to abstract the "disabled" state of this object. 17299 * 17300 * @return {true} if the disabled option is true. 17301 * @return {false} if the disabled option is false. 17302 */ 17303 BaseSelection.prototype.isDisabled = function () { 17304 return this.options.get('disabled'); 17305 }; 17306 17307 return BaseSelection; 17308}); 17309 17310S2.define('select2/selection/single',[ 17311 'jquery', 17312 './base', 17313 '../utils', 17314 '../keys' 17315], function ($, BaseSelection, Utils, KEYS) { 17316 function SingleSelection () { 17317 SingleSelection.__super__.constructor.apply(this, arguments); 17318 } 17319 17320 Utils.Extend(SingleSelection, BaseSelection); 17321 17322 SingleSelection.prototype.render = function () { 17323 var $selection = SingleSelection.__super__.render.call(this); 17324 17325 $selection.addClass('select2-selection--single'); 17326 17327 $selection.html( 17328 '<span class="select2-selection__rendered"></span>' + 17329 '<span class="select2-selection__arrow" role="presentation">' + 17330 '<b role="presentation"></b>' + 17331 '</span>' 17332 ); 17333 17334 return $selection; 17335 }; 17336 17337 SingleSelection.prototype.bind = function (container, $container) { 17338 var self = this; 17339 17340 SingleSelection.__super__.bind.apply(this, arguments); 17341 17342 var id = container.id + '-container'; 17343 17344 this.$selection.find('.select2-selection__rendered') 17345 .attr('id', id) 17346 .attr('role', 'textbox') 17347 .attr('aria-readonly', 'true'); 17348 this.$selection.attr('aria-labelledby', id); 17349 17350 this.$selection.on('mousedown', function (evt) { 17351 // Only respond to left clicks 17352 if (evt.which !== 1) { 17353 return; 17354 } 17355 17356 self.trigger('toggle', { 17357 originalEvent: evt 17358 }); 17359 }); 17360 17361 this.$selection.on('focus', function (evt) { 17362 // User focuses on the container 17363 }); 17364 17365 this.$selection.on('blur', function (evt) { 17366 // User exits the container 17367 }); 17368 17369 container.on('focus', function (evt) { 17370 if (!container.isOpen()) { 17371 self.$selection.trigger('focus'); 17372 } 17373 }); 17374 }; 17375 17376 SingleSelection.prototype.clear = function () { 17377 var $rendered = this.$selection.find('.select2-selection__rendered'); 17378 $rendered.empty(); 17379 $rendered.removeAttr('title'); // clear tooltip on empty 17380 }; 17381 17382 SingleSelection.prototype.display = function (data, container) { 17383 var template = this.options.get('templateSelection'); 17384 var escapeMarkup = this.options.get('escapeMarkup'); 17385 17386 return escapeMarkup(template(data, container)); 17387 }; 17388 17389 SingleSelection.prototype.selectionContainer = function () { 17390 return $('<span></span>'); 17391 }; 17392 17393 SingleSelection.prototype.update = function (data) { 17394 if (data.length === 0) { 17395 this.clear(); 17396 return; 17397 } 17398 17399 var selection = data[0]; 17400 17401 var $rendered = this.$selection.find('.select2-selection__rendered'); 17402 var formatted = this.display(selection, $rendered); 17403 17404 $rendered.empty().append(formatted); 17405 17406 var title = selection.title || selection.text; 17407 17408 if (title) { 17409 $rendered.attr('title', title); 17410 } else { 17411 $rendered.removeAttr('title'); 17412 } 17413 }; 17414 17415 return SingleSelection; 17416}); 17417 17418S2.define('select2/selection/multiple',[ 17419 'jquery', 17420 './base', 17421 '../utils' 17422], function ($, BaseSelection, Utils) { 17423 function MultipleSelection ($element, options) { 17424 MultipleSelection.__super__.constructor.apply(this, arguments); 17425 } 17426 17427 Utils.Extend(MultipleSelection, BaseSelection); 17428 17429 MultipleSelection.prototype.render = function () { 17430 var $selection = MultipleSelection.__super__.render.call(this); 17431 17432 $selection.addClass('select2-selection--multiple'); 17433 17434 $selection.html( 17435 '<ul class="select2-selection__rendered"></ul>' 17436 ); 17437 17438 return $selection; 17439 }; 17440 17441 MultipleSelection.prototype.bind = function (container, $container) { 17442 var self = this; 17443 17444 MultipleSelection.__super__.bind.apply(this, arguments); 17445 17446 this.$selection.on('click', function (evt) { 17447 self.trigger('toggle', { 17448 originalEvent: evt 17449 }); 17450 }); 17451 17452 this.$selection.on( 17453 'click', 17454 '.select2-selection__choice__remove', 17455 function (evt) { 17456 // Ignore the event if it is disabled 17457 if (self.isDisabled()) { 17458 return; 17459 } 17460 17461 var $remove = $(this); 17462 var $selection = $remove.parent(); 17463 17464 var data = Utils.GetData($selection[0], 'data'); 17465 17466 self.trigger('unselect', { 17467 originalEvent: evt, 17468 data: data 17469 }); 17470 } 17471 ); 17472 }; 17473 17474 MultipleSelection.prototype.clear = function () { 17475 var $rendered = this.$selection.find('.select2-selection__rendered'); 17476 $rendered.empty(); 17477 $rendered.removeAttr('title'); 17478 }; 17479 17480 MultipleSelection.prototype.display = function (data, container) { 17481 var template = this.options.get('templateSelection'); 17482 var escapeMarkup = this.options.get('escapeMarkup'); 17483 17484 return escapeMarkup(template(data, container)); 17485 }; 17486 17487 MultipleSelection.prototype.selectionContainer = function () { 17488 var $container = $( 17489 '<li class="select2-selection__choice">' + 17490 '<span class="select2-selection__choice__remove" role="presentation">' + 17491 '×' + 17492 '</span>' + 17493 '</li>' 17494 ); 17495 17496 return $container; 17497 }; 17498 17499 MultipleSelection.prototype.update = function (data) { 17500 this.clear(); 17501 17502 if (data.length === 0) { 17503 return; 17504 } 17505 17506 var $selections = []; 17507 17508 for (var d = 0; d < data.length; d++) { 17509 var selection = data[d]; 17510 17511 var $selection = this.selectionContainer(); 17512 var formatted = this.display(selection, $selection); 17513 17514 $selection.append(formatted); 17515 17516 var title = selection.title || selection.text; 17517 17518 if (title) { 17519 $selection.attr('title', title); 17520 } 17521 17522 Utils.StoreData($selection[0], 'data', selection); 17523 17524 $selections.push($selection); 17525 } 17526 17527 var $rendered = this.$selection.find('.select2-selection__rendered'); 17528 17529 Utils.appendMany($rendered, $selections); 17530 }; 17531 17532 return MultipleSelection; 17533}); 17534 17535S2.define('select2/selection/placeholder',[ 17536 '../utils' 17537], function (Utils) { 17538 function Placeholder (decorated, $element, options) { 17539 this.placeholder = this.normalizePlaceholder(options.get('placeholder')); 17540 17541 decorated.call(this, $element, options); 17542 } 17543 17544 Placeholder.prototype.normalizePlaceholder = function (_, placeholder) { 17545 if (typeof placeholder === 'string') { 17546 placeholder = { 17547 id: '', 17548 text: placeholder 17549 }; 17550 } 17551 17552 return placeholder; 17553 }; 17554 17555 Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { 17556 var $placeholder = this.selectionContainer(); 17557 17558 $placeholder.html(this.display(placeholder)); 17559 $placeholder.addClass('select2-selection__placeholder') 17560 .removeClass('select2-selection__choice'); 17561 17562 return $placeholder; 17563 }; 17564 17565 Placeholder.prototype.update = function (decorated, data) { 17566 var singlePlaceholder = ( 17567 data.length == 1 && data[0].id != this.placeholder.id 17568 ); 17569 var multipleSelections = data.length > 1; 17570 17571 if (multipleSelections || singlePlaceholder) { 17572 return decorated.call(this, data); 17573 } 17574 17575 this.clear(); 17576 17577 var $placeholder = this.createPlaceholder(this.placeholder); 17578 17579 this.$selection.find('.select2-selection__rendered').append($placeholder); 17580 }; 17581 17582 return Placeholder; 17583}); 17584 17585S2.define('select2/selection/allowClear',[ 17586 'jquery', 17587 '../keys', 17588 '../utils' 17589], function ($, KEYS, Utils) { 17590 function AllowClear () { } 17591 17592 AllowClear.prototype.bind = function (decorated, container, $container) { 17593 var self = this; 17594 17595 decorated.call(this, container, $container); 17596 17597 if (this.placeholder == null) { 17598 if (this.options.get('debug') && window.console && console.error) { 17599 console.error( 17600 'Select2: The `allowClear` option should be used in combination ' + 17601 'with the `placeholder` option.' 17602 ); 17603 } 17604 } 17605 17606 this.$selection.on('mousedown', '.select2-selection__clear', 17607 function (evt) { 17608 self._handleClear(evt); 17609 }); 17610 17611 container.on('keypress', function (evt) { 17612 self._handleKeyboardClear(evt, container); 17613 }); 17614 }; 17615 17616 AllowClear.prototype._handleClear = function (_, evt) { 17617 // Ignore the event if it is disabled 17618 if (this.isDisabled()) { 17619 return; 17620 } 17621 17622 var $clear = this.$selection.find('.select2-selection__clear'); 17623 17624 // Ignore the event if nothing has been selected 17625 if ($clear.length === 0) { 17626 return; 17627 } 17628 17629 evt.stopPropagation(); 17630 17631 var data = Utils.GetData($clear[0], 'data'); 17632 17633 var previousVal = this.$element.val(); 17634 this.$element.val(this.placeholder.id); 17635 17636 var unselectData = { 17637 data: data 17638 }; 17639 this.trigger('clear', unselectData); 17640 if (unselectData.prevented) { 17641 this.$element.val(previousVal); 17642 return; 17643 } 17644 17645 for (var d = 0; d < data.length; d++) { 17646 unselectData = { 17647 data: data[d] 17648 }; 17649 17650 // Trigger the `unselect` event, so people can prevent it from being 17651 // cleared. 17652 this.trigger('unselect', unselectData); 17653 17654 // If the event was prevented, don't clear it out. 17655 if (unselectData.prevented) { 17656 this.$element.val(previousVal); 17657 return; 17658 } 17659 } 17660 17661 this.$element.trigger('input').trigger('change'); 17662 17663 this.trigger('toggle', {}); 17664 }; 17665 17666 AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { 17667 if (container.isOpen()) { 17668 return; 17669 } 17670 17671 if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) { 17672 this._handleClear(evt); 17673 } 17674 }; 17675 17676 AllowClear.prototype.update = function (decorated, data) { 17677 decorated.call(this, data); 17678 17679 if (this.$selection.find('.select2-selection__placeholder').length > 0 || 17680 data.length === 0) { 17681 return; 17682 } 17683 17684 var removeAll = this.options.get('translations').get('removeAllItems'); 17685 17686 var $remove = $( 17687 '<span class="select2-selection__clear" title="' + removeAll() +'">' + 17688 '×' + 17689 '</span>' 17690 ); 17691 Utils.StoreData($remove[0], 'data', data); 17692 17693 this.$selection.find('.select2-selection__rendered').prepend($remove); 17694 }; 17695 17696 return AllowClear; 17697}); 17698 17699S2.define('select2/selection/search',[ 17700 'jquery', 17701 '../utils', 17702 '../keys' 17703], function ($, Utils, KEYS) { 17704 function Search (decorated, $element, options) { 17705 decorated.call(this, $element, options); 17706 } 17707 17708 Search.prototype.render = function (decorated) { 17709 var $search = $( 17710 '<li class="select2-search select2-search--inline">' + 17711 '<input class="select2-search__field" type="search" tabindex="-1"' + 17712 ' autocomplete="off" autocorrect="off" autocapitalize="none"' + 17713 ' spellcheck="false" role="searchbox" aria-autocomplete="list" />' + 17714 '</li>' 17715 ); 17716 17717 this.$searchContainer = $search; 17718 this.$search = $search.find('input'); 17719 17720 var $rendered = decorated.call(this); 17721 17722 this._transferTabIndex(); 17723 17724 return $rendered; 17725 }; 17726 17727 Search.prototype.bind = function (decorated, container, $container) { 17728 var self = this; 17729 17730 var resultsId = container.id + '-results'; 17731 17732 decorated.call(this, container, $container); 17733 17734 container.on('open', function () { 17735 self.$search.attr('aria-controls', resultsId); 17736 self.$search.trigger('focus'); 17737 }); 17738 17739 container.on('close', function () { 17740 self.$search.val(''); 17741 self.$search.removeAttr('aria-controls'); 17742 self.$search.removeAttr('aria-activedescendant'); 17743 self.$search.trigger('focus'); 17744 }); 17745 17746 container.on('enable', function () { 17747 self.$search.prop('disabled', false); 17748 17749 self._transferTabIndex(); 17750 }); 17751 17752 container.on('disable', function () { 17753 self.$search.prop('disabled', true); 17754 }); 17755 17756 container.on('focus', function (evt) { 17757 self.$search.trigger('focus'); 17758 }); 17759 17760 container.on('results:focus', function (params) { 17761 if (params.data._resultId) { 17762 self.$search.attr('aria-activedescendant', params.data._resultId); 17763 } else { 17764 self.$search.removeAttr('aria-activedescendant'); 17765 } 17766 }); 17767 17768 this.$selection.on('focusin', '.select2-search--inline', function (evt) { 17769 self.trigger('focus', evt); 17770 }); 17771 17772 this.$selection.on('focusout', '.select2-search--inline', function (evt) { 17773 self._handleBlur(evt); 17774 }); 17775 17776 this.$selection.on('keydown', '.select2-search--inline', function (evt) { 17777 evt.stopPropagation(); 17778 17779 self.trigger('keypress', evt); 17780 17781 self._keyUpPrevented = evt.isDefaultPrevented(); 17782 17783 var key = evt.which; 17784 17785 if (key === KEYS.BACKSPACE && self.$search.val() === '') { 17786 var $previousChoice = self.$searchContainer 17787 .prev('.select2-selection__choice'); 17788 17789 if ($previousChoice.length > 0) { 17790 var item = Utils.GetData($previousChoice[0], 'data'); 17791 17792 self.searchRemoveChoice(item); 17793 17794 evt.preventDefault(); 17795 } 17796 } 17797 }); 17798 17799 this.$selection.on('click', '.select2-search--inline', function (evt) { 17800 if (self.$search.val()) { 17801 evt.stopPropagation(); 17802 } 17803 }); 17804 17805 // Try to detect the IE version should the `documentMode` property that 17806 // is stored on the document. This is only implemented in IE and is 17807 // slightly cleaner than doing a user agent check. 17808 // This property is not available in Edge, but Edge also doesn't have 17809 // this bug. 17810 var msie = document.documentMode; 17811 var disableInputEvents = msie && msie <= 11; 17812 17813 // Workaround for browsers which do not support the `input` event 17814 // This will prevent double-triggering of events for browsers which support 17815 // both the `keyup` and `input` events. 17816 this.$selection.on( 17817 'input.searchcheck', 17818 '.select2-search--inline', 17819 function (evt) { 17820 // IE will trigger the `input` event when a placeholder is used on a 17821 // search box. To get around this issue, we are forced to ignore all 17822 // `input` events in IE and keep using `keyup`. 17823 if (disableInputEvents) { 17824 self.$selection.off('input.search input.searchcheck'); 17825 return; 17826 } 17827 17828 // Unbind the duplicated `keyup` event 17829 self.$selection.off('keyup.search'); 17830 } 17831 ); 17832 17833 this.$selection.on( 17834 'keyup.search input.search', 17835 '.select2-search--inline', 17836 function (evt) { 17837 // IE will trigger the `input` event when a placeholder is used on a 17838 // search box. To get around this issue, we are forced to ignore all 17839 // `input` events in IE and keep using `keyup`. 17840 if (disableInputEvents && evt.type === 'input') { 17841 self.$selection.off('input.search input.searchcheck'); 17842 return; 17843 } 17844 17845 var key = evt.which; 17846 17847 // We can freely ignore events from modifier keys 17848 if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) { 17849 return; 17850 } 17851 17852 // Tabbing will be handled during the `keydown` phase 17853 if (key == KEYS.TAB) { 17854 return; 17855 } 17856 17857 self.handleSearch(evt); 17858 } 17859 ); 17860 }; 17861 17862 /** 17863 * This method will transfer the tabindex attribute from the rendered 17864 * selection to the search box. This allows for the search box to be used as 17865 * the primary focus instead of the selection container. 17866 * 17867 * @private 17868 */ 17869 Search.prototype._transferTabIndex = function (decorated) { 17870 this.$search.attr('tabindex', this.$selection.attr('tabindex')); 17871 this.$selection.attr('tabindex', '-1'); 17872 }; 17873 17874 Search.prototype.createPlaceholder = function (decorated, placeholder) { 17875 this.$search.attr('placeholder', placeholder.text); 17876 }; 17877 17878 Search.prototype.update = function (decorated, data) { 17879 var searchHadFocus = this.$search[0] == document.activeElement; 17880 17881 this.$search.attr('placeholder', ''); 17882 17883 decorated.call(this, data); 17884 17885 this.$selection.find('.select2-selection__rendered') 17886 .append(this.$searchContainer); 17887 17888 this.resizeSearch(); 17889 if (searchHadFocus) { 17890 this.$search.trigger('focus'); 17891 } 17892 }; 17893 17894 Search.prototype.handleSearch = function () { 17895 this.resizeSearch(); 17896 17897 if (!this._keyUpPrevented) { 17898 var input = this.$search.val(); 17899 17900 this.trigger('query', { 17901 term: input 17902 }); 17903 } 17904 17905 this._keyUpPrevented = false; 17906 }; 17907 17908 Search.prototype.searchRemoveChoice = function (decorated, item) { 17909 this.trigger('unselect', { 17910 data: item 17911 }); 17912 17913 this.$search.val(item.text); 17914 this.handleSearch(); 17915 }; 17916 17917 Search.prototype.resizeSearch = function () { 17918 this.$search.css('width', '25px'); 17919 17920 var width = ''; 17921 17922 if (this.$search.attr('placeholder') !== '') { 17923 width = this.$selection.find('.select2-selection__rendered').width(); 17924 } else { 17925 var minimumWidth = this.$search.val().length + 1; 17926 17927 width = (minimumWidth * 0.75) + 'em'; 17928 } 17929 17930 this.$search.css('width', width); 17931 }; 17932 17933 return Search; 17934}); 17935 17936S2.define('select2/selection/eventRelay',[ 17937 'jquery' 17938], function ($) { 17939 function EventRelay () { } 17940 17941 EventRelay.prototype.bind = function (decorated, container, $container) { 17942 var self = this; 17943 var relayEvents = [ 17944 'open', 'opening', 17945 'close', 'closing', 17946 'select', 'selecting', 17947 'unselect', 'unselecting', 17948 'clear', 'clearing' 17949 ]; 17950 17951 var preventableEvents = [ 17952 'opening', 'closing', 'selecting', 'unselecting', 'clearing' 17953 ]; 17954 17955 decorated.call(this, container, $container); 17956 17957 container.on('*', function (name, params) { 17958 // Ignore events that should not be relayed 17959 if ($.inArray(name, relayEvents) === -1) { 17960 return; 17961 } 17962 17963 // The parameters should always be an object 17964 params = params || {}; 17965 17966 // Generate the jQuery event for the Select2 event 17967 var evt = $.Event('select2:' + name, { 17968 params: params 17969 }); 17970 17971 self.$element.trigger(evt); 17972 17973 // Only handle preventable events if it was one 17974 if ($.inArray(name, preventableEvents) === -1) { 17975 return; 17976 } 17977 17978 params.prevented = evt.isDefaultPrevented(); 17979 }); 17980 }; 17981 17982 return EventRelay; 17983}); 17984 17985S2.define('select2/translation',[ 17986 'jquery', 17987 'require' 17988], function ($, require) { 17989 function Translation (dict) { 17990 this.dict = dict || {}; 17991 } 17992 17993 Translation.prototype.all = function () { 17994 return this.dict; 17995 }; 17996 17997 Translation.prototype.get = function (key) { 17998 return this.dict[key]; 17999 }; 18000 18001 Translation.prototype.extend = function (translation) { 18002 this.dict = $.extend({}, translation.all(), this.dict); 18003 }; 18004 18005 // Static functions 18006 18007 Translation._cache = {}; 18008 18009 Translation.loadPath = function (path) { 18010 if (!(path in Translation._cache)) { 18011 var translations = require(path); 18012 18013 Translation._cache[path] = translations; 18014 } 18015 18016 return new Translation(Translation._cache[path]); 18017 }; 18018 18019 return Translation; 18020}); 18021 18022S2.define('select2/diacritics',[ 18023 18024], function () { 18025 var diacritics = { 18026 '\u24B6': 'A', 18027 '\uFF21': 'A', 18028 '\u00C0': 'A', 18029 '\u00C1': 'A', 18030 '\u00C2': 'A', 18031 '\u1EA6': 'A', 18032 '\u1EA4': 'A', 18033 '\u1EAA': 'A', 18034 '\u1EA8': 'A', 18035 '\u00C3': 'A', 18036 '\u0100': 'A', 18037 '\u0102': 'A', 18038 '\u1EB0': 'A', 18039 '\u1EAE': 'A', 18040 '\u1EB4': 'A', 18041 '\u1EB2': 'A', 18042 '\u0226': 'A', 18043 '\u01E0': 'A', 18044 '\u00C4': 'A', 18045 '\u01DE': 'A', 18046 '\u1EA2': 'A', 18047 '\u00C5': 'A', 18048 '\u01FA': 'A', 18049 '\u01CD': 'A', 18050 '\u0200': 'A', 18051 '\u0202': 'A', 18052 '\u1EA0': 'A', 18053 '\u1EAC': 'A', 18054 '\u1EB6': 'A', 18055 '\u1E00': 'A', 18056 '\u0104': 'A', 18057 '\u023A': 'A', 18058 '\u2C6F': 'A', 18059 '\uA732': 'AA', 18060 '\u00C6': 'AE', 18061 '\u01FC': 'AE', 18062 '\u01E2': 'AE', 18063 '\uA734': 'AO', 18064 '\uA736': 'AU', 18065 '\uA738': 'AV', 18066 '\uA73A': 'AV', 18067 '\uA73C': 'AY', 18068 '\u24B7': 'B', 18069 '\uFF22': 'B', 18070 '\u1E02': 'B', 18071 '\u1E04': 'B', 18072 '\u1E06': 'B', 18073 '\u0243': 'B', 18074 '\u0182': 'B', 18075 '\u0181': 'B', 18076 '\u24B8': 'C', 18077 '\uFF23': 'C', 18078 '\u0106': 'C', 18079 '\u0108': 'C', 18080 '\u010A': 'C', 18081 '\u010C': 'C', 18082 '\u00C7': 'C', 18083 '\u1E08': 'C', 18084 '\u0187': 'C', 18085 '\u023B': 'C', 18086 '\uA73E': 'C', 18087 '\u24B9': 'D', 18088 '\uFF24': 'D', 18089 '\u1E0A': 'D', 18090 '\u010E': 'D', 18091 '\u1E0C': 'D', 18092 '\u1E10': 'D', 18093 '\u1E12': 'D', 18094 '\u1E0E': 'D', 18095 '\u0110': 'D', 18096 '\u018B': 'D', 18097 '\u018A': 'D', 18098 '\u0189': 'D', 18099 '\uA779': 'D', 18100 '\u01F1': 'DZ', 18101 '\u01C4': 'DZ', 18102 '\u01F2': 'Dz', 18103 '\u01C5': 'Dz', 18104 '\u24BA': 'E', 18105 '\uFF25': 'E', 18106 '\u00C8': 'E', 18107 '\u00C9': 'E', 18108 '\u00CA': 'E', 18109 '\u1EC0': 'E', 18110 '\u1EBE': 'E', 18111 '\u1EC4': 'E', 18112 '\u1EC2': 'E', 18113 '\u1EBC': 'E', 18114 '\u0112': 'E', 18115 '\u1E14': 'E', 18116 '\u1E16': 'E', 18117 '\u0114': 'E', 18118 '\u0116': 'E', 18119 '\u00CB': 'E', 18120 '\u1EBA': 'E', 18121 '\u011A': 'E', 18122 '\u0204': 'E', 18123 '\u0206': 'E', 18124 '\u1EB8': 'E', 18125 '\u1EC6': 'E', 18126 '\u0228': 'E', 18127 '\u1E1C': 'E', 18128 '\u0118': 'E', 18129 '\u1E18': 'E', 18130 '\u1E1A': 'E', 18131 '\u0190': 'E', 18132 '\u018E': 'E', 18133 '\u24BB': 'F', 18134 '\uFF26': 'F', 18135 '\u1E1E': 'F', 18136 '\u0191': 'F', 18137 '\uA77B': 'F', 18138 '\u24BC': 'G', 18139 '\uFF27': 'G', 18140 '\u01F4': 'G', 18141 '\u011C': 'G', 18142 '\u1E20': 'G', 18143 '\u011E': 'G', 18144 '\u0120': 'G', 18145 '\u01E6': 'G', 18146 '\u0122': 'G', 18147 '\u01E4': 'G', 18148 '\u0193': 'G', 18149 '\uA7A0': 'G', 18150 '\uA77D': 'G', 18151 '\uA77E': 'G', 18152 '\u24BD': 'H', 18153 '\uFF28': 'H', 18154 '\u0124': 'H', 18155 '\u1E22': 'H', 18156 '\u1E26': 'H', 18157 '\u021E': 'H', 18158 '\u1E24': 'H', 18159 '\u1E28': 'H', 18160 '\u1E2A': 'H', 18161 '\u0126': 'H', 18162 '\u2C67': 'H', 18163 '\u2C75': 'H', 18164 '\uA78D': 'H', 18165 '\u24BE': 'I', 18166 '\uFF29': 'I', 18167 '\u00CC': 'I', 18168 '\u00CD': 'I', 18169 '\u00CE': 'I', 18170 '\u0128': 'I', 18171 '\u012A': 'I', 18172 '\u012C': 'I', 18173 '\u0130': 'I', 18174 '\u00CF': 'I', 18175 '\u1E2E': 'I', 18176 '\u1EC8': 'I', 18177 '\u01CF': 'I', 18178 '\u0208': 'I', 18179 '\u020A': 'I', 18180 '\u1ECA': 'I', 18181 '\u012E': 'I', 18182 '\u1E2C': 'I', 18183 '\u0197': 'I', 18184 '\u24BF': 'J', 18185 '\uFF2A': 'J', 18186 '\u0134': 'J', 18187 '\u0248': 'J', 18188 '\u24C0': 'K', 18189 '\uFF2B': 'K', 18190 '\u1E30': 'K', 18191 '\u01E8': 'K', 18192 '\u1E32': 'K', 18193 '\u0136': 'K', 18194 '\u1E34': 'K', 18195 '\u0198': 'K', 18196 '\u2C69': 'K', 18197 '\uA740': 'K', 18198 '\uA742': 'K', 18199 '\uA744': 'K', 18200 '\uA7A2': 'K', 18201 '\u24C1': 'L', 18202 '\uFF2C': 'L', 18203 '\u013F': 'L', 18204 '\u0139': 'L', 18205 '\u013D': 'L', 18206 '\u1E36': 'L', 18207 '\u1E38': 'L', 18208 '\u013B': 'L', 18209 '\u1E3C': 'L', 18210 '\u1E3A': 'L', 18211 '\u0141': 'L', 18212 '\u023D': 'L', 18213 '\u2C62': 'L', 18214 '\u2C60': 'L', 18215 '\uA748': 'L', 18216 '\uA746': 'L', 18217 '\uA780': 'L', 18218 '\u01C7': 'LJ', 18219 '\u01C8': 'Lj', 18220 '\u24C2': 'M', 18221 '\uFF2D': 'M', 18222 '\u1E3E': 'M', 18223 '\u1E40': 'M', 18224 '\u1E42': 'M', 18225 '\u2C6E': 'M', 18226 '\u019C': 'M', 18227 '\u24C3': 'N', 18228 '\uFF2E': 'N', 18229 '\u01F8': 'N', 18230 '\u0143': 'N', 18231 '\u00D1': 'N', 18232 '\u1E44': 'N', 18233 '\u0147': 'N', 18234 '\u1E46': 'N', 18235 '\u0145': 'N', 18236 '\u1E4A': 'N', 18237 '\u1E48': 'N', 18238 '\u0220': 'N', 18239 '\u019D': 'N', 18240 '\uA790': 'N', 18241 '\uA7A4': 'N', 18242 '\u01CA': 'NJ', 18243 '\u01CB': 'Nj', 18244 '\u24C4': 'O', 18245 '\uFF2F': 'O', 18246 '\u00D2': 'O', 18247 '\u00D3': 'O', 18248 '\u00D4': 'O', 18249 '\u1ED2': 'O', 18250 '\u1ED0': 'O', 18251 '\u1ED6': 'O', 18252 '\u1ED4': 'O', 18253 '\u00D5': 'O', 18254 '\u1E4C': 'O', 18255 '\u022C': 'O', 18256 '\u1E4E': 'O', 18257 '\u014C': 'O', 18258 '\u1E50': 'O', 18259 '\u1E52': 'O', 18260 '\u014E': 'O', 18261 '\u022E': 'O', 18262 '\u0230': 'O', 18263 '\u00D6': 'O', 18264 '\u022A': 'O', 18265 '\u1ECE': 'O', 18266 '\u0150': 'O', 18267 '\u01D1': 'O', 18268 '\u020C': 'O', 18269 '\u020E': 'O', 18270 '\u01A0': 'O', 18271 '\u1EDC': 'O', 18272 '\u1EDA': 'O', 18273 '\u1EE0': 'O', 18274 '\u1EDE': 'O', 18275 '\u1EE2': 'O', 18276 '\u1ECC': 'O', 18277 '\u1ED8': 'O', 18278 '\u01EA': 'O', 18279 '\u01EC': 'O', 18280 '\u00D8': 'O', 18281 '\u01FE': 'O', 18282 '\u0186': 'O', 18283 '\u019F': 'O', 18284 '\uA74A': 'O', 18285 '\uA74C': 'O', 18286 '\u0152': 'OE', 18287 '\u01A2': 'OI', 18288 '\uA74E': 'OO', 18289 '\u0222': 'OU', 18290 '\u24C5': 'P', 18291 '\uFF30': 'P', 18292 '\u1E54': 'P', 18293 '\u1E56': 'P', 18294 '\u01A4': 'P', 18295 '\u2C63': 'P', 18296 '\uA750': 'P', 18297 '\uA752': 'P', 18298 '\uA754': 'P', 18299 '\u24C6': 'Q', 18300 '\uFF31': 'Q', 18301 '\uA756': 'Q', 18302 '\uA758': 'Q', 18303 '\u024A': 'Q', 18304 '\u24C7': 'R', 18305 '\uFF32': 'R', 18306 '\u0154': 'R', 18307 '\u1E58': 'R', 18308 '\u0158': 'R', 18309 '\u0210': 'R', 18310 '\u0212': 'R', 18311 '\u1E5A': 'R', 18312 '\u1E5C': 'R', 18313 '\u0156': 'R', 18314 '\u1E5E': 'R', 18315 '\u024C': 'R', 18316 '\u2C64': 'R', 18317 '\uA75A': 'R', 18318 '\uA7A6': 'R', 18319 '\uA782': 'R', 18320 '\u24C8': 'S', 18321 '\uFF33': 'S', 18322 '\u1E9E': 'S', 18323 '\u015A': 'S', 18324 '\u1E64': 'S', 18325 '\u015C': 'S', 18326 '\u1E60': 'S', 18327 '\u0160': 'S', 18328 '\u1E66': 'S', 18329 '\u1E62': 'S', 18330 '\u1E68': 'S', 18331 '\u0218': 'S', 18332 '\u015E': 'S', 18333 '\u2C7E': 'S', 18334 '\uA7A8': 'S', 18335 '\uA784': 'S', 18336 '\u24C9': 'T', 18337 '\uFF34': 'T', 18338 '\u1E6A': 'T', 18339 '\u0164': 'T', 18340 '\u1E6C': 'T', 18341 '\u021A': 'T', 18342 '\u0162': 'T', 18343 '\u1E70': 'T', 18344 '\u1E6E': 'T', 18345 '\u0166': 'T', 18346 '\u01AC': 'T', 18347 '\u01AE': 'T', 18348 '\u023E': 'T', 18349 '\uA786': 'T', 18350 '\uA728': 'TZ', 18351 '\u24CA': 'U', 18352 '\uFF35': 'U', 18353 '\u00D9': 'U', 18354 '\u00DA': 'U', 18355 '\u00DB': 'U', 18356 '\u0168': 'U', 18357 '\u1E78': 'U', 18358 '\u016A': 'U', 18359 '\u1E7A': 'U', 18360 '\u016C': 'U', 18361 '\u00DC': 'U', 18362 '\u01DB': 'U', 18363 '\u01D7': 'U', 18364 '\u01D5': 'U', 18365 '\u01D9': 'U', 18366 '\u1EE6': 'U', 18367 '\u016E': 'U', 18368 '\u0170': 'U', 18369 '\u01D3': 'U', 18370 '\u0214': 'U', 18371 '\u0216': 'U', 18372 '\u01AF': 'U', 18373 '\u1EEA': 'U', 18374 '\u1EE8': 'U', 18375 '\u1EEE': 'U', 18376 '\u1EEC': 'U', 18377 '\u1EF0': 'U', 18378 '\u1EE4': 'U', 18379 '\u1E72': 'U', 18380 '\u0172': 'U', 18381 '\u1E76': 'U', 18382 '\u1E74': 'U', 18383 '\u0244': 'U', 18384 '\u24CB': 'V', 18385 '\uFF36': 'V', 18386 '\u1E7C': 'V', 18387 '\u1E7E': 'V', 18388 '\u01B2': 'V', 18389 '\uA75E': 'V', 18390 '\u0245': 'V', 18391 '\uA760': 'VY', 18392 '\u24CC': 'W', 18393 '\uFF37': 'W', 18394 '\u1E80': 'W', 18395 '\u1E82': 'W', 18396 '\u0174': 'W', 18397 '\u1E86': 'W', 18398 '\u1E84': 'W', 18399 '\u1E88': 'W', 18400 '\u2C72': 'W', 18401 '\u24CD': 'X', 18402 '\uFF38': 'X', 18403 '\u1E8A': 'X', 18404 '\u1E8C': 'X', 18405 '\u24CE': 'Y', 18406 '\uFF39': 'Y', 18407 '\u1EF2': 'Y', 18408 '\u00DD': 'Y', 18409 '\u0176': 'Y', 18410 '\u1EF8': 'Y', 18411 '\u0232': 'Y', 18412 '\u1E8E': 'Y', 18413 '\u0178': 'Y', 18414 '\u1EF6': 'Y', 18415 '\u1EF4': 'Y', 18416 '\u01B3': 'Y', 18417 '\u024E': 'Y', 18418 '\u1EFE': 'Y', 18419 '\u24CF': 'Z', 18420 '\uFF3A': 'Z', 18421 '\u0179': 'Z', 18422 '\u1E90': 'Z', 18423 '\u017B': 'Z', 18424 '\u017D': 'Z', 18425 '\u1E92': 'Z', 18426 '\u1E94': 'Z', 18427 '\u01B5': 'Z', 18428 '\u0224': 'Z', 18429 '\u2C7F': 'Z', 18430 '\u2C6B': 'Z', 18431 '\uA762': 'Z', 18432 '\u24D0': 'a', 18433 '\uFF41': 'a', 18434 '\u1E9A': 'a', 18435 '\u00E0': 'a', 18436 '\u00E1': 'a', 18437 '\u00E2': 'a', 18438 '\u1EA7': 'a', 18439 '\u1EA5': 'a', 18440 '\u1EAB': 'a', 18441 '\u1EA9': 'a', 18442 '\u00E3': 'a', 18443 '\u0101': 'a', 18444 '\u0103': 'a', 18445 '\u1EB1': 'a', 18446 '\u1EAF': 'a', 18447 '\u1EB5': 'a', 18448 '\u1EB3': 'a', 18449 '\u0227': 'a', 18450 '\u01E1': 'a', 18451 '\u00E4': 'a', 18452 '\u01DF': 'a', 18453 '\u1EA3': 'a', 18454 '\u00E5': 'a', 18455 '\u01FB': 'a', 18456 '\u01CE': 'a', 18457 '\u0201': 'a', 18458 '\u0203': 'a', 18459 '\u1EA1': 'a', 18460 '\u1EAD': 'a', 18461 '\u1EB7': 'a', 18462 '\u1E01': 'a', 18463 '\u0105': 'a', 18464 '\u2C65': 'a', 18465 '\u0250': 'a', 18466 '\uA733': 'aa', 18467 '\u00E6': 'ae', 18468 '\u01FD': 'ae', 18469 '\u01E3': 'ae', 18470 '\uA735': 'ao', 18471 '\uA737': 'au', 18472 '\uA739': 'av', 18473 '\uA73B': 'av', 18474 '\uA73D': 'ay', 18475 '\u24D1': 'b', 18476 '\uFF42': 'b', 18477 '\u1E03': 'b', 18478 '\u1E05': 'b', 18479 '\u1E07': 'b', 18480 '\u0180': 'b', 18481 '\u0183': 'b', 18482 '\u0253': 'b', 18483 '\u24D2': 'c', 18484 '\uFF43': 'c', 18485 '\u0107': 'c', 18486 '\u0109': 'c', 18487 '\u010B': 'c', 18488 '\u010D': 'c', 18489 '\u00E7': 'c', 18490 '\u1E09': 'c', 18491 '\u0188': 'c', 18492 '\u023C': 'c', 18493 '\uA73F': 'c', 18494 '\u2184': 'c', 18495 '\u24D3': 'd', 18496 '\uFF44': 'd', 18497 '\u1E0B': 'd', 18498 '\u010F': 'd', 18499 '\u1E0D': 'd', 18500 '\u1E11': 'd', 18501 '\u1E13': 'd', 18502 '\u1E0F': 'd', 18503 '\u0111': 'd', 18504 '\u018C': 'd', 18505 '\u0256': 'd', 18506 '\u0257': 'd', 18507 '\uA77A': 'd', 18508 '\u01F3': 'dz', 18509 '\u01C6': 'dz', 18510 '\u24D4': 'e', 18511 '\uFF45': 'e', 18512 '\u00E8': 'e', 18513 '\u00E9': 'e', 18514 '\u00EA': 'e', 18515 '\u1EC1': 'e', 18516 '\u1EBF': 'e', 18517 '\u1EC5': 'e', 18518 '\u1EC3': 'e', 18519 '\u1EBD': 'e', 18520 '\u0113': 'e', 18521 '\u1E15': 'e', 18522 '\u1E17': 'e', 18523 '\u0115': 'e', 18524 '\u0117': 'e', 18525 '\u00EB': 'e', 18526 '\u1EBB': 'e', 18527 '\u011B': 'e', 18528 '\u0205': 'e', 18529 '\u0207': 'e', 18530 '\u1EB9': 'e', 18531 '\u1EC7': 'e', 18532 '\u0229': 'e', 18533 '\u1E1D': 'e', 18534 '\u0119': 'e', 18535 '\u1E19': 'e', 18536 '\u1E1B': 'e', 18537 '\u0247': 'e', 18538 '\u025B': 'e', 18539 '\u01DD': 'e', 18540 '\u24D5': 'f', 18541 '\uFF46': 'f', 18542 '\u1E1F': 'f', 18543 '\u0192': 'f', 18544 '\uA77C': 'f', 18545 '\u24D6': 'g', 18546 '\uFF47': 'g', 18547 '\u01F5': 'g', 18548 '\u011D': 'g', 18549 '\u1E21': 'g', 18550 '\u011F': 'g', 18551 '\u0121': 'g', 18552 '\u01E7': 'g', 18553 '\u0123': 'g', 18554 '\u01E5': 'g', 18555 '\u0260': 'g', 18556 '\uA7A1': 'g', 18557 '\u1D79': 'g', 18558 '\uA77F': 'g', 18559 '\u24D7': 'h', 18560 '\uFF48': 'h', 18561 '\u0125': 'h', 18562 '\u1E23': 'h', 18563 '\u1E27': 'h', 18564 '\u021F': 'h', 18565 '\u1E25': 'h', 18566 '\u1E29': 'h', 18567 '\u1E2B': 'h', 18568 '\u1E96': 'h', 18569 '\u0127': 'h', 18570 '\u2C68': 'h', 18571 '\u2C76': 'h', 18572 '\u0265': 'h', 18573 '\u0195': 'hv', 18574 '\u24D8': 'i', 18575 '\uFF49': 'i', 18576 '\u00EC': 'i', 18577 '\u00ED': 'i', 18578 '\u00EE': 'i', 18579 '\u0129': 'i', 18580 '\u012B': 'i', 18581 '\u012D': 'i', 18582 '\u00EF': 'i', 18583 '\u1E2F': 'i', 18584 '\u1EC9': 'i', 18585 '\u01D0': 'i', 18586 '\u0209': 'i', 18587 '\u020B': 'i', 18588 '\u1ECB': 'i', 18589 '\u012F': 'i', 18590 '\u1E2D': 'i', 18591 '\u0268': 'i', 18592 '\u0131': 'i', 18593 '\u24D9': 'j', 18594 '\uFF4A': 'j', 18595 '\u0135': 'j', 18596 '\u01F0': 'j', 18597 '\u0249': 'j', 18598 '\u24DA': 'k', 18599 '\uFF4B': 'k', 18600 '\u1E31': 'k', 18601 '\u01E9': 'k', 18602 '\u1E33': 'k', 18603 '\u0137': 'k', 18604 '\u1E35': 'k', 18605 '\u0199': 'k', 18606 '\u2C6A': 'k', 18607 '\uA741': 'k', 18608 '\uA743': 'k', 18609 '\uA745': 'k', 18610 '\uA7A3': 'k', 18611 '\u24DB': 'l', 18612 '\uFF4C': 'l', 18613 '\u0140': 'l', 18614 '\u013A': 'l', 18615 '\u013E': 'l', 18616 '\u1E37': 'l', 18617 '\u1E39': 'l', 18618 '\u013C': 'l', 18619 '\u1E3D': 'l', 18620 '\u1E3B': 'l', 18621 '\u017F': 'l', 18622 '\u0142': 'l', 18623 '\u019A': 'l', 18624 '\u026B': 'l', 18625 '\u2C61': 'l', 18626 '\uA749': 'l', 18627 '\uA781': 'l', 18628 '\uA747': 'l', 18629 '\u01C9': 'lj', 18630 '\u24DC': 'm', 18631 '\uFF4D': 'm', 18632 '\u1E3F': 'm', 18633 '\u1E41': 'm', 18634 '\u1E43': 'm', 18635 '\u0271': 'm', 18636 '\u026F': 'm', 18637 '\u24DD': 'n', 18638 '\uFF4E': 'n', 18639 '\u01F9': 'n', 18640 '\u0144': 'n', 18641 '\u00F1': 'n', 18642 '\u1E45': 'n', 18643 '\u0148': 'n', 18644 '\u1E47': 'n', 18645 '\u0146': 'n', 18646 '\u1E4B': 'n', 18647 '\u1E49': 'n', 18648 '\u019E': 'n', 18649 '\u0272': 'n', 18650 '\u0149': 'n', 18651 '\uA791': 'n', 18652 '\uA7A5': 'n', 18653 '\u01CC': 'nj', 18654 '\u24DE': 'o', 18655 '\uFF4F': 'o', 18656 '\u00F2': 'o', 18657 '\u00F3': 'o', 18658 '\u00F4': 'o', 18659 '\u1ED3': 'o', 18660 '\u1ED1': 'o', 18661 '\u1ED7': 'o', 18662 '\u1ED5': 'o', 18663 '\u00F5': 'o', 18664 '\u1E4D': 'o', 18665 '\u022D': 'o', 18666 '\u1E4F': 'o', 18667 '\u014D': 'o', 18668 '\u1E51': 'o', 18669 '\u1E53': 'o', 18670 '\u014F': 'o', 18671 '\u022F': 'o', 18672 '\u0231': 'o', 18673 '\u00F6': 'o', 18674 '\u022B': 'o', 18675 '\u1ECF': 'o', 18676 '\u0151': 'o', 18677 '\u01D2': 'o', 18678 '\u020D': 'o', 18679 '\u020F': 'o', 18680 '\u01A1': 'o', 18681 '\u1EDD': 'o', 18682 '\u1EDB': 'o', 18683 '\u1EE1': 'o', 18684 '\u1EDF': 'o', 18685 '\u1EE3': 'o', 18686 '\u1ECD': 'o', 18687 '\u1ED9': 'o', 18688 '\u01EB': 'o', 18689 '\u01ED': 'o', 18690 '\u00F8': 'o', 18691 '\u01FF': 'o', 18692 '\u0254': 'o', 18693 '\uA74B': 'o', 18694 '\uA74D': 'o', 18695 '\u0275': 'o', 18696 '\u0153': 'oe', 18697 '\u01A3': 'oi', 18698 '\u0223': 'ou', 18699 '\uA74F': 'oo', 18700 '\u24DF': 'p', 18701 '\uFF50': 'p', 18702 '\u1E55': 'p', 18703 '\u1E57': 'p', 18704 '\u01A5': 'p', 18705 '\u1D7D': 'p', 18706 '\uA751': 'p', 18707 '\uA753': 'p', 18708 '\uA755': 'p', 18709 '\u24E0': 'q', 18710 '\uFF51': 'q', 18711 '\u024B': 'q', 18712 '\uA757': 'q', 18713 '\uA759': 'q', 18714 '\u24E1': 'r', 18715 '\uFF52': 'r', 18716 '\u0155': 'r', 18717 '\u1E59': 'r', 18718 '\u0159': 'r', 18719 '\u0211': 'r', 18720 '\u0213': 'r', 18721 '\u1E5B': 'r', 18722 '\u1E5D': 'r', 18723 '\u0157': 'r', 18724 '\u1E5F': 'r', 18725 '\u024D': 'r', 18726 '\u027D': 'r', 18727 '\uA75B': 'r', 18728 '\uA7A7': 'r', 18729 '\uA783': 'r', 18730 '\u24E2': 's', 18731 '\uFF53': 's', 18732 '\u00DF': 's', 18733 '\u015B': 's', 18734 '\u1E65': 's', 18735 '\u015D': 's', 18736 '\u1E61': 's', 18737 '\u0161': 's', 18738 '\u1E67': 's', 18739 '\u1E63': 's', 18740 '\u1E69': 's', 18741 '\u0219': 's', 18742 '\u015F': 's', 18743 '\u023F': 's', 18744 '\uA7A9': 's', 18745 '\uA785': 's', 18746 '\u1E9B': 's', 18747 '\u24E3': 't', 18748 '\uFF54': 't', 18749 '\u1E6B': 't', 18750 '\u1E97': 't', 18751 '\u0165': 't', 18752 '\u1E6D': 't', 18753 '\u021B': 't', 18754 '\u0163': 't', 18755 '\u1E71': 't', 18756 '\u1E6F': 't', 18757 '\u0167': 't', 18758 '\u01AD': 't', 18759 '\u0288': 't', 18760 '\u2C66': 't', 18761 '\uA787': 't', 18762 '\uA729': 'tz', 18763 '\u24E4': 'u', 18764 '\uFF55': 'u', 18765 '\u00F9': 'u', 18766 '\u00FA': 'u', 18767 '\u00FB': 'u', 18768 '\u0169': 'u', 18769 '\u1E79': 'u', 18770 '\u016B': 'u', 18771 '\u1E7B': 'u', 18772 '\u016D': 'u', 18773 '\u00FC': 'u', 18774 '\u01DC': 'u', 18775 '\u01D8': 'u', 18776 '\u01D6': 'u', 18777 '\u01DA': 'u', 18778 '\u1EE7': 'u', 18779 '\u016F': 'u', 18780 '\u0171': 'u', 18781 '\u01D4': 'u', 18782 '\u0215': 'u', 18783 '\u0217': 'u', 18784 '\u01B0': 'u', 18785 '\u1EEB': 'u', 18786 '\u1EE9': 'u', 18787 '\u1EEF': 'u', 18788 '\u1EED': 'u', 18789 '\u1EF1': 'u', 18790 '\u1EE5': 'u', 18791 '\u1E73': 'u', 18792 '\u0173': 'u', 18793 '\u1E77': 'u', 18794 '\u1E75': 'u', 18795 '\u0289': 'u', 18796 '\u24E5': 'v', 18797 '\uFF56': 'v', 18798 '\u1E7D': 'v', 18799 '\u1E7F': 'v', 18800 '\u028B': 'v', 18801 '\uA75F': 'v', 18802 '\u028C': 'v', 18803 '\uA761': 'vy', 18804 '\u24E6': 'w', 18805 '\uFF57': 'w', 18806 '\u1E81': 'w', 18807 '\u1E83': 'w', 18808 '\u0175': 'w', 18809 '\u1E87': 'w', 18810 '\u1E85': 'w', 18811 '\u1E98': 'w', 18812 '\u1E89': 'w', 18813 '\u2C73': 'w', 18814 '\u24E7': 'x', 18815 '\uFF58': 'x', 18816 '\u1E8B': 'x', 18817 '\u1E8D': 'x', 18818 '\u24E8': 'y', 18819 '\uFF59': 'y', 18820 '\u1EF3': 'y', 18821 '\u00FD': 'y', 18822 '\u0177': 'y', 18823 '\u1EF9': 'y', 18824 '\u0233': 'y', 18825 '\u1E8F': 'y', 18826 '\u00FF': 'y', 18827 '\u1EF7': 'y', 18828 '\u1E99': 'y', 18829 '\u1EF5': 'y', 18830 '\u01B4': 'y', 18831 '\u024F': 'y', 18832 '\u1EFF': 'y', 18833 '\u24E9': 'z', 18834 '\uFF5A': 'z', 18835 '\u017A': 'z', 18836 '\u1E91': 'z', 18837 '\u017C': 'z', 18838 '\u017E': 'z', 18839 '\u1E93': 'z', 18840 '\u1E95': 'z', 18841 '\u01B6': 'z', 18842 '\u0225': 'z', 18843 '\u0240': 'z', 18844 '\u2C6C': 'z', 18845 '\uA763': 'z', 18846 '\u0386': '\u0391', 18847 '\u0388': '\u0395', 18848 '\u0389': '\u0397', 18849 '\u038A': '\u0399', 18850 '\u03AA': '\u0399', 18851 '\u038C': '\u039F', 18852 '\u038E': '\u03A5', 18853 '\u03AB': '\u03A5', 18854 '\u038F': '\u03A9', 18855 '\u03AC': '\u03B1', 18856 '\u03AD': '\u03B5', 18857 '\u03AE': '\u03B7', 18858 '\u03AF': '\u03B9', 18859 '\u03CA': '\u03B9', 18860 '\u0390': '\u03B9', 18861 '\u03CC': '\u03BF', 18862 '\u03CD': '\u03C5', 18863 '\u03CB': '\u03C5', 18864 '\u03B0': '\u03C5', 18865 '\u03CE': '\u03C9', 18866 '\u03C2': '\u03C3', 18867 '\u2019': '\'' 18868 }; 18869 18870 return diacritics; 18871}); 18872 18873S2.define('select2/data/base',[ 18874 '../utils' 18875], function (Utils) { 18876 function BaseAdapter ($element, options) { 18877 BaseAdapter.__super__.constructor.call(this); 18878 } 18879 18880 Utils.Extend(BaseAdapter, Utils.Observable); 18881 18882 BaseAdapter.prototype.current = function (callback) { 18883 throw new Error('The `current` method must be defined in child classes.'); 18884 }; 18885 18886 BaseAdapter.prototype.query = function (params, callback) { 18887 throw new Error('The `query` method must be defined in child classes.'); 18888 }; 18889 18890 BaseAdapter.prototype.bind = function (container, $container) { 18891 // Can be implemented in subclasses 18892 }; 18893 18894 BaseAdapter.prototype.destroy = function () { 18895 // Can be implemented in subclasses 18896 }; 18897 18898 BaseAdapter.prototype.generateResultId = function (container, data) { 18899 var id = container.id + '-result-'; 18900 18901 id += Utils.generateChars(4); 18902 18903 if (data.id != null) { 18904 id += '-' + data.id.toString(); 18905 } else { 18906 id += '-' + Utils.generateChars(4); 18907 } 18908 return id; 18909 }; 18910 18911 return BaseAdapter; 18912}); 18913 18914S2.define('select2/data/select',[ 18915 './base', 18916 '../utils', 18917 'jquery' 18918], function (BaseAdapter, Utils, $) { 18919 function SelectAdapter ($element, options) { 18920 this.$element = $element; 18921 this.options = options; 18922 18923 SelectAdapter.__super__.constructor.call(this); 18924 } 18925 18926 Utils.Extend(SelectAdapter, BaseAdapter); 18927 18928 SelectAdapter.prototype.current = function (callback) { 18929 var data = []; 18930 var self = this; 18931 18932 this.$element.find(':selected').each(function () { 18933 var $option = $(this); 18934 18935 var option = self.item($option); 18936 18937 data.push(option); 18938 }); 18939 18940 callback(data); 18941 }; 18942 18943 SelectAdapter.prototype.select = function (data) { 18944 var self = this; 18945 18946 data.selected = true; 18947 18948 // If data.element is a DOM node, use it instead 18949 if ($(data.element).is('option')) { 18950 data.element.selected = true; 18951 18952 this.$element.trigger('input').trigger('change'); 18953 18954 return; 18955 } 18956 18957 if (this.$element.prop('multiple')) { 18958 this.current(function (currentData) { 18959 var val = []; 18960 18961 data = [data]; 18962 data.push.apply(data, currentData); 18963 18964 for (var d = 0; d < data.length; d++) { 18965 var id = data[d].id; 18966 18967 if ($.inArray(id, val) === -1) { 18968 val.push(id); 18969 } 18970 } 18971 18972 self.$element.val(val); 18973 self.$element.trigger('input').trigger('change'); 18974 }); 18975 } else { 18976 var val = data.id; 18977 18978 this.$element.val(val); 18979 this.$element.trigger('input').trigger('change'); 18980 } 18981 }; 18982 18983 SelectAdapter.prototype.unselect = function (data) { 18984 var self = this; 18985 18986 if (!this.$element.prop('multiple')) { 18987 return; 18988 } 18989 18990 data.selected = false; 18991 18992 if ($(data.element).is('option')) { 18993 data.element.selected = false; 18994 18995 this.$element.trigger('input').trigger('change'); 18996 18997 return; 18998 } 18999 19000 this.current(function (currentData) { 19001 var val = []; 19002 19003 for (var d = 0; d < currentData.length; d++) { 19004 var id = currentData[d].id; 19005 19006 if (id !== data.id && $.inArray(id, val) === -1) { 19007 val.push(id); 19008 } 19009 } 19010 19011 self.$element.val(val); 19012 19013 self.$element.trigger('input').trigger('change'); 19014 }); 19015 }; 19016 19017 SelectAdapter.prototype.bind = function (container, $container) { 19018 var self = this; 19019 19020 this.container = container; 19021 19022 container.on('select', function (params) { 19023 self.select(params.data); 19024 }); 19025 19026 container.on('unselect', function (params) { 19027 self.unselect(params.data); 19028 }); 19029 }; 19030 19031 SelectAdapter.prototype.destroy = function () { 19032 // Remove anything added to child elements 19033 this.$element.find('*').each(function () { 19034 // Remove any custom data set by Select2 19035 Utils.RemoveData(this); 19036 }); 19037 }; 19038 19039 SelectAdapter.prototype.query = function (params, callback) { 19040 var data = []; 19041 var self = this; 19042 19043 var $options = this.$element.children(); 19044 19045 $options.each(function () { 19046 var $option = $(this); 19047 19048 if (!$option.is('option') && !$option.is('optgroup')) { 19049 return; 19050 } 19051 19052 var option = self.item($option); 19053 19054 var matches = self.matches(params, option); 19055 19056 if (matches !== null) { 19057 data.push(matches); 19058 } 19059 }); 19060 19061 callback({ 19062 results: data 19063 }); 19064 }; 19065 19066 SelectAdapter.prototype.addOptions = function ($options) { 19067 Utils.appendMany(this.$element, $options); 19068 }; 19069 19070 SelectAdapter.prototype.option = function (data) { 19071 var option; 19072 19073 if (data.children) { 19074 option = document.createElement('optgroup'); 19075 option.label = data.text; 19076 } else { 19077 option = document.createElement('option'); 19078 19079 if (option.textContent !== undefined) { 19080 option.textContent = data.text; 19081 } else { 19082 option.innerText = data.text; 19083 } 19084 } 19085 19086 if (data.id !== undefined) { 19087 option.value = data.id; 19088 } 19089 19090 if (data.disabled) { 19091 option.disabled = true; 19092 } 19093 19094 if (data.selected) { 19095 option.selected = true; 19096 } 19097 19098 if (data.title) { 19099 option.title = data.title; 19100 } 19101 19102 var $option = $(option); 19103 19104 var normalizedData = this._normalizeItem(data); 19105 normalizedData.element = option; 19106 19107 // Override the option's data with the combined data 19108 Utils.StoreData(option, 'data', normalizedData); 19109 19110 return $option; 19111 }; 19112 19113 SelectAdapter.prototype.item = function ($option) { 19114 var data = {}; 19115 19116 data = Utils.GetData($option[0], 'data'); 19117 19118 if (data != null) { 19119 return data; 19120 } 19121 19122 if ($option.is('option')) { 19123 data = { 19124 id: $option.val(), 19125 text: $option.text(), 19126 disabled: $option.prop('disabled'), 19127 selected: $option.prop('selected'), 19128 title: $option.prop('title') 19129 }; 19130 } else if ($option.is('optgroup')) { 19131 data = { 19132 text: $option.prop('label'), 19133 children: [], 19134 title: $option.prop('title') 19135 }; 19136 19137 var $children = $option.children('option'); 19138 var children = []; 19139 19140 for (var c = 0; c < $children.length; c++) { 19141 var $child = $($children[c]); 19142 19143 var child = this.item($child); 19144 19145 children.push(child); 19146 } 19147 19148 data.children = children; 19149 } 19150 19151 data = this._normalizeItem(data); 19152 data.element = $option[0]; 19153 19154 Utils.StoreData($option[0], 'data', data); 19155 19156 return data; 19157 }; 19158 19159 SelectAdapter.prototype._normalizeItem = function (item) { 19160 if (item !== Object(item)) { 19161 item = { 19162 id: item, 19163 text: item 19164 }; 19165 } 19166 19167 item = $.extend({}, { 19168 text: '' 19169 }, item); 19170 19171 var defaults = { 19172 selected: false, 19173 disabled: false 19174 }; 19175 19176 if (item.id != null) { 19177 item.id = item.id.toString(); 19178 } 19179 19180 if (item.text != null) { 19181 item.text = item.text.toString(); 19182 } 19183 19184 if (item._resultId == null && item.id && this.container != null) { 19185 item._resultId = this.generateResultId(this.container, item); 19186 } 19187 19188 return $.extend({}, defaults, item); 19189 }; 19190 19191 SelectAdapter.prototype.matches = function (params, data) { 19192 var matcher = this.options.get('matcher'); 19193 19194 return matcher(params, data); 19195 }; 19196 19197 return SelectAdapter; 19198}); 19199 19200S2.define('select2/data/array',[ 19201 './select', 19202 '../utils', 19203 'jquery' 19204], function (SelectAdapter, Utils, $) { 19205 function ArrayAdapter ($element, options) { 19206 this._dataToConvert = options.get('data') || []; 19207 19208 ArrayAdapter.__super__.constructor.call(this, $element, options); 19209 } 19210 19211 Utils.Extend(ArrayAdapter, SelectAdapter); 19212 19213 ArrayAdapter.prototype.bind = function (container, $container) { 19214 ArrayAdapter.__super__.bind.call(this, container, $container); 19215 19216 this.addOptions(this.convertToOptions(this._dataToConvert)); 19217 }; 19218 19219 ArrayAdapter.prototype.select = function (data) { 19220 var $option = this.$element.find('option').filter(function (i, elm) { 19221 return elm.value == data.id.toString(); 19222 }); 19223 19224 if ($option.length === 0) { 19225 $option = this.option(data); 19226 19227 this.addOptions($option); 19228 } 19229 19230 ArrayAdapter.__super__.select.call(this, data); 19231 }; 19232 19233 ArrayAdapter.prototype.convertToOptions = function (data) { 19234 var self = this; 19235 19236 var $existing = this.$element.find('option'); 19237 var existingIds = $existing.map(function () { 19238 return self.item($(this)).id; 19239 }).get(); 19240 19241 var $options = []; 19242 19243 // Filter out all items except for the one passed in the argument 19244 function onlyItem (item) { 19245 return function () { 19246 return $(this).val() == item.id; 19247 }; 19248 } 19249 19250 for (var d = 0; d < data.length; d++) { 19251 var item = this._normalizeItem(data[d]); 19252 19253 // Skip items which were pre-loaded, only merge the data 19254 if ($.inArray(item.id, existingIds) >= 0) { 19255 var $existingOption = $existing.filter(onlyItem(item)); 19256 19257 var existingData = this.item($existingOption); 19258 var newData = $.extend(true, {}, item, existingData); 19259 19260 var $newOption = this.option(newData); 19261 19262 $existingOption.replaceWith($newOption); 19263 19264 continue; 19265 } 19266 19267 var $option = this.option(item); 19268 19269 if (item.children) { 19270 var $children = this.convertToOptions(item.children); 19271 19272 Utils.appendMany($option, $children); 19273 } 19274 19275 $options.push($option); 19276 } 19277 19278 return $options; 19279 }; 19280 19281 return ArrayAdapter; 19282}); 19283 19284S2.define('select2/data/ajax',[ 19285 './array', 19286 '../utils', 19287 'jquery' 19288], function (ArrayAdapter, Utils, $) { 19289 function AjaxAdapter ($element, options) { 19290 this.ajaxOptions = this._applyDefaults(options.get('ajax')); 19291 19292 if (this.ajaxOptions.processResults != null) { 19293 this.processResults = this.ajaxOptions.processResults; 19294 } 19295 19296 AjaxAdapter.__super__.constructor.call(this, $element, options); 19297 } 19298 19299 Utils.Extend(AjaxAdapter, ArrayAdapter); 19300 19301 AjaxAdapter.prototype._applyDefaults = function (options) { 19302 var defaults = { 19303 data: function (params) { 19304 return $.extend({}, params, { 19305 q: params.term 19306 }); 19307 }, 19308 transport: function (params, success, failure) { 19309 var $request = $.ajax(params); 19310 19311 $request.then(success); 19312 $request.fail(failure); 19313 19314 return $request; 19315 } 19316 }; 19317 19318 return $.extend({}, defaults, options, true); 19319 }; 19320 19321 AjaxAdapter.prototype.processResults = function (results) { 19322 return results; 19323 }; 19324 19325 AjaxAdapter.prototype.query = function (params, callback) { 19326 var matches = []; 19327 var self = this; 19328 19329 if (this._request != null) { 19330 // JSONP requests cannot always be aborted 19331 if ($.isFunction(this._request.abort)) { 19332 this._request.abort(); 19333 } 19334 19335 this._request = null; 19336 } 19337 19338 var options = $.extend({ 19339 type: 'GET' 19340 }, this.ajaxOptions); 19341 19342 if (typeof options.url === 'function') { 19343 options.url = options.url.call(this.$element, params); 19344 } 19345 19346 if (typeof options.data === 'function') { 19347 options.data = options.data.call(this.$element, params); 19348 } 19349 19350 function request () { 19351 var $request = options.transport(options, function (data) { 19352 var results = self.processResults(data, params); 19353 19354 if (self.options.get('debug') && window.console && console.error) { 19355 // Check to make sure that the response included a `results` key. 19356 if (!results || !results.results || !$.isArray(results.results)) { 19357 console.error( 19358 'Select2: The AJAX results did not return an array in the ' + 19359 '`results` key of the response.' 19360 ); 19361 } 19362 } 19363 19364 callback(results); 19365 }, function () { 19366 // Attempt to detect if a request was aborted 19367 // Only works if the transport exposes a status property 19368 if ('status' in $request && 19369 ($request.status === 0 || $request.status === '0')) { 19370 return; 19371 } 19372 19373 self.trigger('results:message', { 19374 message: 'errorLoading' 19375 }); 19376 }); 19377 19378 self._request = $request; 19379 } 19380 19381 if (this.ajaxOptions.delay && params.term != null) { 19382 if (this._queryTimeout) { 19383 window.clearTimeout(this._queryTimeout); 19384 } 19385 19386 this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay); 19387 } else { 19388 request(); 19389 } 19390 }; 19391 19392 return AjaxAdapter; 19393}); 19394 19395S2.define('select2/data/tags',[ 19396 'jquery' 19397], function ($) { 19398 function Tags (decorated, $element, options) { 19399 var tags = options.get('tags'); 19400 19401 var createTag = options.get('createTag'); 19402 19403 if (createTag !== undefined) { 19404 this.createTag = createTag; 19405 } 19406 19407 var insertTag = options.get('insertTag'); 19408 19409 if (insertTag !== undefined) { 19410 this.insertTag = insertTag; 19411 } 19412 19413 decorated.call(this, $element, options); 19414 19415 if ($.isArray(tags)) { 19416 for (var t = 0; t < tags.length; t++) { 19417 var tag = tags[t]; 19418 var item = this._normalizeItem(tag); 19419 19420 var $option = this.option(item); 19421 19422 this.$element.append($option); 19423 } 19424 } 19425 } 19426 19427 Tags.prototype.query = function (decorated, params, callback) { 19428 var self = this; 19429 19430 this._removeOldTags(); 19431 19432 if (params.term == null || params.page != null) { 19433 decorated.call(this, params, callback); 19434 return; 19435 } 19436 19437 function wrapper (obj, child) { 19438 var data = obj.results; 19439 19440 for (var i = 0; i < data.length; i++) { 19441 var option = data[i]; 19442 19443 var checkChildren = ( 19444 option.children != null && 19445 !wrapper({ 19446 results: option.children 19447 }, true) 19448 ); 19449 19450 var optionText = (option.text || '').toUpperCase(); 19451 var paramsTerm = (params.term || '').toUpperCase(); 19452 19453 var checkText = optionText === paramsTerm; 19454 19455 if (checkText || checkChildren) { 19456 if (child) { 19457 return false; 19458 } 19459 19460 obj.data = data; 19461 callback(obj); 19462 19463 return; 19464 } 19465 } 19466 19467 if (child) { 19468 return true; 19469 } 19470 19471 var tag = self.createTag(params); 19472 19473 if (tag != null) { 19474 var $option = self.option(tag); 19475 $option.attr('data-select2-tag', true); 19476 19477 self.addOptions([$option]); 19478 19479 self.insertTag(data, tag); 19480 } 19481 19482 obj.results = data; 19483 19484 callback(obj); 19485 } 19486 19487 decorated.call(this, params, wrapper); 19488 }; 19489 19490 Tags.prototype.createTag = function (decorated, params) { 19491 var term = $.trim(params.term); 19492 19493 if (term === '') { 19494 return null; 19495 } 19496 19497 return { 19498 id: term, 19499 text: term 19500 }; 19501 }; 19502 19503 Tags.prototype.insertTag = function (_, data, tag) { 19504 data.unshift(tag); 19505 }; 19506 19507 Tags.prototype._removeOldTags = function (_) { 19508 var $options = this.$element.find('option[data-select2-tag]'); 19509 19510 $options.each(function () { 19511 if (this.selected) { 19512 return; 19513 } 19514 19515 $(this).remove(); 19516 }); 19517 }; 19518 19519 return Tags; 19520}); 19521 19522S2.define('select2/data/tokenizer',[ 19523 'jquery' 19524], function ($) { 19525 function Tokenizer (decorated, $element, options) { 19526 var tokenizer = options.get('tokenizer'); 19527 19528 if (tokenizer !== undefined) { 19529 this.tokenizer = tokenizer; 19530 } 19531 19532 decorated.call(this, $element, options); 19533 } 19534 19535 Tokenizer.prototype.bind = function (decorated, container, $container) { 19536 decorated.call(this, container, $container); 19537 19538 this.$search = container.dropdown.$search || container.selection.$search || 19539 $container.find('.select2-search__field'); 19540 }; 19541 19542 Tokenizer.prototype.query = function (decorated, params, callback) { 19543 var self = this; 19544 19545 function createAndSelect (data) { 19546 // Normalize the data object so we can use it for checks 19547 var item = self._normalizeItem(data); 19548 19549 // Check if the data object already exists as a tag 19550 // Select it if it doesn't 19551 var $existingOptions = self.$element.find('option').filter(function () { 19552 return $(this).val() === item.id; 19553 }); 19554 19555 // If an existing option wasn't found for it, create the option 19556 if (!$existingOptions.length) { 19557 var $option = self.option(item); 19558 $option.attr('data-select2-tag', true); 19559 19560 self._removeOldTags(); 19561 self.addOptions([$option]); 19562 } 19563 19564 // Select the item, now that we know there is an option for it 19565 select(item); 19566 } 19567 19568 function select (data) { 19569 self.trigger('select', { 19570 data: data 19571 }); 19572 } 19573 19574 params.term = params.term || ''; 19575 19576 var tokenData = this.tokenizer(params, this.options, createAndSelect); 19577 19578 if (tokenData.term !== params.term) { 19579 // Replace the search term if we have the search box 19580 if (this.$search.length) { 19581 this.$search.val(tokenData.term); 19582 this.$search.trigger('focus'); 19583 } 19584 19585 params.term = tokenData.term; 19586 } 19587 19588 decorated.call(this, params, callback); 19589 }; 19590 19591 Tokenizer.prototype.tokenizer = function (_, params, options, callback) { 19592 var separators = options.get('tokenSeparators') || []; 19593 var term = params.term; 19594 var i = 0; 19595 19596 var createTag = this.createTag || function (params) { 19597 return { 19598 id: params.term, 19599 text: params.term 19600 }; 19601 }; 19602 19603 while (i < term.length) { 19604 var termChar = term[i]; 19605 19606 if ($.inArray(termChar, separators) === -1) { 19607 i++; 19608 19609 continue; 19610 } 19611 19612 var part = term.substr(0, i); 19613 var partParams = $.extend({}, params, { 19614 term: part 19615 }); 19616 19617 var data = createTag(partParams); 19618 19619 if (data == null) { 19620 i++; 19621 continue; 19622 } 19623 19624 callback(data); 19625 19626 // Reset the term to not include the tokenized portion 19627 term = term.substr(i + 1) || ''; 19628 i = 0; 19629 } 19630 19631 return { 19632 term: term 19633 }; 19634 }; 19635 19636 return Tokenizer; 19637}); 19638 19639S2.define('select2/data/minimumInputLength',[ 19640 19641], function () { 19642 function MinimumInputLength (decorated, $e, options) { 19643 this.minimumInputLength = options.get('minimumInputLength'); 19644 19645 decorated.call(this, $e, options); 19646 } 19647 19648 MinimumInputLength.prototype.query = function (decorated, params, callback) { 19649 params.term = params.term || ''; 19650 19651 if (params.term.length < this.minimumInputLength) { 19652 this.trigger('results:message', { 19653 message: 'inputTooShort', 19654 args: { 19655 minimum: this.minimumInputLength, 19656 input: params.term, 19657 params: params 19658 } 19659 }); 19660 19661 return; 19662 } 19663 19664 decorated.call(this, params, callback); 19665 }; 19666 19667 return MinimumInputLength; 19668}); 19669 19670S2.define('select2/data/maximumInputLength',[ 19671 19672], function () { 19673 function MaximumInputLength (decorated, $e, options) { 19674 this.maximumInputLength = options.get('maximumInputLength'); 19675 19676 decorated.call(this, $e, options); 19677 } 19678 19679 MaximumInputLength.prototype.query = function (decorated, params, callback) { 19680 params.term = params.term || ''; 19681 19682 if (this.maximumInputLength > 0 && 19683 params.term.length > this.maximumInputLength) { 19684 this.trigger('results:message', { 19685 message: 'inputTooLong', 19686 args: { 19687 maximum: this.maximumInputLength, 19688 input: params.term, 19689 params: params 19690 } 19691 }); 19692 19693 return; 19694 } 19695 19696 decorated.call(this, params, callback); 19697 }; 19698 19699 return MaximumInputLength; 19700}); 19701 19702S2.define('select2/data/maximumSelectionLength',[ 19703 19704], function (){ 19705 function MaximumSelectionLength (decorated, $e, options) { 19706 this.maximumSelectionLength = options.get('maximumSelectionLength'); 19707 19708 decorated.call(this, $e, options); 19709 } 19710 19711 MaximumSelectionLength.prototype.bind = 19712 function (decorated, container, $container) { 19713 var self = this; 19714 19715 decorated.call(this, container, $container); 19716 19717 container.on('select', function () { 19718 self._checkIfMaximumSelected(); 19719 }); 19720 }; 19721 19722 MaximumSelectionLength.prototype.query = 19723 function (decorated, params, callback) { 19724 var self = this; 19725 19726 this._checkIfMaximumSelected(function () { 19727 decorated.call(self, params, callback); 19728 }); 19729 }; 19730 19731 MaximumSelectionLength.prototype._checkIfMaximumSelected = 19732 function (_, successCallback) { 19733 var self = this; 19734 19735 this.current(function (currentData) { 19736 var count = currentData != null ? currentData.length : 0; 19737 if (self.maximumSelectionLength > 0 && 19738 count >= self.maximumSelectionLength) { 19739 self.trigger('results:message', { 19740 message: 'maximumSelected', 19741 args: { 19742 maximum: self.maximumSelectionLength 19743 } 19744 }); 19745 return; 19746 } 19747 19748 if (successCallback) { 19749 successCallback(); 19750 } 19751 }); 19752 }; 19753 19754 return MaximumSelectionLength; 19755}); 19756 19757S2.define('select2/dropdown',[ 19758 'jquery', 19759 './utils' 19760], function ($, Utils) { 19761 function Dropdown ($element, options) { 19762 this.$element = $element; 19763 this.options = options; 19764 19765 Dropdown.__super__.constructor.call(this); 19766 } 19767 19768 Utils.Extend(Dropdown, Utils.Observable); 19769 19770 Dropdown.prototype.render = function () { 19771 var $dropdown = $( 19772 '<span class="select2-dropdown">' + 19773 '<span class="select2-results"></span>' + 19774 '</span>' 19775 ); 19776 19777 $dropdown.attr('dir', this.options.get('dir')); 19778 19779 this.$dropdown = $dropdown; 19780 19781 return $dropdown; 19782 }; 19783 19784 Dropdown.prototype.bind = function () { 19785 // Should be implemented in subclasses 19786 }; 19787 19788 Dropdown.prototype.position = function ($dropdown, $container) { 19789 // Should be implemented in subclasses 19790 }; 19791 19792 Dropdown.prototype.destroy = function () { 19793 // Remove the dropdown from the DOM 19794 this.$dropdown.remove(); 19795 }; 19796 19797 return Dropdown; 19798}); 19799 19800S2.define('select2/dropdown/search',[ 19801 'jquery', 19802 '../utils' 19803], function ($, Utils) { 19804 function Search () { } 19805 19806 Search.prototype.render = function (decorated) { 19807 var $rendered = decorated.call(this); 19808 19809 var $search = $( 19810 '<span class="select2-search select2-search--dropdown">' + 19811 '<input class="select2-search__field" type="search" tabindex="-1"' + 19812 ' autocomplete="off" autocorrect="off" autocapitalize="none"' + 19813 ' spellcheck="false" role="searchbox" aria-autocomplete="list" />' + 19814 '</span>' 19815 ); 19816 19817 this.$searchContainer = $search; 19818 this.$search = $search.find('input'); 19819 19820 $rendered.prepend($search); 19821 19822 return $rendered; 19823 }; 19824 19825 Search.prototype.bind = function (decorated, container, $container) { 19826 var self = this; 19827 19828 var resultsId = container.id + '-results'; 19829 19830 decorated.call(this, container, $container); 19831 19832 this.$search.on('keydown', function (evt) { 19833 self.trigger('keypress', evt); 19834 19835 self._keyUpPrevented = evt.isDefaultPrevented(); 19836 }); 19837 19838 // Workaround for browsers which do not support the `input` event 19839 // This will prevent double-triggering of events for browsers which support 19840 // both the `keyup` and `input` events. 19841 this.$search.on('input', function (evt) { 19842 // Unbind the duplicated `keyup` event 19843 $(this).off('keyup'); 19844 }); 19845 19846 this.$search.on('keyup input', function (evt) { 19847 self.handleSearch(evt); 19848 }); 19849 19850 container.on('open', function () { 19851 self.$search.attr('tabindex', 0); 19852 self.$search.attr('aria-controls', resultsId); 19853 19854 self.$search.trigger('focus'); 19855 19856 window.setTimeout(function () { 19857 self.$search.trigger('focus'); 19858 }, 0); 19859 }); 19860 19861 container.on('close', function () { 19862 self.$search.attr('tabindex', -1); 19863 self.$search.removeAttr('aria-controls'); 19864 self.$search.removeAttr('aria-activedescendant'); 19865 19866 self.$search.val(''); 19867 self.$search.trigger('blur'); 19868 }); 19869 19870 container.on('focus', function () { 19871 if (!container.isOpen()) { 19872 self.$search.trigger('focus'); 19873 } 19874 }); 19875 19876 container.on('results:all', function (params) { 19877 if (params.query.term == null || params.query.term === '') { 19878 var showSearch = self.showSearch(params); 19879 19880 if (showSearch) { 19881 self.$searchContainer.removeClass('select2-search--hide'); 19882 } else { 19883 self.$searchContainer.addClass('select2-search--hide'); 19884 } 19885 } 19886 }); 19887 19888 container.on('results:focus', function (params) { 19889 if (params.data._resultId) { 19890 self.$search.attr('aria-activedescendant', params.data._resultId); 19891 } else { 19892 self.$search.removeAttr('aria-activedescendant'); 19893 } 19894 }); 19895 }; 19896 19897 Search.prototype.handleSearch = function (evt) { 19898 if (!this._keyUpPrevented) { 19899 var input = this.$search.val(); 19900 19901 this.trigger('query', { 19902 term: input 19903 }); 19904 } 19905 19906 this._keyUpPrevented = false; 19907 }; 19908 19909 Search.prototype.showSearch = function (_, params) { 19910 return true; 19911 }; 19912 19913 return Search; 19914}); 19915 19916S2.define('select2/dropdown/hidePlaceholder',[ 19917 19918], function () { 19919 function HidePlaceholder (decorated, $element, options, dataAdapter) { 19920 this.placeholder = this.normalizePlaceholder(options.get('placeholder')); 19921 19922 decorated.call(this, $element, options, dataAdapter); 19923 } 19924 19925 HidePlaceholder.prototype.append = function (decorated, data) { 19926 data.results = this.removePlaceholder(data.results); 19927 19928 decorated.call(this, data); 19929 }; 19930 19931 HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) { 19932 if (typeof placeholder === 'string') { 19933 placeholder = { 19934 id: '', 19935 text: placeholder 19936 }; 19937 } 19938 19939 return placeholder; 19940 }; 19941 19942 HidePlaceholder.prototype.removePlaceholder = function (_, data) { 19943 var modifiedData = data.slice(0); 19944 19945 for (var d = data.length - 1; d >= 0; d--) { 19946 var item = data[d]; 19947 19948 if (this.placeholder.id === item.id) { 19949 modifiedData.splice(d, 1); 19950 } 19951 } 19952 19953 return modifiedData; 19954 }; 19955 19956 return HidePlaceholder; 19957}); 19958 19959S2.define('select2/dropdown/infiniteScroll',[ 19960 'jquery' 19961], function ($) { 19962 function InfiniteScroll (decorated, $element, options, dataAdapter) { 19963 this.lastParams = {}; 19964 19965 decorated.call(this, $element, options, dataAdapter); 19966 19967 this.$loadingMore = this.createLoadingMore(); 19968 this.loading = false; 19969 } 19970 19971 InfiniteScroll.prototype.append = function (decorated, data) { 19972 this.$loadingMore.remove(); 19973 this.loading = false; 19974 19975 decorated.call(this, data); 19976 19977 if (this.showLoadingMore(data)) { 19978 this.$results.append(this.$loadingMore); 19979 this.loadMoreIfNeeded(); 19980 } 19981 }; 19982 19983 InfiniteScroll.prototype.bind = function (decorated, container, $container) { 19984 var self = this; 19985 19986 decorated.call(this, container, $container); 19987 19988 container.on('query', function (params) { 19989 self.lastParams = params; 19990 self.loading = true; 19991 }); 19992 19993 container.on('query:append', function (params) { 19994 self.lastParams = params; 19995 self.loading = true; 19996 }); 19997 19998 this.$results.on('scroll', this.loadMoreIfNeeded.bind(this)); 19999 }; 20000 20001 InfiniteScroll.prototype.loadMoreIfNeeded = function () { 20002 var isLoadMoreVisible = $.contains( 20003 document.documentElement, 20004 this.$loadingMore[0] 20005 ); 20006 20007 if (this.loading || !isLoadMoreVisible) { 20008 return; 20009 } 20010 20011 var currentOffset = this.$results.offset().top + 20012 this.$results.outerHeight(false); 20013 var loadingMoreOffset = this.$loadingMore.offset().top + 20014 this.$loadingMore.outerHeight(false); 20015 20016 if (currentOffset + 50 >= loadingMoreOffset) { 20017 this.loadMore(); 20018 } 20019 }; 20020 20021 InfiniteScroll.prototype.loadMore = function () { 20022 this.loading = true; 20023 20024 var params = $.extend({}, {page: 1}, this.lastParams); 20025 20026 params.page++; 20027 20028 this.trigger('query:append', params); 20029 }; 20030 20031 InfiniteScroll.prototype.showLoadingMore = function (_, data) { 20032 return data.pagination && data.pagination.more; 20033 }; 20034 20035 InfiniteScroll.prototype.createLoadingMore = function () { 20036 var $option = $( 20037 '<li ' + 20038 'class="select2-results__option select2-results__option--load-more"' + 20039 'role="option" aria-disabled="true"></li>' 20040 ); 20041 20042 var message = this.options.get('translations').get('loadingMore'); 20043 20044 $option.html(message(this.lastParams)); 20045 20046 return $option; 20047 }; 20048 20049 return InfiniteScroll; 20050}); 20051 20052S2.define('select2/dropdown/attachBody',[ 20053 'jquery', 20054 '../utils' 20055], function ($, Utils) { 20056 function AttachBody (decorated, $element, options) { 20057 this.$dropdownParent = $(options.get('dropdownParent') || document.body); 20058 20059 decorated.call(this, $element, options); 20060 } 20061 20062 AttachBody.prototype.bind = function (decorated, container, $container) { 20063 var self = this; 20064 20065 decorated.call(this, container, $container); 20066 20067 container.on('open', function () { 20068 self._showDropdown(); 20069 self._attachPositioningHandler(container); 20070 20071 // Must bind after the results handlers to ensure correct sizing 20072 self._bindContainerResultHandlers(container); 20073 }); 20074 20075 container.on('close', function () { 20076 self._hideDropdown(); 20077 self._detachPositioningHandler(container); 20078 }); 20079 20080 this.$dropdownContainer.on('mousedown', function (evt) { 20081 evt.stopPropagation(); 20082 }); 20083 }; 20084 20085 AttachBody.prototype.destroy = function (decorated) { 20086 decorated.call(this); 20087 20088 this.$dropdownContainer.remove(); 20089 }; 20090 20091 AttachBody.prototype.position = function (decorated, $dropdown, $container) { 20092 // Clone all of the container classes 20093 $dropdown.attr('class', $container.attr('class')); 20094 20095 $dropdown.removeClass('select2'); 20096 $dropdown.addClass('select2-container--open'); 20097 20098 $dropdown.css({ 20099 position: 'absolute', 20100 top: -999999 20101 }); 20102 20103 this.$container = $container; 20104 }; 20105 20106 AttachBody.prototype.render = function (decorated) { 20107 var $container = $('<span></span>'); 20108 20109 var $dropdown = decorated.call(this); 20110 $container.append($dropdown); 20111 20112 this.$dropdownContainer = $container; 20113 20114 return $container; 20115 }; 20116 20117 AttachBody.prototype._hideDropdown = function (decorated) { 20118 this.$dropdownContainer.detach(); 20119 }; 20120 20121 AttachBody.prototype._bindContainerResultHandlers = 20122 function (decorated, container) { 20123 20124 // These should only be bound once 20125 if (this._containerResultsHandlersBound) { 20126 return; 20127 } 20128 20129 var self = this; 20130 20131 container.on('results:all', function () { 20132 self._positionDropdown(); 20133 self._resizeDropdown(); 20134 }); 20135 20136 container.on('results:append', function () { 20137 self._positionDropdown(); 20138 self._resizeDropdown(); 20139 }); 20140 20141 container.on('results:message', function () { 20142 self._positionDropdown(); 20143 self._resizeDropdown(); 20144 }); 20145 20146 container.on('select', function () { 20147 self._positionDropdown(); 20148 self._resizeDropdown(); 20149 }); 20150 20151 container.on('unselect', function () { 20152 self._positionDropdown(); 20153 self._resizeDropdown(); 20154 }); 20155 20156 this._containerResultsHandlersBound = true; 20157 }; 20158 20159 AttachBody.prototype._attachPositioningHandler = 20160 function (decorated, container) { 20161 var self = this; 20162 20163 var scrollEvent = 'scroll.select2.' + container.id; 20164 var resizeEvent = 'resize.select2.' + container.id; 20165 var orientationEvent = 'orientationchange.select2.' + container.id; 20166 20167 var $watchers = this.$container.parents().filter(Utils.hasScroll); 20168 $watchers.each(function () { 20169 Utils.StoreData(this, 'select2-scroll-position', { 20170 x: $(this).scrollLeft(), 20171 y: $(this).scrollTop() 20172 }); 20173 }); 20174 20175 $watchers.on(scrollEvent, function (ev) { 20176 var position = Utils.GetData(this, 'select2-scroll-position'); 20177 $(this).scrollTop(position.y); 20178 }); 20179 20180 $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent, 20181 function (e) { 20182 self._positionDropdown(); 20183 self._resizeDropdown(); 20184 }); 20185 }; 20186 20187 AttachBody.prototype._detachPositioningHandler = 20188 function (decorated, container) { 20189 var scrollEvent = 'scroll.select2.' + container.id; 20190 var resizeEvent = 'resize.select2.' + container.id; 20191 var orientationEvent = 'orientationchange.select2.' + container.id; 20192 20193 var $watchers = this.$container.parents().filter(Utils.hasScroll); 20194 $watchers.off(scrollEvent); 20195 20196 $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent); 20197 }; 20198 20199 AttachBody.prototype._positionDropdown = function () { 20200 var $window = $(window); 20201 20202 var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above'); 20203 var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below'); 20204 20205 var newDirection = null; 20206 20207 var offset = this.$container.offset(); 20208 20209 offset.bottom = offset.top + this.$container.outerHeight(false); 20210 20211 var container = { 20212 height: this.$container.outerHeight(false) 20213 }; 20214 20215 container.top = offset.top; 20216 container.bottom = offset.top + container.height; 20217 20218 var dropdown = { 20219 height: this.$dropdown.outerHeight(false) 20220 }; 20221 20222 var viewport = { 20223 top: $window.scrollTop(), 20224 bottom: $window.scrollTop() + $window.height() 20225 }; 20226 20227 var enoughRoomAbove = viewport.top < (offset.top - dropdown.height); 20228 var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height); 20229 20230 var css = { 20231 left: offset.left, 20232 top: container.bottom 20233 }; 20234 20235 // Determine what the parent element is to use for calculating the offset 20236 var $offsetParent = this.$dropdownParent; 20237 20238 // For statically positioned elements, we need to get the element 20239 // that is determining the offset 20240 if ($offsetParent.css('position') === 'static') { 20241 $offsetParent = $offsetParent.offsetParent(); 20242 } 20243 20244 var parentOffset = { 20245 top: 0, 20246 left: 0 20247 }; 20248 20249 if ( 20250 $.contains(document.body, $offsetParent[0]) || 20251 $offsetParent[0].isConnected 20252 ) { 20253 parentOffset = $offsetParent.offset(); 20254 } 20255 20256 css.top -= parentOffset.top; 20257 css.left -= parentOffset.left; 20258 20259 if (!isCurrentlyAbove && !isCurrentlyBelow) { 20260 newDirection = 'below'; 20261 } 20262 20263 if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) { 20264 newDirection = 'above'; 20265 } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) { 20266 newDirection = 'below'; 20267 } 20268 20269 if (newDirection == 'above' || 20270 (isCurrentlyAbove && newDirection !== 'below')) { 20271 css.top = container.top - parentOffset.top - dropdown.height; 20272 } 20273 20274 if (newDirection != null) { 20275 this.$dropdown 20276 .removeClass('select2-dropdown--below select2-dropdown--above') 20277 .addClass('select2-dropdown--' + newDirection); 20278 this.$container 20279 .removeClass('select2-container--below select2-container--above') 20280 .addClass('select2-container--' + newDirection); 20281 } 20282 20283 this.$dropdownContainer.css(css); 20284 }; 20285 20286 AttachBody.prototype._resizeDropdown = function () { 20287 var css = { 20288 width: this.$container.outerWidth(false) + 'px' 20289 }; 20290 20291 if (this.options.get('dropdownAutoWidth')) { 20292 css.minWidth = css.width; 20293 css.position = 'relative'; 20294 css.width = 'auto'; 20295 } 20296 20297 this.$dropdown.css(css); 20298 }; 20299 20300 AttachBody.prototype._showDropdown = function (decorated) { 20301 this.$dropdownContainer.appendTo(this.$dropdownParent); 20302 20303 this._positionDropdown(); 20304 this._resizeDropdown(); 20305 }; 20306 20307 return AttachBody; 20308}); 20309 20310S2.define('select2/dropdown/minimumResultsForSearch',[ 20311 20312], function () { 20313 function countResults (data) { 20314 var count = 0; 20315 20316 for (var d = 0; d < data.length; d++) { 20317 var item = data[d]; 20318 20319 if (item.children) { 20320 count += countResults(item.children); 20321 } else { 20322 count++; 20323 } 20324 } 20325 20326 return count; 20327 } 20328 20329 function MinimumResultsForSearch (decorated, $element, options, dataAdapter) { 20330 this.minimumResultsForSearch = options.get('minimumResultsForSearch'); 20331 20332 if (this.minimumResultsForSearch < 0) { 20333 this.minimumResultsForSearch = Infinity; 20334 } 20335 20336 decorated.call(this, $element, options, dataAdapter); 20337 } 20338 20339 MinimumResultsForSearch.prototype.showSearch = function (decorated, params) { 20340 if (countResults(params.data.results) < this.minimumResultsForSearch) { 20341 return false; 20342 } 20343 20344 return decorated.call(this, params); 20345 }; 20346 20347 return MinimumResultsForSearch; 20348}); 20349 20350S2.define('select2/dropdown/selectOnClose',[ 20351 '../utils' 20352], function (Utils) { 20353 function SelectOnClose () { } 20354 20355 SelectOnClose.prototype.bind = function (decorated, container, $container) { 20356 var self = this; 20357 20358 decorated.call(this, container, $container); 20359 20360 container.on('close', function (params) { 20361 self._handleSelectOnClose(params); 20362 }); 20363 }; 20364 20365 SelectOnClose.prototype._handleSelectOnClose = function (_, params) { 20366 if (params && params.originalSelect2Event != null) { 20367 var event = params.originalSelect2Event; 20368 20369 // Don't select an item if the close event was triggered from a select or 20370 // unselect event 20371 if (event._type === 'select' || event._type === 'unselect') { 20372 return; 20373 } 20374 } 20375 20376 var $highlightedResults = this.getHighlightedResults(); 20377 20378 // Only select highlighted results 20379 if ($highlightedResults.length < 1) { 20380 return; 20381 } 20382 20383 var data = Utils.GetData($highlightedResults[0], 'data'); 20384 20385 // Don't re-select already selected resulte 20386 if ( 20387 (data.element != null && data.element.selected) || 20388 (data.element == null && data.selected) 20389 ) { 20390 return; 20391 } 20392 20393 this.trigger('select', { 20394 data: data 20395 }); 20396 }; 20397 20398 return SelectOnClose; 20399}); 20400 20401S2.define('select2/dropdown/closeOnSelect',[ 20402 20403], function () { 20404 function CloseOnSelect () { } 20405 20406 CloseOnSelect.prototype.bind = function (decorated, container, $container) { 20407 var self = this; 20408 20409 decorated.call(this, container, $container); 20410 20411 container.on('select', function (evt) { 20412 self._selectTriggered(evt); 20413 }); 20414 20415 container.on('unselect', function (evt) { 20416 self._selectTriggered(evt); 20417 }); 20418 }; 20419 20420 CloseOnSelect.prototype._selectTriggered = function (_, evt) { 20421 var originalEvent = evt.originalEvent; 20422 20423 // Don't close if the control key is being held 20424 if (originalEvent && (originalEvent.ctrlKey || originalEvent.metaKey)) { 20425 return; 20426 } 20427 20428 this.trigger('close', { 20429 originalEvent: originalEvent, 20430 originalSelect2Event: evt 20431 }); 20432 }; 20433 20434 return CloseOnSelect; 20435}); 20436 20437S2.define('select2/i18n/en',[],function () { 20438 // English 20439 return { 20440 errorLoading: function () { 20441 return 'The results could not be loaded.'; 20442 }, 20443 inputTooLong: function (args) { 20444 var overChars = args.input.length - args.maximum; 20445 20446 var message = 'Please delete ' + overChars + ' character'; 20447 20448 if (overChars != 1) { 20449 message += 's'; 20450 } 20451 20452 return message; 20453 }, 20454 inputTooShort: function (args) { 20455 var remainingChars = args.minimum - args.input.length; 20456 20457 var message = 'Please enter ' + remainingChars + ' or more characters'; 20458 20459 return message; 20460 }, 20461 loadingMore: function () { 20462 return 'Loading more results…'; 20463 }, 20464 maximumSelected: function (args) { 20465 var message = 'You can only select ' + args.maximum + ' item'; 20466 20467 if (args.maximum != 1) { 20468 message += 's'; 20469 } 20470 20471 return message; 20472 }, 20473 noResults: function () { 20474 return 'No results found'; 20475 }, 20476 searching: function () { 20477 return 'Searching…'; 20478 }, 20479 removeAllItems: function () { 20480 return 'Remove all items'; 20481 } 20482 }; 20483}); 20484 20485S2.define('select2/defaults',[ 20486 'jquery', 20487 'require', 20488 20489 './results', 20490 20491 './selection/single', 20492 './selection/multiple', 20493 './selection/placeholder', 20494 './selection/allowClear', 20495 './selection/search', 20496 './selection/eventRelay', 20497 20498 './utils', 20499 './translation', 20500 './diacritics', 20501 20502 './data/select', 20503 './data/array', 20504 './data/ajax', 20505 './data/tags', 20506 './data/tokenizer', 20507 './data/minimumInputLength', 20508 './data/maximumInputLength', 20509 './data/maximumSelectionLength', 20510 20511 './dropdown', 20512 './dropdown/search', 20513 './dropdown/hidePlaceholder', 20514 './dropdown/infiniteScroll', 20515 './dropdown/attachBody', 20516 './dropdown/minimumResultsForSearch', 20517 './dropdown/selectOnClose', 20518 './dropdown/closeOnSelect', 20519 20520 './i18n/en' 20521], function ($, require, 20522 20523 ResultsList, 20524 20525 SingleSelection, MultipleSelection, Placeholder, AllowClear, 20526 SelectionSearch, EventRelay, 20527 20528 Utils, Translation, DIACRITICS, 20529 20530 SelectData, ArrayData, AjaxData, Tags, Tokenizer, 20531 MinimumInputLength, MaximumInputLength, MaximumSelectionLength, 20532 20533 Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll, 20534 AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect, 20535 20536 EnglishTranslation) { 20537 function Defaults () { 20538 this.reset(); 20539 } 20540 20541 Defaults.prototype.apply = function (options) { 20542 options = $.extend(true, {}, this.defaults, options); 20543 20544 if (options.dataAdapter == null) { 20545 if (options.ajax != null) { 20546 options.dataAdapter = AjaxData; 20547 } else if (options.data != null) { 20548 options.dataAdapter = ArrayData; 20549 } else { 20550 options.dataAdapter = SelectData; 20551 } 20552 20553 if (options.minimumInputLength > 0) { 20554 options.dataAdapter = Utils.Decorate( 20555 options.dataAdapter, 20556 MinimumInputLength 20557 ); 20558 } 20559 20560 if (options.maximumInputLength > 0) { 20561 options.dataAdapter = Utils.Decorate( 20562 options.dataAdapter, 20563 MaximumInputLength 20564 ); 20565 } 20566 20567 if (options.maximumSelectionLength > 0) { 20568 options.dataAdapter = Utils.Decorate( 20569 options.dataAdapter, 20570 MaximumSelectionLength 20571 ); 20572 } 20573 20574 if (options.tags) { 20575 options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags); 20576 } 20577 20578 if (options.tokenSeparators != null || options.tokenizer != null) { 20579 options.dataAdapter = Utils.Decorate( 20580 options.dataAdapter, 20581 Tokenizer 20582 ); 20583 } 20584 20585 if (options.query != null) { 20586 var Query = require(options.amdBase + 'compat/query'); 20587 20588 options.dataAdapter = Utils.Decorate( 20589 options.dataAdapter, 20590 Query 20591 ); 20592 } 20593 20594 if (options.initSelection != null) { 20595 var InitSelection = require(options.amdBase + 'compat/initSelection'); 20596 20597 options.dataAdapter = Utils.Decorate( 20598 options.dataAdapter, 20599 InitSelection 20600 ); 20601 } 20602 } 20603 20604 if (options.resultsAdapter == null) { 20605 options.resultsAdapter = ResultsList; 20606 20607 if (options.ajax != null) { 20608 options.resultsAdapter = Utils.Decorate( 20609 options.resultsAdapter, 20610 InfiniteScroll 20611 ); 20612 } 20613 20614 if (options.placeholder != null) { 20615 options.resultsAdapter = Utils.Decorate( 20616 options.resultsAdapter, 20617 HidePlaceholder 20618 ); 20619 } 20620 20621 if (options.selectOnClose) { 20622 options.resultsAdapter = Utils.Decorate( 20623 options.resultsAdapter, 20624 SelectOnClose 20625 ); 20626 } 20627 } 20628 20629 if (options.dropdownAdapter == null) { 20630 if (options.multiple) { 20631 options.dropdownAdapter = Dropdown; 20632 } else { 20633 var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch); 20634 20635 options.dropdownAdapter = SearchableDropdown; 20636 } 20637 20638 if (options.minimumResultsForSearch !== 0) { 20639 options.dropdownAdapter = Utils.Decorate( 20640 options.dropdownAdapter, 20641 MinimumResultsForSearch 20642 ); 20643 } 20644 20645 if (options.closeOnSelect) { 20646 options.dropdownAdapter = Utils.Decorate( 20647 options.dropdownAdapter, 20648 CloseOnSelect 20649 ); 20650 } 20651 20652 if ( 20653 options.dropdownCssClass != null || 20654 options.dropdownCss != null || 20655 options.adaptDropdownCssClass != null 20656 ) { 20657 var DropdownCSS = require(options.amdBase + 'compat/dropdownCss'); 20658 20659 options.dropdownAdapter = Utils.Decorate( 20660 options.dropdownAdapter, 20661 DropdownCSS 20662 ); 20663 } 20664 20665 options.dropdownAdapter = Utils.Decorate( 20666 options.dropdownAdapter, 20667 AttachBody 20668 ); 20669 } 20670 20671 if (options.selectionAdapter == null) { 20672 if (options.multiple) { 20673 options.selectionAdapter = MultipleSelection; 20674 } else { 20675 options.selectionAdapter = SingleSelection; 20676 } 20677 20678 // Add the placeholder mixin if a placeholder was specified 20679 if (options.placeholder != null) { 20680 options.selectionAdapter = Utils.Decorate( 20681 options.selectionAdapter, 20682 Placeholder 20683 ); 20684 } 20685 20686 if (options.allowClear) { 20687 options.selectionAdapter = Utils.Decorate( 20688 options.selectionAdapter, 20689 AllowClear 20690 ); 20691 } 20692 20693 if (options.multiple) { 20694 options.selectionAdapter = Utils.Decorate( 20695 options.selectionAdapter, 20696 SelectionSearch 20697 ); 20698 } 20699 20700 if ( 20701 options.containerCssClass != null || 20702 options.containerCss != null || 20703 options.adaptContainerCssClass != null 20704 ) { 20705 var ContainerCSS = require(options.amdBase + 'compat/containerCss'); 20706 20707 options.selectionAdapter = Utils.Decorate( 20708 options.selectionAdapter, 20709 ContainerCSS 20710 ); 20711 } 20712 20713 options.selectionAdapter = Utils.Decorate( 20714 options.selectionAdapter, 20715 EventRelay 20716 ); 20717 } 20718 20719 // If the defaults were not previously applied from an element, it is 20720 // possible for the language option to have not been resolved 20721 options.language = this._resolveLanguage(options.language); 20722 20723 // Always fall back to English since it will always be complete 20724 options.language.push('en'); 20725 20726 var uniqueLanguages = []; 20727 20728 for (var l = 0; l < options.language.length; l++) { 20729 var language = options.language[l]; 20730 20731 if (uniqueLanguages.indexOf(language) === -1) { 20732 uniqueLanguages.push(language); 20733 } 20734 } 20735 20736 options.language = uniqueLanguages; 20737 20738 options.translations = this._processTranslations( 20739 options.language, 20740 options.debug 20741 ); 20742 20743 return options; 20744 }; 20745 20746 Defaults.prototype.reset = function () { 20747 function stripDiacritics (text) { 20748 // Used 'uni range + named function' from http://jsperf.com/diacritics/18 20749 function match(a) { 20750 return DIACRITICS[a] || a; 20751 } 20752 20753 return text.replace(/[^\u0000-\u007E]/g, match); 20754 } 20755 20756 function matcher (params, data) { 20757 // Always return the object if there is nothing to compare 20758 if ($.trim(params.term) === '') { 20759 return data; 20760 } 20761 20762 // Do a recursive check for options with children 20763 if (data.children && data.children.length > 0) { 20764 // Clone the data object if there are children 20765 // This is required as we modify the object to remove any non-matches 20766 var match = $.extend(true, {}, data); 20767 20768 // Check each child of the option 20769 for (var c = data.children.length - 1; c >= 0; c--) { 20770 var child = data.children[c]; 20771 20772 var matches = matcher(params, child); 20773 20774 // If there wasn't a match, remove the object in the array 20775 if (matches == null) { 20776 match.children.splice(c, 1); 20777 } 20778 } 20779 20780 // If any children matched, return the new object 20781 if (match.children.length > 0) { 20782 return match; 20783 } 20784 20785 // If there were no matching children, check just the plain object 20786 return matcher(params, match); 20787 } 20788 20789 var original = stripDiacritics(data.text).toUpperCase(); 20790 var term = stripDiacritics(params.term).toUpperCase(); 20791 20792 // Check if the text contains the term 20793 if (original.indexOf(term) > -1) { 20794 return data; 20795 } 20796 20797 // If it doesn't contain the term, don't return anything 20798 return null; 20799 } 20800 20801 this.defaults = { 20802 amdBase: './', 20803 amdLanguageBase: './i18n/', 20804 closeOnSelect: true, 20805 debug: false, 20806 dropdownAutoWidth: false, 20807 escapeMarkup: Utils.escapeMarkup, 20808 language: {}, 20809 matcher: matcher, 20810 minimumInputLength: 0, 20811 maximumInputLength: 0, 20812 maximumSelectionLength: 0, 20813 minimumResultsForSearch: 0, 20814 selectOnClose: false, 20815 scrollAfterSelect: false, 20816 sorter: function (data) { 20817 return data; 20818 }, 20819 templateResult: function (result) { 20820 return result.text; 20821 }, 20822 templateSelection: function (selection) { 20823 return selection.text; 20824 }, 20825 theme: 'default', 20826 width: 'resolve' 20827 }; 20828 }; 20829 20830 Defaults.prototype.applyFromElement = function (options, $element) { 20831 var optionLanguage = options.language; 20832 var defaultLanguage = this.defaults.language; 20833 var elementLanguage = $element.prop('lang'); 20834 var parentLanguage = $element.closest('[lang]').prop('lang'); 20835 20836 var languages = Array.prototype.concat.call( 20837 this._resolveLanguage(elementLanguage), 20838 this._resolveLanguage(optionLanguage), 20839 this._resolveLanguage(defaultLanguage), 20840 this._resolveLanguage(parentLanguage) 20841 ); 20842 20843 options.language = languages; 20844 20845 return options; 20846 }; 20847 20848 Defaults.prototype._resolveLanguage = function (language) { 20849 if (!language) { 20850 return []; 20851 } 20852 20853 if ($.isEmptyObject(language)) { 20854 return []; 20855 } 20856 20857 if ($.isPlainObject(language)) { 20858 return [language]; 20859 } 20860 20861 var languages; 20862 20863 if (!$.isArray(language)) { 20864 languages = [language]; 20865 } else { 20866 languages = language; 20867 } 20868 20869 var resolvedLanguages = []; 20870 20871 for (var l = 0; l < languages.length; l++) { 20872 resolvedLanguages.push(languages[l]); 20873 20874 if (typeof languages[l] === 'string' && languages[l].indexOf('-') > 0) { 20875 // Extract the region information if it is included 20876 var languageParts = languages[l].split('-'); 20877 var baseLanguage = languageParts[0]; 20878 20879 resolvedLanguages.push(baseLanguage); 20880 } 20881 } 20882 20883 return resolvedLanguages; 20884 }; 20885 20886 Defaults.prototype._processTranslations = function (languages, debug) { 20887 var translations = new Translation(); 20888 20889 for (var l = 0; l < languages.length; l++) { 20890 var languageData = new Translation(); 20891 20892 var language = languages[l]; 20893 20894 if (typeof language === 'string') { 20895 try { 20896 // Try to load it with the original name 20897 languageData = Translation.loadPath(language); 20898 } catch (e) { 20899 try { 20900 // If we couldn't load it, check if it wasn't the full path 20901 language = this.defaults.amdLanguageBase + language; 20902 languageData = Translation.loadPath(language); 20903 } catch (ex) { 20904 // The translation could not be loaded at all. Sometimes this is 20905 // because of a configuration problem, other times this can be 20906 // because of how Select2 helps load all possible translation files 20907 if (debug && window.console && console.warn) { 20908 console.warn( 20909 'Select2: The language file for "' + language + '" could ' + 20910 'not be automatically loaded. A fallback will be used instead.' 20911 ); 20912 } 20913 } 20914 } 20915 } else if ($.isPlainObject(language)) { 20916 languageData = new Translation(language); 20917 } else { 20918 languageData = language; 20919 } 20920 20921 translations.extend(languageData); 20922 } 20923 20924 return translations; 20925 }; 20926 20927 Defaults.prototype.set = function (key, value) { 20928 var camelKey = $.camelCase(key); 20929 20930 var data = {}; 20931 data[camelKey] = value; 20932 20933 var convertedData = Utils._convertData(data); 20934 20935 $.extend(true, this.defaults, convertedData); 20936 }; 20937 20938 var defaults = new Defaults(); 20939 20940 return defaults; 20941}); 20942 20943S2.define('select2/options',[ 20944 'require', 20945 'jquery', 20946 './defaults', 20947 './utils' 20948], function (require, $, Defaults, Utils) { 20949 function Options (options, $element) { 20950 this.options = options; 20951 20952 if ($element != null) { 20953 this.fromElement($element); 20954 } 20955 20956 if ($element != null) { 20957 this.options = Defaults.applyFromElement(this.options, $element); 20958 } 20959 20960 this.options = Defaults.apply(this.options); 20961 20962 if ($element && $element.is('input')) { 20963 var InputCompat = require(this.get('amdBase') + 'compat/inputData'); 20964 20965 this.options.dataAdapter = Utils.Decorate( 20966 this.options.dataAdapter, 20967 InputCompat 20968 ); 20969 } 20970 } 20971 20972 Options.prototype.fromElement = function ($e) { 20973 var excludedData = ['select2']; 20974 20975 if (this.options.multiple == null) { 20976 this.options.multiple = $e.prop('multiple'); 20977 } 20978 20979 if (this.options.disabled == null) { 20980 this.options.disabled = $e.prop('disabled'); 20981 } 20982 20983 if (this.options.dir == null) { 20984 if ($e.prop('dir')) { 20985 this.options.dir = $e.prop('dir'); 20986 } else if ($e.closest('[dir]').prop('dir')) { 20987 this.options.dir = $e.closest('[dir]').prop('dir'); 20988 } else { 20989 this.options.dir = 'ltr'; 20990 } 20991 } 20992 20993 $e.prop('disabled', this.options.disabled); 20994 $e.prop('multiple', this.options.multiple); 20995 20996 if (Utils.GetData($e[0], 'select2Tags')) { 20997 if (this.options.debug && window.console && console.warn) { 20998 console.warn( 20999 'Select2: The `data-select2-tags` attribute has been changed to ' + 21000 'use the `data-data` and `data-tags="true"` attributes and will be ' + 21001 'removed in future versions of Select2.' 21002 ); 21003 } 21004 21005 Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags')); 21006 Utils.StoreData($e[0], 'tags', true); 21007 } 21008 21009 if (Utils.GetData($e[0], 'ajaxUrl')) { 21010 if (this.options.debug && window.console && console.warn) { 21011 console.warn( 21012 'Select2: The `data-ajax-url` attribute has been changed to ' + 21013 '`data-ajax--url` and support for the old attribute will be removed' + 21014 ' in future versions of Select2.' 21015 ); 21016 } 21017 21018 $e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl')); 21019 Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl')); 21020 } 21021 21022 var dataset = {}; 21023 21024 function upperCaseLetter(_, letter) { 21025 return letter.toUpperCase(); 21026 } 21027 21028 // Pre-load all of the attributes which are prefixed with `data-` 21029 for (var attr = 0; attr < $e[0].attributes.length; attr++) { 21030 var attributeName = $e[0].attributes[attr].name; 21031 var prefix = 'data-'; 21032 21033 if (attributeName.substr(0, prefix.length) == prefix) { 21034 // Get the contents of the attribute after `data-` 21035 var dataName = attributeName.substring(prefix.length); 21036 21037 // Get the data contents from the consistent source 21038 // This is more than likely the jQuery data helper 21039 var dataValue = Utils.GetData($e[0], dataName); 21040 21041 // camelCase the attribute name to match the spec 21042 var camelDataName = dataName.replace(/-([a-z])/g, upperCaseLetter); 21043 21044 // Store the data attribute contents into the dataset since 21045 dataset[camelDataName] = dataValue; 21046 } 21047 } 21048 21049 // Prefer the element's `dataset` attribute if it exists 21050 // jQuery 1.x does not correctly handle data attributes with multiple dashes 21051 if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) { 21052 dataset = $.extend(true, {}, $e[0].dataset, dataset); 21053 } 21054 21055 // Prefer our internal data cache if it exists 21056 var data = $.extend(true, {}, Utils.GetData($e[0]), dataset); 21057 21058 data = Utils._convertData(data); 21059 21060 for (var key in data) { 21061 if ($.inArray(key, excludedData) > -1) { 21062 continue; 21063 } 21064 21065 if ($.isPlainObject(this.options[key])) { 21066 $.extend(this.options[key], data[key]); 21067 } else { 21068 this.options[key] = data[key]; 21069 } 21070 } 21071 21072 return this; 21073 }; 21074 21075 Options.prototype.get = function (key) { 21076 return this.options[key]; 21077 }; 21078 21079 Options.prototype.set = function (key, val) { 21080 this.options[key] = val; 21081 }; 21082 21083 return Options; 21084}); 21085 21086S2.define('select2/core',[ 21087 'jquery', 21088 './options', 21089 './utils', 21090 './keys' 21091], function ($, Options, Utils, KEYS) { 21092 var Select2 = function ($element, options) { 21093 if (Utils.GetData($element[0], 'select2') != null) { 21094 Utils.GetData($element[0], 'select2').destroy(); 21095 } 21096 21097 this.$element = $element; 21098 21099 this.id = this._generateId($element); 21100 21101 options = options || {}; 21102 21103 this.options = new Options(options, $element); 21104 21105 Select2.__super__.constructor.call(this); 21106 21107 // Set up the tabindex 21108 21109 var tabindex = $element.attr('tabindex') || 0; 21110 Utils.StoreData($element[0], 'old-tabindex', tabindex); 21111 $element.attr('tabindex', '-1'); 21112 21113 // Set up containers and adapters 21114 21115 var DataAdapter = this.options.get('dataAdapter'); 21116 this.dataAdapter = new DataAdapter($element, this.options); 21117 21118 var $container = this.render(); 21119 21120 this._placeContainer($container); 21121 21122 var SelectionAdapter = this.options.get('selectionAdapter'); 21123 this.selection = new SelectionAdapter($element, this.options); 21124 this.$selection = this.selection.render(); 21125 21126 this.selection.position(this.$selection, $container); 21127 21128 var DropdownAdapter = this.options.get('dropdownAdapter'); 21129 this.dropdown = new DropdownAdapter($element, this.options); 21130 this.$dropdown = this.dropdown.render(); 21131 21132 this.dropdown.position(this.$dropdown, $container); 21133 21134 var ResultsAdapter = this.options.get('resultsAdapter'); 21135 this.results = new ResultsAdapter($element, this.options, this.dataAdapter); 21136 this.$results = this.results.render(); 21137 21138 this.results.position(this.$results, this.$dropdown); 21139 21140 // Bind events 21141 21142 var self = this; 21143 21144 // Bind the container to all of the adapters 21145 this._bindAdapters(); 21146 21147 // Register any DOM event handlers 21148 this._registerDomEvents(); 21149 21150 // Register any internal event handlers 21151 this._registerDataEvents(); 21152 this._registerSelectionEvents(); 21153 this._registerDropdownEvents(); 21154 this._registerResultsEvents(); 21155 this._registerEvents(); 21156 21157 // Set the initial state 21158 this.dataAdapter.current(function (initialData) { 21159 self.trigger('selection:update', { 21160 data: initialData 21161 }); 21162 }); 21163 21164 // Hide the original select 21165 $element.addClass('select2-hidden-accessible'); 21166 $element.attr('aria-hidden', 'true'); 21167 21168 // Synchronize any monitored attributes 21169 this._syncAttributes(); 21170 21171 Utils.StoreData($element[0], 'select2', this); 21172 21173 // Ensure backwards compatibility with $element.data('select2'). 21174 $element.data('select2', this); 21175 }; 21176 21177 Utils.Extend(Select2, Utils.Observable); 21178 21179 Select2.prototype._generateId = function ($element) { 21180 var id = ''; 21181 21182 if ($element.attr('id') != null) { 21183 id = $element.attr('id'); 21184 } else if ($element.attr('name') != null) { 21185 id = $element.attr('name') + '-' + Utils.generateChars(2); 21186 } else { 21187 id = Utils.generateChars(4); 21188 } 21189 21190 id = id.replace(/(:|\.|\[|\]|,)/g, ''); 21191 id = 'select2-' + id; 21192 21193 return id; 21194 }; 21195 21196 Select2.prototype._placeContainer = function ($container) { 21197 $container.insertAfter(this.$element); 21198 21199 var width = this._resolveWidth(this.$element, this.options.get('width')); 21200 21201 if (width != null) { 21202 $container.css('width', width); 21203 } 21204 }; 21205 21206 Select2.prototype._resolveWidth = function ($element, method) { 21207 var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i; 21208 21209 if (method == 'resolve') { 21210 var styleWidth = this._resolveWidth($element, 'style'); 21211 21212 if (styleWidth != null) { 21213 return styleWidth; 21214 } 21215 21216 return this._resolveWidth($element, 'element'); 21217 } 21218 21219 if (method == 'element') { 21220 var elementWidth = $element.outerWidth(false); 21221 21222 if (elementWidth <= 0) { 21223 return 'auto'; 21224 } 21225 21226 return elementWidth + 'px'; 21227 } 21228 21229 if (method == 'style') { 21230 var style = $element.attr('style'); 21231 21232 if (typeof(style) !== 'string') { 21233 return null; 21234 } 21235 21236 var attrs = style.split(';'); 21237 21238 for (var i = 0, l = attrs.length; i < l; i = i + 1) { 21239 var attr = attrs[i].replace(/\s/g, ''); 21240 var matches = attr.match(WIDTH); 21241 21242 if (matches !== null && matches.length >= 1) { 21243 return matches[1]; 21244 } 21245 } 21246 21247 return null; 21248 } 21249 21250 if (method == 'computedstyle') { 21251 var computedStyle = window.getComputedStyle($element[0]); 21252 21253 return computedStyle.width; 21254 } 21255 21256 return method; 21257 }; 21258 21259 Select2.prototype._bindAdapters = function () { 21260 this.dataAdapter.bind(this, this.$container); 21261 this.selection.bind(this, this.$container); 21262 21263 this.dropdown.bind(this, this.$container); 21264 this.results.bind(this, this.$container); 21265 }; 21266 21267 Select2.prototype._registerDomEvents = function () { 21268 var self = this; 21269 21270 this.$element.on('change.select2', function () { 21271 self.dataAdapter.current(function (data) { 21272 self.trigger('selection:update', { 21273 data: data 21274 }); 21275 }); 21276 }); 21277 21278 this.$element.on('focus.select2', function (evt) { 21279 self.trigger('focus', evt); 21280 }); 21281 21282 this._syncA = Utils.bind(this._syncAttributes, this); 21283 this._syncS = Utils.bind(this._syncSubtree, this); 21284 21285 if (this.$element[0].attachEvent) { 21286 this.$element[0].attachEvent('onpropertychange', this._syncA); 21287 } 21288 21289 var observer = window.MutationObserver || 21290 window.WebKitMutationObserver || 21291 window.MozMutationObserver 21292 ; 21293 21294 if (observer != null) { 21295 this._observer = new observer(function (mutations) { 21296 self._syncA(); 21297 self._syncS(null, mutations); 21298 }); 21299 this._observer.observe(this.$element[0], { 21300 attributes: true, 21301 childList: true, 21302 subtree: false 21303 }); 21304 } else if (this.$element[0].addEventListener) { 21305 this.$element[0].addEventListener( 21306 'DOMAttrModified', 21307 self._syncA, 21308 false 21309 ); 21310 this.$element[0].addEventListener( 21311 'DOMNodeInserted', 21312 self._syncS, 21313 false 21314 ); 21315 this.$element[0].addEventListener( 21316 'DOMNodeRemoved', 21317 self._syncS, 21318 false 21319 ); 21320 } 21321 }; 21322 21323 Select2.prototype._registerDataEvents = function () { 21324 var self = this; 21325 21326 this.dataAdapter.on('*', function (name, params) { 21327 self.trigger(name, params); 21328 }); 21329 }; 21330 21331 Select2.prototype._registerSelectionEvents = function () { 21332 var self = this; 21333 var nonRelayEvents = ['toggle', 'focus']; 21334 21335 this.selection.on('toggle', function () { 21336 self.toggleDropdown(); 21337 }); 21338 21339 this.selection.on('focus', function (params) { 21340 self.focus(params); 21341 }); 21342 21343 this.selection.on('*', function (name, params) { 21344 if ($.inArray(name, nonRelayEvents) !== -1) { 21345 return; 21346 } 21347 21348 self.trigger(name, params); 21349 }); 21350 }; 21351 21352 Select2.prototype._registerDropdownEvents = function () { 21353 var self = this; 21354 21355 this.dropdown.on('*', fu
21355nction (name, params) { 21356 self.trigger(name, params); 21357 }); 21358 }; 21359 21360 Select2.prototype._registerResultsEvents = function () { 21361 var self = this; 21362 21363 this.results.on('*', function (name, params) { 21364 self.trigger(name, params); 21365 }); 21366 }; 21367 21368 Select2.prototype._registerEvents = function () { 21369 var self = this; 21370 21371 this.on('open', function () { 21372 self.$container.addClass('select2-container--open'); 21373 }); 21374 21375 this.on('close', function () { 21376 self.$container.removeClass('select2-container--open'); 21377 }); 21378 21379 this.on('enable', function () { 21380 self.$container.removeClass('select2-container--disabled'); 21381 }); 21382 21383 this.on('disable', function () { 21384 self.$container.addClass('select2-container--disabled'); 21385 }); 21386 21387 this.on('blur', function () { 21388 self.$container.removeClass('select2-container--focus'); 21389 }); 21390 21391 this.on('query', function (params) { 21392 if (!self.isOpen()) { 21393 self.trigger('open', {}); 21394 } 21395 21396 this.dataAdapter.query(params, function (data) { 21397 self.trigger('results:all', { 21398 data: data, 21399 query: params 21400 }); 21401 }); 21402 }); 21403 21404 this.on('query:append', function (params) { 21405 this.dataAdapter.query(params, function (data) { 21406 self.trigger('results:append', { 21407 data: data, 21408 query: params 21409 }); 21410 }); 21411 }); 21412 21413 this.on('keypress', function (evt) { 21414 var key = evt.which; 21415 21416 if (self.isOpen()) { 21417 if (key === KEYS.ESC || key === KEYS.TAB || 21418 (key === KEYS.UP && evt.altKey)) { 21419 self.close(evt); 21420 21421 evt.preventDefault(); 21422 } else if (key === KEYS.ENTER) { 21423 self.trigger('results:select', {}); 21424 21425 evt.preventDefault(); 21426 } else if ((key === KEYS.SPACE && evt.ctrlKey)) { 21427 self.trigger('results:toggle', {}); 21428 21429 evt.preventDefault(); 21430 } else if (key === KEYS.UP) { 21431 self.trigger('results:previous', {}); 21432 21433 evt.preventDefault(); 21434 } else if (key === KEYS.DOWN) { 21435 self.trigger('results:next', {}); 21436 21437 evt.preventDefault(); 21438 } 21439 } else { 21440 if (key === KEYS.ENTER || key === KEYS.SPACE || 21441 (key === KEYS.DOWN && evt.altKey)) { 21442 self.open(); 21443 21444 evt.preventDefault(); 21445 } 21446 } 21447 }); 21448 }; 21449 21450 Select2.prototype._syncAttributes = function () { 21451 this.options.set('disabled', this.$element.prop('disabled')); 21452 21453 if (this.isDisabled()) { 21454 if (this.isOpen()) { 21455 this.close(); 21456 } 21457 21458 this.trigger('disable', {}); 21459 } else { 21460 this.trigger('enable', {}); 21461 } 21462 }; 21463 21464 Select2.prototype._isChangeMutation = function (evt, mutations) { 21465 var changed = false; 21466 var self = this; 21467 21468 // Ignore any mutation events raised for elements that aren't options or 21469 // optgroups. This handles the case when the select element is destroyed 21470 if ( 21471 evt && evt.target && ( 21472 evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP' 21473 ) 21474 ) { 21475 return; 21476 } 21477 21478 if (!mutations) { 21479 // If mutation events aren't supported, then we can only assume that the 21480 // change affected the selections 21481 changed = true; 21482 } else if (mutations.addedNodes && mutations.addedNodes.length > 0) { 21483 for (var n = 0; n < mutations.addedNodes.length; n++) { 21484 var node = mutations.addedNodes[n]; 21485 21486 if (node.selected) { 21487 changed = true; 21488 } 21489 } 21490 } else if (mutations.removedNodes && mutations.removedNodes.length > 0) { 21491 changed = true; 21492 } else if ($.isArray(mutations)) { 21493 $.each(mutations, function(evt, mutation) { 21494 if (self._isChangeMutation(evt, mutation)) { 21495 // We've found a change mutation. 21496 // Let's escape from the loop and continue 21497 changed = true; 21498 return false; 21499 } 21500 }); 21501 } 21502 return changed; 21503 }; 21504 21505 Select2.prototype._syncSubtree = function (evt, mutations) { 21506 var changed = this._isChangeMutation(evt, mutations); 21507 var self = this; 21508 21509 // Only re-pull the data if we think there is a change 21510 if (changed) { 21511 this.dataAdapter.current(function (currentData) { 21512 self.trigger('selection:update', { 21513 data: currentData 21514 }); 21515 }); 21516 } 21517 }; 21518 21519 /** 21520 * Override the trigger method to automatically trigger pre-events when 21521 * there are events that can be prevented. 21522 */ 21523 Select2.prototype.trigger = function (name, args) { 21524 var actualTrigger = Select2.__super__.trigger; 21525 var preTriggerMap = { 21526 'open': 'opening', 21527 'close': 'closing', 21528 'select': 'selecting', 21529 'unselect': 'unselecting', 21530 'clear': 'clearing' 21531 }; 21532 21533 if (args === undefined) { 21534 args = {}; 21535 } 21536 21537 if (name in preTriggerMap) { 21538 var preTriggerName = preTriggerMap[name]; 21539 var preTriggerArgs = { 21540 prevented: false, 21541 name: name, 21542 args: args 21543 }; 21544 21545 actualTrigger.call(this, preTriggerName, preTriggerArgs); 21546 21547 if (preTriggerArgs.prevented) { 21548 args.prevented = true; 21549 21550 return; 21551 } 21552 } 21553 21554 actualTrigger.call(this, name, args); 21555 }; 21556 21557 Select2.prototype.toggleDropdown = function () { 21558 if (this.isDisabled()) { 21559 return; 21560 } 21561 21562 if (this.isOpen()) { 21563 this.close(); 21564 } else { 21565 this.open(); 21566 } 21567 }; 21568 21569 Select2.prototype.open = function () { 21570 if (this.isOpen()) { 21571 return; 21572 } 21573 21574 if (this.isDisabled()) { 21575 return; 21576 } 21577 21578 this.trigger('query', {}); 21579 }; 21580 21581 Select2.prototype.close = function (evt) { 21582 if (!this.isOpen()) { 21583 return; 21584 } 21585 21586 this.trigger('close', { originalEvent : evt }); 21587 }; 21588 21589 /** 21590 * Helper method to abstract the "enabled" (not "disabled") state of this 21591 * object. 21592 * 21593 * @return {true} if the instance is not disabled. 21594 * @return {false} if the instance is disabled. 21595 */ 21596 Select2.prototype.isEnabled = function () { 21597 return !this.isDisabled(); 21598 }; 21599 21600 /** 21601 * Helper method to abstract the "disabled" state of this object. 21602 * 21603 * @return {true} if the disabled option is true. 21604 * @return {false} if the disabled option is false. 21605 */ 21606 Select2.prototype.isDisabled = function () { 21607 return this.options.get('disabled'); 21608 }; 21609 21610 Select2.prototype.isOpen = function () { 21611 return this.$container.hasClass('select2-container--open'); 21612 }; 21613 21614 Select2.prototype.hasFocus = function () { 21615 return this.$container.hasClass('select2-container--focus'); 21616 }; 21617
21618 Select2.prototype.focus = function (data) { 21619 // No need to re-trigger focus events if we are already focused 21620 if (this.hasFocus()) { 21621 return; 21622 } 21623 21624 this.$container.addClass('select2-container--focus'); 21625 this.trigger('focus', {}); 21626 }; 21627 21628 Select2.prototype.enable = function (args) { 21629 if (this.options.get('debug') && window.console && console.warn) { 21630 console.warn( 21631 'Select2: The `select2("enable")` method has been deprecated and will' + 21632 ' be removed in later Select2 versions. Use $element.prop("disabled")' + 21633 ' instead.' 21634 ); 21635 } 21636 21637 if (args == null || args.length === 0) { 21638 args = [true]; 21639 } 21640 21641 var disabled = !args[0]; 21642 21643 this.$element.prop('disabled', disabled); 21644 }; 21645 21646 Select2.prototype.data = function () { 21647 if (this.options.get('debug') && 21648 arguments.length > 0 && window.console && console.warn) { 21649 console.warn( 21650 'Select2: Data can no longer be set using `select2("data")`. You ' + 21651 'should consider setting the value instead using `$element.val()`.' 21652 ); 21653 } 21654 21655 var data = []; 21656 21657 this.dataAdapter.current(function (currentData) { 21658 data = currentData; 21659 }); 21660 21661 return data; 21662 }; 21663 21664 Select2.prototype.val = function (args) { 21665 if (this.options.get('debug') && window.console && console.warn) { 21666 console.warn( 21667 'Select2: The `select2("val")` method has been deprecated and will be' + 21668 ' removed in later Select2 versions. Use $element.val() instead.' 21669 ); 21670 } 21671 21672 if (args == null || args.length === 0) { 21673 return this.$element.val(); 21674 } 21675 21676 var newVal = args[0]; 21677 21678 if ($.isArray(newVal)) { 21679 newVal = $.map(newVal, function (obj) { 21680 return obj.toString(); 21681 }); 21682 } 21683 21684 this.$element.val(newVal).trigger('input').trigger('change'); 21685 }; 21686 21687 Select2.prototype.destroy = function () { 21688 this.$container.remove(); 21689 21690 if (this.$element[0].detachEvent) { 21691 this.$element[0].detachEvent('onpropertychange', this._syncA); 21692 } 21693 21694 if (this._observer != null) { 21695 this._observer.disconnect(); 21696 this._observer = null; 21697 } else if (this.$element[0].removeEventListener) { 21698 this.$element[0] 21699 .removeEventListener('DOMAttrModified', this._syncA, false); 21700 this.$element[0] 21701 .removeEventListener('DOMNodeInserted', this._syncS, false); 21702 this.$element[0] 21703 .removeEventListener('DOMNodeRemoved', this._syncS, false); 21704 } 21705 21706 this._syncA = null; 21707 this._syncS = null; 21708 21709 this.$element.off('.select2'); 21710 this.$element.attr('tabindex', 21711 Utils.GetData(this.$element[0], 'old-tabindex')); 21712 21713 this.$element.removeClass('select2-hidden-accessible'); 21714 this.$element.attr('aria-hidden', 'false'); 21715 Utils.RemoveData(this.$element[0]); 21716 this.$element.removeData('select2'); 21717 21718 this.dataAdapter.destroy(); 21719 this.selection.destroy(); 21720 this.dropdown.destroy(); 21721 this.results.destroy(); 21722 21723 this.dataAdapter = null; 21724 this.selection = null; 21725 this.dropdown = null; 21726 this.results = null; 21727 }; 21728 21729 Select2.prototype.render = function () { 21730 var $container = $( 21731 '<span class="select2 select2-container">' + 21732 '<span class="selection"></span>' + 21733 '<span class="dropdown-wrapper" aria-hidden="true"></span>' + 21734 '</span>' 21735 ); 21736 21737 $container.attr('dir', this.options.get('dir')); 21738 21739 this.$container = $container; 21740 21741 this.$container.addClass('select2-container--' + this.options.get('theme')); 21742 21743 Utils.StoreData($container[0], 'element', this.$element); 21744 21745 return $container; 21746 }; 21747 21748 return Select2; 21749}); 21750 21751S2.define('jquery-mousewheel',[ 21752 'jquery' 21753], function ($) { 21754 // Used to shim jQuery.mousewheel for non-full builds. 21755 return $; 21756}); 21757 21758S2.define('jquery.select2',[ 21759 'jquery', 21760 'jquery-mousewheel', 21761 21762 './select2/core', 21763 './select2/defaults', 21764 './select2/utils' 21765], function ($, _, Select2, Defaults, Utils) { 21766 if ($.fn.select2 == null) { 21767 // All methods that should return the element 21768 var thisMethods = ['open', 'close', 'destroy']; 21769 21770 $.fn.select2 = function (options) { 21771 options = options || {}; 21772 21773 if (typeof options === 'object') { 21774 this.each(function () { 21775 var instanceOptions = $.extend(true, {}, options); 21776 21777 var instance = new Select2($(this), instanceOptions); 21778 }); 21779 21780 return this; 21781 } else if (typeof options === 'string') { 21782 var ret; 21783 var args = Array.prototype.slice.call(arguments, 1); 21784 21785 this.each(function () { 21786 var instance = Utils.GetData(this, 'select2'); 21787 21788 if (instance == null && window.console && console.error) { 21789 console.error( 21790 'The select2(\'' + options + '\') method was called on an ' + 21791 'element that is not using Select2.' 21792 ); 21793 } 21794 21795 ret = instance[options].apply(instance, args); 21796 }); 21797 21798 // Check if we should be returning `this` 21799 if ($.inArray(options, thisMethods) > -1) { 21800 return this; 21801 } 21802 21803 return ret; 21804 } else { 21805 throw new Error('Invalid arguments for Select2: ' + options); 21806 } 21807 }; 21808 } 21809 21810 if ($.fn.select2.defaults == null) { 21811 $.fn.select2.defaults = Defaults; 21812 } 21813 21814 return Select2; 21815}); 21816 21817 // Return the AMD loader configuration so it can be used outside of this file 21818 return { 21819 define: S2.define, 21820 require: S2.require 21821 }; 21822}()); 21823 21824 // Autoload the jQuery bindings 21825 // We know that all of the modules exist above this, so we're safe 21826 var select2 = S2.require('jquery.select2'); 21827 21828 // Hold the AMD module references on the jQuery function that was just loaded 21829 // This allows Select2 to use the internal loader outside of this file, such 21830 // as in the language files. 21831 jQuery.fn.select2.amd = S2; 21832 21833 // Return the Select2 instance for anyone who is importing it. 21834 return select2; 21835})); 21836/* 21837Trix 1.3.1 21838Copyright © 2020 Basecamp, LLC 21839http://trix-editor.org/ 21840 */ 21841(function(){}).call(this),function(){var t;null==window.Set&&(window.Set=t=function(){function t(){this.clear()}return t.prototype.clear=function(){return this.values=[]},t.prototype.has=function(t){return-1!==this.values.indexOf(t)},t.prototype.add=function(t){return this.has(t)||this.values.push(t),this},t.prototype["delete"]=function(t){var e;return-1===(e=this.values.indexOf(t))?!1:(this.values.splice(e,1),!0)},t.prototype.forEach=function(){var t;
21841return(t=this.values).forEach.apply(t,arguments)},t}())}.call(this),function(t){function e(){}function n(t,e){return function(){t.apply(e,arguments)}}function i(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],c(t,this)}function o(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void h(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?r:s)(e.promise,t._value);var i;try{i=n(t._value)}catch(o){return void s(e.promise,o)}r(e.promise,i)}))}function r(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var o=e.then;if(e instanceof i)return t._state=3,t._value=e,void a(t);if("function"==typeof o)return void c(n(o,e),t)}t._state=1,t._value=e,a(t)}catch(r){s(t,r)}}function s(t,e){t._state=2,t._value=e,a(t)}function a(t){2===t._state&&0===t._deferreds.length&&setTimeout(function(){t._handled||p(t._value)},1);for(var e=0,n=t._deferreds.length;n>e;e++)o(t,t._deferreds[e]);t._deferreds=null}function u(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function c(t,e){var n=!1;try{t(function(t){n||(n=!0,r(e,t))},function(t){n||(n=!0,s(e,t))})}catch(i){if(n)return;n=!0,s(e,i)}}var l=setTimeout,h="function"==typeof setImmediate&&setImmediate||function(t){l(t,1)},p=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};i.prototype["catch"]=function(t){return this.then(null,t)},i.prototype.then=function(t,n){var r=new i(e);return o(this,new u(t,n,r)),r},i.all=function(t){var e=Array.prototype.slice.call(t);return new i(function(t,n){function i(r,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(t){i(r,t)},n)}e[r]=s,0===--o&&t(e)}catch(u){n(u)}}if(0===e.length)return t([]);for(var o=e.length,r=0;r<e.length;r++)i(r,e[r])})},i.resolve=function(t){return t&&"object"==typeof t&&t.constructor===i?t:new i(function(e){e(t)})}
21841,i.reject=function(t){return new i(function(e,n){n(t)})},i.race=function(t){return new i(function(e,n){for(var i=0,o=t.length;o>i;i++)t[i].then(e,n)})},i._setImmediateFn=function(t){h=t},i._setUnhandledRejectionFn=function(t){p=t},"undefined"!=typeof module&&module.exports?module.exports=i:t.Promise||(t.Promise=i)}(this),function(){var t="object"==typeof window.customElements,e="function"==typeof document.registerElement,n=t||e;n||(/** 21842 * @license 21843 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 21844 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 21845 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 21846 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 21847 * Code distributed by Google as part of the polymer project is also 21848 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 21849 */ 21850"undefined"==typeof WeakMap&&!function(){var t=Object.defineProperty,e=Date.now()%1e9,n=function(){this.name="__st"+(1e9*Math.random()>>>0)+(e++ +"__")};n.prototype={set:function(e,n){var i=e[this.name];return i&&i[0]===e?i[1]=n:t(e,this.name,{value:[e,n],writable:!0}),this},get:function(t){var e;return(e=t[this.name])&&e[0]===t?e[1]:void 0},"delete":function(t){var e=t[this.name];return e&&e[0]===t?(e[0]=e[1]=void 0,!0):!1},has:function(t){var e=t[this.name];return e?e[0]===t:!1}},window.WeakMap=n}(),function(t){function e(t){A.push(t),b||(b=!0,g(i))}function n(t){return window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(t)||t}function i(){b=!1;var t=A;A=[],t.sort(function(t,e){return t.uid_-e.uid_});var e=!1;t.forEach(function(t){var n=t.takeRecords();o(t),n.length&&(t.callback_(n,t),e=!0)}),e&&i()}
21850function o(t){t.nodes_.forEach(function(e){var n=m.get(e);n&&n.forEach(function(e){e.observer===t&&e.removeTransientObservers()})})}function r(t,e){for(var n=t;n;n=n.parentNode){var i=m.get(n);if(i)for(var o=0;o<i.length;o++){var r=i[o],s=r.options;if(n===t||s.subtree){var a=e(s);a&&r.enqueue(a)}}}}function s(t){this.callback_=t,this.nodes_=[],this.records_=[],this.uid_=++C}function a(t,e){this.type=t,this.target=e,this.addedNodes=[],this.removedNodes=[],this.previousSibling=null,this.nextSibling=null,this.attributeName=null,this.attributeNamespace=null,this.oldValue=null}function u(t){var e=new a(t.type,t.target);return e.addedNodes=t.addedNodes.slice(),e.removedNodes=t.removedNodes.slice(),e.previousSibling=t.previousSibling,e.nextSibling=t.nextSibling,e.attributeName=t.attributeName,e.attributeNamespace=t.attributeNamespace,e.oldValue=t.oldValue,e}function c(t,e){return x=new a(t,e)}function l(t){return w?w:(w=u(x),w.oldValue=t,w)}function h(){x=w=void 0}function p(t){return t===w||t===x}function d(t,e){return t===e?t:w&&p(t)?w:null}function f(t,e,n){this.observer=t,this.target=e,this.options=n,this.transientObservedNodes=[]}if(!t.JsMutationObserver){var g,m=new WeakMap;if(/Trident|Edge/.test(navigator.userAgent))g=setTimeout;else if(window.setImmediate)g=window.setImmediate;else{var v=[],y=String(Math.random());window.addEventListener("message",function(t){if(t.data===y){var e=v;v=[],e.forEach(function(t){t()})}}),g=function(t){v.push(t),window.postMessage(y,"*")}}var b=!1,A=[],C=0;s.prototype={observe:function(t,e){if(t=n(t),!e.childList&&!e.attributes&&!e.characterData||e.attributeOldValue&&!e.attributes||e.attributeFilter&&e.attributeFilter.length&&!e.attributes||e.characterDataOldValue&&!e.characterData)throw new SyntaxError;var i=m.get(t);i||m.set(t,i=[]);for(var o,r=0;r<i.length;r++)if(i[r].observer===this){o=i[r],o.removeListeners(),o.options=e;break}o||(o=new f(this,t,e),i.push(o),this.nodes_.push(t)),o.addListeners()},disconnect:function(){this.nodes_.forEach(function(t){for(var e=m.get(t),n=0;n<e.length;n++){var i=e[n];if(i.observer===this){i.removeListeners(),e.splice(n,1);break}}},this),this.records_=[]},takeRecords:function(){var t=this.records_;return this.records_=[],t}};var x,w;f.prototype={enqueue:function(t){var n=this.observer.records_,i=n.length;if(n.length>0){var o=n[i-1],r=d(o,t);if(r)return void(n[i-1]=r)}else e(this.observer);n[i]=t},addListeners:function(){this.addListeners_(this.target)},addListeners_:function(t){var e=this.options;e.attributes&&t.addEventListener("DOMAttrModified",this,!0),e.characterData&&t.addEventListener("DOMCharacterDataModified",this,!0),e.childList&&t.addEventListener("DOMNodeInserted",this,!0),(e.childList||e.subtree)&&t.addEventListener("DOMNodeRemoved",this,!0)},removeListeners:function(){this.removeListeners_(this.target)},removeListeners_:function(t){var e=this.options;e.attributes&&t.removeEventListener("DOMAttrModified",this,!0),e.characterData&&t.removeEventListener("DOMCharacterDataModified",this,!0),e.childList&&t.removeEventListener("DOMNodeInserted",this,!0),(e.childList||e.subtree)&&t.removeEventListener("DOMNodeRemoved",this,!0)},addTransientObserver:function(t){if(t!==this.target){this.addListeners_(t),this.transientObservedNodes.push(t);var e=m.get(t);e||m.set(t,e=[]),e.push(this)}},removeTransientObservers:function(){var t=this.transientObservedNodes;this.transientObservedNodes=[],t.forEach(function(t){this.removeListeners_(t);for(var e=m.get(t),n=0;n<e.length;n++)if(e[n]===this){e.splice(n,1);break}},this)},handleEvent:function(t){switch(t.stopImmediatePropagation(),t.type){case"DOMAttrModified":var e=t.attrName,n=t.relatedNode.namespaceURI,i=t.target,o=new c("attributes",i);o.attributeName=e,o.attributeNamespace=n;var s=t.attrChange===MutationEvent.ADDITION?null:t.prevValue;r(i,function(t){return!t.attributes||t.attributeFilter&&t.attributeFilter.length&&-1===t.attributeFilter.indexOf(e)&&-1===t.attributeFilter.indexOf(n)?void 0:t.attributeOldValue?l(s):o});break;case"DOMCharacterDataModified":var i=t.target,o=c("characterData",i),s=t.prevValue;r(i,function(t){return t.characterData?t.characterDataOldValue?l(s):o:void 0});break;case"DOMNodeRemoved":this.addTransientObserver(t.target);case"DOMNodeInserted":var a,u,p=t.target;"DOMNodeInserted"===t.type?(a=[p],u=[]):(a=[],u=[p]);var d=p.previousSibling,f=p.nextSibling,o=c("childList",t.target.parentNode);o.addedNodes=a,o.removedNodes=u,o.previousSibling=d,o.nextSibling=f,r(t.relatedNode,function(t){return t.childList?o:void 0})}h()}},t.JsMutationObserver=s,t.MutationObserver||(t.MutationObserver=s,s._isPolyfilled=!0)}}(self),function(){"use strict";if(!window.performance||!window.performance.now){var t=Date.now();window.performance={now:function(){return Date.now()-t}}}window.requestAnimationFrame||(window.requestAnimationFrame=function(){var t=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame;return t?function(e){return t(function(){e(performance.now())})}:function(t){return window.setTimeout(t,1e3/60)}}()),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(){return window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(t){clearTimeout(t)}}());var e=function(){var t=document.createEvent("Event");return t.initEvent("foo",!0,!0),t.preventDefault(),t.defaultPrevented}();if(!e){var n=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){this.cancelable&&(n.call(this),Ob
21850ject.defineProperty(this,"defaultPrevented",{get:function(){return!0},configurable:!0}))}}var i=/Trident/.test(navigator.userAgent);if((!window.CustomEvent||i&&"function"!=typeof window.CustomEvent)&&(window.CustomEvent=function(t,e){e=e||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,Boolean(e.bubbles),Boolean(e.cancelable),e.detail),n},window.CustomEvent.prototype=window.Event.prototype),!window.Event||i&&"function"!=typeof window.Event){var o=window.Event;window.Event=function(t,e){e=e||{};var n=document.createEvent("Event");return n.initEvent(t,Boolean(e.bubbles),Boolean(e.cancelable)),n},window.Event.prototype=o.prototype}}(window.WebComponents),window.CustomElements=window.CustomElements||{flags:{}},function(t){var e=t.flags,n=[],i=function(t){n.push(t)},o=function(){n.forEach(function(e){e(t)})};t.addModule=i,t.initializeModules=o,t.hasNative=Boolean(document.registerElement),t.isIE=/Trident/.test(navigator.userAgent),t.useNative=!e.register&&t.hasNative&&!window.ShadowDOMPolyfill&&(!window.HTMLImports||window.HTMLImports.useNative)}(window.CustomElements),window.CustomElements.addModule(function(t){function e(t,e){n(t,function(t){return e(t)?!0:void i(t,e)}),i(t,e)}function n(t,e,i){var o=t.firstElementChild;if(!o)for(o=t.firstChild;o&&o.nodeType!==Node.ELEMENT_NODE;)o=o.nextSibling;for(;o;)e(o,i)!==!0&&n(o,e,i),o=o.nextElementSibling;return null}function i(t,n){for(var i=t.shadowRoot;i;)e(i,n),i=i.olderShadowRoot}function o(t,e){r(t,e,[])}function r(t,e,n){if(t=window.wrap(t),!(n.indexOf(t)>=0)){n.push(t);for(var i,o=t.querySelectorAll("link[rel="+s+"]"),a=0,u=o.length;u>a&&(i=o[a]);a++)i.import&&r(i.import,e,n);e(t)}}var s=window.HTMLImports?window.HTMLImports.IMPORT_LINK_TYPE:"none";t.forDocumentTree=o,t.forSubtree=e}),window.CustomElements.addModule(function(t){function e(t,e){return n(t,e)||i(t,e)}function n(e,n){return t.upgrade(e,n)?!0:void(n&&s(e))}function i(t,e){b(t,function(t){return n(t,e)?!0:void 0})}function o(t){w.push(t),x||(x=!0,setTimeout(r))}function r(){x=!1;for(var t,e=w,n=0,i=e.length;i>n&&(t=e[n]);n++)t();w=[]}function s(t){C?o(function(){a(t)}):a(t)}function a(t){t.__upgraded__&&!t.__attached&&(t.__attached=!0,t.attachedCallback&&t.attachedCallback())}function u(t){c(t),b(t,function(t){c(t)})}function c(t){C?o(function(){l(t)}):l(t)}function l(t){t.__upgraded__&&t.__attached&&(t.__attached=!1,t.detachedCallback&&t.detachedCallback())}function h(t){for(var e=t,n=window.wrap(document);e;){if(e==n)return!0;e=e.parentNode||e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host}}function p(t){if(t.shadowRoot&&!t.shadowRoot.__watched){y.dom&&console.log("watching shadow-root for: ",t.localName);for(var e=t.shadowRoot;e;)g(e),e=e.olderShadowRoot}}function d(t,n){if(y.dom){var i=n[0];if(i&&"childList"===i.type&&i.addedNodes&&i.addedNodes){for(var o=i.addedNodes[0];o&&o!==document&&!o.host;)o=o.parentNode;var r=o&&(o.URL||o._URL||o.host&&o.host.localName)||"";r=r.split("/?").shift().split("/").pop()}console.group("mutations (%d) [%s]",n.length,r||"")}var s=h(t);n.forEach(function(t){"childList"===t.type&&(E(t.addedNodes,function(t){t.localName&&e(t,s)}),E(t.removedNodes,function(t){t.localName&&u(t)}))}),y.dom&&console.groupEnd()}function f(t){for(t=window.wrap(t),t||(t=window.wrap(document));t.parentNode;)t=t.parentNode;var e=t.__observer;e&&(d(t,e.takeRecords()),r())}function g(t){if(!t.__observer){var e=new MutationObserver(d.bind(this,t));e.observe(t,{childList:!0,subtree:!0}),t.__observer=e}}function m(t){t=window.wrap(t),y.dom&&console.group("upgradeDocument: ",t.baseURI.split("/").pop());var n=t===window.wrap(document);e(t,n),g(t),y.dom&&console.groupEnd()}function v(t){A(t,m)}var y=t.flags,b=t.forSubtree,A=t.forDocumentTree,C=window.MutationObserver._isPolyfilled&&y["throttle-attached"];t.hasPolyfillMutations=C,t.hasThrottledAttached=C;var x=!1,w=[],E=Array.prototype.forEach.call.bind(Array.prototype.forEach),S=Element.prototype.createShadowRoot;S&&(Element.prototype.createShadowRoot=function(){var t=S.call(this);return window.CustomElements.watchShadow(this),t}),t.watchShadow=p,t.upgradeDocumentTree=v,t.upgradeDocument=m,t.upgradeSubtree=i,t.upgradeAll=e,t.attached=s,t.takeRecords=f}),window.CustomElements.addModule(function(t){function e(e,i){if("template"===e.localName&&window.HTMLTemplateElement&&HTMLTemplateElement.decorate&&HTMLTemplateElement.decorate(e),!e.__upgraded__&&e.nodeType===Node.ELEMENT_NODE){var o=e.getAttribute("is"),r=t.getRegisteredDefinition(e.localName)||t.getRegisteredDefinition(o);
21850if(r&&(o&&r.tag==e.localName||!o&&!r.extends))return n(e,r,i)}}function n(e,n,o){return s.upgrade&&console.group("upgrade:",e.localName),n.is&&e.setAttribute("is",n.is),i(e,n),e.__upgraded__=!0,r(e),o&&t.attached(e),t.upgradeSubtree(e,o),s.upgrade&&console.groupEnd(),e}function i(t,e){Object.__proto__?t.__proto__=e.prototype:(o(t,e.prototype,e.native),t.__proto__=e.prototype)}function o(t,e,n){for(var i={},o=e;o!==n&&o!==HTMLElement.prototype;){for(var r,s=Object.getOwnPropertyNames(o),a=0;r=s[a];a++)i[r]||(Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(o,r)),i[r]=1);o=Object.getPrototypeOf(o)}}function r(t){t.createdCallback&&t.createdCallback()}var s=t.flags;t.upgrade=e,t.upgradeWithDefinition=n,t.implementPrototype=i}),window.CustomElements.addModule(function(t){function e(e,i){var u=i||{};if(!e)throw new Error("document.registerElement: first argument `name` must not be empty");if(e.indexOf("-")<0)throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '"+String(e)+"'.");if(o(e))throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '"+String(e)+"'. The type name is invalid.");if(c(e))throw new Error("DuplicateDefinitionError: a type with name '"+String(e)+"' is already registered");return u.prototype||(u.prototype=Object.create(HTMLElement.prototype)),u.__name=e.toLowerCase(),u.extends&&(u.extends=u.extends.toLowerCase()),u.lifecycle=u.lifecycle||{},u.ancestry=r(u.extends),s(u),a(u),n(u.prototype),l(u.__name,u),u.ctor=h(u),u.ctor.prototype=u.prototype,u.prototype.constructor=u.ctor,t.ready&&m(document),u.ctor}function n(t){if(!t.setAttribute._polyfilled){var e=t.setAttribute;t.setAttribute=function(t,n){i.call(this,t,n,e)};var n=t.removeAttribute;t.removeAttribute=function(t){i.call(this,t,null,n)},t.setAttribute._polyfilled=!0}}function i(t,e,n){t=t.toLowerCase();var i=this.getAttribute(t);n.apply(this,arguments);var o=this.getAttribute(t);this.attributeChangedCallback&&o!==i&&this.attributeChangedCallback(t,i,o)}function o(t){for(var e=0;e<C.length;e++)if(t===C[e])return!0}function r(t){var e=c(t);return e?r(e.extends).concat([e]):[]}function s(t){for(var e,n=t.extends,i=0;e=t.ancestry[i];i++)n=e.is&&e.tag;t.tag=n||t.__name,n&&(t.is=t.__name)}function a(t){if(!Object.__proto__){var e=HTMLElement.prototype;if(t.is){var n=document.createElement(t.tag);e=Object.getPrototypeOf(n)}for(var i,o=t.prototype,r=!1;o;)o==e&&(r=!0),i=Object.getPrototypeOf(o),i&&(o.__proto__=i),o=i;r||console.warn(t.tag+" prototype not found in prototype chain for "+t.is),t.native=e}}function u(t){return y(E(t.tag),t)}function c(t){return t?x[t.toLowerCase()]:void 0}function l(t,e){x[t]=e}function h(t){return function(){return u(t)}}function p(t,e,n){return t===w?d(e,n):S(t,e)}function d(t,e){t&&(t=t.toLowerCase()),e&&(e=e.toLowerCase());var n=c(e||t);if(n){if(t==n.tag&&e==n.is)return new n.ctor;if(!e&&!n.is)return new n.ctor}var i;return e?(i=d(t),i.setAttribute("is",e),i):(i=E(t),t.indexOf("-")>=0&&b(i,HTMLElement),i)}function f(t,e){var n=t[e];t[e]=function(){var t=n.apply(this,arguments);return v(t),t}}var g,m=(t.isIE,t.upgradeDocumentTree),v=t.upgradeAll,y=t.upgradeWithDefinition,b=t.implementPrototype,A=t.useNative,C=["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"],x={},w="http://www.w3.org/1999/xhtml",E=document.createElement.bind(document),S=document.createElementNS.bind(document);g=Object.__proto__||A?function(t,e){return t instanceof e}:function(t,e){if(t instanceof e)return!0;for(var n=t;n;){if(n===e.prototype)return!0;n=n.__proto__}return!1},f(Node.prototype,"cloneNode"),f(document,"importNode"),document.registerElement=e,document.createElement=d,document.createElementNS=p,t.registry=x,t.instanceof=g,t.reservedTagList=C,t.getRegisteredDefinition=c,document.register=document.registerElement}),function(t){function e(){r(window.wrap(document)),window.CustomElements.ready=!0;var t=window.requestAnimationFrame||function(t){setTimeout(t,16)};t(function(){setTimeout(function(){window.CustomElements.readyTime=Date.now(),window.HTMLImports&&(window.CustomElements.elapsed=window.CustomElements.readyTime-window.HTMLImports.readyTime),document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0}))})})}
21850var n=t.useNative,i=t.initializeModules;if(t.isIE,n){var o=function(){};t.watchShadow=o,t.upgrade=o,t.upgradeAll=o,t.upgradeDocumentTree=o,t.upgradeSubtree=o,t.takeRecords=o,t.instanceof=function(t,e){return t instanceof e}}else i();var r=t.upgradeDocumentTree,s=t.upgradeDocument;if(window.wrap||(window.ShadowDOMPolyfill?(window.wrap=window.ShadowDOMPolyfill.wrapIfNeeded,window.unwrap=window.ShadowDOMPolyfill.unwrapIfNeeded):window.wrap=window.unwrap=function(t){return t}),window.HTMLImports&&(window.HTMLImports.__importsParsingHook=function(t){t.import&&s(wrap(t.import))}),"complete"===document.readyState||t.flags.eager)e();else if("interactive"!==document.readyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var a=window.HTMLImports&&!window.HTMLImports.ready?"HTMLImportsLoaded":"DOMContentLoaded";window.addEventListener(a,e)}else e()}(window.CustomElements))}.call(this),function(){}.call(this),function(){var t=this;(function(){(function(){this.Trix={VERSION:"1.3.1",ZERO_WIDTH_SPACE:"\ufeff",NON_BREAKING_SPACE:"\xa0",OBJECT_REPLACEMENT_CHARACTER:"\ufffc",browser:{composesExistingText:/Android.*Chrome/.test(navigator.userAgent),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:function(){var t,e,n,i;if("undefined"==typeof InputEvent)return!1;for(i=["data","getTargetRanges","inputType"],t=0,e=i.length;e>t;t++)if(n=i[t],!(n in InputEvent.prototype))return!1;return!0}()},config:{}}}).call(this)}).call(t);var e=t.Trix;(function(){(function(){e.BasicObject=function(){function t(){}var e,n,i;return t.proxyMethod=function(t){var i,o,r,s,a;return r=n(t),i=r.name,s=r.toMethod,a=r.toProperty,o=r.optional,this.prototype[i]=function(){var t,n;return t=null!=s?o?"function"==typeof this[s]?this[s]():void 0:this[s]():null!=a?this[a]:void 0,o?(n=null!=t?t[i]:void 0,null!=n?e.call(n,t,arguments):void 0):(n=t[i],e.call(n,t,arguments))}},n=function(t){var e,n;if(!(n=t.match(i)))throw new Error("can't parse @proxyMethod expression: "+t);return e={name:n[4]},null!=n[2]?e.toMethod=n[1]:e.toProperty=n[1],null!=n[3]&&(e.optional=!0),e},e=Function.prototype.apply,i=/^(.+?)(\(\))?(\?)?\.(.+?)$/,t}()}).call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.Object=function(n){function i(){this.id=++o}var o;return t(i,n),o=0,i.fromJSONString=function(t){return this.fromJSON(JSON.parse(t))},i.prototype.hasSameConstructorAs=function(t){return this.constructor===(null!=t?t.constructor:void 0)},i.prototype.isEqualTo=function(t){return this===t},i.prototype.inspect=function(){var t,e,n;return t=function(){var t,i,o;i=null!=(t=this.contentsForInspection())?t:{},o=[];for(e in i)n=i[e],o.push(e+"="+n);return o}.call(this),"#<"+this.constructor.name+":"+this.id+(t.length?" "+t.join(", "):"")+">"},i.prototype.contentsForInspection=function(){},i.prototype.toJSONString=function(){return JSON.stringify(this)},i.prototype.toUTF16String=function(){return e.UTF16String.box(this)},i.prototype.getCacheKey=function(){return this.id.toString()},i}(e.BasicObject)}.call(this),function(){e.extend=function(t){var e,n;for(e in t)n=t[e],this[e]=n;return this}}.call(this),function(){e.extend({defer:function(t){return setTimeout(t,1)}})}.call(this),function(){var t,n;e.extend({normalizeSpaces:function(t){return t.replace(RegExp(""+e.ZERO_WIDTH_SPACE,"g"),"").replace(RegExp(""+e.NON_BREAKING_SPACE,"g")," ")},normalizeNewlines:function(t){return t.replace(/\r\n/g,"\n")},breakableWhitespacePattern:RegExp("[^\\S"+e.NON_BREAKING_SPACE+"]"),squishBreakableWhitespace:function(t){return t.replace(RegExp(""+e.breakableWhitespacePattern.source,"g")," ").replace(/\ {2,}/g," ")},summarizeStringChange:function(t,i){var o,r,s,a;return t=e.UTF16String.box(t),i=e.UTF16String.box(i),i.length<t.length?(r=n(t,i),a=r[0],o=r[1]):(s=n(i,t),o=s[0],a=s[1]),{added:o,removed:a}}}),n=function(n,i){var o,r,s,a,u;return n.isEqualTo(i)?["",""]:(r=t(n,i),a=r.utf16String.length,s=a?(u=r.offset,r,o=n.codepoints.slice(0,u).concat(n.codepoints.slice(u+a)),t(i,e.UTF16String.fromCodepoints(o))):t(i,n),[r.utf16String.toString(),s.utf16String.toString()])},t=function(t,e){var n,i,o;for(n=0,i=t.length,o=e.length;i>n&&t.charAt(n).isEqualTo(e.charAt(n));)n++;for(;i>n+1&&t.charAt(i-1).isEqualTo(e.charAt(o-1));)i--,o--;return{utf16String:t.slice(n,i),offset:n}}}.call(this),function(){e.extend({copyObject:function(t){var e,n,i;null==t&&(t={}),n={};for(e in t)i=t[e],n[e]=i;return n},objectsAreEqual:function(t,e){var n,i;if(null==t&&(t={}),null==e&&(e={}),Object.keys(t).length!==Object.keys(e).length)return!1;for(n in t)if(i=t[n],i!==e[n])return!1;return!0}})}.call(this),function(){var t=[].slice;e.extend({arraysAreEqual:function(t,e){var n,i,o,r;if(null==t&&(t=[]),null==e&&(e=[]),t.length!==e.length)return!1;for(i=n=0,o=t.length;o>n;i=++n)if(r=t[i],r!==e[i])return!1;return!0},arrayStartsWith:function(t,n){return null==t&&(t=[]),null==n&&(n=[]),e.arraysAreEqual(t.slice(0,n.length),n)},spliceArray:function(){var e,n,i;
21850return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],i=n.slice(0),i.splice.apply(i,e),i},summarizeArrayChange:function(t,e){var n,i,o,r,s,a,u,c,l,h,p;for(null==t&&(t=[]),null==e&&(e=[]),n=[],h=[],o=new Set,r=0,u=t.length;u>r;r++)p=t[r],o.add(p);for(i=new Set,s=0,c=e.length;c>s;s++)p=e[s],i.add(p),o.has(p)||n.push(p);for(a=0,l=t.length;l>a;a++)p=t[a],i.has(p)||h.push(p);return{added:n,removed:h}}})}.call(this),function(){var t,n,i,o;t=null,n=null,o=null,i=null,e.extend({getAllAttributeNames:function(){return null!=t?t:t=e.getTextAttributeNames().concat(e.getBlockAttributeNames())},getBlockConfig:function(t){return e.config.blockAttributes[t]},getBlockAttributeNames:function(){return null!=n?n:n=Object.keys(e.config.blockAttributes)},getTextConfig:function(t){return e.config.textAttributes[t]},getTextAttributeNames:function(){return null!=o?o:o=Object.keys(e.config.textAttributes)},getListAttributeNames:function(){var t,n;return null!=i?i:i=function(){var i,o;i=e.config.blockAttributes,o=[];for(t in i)n=i[t].listAttribute,null!=n&&o.push(n);return o}()}})}.call(this),function(){var t,n,i,o,r,s=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};t=document.documentElement,n=null!=(i=null!=(o=null!=(r=t.matchesSelector)?r:t.webkitMatchesSelector)?o:t.msMatchesSelector)?i:t.mozMatchesSelector,e.extend({handleEvent:function(n,i){var o,r,s,a,u,c,l,h,p,d,f,g;return h=null!=i?i:{},c=h.onElement,u=h.matchingSelector,g=h.withCallback,a=h.inPhase,l=h.preventDefault,d=h.times,r=null!=c?c:t,p=u,o=g,f="capturing"===a,s=function(t){var n;return null!=d&&0===--d&&s.destroy(),n=e.findClosestElementFromNode(t.target,{matchingSelector:p}),null!=n&&(null!=g&&g.call(n,t,n),l)?t.preventDefault():void 0},s.destroy=function(){return r.removeEventListener(n,s,f)},r.addEventListener(n,s,f),s},handleEventOnce:function(t,n){return null==n&&(n={}),n.times=1,e.handleEvent(t,n)},triggerEvent:function(n,i){var o,r,s,a,u,c,l;return l=null!=i?i:{},c=l.onElement,r=l.bubbles,s=l.cancelable,o=l.attributes,a=null!=c?c:t,r=r!==!1,s=s!==!1,u=document.createEvent("Events"),u.initEvent(n,r,s),null!=o&&e.extend.call(u,o),a.dispatchEvent(u)},elementMatchesSelector:function(t,e){return 1===(null!=t?t.nodeType:void 0)?n.call(t,e):void 0},findClosestElementFromNode:function(t,n){var i,o,r;for(o=null!=n?n:{},i=o.matchingSelector,r=o.untilNode;null!=t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;if(null!=t){if(null==i)return t;if(t.closest&&null==r)return t.closest(i);for(;t&&t!==r;){if(e.elementMatchesSelector(t,i))return t;t=t.parentNode}}},findInnerElement:function(t){for(;null!=t?t.firstElementChild:void 0;)t=t.firstElementChild;return t},innerElementIsActive:function(t){return document.activeElement!==t&&e.elementContainsNode(t,document.activeElement)},elementContainsNode:function(t,e){if(t&&e)for(;e;){if(e===t)return!0;e=e.parentNode}},findNodeFromContainerAndOffset:function(t,e){var n;if(t)return t.nodeType===Node.TEXT_NODE?t:0===e?null!=(n=t.firstChild)?n:t:t.childNodes.item(e-1)},findElementFromContainerAndOffset:function(t,n){var i;return i=e.findNodeFromContainerAndOffset(t,n),e.findClosestElementFromNode(i)},findChildIndexOfNode:function(t){var e;if(null!=t?t.parentNode:void 0){for(e=0;t=t.previousSibling;)e++;return e}},removeNode:function(t){var e;return null!=t&&null!=(e=t.parentNode)?e.removeChild(t):void 0},walkTree:function(t,e){var n,i,o,r,s;return o=null!=e?e:{},i=o.onlyNodesOfType,r=o.usingFilter,n=o.expandEntityReferences,s=function(){switch(i){case"element":return NodeFilter.SHOW_ELEMENT;case"text":return NodeFilter.SHOW_TEXT;case"comment":return NodeFilter.SHOW_COMMENT;default:return NodeFilter.SHOW_ALL}}(),document.createTreeWalker(t,s,null!=r?r:null,n===!0)},tagName:function(t){var e;return null!=t&&null!=(e=t.tagName)?e.toLowerCase():void 0},makeElement:function(t,e){var n,i,o,r,s,a,u,c,l,h,p,d,f,g;if(null==e&&(e={}),"object"==typeof t?(e=t,t=e.tagName):e={attributes:e},o=document.createElement(t),null!=e.editable&&(null==e.attributes&&(e.attributes={}),e.attributes.contenteditable=e.editable),e.attributes){l=e.attributes;for(a in l)g=l[a],o.setAttribute(a,g)}if(e.style){h=e.style;for(a in h)g=h[a],o.style[a]=g}if(e.data){p=e.data;for(a in p)g=p[a],o.dataset[a]=g}if(e.className)for(d=e.className.split(" "),r=0,u=d.length;u>r;r++)i=d[r],o.classList.add(i);if(e.textContent&&(o.textContent=e.textContent),e.childNodes)for(f=[].concat(e.childNodes),s=0,c=f.length;c>s;s++)n=f[s],o.appendChild(n);return o},getBlockTagNames:function(){var t,n;return null!=e.blockTagNames?e.blockTagNames:e.blockTagNames=function(){var i,o;i=e.config.blockAttributes,o=[];for(t in i)n=i[t].tagName,n&&o.push(n);return o}()}
21850,nodeIsBlockContainer:function(t){return e.nodeIsBlockStartComment(null!=t?t.firstChild:void 0)},nodeProbablyIsBlockContainer:function(t){var n,i;return n=e.tagName(t),s.call(e.getBlockTagNames(),n)>=0&&(i=e.tagName(t.firstChild),s.call(e.getBlockTagNames(),i)<0)},nodeIsBlockStart:function(t,n){var i;return i=(null!=n?n:{strict:!0}).strict,i?e.nodeIsBlockStartComment(t):e.nodeIsBlockStartComment(t)||!e.nodeIsBlockStartComment(t.firstChild)&&e.nodeProbablyIsBlockContainer(t)},nodeIsBlockStartComment:function(t){return e.nodeIsCommentNode(t)&&"block"===(null!=t?t.data:void 0)},nodeIsCommentNode:function(t){return(null!=t?t.nodeType:void 0)===Node.COMMENT_NODE},nodeIsCursorTarget:function(t,n){var i;return i=(null!=n?n:{}).name,t?e.nodeIsTextNode(t)?t.data===e.ZERO_WIDTH_SPACE?i?t.parentNode.dataset.trixCursorTarget===i:!0:void 0:e.nodeIsCursorTarget(t.firstChild):void 0},nodeIsAttachmentElement:function(t){return e.elementMatchesSelector(t,e.AttachmentView.attachmentSelector)},nodeIsEmptyTextNode:function(t){return e.nodeIsTextNode(t)&&""===(null!=t?t.data:void 0)},nodeIsTextNode:function(t){return(null!=t?t.nodeType:void 0)===Node.TEXT_NODE}})}.call(this),function(){var t,n,i,o,r;t=e.copyObject,o=e.objectsAreEqual,e.extend({normalizeRange:i=function(t){var e;if(null!=t)return Array.isArray(t)||(t=[t,t]),[n(t[0]),n(null!=(e=t[1])?e:t[0])]},rangeIsCollapsed:function(t){var e,n,o;if(null!=t)return n=i(t),o=n[0],e=n[1],r(o,e)},rangesAreEqual:function(t,e){var n,o,s,a,u,c;if(null!=t&&null!=e)return s=i(t),o=s[0],n=s[1],a=i(e),c=a[0],u=a[1],r(o,c)&&r(n,u)}}),n=function(e){return"number"==typeof e?e:t(e)},r=function(t,e){return"number"==typeof t?t===e:o(t,e)}}.call(this),function(){var t,n,i,o,r,s,a;e.registerElement=function(t,e){var n,i;return null==e&&(e={}),t=t.toLowerCase(),e=a(e),i=s(e),(n=i.defaultCSS)&&(delete i.defaultCSS,o(n,t)),r(t,i)},o=function(t,e){var n;return n=i(e),n.textContent=t.replace(/%t/g,e)},i=function(e){var n,i;return n=document.createElement("style"),n.setAttribute("type","text/css"),n.setAttribute("data-tag-name",e.toLowerCase()),(i=t())&&n.setAttribute("nonce",i),document.head.insertBefore(n,document.head.firstChild),n},t=function(){var t;return(t=n("trix-csp-nonce")||n("csp-nonce"))?t.getAttribute("content"):void 0},n=function(t){return document.head.querySelector("meta[name="+t+"]")},s=function(t){var e,n,i;n={};for(e in t)i=t[e],n[e]="function"==typeof i?{value:i}:i;return n},a=function(){var t;return t=function(t){var e,n,i,o,r;for(e={},r=["initialize","connect","disconnect"],n=0,o=r.length;o>n;n++)i=r[n],e[i]=t[i],delete t[i];return e},window.customElements?function(e){var n,i,o,r,s;return s=t(e),o=s.initialize,n=s.connect,i=s.disconnect,o&&(r=n,n=function(){return this.initialized||(this.initialized=!0,o.call(this)),null!=r?r.call(this):void 0}),n&&(e.connectedCallback=n),i&&(e.disconnectedCallback=i),e}:function(e){var n,i,o,r;return r=t(e),o=r.initialize,n=r.connect,i=r.disconnect,o&&(e.createdCallback=o),n&&(e.attachedCallback=n),i&&(e.detachedCallback=i),e}}(),r=function(){return window.customElements?function(t,e){var n;return n=function(){return"object"==typeof Reflect?Reflect.construct(HTMLElement,[],n):HTMLElement.apply(this)},Object.setPrototypeOf(n.prototype,HTMLElement.prototype),Object.setPrototypeOf(n,HTMLElement),Object.defineProperties(n.prototype,e),window.customElements.define(t,n),n}:function(t,e){var n,i;return i=Object.create(HTMLElement.prototype,e),n=document.registerElement(t,{prototype:i}),Object.defineProperty(i,"constructor",{value:n}),n}}()}.call(this),function(){var t,n;e.extend({getDOMSelection:function(){var t;return t=window.getSelection(),t.rangeCount>0?t:void 0},getDOMRange:function(){var n,i;return(n=null!=(i=e.getDOMSelection())?i.getRangeAt(0):void 0)&&!t(n)?n:void 0},setDOMRange:function(t){var n;return n=window.getSelection(),n.removeAllRanges(),n.addRange(t),e.selectionChangeObserver.update()}}),t=function(t){return n(t.startContainer)||n(t.endContainer)},n=function(t){return!Object.getPrototypeOf(t)}}.call(this),function(){var t;t={"application/x-trix-feature-detection":"test"},e.extend({dataTransferIsPlainText:function(t){var e,n,i;return i=t.getData("text/plain"),n=t.getData("text/html"),i&&n?(e=(new DOMParser).parseFromString(n,"text/html").body,e.textContent===i?!e.querySelector("*"):void 0):null!=i?i.length:void 0},dataTransferIsWritable:function(e){var n,i;if(null!=(null!=e?e.setData:void 0)){for(n in t)if(i=t[n],!function(){try{return e.setData(n,i),e.getData(n)===i}catch(t){}}())return;return!0}},keyEventIsKeyboardCommand:function(){return/Mac|^iP/.test(navigator.platform)?function(t){return t.metaKey}:function(t){return t.ctrlKey}}()})}.call(this),function(){e.extend({RTL_PATTERN:/[\u05BE\u05C0\u05C3\u05D0-\u05EA\u05F0-\u05F4\u061B\u061F\u0621-\u063A\u0640-\u064A\u066D\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D5\u06E5\u06E6\u200F\u202B\u202E\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
21850D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE72\uFE74\uFE76-\uFEFC]/,getDirection:function(){var t,n,i,o;return n=e.makeElement("input",{dir:"auto",name:"x",dirName:"x.dir"}),t=e.makeElement("form"),t.appendChild(n),i=function(){try{return new FormData(t).has(n.dirName)}catch(e){}}(),o=function(){try{return n.matches(":dir(ltr),:dir(rtl)")}catch(t){}}(),i?function(e){return n.value=e,new FormData(t).get(n.dirName)}:o?function(t){return n.value=t,n.matches(":dir(rtl)")?"rtl":"ltr"}:function(t){var n;return n=t.trim().charAt(0),e.RTL_PATTERN.test(n)?"rtl":"ltr"}}()})}.call(this),function(){}.call(this),function(){var t,n=function(t,e){function n(){this.constructor=t}for(var o in e)i.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},i={}.hasOwnProperty;t=e.arraysAreEqual,e.Hash=function(i){function o(t){null==t&&(t={}),this.values=s(t),o.__super__.constructor.apply(this,arguments)}var r,s,a,u,c;return n(o,i),o.fromCommonAttributesOfObjects=function(t){var e,n,i,o,s,a;if(null==t&&(t=[]),!t.length)return new this;for(e=r(t[0]),i=e.getKeys(),a=t.slice(1),n=0,o=a.length;o>n;n++)s=a[n],i=e.getKeysCommonToHash(r(s)),e=e.slice(i);return e},o.box=function(t){return r(t)},o.prototype.add=function(t,e){return this.merge(u(t,e))},o.prototype.remove=function(t){return new e.Hash(s(this.values,t))},o.prototype.get=function(t){return this.values[t]},o.prototype.has=function(t){return t in this.values},o.prototype.merge=function(t){return new e.Hash(a(this.values,c(t)))},o.prototype.slice=function(t){var n,i,o,r;for(r={},n=0,o=t.length;o>n;n++)i=t[n],this.has(i)&&(r[i]=this.values[i]);return new e.Hash(r)},o.prototype.getKeys=function(){return Object.keys(this.values)},o.prototype.getKeysCommonToHash=function(t){var e,n,i,o,s;for(t=r(t),o=this.getKeys(),s=[],e=0,i=o.length;i>e;e++)n=o[e],this.values[n]===t.values[n]&&s.push(n);return s},o.prototype.isEqualTo=function(e){return t(this.toArray(),r(e).toArray())},o.prototype.isEmpty=function(){return 0===this.getKeys().length},o.prototype.toArray=function(){var t,e,n;return(null!=this.array?this.array:this.array=function(){var i;e=[],i=this.values;for(t in i)n=i[t],e.push(t,n);return e}.call(this)).slice(0)},o.prototype.toObject=function(){return s(this.values)},o.prototype.toJSON=function(){return this.toObject()},o.prototype.contentsForInspection=function(){return{values:JSON.stringify(this.values)}},u=function(t,e){var n;return n={},n[t]=e,n},a=function(t,e){var n,i,o;i=s(t);for(n in e)o=e[n],i[n]=o;return i},s=function(t,e){var n,i,o,r,s;for(r={},s=Object.keys(t).sort(),n=0,o=s.length;o>n;n++)i=s[n],i!==e&&(r[i]=t[i]);return r},r=function(t){return t instanceof e.Hash?t:new e.Hash(t)},c=function(t){return t instanceof e.Hash?t.values:t 21851},o}(e.Object)}.call(this),function(){e.ObjectGroup=function(){function t(t,e){var n,i;this.objects=null!=t?t:[],i=e.depth,n=e.asTree,n&&(this.depth=i,this.objects=this.constructor.groupObjects(this.objects,{asTree:n,depth:this.depth+1}))}return t.groupObjects=function(t,e){var n,i,o,r,s,a,u,c,l;for(null==t&&(t=[]),l=null!=e?e:{},o=l.depth,n=l.asTree,n&&null==o&&(o=0),c=[],s=0,a=t.length;a>s;s++){if(u=t[s],r){if(("function"==typeof u.canBeGrouped?u.canBeGrouped(o):void 0)&&("function"==typeof(i=r[r.length-1]).canBeGroupedWith?i.canBeGroupedWith(u,o):void 0)){r.push(u);continue}c.push(new this(r,{depth:o,asTree:n})),r=null}("function"==typeof u.canBeGrouped?u.canBeGrouped(o):void 0)?r=[u]:c.push(u)}return r&&c.push(new this(r,{depth:o,asTree:n})),c},t.prototype.getObjects=function(){return this.objects},t.prototype.getDepth=function(){return this.depth},t.prototype.getCacheKey=function(){var t,e,n,i,o;for(e=["objectGroup"],o=this.getObjects(),t=0,n=o.length;n>t;t++)i=o[t],e.push(i.getCacheKey());return e.join("/")},t}()}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.ObjectMap=function(e){function n(t){var e,n,i,o,r;for(null==t&&(t=[]),this.objects={},i=0,o=t.length;o>i;i++)r=t[i],n=JSON.stringify(r),null==(e=this.objects)[n]&&(e[n]=r)}return t(n,e),n.prototype.find=function(t){var e;return e=JSON.stringify(t),this.objects[e]},n}(e.BasicObject)}.call(this),function(){e.ElementStore=function(){function t(t){this.reset(t)}var e;return t.prototype.add=function(t){var n;return n=e(t),this.elements[n]=t},t.prototype.remove=function(t){var n,i;return n=e(t),(i=this.elements[n])?(delete this.elements[n],i):void 0},t.prototype.reset=function(t){var e,n,i;for(null==t&&(t=[]),this.elements={},n=0,i=t.length;i>n;n++)e=t[n],this.add(e);return t},e=function(t){return t.dataset.trixStoreKey},t}()}.call(this),function(){}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.Operation=function(e){function n(){return n.__super__.constructor.apply(this,arguments)}return t(n,e),n.prototype.isPerforming=function(){return this.performing===!0},n.prototype.hasPerformed=function(){return this.performed===!0},n.prototype.hasSucceeded=function(){return this.performed&&this.succeeded},n.prototype.hasFailed=function(){return this.performed&&!this.succeeded},n.prototype.getPromise=function(){return null!=this.promise?this.promise:this.promise=new Promise(function(t){return function(e,n){return t.performing=!0,t.perform(function(i,o){return t.succeeded=i,t.performing=!1,t.performed=!0,t.succeeded?e(o):n(o)})}}(this))},n.prototype.perform=function(t){return t(!1)},n.prototype.release=function(){var t;return null!=(t=this.promise)&&"function"==typeof t.cancel&&t.cancel(),this.promise=null,this.performing=null,this.performed=null,this.succeeded=null},n.proxyMethod("getPromise().then"),n.proxyMethod("getPromise().catch"),n}(e.BasicObject)}.call(this),function(){var t,n,i,o,r,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty;e.UTF16String=function(t){function e(t,e){this.ucs2String=t,this.co
21851depoints=e,this.length=this.codepoints.length,this.ucs2Length=this.ucs2String.length}return s(e,t),e.box=function(t){return null==t&&(t=""),t instanceof this?t:this.fromUCS2String(null!=t?t.toString():void 0)},e.fromUCS2String=function(t){return new this(t,o(t))},e.fromCodepoints=function(t){return new this(r(t),t)},e.prototype.offsetToUCS2Offset=function(t){return r(this.codepoints.slice(0,Math.max(0,t))).length},e.prototype.offsetFromUCS2Offset=function(t){return o(this.ucs2String.slice(0,Math.max(0,t))).length},e.prototype.slice=function(){var t;return this.constructor.fromCodepoints((t=this.codepoints).slice.apply(t,arguments))},e.prototype.charAt=function(t){return this.slice(t,t+1)},e.prototype.isEqualTo=function(t){return this.constructor.box(t).ucs2String===this.ucs2String},e.prototype.toJSON=function(){return this.ucs2String},e.prototype.getCacheKey=function(){return this.ucs2String},e.prototype.toString=function(){return this.ucs2String},e}(e.BasicObject),t=1===("function"==typeof Array.from?Array.from("\ud83d\udc7c").length:void 0),n=null!=("function"==typeof" ".codePointAt?" ".codePointAt(0):void 0),i=" \ud83d\udc7c"===("function"==typeof String.fromCodePoint?String.fromCodePoint(32,128124):void 0),o=t&&n?function(t){return Array.from(t).map(function(t){return t.codePointAt(0)})}:function(t){var e,n,i,o,r;for(o=[],e=0,i=t.length;i>e;)r=t.charCodeAt(e++),r>=55296&&56319>=r&&i>e&&(n=t.charCodeAt(e++),56320===(64512&n)?r=((1023&r)<<10)+(1023&n)+65536:e--),o.push(r);return o},r=i?function(t){return String.fromCodePoint.apply(String,t)}:function(t){var e,n,i;return e=function(){var e,o,r;for(r=[],e=0,o=t.length;o>e;e++)i=t[e],n="",i>65535&&(i-=65536,n+=String.fromCharCode(i>>>10&1023|55296),i=56320|1023&i),r.push(n+String.fromCharCode(i));return r}(),e.join("")}}.call(this),function(){}.call(this),function(){}.call(this),function(){e.config.lang={attachFiles:"Attach Files",bold:"Bold",bullets:"Bullets","byte":"Byte",bytes:"Bytes",captionPlaceholder:"Add a caption\u2026",code:"Code",heading1:"Heading",indent:"Increase Level",italic:"Italic",link:"Link",numbers:"Numbers",outdent:"Decrease Level",quote:"Quote",redo:"Redo",remove:"Remove",strike:"Strikethrough",undo:"Undo",unlink:"Unlink",url:"URL",urlPlaceholder:"Enter a URL\u2026",GB:"GB",KB:"KB",MB:"MB",PB:"PB",TB:"TB"}}.call(this),function(){e.config.css={attachment:"attachment",attachmentCaption:"attachment__caption",attachmentCaptionEditor:"attachment__caption-editor",attachmentMetadata:"attachment__metadata",attachmentMetadataContainer:"attachment__metadata-container",attachmentName:"attachment__name",attachmentProgress:"attachment__progress",attachmentSize:"attachment__size",attachmentToolbar:"attachment__toolbar",attachmentGallery:"attachment-gallery"}}.call(this),function(){var t;e.config.blockAttributes=t={"default":{tagName:"div",parse:!1},quote:{tagName:"blockquote",nestable:!0},heading1:{tagName:"h1",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:"pre",terminal:!0,text:{plaintext:!0}},bulletList:{tagName:"ul",parse:!1},bullet:{tagName:"li",listAttribute:"bulletList",group:!1,nestable:!0,test:function(n){return e.tagName(n.parentNode)===t[this.listAttribute].tagName}},numberList:{tagName:"ol",parse:!1},number:{tagName:"li",listAttribute:"numberList",group:!1,nestable:!0,test:function(n){return e.tagName(n.parentNode)===t[this.listAttribute].tagName}},attachmentGallery:{tagName:"div",exclusive:!0,terminal:!0,parse:!1,group:!1}}}.call(this),function(){var t,n;t=e.config.lang,n=[t.bytes,t.KB,t.MB,t.GB,t.TB,t.PB],e.config.fileSize={prefix:"IEC",precision:2,formatter:function(e){var i,o,r,s,a;switch(e){case 0:return"0 "+t.bytes;case 1:return"1 "+t.byte;default:return i=function(){switch(this.prefix){case"SI":return 1e3;case"IEC":return 1024}}
21851.call(this),o=Math.floor(Math.log(e)/Math.log(i)),r=e/Math.pow(i,o),s=r.toFixed(this.precision),a=s.replace(/0*$/,"").replace(/\.$/,""),a+" "+n[o]}}}}.call(this),function(){e.config.textAttributes={bold:{tagName:"strong",inheritable:!0,parser:function(t){var e;return e=window.getComputedStyle(t),"bold"===e.fontWeight||e.fontWeight>=600}},italic:{tagName:"em",inheritable:!0,parser:function(t){var e;return e=window.getComputedStyle(t),"italic"===e.fontStyle}},href:{groupTagName:"a",parser:function(t){var n,i,o;return n=e.AttachmentView.attachmentSelector,o="a:not("+n+")",(i=e.findClosestElementFromNode(t,{matchingSelector:o}))?i.getAttribute("href"):void 0}},strike:{tagName:"del",inheritable:!0},frozen:{style:{backgroundColor:"highlight"}}}}.call(this),function(){var t,n,i,o,r;r="[data-trix-serialize=false]",o=["contenteditable","data-trix-id","data-trix-store-key","data-trix-mutable","data-trix-placeholder","tabindex"],n="data-trix-serialized-attributes",i="["+n+"]",t=new RegExp("<!--block-->","g"),e.extend({serializers:{"application/json":function(t){var n;if(t instanceof e.Document)n=t;else{if(!(t instanceof HTMLElement))throw new Error("unserializable object");n=e.Document.fromHTML(t.innerHTML)}return n.toSerializableDocument().toJSONString()},"text/html":function(s){var a,u,c,l,h,p,d,f,g,m,v,y,b,A,C,x,w;if(s instanceof e.Document)l=e.DocumentView.render(s);else{if(!(s instanceof HTMLElement))throw new Error("unserializable object");l=s.cloneNode(!0)}for(A=l.querySelectorAll(r),h=0,g=A.length;g>h;h++)c=A[h],e.removeNode(c);for(p=0,m=o.length;m>p;p++)for(a=o[p],C=l.querySelectorAll("["+a+"]"),d=0,v=C.length;v>d;d++)c=C[d],c.removeAttribute(a);for(x=l.querySelectorAll(i),f=0,y=x.length;y>f;f++){c=x[f];try{u=JSON.parse(c.getAttribute(n)),c.removeAttribute(n);for(b in u)w=u[b],c.setAttribute(b,w)}catch(E){}}return l.innerHTML.replace(t,"")}},deserializers:{"application/json":function(t){return e.Document.fromJSONString(t)},"text/html":function(t){return e.Document.fromHTML(t)}},serializeToContentType:function(t,n){var i;if(i=e.serializers[n])return i(t);throw new Error("unknown content type: "+n)},deserializeFromContentType:function(t,n){var i;if(i=e.deserializers[n])return i(t);throw new Error("unknown content type: "+n)}})}.call(this),function(){var t;t=e.config.lang,e.config.toolbar={getDefaultHTML:function(){return'<div class="trix-button-row">\n <span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="'+t.bold+'" tabindex="-1">'+t.bold+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="'+t.italic+'" tabindex="-1">'+t.italic+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-strike" data-trix-attribute="strike" title="'+t.strike+'" tabindex="-1">'+t.strike+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-link" data-trix-attribute="href" data-trix-action="link" data-trix-key="k" title="'+t.link+'" tabindex="-1">'+t.link+'</button>\n </span>\n\n <span class="trix-button-group trix-button-group--block-tools" data-trix-button-group="block-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-heading-1" data-trix-attribute="heading1" title="'+t.heading1+'" tabindex="-1">'+t.heading1+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-quote" data-trix-attribute="quote" title="'+t.quote+'" tabindex="-1">'+t.quote+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-code" data-trix-attribute="code" title="'+t.code+'" tabindex="-1">'+t.code+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-bullet-list" data-trix-attribute="bullet" title="'+t.bullets+'" tabindex="-1">'+t.bullets+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-number-list" data-trix-attribute="number" title="'+t.numbers+'" tabindex="-1">'+t.numbers+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-decrease-nesting-level" data-trix-action="decreaseNestingLevel" title="'+t.outdent+'" tabindex="-1">'+t.outdent+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-increase-nesting-level" data-trix-action="increaseNestingLevel" title="'+t.indent+'" tabindex="-1">
21851'+t.indent+'</button>\n </span>\n\n <span class="trix-button-group trix-button-group--file-tools" data-trix-button-group="file-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-attach" data-trix-action="attachFiles" title="'+t.attachFiles+'" tabindex="-1">'+t.attachFiles+'</button>\n </span>\n\n <span class="trix-button-group-spacer"></span>\n\n <span class="trix-button-group trix-button-group--history-tools" data-trix-button-group="history-tools">\n <button type="button" class="trix-button trix-button--icon trix-button--icon-undo" data-trix-action="undo" data-trix-key="z" title="'+t.undo+'" tabindex="-1">'+t.undo+'</button>\n <button type="button" class="trix-button trix-button--icon trix-button--icon-redo" data-trix-action="redo" data-trix-key="shift+z" title="'+t.redo+'" tabindex="-1">'+t.redo+'</button>\n </span>\n</div>\n\n<div class="trix-dialogs" data-trix-dialogs>\n <div class="trix-dialog trix-dialog--link" data-trix-dialog="href" data-trix-dialog-attribute="href">\n <div class="trix-dialog__link-fields">\n <input type="url" name="href" class="trix-input trix-input--dialog" placeholder="'+t.urlPlaceholder+'" aria-label="'+t.url+'" required data-trix-input>\n <div class="trix-button-group">\n <input type="button" class="trix-button trix-button--dialog" value="'+t.link+'" data-trix-method="setAttribute">\n <input type="button" class="trix-button trix-button--dialog" value="'+t.unlink+'" data-trix-method="removeAttribute">\n </div>\n </div>\n </div>\n</div>'}}}.call(this),function(){e.config.undoInterval=5e3}.call(this),function(){e.config.attachments={preview:{presentation:"gallery",caption:{name:!0,size:!0}},file:{caption:{size:!0}}}}.call(this),function(){e.config.keyNames={8:"backspace",9:"tab",13:"return",27:"escape",37:"left",39:"right",46:"delete",68:"d",72:"h",79:"o"}}.call(this),function(){e.config.input={level2Enabled:!0,getLevel:function(){return this.level2Enabled&&e.browser.supportsInputEvents?2:0},pickFiles:function(t){var n;return n=e.makeElement("input",{type:"file",multiple:!0,hidden:!0,id:this.fileInputId}),n.addEventListener("change",function(){return t(n.files),e.removeNode(n)}),e.removeNode(document.getElementById(this.fileInputId)),document.body.appendChild(n),n.click()},fileInputId:"trix-file-input-"+Date.now().toString(16)}}.call(this),function(){}.call(this),function(){e.registerElement("trix-toolbar",{defaultCSS:"%t {\n display: block;\n}\n\n%t {\n white-space: nowrap;\n}\n\n%t [data-trix-dialog] {\n display: none;\n}\n\n%t [data-trix-dialog][data-trix-active] {\n display: block;\n}\n\n%t [data-trix-dialog] [data-trix-validate]:invalid {\n background-color: #ffdddd;\n}",initialize:function(){return""===this.innerHTML?this.innerHTML=e.config.toolbar.getDefaultHTML():void 0}})}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty,i=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};e.ObjectView=function(n){function o(t,e){this.object=t,this.options=null!=e?e:{},this.childViews=[],this.rootView=this}return t(o,n),o.prototype.getNodes=function(){var t,e,n,i,o;for(null==this.nodes&&(this.nodes=this.createNodes()),i=this.nodes,o=[],t=0,e=i.length;e>t;t++)n=i[t],o.push(n.cloneNode(!0));return o},o.prototype.invalidate=function(){var t;return this.nodes=null,this.childViews=[],null!=(t=this.parentView)?t.invalidate():void 0},o.prototype.invalidateViewForObject=function(t){var e;return null!=(e=this.findViewForObject(t))?e.invalidate():void 0},o.prototype.findOrCreateCachedChildView=function(t,e){var n;return(n=this.getCachedViewForObject(e))?this.recordChildView(n):(n=this.createChildView.apply(this,arguments),this.cacheViewForObject(n,e)),n},o.prototype.createChildView=function(t,n,i){var o;return null==i&&(i={}),n instanceof e.ObjectGroup&&(i.viewClass=t,t=e.ObjectGroupView),o=new t(n,i),this.recordChildView(o)},o.prototype.recordChildView=function(t){return t.parentView=this,t.rootView=this.root
21851View,this.childViews.push(t),t},o.prototype.getAllChildViews=function(){var t,e,n,i,o;for(o=[],i=this.childViews,e=0,n=i.length;n>e;e++)t=i[e],o.push(t),o=o.concat(t.getAllChildViews());return o},o.prototype.findElement=function(){return this.findElementForObject(this.object)},o.prototype.findElementForObject=function(t){var e;return(e=null!=t?t.id:void 0)?this.rootView.element.querySelector("[data-trix-id='"+e+"']"):void 0},o.prototype.findViewForObject=function(t){var e,n,i,o;for(i=this.getAllChildViews(),e=0,n=i.length;n>e;e++)if(o=i[e],o.object===t)return o},o.prototype.getViewCache=function(){return this.rootView!==this?this.rootView.getViewCache():this.isViewCachingEnabled()?null!=this.viewCache?this.viewCache:this.viewCache={}:void 0},o.prototype.isViewCachingEnabled=function(){return this.shouldCacheViews!==!1},o.prototype.enableViewCaching=function(){return this.shouldCacheViews=!0},o.prototype.disableViewCaching=function(){return this.shouldCacheViews=!1},o.prototype.getCachedViewForObject=function(t){var e;return null!=(e=this.getViewCache())?e[t.getCacheKey()]:void 0},o.prototype.cacheViewForObject=function(t,e){var n;return null!=(n=this.getViewCache())?n[e.getCacheKey()]=t:void 0},o.prototype.garbageCollectCachedViews=function(){var t,e,n,o,r,s;if(t=this.getViewCache()){s=this.getAllChildViews().concat(this),n=function(){var t,e,n;for(n=[],t=0,e=s.length;e>t;t++)r=s[t],n.push(r.object.getCacheKey());return n}(),o=[];for(e in t)i.call(n,e)<0&&o.push(delete t[e]);return o}},o}(e.BasicObject)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.ObjectGroupView=function(e){function n(){n.__super__.constructor.apply(this,arguments),this.objectGroup=this.object,this.viewClass=this.options.viewClass,delete this.options.viewClass}return t(n,e),n.prototype.getChildViews=function(){var t,e,n,i;if(!this.childViews.length)for(i=this.objectGroup.getObjects(),t=0,e=i.length;e>t;t++)n=i[t],this.findOrCreateCachedChildView(this.viewClass,n,this.options);return this.childViews},n.prototype.createNodes=function(){var t,e,n,i,o,r,s,a,u;for(t=this.createContainerElement(),s=this.getChildViews(),e=0,i=s.length;i>e;e++)for(u=s[e],a=u.getNodes(),n=0,o=a.length;o>n;n++)r=a[n],t.appendChild(r);return[t]},n.prototype.createContainerElement=function(t){return null==t&&(t=this.objectGroup.getDepth()),this.getChildViews()[0].createContainerElement(t)},n}(e.ObjectView)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.Controller=function(e){function n(){return n.__super__.constructor.apply(this,arguments)}return t(n,e),n}(e.BasicObject)}.call(this),function(){var t,n,i,o,r,s,a=function(t,e){return function(){return t.apply(e,arguments)}},u=function(t,e){function n(){this.constructor=t}for(var i in e)c.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},c={}.hasOwnProperty,l=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};t=e.findClosestElementFromNode,i=e.nodeIsEmptyTextNode,n=e.nodeIsBlockStartComment,o=e.normalizeSpaces,r=e.summarizeStringChange,s=e.tagName,e.MutationObserver=function(e){function c(t){this.element=t,this.didMutate=a(this.didMutate,this),this.observer=new window.MutationObserver(this.didMutate),this.start()}var h,p,d,f;return u(c,e),p="data-trix-mutable",d="["+p+"]",f={attributes:!0,childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0},c.prototype.start=function(){return this.reset(),this.observer.observe(this.element,f)},c.prototype.stop=function(){return this.observer.disconnect()},c.prototype.didMutate=function(t){var e,n;return(e=this.mutations).push.apply(e,this.findSignificantMutations(t)),this.mutations.length?(null!=(n=this.delegate)&&"function"==typeof n.elementDidMutate&&n.elementDidMutate(this.getMutationSummary()),this.reset()):void 0},c.prototype.reset=function(){return this.mutations=[]},c.prototype.findSignificantMutations=function(t){var e,n,i,o;for(o=[],e=0,n=t.length;n>e;e++)i=t[e],this.mutationIsSignificant(i)&&o.push(i);return o},c.prototype.mutationIsSignificant=function(t){var e,n,i,o;if(this.nodeIsMutable(t.target))return!1;for(o=this.nodesModifiedByMutation(t),e=0,n=o.length;n>e;e++)if(i=o[e],this.nodeIsSignificant(i))return!0;return!1},c.prototype.nodeIsSignificant=function(t){return t!==this.element&&!this.nodeIsMutable(t)&&!i(t)},c.prototype.nodeIsMutable=function(e){return t(e,{matchingSelector:d})},c.prototype.nodesModifiedByMutation=function(t){var e;switch(e=[],t.type){case"attributes":t.attributeName!==p&&e.push(t.target);break;case"characterData":e.push(t.target.parentNode),e.push(t.target);break;case"childList":e.push.apply(e,t.addedNodes),e.push.apply(e,t.removedNodes
21851)}return e},c.prototype.getMutationSummary=function(){return this.getTextMutationSummary()},c.prototype.getTextMutationSummary=function(){var t,e,n,i,o,r,s,a,u,c,h;for(a=this.getTextChangesFromCharacterData(),n=a.additions,o=a.deletions,h=this.getTextChangesFromChildList(),u=h.additions,r=0,s=u.length;s>r;r++)e=u[r],l.call(n,e)<0&&n.push(e);return o.push.apply(o,h.deletions),c={},(t=n.join(""))&&(c.textAdded=t),(i=o.join(""))&&(c.textDeleted=i),c},c.prototype.getMutationsByType=function(t){var e,n,i,o,r;for(o=this.mutations,r=[],e=0,n=o.length;n>e;e++)i=o[e],i.type===t&&r.push(i);return r},c.prototype.getTextChangesFromChildList=function(){var t,e,i,r,s,a,u,c,l,p,d;for(t=[],u=[],a=this.getMutationsByType("childList"),e=0,r=a.length;r>e;e++)s=a[e],t.push.apply(t,s.addedNodes),u.push.apply(u,s.removedNodes);return c=0===t.length&&1===u.length&&n(u[0]),c?(p=[],d=["\n"]):(p=h(t),d=h(u)),{additions:function(){var t,e,n;for(n=[],i=t=0,e=p.length;e>t;i=++t)l=p[i],l!==d[i]&&n.push(o(l));return n}(),deletions:function(){var t,e,n;for(n=[],i=t=0,e=d.length;e>t;i=++t)l=d[i],l!==p[i]&&n.push(o(l));return n}()}},c.prototype.getTextChangesFromCharacterData=function(){var t,e,n,i,s,a,u,c;return e=this.getMutationsByType("characterData"),e.length&&(c=e[0],n=e[e.length-1],s=o(c.oldValue),i=o(n.target.data),a=r(s,i),t=a.added,u=a.removed),{additions:t?[t]:[],deletions:u?[u]:[]}},h=function(t){var e,n,i,o;for(null==t&&(t=[]),o=[],e=0,n=t.length;n>e;e++)switch(i=t[e],i.nodeType){case Node.TEXT_NODE:o.push(i.data);break;case Node.ELEMENT_NODE:"br"===s(i)?o.push("\n"):o.push.apply(o,h(i.childNodes))}return o},c}(e.BasicObject)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.FileVerificationOperation=function(e){function n(t){this.file=t}return t(n,e),n.prototype.perform=function(t){var e;return e=new FileReader,e.onerror=function(){return t(!1)},e.onload=function(n){return function(){e.onerror=null;try{e.abort()}catch(i){}return t(!0,n.file)}}(this),e.readAsArrayBuffer(this.file)},n}(e.Operation)}.call(this),function(){var t,n,i=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},o={}.hasOwnProperty;t=e.handleEvent,n=e.innerElementIsActive,e.InputController=function(o){function r(n){var i;this.element=n,this.mutationObserver=new e.MutationObserver(this.element),this.mutationObserver.delegate=this;for(i in this.events)t(i,{onElement:this.element,withCallback:this.handlerFor(i)})}return i(r,o),r.prototype.events={},r.prototype.elementDidMutate=function(){},r.prototype.editorWillSyncDocumentView=function(){return this.mutationObserver.stop()},r.prototype.editorDidSyncDocumentView=function(){return this.mutationObserver.start()},r.prototype.requestRender=function(){var t;return null!=(t=this.delegate)&&"function"==typeof t.inputControllerDidRequestRender?t.inputControllerDidRequestRender():void 0},r.prototype.requestReparse=function(){var t;return null!=(t=this.delegate)&&"function"==typeof t.inputControllerDidRequestReparse&&t.inputControllerDidRequestReparse(),this.requestRender()},r.prototype.attachFiles=function(t){var n,i;return i=function(){var i,o,r;for(r=[],i=0,o=t.length;o>i;i++)n=t[i],r.push(new e.FileVerificationOperation(n));return r}(),Promise.all(i).then(function(t){return function(e){return t.handleInput(function(){var t,n;return null!=(t=this.delegate)&&t.inputControllerWillAttachFiles(),null!=(n=this.responder)&&n.insertFiles(e),this.requestRender()})}}(this))},r.prototype.handlerFor=function(t){return function(e){return function(i){return i.defaultPrevented?void 0:e.handleInput(function(){return n(this.element)?void 0:(this.eventName=t,this.events[t].call(this,i))})}}(this)},r.prototype.handleInput=function(t){var e,n;try{return null!=(e=this.delegate)&&e.inputControllerWillHandleInput(),t.call(this)}finally{null!=(n=this.delegate)&&n.inputControllerDidHandleInput()}},r.prototype.createLinkHTML=function(t,e){var n;return n=document.createElement("a"),n.href=t,n.textContent=null!=e?e:t,n.outerHTML},r}(e.BasicObject)}.call(this),function(){var t,n,i,o,r,s,a,u,c,l,h,p,d,f=function(t,e){function n(){this.constructor=t}for(var i in e)g.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},g={}.hasOwnProperty,m=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};c=e.makeElement,l=e.objectsAreEqual,d=e.tagName,n=e.browser,a=e.keyEventIsKeyboardCommand,o=e.dataTransferIsWritable,i=e.dataTransferIsPlainText,u=e.config.keyNames,e.Level0InputController=function(n){function s(){s.__super__.constructor.apply(this,arguments),this.resetInputSummary()}var d;return f(s,n),d=0,s.prototype.setInputSummary=function(t){var e,n;null==t&&(t={}),this.inputSummary.eventName=this.eventName;for(e in t)n=t[e],this.inputSummary[e]=n;return this.inputSummary},s.prototype.resetInputSummary=function(){return this.inputSummary={}},s.prototype.reset=function(){return this.resetInputSummary(),e.selectionChangeObserver.reset()},s.prototype.elementDidMutate=function(t){var e;return this.isComposing()?null!=(e=this.delegate)&&"function"==typeof e.inputControllerDidAllowUnhandledInput?e.inputControllerDidAllowUnhandledInput():void 0:this.handleInput(function(){return this.mutationIsSignificant(t)&&(this.mutationIsExpected(t)?this.requestRender():this.requestReparse()),this.reset()})},s.prototype.mutationIsExpected=function(t){var e,n,i,o,r,s,a,u,c,l;return a=t.textAdded,u=t.textDeleted,this.inputSummary.preferDocument?!0:(e=null!=a?a===this.inputSummary.textAdded:!this.inputSummary.textAdded,n=null!=u?this.inputSummary.didDelete:!this.inputSummary.didDelete,c=("\n"===a||" \n"===a)&&!e,l="\n"===u&&!n,s=c&&!l||l&&!c,s&&(o=this.getSelectedRange())&&(i=c?a.replace(/\n$/,"").length||-1:(null!=a?a.length:void 0)||1,null!=(r=this.responder)?r.positionIsBlockBreak(o[1]+i):void 0)?!0:e&&n)},s.prototype.mutationIsSignificant=function(t){var e,n,i;return i=Object.keys(t).length>0,e=""===(null!=(n=this.compositionInput)?n.getEndData():void 0),i||
21851!e},s.prototype.events={keydown:function(t){var n,i,o,r,s,c,l,h,p;if(this.isComposing()||this.resetInputSummary(),this.inputSummary.didInput=!0,r=u[t.keyCode]){for(i=this.keys,h=["ctrl","alt","shift","meta"],o=0,c=h.length;c>o;o++)l=h[o],t[l+"Key"]&&("ctrl"===l&&(l="control"),i=null!=i?i[l]:void 0);null!=(null!=i?i[r]:void 0)&&(this.setInputSummary({keyName:r}),e.selectionChangeObserver.reset(),i[r].call(this,t))}return a(t)&&(n=String.fromCharCode(t.keyCode).toLowerCase())&&(s=function(){var e,n,i,o;for(i=["alt","shift"],o=[],e=0,n=i.length;n>e;e++)l=i[e],t[l+"Key"]&&o.push(l);return o}(),s.push(n),null!=(p=this.delegate)?p.inputControllerDidReceiveKeyboardCommand(s):void 0)?t.preventDefault():void 0},keypress:function(t){var e,n,i;if(null==this.inputSummary.eventName&&!t.metaKey&&(!t.ctrlKey||t.altKey))return(i=p(t))?(null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),null!=(n=this.responder)&&n.insertString(i),this.setInputSummary({textAdded:i,didDelete:this.selectionIsExpanded()})):void 0},textInput:function(t){var e,n,i,o;return e=t.data,o=this.inputSummary.textAdded,o&&o!==e&&o.toUpperCase()===e?(n=this.getSelectedRange(),this.setSelectedRange([n[0],n[1]+o.length]),null!=(i=this.responder)&&i.insertString(e),this.setInputSummary({textAdded:e}),this.setSelectedRange(n)):void 0},dragenter:function(t){return t.preventDefault()},dragstart:function(t){var e,n;return n=t.target,this.serializeSelectionToDataTransfer(t.dataTransfer),this.draggedRange=this.getSelectedRange(),null!=(e=this.delegate)&&"function"==typeof e.inputControllerDidStartDrag?e.inputControllerDidStartDrag():void 0},dragover:function(t){var e,n;return!this.draggedRange&&!this.canAcceptDataTransfer(t.dataTransfer)||(t.preventDefault(),e={x:t.clientX,y:t.clientY},l(e,this.draggingPoint))?void 0:(this.draggingPoint=e,null!=(n=this.delegate)&&"function"==typeof n.inputControllerDidReceiveDragOverPoint?n.inputControllerDidReceiveDragOverPoint(this.draggingPoint):void 0)},dragend:function(){var t;return null!=(t=this.delegate)&&"function"==typeof t.inputControllerDidCancelDrag&&t.inputControllerDidCancelDrag(),this.draggedRange=null,this.draggingPoint=null},drop:function(t){var n,i,o,r,s,a,u,c,l;return t.preventDefault(),o=null!=(s=t.dataTransfer)?s.files:void 0,r={x:t.clientX,y:t.clientY},null!=(a=this.responder)&&a.setLocationRangeFromPointRange(r),(null!=o?o.length:void 0)?this.attachFiles(o):this.draggedRange?(null!=(u=this.delegate)&&u.inputControllerWillMoveText(),null!=(c=this.responder)&&c.moveTextFromRange(this.draggedRange),this.draggedRange=null,this.requestRender()):(i=t.dataTransfer.getData("application/x-trix-document"))&&(n=e.Document.fromJSONString(i),null!=(l=this.responder)&&l.insertDocument(n),this.requestRender()),this.draggedRange=null,this.draggingPoint=null},cut:function(t){var e,n;return(null!=(e=this.responder)?e.selectionIsExpanded():void 0)&&(this.serializeSelectionToDataTransfer(t.clipboardData)&&t.preventDefault(),null!=(n=this.delegate)&&n.inputControllerWillCutText(),this.deleteInDirection("backward"),t.defaultPrevented)?this.requestRender():void 0},copy:function(t){var e;return(null!=(e=this.responder)?e.selectionIsExpanded():void 0)&&this.serializeSelectionToDataTransfer(t.clipboardData)?t.preventDefault():void 0},paste:function(t){var n,o,s,a,u,c,l,p,f,g,v,y,b,A,C,x,w,E,S,R,k,D,L;return n=null!=(p=t.clipboardData)?p:t.testClipboardData,l={clipboard:n},null==n||h(t)?void this.getPastedHTMLUsingHiddenElement(function(t){return function(e){var n,i,o;return l.type="text/html",l.html=e,null!=(n=t.delegate)&&n.inputControllerWillPaste(l),null!=(i=t.responder)&&i.insertHTML(l.html),t.requestRender(),null!=(o=t.delegate)?o.inputControllerDidPaste(l):void 0}}(this)):((a=n.getData("URL"))?(l.type="text/html",L=(c=n.getData("public.url-name"))?e.squishBreakableWhitespace(c).trim():a,l.html=this.createLinkHTML(a,L),null!=(f=this.delegate)&&f.inputControllerWillPaste(l),this.setInputSummary({textAdded:L,didDelete:this.selectionIsExpanded()}),null!=(C=this.responder)&&C.insertHTML(l.html),this.requestRender(),null!=(x=this.delegate)&&x.inputControllerDidPaste(l)):i(n)?(l.type="text/plain",l.string=n.getData("text/plain"),null!=(w=this.delegate)&&w.inputControllerWillPaste(l),this.setInputSummary({textAdded:l.string,didDelete:this.selectionIsExpanded()}),null!=(E=this.responder)&&E.insertString(l.string),this.requestRender(),null!=(S=this.delegate)&&S.inputControllerDidPaste(l)):(u=n.getData("text/html"))?(l.type="text/html",l.html=u,null!=(R=this.delegate)&&R.inputControllerWillPaste(l),null!=(k=this.responder)&&k.insertHTML(l.html),this.requestRender(),null!=(D=this.delegate)&&D.inputControllerDidPaste(l)):m.call(n.types,"Files")>=0&&(s=null!=(g=n.items)&&null!=(v=g[0])&&"function"==typeof v.getAsFile?v.getAsFile():void 0)&&(!s.name&&(o=r(s))&&(s.name="pasted-file-"+ ++d+"."+o),l.type="File",l.file=s,null!=(y=this.delegate)&&y.inputControllerWillAttachFiles(),null!=(b=this.responder)&&b.insertFile(l.file),this.requestRender(),null!=(A=this.delegate)&&A.inputControllerDidPaste(l)),t.preventDefault())},compositionstart:function(t){return this.getCompositionInput().start(t.data)},compositionupdate:function(t){return this.getCompositionInput().update(t.data)},compositionend:function(t){return this.getCompositionInput().end(t.data)}
21851,beforeinput:function(){return this.inputSummary.didInput=!0 21852},input:function(t){return this.inputSummary.didInput=!0,t.stopPropagation()}},s.prototype.keys={backspace:function(t){var e;return null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},"delete":function(t){var e;return null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},"return":function(){var t,e;return this.setInputSummary({preferDocument:!0}),null!=(t=this.delegate)&&t.inputControllerWillPerformTyping(),null!=(e=this.responder)?e.insertLineBreak():void 0},tab:function(t){var e,n;return(null!=(e=this.responder)?e.canIncreaseNestingLevel():void 0)?(null!=(n=this.responder)&&n.increaseNestingLevel(),this.requestRender(),t.preventDefault()):void 0},left:function(t){var e;return this.selectionIsInCursorTarget()?(t.preventDefault(),null!=(e=this.responder)?e.moveCursorInDirection("backward"):void 0):void 0},right:function(t){var e;return this.selectionIsInCursorTarget()?(t.preventDefault(),null!=(e=this.responder)?e.moveCursorInDirection("forward"):void 0):void 0},control:{d:function(t){var e;return null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},h:function(t){var e;return null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},o:function(t){var e,n;return t.preventDefault(),null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),null!=(n=this.responder)&&n.insertString("\n",{updatePosition:!1}),this.requestRender()}},shift:{"return":function(t){var e,n;return null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),null!=(n=this.responder)&&n.insertString("\n"),this.requestRender(),t.preventDefault()},tab:function(t){var e,n;return(null!=(e=this.responder)?e.canDecreaseNestingLevel():void 0)?(null!=(n=this.responder)&&n.decreaseNestingLevel(),this.requestRender(),t.preventDefault()):void 0},left:function(t){return this.selectionIsInCursorTarget()?(t.preventDefault(),this.expandSelectionInDirection("backward")):void 0},right:function(t){return this.selectionIsInCursorTarget()?(t.preventDefault(),this.expandSelectionInDirection("forward")):void 0}},alt:{backspace:function(){var t;return this.setInputSummary({preferDocument:!1}),null!=(t=this.delegate)?t.inputControllerWillPerformTyping():void 0}},meta:{backspace:function(){var t;return this.setInputSummary({preferDocument:!1}),null!=(t=this.delegate)?t.inputControllerWillPerformTyping():void 0}}},s.prototype.getCompositionInput=function(){return this.isComposing()?this.compositionInput:this.compositionInput=new t(this)},s.prototype.isComposing=function(){return null!=this.compositionInput&&!this.compositionInput.isEnded()},s.prototype.deleteInDirection=function(t,e){var n;return(null!=(n=this.responder)?n.deleteInDirection(t):void 0)!==!1?this.setInputSummary({didDelete:!0}):e?(e.preventDefault(),this.requestRender()):void 0},s.prototype.serializeSelectionToDataTransfer=function(t){var n,i;if(o(t))return n=null!=(i=this.responder)?i.getSelectedDocument().toSerializableDocument():void 0,t.setData("application/x-trix-document",JSON.stringify(n)),t.setData("text/html",e.DocumentView.render(n).innerHTML),t.setData("text/plain",n.toString().replace(/\n$/,"")),!0},s.prototype.canAcceptDataTransfer=function(t){var e,n,i,o,r,s;for(s={},o=null!=(i=null!=t?t.types:void 0)?i:[],e=0,n=o.length;n>e;e++)r=o[e],s[r]=!0;return s.Files||s["application/x-trix-document"]||s["text/html"]||s["text/plain"]},s.prototype.getPastedHTMLUsingHiddenElement=function(t){var n,i,o;return i=this.getSelectedRange(),o={position:"absolute",left:window.pageXOffset+"px",top:window.pageYOffset+"px",opacity:0},n=c({style:o,tagName:"div",editable:!0}),document.body.appendChild(n),n.focus(),requestAnimationFrame(function(o){return function(){var r;return r=n.innerHTML,e.removeNode(n),o.setSelectedRange(i),t(r)}}(this))},s.proxyMethod("responder?.getSelectedRange"),s.proxyMethod("responder?.setSelectedRange"),s.proxyMethod("responder?.expandSelectionInDirection"),s.proxyMethod("responder?.selectionIsInCursorTarget"),s.proxyMethod("responder?.selectionIsExpanded"),s}(e.InputController),r=function(t){var e,n;return null!=(e=t.type)&&null!=(n=e.match(/\/(\w+)$/))?n[1]:void 0},s=null!=("function"==typeof" ".codePointAt?" ".codePointAt(0):void 0),p=function(t){var n;return t.key&&s&&t.key.codePointAt(0)===t.keyCode?t.key:(null===t.which?n=t.keyCode:0!==t.which&&0!==t.charCode&&(n=t.charCode),null!=n&&"escape"!==u[n]?e.UTF16String.fromCodepoints([n]).toString():void 0)},h=function(t){var e,n,i,o,r,s,a,u,c,l;if(u=t.clipboardData){if(m.call(u.types,"text/html")>=0){for(c=u.types,i=0,s=c.length;s>i;i++)if(l=c[i],e=/^CorePasteboardFlavorType/.test(l),n=/^dyn\./.test(l)&&u.getData(l),a=e||n)return!0;return!1}return o=m.call(u.types,"com.apple.webarchive")>=0,r=m.call(u.types,"com.apple.flat-rtfd")>=0,o||r}},t=function(t){function e(t){var e;this.inputController=t,e=this.inputController,this.responder=e.responder,this.delegate=e.delegate,this.inputSummary=e.inputSummary,this.data={}}return f(e,t),e.prototype.start=function(t){var e,n;return this.data.start=t,this.isSignificant()?("keypress"===this.inputSummary.eventName&&this.inputSummary.textAdded&&null!=(e=this.responder)&&e.deleteInDirection("left"),this.selectionIsExpanded()||(this.insertPlaceholder(),this.requestRender()),this.range=null!=(n=this.responder)?n.getSelectedRange():void 0):void 0},e.prototype.update=function(t){var e;return this.data.update=t,this.isSignificant()&&(e=this.selectPlaceholder())?(this.forgetPlaceholder(),this.range=e):void 0},e.prototype.end=function(t){var e,n,i,o;return this.data.end=t,this.isSignificant()?(this.forgetPlaceholder(),this.canApplyToDocument()?(this.setInputSummary({preferDocument:!0,didInput:!1}),null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),null!=(n=this.responder)&&n.setSelectedRange(this.range),null!=(i=this.responder)&&i.insertString(this.data.end),null!=(o=this.responder)?o.setSelectedRange(this.range[0]+this.data.end.length):void 0):null!=this.data.start||null!=this.data.update?(this.requestReparse(),this.inputController.reset()):void 0):this.inputController.reset()},e.prototype.getEndData=function(){return this.data.end},e.prototype.isEnded=function(){return null!=this.getEndData()},e.prototype.isSignificant=function(){return n.composesExistingText?this.inputSummary.didInput:!0},e.prototype.canApplyToDocument=function(){var t,e;return 0===(null!=(t=this.data.start)?t.length:void 0)&&(null!=(e=this.data.end)?e.length:void 0)>0&&null!=this.range},e.proxyMethod("inputController.setInputSummary"),e.proxyMethod("inputController.requestRender"),e.proxyMethod("inputController.requestReparse"),e.proxyMethod("responder?.selectionIsExpanded"),e.proxyMethod("responder?.insertPlaceholder"),e.proxyMethod("responder?.selectPlaceholder"),e.proxyMethod("responder?.forgetPlaceholder"),e}(e.BasicObject)}.call(this),function(){var t,n,i,o=function(t,e){return function(){return t.apply(e,arguments)}},r=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},s={}.hasOwnProperty,a=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};t=e.dataTransferIsPlainText,n=e.keyEventIsKeyboardCommand,i=e.objectsAreEqual,e.Level2InputController=function(s){function u(){return this.render=o(this.render,this),u.__super__.constructor.apply(this,arguments)}var c,l,h,p,d,f;return r(u,s),u.prototype.elementDidMutate=function(){var t;return this.scheduledRender?this.composing&&null!=(t=this.delegate)&&"function"==typeof t.inputControllerDidAllowUnhandledInput?t.inputControllerDidAllowUnhandledInput():void 0:this.reparse()},u.prototype.scheduleRender=function(){return null!=this.scheduledRender?this.scheduledRender:this.scheduledRender=requestAnimationFrame(this.render)},u.prototype.render=function(){var t;return cancelAnimationFrame(this.scheduledRender),this.scheduledRender=null,this.composing||null!=(t=this.delegate)&&t.render(),"function"==typeof this.afterRender&&this.afterRender(),this.afterRender=null},u.prototype.reparse=function(){var t;return null!=(t=this.delegate)?t.reparse():void 0},u.prototype.events={keydown:function(t){var e,i,o,r;if(n(t)){if(e=l(t),null!=(r=this.delegate)?r.inputControllerDidReceiveKeyboardCommand(e):void 0)return t.preventDefault()}
21852else if(o=t.key,t.altKey&&(o+="+Alt"),t.shiftKey&&(o+="+Shift"),i=this.keys[o])return this.withEvent(t,i)},paste:function(t){var e,n,i,o,r,s,a,u,c;return h(t)?(t.preventDefault(),this.attachFiles(t.clipboardData.files)):p(t)?(t.preventDefault(),n={type:"text/plain",string:t.clipboardData.getData("text/plain")},null!=(i=this.delegate)&&i.inputControllerWillPaste(n),null!=(o=this.responder)&&o.insertString(n.string),this.render(),null!=(r=this.delegate)?r.inputControllerDidPaste(n):void 0):(e=null!=(s=t.clipboardData)?s.getData("URL"):void 0)?(t.preventDefault(),n={type:"text/html",html:this.createLinkHTML(e)},null!=(a=this.delegate)&&a.inputControllerWillPaste(n),null!=(u=this.responder)&&u.insertHTML(n.html),this.render(),null!=(c=this.delegate)?c.inputControllerDidPaste(n):void 0):void 0},beforeinput:function(t){var e;return(e=this.inputTypes[t.inputType])?(this.withEvent(t,e),this.scheduleRender()):void 0},input:function(){return e.selectionChangeObserver.reset()},dragstart:function(t){var e,n;return(null!=(e=this.responder)?e.selectionContainsAttachments():void 0)?(t.dataTransfer.setData("application/x-trix-dragging",!0),this.dragging={range:null!=(n=this.responder)?n.getSelectedRange():void 0,point:d(t)}):void 0},dragenter:function(t){return c(t)?t.preventDefault():void 0},dragover:function(t){var e,n;if(this.dragging){if(t.preventDefault(),e=d(t),!i(e,this.dragging.point))return this.dragging.point=e,null!=(n=this.responder)?n.setLocationRangeFromPointRange(e):void 0}else if(c(t))return t.preventDefault()},drop:function(t){var e,n,i,o;return this.dragging?(t.preventDefault(),null!=(n=this.delegate)&&n.inputControllerWillMoveText(),null!=(i=this.responder)&&i.moveTextFromRange(this.dragging.range),this.dragging=null,this.scheduleRender()):c(t)?(t.preventDefault(),e=d(t),null!=(o=this.responder)&&o.setLocationRangeFromPointRange(e),this.attachFiles(t.dataTransfer.files)):void 0},dragend:function(){var t;return this.dragging?(null!=(t=this.responder)&&t.setSelectedRange(this.dragging.range),this.dragging=null):void 0},compositionend:function(){return this.composing?(this.composing=!1,this.scheduleRender()):void 0}},u.prototype.keys={ArrowLeft:function(){var t,e;return(null!=(t=this.responder)?t.shouldManageMovingCursorInDirection("backward"):void 0)?(this.event.preventDefault(),null!=(e=this.responder)?e.moveCursorInDirection("backward"):void 0):void 0},ArrowRight:function(){var t,e;return(null!=(t=this.responder)?t.shouldManageMovingCursorInDirection("forward"):void 0)?(this.event.preventDefault(),null!=(e=this.responder)?e.moveCursorInDirection("forward"):void 0):void 0},Backspace:function(){var t,e,n;return(null!=(t=this.responder)?t.shouldManageDeletingInDirection("backward"):void 0)?(this.event.preventDefault(),null!=(e=this.delegate)&&e.inputControllerWillPerformTyping(),null!=(n=this.responder)&&n.deleteInDirection("backward"),this.render()):void 0},Tab:function(){var t,e;return(null!=(t=this.responder)?t.canIncreaseNestingLevel():void 0)?(this.event.preventDefault(),null!=(e=this.responder)&&e.increaseNestingLevel(),this.render()):void 0},"Tab+Shift":function(){var t,e;return(null!=(t=this.responder)?t.canDecreaseNestingLevel():void 0)?(this.event.preventDefault(),null!=(e=this.responder)&&e.decreaseNestingLevel(),this.render()):void 0}},u.prototype.inputTypes={deleteByComposition:function(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteByCut:function(){return this.deleteInDirection("backward")},deleteByDrag:function(){return this.event.preventDefault(),this.withTargetDOMRange(function(){var t;return this.deleteByDragRange=null!=(t=this.responder)?t.getSelectedRange():void 0})},deleteCompositionText:function(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteContent:function(){return this.deleteInDirection("backward")},deleteContentBackward:function(){return this.deleteInDirection("backward")},deleteContentForward:function(){return this.deleteInDirection("forward")},deleteEntireSoftLine:function(){return this.deleteInDirection("forward")},deleteHardLineBackward:function(){return this.deleteInDirection("backward")},deleteHardLineForward:function(){return this.deleteInDirection("forward")},deleteSoftLineBackward:function(){return this.deleteInDirection("backward")},deleteSoftLineForward:function(){return this.deleteInDirection("forward")},deleteWordBackward:function(){return this.deleteInDirection("backward")}
21852,deleteWordForward:function(){return this.deleteInDirection("forward")},formatBackColor:function(){return this.activateAttributeIfSupported("backgroundColor",this.event.data)},formatBold:function(){return this.toggleAttributeIfSupported("bold")},formatFontColor:function(){return this.activateAttributeIfSupported("color",this.event.data)},formatFontName:function(){return this.activateAttributeIfSupported("font",this.event.data)},formatIndent:function(){var t;return(null!=(t=this.responder)?t.canIncreaseNestingLevel():void 0)?this.withTargetDOMRange(function(){var t;return null!=(t=this.responder)?t.increaseNestingLevel():void 0}):void 0},formatItalic:function(){return this.toggleAttributeIfSupported("italic")},formatJustifyCenter:function(){return this.toggleAttributeIfSupported("justifyCenter")},formatJustifyFull:function(){return this.toggleAttributeIfSupported("justifyFull")},formatJustifyLeft:function(){return this.toggleAttributeIfSupported("justifyLeft")},formatJustifyRight:function(){return this.toggleAttributeIfSupported("justifyRight")},formatOutdent:function(){var t;return(null!=(t=this.responder)?t.canDecreaseNestingLevel():void 0)?this.withTargetDOMRange(function(){var t;return null!=(t=this.responder)?t.decreaseNestingLevel():void 0}):void 0},formatRemove:function(){return this.withTargetDOMRange(function(){var t,e,n,i;i=[];for(t in null!=(e=this.responder)?e.getCurrentAttributes():void 0)i.push(null!=(n=this.responder)?n.removeCurrentAttribute(t):void 0);return i})},formatSetBlockTextDirection:function(){return this.activateAttributeIfSupported("blockDir",this.event.data)},formatSetInlineTextDirection:function(){return this.activateAttributeIfSupported("textDir",this.event.data)},formatStrikeThrough:function(){return this.toggleAttributeIfSupported("strike")},formatSubscript:function(){return this.toggleAttributeIfSupported("sub")},formatSuperscript:function(){return this.toggleAttributeIfSupported("sup")},formatUnderline:function(){return this.toggleAttributeIfSupported("underline")},historyRedo:function(){var t;return null!=(t=this.delegate)?t.inputControllerWillPerformRedo():void 0},historyUndo:function(){var t;return null!=(t=this.delegate)?t.inputControllerWillPerformUndo():void 0},insertCompositionText:function(){return this.composing=!0,this.insertString(this.event.data)},insertFromComposition:function(){return this.composing=!1,this.insertString(this.event.data)},insertFromDrop:function(){var t,e;return(t=this.deleteByDragRange)?(this.deleteByDragRange=null,null!=(e=this.delegate)&&e.inputControllerWillMoveText(),this.withTargetDOMRange(function(){var e;return null!=(e=this.responder)?e.moveTextFromRange(t):void 0})):void 0},insertFromPaste:function(){var n,i,o,r,s,a,u,c,l,h,p;return n=this.event.dataTransfer,s={dataTransfer:n},(i=n.getData("URL"))?(this.event.preventDefault(),s.type="text/html",p=(r=n.getData("public.url-name"))?e.squishBreakableWhitespace(r).trim():i,s.html=this.createLinkHTML(i,p),null!=(a=this.delegate)&&a.inputControllerWillPaste(s),this.withTargetDOMRange(function(){var t;return null!=(t=this.responder)?t.insertHTML(s.html):void 0}),this.afterRender=function(t){return function(){var e;return null!=(e=t.delegate)?e.inputControllerDidPaste(s):void 0}}(this)):t(n)?(s.type="text/plain",s.string=n.getData("text/plain"),null!=(u=this.delegate)&&u.inputControllerWillPaste(s),this.withTargetDOMRange(function(){var t;return null!=(t=this.responder)?t.insertString(s.string):void 0}),this.afterRender=function(t){return function(){var e;return null!=(e=t.delegate)?e.inputControllerDidPaste(s):void 0}}(this)):(o=n.getData("text/html"))?(this.event.preventDefault(),s.type="text/html",s.html=o,null!=(c=this.delegate)&&c.inputControllerWillPaste(s),this.withTargetDOMRange(function(){var t;return null!=(t=this.responder)?t.insertHTML(s.html):void 0}),this.afterRender=function(t){return function(){var e;return null!=(e=t.delegate)?e.inputControllerDidPaste(s):void 0}}(this)):(null!=(l=n.files)?l.length:void 0)?(s.type="File",s.file=n.files[0],null!=(h=this.delegate)&&h.inputControllerWillPaste(s),this.withTargetDOMRange(function(){var t;return null!=(t=this.responder)?t.insertFile(s.file):void 0}),this.afterRender=function(t){return function(){var e;return null!=(e=t.delegate)?e.inputControllerDidPaste(s):void 0}}(this)):void 0},insertFromYank:function(){return this.insertString(this.event.data)},insertLineBreak:function(){return this.insertString("\n")},insertLink:function(){return this.activateAttributeIfSupported("href",this.event.data)},insertOrderedList:function(){return this.toggleAttributeIfSupported("number")},insertParagraph:function(){var t;return null!=(t=this.delegate)&&t.inputControllerWillPerformTyping(),this.withTargetDOMRange(function(){var t;return null!=(t=this.responder)?t.insertLineBreak():void 0})},insertReplacementText:function(){return this.insertString(this.event.dataTransfer.getData("text/plain"),{updatePosition:!1})},insertText:function(){var t,e;return this.insertString(null!=(t=this.event.data)?t:null!=(e=this.event.dataTransfer)?e.getData("text/plain"):void 0)},insertTranspose:function(){return this.insertString(this.event.data)},insertUnorderedList:function(){return this.toggleAttributeIfSupported("bullet")}},u.prototype.insertString=function(t,e){var n;return null==t&&(t=""),null!=(n=this.delegate)&&n.inputControllerWillPerformTyping(),this.withTargetDOMRange(function(){var n;return null!=(n=this.responder)?n.insertString(t,e):void 0})},u.prototype.toggleAttributeIfSupported=function(t){var n;return a.call(e.getAllAttributeNames(),t)>=0?(null!=(n=this.delegate)&&n.inputControllerWillPerformFormatting(t),this.withTargetDOMRange(function(){var e;return null!=(e=this.responder)?e.toggleCurrentAttribute(t):void 0})):void 0},u.prototype.activateAttributeIfSupported=function(t,n){var i;return a.call(e.getAllAttributeNames(),t)>=0?(null!=(i=this.delegate)&&i.inputControllerWillPerformFormatting(t),this.withTargetDOMRange(function(){var e;return null!=(e=this.responder)?e.setCurrentAttribute(t,n):void 0})):void 0},u.prototype.deleteInDirection=function(t,e){var n,i,o,r;return o=(null!=e?e:{recordUndoEntry:!0}).recordUndoEntry,o&&null!=(r=this.delegate)&&r.inputControllerWillPerformTyping(),i=function(e){return function(){var n;return null!=(n=e.responder)?n.deleteInDirection(t):void 0}}(this),(n=this.getTargetDOMRange({minLength:2}))?this.withTargetDOMRange(n,i):i()},u.prototype.withTargetDOMRange=function(t,n){var i;return"function"==typeof t&&(n=t,t=this.getTargetDOMRange()),t?null!=(i=this.responder)?i.withTargetDOMRange(t,n.bind(this)):void 0:(e.selectionChangeObserver.reset(),n.call(this))},u.prototype.getTargetDOMRange=function(t){var e,n,i,o;return i=(null!=t?t:{minLength:0}).minLength,(o="function"==typeof(e=this.event).getTargetRanges?e.getTargetRanges():void 0)&&o.length&&(n=f(o[0]),0===i||n.toString().length>=i)?n:void 0},f=function(t){var e;return e=document.createRange(),e.setStart(t.startContainer,t.startOffset),e.setEnd(t.endContainer,t.endOffset),e},u.prototype.withEvent=function(t,e){var n;this.event=t;try{n=e.call(this)}finally{this.event=null}return n},c=function(t){var e,n;return a.call(null!=(e=null!=(n=t.dataTransfer)?n.types:void 0)?e:[],"Files")>=0},h=function(t){var e;
21852return(e=t.clipboardData)?a.call(e.types,"Files")>=0&&1===e.types.length&&e.files.length>=1:void 0},p=function(t){var e;return(e=t.clipboardData)?a.call(e.types,"text/plain")>=0&&1===e.types.length:void 0},l=function(t){var e;return e=[],t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),e.push(t.key),e},d=function(t){return{x:t.clientX,y:t.clientY}},u}(e.InputController)}.call(this),function(){var t,n,i,o,r,s,a,u,c=function(t,e){return function(){return t.apply(e,arguments)}},l=function(t,e){function n(){this.constructor=t}for(var i in e)h.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},h={}.hasOwnProperty;n=e.defer,i=e.handleEvent,s=e.makeElement,u=e.tagName,a=e.config,r=a.lang,t=a.css,o=a.keyNames,e.AttachmentEditorController=function(a){function h(t,e,n,i){this.attachmentPiece=t,this.element=e,this.container=n,this.options=null!=i?i:{},this.didBlurCaption=c(this.didBlurCaption,this),this.didChangeCaption=c(this.didChangeCaption,this),this.didInputCaption=c(this.didInputCaption,this),this.didKeyDownCaption=c(this.didKeyDownCaption,this),this.didClickActionButton=c(this.didClickActionButton,this),this.didClickToolbar=c(this.didClickToolbar,this),this.attachment=this.attachmentPiece.attachment,"a"===u(this.element)&&(this.element=this.element.firstChild),this.install()}var p;return l(h,a),p=function(t){return function(){var e;return e=t.apply(this,arguments),e["do"](),null==this.undos&&(this.undos=[]),this.undos.push(e.undo)}},h.prototype.install=function(){return this.makeElementMutable(),this.addToolbar(),this.attachment.isPreviewable()?this.installCaptionEditor():void 0},h.prototype.uninstall=function(){var t,e;for(this.savePendingCaption();e=this.undos.pop();)e();return null!=(t=this.delegate)?t.didUninstallAttachmentEditor(this):void 0},h.prototype.savePendingCaption=function(){var t,e,n;return null!=this.pendingCaption?(t=this.pendingCaption,this.pendingCaption=null,t?null!=(e=this.delegate)&&"function"==typeof e.attachmentEditorDidRequestUpdatingAttributesForAttachment?e.attachmentEditorDidRequestUpdatingAttributesForAttachment({caption:t},this.attachment):void 0:null!=(n=this.delegate)&&"function"==typeof n.attachmentEditorDidRequestRemovingAttributeForAttachment?n.attachmentEditorDidRequestRemovingAttributeForAttachment("caption",this.attachment):void 0):void 0},h.prototype.makeElementMutable=p(function(){return{"do":function(t){return function(){return t.element.dataset.trixMutable=!0}}(this),undo:function(t){return function(){return delete t.element.dataset.trixMutable}}(this)}}),h.prototype.addToolbar=p(function(){var n;return n=s({tagName:"div",className:t.attachmentToolbar,data:{trixMutable:!0},childNodes:s({tagName:"div",className:"trix-button-row",childNodes:s({tagName:"span",className:"trix-button-group trix-button-group--actions",childNodes:s({tagName:"button",className:"trix-button trix-button--remove",textContent:r.remove,attributes:{title:r.remove},data:{trixAction:"remove"}})})})}),this.attachment.isPreviewable()&&n.appendChild(s({tagName:"div",className:t.attachmentMetadataContainer,childNodes:s({tagName:"span",className:t.attachmentMetadata,childNodes:[s({tagName:"span",className:t.attachmentName,textContent:this.attachment.getFilename(),attributes:{title:this.attachment.getFilename()}}),s({tagName:"span",className:t.attachmentSize,textContent:this.attachment.getFormattedFilesize()})]})})),i("click",{onElement:n,withCallback:this.didClickToolbar}),i("click",{onElement:n,matchingSelector:"[data-trix-action]",withCallback:this.didClickActionButton}),{"do":function(t){return function(){return t.element.appendChild(n)}}(this),undo:function(){return function(){return e.removeNode(n)}}(this)}}),h.prototype.installCaptionEditor=p(function(){var o,a,u,c,l;return c=s({tagName:"textarea",className:t.attachmentCaptionEditor,attributes:{placeholder:r.captionPlaceholder},data:{trixMutable:!0}}),c.value=this.attachmentPiece.getCaption(),l=c.cloneNode(),l.classList.add("trix-autoresize-clone"),l.tabIndex=-1,o=function(){return l.value=c.value,c.style.height=l.scrollHeight+"px"},i("input",{onElement:c,withCallback:o}),i("input",{onElement:c,withCallback:this.didInputCaption}),i("keydown",{onElement:c,withCallback:this.didKeyDownCaption}),i("change",{onElement:c,withCallback:this.didChangeCaption}),i("blur",{onElement:c,withCallback:this.didBlurCaption}),u=this.element.querySelector("figcaption"),a=u.cloneNode(),{"do":function(e){return function(){return u.style.display="none",a.appendChild(c),a.appendChild(l),a.classList.add(t.attachmentCaption+"--editing"),u.parentElement.insertBefore(a,u),o(),e.options.editCaption?n(function(){return c.focus()}):void 0}}(this),undo:function(){return e.removeNode(a),u.style.display=null}}}),h.prototype.didClickToolbar=function(t){return t.preventDefault(),t.stopPropagation()},h.prototype.didClickActionButton=function(t){var e,n;switch(e=t.target.getAttribute("data-trix-action")){case"remove":return null!=(n=this.delegate)?n.attachmentEditorDidRequestRemovalOfAttachment(this.attachment):void 0}},h.prototype.didKeyDownCaption=function(t){var e;return"return"===o[t.keyCode]?(t.preventDefault(),this.savePendingCaption(),null!=(e=this.delegate)&&"function"==typeof e.attachmentEditorDidRequestDeselectingAttachment?e.attachmentEditorDidRequestDeselectingAttachment(this.attachment):void 0):void 0},h.prototype.didInputCaption=function(t){return this.pendingCaption=t.target.value.replace(/\s/g," ").trim()},h.prototype.didChangeCaption=function(){return this.savePendingCaption()},h.prototype.didBlurCaption=function(){return this.savePendingCaption()},h}(e.BasicObject)}.call(this),function(){var t,n,i,o=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},r={}.hasOwnProperty;i=e.makeElement,t=e.config.css,e.AttachmentView=function(r){function s(){s.__super__.constructor.apply(this,arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}var a;return o(s,r),s.attachmentSelector="[data-trix-attachment]",s.prototype.createContentNodes=function(){return[]},s.prototype.createNodes=function(){var e,n,o,r,s,u,c;if(e=r=i({tagName:"figure",className:this.getClassName(),data:this.getData(),editable:!1}),(n=this.getHref())&&(r=i({tagName:"a",editable:!1,attributes:{href:n,tabindex:-1}}),e.appendChild(r)),this.attachment.hasContent())r.innerHTML=this.attachment.getContent();else for(c=this.createContentNodes(),o=0,s=c.length;s>o;o++)u=c[o],r.appendChild(u);return r.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=i({tagName:"progress",attributes:{"class":t.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:["progressElement",this.attachment.id].join("/")}}),e.appendChild(this.progressElement)),[a("left"),e,a("right")]},s.prototype.createCaptionElement=function(){var e,n,o,r,s,a,u;return o=i({tagName:"figcaption",className:t.attachmentCaption}),(e=this.attachmentPiece.getCaption())?(o.classList.add(t.attachmentCaption+"--edited"),o.textContent=e):(n=this.getCaptionConfig(),n.name&&(r=this.attachment.getFilename()),n.size&&(a=this.attachment.getFormattedFilesize()),r&&(s=i({tagName:"span",className:t.attachmentName,textContent:r}),o.appendChild(s)),a&&(r&&o.appendChild(document.createTextNode(" ")),u=i({tagName:"span",className:t.attachmentSize,textContent:a}),o.appendChild(u))),o},s.prototype.getClassName=function(){var e,n;return n=[t.attachment,t.attachment+"--"+this.attachment.getType()],(e=this.attachment.getExtension())&&n.push(t.attachment+"--"+e),n.join(" ")},s.prototype.getData=function(){var t,e;return e={trixAttachment:JSON.stringify(this.attachment),trixContentType:this.attachment.getContentType(),trixId:this.attachment.id},t=this.attachmentPiece.attributes,t.isEmpty()||(e.trixAttributes=JSON.stringify(t)),this.attachment.isPending()&&(e.trixSerialize=!1),e},s.prototype.getHref=function(){return n(this.attachment.getContent(),"a")?void 0:this.attachment.getHref()},s.prototype.getCaptionConfig=function(){var t,n,i;return i=this.attachment.getType(),t=e.copyObject(null!=(n=e.config.attachments[i])?n.caption:void 0),"file"===i&&(t.name=!0),t},s.prototype.findProgressElement=function(){var t;return null!=(t=this.findElement())?t.querySelector("progress"):void 0},a=function(t){return i({tagName:"span",textContent:e.ZERO_WIDTH_SPACE,data:{trixCursorTarget:t,trixSerialize:!1}})},s.prototype.attachmentDidChangeUploadProgress=function(){var t,e;return e=this.attachment.getUploadProgress(),null!=(t=this.findProgressElement())?t.value=e:void 0},s}(e.ObjectView),n=function(t,e){var n;return n=i("div"),n.innerHTML=null!=t?t:"",n.querySelector(e)}}.call(this),function(){var t,n=function(t,e){function n(){this.constructor=t}for(var o in e)i.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},i={}.hasOwnProperty;t=e.makeElement,e.PreviewableAttachmentView=function(i){function o(){o.__super__.constructor.apply(this,arguments),this.attachment.previewDelegate=this}return n(o,i),o.prototype.createContentNodes=function(){return this.image=t({tagName:"img",attributes:{src:""},data:{trixMutable:!0}}),this.refresh(this.image),[this.image]},o.prototype.createCaptionElement=function(){var t;return t=o.__super__.createCaptionElement.apply(this,arguments),t.textContent||t.setAttribute("data-trix-placeholder",e.config.lang.captionPlaceholder),t},o.prototype.refresh=function(t){var e;return null==t&&(t=null!=(e=this.findElement())?e.querySelector("img"):void 0),t?this.updateAttributesForImage(t):void 0},o.prototype.updateAttributesForImage=function(t){var e,n,i,o,r,s;return r=this.attachment.getURL(),n=this.attachment.getPreviewURL(),t.src=n||r,n===r?t.removeAttribute("data-trix-serialized-attributes"):(i=JSON.stringify({src:r}),t.setAttribute("data-trix-serialized-attributes",i)),s=this.attachment.getWidth(),e=this.attachment.getHeight(),null!=s&&(t.width=s),null!=e&&(t.height=e),o=["imageElement",this.attachment.id,t.src,t.width,t.height].join("/"),t.dataset.trixStoreKey=o},o.prototype.attachmentDidChangeAttributes=function(){return this.refresh(this.image),this.refresh()},o}(e.AttachmentView)}.call(this),function(){var t,n,i,o=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},r={}.hasOwnProperty;i=e.makeElement,t=e.findInnerElement,n=e.getTextConfig,e.PieceView=function(r){function s(){var t;s.__super__.constructor.apply(this,arguments),this.piece=this.object,this.attributes=this.piece.getAttributes(),t=this.options,this.textConfig=t.textConfig,this.context=t.context,this.piece.attachment?this.attachment=this.piece.attachment:this.string=this.piece.toString()}var a;return o(s,r),s.prototype.createNodes=function(){var e,n,i,o,r,s;if(s=this.attachment?this.createAttachmentNodes():this.createStringNodes(),e=this.createElement()){for(i=t(e),n=0,o=s.length;o>n;n++)r=s[n],i.appendChild(r);s=[e]}return s},s.prototype.createAttachmentNodes=function(){var t,n;return t=this.attachment.isPreviewable()?e.PreviewableAttachmentView:e.AttachmentView,n=this.createChildView(t,this.piece.attachment,{piece:this.piece}),n.getNodes()},s.prototype.createStringNodes=function(){var t,e,n,o,r,s,a,u,c,l;if(null!=(u=this.textConfig)?u.plaintext:void 0)return[document.createTextNode(this.string)];for(a=[],c=this.string.split("\n"),n=e=0,o=c.length;o>e;n=++e)l=c[n],n>0&&(t=i("br"),a.push(t)),(r=l.length)&&(s=document.createTextNode(this.preserveSpaces(l)),a.push(s));return a},s.prototype.createElement=function(){var t,e,o,r,s,a,u,c,l;c={},a=this.attributes;for(r in a)if(l=a[r],(t=n(r))&&(t.tagName&&(s=i(t.tagName),o?(o.appendChild(s),o=s):e=o=s),t.styleProperty&&(c[t.styleProperty]=l),t.style)){u=t.style;for(r in u)l=u[r],c[r]=l}if(Object.keys(c).length){null==e&&(e=i("span"));for(r in c)l=c[r],e.style[r]=l}return e},s.prototype.createContainerElement=function(){var t,e,o,r,s;r=this.attributes;for(o in r)if(s=r[o],(e=n(o))&&e.groupTagName)return t={},t[o]=s,i(e.groupTagName,t)},a=e.NON_BREAKING_SPACE,s.prototype.preserveSpaces=function(t){return this.context.
21852isLast&&(t=t.replace(/\ $/,a)),t=t.replace(/(\S)\ {3}(\S)/g,"$1 "+a+" $2").replace(/\ {2}/g,a+" ").replace(/\ {2}/g," "+a),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\ /,a)),t},s}(e.ObjectView)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t 21853}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.TextView=function(n){function i(){i.__super__.constructor.apply(this,arguments),this.text=this.object,this.textConfig=this.options.textConfig}var o;return t(i,n),i.prototype.createNodes=function(){var t,n,i,r,s,a,u,c,l,h;for(a=[],c=e.ObjectGroup.groupObjects(this.getPieces()),r=c.length-1,i=n=0,s=c.length;s>n;i=++n)u=c[i],t={},0===i&&(t.isFirst=!0),i===r&&(t.isLast=!0),o(l)&&(t.followsWhitespace=!0),h=this.findOrCreateCachedChildView(e.PieceView,u,{textConfig:this.textConfig,context:t}),a.push.apply(a,h.getNodes()),l=u;return a},i.prototype.getPieces=function(){var t,e,n,i,o;for(i=this.text.getPieces(),o=[],t=0,e=i.length;e>t;t++)n=i[t],n.hasAttribute("blockBreak")||o.push(n);return o},o=function(t){return/\s$/.test(null!=t?t.toString():void 0)},i}(e.ObjectView)}.call(this),function(){var t,n,i,o=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},r={}.hasOwnProperty;i=e.makeElement,n=e.getBlockConfig,t=e.config.css,e.BlockView=function(r){function s(){s.__super__.constructor.apply(this,arguments),this.block=this.object,this.attributes=this.block.getAttributes()}return o(s,r),s.prototype.createNodes=function(){var t,o,r,s,a,u,c,l,h,p,d;if(o=document.createComment("block"),c=[o],this.block.isEmpty()?c.push(i("br")):(p=null!=(l=n(this.block.getLastAttribute()))?l.text:void 0,d=this.findOrCreateCachedChildView(e.TextView,this.block.text,{textConfig:p}),c.push.apply(c,d.getNodes()),this.shouldAddExtraNewlineElement()&&c.push(i("br"))),this.attributes.length)return c;for(h=e.config.blockAttributes["default"].tagName,this.block.isRTL()&&(t={dir:"rtl"}),r=i({tagName:h,attributes:t}),s=0,a=c.length;a>s;s++)u=c[s],r.appendChild(u);return[r]},s.prototype.createContainerElement=function(e){var o,r,s,a,u;return o=this.attributes[e],u=n(o).tagName,0===e&&this.block.isRTL()&&(r={dir:"rtl"}),"attachmentGallery"===o&&(a=this.block.getBlockBreakPosition(),s=t.attachmentGallery+" "+t.attachmentGallery+"--"+a),i({tagName:u,className:s,attributes:r})},s.prototype.shouldAddExtraNewlineElement=function(){return/\n\n$/.test(this.block.toString())},s}(e.ObjectView)}.call(this),function(){var t,n,i=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},o={}.hasOwnProperty;t=e.defer,n=e.makeElement,e.DocumentView=function(o){function r(){r.__super__.constructor.apply(this,arguments),this.element=this.options.element,this.elementStore=new e.ElementStore,this.setDocument(this.object)}var s,a,u;return i(r,o),r.render=function(t){var e,i;return e=n("div"),i=new this(t,{element:e}),i.render(),i.sync(),e},r.prototype.setDocument=function(t){return t.isEqualTo(this.document)?void 0:this.document=this.object=t},r.prototype.render=function(){var t,i,o,r,s,a,u;if(this.childViews=[],this.shadowElement=n("div"),!this.document.isEmpty()){for(s=e.ObjectGroup.groupObjects(this.document.getBlocks(),{asTree:!0}),a=[],t=0,i=s.length;i>t;t++)r=s[t],u=this.findOrCreateCachedChildView(e.BlockView,r),a.push(function(){var t,e,n,i;for(n=u.getNodes(),i=[],t=0,e=n.length;e>t;t++)o=n[t],i.push(this.shadowElement.appendChild(o));return i}.call(this));return a}},r.prototype.isSynced=function(){return s(this.shadowElement,this.element)},r.prototype.sync=function(){var t;for(t=this.createDocumentFragmentForSync();this.element.lastChild;)this.element.removeChild(this.element.lastChild);return this.element.appendChild(t),this.didSync()},r.prototype.didSync=function(){return this.elementStore.reset(a(this.element)),t(function(t){return function(){return t.garbageCollectCachedViews()}}(this))},r.prototype.createDocumentFragmentForSync=function(){var t,e,n,i,o,r,s,u,c,l;for(e=document.createDocumentFragment(),u=this.shadowElement.childNodes,n=0,o=u.length;o>n;n++)s=u[n],e.appendChild(s.cloneNode(!0));for(c=a(e),i=0,r=c.length;r>i;i++)t=c[i],(l=this.elementStore.remove(t))&&t.parentNode.replaceChild(l,t);return e},a=function(t){return t.querySelectorAll("[data-trix-store-key]")},s=function(t,e){return u(t.innerHTML)===u(e.innerHTML)},u=function(t){return t.replace(/ /g," ")},r}(e.ObjectView)}.call(this),function(){var t,n,i,o,r,s=function(t,e){return function(){return t.apply(e,arguments)}},a=function(t,e){function n(){this.constructor=t}for(var i in e)u.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},u={}.hasOwnProperty;i=e.findClosestElementFromNode,o=e.handleEvent,r=e.innerElementIsActive,n=e.defer,t=e.AttachmentView.attachmentSelector,e.CompositionController=function(u){function c(n,i){this.element=n,this.composition=i,this.didClickAttachment=s(this.didClickAttachment,this),this.didBlur=s(this.didBlur,this),this.didFocus=s(this.didFocus,this),this.documentView=new e.DocumentView(this.composition.document,{element:this.element}),o("focus",{onElement:this.element,withCallback:this.didFocus}),o("blur",{onElement:this.element,withCallback:this.didBlur}),o("click",{onElement:this.element,matchingSelector:"a[contenteditable=false]",preventDefault:!0}),o("mousedown",{onElement:this.element,matchingSelector:t,withCallback:this.didClickAttachment}),o("click",{onElement:this.element,matchingSelector:"a"+t,preventDefault:!0})}return a(c,u),c.prototype.didFocus=function(){var t,e,n;return t=function(t){return function(){var e;return t.focused?void 0:(t.focused=!0,null!=(e=t.delegate)&&"function"==typeof e.compositionControllerDidFocus?e.compositionControllerDidFocus():void 0)}}(this),null!=(e=null!=(n=this.blurPromise)?n.then(t):void 0)?e:t()},c.prototype.didBlur=function(){return this.blurPromise=new Promise(function(t){return function(e){return n(function(){var n;return r(t.element)||(t.focused=null,null!=(n=t.delegate)&&"function"==typeof n.compositionControllerDidBlur&&n.compositionControllerDidBlur()),t.blurPromise=null,e()})}}(this))},c.prototype.didClickAttachment=function(t,e){var n,o,r;return n=this.findAttachmentForElement(e),o=null!=i(t.target,{matchingSelector:"figcaption"}),null!=(r=this.delegate)&&"function"==typeof r.compositionControllerDidSelectAttachment?r.compositionControllerDidSelectAttachment(n,{editCaption:o}):void 0},c.prototype.getSerializableElement=function(){return this.isEditingAttachment()?this.documentView.shadowElement:this.element},c.prototype.render=function(){var t,e,n;return this.revision!==this.composition.revision&&(this.documentView.setDocument(this.composition.document),this.documentView.render(),this.revision=this.composition.revision),this.canSyncDocumentView()&&!this.documentView.isSynced()&&(null!=(t=this.delegate)&&"function"==typeof t.compositionControllerWillSyncDocumentView&&t.compositionControllerWillSyncDocumentView(),this.documentView.sync(),null!=(e=this.delegate)&&"function"==typeof e.compositionControllerDidSyncDocumentView&&e.compositionControllerDidSyncDocumentView()),null!=(n=this.delegate)&&"function"==typeof n.compositionControllerDidRender?n.compositionControllerDidRender():void 0},c.prototype.rerenderViewForObject=function(t){return this.invalidateViewForObject(t),this.render()},c.prototype.invalidateViewForObject=function(t){return this.documentView.invalidateViewForObject(t)},c.prototype.isViewCachingEnabled=function(){return this.documentView.isViewCachingEnabled()},c.prototype.enableViewCaching=function(){return this.documentView.enableViewCaching()},c.prototype.disableViewCaching=function(){return this.documentView.disableViewCaching()},c.prototype.refreshViewCache=function(){return this.documentView.garbageCollectCachedViews()},c.prototype.isEditingAttachment=function(){return null!=this.attachmentEditor},c.prototype.installAttachmentEditorForAttachment=function(t,n){var i,o,r;if((null!=(r=this.attachmentEditor)?r.attachment:void 0)!==t&&(o=this.documentView.findElementForOb
21853ject(t)))return this.uninstallAttachmentEditor(),i=this.composition.document.getAttachmentPieceForAttachment(t),this.attachmentEditor=new e.AttachmentEditorController(i,o,this.element,n),this.attachmentEditor.delegate=this},c.prototype.uninstallAttachmentEditor=function(){var t;return null!=(t=this.attachmentEditor)?t.uninstall():void 0},c.prototype.didUninstallAttachmentEditor=function(){return this.attachmentEditor=null,this.render()},c.prototype.attachmentEditorDidRequestUpdatingAttributesForAttachment=function(t,e){var n;return null!=(n=this.delegate)&&"function"==typeof n.compositionControllerWillUpdateAttachment&&n.compositionControllerWillUpdateAttachment(e),this.composition.updateAttributesForAttachment(t,e)},c.prototype.attachmentEditorDidRequestRemovingAttributeForAttachment=function(t,e){var n;return null!=(n=this.delegate)&&"function"==typeof n.compositionControllerWillUpdateAttachment&&n.compositionControllerWillUpdateAttachment(e),this.composition.removeAttributeForAttachment(t,e)},c.prototype.attachmentEditorDidRequestRemovalOfAttachment=function(t){var e;return null!=(e=this.delegate)&&"function"==typeof e.compositionControllerDidRequestRemovalOfAttachment?e.compositionControllerDidRequestRemovalOfAttachment(t):void 0},c.prototype.attachmentEditorDidRequestDeselectingAttachment=function(t){var e;return null!=(e=this.delegate)&&"function"==typeof e.compositionControllerDidRequestDeselectingAttachment?e.compositionControllerDidRequestDeselectingAttachment(t):void 0},c.prototype.canSyncDocumentView=function(){return!this.isEditingAttachment()},c.prototype.findAttachmentForElement=function(t){return this.composition.document.getAttachmentById(parseInt(t.dataset.trixId,10))},c}(e.BasicObject)}.call(this),function(){var t,n,i,o=function(t,e){return function(){return t.apply(e,arguments)}},r=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},s={}.hasOwnProperty;n=e.handleEvent,i=e.triggerEvent,t=e.findClosestElementFromNode,e.ToolbarController=function(e){function s(t){this.element=t,this.didKeyDownDialogInput=o(this.didKeyDownDialogInput,this),this.didClickDialogButton=o(this.didClickDialogButton,this),this.didClickAttributeButton=o(this.didClickAttributeButton,this),this.didClickActionButton=o(this.didClickActionButton,this),this.attributes={},this.actions={},this.resetDialogInputs(),n("mousedown",{onElement:this.element,matchingSelector:a,withCallback:this.didClickActionButton}),n("mousedown",{onElement:this.element,matchingSelector:c,withCallback:this.didClickAttributeButton}),n("click",{onElement:this.element,matchingSelector:v,preventDefault:!0}),n("click",{onElement:this.element,matchingSelector:l,withCallback:this.didClickDialogButton}),n("keydown",{onElement:this.element,matchingSelector:h,withCallback:this.didKeyDownDialogInput})}var a,u,c,l,h,p,d,f,g,m,v;return r(s,e),c="[data-trix-attribute]",a="[data-trix-action]",v=c+", "+a,p="[data-trix-dialog]",u=p+"[data-trix-active]",l=p+" [data-trix-method]",h=p+" [data-trix-input]",s.prototype.didClickActionButton=function(t,e){var n,i,o;return null!=(i=this.delegate)&&i.toolbarDidClickButton(),t.preventDefault(),n=d(e),this.getDialog(n)?this.toggleDialog(n):null!=(o=this.delegate)?o.toolbarDidInvokeAction(n):void 0},s.prototype.didClickAttributeButton=function(t,e){var n,i,o;return null!=(i=this.delegate)&&i.toolbarDidClickButton(),t.preventDefault(),n=f(e),this.getDialog(n)?this.toggleDialog(n):null!=(o=this.delegate)&&o.toolbarDidToggleAttribute(n),this.refreshAttributeButtons()},s.prototype.didClickDialogButton=function(e,n){var i,o;return i=t(n,{matchingSelector:p}),o=n.getAttribute("data-trix-method"),this[o].call(this,i)},s.prototype.didKeyDownDialogInput=function(t,e){var n,i;return 13===t.keyCode&&(t.preventDefault(),n=e.getAttribute("name"),i=this.getDialog(n),this.setAttribute(i)),27===t.keyCode?(t.preventDefault(),this.hideDialog()):void 0},s.prototype.updateActions=function(t){return this.actions=t,this.refreshActionButtons()},s.prototype.refreshActionButtons=function(){return this.eachActionButton(function(t){return function(e,n){return e.disabled=t.actions[n]===!1}}(this))},s.prototype.eachActionButton=function(t){var e,n,i,o,r;for(o=this.element.querySelectorAll(a),r=[],n=0,i=o.length;i>n;n++)e=o[n],r.push(t(e,d(e)));return r},s.prototype.updateAttributes=function(t){return this.attributes=t,this.refreshAttributeButtons()},s.prototype.refreshAttributeButtons=function(){return this.eachAttributeButton(function(t){return function(e,n){return e.disabled=t.attributes[n]===!1,t.attributes[n]||t.dialogIsVisible(n)?(e.setAttribute("data-trix-active",""),e.classList.add("trix-active")):(e.removeAttribute("data-trix-active"),e.classList.remove("trix-active"))}}(this))},s.prototype.eachAttributeButton=function(t){var e,n,i,o,r;for(o=this.element.querySelectorAll(c),r=[],n=0,i=o.length;i>n;n++)e=o[n],r.push(t(e,f(e)));return r},s.prototype.applyKeyboardCommand=function(t){var e,n,o,r,s,a,u;for(s=JSON.stringify(t.sort()),u=this.element.querySelectorAll("[data-trix-key]"),r=0,a=u.length;a>r;r++)if(e=u[r],o=e.getAttribute("data-trix-key").split("+"),n=JSON.stringify(o.sort()),n===s)return i("mousedown",{onElement:e}),!0;return!1},s.prototype.dialogIsVisible=function(t){var e;return(e=this.getDialog(t))?e.hasAttribute("data-trix-active"):void 0},s.prototype.toggleDialog=function(t){return this.dialogIsVisible(t)?this.hideDialog():this.showDialog(t)}
21853,s.prototype.showDialog=function(t){var e,n,i,o,r,s,a,u,c,l;for(this.hideDialog(),null!=(a=this.delegate)&&a.toolbarWillShowDialog(),i=this.getDialog(t),i.setAttribute("data-trix-active",""),i.classList.add("trix-active"),u=i.querySelectorAll("input[disabled]"),o=0,s=u.length;s>o;o++)n=u[o],n.removeAttribute("disabled");return(e=f(i))&&(r=m(i,t))&&(r.value=null!=(c=this.attributes[e])?c:"",r.select()),null!=(l=this.delegate)?l.toolbarDidShowDialog(t):void 0},s.prototype.setAttribute=function(t){var e,n,i;return e=f(t),n=m(t,e),n.willValidate&&!n.checkValidity()?(n.setAttribute("data-trix-validate",""),n.classList.add("trix-validate"),n.focus()):(null!=(i=this.delegate)&&i.toolbarDidUpdateAttribute(e,n.value),this.hideDialog())},s.prototype.removeAttribute=function(t){var e,n;return e=f(t),null!=(n=this.delegate)&&n.toolbarDidRemoveAttribute(e),this.hideDialog()},s.prototype.hideDialog=function(){var t,e;return(t=this.element.querySelector(u))?(t.removeAttribute("data-trix-active"),t.classList.remove("trix-active"),this.resetDialogInputs(),null!=(e=this.delegate)?e.toolbarDidHideDialog(g(t)):void 0):void 0},s.prototype.resetDialogInputs=function(){var t,e,n,i,o;for(i=this.element.querySelectorAll(h),o=[],t=0,n=i.length;n>t;t++)e=i[t],e.setAttribute("disabled","disabled"),e.removeAttribute("data-trix-validate"),o.push(e.classList.remove("trix-validate"));return o},s.prototype.getDialog=function(t){return this.element.querySelector("[data-trix-dialog="+t+"]")},m=function(t,e){return null==e&&(e=f(t)),t.querySelector("[data-trix-input][name='"+e+"']")},d=function(t){return t.getAttribute("data-trix-action")},f=function(t){var e;return null!=(e=t.getAttribute("data-trix-attribute"))?e:t.getAttribute("data-trix-dialog-attribute")},g=function(t){return t.getAttribute("data-trix-dialog")},s}(e.BasicObject)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.ImagePreloadOperation=function(e){function n(t){this.url=t}return t(n,e),n.prototype.perform=function(t){var e;return e=new Image,e.onload=function(n){return function(){return e.width=n.width=e.naturalWidth,e.height=n.height=e.naturalHeight,t(!0,e)}}(this),e.onerror=function(){return t(!1)},e.src=this.url},n}(e.Operation)}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}},n=function(t,e){function n(){this.constructor=t}for(var o in e)i.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},i={}.hasOwnProperty;e.Attachment=function(i){function o(n){null==n&&(n={}),this.releaseFile=t(this.releaseFile,this),o.__super__.constructor.apply(this,arguments),this.attributes=e.Hash.box(n),this.didChangeAttributes()}return n(o,i),o.previewablePattern=/^image(\/(gif|png|jpe?g)|$)/,o.attachmentForFile=function(t){var e,n;return n=this.attributesForFile(t),e=new this(n),e.setFile(t),e},o.attributesForFile=function(t){return new e.Hash({filename:t.name,filesize:t.size,contentType:t.type})},o.fromJSON=function(t){return new this(t)},o.prototype.getAttribute=function(t){return this.attributes.get(t)},o.prototype.hasAttribute=function(t){return this.attributes.has(t)},o.prototype.getAttributes=function(){return this.attributes.toObject()},o.prototype.setAttributes=function(t){var e,n,i;return null==t&&(t={}),e=this.attributes.merge(t),this.attributes.isEqualTo(e)?void 0:(this.attributes=e,this.didChangeAttributes(),null!=(n=this.previewDelegate)&&"function"==typeof n.attachmentDidChangeAttributes&&n.attachmentDidChangeAttributes(this),null!=(i=this.delegate)&&"function"==typeof i.attachmentDidChangeAttributes?i.attachmentDidChangeAttributes(this):void 0)},o.prototype.didChangeAttributes=function(){return this.isPreviewable()?this.preloadURL():void 0},o.prototype.isPending=function(){return null!=this.file&&!(this.getURL()||this.getHref())},o.prototype.isPreviewable=function(){return this.attributes.has("previewable")?this.attributes.get("previewable"):this.constructor.previewablePattern.test(this.getContentType())},o.prototype.getType=function(){return this.hasContent()?"content":this.isPreviewable()?"preview":"file"},o.prototype.getURL=function(){return this.attributes.get("url")},o.prototype.getHref=function(){return this.attributes.get("href")},o.prototype.getFilename=function(){var t;return null!=(t=this.attributes.get("filename"))?t:""},o.prototype.getFilesize=function(){return this.attributes.get("filesize")},o.prototype.getFormattedFilesize=function(){var t;return t=this.attributes.get("filesize"),"number"==typeof t?e.config.fileSize.formatter(t):""},o.prototype.getExtension=function(){var t;return null!=(t=this.getFilename().match(/\.(\w+)$/))?t[1].toLowerCase():void 0},o.prototype.getContentType=function(){return this.attributes.get("contentType")},o.prototype.hasContent=function(){return this.attributes.has("content")},o.prototype.getContent=function(){return this.attributes.get("content")},o.prototype.getWidth=function(){return this.attributes.get("width")},o.prototype.getHeight=function(){return this.attributes.get("height")},o.prototype.getFile=function(){return this.file},o.prototype.setFile=function(t){return this.file=t,this.isPreviewable()?this.preloadFile():void 0},o.prototype.releaseFile=function(){return this.releasePreloadedFile(),this.file=null},o.prototype.getUploadProgress=function(){var t;return null!=(t=this.uploadProgress)?t:0},o.prototype.setUploadProgress=function(t){var e;return this.uploadProgress!==t?(this.uploadProgress=t,null!=(e=this.uploadProgressDelegate)&&"function"==typeof e.attachmentDidChangeUploadProgress?e.attachmentDidChangeUploadProgress(this):void 0):void 0},o.prototype.toJSON=function(){return this.getAttributes()},o.prototype.getCacheKey=function(){return[o.__super__.getCacheKey.apply(this,arguments),this.attributes.getCacheKey(),this.getPreviewURL()].join("/")},o.prototype.getPreviewURL=function(){return this.previewURL||this.preloadingURL},o.prototype.setPreviewURL=function(t){var e,n;
21853return t!==this.getPreviewURL()?(this.previewURL=t,null!=(e=this.previewDelegate)&&"function"==typeof e.attachmentDidChangeAttributes&&e.attachmentDidChangeAttributes(this),null!=(n=this.delegate)&&"function"==typeof n.attachmentDidChangePreviewURL?n.attachmentDidChangePreviewURL(this):void 0):void 0},o.prototype.preloadURL=function(){return this.preload(this.getURL(),this.releaseFile)},o.prototype.preloadFile=function(){return this.file?(this.fileObjectURL=URL.createObjectURL(this.file),this.preload(this.fileObjectURL)):void 0},o.prototype.releasePreloadedFile=function(){return this.fileObjectURL?(URL.revokeObjectURL(this.fileObjectURL),this.fileObjectURL=null):void 0},o.prototype.preload=function(t,n){var i;return t&&t!==this.getPreviewURL()?(this.preloadingURL=t,i=new e.ImagePreloadOperation(t),i.then(function(e){return function(i){var o,r;return r=i.width,o=i.height,e.getWidth()&&e.getHeight()||e.setAttributes({width:r,height:o}),e.preloadingURL=null,e.setPreviewURL(t),"function"==typeof n?n():void 0}}(this))["catch"](function(t){return function(){return t.preloadingURL=null,"function"==typeof n?n():void 0}}(this))):void 0},o}(e.Object)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.Piece=function(n){function i(t,n){null==n&&(n={}),i.__super__.constructor.apply(this,arguments),this.attributes=e.Hash.box(n)}return t(i,n),i.types={},i.registerType=function(t,e){return e.type=t,this.types[t]=e},i.fromJSON=function(t){var e;return(e=this.types[t.type])?e.fromJSON(t):void 0},i.prototype.copyWithAttributes=function(t){return new this.constructor(this.getValue(),t)},i.prototype.copyWithAdditionalAttributes=function(t){return this.copyWithAttributes(this.attributes.merge(t))},i.prototype.copyWithoutAttribute=function(t){return this.copyWithAttributes(this.attributes.remove(t))},i.prototype.copy=function(){return this.copyWithAttributes(this.attributes)},i.prototype.getAttribute=function(t){return this.attributes.get(t)},i.prototype.getAttributesHash=function(){return this.attributes},i.prototype.getAttributes=function(){return this.attributes.toObject()},i.prototype.getCommonAttributes=function(){var t,e,n;return(n=pieceList.getPieceAtIndex(0))?(t=n.attributes,e=t.getKeys(),pieceList.eachPiece(function(n){return e=t.getKeysCommonToHash(n.attributes),t=t.slice(e)}),t.toObject()):{}},i.prototype.hasAttribute=function(t){return this.attributes.has(t)},i.prototype.hasSameStringValueAsPiece=function(t){return null!=t&&this.toString()===t.toString()},i.prototype.hasSameAttributesAsPiece=function(t){return null!=t&&(this.attributes===t.attributes||this.attributes.isEqualTo(t.attributes))},i.prototype.isBlockBreak=function(){return!1},i.prototype.isEqualTo=function(t){return i.__super__.isEqualTo.apply(this,arguments)||this.hasSameConstructorAs(t)&&this.hasSameStringValueAsPiece(t)&&this.hasSameAttributesAsPiece(t)},i.prototype.isEmpty=function(){return 0===this.length},i.prototype.isSerializable=function(){return!0},i.prototype.toJSON=function(){return{type:this.constructor.type,attributes:this.getAttributes()}},i.prototype.contentsForInspection=function(){return{type:this.constructor.type,attributes:this.attributes.inspect()}},i.prototype.canBeGrouped=function(){return this.hasAttribute("href")},i.prototype.canBeGroupedWith=function(t){return this.getAttribute("href")===t.getAttribute("href")},i.prototype.getLength=function(){return this.length},i.prototype.canBeConsolidatedWith=function(){return!1},i}(e.Object)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.Piece.registerType("attachment",e.AttachmentPiece=function(n){function i(t){this.attachment=t,i.__super__.constructor.apply(this,arguments),this.length=1,this.ensureAttachmentExclusivelyHasAttribute("href"),this.attachment.hasContent()||this.removeProhibitedAttributes()}return t(i,n),i.fromJSON=function(t){return new this(e.Attachment.fromJSON(t.attachment),t.attributes)},i.permittedAttributes=["caption","presentation"],i.prototype.ensureAttachmentExclusivelyHasAttribute=function(t){return this.hasAttribute(t)?(this.attachment.hasAttribute(t)||this.attachment.setAttributes(this.attributes.slice(t)),this.attributes=this.attributes.remove(t)):void 0},i.prototype.removeProhibitedAttributes=function(){var t;return t=this.attributes.slice(this.constructor.permittedAttributes),t.isEqualTo(this.attributes)?void 0:this.attributes=t},i.prototype.getValue=function(){return this.attachment},i.prototype.isSerializable=function(){return!this.attachment.isPending()},i.prototype.getCaption=function(){var t;return null!=(t=this.attributes.get("caption"))?t:""},i.prototype.isEqualTo=function(t){var e;return i.__super__.isEqualTo.apply(this,arguments)&&this.attachment.id===(null!=t&&null!=(e=t.attachment)?e.id:void 0)},i.prototype.toString=function(){return e.OBJECT_REPLACEMENT_CHARACTER},i.prototype.toJSON=function(){var t;return t=i.__super__.toJSON.apply(this,arguments),t.attachment=this.attachment,t},i.prototype.getCacheKey=function(){return[i.__super__.getCacheKey.apply(this,arguments),this.attachment.getCacheKey()].join("/")},i.prototype.toConsole=function(){return JSON.stringify(this.toString())},i}(e.Piece))}.call(this),function(){var t,n=function(t,e){function n(){this.constructor=t}for(var o in e)i.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},i={}.hasOwnProperty;t=e.normalizeNewlines,e.Piece.registerType("string",e.StringPiece=function(e){function i(e){i.__super__.constructor.apply(this,arguments),this.string=t(e),this.length=this.string.length}return n(i,e),i.fromJSON=function(t){return new this(t.string,t.attributes)},i.prototype.getValue=function(){return this.string},i.prototype.toString=function(){return this.string.toString()},i.prototype.isBlockBreak=function(){return"\n"===this.toString()&&this.getAttribute("blockBreak")===!0},i.prototype.toJSON=function(){var t;return t=i.__super__.toJSON.apply(this,arguments),t.string=this.string,t},i.prototype.canBeConsolidatedWith=function(t){return null!=t&&this.hasSameConstructorAs(t)&&this.hasSameAttributesAsPiece(t)},i.prototype.consolidateWith=function(t){return new this.constructor(this.toString()+t.toString(),this.attributes)},i.prototype.splitAtOffset=function(t){var e,n;return 0===t?(e=null,n=this):t===this.length?(e=this,n=null):(e=new this.constructor(this.string.slice(0,t),this.attributes),n=new this.constructor(this.string.slice(t),this.attributes)),[e,n]},i.prototype.toConsole=function(){var t;return t=this.string,t.length>15&&(t=t.slice(0,14)+"\u2026"),JSON.stringify(t.toString())},i}(e.Piece))}.call(this),function(){var t,n=function(t,e){function n(){this.constructor=t}for(var o in e)i.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},i={}.hasOwnProperty,o=[].slice;t=e.spliceArray,e.SplittableList=function(e){function i(t){null==t&&(t=[]),i.__super__.constructor.apply(this,arguments),this.objects=t.slice(0),this.length=this.objects.length}var r,s,a;return n(i,e),i.box=function(t){return t instanceof this?t:new this(t)},i.prototype.indexOf=function(t){return this.objects.indexOf(t)},i.prototype.splice=function(){var e;return e=1<=arguments.length?o.call(arguments,0):[],new this.constructor(t.apply(null,[this.objects].concat(o.call(e))))},i.prototype.eachObject=function(t){var e,n,i,o,r,s;for(r=this.objects,s=[],n=e=0,i=r.length;i>e;n=++e)o=r[n],s.push(t(o,n));return s},i.prototype.insertObjectAtIndex=function(t,e){return this.splice(e,0,t)},i.prototype.insertSplittableListAtIndex=function(t,e){return this.splice.apply(this,[e,0].concat(o.call(t.objects)))},i.prototype.insertSplittableListAtPosition=function(t,e){var n,i,o;return o=this.splitObjectAtPosition(e),i=o[0],n=o[1],new this.constructor(i).insertSplittableListAtIndex(t,n)},i.prototype.editObjectAtIndex=function(t,e){return this.replaceObjectAtIndex(e(this.objects[t]),t)},i.prototype.replaceObjectAtIndex=function(t,e){return this.splice(e,1,t)},i.prototype.removeObjectAtIndex=function(t){return this.splice(t,1)},i.prototype.getObjectAtIndex=function(t){return this.objects[t]},i.prototype.getSplittableListInRange=function(t){var e,n,i,o;return i=this.splitObjectsAtRange(t),n=i[0],e=i[1],o=i[2],new this.constructor(n.slice(e,o+1))},i.prototype.selectSplittableList=function(t){var e,n;return n=function(){var n,i,o,r;for(o=this.objects,r=[],n=0,i=o.length;i>n;n++)e=o[n],t(e)&&r.push(e);return r}.call(this),new this.constructor(n)},i.prototype.removeObjectsInRange=function(t){var e,n,i,o;return i=this.splitObjectsAtRange(t),n=i[0],e=i[1],o=i[2],new this.constructor(n).splice(e,o-e+1)},i.prototype.transformObjectsInRange=function(t,e){var n,i,o,r,s,a,u;return s=this.splitObjectsAtRange(t),r=s[0],i=s[1],a=s[2],u=function(){var t,s,u;for(u=[],n=t=0,s=r.length;s>t;n=++t)o=r[n],u.push(n>=i&&a>=n?e(o):o);return u}(),new this.constructor(u)},i.prototype.splitObjectsAtRange=function(t){var e,n,i,o,s,u;return o=this.splitObjectAtPosition(a(t)),n=o[0],e=o[1],i=o[2],s=new this.constructor(n).splitObjectAtPosition(r(t)+i),n=s[0],u=s[1],[n,e,u-1]},i.prototype.getObjectAtPosition=function(t){var e,n,i;return i=this.findIndexAndOffsetAtPosition(t),e=i.index,n=i.offset,this.objects[e]},i.prototype.splitObjectAtPosition=function(t){var e,n,i,o,r,s,a,u,c,l;return s=this.findIndexAndOffsetAtPosition(t),e=s.index,r=s.offset,o=this.objects.slice(0),null!=e?0===r?(c=e,l=0):(i=this.getObjectAtIndex(e),a=i.splitAtOffset(r),n=a[0],u=a[1],o.splice(e,1,n,u),c=e+1,l=n.getLength()-r):(c=o.length,l=0),[o,c,l]},i.prototype.consolidate=function(){var t,e,n,i,o,r;for(i=[],o=this.objects[0],r=this.objects.slice(1),t=0,e=r.length;e>t;t++)n=r[t],("function"==typeof o.canBeConsolidatedWith?o.canBeConsolidatedWith(n):void 0)?o=o.consolidateWith(n):(i.push(o),o=n);return null!=o&&i.push(o),new this.constructor(i)},i.prototype.consolidateFromIndexToIndex=function(t,e){var n,i,r;return i=this.objects.slice(0),r=i.slice(t,e+1),n=new this.constructor(r).consolidate().toArray(),this.splice.apply(this,[t,r.length].concat(o.call(n)))},i.prototype.findIndexAndOffsetAtPosition=function(t){var e,n,i,o,r,s,a;for(e=0,a=this.objects,i=n=0,o=a.length;o>n;i=++n){if(s=a[i],r=e+s.getLength(),t>=e&&r>t)return{index:i,offset:t-e};e=r}return{index:null,offset:null}},i.prototype.findPositionAtIndexAndOffset=function(t,e){var n,i,o,r,s,a;for(s=0,a=this.objects,n=i=0,o=a.length;o>i;n=++i)if(r=a[n],t>n)s+=r.getLength();else if(n===t){s+=e;break}return s},i.prototype.getEndPosition=function(){var t,e;return null!=this.endPosition?this.endPosition:this.endPosition=function(){var n,i,o;for(e=0,o=this.objects,n=0,i=o.length;i>n;
21853n++)t=o[n],e+=t.getLength();return e}.call(this)},i.prototype.toString=function(){return this.objects.join("")},i.prototype.toArray=function(){return this.objects.slice(0)},i.prototype.toJSON=function(){return this.toArray()},i.prototype.isEqualTo=function(t){return i.__super__.isEqualTo.apply(this,arguments)||s(this.objects,null!=t?t.objects:void 0)},s=function(t,e){var n,i,o,r,s;if(null==e&&(e=[]),t.length!==e.length)return!1;for(s=!0,i=n=0,o=t.length;o>n;i=++n)r=t[i],s&&!r.isEqualTo(e[i])&&(s=!1);return s},i.prototype.contentsForInspection=function(){var t;return{objects:"["+function(){var e,n,i,o;for(i=this.objects,o=[],e=0,n=i.length;n>e;e++)t=i[e],o.push(t.inspect());return o}.call(this).join(", ")+"]"}},a=function(t){return t[0]},r=function(t){return t[1]},i}(e.Object)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.Text=function(n){function i(t){var n;null==t&&(t=[]),i.__super__.constructor.apply(this,arguments),this.pieceList=new e.SplittableList(function(){var e,i,o;for(o=[],e=0,i=t.length;i>e;e++)n=t[e],n.isEmpty()||o.push(n);return o}())}return t(i,n),i.textForAttachmentWithAttributes=function(t,n){var i;return i=new e.AttachmentPiece(t,n),new this([i])},i.textForStringWithAttributes=function(t,n){var i;return i=new e.StringPiece(t,n),new this([i])},i.fromJSON=function(t){var n,i;return i=function(){var i,o,r;for(r=[],i=0,o=t.length;o>i;i++)n=t[i],r.push(e.Piece.fromJSON(n));return r}(),new this(i)},i.prototype.copy=function(){return this.copyWithPieceList(this.pieceList)},i.prototype.copyWithPieceList=function(t){return new this.constructor(t.consolidate().toArray())},i.prototype.copyUsingObjectMap=function(t){var e,n;return n=function(){var n,i,o,r,s;for(o=this.getPieces(),s=[],n=0,i=o.length;i>n;n++)e=o[n],s.push(null!=(r=t.find(e))?r:e);return s}.call(this),new this.constructor(n)},i.prototype.appendText=function(t){return this.insertTextAtPosition(t,this.getLength())},i.prototype.insertTextAtPosition=function(t,e){return this.copyWithPieceList(this.pieceList.insertSplittableListAtPosition(t.pieceList,e)) 21854},i.prototype.removeTextAtRange=function(t){return this.copyWithPieceList(this.pieceList.removeObjectsInRange(t))},i.prototype.replaceTextAtRange=function(t,e){return this.removeTextAtRange(e).insertTextAtPosition(t,e[0])},i.prototype.moveTextFromRangeToPosition=function(t,e){var n,i;if(!(t[0]<=e&&e<=t[1]))return i=this.getTextAtRange(t),n=i.getLength(),t[0]<e&&(e-=n),this.removeTextAtRange(t).insertTextAtPosition(i,e)},i.prototype.addAttributeAtRange=function(t,e,n){var i;return i={},i[t]=e,this.addAttributesAtRange(i,n)},i.prototype.addAttributesAtRange=function(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,function(e){return e.copyWithAdditionalAttributes(t)}))},i.prototype.removeAttributeAtRange=function(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,function(e){return e.copyWithoutAttribute(t)}))},i.prototype.setAttributesAtRange=function(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,function(e){return e.copyWithAttributes(t)}))},i.prototype.getAttributesAtPosition=function(t){var e,n;return null!=(e=null!=(n=this.pieceList.getObjectAtPosition(t))?n.getAttributes():void 0)?e:{}},i.prototype.getCommonAttributes=function(){var t,n;return t=function(){var t,e,i,o;for(i=this.pieceList.toArray(),o=[],t=0,e=i.length;e>t;t++)n=i[t],o.push(n.getAttributes());return o}.call(this),e.Hash.fromCommonAttributesOfObjects(t).toObject()},i.prototype.getCommonAttributesAtRange=function(t){var e;return null!=(e=this.getTextAtRange(t).getCommonAttributes())?e:{}},i.prototype.getExpandedRangeForAttributeAtOffset=function(t,e){var n,i,o;for(n=o=e,i=this.getLength();n>0&&this.getCommonAttributesAtRange([n-1,o])[t];)n--;for(;i>o&&this.getCommonAttributesAtRange([e,o+1])[t];)o++;return[n,o]},i.prototype.getTextAtRange=function(t){return this.copyWithPieceList(this.pieceList.getSplittableListInRange(t))},i.prototype.getStringAtRange=function(t){return this.pieceList.getSplittableListInRange(t).toString()}
21854,i.prototype.getStringAtPosition=function(t){return this.getStringAtRange([t,t+1])},i.prototype.startsWithString=function(t){return this.getStringAtRange([0,t.length])===t},i.prototype.endsWithString=function(t){var e;return e=this.getLength(),this.getStringAtRange([e-t.length,e])===t},i.prototype.getAttachmentPieces=function(){var t,e,n,i,o;for(i=this.pieceList.toArray(),o=[],t=0,e=i.length;e>t;t++)n=i[t],null!=n.attachment&&o.push(n);return o},i.prototype.getAttachments=function(){var t,e,n,i,o;for(i=this.getAttachmentPieces(),o=[],t=0,e=i.length;e>t;t++)n=i[t],o.push(n.attachment);return o},i.prototype.getAttachmentAndPositionById=function(t){var e,n,i,o,r,s;for(o=0,r=this.pieceList.toArray(),e=0,n=r.length;n>e;e++){if(i=r[e],(null!=(s=i.attachment)?s.id:void 0)===t)return{attachment:i.attachment,position:o};o+=i.length}return{attachment:null,position:null}},i.prototype.getAttachmentById=function(t){var e,n,i;return i=this.getAttachmentAndPositionById(t),e=i.attachment,n=i.position,e},i.prototype.getRangeOfAttachment=function(t){var e,n;return n=this.getAttachmentAndPositionById(t.id),t=n.attachment,e=n.position,null!=t?[e,e+1]:void 0},i.prototype.updateAttributesForAttachment=function(t,e){var n;return(n=this.getRangeOfAttachment(e))?this.addAttributesAtRange(t,n):this},i.prototype.getLength=function(){return this.pieceList.getEndPosition()},i.prototype.isEmpty=function(){return 0===this.getLength()},i.prototype.isEqualTo=function(t){var e;return i.__super__.isEqualTo.apply(this,arguments)||(null!=t&&null!=(e=t.pieceList)?e.isEqualTo(this.pieceList):void 0)},i.prototype.isBlockBreak=function(){return 1===this.getLength()&&this.pieceList.getObjectAtIndex(0).isBlockBreak()},i.prototype.eachPiece=function(t){return this.pieceList.eachObject(t)},i.prototype.getPieces=function(){return this.pieceList.toArray()},i.prototype.getPieceAtPosition=function(t){return this.pieceList.getObjectAtPosition(t)},i.prototype.contentsForInspection=function(){return{pieceList:this.pieceList.inspect()}},i.prototype.toSerializableText=function(){var t;return t=this.pieceList.selectSplittableList(function(t){return t.isSerializable()}),this.copyWithPieceList(t)},i.prototype.toString=function(){return this.pieceList.toString()},i.prototype.toJSON=function(){return this.pieceList.toJSON()},i.prototype.toConsole=function(){var t;return JSON.stringify(function(){var e,n,i,o;for(i=this.pieceList.toArray(),o=[],e=0,n=i.length;n>e;e++)t=i[e],o.push(JSON.parse(t.toConsole()));return o}.call(this))},i.prototype.getDirection=function(){return e.getDirection(this.toString())},i.prototype.isRTL=function(){return"rtl"===this.getDirection()},i}(e.Object)}.call(this),function(){var t,n,i,o,r,s=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},a={}.hasOwnProperty,u=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},c=[].slice;t=e.arraysAreEqual,r=e.spliceArray,i=e.getBlockConfig,n=e.getBlockAttributeNames,o=e.getListAttributeNames,e.Block=function(n){function a(t,n){null==t&&(t=new e.Text),null==n&&(n=[]),a.__super__.constructor.apply(this,arguments),this.text=h(t),this.attributes=n}var l,h,p,d,f,g,m,v,y;return s(a,n),a.fromJSON=function(t){var n;return n=e.Text.fromJSON(t.text),new this(n,t.attributes)},a.prototype.isEmpty=function(){return this.text.isBlockBreak()},a.prototype.isEqualTo=function(e){return a.__super__.isEqualTo.apply(this,arguments)||this.text.isEqualTo(null!=e?e.text:void 0)&&t(this.attributes,null!=e?e.attributes:void 0)},a.prototype.copyWithText=function(t){return new this.constructor(t,this.attributes)},a.prototype.copyWithoutText=function(){return this.copyWithText(null)},a.prototype.copyWithAttributes=function(t){return new this.constructor(this.text,t)},a.prototype.copyWithoutAttributes=function(){return this.copyWithAttributes(null)},a.prototype.copyUsingObjectMap=function(t){var e;return this.copyWithText((e=t.find(this.text))?e:this.text.copyUsingObjectMap(t))},a.prototype.addAttribute=function(t){var e;return e=this.attributes.concat(d(t)),this.copyWithAttributes(e)},a.prototype.removeAttribute=function(t){var e,n;return n=i(t).listAttribute,e=g(g(this.attributes,t),n),this.copyWithAttributes(e)},a.prototype.removeLastAttribute=function(){return this.removeAttribute(this.getLastAttribute())},a.prototype.getLastAttribute=function(){return f(this.attributes)},a.prototype.getAttributes=function(){return this.attributes.slice(0)},a.prototype.getAttributeLevel=function(){return this.attributes.length},a.prototype.getAttributeAtLevel=function(t){return this.attributes[t-1]},a.prototype.hasAttribute=function(t){return u.call(this.attributes,t)>=0},a.prototype.hasAttributes=function(){return this.getAttributeLevel()>0},a.prototype.getLastNestableAttribute=function(){return f(this.getNestableAttributes())},a.prototype.getNestableAttributes=function(){var t,e,n,o,r;for(o=this.attributes,r=[],e=0,n=o.length;n>e;e++)t=o[e],i(t).nestable&&r.push(t);return r},a.prototype.getNestingLevel=function(){return this.getNestableAttributes().length},a.prototype.decreaseNestingLevel=function(){var t;return(t=this.getLastNestableAttribute())?this.removeAttribute(t):this},a.prototype.increaseNestingLevel=function(){var t,e,n;return(t=this.getLastNestableAttribute())?(n=this.attributes.lastIndexOf(t),e=r.apply(null,[this.attributes,n+1,0].c
21854oncat(c.call(d(t)))),this.copyWithAttributes(e)):this},a.prototype.getListItemAttributes=function(){var t,e,n,o,r;for(o=this.attributes,r=[],e=0,n=o.length;n>e;e++)t=o[e],i(t).listAttribute&&r.push(t);return r},a.prototype.isListItem=function(){var t;return null!=(t=i(this.getLastAttribute()))?t.listAttribute:void 0},a.prototype.isTerminalBlock=function(){var t;return null!=(t=i(this.getLastAttribute()))?t.terminal:void 0},a.prototype.breaksOnReturn=function(){var t;return null!=(t=i(this.getLastAttribute()))?t.breakOnReturn:void 0},a.prototype.findLineBreakInDirectionFromPosition=function(t,e){var n,i;return i=this.toString(),n=function(){switch(t){case"forward":return i.indexOf("\n",e);case"backward":return i.slice(0,e).lastIndexOf("\n")}}(),-1!==n?n:void 0},a.prototype.contentsForInspection=function(){return{text:this.text.inspect(),attributes:this.attributes}},a.prototype.toString=function(){return this.text.toString()},a.prototype.toJSON=function(){return{text:this.text,attributes:this.attributes}},a.prototype.getDirection=function(){return this.text.getDirection()},a.prototype.isRTL=function(){return this.text.isRTL()},a.prototype.getLength=function(){return this.text.getLength()},a.prototype.canBeConsolidatedWith=function(t){return!this.hasAttributes()&&!t.hasAttributes()&&this.getDirection()===t.getDirection()},a.prototype.consolidateWith=function(t){var n,i;return n=e.Text.textForStringWithAttributes("\n"),i=this.getTextWithoutBlockBreak().appendText(n),this.copyWithText(i.appendText(t.text))},a.prototype.splitAtOffset=function(t){var e,n;return 0===t?(e=null,n=this):t===this.getLength()?(e=this,n=null):(e=this.copyWithText(this.text.getTextAtRange([0,t])),n=this.copyWithText(this.text.getTextAtRange([t,this.getLength()]))),[e,n]},a.prototype.getBlockBreakPosition=function(){return this.text.getLength()-1},a.prototype.getTextWithoutBlockBreak=function(){return m(this.text)?this.text.getTextAtRange([0,this.getBlockBreakPosition()]):this.text.copy()},a.prototype.canBeGrouped=function(t){return this.attributes[t]},a.prototype.canBeGroupedWith=function(t,e){var n,r,s,a;return s=t.getAttributes(),r=s[e],n=this.attributes[e],!(n!==r||i(n).group===!1&&(a=s[e+1],u.call(o(),a)<0)||this.getDirection()!==t.getDirection()&&!t.isEmpty())},h=function(t){return t=y(t),t=l(t)},y=function(t){var n,i,o,r,s,a;return r=!1,a=t.getPieces(),i=2<=a.length?c.call(a,0,n=a.length-1):(n=0,[]),o=a[n++],null==o?t:(i=function(){var t,e,n;for(n=[],t=0,e=i.length;e>t;t++)s=i[t],s.isBlockBreak()?(r=!0,n.push(v(s))):n.push(s);return n}(),r?new e.Text(c.call(i).concat([o])):t)},p=e.Text.textForStringWithAttributes("\n",{blockBreak:!0}),l=function(t){return m(t)?t:t.appendText(p)},m=function(t){var e,n;return n=t.getLength(),0===n?!1:(e=t.getTextAtRange([n-1,n]),e.isBlockBreak())},v=function(t){return t.copyWithoutAttribute("blockBreak")},d=function(t){var e;return e=i(t).listAttribute,null!=e?[e,t]:[t]},f=function(t){return t.slice(-1)[0]},g=function(t,e){var n;return n=t.lastIndexOf(e),-1===n?t:r(t,n,1)},a}(e.Object)}.call(this),function(){var t,n,i,o=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},r={}.hasOwnProperty,s=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},a=[].slice;n=e.tagName,i=e.walkTree,t=e.nodeIsAttachmentElement,e.HTMLSanitizer=function(r){function u(t,e){var n;n=null!=e?e:{},this.allowedAttributes=n.allowedAttributes,this.forbiddenProtocols=n.forbiddenProtocols,this.forbiddenElements=n.forbiddenElements,null==this.allowedAttributes&&(this.allowedAttributes=c),null==this.forbiddenProtocols&&(this.forbiddenProtocols=h),null==this.forbiddenElements&&(this.forbiddenElements=l),this.body=p(t)}var c,l,h,p;return o(u,r),c="style href src width height class".split(" "),h="javascript:".split(" "),l="script iframe".split(" "),u.sanitize=function(t,e){var n;return n=new this(t,e),n.sanitize(),n},u.prototype.sanitize=function(){return this.sanitizeElements(),this.normalizeListElementNesting()},u.prototype.getHTML=function(){return this.body.innerHTML},u.prototype.getBody=function(){return this.body},u.prototype.sanitizeElements=function(){var t,n,o,r,s;for(s=i(this.body),r=[];s.nextNode();)switch(o=s.currentNode,o.nodeType){case Node.ELEMENT_NODE:this.elementIsRemovable(o)?r.push(o):this.sanitizeElement(o);break;case Node.COMMENT_NODE:r.push(o)}for(t=0,n=r.length;n>t;t++)o=r[t],e.removeNode(o);return this.body},u.prototype.sanitizeElement=function(t){var e,n,i,o,r;for(t.hasAttribute("href")&&(o=t.protocol,s.call(this.forbiddenProtocols,o)>=0&&t.removeAttribute("href")),r=a.call(t.attributes),e=0,n=r.length;n>e;e++)i=r[e].name,s.call(this.allowedAttributes,i)>=0||0===i.indexOf("data-trix")||t.removeAttribute(i);return t},u.prototype.normalizeListElementNesting=function(){var t,e,i,o,r;for(r=a.call(this.body.querySelectorAll("ul,ol")),t=0,e=r.length;e>t;t++)i=r[t],(o=i.previousElementSibling)&&"li"===n(o)&&o.appendChild(i);return this.body},u.prototype.elementIsRemovable=function(t){return(null!=t?t.nodeType:void 0)===Node.ELEMENT_NODE?this.elementIsForbidden(t)||this.elementIsntSerializable(t):void 0},u.prototype.elementIsForbidden=function(t){var e;return e=n(t),s.call(this.forbiddenElements,e)>=0},u.prototype.elementIsntSerializable=function(e){return"false"===e.getAttribute("data-trix-serialize")&&!t(e)},p=function(t){var e,n,i,o,r;for(null==t&&(t=""),t=t.replace(/<\/html[^>]*>[^]*$/i,"</html>"),e=document.implementation.createHTMLDocument(""),e.documentElement.innerHTML=t,r=e.head.querySelectorAll("style"),i=0,o=r.length;o>i;i++)n=r[i],e.body.appendChild(n);return e.body},u}(e.BasicObject)}.call(this),function(){var t,n,i,o,r,s,a,u,c,l,h,p=function(t,e){function n(){this.constructor=t}for(var i in e)d.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},d={}.hasOwnProperty,f=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};t=e.arraysAreEqual,s=e.makeElement,l=e.tagName,r=e.getBlockTagNames,h=e.walkTree,o=e.findClosestElementFromNode,i=e.elementContainsNode,a=e.nodeIsAttachmentElement,u=e.normalizeSpaces,n=e.breakableWhitespacePattern,c=e.squishBreakableWhitespace,e.HTMLParser=function(d){function g(t,e){this.html=t,this.referenceElement=(null!=e?e:{}).referenceElement,this.blocks=[],this.blockElements=[],this.processedElements=[]}var m,v,y,b,A,C,x,w,E,S,R,k;return p(g,d),g.parse=function(t,e){var n;return n=new this(t,e),n.parse(),n},g.prototype.getDocument=function(){return e.Document.fromJSON(this.blocks)},g.prototype.parse=function(){var t,n;try{for(this.createHiddenContainer(),t=e.HTMLSanitizer.sanitize(this.html).getHTML(),this.containerElement.innerHTML=t,n=h(this.containerElement,{usingFilter:x});n.nextNode();)this.processNode(n.currentNode);return this.translateBlockElementMarginsToNewlines()}finally{this.removeHiddenContainer()}},g.prototype.createHiddenContainer=function(){return this.referenceElement?(this.containerElement=this.referenceElement.cloneNode(!1),this.containerElement.removeAttribute("id"),this.containerElement.setAttribute("data-trix-internal",""),this.containerElement.style.display="none",this.referenceElement.parentNode.insertBefore(this.containerElement,this.referenceElement.nextSibling)):(this.containerElement=s({tagName:"div",style:{display:"none"}}),document.body.appendChild(this.containerElement))},g.prototype.removeHiddenContainer=function(){return e.removeNode(this.containerElement)},x=function(t){return"style"===l(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},g.prototype.processNode=function(t){switch(t.nodeType){case Node.TEXT_NODE:if(!this.isInsignificantTextNode(t))return this.appendBlockForTextNode(t),this.processTextNode(t);break;case Node.ELEMENT_NODE:return this.appendBlockForElement(t),this.processElement(t)}},g.prototype.appendBlockForTextNode=function(e){var n,i,o;return i=e.parentNode,i===this.currentBlockElement&&this.isBlockElement(e.previousSibling)?this.appendStringWithAttributes("\n"):i!==this.containerElement&&!this.isBlockElement(i)||(n=this.getBlockAttributes(i),t(n,null!=(o=this.currentBlock)?o.attributes:void 0))?void 0:(this.currentBlock=this.appendBlockForAttributesWithElement(n,i),this.currentBlockElement=i)},g.prototype.appendBlockForElement=function(e){var n,o,r,s;if(r=this.isBlockElement(e),o=i(this.currentBlockElement,e),r&&!this.isBlockElement(e.firstChild)){if((!this.isInsignificantTextNode(e.firstChild)||!this.isBlockElement(e.firstElementChild))&&(n=this.getBlockAttributes(e),e.firstChild))return o&&t(n,this.currentBlock.attributes)?this.appendStringWithAttributes("\n"):(this.currentBlock=this.appendBlockForAttributesWithElement(n,e),this.currentBlockElement=e)}else if(this.currentBlockElement&&!o&&!r)return(s=this.findParentBlockElement(e))?this.appendBlockForElement(s):(this.currentBlock=this.appendEmptyBlock(),this.currentBlockElement=null)},g.prototype.findParentBlockElement=function(t){var e;
21854for(e=t.parentElement;e&&e!==this.containerElement;){if(this.isBlockElement(e)&&f.call(this.blockElements,e)>=0)return e;e=e.parentElement}return null},g.prototype.processTextNode=function(t){var e,n;return n=t.data,v(t.parentNode)||(n=c(n),R(null!=(e=t.previousSibling)?e.textContent:void 0)&&(n=A(n))),this.appendStringWithAttributes(n,this.getTextAttributes(t.parentNode))},g.prototype.processElement=function(t){var e,n,i,o,r;if(a(t))return e=w(t,"attachment"),Object.keys(e).length&&(o=this.getTextAttributes(t),this.appendAttachmentWithAttributes(e,o),t.innerHTML=""),this.processedElements.push(t);switch(l(t)){case"br":return this.isExtraBR(t)||this.isBlockElement(t.nextSibling)||this.appendStringWithAttributes("\n",this.getTextAttributes(t)),this.processedElements.push(t);case"img":e={url:t.getAttribute("src"),contentType:"image"},i=b(t);for(n in i)r=i[n],e[n]=r;return this.appendAttachmentWithAttributes(e,this.getTextAttributes(t)),this.processedElements.push(t);case"tr":if(t.parentNode.firstChild!==t)return this.appendStringWithAttributes("\n");break;case"td":if(t.parentNode.firstChild!==t)return this.appendStringWithAttributes(" | ")}},g.prototype.appendBlockForAttributesWithElement=function(t,e){var n;return this.blockElements.push(e),n=m(t),this.blocks.push(n),n},g.prototype.appendEmptyBlock=function(){return this.appendBlockForAttributesWithElement([],null)},g.prototype.appendStringWithAttributes=function(t,e){return this.appendPiece(S(t,e))},g.prototype.appendAttachmentWithAttributes=function(t,e){return this.appendPiece(E(t,e))},g.prototype.appendPiece=function(t){return 0===this.blocks.length&&this.appendEmptyBlock(),this.blocks[this.blocks.length-1].text.push(t)},g.prototype.appendStringToTextAtIndex=function(t,e){var n,i;return i=this.blocks[e].text,n=i[i.length-1],"string"===(null!=n?n.type:void 0)?n.string+=t:i.push(S(t))},g.prototype.prependStringToTextAtIndex=function(t,e){var n,i;return i=this.blocks[e].text,n=i[0],"string"===(null!=n?n.type:void 0)?n.string=t+n.string:i.unshift(S(t))},S=function(t,e){var n;return null==e&&(e={}),n="string",t=u(t),{string:t,attributes:e,type:n}},E=function(t,e){var n;return null==e&&(e={}),n="attachment",{attachment:t,attributes:e,type:n}},m=function(t){var e;return null==t&&(t={}),e=[],{text:e,attributes:t}},g.prototype.getTextAttributes=function(t){var n,i,r,s,u,c,l,h,p,d,f,g;r={},p=e.config.textAttributes;for(n in p)if(u=p[n],u.tagName&&o(t,{matchingSelector:u.tagName,untilNode:this.containerElement}))r[n]=!0;else if(u.parser){if(g=u.parser(t)){for(i=!1,d=this.findBlockElementAncestors(t),c=0,h=d.length;h>c;c++)if(s=d[c],u.parser(s)===g){i=!0;break}i||(r[n]=g)}}else u.styleProperty&&(g=t.style[u.styleProperty])&&(r[n]=g);if(a(t)){f=w(t,"attributes");for(l in f)g=f[l],r[l]=g}return r},g.prototype.getBlockAttributes=function(t){var n,i,o,r;for(i=[];t&&t!==this.containerElement;){r=e.config.blockAttributes;for(n in r)o=r[n],o.parse!==!1&&l(t)===o.tagName&&(("function"==typeof o.test?o.test(t):void 0)||!o.test)&&(i.push(n),o.listAttribute&&i.push(o.listAttribute));t=t.parentNode}return i.reverse()},g.prototype.findBlockElementAncestors=function(t){var e,n;for(e=[];t&&t!==this.containerElement;)n=l(t),f.call(r(),n)>=0&&e.push(t),t=t.parentNode;return e},w=function(t,e){try{return JSON.parse(t.getAttribute("data-trix-"+e))}catch(n){return{}}},b=function(t){var e,n,i;return i=t.getAttribute("width"),n=t.getAttribute("height"),e={},i&&(e.width=parseInt(i,10)),n&&(e.height=parseInt(n,10)),e},g.prototype.isBlockElement=function(t){var e;if((null!=t?t.nodeType:void 0)===Node.ELEMENT_NODE&&!a(t)&&!o(t,{matchingSelector:"td",untilNode:this.containerElement}))return e=l(t),f.call(r(),e)>=0||"block"===window.getComputedStyle(t).display},g.prototype.isInsignificantTextNode=function(t){var e,n,i;if((null!=t?t.nodeType:void 0)===Node.TEXT_NODE&&k(t.data)&&(n=t.parentNode,i=t.previousSibling,e=t.nextSibling,(!C(n.previousSibling)||this.isBlockElement(n.previousSibling))&&!v(n)))return!i||this.isBlockElement(i)||!e||this.isBlockElement(e)},g.prototype.isExtraBR=function(t){return"br"===l(t)&&this.isBlockElement(t.parentNode)&&t.parentNode.lastChild===t},v=function(t){var e;return e=window.getComputedStyle(t).whiteSpace,"pre"===e||"pre-wrap"===e||"pre-line"===e},C=function(t){return t&&!R(t.textContent)},g.prototype.translateBlockElementMarginsToNewlines=function(){var t,e,n,i,o,r,s,a;for(e=this.getMarginOfDefaultBlockElement(),s=this.blocks,a=[],i=n=0,o=s.length;o>n;i=++n)t=s[i],(r=this.getMarginOfBlockElementAtIndex(i))&&(r.top>2*e.top&&this.prependStringToTextAtIndex("\n",i),a.push(r.bottom>2*e.bottom?this.appendStringToTextAtIndex("\n",i):void 0));return a},g.prototype.getMarginOfBlockElementAtIndex=function(t){var e,n;return!(e=this.blockElements[t])||!e.textContent||(n=l(e),f.call(r(),n)>=0||f.call(this.processedElements,e)>=0)?void 0:y(e)},g.prototype.getMarginOfDefaultBlockElement=function(){var t;return t=s(e.config.blockAttributes["default"].tagName),this.containerElement.appendChild(t),y(t)},y=function(t){var e;return e=window.getComputedStyle(t),"block"===e.display?{top:parseInt(e.marginTop),bottom:parseInt(e.marginBottom)}:void 0},A=function(t){return t.replace(RegExp("^"+n.source+"+"),"")},k=function(t){return RegExp("^"+n.source+"*$").test(t)},R=function(t){return/\s$/.test(t)},g}(e.BasicObject)}.call(this),function(){var t,n,i,o,r=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},s={}.hasOwnProperty,a=[].slice,u=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};t=e.arraysAreEqual,i=e.normalizeRange,o=e.rangeIsCollapsed,n=e.getBlockConfig,e.Document=function(s){function c(t){null==t&&(t=[]),c.__super__.constructor.apply(this,arguments),0===t.length&&(t=[new e.Block]),this.blockList=e.SplittableList.box(t)}var l;return r(c,s),c.fromJSON=function(t){var n,i;return i=function(){var i,o,r;for(r=[],i=0,o=t.length;o>i;i++)n=t[i],r.push(e.Block.fromJSON(n));return r}(),new this(i)},c.fromHTML=function(t,n){return e.HTMLParser.parse(t,n).getDocument()},c.fromString=function(t,n){var i;return i=e.Text.textForStringWithAttributes(t,n),new this([new e.Block(i)])},c.prototype.isEmpty=function(){var t;return 1===this.blockList.length&&(t=this.getBlockAtIndex(0),t.isEmpty()&&!t.hasAttributes())},c.prototype.copy=function(t){var e;return null==t&&(t={}),e=t.consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray(),new this.constructor(e)},c.prototype.copyUsingObjectsFromDocument=function(t){var n;return n=new e.ObjectMap(t.getObjects()),this.copyUsingObjectMap(n)},c.prototype.copyUsingObjectMap=function(t){var e,n,i;return n=function(){var n,o,r,s;for(r=this.getBlocks(),s=[],n=0,o=r.length;o>n;n++)e=r[n],s.push((i=t.find(e))?i:e.copyUsingObjectMap(t));return s}.call(this),new this.constructor(n)},c.prototype.copyWithBaseBlockAttributes=function(t){var e,n,i;return null==t&&(t=[]),i=function(){var i,o,r,s;for(r=this.getBlocks(),s=[],i=0,o=r.length;o>i;i++)n=r[i],e=t.concat(n.getAttributes()),s.push(n.copyWithAttributes(e));return s}.call(this),new this.constructor(i)},c.prototype.replaceBlock=function(t,e){var n;return n=this.blockList.indexOf(t),-1===n?this:new this.constructor(this.blockList.replaceObjectAtIndex(e,n))},c.prototype.insertDocumentAtRange=function(t,e){var n,r,s,a,u,c,l;return r=t.blockList,u=(e=i(e))[0],c=this.locationFromPosition(u),s=c.index,a=c.offset,l=this,n=this.getBlockAtPosition(u),o(e)&&n.isEmpty()&&!n.hasAttributes()?l=new this.constructor(l.blockList.removeObjectAtIndex(s)):n.getBlockBreakPosition()===a&&u++,l=l.removeTextAtRange(e),new this.constructor(l.blockList.insertSplittableListAtPosition(r,u))},c.prototype.mergeDocumentAtRange=function(e,n){var o,r,s,a,u,c,l,h,p,d,f,g;return f=(n=i(n))[0],d=this.locationFromPosition(f),r=this.getBlockAtIndex(d.index).getAttributes(),o=e.getBaseBlockAttributes(),g=r.slice(-o.length),t(o,g)?(l=r.slice(0,-o.length),c=e.copyWithBaseBlockAttributes(l)):c=e.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(r),s=c.getBlockCount(),a=c.getBlockAtIndex(0),t(r,a.getAttributes())?(u=a.getTextWithoutBlockBreak(),p=this.insertTextAtRange(u,n),s>1&&(c=new this.constructor(c.getBlocks().slice(1)),h=f+u.getLength(),p=p.insertDocumentAtRange(c,h))):p=this.insertDocumentAtRange(c,n),p},c.prototype.insertTextAtRange=function(t,e){var n,o,r,s,a;return a=(e=i(e))[0],s=this.locationFromPosition(a),o=s.index,r=s.offset,n=this.removeTextAtRange(e),new this.constructor(n.blockList.editObjectAtIndex(o,function(e){return e.copyWithText(e.text.insertTextAtPosition(t,r))}))},c.prototype.removeTextAtRange=function(t){var e,n,r,s,a,u,c,l,h,p,d,f,g,m,v,y,b,A,C,x,w;return p=t=i(t),l=p[0],A=p[1],o(t)?this:(d=this.locationRangeFromRange(t),u=d[0],y=d[1],a=u.index,c=u.offset,s=this.getBlockAtIndex(a),v=y.index,b=y.offset,m=this.getBlockAtIndex(v),f=A-l===1&&s.getBlockBreakPosition()===c&&m.getBlockBreakPosition()!==b&&"\n"===m.text.getStringAtPosition(b),f?r=this.blockList.editObjectAtIndex(v,function(t){return t.copyWithText(t.text.removeTextAtRange([b,b+1]))}):(h=s.text.getTextAtRange([0,c]),C=m.text.getTextAtRange([b,m.getLength()]),x=h.appendText(C),g=a!==v&&0===c,w=g&&s.getAttributeLevel()>=m.getAttributeLevel(),n=w?m.copyWithText(x):s.copyWithText(x),e=v+1-a,r=this.blockList.splice(a,e,n)),new this.constructor(r))},c.prototype.moveTextFromRangeToPosition=function(t,e){var n,o,r,s,u,c,l,h,p,d;return c=t=i(t),p=c[0],r=c[1],e>=p&&r>=e?this:(o=this.getDocumentAtRange(t),h=this.removeTextAtRange(t),u=e>p,u&&(e-=o.getLength()),l=o.getBlocks(),s=l[0],n=2<=l.length?a.call(l,1):[],0===n.length?(d=s.getTextWithoutBlockBreak(),u&&(e+=1)):d=s.text,h=h.insertTextAtRange(d,e),0===n.length?h:(o=new this.constructor(n),e+=d.getLength(),h.insertDocumentAtRange(o,e)))}
21854,c.prototype.addAttributeAtRange=function(t,e,i){var o;return o=this.blockList,this.eachBlockAtRange(i,function(i,r,s){return o=o.editObjectAtIndex(s,function(){return n(t)?i.addAttribute(t,e):r[0]===r[1]?i:i.copyWithText(i.text.addAttributeAtRange(t,e,r))})}),new this.constructor(o)},c.prototype.addAttribute=function(t,e){var n;return n=this.blockList,this.eachBlock(function(i,o){return n=n.editObjectAtIndex(o,function(){return i.addAttribute(t,e)})}),new this.constructor(n)},c.prototype.removeAttributeAtRange=function(t,e){var i;return i=this.blockList,this.eachBlockAtRange(e,function(e,o,r){return n(t)?i=i.editObjectAtIndex(r,function(){return e.removeAttribute(t)}):o[0]!==o[1]?i=i.editObjectAtIndex(r,function(){return e.copyWithText(e.text.removeAttributeAtRange(t,o))}):void 0}),new this.constructor(i)},c.prototype.updateAttributesForAttachment=function(t,e){var n,i,o,r;return o=(i=this.getRangeOfAttachment(e))[0],n=this.locationFromPosition(o).index,r=this.getTextAtIndex(n),new this.constructor(this.blockList.editObjectAtIndex(n,function(n){return n.copyWithText(r.updateAttributesForAttachment(t,e))}))},c.prototype.removeAttributeForAttachment=function(t,e){var n;return n=this.getRangeOfAttachment(e),this.removeAttributeAtRange(t,n)},c.prototype.insertBlockBreakAtRange=function(t){var n,o,r,s;return s=(t=i(t))[0],r=this.locationFromPosition(s).offset,o=this.removeTextAtRange(t),0===r&&(n=[new e.Block]),new this.constructor(o.blockList.insertSplittableListAtPosition(new e.SplittableList(n),s))},c.prototype.applyBlockAttributeAtRange=function(t,e,i){var o,r,s,a;return s=this.expandRangeToLineBreaksAndSplitBlocks(i),r=s.document,i=s.range,o=n(t),o.listAttribute?(r=r.removeLastListAttributeAtRange(i,{exceptAttributeName:t}),a=r.convertLineBreaksToBlockBreaksInRange(i),r=a.document,i=a.range):r=o.exclusive?r.removeBlockAttributesAtRange(i):o.terminal?r.removeLastTerminalAttributeAtRange(i):r.consolidateBlocksAtRange(i),r.addAttributeAtRange(t,e,i)},c.prototype.removeLastListAttributeAtRange=function(t,e){var i;return null==e&&(e={}),i=this.blockList,this.eachBlockAtRange(t,function(t,o,r){var s;if((s=t.getLastAttribute())&&n(s).listAttribute&&s!==e.exceptAttributeName)return i=i.editObjectAtIndex(r,function(){return t.removeAttribute(s)})}),new this.constructor(i)},c.prototype.removeLastTerminalAttributeAtRange=function(t){var e;return e=this.blockList,this.eachBlockAtRange(t,function(t,i,o){var r;if((r=t.getLastAttribute())&&n(r).terminal)return e=e.editObjectAtIndex(o,function(){return t.removeAttribute(r)})}),new this.constructor(e)},c.prototype.removeBlockAttributesAtRange=function(t){var e;return e=this.blockList,this.eachBlockAtRange(t,function(t,n,i){return t.hasAttributes()?e=e.editObjectAtIndex(i,function(){return t.copyWithoutAttributes()}):void 0}),new this.constructor(e)},c.prototype.expandRangeToLineBreaksAndSplitBlocks=function(t){var e,n,o,r,s,a,u,c,l;return a=t=i(t),l=a[0],r=a[1],c=this.locationFromPosition(l),o=this.locationFromPosition(r),e=this,u=e.getBlockAtIndex(c.index),null!=(c.offset=u.findLineBreakInDirectionFromPosition("backward",c.offset))&&(s=e.positionFromLocation(c),e=e.insertBlockBreakAtRange([s,s+1]),o.index+=1,o.offset-=e.getBlockAtIndex(c.index).getLength(),c.index+=1),c.offset=0,0===o.offset&&o.index>c.index?(o.index-=1,o.offset=e.getBlockAtIndex(o.index).getBlockBreakPosition()):(n=e.getBlockAtIndex(o.index),"\n"===n.text.getStringAtRange([o.offset-1,o.offset])?o.offset-=1:o.offset=n.findLineBreakInDirectionFromPosition("forward",o.offset),o.offset!==n.getBlockBreakPosition()&&(s=e.positionFromLocation(o),e=e.insertBlockBreakAtRange([s,s+1]))),l=e.positionFromLocation(c),r=e.positionFromLocation(o),t=i([l,r]),{document:e,range:t}},c.prototype.convertLineBreaksToBlockBreaksInRange=function(t){var e,n,o;return n=(t=i(t))[0],o=this.getStringAtRange(t).slice(0,-1),e=this,o.replace(/.*?\n/g,function(t){return n+=t.length,e=e.insertBlockBreakAtRange([n-1,n])}),{document:e,range:t}},c.prototype.consolidateBlocksAtRange=function(t){var e,n,o,r,s;return o=t=i(t),s=o[0],n=o[1],r=this.locationFromPosition(s).index,e=this.locationFromPosition(n).index,new this.constructor(this.blockList.consolidateFromIndexToIndex(r,e))},c.prototype.getDocumentAtRange=function(t){var e;return t=i(t),e=this.blockList.getSplittableListInRange(t).toArray(),new this.constructor(e)},c.prototype.getStringAtRange=function(t){var e,n,o;return o=t=i(t),n=o[o.length-1],n!==this.getLength()&&(e=-1),this.getDocumentAtRange(t).toString().slice(0,e)},c.prototype.getBlockAtIndex=function(t){return this.blockList.getObjectAtIndex(t)},c.prototype.getBlockAtPosition=function(t){var e;return e=this.locationFromPosition(t).index,this.getBlockAtIndex(e)},c.prototype.getTextAtIndex=function(t){var e;return null!=(e=this.getBlockAtIndex(t))?e.text:void 0},c.prototype.getTextAtPosition=function(t){var e;return e=this.locationFromPosition(t).index,this.getTextAtIndex(e)},c.prototype.getPieceAtPosition=function(t){var e,n,i;return i=this.locationFromPosition(t),e=i.index,n=i.offset,this.getTextAtIndex(e).getPieceAtPosition(n)},c.prototype.getCharacterAtPosition=function(t){var e,n,i;return i=this.locationFromPosition(t),e=i.index,n=i.offset,this.getTextAtIndex(e).getStringAtRange([n,n+1])},c.prototype.getLength=function(){return this.blockList.getEndPosition()},c.prototype.getBlocks=function(){return this.blockList.toArray()},c.prototype.getBlockCount=function(){return this.blockList.length},c.prototype.getEditCount=function(){return this.editCount},c.prototype.eachBlock=function(t){return this.blockList.eachObject(t)},c.prototype.eachBlockAtRange=function(t,e){var n,o,r,s,a,u,c,l,h,p,d,f;if(u=t=i(t),d=u[0],r=u[1],p=this.locationFromPosition(d),o=this.locationFromPosition(r),p.index===o.index)return n=this.getBlockAtIndex(p.index),f=[p.offset,o.offset],e(n,f,p.index);for(h=[],a=s=c=p.index,l=o.index;l>=c?l>=s:s>=l;a=l>=c?++s:--s)(n=this.getBlockAtIndex(a))?(f=function(){switch(a){case p.index:return[p.offset,n.text.getLength()];case o.index:return[0,o.offset];default:return[0,n.text.getLength()]}}(),h.push(e(n,f,a))):h.push(void 0);return h},c.prototype.getCommonAttributesAtRange=function(t){var n,r,s;return r=(t=i(t))[0],o(t)?this.getCommonAttributesAtPosition(r):(s=[],n=[],this.eachBlockAtRange(t,function(t,e){return e[0]!==e[1]?(s.push(t.text.getCommonAttributesAtRange(e)),n.push(l(t))):void 0 21855}),e.Hash.fromCommonAttributesOfObjects(s).merge(e.Hash.fromCommonAttributesOfObjects(n)).toObject())},c.prototype.getCommonAttributesAtPosition=function(t){var n,i,o,r,s,a,c,h,p,d;if(p=this.locationFromPosition(t),s=p.index,h=p.offset,o=this.getBlockAtIndex(s),!o)return{};r=l(o),n=o.text.getAttributesAtPosition(h),i=o.text.getAttributesAtPosition(h-1),a=function(){var t,n;t=e.config.textAttributes,n=[];for(c in t)d=t[c],d.inheritable&&n.push(c);return n}();for(c in i)d=i[c],(d===n[c]||u.call(a,c)>=0)&&(r[c]=d);return r},c.prototype.getRangeOfCommonAttributeAtPosition=function(t,e){var n,o,r,s,a,u,c,l,h;return a=this.locationFromPosition(e),r=a.index,s=a.offset,h=this.getTextAtIndex(r),u=h.getExpandedRangeForAttributeAtOffset(t,s),l=u[0],o=u[1],c=this.positionFromLocation({index:r,offset:l}),n=this.positionFromLocation({index:r,offset:o}),i([c,n])},c.prototype.getBaseBlockAttributes=function(){var t,e,n,i,o,r,s;for(t=this.getBlockAtIndex(0).getAttributes(),n=i=1,s=this.getBlockCount();s>=1?s>i:i>s;n=s>=1?++i:--i)e=this.getBlockAtIndex(n).getAttributes(),r=Math.min(t.length,e.length),t=function(){var n,i,s;for(s=[],o=n=0,i=r;(i>=0?i>n:n>i)&&e[o]===t[o];o=i>=0?++n:--n)s.push(e[o]);return s}();return t},l=function(t){var e,n;return n={},(e=t.getLastAttribute())&&(n[e]=!0),n},c.prototype.getAttachmentById=function(t){var e,n,i,o;for(o=this.getAttachments(),n=0,i=o.length;i>n;n++)if(e=o[n],e.id===t)return e},c.prototype.getAttachmentPieces=function(){var t;return t=[],this.blockList.eachObject(function(e){var n;return n=e.text,t=t.concat(n.getAttachmentPieces())}),t},c.prototype.getAttachments=function(){var t,e,n,i,o;for(i=this.getAttachmentPieces(),o=[],t=0,e=i.length;e>t;t++)n=i[t],o.push(n.attachment);return o},c.prototype.getRangeOfAttachment=function(t){var e,n,o,r,s,a,u;for(r=0,s=this.blockList.toArray(),n=e=0,o=s.length;o>e;n=++e){if(a=s[n].text,u=a.getRangeOfAttachment(t))return i([r+u[0],r+u[1]]);r+=a.getLength()}},c.prototype.getLocationRangeOfAttachment=function(t){var e;return e=this.getRangeOfAttachment(t),this.locationRangeFromRange(e)},c.prototype.getAttachmentPieceForAttachment=function(t){var e,n,i,o;for(o=this.getAttachmentPieces(),e=0,n=o.length;n>e;e++)if(i=o[e],i.attachment===t)return i},c.prototype.findRangesForBlockAttribute=function(t){var e,n,i,o,r,s,a;for(r=0,s=[],a=this.getBlocks(),n=0,i=a.length;i>n;n++)e=a[n],o=e.getLength(),e.hasAttribute(t)&&s.push([r,r+o]),r+=o;return s},c.prototype.findRangesForTextAttribute=function(t,e){var n,i,o,r,s,a,u,c,l,h;for(h=(null!=e?e:{}).withValue,a=0,u=[],c=[],r=function(e){return null!=h?e.getAttribute(t)===h:e.hasAttribute(t)},l=this.getPieces(),n=0,i=l.length;i>n;n++)s=l[n],o=s.getLength(),r(s)&&(u[1]===a?u[1]=a+o:c.push(u=[a,a+o])
21855),a+=o;return c},c.prototype.locationFromPosition=function(t){var e,n;return n=this.blockList.findIndexAndOffsetAtPosition(Math.max(0,t)),null!=n.index?n:(e=this.getBlocks(),{index:e.length-1,offset:e[e.length-1].getLength()})},c.prototype.positionFromLocation=function(t){return this.blockList.findPositionAtIndexAndOffset(t.index,t.offset)},c.prototype.locationRangeFromPosition=function(t){return i(this.locationFromPosition(t))},c.prototype.locationRangeFromRange=function(t){var e,n,o,r;if(t=i(t))return r=t[0],n=t[1],o=this.locationFromPosition(r),e=this.locationFromPosition(n),i([o,e])},c.prototype.rangeFromLocationRange=function(t){var e,n;return t=i(t),e=this.positionFromLocation(t[0]),o(t)||(n=this.positionFromLocation(t[1])),i([e,n])},c.prototype.isEqualTo=function(t){return this.blockList.isEqualTo(null!=t?t.blockList:void 0)},c.prototype.getTexts=function(){var t,e,n,i,o;for(i=this.getBlocks(),o=[],e=0,n=i.length;n>e;e++)t=i[e],o.push(t.text);return o},c.prototype.getPieces=function(){var t,e,n,i,o;for(n=[],i=this.getTexts(),t=0,e=i.length;e>t;t++)o=i[t],n.push.apply(n,o.getPieces());return n},c.prototype.getObjects=function(){return this.getBlocks().concat(this.getTexts()).concat(this.getPieces())},c.prototype.toSerializableDocument=function(){var t;return t=[],this.blockList.eachObject(function(e){return t.push(e.copyWithText(e.text.toSerializableText()))}),new this.constructor(t)},c.prototype.toString=function(){return this.blockList.toString()},c.prototype.toJSON=function(){return this.blockList.toJSON()},c.prototype.toConsole=function(){var t;return JSON.stringify(function(){var e,n,i,o;for(i=this.blockList.toArray(),o=[],e=0,n=i.length;n>e;e++)t=i[e],o.push(JSON.parse(t.text.toConsole()));return o}.call(this))},c}(e.Object)}.call(this),function(){e.LineBreakInsertion=function(){function t(t){var e;this.composition=t,this.document=this.composition.document,e=this.composition.getSelectedRange(),this.startPosition=e[0],this.endPosition=e[1],this.startLocation=this.document.locationFromPosition(this.startPosition),this.endLocation=this.document.locationFromPosition(this.endPosition),this.block=this.document.getBlockAtIndex(this.endLocation.index),this.breaksOnReturn=this.block.breaksOnReturn(),this.previousCharacter=this.block.text.getStringAtPosition(this.endLocation.offset-1),this.nextCharacter=this.block.text.getStringAtPosition(this.endLocation.offset)}return t.prototype.shouldInsertBlockBreak=function(){return this.block.hasAttributes()&&this.block.isListItem()&&!this.block.isEmpty()?0!==this.startLocation.offset:this.breaksOnReturn&&"\n"!==this.nextCharacter},t.prototype.shouldBreakFormattedBlock=function(){return this.block.hasAttributes()&&!this.block.isListItem()&&(this.breaksOnReturn&&"\n"===this.nextCharacter||"\n"===this.previousCharacter)},t.prototype.shouldDecreaseListLevel=function(){return this.block.hasAttributes()&&this.block.isListItem()&&this.block.isEmpty()},t.prototype.shouldPrependListItem=function(){return this.block.isListItem()&&0===this.startLocation.offset&&!this.block.isEmpty()},t.prototype.shouldRemoveLastBlockAttribute=function(){return this.block.hasAttributes()&&!this.block.isListItem()&&this.block.isEmpty()},t}()}.call(this),function(){var t,n,i,o,r,s,a,u,c,l,h=function(t,e){function n(){this.constructor=t}for(var i in e)p.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},p={}.hasOwnProperty;s=e.normalizeRange,c=e.rangesAreEqual,u=e.rangeIsCollapsed,a=e.objectsAreEqual,t=e.arrayStartsWith,l=e.summarizeArrayChange,i=e.getAllAttributeNames,o=e.getBlockConfig,r=e.getTextConfig,n=e.extend,e.Composition=function(p){function d(){this.document=new e.Document,this.attachments=[],this.currentAttributes={},this.revision=0}var f;return h(d,p),d.prototype.setDocument=function(t){var e;return t.isEqualTo(this.document)?void 0:(this.document=t,this.refreshAttachments(),this.revision++,null!=(e=this.delegate)&&"function"==typeof e.compositionDidChangeDocument?e.compositionDidChangeDocument(t):void 0)},d.prototype.getSnapshot=function(){return{document:this.document,selectedRange:this.getSelectedRange()}}
21855,d.prototype.loadSnapshot=function(t){var n,i,o,r;return n=t.document,r=t.selectedRange,null!=(i=this.delegate)&&"function"==typeof i.compositionWillLoadSnapshot&&i.compositionWillLoadSnapshot(),this.setDocument(null!=n?n:new e.Document),this.setSelection(null!=r?r:[0,0]),null!=(o=this.delegate)&&"function"==typeof o.compositionDidLoadSnapshot?o.compositionDidLoadSnapshot():void 0},d.prototype.insertText=function(t,e){var n,i,o,r;return r=(null!=e?e:{updatePosition:!0}).updatePosition,i=this.getSelectedRange(),this.setDocument(this.document.insertTextAtRange(t,i)),o=i[0],n=o+t.getLength(),r&&this.setSelection(n),this.notifyDelegateOfInsertionAtRange([o,n])},d.prototype.insertBlock=function(t){var n;return null==t&&(t=new e.Block),n=new e.Document([t]),this.insertDocument(n)},d.prototype.insertDocument=function(t){var n,i,o;return null==t&&(t=new e.Document),i=this.getSelectedRange(),this.setDocument(this.document.insertDocumentAtRange(t,i)),o=i[0],n=o+t.getLength(),this.setSelection(n),this.notifyDelegateOfInsertionAtRange([o,n])},d.prototype.insertString=function(t,n){var i,o;return i=this.getCurrentTextAttributes(),o=e.Text.textForStringWithAttributes(t,i),this.insertText(o,n)},d.prototype.insertBlockBreak=function(){var t,e,n;return e=this.getSelectedRange(),this.setDocument(this.document.insertBlockBreakAtRange(e)),n=e[0],t=n+1,this.setSelection(t),this.notifyDelegateOfInsertionAtRange([n,t])},d.prototype.insertLineBreak=function(){var t,n;return n=new e.LineBreakInsertion(this),n.shouldDecreaseListLevel()?(this.decreaseListLevel(),this.setSelection(n.startPosition)):n.shouldPrependListItem()?(t=new e.Document([n.block.copyWithoutText()]),this.insertDocument(t)):n.shouldInsertBlockBreak()?this.insertBlockBreak():n.shouldRemoveLastBlockAttribute()?this.removeLastBlockAttribute():n.shouldBreakFormattedBlock()?this.breakFormattedBlock(n):this.insertString("\n")},d.prototype.insertHTML=function(t){var n,i,o,r;return n=e.Document.fromHTML(t),o=this.getSelectedRange(),this.setDocument(this.document.mergeDocumentAtRange(n,o)),r=o[0],i=r+n.getLength()-1,this.setSelection(i),this.notifyDelegateOfInsertionAtRange([r,i])},d.prototype.replaceHTML=function(t){var n,i,o;return n=e.Document.fromHTML(t).copyUsingObjectsFromDocument(this.document),i=this.getLocationRange({strict:!1}),o=this.document.rangeFromLocationRange(i),this.setDocument(n),this.setSelection(o)},d.prototype.insertFile=function(t){return this.insertFiles([t])},d.prototype.insertFiles=function(t){var n,i,o,r,s,a;for(i=[],r=0,s=t.length;s>r;r++)o=t[r],(null!=(a=this.delegate)?a.compositionShouldAcceptFile(o):void 0)&&(n=e.Attachment.attachmentForFile(o),i.push(n));return this.insertAttachments(i)},d.prototype.insertAttachment=function(t){return this.insertAttachments([t])},d.prototype.insertAttachments=function(t){var n,i,o,r,s,a,u,c,l;for(c=new e.Text,r=0,s=t.length;s>r;r++)n=t[r],l=n.getType(),a=null!=(u=e.config.attachments[l])?u.presentation:void 0,o=this.getCurrentTextAttributes(),a&&(o.presentation=a),i=e.Text.textForAttachmentWithAttributes(n,o),c=c.appendText(i);return this.insertText(c)},d.prototype.shouldManageDeletingInDirection=function(t){var e;if(e=this.getLocationRange(),u(e)){if("backward"===t&&0===e[0].offset)return!0;if(this.shouldManageMovingCursorInDirection(t))return!0}else if(e[0].index!==e[1].index)return!0;return!1},d.prototype.deleteInDirection=function(t,e){var n,i,o,r,s,a,c,l;return r=(null!=e?e:{}).length,s=this.getLocationRange(),a=this.getSelectedRange(),c=u(a),c?o="backward"===t&&0===s[0].offset:l=s[0].index!==s[1].index,o&&this.canDecreaseBlockAttributeLevel()&&(i=this.getBlock(),i.isListItem()?this.decreaseListLevel():this.decreaseBlockAttributeLevel(),this.setSelection(a[0]),i.isEmpty())?!1:(c&&(a=this.getExpandedRangeInDirection(t,{length:r}),"backward"===t&&(n=this.getAttachmentAtRange(a))),n?(this.editAttachment(n),!1):(this.setDocument(this.document.removeTextAtRange(a)),this.setSelection(a[0]),o||l?!1:void 0))},d.prototype.moveTextFromRange=function(t){var e;return e=this.getSelectedRange()[0],this.setDocument(this.document.moveTextFromRangeToPosition(t,e)),this.setSelection(e)},d.prototype.removeAttachment=function(t){var e;return(e=this.document.getRangeOfAttachment(t))?(this.stopEditingAttachment(),this.setDocument(this.document.removeTextAtRange(e)),this.setSelection(e[0])):void 0},d.prototype.removeLastBlockAttribute=function(){var t,e,n,i;return n=this.getSelectedRange(),i=n[0],e=n[1],t=this.document.getBlockAtPosition(e),this.removeCurrentAttribute(t.getLastAttribute()),this.setSelection(i)},f=" ",d.prototype.insertPlaceholder=function(){return this.placeholderPosition=this.getPosition(),this.insertString(f)},d.prototype.selectPlaceholder=function(){return null!=this.placeholderPosition?(this.setSelectedRange([this.placeholderPosition,this.placeholderPosition+f.length]),this.get
21855SelectedRange()):void 0},d.prototype.forgetPlaceholder=function(){return this.placeholderPosition=null},d.prototype.hasCurrentAttribute=function(t){var e;return e=this.currentAttributes[t],null!=e&&e!==!1},d.prototype.toggleCurrentAttribute=function(t){var e;return(e=!this.currentAttributes[t])?this.setCurrentAttribute(t,e):this.removeCurrentAttribute(t)},d.prototype.canSetCurrentAttribute=function(t){return o(t)?this.canSetCurrentBlockAttribute(t):this.canSetCurrentTextAttribute(t)},d.prototype.canSetCurrentTextAttribute=function(){var t,e,n,i,o;if(e=this.getSelectedDocument()){for(o=e.getAttachments(),n=0,i=o.length;i>n;n++)if(t=o[n],!t.hasContent())return!1;return!0}},d.prototype.canSetCurrentBlockAttribute=function(){var t;if(t=this.getBlock())return!t.isTerminalBlock()},d.prototype.setCurrentAttribute=function(t,e){return o(t)?this.setBlockAttribute(t,e):(this.setTextAttribute(t,e),this.currentAttributes[t]=e,this.notifyDelegateOfCurrentAttributesChange())},d.prototype.setTextAttribute=function(t,n){var i,o,r,s;if(o=this.getSelectedRange())return r=o[0],i=o[1],r!==i?this.setDocument(this.document.addAttributeAtRange(t,n,o)):"href"===t?(s=e.Text.textForStringWithAttributes(n,{href:n}),this.insertText(s)):void 0},d.prototype.setBlockAttribute=function(t,e){var n,i;if(i=this.getSelectedRange())return this.canSetCurrentAttribute(t)?(n=this.getBlock(),this.setDocument(this.document.applyBlockAttributeAtRange(t,e,i)),this.setSelection(i)):void 0},d.prototype.removeCurrentAttribute=function(t){return o(t)?(this.removeBlockAttribute(t),this.updateCurrentAttributes()):(this.removeTextAttribute(t),delete this.currentAttributes[t],this.notifyDelegateOfCurrentAttributesChange())},d.prototype.removeTextAttribute=function(t){var e;if(e=this.getSelectedRange())return this.setDocument(this.document.removeAttributeAtRange(t,e))},d.prototype.removeBlockAttribute=function(t){var e;if(e=this.getSelectedRange())return this.setDocument(this.document.removeAttributeAtRange(t,e))},d.prototype.canDecreaseNestingLevel=function(){var t;return(null!=(t=this.getBlock())?t.getNestingLevel():void 0)>0},d.prototype.canIncreaseNestingLevel=function(){var e,n,i;if(e=this.getBlock())return(null!=(i=o(e.getLastNestableAttribute()))?i.listAttribute:0)?(n=this.getPreviousBlock())?t(n.getListItemAttributes(),e.getListItemAttributes()):void 0:e.getNestingLevel()>0},d.prototype.decreaseNestingLevel=function(){var t;if(t=this.getBlock())return this.setDocument(this.document.replaceBlock(t,t.decreaseNestingLevel()))},d.prototype.increaseNestingLevel=function(){var t;if(t=this.getBlock())return this.setDocument(this.document.replaceBlock(t,t.increaseNestingLevel()))},d.prototype.canDecreaseBlockAttributeLevel=function(){var t;return(null!=(t=this.getBlock())?t.getAttributeLevel():void 0)>0},d.prototype.decreaseBlockAttributeLevel=function(){var t,e;return(t=null!=(e=this.getBlock())?e.getLastAttribute():void 0)?this.removeCurrentAttribute(t):void 0},d.prototype.decreaseListLevel=function(){var t,e,n,i,o,r;for(r=this.getSelectedRange()[0],o=this.document.locationFromPosition(r).index,n=o,t=this.getBlock().getAttributeLevel();(e=this.document.getBlockAtIndex(n+1))&&e.isListItem()&&e.getAttributeLevel()>t;)n++;return r=this.document.positionFromLocation({index:o,offset:0}),i=this.document.positionFromLocation({index:n,offset:0}),this.setDocument(this.document.removeLastListAttributeAtRange([r,i]))},d.prototype.updateCurrentAttributes=function(){var t,e,n,o,r,s;if(s=this.getSelectedRange({ignoreLock:!0})){for(e=this.document.getCommonAttributesAtRange(s),r=i(),n=0,o=r.length;o>n;n++)t=r[n],e[t]||this.canSetCurrentAttribute(t)||(e[t]=!1);if(!a(e,this.currentAttributes))return this.currentAttributes=e,this.notifyDelegateOfCurrentAttributesChange()}},d.prototype.getCurrentAttributes=function(){return n.call({},this.currentAttributes)},d.prototype.getCurrentTextAttributes=function(){var t,e,n,i;t={},n=this.currentAttributes;for(e in n)i=n[e],i!==!1&&r(e)&&(t[e]=i);return t},d.prototype.freezeSelection=function(){return this.setCurrentAttribute("frozen",!0)},d.prototype.thawSelection=function(){return this.removeCurrentAttribute("frozen")},d.prototype.hasFrozenSelection=function(){return this.hasCurrentAttribute("frozen")},d.proxyMethod("getSelectionManager().getPointRange"),d.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"),d.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"),d.proxyMethod("getSelectionManager().locationIsCursorTarget"),d.proxyMethod("getSelectionManager().selectionIsExpanded"),d.proxyMethod("delegate?.getSelectionManager"),d.prototype.setSelection=function(t){var e,n;return e=this.document.locationRangeFromRange(t),null!=(n=this.delegate)?n.compositionDidRequestChangingSelectionToLocationRange(e):void 0},d.prototype.getSelectedRange=function(){var t;return(t=this.getLocationRange())?this.document.rangeFromLocationRange(t):void 0},d.prototype.setSelectedRange=function(t){var e;
21855return e=this.document.locationRangeFromRange(t),this.getSelectionManager().setLocationRange(e)},d.prototype.getPosition=function(){var t;return(t=this.getLocationRange())?this.document.positionFromLocation(t[0]):void 0},d.prototype.getLocationRange=function(t){var e,n;return null!=(e=null!=(n=this.targetLocationRange)?n:this.getSelectionManager().getLocationRange(t))?e:s({index:0,offset:0})},d.prototype.withTargetLocationRange=function(t,e){var n;this.targetLocationRange=t;try{n=e()}finally{this.targetLocationRange=null}return n},d.prototype.withTargetRange=function(t,e){var n;return n=this.document.locationRangeFromRange(t),this.withTargetLocationRange(n,e)},d.prototype.withTargetDOMRange=function(t,e){var n;return n=this.createLocationRangeFromDOMRange(t,{strict:!1}),this.withTargetLocationRange(n,e)},d.prototype.getExpandedRangeInDirection=function(t,e){var n,i,o,r;return i=(null!=e?e:{}).length,o=this.getSelectedRange(),r=o[0],n=o[1],"backward"===t?i?r-=i:r=this.translateUTF16PositionFromOffset(r,-1):i?n+=i:n=this.translateUTF16PositionFromOffset(n,1),s([r,n])},d.prototype.shouldManageMovingCursorInDirection=function(t){var e;return this.editingAttachment?!0:(e=this.getExpandedRangeInDirection(t),null!=this.getAttachmentAtRange(e))},d.prototype.moveCursorInDirection=function(t){var e,n,i,o;return this.editingAttachment?i=this.document.getRangeOfAttachment(this.editingAttachment):(o=this.getSelectedRange(),i=this.getExpandedRangeInDirection(t),n=!c(o,i)),this.setSelectedRange("backward"===t?i[0]:i[1]),n&&(e=this.getAttachmentAtRange(i))?this.editAttachment(e):void 0},d.prototype.expandSelectionInDirection=function(t,e){var n,i;return n=(null!=e?e:{}).length,i=this.getExpandedRangeInDirection(t,{length:n}),this.setSelectedRange(i)},d.prototype.expandSelectionForEditing=function(){return this.hasCurrentAttribute("href")?this.expandSelectionAroundCommonAttribute("href"):void 0},d.prototype.expandSelectionAroundCommonAttribute=function(t){var e,n;return e=this.getPosition(),n=this.document.getRangeOfCommonAttributeAtPosition(t,e),this.setSelectedRange(n)},d.prototype.selectionContainsAttachments=function(){var t;return(null!=(t=this.getSelectedAttachments())?t.length:void 0)>0},d.prototype.selectionIsInCursorTarget=function(){return this.editingAttachment||this.positionIsCursorTarget(this.getPosition())},d.prototype.positionIsCursorTarget=function(t){var e;return(e=this.document.locationFromPosition(t))?this.locationIsCursorTarget(e):void 0},d.prototype.positionIsBlockBreak=function(t){var e;return null!=(e=this.document.getPieceAtPosition(t))?e.isBlockBreak():void 0},d.prototype.getSelectedDocument=function(){var t;return(t=this.getSelectedRange())?this.document.getDocumentAtRange(t):void 0},d.prototype.getSelectedAttachments=function(){var t;return null!=(t=this.getSelectedDocument())?t.getAttachments():void 0},d.prototype.getAttachments=function(){return this.attachments.slice(0)},d.prototype.refreshAttachments=function(){var t,e,n,i,o,r,s,a,u,c,h,p;for(n=this.document.getAttachments(),a=l(this.attachments,n),t=a.added,h=a.removed,this.attachments=n,i=0,r=h.length;r>i;i++)e=h[i],e.delegate=null,null!=(u=this.delegate)&&"function"==typeof u.compositionDidRemoveAttachment&&u.compositionDidRemoveAttachment(e);for(p=[],o=0,s=t.length;s>o;o++)e=t[o],e.delegate=this,p.push(null!=(c=this.delegate)&&"function"==typeof c.compositionDidAddAttachment?c.compositionDidAddAttachment(e):void 0);return p},d.prototype.attachmentDidChangeAttributes=function(t){var e;return this.revision++,null!=(e=this.delegate)&&"function"==typeof e.compositionDidEditAttachment?e.compositionDidEditAttachment(t):void 0},d.prototype.attachmentDidChangePreviewURL=function(t){var e;return this.revision++,null!=(e=this.delegate)&&"function"==typeof e.compositionDidChangeAttachmentPreviewURL?e.compositionDidChangeAttachmentPreviewURL(t):void 0},d.prototype.editAttachment=function(t,e){var n;if(t!==this.editingAttachment)return this.stopEditingAttachment(),this.editingAttachment=t,null!=(n=this.delegate)&&"function"==typeof n.compositionDidStartEditingAttachment?n.compositionDidStartEditingAttachment(this.editingAttachment,e):void 0},d.prototype.stopEditingAttachment=function(){var t;if(this.editingAttachment)return null!=(t=this.delegate)&&"function"==typeof t.compositionDidStopEditingAttachment&&t.compositionDidStopEditingAttachment(this.editingAttachment),this.editingAttachment=null},d.prototype.updateAttributesForAttachment=function(t,e){return this.setDocument(this.document.updateAttributesForAttachment(t,e))},d.prototype.removeAttributeForAttachment=function(t,e){return this.setDocument(this.document.removeAttributeForAttachment(t,e))},d.prototype.breakFormattedBlock=function(t){var n,i,o,r,s;return i=t.document,n=t.block,r=t.startPosition,s=[r-1,r],n.getBlockBreakPosition()===t.startLocation.offset?(n.breaksOnReturn()&&"\n"===t.nextCharacter?r+=1:i=i.removeTextAtRange(s),s=[r,r]):"\n"===t.nextCharacter?"\n"===t.previousCharacter?s=[r-1,r+1]:(s=[r,r+1],r+=1):t.startLocation.offset-1!==0&&(r+=1),o=new e.Document([n.removeLastAttribute().copyWithoutText()]),this.setDocument(i.insertDocumentAtRange(o,s)),this.setSelection(r)},d.prototype.getPreviousBlock=function(){var t,e;return(e=this.getLocationRange())&&(t=e[0].index,t>0)?this.document.getBlockAtIndex(t-1):void 0},d.prototype.getBlock=function(){var t;return(t=this.getLocationRange())?this.document.getBlockAtIndex(t[0].index):void 0},d.prototype.getAttachmentAtRange=function(t){var n;return n=this.document.getDocumentAtRange(t),n.toString()===e.OBJECT_REPLACEMENT_CHARACTER+"\n"?n.getAttachments()[0]:void 0},d.prototype.notifyDelegateOfCurrentAttributesChange=function(){var t;return null!=(t=this.delegate)&&"function"==typeof t.compositionDidChangeCurrentAttributes?t.compositionDidChangeCurrentAttributes(this.currentAttributes):void 0},d.prototype.notifyDelegateOfInsertionAtRange=function(t){var e;return null!=(e=this.delegate)&&"function"==typeof e.compositionDidPerformInsertionAtRange?e.compositionDidPerformInsertionAtRange(t):void 0},d.prototype.translateUTF16PositionFromOffset=function(t,e){var n,i;return i=this.document.toUTF16String(),n=i.offsetFromUCS2Offset(t),i.offsetToUCS2Offset(n+e)},d}(e.BasicObject)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.UndoManager=function(e){function n(t){this.composition=t,this.undoEntries=[],this.redoEntries=[]}var i;return t(n,e),n.prototype.recordUndoEntry=function(t,e){var n,o,r,s,a;return s=null!=e?e:{},o=s.context,n=s.consolidatable,r=this.undoEntries.slice(-1)[0],n&&i(r,t,o)?void 0:(a=this.createEntry({description:t,context:o}),this.undoEntries.push(a),this.redoEntries=[])},n.prototype.undo=function(){var t,e;return(e=this.undoEntries.pop())?(t=this.createEntry(e),this.redoEntries.push(t),this.composition.loadSnapsh
21855ot(e.snapshot)):void 0},n.prototype.redo=function(){var t,e;return(t=this.redoEntries.pop())?(e=this.createEntry(t),this.undoEntries.push(e),this.composition.loadSnapshot(t.snapshot)):void 0},n.prototype.canUndo=function(){return this.undoEntries.length>0},n.prototype.canRedo=function(){return this.redoEntries.length>0},n.prototype.createEntry=function(t){var e,n,i;return i=null!=t?t:{},n=i.description,e=i.context,{description:null!=n?n.toString():void 0,context:JSON.stringify(e),snapshot:this.composition.getSnapshot()}},i=function(t,e,n){return(null!=t?t.description:void 0)===(null!=e?e.toString():void 0)&&(null!=t?t.context:void 0)===JSON.stringify(n)},n}(e.BasicObject)}.call(this),function(){var t;e.attachmentGalleryFilter=function(e){var n;return n=new t(e),n.perform(),n.getSnapshot()},t=function(){function t(t){this.document=t.document,this.selectedRange=t.selectedRange}var e,n,i;return e="attachmentGallery",n="presentation",i="gallery",t.prototype.perform=function(){return this.removeBlockAttribute(),this.applyBlockAttribute()},t.prototype.getSnapshot=function(){return{document:this.document,selectedRange:this.selectedRange}},t.prototype.removeBlockAttribute=function(){var t,n,i,o,r;for(o=this.findRangesOfBlocks(),r=[],t=0,n=o.length;n>t;t++)i=o[t],r.push(this.document=this.document.removeAttributeAtRange(e,i));return r},t.prototype.applyBlockAttribute=function(){var t,n,i,o,r,s;for(i=0,r=this.findRangesOfPieces(),s=[],t=0,n=r.length;n>t;t++)o=r[t],o[1]-o[0]>1&&(o[0]+=i,o[1]+=i,"\n"!==this.document.getCharacterAtPosition(o[1])&&(this.document=this.document.insertBlockBreakAtRange(o[1]),o[1]<this.selectedRange[1]&&this.moveSelectedRangeForward(),o[1]++,i++),0!==o[0]&&"\n"!==this.document.getCharacterAtPosition(o[0]-1)&&(this.document=this.document.insertBlockBreakAtRange(o[0]),o[0]<this.selectedRange[0]&&this.moveSelectedRangeForward(),o[0]++,i++),s.push(this.document=this.document.applyBlockAttributeAtRange(e,!0,o)));return s},t.prototype.findRangesOfBlocks=function(){return this.document.findRangesForBlockAttribute(e)},t.prototype.findRangesOfPieces=function(){return this.document.findRangesForTextAttribute(n,{withValue:i})},t.prototype.moveSelectedRangeForward=function(){return this.selectedRange[0]+=1,this.selectedRange[1]+=1},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};e.Editor=function(){function n(n,o,r){this.composition=n,this.selectionManager=o,this.element=r,this.insertFiles=t(this.insertFiles,this),this.undoManager=new e.UndoManager(this.composition),this.filters=i.slice(0)}var i;return i=[e.attachmentGalleryFilter],n.prototype.loadDocument=function(t){return this.loadSnapshot({document:t,selectedRange:[0,0]})},n.prototype.loadHTML=function(t){return null==t&&(t=""),this.loadDocument(e.Document.fromHTML(t,{referenceElement:this.element}))},n.prototype.loadJSON=function(t){var n,i;return n=t.document,i=t.selectedRange,n=e.Document.fromJSON(n),this.loadSnapshot({document:n,selectedRange:i})},n.prototype.loadSnapshot=function(t){return this.undoManager=new e.UndoManager(this.composition),this.composition.loadSnapshot(t)},n.prototype.getDocument=function(){return this.composition.document},n.prototype.getSelectedDocument=function(){return this.composition.getSelectedDocument()},n.prototype.getSnapshot=function(){return this.composition.getSnapshot()},n.prototype.toJSON=function(){return this.getSnapshot()},n.prototype.deleteInDirection=function(t){return this.composition.deleteInDirection(t)},n.prototype.insertAttachment=function(t){return this.composition.insertAttachment(t)},n.prototype.insertAttachments=function(t){return this.composition.insertAttachments(t)},n.prototype.insertDocument=function(t){return this.composition.insertDocument(t)},n.prototype.insertFile=function(t){return this.composition.insertFile(t)},n.prototype.insertFiles=function(t){return this.composition.insertFiles(t)},n.prototype.insertHTML=function(t){return this.composition.insertHTML(t)},n.prototype.insertString=function(t){return this.composition.insertString(t)},n.prototype.insertText=function(t){return this.composition.insertText(t)},n.prototype.insertLineBreak=function(){return this.composition.insertLineBreak()},n.prototype.getSelectedRange=function(){return this.composition.getSelectedRange()},n.prototype.getPosition=function(){return this.composition.getPosition()},n.prototype.getClientRectAtPosition=function(t){var e;return e=this.getDocument().locationRangeFromRange([t,t+1]),this.selectionManager.getClientRectAtLocationRange(e)},n.prototype.expandSelectionInDirection=function(t){return this.composition.expandSelectionInDirection(t)},n.prototype.moveCursorInDirection=function(t){return this.composition.moveCursorInDirection(t)},n.prototype.setSelectedRange=function(t){return this.composition.setSelectedRange(t)}
21855,n.prototype.activateAttribute=function(t,e){return null==e&&(e=!0),this.composition.setCurrentAttribute(t,e)},n.prototype.attributeIsActive=function(t){return this.composition.hasCurrentAttribute(t)},n.prototype.canActivateAttribute=function(t){return this.composition.canSetCurrentAttribute(t)},n.prototype.deactivateAttribute=function(t){return this.composition.removeCurrentAttribute(t)},n.prototype.canDecreaseNestingLevel=function(){return this.composition.canDecreaseNestingLevel()},n.prototype.canIncreaseNestingLevel=function(){return this.composition.canIncreaseNestingLevel()},n.prototype.decreaseNestingLevel=function(){return this.canDecreaseNestingLevel()?this.composition.decreaseNestingLevel():void 0},n.prototype.increaseNestingLevel=function(){return this.canIncreaseNestingLevel()?this.composition.increaseNestingLevel():void 0},n.prototype.canRedo=function(){return this.undoManager.canRedo()},n.prototype.canUndo=function(){return this.undoManager.canUndo()},n.prototype.recordUndoEntry=function(t,e){var n,i,o;return o=null!=e?e:{},i=o.context,n=o.consolidatable,this.undoManager.recordUndoEntry(t,{context:i,consolidatable:n})},n.prototype.redo=function(){return this.canRedo()?this.undoManager.redo():void 0},n.prototype.undo=function(){return this.canUndo()?this.undoManager.undo():void 0},n}()}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.ManagedAttachment=function(e){function n(t,e){var n;this.attachmentManager=t,this.attachment=e,n=this.attachment,this.id=n.id,this.file=n.file}return t(n,e),n.prototype.remove=function(){return this.attachmentManager.requestRemovalOfAttachment(this.attachment)},n.proxyMethod("attachment.getAttribute"),n.proxyMethod("attachment.hasAttribute"),n.proxyMethod("attachment.setAttribute"),n.proxyMethod("attachment.getAttributes"),n.proxyMethod("attachment.setAttributes"),n.proxyMethod("attachment.isPending"),n.proxyMethod("attachment.isPreviewable"),n.proxyMethod("attachment.getURL"),n.proxyMethod("attachment.getHref"),n.proxyMethod("attachment.getFilename"),n.proxyMethod("attachment.getFilesize"),n.proxyMethod("attachment.getFormattedFilesize"),n.proxyMethod("attachment.getExtension"),n.proxyMethod("attachment.getContentType"),n.proxyMethod("attachment.getFile"),n.proxyMethod("attachment.setFile"),n.proxyMethod("attachment.releaseFile"),n.proxyMethod("attachment.getUploadProgress"),n.proxyMethod("attachment.setUploadProgress"),n}(e.BasicObject)}.call(this),function(){var t=function(t,e){function i(){this.constructor=t}for(var o in e)n.call(e,o)&&(t[o]=e[o]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},n={}.hasOwnProperty;e.AttachmentManager=function(n){function i(t){var e,n,i;for(null==t&&(t=[]),this.managedAttachments={},n=0,i=t.length;i>n;n++)e=t[n],this.manageAttachment(e)}return t(i,n),i.prototype.getAttachments=function(){var t,e,n,i;n=this.managedAttachments,i=[];for(e in n)t=n[e],i.push(t);return i},i.prototype.manageAttachment=function(t){var n,i;return null!=(n=this.managedAttachments)[i=t.id]?n[i]:n[i]=new e.ManagedAttachment(this,t)},i.prototype.attachmentIsManaged=function(t){return t.id in this.managedAttachments},i.prototype.requestRemovalOfAttachment=function(t){var e;return this.attachmentIsManaged(t)&&null!=(e=this.delegate)&&"function"==typeof e.attachmentManagerDidRequestRemovalOfAttachment?e.attachmentManagerDidRequestRemovalOfAttachment(t):void 0},i.prototype.unmanageAttachment=function(t){var e;return e=this.managedAttachments[t.id],delete this.managedAttachments[t.id],e},i}(e.BasicObject)}.call(this),function(){var t,n,i,o,r,s,a,u,c,l,h;t=e.elementContainsNode,n=e.findChildIndexOfNode,r=e.nodeIsBlockStart,s=e.nodeIsBlockStartComment,o=e.nodeIsBlockContainer,a=e.nodeIsCursorTarget,u=e.nodeIsEmptyTextNode,c=e.nodeIsTextNode,i=e.nodeIsAttachmentElement,l=e.tagName,h=e.walkTree,e.LocationMapper=function(){function e(t){this.element=t}var p,d,f,g;return e.prototype.findLocationFromContainerAndOffset=function(e,i,o){var s,u,l,p,g,m,v;for(m=(null!=o?o:{strict:!0}).strict,u=0,l=!1,p={index:0,offset:0},(s=this.findAttachmentElementParentForNode(e))&&(e=s.parentNode,i=n(s)),v=h(this.element,{usingFilter:f});v.nextNode();){if(g=v.currentNode,g===e&&c(e)){a(g)||(p.offset+=i); 21856break}if(g.parentNode===e){if(u++===i)break}else if(!t(e,g)&&u>0)break;r(g,{strict:m})?(l&&p.index++,p.offset=0,l=!0):p.offset+=d(g)}return p},e.prototype.findContainerAndOffsetFromLocation=function(t){var e,i,s,u,l;if(0===t.index&&0===t.offset){for(e=this.element,u=0;e.firstChild;)if(e=e.firstChild,o(e)){u=1;break}return[e,u]}if(l=this.findNodeAndOffsetFromLocation(t),i=l[0],s=l[1],i){if(c(i))0===d(i)?(e=i.parentNode.parentNode,u=n(i.parentNode),a(i,{name:"right"})&&u++):(e=i,u=t.offset-s);else{if(e=i.parentNode,!r(i.previousSibling)&&!o(e))for(;
21856i===e.lastChild&&(i=e,e=e.parentNode,!o(e)););u=n(i),0!==t.offset&&u++}return[e,u]}},e.prototype.findNodeAndOffsetFromLocation=function(t){var e,n,i,o,r,s,u,l;for(u=0,l=this.getSignificantNodesForIndex(t.index),n=0,i=l.length;i>n;n++){if(e=l[n],o=d(e),t.offset<=u+o)if(c(e)){if(r=e,s=u,t.offset===s&&a(r))break}else r||(r=e,s=u);if(u+=o,u>t.offset)break}return[r,s]},e.prototype.findAttachmentElementParentForNode=function(t){for(;t&&t!==this.element;){if(i(t))return t;t=t.parentNode}},e.prototype.getSignificantNodesForIndex=function(t){var e,n,i,o,r;for(i=[],r=h(this.element,{usingFilter:p}),o=!1;r.nextNode();)if(n=r.currentNode,s(n)){if("undefined"!=typeof e&&null!==e?e++:e=0,e===t)o=!0;else if(o)break}else o&&i.push(n);return i},d=function(t){var e;return t.nodeType===Node.TEXT_NODE?a(t)?0:(e=t.textContent,e.length):"br"===l(t)||i(t)?1:0},p=function(t){return g(t)===NodeFilter.FILTER_ACCEPT?f(t):NodeFilter.FILTER_REJECT},g=function(t){return u(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},f=function(t){return i(t.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},e}()}.call(this),function(){var t,n,i=[].slice;t=e.getDOMRange,n=e.setDOMRange,e.PointMapper=function(){function e(){}return e.prototype.createDOMRangeFromPoint=function(e){var i,o,r,s,a,u,c,l;if(c=e.x,l=e.y,document.caretPositionFromPoint)return a=document.caretPositionFromPoint(c,l),r=a.offsetNode,o=a.offset,i=document.createRange(),i.setStart(r,o),i;if(document.caretRangeFromPoint)return document.caretRangeFromPoint(c,l);if(document.body.createTextRange){s=t();try{u=document.body.createTextRange(),u.moveToPoint(c,l),u.select()}catch(h){}return i=t(),n(s),i}},e.prototype.getClientRectsForDOMRange=function(t){var e,n,o;return n=i.call(t.getClientRects()),o=n[0],e=n[n.length-1],[o,e]},e}()}.call(this),function(){var t,n=function(t,e){return function(){return t.apply(e,arguments)}},i=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},o={}.hasOwnProperty,r=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};t=e.getDOMRange,e.SelectionChangeObserver=function(e){function o(){this.run=n(this.run,this),this.update=n(this.update,this),this.selectionManagers=[]}var s;return i(o,e),o.prototype.start=function(){return this.started?void 0:(this.started=!0,"onselectionchange"in document?document.addEventListener("selectionchange",this.update,!0):this.run())},o.prototype.stop=function(){return this.started?(this.started=!1,document.removeEventListener("selectionchange",this.update,!0)):void 0},o.prototype.registerSelectionManager=function(t){return r.call(this.selectionManagers,t)<0?(this.selectionManagers.push(t),this.start()):void 0},o.prototype.unregisterSelectionManager=function(t){var e;return this.selectionManagers=function(){var n,i,o,r;for(o=this.selectionManagers,r=[],n=0,i=o.length;i>n;n++)e=o[n],e!==t&&r.push(e);return r}.call(this),0===this.selectionManagers.length?this.stop():void 0},o.prototype.notifySelectionManagersOfSelectionChange=function(){var t,e,n,i,o;for(n=this.selectionManagers,i=[],t=0,e=n.length;e>t;t++)o=n[t],i.push(o.selectionDidChange());return i},o.prototype.update=function(){var e;return e=t(),s(e,this.domRange)?void 0:(this.domRange=e,this.notifySelectionManagersOfSelectionChange())},o.prototype.reset=function(){return this.domRange=null,this.update()},o.prototype.run=function(){return this.started?(this.update(),requestAnimationFrame(this.run)):void 0},s=function(t,e){return(null!=t?t.startContainer:void 0)===(null!=e?e.startContainer:void 0)&&(null!=t?t.startOffset:void 0)===(null!=e?e.startOffset:void 0)&&(null!=t?t.endContainer:void 0)===(null!=e?e.endContainer:void 0)&&(null!=t?t.endOffset:void 0)===(null!=e?e.endOffset:void 0)},o}(e.BasicObject),null==e.selectionChangeObserver&&(e.selectionChangeObserver=new e.SelectionChangeObserver)}.call(this),function(){var t,n,i,o,r,s,a,u,c,l,h=function(t,e){return function(){return t.apply(e,arguments)}},p=function(t,e){function n(){this.constructor=t}for(var i in e)d.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},d={}.hasOwnProperty;i=e.getDOMSelection,n=e.getDOMRange,l=e.setDOMRange,t=e.elementContainsNode,s=e.nodeIsCursorTarget,r=e.innerElementIsActive,o=e.handleEvent,a=e.normalizeRange,u=e.rangeIsCollapsed,c=e.rangesAreEqual,e.SelectionManager=function(d){function f(t){this.element=t,this.selectionDidChange=h(this.selectionDidChange,this),this.didMouseDown=h(this.didMouseDown,this),this.locationMapper=new e.LocationMapper(this.element),this.pointMapper=new e.PointMapper,this.lockCount=0,o("mousedown",{onElement:this.element,withCallback:this.didMouseDown})}return p(f,d),f.prototype.getLocationRange=function(t){var e,i;return null==t&&(t={}),e=t.strict===!1?this.createLocationRangeFromDOMRange(n(),{strict:!1}):t.ignoreLock?this.currentLocationRange:null!=(i=this.lockedLocationRange)?i:this.currentLocationRange},f.prototype.setLocationRange=function(t){var e;if(!this.lockedLocationRange)return t=a(t),(e=this.createDOMRangeFromLocationRange(t))?(l(e),this.updateCurrentLocationRange(t)):void 0},f.prototype.setLocationRangeFromPointRange=function(t){var e,n;return t=a(t),n=this.getLocationAtPoint(t[0]),e=this.getLocationAtPoint(t[1]),this.setLocationRange([n,e])},f.prototype.getClientRectAtLocationRange=function(t){var e;return(e=this.createDOMRangeFromLocationRange(t))?this.getClientRectsForDOMRange(e)[1]:void 0},f.prototype.locationIsCursorTarget=function(t){var e,n,i;return i=this.findNodeAndOffsetFromLocation(t),e=i[0],n=i[1],s(e)},f.prototype.lock=function(){return 0===this.lockCount++?(this.updateCurrentLocationRange(),this.lockedLocationRange=this.getLocationRange()):void 0},f.prototype.unlock=function(){var t;return 0===--this.lockCount&&(t=this.lockedLocationRange,this.lockedLocationRange=null,null!=t)?this.setLocationRange(t):void 0},f.prototype.clearSelection=function(){var t;return null!=(t=i())?t.removeAllRanges():void 0},f.prototype.selectionIsCollapsed=function(){var t;return(null!=(t=n())?t.collapsed:void 0)===!0},f.prototype.selectionIsExpanded=function(){return!this.selectionIsCollapsed()},f.prototype.createLocationRangeFromDOMRange=function(t,e){var n,i;if(null!=t&&this.domRangeWithinElement(t)&&(i=this.findLocationFromContainerAndOffset(t.startContainer,t.startOffset,e)))return t.collapsed||(n=this.findLocationFromContainerAndOffset(t.endContainer,t.endOffset,e)),a([i,n])},f.proxyMethod("locationMapper.findLocationFromContainerAndOffset"),f.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"),f.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"),f.proxyMethod("pointMapper.createDOMRangeFromPoint"),f.proxyMethod("pointMapper.getClientRectsForDOMRange"),f.prototype.didMouseDown=function(){return this.pauseTemporarily()},f.prototype.pauseTemporarily=function(){var e,n,i,r;return this.paused=!0,n=function(e){return function(){var n,o,s;for(e.paused=!1,clearTimeout(r),o=0,s=i.length;s>o;o++)n=i[o],n.destroy();return t(document,e.element)?e.selectionDidChange():void 0}}(this),r=setTimeout(n,200),i=function(){var t,i,r,s;for(r=["mousemove","keydown"],s=[],t=0,i=r.length;i>t;t++)e=r[t],s.push(o(e,{onElement:document,withCallback:n}));return s}()},f.prototype.selectionDidChange=function(){return this.paused||r(this.element)?void 0:this.updateCurrentLocationRange()},f.prototype.updateCurrentLocationRange=function(t){var e;return(null!=t?t:t=this.createLocationRangeFromDOMRange(n()))&&!c(t,this.currentLocationRange)?(this.currentLocationRange=t,null!=(e=this.delegate)&&"function"==typeof e.locationRangeDidChange?e.locationRangeDidChange(this.currentLocationRange.slice(0)):void 0):void 0},f.prototype.createDOMRangeFromLocationRange=function(t){var e,n,i,o;return i=this.findContainerAndOffsetFromLocation(t[0]),n=u(t)?i:null!=(o=this.findContainerAndOffsetFromLocation(t[1]))?o:i,null!=i&&null!=n?(e=document.createRange(),e.setStart.apply(e,i),e.setEnd.apply(e,n),e):void 0},f.prototype.getLocationAtPoint=function(t){var e,n;return(e=this.createDOMRangeFromPoint(t))&&null!=(n=this.createLocationRangeFromDOMRange(e))?n[0]:void 0},f.prototype.domRangeWithinElement=function(e){return e.collapsed?t(this.element,e.startContainer):t(this.element,e.startContainer)&&t(this.element,e.endContainer)},f}(e.BasicObject)}.call(this),function(){var t,n,i,o,r=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},s={}.hasOwnProperty,a=[].slice;i=e.rangeIsCollapsed,o=e.rangesAreEqual,n=e.objectsAreEqual,t=e.getBlockConfig,e.EditorController=function(s){function u(t){var n,i;this.editorElement=t.editorElement,n=t.document,i=t.html,this.selectionManager=new e.SelectionManager(this.editorElement),this.selectionManager.delegate=this,this.composition=new e.Composition,this.composition.delegate=this,this.attachmentManager=new e.AttachmentManager(this.composition.getAttachments()),this.attachmentManager.delegate=this,this.inputController=new(e["Level"+e.config.input.getLevel()+"InputController"])(this.editorElement),this.inputController.delegate=this,this.inputController.responder=this.composition,this.compositionController=new e.CompositionController(this.editorElement,this.composition),this.compositionController.delegate=this,this.toolbarController=new e.ToolbarController(this.editorElement.toolbarElement),this.toolbarController.delegate=this,this.editor=new e.Editor(this.composition,this.selectionManager,this.editorElement),null!=n?this.editor.loadDocument(n):this.editor.loadHTML(i)}var c;return r(u,s),u.prototype.registerSelectionManager=function(){return e.selectionChangeObserver.registerSelectionManager(this.selectionManager)},u.prototype.unregisterSelectionManager=function(){return e.selectionChangeObserver.unregisterSelectionManager(this.selectionManager)},u.prototype.render=function(){return this.compositionController.render()},u.prototype.reparse=function(){return this.composition.replaceHTML(this.editorElement.innerHTML)},u.prototype.compositionDidChangeDocument=function(){return this.notifyEditorElement("document-change"),this.handlingInput?void 0:this.render()},u.prototype.compositionDidChangeCurrentAttributes=function(t){return this.currentAttributes=t,this.toolbarController.updateAttributes(this.currentAttributes),this.updateCurrentActions(),this.notifyEditorElement("attributes-change",{attributes:this.currentAttributes})},u.prototype.compositionDidPerformInsertionAtRange=function(t){return this.pasting?this.pastedRange=t:void 0},u.prototype.compositionShouldAcceptFile=function(t){return this.notifyEditorElement("file-accept",{file:t})},u.prototype.compositionDidAddAttachment=function(t){var e;return e=this.attachmentManager.manageAttachment(t),this.notifyEditorElement("attachment-add",{attachment:e})},u.prototype.compositionDidEditAttachment=function(t){var e;return this.compositionController.rerenderViewForObject(t),e=this.attachmentManager.manageAttachment(t),this.notifyEditorElement("attachment-edit",{attachment:e}),this.notifyEditorElement("change")},u.prototype.compositionDidChangeAttachmentPreviewURL=function(t){return this.compositionController.invalidateViewForObject(t),this.notifyEditorElement("change")},u.prototype.compositionDidRemoveAttachment=function(t){var e;return e=this.attachmentManager.unmanageAttachment(t),this.notifyEditorElement("attachment-remove",{attachment:e})},u.prototype.compositionDidStartEditingAttachment=function(t,e){return this.attachmentLocationRange=this.composition.document.getLocationRangeOfAttachment(t),this.compositionController.installAttachmentEditorForAttachment(t,e),this.selectionManager.setLocationRange(this.attachmentLocationRange)},u.prototype.compositionDidStopEditingAttachment=function(){return this.compositionController.uninstallAttachmentEditor(),this.attachmentLocationRange=null},u.prototype.compositionDidRequestChangingSelectionToLocationRange=function(t){return!this.loadingSnapshot||this.isFocused()?(this.requestedLocationRange=t,this.compositionRevisionWhe
21856nLocationRangeRequested=this.composition.revision,this.handlingInput?void 0:this.render()):void 0},u.prototype.compositionWillLoadSnapshot=function(){return this.loadingSnapshot=!0},u.prototype.compositionDidLoadSnapshot=function(){return this.compositionController.refreshViewCache(),this.render(),this.loadingSnapshot=!1},u.prototype.getSelectionManager=function(){return this.selectionManager},u.proxyMethod("getSelectionManager().setLocationRange"),u.proxyMethod("getSelectionManager().getLocationRange"),u.prototype.attachmentManagerDidRequestRemovalOfAttachment=function(t){return this.removeAttachment(t)},u.prototype.compositionControllerWillSyncDocumentView=function(){return this.inputController.editorWillSyncDocumentView(),this.selectionManager.lock(),this.selectionManager.clearSelection()},u.prototype.compositionControllerDidSyncDocumentView=function(){return this.inputController.editorDidSyncDocumentView(),this.selectionManager.unlock(),this.updateCurrentActions(),this.notifyEditorElement("sync")},u.prototype.compositionControllerDidRender=function(){return null!=this.requestedLocationRange&&(this.compositionRevisionWhenLocationRangeRequested===this.composition.revision&&this.selectionManager.setLocationRange(this.requestedLocationRange),this.requestedLocationRange=null,this.compositionRevisionWhenLocationRangeRequested=null),this.renderedCompositionRevision!==this.composition.revision&&(this.runEditorFilters(),this.composition.updateCurrentAttributes(),this.notifyEditorElement("render")),this.renderedCompositionRevision=this.composition.revision},u.prototype.compositionControllerDidFocus=function(){return this.isFocusedInvisibly()&&this.setLocationRange({index:0,offset:0}),this.toolbarController.hideDialog(),this.notifyEditorElement("focus")},u.prototype.compositionControllerDidBlur=function(){return this.notifyEditorElement("blur")},u.prototype.compositionControllerDidSelectAttachment=function(t,e){return this.toolbarController.hideDialog(),this.composition.editAttachment(t,e)},u.prototype.compositionControllerDidRequestDeselectingAttachment=function(t){var e,n;return e=null!=(n=this.attachmentLocationRange)?n:this.composition.document.getLocationRangeOfAttachment(t),this.selectionManager.setLocationRange(e[1])},u.prototype.compositionControllerWillUpdateAttachment=function(t){return this.editor.recordUndoEntry("Edit Attachment",{context:t.id,consolidatable:!0})},u.prototype.compositionControllerDidRequestRemovalOfAttachment=function(t){return this.removeAttachment(t)},u.prototype.inputControllerWillHandleInput=function(){return this.handlingInput=!0,this.requestedRender=!1},u.prototype.inputControllerDidRequestRender=function(){return this.requestedRender=!0},u.prototype.inputControllerDidHandleInput=function(){return this.handlingInput=!1,this.requestedRender?(this.requestedRender=!1,this.render()):void 0},u.prototype.inputControllerDidAllowUnhandledInput=function(){return this.notifyEditorElement("change")},u.prototype.inputControllerDidRequestReparse=function(){return this.reparse()},u.prototype.inputControllerWillPerformTyping=function(){return this.recordTypingUndoEntry()},u.prototype.inputControllerWillPerformFormatting=function(t){return this.recordFormattingUndoEntry(t)},u.prototype.inputControllerWillCutText=function(){return this.editor.recordUndoEntry("Cut")},u.prototype.inputControllerWillPaste=function(t){return this.editor.recordUndoEntry("Paste"),this.pasting=!0,this.notifyEditorElement("before-paste",{paste:t})},u.prototype.inputControllerDidPaste=function(t){return t.range=this.pastedRange,this.pastedRange=null,this.pasting=null,this.notifyEditorElement("paste",{paste:t})},u.prototype.inputControllerWillMoveText=function(){return this.editor.recordUndoEntry("Move")},u.prototype.inputControllerWillAttachFiles=function(){return this.editor.recordUndoEntry("Drop Files")},u.prototype.inputControllerWillPerformUndo=function(){return this.editor.undo()},u.prototype.inputControllerWillPerformRedo=function(){return this.editor.redo()},u.prototype.inputControllerDidReceiveKeyboardCommand=function(t){return this.toolbarController.applyKeyboardCommand(t)},u.prototype.inputControllerDidStartDrag=function(){return this.locationRangeBeforeDrag=this.selectionManager.getLocationRange()},u.prototype.inputControllerDidReceiveDragOverPoint=function(t){return this.selectionManager.setLocationRangeFromPointRange(t)},u.prototype.inputControllerDidCancelDrag=function(){return this.selectionManager.setLocationRange(this.locationRangeBeforeDrag),this.locationRangeBeforeDrag=null},u.prototype.locationRangeDidChange=function(t){return this.composition.updateCurrentAttributes(),this.updateCurrentActions(),this.attachmentLocationRange&&!o(this.attachmentLocationRange,t)&&this.composition.stopEditingAttachment(),this.notifyEditorElement("selection-change")},u.prototype.toolbarDidClickButton=function(){return this.getLocationRange()?void 0:this.setLocationRange({index:0,offset:0})},u.prototype.toolbarDidInvokeAction=function(t){return this.invokeAction(t)},u.prototype.toolbarDidToggleAttribute=function(t){return this.recordFormattingUndoEntry(t),this.composition.toggleCurrentAttribute(t),this.render(),this.selectionFrozen?void 0:this.editorElement.focus()},u.prototype.toolbarDidUpdateAttribute=function(t,e){return this.recordFormattingUndoEntry(t),this.composition.setCurrentAttribute(t,e),this.render(),this.selectionFrozen?void 0:this.editorElement.focus()},u.prototype.toolbarDidRemoveAttribute=function(t){return this.recordFormattingUndoEntry(t),this.composition.removeCurrentAttribute(t),this.render(),this.selectionFrozen?void 0:this.editorElement.focus()},u.prototype.toolbarWillShowDialog=function(){return this.composition.expandSelectionForEditing(),this.freezeSelection()},u.prototype.toolbarDidShowDialog=function(t){return this.notifyEditorElement("toolbar-dialog-show",{dialogName:t})},u.prototype.toolbarDidHideDialog=function(t){return this.thawSelection(),this.editorElement.focus(),this.notifyEditorElement("toolbar-dialog-hide",{dialogName:t})},u.prototype.freezeSelection=function(){return this.selectionFrozen?void 0:(this.selectionManager.lock(),this.composition.freezeSelection(),this.selectionFrozen=!0,this.render())},u.prototype.thawSelection=function(){return this.selectionFrozen?(this.composition.thawSelection(),this.selectionManager.unlock(),this.selectionFrozen=!1,this.render()):void 0},u.prototype.actions={undo:{test:function(){return this.editor.canUndo()},perform:function(){return this.editor.undo()}},redo:{test:function(){return this.editor.canRedo()},perform:function(){return this.editor.redo()}},link:{test:function(){return this.editor.canActivateAttribute("href")}},increaseNestingLevel:{test:function(){return this.editor.canIncreaseNestingLevel()},perform:function(){return this.editor.increaseNestingLevel()&&this.render()}},decreaseNestingLevel:{test:function(){return this.editor.canDecreaseNestingLevel()},perform:function(){return this.editor.decreaseNestingLevel()&&this.render()}},attachFiles:{test:function(){return!0},perform:function(){return e.config.input.pickFiles(this.editor.insertFiles)}}},u.prototype.canInvokeAction=function(t){var e,n;return this.actionIsExternal(t)?!0:!!(null!=(e=this.actions[t])&&null!=(n=e.test)?n.c
21856all(this):void 0)},u.prototype.invokeAction=function(t){var e,n;return this.actionIsExternal(t)?this.notifyEditorElement("action-invoke",{actionName:t}):null!=(e=this.actions[t])&&null!=(n=e.perform)?n.call(this):void 0},u.prototype.actionIsExternal=function(t){return/^x-./.test(t)},u.prototype.getCurrentActions=function(){var t,e;e={};for(t in this.actions)e[t]=this.canInvokeAction(t);return e},u.prototype.updateCurrentActions=function(){var t;return t=this.getCurrentActions(),n(t,this.currentActions)?void 0:(this.currentActions=t,this.toolbarController.updateActions(this.currentActions),this.notifyEditorElement("actions-change",{actions:this.currentActions}))},u.prototype.runEditorFilters=function(){var t,e,n,i,o,r,s,a;for(a=this.composition.getSnapshot(),o=this.editor.filters,n=0,i=o.length;i>n;n++)e=o[n],t=a.document,s=a.selectedRange,a=null!=(r=e.call(this.editor,a))?r:{},null==a.document&&(a.document=t),null==a.selectedRange&&(a.selectedRange=s);return c(a,this.composition.getSnapshot())?void 0:this.composition.loadSnapshot(a)},c=function(t,e){return o(t.selectedRange,e.selectedRange)&&t.document.isEqualTo(e.document)},u.prototype.updateInputElement=function(){var t,n;return t=this.compositionController.getSerializableElement(),n=e.serializeToContentType(t,"text/html"),this.editorElement.setInputElementValue(n)},u.prototype.notifyEditorElement=function(t,e){switch(t){case"document-change":this.documentChangedSinceLastRender=!0;break;case"render":this.documentChangedSinceLastRender&&(this.documentChangedSinceLastRender=!1,this.notifyEditorElement("change"));break;case"change":case"attachment-add":case"attachment-edit":case"attachment-remove":this.updateInputElement()}return this.editorElement.notify(t,e)},u.prototype.removeAttachment=function(t){return this.editor.recordUndoEntry("Delete Attachment"),this.composition.removeAttachment(t),this.render()},u.prototype.recordFormattingUndoEntry=function(e){var n,o;return n=t(e),o=this.selectionManager.getLocationRange(),n||!i(o)?this.editor.recordUndoEntry("Formatting",{context:this.getUndoContext(),consolidatable:!0}):void 0},u.prototype.recordTypingUndoEntry=function(){return this.editor.recordUndoEntry("Typing",{context:this.getUndoContext(this.currentAttributes),consolidatable:!0})},u.prototype.getUndoContext=function(){var t;return t=1<=arguments.length?a.call(arguments,0):[],[this.getLocationContext(),this.getTimeContext()].concat(a.call(t))},u.prototype.getLocationContext=function(){var t;return t=this.selectionManager.getLocationRange(),i(t)?t[0].index:t},u.prototype.getTimeContext=function(){return e.config.undoInterval>0?Math.floor((new Date).getTime()/e.config.undoInterval):0},u.prototype.isFocused=function(){var t;return this.editorElement===(null!=(t=this.editorElement.ownerDocument)?t.activeElement:void 0)},u.prototype.isFocusedInvisibly=function(){return this.isFocused()&&!this.getLocationRange()},u}(e.Controller)}.call(this),function(){var t,n,i,o,r,s,a,u=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};n=e.browser,s=e.makeElement,a=e.triggerEvent,o=e.handleEvent,r=e.handleEventOnce,i=e.findClosestElementFromNode,t=e.AttachmentView.attachmentSelector,e.registerElement("trix-editor",function(){var c,l,h,p,d,f,g,m,v;return g=0,l=function(t){return!document.querySelector(":focus")&&t.hasAttribute("autofocus")&&document.querySelector("[autofocus]")===t?t.focus():void 0},m=function(t){return t.hasAttribute("contenteditable")?void 0:(t.setAttribute("contenteditable",""),r("focus",{onElement:t,withCallback:function(){return h(t)}}))},h=function(t){return d(t),v(t)},d=function(t){return("function"==typeof document.queryCommandSupported?document.queryCommandSupported("enableObjectResizing"):void 0)?(document.execCommand("enableObjectResizing",!1,!1),o("mscontrolselect",{onElement:t,preventDefault:!0})):void 0},v=function(){var t;return("function"==typeof document.queryCommandSupported?document.queryCommandSupported("DefaultParagraphSeparator"):void 0)&&(t=e.config.blockAttributes["default"].tagName,"div"===t||"p"===t)?document.execCommand("DefaultParagraphSeparator",!1,t):void 0},c=function(t){return t.hasAttribute("role")?void 0:t.setAttribute("role","textbox")},f=function(t){var e;if(!t.hasAttribute("aria-label")&&!t.hasAttribute("aria-labelledby"))return(e=function(){var e,n,i;return i=function(){var n,i,o,r;for(o=t.labels,r=[],n=0,i=o.length;i>n;n++)e=o[n],e.contains(t)||r.push(e.textContent);return r}(),(n=i.join(" "))?t.setAttribute("aria-label",n):t.removeAttribute("aria-label")})(),o("focus",{onElement:t,withCallback:e})},p=function(){return n.forcesObjectResizing?{display:"inline",width:"auto"}:{display:"inline-block",width:"1px"}}(),{defaultCSS:"%t {\n display: block;\n}\n\n%t:empty:not(:focus)::before {\n content: attr(placeholder);\n color: graytext;\n cursor: text;\n pointer-events: none;\n}\n\n%t a[contenteditable=false] {\n cursor: text;\n}\n\n%t img {\n max-width: 100%;\n height: auto;\n}\n\n%t "+t+" figcaption textarea {\n resize: none;\n}\n\n%t "+t+" figcaption textarea.trix-autoresize-clone {\n position: absolute;\n left: -9999px;\n max-height: 0px;\n}\n\n%t "+t+" figcaption[data-trix-placeholder]:empty::before {\n content: attr(data-trix-placeholder);\n color: graytext;\n}\n\n%t [data-trix-cursor-target] {\n display: "+p.display+" !important;\n width: "+p.width+" !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n}\n\n%t [data-trix-cursor-target=left] {\n vertical-align: top !important;\n margin-left: -1px !important;\n}\n\n%t [data-trix-cursor-target=right] {\n vertical-align: bottom !important;\n margin-right: -1px !important;\n}",trixId:{get:function(){return this.hasAttribute("trix-id")?this.getAttribute("trix-id"):(this.setAttribute("trix-id",++g),this.trixId)}},labels:{get:function(){var t,e,n;return e=[],this.id&&this.ownerDocument&&e.push.apply(e,this.ownerDocument.querySelectorAll("label[for='"+this.id+"']")),(t=i(this,{matchingSelector:"label"}))&&((n=t.control)===this||null===n)&&e.push(t),e}},toolbarElement:{get:function(){var t,e,n;return this.hasAttribute("toolbar")?null!=(e=this.ownerDocument)?e.getElementById(this.getAttribute("toolbar")):void 0:this.parentNode?(n="trix-toolbar-"+this.trixId,this.setAttribute("toolbar",n),t=s("trix-toolbar",{id:n}),this.parentNode.insertBefore(t,this),t):void 0}},inputElement:{get:function(){var t,e,n;return this.hasAttribute("input")?null!=(n=this.ownerDocument)?n.getElementById(this.getAttribute("input")):void 0:this.parentNode?(e="trix-input-"+this.trixId,this.setAttribute("input",e),t=s("input",{type:"hidden",id:e}),this.parentNode.insertBefore(t,this.nextElementSibling),t):void 0}},editor:{get:function(){var t;return null!=(t=this.editorController)?t.editor:void 0}},name:{get:function(){var t;return null!=(t=this.inputElement)?t.name:void 0}},value:{get:function(){var t;return null!=(t=this.inputElement)?t.value:void 0},set:function(t){var e;return this.defaultValue=t,null!=(e=this.editor)?e.loadHTML(this.defaultValue):void 0}},notify:function(t,e){return this.editorController?a("trix-"+t,{onElement:this,attributes:e}):void 0},setInputElementValue:function(t){var e;return null!=(e=this.inputElement)?e.value=t:void 0},initialize:function(){return this.hasAttribute("data-trix-internal")?void 0:(m(this),c(this),f(this))},connect:function(){return this.hasAttribute("data-trix-internal")?void 0:(this.editorController||(a("trix-before-initialize",{onElement:this}),this.editorController=new e.EditorController({editorElement:this,html:this.defaultValue=this.value}),requestAnimationFrame(function(t){return function(){return a("trix-initialize",{onElement:t})}}(this))),this.editorController.registerSelectionManager(),this.registerResetListener(),this.registerClickListener(),l(this))},disconnect:function(){var t;return null!=(t=this.editorController)&&t.unregisterSelectionManager(),this.unregisterResetListener(),this.unregisterClickListener()},registerResetListener:function(){return this.resetListener=this.resetBubbled.bind(this),window.addEventListener("reset",this.resetListener,!1)},unregisterResetListener:function(){return window.removeEventListener("reset",this.resetListener,!1)},registerClickListener:function(){return this.clickListener=this.clickBubbled.bind(this),window.addEventListener("click",this.clickListener,!1)},unregisterClickListener:function(){return window.removeEventListener("click",this.clickListener,!1)},resetBubbled:function(t){var e;if(!t.defaultPrevented&&t.target===(null!=(e=this.inputElement)?e.form:void 0))return this.reset()},clickBubbled:function(t){var e;if(!(t.defaultPrevented||this.contains(t.target)||!(e=i(t.target,{matchingSelector:"label"}))||u.call(this.labels,e)<0))return this.focus()},reset:function(){return this.value=this.defaultValue}}}())}.call(this),function(){}.call(this)}).call(this),"object"==typeof module&&module.exports?module.exports=e:"function"==typeof define&&define.amd&&define(e)}.call(this); 21857(function(global, factory) { 21858 typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define([ "exports" ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, 21859 factory(global.ActionCable = {})); 21860})(this, (function(exports) { 21861 "use strict"; 21862 var adapters = { 21863 logger: typeof console !== "undefined" ? console : undefined, 21864 WebSocket: typeof WebSocket !== "undefined" ? WebSocket : undefined 21865 }; 21866 var logger = { 21867 log(...messages) { 21868 if (this.enabled) { 21869 messages.push(Date.now()); 21870 adapters.logger.log("[ActionCable]", ...messages); 21871 } 21872 } 21873 }; 21874 const now = () => (new Date).getTime(); 21875 const secondsSince = time => (now() - time) / 1e3; 21876 class ConnectionMonitor { 21877 constructor(connection) { 21878 this.visibilityDidChange = this.visibilityDidChange.bind(this); 21879 this.connection = connection; 21880 this.reconnectAttempts = 0; 21881 } 21882 start() { 21883 if (!this.isRunning()) { 21884 this.startedAt = now(); 21885 delete this.stoppedAt; 21886 this.startPolling(); 21887 addEventListener("visibilitychange", this.visibilityDidChange); 21888 logger.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`); 21889 } 21890 } 21891 stop() { 21892 if (this.isRunning()) { 21893 this.stoppedAt = now(); 21894 this.stopPolling(); 21895 removeEventListener("visibilitychange", this.visibilityDidChange); 21896 logger.log("ConnectionMonitor stopped"); 21897 } 21898 } 21899 isRunning() { 21900 return this.startedAt && !this.stoppedAt; 21901 } 21902 recordMessage() { 21903 this.pingedAt = now(); 21904 } 21905 recordConnect() { 21906 this.reconnectAttempts = 0; 21907 delete this.disconnectedAt; 21908 logger.log("ConnectionMonitor recorded connect"); 21909 } 21910 recordDisconnect() { 21911 this.disconnectedAt = now(); 21912 logger.log("ConnectionMonitor recorded disconnect"); 21913 } 21914 startPolling() { 21915 this.stopPolling(); 21916 this.poll(); 21917 } 21918 stopPolling() { 21919 clearTimeout(this.pollTimeout); 21920 } 21921 poll() { 21922 this.pollTimeout = setTimeout((() => { 21923 this.reconnectIfStale(); 21924 this.poll(); 21925 }), this.getPollInterval()); 21926 } 21927 getPollInterval() { 21928 const {staleThreshold: staleThreshold, reconnectionBackoffRate: reconnectionBackoffRate} = this.constructor; 21929 const backoff = Math.pow(1 + reconnectionBackoffRate, Math.min(this.reconnectAttempts, 10)); 21930 const jitterMax = this.reconnectAttempts === 0 ? 1 : reconnectionBackoffRate; 21931 const jitter = jitterMax * Math.random(); 21932 return staleThreshold * 1e3 * backoff * (1 + jitter); 21933 } 21934 reconnectIfStale() { 21935 if (this.connectionIsStale()) {
21936 logger.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${secondsSince(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`); 21937 this.reconnectAttempts++; 21938 if (this.disconnectedRecently()) { 21939 logger.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${secondsSince(this.disconnectedAt)} s`); 21940 } else { 21941 logger.log("ConnectionMonitor reopening"); 21942 this.connection.reopen(); 21943 } 21944 } 21945 } 21946 get refreshedAt() { 21947 return this.pingedAt ? this.pingedAt : this.startedAt; 21948 } 21949 connectionIsStale() { 21950 return secondsSince(this.refreshedAt) > this.constructor.staleThreshold; 21951 } 21952 disconnectedRecently() { 21953 return this.disconnectedAt && secondsSince(this.disconnectedAt) < this.constructor.staleThreshold; 21954 } 21955 visibilityDidChange() { 21956 if (document.visibilityState === "visible") { 21957 setTimeout((() => { 21958 if (this.connectionIsStale() || !this.connection.isOpen()) { 21959 logger.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`); 21960 this.connection.reopen(); 21961 } 21962 }), 200); 21963 } 21964 } 21965 } 21966 ConnectionMonitor.staleThreshold = 6; 21967 ConnectionMonitor.reconnectionBackoffRate = .15; 21968 var INTERNAL = { 21969 message_types: { 21970 welcome: "welcome", 21971 disconnect: "disconnect", 21972 ping: "ping", 21973 confirmation: "confirm_subscription", 21974 rejection: "reject_subscription" 21975 }, 21976 disconnect_reasons: { 21977 unauthorized: "unauthorized", 21978 invalid_request: "invalid_request", 21979 server_restart: "server_restart", 21980 remote: "remote" 21981 }, 21982 default_mount_path: "/cable", 21983 protocols: [ "actioncable-v1-json", "actioncable-unsupported" ] 21984 }; 21985 const {message_types: message_types, protocols: protocols} = INTERNAL; 21986 const supportedProtocols = protocols.slice(0, protocols.length - 1); 21987 const indexOf = [].indexOf; 21988 class Connection { 21989 constructor(consumer) { 21990 this.open = this.open.bind(this); 21991 this.consumer = consumer; 21992 this.subscriptions = this.consumer.subscriptions; 21993 this.monitor = new ConnectionMonitor(this); 21994 this.disconnected = true; 21995 } 21996 send(data) { 21997 if (this.isOpen()) { 21998 this.webSocket.send(JSON.stringify(data)); 21999 return true; 22000 } else { 22001 return false; 22002 } 22003 } 22004 open() { 22005 if (this.isActive()) { 22006 logger.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`); 22007 return false; 22008 } else { 22009 const socketProtocols = [ ...protocols, ...this.consumer.subprotocols || [] ]; 22010 logger.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${socketProtocols}`); 22011 if (this.webSocket) { 22012 this.uninstallEventHandlers(); 22013 } 22014 this.webSocket = new adapters.WebSocket(this.consumer.url, socketProtocols); 22015 this.installEventHandlers(); 22016 this.monitor.start(); 22017 return true; 22018 } 22019 } 22020 close({allowReconnect: allowReconnect} = { 22021 allowReconnect: true 22022 }) { 22023 if (!allowReconnect) { 22024 this.monitor.stop(); 22025 } 22026 if (this.isOpen()) { 22027 return this.webSocket.close(); 22028 } 22029 } 22030 reopen() { 22031 logger.log(`Reopening WebSocket, current state is ${this.getState()}`); 22032 if (this.isActive()) { 22033 try { 22034 return this.close(); 22035 } catch (error) { 22036 logger.log("Failed to reopen WebSocket", error); 22037 } finally { 22038 logger.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`); 22039 setTimeout(this.open, this.constructor.reopenDelay); 22040 } 22041 } else { 22042 return this.open(); 22043 } 22044 } 22045 getProtocol() { 22046 if (this.webSocket) { 22047 return this.webSocket.protocol; 22048 } 22049 } 22050 isOpen() { 22051 return this.isState("open"); 22052 } 22053 isActive() { 22054 return this.isState("open", "connecting"); 22055 } 22056 triedToReconnect() { 22057 return this.monitor.reconnectAttempts > 0; 22058 }
22059 isProtocolSupported() { 22060 return indexOf.call(supportedProtocols, this.getProtocol()) >= 0; 22061 } 22062 isState(...states) { 22063 return indexOf.call(states, this.getState()) >= 0; 22064 } 22065 getState() { 22066 if (this.webSocket) { 22067 for (let state in adapters.WebSocket) { 22068 if (adapters.WebSocket[state] === this.webSocket.readyState) { 22069 return state.toLowerCase(); 22070 } 22071 } 22072 } 22073 return null; 22074 } 22075 installEventHandlers() { 22076 for (let eventName in this.events) { 22077 const handler = this.events[eventName].bind(this); 22078 this.webSocket[`on${eventName}`] = handler; 22079 } 22080 } 22081 uninstallEventHandlers() { 22082 for (let eventName in this.events) { 22083 this.webSocket[`on${eventName}`] = function() {}; 22084 } 22085 } 22086 } 22087 Connection.reopenDelay = 500; 22088 Connection.prototype.events = { 22089 message(event) { 22090 if (!this.isProtocolSupported()) { 22091 return; 22092 } 22093 const {identifier: identifier, message: message, reason: reason, reconnect: reconnect, type: type} = JSON.parse(event.data); 22094 this.monitor.recordMessage(); 22095 switch (type) { 22096 case message_types.welcome: 22097 if (this.triedToReconnect()) { 22098 this.reconnectAttempted = true; 22099 } 22100 this.monitor.recordConnect(); 22101 return this.subscriptions.reload(); 22102 22103 case message_types.disconnect: 22104 logger.log(`Disconnecting. Reason: ${reason}`); 22105 return this.close({ 22106 allowReconnect: reconnect 22107 }); 22108 22109 case message_types.ping: 22110 return null; 22111 22112 case message_types.confirmation: 22113 this.subscriptions.confirmSubscription(identifier); 22114 if (this.reconnectAttempted) { 22115 this.reconnectAttempted = false; 22116 return this.subscriptions.notify(identifier, "connected", { 22117 reconnected: true 22118 }); 22119 } else { 22120 return this.subscriptions.notify(identifier, "connected", { 22121 reconnected: false 22122 }); 22123 } 22124 22125 case message_types.rejection: 22126 return this.subscriptions.reject(identifier); 22127 22128 default: 22129 return this.subscriptions.notify(identifier, "received", message); 22130 } 22131 }, 22132 open() { 22133 logger.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`); 22134 this.disconnected = false; 22135 if (!this.isProtocolSupported()) { 22136 logger.log("Protocol is unsupported. Stopping monitor and disconnecting."); 22137 return this.close({ 22138 allowReconnect: false 22139 }); 22140 } 22141 }, 22142 close(event) { 22143 logger.log("WebSocket onclose event"); 22144 if (this.disconnected) { 22145 return; 22146 } 22147 this.disconnected = true; 22148 this.monitor.recordDisconnect(); 22149 return this.subscriptions.notifyAll("disconnected", { 22150 willAttemptReconnect: this.monitor.isRunning() 22151 }); 22152 }, 22153 error() { 22154 logger.log("WebSocket onerror event"); 22155 } 22156 }; 22157 const extend = function(object, properties) { 22158 if (properties != null) { 22159 for (let key in properties) { 22160 const value = properties[key]; 22161 object[key] = value; 22162 } 22163 } 22164 return object; 22165 }; 22166 class Subscription { 22167 constructor(consumer, params = {}, mixin) { 22168 this.consumer = consumer; 22169 this.identifier = JSON.stringify(params); 22170 extend(this, mixin); 22171 } 22172 perform(action, data = {}) { 22173 data.action = action; 22174 return this.send(data); 22175 } 22176 send(data) { 22177 return this.consumer.send({ 22178 command: "message", 22179 identifier: this.identifier, 22180 data: JSON.stringify(data) 22181 }); 22182 } 22183 unsubscribe() { 22184 return this.consumer.subscriptions.remove(this); 22185 } 22186 } 22187 class SubscriptionGuarantor { 22188 constructor(subscriptions) { 22189 this.subscriptions = subscriptions; 22190 this.pendingSubscriptions = []; 22191 } 22192 guarantee(subscription) { 22193 if (this.pendingSubscriptions.indexOf(subscription) == -1) { 22194 logger.log(`SubscriptionGuarantor guaranteeing ${subscription.identifier}`); 22195 this.pendingSubscriptions.push(subscription); 22196 } else { 22197 logger.log(`SubscriptionGuarantor already guaranteeing ${subscription.identifier}`); 22198 } 22199 this.startGuaranteeing(); 22200 } 22201 forget(subscription) { 22202 logger.log(`SubscriptionGuarantor forgetting ${subscription.identifier}`); 22203 this.pendingSubscriptions = this.pendingSubscriptions.filter((s => s !== subscription)); 22204 } 22205 startGuaranteeing() { 22206 this.stopGuaranteeing(); 22207 this.retrySubscribing(); 22208 } 22209 stopGuaranteeing() { 22210 clearTimeout(this.retryTimeout); 22211 } 22212 retrySubscribing() { 22213 this.retryTimeout = setTimeout((() => { 22214 if (this.subscriptions && typeof this.subscriptions.subscribe === "function") { 22215 this.pendingSubscriptions.map((subscription => { 22216 logger.log(`SubscriptionGuarantor resubscribing ${subscription.identifier}`); 22217 this.subscriptions.subscribe(subscription); 22218 })); 22219 } 22220 }), 500); 22221 } 22222 } 22223 class Subscriptions { 22224 constructor(consumer) { 22225 this.consumer = consumer; 22226 this.guarantor = new SubscriptionGuarantor(this); 22227 this.subscriptions = []; 22228 } 22229 create(channelName, mixin) { 22230 const channel = channelName; 22231 const params = typeof channel === "object" ? channel : { 22232 channel: channel 22233 }; 22234 const subscription = new Subscription(this.consumer, params, mixin); 22235 return this.add(subscription); 22236 } 22237 add(subscription) { 22238 this.subscriptions.push(subscription); 22239 this.consumer.ensureActiveConnection(); 22240 this.notify(subscription, "initialized"); 22241 this.subscribe(subscription); 22242 return subscription; 22243 } 22244 remove(subscription) { 22245 this.forget(subscription); 22246 if (!this.findAll(subscription.identifier).length) { 22247 this.sendCommand(subscription, "unsubscribe"); 22248 } 22249 return subscription; 22250 } 22251 reject(identifier) { 22252 return this.findAll(identifier).map((subscription => { 22253 this.forget(subscription); 22254 this.notify(subscription, "rejected"); 22255 return subscription; 22256 })); 22257 } 22258 forget(subscription) { 22259 this.guarantor.forget(subscription); 22260 this.subscriptions = this.subscriptions.filter((s => s !== subscription)); 22261 return subscription; 22262 } 22263 findAll(identifier) { 22264 return this.subscriptions.filter((s => s.identifier === identifier)); 22265 } 22266 reload() { 22267 return this.subscriptions.map((subscription => this.subscribe(subscription))); 22268 } 22269 notifyAll(callbackName, ...args) { 22270 return this.subscriptions.map((subscription => this.notify(subscription, callbackName, ...args))); 22271 } 22272 notify(subscription, callbackName, ...args) { 22273 let subscriptions; 22274 if (typeof subscription === "string") { 22275 subscriptions = this.findAll(subscription); 22276 } else { 22277 subscriptions = [ subscription ]; 22278 } 22279 return subscriptions.map((subscription => typeof subscription[callbackName] === "function" ? subscription[callbackName](...args) : undefined)); 22280 } 22281 subscribe(subscription) { 22282 if (this.sendCommand(subscription, "subscribe")) { 22283 this.guarantor.guarantee(subscription); 22284 } 22285 } 22286 confirmSubscription(identifier) { 22287 logger.log(`Subscription confirmed ${identifier}`); 22288 this.findAll(identifier).map((subscription => this.guarantor.forget(subscription))); 22289 } 22290 sendCommand(subscription, command) { 22291 const {identifier: identifier} = subscription; 22292 return this.consumer.send({ 22293 command: command, 22294 identifier: identifier 22295 }); 22296 } 22297 } 22298 class Consumer { 22299 constructor(url) { 22300 this._url = url; 22301 this.subscriptions = new Subscriptions(this); 22302 this.connection = new Connection(this); 22303 this.subprotocols = []; 22304 } 22305 get url() { 22306 return createWebSocketURL(this._url); 22307 } 22308 send(data) { 22309 return this.connection.send(data); 22310 } 22311 connect() { 22312 return this.connection.open(); 22313 } 22314 disconnect() { 22315 return this.connection.close({ 22316 allowReconnect: false 22317 }); 22318 } 22319 ensureActiveConnection() { 22320 if (!this.connection.isActive()) { 22321 return this.connection.open(); 22322 } 22323 } 22324 addSubProtocol(subprotocol) { 22325 this.subprotocols = [ ...this.subprotocols, subprotocol ]; 22326 } 22327 } 22328 function createWebSocketURL(url) { 22329 if (typeof url === "function") { 22330 url = url(); 22331 } 22332 if (url && !/^wss?:/i.test(url)) { 22333 const a = document.createElement("a"); 22334 a.href = url; 22335 a.href = a.href; 22336 a.protocol = a.protocol.replace("http", "ws"); 22337 return a.href; 22338 } else { 22339 return url; 22340 } 22341 } 22342 function createConsumer(url = getConfig("url") || INTERNAL.default_mount_path) { 22343 return new Consumer(url); 22344 } 22345 function getConfig(name) { 22346 const element = document.head.querySelector(`meta[name='action-cable-${name}']`); 22347 if (element) { 22348 return element.getAttribute("content"); 22349 } 22350 } 22351 console.log("DEPRECATION: action_cable.js has been renamed to actioncable.js – please update your reference before Rails 8"); 22352 exports.Connection = Connection; 22353 exports.ConnectionMonitor = ConnectionMonitor; 22354 exports.Consumer = Consumer; 22355 exports.INTERNAL = INTERNAL; 22356 exports.Subscription = Subscription; 22357 exports.SubscriptionGuarantor = SubscriptionGuarantor; 22358 exports.Subscriptions = Subscriptions; 22359 exports.adapters = adapters; 22360 exports.createConsumer = createConsumer; 22361 exports.createWebSocketURL = createWebSocketURL; 22362 exports.getConfig = getConfig; 22363 exports.logger = logger; 22364 Object.defineProperty(exports, "__esModule", { 22365 value: true 22366 }); 22367})); 22368// Action Cable provides the framework to deal with WebSockets in Rails. 22369// You can generate new channels where WebSocket features live using the rails generate channel command. 22370// 22371 22372 22373 22374 22375(function() {
22376 this.App || (this.App = {}); 22377 22378 App.cable = ActionCable.createConsumer(); 22379 22380}).call(this); 22381(function() { 22382 $(document).on('turbolinks:load', function() { 22383 return $('.slider-mobile-menu').click(function() { 22384 $('.slider-menu-mobile-wrapper').slideToggle(); 22385 return $(this).toggleClass('menu-open'); 22386 }); 22387 }); 22388 22389}).call(this); 22390var compared_images = []; 22391// since all the images will be the same size, compared_image[0] can be used for calculating heights and widths 22392var image = { 22393 collection: function () { 22394 return compared_images; 22395 }, 22396 original: { 22397 width: function () { 22398 return compared_images[0].getAttribute('width'); 22399 }, 22400 height: function () { 22401 return compared_images[0].getAttribute('height'); 22402 } 22403 }, 22404 current: { 22405 width: function () { 22406 return compared_images[0].clientWidth; 22407 }, 22408 height: function () { 22409 return compared_images[0].clientHeight; 22410 } 22411 } 22412} 22413 22414 22415$(document).on('turbolinks:load', function () { 22416 $('[data-toggle="tooltip"][data-trigger="manual"]').tooltip("show"); 22417 topic_menu_init(); 22418 slider_init(); 22419 22420 // Slide the slider via label click 22421 $('.control-labels .label_text').click(function () { 22422 document.getElementById("slider_control").value = this.dataset.index * 100 22423 document.getElementById("slider_control").oninput(); 22424 }); 22425 22426 $(window).resize(function () { 22427 resize_slide_above_fold(); 22428 // tooltips are computed in absolute px, need to reshow so it's position gets recomputed 22429 showVisibleTooltips(); 22430 }); 22431}); 22432 22433function slider_init() { 22434 var slider = document.getElementById("slider_control"); 22435 if (slider == undefined) return; 22436 // Update the current slider value (each time you drag the slider handle) 22437 slider.oninput = sliderChange; 22438 slider.onchange = sliderChange; 22439 22440 function sliderChange(event) { 22441 var slider_location = this.value / 100; 22442 // go through each image and determine opacity 22443 $('.slide').each(function (index, imageEl) { 22444 var newOpacity = (slider_location + 1) - parseInt(imageEl.dataset.imageIndex) 22445 imageEl.style.opacity = newOpacity; 22446 }); 22447 } 22448} 22449 22450// call when tooltips could lose their positioning 22451function showVisibleTooltips() { 22452 $('.points.show:first').find('.point').tooltip('show'); 22453} 22454 22455// initializes the subnav "Topics" menu dropdown in the topbar 22456function topic_menu_init() { 22457 selector_for_indicators = '.has_more_options .wrapper .indicator' 22458 selector_for_non_link_text = '.has_more_options .wrapper span.text' 22459 clickable_selectors = selector_for_indicators + ',' + selector_for_non_link_text; 22460 22461 $(clickable_selectors).click(function () { 22462 var immediate_parent = $(this).parents('.has_more_options')[0]; 22463 $(immediate_parent).toggleClass('selected'); 22464 }); 22465
22466 // Allows a user to press 'Enter' or the spacebars to interact 22467 $(document).on('keyup', clickable_selectors, function (e) { 22468 if (e.which == 13 || e.which == 32) 22469 $(this).click(); 22470 }); 22471} 22472 22473// configures the images & slides to fit above the fold while centered. 22474function resize_slide_above_fold() { 22475 var slider_body = $('.slider .body, .slider .body img'); 22476 22477 // need to clear it all before setting, wouldn't resize when changing widths on the fly 22478 $(slider_body).css('max-height', ''); 22479 22480 var window_height = document.body.clientHeight; 22481 // using outerHieght because it takes padding into account 22482 var nav_height = $('nav').outerHeight(); 22483 var topbar_height = $('.top-bar:first').outerHeight(); 22484 var slider_height = $('.slider .controller').outerHeight(); 22485 var offset_height = nav_height + topbar_height + slider_height; 22486 22487 var slider_image_height = window_height - offset_height; 22488 if (slider_image_height < 420) slider_image_height = 420 22489 $(slider_body).css('max-height', slider_image_height + 'px'); 22490} 22491 22492var amount_loaded = 0; // keep track amount of loaded images 22493// the callback a slide image calls when finished loading 22494function slide_image_load(image_label) { 22495 var the_slide = $('.slide[data-label="' + image_label + '"]')[0]; 22496 var the_slide_image = $(the_slide).find('.image img.primary')[0]; 22497 compared_images.push(the_slide_image); 22498 22499 amount_loaded++; 22500 // console.debug("UIU: Loading image", image_label, "amount_loaded", amount_loaded) 22501 slides = document.querySelectorAll('.slide'); 22502 22503 // if one is loaded, we can start init to look more ready 22504 if (amount_loaded == 1) { 22505 resize_slide_above_fold(); 22506 for (var i = 0; i < slides.length; i++) { 22507 slideEl = slides[i]; 22508 init_slider_image(slideEl); 22509 init_points_for_slide($(slideEl).find('.points')); 22510 } 22511 // if two, or the starting, image(s) is loaded, we can start showing points 22512 } else if (amount_loaded == 2) { 22513 resize_slide_above_fold(); 22514 // had to break this out due to race conditions with other browsers 22515 for (var i = 0; i < slides.length; i++) { 22516 slideEl = slides[i]; 22517 visibilities(slideEl); 22518 } 22519 $('.loading_text').hide(); 22520 } 22521 // tooltips sometimes lose their positioning here when defaulted to appear, 22522 // showVisibleTooltips() is intended to correct such situations 22523 showVisibleTooltips(); 22524 22525 // initializes the image's mutation obesver to handle it's showing/hiding of descriptions and points 22526 function init_slider_image(imageEl) { 22527 // using MutationObserver so each slide cares about it's own points/description 22528 var opacity_observer = new MutationObserver(function (mutations) { 22529 for (var i = 0; i < mutations.length; i++) { 22530 mutation = mutations[i]; 22531 visibilities(mutation.target); 22532 } 22533 }); 22534 22535 opacity_observer.observe(imageEl, { attributes: true, attributeFilter: ['style'] }); 22536 } 22537 22538 // computes the relative location of each point to a percentage left/top 22539 function init_points_for_slide(hotpoints) { 22540 //find point location relative to image 22541 hotpoints.each(function (index, hotpoint) { 22542 // console.debug("UIU: init points, hotpoint", hotpoint) 22543 var points = hotpoint.querySelectorAll('.point'); 22544 for (var i = 0; i < points.length; i++) { 22545 pointObject = points[i]; 22546 // console.debug("UIU: init point", pointObject.dataset.originaltitle) 22547 calculatePoint(pointObject); 22548 } 22549 }); 22550 22551 function calculatePoint(pointObject) { 22552 var point = { 22553 x: parseFloat(pointObject.dataset.xposition), // explicitly coerce user entered info 22554 y: parseFloat(pointObject.dataset.yposition), // explicitly coerce user entered info 22555 height: pointObject.offsetHeight, 22556 width: pointObject.offsetWidth, 22557 } 22558 // console.debug("UIU: calculatePoint", point, {"image orig h": image.original.height(), "image orig w": image.original.width(), "image cur h": image.current.height(), "img cur w": image.current.width()}) 22559 calculateTop(pointObject, point); 22560 calculateLeft(pointObject, point); 22561 // console.debug("UIU: calculated Point, top:", pointObject.style.top, "left:", pointObject.style.left) 22562 22563 function calculateLeft(pointObject, point) { 22564 var width_percentage = point.width / image.original.width(); 22565 var calculated_width = image.current.width() * width_percentage; 22566 22567 //calculating x/top 22568 //so we can move in to get to the middle of the element 22569 var pointOffsetX = calculated_width / 2; 22570 // account for the width of the point, to be true center 22571 var pointTrueX = point.x - pointOffsetX; 22572 //the percentage of where it should lie on the image 22573 var percentageOffsetFromImage = pointTrueX / image.original.width(); 22574 22575 xCalculated = percentageOffsetFromImage * 100; 22576 pointObject.style.left = xCalculated + "%"; 22577 } 22578 function calculateTop(pointObject, point) { 22579 var height_percentage = point.height / image.original.height(); 22580 var calculated_height = image.current.height() * height_percentage; 22581 22582 //calculating y/left 22583 //so we can move in to get to the middle of the element 22584 var pointOffsetY = calculated_height / 2; 22585 // account for the height of the point, to be true center 22586 var pointTrueY = point.y - pointOffsetY; 22587 //the percentage of where it should lie on the image 22588 var percentageOffsetFromImage = pointTrueY / image.original.height(); 22589 22590 yCalculated = percentageOffsetFromImage * 100; 22591 pointObject.style.top = yCalculated + "%"; 22592 } 22593 } 22594 } 22595 22596 function is_starting_image(slide_image) { 22597 var starting_image = $('.slide[data-starting-opacity="1"] img.primary')[0]; 22598 return (starting_image.src == slide_image.src); 22599 } 22600 22601 // determines if a slide should be showing or hiding their related elements 22602 function visibilities(slide) { 22603 point_visibility(slide); 22604 description_visibility(slide); 22605 mobile_label_visibility(slide); 22606 22607 // the opacity limits where a slide should show it's points/descriptions/mobile label 22608 function between_the_bounds(opacity) { 22609 var UPPER_BOUND = 1.45; 22610 var LOWER_BOUND = .75; 22611 return (UPPER_BOUND >
22611 opacity) && (LOWER_BOUND < opacity); 22612 } 22613 22614 function description_visibility(image) { 22615 var label = image.dataset.label; 22616 var description = $(".description[data-label='" + label + "']"); 22617 if (between_the_bounds(image.style.opacity)) { 22618 $(description).addClass('show'); 22619 } else { 22620 $(description).removeClass('show'); 22621 } 22622 } 22623 22624 function point_visibility(image) { 22625 var label = image.dataset.label; 22626 var hotpoints = $(".slide[data-label='" + label + "'] .points"); 22627 22628 if (between_the_bounds(image.style.opacity)) { 22629 $(hotpoints).addClass('show'); 22630 $(hotpoints).find('.point').tooltip('show'); 22631 } else { 22632 $(hotpoints).removeClass('show'); 22633 } 22634 } 22635 22636 function mobile_label_visibility(image) { 22637 var label = image.dataset.label; 22638 var mobile_label = $(".mobile-label[data-label='" + label + "']"); 22639 22640 if (between_the_bounds(image.style.opacity)) { 22641 $(mobile_label).addClass('show'); 22642 } else { 22643 $(mobile_label).removeClass('show'); 22644 } 22645 } 22646 } 22647} 22648 22649// persists config for slider labels and toggles labels 22650function slider_labels_changed(event) { 22651 const checked = event.target.checked; 22652 // cookie properties are persisted in the checkbox data (server-side) 22653 const cookieProperties = JSON.parse(event.target.dataset.showLabelsCookie) 22654 persist_labels_preference(checked, cookieProperties); 22655 // Now perform the toggle on the element 22656 return labels_toggle(checked); 22657} 22658 22659function labels_toggle(show, sliderElId = "main-slider"){ 22660 var slider = document.getElementById(sliderElId); 22661 22662 if (show) { 22663 $(slider).removeClass('show-clean'); 22664 // WORKAROUND: after sliding, if points are to be visible again, they lose their positioning 22665 // MMS(2024/11/18): why is this only done when we hide labels? 22666 showVisibleTooltips(); 22667 } else { 22668 $(slider).addClass('show-clean'); 22669 } 22670} 22671 22672function persist_labels_preference(show_labels, existingCookieProperties) { 22673 // NOTE! Contrary to documentation, we can NOT overwrite the value of an existing cookie 22674 // This recreates the cookie with all the same values 22675 22676 // Create properties. 22677 // JS needs { name: value } vs { name: 'abc', value: 123 } 22678 // Merge with passed properties to ensure we get all props, including recently added 22679 var newCookieProperties = Object.assign({ [existingCookieProperties.name]: show_labels }, existingCookieProperties); 22680 newCookieProperties['Max-Age'] = existingCookieProperties.max_age; // use appropriate key 22681 newCookieProperties['SameSite'] = existingCookieProperties.same_site; // use appropriate key 22682 // remove unused keys 22683 delete newCookieProperties.max_age; 22684 delete newCookieProperties.name; 22685 delete newCookieProperties.same_site; 22686 delete newCookieProperties.value; 22687 22688 // Step 2: Convert the object into a cookie-compatible string 22689 const cookieString = Object.entries(newCookieProperties) 22690 .map(([key, value]) => `${key}=${value}`) 22691 .join("; "); 22692 22693 // Step 3: Assign the cookie 22694 document.cookie = cookieString; 22695 22696 console.log("Cookie string set:", cookieString); 22697} 22698; 22699function change_video(vimeo_id, player_selector) { 22700 iframe = document.querySelector(player_selector); 22701 var player = new Vimeo.Player(iframe); 22702 player.loadVideo(vimeo_id); 22703}; 22704// Called when dropdown header is clicked, toggles expand/collapse of content 22705function viewspace_dropdown(element) { 22706 dropdown = element.closest('.viewspace-dropdown-container'); 22707 dropdown.classList.toggle('selected'); 22708 expanded = dropdown.classList.contains('selected'); 22709 22710 element.setAttribute('aria-expanded', String(expanded)); // toggle aria-expanded of button 22711 22712 text_height = dropdown.clientHeight; 22713 content_height = dropdown.querySelector('.selector-content').clientHeight; 22714 22715 if (dropdown.querySelector('.shadow_on_open') !== null) { 22716 dropshadow_height = text_height + content_height; 22717 boxshadow = dropdown.querySelector('.shadow_on_open') 22718 boxshadow.style = 'height:' + dropshadow_height + 'px'; 22719 } 22720 22721 // This closes the topics dropdown when you click off of it 22722 document.addEventListener('click', closeDropdownWhenClickedOut) 22723} 22724 22725function closeDropdownWhenClickedOut(event) { 22726 if (!$(event.target).is('.viewspace-dropdown-container *') && !$(event.target).is('.select2-selection__choice__remove')) { 22727 $selected_dropdowns = $('.viewspace-dropdown-container.selected'); 22728 $selected_dropdowns.removeClass('selected'); 22729 $selected_dropdowns.children('button').attr('aria-expanded', 'false'); 22730 22731 document.removeEventListener('click', closeDropdownWhenClickedOut); 22732 } 22733} 22734var option_selector = '.dropdown_option' 22735$(document).on('turbolinks:load', function () { 22736 var dropdowns_with_values = document.querySelectorAll('.viewspace-dropdown-container.can_have_value') 22737 for (var i = 0; i < dropdowns_with_values.length; i++) { 22738 dd = dropdowns_with_values[i] 22739 initSelect(dd); 22740 } 22741 22742 var dropdowns_with_dim = document.querySelectorAll('.viewspace-dropdown-container.can_dim') 22743 for (var i = 0; i < dropdowns_with_dim.length; i++) { 22744 dd = dropdowns_with_dim[i] 22745 dimmableObserver(dd); 22746 } 22747}) 22748 22749function dimmableObserver(element) { 22750 var value_observer = new MutationObserver(function (mutations) { 22751 for (var i = 0; i < mutations.length; i++) { 22752 dropdown = mutations[i].target 22753 if (mutations[i].type === 'attributes') { 22754 if (mutations[i].attributeName === 'class') { 22755 dimContentWhenDropdownSelected(dropdown); 22756 } 22757 } 22758 } 22759 }); 22760 options = { attributes: true, attributeFilter: ['class'] } 22761 value_observer.observe(element, options); 22762} 22763 22764function initSelect(dropdown) { 22765 updateDropdownIfSorted(dropdown) 22766 initOptions(dropdown); 22767 initObserver(dropdown); 22768 22769 function updateDropdownIfSorted(dropdown) { 22770 selectedOption = getSelectedOption(dropdown) 22771 if (selectedOption !== undefined) 22772 updateDropdownText(dropdown, selectedOption) 22773 } 22774 22775 function initOptions(dropdown) {
22776 options = dropdown.querySelectorAll(option_selector); 22777 for (var i = 0; i < options.length; i++) { 22778 option = options[i] 22779 option.addEventListener('click', function () { 22780 updateDropdownValue(dropdown, this) 22781 }) 22782 } 22783 } 22784 22785 function initObserver(element) { 22786 var value_observer = new MutationObserver(function (mutations) { 22787 for (var i = 0; i < mutations.length; i++) { 22788 dropdown = mutations[i].target 22789 if (mutations[i].type === 'attributes') { 22790 if (mutations[i].attributeName === 'data-value') { 22791 option = getSelectedOption(dropdown) 22792 updateDropdownText(dropdown, option) 22793 } 22794 } 22795 } 22796 }); 22797 options = { attributes: true, attributeFilter: ['data-value'] } 22798 value_observer.observe(element, options); 22799 } 22800 22801 22802 function updateDropdownValue(dropdown, option) { 22803 dropdown.setAttribute('data-value', option.dataset.value); 22804 dropdown.classList.remove('selected'); 22805 $(dropdown).children('button').attr('aria-expanded', 'false'); 22806 } 22807 22808 function updateDropdownText(dropdown, option) { 22809 if (option != null){ 22810 title = dropdown.querySelector('.selector-text .title') 22811 title.innerHTML = option.innerHTML 22812 } 22813 } 22814 22815 function getSelectedOption(dropdown) { 22816 val = dropdown.dataset.value 22817 if (val === undefined) return; 22818 22819 selector = option_selector + '[data-value="' + val + '"]' 22820 return dropdown.querySelector(selector) 22821 } 22822} 22823 22824function dimContentWhenDropdownSelected() { 22825 dimmable_elements = document.querySelectorAll('.dimmable'); 22826 for (var i = 0; i < dimmable_elements.length; i++) { 22827 element = dimmable_elements[i]; 22828 22829 if (canUnDimElement(element)) { 22830 element.className = element.className.replace('dimmed', '') 22831 } else if (canDimElement(element)) { 22832 element.className += ' dimmed' 22833 dimClickBlocker(element); 22834 } 22835 } 22836 22837 function dimClickBlocker(element) { 22838 if (element.querySelectorAll('.dim_click_blocker').length === 0) { 22839 var dim_blocker = document.createElement("div"); 22840 dim_blocker.className = 'dim_click_blocker' 22841 element.insertBefore(dim_blocker, element.childNodes[0]) 22842 } 22843 } 22844 22845 function canDimElement(element) { 22846 elected_can_dim_dropdowns = document.querySelectorAll('.selected.can_dim') 22847 return (selected_can_dim_dropdowns.length > 0) && !element.className.includes('dimmed') 22848 } 22849 22850 function canUnDimElement(element) { 22851 selected_can_dim_dropdowns = document.querySelectorAll('.selected.can_dim') 22852 return ( 22853 (selected_can_dim_dropdowns.length === 0) && 22854 element.className.includes('dimmed') 22855 ) 22856 } 22857}; 22858$(document).on('turbolinks:load', function () { 22859 pwa_hide_html_elements(); 22860}) 22861 22862let subdomain = window.location.hostname.split('.')[0] 22863let interactives_path = "/interactives/unveiling_invisible_universe" // Default to the original released pwa's start page 22864if (subdomain == 'tours'){ 22865 interactives_path = '/interactives/image_tours' 22866} else if (subdomain == 'sliders'){ 22867 interactives_path = '/interactives/image_sliders' 22868} 22869 22870function pwa_hide_html_elements(){ 22871 hide_elements = document.getElementsByClassName('hide-for-pwa') 22872 if (onPwaInteractivesPages()) { 22873 for(i=0; i<hide_elements.length; i++){hide_elements[i].style.display = "none";} // Hide these elements when in pwa mode 22874 document.getElementById('navbar-brand-id').setAttribute('href', interactives_path); 22875 } else { 22876 document.getElementById('navbar-brand-id').setAttribute('href', '/'); 22877 } 22878} 22879 22880// 'appinstalled' is used only for when PWA is first installed. It redirects to interactives home page. 22881// Note1- When PWA is first installed, the VS page it is installed from opens as a PWA, however, 22882// it is simply cloned (ie. not re-loaded). Therefore, no backend controller actions nor 22883// front end view or JS get run. So there doesn't seem to be a way to use those to redirect 22884// to the interactives home page. This 'appinstalled' event allows us to do so. 22885// Note2- The 'appinstalled' event is deprecated. We will need to find an alternate solution at 22886// some point. Fortunately, it's only used for right after the pwa is installed. So users can 22887// simply close the app, reload it, and it should function normally from there on. 22888window.addEventListener('appinstalled', function(event){ 22889 console.log(subdomain + ' appinstalled event') 22890 if (window.location.pathname != interactives_path){ 22891 window.location.href = interactives_path 22892 } 22893}); 22894 22895if (navigator.serviceWorker) { 22896 navigator.serviceWorker.register('/serviceworker.js', { scope: './' }) 22897 .then(function(reg) { 22898 console.log('[Companion]', 'Service worker registered!'); 22899 }); 22900}; 22901( function() { // Use IIFE to isolate code from app 22902 22903 // Rails automatically adds autocomplete="off" to all hidden fields to "fix" a long-standing Firefox bug 22904 // Firefox's autocomplete can randomly change the value of the first hidden field 22905 // Around November of 2022, HTML validators started failing on Rails forms, due to the autocomplete attribute 22906 // We started seeing this in our checker: http://plopoweb1:3005/websites/1-viewspace-demo 22907 // This is an attempt to correct that issue: 22908 // - prepends a "fake" hidden field so FF bug will not affect important fields 22909 // - removes the autocomplete attribute from all hidden fields on all forms 22910 // 22911 // The bug in FF: https://discuss.rubyonrails.org/t/form-with-first-field-value-is-overriden-with-a-token-like-string/74861/11 22912 // Rail's workaround: https://github.com/rails/rails/issues/42610 22913 // Inspiration for workaround: https://github.com/podqueue/rails-hidden_autocomplete 22914 // Fails html validator: https://stackoverflow.com/questions/74256523/rails-button-to-fails-with-w3c-validator 22915 // Also, button_to: https://stackoverflow.com/questions/74256523/rails-button-to-fails-with-w3c-validator 22916 class FixRailsHiddenAutoComplete { 22917 // Returns boolean, indicating if we have already implemented the fix(es) 22918 alreadyPerformed() { 22919 return Boolean($('input[name="workaroundForFirefoxHiddenFieldBug"]').length); 22920 } 22921 22922 // Returns boolean, indicating if browser is Firefox with the hidden/autocomplete bug 22923 browserIsFirefoxWithAutoCompleteBug() { 22924 // Once they fix the bug, check if version is < fixed version 22925 const regex = /Firefox\/\d{2,3}\.\d+/; // i.e. Firefox/120.1, Firefox/99.0 22926 return regex.test(navigator.userAgent); 22927 } 22928 22929 // Prepends a "fake" hidden field so FF bug will not affect important fields 22930 // Kind of like a honeypot for Firefox's bug 22931 prependFakeInputForFirefoxWorkaround(){ 22932 const formElsWithHiddenFields = jQuery('form:has(input[type="hidden"])');
22933 console.debug("In prependFakeInputForFirefoxWorkaround", {ct: formElsWithHiddenFields.length, ids: formElsWithHiddenFields.map(function(){return $(this).attr("id");}).get().join(',') }); 22934 var ffWorkaroundHiddenField = '<input type="hidden" name="workaroundForFirefoxHiddenFieldBug" value="-1" />'; 22935 formElsWithHiddenFields.prepend(ffWorkaroundHiddenField); 22936 } 22937 22938 // Removes the autocomplete attribute from all hidden fields on all forms (correcting to valid html) 22939 removeAutocompleteFromHiddenFields(){ 22940 const hiddenEls = jQuery('input[type="hidden"]'); 22941 // console.debug("In removeAutocompleteFromHiddenFields", {ct: hiddenEls.length, names: hiddenEls.map(function(){return $(this).attr("name");}).get().join(',')}); 22942 22943 hiddenEls.removeAttr("autocomplete"); 22944 } 22945 } 22946 22947 // Automatically run on all pages 22948 // $(document).ready(function(){ // Preferred but not reliable?!? Didn't run sometimes on new page load 22949 jQuery(document).on('turbolinks:load', function () { 22950 var fixer = new FixRailsHiddenAutoComplete(); 22951 if (! fixer.alreadyPerformed()) { // Handle multiple calls (Turbo?) 22952 if (fixer.browserIsFirefoxWithAutoCompleteBug()) { //only add honeypot if browser has bug 22953 fixer.prependFakeInputForFirefoxWorkaround(); 22954 } 22955 fixer.removeAutocompleteFromHiddenFields(); // always correct to valid html 22956 } 22957 }); 22958})(); 22959/* 22960 * This content is licensed according to the W3C Software License at 22961 * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document 22962 * 22963 * Simple accordion pattern example 22964 * 22965 * Updates: 22966 * - Manage visibility via .accordion[data-expanded] and data-show-when-expanded, data-show-when-collapsed 22967 */ 22968 22969'use strict'; 22970 22971class Accordion { 22972 constructor(domNode) { 22973 // State of the acccordion 22974 this.isOpen = false; 22975 22976 this.rootEl = domNode; 22977 this.urlHash = this.rootEl.id; 22978 this.buttonEl = this.rootEl.querySelector('button[aria-expanded]'); 22979 22980 const controlsId = this.buttonEl.getAttribute('aria-controls'); 22981 this.contentEl = document.getElementById(controlsId); 22982 22983 // save state of accordion 22984 // console.debug('this.rootEl', this.rootEl) 22985 // console.debug('accordion dataset', this.rootEl.dataset, { expanded: this.rootEl.dataset.expanded, ownProp: this.rootEl.dataset.hasOwnProperty('expanded'), in: ("expanded" in this.rootEl.dataset) }) 22986 this.toggle(this.rootEl.dataset.hasOwnProperty('expanded')); 22987 22988 // add event listeners 22989 this.buttonEl.addEventListener('click', this.onButtonClick.bind(this)); 22990 } 22991 22992 onButtonClick() { 22993 this.toggle(!this.isOpen); 22994 } 22995 22996 toggle(action) { 22997 // don't do anything if the action state doesn't change 22998 if (action === this.isOpen) { 22999 return; 23000 } 23001 console.debug('In Accordion, toggle', 'action', action, 'isOpen', this.isOpen) 23002 // update the internal state 23003 this.isOpen = action; 23004 23005 // Update state of accordion (for CSS) 23006 if (action) { 23007 // expanded 23008 this.rootEl.dataset.expanded = true; 23009 $(this.contentEl).slideDown(); // WORKAROUND: could not find a way to use data-show-when-expanded AND transition smoothly 23010 23011 // Update browser URL 23012 const requestHash = window.location.hash.substring(1); 23013 if (this.urlHash != requestHash){ 23014 history.pushState({}, '', `#${this.urlHash}`); 23015 } 23016 } else { 23017 // contracted 23018 delete this.rootEl.dataset.expanded; 23019 $(this.contentEl).slideUp(); // WORKAROUND: could not find a way to use data-show-when-expanded AND transition smoothly 23020 } 23021 23022 // Update a11y/aria-expanded 23023 this.buttonEl.setAttribute('aria-expanded', `${action}`); 23024 } 23025 23026 // Add public open and close methods for convenience 23027 open() { 23028 this.toggle(true); 23029 } 23030 23031 close() { 23032 this.toggle(false); 23033 } 23034} 23035 23036 23037function initAccordions(){ 23038 const accordions = document.querySelectorAll('.accordion'); 23039 if (accordions.length > 0) { 23040 console.error('DEBUG! accordions exist! We are using initAccordions:', accordions); 23041 } 23042 accordions.forEach((accordionEl) => { 23043 // console.debug('Initializing accordion', accordionEl) 23044 new Accordion(accordionEl); 23045 }); 23046} 23047 23048$(document).on('turbolinks:load', function() { 23049 initAccordions(); 23050}); 23051 23052 23053// Function to handle hash changes and page load
23054function handleAccordionHash() { 23055 // Get the requestHash without the # 23056 const requestHash = window.location.hash.substring(1); 23057 console.debug('In handleAccordionHash', { requestHash: requestHash }) 23058 23059 if (!requestHash) return; 23060 23061 const targetElement = document.getElementById(requestHash); 23062 23063 if (!targetElement){ 23064 console.warn('Target hash does not exist', requestHash); 23065 return; 23066 } 23067 // Open accordions 23068 if (targetElement.classList.contains('accordion')){ 23069 const accordion = new Accordion(targetElement); 23070 accordion.open(); 23071 } 23072 23073 // Scroll into view 23074 targetElement.scrollIntoView({ 23075 behavior: 'smooth', 23076 block: 'start', 23077 }); 23078} 23079 23080// Add event listener for Turbo load 23081document.addEventListener('turbolinks:load', handleAccordionHash); 23082 23083// Still listen for hash changes while on the page 23084window.addEventListener('hashchange', handleAccordionHash); 23085// Copies the passed copyText to the OS clipboard for pasting 23086function copyToClipboard(copyText) { 23087 navigator.clipboard.writeText(copyText); 23088}; 23089 23090// Helper functions that assist with preocessing time/duration 23091class TimeHelpers { 23092// TODO: export default class Debug { 23093 23094 // Converts hh:mm::ss::nnn to milliseconds 23095 // nanoseconds are optional 23096 static convertHHMMSStoMillseconds(hhmmss) { 23097 var parts = hhmmss.split(':'); // split it at the colons 23098 // TODO: support partial hhmmss params (e.g. mm:ss) 23099 23100 if (parts.length != 3) { 23101 throw new Error('hhmmss must include hr, min, and sec segments') 23102 } 23103 23104 // minutes are worth 60 seconds. Hours are worth 60 minutes. 23105 // Preceding "+" converts to number 23106 // Use parens to ensure conversion is done before multiplication 23107 var hours_to_seconds = (+parts[0]) * 60 * 60; 23108 var minutes_to_seconds = (+parts[1]) * 60; 23109 var seconds = +parts[2]; 23110 var total_seconds = hours_to_seconds + minutes_to_seconds + seconds; 23111 var total_milliseconds = total_seconds * 1000; 23112 23113 // Add optional nanoseconds 23114 // Leaving as string so we can check for existence 23115 // If we convert empty/nonexistent array element to number first, we find that: typeof(NaN)==="number" ?!? 23116 var milliseconds = parts[3]; 23117 if (typeof(milliseconds) === "string") { total_milliseconds += +milliseconds; } 23118 23119 return total_milliseconds; 23120 } 23121 23122 // Converts duration, as milliseconds, into hh:mm:ss:nnn 23123 static convertMillisecondsToHHMMSS(durationInMillisecs, showNano = false) { 23124 // MMS: using a date format is simple, but has issues across midnight boundary 23125 //var selectionLength = showNano ? 12 : 8; 23126 //var hhmmss = new Date(durationInMillisecs).toISOString().substr(11, selectionLength) // convert to HH:MM:SS 23127 let hours = Math.floor(durationInMillisecs / (1000 * 60 * 60)); 23128 let minutes = Math.floor((durationInMillisecs % (1000 * 60 * 60)) / (1000 * 60)); 23129 let seconds = Math.floor((durationInMillisecs % (1000 * 60)) / 1000); 23130 var hhmmss = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; 23131 if (showNano) { 23132 let nanoseconds = Math.floor(durationInMillisecs % 1000); 23133 hhmmss += `:${nanoseconds.toString().padStart(3, '0')}`; 23134 } 23135 return hhmmss; 23136 } 23137 23138 static futureTimePayload(delay) { 23139 const currentTime = new Date(); 23140 let firesAt = new Date(currentTime.getTime()); // mutable copy of currentTime 23141 firesAt.setSeconds(firesAt.getSeconds() + (delay / 1000)) // add the millisecond delay as seconds 23142 return { 23143 delay: TimeHelpers.convertMillisecondsToHHMMSS(delay, true), 23144 firesAt: firesAt.toLocaleString(), 23145 currentTime: currentTime.toLocaleString(), 23146 } 23147 } 23148} 23149 23150// Class to manage a stopwatch-type function 23151// This will call each callback, passing elapsedTime, after each delay (defaults to 333 ms), until stopped 23152// Options (all are optional): 23153// [delay] (integer, ms, default: 333): millisecond delay before firing callbacks 23154// [includeTimeInfo] (boolean, default: false): Should/not include time info in event payloads 23155// [title] (string): concise decription of stopwatch purpose (included in event payloads) 23156// Usage: 23157// const stopwatch = new Stopwatch( 23158// {delay: 1000}, 23159// function(elapsedTime){ 23160// var stopwatchEl = document.querySelector('#cummulative_timer'); 23161// stopwatchEl.innerHTML = elapsedTime; 23162// }, 23163// ); 23164// stopwatch.start(); 23165class Stopwatch { 23166 constructor(options, ...callbacks) { 23167 var offset, clock, interval; 23168 23169 // default options 23170 this.options = options || {}; 23171 var defaultTimerDuration = 333; //ms 23172 this.options.delay = this.options.delay || defaultTimerDuration; 23173 23174 this.callbacks = callbacks; 23175 23176 this.reset(); 23177 } 23178 23179 delta() { 23180 var now = performance.now(), 23181 d = now - this.offset; 23182 23183 this.offset = now; 23184 return d; 23185 } 23186 23187 info() { 23188 return this.options.title ? { title: this.options.title } : {}; 23189 } 23190 23191 processCallbacks(elapsedTime) { 23192 // console.debug('Stopwatch.processCallbacks', elapsedTime, { callbackCount: this.callbacks.length }) 23193 // Call each callback, passing elapsedTime 23194 this.callbacks.forEach(cb => cb(elapsedTime)); 23195 } 23196 23197 reset() { 23198 console.debug('Stopwatch.reset', this.info()); 23199 this.clock = 0; 23200 } 23201 23202 start() { 23203 if (this.interval) { 23204 console.debug("Stopwatch.start:resetting", this.interval) 23205 this.stop(); 23206 this.reset(); 23207 } 23208 23209 this.offset = performance.now(); 23210 23211 let timeInfo = this.options.includeTimeInfo ? TimeHelpers.futureTimePayload(this.options.delay) : { delay: this.options.delay }; 23212 23213 let startInfo = Object.assign(this.info(), timeInfo); 23214 console.debug("Stopwatch.start:starting", startInfo); 23215 this.interval = setInterval(this.update.bind(this), this.options.delay); 23216 } 23217 23218 stop() { 23219 if (!this.interval) throw new Error("interval is " + typeof(this.interval)); 23220 23221 clearInterval(this.interval); 23222 this.interval = null; 23223 } 23224 23225 update() { 23226 this.clock += this.delta(); 23227 //console.debug("Stopwatch.update", this.clock) 23228 this.processCallbacks(this.clock); 23229 } 23230}; 23231 23232// ----------------------------------------------------------------------------- 23233// DebugTasks 23234// ----------------------------------------------------------------------------- 23235// Thin collection of browser-side utilities that mirror the ergonomics of 23236// Ruby rake tasks. Each top-level key functions like a namespace, allowing us to 23237// group helpers by feature area (e.g., events, imageTours) while keeping a 23238// single entry point at `window.DebugTasks`. 23239// 23240// Why this exists: 23241// - Provides quick, discoverable hooks for QA/debug flows without round-tripping 23242// through the Rails console. 23243// - Lets us mirror naming from `rake` (namespace:task_name) while living in the 23244// browser. 23245// - Encourages small, scriptable helpers that can be invoked from DevTools or 23246// automated smoke tests. 23247// 23248// Usage examples: 23249// DebugTasks.listNamespaces(); // ['events', 'imageTours'] 23250// DebugTasks.listTasks(); // Root-level utilities like raiseError 23251// DebugTasks.listTasks('events'); // ['listStored', 'recordTestEvent', ...] 23252// DebugTasks.events.recordTestEvent(); // Runs a grouped helper 23253// DebugTasks.raiseError('boom'); // Simple root task 23254// ----------------------------------------------------------------------------- 23255class DebugTasks {} 23256 23257DebugTasks.listNamespaces = function() { 23258 const namespaces = Object.getOwnPropertyNames(DebugTasks) 23259 .filter(key => { 23260 if (['length', 'name', 'prototype'].includes(key)) return false;
23261 const value = DebugTasks[key]; 23262 return typeof value === 'object' && value !== null; 23263 }); 23264 console.info('DebugTasks namespaces', namespaces); 23265 return namespaces; 23266}; 23267 23268// Lists all tasks, or those within a specific namespace if provided. 23269// Logs results to console and returns an array of task names. 23270DebugTasks.listTasks = function(namespace) { 23271 console.group('DEBUG Tasks'); 23272 try { 23273 if (namespace) { 23274 const group = DebugTasks[namespace]; 23275 if (!group || typeof group !== 'object') { 23276 console.warn(`DebugTasks.listTasks: namespace "${namespace}" not found`); 23277 return []; 23278 } 23279 const tasks = Object.keys(group).filter(key => typeof group[key] === 'function'); 23280 console.groupCollapsed(`DebugTasks.${namespace}`); 23281 console.info(tasks.length ? tasks.map(name => `"${name}"`).join(', ') : '[no tasks]'); 23282 console.groupEnd(); 23283 return tasks; 23284 } 23285 23286 const rootTasks = Object.getOwnPropertyNames(DebugTasks) 23287 .filter(key => typeof DebugTasks[key] === 'function' && !['length', 'name', 'prototype', 'listTasks', 'listNamespaces'].includes(key)); 23288 if (rootTasks.length) { 23289 console.groupCollapsed('DebugTasks (root)'); 23290 console.info(rootTasks.map(name => `"${name}"`).join(', ')); 23291 console.groupEnd(); 23292 } 23293 23294 const namespaces = DebugTasks.listNamespaces(); 23295 namespaces.forEach(ns => { 23296 const tasks = Object.keys(DebugTasks[ns]).filter(key => typeof DebugTasks[ns][key] === 'function'); 23297 console.groupCollapsed(`DebugTasks.${ns}`); 23298 console.info(tasks.length ? tasks.map(name => name).join(', ') : '[no tasks]'); 23299 console.groupEnd(); 23300 }); 23301 return rootTasks; 23302 } finally { 23303 console.groupEnd(); 23304 } 23305}; 23306 23307// Raise a test error with a custom message (or "TEST ERROR" if none provided) 23308DebugTasks.raiseError = function(message = 'TEST ERROR') { 23309 throw new Error(message); 23310}; 23311 23312DebugTasks.events = { 23313 listStored(options) { 23314 if (!window.vse || typeof window.vse.listStoredEvents !== 'function') { 23315 console.warn('DebugTasks.events.listStored: window.vse.listStoredEvents not available'); 23316 return Promise.resolve([]); 23317 } 23318 return window.vse.listStoredEvents(options); 23319 }, 23320 23321 uploadCached({ endpoint = '/ahoy/events', visit_token = null, visitor_token = null } = {}) { 23322 if (!window.vse || typeof window.vse.uploadUnsyncedEvents !== 'function') { 23323 console.warn('DebugTasks.events.uploadCached: window.vse.uploadUnsyncedEvents not available'); 23324 return Promise.resolve({ success: false, uploaded: 0, error: 'uploadUnsyncedEvents not available' }); 23325 } 23326 23327 console.info('DebugTasks.events.uploadCached: Uploading cached events', { endpoint, visit_token, visitor_token }); 23328 return window.vse.uploadUnsyncedEvents(endpoint, visit_token, visitor_token); 23329 }, 23330 23331 recordTestEvent(overrides = {}) { 23332 if (!window.vse || typeof window.vse.recordEvent !== 'function') { 23333 console.warn('DebugTasks.events.recordTestEvent: window.vse.recordEvent not available'); 23334 return Promise.resolve(null); 23335 } 23336 23337 const { 23338 name = 'debug_test_event', 23339 properties = {}, 23340 ...rest 23341 } = overrides; 23342 23343 const payload = { 23344 name, 23345 properties: { 23346 debug_task: true, 23347 note: 'Triggered via DebugTasks.events.recordTestEvent', 23348 ...properties 23349 }, 23350 ...rest 23351 }; 23352 23353 console.info('DebugTasks.events.recordTestEvent: Recording event', payload); 23354 return window.vse.recordEvent(payload); 23355 }, 23356 23357 recordTestError(overrides = {}) { 23358 if (!window.vse || typeof window.vse.recordErrorEvent !== 'function') { 23359 console.warn('DebugTasks.events.recordTestError: window.vse.recordErrorEvent not available'); 23360 return Promise.resolve(null); 23361 } 23362 23363 const defaultStack = new Error('DebugTasks.events.recordTestError trigger').stack; 23364 const { 23365 name = 'debug_test_error', 23366 reason = 'Triggered via DebugTasks.events.recordTestError', 23367 data = {}, 23368 stack = defaultStack, 23369 ...rest 23370 } = overrides; 23371 23372 const payload = { 23373 name, 23374 reason, 23375 data: { 23376 debug_task: true, 23377 note: 'Triggered via DebugTasks.events.recordTestError', 23378 ...data 23379 }, 23380 stack, 23381 ...rest 23382 }; 23383 23384 console.info('DebugTasks.events.recordTestError: Recording error event', payload); 23385 return window.vse.recordErrorEvent(payload); 23386 } 23387}; 23388 23389// Placeholder for future imageTours-related debug tasks 23390DebugTasks.imageTours = { 23391 // Example task 23392 // gotoStop(tourID, stopIdx) {}; 23393} 23394 23395if (typeof window !== 'undefined') { 23396 window.DebugTasks = DebugTasks; 23397}; 23398(function() { 23399 var FlashPresenter; 23400
23401 FlashPresenter = (function() { 23402 function FlashPresenter(containerSelector) { 23403 this.containerSelector = containerSelector; 23404 } 23405 23406 FlashPresenter.prototype.dismiss = function() { 23407 var $flashContainer; 23408 $flashContainer = $(this.containerSelector); 23409 return $flashContainer.empty(); 23410 }; 23411 23412 FlashPresenter.prototype.display = function(flashData) { 23413 var flashMessage, flashType, results; 23414 this.dismiss(); 23415 results = []; 23416 for (flashType in flashData) { 23417 flashMessage = flashData[flashType]; 23418 results.push(this.appendElement(flashType, flashMessage)); 23419 } 23420 return results; 23421 }; 23422 23423 FlashPresenter.prototype.appendElement = function(flashType, flashMessage) { 23424 var $flashContainer; 23425 $flashContainer = $(this.containerSelector); 23426 return $("<div/>", { 23427 "class": "alert alert-dismissible alert-" + flashType 23428 }).append($('<a/>', { 23429 "class": "close", 23430 'data-dismiss': "alert", 23431 'aria-label': "Close" 23432 }).append($('<span/>', { 23433 'aria-hidden': "true", 23434 html: '×' 23435 })), flashMessage).appendTo($flashContainer); 23436 }; 23437 23438 return FlashPresenter; 23439 23440 })(); 23441 23442 $(document).ready(function() { 23443 return App.flashPresenter = new FlashPresenter('#flashMessages'); 23444 }); 23445 23446 $(document).ajaxComplete(function(event, request) { 23447 var flashData, msg; 23448 msg = request.getResponseHeader('X-Message'); 23449 flashData = JSON.parse(msg); 23450 return App.flashPresenter.display(flashData); 23451 }); 23452 23453}).call(this); 23454// Keyboard focus will remain on items in the container 23455// e.g. modal dialog 23456// Derived from: https://uxdesign.cc/how-to-trap-focus-inside-modal-to-make-it-ada-compliant-6a50f9a70700 23457function lockKeyboardFocusToContainer(containerEl, focusableElements) { 23458 if (focusableElements === undefined) { 23459 // add all the elements inside container which you want to make focusable 23460 focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'; 23461 } 23462 23463 const firstFocusableElement = containerEl.querySelectorAll(focusableElements)[0]; // get first element to be focused inside containerEl 23464 const focusableContent = containerEl.querySelectorAll(focusableElements); 23465 const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside containerEl 23466 23467 document.addEventListener('keydown', function(e) { 23468 let isTabPressed = e.key === 'Tab' || e.keyCode === 9; 23469 23470 if (!isTabPressed) { 23471 return; 23472 } 23473 23474 if (e.shiftKey) { // if shift key pressed for shift + tab combination 23475 if (document.activeElement === firstFocusableElement) { 23476 lastFocusableElement.focus();
23476 // add focus for the last focusable element 23477 e.preventDefault(); 23478 } 23479 } else { // if tab key is pressed 23480 if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab 23481 firstFocusableElement.focus(); // add focus for the first focusable element 23482 e.preventDefault(); 23483 } 23484 } 23485 }); 23486 23487 firstFocusableElement.focus(); 23488}; 23489(function() { 23490 23491 23492}).call(this); 23493// Helper functions that assist with preocessing page level functionality 23494class PageHelpers { 23495 static avoidRefreshForInternalHashLink(event) { 23496 const currentPath = window.location.pathname; 23497 const targetUrl = new URL(event.data.url); 23498 23499 if (targetUrl.hash && targetUrl.pathname === currentPath) { 23500 event.preventDefault(); 23501 window.location.hash = targetUrl.hash; 23502 } 23503 } 23504 23505 // Refreshes the page, after sending helpful warning to the console. 23506 static refreshPage(message, payload = {}) { 23507 var defaultPayload = { currentTime: new Date().toLocaleString() }; 23508 var messagePayload = Object.assign({}, defaultPayload, payload); 23509 console.warn(message, "Refreshing page...", messagePayload); 23510 location.reload(); 23511 } 23512 23513 // Only refreshes if the web server is available 23514 // Synchronous ajax call, waits for response before returning 23515 static safeRefresh(message, payload = {}, failure_callback){ 23516 $.ajax({ 23517 type: "HEAD", 23518 url: "/up", 23519 cache: false 23520 }) 23521 .done(function( data, jqXHR, textStatus ) { 23522 // server is available 23523 PageHelpers.refreshPage(message + ' Server is up.', payload); 23524 }) 23525 .fail(function( jqXHR, textStatus, errorThrown ) { 23526 // server is NOT available 23527 const eventPayload = { textStatus: textStatus, errorThrown: errorThrown }; 23528 const failurePayload = Object.assign({ message: message }, payload, eventPayload); 23529 console.warn("Server is NOT available, skipping refresh.", failurePayload); 23530 if(failure_callback){ 23531 failure_callback(); 23532 } 23533 }); 23534 } 23535} 23536 23537// Don't refresh page for internal hash links 23538document.addEventListener("turbolinks:before-visit", (event) => { 23539 PageHelpers.avoidRefreshForInternalHashLink(event); 23540}); 23541// Various waitFor functions 23542 23543 23544// wait until an element is avaiable 23545// Derived from: https://stackoverflow.com/a/61511955 23546// Usage: 23547// waitForElement('.some-class').then((elm) => { 23548// console.log('Element is ready'); 23549// console.log(elm.textContent); 23550// }); 23551// 23552// Usage with async/await: 23553// const elm = await waitForElement('.some-class'); 23554function waitForElement(selector) { 23555 return new Promise(resolve => { 23556 if (document.querySelector(selector)) { 23557 return resolve(document.querySelector(selector)); 23558 } 23559 23560 const observer = new MutationObserver(mutations => { 23561 if (mutations.addedNodes.find(node => node.matchesSelector(selector))) { 23562 observer.disconnect(); 23563 resolve(node); 23564 } 23565 }); 23566 23567 observer.observe(document.body, { 23568 childList: true, 23569 subtree: true 23570 }); 23571 }); 23572} 23573 23574// Wait for variable to be available on window 23575function waitForGlobal(propName, interval = 50, timeout = 10000) { 23576 return new Promise(function(resolve, reject) { 23577 try { 23578 if (typeof window !== 'undefined' && window[propName] != null) return resolve(window[propName]); 23579 } catch (e) { 23580 // ignore and continue polling 23581 } 23582 23583 var start = Date.now(); 23584 var id = setInterval(function() { 23585 try { 23586 if (typeof window !== 'undefined' && window[propName] != null) { 23587 clearInterval(id); 23588 return resolve(window[propName]); 23589 } 23590 } catch (e) { 23591 // ignore 23592 } 23593 if (Date.now() - start > timeout) { 23594 clearInterval(id); 23595 return reject(new Error(propName + ' not found after ' + timeout + 'ms')); 23596 } 23597 }, interval); 23598 }); 23599} 23600 23601// Support ES modules and non-ES loading 23602 23603// Assign to window for global usage (asset pipeline, non-module) 23604if (typeof window !== 'undefined') { 23605 window.waitForGlobal = waitForGlobal; 23606}; 23607(function() { 23608 var DomInitializer; 23609 23610 window.App || (window.App = {}); 23611 23612 DomInitializer = (function() { 23613 var initBootstrapElements, initCollapsibleSection, initElements, initEvents, initHotKeys, initModals, initSimpleCollapsible, initTurbolinksElements, resetSelect2, resetTooltips; 23614 23615 function DomInitializer() { 23616 initEvents(); 23617 $(document).on('turbolinks:before-cache', resetTooltips); 23618 $(document).on('turbolinks:before-cache', resetSelect2); 23619 $(document).on('turbolinks:load', initTurbolinksElements); 23620 $(document).ready(function() { 23621 return initElements(); 23622 }); 23623 } 23624 23625 initBootstrapElements = function() { 23626 return $('.dropdown-toggle').dropdown(); 23627 }; 23628
23629 initCollapsibleSection = function() { 23630 return $(document).on('click', '.collapsible_section .section_head', function() { 23631 return $(this).closest('.collapsible_section').toggleClass('opened'); 23632 }); 23633 }; 23634 23635 initElements = function() { 23636 return initBootstrapElements(); 23637 }; 23638 23639 initEvents = function() { 23640 console.log('initEvents'); 23641 initCollapsibleSection(); 23642 initHotKeys(); 23643 initModals(); 23644 return initSimpleCollapsible(); 23645 }; 23646 23647 initHotKeys = function() { 23648 return $(document).on('keydown', ':not(input)', function(event) { 23649 switch (event.which) { 23650 case 68: 23651 $('.debug').toggle(); 23652 } 23653 return event.stopPropagation(); 23654 }); 23655 }; 23656 23657 initModals = function() { 23658 return $(document).on('shown.bs.modal', '.modal', function(event) { 23659 return lockKeyboardFocusToContainer(event.target); 23660 }); 23661 }; 23662 23663 initSimpleCollapsible = function() { 23664 return $(document).on('click', '.collapsible-control', function() { 23665 return $(this).toggleClass('collapsed'); 23666 }); 23667 }; 23668 23669 initTurbolinksElements = function() { 23670 return $('[data-toggle="tooltip"]').tooltip(); 23671 }; 23672 23673 resetSelect2 = function() { 23674 return $('.select2').remove(); 23675 }; 23676 23677 resetTooltips = function() { 23678 return $('[data-toggle="tooltip"]').tooltip('hide'); 23679 }; 23680 23681 return DomInitializer; 23682 23683 })(); 23684 23685 new DomInitializer; 23686 23687}).call(this); 23688// This is a manifest file that'll be compiled into application.js, which will include all the files 23689// listed below. 23690// 23691// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 23692// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 23693// 23694// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 23695// compiled file. JavaScript code in this file should be added after the last require_* statement. 23696// 23697// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 23698// about supported directives. 23699// 23700// Require viewspace_events first to record all errors. 23701 23702// ensure jQuery 3.x is used by jquery_ujs, et al 23703 23704 23705 23706 23707 23708 23709 23710 23711 23712 23713 23714 23715 23716 23717 23718 23719 23720// For conventions, see http://brandonhilkert.com/blog/organizing-javascript-in-rails-application-with-turbolinks/ 23721// Summary: 23722// - viewspace holds basic initialization 23723// - "always-on" js uses: 23724// - class def, then invocation with... 23725// - `$(document).on 'turbolinks:load', ->` 23726// - use data-behavior for user events 23727// - `$(document).on "click", "[data-behavior~=update-credit-card]", =>`;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.