/*! ranegPicker v1.0 (c) 2013 Yair Even Or MIT-style license. */ ; (function ($) { "use strict"; var $doc = $(document), RangePicker, lastValue, // DOM structure Template = $('<div class="rangePicker"> \ <div class="wrap"> \ <div class="preset"></div> \ <div class="custom"> \ <div class="calendar from"><strong></strong></div> \ <div class="calendar to"></div> \ <footer> \ <button type="button" class="confirm btn btn-primary"></button> \ <button type="button" class="cancel btn"></button> \ </footer> \ </div> \ </div> \ </div>'); RangePicker = function (obj, settings, callback) { this.settings = settings; this.picker = Template.clone(); this.obj = $(obj); this.callback = typeof callback == 'function' ? callback : null; this.result; // the chosen date // set direction mode if (this.settings.RTL) this.picker.addClass('RTL'); // inject picker this.picker.insertAfter(this.obj); // for positioning this.tether = new Tether({ element: this.picker, target: this.obj, attachment: this.settings.RTL ? 'top right' : 'top left', targetAttachment: this.settings.RTL ? 'bottom right' : 'bottom left', constraints: [{ to: 'window', attachment: 'together' }] }) }; RangePicker.prototype = { // prepare the DOM for a new picker init: function () { var i, len; // prevent bubbling of clicking inside the picker to the outside this.picker.add(this.obj).on('mousedown', function (e) { e.stopPropagation() }); var that = this, presetWrap = this.picker.find('.preset'), presetDefault = null, years = '', months = '', startYear = this.settings.minDate[1], endYear = this.settings.maxDate[1], totalYears = endYear - startYear, month, button, i; // add the "custom" preset to the array of presets // this.settings.presets.push({ buttonText:'custom', value:'custom' }); // presets for (i = this.settings.presets.length; i--;) { presetWrap.prepend("<button type='button' value='" + this.settings.presets[i].value + "'>" + this.settings.presets[i].buttonText + "</button>"); } this.presets = presetWrap.find('button'); // add indexes to match them for the right place in the this.result array this.calendar = { from: this.picker.find('.calendar.from'), to: this.picker.find('.calendar.to') } //2017-04-24init btn text this.picker.find('.confirm.btn.btn-primary').html(this.settings.ConfirmBtnText); this.picker.find('.cancel.btn').html(this.settings.CancelBtnText); // years for (i = totalYears + 1; i--;) { years += '<option value="' + (endYear - i) + '">' + (endYear - i) + '</option>'; } // months for (i = 0, len = this.settings.months.length; i < len; i++) { month = '<button>' + this.settings.months[i] + '</button>'; months += month; } // generate "custom" markup for years and months this.calendar.from.append( $('<select>').html(years), // years.replace(/%%/g,'From - ') $('<div>').addClass('months').html(months) ); this.calendar.to.append(this.calendar.from.html()); this.yearSelectors = this.picker.find('select'); this.yearSelectors.addClass('form-control'); // pre-select the last year for the END picker // link each <select> to the other one for validation purposes this.yearSelectors[0].selectedIndex = this.yearSelectors[1].selectedIndex = totalYears; this.bind(); // preselect years: this.yearSelectors.trigger('change'); if (this.settings.setDate) this.update(this.settings.setDate); }, bind: function () { var that = this; // when clicking the input object bound to this picker, show the picker this.obj.on('click', function () { that.show.apply(that) }); this.picker .on('click', '.preset > button', that.presetClick.bind(that)) .on('click.dp', '.months > button', that.monthClick.bind(that)) .on('change', 'select', that.changeYear.bind(that)) .on('click', '.confirm', that.applyDate.bind(that)) .on('click', '.cancel', that.cancel.bind(that)) }, destroy: function () { this.picker.remove(); this.obj.removeData('_ranegPicker'); }, show: function () { var that = this; // hide all other pickers, if present on the page $('.rangePicker.show').removeClass('show'); if (this.picker.hasClass('show')) { this.hide(); return; } this.picker.addClass('show'); // close picker when clicking outside setTimeout(function () { $doc.on('mousedown._rp', function () { that.cancel.apply(that); }); }, 100); this.tether.position(); this.obj.trigger('datePicker.show'); //2017-04-24增加,直接进入自定义期间选择 if (this.settings.onlyCustom) { this.changePreset('custom'); } }, hide: function () { this.picker.removeClass('show'); $doc.off('mousedown._rp'); }, cancel: function () { // reverse changes this.update(lastValue); this.hide(); }, monthClick: function (e) { var calendarIdx = $(e.target).parents('.calendar').index(), monthIdx = $(e.target).index(); this.changeMonth(calendarIdx, monthIdx); }, // when clicking the "apply" button applyDate: function () { this.update(); if (this.settings.closeOnSelect) this.hide(); this.obj.trigger('datePicker.done', [this.result]); }, presetClick: function (e) { this.changePreset(e.target.value); }, // change selected preset and remove the selection from the custom area changePreset: function (val) { var presetWrap = this.presets.parent(); this.summary(); if (val) { this.presets.removeClass('selected').filter('[value=' + val + ']').addClass('selected'); // set the result presetWrap.addClass('set'); // remove the custom range selections if (val == 'custom') { this.picker.addClass('custom'); this.applyBtnState(); } else { this.result = val; this.picker.find('.months').find('.selected').removeClass('selected'); this.picker.removeClass('custom'); this.applyDate(); } } }, // make sure the all options for the END year will be valid, relative to the chosen START year valideEndYear: function () { var index = this.yearSelectors[0].selectedIndex; // hide irrelevant options in the END year selector this.yearSelectors.eq(1).find('option').hide().slice(index).show(); if (this.yearSelectors[1].selectedIndex < index) { this.yearSelectors[1].selectedIndex = index; this.result[1][1] = this.result[0][1] } }, // disable irrelevant months validMonthsInYear: function (reset) { var that = this, monthsElements; // both month pickers must be validated because they are "linked" to each-other. this.yearSelectors.each(function () { monthsElements = $(this).next('.months').find('button'); // reset all months if (reset) monthsElements.prop('disabled', false); // for FIRST year if (this.selectedIndex == 0) monthsElements.slice(0, that.settings.minDate[0] - 1).prop('disabled', true); // for LAST year if (this.selectedIndex == (this.length - 1)) monthsElements.slice(that.settings.maxDate[0]).prop('disabled', true); }); }, changeYear: function (e) { var that = this, calendarIdx = this.yearSelectors.index(e.target); // FROM or TO range this.changePreset(); this.validMonthsInYear(true); if (calendarIdx == 0) this.valideEndYear(); if (typeof this.result != 'object') this.result = [[], []]; // on year change, reset last selected month $(e.target).next('.months').find('.selected').removeAttr('class'); this.result[calendarIdx][0] = undefined; // set the result this.result[calendarIdx][1] = e.target.value | 0; // disable the dates of the "TO" calendar which are in the relative past if (calendarIdx == 1) this.picker.find('.calendar.from').find('.selected').trigger('click.dp'); this.summary(); this.applyBtnState(); }, // validate months in one picker, relative to the other, to prevent "illegal" time-frame selections changeMonth: function (calendarIdx, monthIdx) { var that = this, monthBtn = this.picker.find('.calendar').eq(calendarIdx).find('button').eq(monthIdx); monthBtn.addClass('selected').siblings().removeClass('selected'); // it can also be a "string" when a preset was previously selected,so the result object needs to be reset if (typeof this.result != 'object') { this.result = [[undefined, this.yearSelectors[0].value | 0], [undefined, this.yearSelectors[1].value | 0]]; } this.result[calendarIdx][0] = monthIdx + 1; this.changePreset(); // if both month pickers are currently at the same year, disable the END month which are in the "relative" past // & only the START month picker should affect the END picker and disable its "past" buttons if (this.result[0][1] == this.result[1][1] && calendarIdx == 0) { this.picker.find('.calendar.to').find('button').prop('disabled', false).slice(0, monthIdx).prop('disabled', true).removeClass('selected'); // update the result if the "TO" value is now invalid because it's in the relative PAST to the "FROM" value if (this.result[0][0] > this.result[1][0]) this.result[1][0] = ''; // if is also the last available year if (this.result[0][1] == this.settings.maxDate[1]) this.validMonthsInYear(false); } // set the year (should happen here as well) this.result[0][1] = this.yearSelectors[0].value; this.result[1][1] = this.yearSelectors[1].value; this.applyBtnState(!this.validateResult()); }, // update the state (disabled/enabled) of the control buttons (apply) applyBtnState: function (state) { if (state !== false) state = (typeof this.result == 'string') || !this.validateResult(); this.picker.find('.confirm').prop('disabled', state); }, // validate the result object // disable the "apply" button if validation fails validateResult: function (result) { result = result || this.result; if (typeof this.result == 'object') { if (result[0].length < 2 || result[1].length < 2 || !result[0][0] || !result[1][0] // if there is no value || result[0][1] < this.settings.minDate[1] || result[0][1] > this.settings.maxDate[1] // if START year is in the range || result[1][1] < this.settings.minDate[1] || result[1][1] > this.settings.maxDate[1] // if END year is in the range || result[0][1] > result[1][1] // if START year is bigger than END year || result[0][0] < 0 || result[0][0] > 12 || result[1][0] < 0 || result[1][0] > 12 || (result[0][1] == result[1][1] && result[0][0] > result[1][0]) // if START year == END year, then START month should be before the END month in the timeframe ) return false; } return true; }, changeCalendar: function (result) { if (!this.validateResult(result)) return false; var that = this; // Years this.yearSelectors[0].value = +result[0][1]; this.yearSelectors[1].value = +result[1][1]; this.valideEndYear(); // Months this.validMonthsInYear(true); this.picker.find('.months').each(function (i) { that.changeMonth(i, result[i][0] - 1); }); this.summary(); return this; }, summary: function (calendarIdx) { if (!this.result) return this; var from = '', to = ''; if (typeof this.result != 'string') { if (this.result[0][0] && this.result[0][1]) from = '<span>' + this.displayValue('%S') + '</span>'; if (this.result[1][0] && this.result[1][1]) to = '<span>' + this.displayValue('%E') + '</span>'; } this.calendar.from.find('strong').html(from); this.calendar.to.find('strong').html(to); }, // human-readable format for custom date displayValue: function (format) { format = format || '%S - %E'; format = format.replace('%S', this.result[0][1] + '-' + this.settings.months[this.result[0][0] - 1]); format = format.replace('%E', this.result[1][1] + '-' + this.settings.months[this.result[1][0] - 1]); return format; }, update: function (result) { var displayValue = ''; if (result) { this.result = result; // if it's a preset if (typeof result == 'string') { this.changePreset(result); return this; } if (!this.changeCalendar(result)) return this; this.changePreset('custom'); } result = result || this.result || this.settings.presets[0].value; // update the object which had triggered rangePicker if (typeof result == 'string') { for (var i = this.settings.presets.length; i--;) { if (this.settings.presets[i].value == result) { displayValue = this.settings.presets[i].displayText; break; } } } else { // parse it displayValue = this.displayValue(); // normalize result type to "Number" result[0][1] = +result[0][1]; result[1][1] = +result[1][1]; } if (displayValue != undefined) this.obj[0].value = displayValue; lastValue = (typeof result == 'string') ? result : $.extend(true, {}, result); this.result = result; return this; } }; //////////////////////////////////// // jQuery plugin intitilization $.fn.rangePicker = function (settings, callback) { return this.each(function () { var $obj = $(this), $settings, rangePicker; if ($obj.data('_ranegPicker')) { rangePicker = $obj.data('_ranegPicker'); if (settings.setDate) rangePicker.update(settings.setDate); return this; } else $settings = $.extend(true, {}, $.fn.rangePicker.defaults, settings || {}); // when calling rangePicker without any settings, only callback if (typeof settings == 'function') callback = settings; rangePicker = new RangePicker($obj, $settings, callback); rangePicker.init(); // save this instance on the element it's bound to $obj.data('_ranegPicker', rangePicker); }); }; //////////////////////////////////// // Defaults $.fn.rangePicker.defaults = { RTL: false, closeOnSelect: true, //2017-04-24 删除,因为不需要左边的预设,原版请参照https://github.com/yairEO/dateRangePicker/tree/gh-pages //presets: [{ // buttonText: '1 month', // displayText: 'one month', // value: '1m' //}, { // buttonText: '3 months', // displayText: 'three months', // value: '3m' //}, { // buttonText: '6 months', // displayText: 'six months', // value: '6m' //}, { // buttonText: '12 months', // displayText: 'twelve months', // value: '12m', //}, { // buttonText: 'Custom', // displayText: 'twelve months', // value: 'custom' //}], presets: [], months: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'], minDate: [5, 2006], maxDate: [8, 2013], setDate: null, //2017-04-24 增设是否只有自定义,直接在打开时执行一次自定义选择事件 onlyCustom: false, ConfirmBtnText: 'Apply', CancelBtnText: 'Cancel' }; })(window.jQuery); /*! tether 0.6.5 */ !function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e(require,exports,module):t.Tether=e()}(this,function(){return function(){var t,e,o,i,n,s,l,r,h,a,f,p,u,d,g,c,m,b,v,y={}.hasOwnProperty,w=[].indexOf||function(t){for(var e=0,o=this.length;o>e;e++)if(e in this&&this[e]===t)return e;return-1},C=[].slice;null==this.Tether&&(this.Tether={modules:[]}),p=function(t){var e,o,i,n,s;if(o=getComputedStyle(t).position,"fixed"===o)return t;for(i=void 0,e=t;e=e.parentNode;){try{n=getComputedStyle(e)}catch(l){}if(null==n)return e;if(/(auto|scroll)/.test(n.overflow+n.overflowY+n.overflowX)&&("absolute"!==o||"relative"===(s=n.position)||"absolute"===s||"fixed"===s))return e}return document.body},m=function(){var t;return t=0,function(){return t++}}(),v={},a=function(t){var e,i,s,l,r;if(s=t._tetherZeroElement,null==s&&(s=t.createElement("div"),s.setAttribute("data-tether-id",m()),n(s.style,{top:0,left:0,position:"absolute"}),t.body.appendChild(s),t._tetherZeroElement=s),e=s.getAttribute("data-tether-id"),null==v[e]){v[e]={},r=s.getBoundingClientRect();for(i in r)l=r[i],v[e][i]=l;o(function(){return v[e]=void 0})}return v[e]},d=null,l=function(t){var e,o,i,n,s,l,r;t===document?(o=document,t=document.documentElement):o=t.ownerDocument,i=o.documentElement,e={},r=t.getBoundingClientRect();for(n in r)l=r[n],e[n]=l;return s=a(o),e.top-=s.top,e.left-=s.left,null==e.width&&(e.width=document.body.scrollWidth-e.left-e.right),null==e.height&&(e.height=document.body.scrollHeight-e.top-e.bottom),e.top=e.top-i.clientTop,e.left=e.left-i.clientLeft,e.right=o.body.clientWidth-e.width-e.left,e.bottom=o.body.clientHeight-e.height-e.top,e},h=function(t){return t.offsetParent||document.documentElement},f=function(){var t,e,o,i,s;return t=document.createElement("div"),t.style.width="100%",t.style.height="200px",e=document.createElement("div"),n(e.style,{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",width:"200px",height:"150px",overflow:"hidden"}),e.appendChild(t),document.body.appendChild(e),i=t.offsetWidth,e.style.overflow="scroll",s=t.offsetWidth,i===s&&(s=e.clientWidth),document.body.removeChild(e),o=i-s,{width:o,height:o}},n=function(t){var e,o,i,n,s,l,r;for(null==t&&(t={}),e=[],Array.prototype.push.apply(e,arguments),r=e.slice(1),s=0,l=r.length;l>s;s++)if(i=r[s])for(o in i)y.call(i,o)&&(n=i[o],t[o]=n);return t},g=function(t,e){var o,i,n,s,l,h;if(null!=t.classList){for(l=e.split(" "),h=[],n=0,s=l.length;s>n;n++)i=l[n],i.trim()&&h.push(t.classList.remove(i));return h}return o=r(t).replace(new RegExp("(^| )"+e.split(" ").join("|")+"( |$)","gi")," "),c(t,o)},e=function(t,e){var o,i,n,s,l;if(null!=t.classList){for(s=e.split(" "),l=[],i=0,n=s.length;n>i;i++)o=s[i],o.trim()&&l.push(t.classList.add(o));return l}return g(t,e),o=r(t)+(" "+e),c(t,o)},u=function(t,e){return null!=t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(r(t))},r=function(t){return t.className instanceof SVGAnimatedString?t.className.baseVal:t.className},c=function(t,e){return t.setAttribute("class",e)},b=function(t,o,i){var n,s,l,r,h,a;for(s=0,r=i.length;r>s;s++)n=i[s],w.call(o,n)<0&&u(t,n)&&g(t,n);for(a=[],l=0,h=o.length;h>l;l++)n=o[l],a.push(u(t,n)?void 0:e(t,n));return a},i=[],o=function(t){return i.push(t)},s=function(){var t,e;for(e=[];t=i.pop();)e.push(t());return e},t=function(){function t(){}return t.prototype.on=function(t,e,o,i){var n;return null==i&&(i=!1),null==this.bindings&&(this.bindings={}),null==(n=this.bindings)[t]&&(n[t]=[]),this.bindings[t].push({handler:e,ctx:o,once:i})},t.prototype.once=function(t,e,o){return this.on(t,e,o,!0)},t.prototype.off=function(t,e){var o,i,n;if(null!=(null!=(i=this.bindings)?i[t]:void 0)){if(null==e)return delete this.bindings[t];for(o=0,n=[];o<this.bindings[t].length;)n.push(this.bindings[t][o].handler===e?this.bindings[t].splice(o,1):o++);return n}},t.prototype.trigger=function(){var t,e,o,i,n,s,l,r,h;if(o=arguments[0],t=2<=arguments.length?C.call(arguments,1):[],null!=(l=this.bindings)?l[o]:void 0){for(n=0,h=[];n<this.bindings[o].length;)r=this.bindings[o][n],i=r.handler,e=r.ctx,s=r.once,i.apply(null!=e?e:this,t),h.push(s?this.bindings[o].splice(n,1):n++);return h}},t}(),this.Tether.Utils={getScrollParent:p,getBounds:l,getOffsetParent:h,extend:n,addClass:e,removeClass:g,hasClass:u,updateClasses:b,defer:o,flush:s,uniqueId:m,Evented:t,getScrollBarSize:f}}.call(this),function(){var t,e,o,i,n,s,l,r,h,a,f,p,u,d,g,c,m,b,v,y,w,C,O,T,x,A,E,S,W,M=[].slice,z=function(t,e){return function(){return t.apply(e,arguments)}};if(null==this.Tether)throw new Error("You must include the utils.js file before tether.js");i=this.Tether,W=i.Utils,c=W.getScrollParent,m=W.getSize,d=W.getOuterSize,p=W.getBounds,u=W.getOffsetParent,a=W.extend,n=W.addClass,O=W.removeClass,A=W.updateClasses,h=W.defer,f=W.flush,g=W.getScrollBarSize,E=function(t,e,o){return null==o&&(o=1),t+o>=e&&e>=t-o},x=function(){var t,e,o,i,n;for(t=document.createElement("div"),n=["transform","webkitTransform","OTransform","MozTransform","msTransform"],o=0,i=n.length;i>o;o++)if(e=n[o],void 0!==t.style[e])return e}(),T=[],C=function(){var t,e,o;for(e=0,o=T.length;o>e;e++)t=T[e],t.position(!1);return f()},b=function(){var t;return null!=(t="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance.now():void 0)?t:+new Date},function(){var t,e,o,i,n,s,l,r,h;for(e=null,o=null,i=null,n=function(){if(null!=o&&o>16)return o=Math.min(o-16,250),void(i=setTimeout(n,250));if(!(null!=e&&b()-e<10))return null!=i&&(clearTimeout(i),i=null),e=b(),C(),o=b()-e},r=["resize","scroll","touchmove"],h=[],s=0,l=r.length;l>s;s++)t=r[s],h.push(window.addEventListener(t,n));return h}(),t={center:"center",left:"right",right:"left"},e={middle:"middle",top:"bottom",bottom:"top"},o={top:0,left:0,middle:"50%",center:"50%",bottom:"100%",right:"100%"},r=function(o,i){var n,s;return n=o.left,s=o.top,"auto"===n&&(n=t[i.left]),"auto"===s&&(s=e[i.top]),{left:n,top:s}},l=function(t){var e,i;return{left:null!=(e=o[t.left])?e:t.left,top:null!=(i=o[t.top])?i:t.top}},s=function(){var t,e,o,i,n,s,l;for(e=1<=arguments.length?M.call(arguments,0):[],o={top:0,left:0},n=0,s=e.length;s>n;n++)l=e[n],i=l.top,t=l.left,"string"==typeof i&&(i=parseFloat(i,10)),"string"==typeof t&&(t=parseFloat(t,10)),o.top+=i,o.left+=t;return o},v=function(t,e){return"string"==typeof t.left&&-1!==t.left.indexOf("%")&&(t.left=parseFloat(t.left,10)/100*e.width),"string"==typeof t.top&&-1!==t.top.indexOf("%")&&(t.top=parseFloat(t.top,10)/100*e.height),t},y=w=function(t){var e,o,i;return i=t.split(" "),o=i[0],e=i[1],{top:o,left:e}},S=function(){function t(t){this.position=z(this.position,this);var e,o,n,s,l;for(T.push(this),this.history=[],this.setOptions(t,!1),s=i.modules,o=0,n=s.length;n>o;o++)e=s[o],null!=(l=e.initialize)&&l.call(this);this.position()}return t.modules=[],t.prototype.getClass=function(t){var e,o;return(null!=(e=this.options.classes)?e[t]:void 0)?this.options.classes[t]:(null!=(o=this.options.classes)?o[t]:void 0)!==!1?this.options.classPrefix?""+this.options.classPrefix+"-"+t:t:""},t.prototype.setOptions=function(t,e){var o,i,s,l,r,h;for(this.options=t,null==e&&(e=!0),o={offset:"0 0",targetOffset:"0 0",targetAttachment:"auto auto",classPrefix:"tether"},this.options=a(o,this.options),r=this.options,this.element=r.element,this.target=r.target,this.targetModifier=r.targetModifier,"viewport"===this.target?(this.target=document.body,this.targetModifier="visible"):"scroll-handle"===this.target&&(this.target=document.body,this.targetModifier="scroll-handle"),h=["element","target"],s=0,l=h.length;l>s;s++){if(i=h[s],null==this[i])throw new Error("Tether Error: Both element and target must be defined");null!=this[i].jquery?this[i]=this[i][0]:"string"==typeof this[i]&&(this[i]=document.querySelector(this[i]))}if(n(this.element,this.getClass("element")),n(this.target,this.getClass("target")),!this.options.attachment)throw new Error("Tether Error: You must provide an attachment");return this.targetAttachment=y(this.options.targetAttachment),this.attachment=y(this.options.attachment),this.offset=w(this.options.offset),this.targetOffset=w(this.options.targetOffset),null!=this.scrollParent&&this.disable(),this.scrollParent="scroll-handle"===this.targetModifier?this.target:c(this.target),this.options.enabled!==!1?this.enable(e):void 0},t.prototype.getTargetBounds=function(){var t,e,o,i,n,s,l,r,h;if(null==this.targetModifier)return p(this.target);switch(this.targetModifier){case"visible":return this.target===document.body?{top:pageYOffset,left:pageXOffset,height:innerHeight,width:innerWidth}:(t=p(this.target),n={height:t.height,width:t.width,top:t.top,left:t.left},n.height=Math.min(n.height,t.height-(pageYOffset-t.top)),n.height=Math.min(n.height,t.height-(t.top+t.height-(pageYOffset+innerHeight))),n.height=Math.min(innerHeight,n.height),n.height-=2,n.width=Math.min(n.width,t.width-(pageXOffset-t.left)),n.width=Math.min(n.width,t.width-(t.left+t.width-(pageXOffset+innerWidth))),n.width=Math.min(innerWidth,n.width),n.width-=2,n.top<pageYOffset&&(n.top=pageYOffset),n.left<pageXOffset&&(n.left=pageXOffset),n);case"scroll-handle":return h=this.target,h===document.body?(h=document.documentElement,t={left:pageXOffset,top:pageYOffset,height:innerHeight,width:innerWidth}):t=p(h),r=getComputedStyle(h),o=h.scrollWidth>h.clientWidth||"scroll"===[r.overflow,r.overflowX]||this.target!==document.body,s=0,o&&(s=15),i=t.height-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth)-s,n={width:15,height:.975*i*(i/h.scrollHeight),left:t.left+t.width-parseFloat(r.borderLeftWidth)-15},e=0,408>i&&this.target===document.body&&(e=-11e-5*Math.pow(i,2)-.00727*i+22.58),this.target!==document.body&&(n.height=Math.max(n.height,24)),l=this.target.scrollTop/(h.scrollHeight-i),n.top=l*(i-n.height-e)+t.top+parseFloat(r.borderTopWidth),this.target===document.body&&(n.height=Math.max(n.height,24)),n}},t.prototype.clearCache=function(){return this._cache={}},t.prototype.cache=function(t,e){return null==this._cache&&(this._cache={}),null==this._cache[t]&&(this._cache[t]=e.call(this)),this._cache[t]},t.prototype.enable=function(t){return null==t&&(t=!0),n(this.target,this.getClass("enabled")),n(this.element,this.getClass("enabled")),this.enabled=!0,this.scrollParent!==document&&this.scrollParent.addEventListener("scroll",this.position),t?this.position():void 0},t.prototype.disable=function(){return O(this.target,this.getClass("enabled")),O(this.element,this.getClass("enabled")),this.enabled=!1,null!=this.scrollParent?this.scrollParent.removeEventListener("scroll",this.position):void 0},t.prototype.destroy=function(){var t,e,o,i,n;for(this.disable(),n=[],t=o=0,i=T.length;i>o;t=++o){if(e=T[t],e===this){T.splice(t,1);break}n.push(void 0)}return n},t.prototype.updateAttachClasses=function(t,e){var o,i,n,s,l,r,a,f,p,u=this;for(null==t&&(t=this.attachment),null==e&&(e=this.targetAttachment),s=["left","top","bottom","right","middle","center"],(null!=(p=this._addAttachClasses)?p.length:void 0)&&this._addAttachClasses.splice(0,this._addAttachClasses.length),o=null!=this._addAttachClasses?this._addAttachClasses:this._addAttachClasses=[],t.top&&o.push(""+this.getClass("element-attached")+"-"+t.top),t.left&&o.push(""+this.getClass("element-attached")+"-"+t.left),e.top&&o.push(""+this.getClass("target-attached")+"-"+e.top),e.left&&o.push(""+this.getClass("target-attached")+"-"+e.left),i=[],l=0,a=s.length;a>l;l++)n=s[l],i.push(""+this.getClass("element-attached")+"-"+n);for(r=0,f=s.length;f>r;r++)n=s[r],i.push(""+this.getClass("target-attached")+"-"+n);return h(function(){return null!=u._addAttachClasses?(A(u.element,u._addAttachClasses,i),A(u.target,u._addAttachClasses,i),u._addAttachClasses=void 0):void 0})},t.prototype.position=function(t){var e,o,n,h,a,d,c,m,b,y,w,C,O,T,x,A,E,S,W,M,z,B,P,_,F,L,Y,H,X,N,j,R,U,q,k,D=this;if(null==t&&(t=!0),this.enabled){for(this.clearCache(),M=r(this.targetAttachment,this.attachment),this.updateAttachClasses(this.attachment,M),e=this.cache("element-bounds",function(){return p(D.element)}),F=e.width,n=e.height,0===F&&0===n&&null!=this.lastSize?(N=this.lastSize,F=N.width,n=N.height):this.lastSize={width:F,height:n},P=B=this.cache("target-bounds",function(){return D.getTargetBounds()}),b=v(l(this.attachment),{width:F,height:n}),z=v(l(M),P),a=v(this.offset,{width:F,height:n}),d=v(this.targetOffset,P),b=s(b,a),z=s(z,d),h=B.left+z.left-b.left,_=B.top+z.top-b.top,j=i.modules,L=0,H=j.length;H>L;L++)if(c=j[L],x=c.position.call(this,{left:h,top:_,targetAttachment:M,targetPos:B,attachment:this.attachment,elementPos:e,offset:b,targetOffset:z,manualOffset:a,manualTargetOffset:d,scrollbarSize:S}),null!=x&&"object"==typeof x){if(x===!1)return!1;_=x.top,h=x.left}if(m={page:{top:_,left:h},viewport:{top:_-pageYOffset,bottom:pageYOffset-_-n+innerHeight,left:h-pageXOffset,right:pageXOffset-h-F+innerWidth}},document.body.scrollWidth>window.innerWidth&&(S=this.cache("scrollbar-size",g),m.viewport.bottom-=S.height),document.body.scrollHeight>window.innerHeight&&(S=this.cache("scrollbar-size",g),m.viewport.right-=S.width),(""!==(R=document.body.style.position)&&"static"!==R||""!==(U=document.body.parentElement.style.position)&&"static"!==U)&&(m.page.bottom=document.body.scrollHeight-_-n,m.page.right=document.body.scrollWidth-h-F),(null!=(q=this.options.optimizations)?q.moveElement:void 0)!==!1&&null==this.targetModifier){for(w=this.cache("target-offsetparent",function(){return u(D.target)}),T=this.cache("target-offsetparent-bounds",function(){return p(w)}),O=getComputedStyle(w),o=getComputedStyle(this.element),C=T,y={},k=["Top","Left","Bottom","Right"],Y=0,X=k.length;X>Y;Y++)W=k[Y],y[W.toLowerCase()]=parseFloat(O["border"+W+"Width"]);T.right=document.body.scrollWidth-T.left-C.width+y.right,T.bottom=document.body.scrollHeight-T.top-C.height+y.bottom,m.page.top>=T.top+y.top&&m.page.bottom>=T.bottom&&m.page.left>=T.left+y.left&&m.page.right>=T.right&&(E=w.scrollTop,A=w.scrollLeft,m.offset={top:m.page.top-T.top+E-y.top,left:m.page.left-T.left+A-y.left})}return this.move(m),this.history.unshift(m),this.history.length>3&&this.history.pop(),t&&f(),!0}},t.prototype.move=function(t){var e,o,i,n,s,l,r,f,p,d,g,c,m,b,v,y,w,C=this;if(null!=this.element.parentNode){f={};for(d in t){f[d]={};for(n in t[d]){for(i=!1,y=this.history,b=0,v=y.length;v>b;b++)if(r=y[b],!E(null!=(w=r[d])?w[n]:void 0,t[d][n])){i=!0;break}i||(f[d][n]=!0)}}e={top:"",left:"",right:"",bottom:""},p=function(t,o){var i,n,s;return(null!=(s=C.options.optimizations)?s.gpu:void 0)===!1?(t.top?e.top=""+o.top+"px":e.bottom=""+o.bottom+"px",t.left?e.left=""+o.left+"px":e.right=""+o.right+"px"):(t.top?(e.top=0,n=o.top):(e.bottom=0,n=-o.bottom),t.left?(e.left=0,i=o.left):(e.right=0,i=-o.right),e[x]="translateX("+Math.round(i)+"px) translateY("+Math.round(n)+"px)","msTransform"!==x?e[x]+=" translateZ(0)":void 0)},s=!1,(f.page.top||f.page.bottom)&&(f.page.left||f.page.right)?(e.position="absolute",p(f.page,t.page)):(f.viewport.top||f.viewport.bottom)&&(f.viewport.left||f.viewport.right)?(e.position="fixed",p(f.viewport,t.viewport)):null!=f.offset&&f.offset.top&&f.offset.left?(e.position="absolute",l=this.cache("target-offsetparent",function(){return u(C.target)}),u(this.element)!==l&&h(function(){return C.element.parentNode.removeChild(C.element),l.appendChild(C.element)}),p(f.offset,t.offset),s=!0):(e.position="absolute",p({top:!0,left:!0},t.page)),s||"BODY"===this.element.parentNode.tagName||(this.element.parentNode.removeChild(this.element),document.body.appendChild(this.element)),m={},c=!1;for(n in e)g=e[n],o=this.element.style[n],""===o||""===g||"top"!==n&&"left"!==n&&"bottom"!==n&&"right"!==n||(o=parseFloat(o),g=parseFloat(g)),o!==g&&(c=!0,m[n]=e[n]);return c?h(function(){return a(C.element.style,m)}):void 0}},t}(),i.position=C,this.Tether=a(S,i)}.call(this),function(){var t,e,o,i,n,s,l,r,h,a,f=[].indexOf||function(t){for(var e=0,o=this.length;o>e;e++)if(e in this&&this[e]===t)return e;return-1};a=this.Tether.Utils,l=a.getOuterSize,s=a.getBounds,r=a.getSize,i=a.extend,h=a.updateClasses,o=a.defer,e={left:"right",right:"left",top:"bottom",bottom:"top",middle:"middle"},t=["left","top","right","bottom"],n=function(e,o){var i,n,l,r,h,a,f;if("scrollParent"===o?o=e.scrollParent:"window"===o&&(o=[pageXOffset,pageYOffset,innerWidth+pageXOffset,innerHeight+pageYOffset]),o===document&&(o=o.documentElement),null!=o.nodeType)for(n=r=s(o),h=getComputedStyle(o),o=[n.left,n.top,r.width+n.left,r.height+n.top],i=a=0,f=t.length;f>a;i=++a)l=t[i],l=l[0].toUpperCase()+l.substr(1),"Top"===l||"Left"===l?o[i]+=parseFloat(h["border"+l+"Width"]):o[i]-=parseFloat(h["border"+l+"Width"]);return o},this.Tether.modules.push({position:function(e){var l,r,a,p,u,d,g,c,m,b,v,y,w,C,O,T,x,A,E,S,W,M,z,B,P,_,F,L,Y,H,X,N,j,R,U,q,k,D,Z,V,$,G,I,J,K,Q,te,ee=this;if(_=e.top,v=e.left,W=e.targetAttachment,!this.options.constraints)return!0;for(A=function(e){var o,i,n,s;for(ee.removeClass(e),s=[],i=0,n=t.length;n>i;i++)o=t[i],s.push(ee.removeClass(""+e+"-"+o));return s},V=this.cache("element-bounds",function(){return s(ee.element)}),b=V.height,F=V.width,0===F&&0===b&&null!=this.lastSize&&($=this.lastSize,F=$.width,b=$.height),z=this.cache("target-bounds",function(){return ee.getTargetBounds()}),M=z.height,B=z.width,S={},m={},r=[this.getClass("pinned"),this.getClass("out-of-bounds")],G=this.options.constraints,L=0,N=G.length;N>L;L++)c=G[L],c.outOfBoundsClass&&r.push(c.outOfBoundsClass),c.pinnedClass&&r.push(c.pinnedClass);for(Y=0,j=r.length;j>Y;Y++)for(g=r[Y],I=["left","top","right","bottom"],H=0,R=I.length;R>H;H++)E=I[H],r.push(""+g+"-"+E);for(l=[],S=i({},W),m=i({},this.attachment),J=this.options.constraints,X=0,U=J.length;U>X;X++){if(c=J[X],P=c.to,a=c.attachment,O=c.pin,null==a&&(a=""),f.call(a," ")>=0?(K=a.split(" "),d=K[0],u=K[1]):u=d=a,p=n(this,P),("target"===d||"both"===d)&&(_<p[1]&&"top"===S.top&&(_+=M,S.top="bottom"),_+b>p[3]&&"bottom"===S.top&&(_-=M,S.top="top")),"together"===d&&(_<p[1]&&"top"===S.top&&("bottom"===m.top?(_+=M,S.top="bottom",_+=b,m.top="top"):"top"===m.top&&(_+=M,S.top="bottom",_-=b,m.top="bottom")),_+b>p[3]&&"bottom"===S.top&&("top"===m.top?(_-=M,S.top="top",_-=b,m.top="bottom"):"bottom"===m.top&&(_-=M,S.top="top",_+=b,m.top="top")),"middle"===S.top&&(_+b>p[3]&&"top"===m.top?(_-=b,m.top="bottom"):_<p[1]&&"bottom"===m.top&&(_+=b,m.top="top"))),("target"===u||"both"===u)&&(v<p[0]&&"left"===S.left&&(v+=B,S.left="right"),v+F>p[2]&&"right"===S.left&&(v-=B,S.left="left")),"together"===u&&(v<p[0]&&"left"===S.left?"right"===m.left?(v+=B,S.left="right",v+=F,m.left="left"):"left"===m.left&&(v+=B,S.left="right",v-=F,m.left="right"):v+F>p[2]&&"right"===S.left?"left"===m.left?(v-=B,S.left="left",v-=F,m.left="right"):"right"===m.left&&(v-=B,S.left="left",v+=F,m.left="left"):"center"===S.left&&(v+F>p[2]&&"left"===m.left?(v-=F,m.left="right"):v<p[0]&&"right"===m.left&&(v+=F,m.left="left"))),("element"===d||"both"===d)&&(_<p[1]&&"bottom"===m.top&&(_+=b,m.top="top"),_+b>p[3]&&"top"===m.top&&(_-=b,m.top="bottom")),("element"===u||"both"===u)&&(v<p[0]&&"right"===m.left&&(v+=F,m.left="left"),v+F>p[2]&&"left"===m.left&&(v-=F,m.left="right")),"string"==typeof O?O=function(){var t,e,o,i;for(o=O.split(","),i=[],e=0,t=o.length;t>e;e++)C=o[e],i.push(C.trim());return i}():O===!0&&(O=["top","left","right","bottom"]),O||(O=[]),T=[],y=[],_<p[1]&&(f.call(O,"top")>=0?(_=p[1],T.push("top")):y.push("top")),_+b>p[3]&&(f.call(O,"bottom")>=0?(_=p[3]-b,T.push("bottom")):y.push("bottom")),v<p[0]&&(f.call(O,"left")>=0?(v=p[0],T.push("left")):y.push("left")),v+F>p[2]&&(f.call(O,"right")>=0?(v=p[2]-F,T.push("right")):y.push("right")),T.length)for(x=null!=(Q=this.options.pinnedClass)?Q:this.getClass("pinned"),l.push(x),D=0,q=T.length;q>D;D++)E=T[D],l.push(""+x+"-"+E);if(y.length)for(w=null!=(te=this.options.outOfBoundsClass)?te:this.getClass("out-of-bounds"),l.push(w),Z=0,k=y.length;k>Z;Z++)E=y[Z],l.push(""+w+"-"+E);(f.call(T,"left")>=0||f.call(T,"right")>=0)&&(m.left=S.left=!1),(f.call(T,"top")>=0||f.call(T,"bottom")>=0)&&(m.top=S.top=!1),(S.top!==W.top||S.left!==W.left||m.top!==this.attachment.top||m.left!==this.attachment.left)&&this.updateAttachClasses(m,S)}return o(function(){return h(ee.target,l,r),h(ee.element,l,r)}),{top:_,left:v}}})}.call(this),function(){var t,e,o,i;i=this.Tether.Utils,e=i.getBounds,o=i.updateClasses,t=i.defer,this.Tether.modules.push({position:function(i){var n,s,l,r,h,a,f,p,u,d,g,c,m,b,v,y,w,C,O,T,x,A,E,S,W,M=this;if(g=i.top,a=i.left,x=this.cache("element-bounds",function(){return e(M.element)}),h=x.height,c=x.width,d=this.getTargetBounds(),r=g+h,f=a+c,n=[],g<=d.bottom&&r>=d.top)for(A=["left","right"],m=0,w=A.length;w>m;m++)p=A[m],((E=d[p])===a||E===f)&&n.push(p);if(a<=d.right&&f>=d.left)for(S=["top","bottom"],b=0,C=S.length;C>b;b++)p=S[b],((W=d[p])===g||W===r)&&n.push(p);for(l=[],s=[],u=["left","top","right","bottom"],l.push(this.getClass("abutted")),v=0,O=u.length;O>v;v++)p=u[v],l.push(""+this.getClass("abutted")+"-"+p);for(n.length&&s.push(this.getClass("abutted")),y=0,T=n.length;T>y;y++)p=n[y],s.push(""+this.getClass("abutted")+"-"+p);return t(function(){return o(M.target,s,l),o(M.element,s,l)}),!0}})}.call(this),function(){this.Tether.modules.push({position:function(t){var e,o,i,n,s,l,r;return l=t.top,e=t.left,this.options.shift?(o=function(t){return"function"==typeof t?t.call(this,{top:l,left:e}):t},i=o(this.options.shift),"string"==typeof i?(i=i.split(" "),i[1]||(i[1]=i[0]),s=i[0],n=i[1],s=parseFloat(s,10),n=parseFloat(n,10)):(r=[i.top,i.left],s=r[0],n=r[1]),l+=s,e+=n,{top:l,left:e}):void 0}})}.call(this),this.Tether});