diff --git a/.gitignore b/.gitignore index 665aa21..3907b55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ components -build node_modules diff --git a/build/build.css b/build/build.css new file mode 100644 index 0000000..9abd98f --- /dev/null +++ b/build/build.css @@ -0,0 +1,4 @@ +.sidebar .affix select{ + width: 68%; +} + diff --git a/build/build.js b/build/build.js new file mode 100644 index 0000000..f2ee0c9 --- /dev/null +++ b/build/build.js @@ -0,0 +1,25628 @@ +/** + * Require the module at `name`. + * + * @param {String} name + * @return {Object} exports + * @api public + */ + +function require(name) { + var module = require.modules[name]; + if (!module) throw new Error('failed to require "' + name + '"'); + + if (!('exports' in module) && typeof module.definition === 'function') { + module.client = module.component = true; + module.definition.call(this, module.exports = {}, module); + delete module.definition; + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Register module at `name` with callback `definition`. + * + * @param {String} name + * @param {Function} definition + * @api private + */ + +require.register = function (name, definition) { + require.modules[name] = { + definition: definition + }; +}; + +/** + * Define a module's exports immediately with `exports`. + * + * @param {String} name + * @param {Generic} exports + * @api private + */ + +require.define = function (name, exports) { + require.modules[name] = { + exports: exports + }; +}; +require.register("moment~moment@2.7.0", function (exports, module) { +//! moment.js +//! version : 2.7.0 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com + +(function (undefined) { + + /************************************ + Constants + ************************************/ + + var moment, + VERSION = "2.7.0", + // the global-scope this is NOT the global object in Node.js + globalScope = typeof global !== 'undefined' ? global : this, + oldGlobalMoment, + round = Math.round, + i, + + YEAR = 0, + MONTH = 1, + DATE = 2, + HOUR = 3, + MINUTE = 4, + SECOND = 5, + MILLISECOND = 6, + + // internal storage for language config files + languages = {}, + + // moment internal properties + momentProperties = { + _isAMomentObject: null, + _i : null, + _f : null, + _l : null, + _strict : null, + _tzm : null, + _isUTC : null, + _offset : null, // optional. Combine with _isUTC + _pf : null, + _lang : null // optional + }, + + // check for nodeJS + hasModule = (typeof module !== 'undefined' && module.exports), + + // ASP.NET json date format regex + aspNetJsonRegex = /^\/?Date\((\-?\d+)/i, + aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/, + + // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html + // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere + isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/, + + // format tokens + formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g, + localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g, + + // parsing token regexes + parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99 + parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999 + parseTokenOneToFourDigits = /\d{1,4}/, // 0 - 9999 + parseTokenOneToSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999 + parseTokenDigits = /\d+/, // nonzero number of digits + parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic. + parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z + parseTokenT = /T/i, // T (ISO separator) + parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 + parseTokenOrdinal = /\d{1,2}/, + + //strict parsing regexes + parseTokenOneDigit = /\d/, // 0 - 9 + parseTokenTwoDigits = /\d\d/, // 00 - 99 + parseTokenThreeDigits = /\d{3}/, // 000 - 999 + parseTokenFourDigits = /\d{4}/, // 0000 - 9999 + parseTokenSixDigits = /[+-]?\d{6}/, // -999,999 - 999,999 + parseTokenSignedNumber = /[+-]?\d+/, // -inf - inf + + // iso 8601 regex + // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) + isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/, + + isoFormat = 'YYYY-MM-DDTHH:mm:ssZ', + + isoDates = [ + ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/], + ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/], + ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/], + ['GGGG-[W]WW', /\d{4}-W\d{2}/], + ['YYYY-DDD', /\d{4}-\d{3}/] + ], + + // iso time formats and regexes + isoTimes = [ + ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/], + ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/], + ['HH:mm', /(T| )\d\d:\d\d/], + ['HH', /(T| )\d\d/] + ], + + // timezone chunker "+10:00" > ["10", "00"] or "-1530" > ["-15", "30"] + parseTimezoneChunker = /([\+\-]|\d\d)/gi, + + // getter and setter names + proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'), + unitMillisecondFactors = { + 'Milliseconds' : 1, + 'Seconds' : 1e3, + 'Minutes' : 6e4, + 'Hours' : 36e5, + 'Days' : 864e5, + 'Months' : 2592e6, + 'Years' : 31536e6 + }, + + unitAliases = { + ms : 'millisecond', + s : 'second', + m : 'minute', + h : 'hour', + d : 'day', + D : 'date', + w : 'week', + W : 'isoWeek', + M : 'month', + Q : 'quarter', + y : 'year', + DDD : 'dayOfYear', + e : 'weekday', + E : 'isoWeekday', + gg: 'weekYear', + GG: 'isoWeekYear' + }, + + camelFunctions = { + dayofyear : 'dayOfYear', + isoweekday : 'isoWeekday', + isoweek : 'isoWeek', + weekyear : 'weekYear', + isoweekyear : 'isoWeekYear' + }, + + // format function strings + formatFunctions = {}, + + // default relative time thresholds + relativeTimeThresholds = { + s: 45, //seconds to minutes + m: 45, //minutes to hours + h: 22, //hours to days + dd: 25, //days to month (month == 1) + dm: 45, //days to months (months > 1) + dy: 345 //days to year + }, + + // tokens to ordinalize and pad + ordinalizeTokens = 'DDD w W M D d'.split(' '), + paddedTokens = 'M D H h m s w W'.split(' '), + + formatTokenFunctions = { + M : function () { + return this.month() + 1; + }, + MMM : function (format) { + return this.lang().monthsShort(this, format); + }, + MMMM : function (format) { + return this.lang().months(this, format); + }, + D : function () { + return this.date(); + }, + DDD : function () { + return this.dayOfYear(); + }, + d : function () { + return this.day(); + }, + dd : function (format) { + return this.lang().weekdaysMin(this, format); + }, + ddd : function (format) { + return this.lang().weekdaysShort(this, format); + }, + dddd : function (format) { + return this.lang().weekdays(this, format); + }, + w : function () { + return this.week(); + }, + W : function () { + return this.isoWeek(); + }, + YY : function () { + return leftZeroFill(this.year() % 100, 2); + }, + YYYY : function () { + return leftZeroFill(this.year(), 4); + }, + YYYYY : function () { + return leftZeroFill(this.year(), 5); + }, + YYYYYY : function () { + var y = this.year(), sign = y >= 0 ? '+' : '-'; + return sign + leftZeroFill(Math.abs(y), 6); + }, + gg : function () { + return leftZeroFill(this.weekYear() % 100, 2); + }, + gggg : function () { + return leftZeroFill(this.weekYear(), 4); + }, + ggggg : function () { + return leftZeroFill(this.weekYear(), 5); + }, + GG : function () { + return leftZeroFill(this.isoWeekYear() % 100, 2); + }, + GGGG : function () { + return leftZeroFill(this.isoWeekYear(), 4); + }, + GGGGG : function () { + return leftZeroFill(this.isoWeekYear(), 5); + }, + e : function () { + return this.weekday(); + }, + E : function () { + return this.isoWeekday(); + }, + a : function () { + return this.lang().meridiem(this.hours(), this.minutes(), true); + }, + A : function () { + return this.lang().meridiem(this.hours(), this.minutes(), false); + }, + H : function () { + return this.hours(); + }, + h : function () { + return this.hours() % 12 || 12; + }, + m : function () { + return this.minutes(); + }, + s : function () { + return this.seconds(); + }, + S : function () { + return toInt(this.milliseconds() / 100); + }, + SS : function () { + return leftZeroFill(toInt(this.milliseconds() / 10), 2); + }, + SSS : function () { + return leftZeroFill(this.milliseconds(), 3); + }, + SSSS : function () { + return leftZeroFill(this.milliseconds(), 3); + }, + Z : function () { + var a = -this.zone(), + b = "+"; + if (a < 0) { + a = -a; + b = "-"; + } + return b + leftZeroFill(toInt(a / 60), 2) + ":" + leftZeroFill(toInt(a) % 60, 2); + }, + ZZ : function () { + var a = -this.zone(), + b = "+"; + if (a < 0) { + a = -a; + b = "-"; + } + return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2); + }, + z : function () { + return this.zoneAbbr(); + }, + zz : function () { + return this.zoneName(); + }, + X : function () { + return this.unix(); + }, + Q : function () { + return this.quarter(); + } + }, + + lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; + + // Pick the first defined of two or three arguments. dfl comes from + // default. + function dfl(a, b, c) { + switch (arguments.length) { + case 2: return a != null ? a : b; + case 3: return a != null ? a : b != null ? b : c; + default: throw new Error("Implement me"); + } + } + + function defaultParsingFlags() { + // We need to deep clone this object, and es5 standard is not very + // helpful. + return { + empty : false, + unusedTokens : [], + unusedInput : [], + overflow : -2, + charsLeftOver : 0, + nullInput : false, + invalidMonth : null, + invalidFormat : false, + userInvalidated : false, + iso: false + }; + } + + function deprecate(msg, fn) { + var firstTime = true; + function printMsg() { + if (moment.suppressDeprecationWarnings === false && + typeof console !== 'undefined' && console.warn) { + console.warn("Deprecation warning: " + msg); + } + } + return extend(function () { + if (firstTime) { + printMsg(); + firstTime = false; + } + return fn.apply(this, arguments); + }, fn); + } + + function padToken(func, count) { + return function (a) { + return leftZeroFill(func.call(this, a), count); + }; + } + function ordinalizeToken(func, period) { + return function (a) { + return this.lang().ordinal(func.call(this, a), period); + }; + } + + while (ordinalizeTokens.length) { + i = ordinalizeTokens.pop(); + formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i); + } + while (paddedTokens.length) { + i = paddedTokens.pop(); + formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2); + } + formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3); + + + /************************************ + Constructors + ************************************/ + + function Language() { + + } + + // Moment prototype object + function Moment(config) { + checkOverflow(config); + extend(this, config); + } + + // Duration Constructor + function Duration(duration) { + var normalizedInput = normalizeObjectUnits(duration), + years = normalizedInput.year || 0, + quarters = normalizedInput.quarter || 0, + months = normalizedInput.month || 0, + weeks = normalizedInput.week || 0, + days = normalizedInput.day || 0, + hours = normalizedInput.hour || 0, + minutes = normalizedInput.minute || 0, + seconds = normalizedInput.second || 0, + milliseconds = normalizedInput.millisecond || 0; + + // representation for dateAddRemove + this._milliseconds = +milliseconds + + seconds * 1e3 + // 1000 + minutes * 6e4 + // 1000 * 60 + hours * 36e5; // 1000 * 60 * 60 + // Because of dateAddRemove treats 24 hours as different from a + // day when working around DST, we need to store them separately + this._days = +days + + weeks * 7; + // It is impossible translate months into days without knowing + // which months you are are talking about, so we have to store + // it separately. + this._months = +months + + quarters * 3 + + years * 12; + + this._data = {}; + + this._bubble(); + } + + /************************************ + Helpers + ************************************/ + + + function extend(a, b) { + for (var i in b) { + if (b.hasOwnProperty(i)) { + a[i] = b[i]; + } + } + + if (b.hasOwnProperty("toString")) { + a.toString = b.toString; + } + + if (b.hasOwnProperty("valueOf")) { + a.valueOf = b.valueOf; + } + + return a; + } + + function cloneMoment(m) { + var result = {}, i; + for (i in m) { + if (m.hasOwnProperty(i) && momentProperties.hasOwnProperty(i)) { + result[i] = m[i]; + } + } + + return result; + } + + function absRound(number) { + if (number < 0) { + return Math.ceil(number); + } else { + return Math.floor(number); + } + } + + // left zero fill a number + // see http://jsperf.com/left-zero-filling for performance comparison + function leftZeroFill(number, targetLength, forceSign) { + var output = '' + Math.abs(number), + sign = number >= 0; + + while (output.length < targetLength) { + output = '0' + output; + } + return (sign ? (forceSign ? '+' : '') : '-') + output; + } + + // helper function for _.addTime and _.subtractTime + function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) { + var milliseconds = duration._milliseconds, + days = duration._days, + months = duration._months; + updateOffset = updateOffset == null ? true : updateOffset; + + if (milliseconds) { + mom._d.setTime(+mom._d + milliseconds * isAdding); + } + if (days) { + rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding); + } + if (months) { + rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding); + } + if (updateOffset) { + moment.updateOffset(mom, days || months); + } + } + + // check if is an array + function isArray(input) { + return Object.prototype.toString.call(input) === '[object Array]'; + } + + function isDate(input) { + return Object.prototype.toString.call(input) === '[object Date]' || + input instanceof Date; + } + + // compare two arrays, return the number of differences + function compareArrays(array1, array2, dontConvert) { + var len = Math.min(array1.length, array2.length), + lengthDiff = Math.abs(array1.length - array2.length), + diffs = 0, + i; + for (i = 0; i < len; i++) { + if ((dontConvert && array1[i] !== array2[i]) || + (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { + diffs++; + } + } + return diffs + lengthDiff; + } + + function normalizeUnits(units) { + if (units) { + var lowered = units.toLowerCase().replace(/(.)s$/, '$1'); + units = unitAliases[units] || camelFunctions[lowered] || lowered; + } + return units; + } + + function normalizeObjectUnits(inputObject) { + var normalizedInput = {}, + normalizedProp, + prop; + + for (prop in inputObject) { + if (inputObject.hasOwnProperty(prop)) { + normalizedProp = normalizeUnits(prop); + if (normalizedProp) { + normalizedInput[normalizedProp] = inputObject[prop]; + } + } + } + + return normalizedInput; + } + + function makeList(field) { + var count, setter; + + if (field.indexOf('week') === 0) { + count = 7; + setter = 'day'; + } + else if (field.indexOf('month') === 0) { + count = 12; + setter = 'month'; + } + else { + return; + } + + moment[field] = function (format, index) { + var i, getter, + method = moment.fn._lang[field], + results = []; + + if (typeof format === 'number') { + index = format; + format = undefined; + } + + getter = function (i) { + var m = moment().utc().set(setter, i); + return method.call(moment.fn._lang, m, format || ''); + }; + + if (index != null) { + return getter(index); + } + else { + for (i = 0; i < count; i++) { + results.push(getter(i)); + } + return results; + } + }; + } + + function toInt(argumentForCoercion) { + var coercedNumber = +argumentForCoercion, + value = 0; + + if (coercedNumber !== 0 && isFinite(coercedNumber)) { + if (coercedNumber >= 0) { + value = Math.floor(coercedNumber); + } else { + value = Math.ceil(coercedNumber); + } + } + + return value; + } + + function daysInMonth(year, month) { + return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); + } + + function weeksInYear(year, dow, doy) { + return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week; + } + + function daysInYear(year) { + return isLeapYear(year) ? 366 : 365; + } + + function isLeapYear(year) { + return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + } + + function checkOverflow(m) { + var overflow; + if (m._a && m._pf.overflow === -2) { + overflow = + m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH : + m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE : + m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR : + m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE : + m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND : + m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND : + -1; + + if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { + overflow = DATE; + } + + m._pf.overflow = overflow; + } + } + + function isValid(m) { + if (m._isValid == null) { + m._isValid = !isNaN(m._d.getTime()) && + m._pf.overflow < 0 && + !m._pf.empty && + !m._pf.invalidMonth && + !m._pf.nullInput && + !m._pf.invalidFormat && + !m._pf.userInvalidated; + + if (m._strict) { + m._isValid = m._isValid && + m._pf.charsLeftOver === 0 && + m._pf.unusedTokens.length === 0; + } + } + return m._isValid; + } + + function normalizeLanguage(key) { + return key ? key.toLowerCase().replace('_', '-') : key; + } + + // Return a moment from input, that is local/utc/zone equivalent to model. + function makeAs(input, model) { + return model._isUTC ? moment(input).zone(model._offset || 0) : + moment(input).local(); + } + + /************************************ + Languages + ************************************/ + + + extend(Language.prototype, { + + set : function (config) { + var prop, i; + for (i in config) { + prop = config[i]; + if (typeof prop === 'function') { + this[i] = prop; + } else { + this['_' + i] = prop; + } + } + }, + + _months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), + months : function (m) { + return this._months[m.month()]; + }, + + _monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"), + monthsShort : function (m) { + return this._monthsShort[m.month()]; + }, + + monthsParse : function (monthName) { + var i, mom, regex; + + if (!this._monthsParse) { + this._monthsParse = []; + } + + for (i = 0; i < 12; i++) { + // make the regex if we don't have it already + if (!this._monthsParse[i]) { + mom = moment.utc([2000, i]); + regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); + this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if (this._monthsParse[i].test(monthName)) { + return i; + } + } + }, + + _weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), + weekdays : function (m) { + return this._weekdays[m.day()]; + }, + + _weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"), + weekdaysShort : function (m) { + return this._weekdaysShort[m.day()]; + }, + + _weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"), + weekdaysMin : function (m) { + return this._weekdaysMin[m.day()]; + }, + + weekdaysParse : function (weekdayName) { + var i, mom, regex; + + if (!this._weekdaysParse) { + this._weekdaysParse = []; + } + + for (i = 0; i < 7; i++) { + // make the regex if we don't have it already + if (!this._weekdaysParse[i]) { + mom = moment([2000, 1]).day(i); + regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); + this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if (this._weekdaysParse[i].test(weekdayName)) { + return i; + } + } + }, + + _longDateFormat : { + LT : "h:mm A", + L : "MM/DD/YYYY", + LL : "MMMM D YYYY", + LLL : "MMMM D YYYY LT", + LLLL : "dddd, MMMM D YYYY LT" + }, + longDateFormat : function (key) { + var output = this._longDateFormat[key]; + if (!output && this._longDateFormat[key.toUpperCase()]) { + output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) { + return val.slice(1); + }); + this._longDateFormat[key] = output; + } + return output; + }, + + isPM : function (input) { + // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays + // Using charAt should be more compatible. + return ((input + '').toLowerCase().charAt(0) === 'p'); + }, + + _meridiemParse : /[ap]\.?m?\.?/i, + meridiem : function (hours, minutes, isLower) { + if (hours > 11) { + return isLower ? 'pm' : 'PM'; + } else { + return isLower ? 'am' : 'AM'; + } + }, + + _calendar : { + sameDay : '[Today at] LT', + nextDay : '[Tomorrow at] LT', + nextWeek : 'dddd [at] LT', + lastDay : '[Yesterday at] LT', + lastWeek : '[Last] dddd [at] LT', + sameElse : 'L' + }, + calendar : function (key, mom) { + var output = this._calendar[key]; + return typeof output === 'function' ? output.apply(mom) : output; + }, + + _relativeTime : { + future : "in %s", + past : "%s ago", + s : "a few seconds", + m : "a minute", + mm : "%d minutes", + h : "an hour", + hh : "%d hours", + d : "a day", + dd : "%d days", + M : "a month", + MM : "%d months", + y : "a year", + yy : "%d years" + }, + relativeTime : function (number, withoutSuffix, string, isFuture) { + var output = this._relativeTime[string]; + return (typeof output === 'function') ? + output(number, withoutSuffix, string, isFuture) : + output.replace(/%d/i, number); + }, + pastFuture : function (diff, output) { + var format = this._relativeTime[diff > 0 ? 'future' : 'past']; + return typeof format === 'function' ? format(output) : format.replace(/%s/i, output); + }, + + ordinal : function (number) { + return this._ordinal.replace("%d", number); + }, + _ordinal : "%d", + + preparse : function (string) { + return string; + }, + + postformat : function (string) { + return string; + }, + + week : function (mom) { + return weekOfYear(mom, this._week.dow, this._week.doy).week; + }, + + _week : { + dow : 0, // Sunday is the first day of the week. + doy : 6 // The week that contains Jan 1st is the first week of the year. + }, + + _invalidDate: 'Invalid date', + invalidDate: function () { + return this._invalidDate; + } + }); + + // Loads a language definition into the `languages` cache. The function + // takes a key and optionally values. If not in the browser and no values + // are provided, it will load the language file module. As a convenience, + // this function also returns the language values. + function loadLang(key, values) { + values.abbr = key; + if (!languages[key]) { + languages[key] = new Language(); + } + languages[key].set(values); + return languages[key]; + } + + // Remove a language from the `languages` cache. Mostly useful in tests. + function unloadLang(key) { + delete languages[key]; + } + + // Determines which language definition to use and returns it. + // + // With no parameters, it will return the global language. If you + // pass in a language key, such as 'en', it will return the + // definition for 'en', so long as 'en' has already been loaded using + // moment.lang. + function getLangDefinition(key) { + var i = 0, j, lang, next, split, + get = function (k) { + if (!languages[k] && hasModule) { + try { + require('./lang/' + k); + } catch (e) { } + } + return languages[k]; + }; + + if (!key) { + return moment.fn._lang; + } + + if (!isArray(key)) { + //short-circuit everything else + lang = get(key); + if (lang) { + return lang; + } + key = [key]; + } + + //pick the language from the array + //try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each + //substring from most specific to least, but move to the next array item if it's a more specific variant than the current root + while (i < key.length) { + split = normalizeLanguage(key[i]).split('-'); + j = split.length; + next = normalizeLanguage(key[i + 1]); + next = next ? next.split('-') : null; + while (j > 0) { + lang = get(split.slice(0, j).join('-')); + if (lang) { + return lang; + } + if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { + //the next array item is better than a shallower substring of this one + break; + } + j--; + } + i++; + } + return moment.fn._lang; + } + + /************************************ + Formatting + ************************************/ + + + function removeFormattingTokens(input) { + if (input.match(/\[[\s\S]/)) { + return input.replace(/^\[|\]$/g, ""); + } + return input.replace(/\\/g, ""); + } + + function makeFormatFunction(format) { + var array = format.match(formattingTokens), i, length; + + for (i = 0, length = array.length; i < length; i++) { + if (formatTokenFunctions[array[i]]) { + array[i] = formatTokenFunctions[array[i]]; + } else { + array[i] = removeFormattingTokens(array[i]); + } + } + + return function (mom) { + var output = ""; + for (i = 0; i < length; i++) { + output += array[i] instanceof Function ? array[i].call(mom, format) : array[i]; + } + return output; + }; + } + + // format date using native date object + function formatMoment(m, format) { + + if (!m.isValid()) { + return m.lang().invalidDate(); + } + + format = expandFormat(format, m.lang()); + + if (!formatFunctions[format]) { + formatFunctions[format] = makeFormatFunction(format); + } + + return formatFunctions[format](m); + } + + function expandFormat(format, lang) { + var i = 5; + + function replaceLongDateFormatTokens(input) { + return lang.longDateFormat(input) || input; + } + + localFormattingTokens.lastIndex = 0; + while (i >= 0 && localFormattingTokens.test(format)) { + format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); + localFormattingTokens.lastIndex = 0; + i -= 1; + } + + return format; + } + + + /************************************ + Parsing + ************************************/ + + + // get the regex to find the next token + function getParseRegexForToken(token, config) { + var a, strict = config._strict; + switch (token) { + case 'Q': + return parseTokenOneDigit; + case 'DDDD': + return parseTokenThreeDigits; + case 'YYYY': + case 'GGGG': + case 'gggg': + return strict ? parseTokenFourDigits : parseTokenOneToFourDigits; + case 'Y': + case 'G': + case 'g': + return parseTokenSignedNumber; + case 'YYYYYY': + case 'YYYYY': + case 'GGGGG': + case 'ggggg': + return strict ? parseTokenSixDigits : parseTokenOneToSixDigits; + case 'S': + if (strict) { return parseTokenOneDigit; } + /* falls through */ + case 'SS': + if (strict) { return parseTokenTwoDigits; } + /* falls through */ + case 'SSS': + if (strict) { return parseTokenThreeDigits; } + /* falls through */ + case 'DDD': + return parseTokenOneToThreeDigits; + case 'MMM': + case 'MMMM': + case 'dd': + case 'ddd': + case 'dddd': + return parseTokenWord; + case 'a': + case 'A': + return getLangDefinition(config._l)._meridiemParse; + case 'X': + return parseTokenTimestampMs; + case 'Z': + case 'ZZ': + return parseTokenTimezone; + case 'T': + return parseTokenT; + case 'SSSS': + return parseTokenDigits; + case 'MM': + case 'DD': + case 'YY': + case 'GG': + case 'gg': + case 'HH': + case 'hh': + case 'mm': + case 'ss': + case 'ww': + case 'WW': + return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits; + case 'M': + case 'D': + case 'd': + case 'H': + case 'h': + case 'm': + case 's': + case 'w': + case 'W': + case 'e': + case 'E': + return parseTokenOneOrTwoDigits; + case 'Do': + return parseTokenOrdinal; + default : + a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i")); + return a; + } + } + + function timezoneMinutesFromString(string) { + string = string || ""; + var possibleTzMatches = (string.match(parseTokenTimezone) || []), + tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [], + parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0], + minutes = +(parts[1] * 60) + toInt(parts[2]); + + return parts[0] === '+' ? -minutes : minutes; + } + + // function to convert string input to date + function addTimeToArrayFromToken(token, input, config) { + var a, datePartArray = config._a; + + switch (token) { + // QUARTER + case 'Q': + if (input != null) { + datePartArray[MONTH] = (toInt(input) - 1) * 3; + } + break; + // MONTH + case 'M' : // fall through to MM + case 'MM' : + if (input != null) { + datePartArray[MONTH] = toInt(input) - 1; + } + break; + case 'MMM' : // fall through to MMMM + case 'MMMM' : + a = getLangDefinition(config._l).monthsParse(input); + // if we didn't find a month name, mark the date as invalid. + if (a != null) { + datePartArray[MONTH] = a; + } else { + config._pf.invalidMonth = input; + } + break; + // DAY OF MONTH + case 'D' : // fall through to DD + case 'DD' : + if (input != null) { + datePartArray[DATE] = toInt(input); + } + break; + case 'Do' : + if (input != null) { + datePartArray[DATE] = toInt(parseInt(input, 10)); + } + break; + // DAY OF YEAR + case 'DDD' : // fall through to DDDD + case 'DDDD' : + if (input != null) { + config._dayOfYear = toInt(input); + } + + break; + // YEAR + case 'YY' : + datePartArray[YEAR] = moment.parseTwoDigitYear(input); + break; + case 'YYYY' : + case 'YYYYY' : + case 'YYYYYY' : + datePartArray[YEAR] = toInt(input); + break; + // AM / PM + case 'a' : // fall through to A + case 'A' : + config._isPm = getLangDefinition(config._l).isPM(input); + break; + // 24 HOUR + case 'H' : // fall through to hh + case 'HH' : // fall through to hh + case 'h' : // fall through to hh + case 'hh' : + datePartArray[HOUR] = toInt(input); + break; + // MINUTE + case 'm' : // fall through to mm + case 'mm' : + datePartArray[MINUTE] = toInt(input); + break; + // SECOND + case 's' : // fall through to ss + case 'ss' : + datePartArray[SECOND] = toInt(input); + break; + // MILLISECOND + case 'S' : + case 'SS' : + case 'SSS' : + case 'SSSS' : + datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000); + break; + // UNIX TIMESTAMP WITH MS + case 'X': + config._d = new Date(parseFloat(input) * 1000); + break; + // TIMEZONE + case 'Z' : // fall through to ZZ + case 'ZZ' : + config._useUTC = true; + config._tzm = timezoneMinutesFromString(input); + break; + // WEEKDAY - human + case 'dd': + case 'ddd': + case 'dddd': + a = getLangDefinition(config._l).weekdaysParse(input); + // if we didn't get a weekday name, mark the date as invalid + if (a != null) { + config._w = config._w || {}; + config._w['d'] = a; + } else { + config._pf.invalidWeekday = input; + } + break; + // WEEK, WEEK DAY - numeric + case 'w': + case 'ww': + case 'W': + case 'WW': + case 'd': + case 'e': + case 'E': + token = token.substr(0, 1); + /* falls through */ + case 'gggg': + case 'GGGG': + case 'GGGGG': + token = token.substr(0, 2); + if (input) { + config._w = config._w || {}; + config._w[token] = toInt(input); + } + break; + case 'gg': + case 'GG': + config._w = config._w || {}; + config._w[token] = moment.parseTwoDigitYear(input); + } + } + + function dayOfYearFromWeekInfo(config) { + var w, weekYear, week, weekday, dow, doy, temp, lang; + + w = config._w; + if (w.GG != null || w.W != null || w.E != null) { + dow = 1; + doy = 4; + + // TODO: We need to take the current isoWeekYear, but that depends on + // how we interpret now (local, utc, fixed offset). So create + // a now version of current config (take local/utc/offset flags, and + // create now). + weekYear = dfl(w.GG, config._a[YEAR], weekOfYear(moment(), 1, 4).year); + week = dfl(w.W, 1); + weekday = dfl(w.E, 1); + } else { + lang = getLangDefinition(config._l); + dow = lang._week.dow; + doy = lang._week.doy; + + weekYear = dfl(w.gg, config._a[YEAR], weekOfYear(moment(), dow, doy).year); + week = dfl(w.w, 1); + + if (w.d != null) { + // weekday -- low day numbers are considered next week + weekday = w.d; + if (weekday < dow) { + ++week; + } + } else if (w.e != null) { + // local weekday -- counting starts from begining of week + weekday = w.e + dow; + } else { + // default to begining of week + weekday = dow; + } + } + temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow); + + config._a[YEAR] = temp.year; + config._dayOfYear = temp.dayOfYear; + } + + // convert an array to a date. + // the array should mirror the parameters below + // note: all values past the year are optional and will default to the lowest possible value. + // [year, month, day , hour, minute, second, millisecond] + function dateFromConfig(config) { + var i, date, input = [], currentDate, yearToUse; + + if (config._d) { + return; + } + + currentDate = currentDateArray(config); + + //compute day of the year from weeks and weekdays + if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { + dayOfYearFromWeekInfo(config); + } + + //if the day of the year is set, figure out what it is + if (config._dayOfYear) { + yearToUse = dfl(config._a[YEAR], currentDate[YEAR]); + + if (config._dayOfYear > daysInYear(yearToUse)) { + config._pf._overflowDayOfYear = true; + } + + date = makeUTCDate(yearToUse, 0, config._dayOfYear); + config._a[MONTH] = date.getUTCMonth(); + config._a[DATE] = date.getUTCDate(); + } + + // Default to current date. + // * if no year, month, day of month are given, default to today + // * if day of month is given, default month and year + // * if month is given, default only year + // * if year is given, don't default anything + for (i = 0; i < 3 && config._a[i] == null; ++i) { + config._a[i] = input[i] = currentDate[i]; + } + + // Zero out whatever was not defaulted, including time + for (; i < 7; i++) { + config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; + } + + config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input); + // Apply timezone offset from input. The actual zone can be changed + // with parseZone. + if (config._tzm != null) { + config._d.setUTCMinutes(config._d.getUTCMinutes() + config._tzm); + } + } + + function dateFromObject(config) { + var normalizedInput; + + if (config._d) { + return; + } + + normalizedInput = normalizeObjectUnits(config._i); + config._a = [ + normalizedInput.year, + normalizedInput.month, + normalizedInput.day, + normalizedInput.hour, + normalizedInput.minute, + normalizedInput.second, + normalizedInput.millisecond + ]; + + dateFromConfig(config); + } + + function currentDateArray(config) { + var now = new Date(); + if (config._useUTC) { + return [ + now.getUTCFullYear(), + now.getUTCMonth(), + now.getUTCDate() + ]; + } else { + return [now.getFullYear(), now.getMonth(), now.getDate()]; + } + } + + // date from string and format string + function makeDateFromStringAndFormat(config) { + + if (config._f === moment.ISO_8601) { + parseISO(config); + return; + } + + config._a = []; + config._pf.empty = true; + + // This array is used to make a Date, either with `new Date` or `Date.UTC` + var lang = getLangDefinition(config._l), + string = '' + config._i, + i, parsedInput, tokens, token, skipped, + stringLength = string.length, + totalParsedInputLength = 0; + + tokens = expandFormat(config._f, lang).match(formattingTokens) || []; + + for (i = 0; i < tokens.length; i++) { + token = tokens[i]; + parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; + if (parsedInput) { + skipped = string.substr(0, string.indexOf(parsedInput)); + if (skipped.length > 0) { + config._pf.unusedInput.push(skipped); + } + string = string.slice(string.indexOf(parsedInput) + parsedInput.length); + totalParsedInputLength += parsedInput.length; + } + // don't parse if it's not a known token + if (formatTokenFunctions[token]) { + if (parsedInput) { + config._pf.empty = false; + } + else { + config._pf.unusedTokens.push(token); + } + addTimeToArrayFromToken(token, parsedInput, config); + } + else if (config._strict && !parsedInput) { + config._pf.unusedTokens.push(token); + } + } + + // add remaining unparsed input length to the string + config._pf.charsLeftOver = stringLength - totalParsedInputLength; + if (string.length > 0) { + config._pf.unusedInput.push(string); + } + + // handle am pm + if (config._isPm && config._a[HOUR] < 12) { + config._a[HOUR] += 12; + } + // if is 12 am, change hours to 0 + if (config._isPm === false && config._a[HOUR] === 12) { + config._a[HOUR] = 0; + } + + dateFromConfig(config); + checkOverflow(config); + } + + function unescapeFormat(s) { + return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { + return p1 || p2 || p3 || p4; + }); + } + + // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript + function regexpEscape(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + } + + // date from string and array of format strings + function makeDateFromStringAndArray(config) { + var tempConfig, + bestMoment, + + scoreToBeat, + i, + currentScore; + + if (config._f.length === 0) { + config._pf.invalidFormat = true; + config._d = new Date(NaN); + return; + } + + for (i = 0; i < config._f.length; i++) { + currentScore = 0; + tempConfig = extend({}, config); + tempConfig._pf = defaultParsingFlags(); + tempConfig._f = config._f[i]; + makeDateFromStringAndFormat(tempConfig); + + if (!isValid(tempConfig)) { + continue; + } + + // if there is any input that was not parsed add a penalty for that format + currentScore += tempConfig._pf.charsLeftOver; + + //or tokens + currentScore += tempConfig._pf.unusedTokens.length * 10; + + tempConfig._pf.score = currentScore; + + if (scoreToBeat == null || currentScore < scoreToBeat) { + scoreToBeat = currentScore; + bestMoment = tempConfig; + } + } + + extend(config, bestMoment || tempConfig); + } + + // date from iso format + function parseISO(config) { + var i, l, + string = config._i, + match = isoRegex.exec(string); + + if (match) { + config._pf.iso = true; + for (i = 0, l = isoDates.length; i < l; i++) { + if (isoDates[i][1].exec(string)) { + // match[5] should be "T" or undefined + config._f = isoDates[i][0] + (match[6] || " "); + break; + } + } + for (i = 0, l = isoTimes.length; i < l; i++) { + if (isoTimes[i][1].exec(string)) { + config._f += isoTimes[i][0]; + break; + } + } + if (string.match(parseTokenTimezone)) { + config._f += "Z"; + } + makeDateFromStringAndFormat(config); + } else { + config._isValid = false; + } + } + + // date from iso format or fallback + function makeDateFromString(config) { + parseISO(config); + if (config._isValid === false) { + delete config._isValid; + moment.createFromInputFallback(config); + } + } + + function makeDateFromInput(config) { + var input = config._i, + matched = aspNetJsonRegex.exec(input); + + if (input === undefined) { + config._d = new Date(); + } else if (matched) { + config._d = new Date(+matched[1]); + } else if (typeof input === 'string') { + makeDateFromString(config); + } else if (isArray(input)) { + config._a = input.slice(0); + dateFromConfig(config); + } else if (isDate(input)) { + config._d = new Date(+input); + } else if (typeof(input) === 'object') { + dateFromObject(config); + } else if (typeof(input) === 'number') { + // from milliseconds + config._d = new Date(input); + } else { + moment.createFromInputFallback(config); + } + } + + function makeDate(y, m, d, h, M, s, ms) { + //can't just apply() to create a date: + //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply + var date = new Date(y, m, d, h, M, s, ms); + + //the date constructor doesn't accept years < 1970 + if (y < 1970) { + date.setFullYear(y); + } + return date; + } + + function makeUTCDate(y) { + var date = new Date(Date.UTC.apply(null, arguments)); + if (y < 1970) { + date.setUTCFullYear(y); + } + return date; + } + + function parseWeekday(input, language) { + if (typeof input === 'string') { + if (!isNaN(input)) { + input = parseInt(input, 10); + } + else { + input = language.weekdaysParse(input); + if (typeof input !== 'number') { + return null; + } + } + } + return input; + } + + /************************************ + Relative Time + ************************************/ + + + // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize + function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) { + return lang.relativeTime(number || 1, !!withoutSuffix, string, isFuture); + } + + function relativeTime(milliseconds, withoutSuffix, lang) { + var seconds = round(Math.abs(milliseconds) / 1000), + minutes = round(seconds / 60), + hours = round(minutes / 60), + days = round(hours / 24), + years = round(days / 365), + args = seconds < relativeTimeThresholds.s && ['s', seconds] || + minutes === 1 && ['m'] || + minutes < relativeTimeThresholds.m && ['mm', minutes] || + hours === 1 && ['h'] || + hours < relativeTimeThresholds.h && ['hh', hours] || + days === 1 && ['d'] || + days <= relativeTimeThresholds.dd && ['dd', days] || + days <= relativeTimeThresholds.dm && ['M'] || + days < relativeTimeThresholds.dy && ['MM', round(days / 30)] || + years === 1 && ['y'] || ['yy', years]; + args[2] = withoutSuffix; + args[3] = milliseconds > 0; + args[4] = lang; + return substituteTimeAgo.apply({}, args); + } + + + /************************************ + Week of Year + ************************************/ + + + // firstDayOfWeek 0 = sun, 6 = sat + // the day of the week that starts the week + // (usually sunday or monday) + // firstDayOfWeekOfYear 0 = sun, 6 = sat + // the first week is the week that contains the first + // of this day of the week + // (eg. ISO weeks use thursday (4)) + function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) { + var end = firstDayOfWeekOfYear - firstDayOfWeek, + daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(), + adjustedMoment; + + + if (daysToDayOfWeek > end) { + daysToDayOfWeek -= 7; + } + + if (daysToDayOfWeek < end - 7) { + daysToDayOfWeek += 7; + } + + adjustedMoment = moment(mom).add('d', daysToDayOfWeek); + return { + week: Math.ceil(adjustedMoment.dayOfYear() / 7), + year: adjustedMoment.year() + }; + } + + //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday + function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { + var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear; + + d = d === 0 ? 7 : d; + weekday = weekday != null ? weekday : firstDayOfWeek; + daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); + dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; + + return { + year: dayOfYear > 0 ? year : year - 1, + dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear + }; + } + + /************************************ + Top Level Functions + ************************************/ + + function makeMoment(config) { + var input = config._i, + format = config._f; + + if (input === null || (format === undefined && input === '')) { + return moment.invalid({nullInput: true}); + } + + if (typeof input === 'string') { + config._i = input = getLangDefinition().preparse(input); + } + + if (moment.isMoment(input)) { + config = cloneMoment(input); + + config._d = new Date(+input._d); + } else if (format) { + if (isArray(format)) { + makeDateFromStringAndArray(config); + } else { + makeDateFromStringAndFormat(config); + } + } else { + makeDateFromInput(config); + } + + return new Moment(config); + } + + moment = function (input, format, lang, strict) { + var c; + + if (typeof(lang) === "boolean") { + strict = lang; + lang = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._i = input; + c._f = format; + c._l = lang; + c._strict = strict; + c._isUTC = false; + c._pf = defaultParsingFlags(); + + return makeMoment(c); + }; + + moment.suppressDeprecationWarnings = false; + + moment.createFromInputFallback = deprecate( + "moment construction falls back to js Date. This is " + + "discouraged and will be removed in upcoming major " + + "release. Please refer to " + + "https://github.com/moment/moment/issues/1407 for more info.", + function (config) { + config._d = new Date(config._i); + }); + + // Pick a moment m from moments so that m[fn](other) is true for all + // other. This relies on the function fn to be transitive. + // + // moments should either be an array of moment objects or an array, whose + // first element is an array of moment objects. + function pickBy(fn, moments) { + var res, i; + if (moments.length === 1 && isArray(moments[0])) { + moments = moments[0]; + } + if (!moments.length) { + return moment(); + } + res = moments[0]; + for (i = 1; i < moments.length; ++i) { + if (moments[i][fn](res)) { + res = moments[i]; + } + } + return res; + } + + moment.min = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isBefore', args); + }; + + moment.max = function () { + var args = [].slice.call(arguments, 0); + + return pickBy('isAfter', args); + }; + + // creating with utc + moment.utc = function (input, format, lang, strict) { + var c; + + if (typeof(lang) === "boolean") { + strict = lang; + lang = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._useUTC = true; + c._isUTC = true; + c._l = lang; + c._i = input; + c._f = format; + c._strict = strict; + c._pf = defaultParsingFlags(); + + return makeMoment(c).utc(); + }; + + // creating with unix timestamp (in seconds) + moment.unix = function (input) { + return moment(input * 1000); + }; + + // duration + moment.duration = function (input, key) { + var duration = input, + // matching against regexp is expensive, do it on demand + match = null, + sign, + ret, + parseIso; + + if (moment.isDuration(input)) { + duration = { + ms: input._milliseconds, + d: input._days, + M: input._months + }; + } else if (typeof input === 'number') { + duration = {}; + if (key) { + duration[key] = input; + } else { + duration.milliseconds = input; + } + } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) { + sign = (match[1] === "-") ? -1 : 1; + duration = { + y: 0, + d: toInt(match[DATE]) * sign, + h: toInt(match[HOUR]) * sign, + m: toInt(match[MINUTE]) * sign, + s: toInt(match[SECOND]) * sign, + ms: toInt(match[MILLISECOND]) * sign + }; + } else if (!!(match = isoDurationRegex.exec(input))) { + sign = (match[1] === "-") ? -1 : 1; + parseIso = function (inp) { + // We'd normally use ~~inp for this, but unfortunately it also + // converts floats to ints. + // inp may be undefined, so careful calling replace on it. + var res = inp && parseFloat(inp.replace(',', '.')); + // apply sign while we're at it + return (isNaN(res) ? 0 : res) * sign; + }; + duration = { + y: parseIso(match[2]), + M: parseIso(match[3]), + d: parseIso(match[4]), + h: parseIso(match[5]), + m: parseIso(match[6]), + s: parseIso(match[7]), + w: parseIso(match[8]) + }; + } + + ret = new Duration(duration); + + if (moment.isDuration(input) && input.hasOwnProperty('_lang')) { + ret._lang = input._lang; + } + + return ret; + }; + + // version number + moment.version = VERSION; + + // default format + moment.defaultFormat = isoFormat; + + // constant that refers to the ISO standard + moment.ISO_8601 = function () {}; + + // Plugins that add properties should also add the key here (null value), + // so we can properly clone ourselves. + moment.momentProperties = momentProperties; + + // This function will be called whenever a moment is mutated. + // It is intended to keep the offset in sync with the timezone. + moment.updateOffset = function () {}; + + // This function allows you to set a threshold for relative time strings + moment.relativeTimeThreshold = function(threshold, limit) { + if (relativeTimeThresholds[threshold] === undefined) { + return false; + } + relativeTimeThresholds[threshold] = limit; + return true; + }; + + // This function will load languages and then set the global language. If + // no arguments are passed in, it will simply return the current global + // language key. + moment.lang = function (key, values) { + var r; + if (!key) { + return moment.fn._lang._abbr; + } + if (values) { + loadLang(normalizeLanguage(key), values); + } else if (values === null) { + unloadLang(key); + key = 'en'; + } else if (!languages[key]) { + getLangDefinition(key); + } + r = moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key); + return r._abbr; + }; + + // returns language data + moment.langData = function (key) { + if (key && key._lang && key._lang._abbr) { + key = key._lang._abbr; + } + return getLangDefinition(key); + }; + + // compare moment object + moment.isMoment = function (obj) { + return obj instanceof Moment || + (obj != null && obj.hasOwnProperty('_isAMomentObject')); + }; + + // for typechecking Duration objects + moment.isDuration = function (obj) { + return obj instanceof Duration; + }; + + for (i = lists.length - 1; i >= 0; --i) { + makeList(lists[i]); + } + + moment.normalizeUnits = function (units) { + return normalizeUnits(units); + }; + + moment.invalid = function (flags) { + var m = moment.utc(NaN); + if (flags != null) { + extend(m._pf, flags); + } + else { + m._pf.userInvalidated = true; + } + + return m; + }; + + moment.parseZone = function () { + return moment.apply(null, arguments).parseZone(); + }; + + moment.parseTwoDigitYear = function (input) { + return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); + }; + + /************************************ + Moment Prototype + ************************************/ + + + extend(moment.fn = Moment.prototype, { + + clone : function () { + return moment(this); + }, + + valueOf : function () { + return +this._d + ((this._offset || 0) * 60000); + }, + + unix : function () { + return Math.floor(+this / 1000); + }, + + toString : function () { + return this.clone().lang('en').format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ"); + }, + + toDate : function () { + return this._offset ? new Date(+this) : this._d; + }, + + toISOString : function () { + var m = moment(this).utc(); + if (0 < m.year() && m.year() <= 9999) { + return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } else { + return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } + }, + + toArray : function () { + var m = this; + return [ + m.year(), + m.month(), + m.date(), + m.hours(), + m.minutes(), + m.seconds(), + m.milliseconds() + ]; + }, + + isValid : function () { + return isValid(this); + }, + + isDSTShifted : function () { + + if (this._a) { + return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0; + } + + return false; + }, + + parsingFlags : function () { + return extend({}, this._pf); + }, + + invalidAt: function () { + return this._pf.overflow; + }, + + utc : function () { + return this.zone(0); + }, + + local : function () { + this.zone(0); + this._isUTC = false; + return this; + }, + + format : function (inputString) { + var output = formatMoment(this, inputString || moment.defaultFormat); + return this.lang().postformat(output); + }, + + add : function (input, val) { + var dur; + // switch args to support add('s', 1) and add(1, 's') + if (typeof input === 'string' && typeof val === 'string') { + dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input); + } else if (typeof input === 'string') { + dur = moment.duration(+val, input); + } else { + dur = moment.duration(input, val); + } + addOrSubtractDurationFromMoment(this, dur, 1); + return this; + }, + + subtract : function (input, val) { + var dur; + // switch args to support subtract('s', 1) and subtract(1, 's') + if (typeof input === 'string' && typeof val === 'string') { + dur = moment.duration(isNaN(+val) ? +input : +val, isNaN(+val) ? val : input); + } else if (typeof input === 'string') { + dur = moment.duration(+val, input); + } else { + dur = moment.duration(input, val); + } + addOrSubtractDurationFromMoment(this, dur, -1); + return this; + }, + + diff : function (input, units, asFloat) { + var that = makeAs(input, this), + zoneDiff = (this.zone() - that.zone()) * 6e4, + diff, output; + + units = normalizeUnits(units); + + if (units === 'year' || units === 'month') { + // average number of days in the months in the given dates + diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2 + // difference in months + output = ((this.year() - that.year()) * 12) + (this.month() - that.month()); + // adjust by taking difference in days, average number of days + // and dst in the given months. + output += ((this - moment(this).startOf('month')) - + (that - moment(that).startOf('month'))) / diff; + // same as above but with zones, to negate all dst + output -= ((this.zone() - moment(this).startOf('month').zone()) - + (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff; + if (units === 'year') { + output = output / 12; + } + } else { + diff = (this - that); + output = units === 'second' ? diff / 1e3 : // 1000 + units === 'minute' ? diff / 6e4 : // 1000 * 60 + units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60 + units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst + units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst + diff; + } + return asFloat ? output : absRound(output); + }, + + from : function (time, withoutSuffix) { + return moment.duration(this.diff(time)).lang(this.lang()._abbr).humanize(!withoutSuffix); + }, + + fromNow : function (withoutSuffix) { + return this.from(moment(), withoutSuffix); + }, + + calendar : function (time) { + // We want to compare the start of today, vs this. + // Getting start-of-today depends on whether we're zone'd or not. + var now = time || moment(), + sod = makeAs(now, this).startOf('day'), + diff = this.diff(sod, 'days', true), + format = diff < -6 ? 'sameElse' : + diff < -1 ? 'lastWeek' : + diff < 0 ? 'lastDay' : + diff < 1 ? 'sameDay' : + diff < 2 ? 'nextDay' : + diff < 7 ? 'nextWeek' : 'sameElse'; + return this.format(this.lang().calendar(format, this)); + }, + + isLeapYear : function () { + return isLeapYear(this.year()); + }, + + isDST : function () { + return (this.zone() < this.clone().month(0).zone() || + this.zone() < this.clone().month(5).zone()); + }, + + day : function (input) { + var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); + if (input != null) { + input = parseWeekday(input, this.lang()); + return this.add({ d : input - day }); + } else { + return day; + } + }, + + month : makeAccessor('Month', true), + + startOf: function (units) { + units = normalizeUnits(units); + // the following switch intentionally omits break keywords + // to utilize falling through the cases. + switch (units) { + case 'year': + this.month(0); + /* falls through */ + case 'quarter': + case 'month': + this.date(1); + /* falls through */ + case 'week': + case 'isoWeek': + case 'day': + this.hours(0); + /* falls through */ + case 'hour': + this.minutes(0); + /* falls through */ + case 'minute': + this.seconds(0); + /* falls through */ + case 'second': + this.milliseconds(0); + /* falls through */ + } + + // weeks are a special case + if (units === 'week') { + this.weekday(0); + } else if (units === 'isoWeek') { + this.isoWeekday(1); + } + + // quarters are also special + if (units === 'quarter') { + this.month(Math.floor(this.month() / 3) * 3); + } + + return this; + }, + + endOf: function (units) { + units = normalizeUnits(units); + return this.startOf(units).add((units === 'isoWeek' ? 'week' : units), 1).subtract('ms', 1); + }, + + isAfter: function (input, units) { + units = typeof units !== 'undefined' ? units : 'millisecond'; + return +this.clone().startOf(units) > +moment(input).startOf(units); + }, + + isBefore: function (input, units) { + units = typeof units !== 'undefined' ? units : 'millisecond'; + return +this.clone().startOf(units) < +moment(input).startOf(units); + }, + + isSame: function (input, units) { + units = units || 'ms'; + return +this.clone().startOf(units) === +makeAs(input, this).startOf(units); + }, + + min: deprecate( + "moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548", + function (other) { + other = moment.apply(null, arguments); + return other < this ? this : other; + } + ), + + max: deprecate( + "moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548", + function (other) { + other = moment.apply(null, arguments); + return other > this ? this : other; + } + ), + + // keepTime = true means only change the timezone, without affecting + // the local hour. So 5:31:26 +0300 --[zone(2, true)]--> 5:31:26 +0200 + // It is possible that 5:31:26 doesn't exist int zone +0200, so we + // adjust the time as needed, to be valid. + // + // Keeping the time actually adds/subtracts (one hour) + // from the actual represented time. That is why we call updateOffset + // a second time. In case it wants us to change the offset again + // _changeInProgress == true case, then we have to adjust, because + // there is no such time in the given timezone. + zone : function (input, keepTime) { + var offset = this._offset || 0; + if (input != null) { + if (typeof input === "string") { + input = timezoneMinutesFromString(input); + } + if (Math.abs(input) < 16) { + input = input * 60; + } + this._offset = input; + this._isUTC = true; + if (offset !== input) { + if (!keepTime || this._changeInProgress) { + addOrSubtractDurationFromMoment(this, + moment.duration(offset - input, 'm'), 1, false); + } else if (!this._changeInProgress) { + this._changeInProgress = true; + moment.updateOffset(this, true); + this._changeInProgress = null; + } + } + } else { + return this._isUTC ? offset : this._d.getTimezoneOffset(); + } + return this; + }, + + zoneAbbr : function () { + return this._isUTC ? "UTC" : ""; + }, + + zoneName : function () { + return this._isUTC ? "Coordinated Universal Time" : ""; + }, + + parseZone : function () { + if (this._tzm) { + this.zone(this._tzm); + } else if (typeof this._i === 'string') { + this.zone(this._i); + } + return this; + }, + + hasAlignedHourOffset : function (input) { + if (!input) { + input = 0; + } + else { + input = moment(input).zone(); + } + + return (this.zone() - input) % 60 === 0; + }, + + daysInMonth : function () { + return daysInMonth(this.year(), this.month()); + }, + + dayOfYear : function (input) { + var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1; + return input == null ? dayOfYear : this.add("d", (input - dayOfYear)); + }, + + quarter : function (input) { + return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); + }, + + weekYear : function (input) { + var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year; + return input == null ? year : this.add("y", (input - year)); + }, + + isoWeekYear : function (input) { + var year = weekOfYear(this, 1, 4).year; + return input == null ? year : this.add("y", (input - year)); + }, + + week : function (input) { + var week = this.lang().week(this); + return input == null ? week : this.add("d", (input - week) * 7); + }, + + isoWeek : function (input) { + var week = weekOfYear(this, 1, 4).week; + return input == null ? week : this.add("d", (input - week) * 7); + }, + + weekday : function (input) { + var weekday = (this.day() + 7 - this.lang()._week.dow) % 7; + return input == null ? weekday : this.add("d", input - weekday); + }, + + isoWeekday : function (input) { + // behaves the same as moment#day except + // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) + // as a setter, sunday should belong to the previous week. + return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7); + }, + + isoWeeksInYear : function () { + return weeksInYear(this.year(), 1, 4); + }, + + weeksInYear : function () { + var weekInfo = this._lang._week; + return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); + }, + + get : function (units) { + units = normalizeUnits(units); + return this[units](); + }, + + set : function (units, value) { + units = normalizeUnits(units); + if (typeof this[units] === 'function') { + this[units](value); + } + return this; + }, + + // If passed a language key, it will set the language for this + // instance. Otherwise, it will return the language configuration + // variables for this instance. + lang : function (key) { + if (key === undefined) { + return this._lang; + } else { + this._lang = getLangDefinition(key); + return this; + } + } + }); + + function rawMonthSetter(mom, value) { + var dayOfMonth; + + // TODO: Move this out of here! + if (typeof value === 'string') { + value = mom.lang().monthsParse(value); + // TODO: Another silent failure? + if (typeof value !== 'number') { + return mom; + } + } + + dayOfMonth = Math.min(mom.date(), + daysInMonth(mom.year(), value)); + mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); + return mom; + } + + function rawGetter(mom, unit) { + return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit](); + } + + function rawSetter(mom, unit, value) { + if (unit === 'Month') { + return rawMonthSetter(mom, value); + } else { + return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); + } + } + + function makeAccessor(unit, keepTime) { + return function (value) { + if (value != null) { + rawSetter(this, unit, value); + moment.updateOffset(this, keepTime); + return this; + } else { + return rawGetter(this, unit); + } + }; + } + + moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false); + moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false); + moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false); + // Setting the hour should keep the time, because the user explicitly + // specified which hour he wants. So trying to maintain the same hour (in + // a new timezone) makes sense. Adding/subtracting hours does not follow + // this rule. + moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true); + // moment.fn.month is defined separately + moment.fn.date = makeAccessor('Date', true); + moment.fn.dates = deprecate("dates accessor is deprecated. Use date instead.", makeAccessor('Date', true)); + moment.fn.year = makeAccessor('FullYear', true); + moment.fn.years = deprecate("years accessor is deprecated. Use year instead.", makeAccessor('FullYear', true)); + + // add plural methods + moment.fn.days = moment.fn.day; + moment.fn.months = moment.fn.month; + moment.fn.weeks = moment.fn.week; + moment.fn.isoWeeks = moment.fn.isoWeek; + moment.fn.quarters = moment.fn.quarter; + + // add aliased format methods + moment.fn.toJSON = moment.fn.toISOString; + + /************************************ + Duration Prototype + ************************************/ + + + extend(moment.duration.fn = Duration.prototype, { + + _bubble : function () { + var milliseconds = this._milliseconds, + days = this._days, + months = this._months, + data = this._data, + seconds, minutes, hours, years; + + // The following code bubbles up values, see the tests for + // examples of what that means. + data.milliseconds = milliseconds % 1000; + + seconds = absRound(milliseconds / 1000); + data.seconds = seconds % 60; + + minutes = absRound(seconds / 60); + data.minutes = minutes % 60; + + hours = absRound(minutes / 60); + data.hours = hours % 24; + + days += absRound(hours / 24); + data.days = days % 30; + + months += absRound(days / 30); + data.months = months % 12; + + years = absRound(months / 12); + data.years = years; + }, + + weeks : function () { + return absRound(this.days() / 7); + }, + + valueOf : function () { + return this._milliseconds + + this._days * 864e5 + + (this._months % 12) * 2592e6 + + toInt(this._months / 12) * 31536e6; + }, + + humanize : function (withSuffix) { + var difference = +this, + output = relativeTime(difference, !withSuffix, this.lang()); + + if (withSuffix) { + output = this.lang().pastFuture(difference, output); + } + + return this.lang().postformat(output); + }, + + add : function (input, val) { + // supports only 2.0-style add(1, 's') or add(moment) + var dur = moment.duration(input, val); + + this._milliseconds += dur._milliseconds; + this._days += dur._days; + this._months += dur._months; + + this._bubble(); + + return this; + }, + + subtract : function (input, val) { + var dur = moment.duration(input, val); + + this._milliseconds -= dur._milliseconds; + this._days -= dur._days; + this._months -= dur._months; + + this._bubble(); + + return this; + }, + + get : function (units) { + units = normalizeUnits(units); + return this[units.toLowerCase() + 's'](); + }, + + as : function (units) { + units = normalizeUnits(units); + return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's'](); + }, + + lang : moment.fn.lang, + + toIsoString : function () { + // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js + var years = Math.abs(this.years()), + months = Math.abs(this.months()), + days = Math.abs(this.days()), + hours = Math.abs(this.hours()), + minutes = Math.abs(this.minutes()), + seconds = Math.abs(this.seconds() + this.milliseconds() / 1000); + + if (!this.asSeconds()) { + // this is the same as C#'s (Noda) and python (isodate)... + // but not other JS (goog.date) + return 'P0D'; + } + + return (this.asSeconds() < 0 ? '-' : '') + + 'P' + + (years ? years + 'Y' : '') + + (months ? months + 'M' : '') + + (days ? days + 'D' : '') + + ((hours || minutes || seconds) ? 'T' : '') + + (hours ? hours + 'H' : '') + + (minutes ? minutes + 'M' : '') + + (seconds ? seconds + 'S' : ''); + } + }); + + function makeDurationGetter(name) { + moment.duration.fn[name] = function () { + return this._data[name]; + }; + } + + function makeDurationAsGetter(name, factor) { + moment.duration.fn['as' + name] = function () { + return +this / factor; + }; + } + + for (i in unitMillisecondFactors) { + if (unitMillisecondFactors.hasOwnProperty(i)) { + makeDurationAsGetter(i, unitMillisecondFactors[i]); + makeDurationGetter(i.toLowerCase()); + } + } + + makeDurationAsGetter('Weeks', 6048e5); + moment.duration.fn.asMonths = function () { + return (+this - this.years() * 31536e6) / 2592e6 + this.years() * 12; + }; + + + /************************************ + Default Lang + ************************************/ + + + // Set default language, other languages will inherit from English. + moment.lang('en', { + ordinal : function (number) { + var b = number % 10, + output = (toInt(number % 100 / 10) === 1) ? 'th' : + (b === 1) ? 'st' : + (b === 2) ? 'nd' : + (b === 3) ? 'rd' : 'th'; + return number + output; + } + }); + + /* EMBED_LANGUAGES */ + + /************************************ + Exposing Moment + ************************************/ + + function makeGlobal(shouldDeprecate) { + /*global ender:false */ + if (typeof ender !== 'undefined') { + return; + } + oldGlobalMoment = globalScope.moment; + if (shouldDeprecate) { + globalScope.moment = deprecate( + "Accessing Moment through the global scope is " + + "deprecated, and will be removed in an upcoming " + + "release.", + moment); + } else { + globalScope.moment = moment; + } + } + + // CommonJS module is defined + if (hasModule) { + module.exports = moment; + } else if (typeof define === "function" && define.amd) { + define("moment", function (require, exports, module) { + if (module.config && module.config() && module.config().noGlobal === true) { + // release the global variable + globalScope.moment = oldGlobalMoment; + } + + return moment; + }); + makeGlobal(true); + } else { + makeGlobal(); + } +}).call(this); + +}); + +require.register("yyx990803~vue@v0.10.5", function (exports, module) { +var config = require("yyx990803~vue@v0.10.5/src/config.js"), + ViewModel = require("yyx990803~vue@v0.10.5/src/viewmodel.js"), + utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + makeHash = utils.hash, + assetTypes = ['directive', 'filter', 'partial', 'effect', 'component'] + +// require these so Browserify can catch them +// so they can be used in Vue.require +require("yyx990803~vue@v0.10.5/src/observer.js") +require("yyx990803~vue@v0.10.5/src/transition.js") + +ViewModel.options = config.globalAssets = { + directives : require("yyx990803~vue@v0.10.5/src/directives/index.js"), + filters : require("yyx990803~vue@v0.10.5/src/filters.js"), + partials : makeHash(), + effects : makeHash(), + components : makeHash() +} + +/** + * Expose asset registration methods + */ +assetTypes.forEach(function (type) { + ViewModel[type] = function (id, value) { + var hash = this.options[type + 's'] + if (!hash) { + hash = this.options[type + 's'] = makeHash() + } + if (!value) return hash[id] + if (type === 'partial') { + value = utils.toFragment(value) + } else if (type === 'component') { + value = utils.toConstructor(value) + } else if (type === 'filter') { + utils.checkFilter(value) + } + hash[id] = value + return this + } +}) + +/** + * Set config options + */ +ViewModel.config = function (opts, val) { + if (typeof opts === 'string') { + if (val === undefined) { + return config[opts] + } else { + config[opts] = val + } + } else { + utils.extend(config, opts) + } + return this +} + +/** + * Expose an interface for plugins + */ +ViewModel.use = function (plugin) { + if (typeof plugin === 'string') { + try { + plugin = require(plugin) + } catch (e) { + utils.warn('Cannot find plugin: ' + plugin) + return + } + } + + // additional parameters + var args = [].slice.call(arguments, 1) + args.unshift(this) + + if (typeof plugin.install === 'function') { + plugin.install.apply(plugin, args) + } else { + plugin.apply(null, args) + } + return this +} + +/** + * Expose internal modules for plugins + */ +ViewModel.require = function (path) { + return require('./' + path) +} + +ViewModel.extend = extend +ViewModel.nextTick = utils.nextTick + +/** + * Expose the main ViewModel class + * and add extend method + */ +function extend (options) { + + var ParentVM = this + + // extend data options need to be copied + // on instantiation + if (options.data) { + options.defaultData = options.data + delete options.data + } + + // inherit options + // but only when the super class is not the native Vue. + if (ParentVM !== ViewModel) { + options = inheritOptions(options, ParentVM.options, true) + } + utils.processOptions(options) + + var ExtendedVM = function (opts, asParent) { + if (!asParent) { + opts = inheritOptions(opts, options, true) + } + ParentVM.call(this, opts, true) + } + + // inherit prototype props + var proto = ExtendedVM.prototype = Object.create(ParentVM.prototype) + utils.defProtected(proto, 'constructor', ExtendedVM) + + // allow extended VM to be further extended + ExtendedVM.extend = extend + ExtendedVM.super = ParentVM + ExtendedVM.options = options + + // allow extended VM to add its own assets + assetTypes.forEach(function (type) { + ExtendedVM[type] = ViewModel[type] + }) + + // allow extended VM to use plugins + ExtendedVM.use = ViewModel.use + ExtendedVM.require = ViewModel.require + + return ExtendedVM +} + +/** + * Inherit options + * + * For options such as `data`, `vms`, `directives`, 'partials', + * they should be further extended. However extending should only + * be done at top level. + * + * `proto` is an exception because it's handled directly on the + * prototype. + * + * `el` is an exception because it's not allowed as an + * extension option, but only as an instance option. + */ +function inheritOptions (child, parent, topLevel) { + child = child || {} + if (!parent) return child + for (var key in parent) { + if (key === 'el') continue + var val = child[key], + parentVal = parent[key] + if (topLevel && typeof val === 'function' && parentVal) { + // merge hook functions into an array + child[key] = [val] + if (Array.isArray(parentVal)) { + child[key] = child[key].concat(parentVal) + } else { + child[key].push(parentVal) + } + } else if ( + topLevel && + (utils.isTrueObject(val) || utils.isTrueObject(parentVal)) + && !(parentVal instanceof ViewModel) + ) { + // merge toplevel object options + child[key] = inheritOptions(val, parentVal) + } else if (val === undefined) { + // inherit if child doesn't override + child[key] = parentVal + } + } + return child +} + +module.exports = ViewModel +}); + +require.register("yyx990803~vue@v0.10.5/src/emitter.js", function (exports, module) { +var slice = [].slice + +function Emitter (ctx) { + this._ctx = ctx || this +} + +var EmitterProto = Emitter.prototype + +EmitterProto.on = function (event, fn) { + this._cbs = this._cbs || {} + ;(this._cbs[event] = this._cbs[event] || []) + .push(fn) + return this +} + +EmitterProto.once = function (event, fn) { + var self = this + this._cbs = this._cbs || {} + + function on () { + self.off(event, on) + fn.apply(this, arguments) + } + + on.fn = fn + this.on(event, on) + return this +} + +EmitterProto.off = function (event, fn) { + this._cbs = this._cbs || {} + + // all + if (!arguments.length) { + this._cbs = {} + return this + } + + // specific event + var callbacks = this._cbs[event] + if (!callbacks) return this + + // remove all handlers + if (arguments.length === 1) { + delete this._cbs[event] + return this + } + + // remove specific handler + var cb + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i] + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1) + break + } + } + return this +} + +/** + * The internal, faster emit with fixed amount of arguments + * using Function.call + */ +EmitterProto.emit = function (event, a, b, c) { + this._cbs = this._cbs || {} + var callbacks = this._cbs[event] + + if (callbacks) { + callbacks = callbacks.slice(0) + for (var i = 0, len = callbacks.length; i < len; i++) { + callbacks[i].call(this._ctx, a, b, c) + } + } + + return this +} + +/** + * The external emit using Function.apply + */ +EmitterProto.applyEmit = function (event) { + this._cbs = this._cbs || {} + var callbacks = this._cbs[event], args + + if (callbacks) { + callbacks = callbacks.slice(0) + args = slice.call(arguments, 1) + for (var i = 0, len = callbacks.length; i < len; i++) { + callbacks[i].apply(this._ctx, args) + } + } + + return this +} + +module.exports = Emitter +}); + +require.register("yyx990803~vue@v0.10.5/src/config.js", function (exports, module) { +var TextParser = require("yyx990803~vue@v0.10.5/src/text-parser.js") + +module.exports = { + prefix : 'v', + debug : false, + silent : false, + enterClass : 'v-enter', + leaveClass : 'v-leave', + interpolate : true +} + +Object.defineProperty(module.exports, 'delimiters', { + get: function () { + return TextParser.delimiters + }, + set: function (delimiters) { + TextParser.setDelimiters(delimiters) + } +}) +}); + +require.register("yyx990803~vue@v0.10.5/src/utils.js", function (exports, module) { +var config = require("yyx990803~vue@v0.10.5/src/config.js"), + toString = ({}).toString, + win = window, + console = win.console, + def = Object.defineProperty, + OBJECT = 'object', + THIS_RE = /[^\w]this[^\w]/, + BRACKET_RE_S = /\['([^']+)'\]/g, + BRACKET_RE_D = /\["([^"]+)"\]/g, + hasClassList = 'classList' in document.documentElement, + ViewModel // late def + +var defer = + win.requestAnimationFrame || + win.webkitRequestAnimationFrame || + win.setTimeout + +/** + * Normalize keypath with possible brackets into dot notations + */ +function normalizeKeypath (key) { + return key.indexOf('[') < 0 + ? key + : key.replace(BRACKET_RE_S, '.$1') + .replace(BRACKET_RE_D, '.$1') +} + +var utils = module.exports = { + + /** + * Convert a string template to a dom fragment + */ + toFragment: require("yyx990803~vue@v0.10.5/src/fragment.js"), + + /** + * get a value from an object keypath + */ + get: function (obj, key) { + /* jshint eqeqeq: false */ + key = normalizeKeypath(key) + if (key.indexOf('.') < 0) { + return obj[key] + } + var path = key.split('.'), + d = -1, l = path.length + while (++d < l && obj != null) { + obj = obj[path[d]] + } + return obj + }, + + /** + * set a value to an object keypath + */ + set: function (obj, key, val) { + /* jshint eqeqeq: false */ + key = normalizeKeypath(key) + if (key.indexOf('.') < 0) { + obj[key] = val + return + } + var path = key.split('.'), + d = -1, l = path.length - 1 + while (++d < l) { + if (obj[path[d]] == null) { + obj[path[d]] = {} + } + obj = obj[path[d]] + } + obj[path[d]] = val + }, + + /** + * return the base segment of a keypath + */ + baseKey: function (key) { + return key.indexOf('.') > 0 + ? key.split('.')[0] + : key + }, + + /** + * Create a prototype-less object + * which is a better hash/map + */ + hash: function () { + return Object.create(null) + }, + + /** + * get an attribute and remove it. + */ + attr: function (el, type) { + var attr = config.prefix + '-' + type, + val = el.getAttribute(attr) + if (val !== null) { + el.removeAttribute(attr) + } + return val + }, + + /** + * Define an ienumerable property + * This avoids it being included in JSON.stringify + * or for...in loops. + */ + defProtected: function (obj, key, val, enumerable, writable) { + def(obj, key, { + value : val, + enumerable : enumerable, + writable : writable, + configurable : true + }) + }, + + /** + * A less bullet-proof but more efficient type check + * than Object.prototype.toString + */ + isObject: function (obj) { + return typeof obj === OBJECT && obj && !Array.isArray(obj) + }, + + /** + * A more accurate but less efficient type check + */ + isTrueObject: function (obj) { + return toString.call(obj) === '[object Object]' + }, + + /** + * Most simple bind + * enough for the usecase and fast than native bind() + */ + bind: function (fn, ctx) { + return function (arg) { + return fn.call(ctx, arg) + } + }, + + /** + * Make sure null and undefined output empty string + */ + guard: function (value) { + /* jshint eqeqeq: false, eqnull: true */ + return value == null + ? '' + : (typeof value == 'object') + ? JSON.stringify(value) + : value + }, + + /** + * When setting value on the VM, parse possible numbers + */ + checkNumber: function (value) { + return (isNaN(value) || value === null || typeof value === 'boolean') + ? value + : Number(value) + }, + + /** + * simple extend + */ + extend: function (obj, ext) { + for (var key in ext) { + if (obj[key] !== ext[key]) { + obj[key] = ext[key] + } + } + return obj + }, + + /** + * filter an array with duplicates into uniques + */ + unique: function (arr) { + var hash = utils.hash(), + i = arr.length, + key, res = [] + while (i--) { + key = arr[i] + if (hash[key]) continue + hash[key] = 1 + res.push(key) + } + return res + }, + + /** + * Convert the object to a ViewModel constructor + * if it is not already one + */ + toConstructor: function (obj) { + ViewModel = ViewModel || require("yyx990803~vue@v0.10.5/src/viewmodel.js") + return utils.isObject(obj) + ? ViewModel.extend(obj) + : typeof obj === 'function' + ? obj + : null + }, + + /** + * Check if a filter function contains references to `this` + * If yes, mark it as a computed filter. + */ + checkFilter: function (filter) { + if (THIS_RE.test(filter.toString())) { + filter.computed = true + } + }, + + /** + * convert certain option values to the desired format. + */ + processOptions: function (options) { + var components = options.components, + partials = options.partials, + template = options.template, + filters = options.filters, + key + if (components) { + for (key in components) { + components[key] = utils.toConstructor(components[key]) + } + } + if (partials) { + for (key in partials) { + partials[key] = utils.toFragment(partials[key]) + } + } + if (filters) { + for (key in filters) { + utils.checkFilter(filters[key]) + } + } + if (template) { + options.template = utils.toFragment(template) + } + }, + + /** + * used to defer batch updates + */ + nextTick: function (cb) { + defer(cb, 0) + }, + + /** + * add class for IE9 + * uses classList if available + */ + addClass: function (el, cls) { + if (hasClassList) { + el.classList.add(cls) + } else { + var cur = ' ' + el.className + ' ' + if (cur.indexOf(' ' + cls + ' ') < 0) { + el.className = (cur + cls).trim() + } + } + }, + + /** + * remove class for IE9 + */ + removeClass: function (el, cls) { + if (hasClassList) { + el.classList.remove(cls) + } else { + var cur = ' ' + el.className + ' ', + tar = ' ' + cls + ' ' + while (cur.indexOf(tar) >= 0) { + cur = cur.replace(tar, ' ') + } + el.className = cur.trim() + } + }, + + /** + * Convert an object to Array + * used in v-repeat and array filters + */ + objectToArray: function (obj) { + var res = [], val, data + for (var key in obj) { + val = obj[key] + data = utils.isObject(val) + ? val + : { $value: val } + data.$key = key + res.push(data) + } + return res + } +} + +enableDebug() +function enableDebug () { + /** + * log for debugging + */ + utils.log = function (msg) { + if (config.debug && console) { + console.log(msg) + } + } + + /** + * warnings, traces by default + * can be suppressed by `silent` option. + */ + utils.warn = function (msg) { + if (!config.silent && console) { + console.warn(msg) + if (config.debug && console.trace) { + console.trace() + } + } + } +} +}); + +require.register("yyx990803~vue@v0.10.5/src/fragment.js", function (exports, module) { +// string -> DOM conversion +// wrappers originally from jQuery, scooped from component/domify +var map = { + legend : [1, '
', '
'], + tr : [2, '', '
'], + col : [2, '', '
'], + _default : [0, '', ''] +} + +map.td = +map.th = [3, '', '
'] + +map.option = +map.optgroup = [1, ''] + +map.thead = +map.tbody = +map.colgroup = +map.caption = +map.tfoot = [1, '', '
'] + +map.text = +map.circle = +map.ellipse = +map.line = +map.path = +map.polygon = +map.polyline = +map.rect = [1, '',''] + +var TAG_RE = /<([\w:]+)/ + +module.exports = function (template) { + + if (typeof template !== 'string') { + return template + } + + // template by ID + if (template.charAt(0) === '#') { + var templateNode = document.getElementById(template.slice(1)) + if (!templateNode) return + // if its a template tag and the browser supports it, + // its content is already a document fragment! + if (templateNode.tagName === 'TEMPLATE' && templateNode.content) { + return templateNode.content + } + template = templateNode.innerHTML + } + + var frag = document.createDocumentFragment(), + m = TAG_RE.exec(template) + // text only + if (!m) { + frag.appendChild(document.createTextNode(template)) + return frag + } + + var tag = m[1], + wrap = map[tag] || map._default, + depth = wrap[0], + prefix = wrap[1], + suffix = wrap[2], + node = document.createElement('div') + + node.innerHTML = prefix + template.trim() + suffix + while (depth--) node = node.lastChild + + // one element + if (node.firstChild === node.lastChild) { + frag.appendChild(node.firstChild) + return frag + } + + // multiple nodes, return a fragment + var child + /* jshint boss: true */ + while (child = node.firstChild) { + if (node.nodeType === 1) { + frag.appendChild(child) + } + } + return frag +} +}); + +require.register("yyx990803~vue@v0.10.5/src/compiler.js", function (exports, module) { +var Emitter = require("yyx990803~vue@v0.10.5/src/emitter.js"), + Observer = require("yyx990803~vue@v0.10.5/src/observer.js"), + config = require("yyx990803~vue@v0.10.5/src/config.js"), + utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + Binding = require("yyx990803~vue@v0.10.5/src/binding.js"), + Directive = require("yyx990803~vue@v0.10.5/src/directive.js"), + TextParser = require("yyx990803~vue@v0.10.5/src/text-parser.js"), + DepsParser = require("yyx990803~vue@v0.10.5/src/deps-parser.js"), + ExpParser = require("yyx990803~vue@v0.10.5/src/exp-parser.js"), + ViewModel, + + // cache methods + slice = [].slice, + extend = utils.extend, + hasOwn = ({}).hasOwnProperty, + def = Object.defineProperty, + + // hooks to register + hooks = [ + 'created', 'ready', + 'beforeDestroy', 'afterDestroy', + 'attached', 'detached' + ], + + // list of priority directives + // that needs to be checked in specific order + priorityDirectives = [ + 'if', + 'repeat', + 'view', + 'component' + ] + +/** + * The DOM compiler + * scans a DOM node and compile bindings for a ViewModel + */ +function Compiler (vm, options) { + + var compiler = this, + key, i + + // default state + compiler.init = true + compiler.destroyed = false + + // process and extend options + options = compiler.options = options || {} + utils.processOptions(options) + + // copy compiler options + extend(compiler, options.compilerOptions) + // repeat indicates this is a v-repeat instance + compiler.repeat = compiler.repeat || false + // expCache will be shared between v-repeat instances + compiler.expCache = compiler.expCache || {} + + // initialize element + var el = compiler.el = compiler.setupElement(options) + utils.log('\nnew VM instance: ' + el.tagName + '\n') + + // set other compiler properties + compiler.vm = el.vue_vm = vm + compiler.bindings = utils.hash() + compiler.dirs = [] + compiler.deferred = [] + compiler.computed = [] + compiler.children = [] + compiler.emitter = new Emitter(vm) + + // VM --------------------------------------------------------------------- + + // set VM properties + vm.$ = {} + vm.$el = el + vm.$options = options + vm.$compiler = compiler + vm.$event = null + + // set parent & root + var parentVM = options.parent + if (parentVM) { + compiler.parent = parentVM.$compiler + parentVM.$compiler.children.push(compiler) + vm.$parent = parentVM + // inherit lazy option + if (!('lazy' in options)) { + options.lazy = compiler.parent.options.lazy + } + } + vm.$root = getRoot(compiler).vm + + // DATA ------------------------------------------------------------------- + + // setup observer + // this is necesarry for all hooks and data observation events + compiler.setupObserver() + + // create bindings for computed properties + if (options.methods) { + for (key in options.methods) { + compiler.createBinding(key) + } + } + + // create bindings for methods + if (options.computed) { + for (key in options.computed) { + compiler.createBinding(key) + } + } + + // initialize data + var data = compiler.data = options.data || {}, + defaultData = options.defaultData + if (defaultData) { + for (key in defaultData) { + if (!hasOwn.call(data, key)) { + data[key] = defaultData[key] + } + } + } + + // copy paramAttributes + var params = options.paramAttributes + if (params) { + i = params.length + while (i--) { + data[params[i]] = utils.checkNumber( + compiler.eval( + el.getAttribute(params[i]) + ) + ) + } + } + + // copy data properties to vm + // so user can access them in the created hook + extend(vm, data) + vm.$data = data + + // beforeCompile hook + compiler.execHook('created') + + // the user might have swapped the data ... + data = compiler.data = vm.$data + + // user might also set some properties on the vm + // in which case we should copy back to $data + var vmProp + for (key in vm) { + vmProp = vm[key] + if ( + key.charAt(0) !== '$' && + data[key] !== vmProp && + typeof vmProp !== 'function' + ) { + data[key] = vmProp + } + } + + // now we can observe the data. + // this will convert data properties to getter/setters + // and emit the first batch of set events, which will + // in turn create the corresponding bindings. + compiler.observeData(data) + + // COMPILE ---------------------------------------------------------------- + + // before compiling, resolve content insertion points + if (options.template) { + this.resolveContent() + } + + // now parse the DOM and bind directives. + // During this stage, we will also create bindings for + // encountered keypaths that don't have a binding yet. + compiler.compile(el, true) + + // Any directive that creates child VMs are deferred + // so that when they are compiled, all bindings on the + // parent VM have been created. + i = compiler.deferred.length + while (i--) { + compiler.bindDirective(compiler.deferred[i]) + } + compiler.deferred = null + + // extract dependencies for computed properties. + // this will evaluated all collected computed bindings + // and collect get events that are emitted. + if (this.computed.length) { + DepsParser.parse(this.computed) + } + + // done! + compiler.init = false + + // post compile / ready hook + compiler.execHook('ready') +} + +var CompilerProto = Compiler.prototype + +/** + * Initialize the VM/Compiler's element. + * Fill it in with the template if necessary. + */ +CompilerProto.setupElement = function (options) { + // create the node first + var el = typeof options.el === 'string' + ? document.querySelector(options.el) + : options.el || document.createElement(options.tagName || 'div') + + var template = options.template, + child, replacer, i, attr, attrs + + if (template) { + // collect anything already in there + if (el.hasChildNodes()) { + this.rawContent = document.createElement('div') + /* jshint boss: true */ + while (child = el.firstChild) { + this.rawContent.appendChild(child) + } + } + // replace option: use the first node in + // the template directly + if (options.replace && template.firstChild === template.lastChild) { + replacer = template.firstChild.cloneNode(true) + if (el.parentNode) { + el.parentNode.insertBefore(replacer, el) + el.parentNode.removeChild(el) + } + // copy over attributes + if (el.hasAttributes()) { + i = el.attributes.length + while (i--) { + attr = el.attributes[i] + replacer.setAttribute(attr.name, attr.value) + } + } + // replace + el = replacer + } else { + el.appendChild(template.cloneNode(true)) + } + + } + + // apply element options + if (options.id) el.id = options.id + if (options.className) el.className = options.className + attrs = options.attributes + if (attrs) { + for (attr in attrs) { + el.setAttribute(attr, attrs[attr]) + } + } + + return el +} + +/** + * Deal with insertion points + * per the Web Components spec + */ +CompilerProto.resolveContent = function () { + + var outlets = slice.call(this.el.getElementsByTagName('content')), + raw = this.rawContent, + outlet, select, i, j, main + + i = outlets.length + if (i) { + // first pass, collect corresponding content + // for each outlet. + while (i--) { + outlet = outlets[i] + if (raw) { + select = outlet.getAttribute('select') + if (select) { // select content + outlet.content = + slice.call(raw.querySelectorAll(select)) + } else { // default content + main = outlet + } + } else { // fallback content + outlet.content = + slice.call(outlet.childNodes) + } + } + // second pass, actually insert the contents + for (i = 0, j = outlets.length; i < j; i++) { + outlet = outlets[i] + if (outlet === main) continue + insert(outlet, outlet.content) + } + // finally insert the main content + if (raw && main) { + insert(main, slice.call(raw.childNodes)) + } + } + + function insert (outlet, contents) { + var parent = outlet.parentNode, + i = 0, j = contents.length + for (; i < j; i++) { + parent.insertBefore(contents[i], outlet) + } + parent.removeChild(outlet) + } + + this.rawContent = null +} + +/** + * Setup observer. + * The observer listens for get/set/mutate events on all VM + * values/objects and trigger corresponding binding updates. + * It also listens for lifecycle hooks. + */ +CompilerProto.setupObserver = function () { + + var compiler = this, + bindings = compiler.bindings, + options = compiler.options, + observer = compiler.observer = new Emitter(compiler.vm) + + // a hash to hold event proxies for each root level key + // so they can be referenced and removed later + observer.proxies = {} + + // add own listeners which trigger binding updates + observer + .on('get', onGet) + .on('set', onSet) + .on('mutate', onSet) + + // register hooks + var i = hooks.length, j, hook, fns + while (i--) { + hook = hooks[i] + fns = options[hook] + if (Array.isArray(fns)) { + j = fns.length + // since hooks were merged with child at head, + // we loop reversely. + while (j--) { + registerHook(hook, fns[j]) + } + } else if (fns) { + registerHook(hook, fns) + } + } + + // broadcast attached/detached hooks + observer + .on('hook:attached', function () { + broadcast(1) + }) + .on('hook:detached', function () { + broadcast(0) + }) + + function onGet (key) { + check(key) + DepsParser.catcher.emit('get', bindings[key]) + } + + function onSet (key, val, mutation) { + observer.emit('change:' + key, val, mutation) + check(key) + bindings[key].update(val) + } + + function registerHook (hook, fn) { + observer.on('hook:' + hook, function () { + fn.call(compiler.vm) + }) + } + + function broadcast (event) { + var children = compiler.children + if (children) { + var child, i = children.length + while (i--) { + child = children[i] + if (child.el.parentNode) { + event = 'hook:' + (event ? 'attached' : 'detached') + child.observer.emit(event) + child.emitter.emit(event) + } + } + } + } + + function check (key) { + if (!bindings[key]) { + compiler.createBinding(key) + } + } +} + +CompilerProto.observeData = function (data) { + + var compiler = this, + observer = compiler.observer + + // recursively observe nested properties + Observer.observe(data, '', observer) + + // also create binding for top level $data + // so it can be used in templates too + var $dataBinding = compiler.bindings['$data'] = new Binding(compiler, '$data') + $dataBinding.update(data) + + // allow $data to be swapped + def(compiler.vm, '$data', { + get: function () { + compiler.observer.emit('get', '$data') + return compiler.data + }, + set: function (newData) { + var oldData = compiler.data + Observer.unobserve(oldData, '', observer) + compiler.data = newData + Observer.copyPaths(newData, oldData) + Observer.observe(newData, '', observer) + update() + } + }) + + // emit $data change on all changes + observer + .on('set', onSet) + .on('mutate', onSet) + + function onSet (key) { + if (key !== '$data') update() + } + + function update () { + $dataBinding.update(compiler.data) + observer.emit('change:$data', compiler.data) + } +} + +/** + * Compile a DOM node (recursive) + */ +CompilerProto.compile = function (node, root) { + var nodeType = node.nodeType + if (nodeType === 1 && node.tagName !== 'SCRIPT') { // a normal node + this.compileElement(node, root) + } else if (nodeType === 3 && config.interpolate) { + this.compileTextNode(node) + } +} + +/** + * Check for a priority directive + * If it is present and valid, return true to skip the rest + */ +CompilerProto.checkPriorityDir = function (dirname, node, root) { + var expression, directive, Ctor + if ( + dirname === 'component' && + root !== true && + (Ctor = this.resolveComponent(node, undefined, true)) + ) { + directive = this.parseDirective(dirname, '', node) + directive.Ctor = Ctor + } else { + expression = utils.attr(node, dirname) + directive = expression && this.parseDirective(dirname, expression, node) + } + if (directive) { + if (root === true) { + utils.warn( + 'Directive v-' + dirname + ' cannot be used on an already instantiated ' + + 'VM\'s root node. Use it from the parent\'s template instead.' + ) + return + } + this.deferred.push(directive) + return true + } +} + +/** + * Compile normal directives on a node + */ +CompilerProto.compileElement = function (node, root) { + + // textarea is pretty annoying + // because its value creates childNodes which + // we don't want to compile. + if (node.tagName === 'TEXTAREA' && node.value) { + node.value = this.eval(node.value) + } + + // only compile if this element has attributes + // or its tagName contains a hyphen (which means it could + // potentially be a custom element) + if (node.hasAttributes() || node.tagName.indexOf('-') > -1) { + + // skip anything with v-pre + if (utils.attr(node, 'pre') !== null) { + return + } + + var i, l, j, k + + // check priority directives. + // if any of them are present, it will take over the node with a childVM + // so we can skip the rest + for (i = 0, l = priorityDirectives.length; i < l; i++) { + if (this.checkPriorityDir(priorityDirectives[i], node, root)) { + return + } + } + + // check transition & animation properties + node.vue_trans = utils.attr(node, 'transition') + node.vue_anim = utils.attr(node, 'animation') + node.vue_effect = this.eval(utils.attr(node, 'effect')) + + var prefix = config.prefix + '-', + params = this.options.paramAttributes, + attr, attrname, isDirective, exp, directives, directive, dirname + + // v-with has special priority among the rest + // it needs to pull in the value from the parent before + // computed properties are evaluated, because at this stage + // the computed properties have not set up their dependencies yet. + if (root) { + var withExp = utils.attr(node, 'with') + if (withExp) { + directives = this.parseDirective('with', withExp, node, true) + for (j = 0, k = directives.length; j < k; j++) { + this.bindDirective(directives[j], this.parent) + } + } + } + + var attrs = slice.call(node.attributes) + for (i = 0, l = attrs.length; i < l; i++) { + + attr = attrs[i] + attrname = attr.name + isDirective = false + + if (attrname.indexOf(prefix) === 0) { + // a directive - split, parse and bind it. + isDirective = true + dirname = attrname.slice(prefix.length) + // build with multiple: true + directives = this.parseDirective(dirname, attr.value, node, true) + // loop through clauses (separated by ",") + // inside each attribute + for (j = 0, k = directives.length; j < k; j++) { + this.bindDirective(directives[j]) + } + } else if (config.interpolate) { + // non directive attribute, check interpolation tags + exp = TextParser.parseAttr(attr.value) + if (exp) { + directive = this.parseDirective('attr', exp, node) + directive.arg = attrname + if (params && params.indexOf(attrname) > -1) { + // a param attribute... we should use the parent binding + // to avoid circular updates like size={{size}} + this.bindDirective(directive, this.parent) + } else { + this.bindDirective(directive) + } + } + } + + if (isDirective && dirname !== 'cloak') { + node.removeAttribute(attrname) + } + } + + } + + // recursively compile childNodes + if (node.hasChildNodes()) { + slice.call(node.childNodes).forEach(this.compile, this) + } +} + +/** + * Compile a text node + */ +CompilerProto.compileTextNode = function (node) { + + var tokens = TextParser.parse(node.nodeValue) + if (!tokens) return + var el, token, directive + + for (var i = 0, l = tokens.length; i < l; i++) { + + token = tokens[i] + directive = null + + if (token.key) { // a binding + if (token.key.charAt(0) === '>') { // a partial + el = document.createComment('ref') + directive = this.parseDirective('partial', token.key.slice(1), el) + } else { + if (!token.html) { // text binding + el = document.createTextNode('') + directive = this.parseDirective('text', token.key, el) + } else { // html binding + el = document.createComment(config.prefix + '-html') + directive = this.parseDirective('html', token.key, el) + } + } + } else { // a plain string + el = document.createTextNode(token) + } + + // insert node + node.parentNode.insertBefore(el, node) + // bind directive + this.bindDirective(directive) + + } + node.parentNode.removeChild(node) +} + +/** + * Parse a directive name/value pair into one or more + * directive instances + */ +CompilerProto.parseDirective = function (name, value, el, multiple) { + var compiler = this, + definition = compiler.getOption('directives', name) + if (definition) { + // parse into AST-like objects + var asts = Directive.parse(value) + return multiple + ? asts.map(build) + : build(asts[0]) + } + function build (ast) { + return new Directive(name, ast, definition, compiler, el) + } +} + +/** + * Add a directive instance to the correct binding & viewmodel + */ +CompilerProto.bindDirective = function (directive, bindingOwner) { + + if (!directive) return + + // keep track of it so we can unbind() later + this.dirs.push(directive) + + // for empty or literal directives, simply call its bind() + // and we're done. + if (directive.isEmpty || directive.isLiteral) { + if (directive.bind) directive.bind() + return + } + + // otherwise, we got more work to do... + var binding, + compiler = bindingOwner || this, + key = directive.key + + if (directive.isExp) { + // expression bindings are always created on current compiler + binding = compiler.createBinding(key, directive) + } else { + // recursively locate which compiler owns the binding + while (compiler) { + if (compiler.hasKey(key)) { + break + } else { + compiler = compiler.parent + } + } + compiler = compiler || this + binding = compiler.bindings[key] || compiler.createBinding(key) + } + binding.dirs.push(directive) + directive.binding = binding + + var value = binding.val() + // invoke bind hook if exists + if (directive.bind) { + directive.bind(value) + } + // set initial value + directive.$update(value, true) +} + +/** + * Create binding and attach getter/setter for a key to the viewmodel object + */ +CompilerProto.createBinding = function (key, directive) { + + utils.log(' created binding: ' + key) + + var compiler = this, + methods = compiler.options.methods, + isExp = directive && directive.isExp, + isFn = (directive && directive.isFn) || (methods && methods[key]), + bindings = compiler.bindings, + computed = compiler.options.computed, + binding = new Binding(compiler, key, isExp, isFn) + + if (isExp) { + // expression bindings are anonymous + compiler.defineExp(key, binding, directive) + } else if (isFn) { + bindings[key] = binding + compiler.defineVmProp(key, binding, methods[key]) + } else { + bindings[key] = binding + if (binding.root) { + // this is a root level binding. we need to define getter/setters for it. + if (computed && computed[key]) { + // computed property + compiler.defineComputed(key, binding, computed[key]) + } else if (key.charAt(0) !== '$') { + // normal property + compiler.defineDataProp(key, binding) + } else { + // properties that start with $ are meta properties + // they should be kept on the vm but not in the data object. + compiler.defineVmProp(key, binding, compiler.data[key]) + delete compiler.data[key] + } + } else if (computed && computed[utils.baseKey(key)]) { + // nested path on computed property + compiler.defineExp(key, binding) + } else { + // ensure path in data so that computed properties that + // access the path don't throw an error and can collect + // dependencies + Observer.ensurePath(compiler.data, key) + var parentKey = key.slice(0, key.lastIndexOf('.')) + if (!bindings[parentKey]) { + // this is a nested value binding, but the binding for its parent + // has not been created yet. We better create that one too. + compiler.createBinding(parentKey) + } + } + } + return binding +} + +/** + * Define the getter/setter to proxy a root-level + * data property on the VM + */ +CompilerProto.defineDataProp = function (key, binding) { + var compiler = this, + data = compiler.data, + ob = data.__emitter__ + + // make sure the key is present in data + // so it can be observed + if (!(hasOwn.call(data, key))) { + data[key] = undefined + } + + // if the data object is already observed, but the key + // is not observed, we need to add it to the observed keys. + if (ob && !(hasOwn.call(ob.values, key))) { + Observer.convertKey(data, key) + } + + binding.value = data[key] + + def(compiler.vm, key, { + get: function () { + return compiler.data[key] + }, + set: function (val) { + compiler.data[key] = val + } + }) +} + +/** + * Define a vm property, e.g. $index, $key, or mixin methods + * which are bindable but only accessible on the VM, + * not in the data. + */ +CompilerProto.defineVmProp = function (key, binding, value) { + var ob = this.observer + binding.value = value + def(this.vm, key, { + get: function () { + if (Observer.shouldGet) ob.emit('get', key) + return binding.value + }, + set: function (val) { + ob.emit('set', key, val) + } + }) +} + +/** + * Define an expression binding, which is essentially + * an anonymous computed property + */ +CompilerProto.defineExp = function (key, binding, directive) { + var computedKey = directive && directive.computedKey, + exp = computedKey ? directive.expression : key, + getter = this.expCache[exp] + if (!getter) { + getter = this.expCache[exp] = ExpParser.parse(computedKey || key, this) + } + if (getter) { + this.markComputed(binding, getter) + } +} + +/** + * Define a computed property on the VM + */ +CompilerProto.defineComputed = function (key, binding, value) { + this.markComputed(binding, value) + def(this.vm, key, { + get: binding.value.$get, + set: binding.value.$set + }) +} + +/** + * Process a computed property binding + * so its getter/setter are bound to proper context + */ +CompilerProto.markComputed = function (binding, value) { + binding.isComputed = true + // bind the accessors to the vm + if (binding.isFn) { + binding.value = value + } else { + if (typeof value === 'function') { + value = { $get: value } + } + binding.value = { + $get: utils.bind(value.$get, this.vm), + $set: value.$set + ? utils.bind(value.$set, this.vm) + : undefined + } + } + // keep track for dep parsing later + this.computed.push(binding) +} + +/** + * Retrive an option from the compiler + */ +CompilerProto.getOption = function (type, id, silent) { + var opts = this.options, + parent = this.parent, + globalAssets = config.globalAssets, + res = (opts[type] && opts[type][id]) || ( + parent + ? parent.getOption(type, id, silent) + : globalAssets[type] && globalAssets[type][id] + ) + if (!res && !silent && typeof id === 'string') { + utils.warn('Unknown ' + type.slice(0, -1) + ': ' + id) + } + return res +} + +/** + * Emit lifecycle events to trigger hooks + */ +CompilerProto.execHook = function (event) { + event = 'hook:' + event + this.observer.emit(event) + this.emitter.emit(event) +} + +/** + * Check if a compiler's data contains a keypath + */ +CompilerProto.hasKey = function (key) { + var baseKey = utils.baseKey(key) + return hasOwn.call(this.data, baseKey) || + hasOwn.call(this.vm, baseKey) +} + +/** + * Do a one-time eval of a string that potentially + * includes bindings. It accepts additional raw data + * because we need to dynamically resolve v-component + * before a childVM is even compiled... + */ +CompilerProto.eval = function (exp, data) { + var parsed = TextParser.parseAttr(exp) + return parsed + ? ExpParser.eval(parsed, this, data) + : exp +} + +/** + * Resolve a Component constructor for an element + * with the data to be used + */ +CompilerProto.resolveComponent = function (node, data, test) { + + // late require to avoid circular deps + ViewModel = ViewModel || require("yyx990803~vue@v0.10.5/src/viewmodel.js") + + var exp = utils.attr(node, 'component'), + tagName = node.tagName, + id = this.eval(exp, data), + tagId = (tagName.indexOf('-') > 0 && tagName.toLowerCase()), + Ctor = this.getOption('components', id || tagId, true) + + if (id && !Ctor) { + utils.warn('Unknown component: ' + id) + } + + return test + ? exp === '' + ? ViewModel + : Ctor + : Ctor || ViewModel +} + +/** + * Unbind and remove element + */ +CompilerProto.destroy = function (noRemove) { + + // avoid being called more than once + // this is irreversible! + if (this.destroyed) return + + var compiler = this, + i, j, key, dir, dirs, binding, + vm = compiler.vm, + el = compiler.el, + directives = compiler.dirs, + computed = compiler.computed, + bindings = compiler.bindings, + children = compiler.children, + parent = compiler.parent + + compiler.execHook('beforeDestroy') + + // unobserve data + Observer.unobserve(compiler.data, '', compiler.observer) + + // destroy all children + // do not remove their elements since the parent + // may have transitions and the children may not + i = children.length + while (i--) { + children[i].destroy(true) + } + + // unbind all direcitves + i = directives.length + while (i--) { + dir = directives[i] + // if this directive is an instance of an external binding + // e.g. a directive that refers to a variable on the parent VM + // we need to remove it from that binding's directives + // * empty and literal bindings do not have binding. + if (dir.binding && dir.binding.compiler !== compiler) { + dirs = dir.binding.dirs + if (dirs) { + j = dirs.indexOf(dir) + if (j > -1) dirs.splice(j, 1) + } + } + dir.$unbind() + } + + // unbind all computed, anonymous bindings + i = computed.length + while (i--) { + computed[i].unbind() + } + + // unbind all keypath bindings + for (key in bindings) { + binding = bindings[key] + if (binding) { + binding.unbind() + } + } + + // remove self from parent + if (parent) { + j = parent.children.indexOf(compiler) + if (j > -1) parent.children.splice(j, 1) + } + + // finally remove dom element + if (!noRemove) { + if (el === document.body) { + el.innerHTML = '' + } else { + vm.$remove() + } + } + el.vue_vm = null + + compiler.destroyed = true + // emit destroy hook + compiler.execHook('afterDestroy') + + // finally, unregister all listeners + compiler.observer.off() + compiler.emitter.off() +} + +// Helpers -------------------------------------------------------------------- + +/** + * shorthand for getting root compiler + */ +function getRoot (compiler) { + while (compiler.parent) { + compiler = compiler.parent + } + return compiler +} + +module.exports = Compiler +}); + +require.register("yyx990803~vue@v0.10.5/src/viewmodel.js", function (exports, module) { +var Compiler = require("yyx990803~vue@v0.10.5/src/compiler.js"), + utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + transition = require("yyx990803~vue@v0.10.5/src/transition.js"), + Batcher = require("yyx990803~vue@v0.10.5/src/batcher.js"), + slice = [].slice, + def = utils.defProtected, + nextTick = utils.nextTick, + + // batch $watch callbacks + watcherBatcher = new Batcher(), + watcherId = 1 + +/** + * ViewModel exposed to the user that holds data, + * computed properties, event handlers + * and a few reserved methods + */ +function ViewModel (options) { + // just compile. options are passed directly to compiler + new Compiler(this, options) +} + +// All VM prototype methods are inenumerable +// so it can be stringified/looped through as raw data +var VMProto = ViewModel.prototype + +/** + * Convenience function to get a value from + * a keypath + */ +def(VMProto, '$get', function (key) { + var val = utils.get(this, key) + return val === undefined && this.$parent + ? this.$parent.$get(key) + : val +}) + +/** + * Convenience function to set an actual nested value + * from a flat key string. Used in directives. + */ +def(VMProto, '$set', function (key, value) { + utils.set(this, key, value) +}) + +/** + * watch a key on the viewmodel for changes + * fire callback with new value + */ +def(VMProto, '$watch', function (key, callback) { + // save a unique id for each watcher + var id = watcherId++, + self = this + function on () { + var args = slice.call(arguments) + watcherBatcher.push({ + id: id, + override: true, + execute: function () { + callback.apply(self, args) + } + }) + } + callback._fn = on + self.$compiler.observer.on('change:' + key, on) +}) + +/** + * unwatch a key + */ +def(VMProto, '$unwatch', function (key, callback) { + // workaround here + // since the emitter module checks callback existence + // by checking the length of arguments + var args = ['change:' + key], + ob = this.$compiler.observer + if (callback) args.push(callback._fn) + ob.off.apply(ob, args) +}) + +/** + * unbind everything, remove everything + */ +def(VMProto, '$destroy', function () { + this.$compiler.destroy() +}) + +/** + * broadcast an event to all child VMs recursively. + */ +def(VMProto, '$broadcast', function () { + var children = this.$compiler.children, + i = children.length, + child + while (i--) { + child = children[i] + child.emitter.applyEmit.apply(child.emitter, arguments) + child.vm.$broadcast.apply(child.vm, arguments) + } +}) + +/** + * emit an event that propagates all the way up to parent VMs. + */ +def(VMProto, '$dispatch', function () { + var compiler = this.$compiler, + emitter = compiler.emitter, + parent = compiler.parent + emitter.applyEmit.apply(emitter, arguments) + if (parent) { + parent.vm.$dispatch.apply(parent.vm, arguments) + } +}) + +/** + * delegate on/off/once to the compiler's emitter + */ +;['emit', 'on', 'off', 'once'].forEach(function (method) { + // internal emit has fixed number of arguments. + // exposed emit uses the external version + // with fn.apply. + var realMethod = method === 'emit' + ? 'applyEmit' + : method + def(VMProto, '$' + method, function () { + var emitter = this.$compiler.emitter + emitter[realMethod].apply(emitter, arguments) + }) +}) + +// DOM convenience methods + +def(VMProto, '$appendTo', function (target, cb) { + target = query(target) + var el = this.$el + transition(el, 1, function () { + target.appendChild(el) + if (cb) nextTick(cb) + }, this.$compiler) +}) + +def(VMProto, '$remove', function (cb) { + var el = this.$el + transition(el, -1, function () { + if (el.parentNode) { + el.parentNode.removeChild(el) + } + if (cb) nextTick(cb) + }, this.$compiler) +}) + +def(VMProto, '$before', function (target, cb) { + target = query(target) + var el = this.$el + transition(el, 1, function () { + target.parentNode.insertBefore(el, target) + if (cb) nextTick(cb) + }, this.$compiler) +}) + +def(VMProto, '$after', function (target, cb) { + target = query(target) + var el = this.$el + transition(el, 1, function () { + if (target.nextSibling) { + target.parentNode.insertBefore(el, target.nextSibling) + } else { + target.parentNode.appendChild(el) + } + if (cb) nextTick(cb) + }, this.$compiler) +}) + +function query (el) { + return typeof el === 'string' + ? document.querySelector(el) + : el +} + +module.exports = ViewModel +}); + +require.register("yyx990803~vue@v0.10.5/src/binding.js", function (exports, module) { +var Batcher = require("yyx990803~vue@v0.10.5/src/batcher.js"), + bindingBatcher = new Batcher(), + bindingId = 1 + +/** + * Binding class. + * + * each property on the viewmodel has one corresponding Binding object + * which has multiple directive instances on the DOM + * and multiple computed property dependents + */ +function Binding (compiler, key, isExp, isFn) { + this.id = bindingId++ + this.value = undefined + this.isExp = !!isExp + this.isFn = isFn + this.root = !this.isExp && key.indexOf('.') === -1 + this.compiler = compiler + this.key = key + this.dirs = [] + this.subs = [] + this.deps = [] + this.unbound = false +} + +var BindingProto = Binding.prototype + +/** + * Update value and queue instance updates. + */ +BindingProto.update = function (value) { + if (!this.isComputed || this.isFn) { + this.value = value + } + if (this.dirs.length || this.subs.length) { + var self = this + bindingBatcher.push({ + id: this.id, + execute: function () { + if (!self.unbound) { + self._update() + } + } + }) + } +} + +/** + * Actually update the directives. + */ +BindingProto._update = function () { + var i = this.dirs.length, + value = this.val() + while (i--) { + this.dirs[i].$update(value) + } + this.pub() +} + +/** + * Return the valuated value regardless + * of whether it is computed or not + */ +BindingProto.val = function () { + return this.isComputed && !this.isFn + ? this.value.$get() + : this.value +} + +/** + * Notify computed properties that depend on this binding + * to update themselves + */ +BindingProto.pub = function () { + var i = this.subs.length + while (i--) { + this.subs[i].update() + } +} + +/** + * Unbind the binding, remove itself from all of its dependencies + */ +BindingProto.unbind = function () { + // Indicate this has been unbound. + // It's possible this binding will be in + // the batcher's flush queue when its owner + // compiler has already been destroyed. + this.unbound = true + var i = this.dirs.length + while (i--) { + this.dirs[i].$unbind() + } + i = this.deps.length + var subs + while (i--) { + subs = this.deps[i].subs + var j = subs.indexOf(this) + if (j > -1) subs.splice(j, 1) + } +} + +module.exports = Binding +}); + +require.register("yyx990803~vue@v0.10.5/src/observer.js", function (exports, module) { +/* jshint proto:true */ + +var Emitter = require("yyx990803~vue@v0.10.5/src/emitter.js"), + utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + // cache methods + def = utils.defProtected, + isObject = utils.isObject, + isArray = Array.isArray, + hasOwn = ({}).hasOwnProperty, + oDef = Object.defineProperty, + slice = [].slice, + // fix for IE + __proto__ problem + // define methods as inenumerable if __proto__ is present, + // otherwise enumerable so we can loop through and manually + // attach to array instances + hasProto = ({}).__proto__ + +// Array Mutation Handlers & Augmentations ------------------------------------ + +// The proxy prototype to replace the __proto__ of +// an observed array +var ArrayProxy = Object.create(Array.prototype) + +// intercept mutation methods +;[ + 'push', + 'pop', + 'shift', + 'unshift', + 'splice', + 'sort', + 'reverse' +].forEach(watchMutation) + +// Augment the ArrayProxy with convenience methods +def(ArrayProxy, '$set', function (index, data) { + return this.splice(index, 1, data)[0] +}, !hasProto) + +def(ArrayProxy, '$remove', function (index) { + if (typeof index !== 'number') { + index = this.indexOf(index) + } + if (index > -1) { + return this.splice(index, 1)[0] + } +}, !hasProto) + +/** + * Intercep a mutation event so we can emit the mutation info. + * we also analyze what elements are added/removed and link/unlink + * them with the parent Array. + */ +function watchMutation (method) { + def(ArrayProxy, method, function () { + + var args = slice.call(arguments), + result = Array.prototype[method].apply(this, args), + inserted, removed + + // determine new / removed elements + if (method === 'push' || method === 'unshift') { + inserted = args + } else if (method === 'pop' || method === 'shift') { + removed = [result] + } else if (method === 'splice') { + inserted = args.slice(2) + removed = result + } + + // link & unlink + linkArrayElements(this, inserted) + unlinkArrayElements(this, removed) + + // emit the mutation event + this.__emitter__.emit('mutate', '', this, { + method : method, + args : args, + result : result, + inserted : inserted, + removed : removed + }) + + return result + + }, !hasProto) +} + +/** + * Link new elements to an Array, so when they change + * and emit events, the owner Array can be notified. + */ +function linkArrayElements (arr, items) { + if (items) { + var i = items.length, item, owners + while (i--) { + item = items[i] + if (isWatchable(item)) { + // if object is not converted for observing + // convert it... + if (!item.__emitter__) { + convert(item) + watch(item) + } + owners = item.__emitter__.owners + if (owners.indexOf(arr) < 0) { + owners.push(arr) + } + } + } + } +} + +/** + * Unlink removed elements from the ex-owner Array. + */ +function unlinkArrayElements (arr, items) { + if (items) { + var i = items.length, item + while (i--) { + item = items[i] + if (item && item.__emitter__) { + var owners = item.__emitter__.owners + if (owners) owners.splice(owners.indexOf(arr)) + } + } + } +} + +// Object add/delete key augmentation ----------------------------------------- + +var ObjProxy = Object.create(Object.prototype) + +def(ObjProxy, '$add', function (key, val) { + if (hasOwn.call(this, key)) return + this[key] = val + convertKey(this, key, true) +}, !hasProto) + +def(ObjProxy, '$delete', function (key) { + if (!(hasOwn.call(this, key))) return + // trigger set events + this[key] = undefined + delete this[key] + this.__emitter__.emit('delete', key) +}, !hasProto) + +// Watch Helpers -------------------------------------------------------------- + +/** + * Check if a value is watchable + */ +function isWatchable (obj) { + return typeof obj === 'object' && obj && !obj.$compiler +} + +/** + * Convert an Object/Array to give it a change emitter. + */ +function convert (obj) { + if (obj.__emitter__) return true + var emitter = new Emitter() + def(obj, '__emitter__', emitter) + emitter + .on('set', function (key, val, propagate) { + if (propagate) propagateChange(obj) + }) + .on('mutate', function () { + propagateChange(obj) + }) + emitter.values = utils.hash() + emitter.owners = [] + return false +} + +/** + * Propagate an array element's change to its owner arrays + */ +function propagateChange (obj) { + var owners = obj.__emitter__.owners, + i = owners.length + while (i--) { + owners[i].__emitter__.emit('set', '', '', true) + } +} + +/** + * Watch target based on its type + */ +function watch (obj) { + if (isArray(obj)) { + watchArray(obj) + } else { + watchObject(obj) + } +} + +/** + * Augment target objects with modified + * methods + */ +function augment (target, src) { + if (hasProto) { + target.__proto__ = src + } else { + for (var key in src) { + def(target, key, src[key]) + } + } +} + +/** + * Watch an Object, recursive. + */ +function watchObject (obj) { + augment(obj, ObjProxy) + for (var key in obj) { + convertKey(obj, key) + } +} + +/** + * Watch an Array, overload mutation methods + * and add augmentations by intercepting the prototype chain + */ +function watchArray (arr) { + augment(arr, ArrayProxy) + linkArrayElements(arr, arr) +} + +/** + * Define accessors for a property on an Object + * so it emits get/set events. + * Then watch the value itself. + */ +function convertKey (obj, key, propagate) { + var keyPrefix = key.charAt(0) + if (keyPrefix === '$' || keyPrefix === '_') { + return + } + // emit set on bind + // this means when an object is observed it will emit + // a first batch of set events. + var emitter = obj.__emitter__, + values = emitter.values + + init(obj[key], propagate) + + oDef(obj, key, { + enumerable: true, + configurable: true, + get: function () { + var value = values[key] + // only emit get on tip values + if (pub.shouldGet) { + emitter.emit('get', key) + } + return value + }, + set: function (newVal) { + var oldVal = values[key] + unobserve(oldVal, key, emitter) + copyPaths(newVal, oldVal) + // an immediate property should notify its parent + // to emit set for itself too + init(newVal, true) + } + }) + + function init (val, propagate) { + values[key] = val + emitter.emit('set', key, val, propagate) + if (isArray(val)) { + emitter.emit('set', key + '.length', val.length, propagate) + } + observe(val, key, emitter) + } +} + +/** + * When a value that is already converted is + * observed again by another observer, we can skip + * the watch conversion and simply emit set event for + * all of its properties. + */ +function emitSet (obj) { + var emitter = obj && obj.__emitter__ + if (!emitter) return + if (isArray(obj)) { + emitter.emit('set', 'length', obj.length) + } else { + var key, val + for (key in obj) { + val = obj[key] + emitter.emit('set', key, val) + emitSet(val) + } + } +} + +/** + * Make sure all the paths in an old object exists + * in a new object. + * So when an object changes, all missing keys will + * emit a set event with undefined value. + */ +function copyPaths (newObj, oldObj) { + if (!isObject(newObj) || !isObject(oldObj)) { + return + } + var path, oldVal, newVal + for (path in oldObj) { + if (!(hasOwn.call(newObj, path))) { + oldVal = oldObj[path] + if (isArray(oldVal)) { + newObj[path] = [] + } else if (isObject(oldVal)) { + newVal = newObj[path] = {} + copyPaths(newVal, oldVal) + } else { + newObj[path] = undefined + } + } + } +} + +/** + * walk along a path and make sure it can be accessed + * and enumerated in that object + */ +function ensurePath (obj, key) { + var path = key.split('.'), sec + for (var i = 0, d = path.length - 1; i < d; i++) { + sec = path[i] + if (!obj[sec]) { + obj[sec] = {} + if (obj.__emitter__) convertKey(obj, sec) + } + obj = obj[sec] + } + if (isObject(obj)) { + sec = path[i] + if (!(hasOwn.call(obj, sec))) { + obj[sec] = undefined + if (obj.__emitter__) convertKey(obj, sec) + } + } +} + +// Main API Methods ----------------------------------------------------------- + +/** + * Observe an object with a given path, + * and proxy get/set/mutate events to the provided observer. + */ +function observe (obj, rawPath, observer) { + + if (!isWatchable(obj)) return + + var path = rawPath ? rawPath + '.' : '', + alreadyConverted = convert(obj), + emitter = obj.__emitter__ + + // setup proxy listeners on the parent observer. + // we need to keep reference to them so that they + // can be removed when the object is un-observed. + observer.proxies = observer.proxies || {} + var proxies = observer.proxies[path] = { + get: function (key) { + observer.emit('get', path + key) + }, + set: function (key, val, propagate) { + if (key) observer.emit('set', path + key, val) + // also notify observer that the object itself changed + // but only do so when it's a immediate property. this + // avoids duplicate event firing. + if (rawPath && propagate) { + observer.emit('set', rawPath, obj, true) + } + }, + mutate: function (key, val, mutation) { + // if the Array is a root value + // the key will be null + var fixedPath = key ? path + key : rawPath + observer.emit('mutate', fixedPath, val, mutation) + // also emit set for Array's length when it mutates + var m = mutation.method + if (m !== 'sort' && m !== 'reverse') { + observer.emit('set', fixedPath + '.length', val.length) + } + } + } + + // attach the listeners to the child observer. + // now all the events will propagate upwards. + emitter + .on('get', proxies.get) + .on('set', proxies.set) + .on('mutate', proxies.mutate) + + if (alreadyConverted) { + // for objects that have already been converted, + // emit set events for everything inside + emitSet(obj) + } else { + watch(obj) + } +} + +/** + * Cancel observation, turn off the listeners. + */ +function unobserve (obj, path, observer) { + + if (!obj || !obj.__emitter__) return + + path = path ? path + '.' : '' + var proxies = observer.proxies[path] + if (!proxies) return + + // turn off listeners + obj.__emitter__ + .off('get', proxies.get) + .off('set', proxies.set) + .off('mutate', proxies.mutate) + + // remove reference + observer.proxies[path] = null +} + +// Expose API ----------------------------------------------------------------- + +var pub = module.exports = { + + // whether to emit get events + // only enabled during dependency parsing + shouldGet : false, + + observe : observe, + unobserve : unobserve, + ensurePath : ensurePath, + copyPaths : copyPaths, + watch : watch, + convert : convert, + convertKey : convertKey +} +}); + +require.register("yyx990803~vue@v0.10.5/src/directive.js", function (exports, module) { +var dirId = 1, + ARG_RE = /^[\w\$-]+$/, + FILTER_TOKEN_RE = /[^\s'"]+|'[^']+'|"[^"]+"/g, + NESTING_RE = /^\$(parent|root)\./, + SINGLE_VAR_RE = /^[\w\.$]+$/, + QUOTE_RE = /"/g, + TextParser = require("yyx990803~vue@v0.10.5/src/text-parser.js") + +/** + * Directive class + * represents a single directive instance in the DOM + */ +function Directive (name, ast, definition, compiler, el) { + + this.id = dirId++ + this.name = name + this.compiler = compiler + this.vm = compiler.vm + this.el = el + this.computeFilters = false + this.key = ast.key + this.arg = ast.arg + this.expression = ast.expression + + var isEmpty = this.expression === '' + + // mix in properties from the directive definition + if (typeof definition === 'function') { + this[isEmpty ? 'bind' : 'update'] = definition + } else { + for (var prop in definition) { + this[prop] = definition[prop] + } + } + + // empty expression, we're done. + if (isEmpty || this.isEmpty) { + this.isEmpty = true + return + } + + if (TextParser.Regex.test(this.key)) { + this.key = compiler.eval(this.key) + if (this.isLiteral) { + this.expression = this.key + } + } + + var filters = ast.filters, + filter, fn, i, l, computed + if (filters) { + this.filters = [] + for (i = 0, l = filters.length; i < l; i++) { + filter = filters[i] + fn = this.compiler.getOption('filters', filter.name) + if (fn) { + filter.apply = fn + this.filters.push(filter) + if (fn.computed) { + computed = true + } + } + } + } + + if (!this.filters || !this.filters.length) { + this.filters = null + } + + if (computed) { + this.computedKey = Directive.inlineFilters(this.key, this.filters) + this.filters = null + } + + this.isExp = + computed || + !SINGLE_VAR_RE.test(this.key) || + NESTING_RE.test(this.key) + +} + +var DirProto = Directive.prototype + +/** + * called when a new value is set + * for computed properties, this will only be called once + * during initialization. + */ +DirProto.$update = function (value, init) { + if (this.$lock) return + if (init || value !== this.value || (value && typeof value === 'object')) { + this.value = value + if (this.update) { + this.update( + this.filters && !this.computeFilters + ? this.$applyFilters(value) + : value, + init + ) + } + } +} + +/** + * pipe the value through filters + */ +DirProto.$applyFilters = function (value) { + var filtered = value, filter + for (var i = 0, l = this.filters.length; i < l; i++) { + filter = this.filters[i] + filtered = filter.apply.apply(this.vm, [filtered].concat(filter.args)) + } + return filtered +} + +/** + * Unbind diretive + */ +DirProto.$unbind = function () { + // this can be called before the el is even assigned... + if (!this.el || !this.vm) return + if (this.unbind) this.unbind() + this.vm = this.el = this.binding = this.compiler = null +} + +// Exposed static methods ----------------------------------------------------- + +/** + * Parse a directive string into an Array of + * AST-like objects representing directives + */ +Directive.parse = function (str) { + + var inSingle = false, + inDouble = false, + curly = 0, + square = 0, + paren = 0, + begin = 0, + argIndex = 0, + dirs = [], + dir = {}, + lastFilterIndex = 0, + arg + + for (var c, i = 0, l = str.length; i < l; i++) { + c = str.charAt(i) + if (inSingle) { + // check single quote + if (c === "'") inSingle = !inSingle + } else if (inDouble) { + // check double quote + if (c === '"') inDouble = !inDouble + } else if (c === ',' && !paren && !curly && !square) { + // reached the end of a directive + pushDir() + // reset & skip the comma + dir = {} + begin = argIndex = lastFilterIndex = i + 1 + } else if (c === ':' && !dir.key && !dir.arg) { + // argument + arg = str.slice(begin, i).trim() + if (ARG_RE.test(arg)) { + argIndex = i + 1 + dir.arg = arg + } + } else if (c === '|' && str.charAt(i + 1) !== '|' && str.charAt(i - 1) !== '|') { + if (dir.key === undefined) { + // first filter, end of key + lastFilterIndex = i + 1 + dir.key = str.slice(argIndex, i).trim() + } else { + // already has filter + pushFilter() + } + } else if (c === '"') { + inDouble = true + } else if (c === "'") { + inSingle = true + } else if (c === '(') { + paren++ + } else if (c === ')') { + paren-- + } else if (c === '[') { + square++ + } else if (c === ']') { + square-- + } else if (c === '{') { + curly++ + } else if (c === '}') { + curly-- + } + } + if (i === 0 || begin !== i) { + pushDir() + } + + function pushDir () { + dir.expression = str.slice(begin, i).trim() + if (dir.key === undefined) { + dir.key = str.slice(argIndex, i).trim() + } else if (lastFilterIndex !== begin) { + pushFilter() + } + if (i === 0 || dir.key) { + dirs.push(dir) + } + } + + function pushFilter () { + var exp = str.slice(lastFilterIndex, i).trim(), + filter + if (exp) { + filter = {} + var tokens = exp.match(FILTER_TOKEN_RE) + filter.name = tokens[0] + filter.args = tokens.length > 1 ? tokens.slice(1) : null + } + if (filter) { + (dir.filters = dir.filters || []).push(filter) + } + lastFilterIndex = i + 1 + } + + return dirs +} + +/** + * Inline computed filters so they become part + * of the expression + */ +Directive.inlineFilters = function (key, filters) { + var args, filter + for (var i = 0, l = filters.length; i < l; i++) { + filter = filters[i] + args = filter.args + ? ',"' + filter.args.map(escapeQuote).join('","') + '"' + : '' + key = 'this.$compiler.getOption("filters", "' + + filter.name + + '").call(this,' + + key + args + + ')' + } + return key +} + +/** + * Convert double quotes to single quotes + * so they don't mess up the generated function body + */ +function escapeQuote (v) { + return v.indexOf('"') > -1 + ? v.replace(QUOTE_RE, '\'') + : v +} + +module.exports = Directive +}); + +require.register("yyx990803~vue@v0.10.5/src/exp-parser.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + STR_SAVE_RE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g, + STR_RESTORE_RE = /"(\d+)"/g, + NEWLINE_RE = /\n/g, + CTOR_RE = new RegExp('constructor'.split('').join('[\'"+, ]*')), + UNICODE_RE = /\\u\d\d\d\d/ + +// Variable extraction scooped from https://github.com/RubyLouvre/avalon + +var KEYWORDS = + // keywords + 'break,case,catch,continue,debugger,default,delete,do,else,false' + + ',finally,for,function,if,in,instanceof,new,null,return,switch,this' + + ',throw,true,try,typeof,var,void,while,with,undefined' + + // reserved + ',abstract,boolean,byte,char,class,const,double,enum,export,extends' + + ',final,float,goto,implements,import,int,interface,long,native' + + ',package,private,protected,public,short,static,super,synchronized' + + ',throws,transient,volatile' + + // ECMA 5 - use strict + ',arguments,let,yield' + + // allow using Math in expressions + ',Math', + + KEYWORDS_RE = new RegExp(["\\b" + KEYWORDS.replace(/,/g, '\\b|\\b') + "\\b"].join('|'), 'g'), + REMOVE_RE = /\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+|[\{,]\s*[\w\$_]+\s*:/g, + SPLIT_RE = /[^\w$]+/g, + NUMBER_RE = /\b\d[^,]*/g, + BOUNDARY_RE = /^,+|,+$/g + +/** + * Strip top level variable names from a snippet of JS expression + */ +function getVariables (code) { + code = code + .replace(REMOVE_RE, '') + .replace(SPLIT_RE, ',') + .replace(KEYWORDS_RE, '') + .replace(NUMBER_RE, '') + .replace(BOUNDARY_RE, '') + return code + ? code.split(/,+/) + : [] +} + +/** + * A given path could potentially exist not on the + * current compiler, but up in the parent chain somewhere. + * This function generates an access relationship string + * that can be used in the getter function by walking up + * the parent chain to check for key existence. + * + * It stops at top parent if no vm in the chain has the + * key. It then creates any missing bindings on the + * final resolved vm. + */ +function traceScope (path, compiler, data) { + var rel = '', + dist = 0, + self = compiler + + if (data && utils.get(data, path) !== undefined) { + // hack: temporarily attached data + return '$temp.' + } + + while (compiler) { + if (compiler.hasKey(path)) { + break + } else { + compiler = compiler.parent + dist++ + } + } + if (compiler) { + while (dist--) { + rel += '$parent.' + } + if (!compiler.bindings[path] && path.charAt(0) !== '$') { + compiler.createBinding(path) + } + } else { + self.createBinding(path) + } + return rel +} + +/** + * Create a function from a string... + * this looks like evil magic but since all variables are limited + * to the VM's data it's actually properly sandboxed + */ +function makeGetter (exp, raw) { + var fn + try { + fn = new Function(exp) + } catch (e) { + utils.warn('Error parsing expression: ' + raw) + } + return fn +} + +/** + * Escape a leading dollar sign for regex construction + */ +function escapeDollar (v) { + return v.charAt(0) === '$' + ? '\\' + v + : v +} + +/** + * Parse and return an anonymous computed property getter function + * from an arbitrary expression, together with a list of paths to be + * created as bindings. + */ +exports.parse = function (exp, compiler, data) { + // unicode and 'constructor' are not allowed for XSS security. + if (UNICODE_RE.test(exp) || CTOR_RE.test(exp)) { + utils.warn('Unsafe expression: ' + exp) + return + } + // extract variable names + var vars = getVariables(exp) + if (!vars.length) { + return makeGetter('return ' + exp, exp) + } + vars = utils.unique(vars) + + var accessors = '', + has = utils.hash(), + strings = [], + // construct a regex to extract all valid variable paths + // ones that begin with "$" are particularly tricky + // because we can't use \b for them + pathRE = new RegExp( + "[^$\\w\\.](" + + vars.map(escapeDollar).join('|') + + ")[$\\w\\.]*\\b", 'g' + ), + body = (' ' + exp) + .replace(STR_SAVE_RE, saveStrings) + .replace(pathRE, replacePath) + .replace(STR_RESTORE_RE, restoreStrings) + + body = accessors + 'return ' + body + + function saveStrings (str) { + var i = strings.length + // escape newlines in strings so the expression + // can be correctly evaluated + strings[i] = str.replace(NEWLINE_RE, '\\n') + return '"' + i + '"' + } + + function replacePath (path) { + // keep track of the first char + var c = path.charAt(0) + path = path.slice(1) + var val = 'this.' + traceScope(path, compiler, data) + path + if (!has[path]) { + accessors += val + ';' + has[path] = 1 + } + // don't forget to put that first char back + return c + val + } + + function restoreStrings (str, i) { + return strings[i] + } + + return makeGetter(body, exp) +} + +/** + * Evaluate an expression in the context of a compiler. + * Accepts additional data. + */ +exports.eval = function (exp, compiler, data) { + var getter = exports.parse(exp, compiler, data), res + if (getter) { + // hack: temporarily attach the additional data so + // it can be accessed in the getter + compiler.vm.$temp = data + res = getter.call(compiler.vm) + delete compiler.vm.$temp + } + return res +} +}); + +require.register("yyx990803~vue@v0.10.5/src/text-parser.js", function (exports, module) { +var openChar = '{', + endChar = '}', + ESCAPE_RE = /[-.*+?^${}()|[\]\/\\]/g, + // lazy require + Directive + +exports.Regex = buildInterpolationRegex() + +function buildInterpolationRegex () { + var open = escapeRegex(openChar), + end = escapeRegex(endChar) + return new RegExp(open + open + open + '?(.+?)' + end + '?' + end + end) +} + +function escapeRegex (str) { + return str.replace(ESCAPE_RE, '\\$&') +} + +function setDelimiters (delimiters) { + openChar = delimiters[0] + endChar = delimiters[1] + exports.delimiters = delimiters + exports.Regex = buildInterpolationRegex() +} + +/** + * Parse a piece of text, return an array of tokens + * token types: + * 1. plain string + * 2. object with key = binding key + * 3. object with key & html = true + */ +function parse (text) { + if (!exports.Regex.test(text)) return null + var m, i, token, match, tokens = [] + /* jshint boss: true */ + while (m = text.match(exports.Regex)) { + i = m.index + if (i > 0) tokens.push(text.slice(0, i)) + token = { key: m[1].trim() } + match = m[0] + token.html = + match.charAt(2) === openChar && + match.charAt(match.length - 3) === endChar + tokens.push(token) + text = text.slice(i + m[0].length) + } + if (text.length) tokens.push(text) + return tokens +} + +/** + * Parse an attribute value with possible interpolation tags + * return a Directive-friendly expression + * + * e.g. a {{b}} c => "a " + b + " c" + */ +function parseAttr (attr) { + Directive = Directive || require("yyx990803~vue@v0.10.5/src/directive.js") + var tokens = parse(attr) + if (!tokens) return null + if (tokens.length === 1) return tokens[0].key + var res = [], token + for (var i = 0, l = tokens.length; i < l; i++) { + token = tokens[i] + res.push( + token.key + ? inlineFilters(token.key) + : ('"' + token + '"') + ) + } + return res.join('+') +} + +/** + * Inlines any possible filters in a binding + * so that we can combine everything into a huge expression + */ +function inlineFilters (key) { + if (key.indexOf('|') > -1) { + var dirs = Directive.parse(key), + dir = dirs && dirs[0] + if (dir && dir.filters) { + key = Directive.inlineFilters( + dir.key, + dir.filters + ) + } + } + return '(' + key + ')' +} + +exports.parse = parse +exports.parseAttr = parseAttr +exports.setDelimiters = setDelimiters +exports.delimiters = [openChar, endChar] +}); + +require.register("yyx990803~vue@v0.10.5/src/deps-parser.js", function (exports, module) { +var Emitter = require("yyx990803~vue@v0.10.5/src/emitter.js"), + utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + Observer = require("yyx990803~vue@v0.10.5/src/observer.js"), + catcher = new Emitter() + +/** + * Auto-extract the dependencies of a computed property + * by recording the getters triggered when evaluating it. + */ +function catchDeps (binding) { + if (binding.isFn) return + utils.log('\n- ' + binding.key) + var got = utils.hash() + binding.deps = [] + catcher.on('get', function (dep) { + var has = got[dep.key] + if ( + // avoid duplicate bindings + (has && has.compiler === dep.compiler) || + // avoid repeated items as dependency + // only when the binding is from self or the parent chain + (dep.compiler.repeat && !isParentOf(dep.compiler, binding.compiler)) + ) { + return + } + got[dep.key] = dep + utils.log(' - ' + dep.key) + binding.deps.push(dep) + dep.subs.push(binding) + }) + binding.value.$get() + catcher.off('get') +} + +/** + * Test if A is a parent of or equals B + */ +function isParentOf (a, b) { + while (b) { + if (a === b) { + return true + } + b = b.parent + } +} + +module.exports = { + + /** + * the observer that catches events triggered by getters + */ + catcher: catcher, + + /** + * parse a list of computed property bindings + */ + parse: function (bindings) { + utils.log('\nparsing dependencies...') + Observer.shouldGet = true + bindings.forEach(catchDeps) + Observer.shouldGet = false + utils.log('\ndone.') + } + +} +}); + +require.register("yyx990803~vue@v0.10.5/src/filters.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + get = utils.get, + slice = [].slice, + QUOTE_RE = /^'.*'$/, + filters = module.exports = utils.hash() + +/** + * 'abc' => 'Abc' + */ +filters.capitalize = function (value) { + if (!value && value !== 0) return '' + value = value.toString() + return value.charAt(0).toUpperCase() + value.slice(1) +} + +/** + * 'abc' => 'ABC' + */ +filters.uppercase = function (value) { + return (value || value === 0) + ? value.toString().toUpperCase() + : '' +} + +/** + * 'AbC' => 'abc' + */ +filters.lowercase = function (value) { + return (value || value === 0) + ? value.toString().toLowerCase() + : '' +} + +/** + * 12345 => $12,345.00 + */ +filters.currency = function (value, sign) { + if (!value && value !== 0) return '' + sign = sign || '$' + var s = Math.floor(value).toString(), + i = s.length % 3, + h = i > 0 ? (s.slice(0, i) + (s.length > 3 ? ',' : '')) : '', + f = '.' + value.toFixed(2).slice(-2) + return sign + h + s.slice(i).replace(/(\d{3})(?=\d)/g, '$1,') + f +} + +/** + * args: an array of strings corresponding to + * the single, double, triple ... forms of the word to + * be pluralized. When the number to be pluralized + * exceeds the length of the args, it will use the last + * entry in the array. + * + * e.g. ['single', 'double', 'triple', 'multiple'] + */ +filters.pluralize = function (value) { + var args = slice.call(arguments, 1) + return args.length > 1 + ? (args[value - 1] || args[args.length - 1]) + : (args[value - 1] || args[0] + 's') +} + +/** + * A special filter that takes a handler function, + * wraps it so it only gets triggered on specific keypresses. + * + * v-on only + */ + +var keyCodes = { + enter : 13, + tab : 9, + 'delete' : 46, + up : 38, + left : 37, + right : 39, + down : 40, + esc : 27 +} + +filters.key = function (handler, key) { + if (!handler) return + var code = keyCodes[key] + if (!code) { + code = parseInt(key, 10) + } + return function (e) { + if (e.keyCode === code) { + return handler.call(this, e) + } + } +} + +/** + * Filter filter for v-repeat + */ +filters.filterBy = function (arr, searchKey, delimiter, dataKey) { + + // allow optional `in` delimiter + // because why not + if (delimiter && delimiter !== 'in') { + dataKey = delimiter + } + + // get the search string + var search = stripQuotes(searchKey) || this.$get(searchKey) + if (!search) return arr + search = search.toLowerCase() + + // get the optional dataKey + dataKey = dataKey && (stripQuotes(dataKey) || this.$get(dataKey)) + + // convert object to array + if (!Array.isArray(arr)) { + arr = utils.objectToArray(arr) + } + + return arr.filter(function (item) { + return dataKey + ? contains(get(item, dataKey), search) + : contains(item, search) + }) + +} + +filters.filterBy.computed = true + +/** + * Sort fitler for v-repeat + */ +filters.orderBy = function (arr, sortKey, reverseKey) { + + var key = stripQuotes(sortKey) || this.$get(sortKey) + if (!key) return arr + + // convert object to array + if (!Array.isArray(arr)) { + arr = utils.objectToArray(arr) + } + + var order = 1 + if (reverseKey) { + if (reverseKey === '-1') { + order = -1 + } else if (reverseKey.charAt(0) === '!') { + reverseKey = reverseKey.slice(1) + order = this.$get(reverseKey) ? 1 : -1 + } else { + order = this.$get(reverseKey) ? -1 : 1 + } + } + + // sort on a copy to avoid mutating original array + return arr.slice().sort(function (a, b) { + a = get(a, key) + b = get(b, key) + return a === b ? 0 : a > b ? order : -order + }) + +} + +filters.orderBy.computed = true + +// Array filter helpers ------------------------------------------------------- + +/** + * String contain helper + */ +function contains (val, search) { + /* jshint eqeqeq: false */ + if (utils.isObject(val)) { + for (var key in val) { + if (contains(val[key], search)) { + return true + } + } + } else if (val != null) { + return val.toString().toLowerCase().indexOf(search) > -1 + } +} + +/** + * Test whether a string is in quotes, + * if yes return stripped string + */ +function stripQuotes (str) { + if (QUOTE_RE.test(str)) { + return str.slice(1, -1) + } +} +}); + +require.register("yyx990803~vue@v0.10.5/src/transition.js", function (exports, module) { +var endEvents = sniffEndEvents(), + config = require("yyx990803~vue@v0.10.5/src/config.js"), + // batch enter animations so we only force the layout once + Batcher = require("yyx990803~vue@v0.10.5/src/batcher.js"), + batcher = new Batcher(), + // cache timer functions + setTO = window.setTimeout, + clearTO = window.clearTimeout, + // exit codes for testing + codes = { + CSS_E : 1, + CSS_L : 2, + JS_E : 3, + JS_L : 4, + CSS_SKIP : -1, + JS_SKIP : -2, + JS_SKIP_E : -3, + JS_SKIP_L : -4, + INIT : -5, + SKIP : -6 + } + +// force layout before triggering transitions/animations +batcher._preFlush = function () { + /* jshint unused: false */ + var f = document.body.offsetHeight +} + +/** + * stage: + * 1 = enter + * 2 = leave + */ +var transition = module.exports = function (el, stage, cb, compiler) { + + var changeState = function () { + cb() + compiler.execHook(stage > 0 ? 'attached' : 'detached') + } + + if (compiler.init) { + changeState() + return codes.INIT + } + + var hasTransition = el.vue_trans === '', + hasAnimation = el.vue_anim === '', + effectId = el.vue_effect + + if (effectId) { + return applyTransitionFunctions( + el, + stage, + changeState, + effectId, + compiler + ) + } else if (hasTransition || hasAnimation) { + return applyTransitionClass( + el, + stage, + changeState, + hasAnimation + ) + } else { + changeState() + return codes.SKIP + } + +} + +/** + * Togggle a CSS class to trigger transition + */ +function applyTransitionClass (el, stage, changeState, hasAnimation) { + + if (!endEvents.trans) { + changeState() + return codes.CSS_SKIP + } + + // if the browser supports transition, + // it must have classList... + var onEnd, + classList = el.classList, + existingCallback = el.vue_trans_cb, + enterClass = config.enterClass, + leaveClass = config.leaveClass, + endEvent = hasAnimation ? endEvents.anim : endEvents.trans + + // cancel unfinished callbacks and jobs + if (existingCallback) { + el.removeEventListener(endEvent, existingCallback) + classList.remove(enterClass) + classList.remove(leaveClass) + el.vue_trans_cb = null + } + + if (stage > 0) { // enter + + // set to enter state before appending + classList.add(enterClass) + // append + changeState() + // trigger transition + if (!hasAnimation) { + batcher.push({ + execute: function () { + classList.remove(enterClass) + } + }) + } else { + onEnd = function (e) { + if (e.target === el) { + el.removeEventListener(endEvent, onEnd) + el.vue_trans_cb = null + classList.remove(enterClass) + } + } + el.addEventListener(endEvent, onEnd) + el.vue_trans_cb = onEnd + } + return codes.CSS_E + + } else { // leave + + if (el.offsetWidth || el.offsetHeight) { + // trigger hide transition + classList.add(leaveClass) + onEnd = function (e) { + if (e.target === el) { + el.removeEventListener(endEvent, onEnd) + el.vue_trans_cb = null + // actually remove node here + changeState() + classList.remove(leaveClass) + } + } + // attach transition end listener + el.addEventListener(endEvent, onEnd) + el.vue_trans_cb = onEnd + } else { + // directly remove invisible elements + changeState() + } + return codes.CSS_L + + } + +} + +function applyTransitionFunctions (el, stage, changeState, effectId, compiler) { + + var funcs = compiler.getOption('effects', effectId) + if (!funcs) { + changeState() + return codes.JS_SKIP + } + + var enter = funcs.enter, + leave = funcs.leave, + timeouts = el.vue_timeouts + + // clear previous timeouts + if (timeouts) { + var i = timeouts.length + while (i--) { + clearTO(timeouts[i]) + } + } + + timeouts = el.vue_timeouts = [] + function timeout (cb, delay) { + var id = setTO(function () { + cb() + timeouts.splice(timeouts.indexOf(id), 1) + if (!timeouts.length) { + el.vue_timeouts = null + } + }, delay) + timeouts.push(id) + } + + if (stage > 0) { // enter + if (typeof enter !== 'function') { + changeState() + return codes.JS_SKIP_E + } + enter(el, changeState, timeout) + return codes.JS_E + } else { // leave + if (typeof leave !== 'function') { + changeState() + return codes.JS_SKIP_L + } + leave(el, changeState, timeout) + return codes.JS_L + } + +} + +/** + * Sniff proper transition end event name + */ +function sniffEndEvents () { + var el = document.createElement('vue'), + defaultEvent = 'transitionend', + events = { + 'webkitTransition' : 'webkitTransitionEnd', + 'transition' : defaultEvent, + 'mozTransition' : defaultEvent + }, + ret = {} + for (var name in events) { + if (el.style[name] !== undefined) { + ret.trans = events[name] + break + } + } + ret.anim = el.style.animation === '' + ? 'animationend' + : 'webkitAnimationEnd' + return ret +} + +// Expose some stuff for testing purposes +transition.codes = codes +transition.sniff = sniffEndEvents +}); + +require.register("yyx990803~vue@v0.10.5/src/batcher.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js") + +function Batcher () { + this.reset() +} + +var BatcherProto = Batcher.prototype + +BatcherProto.push = function (job) { + if (!job.id || !this.has[job.id]) { + this.queue.push(job) + this.has[job.id] = job + if (!this.waiting) { + this.waiting = true + utils.nextTick(utils.bind(this.flush, this)) + } + } else if (job.override) { + var oldJob = this.has[job.id] + oldJob.cancelled = true + this.queue.push(job) + this.has[job.id] = job + } +} + +BatcherProto.flush = function () { + // before flush hook + if (this._preFlush) this._preFlush() + // do not cache length because more jobs might be pushed + // as we execute existing jobs + for (var i = 0; i < this.queue.length; i++) { + var job = this.queue[i] + if (!job.cancelled) { + job.execute() + } + } + this.reset() +} + +BatcherProto.reset = function () { + this.has = utils.hash() + this.queue = [] + this.waiting = false +} + +module.exports = Batcher +}); + +require.register("yyx990803~vue@v0.10.5/src/directives/index.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + config = require("yyx990803~vue@v0.10.5/src/config.js"), + transition = require("yyx990803~vue@v0.10.5/src/transition.js"), + directives = module.exports = utils.hash() + +/** + * Nest and manage a Child VM + */ +directives.component = { + isLiteral: true, + bind: function () { + if (!this.el.vue_vm) { + this.childVM = new this.Ctor({ + el: this.el, + parent: this.vm + }) + } + }, + unbind: function () { + if (this.childVM) { + this.childVM.$destroy() + } + } +} + +/** + * Binding HTML attributes + */ +directives.attr = { + bind: function () { + var params = this.vm.$options.paramAttributes + this.isParam = params && params.indexOf(this.arg) > -1 + }, + update: function (value) { + if (value || value === 0) { + this.el.setAttribute(this.arg, value) + } else { + this.el.removeAttribute(this.arg) + } + if (this.isParam) { + this.vm[this.arg] = utils.checkNumber(value) + } + } +} + +/** + * Binding textContent + */ +directives.text = { + bind: function () { + this.attr = this.el.nodeType === 3 + ? 'nodeValue' + : 'textContent' + }, + update: function (value) { + this.el[this.attr] = utils.guard(value) + } +} + +/** + * Binding CSS display property + */ +directives.show = function (value) { + var el = this.el, + target = value ? '' : 'none', + change = function () { + el.style.display = target + } + transition(el, value ? 1 : -1, change, this.compiler) +} + +/** + * Binding CSS classes + */ +directives['class'] = function (value) { + if (this.arg) { + utils[value ? 'addClass' : 'removeClass'](this.el, this.arg) + } else { + if (this.lastVal) { + utils.removeClass(this.el, this.lastVal) + } + if (value) { + utils.addClass(this.el, value) + this.lastVal = value + } + } +} + +/** + * Only removed after the owner VM is ready + */ +directives.cloak = { + isEmpty: true, + bind: function () { + var el = this.el + this.compiler.observer.once('hook:ready', function () { + el.removeAttribute(config.prefix + '-cloak') + }) + } +} + +/** + * Store a reference to self in parent VM's $ + */ +directives.ref = { + isLiteral: true, + bind: function () { + var id = this.expression + if (id) { + this.vm.$parent.$[id] = this.vm + } + }, + unbind: function () { + var id = this.expression + if (id) { + delete this.vm.$parent.$[id] + } + } +} + +directives.on = require("yyx990803~vue@v0.10.5/src/directives/on.js") +directives.repeat = require("yyx990803~vue@v0.10.5/src/directives/repeat.js") +directives.model = require("yyx990803~vue@v0.10.5/src/directives/model.js") +directives['if'] = require("yyx990803~vue@v0.10.5/src/directives/if.js") +directives['with'] = require("yyx990803~vue@v0.10.5/src/directives/with.js") +directives.html = require("yyx990803~vue@v0.10.5/src/directives/html.js") +directives.style = require("yyx990803~vue@v0.10.5/src/directives/style.js") +directives.partial = require("yyx990803~vue@v0.10.5/src/directives/partial.js") +directives.view = require("yyx990803~vue@v0.10.5/src/directives/view.js") +}); + +require.register("yyx990803~vue@v0.10.5/src/directives/if.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js") + +/** + * Manages a conditional child VM + */ +module.exports = { + + bind: function () { + + this.parent = this.el.parentNode + this.ref = document.createComment('vue-if') + this.Ctor = this.compiler.resolveComponent(this.el) + + // insert ref + this.parent.insertBefore(this.ref, this.el) + this.parent.removeChild(this.el) + + if (utils.attr(this.el, 'view')) { + utils.warn( + 'Conflict: v-if cannot be used together with v-view. ' + + 'Just set v-view\'s binding value to empty string to empty it.' + ) + } + if (utils.attr(this.el, 'repeat')) { + utils.warn( + 'Conflict: v-if cannot be used together with v-repeat. ' + + 'Use `v-show` or the `filterBy` filter instead.' + ) + } + }, + + update: function (value) { + + if (!value) { + this.unbind() + } else if (!this.childVM) { + this.childVM = new this.Ctor({ + el: this.el.cloneNode(true), + parent: this.vm + }) + if (this.compiler.init) { + this.parent.insertBefore(this.childVM.$el, this.ref) + } else { + this.childVM.$before(this.ref) + } + } + + }, + + unbind: function () { + if (this.childVM) { + this.childVM.$destroy() + this.childVM = null + } + } +} +}); + +require.register("yyx990803~vue@v0.10.5/src/directives/repeat.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + config = require("yyx990803~vue@v0.10.5/src/config.js") + +/** + * Binding that manages VMs based on an Array + */ +module.exports = { + + bind: function () { + + this.identifier = '$r' + this.id + + // a hash to cache the same expressions on repeated instances + // so they don't have to be compiled for every single instance + this.expCache = utils.hash() + + var el = this.el, + ctn = this.container = el.parentNode + + // extract child Id, if any + this.childId = this.compiler.eval(utils.attr(el, 'ref')) + + // create a comment node as a reference node for DOM insertions + this.ref = document.createComment(config.prefix + '-repeat-' + this.key) + ctn.insertBefore(this.ref, el) + ctn.removeChild(el) + + this.collection = null + this.vms = null + + }, + + update: function (collection) { + + if (!Array.isArray(collection)) { + if (utils.isObject(collection)) { + collection = utils.objectToArray(collection) + } else { + utils.warn('v-repeat only accepts Array or Object values.') + } + } + + // keep reference of old data and VMs + // so we can reuse them if possible + this.oldVMs = this.vms + this.oldCollection = this.collection + collection = this.collection = collection || [] + + var isObject = collection[0] && utils.isObject(collection[0]) + this.vms = this.oldCollection + ? this.diff(collection, isObject) + : this.init(collection, isObject) + + if (this.childId) { + this.vm.$[this.childId] = this.vms + } + + }, + + init: function (collection, isObject) { + var vm, vms = [] + for (var i = 0, l = collection.length; i < l; i++) { + vm = this.build(collection[i], i, isObject) + vms.push(vm) + if (this.compiler.init) { + this.container.insertBefore(vm.$el, this.ref) + } else { + vm.$before(this.ref) + } + } + return vms + }, + + /** + * Diff the new array with the old + * and determine the minimum amount of DOM manipulations. + */ + diff: function (newCollection, isObject) { + + var i, l, item, vm, + oldIndex, + targetNext, + currentNext, + nextEl, + ctn = this.container, + oldVMs = this.oldVMs, + vms = [] + + vms.length = newCollection.length + + // first pass, collect new reused and new created + for (i = 0, l = newCollection.length; i < l; i++) { + item = newCollection[i] + if (isObject) { + item.$index = i + if (item.__emitter__ && item.__emitter__[this.identifier]) { + // this piece of data is being reused. + // record its final position in reused vms + item.$reused = true + } else { + vms[i] = this.build(item, i, isObject) + } + } else { + // we can't attach an identifier to primitive values + // so have to do an indexOf... + oldIndex = indexOf(oldVMs, item) + if (oldIndex > -1) { + // record the position on the existing vm + oldVMs[oldIndex].$reused = true + oldVMs[oldIndex].$data.$index = i + } else { + vms[i] = this.build(item, i, isObject) + } + } + } + + // second pass, collect old reused and destroy unused + for (i = 0, l = oldVMs.length; i < l; i++) { + vm = oldVMs[i] + item = this.arg + ? vm.$data[this.arg] + : vm.$data + if (item.$reused) { + vm.$reused = true + delete item.$reused + } + if (vm.$reused) { + // update the index to latest + vm.$index = item.$index + // the item could have had a new key + if (item.$key && item.$key !== vm.$key) { + vm.$key = item.$key + } + vms[vm.$index] = vm + } else { + // this one can be destroyed. + if (item.__emitter__) { + delete item.__emitter__[this.identifier] + } + vm.$destroy() + } + } + + // final pass, move/insert DOM elements + i = vms.length + while (i--) { + vm = vms[i] + item = vm.$data + targetNext = vms[i + 1] + if (vm.$reused) { + nextEl = vm.$el.nextSibling + // destroyed VMs' element might still be in the DOM + // due to transitions + while (!nextEl.vue_vm && nextEl !== this.ref) { + nextEl = nextEl.nextSibling + } + currentNext = nextEl.vue_vm + if (currentNext !== targetNext) { + if (!targetNext) { + ctn.insertBefore(vm.$el, this.ref) + } else { + nextEl = targetNext.$el + // new VMs' element might not be in the DOM yet + // due to transitions + while (!nextEl.parentNode) { + targetNext = vms[nextEl.vue_vm.$index + 1] + nextEl = targetNext + ? targetNext.$el + : this.ref + } + ctn.insertBefore(vm.$el, nextEl) + } + } + delete vm.$reused + delete item.$index + delete item.$key + } else { // a new vm + vm.$before(targetNext ? targetNext.$el : this.ref) + } + } + + return vms + }, + + build: function (data, index, isObject) { + + // wrap non-object values + var raw, alias, + wrap = !isObject || this.arg + if (wrap) { + raw = data + alias = this.arg || '$value' + data = {} + data[alias] = raw + } + data.$index = index + + var el = this.el.cloneNode(true), + Ctor = this.compiler.resolveComponent(el, data), + vm = new Ctor({ + el: el, + data: data, + parent: this.vm, + compilerOptions: { + repeat: true, + expCache: this.expCache + } + }) + + if (isObject) { + // attach an ienumerable identifier to the raw data + (raw || data).__emitter__[this.identifier] = true + } + + return vm + + }, + + unbind: function () { + if (this.childId) { + delete this.vm.$[this.childId] + } + if (this.vms) { + var i = this.vms.length + while (i--) { + this.vms[i].$destroy() + } + } + } +} + +// Helpers -------------------------------------------------------------------- + +/** + * Find an object or a wrapped data object + * from an Array + */ +function indexOf (vms, obj) { + for (var vm, i = 0, l = vms.length; i < l; i++) { + vm = vms[i] + if (!vm.$reused && vm.$value === obj) { + return i + } + } + return -1 +} +}); + +require.register("yyx990803~vue@v0.10.5/src/directives/on.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js") + +/** + * Binding for event listeners + */ +module.exports = { + + isFn: true, + + bind: function () { + this.context = this.binding.isExp + ? this.vm + : this.binding.compiler.vm + if (this.el.tagName === 'IFRAME' && this.arg !== 'load') { + var self = this + this.iframeBind = function () { + self.el.contentWindow.addEventListener(self.arg, self.handler) + } + this.el.addEventListener('load', this.iframeBind) + } + }, + + update: function (handler) { + if (typeof handler !== 'function') { + utils.warn('Directive "v-on:' + this.expression + '" expects a method.') + return + } + this.reset() + var vm = this.vm, + context = this.context + this.handler = function (e) { + e.targetVM = vm + context.$event = e + var res = handler.call(context, e) + context.$event = null + return res + } + if (this.iframeBind) { + this.iframeBind() + } else { + this.el.addEventListener(this.arg, this.handler) + } + }, + + reset: function () { + var el = this.iframeBind + ? this.el.contentWindow + : this.el + el.removeEventListener(this.arg, this.handler) + }, + + unbind: function () { + this.reset() + this.el.removeEventListener('load', this.iframeBind) + } +} +}); + +require.register("yyx990803~vue@v0.10.5/src/directives/model.js", function (exports, module) { +var utils = require("yyx990803~vue@v0.10.5/src/utils.js"), + isIE9 = navigator.userAgent.indexOf('MSIE 9.0') > 0, + filter = [].filter + +/** + * Returns an array of values from a multiple select + */ +function getMultipleSelectOptions (select) { + return filter + .call(select.options, function (option) { + return option.selected + }) + .map(function (option) { + return option.value || option.text + }) +} + +/** + * Two-way binding for form input elements + */ +module.exports = { + + bind: function () { + + var self = this, + el = self.el, + type = el.type, + tag = el.tagName + + self.lock = false + self.ownerVM = self.binding.compiler.vm + + // determine what event to listen to + self.event = + (self.compiler.options.lazy || + tag === 'SELECT' || + type === 'checkbox' || type === 'radio') + ? 'change' + : 'input' + + // determine the attribute to change when updating + self.attr = type === 'checkbox' + ? 'checked' + : (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA') + ? 'value' + : 'innerHTML' + + // select[multiple] support + if(tag === 'SELECT' && el.hasAttribute('multiple')) { + this.multi = true + } + + var compositionLock = false + self.cLock = function () { + compositionLock = true + } + self.cUnlock = function () { + compositionLock = false + } + el.addEventListener('compositionstart', this.cLock) + el.addEventListener('compositionend', this.cUnlock) + + // attach listener + self.set = self.filters + ? function () { + if (compositionLock) return + // if this directive has filters + // we need to let the vm.$set trigger + // update() so filters are applied. + // therefore we have to record cursor position + // so that after vm.$set changes the input + // value we can put the cursor back at where it is + var cursorPos + try { cursorPos = el.selectionStart } catch (e) {} + + self._set() + + // since updates are async + // we need to reset cursor position async too + utils.nextTick(function () { + if (cursorPos !== undefined) { + el.setSelectionRange(cursorPos, cursorPos) + } + }) + } + : function () { + if (compositionLock) return + // no filters, don't let it trigger update() + self.lock = true + + self._set() + + utils.nextTick(function () { + self.lock = false + }) + } + el.addEventListener(self.event, self.set) + + // fix shit for IE9 + // since it doesn't fire input on backspace / del / cut + if (isIE9) { + self.onCut = function () { + // cut event fires before the value actually changes + utils.nextTick(function () { + self.set() + }) + } + self.onDel = function (e) { + if (e.keyCode === 46 || e.keyCode === 8) { + self.set() + } + } + el.addEventListener('cut', self.onCut) + el.addEventListener('keyup', self.onDel) + } + }, + + _set: function () { + this.ownerVM.$set( + this.key, this.multi + ? getMultipleSelectOptions(this.el) + : this.el[this.attr] + ) + }, + + update: function (value, init) { + /* jshint eqeqeq: false */ + // sync back inline value if initial data is undefined + if (init && value === undefined) { + return this._set() + } + if (this.lock) return + var el = this.el + if (el.tagName === 'SELECT') { // select dropdown + el.selectedIndex = -1 + if(this.multi && Array.isArray(value)) { + value.forEach(this.updateSelect, this) + } else { + this.updateSelect(value) + } + } else if (el.type === 'radio') { // radio button + el.checked = value == el.value + } else if (el.type === 'checkbox') { // checkbox + el.checked = !!value + } else { + el[this.attr] = utils.guard(value) + } + }, + + updateSelect: function (value) { + /* jshint eqeqeq: false */ + // setting "; + + // Support: IE8, Opera 10-12 + // Nothing should be selected when empty strings follow ^= or $= or *= + if ( div.querySelectorAll("[t^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); + } + }); + + assert(function( div ) { + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + var input = doc.createElement("input"); + input.setAttribute( "type", "hidden" ); + div.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( div.querySelectorAll("[name=d]").length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Opera 10-11 does not throw on post-comma invalid pseudos + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } + + if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { + + assert(function( div ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( div, "div" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + // Element contains another + // Purposefully does not implement inclusive descendent + // As in, an element does not contain itself + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + )); + } : + function( a, b ) { + if ( b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = hasCompare ? + function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } + + // Calculate position if both inputs belong to the same document + compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : + + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + + // Choose the first element that is related to our preferred document + if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { + return -1; + } + if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + } : + function( a, b ) { + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Parentless nodes are either documents or disconnected + if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( (cur = cur.parentNode) ) { + ap.unshift( cur ); + } + cur = b; + while ( (cur = cur.parentNode) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[i] === bp[i] ) { + i++; + } + + return i ? + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[i], bp[i] ) : + + // Otherwise nodes in our document sort first + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; + + return doc; +}; + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); + + if ( support.matchesSelector && documentIsHTML && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch(e) {} + } + + return Sizzle( expr, document, null, [elem] ).length > 0; +}; + +Sizzle.contains = function( context, elem ) { + // Set document vars if needed + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; + +Sizzle.attr = function( elem, name ) { + // Set document vars if needed + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + // Don't get fooled by Object.prototype properties (jQuery #13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val !== undefined ? + val : + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + (val = elem.getAttributeNode(name)) && val.specified ? + val.value : + null; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( (elem = results[i++]) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + + return results; +}; + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + // If no nodeType, this is expected to be an array + while ( (node = elem[i++]) ) { + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (jQuery #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + // Do not include comment or processing instruction nodes + + return ret; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); + + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1].slice( 0, 3 ) === "nth" ) { + // nth-* requires argument + if ( !match[3] ) { + Sizzle.error( match[0] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); + match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); + + // other types prohibit arguments + } else if ( match[3] ) { + Sizzle.error( match[0] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[5] && match[2]; + + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[3] && match[4] !== undefined ) { + match[2] = match[4]; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + // Get excess from tokenize (recursively) + (excess = tokenize( unquoted, true )) && + // advance to the next closing parenthesis + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + + // excess is a negative index + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { return true; } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); + }); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; + }, + + "CHILD": function( type, what, argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, context, xml ) { + var cache, outerCache, node, diff, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( (node = node[ dir ]) ) { + if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + return false; + } + } + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + // Seek `elem` from a previously-cached index + outerCache = parent[ expando ] || (parent[ expando ] = {}); + cache = outerCache[ type ] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( (node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + (diff = nodeIndex = 0) || start.pop()) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + // Use previously-cached element index if available + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; + + // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) + } else { + // Use the same loop as above to seek `elem` from the start + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { + + if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { + // Cache the index of each encountered element + if ( useCache ) { + (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + // Potentially complex pseudos + "not": markFunction(function( selector ) { + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } + } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + // lang value must be a valid identifier + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + }, + + // Boolean properties + "enabled": function( elem ) { + return elem.disabled === false; + }, + + "disabled": function( elem ) { + return elem.disabled === true; + }, + + "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, + + "selected": function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + + // Support: IE<8 + // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); + }, + + // Position-in-collection + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), + + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), + + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), + + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; + +Expr.pseudos["nth"] = Expr.pseudos["eq"]; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +// Easy API for creating new setFilters +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); + +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + // Don't consume trailing commas as valid + soFar = soFar.slice( match[0].length ) || soFar; + } + groups.push( (tokens = []) ); + } + + matched = false; + + // Combinators + if ( (match = rcombinators.exec( soFar )) ) { + matched = match.shift(); + tokens.push({ + value: matched, + // Cast descendant combinators to space + type: match[0].replace( rtrim, " " ) + }); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + (match = preFilters[ type ]( match ))) ) { + matched = match.shift(); + tokens.push({ + value: matched, + type: type, + matches: match + }); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +} + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; + + return combinator.first ? + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var oldCache, outerCache, + newCache = [ dirruns, doneName ]; + + // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + if ( xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (oldCache = outerCache[ dir ]) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return (newCache[ 2 ] = oldCache[ 2 ]); + } else { + // Reuse newcache so results back-propagate to previous elements + outerCache[ dir ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { + return true; + } + } + } + } + } + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( (elem = temp[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + // Restore matcherIn since elem is not yet a final match + temp.push( (matcherIn[i] = elem) ); + } + } + postFinder( null, (matcherOut = []), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { + + seed[temp] = !(results[temp] = elem); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + } else { + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), + len = elems.length; + + if ( outermost ) { + outermostContext = context !== document && context; + } + + // Add elements passing elementMatchers directly to results + // Keep `i` a string if there are no elements so `matchedCount` will be "00" below + // Support: IE<9, Safari + // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id + for ( ; i !== len && (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element + if ( !group ) { + group = tokenize( selector ); + } + i = group.length; + while ( i-- ) { + cached = matcherFromTokens( group[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + } + return cached; +}; + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); + } + return results; +} + +function select( selector, context, results, seed ) { + var i, tokens, token, type, find, + match = tokenize( selector ); + + if ( !seed ) { + // Try to minimize operations if there is only one group + if ( match.length === 1 ) { + + // Take a shortcut and set the context if the root selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + support.getById && context.nodeType === 9 && documentIsHTML && + Expr.relative[ tokens[1].type ] ) { + + context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + if ( !context ) { + return results; + } + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + } + + // Compile and execute a filtering function + // Provide `match` to avoid retokenization if we modified the selector above + compile( selector, match )( + seed, + context, + !documentIsHTML, + results, + rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; +} + +// One-time assignments + +// Sort stability +support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; + +// Support: Chrome<14 +// Always assume duplicates if they aren't passed to the comparison function +support.detectDuplicates = !!hasDuplicate; + +// Initialize against the default document +setDocument(); + +// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) +// Detached nodes confoundingly follow *each other* +support.sortDetached = assert(function( div1 ) { + // Should return 1, but returns 4 (following) + return div1.compareDocumentPosition( document.createElement("div") ) & 1; +}); + +// Support: IE<8 +// Prevent attribute/property "interpolation" +// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +if ( !assert(function( div ) { + div.innerHTML = ""; + return div.firstChild.getAttribute("href") === "#" ; +}) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + }); +} + +// Support: IE<9 +// Use defaultValue in place of getAttribute("value") +if ( !support.attributes || !assert(function( div ) { + div.innerHTML = ""; + div.firstChild.setAttribute( "value", "" ); + return div.firstChild.getAttribute( "value" ) === ""; +}) ) { + addHandle( "value", function( elem, name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + }); +} + +// Support: IE<9 +// Use getAttributeNode to fetch booleans when getAttribute lies +if ( !assert(function( div ) { + return div.getAttribute("disabled") == null; +}) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return elem[ name ] === true ? name.toLowerCase() : + (val = elem.getAttributeNode( name )) && val.specified ? + val.value : + null; + } + }); +} + +return Sizzle; + +})( window ); + + + +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.pseudos; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + + +var rneedsContext = jQuery.expr.match.needsContext; + +var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); + + + +var risSimple = /^.[^:#\[\.,]*$/; + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + /* jshint -W018 */ + return !!qualifier.call( elem, i, elem ) !== not; + }); + + } + + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + }); + + } + + if ( typeof qualifier === "string" ) { + if ( risSimple.test( qualifier ) ) { + return jQuery.filter( qualifier, elements, not ); + } + + qualifier = jQuery.filter( qualifier, elements ); + } + + return jQuery.grep( elements, function( elem ) { + return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; + }); +} + +jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 && elem.nodeType === 1 ? + jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : + jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + })); +}; + +jQuery.fn.extend({ + find: function( selector ) { + var i, + len = this.length, + ret = [], + self = this; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }) ); + } + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + // Needed because $( selector, context ) becomes $( context ).find( selector ) + ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); + ret.selector = this.selector ? this.selector + " " + selector : selector; + return ret; + }, + filter: function( selector ) { + return this.pushStack( winnow(this, selector || [], false) ); + }, + not: function( selector ) { + return this.pushStack( winnow(this, selector || [], true) ); + }, + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + } +}); + + +// Initialize a jQuery object + + +// A central reference to the root jQuery(document) +var rootjQuery, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, + + init = jQuery.fn.init = function( selector, context ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + + // scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[1], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + // Properties of context are called as methods if possible + if ( jQuery.isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return typeof rootjQuery.ready !== "undefined" ? + rootjQuery.ready( selector ) : + // Execute immediately if ready is not present + selector( jQuery ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; + +// Initialize central reference +rootjQuery = jQuery( document ); + + +var rparentsprev = /^(?:parents|prev(?:Until|All))/, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.extend({ + dir: function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; + + while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; + }, + + sibling: function( n, elem ) { + var matched = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; + } +}); + +jQuery.fn.extend({ + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; + + return this.filter(function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( ; i < l; i++ ) { + for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { + // Always skip document fragments + if ( cur.nodeType < 11 && (pos ? + pos.index(cur) > -1 : + + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector(cur, selectors)) ) { + + matched.push( cur ); + break; + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return indexOf.call( jQuery( elem ), this[ 0 ] ); + } + + // Locate the position of the desired element + return indexOf.call( this, + + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, + + add: function( selector, context ) { + return this.pushStack( + jQuery.unique( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); + } +}); + +function sibling( cur, dir ) { + while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} + return cur; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return elem.contentDocument || jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); + } + + if ( this.length > 1 ) { + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.unique( matched ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } + } + + return this.pushStack( matched ); + }; +}); +var rnotwhite = (/\S+/g); + + + +// String to Object options format cache +var optionsCache = {}; + +// Convert String-formatted options into Object-formatted ones and store in cache +function createOptions( options ) { + var object = optionsCache[ options ] = {}; + jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { + object[ flag ] = true; + }); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); + + var // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = !options.once && [], + // Fire callbacks + fire = function( data ) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { + memory = false; // To prevent further calls using add + break; + } + } + firing = false; + if ( list ) { + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); + } + } else if ( memory ) { + list = []; + } else { + self.disable(); + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + // First, we save the current length + var start = list.length; + (function add( args ) { + jQuery.each( args, function( _, arg ) { + var type = jQuery.type( arg ); + if ( type === "function" ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && type !== "string" ) { + // Inspect recursively + add( arg ); + } + }); + })( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + // Handle firing indexes + if ( firing ) { + if ( index <= firingLength ) { + firingLength--; + } + if ( index <= firingIndex ) { + firingIndex--; + } + } + } + }); + } + return this; + }, + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); + }, + // Remove all callbacks from the list + empty: function() { + list = []; + firingLength = 0; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( list && ( !fired || stack ) ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( firing ) { + stack.push( args ); + } else { + fire( args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; + + +jQuery.extend({ + + Deferred: function( func ) { + var tuples = [ + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], + [ "notify", "progress", jQuery.Callbacks("memory") ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred(function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[1] ](function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .done( newDefer.resolve ) + .fail( newDefer.reject ) + .progress( newDefer.notify ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); + } + }); + }); + fns = null; + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Keep pipe for back-compat + promise.pipe = promise.then; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; + + // promise[ done | fail | progress ] = list.add + promise[ tuple[1] ] = list.add; + + // Handle state + if ( stateString ) { + list.add(function() { + // state = [ resolved | rejected ] + state = stateString; + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + } + + // deferred[ resolve | reject | notify ] + deferred[ tuple[0] ] = function() { + deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + return this; + }; + deferred[ tuple[0] + "With" ] = list.fireWith; + }); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = slice.call( arguments ), + length = resolveValues.length, + + // the count of uncompleted subordinates + remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( values === progressValues ) { + deferred.notifyWith( contexts, values ); + } else if ( !( --remaining ) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ) + .progress( updateFunc( i, progressContexts, progressValues ) ); + } else { + --remaining; + } + } + } + + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + + return deferred.promise(); + } +}); + + +// The deferred used on DOM ready +var readyList; + +jQuery.fn.ready = function( fn ) { + // Add the callback + jQuery.ready.promise().done( fn ); + + return this; +}; + +jQuery.extend({ + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger("ready").off("ready"); + } + } +}); + +/** + * The ready event handler and self cleanup method + */ +function completed() { + document.removeEventListener( "DOMContentLoaded", completed, false ); + window.removeEventListener( "load", completed, false ); + jQuery.ready(); +} + +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { + + readyList = jQuery.Deferred(); + + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( jQuery.ready ); + + } else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed, false ); + } + } + return readyList.promise( obj ); +}; + +// Kick off the DOM ready check even if the user does not +jQuery.ready.promise(); + + + + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( jQuery.type( key ) === "object" ) { + chainable = true; + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !jQuery.isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < len; i++ ) { + fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + } + } + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + len ? fn( elems[0], key ) : emptyGet; +}; + + +/** + * Determines whether an object can have data + */ +jQuery.acceptData = function( owner ) { + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + /* jshint -W018 */ + return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); +}; + + +function Data() { + // Support: Android < 4, + // Old WebKit does not have Object.preventExtensions/freeze method, + // return new empty object instead with no [[set]] accessor + Object.defineProperty( this.cache = {}, 0, { + get: function() { + return {}; + } + }); + + this.expando = jQuery.expando + Math.random(); +} + +Data.uid = 1; +Data.accepts = jQuery.acceptData; + +Data.prototype = { + key: function( owner ) { + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return the key for a frozen object. + if ( !Data.accepts( owner ) ) { + return 0; + } + + var descriptor = {}, + // Check if the owner object already has a cache key + unlock = owner[ this.expando ]; + + // If not, create one + if ( !unlock ) { + unlock = Data.uid++; + + // Secure it in a non-enumerable, non-writable property + try { + descriptor[ this.expando ] = { value: unlock }; + Object.defineProperties( owner, descriptor ); + + // Support: Android < 4 + // Fallback to a less secure definition + } catch ( e ) { + descriptor[ this.expando ] = unlock; + jQuery.extend( owner, descriptor ); + } + } + + // Ensure the cache object + if ( !this.cache[ unlock ] ) { + this.cache[ unlock ] = {}; + } + + return unlock; + }, + set: function( owner, data, value ) { + var prop, + // There may be an unlock assigned to this node, + // if there is no entry for this "owner", create one inline + // and set the unlock as though an owner entry had always existed + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + // Handle: [ owner, key, value ] args + if ( typeof data === "string" ) { + cache[ data ] = value; + + // Handle: [ owner, { properties } ] args + } else { + // Fresh assignments by object are shallow copied + if ( jQuery.isEmptyObject( cache ) ) { + jQuery.extend( this.cache[ unlock ], data ); + // Otherwise, copy the properties one-by-one to the cache object + } else { + for ( prop in data ) { + cache[ prop ] = data[ prop ]; + } + } + } + return cache; + }, + get: function( owner, key ) { + // Either a valid cache is found, or will be created. + // New caches will be created and the unlock returned, + // allowing direct access to the newly created + // empty data object. A valid owner object must be provided. + var cache = this.cache[ this.key( owner ) ]; + + return key === undefined ? + cache : cache[ key ]; + }, + access: function( owner, key, value ) { + var stored; + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ((key && typeof key === "string") && value === undefined) ) { + + stored = this.get( owner, key ); + + return stored !== undefined ? + stored : this.get( owner, jQuery.camelCase(key) ); + } + + // [*]When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); + + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, name, camel, + unlock = this.key( owner ), + cache = this.cache[ unlock ]; + + if ( key === undefined ) { + this.cache[ unlock ] = {}; + + } else { + // Support array or space separated string of keys + if ( jQuery.isArray( key ) ) { + // If "name" is an array of keys... + // When data is initially created, via ("key", "val") signature, + // keys will be converted to camelCase. + // Since there is no way to tell _how_ a key was added, remove + // both plain key and camelCase key. #12786 + // This will only penalize the array argument path. + name = key.concat( key.map( jQuery.camelCase ) ); + } else { + camel = jQuery.camelCase( key ); + // Try the string as a key before any manipulation + if ( key in cache ) { + name = [ key, camel ]; + } else { + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + name = camel; + name = name in cache ? + [ name ] : ( name.match( rnotwhite ) || [] ); + } + } + + i = name.length; + while ( i-- ) { + delete cache[ name[ i ] ]; + } + } + }, + hasData: function( owner ) { + return !jQuery.isEmptyObject( + this.cache[ owner[ this.expando ] ] || {} + ); + }, + discard: function( owner ) { + if ( owner[ this.expando ] ) { + delete this.cache[ owner[ this.expando ] ]; + } + } +}; +var data_priv = new Data(); + +var data_user = new Data(); + + + +/* + Implementation Summary + + 1. Enforce API surface and semantic compatibility with 1.9.x branch + 2. Improve the module's maintainability by reducing the storage + paths to a single mechanism. + 3. Use the same single mechanism to support "private" and "user" data. + 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) + 5. Avoid exposing implementation details on user objects (eg. expando properties) + 6. Provide a clear path for implementation upgrade to WeakMap in 2014 +*/ +var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /([A-Z])/g; + +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + data_user.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; +} + +jQuery.extend({ + hasData: function( elem ) { + return data_user.hasData( elem ) || data_priv.hasData( elem ); + }, + + data: function( elem, name, data ) { + return data_user.access( elem, name, data ); + }, + + removeData: function( elem, name ) { + data_user.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to data_priv methods, these can be deprecated. + _data: function( elem, name, data ) { + return data_priv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + data_priv.remove( elem, name ); + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var i, name, data, + elem = this[ 0 ], + attrs = elem && elem.attributes; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = data_user.get( elem ); + + if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { + i = attrs.length; + while ( i-- ) { + name = attrs[ i ].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.slice(5) ); + dataAttr( elem, name, data[ name ] ); + } + } + data_priv.set( elem, "hasDataAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + data_user.set( this, key ); + }); + } + + return access( this, function( value ) { + var data, + camelKey = jQuery.camelCase( key ); + + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { + // Attempt to get data from the cache + // with the key as-is + data = data_user.get( elem, key ); + if ( data !== undefined ) { + return data; + } + + // Attempt to get data from the cache + // with the key camelized + data = data_user.get( elem, camelKey ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, camelKey, undefined ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; + } + + // Set the data... + this.each(function() { + // First, attempt to store a copy or reference of any + // data that might've been store with a camelCased key. + var data = data_user.get( this, camelKey ); + + // For HTML5 data-* attribute interop, we have to + // store property names with dashes in a camelCase form. + // This might not apply to all properties...* + data_user.set( this, camelKey, value ); + + // *... In the case of properties that might _actually_ + // have dashes, we need to also store a copy of that + // unchanged property. + if ( key.indexOf("-") !== -1 && data !== undefined ) { + data_user.set( this, key, value ); + } + }); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each(function() { + data_user.remove( this, key ); + }); + } +}); + + +jQuery.extend({ + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = data_priv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray( data ) ) { + queue = data_priv.access( elem, type, jQuery.makeArray(data) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // not intended for public consumption - generates a queueHooks object, or returns the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return data_priv.get( elem, key ) || data_priv.access( elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + data_priv.remove( elem, [ type + "queue", key ] ); + }) + }); + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + // ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while ( i-- ) { + tmp = data_priv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +}); +var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; + +var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + +var isHidden = function( elem, el ) { + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); + }; + +var rcheckableType = (/^(?:checkbox|radio)$/i); + + + +(function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ); + + // #11217 - WebKit loses check when the name is after the checked attribute + div.innerHTML = ""; + + // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 + // old WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Make sure textarea (and checkbox) defaultValue is properly cloned + // Support: IE9-IE11+ + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; +})(); +var strundefined = typeof undefined; + + + +support.focusinBubbles = "onfocusin" in window; + + +var + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.get( elem ); + + // Don't attach events to noData or text/comment nodes (but allow plain objects) + if ( !elemData ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !(events = elemData.events) ) { + events = elemData.events = {}; + } + if ( !(eventHandle = elemData.handle) ) { + eventHandle = elemData.handle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? + jQuery.event.dispatch.apply( elem, arguments ) : undefined; + }; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !(handlers = events[ type ]) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = data_priv.hasData( elem ) && data_priv.get( elem ); + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnotwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[t] ) || []; + type = origType = tmp[1]; + namespaces = ( tmp[2] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + delete elemData.handle; + data_priv.remove( elem, "events" ); + } + }, + + trigger: function( event, data, elem, onlyHandlers ) { + + var i, cur, tmp, bubbleType, ontype, handle, special, + eventPath = [ elem || document ], + type = hasOwn.call( event, "type" ) ? event.type : event, + namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; + + cur = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf(":") < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join("."); + event.namespace_re = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === (elem.ownerDocument || document) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { + + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && handle.apply && jQuery.acceptData( cur ) ) { + event.result = handle.apply( cur, data ); + if ( event.result === false ) { + event.preventDefault(); + } + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && + jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event ); + + var i, j, ret, matched, handleObj, + handlerQueue = [], + args = slice.call( arguments ), + handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { + + // Triggered event must either 1) have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( (event.result = ret) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var i, matches, sel, handleObj, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + // Black-hole SVG instance trees (#13180) + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { + + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.disabled !== true || event.type !== "click" ) { + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matches[ sel ] === undefined ) { + matches[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) >= 0 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matches[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, handlers: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( delegateCount < handlers.length ) { + handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); + } + + return handlerQueue; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, copy, + type = event.type, + originalEvent = event, + fixHook = this.fixHooks[ type ]; + + if ( !fixHook ) { + this.fixHooks[ type ] = fixHook = + rmouseEvent.test( type ) ? this.mouseHooks : + rkeyEvent.test( type ) ? this.keyHooks : + {}; + } + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = new jQuery.Event( originalEvent ); + + i = copy.length; + while ( i-- ) { + prop = copy[ i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Support: Cordova 2.5 (WebKit) (#13255) + // All events should have a target; Cordova deviceready doesn't + if ( !event.target ) { + event.target = document; + } + + // Support: Safari 6.0+, Chrome < 28 + // Target should not be a text node (#504, #13143) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + focus: { + // Fire native event if possible so blur/focus sequence is correct + trigger: function() { + if ( this !== safeActiveElement() && this.focus ) { + this.focus(); + return false; + } + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + if ( this === safeActiveElement() && this.blur ) { + this.blur(); + return false; + } + }, + delegateType: "focusout" + }, + click: { + // For checkbox, fire native event so checked state will be right + trigger: function() { + if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { + this.click(); + return false; + } + }, + + // For cross-browser consistency, don't fire native .click() on links + _default: function( event ) { + return jQuery.nodeName( event.target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined ) { + event.originalEvent.returnValue = event.result; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +jQuery.removeEvent = function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } +}; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented || + // Support: Android < 4.0 + src.defaultPrevented === undefined && + src.getPreventDefault && src.getPreventDefault() ? + returnTrue : + returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + + if ( e && e.preventDefault ) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + + if ( e && e.stopPropagation ) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + } +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +// Support: Chrome 15+ +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// Create "bubbling" focus and blur events +// Support: Firefox, Chrome, Safari +if ( !support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler on the document while someone wants focusin/focusout + var handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + var doc = this.ownerDocument || this, + attaches = data_priv.access( doc, fix ); + + if ( !attaches ) { + doc.addEventListener( orig, handler, true ); + } + data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); + }, + teardown: function() { + var doc = this.ownerDocument || this, + attaches = data_priv.access( doc, fix ) - 1; + + if ( !attaches ) { + doc.removeEventListener( orig, handler, true ); + data_priv.remove( doc, fix ); + + } else { + data_priv.access( doc, fix, attaches ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + var elem = this[0]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +}); + + +var + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + rtagName = /<([\w:]+)/, + rhtml = /<|&#?\w+;/, + rnoInnerhtml = /<(?:script|style|link)/i, + // checked="checked" or checked + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, + rscriptType = /^$|\/(?:java|ecma)script/i, + rscriptTypeMasked = /^true\/(.*)/, + rcleanScript = /^\s*\s*$/g, + + // We have to close these tags to support XHTML (#13200) + wrapMap = { + + // Support: IE 9 + option: [ 1, "" ], + + thead: [ 1, "", "
" ], + col: [ 2, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + + _default: [ 0, "", "" ] + }; + +// Support: IE 9 +wrapMap.optgroup = wrapMap.option; + +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// Support: 1.x compatibility +// Manipulating tables requires a tbody +function manipulationTarget( elem, content ) { + return jQuery.nodeName( elem, "table" ) && + jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? + + elem.getElementsByTagName("tbody")[0] || + elem.appendChild( elem.ownerDocument.createElement("tbody") ) : + elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + var match = rscriptTypeMasked.exec( elem.type ); + + if ( match ) { + elem.type = match[ 1 ]; + } else { + elem.removeAttribute("type"); + } + + return elem; +} + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + data_priv.set( + elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) + ); + } +} + +function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( data_priv.hasData( src ) ) { + pdataOld = data_priv.access( src ); + pdataCur = data_priv.set( dest, pdataOld ); + events = pdataOld.events; + + if ( events ) { + delete pdataCur.handle; + pdataCur.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( data_user.hasData( src ) ) { + udataOld = data_user.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + data_user.set( dest, udataCur ); + } +} + +function getAll( context, tag ) { + var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : + context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : + []; + + return tag === undefined || tag && jQuery.nodeName( context, tag ) ? + jQuery.merge( [ context ], ret ) : + ret; +} + +// Support: IE >= 9 +function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +jQuery.extend({ + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = jQuery.contains( elem.ownerDocument, elem ); + + // Support: IE >= 9 + // Fix Cloning issues + if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + !jQuery.isXMLDoc( elem ) ) { + + // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + buildFragment: function( elems, context, scripts, selection ) { + var elem, tmp, tag, wrap, contains, j, + fragment = context.createDocumentFragment(), + nodes = [], + i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( jQuery.type( elem ) === "object" ) { + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement("div") ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[ 2 ]; + + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Fixes #12346 + // Support: Webkit, IE + tmp.textContent = ""; + } + } + } + + // Remove wrapper from fragment + fragment.textContent = ""; + + i = 0; + while ( (elem = nodes[ i++ ]) ) { + + // #4087 - If origin and destination elements are the same, and this is + // that element, do not do anything + if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { + continue; + } + + contains = jQuery.contains( elem.ownerDocument, elem ); + + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( contains ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( (elem = tmp[ j++ ]) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + return fragment; + }, + + cleanData: function( elems ) { + var data, elem, events, type, key, j, + special = jQuery.event.special, + i = 0; + + for ( ; (elem = elems[ i ]) !== undefined; i++ ) { + if ( jQuery.acceptData( elem ) ) { + key = elem[ data_priv.expando ]; + + if ( key && (data = data_priv.cache[ key ]) ) { + events = Object.keys( data.events || {} ); + if ( events.length ) { + for ( j = 0; (type = events[j]) !== undefined; j++ ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + if ( data_priv.cache[ key ] ) { + // Discard any remaining `private` data + delete data_priv.cache[ key ]; + } + } + } + // Discard any remaining `user` data + delete data_user.cache[ elem[ data_user.expando ] ]; + } + } +}); + +jQuery.fn.extend({ + text: function( value ) { + return access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().each(function() { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.textContent = value; + } + }); + }, null, value, arguments.length ); + }, + + append: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + }); + }, + + prepend: function() { + return this.domManip( arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + }); + }, + + before: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + }); + }, + + after: function() { + return this.domManip( arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + }); + }, + + remove: function( selector, keepData /* Internal Use Only */ ) { + var elem, + elems = selector ? jQuery.filter( selector, this ) : this, + i = 0; + + for ( ; (elem = elems[i]) != null; i++ ) { + if ( !keepData && elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem ) ); + } + + if ( elem.parentNode ) { + if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { + setGlobalEval( getAll( elem, "script" ) ); + } + elem.parentNode.removeChild( elem ); + } + } + + return this; + }, + + empty: function() { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + if ( elem.nodeType === 1 ) { + + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); + + // Remove any remaining nodes + elem.textContent = ""; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map(function() { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + }); + }, + + html: function( value ) { + return access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { + + value = value.replace( rxhtmlTag, "<$1>" ); + + try { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch( e ) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var arg = arguments[ 0 ]; + + // Make the changes, replacing each context element with the new content + this.domManip( arguments, function( elem ) { + arg = this.parentNode; + + jQuery.cleanData( getAll( this ) ); + + if ( arg ) { + arg.replaceChild( elem, this ); + } + }); + + // Force removal if there was no new content (e.g., from empty arguments) + return arg && (arg.length || arg.nodeType) ? this : this.remove(); + }, + + detach: function( selector ) { + return this.remove( selector, true ); + }, + + domManip: function( args, callback ) { + + // Flatten any nested arrays + args = concat.apply( [], args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = this.length, + set = this, + iNoClone = l - 1, + value = args[ 0 ], + isFunction = jQuery.isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( isFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return this.each(function( index ) { + var self = set.eq( index ); + if ( isFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + self.domManip( args, callback ); + }); + } + + if ( l ) { + fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + if ( first ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + // Support: QtWebKit + // jQuery.merge because push.apply(_, arraylike) throws + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( this[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { + + if ( node.src ) { + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl ) { + jQuery._evalUrl( node.src ); + } + } else { + jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); + } + } + } + } + } + } + + return this; + } +}); + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); + + // Support: QtWebKit + // .get() because push.apply(_, arraylike) throws + push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +}); + + +var iframe, + elemdisplay = {}; + +/** + * Retrieve the actual display of a element + * @param {String} name nodeName of the element + * @param {Object} doc Document object + */ +// Called only from within defaultDisplay +function actualDisplay( name, doc ) { + var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), + + // getDefaultComputedStyle might be reliably used only on attached element + display = window.getDefaultComputedStyle ? + + // Use of this method is a temporary fix (more like optmization) until something better comes along, + // since it was removed from specification and supported only in FF + window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" ); + + // We don't have any data stored on the element, + // so use "detach" method as fast way to get rid of the element + elem.detach(); + + return display; +} + +/** + * Try to determine the default display value of an element + * @param {String} nodeName + */ +function defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; + + if ( !display ) { + display = actualDisplay( nodeName, doc ); + + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { + + // Use the already-created iframe if possible + iframe = (iframe || jQuery( "