/* 縮小失敗。正在傳回未縮小的內容。 (3801,41-42): run-time error JS1100: Expected ',': = (3827,29-30): run-time error JS1195: Expected expression: > (3854,10-11): run-time error JS1195: Expected expression: ) (3856,6-7): run-time error JS1195: Expected expression: , (3856,9-10): run-time error JS1002: Syntax error: } (3861,35-36): run-time error JS1004: Expected ';': { (4159,43-44): run-time error JS1195: Expected expression: ) (4159,46-47): run-time error JS1195: Expected expression: > (4161,18-19): run-time error JS1195: Expected expression: , (4162,14-15): run-time error JS1006: Expected ')': ; (4165,34-35): run-time error JS1195: Expected expression: ) (4165,37-38): run-time error JS1195: Expected expression: > (4168,13-14): run-time error JS1002: Syntax error: } (4172,31-32): run-time error JS1014: Invalid character: ` (4172,38-39): run-time error JS1014: Invalid character: : (4172,39-40): run-time error JS1193: Expected ',' or ')': $ (4172,52-53): run-time error JS1002: Syntax error: } (4172,53-54): run-time error JS1014: Invalid character: ` (4178,45-46): run-time error JS1004: Expected ';': { (4183,40-41): run-time error JS1195: Expected expression: ) (4183,43-44): run-time error JS1195: Expected expression: > (4193,43-44): run-time error JS1195: Expected expression: ) (4193,46-47): run-time error JS1195: Expected expression: > (4195,17-18): run-time error JS1002: Syntax error: } (4201,13-14): run-time error JS1002: Syntax error: } (4201,16-20): run-time error JS1197: Too many errors. The file might not be a JavaScript file: 6000 */ ;(function () { 'use strict'; /** * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs. * * @codingstandard ftlabs-jsv2 * @copyright The Financial Times Limited [All Rights Reserved] * @license MIT License (see LICENSE.txt) */ /*jslint browser:true, node:true*/ /*global define, Event, Node*/ /** * Instantiate fast-clicking listeners on the specified layer. * * @constructor * @param {Element} layer The layer to listen on * @param {Object} [options={}] The options to override the defaults */ function FastClick(layer, options) { var oldOnClick; options = options || {}; /** * Whether a click is currently being tracked. * * @type boolean */ this.trackingClick = false; /** * Timestamp for when click tracking started. * * @type number */ this.trackingClickStart = 0; /** * The element being tracked for a click. * * @type EventTarget */ this.targetElement = null; /** * X-coordinate of touch start event. * * @type number */ this.touchStartX = 0; /** * Y-coordinate of touch start event. * * @type number */ this.touchStartY = 0; /** * ID of the last touch, retrieved from Touch.identifier. * * @type number */ this.lastTouchIdentifier = 0; /** * Touchmove boundary, beyond which a click will be cancelled. * * @type number */ this.touchBoundary = options.touchBoundary || 10; /** * The FastClick layer. * * @type Element */ this.layer = layer; /** * The minimum time between tap(touchstart and touchend) events * * @type number */ this.tapDelay = options.tapDelay || 200; /** * The maximum time for a tap * * @type number */ this.tapTimeout = options.tapTimeout || 700; if (FastClick.notNeeded(layer)) { return; } // Some old versions of Android don't have Function.prototype.bind function bind(method, context) { return function() { return method.apply(context, arguments); }; } var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel']; var context = this; for (var i = 0, l = methods.length; i < l; i++) { context[methods[i]] = bind(context[methods[i]], context); } // Set up event handlers as required if (deviceIsAndroid) { layer.addEventListener('mouseover', this.onMouse, true); layer.addEventListener('mousedown', this.onMouse, true); layer.addEventListener('mouseup', this.onMouse, true); } layer.addEventListener('click', this.onClick, true); layer.addEventListener('touchstart', this.onTouchStart, false); layer.addEventListener('touchmove', this.onTouchMove, false); layer.addEventListener('touchend', this.onTouchEnd, false); layer.addEventListener('touchcancel', this.onTouchCancel, false); // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick // layer when they are cancelled. if (!Event.prototype.stopImmediatePropagation) { layer.removeEventListener = function(type, callback, capture) { var rmv = Node.prototype.removeEventListener; if (type === 'click') { rmv.call(layer, type, callback.hijacked || callback, capture); } else { rmv.call(layer, type, callback, capture); } }; layer.addEventListener = function(type, callback, capture) { var adv = Node.prototype.addEventListener; if (type === 'click') { adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) { if (!event.propagationStopped) { callback(event); } }), capture); } else { adv.call(layer, type, callback, capture); } }; } // If a handler is already declared in the element's onclick attribute, it will be fired before // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and // adding it as listener. if (typeof layer.onclick === 'function') { // Android browser on at least 3.2 requires a new reference to the function in layer.onclick // - the old one won't work if passed to addEventListener directly. oldOnClick = layer.onclick; layer.addEventListener('click', function(event) { oldOnClick(event); }, false); layer.onclick = null; } } /** * Windows Phone 8.1 fakes user agent string to look like Android and iPhone. * * @type boolean */ var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0; /** * Android requires exceptions. * * @type boolean */ var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone; /** * iOS requires exceptions. * * @type boolean */ var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone; /** * iOS 4 requires an exception for select elements. * * @type boolean */ var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent); /** * iOS 6.0-7.* requires the target element to be manually derived * * @type boolean */ var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\d/).test(navigator.userAgent); /** * BlackBerry requires exceptions. * * @type boolean */ var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0; /** * Determine whether a given element requires a native click. * * @param {EventTarget|Element} target Target DOM element * @returns {boolean} Returns true if the element needs a native click */ FastClick.prototype.needsClick = function(target) { switch (target.nodeName.toLowerCase()) { // Don't send a synthetic click to disabled inputs (issue #62) case 'button': case 'select': case 'textarea': if (target.disabled) { return true; } break; case 'input': // File inputs need real clicks on iOS 6 due to a browser bug (issue #68) if ((deviceIsIOS && target.type === 'file') || target.disabled) { return true; } break; case 'label': case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames case 'video': return true; } return (/\bneedsclick\b/).test(target.className); }; /** * Determine whether a given element requires a call to focus to simulate click into element. * * @param {EventTarget|Element} target Target DOM element * @returns {boolean} Returns true if the element requires a call to focus to simulate native click. */ FastClick.prototype.needsFocus = function(target) { switch (target.nodeName.toLowerCase()) { case 'textarea': return true; case 'select': return !deviceIsAndroid; case 'input': switch (target.type) { case 'button': case 'checkbox': case 'file': case 'image': case 'radio': case 'submit': return false; } // No point in attempting to focus disabled inputs return !target.disabled && !target.readOnly; default: return (/\bneedsfocus\b/).test(target.className); } }; /** * Send a click event to the specified element. * * @param {EventTarget|Element} targetElement * @param {Event} event */ FastClick.prototype.sendClick = function(targetElement, event) { var clickEvent, touch; // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24) if (document.activeElement && document.activeElement !== targetElement) { document.activeElement.blur(); } touch = event.changedTouches[0]; // Synthesise a click event, with an extra attribute so it can be tracked clickEvent = document.createEvent('MouseEvents'); clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); clickEvent.forwardedTouchEvent = true; targetElement.dispatchEvent(clickEvent); }; FastClick.prototype.determineEventType = function(targetElement) { //Issue #159: Android Chrome Select Box does not open with a synthetic click event if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') { return 'mousedown'; } return 'click'; }; /** * @param {EventTarget|Element} targetElement */ FastClick.prototype.focus = function(targetElement) { var length; // Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724. if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') { length = targetElement.value.length; targetElement.setSelectionRange(length, length); } else { targetElement.focus(); } }; /** * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it. * * @param {EventTarget|Element} targetElement */ FastClick.prototype.updateScrollParent = function(targetElement) { var scrollParent, parentElement; scrollParent = targetElement.fastClickScrollParent; // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the // target element was moved to another parent. if (!scrollParent || !scrollParent.contains(targetElement)) { parentElement = targetElement; do { if (parentElement.scrollHeight > parentElement.offsetHeight) { scrollParent = parentElement; targetElement.fastClickScrollParent = parentElement; break; } parentElement = parentElement.parentElement; } while (parentElement); } // Always update the scroll top tracker if possible. if (scrollParent) { scrollParent.fastClickLastScrollTop = scrollParent.scrollTop; } }; /** * @param {EventTarget} targetElement * @returns {Element|EventTarget} */ FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) { // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node. if (eventTarget.nodeType === Node.TEXT_NODE) { return eventTarget.parentNode; } return eventTarget; }; /** * On touch start, record the position and scroll offset. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onTouchStart = function(event) { var targetElement, touch, selection; // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111). if (event.targetTouches.length > 1) { return true; } targetElement = this.getTargetElementFromEventTarget(event.target); touch = event.targetTouches[0]; if (deviceIsIOS) { // Only trusted events will deselect text on iOS (issue #49) selection = window.getSelection(); if (selection.rangeCount && !selection.isCollapsed) { return true; } if (!deviceIsIOS4) { // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23): // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched // with the same identifier as the touch event that previously triggered the click that triggered the alert. // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform. // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string, // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long, // random integers, it's safe to to continue if the identifier is 0 here. if (touch.identifier && touch.identifier === this.lastTouchIdentifier) { event.preventDefault(); return false; } this.lastTouchIdentifier = touch.identifier; // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and: // 1) the user does a fling scroll on the scrollable layer // 2) the user stops the fling scroll with another tap // then the event.target of the last 'touchend' event will be the element that was under the user's finger // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42). this.updateScrollParent(targetElement); } } this.trackingClick = true; this.trackingClickStart = event.timeStamp; this.targetElement = targetElement; this.touchStartX = touch.pageX; this.touchStartY = touch.pageY; // Prevent phantom clicks on fast double-tap (issue #36) if ((event.timeStamp - this.lastClickTime) < this.tapDelay) { event.preventDefault(); } return true; }; /** * Based on a touchmove event object, check whether the touch has moved past a boundary since it started. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.touchHasMoved = function(event) { var touch = event.changedTouches[0], boundary = this.touchBoundary; if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) { return true; } return false; }; /** * Update the last position. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onTouchMove = function(event) { if (!this.trackingClick) { return true; } // If the touch has moved, cancel the click tracking if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) { this.trackingClick = false; this.targetElement = null; } return true; }; /** * Attempt to find the labelled control for the given label element. * * @param {EventTarget|HTMLLabelElement} labelElement * @returns {Element|null} */ FastClick.prototype.findControl = function(labelElement) { // Fast path for newer browsers supporting the HTML5 control attribute if (labelElement.control !== undefined) { return labelElement.control; } // All browsers under test that support touch events also support the HTML5 htmlFor attribute if (labelElement.htmlFor) { return document.getElementById(labelElement.htmlFor); } // If no for attribute exists, attempt to retrieve the first labellable descendant element // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea'); }; /** * On touch end, determine whether to send a click event at once. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onTouchEnd = function(event) { var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement; if (!this.trackingClick) { return true; } // Prevent phantom clicks on fast double-tap (issue #36) if ((event.timeStamp - this.lastClickTime) < this.tapDelay) { this.cancelNextClick = true; return true; } if ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) { return true; } // Reset to prevent wrong click cancel on input (issue #156). this.cancelNextClick = false; this.lastClickTime = event.timeStamp; trackingClickStart = this.trackingClickStart; this.trackingClick = false; this.trackingClickStart = 0; // On some iOS devices, the targetElement supplied with the event is invalid if the layer // is performing a transition or scroll, and has to be re-detected manually. Note that // for this to function correctly, it must be called *after* the event target is checked! // See issue #57; also filed as rdar://13048589 . if (deviceIsIOSWithBadTarget) { touch = event.changedTouches[0]; // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement; targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent; } targetTagName = targetElement.tagName.toLowerCase(); if (targetTagName === 'label') { forElement = this.findControl(targetElement); if (forElement) { this.focus(targetElement); if (deviceIsAndroid) { return false; } targetElement = forElement; } } else if (this.needsFocus(targetElement)) { // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through. // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37). if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) { this.targetElement = null; return false; } this.focus(targetElement); this.sendClick(targetElement, event); // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open. // Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others) if (!deviceIsIOS || targetTagName !== 'select') { this.targetElement = null; event.preventDefault(); } return false; } if (deviceIsIOS && !deviceIsIOS4) { // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42). scrollParent = targetElement.fastClickScrollParent; if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) { return true; } } // Prevent the actual click from going though - unless the target node is marked as requiring // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted. if (!this.needsClick(targetElement)) { event.preventDefault(); this.sendClick(targetElement, event); } return false; }; /** * On touch cancel, stop tracking the click. * * @returns {void} */ FastClick.prototype.onTouchCancel = function() { this.trackingClick = false; this.targetElement = null; }; /** * Determine mouse events which should be permitted. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onMouse = function(event) { // If a target element was never set (because a touch event was never fired) allow the event if (!this.targetElement) { return true; } if (event.forwardedTouchEvent) { return true; } // Programmatically generated events targeting a specific element should be permitted if (!event.cancelable) { return true; } // Derive and check the target element to see whether the mouse event needs to be permitted; // unless explicitly enabled, prevent non-touch click events from triggering actions, // to prevent ghost/doubleclicks. if (!this.needsClick(this.targetElement) || this.cancelNextClick) { // Prevent any user-added listeners declared on FastClick element from being fired. if (event.stopImmediatePropagation) { event.stopImmediatePropagation(); } else { // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) event.propagationStopped = true; } // Cancel the event event.stopPropagation(); event.preventDefault(); return false; } // If the mouse event is permitted, return true for the action to go through. return true; }; /** * On actual clicks, determine whether this is a touch-generated click, a click action occurring * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or * an actual click which should be permitted. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onClick = function(event) { var permitted; // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early. if (this.trackingClick) { this.targetElement = null; this.trackingClick = false; return true; } // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target. if (event.target.type === 'submit' && event.detail === 0) { return true; } permitted = this.onMouse(event); // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through. if (!permitted) { this.targetElement = null; } // If clicks are permitted, return true for the action to go through. return permitted; }; /** * Remove all FastClick's event listeners. * * @returns {void} */ FastClick.prototype.destroy = function() { var layer = this.layer; if (deviceIsAndroid) { layer.removeEventListener('mouseover', this.onMouse, true); layer.removeEventListener('mousedown', this.onMouse, true); layer.removeEventListener('mouseup', this.onMouse, true); } layer.removeEventListener('click', this.onClick, true); layer.removeEventListener('touchstart', this.onTouchStart, false); layer.removeEventListener('touchmove', this.onTouchMove, false); layer.removeEventListener('touchend', this.onTouchEnd, false); layer.removeEventListener('touchcancel', this.onTouchCancel, false); }; /** * Check whether FastClick is needed. * * @param {Element} layer The layer to listen on */ FastClick.notNeeded = function(layer) { var metaViewport; var chromeVersion; var blackberryVersion; var firefoxVersion; // Devices that don't support touch don't need FastClick if (typeof window.ontouchstart === 'undefined') { return true; } // Chrome version - zero for other browsers chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1]; if (chromeVersion) { if (deviceIsAndroid) { metaViewport = document.querySelector('meta[name=viewport]'); if (metaViewport) { // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89) if (metaViewport.content.indexOf('user-scalable=no') !== -1) { return true; } // Chrome 32 and above with width=device-width or less don't need FastClick if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) { return true; } } // Chrome desktop doesn't need FastClick (issue #15) } else { return true; } } if (deviceIsBlackBerry10) { blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/); // BlackBerry 10.3+ does not require Fastclick library. // https://github.com/ftlabs/fastclick/issues/251 if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) { metaViewport = document.querySelector('meta[name=viewport]'); if (metaViewport) { // user-scalable=no eliminates click delay. if (metaViewport.content.indexOf('user-scalable=no') !== -1) { return true; } // width=device-width (or less than device-width) eliminates click delay. if (document.documentElement.scrollWidth <= window.outerWidth) { return true; } } } } // IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97) if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') { return true; } // Firefox version - zero for other browsers firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1]; if (firefoxVersion >= 27) { // Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896 metaViewport = document.querySelector('meta[name=viewport]'); if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) { return true; } } // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') { return true; } return false; }; /** * Factory method for creating a FastClick object * * @param {Element} layer The layer to listen on * @param {Object} [options={}] The options to override the defaults */ FastClick.attach = function(layer, options) { return new FastClick(layer, options); }; if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) { // AMD. Register as an anonymous module. define(function() { return FastClick; }); } else if (typeof module !== 'undefined' && module.exports) { module.exports = FastClick.attach; module.exports.FastClick = FastClick; } else { window.FastClick = FastClick; } }()); ; (function() { var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i 0) { v = r.exec(n).toString(); v = v.split(" ")[1]; if (v < 9) { $("html").addClass("lt-ie9"); return true; } } return false; } ()); if (!Function.prototype.bind) { Function.prototype.bind = function bind(that) { var target = this; var slice = [].slice; if (typeof target != "function") { throw new TypeError(); } var args = slice.call(arguments, 1), bound = function () { if (this instanceof bound) { var F = function(){}; F.prototype = target.prototype; var self = new F(); var result = target.apply( self, args.concat(slice.call(arguments)) ); if (Object(result) === result) { return result; } return self; } else { return target.apply( that, args.concat(slice.call(arguments)) ); } }; return bound; }; } if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(searchElement, fromIndex) { var k; if (this == null) { throw new TypeError('"this" is null or not defined'); } var O = Object(this); var len = O.length >>> 0; if (len === 0) { return -1; } var n = +fromIndex || 0; if (Math.abs(n) === Infinity) { n = 0; } if (n >= len) { return -1; } k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); while (k < len) { if (k in O && O[k] === searchElement) { return k; } k++; } return -1; }; } // ================================================================================================================= // Template var base_html = '' + '' + '01' + '000' + '' + '' + ''; var single_html = '' + '' + ''; var double_html = '' + '' + '' + ''; var disable_html = ''; // ================================================================================================================= // Core /** * Main plugin constructor * * @param input {Object} link to base input element * @param options {Object} slider config * @param plugin_count {Number} * @constructor */ var IonRangeSlider = function (input, options, plugin_count) { this.VERSION = "2.1.7"; this.input = input; this.plugin_count = plugin_count; this.current_plugin = 0; this.calc_count = 0; this.update_tm = 0; this.old_from = 0; this.old_to = 0; this.old_min_interval = null; this.raf_id = null; this.dragging = false; this.force_redraw = false; this.no_diapason = false; this.is_key = false; this.is_update = false; this.is_start = true; this.is_finish = false; this.is_active = false; this.is_resize = false; this.is_click = false; options = options || {}; // cache for links to all DOM elements this.$cache = { win: $(window), body: $(document.body), input: $(input), cont: null, rs: null, min: null, max: null, from: null, to: null, single: null, bar: null, line: null, s_single: null, s_from: null, s_to: null, shad_single: null, shad_from: null, shad_to: null, edge: null, grid: null, grid_labels: [] }; // storage for measure variables this.coords = { // left x_gap: 0, x_pointer: 0, // width w_rs: 0, w_rs_old: 0, w_handle: 0, // percents p_gap: 0, p_gap_left: 0, p_gap_right: 0, p_step: 0, p_pointer: 0, p_handle: 0, p_single_fake: 0, p_single_real: 0, p_from_fake: 0, p_from_real: 0, p_to_fake: 0, p_to_real: 0, p_bar_x: 0, p_bar_w: 0, // grid grid_gap: 0, big_num: 0, big: [], big_w: [], big_p: [], big_x: [] }; // storage for labels measure variables this.labels = { // width w_min: 0, w_max: 0, w_from: 0, w_to: 0, w_single: 0, // percents p_min: 0, p_max: 0, p_from_fake: 0, p_from_left: 0, p_to_fake: 0, p_to_left: 0, p_single_fake: 0, p_single_left: 0 }; /** * get and validate config */ var $inp = this.$cache.input, val = $inp.prop("value"), config, config_from_data, prop; // default config config = { type: "single", min: 10, max: 100, from: null, to: null, step: 1, min_interval: 0, max_interval: 0, drag_interval: false, values: [], p_values: [], from_fixed: false, from_min: null, from_max: null, from_shadow: false, to_fixed: false, to_min: null, to_max: null, to_shadow: false, prettify_enabled: true, prettify_separator: " ", prettify: null, force_edges: false, keyboard: false, keyboard_step: 5, grid: false, grid_margin: true, grid_num: 4, grid_snap: false, hide_min_max: false, hide_from_to: false, prefix: "", postfix: "", max_postfix: "", decorate_both: true, values_separator: " — ", input_values_separator: ";", disable: false, onStart: null, onChange: null, onFinish: null, onUpdate: null }; // check if base element is input if ($inp[0].nodeName !== "INPUT") { console && console.warn && console.warn("Base element should be !", $inp[0]); } // config from data-attributes extends js config config_from_data = { type: $inp.data("type"), min: $inp.data("min"), max: $inp.data("max"), from: $inp.data("from"), to: $inp.data("to"), step: $inp.data("step"), min_interval: $inp.data("minInterval"), max_interval: $inp.data("maxInterval"), drag_interval: $inp.data("dragInterval"), values: $inp.data("values"), from_fixed: $inp.data("fromFixed"), from_min: $inp.data("fromMin"), from_max: $inp.data("fromMax"), from_shadow: $inp.data("fromShadow"), to_fixed: $inp.data("toFixed"), to_min: $inp.data("toMin"), to_max: $inp.data("toMax"), to_shadow: $inp.data("toShadow"), prettify_enabled: $inp.data("prettifyEnabled"), prettify_separator: $inp.data("prettifySeparator"), force_edges: $inp.data("forceEdges"), keyboard: $inp.data("keyboard"), keyboard_step: $inp.data("keyboardStep"), grid: $inp.data("grid"), grid_margin: $inp.data("gridMargin"), grid_num: $inp.data("gridNum"), grid_snap: $inp.data("gridSnap"), hide_min_max: $inp.data("hideMinMax"), hide_from_to: $inp.data("hideFromTo"), prefix: $inp.data("prefix"), postfix: $inp.data("postfix"), max_postfix: $inp.data("maxPostfix"), decorate_both: $inp.data("decorateBoth"), values_separator: $inp.data("valuesSeparator"), input_values_separator: $inp.data("inputValuesSeparator"), disable: $inp.data("disable") }; config_from_data.values = config_from_data.values && config_from_data.values.split(","); for (prop in config_from_data) { if (config_from_data.hasOwnProperty(prop)) { if (config_from_data[prop] === undefined || config_from_data[prop] === "") { delete config_from_data[prop]; } } } // input value extends default config if (val !== undefined && val !== "") { val = val.split(config_from_data.input_values_separator || options.input_values_separator || ";"); if (val[0] && val[0] == +val[0]) { val[0] = +val[0]; } if (val[1] && val[1] == +val[1]) { val[1] = +val[1]; } if (options && options.values && options.values.length) { config.from = val[0] && options.values.indexOf(val[0]); config.to = val[1] && options.values.indexOf(val[1]); } else { config.from = val[0] && +val[0]; config.to = val[1] && +val[1]; } } // js config extends default config $.extend(config, options); // data config extends config $.extend(config, config_from_data); this.options = config; // validate config, to be sure that all data types are correct this.update_check = {}; this.validate(); // default result object, returned to callbacks this.result = { input: this.$cache.input, slider: null, min: this.options.min, max: this.options.max, from: this.options.from, from_percent: 0, from_value: null, to: this.options.to, to_percent: 0, to_value: null }; this.init(); }; IonRangeSlider.prototype = { /** * Starts or updates the plugin instance * * @param [is_update] {boolean} */ init: function (is_update) { this.no_diapason = false; this.coords.p_step = this.convertToPercent(this.options.step, true); this.target = "base"; this.toggleInput(); this.append(); this.setMinMax(); if (is_update) { this.force_redraw = true; this.calc(true); // callbacks called this.callOnUpdate(); } else { this.force_redraw = true; this.calc(true); // callbacks called this.callOnStart(); } this.updateScene(); }, /** * Appends slider template to a DOM */ append: function () { var container_html = ''; this.$cache.input.before(container_html); this.$cache.input.prop("readonly", true); this.$cache.cont = this.$cache.input.prev(); this.result.slider = this.$cache.cont; this.$cache.cont.html(base_html); this.$cache.rs = this.$cache.cont.find(".irs"); this.$cache.min = this.$cache.cont.find(".irs-min"); this.$cache.max = this.$cache.cont.find(".irs-max"); this.$cache.from = this.$cache.cont.find(".irs-from"); this.$cache.to = this.$cache.cont.find(".irs-to"); this.$cache.single = this.$cache.cont.find(".irs-single"); this.$cache.bar = this.$cache.cont.find(".irs-bar"); this.$cache.line = this.$cache.cont.find(".irs-line"); this.$cache.grid = this.$cache.cont.find(".irs-grid"); if (this.options.type === "single") { this.$cache.cont.append(single_html); this.$cache.edge = this.$cache.cont.find(".irs-bar-edge"); this.$cache.s_single = this.$cache.cont.find(".single"); this.$cache.from[0].style.visibility = "hidden"; this.$cache.to[0].style.visibility = "hidden"; this.$cache.shad_single = this.$cache.cont.find(".shadow-single"); } else { this.$cache.cont.append(double_html); this.$cache.s_from = this.$cache.cont.find(".from"); this.$cache.s_to = this.$cache.cont.find(".to"); this.$cache.shad_from = this.$cache.cont.find(".shadow-from"); this.$cache.shad_to = this.$cache.cont.find(".shadow-to"); this.setTopHandler(); } if (this.options.hide_from_to) { this.$cache.from[0].style.display = "none"; this.$cache.to[0].style.display = "none"; this.$cache.single[0].style.display = "none"; } this.appendGrid(); if (this.options.disable) { this.appendDisableMask(); this.$cache.input[0].disabled = true; } else { this.$cache.cont.removeClass("irs-disabled"); this.$cache.input[0].disabled = false; this.bindEvents(); } if (this.options.drag_interval) { this.$cache.bar[0].style.cursor = "ew-resize"; } }, /** * Determine which handler has a priority * works only for double slider type */ setTopHandler: function () { var min = this.options.min, max = this.options.max, from = this.options.from, to = this.options.to; if (from > min && to === max) { this.$cache.s_from.addClass("type_last"); } else if (to < max) { this.$cache.s_to.addClass("type_last"); } }, /** * Determine which handles was clicked last * and which handler should have hover effect * * @param target {String} */ changeLevel: function (target) { switch (target) { case "single": this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_single_fake); break; case "from": this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_from_fake); this.$cache.s_from.addClass("state_hover"); this.$cache.s_from.addClass("type_last"); this.$cache.s_to.removeClass("type_last"); break; case "to": this.coords.p_gap = this.toFixed(this.coords.p_pointer - this.coords.p_to_fake); this.$cache.s_to.addClass("state_hover"); this.$cache.s_to.addClass("type_last"); this.$cache.s_from.removeClass("type_last"); break; case "both": this.coords.p_gap_left = this.toFixed(this.coords.p_pointer - this.coords.p_from_fake); this.coords.p_gap_right = this.toFixed(this.coords.p_to_fake - this.coords.p_pointer); this.$cache.s_to.removeClass("type_last"); this.$cache.s_from.removeClass("type_last"); break; } }, /** * Then slider is disabled * appends extra layer with opacity */ appendDisableMask: function () { this.$cache.cont.append(disable_html); this.$cache.cont.addClass("irs-disabled"); }, /** * Remove slider instance * and ubind all events */ remove: function () { this.$cache.cont.remove(); this.$cache.cont = null; this.$cache.line.off("keydown.irs_" + this.plugin_count); this.$cache.body.off("touchmove.irs_" + this.plugin_count); this.$cache.body.off("mousemove.irs_" + this.plugin_count); this.$cache.win.off("touchend.irs_" + this.plugin_count); this.$cache.win.off("mouseup.irs_" + this.plugin_count); if (is_old_ie) { this.$cache.body.off("mouseup.irs_" + this.plugin_count); this.$cache.body.off("mouseleave.irs_" + this.plugin_count); } this.$cache.grid_labels = []; this.coords.big = []; this.coords.big_w = []; this.coords.big_p = []; this.coords.big_x = []; cancelAnimationFrame(this.raf_id); }, /** * bind all slider events */ bindEvents: function () { if (this.no_diapason) { return; } this.$cache.body.on("touchmove.irs_" + this.plugin_count, this.pointerMove.bind(this)); this.$cache.body.on("mousemove.irs_" + this.plugin_count, this.pointerMove.bind(this)); this.$cache.win.on("touchend.irs_" + this.plugin_count, this.pointerUp.bind(this)); this.$cache.win.on("mouseup.irs_" + this.plugin_count, this.pointerUp.bind(this)); this.$cache.line.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); this.$cache.line.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); if (this.options.drag_interval && this.options.type === "double") { this.$cache.bar.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "both")); this.$cache.bar.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "both")); } else { this.$cache.bar.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); this.$cache.bar.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); } if (this.options.type === "single") { this.$cache.single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "single")); this.$cache.s_single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "single")); this.$cache.shad_single.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); this.$cache.single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "single")); this.$cache.s_single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "single")); this.$cache.edge.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); this.$cache.shad_single.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); } else { this.$cache.single.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, null)); this.$cache.single.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, null)); this.$cache.from.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "from")); this.$cache.s_from.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "from")); this.$cache.to.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "to")); this.$cache.s_to.on("touchstart.irs_" + this.plugin_count, this.pointerDown.bind(this, "to")); this.$cache.shad_from.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); this.$cache.shad_to.on("touchstart.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); this.$cache.from.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "from")); this.$cache.s_from.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "from")); this.$cache.to.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "to")); this.$cache.s_to.on("mousedown.irs_" + this.plugin_count, this.pointerDown.bind(this, "to")); this.$cache.shad_from.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); this.$cache.shad_to.on("mousedown.irs_" + this.plugin_count, this.pointerClick.bind(this, "click")); } if (this.options.keyboard) { this.$cache.line.on("keydown.irs_" + this.plugin_count, this.key.bind(this, "keyboard")); } if (is_old_ie) { this.$cache.body.on("mouseup.irs_" + this.plugin_count, this.pointerUp.bind(this)); this.$cache.body.on("mouseleave.irs_" + this.plugin_count, this.pointerUp.bind(this)); } }, /** * Mousemove or touchmove * only for handlers * * @param e {Object} event object */ pointerMove: function (e) { if (!this.dragging) { return; } var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX; this.coords.x_pointer = x - this.coords.x_gap; this.calc(); }, /** * Mouseup or touchend * only for handlers * * @param e {Object} event object */ pointerUp: function (e) { if (this.current_plugin !== this.plugin_count) { return; } if (this.is_active) { this.is_active = false; } else { return; } this.$cache.cont.find(".state_hover").removeClass("state_hover"); this.force_redraw = true; if (is_old_ie) { $("*").prop("unselectable", false); } this.updateScene(); this.restoreOriginalMinInterval(); // callbacks call if ($.contains(this.$cache.cont[0], e.target) || this.dragging) { this.callOnFinish(); } this.dragging = false; }, /** * Mousedown or touchstart * only for handlers * * @param target {String|null} * @param e {Object} event object */ pointerDown: function (target, e) { e.preventDefault(); var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX; if (e.button === 2) { return; } if (target === "both") { this.setTempMinInterval(); } if (!target) { target = this.target || "from"; } this.current_plugin = this.plugin_count; this.target = target; this.is_active = true; this.dragging = true; this.coords.x_gap = this.$cache.rs.offset().left; this.coords.x_pointer = x - this.coords.x_gap; this.calcPointerPercent(); this.changeLevel(target); if (is_old_ie) { $("*").prop("unselectable", true); } this.$cache.line.trigger("focus"); this.updateScene(); }, /** * Mousedown or touchstart * for other slider elements, like diapason line * * @param target {String} * @param e {Object} event object */ pointerClick: function (target, e) { e.preventDefault(); var x = e.pageX || e.originalEvent.touches && e.originalEvent.touches[0].pageX; if (e.button === 2) { return; } this.current_plugin = this.plugin_count; this.target = target; this.is_click = true; this.coords.x_gap = this.$cache.rs.offset().left; this.coords.x_pointer = +(x - this.coords.x_gap).toFixed(); this.force_redraw = true; this.calc(); this.$cache.line.trigger("focus"); }, /** * Keyborard controls for focused slider * * @param target {String} * @param e {Object} event object * @returns {boolean|undefined} */ key: function (target, e) { if (this.current_plugin !== this.plugin_count || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) { return; } switch (e.which) { case 83: // W case 65: // A case 40: // DOWN case 37: // LEFT e.preventDefault(); this.moveByKey(false); break; case 87: // S case 68: // D case 38: // UP case 39: // RIGHT e.preventDefault(); this.moveByKey(true); break; } return true; }, /** * Move by key. Beta * @todo refactor than have plenty of time * * @param right {boolean} direction to move */ moveByKey: function (right) { var p = this.coords.p_pointer; if (right) { p += this.options.keyboard_step; } else { p -= this.options.keyboard_step; } this.coords.x_pointer = this.toFixed(this.coords.w_rs / 100 * p); this.is_key = true; this.calc(); }, /** * Set visibility and content * of Min and Max labels */ setMinMax: function () { if (!this.options) { return; } if (this.options.hide_min_max) { this.$cache.min[0].style.display = "none"; this.$cache.max[0].style.display = "none"; return; } if (this.options.values.length) { this.$cache.min.html(this.decorate(this.options.p_values[this.options.min])); this.$cache.max.html(this.decorate(this.options.p_values[this.options.max])); } else { this.$cache.min.html(this.decorate(this._prettify(this.options.min), this.options.min)); this.$cache.max.html(this.decorate(this._prettify(this.options.max), this.options.max)); } this.labels.w_min = this.$cache.min.outerWidth(false); this.labels.w_max = this.$cache.max.outerWidth(false); }, /** * Then dragging interval, prevent interval collapsing * using min_interval option */ setTempMinInterval: function () { var interval = this.result.to - this.result.from; if (this.old_min_interval === null) { this.old_min_interval = this.options.min_interval; } this.options.min_interval = interval; }, /** * Restore min_interval option to original */ restoreOriginalMinInterval: function () { if (this.old_min_interval !== null) { this.options.min_interval = this.old_min_interval; this.old_min_interval = null; } }, // ============================================================================================================= // Calculations /** * All calculations and measures start here * * @param update {boolean=} */ calc: function (update) { if (!this.options) { return; } this.calc_count++; if (this.calc_count === 10 || update) { this.calc_count = 0; this.coords.w_rs = this.$cache.rs.outerWidth(false); this.calcHandlePercent(); } if (!this.coords.w_rs) { return; } this.calcPointerPercent(); var handle_x = this.getHandleX(); if (this.target === "both") { this.coords.p_gap = 0; handle_x = this.getHandleX(); } if (this.target === "click") { this.coords.p_gap = this.coords.p_handle / 2; handle_x = this.getHandleX(); if (this.options.drag_interval) { this.target = "both_one"; } else { this.target = this.chooseHandle(handle_x); } } switch (this.target) { case "base": var w = (this.options.max - this.options.min) / 100, f = (this.result.from - this.options.min) / w, t = (this.result.to - this.options.min) / w; this.coords.p_single_real = this.toFixed(f); this.coords.p_from_real = this.toFixed(f); this.coords.p_to_real = this.toFixed(t); this.coords.p_single_real = this.checkDiapason(this.coords.p_single_real, this.options.from_min, this.options.from_max); this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max); this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max); this.coords.p_single_fake = this.convertToFakePercent(this.coords.p_single_real); this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real); this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real); this.target = null; break; case "single": if (this.options.from_fixed) { break; } this.coords.p_single_real = this.convertToRealPercent(handle_x); this.coords.p_single_real = this.calcWithStep(this.coords.p_single_real); this.coords.p_single_real = this.checkDiapason(this.coords.p_single_real, this.options.from_min, this.options.from_max); this.coords.p_single_fake = this.convertToFakePercent(this.coords.p_single_real); break; case "from": if (this.options.from_fixed) { break; } this.coords.p_from_real = this.convertToRealPercent(handle_x); this.coords.p_from_real = this.calcWithStep(this.coords.p_from_real); if (this.coords.p_from_real > this.coords.p_to_real) { this.coords.p_from_real = this.coords.p_to_real; } this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max); this.coords.p_from_real = this.checkMinInterval(this.coords.p_from_real, this.coords.p_to_real, "from"); this.coords.p_from_real = this.checkMaxInterval(this.coords.p_from_real, this.coords.p_to_real, "from"); this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real); break; case "to": if (this.options.to_fixed) { break; } this.coords.p_to_real = this.convertToRealPercent(handle_x); this.coords.p_to_real = this.calcWithStep(this.coords.p_to_real); if (this.coords.p_to_real < this.coords.p_from_real) { this.coords.p_to_real = this.coords.p_from_real; } this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max); this.coords.p_to_real = this.checkMinInterval(this.coords.p_to_real, this.coords.p_from_real, "to"); this.coords.p_to_real = this.checkMaxInterval(this.coords.p_to_real, this.coords.p_from_real, "to"); this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real); break; case "both": if (this.options.from_fixed || this.options.to_fixed) { break; } handle_x = this.toFixed(handle_x + (this.coords.p_handle * 0.001)); this.coords.p_from_real = this.convertToRealPercent(handle_x) - this.coords.p_gap_left; this.coords.p_from_real = this.calcWithStep(this.coords.p_from_real); this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max); this.coords.p_from_real = this.checkMinInterval(this.coords.p_from_real, this.coords.p_to_real, "from"); this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real); this.coords.p_to_real = this.convertToRealPercent(handle_x) + this.coords.p_gap_right; this.coords.p_to_real = this.calcWithStep(this.coords.p_to_real); this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max); this.coords.p_to_real = this.checkMinInterval(this.coords.p_to_real, this.coords.p_from_real, "to"); this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real); break; case "both_one": if (this.options.from_fixed || this.options.to_fixed) { break; } var real_x = this.convertToRealPercent(handle_x), from = this.result.from_percent, to = this.result.to_percent, full = to - from, half = full / 2, new_from = real_x - half, new_to = real_x + half; if (new_from < 0) { new_from = 0; new_to = new_from + full; } if (new_to > 100) { new_to = 100; new_from = new_to - full; } this.coords.p_from_real = this.calcWithStep(new_from); this.coords.p_from_real = this.checkDiapason(this.coords.p_from_real, this.options.from_min, this.options.from_max); this.coords.p_from_fake = this.convertToFakePercent(this.coords.p_from_real); this.coords.p_to_real = this.calcWithStep(new_to); this.coords.p_to_real = this.checkDiapason(this.coords.p_to_real, this.options.to_min, this.options.to_max); this.coords.p_to_fake = this.convertToFakePercent(this.coords.p_to_real); break; } if (this.options.type === "single") { this.coords.p_bar_x = (this.coords.p_handle / 2); this.coords.p_bar_w = this.coords.p_single_fake; this.result.from_percent = this.coords.p_single_real; this.result.from = this.convertToValue(this.coords.p_single_real); if (this.options.values.length) { this.result.from_value = this.options.values[this.result.from]; } } else { this.coords.p_bar_x = this.toFixed(this.coords.p_from_fake + (this.coords.p_handle / 2)); this.coords.p_bar_w = this.toFixed(this.coords.p_to_fake - this.coords.p_from_fake); this.result.from_percent = this.coords.p_from_real; this.result.from = this.convertToValue(this.coords.p_from_real); this.result.to_percent = this.coords.p_to_real; this.result.to = this.convertToValue(this.coords.p_to_real); if (this.options.values.length) { this.result.from_value = this.options.values[this.result.from]; this.result.to_value = this.options.values[this.result.to]; } } this.calcMinMax(); this.calcLabels(); }, /** * calculates pointer X in percent */ calcPointerPercent: function () { if (!this.coords.w_rs) { this.coords.p_pointer = 0; return; } if (this.coords.x_pointer < 0 || isNaN(this.coords.x_pointer) ) { this.coords.x_pointer = 0; } else if (this.coords.x_pointer > this.coords.w_rs) { this.coords.x_pointer = this.coords.w_rs; } this.coords.p_pointer = this.toFixed(this.coords.x_pointer / this.coords.w_rs * 100); }, convertToRealPercent: function (fake) { var full = 100 - this.coords.p_handle; return fake / full * 100; }, convertToFakePercent: function (real) { var full = 100 - this.coords.p_handle; return real / 100 * full; }, getHandleX: function () { var max = 100 - this.coords.p_handle, x = this.toFixed(this.coords.p_pointer - this.coords.p_gap); if (x < 0) { x = 0; } else if (x > max) { x = max; } return x; }, calcHandlePercent: function () { if (this.options.type === "single") { this.coords.w_handle = this.$cache.s_single.outerWidth(false); } else { this.coords.w_handle = this.$cache.s_from.outerWidth(false); } this.coords.p_handle = this.toFixed(this.coords.w_handle / this.coords.w_rs * 100); }, /** * Find closest handle to pointer click * * @param real_x {Number} * @returns {String} */ chooseHandle: function (real_x) { if (this.options.type === "single") { return "single"; } else { var m_point = this.coords.p_from_real + ((this.coords.p_to_real - this.coords.p_from_real) / 2); if (real_x >= m_point) { return this.options.to_fixed ? "from" : "to"; } else { return this.options.from_fixed ? "to" : "from"; } } }, /** * Measure Min and Max labels width in percent */ calcMinMax: function () { if (!this.coords.w_rs) { return; } this.labels.p_min = this.labels.w_min / this.coords.w_rs * 100; this.labels.p_max = this.labels.w_max / this.coords.w_rs * 100; }, /** * Measure labels width and X in percent */ calcLabels: function () { if (!this.coords.w_rs || this.options.hide_from_to) { return; } if (this.options.type === "single") { this.labels.w_single = this.$cache.single.outerWidth(false); this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100; this.labels.p_single_left = this.coords.p_single_fake + (this.coords.p_handle / 2) - (this.labels.p_single_fake / 2); this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake); } else { this.labels.w_from = this.$cache.from.outerWidth(false); this.labels.p_from_fake = this.labels.w_from / this.coords.w_rs * 100; this.labels.p_from_left = this.coords.p_from_fake + (this.coords.p_handle / 2) - (this.labels.p_from_fake / 2); this.labels.p_from_left = this.toFixed(this.labels.p_from_left); this.labels.p_from_left = this.checkEdges(this.labels.p_from_left, this.labels.p_from_fake); this.labels.w_to = this.$cache.to.outerWidth(false); this.labels.p_to_fake = this.labels.w_to / this.coords.w_rs * 100; this.labels.p_to_left = this.coords.p_to_fake + (this.coords.p_handle / 2) - (this.labels.p_to_fake / 2); this.labels.p_to_left = this.toFixed(this.labels.p_to_left); this.labels.p_to_left = this.checkEdges(this.labels.p_to_left, this.labels.p_to_fake); this.labels.w_single = this.$cache.single.outerWidth(false); this.labels.p_single_fake = this.labels.w_single / this.coords.w_rs * 100; this.labels.p_single_left = ((this.labels.p_from_left + this.labels.p_to_left + this.labels.p_to_fake) / 2) - (this.labels.p_single_fake / 2); this.labels.p_single_left = this.toFixed(this.labels.p_single_left); this.labels.p_single_left = this.checkEdges(this.labels.p_single_left, this.labels.p_single_fake); } }, // ============================================================================================================= // Drawings /** * Main function called in request animation frame * to update everything */ updateScene: function () { if (this.raf_id) { cancelAnimationFrame(this.raf_id); this.raf_id = null; } clearTimeout(this.update_tm); this.update_tm = null; if (!this.options) { return; } this.drawHandles(); if (this.is_active) { this.raf_id = requestAnimationFrame(this.updateScene.bind(this)); } else { this.update_tm = setTimeout(this.updateScene.bind(this), 300); } }, /** * Draw handles */ drawHandles: function () { this.coords.w_rs = this.$cache.rs.outerWidth(false); if (!this.coords.w_rs) { return; } if (this.coords.w_rs !== this.coords.w_rs_old) { this.target = "base"; this.is_resize = true; } if (this.coords.w_rs !== this.coords.w_rs_old || this.force_redraw) { this.setMinMax(); this.calc(true); this.drawLabels(); if (this.options.grid) { this.calcGridMargin(); this.calcGridLabels(); } this.force_redraw = true; this.coords.w_rs_old = this.coords.w_rs; this.drawShadow(); } if (!this.coords.w_rs) { return; } if (!this.dragging && !this.force_redraw && !this.is_key) { return; } if (this.old_from !== this.result.from || this.old_to !== this.result.to || this.force_redraw || this.is_key) { this.drawLabels(); this.$cache.bar[0].style.left = this.coords.p_bar_x + "%"; this.$cache.bar[0].style.width = this.coords.p_bar_w + "%"; if (this.options.type === "single") { this.$cache.s_single[0].style.left = this.coords.p_single_fake + "%"; this.$cache.single[0].style.left = this.labels.p_single_left + "%"; } else { this.$cache.s_from[0].style.left = this.coords.p_from_fake + "%"; this.$cache.s_to[0].style.left = this.coords.p_to_fake + "%"; if (this.old_from !== this.result.from || this.force_redraw) { this.$cache.from[0].style.left = this.labels.p_from_left + "%"; } if (this.old_to !== this.result.to || this.force_redraw) { this.$cache.to[0].style.left = this.labels.p_to_left + "%"; } this.$cache.single[0].style.left = this.labels.p_single_left + "%"; } this.writeToInput(); if ((this.old_from !== this.result.from || this.old_to !== this.result.to) && !this.is_start) { this.$cache.input.trigger("change"); this.$cache.input.trigger("input"); } this.old_from = this.result.from; this.old_to = this.result.to; // callbacks call if (!this.is_resize && !this.is_update && !this.is_start && !this.is_finish) { this.callOnChange(); } if (this.is_key || this.is_click) { this.is_key = false; this.is_click = false; this.callOnFinish(); } this.is_update = false; this.is_resize = false; this.is_finish = false; } this.is_start = false; this.is_key = false; this.is_click = false; this.force_redraw = false; }, /** * Draw labels * measure labels collisions * collapse close labels */ drawLabels: function () { if (!this.options) { return; } var values_num = this.options.values.length, p_values = this.options.p_values, text_single, text_from, text_to; if (this.options.hide_from_to) { return; } if (this.options.type === "single") { if (values_num) { text_single = this.decorate(p_values[this.result.from]); this.$cache.single.html(text_single); } else { text_single = this.decorate(this._prettify(this.result.from), this.result.from); this.$cache.single.html(text_single); } this.calcLabels(); if (this.labels.p_single_left < this.labels.p_min + 1) { this.$cache.min[0].style.visibility = "hidden"; } else { this.$cache.min[0].style.visibility = "visible"; } if (this.labels.p_single_left + this.labels.p_single_fake > 100 - this.labels.p_max - 1) { this.$cache.max[0].style.visibility = "hidden"; } else { this.$cache.max[0].style.visibility = "visible"; } } else { if (values_num) { if (this.options.decorate_both) { text_single = this.decorate(p_values[this.result.from]); text_single += this.options.values_separator; text_single += this.decorate(p_values[this.result.to]); } else { text_single = this.decorate(p_values[this.result.from] + this.options.values_separator + p_values[this.result.to]); } text_from = this.decorate(p_values[this.result.from]); text_to = this.decorate(p_values[this.result.to]); this.$cache.single.html(text_single); this.$cache.from.html(text_from); this.$cache.to.html(text_to); } else { if (this.options.decorate_both) { text_single = this.decorate(this._prettify(this.result.from), this.result.from); text_single += this.options.values_separator; text_single += this.decorate(this._prettify(this.result.to), this.result.to); } else { text_single = this.decorate(this._prettify(this.result.from) + this.options.values_separator + this._prettify(this.result.to), this.result.to); } text_from = this.decorate(this._prettify(this.result.from), this.result.from); text_to = this.decorate(this._prettify(this.result.to), this.result.to); this.$cache.single.html(text_single); this.$cache.from.html(text_from); this.$cache.to.html(text_to); } this.calcLabels(); var min = Math.min(this.labels.p_single_left, this.labels.p_from_left), single_left = this.labels.p_single_left + this.labels.p_single_fake, to_left = this.labels.p_to_left + this.labels.p_to_fake, max = Math.max(single_left, to_left); if (this.labels.p_from_left + this.labels.p_from_fake >= this.labels.p_to_left) { this.$cache.from[0].style.visibility = "hidden"; this.$cache.to[0].style.visibility = "hidden"; this.$cache.single[0].style.visibility = "visible"; if (this.result.from === this.result.to) { if (this.target === "from") { this.$cache.from[0].style.visibility = "visible"; } else if (this.target === "to") { this.$cache.to[0].style.visibility = "visible"; } else if (!this.target) { this.$cache.from[0].style.visibility = "visible"; } this.$cache.single[0].style.visibility = "hidden"; max = to_left; } else { this.$cache.from[0].style.visibility = "hidden"; this.$cache.to[0].style.visibility = "hidden"; this.$cache.single[0].style.visibility = "visible"; max = Math.max(single_left, to_left); } } else { this.$cache.from[0].style.visibility = "visible"; this.$cache.to[0].style.visibility = "visible"; this.$cache.single[0].style.visibility = "hidden"; } if (min < this.labels.p_min + 1) { this.$cache.min[0].style.visibility = "hidden"; } else { this.$cache.min[0].style.visibility = "visible"; } if (max > 100 - this.labels.p_max - 1) { this.$cache.max[0].style.visibility = "hidden"; } else { this.$cache.max[0].style.visibility = "visible"; } } }, /** * Draw shadow intervals */ drawShadow: function () { var o = this.options, c = this.$cache, is_from_min = typeof o.from_min === "number" && !isNaN(o.from_min), is_from_max = typeof o.from_max === "number" && !isNaN(o.from_max), is_to_min = typeof o.to_min === "number" && !isNaN(o.to_min), is_to_max = typeof o.to_max === "number" && !isNaN(o.to_max), from_min, from_max, to_min, to_max; if (o.type === "single") { if (o.from_shadow && (is_from_min || is_from_max)) { from_min = this.convertToPercent(is_from_min ? o.from_min : o.min); from_max = this.convertToPercent(is_from_max ? o.from_max : o.max) - from_min; from_min = this.toFixed(from_min - (this.coords.p_handle / 100 * from_min)); from_max = this.toFixed(from_max - (this.coords.p_handle / 100 * from_max)); from_min = from_min + (this.coords.p_handle / 2); c.shad_single[0].style.display = "block"; c.shad_single[0].style.left = from_min + "%"; c.shad_single[0].style.width = from_max + "%"; } else { c.shad_single[0].style.display = "none"; } } else { if (o.from_shadow && (is_from_min || is_from_max)) { from_min = this.convertToPercent(is_from_min ? o.from_min : o.min); from_max = this.convertToPercent(is_from_max ? o.from_max : o.max) - from_min; from_min = this.toFixed(from_min - (this.coords.p_handle / 100 * from_min)); from_max = this.toFixed(from_max - (this.coords.p_handle / 100 * from_max)); from_min = from_min + (this.coords.p_handle / 2); c.shad_from[0].style.display = "block"; c.shad_from[0].style.left = from_min + "%"; c.shad_from[0].style.width = from_max + "%"; } else { c.shad_from[0].style.display = "none"; } if (o.to_shadow && (is_to_min || is_to_max)) { to_min = this.convertToPercent(is_to_min ? o.to_min : o.min); to_max = this.convertToPercent(is_to_max ? o.to_max : o.max) - to_min; to_min = this.toFixed(to_min - (this.coords.p_handle / 100 * to_min)); to_max = this.toFixed(to_max - (this.coords.p_handle / 100 * to_max)); to_min = to_min + (this.coords.p_handle / 2); c.shad_to[0].style.display = "block"; c.shad_to[0].style.left = to_min + "%"; c.shad_to[0].style.width = to_max + "%"; } else { c.shad_to[0].style.display = "none"; } } }, /** * Write values to input element */ writeToInput: function () { if (this.options.type === "single") { if (this.options.values.length) { this.$cache.input.prop("value", this.result.from_value); } else { this.$cache.input.prop("value", this.result.from); } this.$cache.input.data("from", this.result.from); } else { if (this.options.values.length) { this.$cache.input.prop("value", this.result.from_value + this.options.input_values_separator + this.result.to_value); } else { this.$cache.input.prop("value", this.result.from + this.options.input_values_separator + this.result.to); } this.$cache.input.data("from", this.result.from); this.$cache.input.data("to", this.result.to); } }, // ============================================================================================================= // Callbacks callOnStart: function () { this.writeToInput(); if (this.options.onStart && typeof this.options.onStart === "function") { this.options.onStart(this.result); } }, callOnChange: function () { this.writeToInput(); if (this.options.onChange && typeof this.options.onChange === "function") { this.options.onChange(this.result); } }, callOnFinish: function () { this.writeToInput(); if (this.options.onFinish && typeof this.options.onFinish === "function") { this.options.onFinish(this.result); } }, callOnUpdate: function () { this.writeToInput(); if (this.options.onUpdate && typeof this.options.onUpdate === "function") { this.options.onUpdate(this.result); } }, // ============================================================================================================= // Service methods toggleInput: function () { this.$cache.input.toggleClass("irs-hidden-input"); }, /** * Convert real value to percent * * @param value {Number} X in real * @param no_min {boolean=} don't use min value * @returns {Number} X in percent */ convertToPercent: function (value, no_min) { var diapason = this.options.max - this.options.min, one_percent = diapason / 100, val, percent; if (!diapason) { this.no_diapason = true; return 0; } if (no_min) { val = value; } else { val = value - this.options.min; } percent = val / one_percent; return this.toFixed(percent); }, /** * Convert percent to real values * * @param percent {Number} X in percent * @returns {Number} X in real */ convertToValue: function (percent) { var min = this.options.min, max = this.options.max, min_decimals = min.toString().split(".")[1], max_decimals = max.toString().split(".")[1], min_length, max_length, avg_decimals = 0, abs = 0; if (percent === 0) { return this.options.min; } if (percent === 100) { return this.options.max; } if (min_decimals) { min_length = min_decimals.length; avg_decimals = min_length; } if (max_decimals) { max_length = max_decimals.length; avg_decimals = max_length; } if (min_length && max_length) { avg_decimals = (min_length >= max_length) ? min_length : max_length; } if (min < 0) { abs = Math.abs(min); min = +(min + abs).toFixed(avg_decimals); max = +(max + abs).toFixed(avg_decimals); } var number = ((max - min) / 100 * percent) + min, string = this.options.step.toString().split(".")[1], result; if (string) { number = +number.toFixed(string.length); } else { number = number / this.options.step; number = number * this.options.step; number = +number.toFixed(0); } if (abs) { number -= abs; } if (string) { result = +number.toFixed(string.length); } else { result = this.toFixed(number); } if (result < this.options.min) { result = this.options.min; } else if (result > this.options.max) { result = this.options.max; } return result; }, /** * Round percent value with step * * @param percent {Number} * @returns percent {Number} rounded */ calcWithStep: function (percent) { var rounded = Math.round(percent / this.coords.p_step) * this.coords.p_step; if (rounded > 100) { rounded = 100; } if (percent === 100) { rounded = 100; } return this.toFixed(rounded); }, checkMinInterval: function (p_current, p_next, type) { var o = this.options, current, next; if (!o.min_interval) { return p_current; } current = this.convertToValue(p_current); next = this.convertToValue(p_next); if (type === "from") { if (next - current < o.min_interval) { current = next - o.min_interval; } } else { if (current - next < o.min_interval) { current = next + o.min_interval; } } return this.convertToPercent(current); }, checkMaxInterval: function (p_current, p_next, type) { var o = this.options, current, next; if (!o.max_interval) { return p_current; } current = this.convertToValue(p_current); next = this.convertToValue(p_next); if (type === "from") { if (next - current > o.max_interval) { current = next - o.max_interval; } } else { if (current - next > o.max_interval) { current = next + o.max_interval; } } return this.convertToPercent(current); }, checkDiapason: function (p_num, min, max) { var num = this.convertToValue(p_num), o = this.options; if (typeof min !== "number") { min = o.min; } if (typeof max !== "number") { max = o.max; } if (num < min) { num = min; } if (num > max) { num = max; } return this.convertToPercent(num); }, toFixed: function (num) { num = num.toFixed(20); return +num; }, _prettify: function (num) { if (!this.options.prettify_enabled) { return num; } if (this.options.prettify && typeof this.options.prettify === "function") { return this.options.prettify(num); } else { return this.prettify(num); } }, prettify: function (num) { var n = num.toString(); return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + this.options.prettify_separator); }, checkEdges: function (left, width) { if (!this.options.force_edges) { return this.toFixed(left); } if (left < 0) { left = 0; } else if (left > 100 - width) { left = 100 - width; } return this.toFixed(left); }, validate: function () { var o = this.options, r = this.result, v = o.values, vl = v.length, value, i; if (typeof o.min === "string") o.min = +o.min; if (typeof o.max === "string") o.max = +o.max; if (typeof o.from === "string") o.from = +o.from; if (typeof o.to === "string") o.to = +o.to; if (typeof o.step === "string") o.step = +o.step; if (typeof o.from_min === "string") o.from_min = +o.from_min; if (typeof o.from_max === "string") o.from_max = +o.from_max; if (typeof o.to_min === "string") o.to_min = +o.to_min; if (typeof o.to_max === "string") o.to_max = +o.to_max; if (typeof o.keyboard_step === "string") o.keyboard_step = +o.keyboard_step; if (typeof o.grid_num === "string") o.grid_num = +o.grid_num; if (o.max < o.min) { o.max = o.min; } if (vl) { o.p_values = []; o.min = 0; o.max = vl - 1; o.step = 1; o.grid_num = o.max; o.grid_snap = true; for (i = 0; i < vl; i++) { value = +v[i]; if (!isNaN(value)) { v[i] = value; value = this._prettify(value); } else { value = v[i]; } o.p_values.push(value); } } if (typeof o.from !== "number" || isNaN(o.from)) { o.from = o.min; } if (typeof o.to !== "number" || isNaN(o.to)) { o.to = o.max; } if (o.type === "single") { if (o.from < o.min) o.from = o.min; if (o.from > o.max) o.from = o.max; } else { if (o.from < o.min) o.from = o.min; if (o.from > o.max) o.from = o.max; if (o.to < o.min) o.to = o.min; if (o.to > o.max) o.to = o.max; if (this.update_check.from) { if (this.update_check.from !== o.from) { if (o.from > o.to) o.from = o.to; } if (this.update_check.to !== o.to) { if (o.to < o.from) o.to = o.from; } } if (o.from > o.to) o.from = o.to; if (o.to < o.from) o.to = o.from; } if (typeof o.step !== "number" || isNaN(o.step) || !o.step || o.step < 0) { o.step = 1; } if (typeof o.keyboard_step !== "number" || isNaN(o.keyboard_step) || !o.keyboard_step || o.keyboard_step < 0) { o.keyboard_step = 5; } if (typeof o.from_min === "number" && o.from < o.from_min) { o.from = o.from_min; } if (typeof o.from_max === "number" && o.from > o.from_max) { o.from = o.from_max; } if (typeof o.to_min === "number" && o.to < o.to_min) { o.to = o.to_min; } if (typeof o.to_max === "number" && o.from > o.to_max) { o.to = o.to_max; } if (r) { if (r.min !== o.min) { r.min = o.min; } if (r.max !== o.max) { r.max = o.max; } if (r.from < r.min || r.from > r.max) { r.from = o.from; } if (r.to < r.min || r.to > r.max) { r.to = o.to; } } if (typeof o.min_interval !== "number" || isNaN(o.min_interval) || !o.min_interval || o.min_interval < 0) { o.min_interval = 0; } if (typeof o.max_interval !== "number" || isNaN(o.max_interval) || !o.max_interval || o.max_interval < 0) { o.max_interval = 0; } if (o.min_interval && o.min_interval > o.max - o.min) { o.min_interval = o.max - o.min; } if (o.max_interval && o.max_interval > o.max - o.min) { o.max_interval = o.max - o.min; } }, decorate: function (num, original) { var decorated = "", o = this.options; if (o.prefix) { decorated += o.prefix; } decorated += num; if (o.max_postfix) { if (o.values.length && num === o.p_values[o.max]) { decorated += o.max_postfix; if (o.postfix) { decorated += " "; } } else if (original === o.max) { decorated += o.max_postfix; if (o.postfix) { decorated += " "; } } } if (o.postfix) { decorated += o.postfix; } return decorated; }, updateFrom: function () { this.result.from = this.options.from; this.result.from_percent = this.convertToPercent(this.result.from); if (this.options.values) { this.result.from_value = this.options.values[this.result.from]; } }, updateTo: function () { this.result.to = this.options.to; this.result.to_percent = this.convertToPercent(this.result.to); if (this.options.values) { this.result.to_value = this.options.values[this.result.to]; } }, updateResult: function () { this.result.min = this.options.min; this.result.max = this.options.max; this.updateFrom(); this.updateTo(); }, // ============================================================================================================= // Grid appendGrid: function () { if (!this.options.grid) { return; } var o = this.options, i, z, total = o.max - o.min, big_num = o.grid_num, big_p = 0, big_w = 0, small_max = 4, local_small_max, small_p, small_w = 0, result, html = ''; this.calcGridMargin(); if (o.grid_snap) { if (total > 50) { big_num = 50 / o.step; big_p = this.toFixed(o.step / 0.5); } else { big_num = total / o.step; big_p = this.toFixed(o.step / (total / 100)); } } else { big_p = this.toFixed(100 / big_num); } if (big_num > 4) { small_max = 3; } if (big_num > 7) { small_max = 2; } if (big_num > 14) { small_max = 1; } if (big_num > 28) { small_max = 0; } for (i = 0; i < big_num + 1; i++) { local_small_max = small_max; big_w = this.toFixed(big_p * i); if (big_w > 100) { big_w = 100; local_small_max -= 2; if (local_small_max < 0) { local_small_max = 0; } } this.coords.big[i] = big_w; small_p = (big_w - (big_p * (i - 1))) / (local_small_max + 1); for (z = 1; z <= local_small_max; z++) { if (big_w === 0) { break; } small_w = this.toFixed(big_w - (small_p * z)); html += ''; } html += ''; result = this.convertToValue(big_w); if (o.values.length) { result = o.p_values[result]; } else { result = this._prettify(result); } html += '' + result + ''; } this.coords.big_num = Math.ceil(big_num + 1); this.$cache.cont.addClass("irs-with-grid"); this.$cache.grid.html(html); this.cacheGridLabels(); }, cacheGridLabels: function () { var $label, i, num = this.coords.big_num; for (i = 0; i < num; i++) { $label = this.$cache.grid.find(".js-grid-text-" + i); this.$cache.grid_labels.push($label); } this.calcGridLabels(); }, calcGridLabels: function () { var i, label, start = [], finish = [], num = this.coords.big_num; for (i = 0; i < num; i++) { this.coords.big_w[i] = this.$cache.grid_labels[i].outerWidth(false); this.coords.big_p[i] = this.toFixed(this.coords.big_w[i] / this.coords.w_rs * 100); this.coords.big_x[i] = this.toFixed(this.coords.big_p[i] / 2); start[i] = this.toFixed(this.coords.big[i] - this.coords.big_x[i]); finish[i] = this.toFixed(start[i] + this.coords.big_p[i]); } if (this.options.force_edges) { if (start[0] < -this.coords.grid_gap) { start[0] = -this.coords.grid_gap; finish[0] = this.toFixed(start[0] + this.coords.big_p[0]); this.coords.big_x[0] = this.coords.grid_gap; } if (finish[num - 1] > 100 + this.coords.grid_gap) { finish[num - 1] = 100 + this.coords.grid_gap; start[num - 1] = this.toFixed(finish[num - 1] - this.coords.big_p[num - 1]); this.coords.big_x[num - 1] = this.toFixed(this.coords.big_p[num - 1] - this.coords.grid_gap); } } this.calcGridCollision(2, start, finish); this.calcGridCollision(4, start, finish); for (i = 0; i < num; i++) { label = this.$cache.grid_labels[i][0]; if (this.coords.big_x[i] !== Number.POSITIVE_INFINITY) { label.style.marginLeft = -this.coords.big_x[i] + "%"; } } }, // Collisions Calc Beta // TODO: Refactor then have plenty of time calcGridCollision: function (step, start, finish) { var i, next_i, label, num = this.coords.big_num; for (i = 0; i < num; i += step) { next_i = i + (step / 2); if (next_i >= num) { break; } label = this.$cache.grid_labels[next_i][0]; if (finish[i] <= start[next_i]) { label.style.visibility = "visible"; } else { label.style.visibility = "hidden"; } } }, calcGridMargin: function () { if (!this.options.grid_margin) { return; } this.coords.w_rs = this.$cache.rs.outerWidth(false); if (!this.coords.w_rs) { return; } if (this.options.type === "single") { this.coords.w_handle = this.$cache.s_single.outerWidth(false); } else { this.coords.w_handle = this.$cache.s_from.outerWidth(false); } this.coords.p_handle = this.toFixed(this.coords.w_handle / this.coords.w_rs * 100); this.coords.grid_gap = this.toFixed((this.coords.p_handle / 2) - 0.1); this.$cache.grid[0].style.width = this.toFixed(100 - this.coords.p_handle) + "%"; this.$cache.grid[0].style.left = this.coords.grid_gap + "%"; }, // ============================================================================================================= // Public methods update: function (options) { if (!this.input) { return; } this.is_update = true; this.options.from = this.result.from; this.options.to = this.result.to; this.update_check.from = this.result.from; this.update_check.to = this.result.to; this.options = $.extend(this.options, options); this.validate(); this.updateResult(options); this.toggleInput(); this.remove(); this.init(true); }, reset: function () { if (!this.input) { return; } this.updateResult(); this.update(); }, destroy: function () { if (!this.input) { return; } this.toggleInput(); this.$cache.input.prop("readonly", false); $.data(this.input, "ionRangeSlider", null); this.remove(); this.input = null; this.options = null; } }; $.fn.ionRangeSlider = function (options) { return this.each(function() { if (!$.data(this, "ionRangeSlider")) { $.data(this, "ionRangeSlider", new IonRangeSlider(this, options, plugin_count++)); } }); }; // ================================================================================================================= // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel // MIT license (function() { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); }; }()); })); // 初始化請參考 http://ionden.com/a/plugins/ion.rangeSlider/api.html // 並在對應的頁面設定,這邊是 rangeSlider 原碼,或許不應該放初始化。 // 怕以下程式碼移除會造成錯誤,故先不移除。 // Trigger $(function () { var $range = $(".js-range-slider"), $inputFrom = $(".js-input-from"), $inputTo = $(".js-input-to"), instance, min = 0, max = 1000000, from = 0, to = 0; $range.ionRangeSlider({ type: "double", min: min, max: max, from: 20000, to: 500000, prefix: '$ ', onStart: updateInputs, onChange: updateInputs, step: 50000, prettify_enabled: true, prettify_separator: ".", values_separator: " - ", force_edges: true }); instance = $range.data("ionRangeSlider"); function updateInputs (data) { from = data.from; to = data.to; $inputFrom.prop("value", from).keyup(resizeInput).each(resizeInput); $inputTo.prop("value", to).keyup(resizeInput).each(resizeInput); } $inputFrom.on("input", function () { var val = $(this).prop("value"); // validate if (val < min) { val = min; } else if (val > to) { val = to; } instance.update({ from: val }); }); $inputTo.on("input", function () { var val = $(this).prop("value"); // validate if (val < from) { val = from; } else if (val > max) { val = max; } instance.update({ to: val }); }); });; // Sticky Plugin v1.0.4 for jQuery // ============= // Author: Anthony Garand // Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk) // Improvements by Leonardo C. Daronco (daronco) // Created: 02/14/2011 // Date: 07/20/2015 // Website: http://stickyjs.com/ // Description: Makes an element on the page stick on the screen as you scroll // It will only set the 'top' and 'position' of your element, you // might need to adjust the width in some cases. (function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], factory); } else if (typeof module === 'object' && module.exports) { // Node/CommonJS module.exports = factory(require('jquery')); } else { // Browser globals factory(jQuery); } }(function ($) { var slice = Array.prototype.slice; // save ref to original slice() var splice = Array.prototype.splice; // save ref to original slice() var defaults = { topSpacing: 0, bottomSpacing: 0, className: 'is-sticky', wrapperClassName: 'sticky-wrapper', center: false, getWidthFrom: '', widthFromWrapper: true, // works only when .getWidthFrom is empty responsiveWidth: false, zIndex: 'inherit' }, $window = $(window), $document = $(document), sticked = [], windowHeight = $window.height(), scroller = function() { var scrollTop = $window.scrollTop(), documentHeight = $document.height(), dwh = documentHeight - windowHeight, extra = (scrollTop > dwh) ? dwh - scrollTop : 0; for (var i = 0, l = sticked.length; i < l; i++) { var s = sticked[i], elementTop = s.stickyWrapper.offset().top, etse = elementTop - s.topSpacing - extra; //update height in case of dynamic content s.stickyWrapper.css('height', s.stickyElement.outerHeight()); if (scrollTop <= etse) { if (s.currentTop !== null) { s.stickyElement .css({ 'width': '', 'position': '', 'top': '', 'z-index': '' }); s.stickyElement.parent().removeClass(s.className); s.stickyElement.trigger('sticky-end', [s]); s.currentTop = null; } } else { var newTop = documentHeight - s.stickyElement.outerHeight() - s.topSpacing - s.bottomSpacing - scrollTop - extra; if (newTop < 0) { newTop = newTop + s.topSpacing; } else { newTop = s.topSpacing; } if (s.currentTop !== newTop) { var newWidth; if (s.getWidthFrom) { padding = s.stickyElement.innerWidth() - s.stickyElement.width(); newWidth = $(s.getWidthFrom).width() - padding || null; } else if (s.widthFromWrapper) { newWidth = s.stickyWrapper.width(); } if (newWidth == null) { newWidth = s.stickyElement.width(); } s.stickyElement .css('width', newWidth) .css('position', 'fixed') .css('top', newTop) .css('z-index', s.zIndex); s.stickyElement.parent().addClass(s.className); if (s.currentTop === null) { s.stickyElement.trigger('sticky-start', [s]); } else { // sticky is started but it have to be repositioned s.stickyElement.trigger('sticky-update', [s]); } if (s.currentTop === s.topSpacing && s.currentTop > newTop || s.currentTop === null && newTop < s.topSpacing) { // just reached bottom || just started to stick but bottom is already reached s.stickyElement.trigger('sticky-bottom-reached', [s]); } else if(s.currentTop !== null && newTop === s.topSpacing && s.currentTop < newTop) { // sticky is started && sticked at topSpacing && overflowing from top just finished s.stickyElement.trigger('sticky-bottom-unreached', [s]); } s.currentTop = newTop; } // Check if sticky has reached end of container and stop sticking var stickyWrapperContainer = s.stickyWrapper.parent(); var unstick = (s.stickyElement.offset().top + s.stickyElement.outerHeight() >= stickyWrapperContainer.offset().top + stickyWrapperContainer.outerHeight()) && (s.stickyElement.offset().top <= s.topSpacing); if( unstick ) { s.stickyElement .css('position', 'absolute') .css('top', '') .css('bottom', 0) .css('z-index', ''); } else { s.stickyElement .css('position', 'fixed') .css('top', newTop) .css('bottom', '') .css('z-index', s.zIndex); } } } }, resizer = function() { windowHeight = $window.height(); for (var i = 0, l = sticked.length; i < l; i++) { var s = sticked[i]; var newWidth = null; if (s.getWidthFrom) { if (s.responsiveWidth) { newWidth = $(s.getWidthFrom).width(); } } else if(s.widthFromWrapper) { newWidth = s.stickyWrapper.width(); } if (newWidth != null) { s.stickyElement.css('width', newWidth); } } }, methods = { init: function(options) { return this.each(function() { var o = $.extend({}, defaults, options); var stickyElement = $(this); var stickyId = stickyElement.attr('id'); var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName; var wrapper = $('
') .attr('id', wrapperId) .addClass(o.wrapperClassName); stickyElement.wrapAll(function() { if ($(this).parent("#" + wrapperId).length == 0) { return wrapper; } }); var stickyWrapper = stickyElement.parent(); if (o.center) { stickyWrapper.css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"}); } if (stickyElement.css("float") === "right") { stickyElement.css({"float":"none"}).parent().css({"float":"right"}); } o.stickyElement = stickyElement; o.stickyWrapper = stickyWrapper; o.currentTop = null; sticked.push(o); methods.setWrapperHeight(this); methods.setupChangeListeners(this); }); }, setWrapperHeight: function(stickyElement) { var element = $(stickyElement); var stickyWrapper = element.parent(); if (stickyWrapper) { stickyWrapper.css('height', element.outerHeight()); } }, setupChangeListeners: function(stickyElement) { if (window.MutationObserver) { var mutationObserver = new window.MutationObserver(function(mutations) { if (mutations[0].addedNodes.length || mutations[0].removedNodes.length) { methods.setWrapperHeight(stickyElement); } }); mutationObserver.observe(stickyElement, {subtree: true, childList: true}); } else { if (window.addEventListener) { stickyElement.addEventListener('DOMNodeInserted', function() { methods.setWrapperHeight(stickyElement); }, false); stickyElement.addEventListener('DOMNodeRemoved', function() { methods.setWrapperHeight(stickyElement); }, false); } else if (window.attachEvent) { stickyElement.attachEvent('onDOMNodeInserted', function() { methods.setWrapperHeight(stickyElement); }); stickyElement.attachEvent('onDOMNodeRemoved', function() { methods.setWrapperHeight(stickyElement); }); } } }, update: scroller, unstick: function(options) { return this.each(function() { var that = this; var unstickyElement = $(that); var removeIdx = -1; var i = sticked.length; while (i-- > 0) { if (sticked[i].stickyElement.get(0) === that) { splice.call(sticked,i,1); removeIdx = i; } } if(removeIdx !== -1) { unstickyElement.unwrap(); unstickyElement .css({ 'width': '', 'position': '', 'top': '', 'float': '', 'z-index': '' }) ; } }); } }; // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer): if (window.addEventListener) { window.addEventListener('scroll', scroller, false); window.addEventListener('resize', resizer, false); } else if (window.attachEvent) { window.attachEvent('onscroll', scroller); window.attachEvent('onresize', resizer); } $.fn.sticky = function(method) { if (methods[method]) { return methods[method].apply(this, slice.call(arguments, 1)); } else if (typeof method === 'object' || !method ) { return methods.init.apply( this, arguments ); } else { $.error('Method ' + method + ' does not exist on jQuery.sticky'); } }; $.fn.unstick = function(method) { if (methods[method]) { return methods[method].apply(this, slice.call(arguments, 1)); } else if (typeof method === 'object' || !method ) { return methods.unstick.apply( this, arguments ); } else { $.error('Method ' + method + ' does not exist on jQuery.sticky'); } }; $(function() { setTimeout(scroller, 0); }); })); ; /** MIT License Copyright (c) 2017 yiming.hsu >> 0; // Steps 3, 4, 5, 6, 7 var k = 0; var value; if (arguments.length >= 2) { value = arguments[1]; } else { while (k < len && !(k in o)) { k++; } // 3. If len is 0 and initialValue is not present, // throw a TypeError exception. if (k >= len) { throw new TypeError( 'Reduce of empty array ' + 'with no initial value' ); } value = o[k++]; } // 8. Repeat, while k < len while (k < len) { // a. Let Pk be ! ToString(k). // b. Let kPresent be ? HasProperty(O, Pk). // c. If kPresent is true, then // i. Let kValue be ? Get(O, Pk). // ii. Let accumulator be ? Call( // callbackfn, undefined, // « accumulator, kValue, k, O »). if (k in o) { value = callback(value, o[k], k, o); } // d. Increase k by 1. k++; } // 9. Return accumulator. return value; } }); } // main function function serializeJson (form, protected = false) { var data = {}, form_arr = []; // export to array if(typeof HTMLFormElement === "function" && form instanceof HTMLFormElement) { for(var i in form.elements) { if(form.elements[i] instanceof HTMLInputElement || form.elements[i] instanceof HTMLSelectElement || form.elements[i] instanceof HTMLTextAreaElement) { switch(form.elements[i].type) { case "checkbox": if(form.elements[i].checked) form_arr.push({name:form.elements[i].name, value:form.elements[i].value}); break; default: form_arr.push({name:form.elements[i].name, value:form.elements[i].value}); } } } } else if(Array.isArray(form)) { form_arr = form; } // serialize to json data = form_arr.reduce(function (r, o) { var s = r, arr = o.name.split('.'); arr.forEach((n, k) => { var ck = n.replace(/\[[0-9]*\]$/, ""); if (!s.hasOwnProperty(ck)) s[ck] = (new RegExp("\[[0-9]*\]$").test(n)) ? [] : {}; if (s[ck] instanceof Array) { var i = parseInt((n.match(new RegExp("([0-9]+)\]$")) || []).pop(), 10); i = isNaN(i) ? s[ck].length : i; s[ck][i] = s[ck][i] || {}; if(k === arr.length - 1) { if(protected && JSON.stringify({}) !== JSON.stringify(s[ck][i])) { while(s[ck][i] !== undefined) { var tmp = s[ck][i]; s[ck][i] = o.value; o.value = tmp; i++; } } return s[ck][i] = o.value; } else { return s = s[ck][i]; } } else { return (k === arr.length - 1) ? s[ck] = o.value : s = s[ck]; } }); return r; }, {}); return data; } // for jquery if(typeof jQuery !== "undefined") { jQuery.fn.extend({ serializeJson: function() { return serializeJson( this.serializeArray() ); } }); } // for nodejs if(typeof module !== "undefined") { module.exports = serializeJson; } ; /*! * jQuery Cookie Plugin v1.4.1 * https://github.com/carhartl/jquery-cookie * * Copyright 2013 Klaus Hartl * Released under the MIT license */ (function (factory) { if (typeof define === 'function' && define.amd) { // AMD define(['jquery'], factory); } else if (typeof exports === 'object') { // CommonJS factory(require('jquery')); } else { // Browser globals factory(jQuery); } }(function ($) { var pluses = /\+/g; function encode(s) { return config.raw ? s : encodeURIComponent(s); } function decode(s) { return config.raw ? s : decodeURIComponent(s); } function stringifyCookieValue(value) { return encode(config.json ? JSON.stringify(value) : String(value)); } function parseCookieValue(s) { if (s.indexOf('"') === 0) { // This is a quoted cookie as according to RFC2068, unescape... s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } try { // Replace server-side written pluses with spaces. // If we can't decode the cookie, ignore it, it's unusable. // If we can't parse the cookie, ignore it, it's unusable. s = decodeURIComponent(s.replace(pluses, ' ')); return config.json ? JSON.parse(s) : s; } catch(e) {} } function read(s, converter) { var value = config.raw ? s : parseCookieValue(s); return $.isFunction(converter) ? converter(value) : value; } var config = $.cookie = function (key, value, options) { // Write if (value !== undefined && !$.isFunction(value)) { options = $.extend({}, config.defaults, options); if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setTime(+t + days * 864e+5); } return (document.cookie = [ encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } // Read var result = key ? undefined : {}; // To prevent the for loop in the first place assign an empty array // in case there are no cookies at all. Also prevents odd result when // calling $.cookie(). var cookies = document.cookie ? document.cookie.split('; ') : []; for (var i = 0, l = cookies.length; i < l; i++) { var parts = cookies[i].split('='); var name = decode(parts.shift()); var cookie = parts.join('='); if (key && key === name) { // If second argument (value) is a function it's a converter... result = read(cookie, value); break; } // Prevent storing a cookie that we couldn't decode. if (!key && (cookie = read(cookie)) !== undefined) { result[name] = cookie; } } return result; }; config.defaults = {}; $.removeCookie = function (key, options) { if ($.cookie(key) === undefined) { return false; } // Must not alter options, thus extending a fresh object... $.cookie(key, '', $.extend({}, options, { expires: -1 })); return !$.cookie(key); }; })); ; // Closure (function () { /** * Decimal adjustment of a number. * * @param {String} type The type of adjustment. * @param {Number} value The number. * @param {Integer} exp The exponent (the 10 logarithm of the adjustment base). * @returns {Number} The adjusted value. */ function decimalAdjust(type, value, exp) { // If the exp is undefined or zero... if (typeof exp === 'undefined' || +exp === 0) { return Math[type](value); } value = +value; exp = +exp; // If the value is not a number or the exp is not an integer... if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { return NaN; } // Shift value = value.toString().split('e'); value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))); // Shift back value = value.toString().split('e'); return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); } // Decimal round if (!Math.round10) { Math.round10 = function (value, exp) { return decimalAdjust('round', value, exp); }; } // Decimal floor if (!Math.floor10) { Math.floor10 = function (value, exp) { return decimalAdjust('floor', value, exp); }; } // Decimal ceil if (!Math.ceil10) { Math.ceil10 = function (value, exp) { return decimalAdjust('ceil', value, exp); }; } })();; /*! * Vue.js v2.6.11 * (c) 2014-2019 Evan You * Released under the MIT License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Vue=t()}(this,function(){"use strict";var e=Object.freeze({});function t(e){return null==e}function n(e){return null!=e}function r(e){return!0===e}function i(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function o(e){return null!==e&&"object"==typeof e}var a=Object.prototype.toString;function s(e){return"[object Object]"===a.call(e)}function c(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function u(e){return n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function l(e){return null==e?"":Array.isArray(e)||s(e)&&e.toString===a?JSON.stringify(e,null,2):String(e)}function f(e){var t=parseFloat(e);return isNaN(t)?e:t}function p(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i-1)return e.splice(n,1)}}var m=Object.prototype.hasOwnProperty;function y(e,t){return m.call(e,t)}function g(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var _=/-(\w)/g,b=g(function(e){return e.replace(_,function(e,t){return t?t.toUpperCase():""})}),$=g(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}),w=/\B([A-Z])/g,C=g(function(e){return e.replace(w,"-$1").toLowerCase()});var x=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function k(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function A(e,t){for(var n in t)e[n]=t[n];return e}function O(e){for(var t={},n=0;n0,Z=J&&J.indexOf("edge/")>0,G=(J&&J.indexOf("android"),J&&/iphone|ipad|ipod|ios/.test(J)||"ios"===K),X=(J&&/chrome\/\d+/.test(J),J&&/phantomjs/.test(J),J&&J.match(/firefox\/(\d+)/)),Y={}.watch,Q=!1;if(z)try{var ee={};Object.defineProperty(ee,"passive",{get:function(){Q=!0}}),window.addEventListener("test-passive",null,ee)}catch(e){}var te=function(){return void 0===B&&(B=!z&&!V&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),B},ne=z&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function re(e){return"function"==typeof e&&/native code/.test(e.toString())}var ie,oe="undefined"!=typeof Symbol&&re(Symbol)&&"undefined"!=typeof Reflect&&re(Reflect.ownKeys);ie="undefined"!=typeof Set&&re(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ae=S,se=0,ce=function(){this.id=se++,this.subs=[]};ce.prototype.addSub=function(e){this.subs.push(e)},ce.prototype.removeSub=function(e){h(this.subs,e)},ce.prototype.depend=function(){ce.target&&ce.target.addDep(this)},ce.prototype.notify=function(){for(var e=this.subs.slice(),t=0,n=e.length;t-1)if(o&&!y(i,"default"))a=!1;else if(""===a||a===C(e)){var c=Pe(String,i.type);(c<0||s0&&(st((u=e(u,(a||"")+"_"+c))[0])&&st(f)&&(s[l]=he(f.text+u[0].text),u.shift()),s.push.apply(s,u)):i(u)?st(f)?s[l]=he(f.text+u):""!==u&&s.push(he(u)):st(u)&&st(f)?s[l]=he(f.text+u.text):(r(o._isVList)&&n(u.tag)&&t(u.key)&&n(a)&&(u.key="__vlist"+a+"_"+c+"__"),s.push(u)));return s}(e):void 0}function st(e){return n(e)&&n(e.text)&&!1===e.isComment}function ct(e,t){if(e){for(var n=Object.create(null),r=oe?Reflect.ownKeys(e):Object.keys(e),i=0;i0,a=t?!!t.$stable:!o,s=t&&t.$key;if(t){if(t._normalized)return t._normalized;if(a&&r&&r!==e&&s===r.$key&&!o&&!r.$hasNormal)return r;for(var c in i={},t)t[c]&&"$"!==c[0]&&(i[c]=pt(n,c,t[c]))}else i={};for(var u in n)u in i||(i[u]=dt(n,u));return t&&Object.isExtensible(t)&&(t._normalized=i),R(i,"$stable",a),R(i,"$key",s),R(i,"$hasNormal",o),i}function pt(e,t,n){var r=function(){var e=arguments.length?n.apply(null,arguments):n({});return(e=e&&"object"==typeof e&&!Array.isArray(e)?[e]:at(e))&&(0===e.length||1===e.length&&e[0].isComment)?void 0:e};return n.proxy&&Object.defineProperty(e,t,{get:r,enumerable:!0,configurable:!0}),r}function dt(e,t){return function(){return e[t]}}function vt(e,t){var r,i,a,s,c;if(Array.isArray(e)||"string"==typeof e)for(r=new Array(e.length),i=0,a=e.length;idocument.createEvent("Event").timeStamp&&(sn=function(){return cn.now()})}function un(){var e,t;for(an=sn(),rn=!0,Qt.sort(function(e,t){return e.id-t.id}),on=0;onon&&Qt[n].id>e.id;)n--;Qt.splice(n+1,0,e)}else Qt.push(e);nn||(nn=!0,Ye(un))}}(this)},fn.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||o(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){Re(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},fn.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},fn.prototype.depend=function(){for(var e=this.deps.length;e--;)this.deps[e].depend()},fn.prototype.teardown=function(){if(this.active){this.vm._isBeingDestroyed||h(this.vm._watchers,this);for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1}};var pn={enumerable:!0,configurable:!0,get:S,set:S};function dn(e,t,n){pn.get=function(){return this[t][n]},pn.set=function(e){this[t][n]=e},Object.defineProperty(e,n,pn)}function vn(e){e._watchers=[];var t=e.$options;t.props&&function(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[];e.$parent&&$e(!1);var o=function(o){i.push(o);var a=Me(o,t,n,e);xe(r,o,a),o in e||dn(e,"_props",o)};for(var a in t)o(a);$e(!0)}(e,t.props),t.methods&&function(e,t){e.$options.props;for(var n in t)e[n]="function"!=typeof t[n]?S:x(t[n],e)}(e,t.methods),t.data?function(e){var t=e.$options.data;s(t=e._data="function"==typeof t?function(e,t){le();try{return e.call(t,t)}catch(e){return Re(e,t,"data()"),{}}finally{fe()}}(t,e):t||{})||(t={});var n=Object.keys(t),r=e.$options.props,i=(e.$options.methods,n.length);for(;i--;){var o=n[i];r&&y(r,o)||(a=void 0,36!==(a=(o+"").charCodeAt(0))&&95!==a&&dn(e,"_data",o))}var a;Ce(t,!0)}(e):Ce(e._data={},!0),t.computed&&function(e,t){var n=e._computedWatchers=Object.create(null),r=te();for(var i in t){var o=t[i],a="function"==typeof o?o:o.get;r||(n[i]=new fn(e,a||S,S,hn)),i in e||mn(e,i,o)}}(e,t.computed),t.watch&&t.watch!==Y&&function(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i-1:"string"==typeof e?e.split(",").indexOf(t)>-1:(n=e,"[object RegExp]"===a.call(n)&&e.test(t));var n}function An(e,t){var n=e.cache,r=e.keys,i=e._vnode;for(var o in n){var a=n[o];if(a){var s=xn(a.componentOptions);s&&!t(s)&&On(n,o,r,i)}}}function On(e,t,n,r){var i=e[t];!i||r&&i.tag===r.tag||i.componentInstance.$destroy(),e[t]=null,h(n,t)}!function(t){t.prototype._init=function(t){var n=this;n._uid=bn++,n._isVue=!0,t&&t._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var i=r.componentOptions;n.propsData=i.propsData,n._parentListeners=i.listeners,n._renderChildren=i.children,n._componentTag=i.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(n,t):n.$options=De($n(n.constructor),t||{},n),n._renderProxy=n,n._self=n,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(n),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&qt(e,t)}(n),function(t){t._vnode=null,t._staticTrees=null;var n=t.$options,r=t.$vnode=n._parentVnode,i=r&&r.context;t.$slots=ut(n._renderChildren,i),t.$scopedSlots=e,t._c=function(e,n,r,i){return Pt(t,e,n,r,i,!1)},t.$createElement=function(e,n,r,i){return Pt(t,e,n,r,i,!0)};var o=r&&r.data;xe(t,"$attrs",o&&o.attrs||e,null,!0),xe(t,"$listeners",n._parentListeners||e,null,!0)}(n),Yt(n,"beforeCreate"),function(e){var t=ct(e.$options.inject,e);t&&($e(!1),Object.keys(t).forEach(function(n){xe(e,n,t[n])}),$e(!0))}(n),vn(n),function(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}(n),Yt(n,"created"),n.$options.el&&n.$mount(n.$options.el)}}(wn),function(e){var t={get:function(){return this._data}},n={get:function(){return this._props}};Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=ke,e.prototype.$delete=Ae,e.prototype.$watch=function(e,t,n){if(s(t))return _n(this,e,t,n);(n=n||{}).user=!0;var r=new fn(this,e,t,n);if(n.immediate)try{t.call(this,r.value)}catch(e){Re(e,this,'callback for immediate watcher "'+r.expression+'"')}return function(){r.teardown()}}}(wn),function(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this;if(Array.isArray(e))for(var i=0,o=e.length;i1?k(t):t;for(var n=k(arguments,1),r='event handler for "'+e+'"',i=0,o=t.length;iparseInt(this.max)&&On(a,s[0],s,this._vnode)),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return F}};Object.defineProperty(e,"config",t),e.util={warn:ae,extend:A,mergeOptions:De,defineReactive:xe},e.set=ke,e.delete=Ae,e.nextTick=Ye,e.observable=function(e){return Ce(e),e},e.options=Object.create(null),M.forEach(function(t){e.options[t+"s"]=Object.create(null)}),e.options._base=e,A(e.options.components,Tn),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=k(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=De(this.options,e),this}}(e),Cn(e),function(e){M.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&s(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}(e)}(wn),Object.defineProperty(wn.prototype,"$isServer",{get:te}),Object.defineProperty(wn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(wn,"FunctionalRenderContext",{value:Tt}),wn.version="2.6.11";var En=p("style,class"),Nn=p("input,textarea,option,select,progress"),jn=function(e,t,n){return"value"===n&&Nn(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},Dn=p("contenteditable,draggable,spellcheck"),Ln=p("events,caret,typing,plaintext-only"),Mn=function(e,t){return Hn(t)||"false"===t?"false":"contenteditable"===e&&Ln(t)?t:"true"},In=p("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),Fn="http://www.w3.org/1999/xlink",Pn=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},Rn=function(e){return Pn(e)?e.slice(6,e.length):""},Hn=function(e){return null==e||!1===e};function Bn(e){for(var t=e.data,r=e,i=e;n(i.componentInstance);)(i=i.componentInstance._vnode)&&i.data&&(t=Un(i.data,t));for(;n(r=r.parent);)r&&r.data&&(t=Un(t,r.data));return function(e,t){if(n(e)||n(t))return zn(e,Vn(t));return""}(t.staticClass,t.class)}function Un(e,t){return{staticClass:zn(e.staticClass,t.staticClass),class:n(e.class)?[e.class,t.class]:t.class}}function zn(e,t){return e?t?e+" "+t:e:t||""}function Vn(e){return Array.isArray(e)?function(e){for(var t,r="",i=0,o=e.length;i-1?hr(e,t,n):In(t)?Hn(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Dn(t)?e.setAttribute(t,Mn(t,n)):Pn(t)?Hn(n)?e.removeAttributeNS(Fn,Rn(t)):e.setAttributeNS(Fn,t,n):hr(e,t,n)}function hr(e,t,n){if(Hn(n))e.removeAttribute(t);else{if(q&&!W&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}var mr={create:dr,update:dr};function yr(e,r){var i=r.elm,o=r.data,a=e.data;if(!(t(o.staticClass)&&t(o.class)&&(t(a)||t(a.staticClass)&&t(a.class)))){var s=Bn(r),c=i._transitionClasses;n(c)&&(s=zn(s,Vn(c))),s!==i._prevClass&&(i.setAttribute("class",s),i._prevClass=s)}}var gr,_r,br,$r,wr,Cr,xr={create:yr,update:yr},kr=/[\w).+\-_$\]]/;function Ar(e){var t,n,r,i,o,a=!1,s=!1,c=!1,u=!1,l=0,f=0,p=0,d=0;for(r=0;r=0&&" "===(h=e.charAt(v));v--);h&&kr.test(h)||(u=!0)}}else void 0===i?(d=r+1,i=e.slice(0,r).trim()):m();function m(){(o||(o=[])).push(e.slice(d,r).trim()),d=r+1}if(void 0===i?i=e.slice(0,r).trim():0!==d&&m(),o)for(r=0;r-1?{exp:e.slice(0,$r),key:'"'+e.slice($r+1)+'"'}:{exp:e,key:null};_r=e,$r=wr=Cr=0;for(;!zr();)Vr(br=Ur())?Jr(br):91===br&&Kr(br);return{exp:e.slice(0,wr),key:e.slice(wr+1,Cr)}}(e);return null===n.key?e+"="+t:"$set("+n.exp+", "+n.key+", "+t+")"}function Ur(){return _r.charCodeAt(++$r)}function zr(){return $r>=gr}function Vr(e){return 34===e||39===e}function Kr(e){var t=1;for(wr=$r;!zr();)if(Vr(e=Ur()))Jr(e);else if(91===e&&t++,93===e&&t--,0===t){Cr=$r;break}}function Jr(e){for(var t=e;!zr()&&(e=Ur())!==t;);}var qr,Wr="__r",Zr="__c";function Gr(e,t,n){var r=qr;return function i(){null!==t.apply(null,arguments)&&Qr(e,i,n,r)}}var Xr=Ve&&!(X&&Number(X[1])<=53);function Yr(e,t,n,r){if(Xr){var i=an,o=t;t=o._wrapper=function(e){if(e.target===e.currentTarget||e.timeStamp>=i||e.timeStamp<=0||e.target.ownerDocument!==document)return o.apply(this,arguments)}}qr.addEventListener(e,t,Q?{capture:n,passive:r}:n)}function Qr(e,t,n,r){(r||qr).removeEventListener(e,t._wrapper||t,n)}function ei(e,r){if(!t(e.data.on)||!t(r.data.on)){var i=r.data.on||{},o=e.data.on||{};qr=r.elm,function(e){if(n(e[Wr])){var t=q?"change":"input";e[t]=[].concat(e[Wr],e[t]||[]),delete e[Wr]}n(e[Zr])&&(e.change=[].concat(e[Zr],e.change||[]),delete e[Zr])}(i),rt(i,o,Yr,Qr,Gr,r.context),qr=void 0}}var ti,ni={create:ei,update:ei};function ri(e,r){if(!t(e.data.domProps)||!t(r.data.domProps)){var i,o,a=r.elm,s=e.data.domProps||{},c=r.data.domProps||{};for(i in n(c.__ob__)&&(c=r.data.domProps=A({},c)),s)i in c||(a[i]="");for(i in c){if(o=c[i],"textContent"===i||"innerHTML"===i){if(r.children&&(r.children.length=0),o===s[i])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===i&&"PROGRESS"!==a.tagName){a._value=o;var u=t(o)?"":String(o);ii(a,u)&&(a.value=u)}else if("innerHTML"===i&&qn(a.tagName)&&t(a.innerHTML)){(ti=ti||document.createElement("div")).innerHTML=""+o+"";for(var l=ti.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}else if(o!==s[i])try{a[i]=o}catch(e){}}}}function ii(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var r=e.value,i=e._vModifiers;if(n(i)){if(i.number)return f(r)!==f(t);if(i.trim)return r.trim()!==t.trim()}return r!==t}(e,t))}var oi={create:ri,update:ri},ai=g(function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach(function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t});function si(e){var t=ci(e.style);return e.staticStyle?A(e.staticStyle,t):t}function ci(e){return Array.isArray(e)?O(e):"string"==typeof e?ai(e):e}var ui,li=/^--/,fi=/\s*!important$/,pi=function(e,t,n){if(li.test(t))e.style.setProperty(t,n);else if(fi.test(n))e.style.setProperty(C(t),n.replace(fi,""),"important");else{var r=vi(t);if(Array.isArray(n))for(var i=0,o=n.length;i-1?t.split(yi).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function _i(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(yi).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function bi(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&A(t,$i(e.name||"v")),A(t,e),t}return"string"==typeof e?$i(e):void 0}}var $i=g(function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}}),wi=z&&!W,Ci="transition",xi="animation",ki="transition",Ai="transitionend",Oi="animation",Si="animationend";wi&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(ki="WebkitTransition",Ai="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(Oi="WebkitAnimation",Si="webkitAnimationEnd"));var Ti=z?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function Ei(e){Ti(function(){Ti(e)})}function Ni(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),gi(e,t))}function ji(e,t){e._transitionClasses&&h(e._transitionClasses,t),_i(e,t)}function Di(e,t,n){var r=Mi(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===Ci?Ai:Si,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c0&&(n=Ci,l=a,f=o.length):t===xi?u>0&&(n=xi,l=u,f=c.length):f=(n=(l=Math.max(a,u))>0?a>u?Ci:xi:null)?n===Ci?o.length:c.length:0,{type:n,timeout:l,propCount:f,hasTransform:n===Ci&&Li.test(r[ki+"Property"])}}function Ii(e,t){for(;e.length1}function Ui(e,t){!0!==t.data.show&&Pi(t)}var zi=function(e){var o,a,s={},c=e.modules,u=e.nodeOps;for(o=0;ov?_(e,t(i[y+1])?null:i[y+1].elm,i,d,y,o):d>y&&$(r,p,v)}(p,h,y,o,l):n(y)?(n(e.text)&&u.setTextContent(p,""),_(p,null,y,0,y.length-1,o)):n(h)?$(h,0,h.length-1):n(e.text)&&u.setTextContent(p,""):e.text!==i.text&&u.setTextContent(p,i.text),n(v)&&n(d=v.hook)&&n(d=d.postpatch)&&d(e,i)}}}function k(e,t,i){if(r(i)&&n(e.parent))e.parent.data.pendingInsert=t;else for(var o=0;o-1,a.selected!==o&&(a.selected=o);else if(N(Wi(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function qi(e,t){return t.every(function(t){return!N(t,e)})}function Wi(e){return"_value"in e?e._value:e.value}function Zi(e){e.target.composing=!0}function Gi(e){e.target.composing&&(e.target.composing=!1,Xi(e.target,"input"))}function Xi(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Yi(e){return!e.componentInstance||e.data&&e.data.transition?e:Yi(e.componentInstance._vnode)}var Qi={model:Vi,show:{bind:function(e,t,n){var r=t.value,i=(n=Yi(n)).data&&n.data.transition,o=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&i?(n.data.show=!0,Pi(n,function(){e.style.display=o})):e.style.display=r?o:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=Yi(n)).data&&n.data.transition?(n.data.show=!0,r?Pi(n,function(){e.style.display=e.__vOriginalDisplay}):Ri(n,function(){e.style.display="none"})):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,i){i||(e.style.display=e.__vOriginalDisplay)}}},eo={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function to(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?to(zt(t.children)):e}function no(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var i=n._parentListeners;for(var o in i)t[b(o)]=i[o];return t}function ro(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var io=function(e){return e.tag||Ut(e)},oo=function(e){return"show"===e.name},ao={name:"transition",props:eo,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(io)).length){var r=this.mode,o=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return o;var a=to(o);if(!a)return o;if(this._leaving)return ro(e,o);var s="__transition-"+this._uid+"-";a.key=null==a.key?a.isComment?s+"comment":s+a.tag:i(a.key)?0===String(a.key).indexOf(s)?a.key:s+a.key:a.key;var c=(a.data||(a.data={})).transition=no(this),u=this._vnode,l=to(u);if(a.data.directives&&a.data.directives.some(oo)&&(a.data.show=!0),l&&l.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(a,l)&&!Ut(l)&&(!l.componentInstance||!l.componentInstance._vnode.isComment)){var f=l.data.transition=A({},c);if("out-in"===r)return this._leaving=!0,it(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),ro(e,o);if("in-out"===r){if(Ut(a))return u;var p,d=function(){p()};it(c,"afterEnter",d),it(c,"enterCancelled",d),it(f,"delayLeave",function(e){p=e})}}return o}}},so=A({tag:String,moveClass:String},eo);function co(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function uo(e){e.data.newPos=e.elm.getBoundingClientRect()}function lo(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,i=t.top-n.top;if(r||i){e.data.moved=!0;var o=e.elm.style;o.transform=o.WebkitTransform="translate("+r+"px,"+i+"px)",o.transitionDuration="0s"}}delete so.mode;var fo={Transition:ao,TransitionGroup:{props:so,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var i=Zt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,i(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,i=this.$slots.default||[],o=this.children=[],a=no(this),s=0;s-1?Gn[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Gn[e]=/HTMLUnknownElement/.test(t.toString())},A(wn.options.directives,Qi),A(wn.options.components,fo),wn.prototype.__patch__=z?zi:S,wn.prototype.$mount=function(e,t){return function(e,t,n){var r;return e.$el=t,e.$options.render||(e.$options.render=ve),Yt(e,"beforeMount"),r=function(){e._update(e._render(),n)},new fn(e,r,S,{before:function(){e._isMounted&&!e._isDestroyed&&Yt(e,"beforeUpdate")}},!0),n=!1,null==e.$vnode&&(e._isMounted=!0,Yt(e,"mounted")),e}(this,e=e&&z?Yn(e):void 0,t)},z&&setTimeout(function(){F.devtools&&ne&&ne.emit("init",wn)},0);var po=/\{\{((?:.|\r?\n)+?)\}\}/g,vo=/[-.*+?^${}()|[\]\/\\]/g,ho=g(function(e){var t=e[0].replace(vo,"\\$&"),n=e[1].replace(vo,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")});var mo={staticKeys:["staticClass"],transformNode:function(e,t){t.warn;var n=Fr(e,"class");n&&(e.staticClass=JSON.stringify(n));var r=Ir(e,"class",!1);r&&(e.classBinding=r)},genData:function(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}};var yo,go={staticKeys:["staticStyle"],transformNode:function(e,t){t.warn;var n=Fr(e,"style");n&&(e.staticStyle=JSON.stringify(ai(n)));var r=Ir(e,"style",!1);r&&(e.styleBinding=r)},genData:function(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}},_o=function(e){return(yo=yo||document.createElement("div")).innerHTML=e,yo.textContent},bo=p("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),$o=p("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),wo=p("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),Co=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,xo=/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,ko="[a-zA-Z_][\\-\\.0-9_a-zA-Z"+P.source+"]*",Ao="((?:"+ko+"\\:)?"+ko+")",Oo=new RegExp("^<"+Ao),So=/^\s*(\/?)>/,To=new RegExp("^<\\/"+Ao+"[^>]*>"),Eo=/^]+>/i,No=/^",""":'"',"&":"&"," ":"\n"," ":"\t","'":"'"},Io=/&(?:lt|gt|quot|amp|#39);/g,Fo=/&(?:lt|gt|quot|amp|#39|#10|#9);/g,Po=p("pre,textarea",!0),Ro=function(e,t){return e&&Po(e)&&"\n"===t[0]};function Ho(e,t){var n=t?Fo:Io;return e.replace(n,function(e){return Mo[e]})}var Bo,Uo,zo,Vo,Ko,Jo,qo,Wo,Zo=/^@|^v-on:/,Go=/^v-|^@|^:|^#/,Xo=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,Yo=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Qo=/^\(|\)$/g,ea=/^\[.*\]$/,ta=/:(.*)$/,na=/^:|^\.|^v-bind:/,ra=/\.[^.\]]+(?=[^\]]*$)/g,ia=/^v-slot(:|$)|^#/,oa=/[\r\n]/,aa=/\s+/g,sa=g(_o),ca="_empty_";function ua(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ma(t),rawAttrsMap:{},parent:n,children:[]}}function la(e,t){Bo=t.warn||Sr,Jo=t.isPreTag||T,qo=t.mustUseProp||T,Wo=t.getTagNamespace||T;t.isReservedTag;zo=Tr(t.modules,"transformNode"),Vo=Tr(t.modules,"preTransformNode"),Ko=Tr(t.modules,"postTransformNode"),Uo=t.delimiters;var n,r,i=[],o=!1!==t.preserveWhitespace,a=t.whitespace,s=!1,c=!1;function u(e){if(l(e),s||e.processed||(e=fa(e,t)),i.length||e===n||n.if&&(e.elseif||e.else)&&da(n,{exp:e.elseif,block:e}),r&&!e.forbidden)if(e.elseif||e.else)a=e,(u=function(e){var t=e.length;for(;t--;){if(1===e[t].type)return e[t];e.pop()}}(r.children))&&u.if&&da(u,{exp:a.elseif,block:a});else{if(e.slotScope){var o=e.slotTarget||'"default"';(r.scopedSlots||(r.scopedSlots={}))[o]=e}r.children.push(e),e.parent=r}var a,u;e.children=e.children.filter(function(e){return!e.slotScope}),l(e),e.pre&&(s=!1),Jo(e.tag)&&(c=!1);for(var f=0;f]*>)","i")),p=e.replace(f,function(e,n,r){return u=r.length,Do(l)||"noscript"===l||(n=n.replace(//g,"$1").replace(//g,"$1")),Ro(l,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""});c+=e.length-p.length,e=p,A(l,c-u,c)}else{var d=e.indexOf("<");if(0===d){if(No.test(e)){var v=e.indexOf("--\x3e");if(v>=0){t.shouldKeepComment&&t.comment(e.substring(4,v),c,c+v+3),C(v+3);continue}}if(jo.test(e)){var h=e.indexOf("]>");if(h>=0){C(h+2);continue}}var m=e.match(Eo);if(m){C(m[0].length);continue}var y=e.match(To);if(y){var g=c;C(y[0].length),A(y[1],g,c);continue}var _=x();if(_){k(_),Ro(_.tagName,e)&&C(1);continue}}var b=void 0,$=void 0,w=void 0;if(d>=0){for($=e.slice(d);!(To.test($)||Oo.test($)||No.test($)||jo.test($)||(w=$.indexOf("<",1))<0);)d+=w,$=e.slice(d);b=e.substring(0,d)}d<0&&(b=e),b&&C(b.length),t.chars&&b&&t.chars(b,c-b.length,c)}if(e===n){t.chars&&t.chars(e);break}}function C(t){c+=t,e=e.substring(t)}function x(){var t=e.match(Oo);if(t){var n,r,i={tagName:t[1],attrs:[],start:c};for(C(t[0].length);!(n=e.match(So))&&(r=e.match(xo)||e.match(Co));)r.start=c,C(r[0].length),r.end=c,i.attrs.push(r);if(n)return i.unarySlash=n[1],C(n[0].length),i.end=c,i}}function k(e){var n=e.tagName,c=e.unarySlash;o&&("p"===r&&wo(n)&&A(r),s(n)&&r===n&&A(n));for(var u=a(n)||!!c,l=e.attrs.length,f=new Array(l),p=0;p=0&&i[a].lowerCasedTag!==s;a--);else a=0;if(a>=0){for(var u=i.length-1;u>=a;u--)t.end&&t.end(i[u].tag,n,o);i.length=a,r=a&&i[a-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,o):"p"===s&&(t.start&&t.start(e,[],!1,n,o),t.end&&t.end(e,n,o))}A()}(e,{warn:Bo,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,canBeLeftOpenTag:t.canBeLeftOpenTag,shouldDecodeNewlines:t.shouldDecodeNewlines,shouldDecodeNewlinesForHref:t.shouldDecodeNewlinesForHref,shouldKeepComment:t.comments,outputSourceRange:t.outputSourceRange,start:function(e,o,a,l,f){var p=r&&r.ns||Wo(e);q&&"svg"===p&&(o=function(e){for(var t=[],n=0;nc&&(s.push(o=e.slice(c,i)),a.push(JSON.stringify(o)));var u=Ar(r[1].trim());a.push("_s("+u+")"),s.push({"@binding":u}),c=i+r[0].length}return c-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),Mr(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+Br(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+Br(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+Br(t,"$$c")+"}",null,!0)}(e,r,i);else if("input"===o&&"radio"===a)!function(e,t,n){var r=n&&n.number,i=Ir(e,"value")||"null";Er(e,"checked","_q("+t+","+(i=r?"_n("+i+")":i)+")"),Mr(e,"change",Br(t,i),null,!0)}(e,r,i);else if("input"===o||"textarea"===o)!function(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?Wr:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=Br(t,l);c&&(f="if($event.target.composing)return;"+f),Er(e,"value","("+t+")"),Mr(e,u,f,null,!0),(s||a)&&Mr(e,"blur","$forceUpdate()")}(e,r,i);else if(!F.isReservedTag(o))return Hr(e,r,i),!1;return!0},text:function(e,t){t.value&&Er(e,"textContent","_s("+t.value+")",t)},html:function(e,t){t.value&&Er(e,"innerHTML","_s("+t.value+")",t)}},isPreTag:function(e){return"pre"===e},isUnaryTag:bo,mustUseProp:jn,canBeLeftOpenTag:$o,isReservedTag:Wn,getTagNamespace:Zn,staticKeys:function(e){return e.reduce(function(e,t){return e.concat(t.staticKeys||[])},[]).join(",")}(ba)},xa=g(function(e){return p("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap"+(e?","+e:""))});function ka(e,t){e&&($a=xa(t.staticKeys||""),wa=t.isReservedTag||T,function e(t){t.static=function(e){if(2===e.type)return!1;if(3===e.type)return!0;return!(!e.pre&&(e.hasBindings||e.if||e.for||d(e.tag)||!wa(e.tag)||function(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1;if(e.for)return!0}return!1}(e)||!Object.keys(e).every($a)))}(t);if(1===t.type){if(!wa(t.tag)&&"slot"!==t.tag&&null==t.attrsMap["inline-template"])return;for(var n=0,r=t.children.length;n|^function(?:\s+[\w$]+)?\s*\(/,Oa=/\([^)]*?\);*$/,Sa=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ta={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},Ea={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]},Na=function(e){return"if("+e+")return null;"},ja={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Na("$event.target !== $event.currentTarget"),ctrl:Na("!$event.ctrlKey"),shift:Na("!$event.shiftKey"),alt:Na("!$event.altKey"),meta:Na("!$event.metaKey"),left:Na("'button' in $event && $event.button !== 0"),middle:Na("'button' in $event && $event.button !== 1"),right:Na("'button' in $event && $event.button !== 2")};function Da(e,t){var n=t?"nativeOn:":"on:",r="",i="";for(var o in e){var a=La(e[o]);e[o]&&e[o].dynamic?i+=o+","+a+",":r+='"'+o+'":'+a+","}return r="{"+r.slice(0,-1)+"}",i?n+"_d("+r+",["+i.slice(0,-1)+"])":n+r}function La(e){if(!e)return"function(){}";if(Array.isArray(e))return"["+e.map(function(e){return La(e)}).join(",")+"]";var t=Sa.test(e.value),n=Aa.test(e.value),r=Sa.test(e.value.replace(Oa,""));if(e.modifiers){var i="",o="",a=[];for(var s in e.modifiers)if(ja[s])o+=ja[s],Ta[s]&&a.push(s);else if("exact"===s){var c=e.modifiers;o+=Na(["ctrl","shift","alt","meta"].filter(function(e){return!c[e]}).map(function(e){return"$event."+e+"Key"}).join("||"))}else a.push(s);return a.length&&(i+=function(e){return"if(!$event.type.indexOf('key')&&"+e.map(Ma).join("&&")+")return null;"}(a)),o&&(i+=o),"function($event){"+i+(t?"return "+e.value+"($event)":n?"return ("+e.value+")($event)":r?"return "+e.value:e.value)+"}"}return t||n?e.value:"function($event){"+(r?"return "+e.value:e.value)+"}"}function Ma(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ta[e],r=Ea[e];return"_k($event.keyCode,"+JSON.stringify(e)+","+JSON.stringify(n)+",$event.key,"+JSON.stringify(r)+")"}var Ia={on:function(e,t){e.wrapListeners=function(e){return"_g("+e+","+t.value+")"}},bind:function(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+","+(t.modifiers&&t.modifiers.prop?"true":"false")+(t.modifiers&&t.modifiers.sync?",true":"")+")"}},cloak:S},Fa=function(e){this.options=e,this.warn=e.warn||Sr,this.transforms=Tr(e.modules,"transformCode"),this.dataGenFns=Tr(e.modules,"genData"),this.directives=A(A({},Ia),e.directives);var t=e.isReservedTag||T;this.maybeComponent=function(e){return!!e.component||!t(e.tag)},this.onceId=0,this.staticRenderFns=[],this.pre=!1};function Pa(e,t){var n=new Fa(t);return{render:"with(this){return "+(e?Ra(e,n):'_c("div")')+"}",staticRenderFns:n.staticRenderFns}}function Ra(e,t){if(e.parent&&(e.pre=e.pre||e.parent.pre),e.staticRoot&&!e.staticProcessed)return Ha(e,t);if(e.once&&!e.onceProcessed)return Ba(e,t);if(e.for&&!e.forProcessed)return za(e,t);if(e.if&&!e.ifProcessed)return Ua(e,t);if("template"!==e.tag||e.slotTarget||t.pre){if("slot"===e.tag)return function(e,t){var n=e.slotName||'"default"',r=qa(e,t),i="_t("+n+(r?","+r:""),o=e.attrs||e.dynamicAttrs?Ga((e.attrs||[]).concat(e.dynamicAttrs||[]).map(function(e){return{name:b(e.name),value:e.value,dynamic:e.dynamic}})):null,a=e.attrsMap["v-bind"];!o&&!a||r||(i+=",null");o&&(i+=","+o);a&&(i+=(o?"":",null")+","+a);return i+")"}(e,t);var n;if(e.component)n=function(e,t,n){var r=t.inlineTemplate?null:qa(t,n,!0);return"_c("+e+","+Va(t,n)+(r?","+r:"")+")"}(e.component,e,t);else{var r;(!e.plain||e.pre&&t.maybeComponent(e))&&(r=Va(e,t));var i=e.inlineTemplate?null:qa(e,t,!0);n="_c('"+e.tag+"'"+(r?","+r:"")+(i?","+i:"")+")"}for(var o=0;o>>0}(a):"")+")"}(e,e.scopedSlots,t)+","),e.model&&(n+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var o=function(e,t){var n=e.children[0];if(n&&1===n.type){var r=Pa(n,t.options);return"inlineTemplate:{render:function(){"+r.render+"},staticRenderFns:["+r.staticRenderFns.map(function(e){return"function(){"+e+"}"}).join(",")+"]}"}}(e,t);o&&(n+=o+",")}return n=n.replace(/,$/,"")+"}",e.dynamicAttrs&&(n="_b("+n+',"'+e.tag+'",'+Ga(e.dynamicAttrs)+")"),e.wrapData&&(n=e.wrapData(n)),e.wrapListeners&&(n=e.wrapListeners(n)),n}function Ka(e){return 1===e.type&&("slot"===e.tag||e.children.some(Ka))}function Ja(e,t){var n=e.attrsMap["slot-scope"];if(e.if&&!e.ifProcessed&&!n)return Ua(e,t,Ja,"null");if(e.for&&!e.forProcessed)return za(e,t,Ja);var r=e.slotScope===ca?"":String(e.slotScope),i="function("+r+"){return "+("template"===e.tag?e.if&&n?"("+e.if+")?"+(qa(e,t)||"undefined")+":undefined":qa(e,t)||"undefined":Ra(e,t))+"}",o=r?"":",proxy:true";return"{key:"+(e.slotTarget||'"default"')+",fn:"+i+o+"}"}function qa(e,t,n,r,i){var o=e.children;if(o.length){var a=o[0];if(1===o.length&&a.for&&"template"!==a.tag&&"slot"!==a.tag){var s=n?t.maybeComponent(a)?",1":",0":"";return""+(r||Ra)(a,t)+s}var c=n?function(e,t){for(var n=0,r=0;r':'
',ts.innerHTML.indexOf(" ")>0}var os=!!z&&is(!1),as=!!z&&is(!0),ss=g(function(e){var t=Yn(e);return t&&t.innerHTML}),cs=wn.prototype.$mount;return wn.prototype.$mount=function(e,t){if((e=e&&Yn(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=ss(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){var i=rs(r,{outputSourceRange:!1,shouldDecodeNewlines:os,shouldDecodeNewlinesForHref:as,delimiters:n.delimiters,comments:n.comments},this),o=i.render,a=i.staticRenderFns;n.render=o,n.staticRenderFns=a}}return cs.call(this,e,t)},wn.compile=rs,wn});; /*! * Datepicker for Bootstrap v1.8.0 (https://github.com/uxsolutions/bootstrap-datepicker) * * Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a,b){function c(){return new Date(Date.UTC.apply(Date,arguments))}function d(){var a=new Date;return c(a.getFullYear(),a.getMonth(),a.getDate())}function e(a,b){return a.getUTCFullYear()===b.getUTCFullYear()&&a.getUTCMonth()===b.getUTCMonth()&&a.getUTCDate()===b.getUTCDate()}function f(c,d){return function(){return d!==b&&a.fn.datepicker.deprecated(d),this[c].apply(this,arguments)}}function g(a){return a&&!isNaN(a.getTime())}function h(b,c){function d(a,b){return b.toLowerCase()}var e,f=a(b).data(),g={},h=new RegExp("^"+c.toLowerCase()+"([A-Z])");c=new RegExp("^"+c.toLowerCase());for(var i in f)c.test(i)&&(e=i.replace(h,d),g[e]=f[i]);return g}function i(b){var c={};if(q[b]||(b=b.split("-")[0],q[b])){var d=q[b];return a.each(p,function(a,b){b in d&&(c[b]=d[b])}),c}}var j=function(){var b={get:function(a){return this.slice(a)[0]},contains:function(a){for(var b=a&&a.valueOf(),c=0,d=this.length;c]/g)||[]).length<=0)return!0;var d=a(c);return d.length>0}catch(a){return!1}},_process_options:function(b){this._o=a.extend({},this._o,b);var e=this.o=a.extend({},this._o),f=e.language;q[f]||(f=f.split("-")[0],q[f]||(f=o.language)),e.language=f,e.startView=this._resolveViewName(e.startView),e.minViewMode=this._resolveViewName(e.minViewMode),e.maxViewMode=this._resolveViewName(e.maxViewMode),e.startView=Math.max(this.o.minViewMode,Math.min(this.o.maxViewMode,e.startView)),e.multidate!==!0&&(e.multidate=Number(e.multidate)||!1,e.multidate!==!1&&(e.multidate=Math.max(0,e.multidate))),e.multidateSeparator=String(e.multidateSeparator),e.weekStart%=7,e.weekEnd=(e.weekStart+6)%7;var g=r.parseFormat(e.format);e.startDate!==-(1/0)&&(e.startDate?e.startDate instanceof Date?e.startDate=this._local_to_utc(this._zero_time(e.startDate)):e.startDate=r.parseDate(e.startDate,g,e.language,e.assumeNearbyYear):e.startDate=-(1/0)),e.endDate!==1/0&&(e.endDate?e.endDate instanceof Date?e.endDate=this._local_to_utc(this._zero_time(e.endDate)):e.endDate=r.parseDate(e.endDate,g,e.language,e.assumeNearbyYear):e.endDate=1/0),e.daysOfWeekDisabled=this._resolveDaysOfWeek(e.daysOfWeekDisabled||[]),e.daysOfWeekHighlighted=this._resolveDaysOfWeek(e.daysOfWeekHighlighted||[]),e.datesDisabled=e.datesDisabled||[],a.isArray(e.datesDisabled)||(e.datesDisabled=e.datesDisabled.split(",")),e.datesDisabled=a.map(e.datesDisabled,function(a){return r.parseDate(a,g,e.language,e.assumeNearbyYear)});var h=String(e.orientation).toLowerCase().split(/\s+/g),i=e.orientation.toLowerCase();if(h=a.grep(h,function(a){return/^auto|left|right|top|bottom$/.test(a)}),e.orientation={x:"auto",y:"auto"},i&&"auto"!==i)if(1===h.length)switch(h[0]){case"top":case"bottom":e.orientation.y=h[0];break;case"left":case"right":e.orientation.x=h[0]}else i=a.grep(h,function(a){return/^left|right$/.test(a)}),e.orientation.x=i[0]||"auto",i=a.grep(h,function(a){return/^top|bottom$/.test(a)}),e.orientation.y=i[0]||"auto";else;if(e.defaultViewDate instanceof Date||"string"==typeof e.defaultViewDate)e.defaultViewDate=r.parseDate(e.defaultViewDate,g,e.language,e.assumeNearbyYear);else if(e.defaultViewDate){var j=e.defaultViewDate.year||(new Date).getFullYear(),k=e.defaultViewDate.month||0,l=e.defaultViewDate.day||1;e.defaultViewDate=c(j,k,l)}else e.defaultViewDate=d()},_events:[],_secondaryEvents:[],_applyEvents:function(a){for(var c,d,e,f=0;ff?(this.picker.addClass("datepicker-orient-right"),n+=m-b):this.o.rtl?this.picker.addClass("datepicker-orient-right"):this.picker.addClass("datepicker-orient-left");var p,q=this.o.orientation.y;if("auto"===q&&(p=-g+o-c,q=p<0?"bottom":"top"),this.picker.addClass("datepicker-orient-"+q),"top"===q?o-=c+parseInt(this.picker.css("padding-top")):o+=l,this.o.rtl){var r=f-(n+m);this.picker.css({top:o,right:r,zIndex:j})}else this.picker.css({top:o,left:n,zIndex:j});return this},_allow_update:!0,update:function(){if(!this._allow_update)return this;var b=this.dates.copy(),c=[],d=!1;return arguments.length?(a.each(arguments,a.proxy(function(a,b){b instanceof Date&&(b=this._local_to_utc(b)),c.push(b)},this)),d=!0):(c=this.isInput?this.element.val():this.element.data("date")||this.inputField.val(),c=c&&this.o.multidate?c.split(this.o.multidateSeparator):[c],delete this.element.data().date),c=a.map(c,a.proxy(function(a){return r.parseDate(a,this.o.format,this.o.language,this.o.assumeNearbyYear)},this)),c=a.grep(c,a.proxy(function(a){return!this.dateWithinRange(a)||!a},this),!0),this.dates.replace(c),this.o.updateViewDate&&(this.dates.length?this.viewDate=new Date(this.dates.get(-1)):this.viewDatethis.o.endDate?this.viewDate=new Date(this.o.endDate):this.viewDate=this.o.defaultViewDate),d?(this.setValue(),this.element.change()):this.dates.length&&String(b)!==String(this.dates)&&d&&(this._trigger("changeDate"),this.element.change()),!this.dates.length&&b.length&&(this._trigger("clearDate"),this.element.change()),this.fill(),this},fillDow:function(){if(this.o.showWeekDays){var b=this.o.weekStart,c="";for(this.o.calendarWeeks&&(c+=' ');b";c+="",this.picker.find(".datepicker-days thead").append(c)}},fillMonths:function(){for(var a,b=this._utc_to_local(this.viewDate),c="",d=0;d<12;d++)a=b&&b.getMonth()===d?" focused":"",c+=''+q[this.o.language].monthsShort[d]+"";this.picker.find(".datepicker-months td").html(c)},setRange:function(b){b&&b.length?this.range=a.map(b,function(a){return a.valueOf()}):delete this.range,this.fill()},getClassNames:function(b){var c=[],f=this.viewDate.getUTCFullYear(),g=this.viewDate.getUTCMonth(),h=d();return b.getUTCFullYear()f||b.getUTCFullYear()===f&&b.getUTCMonth()>g)&&c.push("new"),this.focusDate&&b.valueOf()===this.focusDate.valueOf()&&c.push("focused"),this.o.todayHighlight&&e(b,h)&&c.push("today"),this.dates.contains(b)!==-1&&c.push("active"),this.dateWithinRange(b)||c.push("disabled"),this.dateIsDisabled(b)&&c.push("disabled","disabled-date"),a.inArray(b.getUTCDay(),this.o.daysOfWeekHighlighted)!==-1&&c.push("highlighted"),this.range&&(b>this.range[0]&&bh)&&j.push("disabled"),t===r&&j.push("focused"),i!==a.noop&&(l=i(new Date(t,0,1)),l===b?l={}:"boolean"==typeof l?l={enabled:l}:"string"==typeof l&&(l={classes:l}),l.enabled===!1&&j.push("disabled"),l.classes&&(j=j.concat(l.classes.split(/\s+/))),l.tooltip&&(k=l.tooltip)),m+='"+t+"";o.find(".datepicker-switch").text(p+"-"+q),o.find("td").html(m)},fill:function(){var d,e,f=new Date(this.viewDate),g=f.getUTCFullYear(),h=f.getUTCMonth(),i=this.o.startDate!==-(1/0)?this.o.startDate.getUTCFullYear():-(1/0),j=this.o.startDate!==-(1/0)?this.o.startDate.getUTCMonth():-(1/0),k=this.o.endDate!==1/0?this.o.endDate.getUTCFullYear():1/0,l=this.o.endDate!==1/0?this.o.endDate.getUTCMonth():1/0,m=q[this.o.language].today||q.en.today||"",n=q[this.o.language].clear||q.en.clear||"",o=q[this.o.language].titleFormat||q.en.titleFormat;if(!isNaN(g)&&!isNaN(h)){this.picker.find(".datepicker-days .datepicker-switch").text(r.formatDate(f,o,this.o.language)),this.picker.find("tfoot .today").text(m).css("display",this.o.todayBtn===!0||"linked"===this.o.todayBtn?"table-cell":"none"),this.picker.find("tfoot .clear").text(n).css("display",this.o.clearBtn===!0?"table-cell":"none"),this.picker.find("thead .datepicker-title").text(this.o.title).css("display","string"==typeof this.o.title&&""!==this.o.title?"table-cell":"none"),this.updateNavArrows(),this.fillMonths();var p=c(g,h,0),s=p.getUTCDate();p.setUTCDate(s-(p.getUTCDay()-this.o.weekStart+7)%7);var t=new Date(p);p.getUTCFullYear()<100&&t.setUTCFullYear(p.getUTCFullYear()),t.setUTCDate(t.getUTCDate()+42),t=t.valueOf();for(var u,v,w=[];p.valueOf()"),this.o.calendarWeeks)){var x=new Date(+p+(this.o.weekStart-u-7)%7*864e5),y=new Date(Number(x)+(11-x.getUTCDay())%7*864e5),z=new Date(Number(z=c(y.getUTCFullYear(),0,1))+(11-z.getUTCDay())%7*864e5),A=(y-z)/864e5/7+1;w.push(''+A+"")}v=this.getClassNames(p),v.push("day");var B=p.getUTCDate();this.o.beforeShowDay!==a.noop&&(e=this.o.beforeShowDay(this._utc_to_local(p)),e===b?e={}:"boolean"==typeof e?e={enabled:e}:"string"==typeof e&&(e={classes:e}),e.enabled===!1&&v.push("disabled"),e.classes&&(v=v.concat(e.classes.split(/\s+/))),e.tooltip&&(d=e.tooltip),e.content&&(B=e.content)),v=a.isFunction(a.uniqueSort)?a.uniqueSort(v):a.unique(v),w.push(''+B+""),d=null,u===this.o.weekEnd&&w.push(""),p.setUTCDate(p.getUTCDate()+1)}this.picker.find(".datepicker-days tbody").html(w.join(""));var C=q[this.o.language].monthsTitle||q.en.monthsTitle||"Months",D=this.picker.find(".datepicker-months").find(".datepicker-switch").text(this.o.maxViewMode<2?C:g).end().find("tbody span").removeClass("active");if(a.each(this.dates,function(a,b){b.getUTCFullYear()===g&&D.eq(b.getUTCMonth()).addClass("active")}),(gk)&&D.addClass("disabled"),g===i&&D.slice(0,j).addClass("disabled"),g===k&&D.slice(l+1).addClass("disabled"),this.o.beforeShowMonth!==a.noop){var E=this;a.each(D,function(c,d){var e=new Date(g,c,1),f=E.o.beforeShowMonth(e);f===b?f={}:"boolean"==typeof f?f={enabled:f}:"string"==typeof f&&(f={classes:f}),f.enabled!==!1||a(d).hasClass("disabled")||a(d).addClass("disabled"),f.classes&&a(d).addClass(f.classes),f.tooltip&&a(d).prop("title",f.tooltip)})}this._fill_yearsView(".datepicker-years","year",10,g,i,k,this.o.beforeShowYear),this._fill_yearsView(".datepicker-decades","decade",100,g,i,k,this.o.beforeShowDecade),this._fill_yearsView(".datepicker-centuries","century",1e3,g,i,k,this.o.beforeShowCentury)}},updateNavArrows:function(){if(this._allow_update){var a,b,c=new Date(this.viewDate),d=c.getUTCFullYear(),e=c.getUTCMonth(),f=this.o.startDate!==-(1/0)?this.o.startDate.getUTCFullYear():-(1/0),g=this.o.startDate!==-(1/0)?this.o.startDate.getUTCMonth():-(1/0),h=this.o.endDate!==1/0?this.o.endDate.getUTCFullYear():1/0,i=this.o.endDate!==1/0?this.o.endDate.getUTCMonth():1/0,j=1;switch(this.viewMode){case 4:j*=10;case 3:j*=10;case 2:j*=10;case 1:a=Math.floor(d/j)*jh;break;case 0:a=d<=f&&e=h&&e>i}this.picker.find(".prev").toggleClass("disabled",a),this.picker.find(".next").toggleClass("disabled",b)}},click:function(b){b.preventDefault(),b.stopPropagation();var e,f,g,h;e=a(b.target),e.hasClass("datepicker-switch")&&this.viewMode!==this.o.maxViewMode&&this.setViewMode(this.viewMode+1),e.hasClass("today")&&!e.hasClass("day")&&(this.setViewMode(0),this._setDate(d(),"linked"===this.o.todayBtn?null:"view")),e.hasClass("clear")&&this.clearDates(),e.hasClass("disabled")||(e.hasClass("month")||e.hasClass("year")||e.hasClass("decade")||e.hasClass("century"))&&(this.viewDate.setUTCDate(1),f=1,1===this.viewMode?(h=e.parent().find("span").index(e),g=this.viewDate.getUTCFullYear(),this.viewDate.setUTCMonth(h)):(h=0,g=Number(e.text()),this.viewDate.setUTCFullYear(g)),this._trigger(r.viewModes[this.viewMode-1].e,this.viewDate),this.viewMode===this.o.minViewMode?this._setDate(c(g,h,f)):(this.setViewMode(this.viewMode-1),this.fill())),this.picker.is(":visible")&&this._focused_from&&this._focused_from.focus(),delete this._focused_from},dayCellClick:function(b){var c=a(b.currentTarget),d=c.data("date"),e=new Date(d);this.o.updateViewDate&&(e.getUTCFullYear()!==this.viewDate.getUTCFullYear()&&this._trigger("changeYear",this.viewDate),e.getUTCMonth()!==this.viewDate.getUTCMonth()&&this._trigger("changeMonth",this.viewDate)),this._setDate(e)},navArrowsClick:function(b){var c=a(b.currentTarget),d=c.hasClass("prev")?-1:1;0!==this.viewMode&&(d*=12*r.viewModes[this.viewMode].navStep),this.viewDate=this.moveMonth(this.viewDate,d),this._trigger(r.viewModes[this.viewMode].e,this.viewDate),this.fill()},_toggle_multidate:function(a){var b=this.dates.contains(a);if(a||this.dates.clear(),b!==-1?(this.o.multidate===!0||this.o.multidate>1||this.o.toggleActive)&&this.dates.remove(b):this.o.multidate===!1?(this.dates.clear(),this.dates.push(a)):this.dates.push(a),"number"==typeof this.o.multidate)for(;this.dates.length>this.o.multidate;)this.dates.remove(0)},_setDate:function(a,b){b&&"date"!==b||this._toggle_multidate(a&&new Date(a)),(!b&&this.o.updateViewDate||"view"===b)&&(this.viewDate=a&&new Date(a)),this.fill(),this.setValue(),b&&"view"===b||this._trigger("changeDate"),this.inputField.trigger("change"),!this.o.autoclose||b&&"date"!==b||this.hide()},moveDay:function(a,b){var c=new Date(a);return c.setUTCDate(a.getUTCDate()+b),c},moveWeek:function(a,b){return this.moveDay(a,7*b)},moveMonth:function(a,b){if(!g(a))return this.o.defaultViewDate;if(!b)return a;var c,d,e=new Date(a.valueOf()),f=e.getUTCDate(),h=e.getUTCMonth(),i=Math.abs(b);if(b=b>0?1:-1,1===i)d=b===-1?function(){return e.getUTCMonth()===h}:function(){return e.getUTCMonth()!==c},c=h+b,e.setUTCMonth(c),c=(c+12)%12;else{for(var j=0;j0},dateWithinRange:function(a){return a>=this.o.startDate&&a<=this.o.endDate},keydown:function(a){if(!this.picker.is(":visible"))return void(40!==a.keyCode&&27!==a.keyCode||(this.show(),a.stopPropagation()));var b,c,d=!1,e=this.focusDate||this.viewDate;switch(a.keyCode){case 27:this.focusDate?(this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.fill()):this.hide(),a.preventDefault(),a.stopPropagation();break;case 37:case 38:case 39:case 40:if(!this.o.keyboardNavigation||7===this.o.daysOfWeekDisabled.length)break;b=37===a.keyCode||38===a.keyCode?-1:1,0===this.viewMode?a.ctrlKey?(c=this.moveAvailableDate(e,b,"moveYear"),c&&this._trigger("changeYear",this.viewDate)):a.shiftKey?(c=this.moveAvailableDate(e,b,"moveMonth"),c&&this._trigger("changeMonth",this.viewDate)):37===a.keyCode||39===a.keyCode?c=this.moveAvailableDate(e,b,"moveDay"):this.weekOfDateIsDisabled(e)||(c=this.moveAvailableDate(e,b,"moveWeek")):1===this.viewMode?(38!==a.keyCode&&40!==a.keyCode||(b*=4),c=this.moveAvailableDate(e,b,"moveMonth")):2===this.viewMode&&(38!==a.keyCode&&40!==a.keyCode||(b*=4),c=this.moveAvailableDate(e,b,"moveYear")),c&&(this.focusDate=this.viewDate=c,this.setValue(),this.fill(),a.preventDefault());break;case 13:if(!this.o.forceParse)break;e=this.focusDate||this.dates.get(-1)||this.viewDate,this.o.keyboardNavigation&&(this._toggle_multidate(e),d=!0),this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.setValue(),this.fill(),this.picker.is(":visible")&&(a.preventDefault(),a.stopPropagation(),this.o.autoclose&&this.hide());break;case 9:this.focusDate=null,this.viewDate=this.dates.get(-1)||this.viewDate,this.fill(),this.hide()}d&&(this.dates.length?this._trigger("changeDate"):this._trigger("clearDate"),this.inputField.trigger("change"))},setViewMode:function(a){this.viewMode=a,this.picker.children("div").hide().filter(".datepicker-"+r.viewModes[this.viewMode].clsName).show(),this.updateNavArrows(),this._trigger("changeViewMode",new Date(this.viewDate))}};var l=function(b,c){a.data(b,"datepicker",this),this.element=a(b),this.inputs=a.map(c.inputs,function(a){return a.jquery?a[0]:a}),delete c.inputs,this.keepEmptyValues=c.keepEmptyValues,delete c.keepEmptyValues,n.call(a(this.inputs),c).on("changeDate",a.proxy(this.dateUpdated,this)),this.pickers=a.map(this.inputs,function(b){return a.data(b,"datepicker")}),this.updateDates()};l.prototype={updateDates:function(){this.dates=a.map(this.pickers,function(a){return a.getUTCDate()}),this.updateRanges()},updateRanges:function(){var b=a.map(this.dates,function(a){return a.valueOf()});a.each(this.pickers,function(a,c){c.setRange(b)})},clearDates:function(){a.each(this.pickers,function(a,b){b.clearDates()})},dateUpdated:function(c){if(!this.updating){this.updating=!0;var d=a.data(c.target,"datepicker");if(d!==b){var e=d.getUTCDate(),f=this.keepEmptyValues,g=a.inArray(c.target,this.inputs),h=g-1,i=g+1,j=this.inputs.length;if(g!==-1){if(a.each(this.pickers,function(a,b){b.getUTCDate()||b!==d&&f||b.setUTCDate(e)}),e=0&&ethis.dates[i])for(;ithis.dates[i];)this.pickers[i++].setUTCDate(e);this.updateDates(),delete this.updating}}}},destroy:function(){a.map(this.pickers,function(a){a.destroy()}),a(this.inputs).off("changeDate",this.dateUpdated),delete this.element.data().datepicker},remove:f("destroy","Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead")};var m=a.fn.datepicker,n=function(c){var d=Array.apply(null,arguments);d.shift();var e;if(this.each(function(){var b=a(this),f=b.data("datepicker"),g="object"==typeof c&&c;if(!f){var j=h(this,"date"),m=a.extend({},o,j,g),n=i(m.language),p=a.extend({},o,n,j,g);b.hasClass("input-daterange")||p.inputs?(a.extend(p,{inputs:p.inputs||b.find("input").toArray()}),f=new l(this,p)):f=new k(this,p),b.data("datepicker",f)}"string"==typeof c&&"function"==typeof f[c]&&(e=f[c].apply(f,d))}),e===b||e instanceof k||e instanceof l)return this;if(this.length>1)throw new Error("Using only allowed for the collection of a single element ("+c+" function)");return e};a.fn.datepicker=n;var o=a.fn.datepicker.defaults={assumeNearbyYear:!1,autoclose:!1,beforeShowDay:a.noop,beforeShowMonth:a.noop,beforeShowYear:a.noop,beforeShowDecade:a.noop,beforeShowCentury:a.noop,calendarWeeks:!1,clearBtn:!1,toggleActive:!1,daysOfWeekDisabled:[],daysOfWeekHighlighted:[],datesDisabled:[],endDate:1/0,forceParse:!0,format:"mm/dd/yyyy",keepEmptyValues:!1,keyboardNavigation:!0,language:"en",minViewMode:0,maxViewMode:4,multidate:!1,multidateSeparator:",",orientation:"auto",rtl:!1,startDate:-(1/0),startView:0,todayBtn:!1,todayHighlight:!1,updateViewDate:!0,weekStart:0,disableTouchKeyboard:!1,enableOnReadonly:!0,showOnFocus:!0,zIndexOffset:10,container:"body",immediateUpdates:!1,title:"",templates:{leftArrow:"«",rightArrow:"»"},showWeekDays:!0},p=a.fn.datepicker.locale_opts=["format","rtl","weekStart"];a.fn.datepicker.Constructor=k;var q=a.fn.datepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear",titleFormat:"MM yyyy"}},r={viewModes:[{names:["days","month"],clsName:"days",e:"changeMonth"},{names:["months","year"],clsName:"months",e:"changeYear",navStep:1},{names:["years","decade"],clsName:"years",e:"changeDecade",navStep:10},{names:["decades","century"],clsName:"decades",e:"changeCentury",navStep:100},{names:["centuries","millennium"],clsName:"centuries",e:"changeMillennium",navStep:1e3}],validParts:/dd?|DD?|mm?|MM?|yy(?:yy)?/g,nonpunctuation:/[^ -\/:-@\u5e74\u6708\u65e5\[-`{-~\t\n\r]+/g,parseFormat:function(a){if("function"==typeof a.toValue&&"function"==typeof a.toDisplay)return a;var b=a.replace(this.validParts,"\0").split("\0"),c=a.match(this.validParts);if(!b||!b.length||!c||0===c.length)throw new Error("Invalid date format.");return{separators:b,parts:c}},parseDate:function(c,e,f,g){function h(a,b){return b===!0&&(b=10),a<100&&(a+=2e3,a>(new Date).getFullYear()+b&&(a-=100)),a}function i(){var a=this.slice(0,j[n].length),b=j[n].slice(0,a.length);return a.toLowerCase()===b.toLowerCase()}if(!c)return b;if(c instanceof Date)return c;if("string"==typeof e&&(e=r.parseFormat(e)),e.toValue)return e.toValue(c,e,f);var j,l,m,n,o,p={d:"moveDay",m:"moveMonth",w:"moveWeek",y:"moveYear"},s={yesterday:"-1d",today:"+0d",tomorrow:"+1d"};if(c in s&&(c=s[c]),/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/i.test(c)){for(j=c.match(/([\-+]\d+)([dmwy])/gi),c=new Date,n=0;n'+o.templates.leftArrow+''+o.templates.rightArrow+"", contTemplate:'',footTemplate:''};r.template='
'+r.headTemplate+""+r.footTemplate+'
'+r.headTemplate+r.contTemplate+r.footTemplate+'
'+r.headTemplate+r.contTemplate+r.footTemplate+'
'+r.headTemplate+r.contTemplate+r.footTemplate+'
'+r.headTemplate+r.contTemplate+r.footTemplate+"
",a.fn.datepicker.DPGlobal=r,a.fn.datepicker.noConflict=function(){return a.fn.datepicker=m,this},a.fn.datepicker.version="1.8.0",a.fn.datepicker.deprecated=function(a){var b=window.console;b&&b.warn&&b.warn("DEPRECATED: "+a)},a(document).on("focus.datepicker.data-api click.datepicker.data-api",'[data-provide="datepicker"]',function(b){var c=a(this);c.data("datepicker")||(b.preventDefault(),n.call(c,"show"))}),a(function(){n.call(a('[data-provide="datepicker-inline"]'))})}); !function(a){a.fn.datepicker.dates["zh-TW"]={days:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],daysShort:["週日","週一","週二","週三","週四","週五","週六"],daysMin:["日","一","二","三","四","五","六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthsShort:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],today:"今天",format:"yyyy年mm月dd日",weekStart:1,clear:"清除"}}(jQuery); (function($, window, document){ var win = $(window), ww = win.innerWidth(), wh = win.innerHeight(), window_width = win.width(), ws = win.scrollTop(); var resizeWindow = function(){ ww = win.innerWidth(); wh = win.innerHeight(); } //isMobile 判斷 var isMobile = false; if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){ isMobile = true } //isTablet 判斷 var isTablet = false; if (navigator.userAgent.match(/Android/i)) { if (!navigator.userAgent.match(/Mobile/i)) { isTablet = true } } else if (navigator.userAgent.match(/BlackBerry|iPad|Opera Mini|IEMobile/i)) { isTablet = true } $(document).ready(function () { //-------------------------------------------------- date picker $('.date-start , .date-end').datepicker({ format: "yyyy/mm/dd", clearBtn: true, autoclose: true, toggleActive: true, defaultDate: new Date(), language: "zh-TW", startDate: new Date(), zIndexOffset: (function findHighestZIndex(elem) { var elems = document.getElementsByTagName(elem); var highest = 0; for (var i = 0; i < elems.length; i++) { var zindex = document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"); if ((zindex > highest) && (zindex != 'auto')) { highest = zindex; } } return highest + 1; })("header") }); // 結束日期的選擇變化 $('.date-end').datepicker().on('blur', function (e) { let startDate = $('.date-start').datepicker('getDate'); let endDate = $('.date-end').datepicker('getDate'); // 判斷如果結束日期小於起始日期,觸發 alert if (endDate < startDate) { alert("出發期間迄日不可小於出發期間起日"); $('.date-end').datepicker('setDate', startDate); // 重置結束日期爲起始日期 } }); //-------------------------------------------------- tooltip $('[data-toggle="tooltip"]').tooltip(); //-------------------------------------------------- filter menu function FilterMenu() { $(document).on('click', '.filter_header', function (event) { event.stopPropagation(); $('.accordion_all').toggleClass('active'); }); $(document).on('click', '.filter_close', function () { $(this).parent().removeClass('active'); }); } //--------------------------------------------------Web Speech API // 創建語音識別對象 const recognition = new webkitSpeechRecognition(); function startSpeechRecognition() { // 設置識別語言為中文 recognition.lang = "zh-TW"; // 設置連續識別模式 recognition.continuous = true; // 設置識別結果是否包含中間結果 recognition.interimResults = false; // 定義搜尋計時器變量 let searchTimer = null; // 監聽語音識別結果 recognition.onresult = function (event) { const result = event.results[event.resultIndex][0].transcript; $('.select-input input[name="kwd"], .select-input input[name="Filter.Keyword"]').val(result); // 取消搜尋計時器 clearTimeout(searchTimer); // 啟動新的搜尋計時器 searchTimer = setTimeout(() => { performSearch(result); }, 1000); }; // 監聽語音識別結束事件 recognition.onend = () => { // 停止語音識別 recognitionStop(); }; // 監聽語音識別錯誤事件 recognition.onerror = (event) => { console.error(`語音識別錯誤:${event.error}`); // 停止語音識別 recognitionStop(); }; // 定義搜索 function performSearch(keyword) { $('.search-btn').click(); } // 監聽使用者停止說話事件 recognition.onspeechend = () => { // 停止語音識別 recognitionStop(); // 取消搜尋計時器 if (searchTimer !== null) { clearTimeout(searchTimer); } // 啟動新的搜尋計時器 searchTimer = setTimeout(() => { performSearch($('.select-input input[name="kwd"], .select-input input[name="Filter.Keyword"]').val()); }, 500); }; // 設置語音識別超時,如果使用者沒有在6秒內說話,則停止語音識別 setTimeout(() => { recognitionStop(); }, 6000); // 啟動語音識別 recognitionStart(); } //控制Icon function setIconVisibility(micIconVisible, chartIconVisible) { $('.micIcon').css('visibility', micIconVisible ? 'visible' : 'hidden'); $('.chartIcon').css('visibility', chartIconVisible ? 'visible' : 'hidden'); } //控制語音輸入 function recognitionStart() { recognition.start(); setIconVisibility(false, true); } function recognitionStop() { recognition.stop(); setIconVisibility(true, false); } //--------------------------------------------------Web Speech API Modal $('.mic_icon .fa-microphone').on('click', function () { // 設定燈箱開啟時禁止滑動 $('body').css('overflow', 'hidden'); // 設定燈箱樣式 const dialog = $('
').css({ position: 'fixed', bottom: '-50%', // 設定起始位置 left: '0', width: '100%', height: '30%', background: '#fff', boxShadow: '0 0 10px rgba(0, 0, 0, 0.5)', borderTopLeftRadius: '10px', borderTopRightRadius: '10px' }); // 文字標題 const message = $('
請說
').css({ position: 'absolute', top: '20%', left: '50%', transform: 'translate(-50%, -50%)', fontSize: '20px', fontWeight: 'bold' }); dialog.append(message); // 文字內容1 const grayText1 = $('
請說出您要搜尋的關鍵字
').css({ color: '#777', fontSize: '15px', position: 'absolute', top: '35%', left: '50%', transform: 'translate(-50%, -50%)' }); dialog.append(grayText1); // 文字內容2 const grayText2 = $('
例如:東京、奧地利、巴里島...
').css({ color: '#777', fontSize: '15px', position: 'absolute', top: '55%', left: '50%', transform: 'translate(-50%, -50%)' }); dialog.append(grayText2); // 麥克風 Icon const micIcon = $('
').css({ position: 'absolute', top: '75%', left: '50%', transform: 'translate(-50%, -50%)' }); micIcon.find('i').css({ color: '#777', fontSize: '40px' }); dialog.append(micIcon); micIcon.on('click', startSpeechRecognition); // 波型 Icon for (let i = 1; i <= 4; i++) { const chartIcon = $('
').css({ position: 'absolute', top: '70%', left: (28 + i * 7) + '%', }); chartIcon.find('i').css({ color: '#777', fontSize: '33px', transform: i % 2 == 1 ? 'rotate(-90deg)' : 'rotate(90deg)' }); dialog.append(chartIcon); } // 設定半透明背景樣式 const body = $('body'); const bg = $('
'); bg.css({ 'position': 'fixed', 'top': '0', 'left': '0', 'width': '100%', 'height': '100%', 'background-color': 'rgba(0, 0, 0, 0.5)' }); const wrapper = $('
'); wrapper.css({ 'position': 'fixed', 'top': '0', 'left': '0', 'width': '100%', 'height': '100%', 'z-index': '9998' }); wrapper.append(bg); wrapper.append(dialog); body.append(wrapper); // 關閉按鈕 const closeButton = $(''); closeButton.css({ position: 'absolute', top: '10px', right: '10px', border: 'none', background: 'none', fontSize: '30px', cursor: 'pointer' }); dialog.append(closeButton); // 燈箱動畫 const dialogHeight = $(dialog).outerHeight(); $(dialog).css('bottom', '-' + dialogHeight + 'px'); setTimeout(function () { $(dialog).css({ 'transition': 'bottom 0.3s ease-out', 'bottom': '0' }); }, 10); const closeDialog = function () { recognition.stop(); $(dialog).css('bottom', '-' + dialogHeight + 'px'); setTimeout(function () { $(bg).remove(); $(dialog).remove(); $(wrapper).remove(); $('body').css('overflow', 'auto'); }, 300); } $(closeButton).on('click', closeDialog); $(bg).on('click', closeDialog); startSpeechRecognition(); }); //-------------------------------------------------- tabs $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { e.target // newly activated tab e.relatedTarget // previous active tab }) //-------------------------------------------------- set reload/scroll/resize //window on scroll use javascript //Reference: https://stackoverflow.com/a/10915048 //http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#event-type-scroll var windowWidth = $(window).width(); function onScrollEventHandler(ev) { } function onResizeEventHandler(ev) { if (windowWidth != $(window).width()) { location.reload(); return; } } function onLoadEventHandler(ev) { if (window_width <= 991) { FilterMenu(); } } var el = window; if (el.addEventListener) { el.addEventListener('scroll', onScrollEventHandler, false); el.addEventListener('resize', onResizeEventHandler, false); el.addEventListener('load', onLoadEventHandler, false); } else if (el.attachEvent) { el.attachEvent('onscroll', onScrollEventHandler); el.attachEvent('onresize', onScrollEventHandler); el.attachEvent('load', onLoadEventHandler); } }); })(jQuery, window, document);; $(document).ready(function () { BindEvent(); }); var _frmSearch = '#frmSearch'; var _frmCondition = '#frmCondition'; var _frm = '#frmSearch, #frmCondition'; function BindEvent() { InitialDisplayStyle(); checkQueryString(); updateCheckboxName(); $("#pgochksub_cd, #gochksub_cd").on("change", updateCheckboxName); //$(window).on('resize', function () { // $('.accordion_all').trigger("initSticky"); //}); //選取大分類後 更改小分類選項, 啟程地選項 $('[name="regm_cd"]', _frm).on('change', function () { var $regs = $('[name="regs_cd"]', _frm); var regmCd = $(this).val(); $.post($(this).data('url'), { regm_cd: regmCd }, function (data) { $regs.find('option:not(.empty)').remove(); for (var i = 0; i < data.length; i++) { console.log(data[i]); $regs.append($("").attr("value", data[i].Value).text(data[i].Text)); if (data[i].Selected) $regs.val(data[i].Value); } }, "json"); changePortSelect(); }); // 選取小分類後 更改啟程地選項 $('[name="regs_cd"]', _frm).on('change', function () { changePortSelect(); }); //搜尋列表的checkbox值 $('[id^="chk"]', _frmSearch).on('change', function () { var fieldName = $(this).prop('id').replace(/chk/g, ''); var $el = $('[name="' + fieldName + '"]'); if ($(this).prop('checked')) { $el.val($(this).val()); } else { $el.val(""); } }); //收藏 $('.icon-collect').click(function () { $(this).toggleClass('active'); }); // _ListConditions(左側篩選器) 啟用 sticky //$('.accordion_all') // .on('initSticky', function () { // if (typeof $(this).unstick === "function") // $(this).unstick(); // var resetTopSpacing = $(window).height() - $(this).outerHeight(); // $(this).sticky($.extend({ // topSpacing: (resetTopSpacing < 0) ? resetTopSpacing - 16 : 0 // }, $(this).data())); // }) // .trigger("initSticky"); $('.search-btn').on("click", function () { $("#selFrom").val("selU"); //觸發搜尋的來源 let $gochksub = $('#gochksub_cd', _frm); // 團體旅遊CheckBox let $pgochksub = $('#pgochksub_cd', _frm); // 團體自由行CheckBox if (!$gochksub.is(':checked') && !$pgochksub.is(':checked')) { alert("旅遊類型 [團體旅遊] / [團體自由行] 至少須選擇一項"); return false; } }); // 綁定 _ListConditions 元件 $(".search_con") // 當元件變化時觸發查詢 .on("change", "[data-rel='search-update']", function (event) { if ($(event.currentTarget).data('field') === "sub_cd") ChangeSubCd(); $(event.delegateTarget).trigger("send"); }) // 送出查詢 .on("send", function (event, page) { $("#selFrom").val("selL"); //觸發搜尋的來源 $('#countFg').val('True') $("html, body").animate({ scrollTop: $(this).offset().top || 0 }, "fast"); if ($(self).data("hold")) { clearTimeout($(self).data("hold")); $(self).removeData("hold"); } if ($(self).data("hold_go")) { $(self).data("hold_go").abort(); $(self).removeData("hold_go"); } $('.list_con .tab-content .alert', this).remove(); $('.list_con .tab-content', this).prepend($('')); var ori = this; var $range = $(".js-range-slider", ori); var url = $(_frmCondition).attr("action"); var queryStr = []; var otherObj = $(':not([data-rel="page_info"])', _frm).serializeJson(); for (var i in otherObj) { if (i) { var spt = (["prices","days"].includes(i)) ? "-" : ","; if (otherObj[i] instanceof Array) queryStr.push(i + "=" + encodeURIComponent(otherObj[i].join(spt))); else queryStr.push(i + "=" + encodeURIComponent(otherObj[i])); } } queryStr = queryStr.filter(function (v) { return !v.startsWith("page="); }) //不是點擊頁數都導向第一頁 if (page) queryStr.push("page="+page); else queryStr.push("page=1"); var queryUrl = [url, queryStr.filter(Boolean).join("&")].join("?"); $(self).data("hold", setTimeout(function () { $(self).data("hold_go", $.get(queryUrl, function (data, status, xhr) { // 不重整頁面下,更新 products/group/search 的 querystring const newSearchUrl = new URL(window.location); newSearchUrl.search = queryStr.filter(Boolean).join("&"); history.pushState({ path: newSearchUrl.href }, "", newSearchUrl); // 更新右側頁面內容 $(".list_con", ori).html(data); // 日期選擇改成拉bar,以下無效所以隱藏 //var daysObj = JSON.parse($('#daysData', _frm).val()); //$('.travel-days .customcheck').each(function () { // var text = $(this).text().trim(); // var day = daysObj.filter((element, index) => text.indexOf(element.Text) >= 0); // $(this).find('.badge').text(day.length > 0 ? day[0].Count : 0); //}) InitialDisplayStyle(); }) .fail(function () { console.log("error"); }) .always(function () { console.log("finished"); })); }, 1000 * 0.5)); }) // 初始化篩選條件 .on("init_list", function () { // 價格區間 var pricePrefix = $('#hdnPricePrefix', _frm).val() || "$ "; var ori = this, $range = $(".js-range-slider", ori), $inputFrom = $(".js-input-from", ori), $inputTo = $(".js-input-to", ori), instance, from = Number($range.data().from), to = Number($range.data().to), min = from, max = to; // $(".js-range-slider")在 rangeSlider.js 被設定了初始化,故先移除設定。 $range.data("ionRangeSlider").destroy(); $range.ionRangeSlider({ type: "double", min: min, max: max, from: from, to: to, //from_min: min_price, //to_max: max_price, prefix: pricePrefix, onStart: updateInputs, onChange: updateInputs, onFinish: function (data) { $(ori).trigger('send'); }, step: 1000, prettify_enabled: true, prettify_separator: ",", values_separator: " - ", force_edges: true, }); instance = $range.data("ionRangeSlider"); // 更新價錢區間數字 function updateInputs(data) { from = data.from; to = data.to; $inputFrom.val(from).keyup(resizeInput).each(resizeInput); $inputTo.val(to).keyup(resizeInput).each(resizeInput); } // 重設價錢區間 input 大小 function resizeInput() { $('.resize_input').each(function () { var size = $(this).val().length; $(this).attr('size', size === 0 ? 1 : size); }); } $inputFrom.on("input", function () { var val = $(this).prop("value"); // validate if (val < min) { val = min; } else if (val > to) { val = to; } instance.update({ from: val }); }); $inputTo.on("input", function () { var val = $(this).prop("value"); // validate if (val < from) { val = from; } else if (val > max) { val = max; } instance.update({ to: val }); }); // 設定參考文件 http://ionden.com/a/plugins/ion.rangeSlider/api.html // 天數 var $daysRange = $("#daysRrangeSlider", ori), $daysFrom = $("#daysFrom", ori), $daysTo = $("#daysTo", ori), $daysText = $("#daysText", ori); $daysRange.ionRangeSlider({ onFinish: function (data) { updateDaysInputs(data); $(ori).trigger('send'); } }); // 要等初始化(ionRangeSlider)完才有效 var daysInstance = $daysRange.data("ionRangeSlider"); // 更新天數input function updateDaysInputs(data) { var daysFrom = data.from; var daysTo = data.to; // 16+天 if (daysTo >= 16) { daysTo = 999; } $daysFrom.prop("value", daysFrom); $daysTo.prop("value", daysTo); updateDaysText(); } // 更新天數結果文字 function updateDaysText() { var daysFromVal = $daysFrom.val(); var daysToVal = $daysTo.val(); var numFrom = parseInt(daysFromVal); var numTo = parseInt(daysToVal); if (!numFrom && !numTo) { $daysText.html('不限'); return; } if (numFrom >= 16 && numTo >= 16) { $daysText.html('16+ 天'); return; } if (numTo > 16) { $daysText.html(daysFromVal + '~16+ 天'); return; } $daysText.html(daysFromVal + '~' + daysToVal + ' 天'); } // 初始化先更新一次 updateDaysText(); }) .trigger("init_list"); //航班詳細資料 var flightVue = new Vue({ el: '#flightModal', data: { flights: { } } }); $('#flightModal').on('show.bs.modal', function (event) { var grupCd = $(event.relatedTarget).data('id'); var sacctNo = $(event.relatedTarget).data('sacctno'); var subCd = $(event.relatedTarget).data('subcd'); var url = $('#getFlightUrl').val(); $.post(url, { id: grupCd, sacct_no: sacctNo, sub_cd: subCd }, function (data) { console.log(data); for (var flight of data.flights) { for (var item of flight.Segment) { if (item.AirportNm === '' && item.Route != null) item.AirportNm = item.Route.split('/')[0] || ""; } } flightVue.flights = data.flights; }); }); $('a[data-toggle="pill"]').on('shown.bs.tab', function (e) { $.cookie("group-search-display", $(e.target).attr('href'), { path: '/' }); }); } // 依照當前所選的大小分類,取得正確的啟程地(機場/港口)下拉選單 function changePortSelect() { var $port = $('[name="port_cd"]', _frm); var regmCd = $('[name="regm_cd"] :selected', _frm).val(); // 大分類代碼 var regsCd = $('[name="regs_cd"] :selected', _frm).val(); // 小分類代碼 var portCd = $('[name="port_cd"] :selected', _frm).val(); // 當前啟程地代碼(如果連動時,要刷新成"不限"的話,把這個改成空值就好) $.post($('#depPortUrl').val(), { regm_cd: regmCd, regs_cd: regsCd, port_cd: portCd}, function (data) { $port.find('option:not(.empty)').remove(); for (var i = 0; i < data.length; i++) { $port.append($("").attr("value", data[i].OptValue).text(data[i].OptText)); if (data[i].IsSelected) $port.val(data[i].OptValue); } }, "json"); } // 旅遊類型變更 (目前僅在團型列表時有作用) //function ChangeSubCd() { // var chkGo = $('#GoTrip', _frm).is(':checked'); // var chkPgo = $('#PgoTrip', _frm).is(':checked'); // var $subCd = $('#sub_cd', _frm); // if (chkGo == chkPgo) // $subCd.val(''); // else if (chkGo) // $subCd.val('GO'); // else if (chkPgo) // $subCd.val('PGO'); //} function InitialDisplayStyle() { if ($.cookie('group-search-display') !== undefined) { $('a[data-toggle="pill"][href="' + $.cookie('group-search-display') + '"]').tab('show'); } } function getPage(page) { $('#page', _frm).val(page) $(".search_con").trigger("send",[page]) } //判斷url是否有sub_cd的值 function checkQueryString() { const urlParams = new URLSearchParams(window.location.search); const urlSubCd = urlParams.get('sub_cd'); if (urlSubCd == null) { $('#pgochksub_cd', _frm).prop('checked', 'true'); $('#gochksub_cd', _frm).prop('checked', 'true'); } } //Checkbox添加name="sub_cd" function updateCheckboxName() { const pgochkChecked = $("#pgochksub_cd", _frm).prop("checked"); const gochkChecked = $("#gochksub_cd", _frm).prop("checked"); if (pgochkChecked && !gochkChecked) { $("#pgochk", _frm).attr("name", "sub_cd"); } else { $("#pgochk", _frm).removeAttr("name"); } if (!pgochkChecked && gochkChecked) { $("#gochk", _frm).attr("name", "sub_cd"); } else { $("#gochk", _frm).removeAttr("name"); } };