From 8ba815d881427f5bd3c2a48c2cae6433d8655cdd Mon Sep 17 00:00:00 2001 From: fredyrivera Date: Mon, 16 Oct 2017 13:51:40 -0500 Subject: [PATCH] Prueba de concepto para visualizar eventos --- index.php | 42 +- librerias/calendar/fullcalendar.css | 1494 ++ librerias/calendar/fullcalendar.js | 18310 ++++++++++++++++ librerias/calendar/fullcalendar.min.css | 5 + librerias/calendar/fullcalendar.min.js | 11 + librerias/calendar/fullcalendar.print.css | 208 + librerias/calendar/fullcalendar.print.min.css | 5 + librerias/calendar/gcal.js | 288 + librerias/calendar/gcal.min.js | 6 + librerias/calendar/index.php | 0 librerias/calendar/lib/jquery-ui.min.js | 13 + librerias/calendar/lib/jquery.min.js | 4 + librerias/calendar/lib/moment.min.js | 1 + librerias/calendar/locale-all.js | 5 + librerias/calendar/locale/af.js | 1 + librerias/calendar/locale/ar-dz.js | 1 + librerias/calendar/locale/ar-kw.js | 1 + librerias/calendar/locale/ar-ly.js | 1 + librerias/calendar/locale/ar-ma.js | 1 + librerias/calendar/locale/ar-sa.js | 1 + librerias/calendar/locale/ar-tn.js | 1 + librerias/calendar/locale/ar.js | 1 + librerias/calendar/locale/bg.js | 1 + librerias/calendar/locale/ca.js | 1 + librerias/calendar/locale/cs.js | 1 + librerias/calendar/locale/da.js | 1 + librerias/calendar/locale/de-at.js | 1 + librerias/calendar/locale/de-ch.js | 1 + librerias/calendar/locale/de.js | 1 + librerias/calendar/locale/el.js | 1 + librerias/calendar/locale/en-au.js | 1 + librerias/calendar/locale/en-ca.js | 1 + librerias/calendar/locale/en-gb.js | 1 + librerias/calendar/locale/en-ie.js | 1 + librerias/calendar/locale/en-nz.js | 1 + librerias/calendar/locale/es-do.js | 1 + librerias/calendar/locale/es-us.js | 1 + librerias/calendar/locale/es.js | 1 + librerias/calendar/locale/et.js | 1 + librerias/calendar/locale/eu.js | 1 + librerias/calendar/locale/fa.js | 1 + librerias/calendar/locale/fi.js | 1 + librerias/calendar/locale/fr-ca.js | 1 + librerias/calendar/locale/fr-ch.js | 1 + librerias/calendar/locale/fr.js | 1 + librerias/calendar/locale/gl.js | 1 + librerias/calendar/locale/he.js | 1 + librerias/calendar/locale/hi.js | 1 + librerias/calendar/locale/hr.js | 1 + librerias/calendar/locale/hu.js | 1 + librerias/calendar/locale/id.js | 1 + librerias/calendar/locale/is.js | 1 + librerias/calendar/locale/it.js | 1 + librerias/calendar/locale/ja.js | 1 + librerias/calendar/locale/kk.js | 1 + librerias/calendar/locale/ko.js | 1 + librerias/calendar/locale/lb.js | 1 + librerias/calendar/locale/lt.js | 1 + librerias/calendar/locale/lv.js | 1 + librerias/calendar/locale/mk.js | 1 + librerias/calendar/locale/ms-my.js | 1 + librerias/calendar/locale/ms.js | 1 + librerias/calendar/locale/nb.js | 1 + librerias/calendar/locale/nl-be.js | 1 + librerias/calendar/locale/nl.js | 1 + librerias/calendar/locale/nn.js | 1 + librerias/calendar/locale/pl.js | 1 + librerias/calendar/locale/pt-br.js | 1 + librerias/calendar/locale/pt.js | 1 + librerias/calendar/locale/ro.js | 1 + librerias/calendar/locale/ru.js | 1 + librerias/calendar/locale/sk.js | 1 + librerias/calendar/locale/sl.js | 1 + librerias/calendar/locale/sq.js | 1 + librerias/calendar/locale/sr-cyrl.js | 1 + librerias/calendar/locale/sr.js | 1 + librerias/calendar/locale/sv.js | 1 + librerias/calendar/locale/th.js | 1 + librerias/calendar/locale/tr.js | 1 + librerias/calendar/locale/uk.js | 1 + librerias/calendar/locale/vi.js | 1 + librerias/calendar/locale/zh-cn.js | 1 + librerias/calendar/locale/zh-tw.js | 1 + milfs/funciones/funciones.php | 47 +- 84 files changed, 20498 insertions(+), 10 deletions(-) create mode 100755 librerias/calendar/fullcalendar.css create mode 100755 librerias/calendar/fullcalendar.js create mode 100755 librerias/calendar/fullcalendar.min.css create mode 100755 librerias/calendar/fullcalendar.min.js create mode 100755 librerias/calendar/fullcalendar.print.css create mode 100755 librerias/calendar/fullcalendar.print.min.css create mode 100755 librerias/calendar/gcal.js create mode 100755 librerias/calendar/gcal.min.js create mode 100755 librerias/calendar/index.php create mode 100755 librerias/calendar/lib/jquery-ui.min.js create mode 100755 librerias/calendar/lib/jquery.min.js create mode 100755 librerias/calendar/lib/moment.min.js create mode 100755 librerias/calendar/locale-all.js create mode 100755 librerias/calendar/locale/af.js create mode 100755 librerias/calendar/locale/ar-dz.js create mode 100755 librerias/calendar/locale/ar-kw.js create mode 100755 librerias/calendar/locale/ar-ly.js create mode 100755 librerias/calendar/locale/ar-ma.js create mode 100755 librerias/calendar/locale/ar-sa.js create mode 100755 librerias/calendar/locale/ar-tn.js create mode 100755 librerias/calendar/locale/ar.js create mode 100755 librerias/calendar/locale/bg.js create mode 100755 librerias/calendar/locale/ca.js create mode 100755 librerias/calendar/locale/cs.js create mode 100755 librerias/calendar/locale/da.js create mode 100755 librerias/calendar/locale/de-at.js create mode 100755 librerias/calendar/locale/de-ch.js create mode 100755 librerias/calendar/locale/de.js create mode 100755 librerias/calendar/locale/el.js create mode 100755 librerias/calendar/locale/en-au.js create mode 100755 librerias/calendar/locale/en-ca.js create mode 100755 librerias/calendar/locale/en-gb.js create mode 100755 librerias/calendar/locale/en-ie.js create mode 100755 librerias/calendar/locale/en-nz.js create mode 100755 librerias/calendar/locale/es-do.js create mode 100755 librerias/calendar/locale/es-us.js create mode 100755 librerias/calendar/locale/es.js create mode 100755 librerias/calendar/locale/et.js create mode 100755 librerias/calendar/locale/eu.js create mode 100755 librerias/calendar/locale/fa.js create mode 100755 librerias/calendar/locale/fi.js create mode 100755 librerias/calendar/locale/fr-ca.js create mode 100755 librerias/calendar/locale/fr-ch.js create mode 100755 librerias/calendar/locale/fr.js create mode 100755 librerias/calendar/locale/gl.js create mode 100755 librerias/calendar/locale/he.js create mode 100755 librerias/calendar/locale/hi.js create mode 100755 librerias/calendar/locale/hr.js create mode 100755 librerias/calendar/locale/hu.js create mode 100755 librerias/calendar/locale/id.js create mode 100755 librerias/calendar/locale/is.js create mode 100755 librerias/calendar/locale/it.js create mode 100755 librerias/calendar/locale/ja.js create mode 100755 librerias/calendar/locale/kk.js create mode 100755 librerias/calendar/locale/ko.js create mode 100755 librerias/calendar/locale/lb.js create mode 100755 librerias/calendar/locale/lt.js create mode 100755 librerias/calendar/locale/lv.js create mode 100755 librerias/calendar/locale/mk.js create mode 100755 librerias/calendar/locale/ms-my.js create mode 100755 librerias/calendar/locale/ms.js create mode 100755 librerias/calendar/locale/nb.js create mode 100755 librerias/calendar/locale/nl-be.js create mode 100755 librerias/calendar/locale/nl.js create mode 100755 librerias/calendar/locale/nn.js create mode 100755 librerias/calendar/locale/pl.js create mode 100755 librerias/calendar/locale/pt-br.js create mode 100755 librerias/calendar/locale/pt.js create mode 100755 librerias/calendar/locale/ro.js create mode 100755 librerias/calendar/locale/ru.js create mode 100755 librerias/calendar/locale/sk.js create mode 100755 librerias/calendar/locale/sl.js create mode 100755 librerias/calendar/locale/sq.js create mode 100755 librerias/calendar/locale/sr-cyrl.js create mode 100755 librerias/calendar/locale/sr.js create mode 100755 librerias/calendar/locale/sv.js create mode 100755 librerias/calendar/locale/th.js create mode 100755 librerias/calendar/locale/tr.js create mode 100755 librerias/calendar/locale/uk.js create mode 100755 librerias/calendar/locale/vi.js create mode 100755 librerias/calendar/locale/zh-cn.js create mode 100755 librerias/calendar/locale/zh-tw.js diff --git a/index.php b/index.php index 1f5a5e5..db2f73b 100755 --- a/index.php +++ b/index.php @@ -759,10 +759,50 @@ document.oncopy = addLink; echo " " ; } if(isset($_SESSION['id'])) {$id_empresa_portada='1'; echo panel_aplicaciones('1',"$_SESSION[id_empresa]",""); } +if(isset($_REQUEST['eventos'])) { + //$embebido='1'; +$eventos= " + + + + + +

Eventos


"; + +} if( $embebido =="1" ){ /* SI SE SOLICITA UN EMBEBIDO SE MUESTRA ESTO */ + echo $onload; if(isset($set)) { @@ -877,7 +917,7 @@ document.oncopy = addLink;
- + tags, normalized to work cross-browser) +--------------------------------------------------------------------------------------------------*/ + +.fc button { + /* force height to include the border and padding */ + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + + /* dimensions */ + margin: 0; + height: 2.1em; + padding: 0 .6em; + + /* text & cursor */ + font-size: 1em; /* normalize */ + white-space: nowrap; + cursor: pointer; +} + +/* Firefox has an annoying inner border */ +.fc button::-moz-focus-inner { margin: 0; padding: 0; } + +.fc-state-default { /* non-theme */ + border: 1px solid; +} + +.fc-state-default.fc-corner-left { /* non-theme */ + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; +} + +.fc-state-default.fc-corner-right { /* non-theme */ + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +/* icons in buttons */ + +.fc button .fc-icon { /* non-theme */ + position: relative; + top: -0.05em; /* seems to be a good adjustment across browsers */ + margin: 0 .2em; + vertical-align: middle; +} + +/* + button states + borrowed from twitter bootstrap (http://twitter.github.com/bootstrap/) +*/ + +.fc-state-default { + background-color: #f5f5f5; + background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); + background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); + background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); + background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); + background-repeat: repeat-x; + border-color: #e6e6e6 #e6e6e6 #bfbfbf; + border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); + color: #333; + text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.fc-state-hover, +.fc-state-down, +.fc-state-active, +.fc-state-disabled { + color: #333333; + background-color: #e6e6e6; +} + +.fc-state-hover { + color: #333333; + text-decoration: none; + background-position: 0 -15px; + -webkit-transition: background-position 0.1s linear; + -moz-transition: background-position 0.1s linear; + -o-transition: background-position 0.1s linear; + transition: background-position 0.1s linear; +} + +.fc-state-down, +.fc-state-active { + background-color: #cccccc; + background-image: none; + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.fc-state-disabled { + cursor: default; + background-image: none; + opacity: 0.65; + box-shadow: none; +} + + +/* Buttons Groups +--------------------------------------------------------------------------------------------------*/ + +.fc-button-group { + display: inline-block; +} + +/* +every button that is not first in a button group should scootch over one pixel and cover the +previous button's border... +*/ + +.fc .fc-button-group > * { /* extra precedence b/c buttons have margin set to zero */ + float: left; + margin: 0 0 0 -1px; +} + +.fc .fc-button-group > :first-child { /* same */ + margin-left: 0; +} + + +/* Popover +--------------------------------------------------------------------------------------------------*/ + +.fc-popover { + position: absolute; + box-shadow: 0 2px 6px rgba(0,0,0,.15); +} + +.fc-popover .fc-header { /* TODO: be more consistent with fc-head/fc-body */ + padding: 2px 4px; +} + +.fc-popover .fc-header .fc-title { + margin: 0 2px; +} + +.fc-popover .fc-header .fc-close { + cursor: pointer; +} + +.fc-ltr .fc-popover .fc-header .fc-title, +.fc-rtl .fc-popover .fc-header .fc-close { + float: left; +} + +.fc-rtl .fc-popover .fc-header .fc-title, +.fc-ltr .fc-popover .fc-header .fc-close { + float: right; +} + + +/* Misc Reusable Components +--------------------------------------------------------------------------------------------------*/ + +.fc-divider { + border-style: solid; + border-width: 1px; +} + +hr.fc-divider { + height: 0; + margin: 0; + padding: 0 0 2px; /* height is unreliable across browsers, so use padding */ + border-width: 1px 0; +} + +.fc-clear { + clear: both; +} + +.fc-bg, +.fc-bgevent-skeleton, +.fc-highlight-skeleton, +.fc-helper-skeleton { + /* these element should always cling to top-left/right corners */ + position: absolute; + top: 0; + left: 0; + right: 0; +} + +.fc-bg { + bottom: 0; /* strech bg to bottom edge */ +} + +.fc-bg table { + height: 100%; /* strech bg to bottom edge */ +} + + +/* Tables +--------------------------------------------------------------------------------------------------*/ + +.fc table { + width: 100%; + box-sizing: border-box; /* fix scrollbar issue in firefox */ + table-layout: fixed; + border-collapse: collapse; + border-spacing: 0; + font-size: 1em; /* normalize cross-browser */ +} + +.fc th { + text-align: center; +} + +.fc th, +.fc td { + border-style: solid; + border-width: 1px; + padding: 0; + vertical-align: top; +} + +.fc td.fc-today { + border-style: double; /* overcome neighboring borders */ +} + + +/* Internal Nav Links +--------------------------------------------------------------------------------------------------*/ + +a[data-goto] { + cursor: pointer; +} + +a[data-goto]:hover { + text-decoration: underline; +} + + +/* Fake Table Rows +--------------------------------------------------------------------------------------------------*/ + +.fc .fc-row { /* extra precedence to overcome themes w/ .ui-widget-content forcing a 1px border */ + /* no visible border by default. but make available if need be (scrollbar width compensation) */ + border-style: solid; + border-width: 0; +} + +.fc-row table { + /* don't put left/right border on anything within a fake row. + the outer tbody will worry about this */ + border-left: 0 hidden transparent; + border-right: 0 hidden transparent; + + /* no bottom borders on rows */ + border-bottom: 0 hidden transparent; +} + +.fc-row:first-child table { + border-top: 0 hidden transparent; /* no top border on first row */ +} + + +/* Day Row (used within the header and the DayGrid) +--------------------------------------------------------------------------------------------------*/ + +.fc-row { + position: relative; +} + +.fc-row .fc-bg { + z-index: 1; +} + +/* highlighting cells & background event skeleton */ + +.fc-row .fc-bgevent-skeleton, +.fc-row .fc-highlight-skeleton { + bottom: 0; /* stretch skeleton to bottom of row */ +} + +.fc-row .fc-bgevent-skeleton table, +.fc-row .fc-highlight-skeleton table { + height: 100%; /* stretch skeleton to bottom of row */ +} + +.fc-row .fc-highlight-skeleton td, +.fc-row .fc-bgevent-skeleton td { + border-color: transparent; +} + +.fc-row .fc-bgevent-skeleton { + z-index: 2; + +} + +.fc-row .fc-highlight-skeleton { + z-index: 3; +} + +/* +row content (which contains day/week numbers and events) as well as "helper" (which contains +temporary rendered events). +*/ + +.fc-row .fc-content-skeleton { + position: relative; + z-index: 4; + padding-bottom: 2px; /* matches the space above the events */ +} + +.fc-row .fc-helper-skeleton { + z-index: 5; +} + +.fc .fc-row .fc-content-skeleton table, +.fc .fc-row .fc-content-skeleton td, +.fc .fc-row .fc-helper-skeleton td { + /* see-through to the background below */ + /* extra precedence to prevent theme-provided backgrounds */ + background: none; /* in case s are globally styled */ + border-color: transparent; +} + +.fc-row .fc-content-skeleton td, +.fc-row .fc-helper-skeleton td { + /* don't put a border between events and/or the day number */ + border-bottom: 0; +} + +.fc-row .fc-content-skeleton tbody td, /* cells with events inside (so NOT the day number cell) */ +.fc-row .fc-helper-skeleton tbody td { + /* don't put a border between event cells */ + border-top: 0; +} + + +/* Scrolling Container +--------------------------------------------------------------------------------------------------*/ + +.fc-scroller { + -webkit-overflow-scrolling: touch; +} + +/* TODO: move to agenda/basic */ +.fc-scroller > .fc-day-grid, +.fc-scroller > .fc-time-grid { + position: relative; /* re-scope all positions */ + width: 100%; /* hack to force re-sizing this inner element when scrollbars appear/disappear */ +} + + +/* Global Event Styles +--------------------------------------------------------------------------------------------------*/ + +.fc-event { + position: relative; /* for resize handle and other inner positioning */ + display: block; /* make the tag block */ + font-size: .85em; + line-height: 1.3; + border-radius: 3px; + border: 1px solid #3a87ad; /* default BORDER color */ +} + +.fc-event, +.fc-event-dot { + background-color: #3a87ad; /* default BACKGROUND color */ +} + +.fc-event, +.fc-event:hover { + color: #fff; /* default TEXT color */ + text-decoration: none; /* if has an href */ +} + +.fc-event[href], +.fc-event.fc-draggable { + cursor: pointer; /* give events with links and draggable events a hand mouse pointer */ +} + +.fc-not-allowed, /* causes a "warning" cursor. applied on body */ +.fc-not-allowed .fc-event { /* to override an event's custom cursor */ + cursor: not-allowed; +} + +.fc-event .fc-bg { /* the generic .fc-bg already does position */ + z-index: 1; + background: #fff; + opacity: .25; +} + +.fc-event .fc-content { + position: relative; + z-index: 2; +} + +/* resizer (cursor AND touch devices) */ + +.fc-event .fc-resizer { + position: absolute; + z-index: 4; +} + +/* resizer (touch devices) */ + +.fc-event .fc-resizer { + display: none; +} + +.fc-event.fc-allow-mouse-resize .fc-resizer, +.fc-event.fc-selected .fc-resizer { + /* only show when hovering or selected (with touch) */ + display: block; +} + +/* hit area */ + +.fc-event.fc-selected .fc-resizer:before { + /* 40x40 touch area */ + content: ""; + position: absolute; + z-index: 9999; /* user of this util can scope within a lower z-index */ + top: 50%; + left: 50%; + width: 40px; + height: 40px; + margin-left: -20px; + margin-top: -20px; +} + + +/* Event Selection (only for touch devices) +--------------------------------------------------------------------------------------------------*/ + +.fc-event.fc-selected { + z-index: 9999 !important; /* overcomes inline z-index */ + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); +} + +.fc-event.fc-selected.fc-dragging { + box-shadow: 0 2px 7px rgba(0, 0, 0, 0.3); +} + + +/* Horizontal Events +--------------------------------------------------------------------------------------------------*/ + +/* bigger touch area when selected */ +.fc-h-event.fc-selected:before { + content: ""; + position: absolute; + z-index: 3; /* below resizers */ + top: -10px; + bottom: -10px; + left: 0; + right: 0; +} + +/* events that are continuing to/from another week. kill rounded corners and butt up against edge */ + +.fc-ltr .fc-h-event.fc-not-start, +.fc-rtl .fc-h-event.fc-not-end { + margin-left: 0; + border-left-width: 0; + padding-left: 1px; /* replace the border with padding */ + border-top-left-radius: 0; + border-bottom-left-radius: 0; +} + +.fc-ltr .fc-h-event.fc-not-end, +.fc-rtl .fc-h-event.fc-not-start { + margin-right: 0; + border-right-width: 0; + padding-right: 1px; /* replace the border with padding */ + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +/* resizer (cursor AND touch devices) */ + +/* left resizer */ +.fc-ltr .fc-h-event .fc-start-resizer, +.fc-rtl .fc-h-event .fc-end-resizer { + cursor: w-resize; + left: -1px; /* overcome border */ +} + +/* right resizer */ +.fc-ltr .fc-h-event .fc-end-resizer, +.fc-rtl .fc-h-event .fc-start-resizer { + cursor: e-resize; + right: -1px; /* overcome border */ +} + +/* resizer (mouse devices) */ + +.fc-h-event.fc-allow-mouse-resize .fc-resizer { + width: 7px; + top: -1px; /* overcome top border */ + bottom: -1px; /* overcome bottom border */ +} + +/* resizer (touch devices) */ + +.fc-h-event.fc-selected .fc-resizer { + /* 8x8 little dot */ + border-radius: 4px; + border-width: 1px; + width: 6px; + height: 6px; + border-style: solid; + border-color: inherit; + background: #fff; + /* vertically center */ + top: 50%; + margin-top: -4px; +} + +/* left resizer */ +.fc-ltr .fc-h-event.fc-selected .fc-start-resizer, +.fc-rtl .fc-h-event.fc-selected .fc-end-resizer { + margin-left: -4px; /* centers the 8x8 dot on the left edge */ +} + +/* right resizer */ +.fc-ltr .fc-h-event.fc-selected .fc-end-resizer, +.fc-rtl .fc-h-event.fc-selected .fc-start-resizer { + margin-right: -4px; /* centers the 8x8 dot on the right edge */ +} + + +/* DayGrid events +---------------------------------------------------------------------------------------------------- +We use the full "fc-day-grid-event" class instead of using descendants because the event won't +be a descendant of the grid when it is being dragged. +*/ + +.fc-day-grid-event { + margin: 1px 2px 0; /* spacing between events and edges */ + padding: 0 1px; +} + +tr:first-child > td > .fc-day-grid-event { + margin-top: 2px; /* a little bit more space before the first event */ +} + +.fc-day-grid-event.fc-selected:after { + content: ""; + position: absolute; + z-index: 1; /* same z-index as fc-bg, behind text */ + /* overcome the borders */ + top: -1px; + right: -1px; + bottom: -1px; + left: -1px; + /* darkening effect */ + background: #000; + opacity: .25; +} + +.fc-day-grid-event .fc-content { /* force events to be one-line tall */ + white-space: nowrap; + overflow: hidden; +} + +.fc-day-grid-event .fc-time { + font-weight: bold; +} + +/* resizer (cursor devices) */ + +/* left resizer */ +.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer, +.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer { + margin-left: -2px; /* to the day cell's edge */ +} + +/* right resizer */ +.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer, +.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer { + margin-right: -2px; /* to the day cell's edge */ +} + + +/* Event Limiting +--------------------------------------------------------------------------------------------------*/ + +/* "more" link that represents hidden events */ + +a.fc-more { + margin: 1px 3px; + font-size: .85em; + cursor: pointer; + text-decoration: none; +} + +a.fc-more:hover { + text-decoration: underline; +} + +.fc-limited { /* rows and cells that are hidden because of a "more" link */ + display: none; +} + +/* popover that appears when "more" link is clicked */ + +.fc-day-grid .fc-row { + z-index: 1; /* make the "more" popover one higher than this */ +} + +.fc-more-popover { + z-index: 2; + width: 220px; +} + +.fc-more-popover .fc-event-container { + padding: 10px; +} + + +/* Now Indicator +--------------------------------------------------------------------------------------------------*/ + +.fc-now-indicator { + position: absolute; + border: 0 solid red; +} + + +/* Utilities +--------------------------------------------------------------------------------------------------*/ + +.fc-unselectable { + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + -webkit-touch-callout: none; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + + + +/* +TODO: more distinction between this file and common.css +*/ + +/* Colors +--------------------------------------------------------------------------------------------------*/ + +.fc-unthemed th, +.fc-unthemed td, +.fc-unthemed thead, +.fc-unthemed tbody, +.fc-unthemed .fc-divider, +.fc-unthemed .fc-row, +.fc-unthemed .fc-content, /* for gutter border */ +.fc-unthemed .fc-popover, +.fc-unthemed .fc-list-view, +.fc-unthemed .fc-list-heading td { + border-color: #ddd; +} + +.fc-unthemed .fc-popover { + background-color: #fff; +} + +.fc-unthemed .fc-divider, +.fc-unthemed .fc-popover .fc-header, +.fc-unthemed .fc-list-heading td { + background: #eee; +} + +.fc-unthemed .fc-popover .fc-header .fc-close { + color: #666; +} + +.fc-unthemed td.fc-today { + background: #fcf8e3; +} + +.fc-unthemed .fc-disabled-day { + background: #d7d7d7; + opacity: .3; +} + + +/* Icons (inline elements with styled text that mock arrow icons) +--------------------------------------------------------------------------------------------------*/ + +.fc-icon { + display: inline-block; + height: 1em; + line-height: 1em; + font-size: 1em; + text-align: center; + overflow: hidden; + font-family: "Courier New", Courier, monospace; + + /* don't allow browser text-selection */ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* +Acceptable font-family overrides for individual icons: + "Arial", sans-serif + "Times New Roman", serif + +NOTE: use percentage font sizes or else old IE chokes +*/ + +.fc-icon:after { + position: relative; +} + +.fc-icon-left-single-arrow:after { + content: "\02039"; + font-weight: bold; + font-size: 200%; + top: -7%; +} + +.fc-icon-right-single-arrow:after { + content: "\0203A"; + font-weight: bold; + font-size: 200%; + top: -7%; +} + +.fc-icon-left-double-arrow:after { + content: "\000AB"; + font-size: 160%; + top: -7%; +} + +.fc-icon-right-double-arrow:after { + content: "\000BB"; + font-size: 160%; + top: -7%; +} + +.fc-icon-left-triangle:after { + content: "\25C4"; + font-size: 125%; + top: 3%; +} + +.fc-icon-right-triangle:after { + content: "\25BA"; + font-size: 125%; + top: 3%; +} + +.fc-icon-down-triangle:after { + content: "\25BC"; + font-size: 125%; + top: 2%; +} + +.fc-icon-x:after { + content: "\000D7"; + font-size: 200%; + top: 6%; +} + + +/* Popover +--------------------------------------------------------------------------------------------------*/ + +.fc-unthemed .fc-popover { + border-width: 1px; + border-style: solid; +} + +.fc-unthemed .fc-popover .fc-header .fc-close { + font-size: .9em; + margin-top: 2px; +} + + +/* List View +--------------------------------------------------------------------------------------------------*/ + +.fc-unthemed .fc-list-item:hover td { + background-color: #f5f5f5; +} + + + +/* Colors +--------------------------------------------------------------------------------------------------*/ + +.ui-widget .fc-disabled-day { + background-image: none; +} + + +/* Popover +--------------------------------------------------------------------------------------------------*/ + +.fc-popover > .ui-widget-header + .ui-widget-content { + border-top: 0; /* where they meet, let the header have the border */ +} + + +/* Global Event Styles +--------------------------------------------------------------------------------------------------*/ + +.ui-widget .fc-event { + /* overpower jqui's styles on tags. TODO: more DRY */ + color: #fff; /* default TEXT color */ + text-decoration: none; /* if has an href */ + + /* undo ui-widget-header bold */ + font-weight: normal; +} + + +/* TimeGrid axis running down the side (for both the all-day area and the slot area) +--------------------------------------------------------------------------------------------------*/ + +.ui-widget td.fc-axis { + font-weight: normal; /* overcome bold */ +} + + +/* TimeGrid Slats (lines that run horizontally) +--------------------------------------------------------------------------------------------------*/ + +.fc-time-grid .fc-slats .ui-widget-content { + background: none; /* see through to fc-bg */ +} + + + +.fc.fc-bootstrap3 a { + text-decoration: none; +} + +.fc.fc-bootstrap3 a[data-goto]:hover { + text-decoration: underline; +} + +.fc-bootstrap3 hr.fc-divider { + border-color: inherit; +} + +.fc-bootstrap3 .fc-today.alert { + border-radius: 0; +} + + +/* Popover +--------------------------------------------------------------------------------------------------*/ + +.fc-bootstrap3 .fc-popover .panel-body { + padding: 0; /* undo built-in padding */ +} + + +/* TimeGrid Slats (lines that run horizontally) +--------------------------------------------------------------------------------------------------*/ + +.fc-bootstrap3 .fc-time-grid .fc-slats table { + /* some themes have background color. see through to slats */ + background: none; +} + + + +/* Toolbar +--------------------------------------------------------------------------------------------------*/ + +.fc-toolbar { + text-align: center; +} + +.fc-toolbar.fc-header-toolbar { + margin-bottom: 1em; +} + +.fc-toolbar.fc-footer-toolbar { + margin-top: 1em; +} + +.fc-toolbar .fc-left { + float: left; +} + +.fc-toolbar .fc-right { + float: right; +} + +.fc-toolbar .fc-center { + display: inline-block; +} + +/* the things within each left/right/center section */ +.fc .fc-toolbar > * > * { /* extra precedence to override button border margins */ + float: left; + margin-left: .75em; +} + +/* the first thing within each left/center/right section */ +.fc .fc-toolbar > * > :first-child { /* extra precedence to override button border margins */ + margin-left: 0; +} + +/* title text */ + +.fc-toolbar h2 { + margin: 0; +} + +/* button layering (for border precedence) */ + +.fc-toolbar button { + position: relative; +} + +.fc-toolbar .fc-state-hover, +.fc-toolbar .ui-state-hover { + z-index: 2; +} + +.fc-toolbar .fc-state-down { + z-index: 3; +} + +.fc-toolbar .fc-state-active, +.fc-toolbar .ui-state-active { + z-index: 4; +} + +.fc-toolbar button:focus { + z-index: 5; +} + + +/* View Structure +--------------------------------------------------------------------------------------------------*/ + +/* undo twitter bootstrap's box-sizing rules. normalizes positioning techniques */ +/* don't do this for the toolbar because we'll want bootstrap to style those buttons as some pt */ +.fc-view-container *, +.fc-view-container *:before, +.fc-view-container *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +.fc-view, /* scope positioning and z-index's for everything within the view */ +.fc-view > table { /* so dragged elements can be above the view's main element */ + position: relative; + z-index: 1; +} + + + +/* BasicView +--------------------------------------------------------------------------------------------------*/ + +/* day row structure */ + +.fc-basicWeek-view .fc-content-skeleton, +.fc-basicDay-view .fc-content-skeleton { + /* there may be week numbers in these views, so no padding-top */ + padding-bottom: 1em; /* ensure a space at bottom of cell for user selecting/clicking */ +} + +.fc-basic-view .fc-body .fc-row { + min-height: 4em; /* ensure that all rows are at least this tall */ +} + +/* a "rigid" row will take up a constant amount of height because content-skeleton is absolute */ + +.fc-row.fc-rigid { + overflow: hidden; +} + +.fc-row.fc-rigid .fc-content-skeleton { + position: absolute; + top: 0; + left: 0; + right: 0; +} + +/* week and day number styling */ + +.fc-day-top.fc-other-month { + opacity: 0.3; +} + +.fc-basic-view .fc-week-number, +.fc-basic-view .fc-day-number { + padding: 2px; +} + +.fc-basic-view th.fc-week-number, +.fc-basic-view th.fc-day-number { + padding: 0 2px; /* column headers can't have as much v space */ +} + +.fc-ltr .fc-basic-view .fc-day-top .fc-day-number { float: right; } +.fc-rtl .fc-basic-view .fc-day-top .fc-day-number { float: left; } + +.fc-ltr .fc-basic-view .fc-day-top .fc-week-number { float: left; border-radius: 0 0 3px 0; } +.fc-rtl .fc-basic-view .fc-day-top .fc-week-number { float: right; border-radius: 0 0 0 3px; } + +.fc-basic-view .fc-day-top .fc-week-number { + min-width: 1.5em; + text-align: center; + background-color: #f2f2f2; + color: #808080; +} + +/* when week/day number have own column */ + +.fc-basic-view td.fc-week-number { + text-align: center; +} + +.fc-basic-view td.fc-week-number > * { + /* work around the way we do column resizing and ensure a minimum width */ + display: inline-block; + min-width: 1.25em; +} + + +/* AgendaView all-day area +--------------------------------------------------------------------------------------------------*/ + +.fc-agenda-view .fc-day-grid { + position: relative; + z-index: 2; /* so the "more.." popover will be over the time grid */ +} + +.fc-agenda-view .fc-day-grid .fc-row { + min-height: 3em; /* all-day section will never get shorter than this */ +} + +.fc-agenda-view .fc-day-grid .fc-row .fc-content-skeleton { + padding-bottom: 1em; /* give space underneath events for clicking/selecting days */ +} + + +/* TimeGrid axis running down the side (for both the all-day area and the slot area) +--------------------------------------------------------------------------------------------------*/ + +.fc .fc-axis { /* .fc to overcome default cell styles */ + vertical-align: middle; + padding: 0 4px; + white-space: nowrap; +} + +.fc-ltr .fc-axis { + text-align: right; +} + +.fc-rtl .fc-axis { + text-align: left; +} + + +/* TimeGrid Structure +--------------------------------------------------------------------------------------------------*/ + +.fc-time-grid-container, /* so scroll container's z-index is below all-day */ +.fc-time-grid { /* so slats/bg/content/etc positions get scoped within here */ + position: relative; + z-index: 1; +} + +.fc-time-grid { + min-height: 100%; /* so if height setting is 'auto', .fc-bg stretches to fill height */ +} + +.fc-time-grid table { /* don't put outer borders on slats/bg/content/etc */ + border: 0 hidden transparent; +} + +.fc-time-grid > .fc-bg { + z-index: 1; +} + +.fc-time-grid .fc-slats, +.fc-time-grid > hr { /* the
AgendaView injects when grid is shorter than scroller */ + position: relative; + z-index: 2; +} + +.fc-time-grid .fc-content-col { + position: relative; /* because now-indicator lives directly inside */ +} + +.fc-time-grid .fc-content-skeleton { + position: absolute; + z-index: 3; + top: 0; + left: 0; + right: 0; +} + +/* divs within a cell within the fc-content-skeleton */ + +.fc-time-grid .fc-business-container { + position: relative; + z-index: 1; +} + +.fc-time-grid .fc-bgevent-container { + position: relative; + z-index: 2; +} + +.fc-time-grid .fc-highlight-container { + position: relative; + z-index: 3; +} + +.fc-time-grid .fc-event-container { + position: relative; + z-index: 4; +} + +.fc-time-grid .fc-now-indicator-line { + z-index: 5; +} + +.fc-time-grid .fc-helper-container { /* also is fc-event-container */ + position: relative; + z-index: 6; +} + + +/* TimeGrid Slats (lines that run horizontally) +--------------------------------------------------------------------------------------------------*/ + +.fc-time-grid .fc-slats td { + height: 1.5em; + border-bottom: 0; /* each cell is responsible for its top border */ +} + +.fc-time-grid .fc-slats .fc-minor td { + border-top-style: dotted; +} + + +/* TimeGrid Highlighting Slots +--------------------------------------------------------------------------------------------------*/ + +.fc-time-grid .fc-highlight-container { /* a div within a cell within the fc-highlight-skeleton */ + position: relative; /* scopes the left/right of the fc-highlight to be in the column */ +} + +.fc-time-grid .fc-highlight { + position: absolute; + left: 0; + right: 0; + /* top and bottom will be in by JS */ +} + + +/* TimeGrid Event Containment +--------------------------------------------------------------------------------------------------*/ + +.fc-ltr .fc-time-grid .fc-event-container { /* space on the sides of events for LTR (default) */ + margin: 0 2.5% 0 2px; +} + +.fc-rtl .fc-time-grid .fc-event-container { /* space on the sides of events for RTL */ + margin: 0 2px 0 2.5%; +} + +.fc-time-grid .fc-event, +.fc-time-grid .fc-bgevent { + position: absolute; + z-index: 1; /* scope inner z-index's */ +} + +.fc-time-grid .fc-bgevent { + /* background events always span full width */ + left: 0; + right: 0; +} + + +/* Generic Vertical Event +--------------------------------------------------------------------------------------------------*/ + +.fc-v-event.fc-not-start { /* events that are continuing from another day */ + /* replace space made by the top border with padding */ + border-top-width: 0; + padding-top: 1px; + + /* remove top rounded corners */ + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.fc-v-event.fc-not-end { + /* replace space made by the top border with padding */ + border-bottom-width: 0; + padding-bottom: 1px; + + /* remove bottom rounded corners */ + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + + +/* TimeGrid Event Styling +---------------------------------------------------------------------------------------------------- +We use the full "fc-time-grid-event" class instead of using descendants because the event won't +be a descendant of the grid when it is being dragged. +*/ + +.fc-time-grid-event { + overflow: hidden; /* don't let the bg flow over rounded corners */ +} + +.fc-time-grid-event.fc-selected { + /* need to allow touch resizers to extend outside event's bounding box */ + /* common fc-selected styles hide the fc-bg, so don't need this anyway */ + overflow: visible; +} + +.fc-time-grid-event.fc-selected .fc-bg { + display: none; /* hide semi-white background, to appear darker */ +} + +.fc-time-grid-event .fc-content { + overflow: hidden; /* for when .fc-selected */ +} + +.fc-time-grid-event .fc-time, +.fc-time-grid-event .fc-title { + padding: 0 1px; +} + +.fc-time-grid-event .fc-time { + font-size: .85em; + white-space: nowrap; +} + +/* short mode, where time and title are on the same line */ + +.fc-time-grid-event.fc-short .fc-content { + /* don't wrap to second line (now that contents will be inline) */ + white-space: nowrap; +} + +.fc-time-grid-event.fc-short .fc-time, +.fc-time-grid-event.fc-short .fc-title { + /* put the time and title on the same line */ + display: inline-block; + vertical-align: top; +} + +.fc-time-grid-event.fc-short .fc-time span { + display: none; /* don't display the full time text... */ +} + +.fc-time-grid-event.fc-short .fc-time:before { + content: attr(data-start); /* ...instead, display only the start time */ +} + +.fc-time-grid-event.fc-short .fc-time:after { + content: "\000A0-\000A0"; /* seperate with a dash, wrapped in nbsp's */ +} + +.fc-time-grid-event.fc-short .fc-title { + font-size: .85em; /* make the title text the same size as the time */ + padding: 0; /* undo padding from above */ +} + +/* resizer (cursor device) */ + +.fc-time-grid-event.fc-allow-mouse-resize .fc-resizer { + left: 0; + right: 0; + bottom: 0; + height: 8px; + overflow: hidden; + line-height: 8px; + font-size: 11px; + font-family: monospace; + text-align: center; + cursor: s-resize; +} + +.fc-time-grid-event.fc-allow-mouse-resize .fc-resizer:after { + content: "="; +} + +/* resizer (touch device) */ + +.fc-time-grid-event.fc-selected .fc-resizer { + /* 10x10 dot */ + border-radius: 5px; + border-width: 1px; + width: 8px; + height: 8px; + border-style: solid; + border-color: inherit; + background: #fff; + /* horizontally center */ + left: 50%; + margin-left: -5px; + /* center on the bottom edge */ + bottom: -5px; +} + + +/* Now Indicator +--------------------------------------------------------------------------------------------------*/ + +.fc-time-grid .fc-now-indicator-line { + border-top-width: 1px; + left: 0; + right: 0; +} + +/* arrow on axis */ + +.fc-time-grid .fc-now-indicator-arrow { + margin-top: -5px; /* vertically center on top coordinate */ +} + +.fc-ltr .fc-time-grid .fc-now-indicator-arrow { + left: 0; + /* triangle pointing right... */ + border-width: 5px 0 5px 6px; + border-top-color: transparent; + border-bottom-color: transparent; +} + +.fc-rtl .fc-time-grid .fc-now-indicator-arrow { + right: 0; + /* triangle pointing left... */ + border-width: 5px 6px 5px 0; + border-top-color: transparent; + border-bottom-color: transparent; +} + + + +/* List View +--------------------------------------------------------------------------------------------------*/ + +/* possibly reusable */ + +.fc-event-dot { + display: inline-block; + width: 10px; + height: 10px; + border-radius: 5px; +} + +/* view wrapper */ + +.fc-rtl .fc-list-view { + direction: rtl; /* unlike core views, leverage browser RTL */ +} + +.fc-list-view { + border-width: 1px; + border-style: solid; +} + +/* table resets */ + +.fc .fc-list-table { + table-layout: auto; /* for shrinkwrapping cell content */ +} + +.fc-list-table td { + border-width: 1px 0 0; + padding: 8px 14px; +} + +.fc-list-table tr:first-child td { + border-top-width: 0; +} + +/* day headings with the list */ + +.fc-list-heading { + border-bottom-width: 1px; +} + +.fc-list-heading td { + font-weight: bold; +} + +.fc-ltr .fc-list-heading-main { float: left; } +.fc-ltr .fc-list-heading-alt { float: right; } + +.fc-rtl .fc-list-heading-main { float: right; } +.fc-rtl .fc-list-heading-alt { float: left; } + +/* event list items */ + +.fc-list-item.fc-has-url { + cursor: pointer; /* whole row will be clickable */ +} + +.fc-list-item-marker, +.fc-list-item-time { + white-space: nowrap; + width: 1px; +} + +/* make the dot closer to the event title */ +.fc-ltr .fc-list-item-marker { padding-right: 0; } +.fc-rtl .fc-list-item-marker { padding-left: 0; } + +.fc-list-item-title a { + /* every event title cell has an
tag */ + text-decoration: none; + color: inherit; +} + +.fc-list-item-title a[href]:hover { + /* hover effect only on titles with hrefs */ + text-decoration: underline; +} + +/* message when no events */ + +.fc-list-empty-wrap2 { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +.fc-list-empty-wrap1 { + width: 100%; + height: 100%; + display: table; +} + +.fc-list-empty { + display: table-cell; + vertical-align: middle; + text-align: center; +} + +.fc-unthemed .fc-list-empty { /* theme will provide own background */ + background-color: #eee; +} diff --git a/librerias/calendar/fullcalendar.js b/librerias/calendar/fullcalendar.js new file mode 100755 index 0000000..69c5b1d --- /dev/null +++ b/librerias/calendar/fullcalendar.js @@ -0,0 +1,18310 @@ +/*! + * FullCalendar v3.6.1 + * Docs & License: https://fullcalendar.io/ + * (c) 2017 Adam Shaw + */ + +(function(factory) { + if (typeof define === 'function' && define.amd) { + define([ 'jquery', 'moment' ], factory); + } + else if (typeof exports === 'object') { // Node/CommonJS + module.exports = factory(require('jquery'), require('moment')); + } + else { + factory(jQuery, moment); + } +})(function($, moment) { + +;; + +var FC = $.fullCalendar = { + version: "3.6.1", + // When introducing internal API incompatibilities (where fullcalendar plugins would break), + // the minor version of the calendar should be upped (ex: 2.7.2 -> 2.8.0) + // and the below integer should be incremented. + internalApiVersion: 11 +}; +var fcViews = FC.views = {}; + + +$.fn.fullCalendar = function(options) { + var args = Array.prototype.slice.call(arguments, 1); // for a possible method call + var res = this; // what this function will return (this jQuery object by default) + + this.each(function(i, _element) { // loop each DOM element involved + var element = $(_element); + var calendar = element.data('fullCalendar'); // get the existing calendar object (if any) + var singleRes; // the returned value of this single method call + + // a method call + if (typeof options === 'string') { + + if (options === 'getCalendar') { + if (!i) { // first element only + res = calendar; + } + } + else if (options === 'destroy') { // don't warn if no calendar object + if (calendar) { + calendar.destroy(); + element.removeData('fullCalendar'); + } + } + else if (!calendar) { + FC.warn("Attempting to call a FullCalendar method on an element with no calendar."); + } + else if ($.isFunction(calendar[options])) { + singleRes = calendar[options].apply(calendar, args); + + if (!i) { + res = singleRes; // record the first method call result + } + if (options === 'destroy') { // for the destroy method, must remove Calendar object data + element.removeData('fullCalendar'); + } + } + else { + FC.warn("'" + options + "' is an unknown FullCalendar method."); + } + } + // a new calendar initialization + else if (!calendar) { // don't initialize twice + calendar = new Calendar(element, options); + element.data('fullCalendar', calendar); + calendar.render(); + } + }); + + return res; +}; + + +var complexOptions = [ // names of options that are objects whose properties should be combined + 'header', + 'footer', + 'buttonText', + 'buttonIcons', + 'themeButtonIcons' +]; + + +// Merges an array of option objects into a single object +function mergeOptions(optionObjs) { + return mergeProps(optionObjs, complexOptions); +} + +;; + +// exports +FC.applyAll = applyAll; +FC.debounce = debounce; +FC.isInt = isInt; +FC.htmlEscape = htmlEscape; +FC.cssToStr = cssToStr; +FC.proxy = proxy; +FC.capitaliseFirstLetter = capitaliseFirstLetter; + + +/* FullCalendar-specific DOM Utilities +----------------------------------------------------------------------------------------------------------------------*/ + + +// Given the scrollbar widths of some other container, create borders/margins on rowEls in order to match the left +// and right space that was offset by the scrollbars. A 1-pixel border first, then margin beyond that. +function compensateScroll(rowEls, scrollbarWidths) { + if (scrollbarWidths.left) { + rowEls.css({ + 'border-left-width': 1, + 'margin-left': scrollbarWidths.left - 1 + }); + } + if (scrollbarWidths.right) { + rowEls.css({ + 'border-right-width': 1, + 'margin-right': scrollbarWidths.right - 1 + }); + } +} + + +// Undoes compensateScroll and restores all borders/margins +function uncompensateScroll(rowEls) { + rowEls.css({ + 'margin-left': '', + 'margin-right': '', + 'border-left-width': '', + 'border-right-width': '' + }); +} + + +// Make the mouse cursor express that an event is not allowed in the current area +function disableCursor() { + $('body').addClass('fc-not-allowed'); +} + + +// Returns the mouse cursor to its original look +function enableCursor() { + $('body').removeClass('fc-not-allowed'); +} + + +// Given a total available height to fill, have `els` (essentially child rows) expand to accomodate. +// By default, all elements that are shorter than the recommended height are expanded uniformly, not considering +// any other els that are already too tall. if `shouldRedistribute` is on, it considers these tall rows and +// reduces the available height. +function distributeHeight(els, availableHeight, shouldRedistribute) { + + // *FLOORING NOTE*: we floor in certain places because zoom can give inaccurate floating-point dimensions, + // and it is better to be shorter than taller, to avoid creating unnecessary scrollbars. + + var minOffset1 = Math.floor(availableHeight / els.length); // for non-last element + var minOffset2 = Math.floor(availableHeight - minOffset1 * (els.length - 1)); // for last element *FLOORING NOTE* + var flexEls = []; // elements that are allowed to expand. array of DOM nodes + var flexOffsets = []; // amount of vertical space it takes up + var flexHeights = []; // actual css height + var usedHeight = 0; + + undistributeHeight(els); // give all elements their natural height + + // find elements that are below the recommended height (expandable). + // important to query for heights in a single first pass (to avoid reflow oscillation). + els.each(function(i, el) { + var minOffset = i === els.length - 1 ? minOffset2 : minOffset1; + var naturalOffset = $(el).outerHeight(true); + + if (naturalOffset < minOffset) { + flexEls.push(el); + flexOffsets.push(naturalOffset); + flexHeights.push($(el).height()); + } + else { + // this element stretches past recommended height (non-expandable). mark the space as occupied. + usedHeight += naturalOffset; + } + }); + + // readjust the recommended height to only consider the height available to non-maxed-out rows. + if (shouldRedistribute) { + availableHeight -= usedHeight; + minOffset1 = Math.floor(availableHeight / flexEls.length); + minOffset2 = Math.floor(availableHeight - minOffset1 * (flexEls.length - 1)); // *FLOORING NOTE* + } + + // assign heights to all expandable elements + $(flexEls).each(function(i, el) { + var minOffset = i === flexEls.length - 1 ? minOffset2 : minOffset1; + var naturalOffset = flexOffsets[i]; + var naturalHeight = flexHeights[i]; + var newHeight = minOffset - (naturalOffset - naturalHeight); // subtract the margin/padding + + if (naturalOffset < minOffset) { // we check this again because redistribution might have changed things + $(el).height(newHeight); + } + }); +} + + +// Undoes distrubuteHeight, restoring all els to their natural height +function undistributeHeight(els) { + els.height(''); +} + + +// Given `els`, a jQuery set of cells, find the cell with the largest natural width and set the widths of all the +// cells to be that width. +// PREREQUISITE: if you want a cell to take up width, it needs to have a single inner element w/ display:inline +function matchCellWidths(els) { + var maxInnerWidth = 0; + + els.find('> *').each(function(i, innerEl) { + var innerWidth = $(innerEl).outerWidth(); + if (innerWidth > maxInnerWidth) { + maxInnerWidth = innerWidth; + } + }); + + maxInnerWidth++; // sometimes not accurate of width the text needs to stay on one line. insurance + + els.width(maxInnerWidth); + + return maxInnerWidth; +} + + +// Given one element that resides inside another, +// Subtracts the height of the inner element from the outer element. +function subtractInnerElHeight(outerEl, innerEl) { + var both = outerEl.add(innerEl); + var diff; + + // effin' IE8/9/10/11 sometimes returns 0 for dimensions. this weird hack was the only thing that worked + both.css({ + position: 'relative', // cause a reflow, which will force fresh dimension recalculation + left: -1 // ensure reflow in case the el was already relative. negative is less likely to cause new scroll + }); + diff = outerEl.outerHeight() - innerEl.outerHeight(); // grab the dimensions + both.css({ position: '', left: '' }); // undo hack + + return diff; +} + + +/* Element Geom Utilities +----------------------------------------------------------------------------------------------------------------------*/ + +FC.getOuterRect = getOuterRect; +FC.getClientRect = getClientRect; +FC.getContentRect = getContentRect; +FC.getScrollbarWidths = getScrollbarWidths; + + +// borrowed from https://github.com/jquery/jquery-ui/blob/1.11.0/ui/core.js#L51 +function getScrollParent(el) { + var position = el.css('position'), + scrollParent = el.parents().filter(function() { + var parent = $(this); + return (/(auto|scroll)/).test( + parent.css('overflow') + parent.css('overflow-y') + parent.css('overflow-x') + ); + }).eq(0); + + return position === 'fixed' || !scrollParent.length ? $(el[0].ownerDocument || document) : scrollParent; +} + + +// Queries the outer bounding area of a jQuery element. +// Returns a rectangle with absolute coordinates: left, right (exclusive), top, bottom (exclusive). +// Origin is optional. +function getOuterRect(el, origin) { + var offset = el.offset(); + var left = offset.left - (origin ? origin.left : 0); + var top = offset.top - (origin ? origin.top : 0); + + return { + left: left, + right: left + el.outerWidth(), + top: top, + bottom: top + el.outerHeight() + }; +} + + +// Queries the area within the margin/border/scrollbars of a jQuery element. Does not go within the padding. +// Returns a rectangle with absolute coordinates: left, right (exclusive), top, bottom (exclusive). +// Origin is optional. +// WARNING: given element can't have borders +// NOTE: should use clientLeft/clientTop, but very unreliable cross-browser. +function getClientRect(el, origin) { + var offset = el.offset(); + var scrollbarWidths = getScrollbarWidths(el); + var left = offset.left + getCssFloat(el, 'border-left-width') + scrollbarWidths.left - (origin ? origin.left : 0); + var top = offset.top + getCssFloat(el, 'border-top-width') + scrollbarWidths.top - (origin ? origin.top : 0); + + return { + left: left, + right: left + el[0].clientWidth, // clientWidth includes padding but NOT scrollbars + top: top, + bottom: top + el[0].clientHeight // clientHeight includes padding but NOT scrollbars + }; +} + + +// Queries the area within the margin/border/padding of a jQuery element. Assumed not to have scrollbars. +// Returns a rectangle with absolute coordinates: left, right (exclusive), top, bottom (exclusive). +// Origin is optional. +function getContentRect(el, origin) { + var offset = el.offset(); // just outside of border, margin not included + var left = offset.left + getCssFloat(el, 'border-left-width') + getCssFloat(el, 'padding-left') - + (origin ? origin.left : 0); + var top = offset.top + getCssFloat(el, 'border-top-width') + getCssFloat(el, 'padding-top') - + (origin ? origin.top : 0); + + return { + left: left, + right: left + el.width(), + top: top, + bottom: top + el.height() + }; +} + + +// Returns the computed left/right/top/bottom scrollbar widths for the given jQuery element. +// WARNING: given element can't have borders (which will cause offsetWidth/offsetHeight to be larger). +// NOTE: should use clientLeft/clientTop, but very unreliable cross-browser. +function getScrollbarWidths(el) { + var leftRightWidth = el[0].offsetWidth - el[0].clientWidth; + var bottomWidth = el[0].offsetHeight - el[0].clientHeight; + var widths; + + leftRightWidth = sanitizeScrollbarWidth(leftRightWidth); + bottomWidth = sanitizeScrollbarWidth(bottomWidth); + + widths = { left: 0, right: 0, top: 0, bottom: bottomWidth }; + + if (getIsLeftRtlScrollbars() && el.css('direction') == 'rtl') { // is the scrollbar on the left side? + widths.left = leftRightWidth; + } + else { + widths.right = leftRightWidth; + } + + return widths; +} + + +// The scrollbar width computations in getScrollbarWidths are sometimes flawed when it comes to +// retina displays, rounding, and IE11. Massage them into a usable value. +function sanitizeScrollbarWidth(width) { + width = Math.max(0, width); // no negatives + width = Math.round(width); + return width; +} + + +// Logic for determining if, when the element is right-to-left, the scrollbar appears on the left side + +var _isLeftRtlScrollbars = null; + +function getIsLeftRtlScrollbars() { // responsible for caching the computation + if (_isLeftRtlScrollbars === null) { + _isLeftRtlScrollbars = computeIsLeftRtlScrollbars(); + } + return _isLeftRtlScrollbars; +} + +function computeIsLeftRtlScrollbars() { // creates an offscreen test element, then removes it + var el = $('
') + .css({ + position: 'absolute', + top: -1000, + left: 0, + border: 0, + padding: 0, + overflow: 'scroll', + direction: 'rtl' + }) + .appendTo('body'); + var innerEl = el.children(); + var res = innerEl.offset().left > el.offset().left; // is the inner div shifted to accommodate a left scrollbar? + el.remove(); + return res; +} + + +// Retrieves a jQuery element's computed CSS value as a floating-point number. +// If the queried value is non-numeric (ex: IE can return "medium" for border width), will just return zero. +function getCssFloat(el, prop) { + return parseFloat(el.css(prop)) || 0; +} + + +/* Mouse / Touch Utilities +----------------------------------------------------------------------------------------------------------------------*/ + +FC.preventDefault = preventDefault; + + +// Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac) +function isPrimaryMouseButton(ev) { + return ev.which == 1 && !ev.ctrlKey; +} + + +function getEvX(ev) { + var touches = ev.originalEvent.touches; + + // on mobile FF, pageX for touch events is present, but incorrect, + // so, look at touch coordinates first. + if (touches && touches.length) { + return touches[0].pageX; + } + + return ev.pageX; +} + + +function getEvY(ev) { + var touches = ev.originalEvent.touches; + + // on mobile FF, pageX for touch events is present, but incorrect, + // so, look at touch coordinates first. + if (touches && touches.length) { + return touches[0].pageY; + } + + return ev.pageY; +} + + +function getEvIsTouch(ev) { + return /^touch/.test(ev.type); +} + + +function preventSelection(el) { + el.addClass('fc-unselectable') + .on('selectstart', preventDefault); +} + + +function allowSelection(el) { + el.removeClass('fc-unselectable') + .off('selectstart', preventDefault); +} + + +// Stops a mouse/touch event from doing it's native browser action +function preventDefault(ev) { + ev.preventDefault(); +} + + +/* General Geometry Utils +----------------------------------------------------------------------------------------------------------------------*/ + +FC.intersectRects = intersectRects; + +// Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false +function intersectRects(rect1, rect2) { + var res = { + left: Math.max(rect1.left, rect2.left), + right: Math.min(rect1.right, rect2.right), + top: Math.max(rect1.top, rect2.top), + bottom: Math.min(rect1.bottom, rect2.bottom) + }; + + if (res.left < res.right && res.top < res.bottom) { + return res; + } + return false; +} + + +// Returns a new point that will have been moved to reside within the given rectangle +function constrainPoint(point, rect) { + return { + left: Math.min(Math.max(point.left, rect.left), rect.right), + top: Math.min(Math.max(point.top, rect.top), rect.bottom) + }; +} + + +// Returns a point that is the center of the given rectangle +function getRectCenter(rect) { + return { + left: (rect.left + rect.right) / 2, + top: (rect.top + rect.bottom) / 2 + }; +} + + +// Subtracts point2's coordinates from point1's coordinates, returning a delta +function diffPoints(point1, point2) { + return { + left: point1.left - point2.left, + top: point1.top - point2.top + }; +} + + +/* Object Ordering by Field +----------------------------------------------------------------------------------------------------------------------*/ + +FC.parseFieldSpecs = parseFieldSpecs; +FC.compareByFieldSpecs = compareByFieldSpecs; +FC.compareByFieldSpec = compareByFieldSpec; +FC.flexibleCompare = flexibleCompare; + + +function parseFieldSpecs(input) { + var specs = []; + var tokens = []; + var i, token; + + if (typeof input === 'string') { + tokens = input.split(/\s*,\s*/); + } + else if (typeof input === 'function') { + tokens = [ input ]; + } + else if ($.isArray(input)) { + tokens = input; + } + + for (i = 0; i < tokens.length; i++) { + token = tokens[i]; + + if (typeof token === 'string') { + specs.push( + token.charAt(0) == '-' ? + { field: token.substring(1), order: -1 } : + { field: token, order: 1 } + ); + } + else if (typeof token === 'function') { + specs.push({ func: token }); + } + } + + return specs; +} + + +function compareByFieldSpecs(obj1, obj2, fieldSpecs) { + var i; + var cmp; + + for (i = 0; i < fieldSpecs.length; i++) { + cmp = compareByFieldSpec(obj1, obj2, fieldSpecs[i]); + if (cmp) { + return cmp; + } + } + + return 0; +} + + +function compareByFieldSpec(obj1, obj2, fieldSpec) { + if (fieldSpec.func) { + return fieldSpec.func(obj1, obj2); + } + return flexibleCompare(obj1[fieldSpec.field], obj2[fieldSpec.field]) * + (fieldSpec.order || 1); +} + + +function flexibleCompare(a, b) { + if (!a && !b) { + return 0; + } + if (b == null) { + return -1; + } + if (a == null) { + return 1; + } + if ($.type(a) === 'string' || $.type(b) === 'string') { + return String(a).localeCompare(String(b)); + } + return a - b; +} + + +/* Date Utilities +----------------------------------------------------------------------------------------------------------------------*/ + +FC.computeGreatestUnit = computeGreatestUnit; +FC.divideRangeByDuration = divideRangeByDuration; +FC.divideDurationByDuration = divideDurationByDuration; +FC.multiplyDuration = multiplyDuration; +FC.durationHasTime = durationHasTime; + +var dayIDs = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ]; +var unitsDesc = [ 'year', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond' ]; // descending + + +// Diffs the two moments into a Duration where full-days are recorded first, then the remaining time. +// Moments will have their timezones normalized. +function diffDayTime(a, b) { + return moment.duration({ + days: a.clone().stripTime().diff(b.clone().stripTime(), 'days'), + ms: a.time() - b.time() // time-of-day from day start. disregards timezone + }); +} + + +// Diffs the two moments via their start-of-day (regardless of timezone). Produces whole-day durations. +function diffDay(a, b) { + return moment.duration({ + days: a.clone().stripTime().diff(b.clone().stripTime(), 'days') + }); +} + + +// Diffs two moments, producing a duration, made of a whole-unit-increment of the given unit. Uses rounding. +function diffByUnit(a, b, unit) { + return moment.duration( + Math.round(a.diff(b, unit, true)), // returnFloat=true + unit + ); +} + + +// Computes the unit name of the largest whole-unit period of time. +// For example, 48 hours will be "days" whereas 49 hours will be "hours". +// Accepts start/end, a range object, or an original duration object. +function computeGreatestUnit(start, end) { + var i, unit; + var val; + + for (i = 0; i < unitsDesc.length; i++) { + unit = unitsDesc[i]; + val = computeRangeAs(unit, start, end); + + if (val >= 1 && isInt(val)) { + break; + } + } + + return unit; // will be "milliseconds" if nothing else matches +} + + +// like computeGreatestUnit, but has special abilities to interpret the source input for clues +function computeDurationGreatestUnit(duration, durationInput) { + var unit = computeGreatestUnit(duration); + + // prevent days:7 from being interpreted as a week + if (unit === 'week' && typeof durationInput === 'object' && durationInput.days) { + unit = 'day'; + } + + return unit; +} + + +// Computes the number of units (like "hours") in the given range. +// Range can be a {start,end} object, separate start/end args, or a Duration. +// Results are based on Moment's .as() and .diff() methods, so results can depend on internal handling +// of month-diffing logic (which tends to vary from version to version). +function computeRangeAs(unit, start, end) { + + if (end != null) { // given start, end + return end.diff(start, unit, true); + } + else if (moment.isDuration(start)) { // given duration + return start.as(unit); + } + else { // given { start, end } range object + return start.end.diff(start.start, unit, true); + } +} + + +// Intelligently divides a range (specified by a start/end params) by a duration +function divideRangeByDuration(start, end, dur) { + var months; + + if (durationHasTime(dur)) { + return (end - start) / dur; + } + months = dur.asMonths(); + if (Math.abs(months) >= 1 && isInt(months)) { + return end.diff(start, 'months', true) / months; + } + return end.diff(start, 'days', true) / dur.asDays(); +} + + +// Intelligently divides one duration by another +function divideDurationByDuration(dur1, dur2) { + var months1, months2; + + if (durationHasTime(dur1) || durationHasTime(dur2)) { + return dur1 / dur2; + } + months1 = dur1.asMonths(); + months2 = dur2.asMonths(); + if ( + Math.abs(months1) >= 1 && isInt(months1) && + Math.abs(months2) >= 1 && isInt(months2) + ) { + return months1 / months2; + } + return dur1.asDays() / dur2.asDays(); +} + + +// Intelligently multiplies a duration by a number +function multiplyDuration(dur, n) { + var months; + + if (durationHasTime(dur)) { + return moment.duration(dur * n); + } + months = dur.asMonths(); + if (Math.abs(months) >= 1 && isInt(months)) { + return moment.duration({ months: months * n }); + } + return moment.duration({ days: dur.asDays() * n }); +} + + +// Returns a boolean about whether the given duration has any time parts (hours/minutes/seconds/ms) +function durationHasTime(dur) { + return Boolean(dur.hours() || dur.minutes() || dur.seconds() || dur.milliseconds()); +} + + +function isNativeDate(input) { + return Object.prototype.toString.call(input) === '[object Date]' || input instanceof Date; +} + + +// Returns a boolean about whether the given input is a time string, like "06:40:00" or "06:00" +function isTimeString(str) { + return typeof str === 'string' && + /^\d+\:\d+(?:\:\d+\.?(?:\d{3})?)?$/.test(str); +} + + +/* Logging and Debug +----------------------------------------------------------------------------------------------------------------------*/ + +FC.log = function() { + var console = window.console; + + if (console && console.log) { + return console.log.apply(console, arguments); + } +}; + +FC.warn = function() { + var console = window.console; + + if (console && console.warn) { + return console.warn.apply(console, arguments); + } + else { + return FC.log.apply(FC, arguments); + } +}; + + +/* General Utilities +----------------------------------------------------------------------------------------------------------------------*/ + +var hasOwnPropMethod = {}.hasOwnProperty; + + +// Merges an array of objects into a single object. +// The second argument allows for an array of property names who's object values will be merged together. +function mergeProps(propObjs, complexProps) { + var dest = {}; + var i, name; + var complexObjs; + var j, val; + var props; + + if (complexProps) { + for (i = 0; i < complexProps.length; i++) { + name = complexProps[i]; + complexObjs = []; + + // collect the trailing object values, stopping when a non-object is discovered + for (j = propObjs.length - 1; j >= 0; j--) { + val = propObjs[j][name]; + + if (typeof val === 'object') { + complexObjs.unshift(val); + } + else if (val !== undefined) { + dest[name] = val; // if there were no objects, this value will be used + break; + } + } + + // if the trailing values were objects, use the merged value + if (complexObjs.length) { + dest[name] = mergeProps(complexObjs); + } + } + } + + // copy values into the destination, going from last to first + for (i = propObjs.length - 1; i >= 0; i--) { + props = propObjs[i]; + + for (name in props) { + if (!(name in dest)) { // if already assigned by previous props or complex props, don't reassign + dest[name] = props[name]; + } + } + } + + return dest; +} + + +function copyOwnProps(src, dest) { + for (var name in src) { + if (hasOwnProp(src, name)) { + dest[name] = src[name]; + } + } +} + + +function hasOwnProp(obj, name) { + return hasOwnPropMethod.call(obj, name); +} + + +function applyAll(functions, thisObj, args) { + if ($.isFunction(functions)) { + functions = [ functions ]; + } + if (functions) { + var i; + var ret; + for (i=0; i/g, '>') + .replace(/'/g, ''') + .replace(/"/g, '"') + .replace(/\n/g, '
'); +} + + +function stripHtmlEntities(text) { + return text.replace(/&.*?;/g, ''); +} + + +// Given a hash of CSS properties, returns a string of CSS. +// Uses property names as-is (no camel-case conversion). Will not make statements for null/undefined values. +function cssToStr(cssProps) { + var statements = []; + + $.each(cssProps, function(name, val) { + if (val != null) { + statements.push(name + ':' + val); + } + }); + + return statements.join(';'); +} + + +// Given an object hash of HTML attribute names to values, +// generates a string that can be injected between < > in HTML +function attrsToStr(attrs) { + var parts = []; + + $.each(attrs, function(name, val) { + if (val != null) { + parts.push(name + '="' + htmlEscape(val) + '"'); + } + }); + + return parts.join(' '); +} + + +function capitaliseFirstLetter(str) { + return str.charAt(0).toUpperCase() + str.slice(1); +} + + +function compareNumbers(a, b) { // for .sort() + return a - b; +} + + +function isInt(n) { + return n % 1 === 0; +} + + +// Returns a method bound to the given object context. +// Just like one of the jQuery.proxy signatures, but without the undesired behavior of treating the same method with +// different contexts as identical when binding/unbinding events. +function proxy(obj, methodName) { + var method = obj[methodName]; + + return function() { + return method.apply(obj, arguments); + }; +} + + +// Returns a function, that, as long as it continues to be invoked, will not +// be triggered. The function will be called after it stops being called for +// N milliseconds. If `immediate` is passed, trigger the function on the +// leading edge, instead of the trailing. +// https://github.com/jashkenas/underscore/blob/1.6.0/underscore.js#L714 +function debounce(func, wait, immediate) { + var timeout, args, context, timestamp, result; + + var later = function() { + var last = +new Date() - timestamp; + if (last < wait) { + timeout = setTimeout(later, wait - last); + } + else { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + context = args = null; + } + } + }; + + return function() { + context = this; + args = arguments; + timestamp = +new Date(); + var callNow = immediate && !timeout; + if (!timeout) { + timeout = setTimeout(later, wait); + } + if (callNow) { + result = func.apply(context, args); + context = args = null; + } + return result; + }; +} + +;; + +/* +GENERAL NOTE on moments throughout the *entire rest* of the codebase: +All moments are assumed to be ambiguously-zoned unless otherwise noted, +with the NOTABLE EXCEOPTION of start/end dates that live on *Event Objects*. +Ambiguously-TIMED moments are assumed to be ambiguously-zoned by nature. +*/ + +var ambigDateOfMonthRegex = /^\s*\d{4}-\d\d$/; +var ambigTimeOrZoneRegex = + /^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?)?$/; +var newMomentProto = moment.fn; // where we will attach our new methods +var oldMomentProto = $.extend({}, newMomentProto); // copy of original moment methods + +// tell momentjs to transfer these properties upon clone +var momentProperties = moment.momentProperties; +momentProperties.push('_fullCalendar'); +momentProperties.push('_ambigTime'); +momentProperties.push('_ambigZone'); + + +// Creating +// ------------------------------------------------------------------------------------------------- + +// Creates a new moment, similar to the vanilla moment(...) constructor, but with +// extra features (ambiguous time, enhanced formatting). When given an existing moment, +// it will function as a clone (and retain the zone of the moment). Anything else will +// result in a moment in the local zone. +FC.moment = function() { + return makeMoment(arguments); +}; + +// Sames as FC.moment, but forces the resulting moment to be in the UTC timezone. +FC.moment.utc = function() { + var mom = makeMoment(arguments, true); + + // Force it into UTC because makeMoment doesn't guarantee it + // (if given a pre-existing moment for example) + if (mom.hasTime()) { // don't give ambiguously-timed moments a UTC zone + mom.utc(); + } + + return mom; +}; + +// Same as FC.moment, but when given an ISO8601 string, the timezone offset is preserved. +// ISO8601 strings with no timezone offset will become ambiguously zoned. +FC.moment.parseZone = function() { + return makeMoment(arguments, true, true); +}; + +// Builds an enhanced moment from args. When given an existing moment, it clones. When given a +// native Date, or called with no arguments (the current time), the resulting moment will be local. +// Anything else needs to be "parsed" (a string or an array), and will be affected by: +// parseAsUTC - if there is no zone information, should we parse the input in UTC? +// parseZone - if there is zone information, should we force the zone of the moment? +function makeMoment(args, parseAsUTC, parseZone) { + var input = args[0]; + var isSingleString = args.length == 1 && typeof input === 'string'; + var isAmbigTime; + var isAmbigZone; + var ambigMatch; + var mom; + + if (moment.isMoment(input) || isNativeDate(input) || input === undefined) { + mom = moment.apply(null, args); + } + else { // "parsing" is required + isAmbigTime = false; + isAmbigZone = false; + + if (isSingleString) { + if (ambigDateOfMonthRegex.test(input)) { + // accept strings like '2014-05', but convert to the first of the month + input += '-01'; + args = [ input ]; // for when we pass it on to moment's constructor + isAmbigTime = true; + isAmbigZone = true; + } + else if ((ambigMatch = ambigTimeOrZoneRegex.exec(input))) { + isAmbigTime = !ambigMatch[5]; // no time part? + isAmbigZone = true; + } + } + else if ($.isArray(input)) { + // arrays have no timezone information, so assume ambiguous zone + isAmbigZone = true; + } + // otherwise, probably a string with a format + + if (parseAsUTC || isAmbigTime) { + mom = moment.utc.apply(moment, args); + } + else { + mom = moment.apply(null, args); + } + + if (isAmbigTime) { + mom._ambigTime = true; + mom._ambigZone = true; // ambiguous time always means ambiguous zone + } + else if (parseZone) { // let's record the inputted zone somehow + if (isAmbigZone) { + mom._ambigZone = true; + } + else if (isSingleString) { + mom.utcOffset(input); // if not a valid zone, will assign UTC + } + } + } + + mom._fullCalendar = true; // flag for extended functionality + + return mom; +} + + +// Week Number +// ------------------------------------------------------------------------------------------------- + + +// Returns the week number, considering the locale's custom week number calcuation +// `weeks` is an alias for `week` +newMomentProto.week = newMomentProto.weeks = function(input) { + var weekCalc = this._locale._fullCalendar_weekCalc; + + if (input == null && typeof weekCalc === 'function') { // custom function only works for getter + return weekCalc(this); + } + else if (weekCalc === 'ISO') { + return oldMomentProto.isoWeek.apply(this, arguments); // ISO getter/setter + } + + return oldMomentProto.week.apply(this, arguments); // local getter/setter +}; + + +// Time-of-day +// ------------------------------------------------------------------------------------------------- + +// GETTER +// Returns a Duration with the hours/minutes/seconds/ms values of the moment. +// If the moment has an ambiguous time, a duration of 00:00 will be returned. +// +// SETTER +// You can supply a Duration, a Moment, or a Duration-like argument. +// When setting the time, and the moment has an ambiguous time, it then becomes unambiguous. +newMomentProto.time = function(time) { + + // Fallback to the original method (if there is one) if this moment wasn't created via FullCalendar. + // `time` is a generic enough method name where this precaution is necessary to avoid collisions w/ other plugins. + if (!this._fullCalendar) { + return oldMomentProto.time.apply(this, arguments); + } + + if (time == null) { // getter + return moment.duration({ + hours: this.hours(), + minutes: this.minutes(), + seconds: this.seconds(), + milliseconds: this.milliseconds() + }); + } + else { // setter + + this._ambigTime = false; // mark that the moment now has a time + + if (!moment.isDuration(time) && !moment.isMoment(time)) { + time = moment.duration(time); + } + + // The day value should cause overflow (so 24 hours becomes 00:00:00 of next day). + // Only for Duration times, not Moment times. + var dayHours = 0; + if (moment.isDuration(time)) { + dayHours = Math.floor(time.asDays()) * 24; + } + + // We need to set the individual fields. + // Can't use startOf('day') then add duration. In case of DST at start of day. + return this.hours(dayHours + time.hours()) + .minutes(time.minutes()) + .seconds(time.seconds()) + .milliseconds(time.milliseconds()); + } +}; + +// Converts the moment to UTC, stripping out its time-of-day and timezone offset, +// but preserving its YMD. A moment with a stripped time will display no time +// nor timezone offset when .format() is called. +newMomentProto.stripTime = function() { + + if (!this._ambigTime) { + + this.utc(true); // keepLocalTime=true (for keeping *date* value) + + // set time to zero + this.set({ + hours: 0, + minutes: 0, + seconds: 0, + ms: 0 + }); + + // Mark the time as ambiguous. This needs to happen after the .utc() call, which might call .utcOffset(), + // which clears all ambig flags. + this._ambigTime = true; + this._ambigZone = true; // if ambiguous time, also ambiguous timezone offset + } + + return this; // for chaining +}; + +// Returns if the moment has a non-ambiguous time (boolean) +newMomentProto.hasTime = function() { + return !this._ambigTime; +}; + + +// Timezone +// ------------------------------------------------------------------------------------------------- + +// Converts the moment to UTC, stripping out its timezone offset, but preserving its +// YMD and time-of-day. A moment with a stripped timezone offset will display no +// timezone offset when .format() is called. +newMomentProto.stripZone = function() { + var wasAmbigTime; + + if (!this._ambigZone) { + + wasAmbigTime = this._ambigTime; + + this.utc(true); // keepLocalTime=true (for keeping date and time values) + + // the above call to .utc()/.utcOffset() unfortunately might clear the ambig flags, so restore + this._ambigTime = wasAmbigTime || false; + + // Mark the zone as ambiguous. This needs to happen after the .utc() call, which might call .utcOffset(), + // which clears the ambig flags. + this._ambigZone = true; + } + + return this; // for chaining +}; + +// Returns of the moment has a non-ambiguous timezone offset (boolean) +newMomentProto.hasZone = function() { + return !this._ambigZone; +}; + + +// implicitly marks a zone +newMomentProto.local = function(keepLocalTime) { + + // for when converting from ambiguously-zoned to local, + // keep the time values when converting from UTC -> local + oldMomentProto.local.call(this, this._ambigZone || keepLocalTime); + + // ensure non-ambiguous + // this probably already happened via local() -> utcOffset(), but don't rely on Moment's internals + this._ambigTime = false; + this._ambigZone = false; + + return this; // for chaining +}; + + +// implicitly marks a zone +newMomentProto.utc = function(keepLocalTime) { + + oldMomentProto.utc.call(this, keepLocalTime); + + // ensure non-ambiguous + // this probably already happened via utc() -> utcOffset(), but don't rely on Moment's internals + this._ambigTime = false; + this._ambigZone = false; + + return this; +}; + + +// implicitly marks a zone (will probably get called upon .utc() and .local()) +newMomentProto.utcOffset = function(tzo) { + + if (tzo != null) { // setter + // these assignments needs to happen before the original zone method is called. + // I forget why, something to do with a browser crash. + this._ambigTime = false; + this._ambigZone = false; + } + + return oldMomentProto.utcOffset.apply(this, arguments); +}; + + +// Formatting +// ------------------------------------------------------------------------------------------------- + +newMomentProto.format = function() { + + if (this._fullCalendar && arguments[0]) { // an enhanced moment? and a format string provided? + return formatDate(this, arguments[0]); // our extended formatting + } + if (this._ambigTime) { + return oldMomentFormat(englishMoment(this), 'YYYY-MM-DD'); + } + if (this._ambigZone) { + return oldMomentFormat(englishMoment(this), 'YYYY-MM-DD[T]HH:mm:ss'); + } + if (this._fullCalendar) { // enhanced non-ambig moment? + // moment.format() doesn't ensure english, but we want to. + return oldMomentFormat(englishMoment(this)); + } + + return oldMomentProto.format.apply(this, arguments); +}; + +newMomentProto.toISOString = function() { + + if (this._ambigTime) { + return oldMomentFormat(englishMoment(this), 'YYYY-MM-DD'); + } + if (this._ambigZone) { + return oldMomentFormat(englishMoment(this), 'YYYY-MM-DD[T]HH:mm:ss'); + } + if (this._fullCalendar) { // enhanced non-ambig moment? + // depending on browser, moment might not output english. ensure english. + // https://github.com/moment/moment/blob/2.18.1/src/lib/moment/format.js#L22 + return oldMomentProto.toISOString.apply(englishMoment(this), arguments); + } + + return oldMomentProto.toISOString.apply(this, arguments); +}; + +function englishMoment(mom) { + if (mom.locale() !== 'en') { + return mom.clone().locale('en'); + } + return mom; +} + +;; +(function() { + +// exports +FC.formatDate = formatDate; +FC.formatRange = formatRange; +FC.oldMomentFormat = oldMomentFormat; +FC.queryMostGranularFormatUnit = queryMostGranularFormatUnit; + + +// Config +// --------------------------------------------------------------------------------------------------------------------- + +/* +Inserted between chunks in the fake ("intermediate") formatting string. +Important that it passes as whitespace (\s) because moment often identifies non-standalone months +via a regexp with an \s. +*/ +var PART_SEPARATOR = '\u000b'; // vertical tab + +/* +Inserted as the first character of a literal-text chunk to indicate that the literal text is not actually literal text, +but rather, a "special" token that has custom rendering (see specialTokens map). +*/ +var SPECIAL_TOKEN_MARKER = '\u001f'; // information separator 1 + +/* +Inserted at the beginning and end of a span of text that must have non-zero numeric characters. +Handling of these markers is done in a post-processing step at the very end of text rendering. +*/ +var MAYBE_MARKER = '\u001e'; // information separator 2 +var MAYBE_REGEXP = new RegExp(MAYBE_MARKER + '([^' + MAYBE_MARKER + ']*)' + MAYBE_MARKER, 'g'); // must be global + +/* +Addition formatting tokens we want recognized +*/ +var specialTokens = { + t: function(date) { // "a" or "p" + return oldMomentFormat(date, 'a').charAt(0); + }, + T: function(date) { // "A" or "P" + return oldMomentFormat(date, 'A').charAt(0); + } +}; + +/* +The first characters of formatting tokens for units that are 1 day or larger. +`value` is for ranking relative size (lower means bigger). +`unit` is a normalized unit, used for comparing moments. +*/ +var largeTokenMap = { + Y: { value: 1, unit: 'year' }, + M: { value: 2, unit: 'month' }, + W: { value: 3, unit: 'week' }, // ISO week + w: { value: 3, unit: 'week' }, // local week + D: { value: 4, unit: 'day' }, // day of month + d: { value: 4, unit: 'day' } // day of week +}; + + +// Single Date Formatting +// --------------------------------------------------------------------------------------------------------------------- + +/* +Formats `date` with a Moment formatting string, but allow our non-zero areas and special token +*/ +function formatDate(date, formatStr) { + return renderFakeFormatString( + getParsedFormatString(formatStr).fakeFormatString, + date + ); +} + +/* +Call this if you want Moment's original format method to be used +*/ +function oldMomentFormat(mom, formatStr) { + return oldMomentProto.format.call(mom, formatStr); // oldMomentProto defined in moment-ext.js +} + + +// Date Range Formatting +// ------------------------------------------------------------------------------------------------- +// TODO: make it work with timezone offset + +/* +Using a formatting string meant for a single date, generate a range string, like +"Sep 2 - 9 2013", that intelligently inserts a separator where the dates differ. +If the dates are the same as far as the format string is concerned, just return a single +rendering of one date, without any separator. +*/ +function formatRange(date1, date2, formatStr, separator, isRTL) { + var localeData; + + date1 = FC.moment.parseZone(date1); + date2 = FC.moment.parseZone(date2); + + localeData = date1.localeData(); + + // Expand localized format strings, like "LL" -> "MMMM D YYYY". + // BTW, this is not important for `formatDate` because it is impossible to put custom tokens + // or non-zero areas in Moment's localized format strings. + formatStr = localeData.longDateFormat(formatStr) || formatStr; + + return renderParsedFormat( + getParsedFormatString(formatStr), + date1, + date2, + separator || ' - ', + isRTL + ); +} + +/* +Renders a range with an already-parsed format string. +*/ +function renderParsedFormat(parsedFormat, date1, date2, separator, isRTL) { + var sameUnits = parsedFormat.sameUnits; + var unzonedDate1 = date1.clone().stripZone(); // for same-unit comparisons + var unzonedDate2 = date2.clone().stripZone(); // " + + var renderedParts1 = renderFakeFormatStringParts(parsedFormat.fakeFormatString, date1); + var renderedParts2 = renderFakeFormatStringParts(parsedFormat.fakeFormatString, date2); + + var leftI; + var leftStr = ''; + var rightI; + var rightStr = ''; + var middleI; + var middleStr1 = ''; + var middleStr2 = ''; + var middleStr = ''; + + // Start at the leftmost side of the formatting string and continue until you hit a token + // that is not the same between dates. + for ( + leftI = 0; + leftI < sameUnits.length && (!sameUnits[leftI] || unzonedDate1.isSame(unzonedDate2, sameUnits[leftI])); + leftI++ + ) { + leftStr += renderedParts1[leftI]; + } + + // Similarly, start at the rightmost side of the formatting string and move left + for ( + rightI = sameUnits.length - 1; + rightI > leftI && (!sameUnits[rightI] || unzonedDate1.isSame(unzonedDate2, sameUnits[rightI])); + rightI-- + ) { + // If current chunk is on the boundary of unique date-content, and is a special-case + // date-formatting postfix character, then don't consume it. Consider it unique date-content. + // TODO: make configurable + if (rightI - 1 === leftI && renderedParts1[rightI] === '.') { + break; + } + + rightStr = renderedParts1[rightI] + rightStr; + } + + // The area in the middle is different for both of the dates. + // Collect them distinctly so we can jam them together later. + for (middleI = leftI; middleI <= rightI; middleI++) { + middleStr1 += renderedParts1[middleI]; + middleStr2 += renderedParts2[middleI]; + } + + if (middleStr1 || middleStr2) { + if (isRTL) { + middleStr = middleStr2 + separator + middleStr1; + } + else { + middleStr = middleStr1 + separator + middleStr2; + } + } + + return processMaybeMarkers( + leftStr + middleStr + rightStr + ); +} + + +// Format String Parsing +// --------------------------------------------------------------------------------------------------------------------- + +var parsedFormatStrCache = {}; + +/* +Returns a parsed format string, leveraging a cache. +*/ +function getParsedFormatString(formatStr) { + return parsedFormatStrCache[formatStr] || + (parsedFormatStrCache[formatStr] = parseFormatString(formatStr)); +} + +/* +Parses a format string into the following: +- fakeFormatString: a momentJS formatting string, littered with special control characters that get post-processed. +- sameUnits: for every part in fakeFormatString, if the part is a token, the value will be a unit string (like "day"), + that indicates how similar a range's start & end must be in order to share the same formatted text. + If not a token, then the value is null. + Always a flat array (not nested liked "chunks"). +*/ +function parseFormatString(formatStr) { + var chunks = chunkFormatString(formatStr); + + return { + fakeFormatString: buildFakeFormatString(chunks), + sameUnits: buildSameUnits(chunks) + }; +} + +/* +Break the formatting string into an array of chunks. +A 'maybe' chunk will have nested chunks. +*/ +function chunkFormatString(formatStr) { + var chunks = []; + var match; + + // TODO: more descrimination + // \4 is a backreference to the first character of a multi-character set. + var chunker = /\[([^\]]*)\]|\(([^\)]*)\)|(LTS|LT|(\w)\4*o?)|([^\w\[\(]+)/g; + + while ((match = chunker.exec(formatStr))) { + if (match[1]) { // a literal string inside [ ... ] + chunks.push.apply(chunks, // append + splitStringLiteral(match[1]) + ); + } + else if (match[2]) { // non-zero formatting inside ( ... ) + chunks.push({ maybe: chunkFormatString(match[2]) }); + } + else if (match[3]) { // a formatting token + chunks.push({ token: match[3] }); + } + else if (match[5]) { // an unenclosed literal string + chunks.push.apply(chunks, // append + splitStringLiteral(match[5]) + ); + } + } + + return chunks; +} + +/* +Potentially splits a literal-text string into multiple parts. For special cases. +*/ +function splitStringLiteral(s) { + if (s === '. ') { + return [ '.', ' ' ]; // for locales with periods bound to the end of each year/month/date + } + else { + return [ s ]; + } +} + +/* +Given chunks parsed from a real format string, generate a fake (aka "intermediate") format string with special control +characters that will eventually be given to moment for formatting, and then post-processed. +*/ +function buildFakeFormatString(chunks) { + var parts = []; + var i, chunk; + + for (i = 0; i < chunks.length; i++) { + chunk = chunks[i]; + + if (typeof chunk === 'string') { + parts.push('[' + chunk + ']'); + } + else if (chunk.token) { + if (chunk.token in specialTokens) { + parts.push( + SPECIAL_TOKEN_MARKER + // useful during post-processing + '[' + chunk.token + ']' // preserve as literal text + ); + } + else { + parts.push(chunk.token); // unprotected text implies a format string + } + } + else if (chunk.maybe) { + parts.push( + MAYBE_MARKER + // useful during post-processing + buildFakeFormatString(chunk.maybe) + + MAYBE_MARKER + ); + } + } + + return parts.join(PART_SEPARATOR); +} + +/* +Given parsed chunks from a real formatting string, generates an array of unit strings (like "day") that indicate +in which regard two dates must be similar in order to share range formatting text. +The `chunks` can be nested (because of "maybe" chunks), however, the returned array will be flat. +*/ +function buildSameUnits(chunks) { + var units = []; + var i, chunk; + var tokenInfo; + + for (i = 0; i < chunks.length; i++) { + chunk = chunks[i]; + + if (chunk.token) { + tokenInfo = largeTokenMap[chunk.token.charAt(0)]; + units.push(tokenInfo ? tokenInfo.unit : 'second'); // default to a very strict same-second + } + else if (chunk.maybe) { + units.push.apply(units, // append + buildSameUnits(chunk.maybe) + ); + } + else { + units.push(null); + } + } + + return units; +} + + +// Rendering to text +// --------------------------------------------------------------------------------------------------------------------- + +/* +Formats a date with a fake format string, post-processes the control characters, then returns. +*/ +function renderFakeFormatString(fakeFormatString, date) { + return processMaybeMarkers( + renderFakeFormatStringParts(fakeFormatString, date).join('') + ); +} + +/* +Formats a date into parts that will have been post-processed, EXCEPT for the "maybe" markers. +*/ +function renderFakeFormatStringParts(fakeFormatString, date) { + var parts = []; + var fakeRender = oldMomentFormat(date, fakeFormatString); + var fakeParts = fakeRender.split(PART_SEPARATOR); + var i, fakePart; + + for (i = 0; i < fakeParts.length; i++) { + fakePart = fakeParts[i]; + + if (fakePart.charAt(0) === SPECIAL_TOKEN_MARKER) { + parts.push( + // the literal string IS the token's name. + // call special token's registered function. + specialTokens[fakePart.substring(1)](date) + ); + } + else { + parts.push(fakePart); + } + } + + return parts; +} + +/* +Accepts an almost-finally-formatted string and processes the "maybe" control characters, returning a new string. +*/ +function processMaybeMarkers(s) { + return s.replace(MAYBE_REGEXP, function(m0, m1) { // regex assumed to have 'g' flag + if (m1.match(/[1-9]/)) { // any non-zero numeric characters? + return m1; + } + else { + return ''; + } + }); +} + + +// Misc Utils +// ------------------------------------------------------------------------------------------------- + +/* +Returns a unit string, either 'year', 'month', 'day', or null for the most granular formatting token in the string. +*/ +function queryMostGranularFormatUnit(formatStr) { + var chunks = chunkFormatString(formatStr); + var i, chunk; + var candidate; + var best; + + for (i = 0; i < chunks.length; i++) { + chunk = chunks[i]; + + if (chunk.token) { + candidate = largeTokenMap[chunk.token.charAt(0)]; + if (candidate) { + if (!best || candidate.value > best.value) { + best = candidate; + } + } + } + } + + if (best) { + return best.unit; + } + + return null; +}; + +})(); + +// quick local references +var formatDate = FC.formatDate; +var formatRange = FC.formatRange; +var oldMomentFormat = FC.oldMomentFormat; + +;; + +FC.Class = Class; // export + +// Class that all other classes will inherit from +function Class() { } + + +// Called on a class to create a subclass. +// Last argument contains instance methods. Any argument before the last are considered mixins. +Class.extend = function() { + var members = {}; + var i; + + for (i = 0; i < arguments.length; i++) { + copyOwnProps(arguments[i], members); + } + + return extendClass(this, members); +}; + + +// Adds new member variables/methods to the class's prototype. +// Can be called with another class, or a plain object hash containing new members. +Class.mixin = function(members) { + copyOwnProps(members, this.prototype); +}; + + +function extendClass(superClass, members) { + var subClass; + + // ensure a constructor for the subclass, forwarding all arguments to the super-constructor if it doesn't exist + if (hasOwnProp(members, 'constructor')) { + subClass = members.constructor; + } + if (typeof subClass !== 'function') { + subClass = members.constructor = function() { + superClass.apply(this, arguments); + }; + } + + // build the base prototype for the subclass, which is an new object chained to the superclass's prototype + subClass.prototype = Object.create(superClass.prototype); + + // copy each member variable/method onto the the subclass's prototype + copyOwnProps(members, subClass.prototype); + + // copy over all class variables/methods to the subclass, such as `extend` and `mixin` + copyOwnProps(superClass, subClass); + + return subClass; +} + +;; + +var EmitterMixin = FC.EmitterMixin = { + + // jQuery-ification via $(this) allows a non-DOM object to have + // the same event handling capabilities (including namespaces). + + + on: function(types, handler) { + $(this).on(types, this._prepareIntercept(handler)); + return this; // for chaining + }, + + + one: function(types, handler) { + $(this).one(types, this._prepareIntercept(handler)); + return this; // for chaining + }, + + + _prepareIntercept: function(handler) { + // handlers are always called with an "event" object as their first param. + // sneak the `this` context and arguments into the extra parameter object + // and forward them on to the original handler. + var intercept = function(ev, extra) { + return handler.apply( + extra.context || this, + extra.args || [] + ); + }; + + // mimick jQuery's internal "proxy" system (risky, I know) + // causing all functions with the same .guid to appear to be the same. + // https://github.com/jquery/jquery/blob/2.2.4/src/core.js#L448 + // this is needed for calling .off with the original non-intercept handler. + if (!handler.guid) { + handler.guid = $.guid++; + } + intercept.guid = handler.guid; + + return intercept; + }, + + + off: function(types, handler) { + $(this).off(types, handler); + + return this; // for chaining + }, + + + trigger: function(types) { + var args = Array.prototype.slice.call(arguments, 1); // arguments after the first + + // pass in "extra" info to the intercept + $(this).triggerHandler(types, { args: args }); + + return this; // for chaining + }, + + + triggerWith: function(types, context, args) { + + // `triggerHandler` is less reliant on the DOM compared to `trigger`. + // pass in "extra" info to the intercept. + $(this).triggerHandler(types, { context: context, args: args }); + + return this; // for chaining + }, + + + hasHandlers: function(type) { + var hash = $._data(this, 'events'); // http://blog.jquery.com/2012/08/09/jquery-1-8-released/ + + return hash && hash[type] && hash[type].length > 0; + } + +}; + +;; + +/* +Utility methods for easily listening to events on another object, +and more importantly, easily unlistening from them. +*/ +var ListenerMixin = FC.ListenerMixin = (function() { + var guid = 0; + var ListenerMixin = { + + listenerId: null, + + /* + Given an `other` object that has on/off methods, bind the given `callback` to an event by the given name. + The `callback` will be called with the `this` context of the object that .listenTo is being called on. + Can be called: + .listenTo(other, eventName, callback) + OR + .listenTo(other, { + eventName1: callback1, + eventName2: callback2 + }) + */ + listenTo: function(other, arg, callback) { + if (typeof arg === 'object') { // given dictionary of callbacks + for (var eventName in arg) { + if (arg.hasOwnProperty(eventName)) { + this.listenTo(other, eventName, arg[eventName]); + } + } + } + else if (typeof arg === 'string') { + other.on( + arg + '.' + this.getListenerNamespace(), // use event namespacing to identify this object + $.proxy(callback, this) // always use `this` context + // the usually-undesired jQuery guid behavior doesn't matter, + // because we always unbind via namespace + ); + } + }, + + /* + Causes the current object to stop listening to events on the `other` object. + `eventName` is optional. If omitted, will stop listening to ALL events on `other`. + */ + stopListeningTo: function(other, eventName) { + other.off((eventName || '') + '.' + this.getListenerNamespace()); + }, + + /* + Returns a string, unique to this object, to be used for event namespacing + */ + getListenerNamespace: function() { + if (this.listenerId == null) { + this.listenerId = guid++; + } + return '_listener' + this.listenerId; + } + + }; + return ListenerMixin; +})(); +;; + +var ParsableModelMixin = { + + standardPropMap: {}, // will be cloned by defineStandardProps + + + /* + Returns true/false for success. + Meant to be only called ONCE, at object creation. + */ + applyProps: function(rawProps) { + var standardPropMap = this.standardPropMap; + var manualProps = {}; + var miscProps = {}; + var propName; + + for (propName in rawProps) { + if (standardPropMap[propName] === true) { // copy verbatim + this[propName] = rawProps[propName]; + } + else if (standardPropMap[propName] === false) { + manualProps[propName] = rawProps[propName]; + } + else { + miscProps[propName] = rawProps[propName]; + } + } + + this.applyMiscProps(miscProps); + + return this.applyManualStandardProps(manualProps); + }, + + + /* + If subclasses override, they must call this supermethod and return the boolean response. + Meant to be only called ONCE, at object creation. + */ + applyManualStandardProps: function(rawProps) { + return true; + }, + + + /* + Can be called even after initial object creation. + */ + applyMiscProps: function(rawProps) { + // subclasses can implement + }, + + + /* + TODO: why is this a method when defineStandardProps is static + */ + isStandardProp: function(propName) { + return propName in this.standardPropMap; + } + +}; + + +/* +TODO: devise a better system +*/ +var ParsableModelMixin_defineStandardProps = function(propDefs) { + var proto = this.prototype; + + if (!proto.hasOwnProperty('standardPropMap')) { + proto.standardPropMap = Object.create(proto.standardPropMap); + } + + copyOwnProps(propDefs, proto.standardPropMap); +}; + + +/* +TODO: devise a better system +*/ +var ParsableModelMixin_copyVerbatimStandardProps = function(src, dest) { + var map = this.prototype.standardPropMap; + var propName; + + for (propName in map) { + if ( + src[propName] != null && // in the src object? + map[propName] === true // false means "copy verbatim" + ) { + dest[propName] = src[propName]; + } + } +}; + +;; + +var Model = Class.extend(EmitterMixin, ListenerMixin, { + + _props: null, + _watchers: null, + _globalWatchArgs: {}, // mutation protection in Model.watch + + constructor: function() { + this._watchers = {}; + this._props = {}; + this.applyGlobalWatchers(); + this.constructed(); + }, + + // useful for monkeypatching. TODO: BaseClass? + constructed: function() { + }, + + applyGlobalWatchers: function() { + var map = this._globalWatchArgs; + var name; + + for (name in map) { + this.watch.apply(this, map[name]); + } + }, + + has: function(name) { + return name in this._props; + }, + + get: function(name) { + if (name === undefined) { + return this._props; + } + + return this._props[name]; + }, + + set: function(name, val) { + var newProps; + + if (typeof name === 'string') { + newProps = {}; + newProps[name] = val === undefined ? null : val; + } + else { + newProps = name; + } + + this.setProps(newProps); + }, + + reset: function(newProps) { + var oldProps = this._props; + var changeset = {}; // will have undefined's to signal unsets + var name; + + for (name in oldProps) { + changeset[name] = undefined; + } + + for (name in newProps) { + changeset[name] = newProps[name]; + } + + this.setProps(changeset); + }, + + unset: function(name) { // accepts a string or array of strings + var newProps = {}; + var names; + var i; + + if (typeof name === 'string') { + names = [ name ]; + } + else { + names = name; + } + + for (i = 0; i < names.length; i++) { + newProps[names[i]] = undefined; + } + + this.setProps(newProps); + }, + + setProps: function(newProps) { + var changedProps = {}; + var changedCnt = 0; + var name, val; + + for (name in newProps) { + val = newProps[name]; + + // a change in value? + // if an object, don't check equality, because might have been mutated internally. + // TODO: eventually enforce immutability. + if ( + typeof val === 'object' || + val !== this._props[name] + ) { + changedProps[name] = val; + changedCnt++; + } + } + + if (changedCnt) { + + this.trigger('before:batchChange', changedProps); + + for (name in changedProps) { + val = changedProps[name]; + + this.trigger('before:change', name, val); + this.trigger('before:change:' + name, val); + } + + for (name in changedProps) { + val = changedProps[name]; + + if (val === undefined) { + delete this._props[name]; + } + else { + this._props[name] = val; + } + + this.trigger('change:' + name, val); + this.trigger('change', name, val); + } + + this.trigger('batchChange', changedProps); + } + }, + + watch: function(name, depList, startFunc, stopFunc) { + var _this = this; + + this.unwatch(name); + + this._watchers[name] = this._watchDeps(depList, function(deps) { + var res = startFunc.call(_this, deps); + + if (res && res.then) { + _this.unset(name); // put in an unset state while resolving + res.then(function(val) { + _this.set(name, val); + }); + } + else { + _this.set(name, res); + } + }, function(deps) { + _this.unset(name); + + if (stopFunc) { + stopFunc.call(_this, deps); + } + }); + }, + + unwatch: function(name) { + var watcher = this._watchers[name]; + + if (watcher) { + delete this._watchers[name]; + watcher.teardown(); + } + }, + + _watchDeps: function(depList, startFunc, stopFunc) { + var _this = this; + var queuedChangeCnt = 0; + var depCnt = depList.length; + var satisfyCnt = 0; + var values = {}; // what's passed as the `deps` arguments + var bindTuples = []; // array of [ eventName, handlerFunc ] arrays + var isCallingStop = false; + + function onBeforeDepChange(depName, val, isOptional) { + queuedChangeCnt++; + if (queuedChangeCnt === 1) { // first change to cause a "stop" ? + if (satisfyCnt === depCnt) { // all deps previously satisfied? + isCallingStop = true; + stopFunc(values); + isCallingStop = false; + } + } + } + + function onDepChange(depName, val, isOptional) { + + if (val === undefined) { // unsetting a value? + + // required dependency that was previously set? + if (!isOptional && values[depName] !== undefined) { + satisfyCnt--; + } + + delete values[depName]; + } + else { // setting a value? + + // required dependency that was previously unset? + if (!isOptional && values[depName] === undefined) { + satisfyCnt++; + } + + values[depName] = val; + } + + queuedChangeCnt--; + if (!queuedChangeCnt) { // last change to cause a "start"? + + // now finally satisfied or satisfied all along? + if (satisfyCnt === depCnt) { + + // if the stopFunc initiated another value change, ignore it. + // it will be processed by another change event anyway. + if (!isCallingStop) { + startFunc(values); + } + } + } + } + + // intercept for .on() that remembers handlers + function bind(eventName, handler) { + _this.on(eventName, handler); + bindTuples.push([ eventName, handler ]); + } + + // listen to dependency changes + depList.forEach(function(depName) { + var isOptional = false; + + if (depName.charAt(0) === '?') { // TODO: more DRY + depName = depName.substring(1); + isOptional = true; + } + + bind('before:change:' + depName, function(val) { + onBeforeDepChange(depName, val, isOptional); + }); + + bind('change:' + depName, function(val) { + onDepChange(depName, val, isOptional); + }); + }); + + // process current dependency values + depList.forEach(function(depName) { + var isOptional = false; + + if (depName.charAt(0) === '?') { // TODO: more DRY + depName = depName.substring(1); + isOptional = true; + } + + if (_this.has(depName)) { + values[depName] = _this.get(depName); + satisfyCnt++; + } + else if (isOptional) { + satisfyCnt++; + } + }); + + // initially satisfied + if (satisfyCnt === depCnt) { + startFunc(values); + } + + return { + teardown: function() { + // remove all handlers + for (var i = 0; i < bindTuples.length; i++) { + _this.off(bindTuples[i][0], bindTuples[i][1]); + } + bindTuples = null; + + // was satisfied, so call stopFunc + if (satisfyCnt === depCnt) { + stopFunc(); + } + }, + flash: function() { + if (satisfyCnt === depCnt) { + stopFunc(); + startFunc(values); + } + } + }; + }, + + flash: function(name) { + var watcher = this._watchers[name]; + + if (watcher) { + watcher.flash(); + } + } + +}); + + +Model.watch = function(name /* , depList, startFunc, stopFunc */) { + + // subclasses should make a masked-copy of the superclass's map + // TODO: write test + if (!this.prototype.hasOwnProperty('_globalWatchArgs')) { + this.prototype._globalWatchArgs = Object.create(this.prototype._globalWatchArgs); + } + + this.prototype._globalWatchArgs[name] = arguments; +}; + + +FC.Model = Model; + + +;; + +var Promise = { + + construct: function(executor) { + var deferred = $.Deferred(); + var promise = deferred.promise(); + + if (typeof executor === 'function') { + executor( + function(val) { // resolve + deferred.resolve(val); + attachImmediatelyResolvingThen(promise, val); + }, + function() { // reject + deferred.reject(); + attachImmediatelyRejectingThen(promise); + } + ); + } + + return promise; + }, + + resolve: function(val) { + var deferred = $.Deferred().resolve(val); + var promise = deferred.promise(); + + attachImmediatelyResolvingThen(promise, val); + + return promise; + }, + + reject: function() { + var deferred = $.Deferred().reject(); + var promise = deferred.promise(); + + attachImmediatelyRejectingThen(promise); + + return promise; + } + +}; + + +function attachImmediatelyResolvingThen(promise, val) { + promise.then = function(onResolve) { + if (typeof onResolve === 'function') { + return Promise.resolve(onResolve(val)); + } + return promise; + }; +} + + +function attachImmediatelyRejectingThen(promise) { + promise.then = function(onResolve, onReject) { + if (typeof onReject === 'function') { + onReject(); + } + return promise; + }; +} + + +FC.Promise = Promise; + +;; + +var TaskQueue = Class.extend(EmitterMixin, { + + q: null, + isPaused: false, + isRunning: false, + + + constructor: function() { + this.q = []; + }, + + + queue: function(/* taskFunc, taskFunc... */) { + this.q.push.apply(this.q, arguments); // append + this.tryStart(); + }, + + + pause: function() { + this.isPaused = true; + }, + + + resume: function() { + this.isPaused = false; + this.tryStart(); + }, + + + getIsIdle: function() { + return !this.isRunning && !this.isPaused; + }, + + + tryStart: function() { + if (!this.isRunning && this.canRunNext()) { + this.isRunning = true; + this.trigger('start'); + this.runRemaining(); + } + }, + + + canRunNext: function() { + return !this.isPaused && this.q.length; + }, + + + runRemaining: function() { // assumes at least one task in queue. does not check canRunNext for first task. + var _this = this; + var task; + var res; + + do { + task = this.q.shift(); // always freshly reference q. might have been reassigned. + res = this.runTask(task); + + if (res && res.then) { + res.then(function() { // jshint ignore:line + if (_this.canRunNext()) { + _this.runRemaining(); + } + }); + return; // prevent marking as stopped + } + } while (this.canRunNext()); + + this.trigger('stop'); // not really a 'stop' ... more of a 'drained' + this.isRunning = false; + + // if 'stop' handler added more tasks.... TODO: write test for this + this.tryStart(); + }, + + + runTask: function(task) { + return task(); // task *is* the function, but subclasses can change the format of a task + } + +}); + +FC.TaskQueue = TaskQueue; + +;; + +var RenderQueue = TaskQueue.extend({ + + waitsByNamespace: null, + waitNamespace: null, + waitId: null, + + + constructor: function(waitsByNamespace) { + TaskQueue.call(this); // super-constructor + + this.waitsByNamespace = waitsByNamespace || {}; + }, + + + queue: function(taskFunc, namespace, type) { + var task = { + func: taskFunc, + namespace: namespace, + type: type + }; + var waitMs; + + if (namespace) { + waitMs = this.waitsByNamespace[namespace]; + } + + if (this.waitNamespace) { + if (namespace === this.waitNamespace && waitMs != null) { + this.delayWait(waitMs); + } + else { + this.clearWait(); + this.tryStart(); + } + } + + if (this.compoundTask(task)) { // appended to queue? + + if (!this.waitNamespace && waitMs != null) { + this.startWait(namespace, waitMs); + } + else { + this.tryStart(); + } + } + }, + + + startWait: function(namespace, waitMs) { + this.waitNamespace = namespace; + this.spawnWait(waitMs); + }, + + + delayWait: function(waitMs) { + clearTimeout(this.waitId); + this.spawnWait(waitMs); + }, + + + spawnWait: function(waitMs) { + var _this = this; + + this.waitId = setTimeout(function() { + _this.waitNamespace = null; + _this.tryStart(); + }, waitMs); + }, + + + clearWait: function() { + if (this.waitNamespace) { + clearTimeout(this.waitId); + this.waitId = null; + this.waitNamespace = null; + } + }, + + + canRunNext: function() { + if (!TaskQueue.prototype.canRunNext.apply(this, arguments)) { + return false; + } + + // waiting for a certain namespace to stop receiving tasks? + if (this.waitNamespace) { + + // if there was a different namespace task in the meantime, + // that forces all previously-waiting tasks to suddenly execute. + // TODO: find a way to do this in constant time. + for (var q = this.q, i = 0; i < q.length; i++) { + if (q[i].namespace !== this.waitNamespace) { + return true; // allow execution + } + } + + return false; + } + + return true; + }, + + + runTask: function(task) { + task.func(); + }, + + + compoundTask: function(newTask) { + var q = this.q; + var shouldAppend = true; + var i, task; + + if (newTask.namespace && newTask.type === 'destroy') { + + // remove all init/add/remove ops with same namespace, regardless of order + for (i = q.length - 1; i >= 0; i--) { + task = q[i]; + + switch (task.type) { + case 'init': + shouldAppend = false; // jshint ignore:line + // the latest destroy is cancelled out by not doing the init + // and fallthrough.... + case 'add': + case 'remove': + q.splice(i, 1); // remove task + } + } + } + + if (shouldAppend) { + q.push(newTask); + } + + return shouldAppend; + } + +}); + +FC.RenderQueue = RenderQueue; + +;; + +/* A rectangular panel that is absolutely positioned over other content +------------------------------------------------------------------------------------------------------------------------ +Options: + - className (string) + - content (HTML string or jQuery element set) + - parentEl + - top + - left + - right (the x coord of where the right edge should be. not a "CSS" right) + - autoHide (boolean) + - show (callback) + - hide (callback) +*/ + +var Popover = Class.extend(ListenerMixin, { + + isHidden: true, + options: null, + el: null, // the container element for the popover. generated by this object + margin: 10, // the space required between the popover and the edges of the scroll container + + + constructor: function(options) { + this.options = options || {}; + }, + + + // Shows the popover on the specified position. Renders it if not already + show: function() { + if (this.isHidden) { + if (!this.el) { + this.render(); + } + this.el.show(); + this.position(); + this.isHidden = false; + this.trigger('show'); + } + }, + + + // Hides the popover, through CSS, but does not remove it from the DOM + hide: function() { + if (!this.isHidden) { + this.el.hide(); + this.isHidden = true; + this.trigger('hide'); + } + }, + + + // Creates `this.el` and renders content inside of it + render: function() { + var _this = this; + var options = this.options; + + this.el = $('
') + .addClass(options.className || '') + .css({ + // position initially to the top left to avoid creating scrollbars + top: 0, + left: 0 + }) + .append(options.content) + .appendTo(options.parentEl); + + // when a click happens on anything inside with a 'fc-close' className, hide the popover + this.el.on('click', '.fc-close', function() { + _this.hide(); + }); + + if (options.autoHide) { + this.listenTo($(document), 'mousedown', this.documentMousedown); + } + }, + + + // Triggered when the user clicks *anywhere* in the document, for the autoHide feature + documentMousedown: function(ev) { + // only hide the popover if the click happened outside the popover + if (this.el && !$(ev.target).closest(this.el).length) { + this.hide(); + } + }, + + + // Hides and unregisters any handlers + removeElement: function() { + this.hide(); + + if (this.el) { + this.el.remove(); + this.el = null; + } + + this.stopListeningTo($(document), 'mousedown'); + }, + + + // Positions the popover optimally, using the top/left/right options + position: function() { + var options = this.options; + var origin = this.el.offsetParent().offset(); + var width = this.el.outerWidth(); + var height = this.el.outerHeight(); + var windowEl = $(window); + var viewportEl = getScrollParent(this.el); + var viewportTop; + var viewportLeft; + var viewportOffset; + var top; // the "position" (not "offset") values for the popover + var left; // + + // compute top and left + top = options.top || 0; + if (options.left !== undefined) { + left = options.left; + } + else if (options.right !== undefined) { + left = options.right - width; // derive the left value from the right value + } + else { + left = 0; + } + + if (viewportEl.is(window) || viewportEl.is(document)) { // normalize getScrollParent's result + viewportEl = windowEl; + viewportTop = 0; // the window is always at the top left + viewportLeft = 0; // (and .offset() won't work if called here) + } + else { + viewportOffset = viewportEl.offset(); + viewportTop = viewportOffset.top; + viewportLeft = viewportOffset.left; + } + + // if the window is scrolled, it causes the visible area to be further down + viewportTop += windowEl.scrollTop(); + viewportLeft += windowEl.scrollLeft(); + + // constrain to the view port. if constrained by two edges, give precedence to top/left + if (options.viewportConstrain !== false) { + top = Math.min(top, viewportTop + viewportEl.outerHeight() - height - this.margin); + top = Math.max(top, viewportTop + this.margin); + left = Math.min(left, viewportLeft + viewportEl.outerWidth() - width - this.margin); + left = Math.max(left, viewportLeft + this.margin); + } + + this.el.css({ + top: top - origin.top, + left: left - origin.left + }); + }, + + + // Triggers a callback. Calls a function in the option hash of the same name. + // Arguments beyond the first `name` are forwarded on. + // TODO: better code reuse for this. Repeat code + trigger: function(name) { + if (this.options[name]) { + this.options[name].apply(this, Array.prototype.slice.call(arguments, 1)); + } + } + +}); + +;; + +/* +A cache for the left/right/top/bottom/width/height values for one or more elements. +Works with both offset (from topleft document) and position (from offsetParent). + +options: +- els +- isHorizontal +- isVertical +*/ +var CoordCache = FC.CoordCache = Class.extend({ + + els: null, // jQuery set (assumed to be siblings) + forcedOffsetParentEl: null, // options can override the natural offsetParent + origin: null, // {left,top} position of offsetParent of els + boundingRect: null, // constrain cordinates to this rectangle. {left,right,top,bottom} or null + isHorizontal: false, // whether to query for left/right/width + isVertical: false, // whether to query for top/bottom/height + + // arrays of coordinates (offsets from topleft of document) + lefts: null, + rights: null, + tops: null, + bottoms: null, + + + constructor: function(options) { + this.els = $(options.els); + this.isHorizontal = options.isHorizontal; + this.isVertical = options.isVertical; + this.forcedOffsetParentEl = options.offsetParent ? $(options.offsetParent) : null; + }, + + + // Queries the els for coordinates and stores them. + // Call this method before using and of the get* methods below. + build: function() { + var offsetParentEl = this.forcedOffsetParentEl; + if (!offsetParentEl && this.els.length > 0) { + offsetParentEl = this.els.eq(0).offsetParent(); + } + + this.origin = offsetParentEl ? + offsetParentEl.offset() : + null; + + this.boundingRect = this.queryBoundingRect(); + + if (this.isHorizontal) { + this.buildElHorizontals(); + } + if (this.isVertical) { + this.buildElVerticals(); + } + }, + + + // Destroys all internal data about coordinates, freeing memory + clear: function() { + this.origin = null; + this.boundingRect = null; + this.lefts = null; + this.rights = null; + this.tops = null; + this.bottoms = null; + }, + + + // When called, if coord caches aren't built, builds them + ensureBuilt: function() { + if (!this.origin) { + this.build(); + } + }, + + + // Populates the left/right internal coordinate arrays + buildElHorizontals: function() { + var lefts = []; + var rights = []; + + this.els.each(function(i, node) { + var el = $(node); + var left = el.offset().left; + var width = el.outerWidth(); + + lefts.push(left); + rights.push(left + width); + }); + + this.lefts = lefts; + this.rights = rights; + }, + + + // Populates the top/bottom internal coordinate arrays + buildElVerticals: function() { + var tops = []; + var bottoms = []; + + this.els.each(function(i, node) { + var el = $(node); + var top = el.offset().top; + var height = el.outerHeight(); + + tops.push(top); + bottoms.push(top + height); + }); + + this.tops = tops; + this.bottoms = bottoms; + }, + + + // Given a left offset (from document left), returns the index of the el that it horizontally intersects. + // If no intersection is made, returns undefined. + getHorizontalIndex: function(leftOffset) { + this.ensureBuilt(); + + var lefts = this.lefts; + var rights = this.rights; + var len = lefts.length; + var i; + + for (i = 0; i < len; i++) { + if (leftOffset >= lefts[i] && leftOffset < rights[i]) { + return i; + } + } + }, + + + // Given a top offset (from document top), returns the index of the el that it vertically intersects. + // If no intersection is made, returns undefined. + getVerticalIndex: function(topOffset) { + this.ensureBuilt(); + + var tops = this.tops; + var bottoms = this.bottoms; + var len = tops.length; + var i; + + for (i = 0; i < len; i++) { + if (topOffset >= tops[i] && topOffset < bottoms[i]) { + return i; + } + } + }, + + + // Gets the left offset (from document left) of the element at the given index + getLeftOffset: function(leftIndex) { + this.ensureBuilt(); + return this.lefts[leftIndex]; + }, + + + // Gets the left position (from offsetParent left) of the element at the given index + getLeftPosition: function(leftIndex) { + this.ensureBuilt(); + return this.lefts[leftIndex] - this.origin.left; + }, + + + // Gets the right offset (from document left) of the element at the given index. + // This value is NOT relative to the document's right edge, like the CSS concept of "right" would be. + getRightOffset: function(leftIndex) { + this.ensureBuilt(); + return this.rights[leftIndex]; + }, + + + // Gets the right position (from offsetParent left) of the element at the given index. + // This value is NOT relative to the offsetParent's right edge, like the CSS concept of "right" would be. + getRightPosition: function(leftIndex) { + this.ensureBuilt(); + return this.rights[leftIndex] - this.origin.left; + }, + + + // Gets the width of the element at the given index + getWidth: function(leftIndex) { + this.ensureBuilt(); + return this.rights[leftIndex] - this.lefts[leftIndex]; + }, + + + // Gets the top offset (from document top) of the element at the given index + getTopOffset: function(topIndex) { + this.ensureBuilt(); + return this.tops[topIndex]; + }, + + + // Gets the top position (from offsetParent top) of the element at the given position + getTopPosition: function(topIndex) { + this.ensureBuilt(); + return this.tops[topIndex] - this.origin.top; + }, + + // Gets the bottom offset (from the document top) of the element at the given index. + // This value is NOT relative to the offsetParent's bottom edge, like the CSS concept of "bottom" would be. + getBottomOffset: function(topIndex) { + this.ensureBuilt(); + return this.bottoms[topIndex]; + }, + + + // Gets the bottom position (from the offsetParent top) of the element at the given index. + // This value is NOT relative to the offsetParent's bottom edge, like the CSS concept of "bottom" would be. + getBottomPosition: function(topIndex) { + this.ensureBuilt(); + return this.bottoms[topIndex] - this.origin.top; + }, + + + // Gets the height of the element at the given index + getHeight: function(topIndex) { + this.ensureBuilt(); + return this.bottoms[topIndex] - this.tops[topIndex]; + }, + + + // Bounding Rect + // TODO: decouple this from CoordCache + + // Compute and return what the elements' bounding rectangle is, from the user's perspective. + // Right now, only returns a rectangle if constrained by an overflow:scroll element. + // Returns null if there are no elements + queryBoundingRect: function() { + var scrollParentEl; + + if (this.els.length > 0) { + scrollParentEl = getScrollParent(this.els.eq(0)); + + if (!scrollParentEl.is(document)) { + return getClientRect(scrollParentEl); + } + } + + return null; + }, + + isPointInBounds: function(leftOffset, topOffset) { + return this.isLeftInBounds(leftOffset) && this.isTopInBounds(topOffset); + }, + + isLeftInBounds: function(leftOffset) { + return !this.boundingRect || (leftOffset >= this.boundingRect.left && leftOffset < this.boundingRect.right); + }, + + isTopInBounds: function(topOffset) { + return !this.boundingRect || (topOffset >= this.boundingRect.top && topOffset < this.boundingRect.bottom); + } + +}); + +;; + +/* Tracks a drag's mouse movement, firing various handlers +----------------------------------------------------------------------------------------------------------------------*/ +// TODO: use Emitter + +var DragListener = FC.DragListener = Class.extend(ListenerMixin, { + + options: null, + subjectEl: null, + + // coordinates of the initial mousedown + originX: null, + originY: null, + + // the wrapping element that scrolls, or MIGHT scroll if there's overflow. + // TODO: do this for wrappers that have overflow:hidden as well. + scrollEl: null, + + isInteracting: false, + isDistanceSurpassed: false, + isDelayEnded: false, + isDragging: false, + isTouch: false, + isGeneric: false, // initiated by 'dragstart' (jqui) + + delay: null, + delayTimeoutId: null, + minDistance: null, + + shouldCancelTouchScroll: true, + scrollAlwaysKills: false, + + + constructor: function(options) { + this.options = options || {}; + }, + + + // Interaction (high-level) + // ----------------------------------------------------------------------------------------------------------------- + + + startInteraction: function(ev, extraOptions) { + + if (ev.type === 'mousedown') { + if (GlobalEmitter.get().shouldIgnoreMouse()) { + return; + } + else if (!isPrimaryMouseButton(ev)) { + return; + } + else { + ev.preventDefault(); // prevents native selection in most browsers + } + } + + if (!this.isInteracting) { + + // process options + extraOptions = extraOptions || {}; + this.delay = firstDefined(extraOptions.delay, this.options.delay, 0); + this.minDistance = firstDefined(extraOptions.distance, this.options.distance, 0); + this.subjectEl = this.options.subjectEl; + + preventSelection($('body')); + + this.isInteracting = true; + this.isTouch = getEvIsTouch(ev); + this.isGeneric = ev.type === 'dragstart'; + this.isDelayEnded = false; + this.isDistanceSurpassed = false; + + this.originX = getEvX(ev); + this.originY = getEvY(ev); + this.scrollEl = getScrollParent($(ev.target)); + + this.bindHandlers(); + this.initAutoScroll(); + this.handleInteractionStart(ev); + this.startDelay(ev); + + if (!this.minDistance) { + this.handleDistanceSurpassed(ev); + } + } + }, + + + handleInteractionStart: function(ev) { + this.trigger('interactionStart', ev); + }, + + + endInteraction: function(ev, isCancelled) { + if (this.isInteracting) { + this.endDrag(ev); + + if (this.delayTimeoutId) { + clearTimeout(this.delayTimeoutId); + this.delayTimeoutId = null; + } + + this.destroyAutoScroll(); + this.unbindHandlers(); + + this.isInteracting = false; + this.handleInteractionEnd(ev, isCancelled); + + allowSelection($('body')); + } + }, + + + handleInteractionEnd: function(ev, isCancelled) { + this.trigger('interactionEnd', ev, isCancelled || false); + }, + + + // Binding To DOM + // ----------------------------------------------------------------------------------------------------------------- + + + bindHandlers: function() { + // some browsers (Safari in iOS 10) don't allow preventDefault on touch events that are bound after touchstart, + // so listen to the GlobalEmitter singleton, which is always bound, instead of the document directly. + var globalEmitter = GlobalEmitter.get(); + + if (this.isGeneric) { + this.listenTo($(document), { // might only work on iOS because of GlobalEmitter's bind :( + drag: this.handleMove, + dragstop: this.endInteraction + }); + } + else if (this.isTouch) { + this.listenTo(globalEmitter, { + touchmove: this.handleTouchMove, + touchend: this.endInteraction, + scroll: this.handleTouchScroll + }); + } + else { + this.listenTo(globalEmitter, { + mousemove: this.handleMouseMove, + mouseup: this.endInteraction + }); + } + + this.listenTo(globalEmitter, { + selectstart: preventDefault, // don't allow selection while dragging + contextmenu: preventDefault // long taps would open menu on Chrome dev tools + }); + }, + + + unbindHandlers: function() { + this.stopListeningTo(GlobalEmitter.get()); + this.stopListeningTo($(document)); // for isGeneric + }, + + + // Drag (high-level) + // ----------------------------------------------------------------------------------------------------------------- + + + // extraOptions ignored if drag already started + startDrag: function(ev, extraOptions) { + this.startInteraction(ev, extraOptions); // ensure interaction began + + if (!this.isDragging) { + this.isDragging = true; + this.handleDragStart(ev); + } + }, + + + handleDragStart: function(ev) { + this.trigger('dragStart', ev); + }, + + + handleMove: function(ev) { + var dx = getEvX(ev) - this.originX; + var dy = getEvY(ev) - this.originY; + var minDistance = this.minDistance; + var distanceSq; // current distance from the origin, squared + + if (!this.isDistanceSurpassed) { + distanceSq = dx * dx + dy * dy; + if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem + this.handleDistanceSurpassed(ev); + } + } + + if (this.isDragging) { + this.handleDrag(dx, dy, ev); + } + }, + + + // Called while the mouse is being moved and when we know a legitimate drag is taking place + handleDrag: function(dx, dy, ev) { + this.trigger('drag', dx, dy, ev); + this.updateAutoScroll(ev); // will possibly cause scrolling + }, + + + endDrag: function(ev) { + if (this.isDragging) { + this.isDragging = false; + this.handleDragEnd(ev); + } + }, + + + handleDragEnd: function(ev) { + this.trigger('dragEnd', ev); + }, + + + // Delay + // ----------------------------------------------------------------------------------------------------------------- + + + startDelay: function(initialEv) { + var _this = this; + + if (this.delay) { + this.delayTimeoutId = setTimeout(function() { + _this.handleDelayEnd(initialEv); + }, this.delay); + } + else { + this.handleDelayEnd(initialEv); + } + }, + + + handleDelayEnd: function(initialEv) { + this.isDelayEnded = true; + + if (this.isDistanceSurpassed) { + this.startDrag(initialEv); + } + }, + + + // Distance + // ----------------------------------------------------------------------------------------------------------------- + + + handleDistanceSurpassed: function(ev) { + this.isDistanceSurpassed = true; + + if (this.isDelayEnded) { + this.startDrag(ev); + } + }, + + + // Mouse / Touch + // ----------------------------------------------------------------------------------------------------------------- + + + handleTouchMove: function(ev) { + + // prevent inertia and touchmove-scrolling while dragging + if (this.isDragging && this.shouldCancelTouchScroll) { + ev.preventDefault(); + } + + this.handleMove(ev); + }, + + + handleMouseMove: function(ev) { + this.handleMove(ev); + }, + + + // Scrolling (unrelated to auto-scroll) + // ----------------------------------------------------------------------------------------------------------------- + + + handleTouchScroll: function(ev) { + // if the drag is being initiated by touch, but a scroll happens before + // the drag-initiating delay is over, cancel the drag + if (!this.isDragging || this.scrollAlwaysKills) { + this.endInteraction(ev, true); // isCancelled=true + } + }, + + + // Utils + // ----------------------------------------------------------------------------------------------------------------- + + + // Triggers a callback. Calls a function in the option hash of the same name. + // Arguments beyond the first `name` are forwarded on. + trigger: function(name) { + if (this.options[name]) { + this.options[name].apply(this, Array.prototype.slice.call(arguments, 1)); + } + // makes _methods callable by event name. TODO: kill this + if (this['_' + name]) { + this['_' + name].apply(this, Array.prototype.slice.call(arguments, 1)); + } + } + + +}); + +;; +/* +this.scrollEl is set in DragListener +*/ +DragListener.mixin({ + + isAutoScroll: false, + + scrollBounds: null, // { top, bottom, left, right } + scrollTopVel: null, // pixels per second + scrollLeftVel: null, // pixels per second + scrollIntervalId: null, // ID of setTimeout for scrolling animation loop + + // defaults + scrollSensitivity: 30, // pixels from edge for scrolling to start + scrollSpeed: 200, // pixels per second, at maximum speed + scrollIntervalMs: 50, // millisecond wait between scroll increment + + + initAutoScroll: function() { + var scrollEl = this.scrollEl; + + this.isAutoScroll = + this.options.scroll && + scrollEl && + !scrollEl.is(window) && + !scrollEl.is(document); + + if (this.isAutoScroll) { + // debounce makes sure rapid calls don't happen + this.listenTo(scrollEl, 'scroll', debounce(this.handleDebouncedScroll, 100)); + } + }, + + + destroyAutoScroll: function() { + this.endAutoScroll(); // kill any animation loop + + // remove the scroll handler if there is a scrollEl + if (this.isAutoScroll) { + this.stopListeningTo(this.scrollEl, 'scroll'); // will probably get removed by unbindHandlers too :( + } + }, + + + // Computes and stores the bounding rectangle of scrollEl + computeScrollBounds: function() { + if (this.isAutoScroll) { + this.scrollBounds = getOuterRect(this.scrollEl); + // TODO: use getClientRect in future. but prevents auto scrolling when on top of scrollbars + } + }, + + + // Called when the dragging is in progress and scrolling should be updated + updateAutoScroll: function(ev) { + var sensitivity = this.scrollSensitivity; + var bounds = this.scrollBounds; + var topCloseness, bottomCloseness; + var leftCloseness, rightCloseness; + var topVel = 0; + var leftVel = 0; + + if (bounds) { // only scroll if scrollEl exists + + // compute closeness to edges. valid range is from 0.0 - 1.0 + topCloseness = (sensitivity - (getEvY(ev) - bounds.top)) / sensitivity; + bottomCloseness = (sensitivity - (bounds.bottom - getEvY(ev))) / sensitivity; + leftCloseness = (sensitivity - (getEvX(ev) - bounds.left)) / sensitivity; + rightCloseness = (sensitivity - (bounds.right - getEvX(ev))) / sensitivity; + + // translate vertical closeness into velocity. + // mouse must be completely in bounds for velocity to happen. + if (topCloseness >= 0 && topCloseness <= 1) { + topVel = topCloseness * this.scrollSpeed * -1; // negative. for scrolling up + } + else if (bottomCloseness >= 0 && bottomCloseness <= 1) { + topVel = bottomCloseness * this.scrollSpeed; + } + + // translate horizontal closeness into velocity + if (leftCloseness >= 0 && leftCloseness <= 1) { + leftVel = leftCloseness * this.scrollSpeed * -1; // negative. for scrolling left + } + else if (rightCloseness >= 0 && rightCloseness <= 1) { + leftVel = rightCloseness * this.scrollSpeed; + } + } + + this.setScrollVel(topVel, leftVel); + }, + + + // Sets the speed-of-scrolling for the scrollEl + setScrollVel: function(topVel, leftVel) { + + this.scrollTopVel = topVel; + this.scrollLeftVel = leftVel; + + this.constrainScrollVel(); // massages into realistic values + + // if there is non-zero velocity, and an animation loop hasn't already started, then START + if ((this.scrollTopVel || this.scrollLeftVel) && !this.scrollIntervalId) { + this.scrollIntervalId = setInterval( + proxy(this, 'scrollIntervalFunc'), // scope to `this` + this.scrollIntervalMs + ); + } + }, + + + // Forces scrollTopVel and scrollLeftVel to be zero if scrolling has already gone all the way + constrainScrollVel: function() { + var el = this.scrollEl; + + if (this.scrollTopVel < 0) { // scrolling up? + if (el.scrollTop() <= 0) { // already scrolled all the way up? + this.scrollTopVel = 0; + } + } + else if (this.scrollTopVel > 0) { // scrolling down? + if (el.scrollTop() + el[0].clientHeight >= el[0].scrollHeight) { // already scrolled all the way down? + this.scrollTopVel = 0; + } + } + + if (this.scrollLeftVel < 0) { // scrolling left? + if (el.scrollLeft() <= 0) { // already scrolled all the left? + this.scrollLeftVel = 0; + } + } + else if (this.scrollLeftVel > 0) { // scrolling right? + if (el.scrollLeft() + el[0].clientWidth >= el[0].scrollWidth) { // already scrolled all the way right? + this.scrollLeftVel = 0; + } + } + }, + + + // This function gets called during every iteration of the scrolling animation loop + scrollIntervalFunc: function() { + var el = this.scrollEl; + var frac = this.scrollIntervalMs / 1000; // considering animation frequency, what the vel should be mult'd by + + // change the value of scrollEl's scroll + if (this.scrollTopVel) { + el.scrollTop(el.scrollTop() + this.scrollTopVel * frac); + } + if (this.scrollLeftVel) { + el.scrollLeft(el.scrollLeft() + this.scrollLeftVel * frac); + } + + this.constrainScrollVel(); // since the scroll values changed, recompute the velocities + + // if scrolled all the way, which causes the vels to be zero, stop the animation loop + if (!this.scrollTopVel && !this.scrollLeftVel) { + this.endAutoScroll(); + } + }, + + + // Kills any existing scrolling animation loop + endAutoScroll: function() { + if (this.scrollIntervalId) { + clearInterval(this.scrollIntervalId); + this.scrollIntervalId = null; + + this.handleScrollEnd(); + } + }, + + + // Get called when the scrollEl is scrolled (NOTE: this is delayed via debounce) + handleDebouncedScroll: function() { + // recompute all coordinates, but *only* if this is *not* part of our scrolling animation + if (!this.scrollIntervalId) { + this.handleScrollEnd(); + } + }, + + + // Called when scrolling has stopped, whether through auto scroll, or the user scrolling + handleScrollEnd: function() { + } + +}); +;; + +/* Tracks mouse movements over a component and raises events about which hit the mouse is over. +------------------------------------------------------------------------------------------------------------------------ +options: +- subjectEl +- subjectCenter +*/ + +var HitDragListener = DragListener.extend({ + + component: null, // converts coordinates to hits + // methods: hitsNeeded, hitsNotNeeded, queryHit + + origHit: null, // the hit the mouse was over when listening started + hit: null, // the hit the mouse is over + coordAdjust: null, // delta that will be added to the mouse coordinates when computing collisions + + + constructor: function(component, options) { + DragListener.call(this, options); // call the super-constructor + + this.component = component; + }, + + + // Called when drag listening starts (but a real drag has not necessarily began). + // ev might be undefined if dragging was started manually. + handleInteractionStart: function(ev) { + var subjectEl = this.subjectEl; + var subjectRect; + var origPoint; + var point; + + this.component.hitsNeeded(); + this.computeScrollBounds(); // for autoscroll + + if (ev) { + origPoint = { left: getEvX(ev), top: getEvY(ev) }; + point = origPoint; + + // constrain the point to bounds of the element being dragged + if (subjectEl) { + subjectRect = getOuterRect(subjectEl); // used for centering as well + point = constrainPoint(point, subjectRect); + } + + this.origHit = this.queryHit(point.left, point.top); + + // treat the center of the subject as the collision point? + if (subjectEl && this.options.subjectCenter) { + + // only consider the area the subject overlaps the hit. best for large subjects. + // TODO: skip this if hit didn't supply left/right/top/bottom + if (this.origHit) { + subjectRect = intersectRects(this.origHit, subjectRect) || + subjectRect; // in case there is no intersection + } + + point = getRectCenter(subjectRect); + } + + this.coordAdjust = diffPoints(point, origPoint); // point - origPoint + } + else { + this.origHit = null; + this.coordAdjust = null; + } + + // call the super-method. do it after origHit has been computed + DragListener.prototype.handleInteractionStart.apply(this, arguments); + }, + + + // Called when the actual drag has started + handleDragStart: function(ev) { + var hit; + + DragListener.prototype.handleDragStart.apply(this, arguments); // call the super-method + + // might be different from this.origHit if the min-distance is large + hit = this.queryHit(getEvX(ev), getEvY(ev)); + + // report the initial hit the mouse is over + // especially important if no min-distance and drag starts immediately + if (hit) { + this.handleHitOver(hit); + } + }, + + + // Called when the drag moves + handleDrag: function(dx, dy, ev) { + var hit; + + DragListener.prototype.handleDrag.apply(this, arguments); // call the super-method + + hit = this.queryHit(getEvX(ev), getEvY(ev)); + + if (!isHitsEqual(hit, this.hit)) { // a different hit than before? + if (this.hit) { + this.handleHitOut(); + } + if (hit) { + this.handleHitOver(hit); + } + } + }, + + + // Called when dragging has been stopped + handleDragEnd: function() { + this.handleHitDone(); + DragListener.prototype.handleDragEnd.apply(this, arguments); // call the super-method + }, + + + // Called when a the mouse has just moved over a new hit + handleHitOver: function(hit) { + var isOrig = isHitsEqual(hit, this.origHit); + + this.hit = hit; + + this.trigger('hitOver', this.hit, isOrig, this.origHit); + }, + + + // Called when the mouse has just moved out of a hit + handleHitOut: function() { + if (this.hit) { + this.trigger('hitOut', this.hit); + this.handleHitDone(); + this.hit = null; + } + }, + + + // Called after a hitOut. Also called before a dragStop + handleHitDone: function() { + if (this.hit) { + this.trigger('hitDone', this.hit); + } + }, + + + // Called when the interaction ends, whether there was a real drag or not + handleInteractionEnd: function() { + DragListener.prototype.handleInteractionEnd.apply(this, arguments); // call the super-method + + this.origHit = null; + this.hit = null; + + this.component.hitsNotNeeded(); + }, + + + // Called when scrolling has stopped, whether through auto scroll, or the user scrolling + handleScrollEnd: function() { + DragListener.prototype.handleScrollEnd.apply(this, arguments); // call the super-method + + // hits' absolute positions will be in new places after a user's scroll. + // HACK for recomputing. + if (this.isDragging) { + this.component.releaseHits(); + this.component.prepareHits(); + } + }, + + + // Gets the hit underneath the coordinates for the given mouse event + queryHit: function(left, top) { + + if (this.coordAdjust) { + left += this.coordAdjust.left; + top += this.coordAdjust.top; + } + + return this.component.queryHit(left, top); + } + +}); + + +// Returns `true` if the hits are identically equal. `false` otherwise. Must be from the same component. +// Two null values will be considered equal, as two "out of the component" states are the same. +function isHitsEqual(hit0, hit1) { + + if (!hit0 && !hit1) { + return true; + } + + if (hit0 && hit1) { + return hit0.component === hit1.component && + isHitPropsWithin(hit0, hit1) && + isHitPropsWithin(hit1, hit0); // ensures all props are identical + } + + return false; +} + + +// Returns true if all of subHit's non-standard properties are within superHit +function isHitPropsWithin(subHit, superHit) { + for (var propName in subHit) { + if (!/^(component|left|right|top|bottom)$/.test(propName)) { + if (subHit[propName] !== superHit[propName]) { + return false; + } + } + } + return true; +} + +;; + +/* +Listens to document and window-level user-interaction events, like touch events and mouse events, +and fires these events as-is to whoever is observing a GlobalEmitter. +Best when used as a singleton via GlobalEmitter.get() + +Normalizes mouse/touch events. For examples: +- ignores the the simulated mouse events that happen after a quick tap: mousemove+mousedown+mouseup+click +- compensates for various buggy scenarios where a touchend does not fire +*/ + +FC.touchMouseIgnoreWait = 500; + +var GlobalEmitter = Class.extend(ListenerMixin, EmitterMixin, { + + isTouching: false, + mouseIgnoreDepth: 0, + handleScrollProxy: null, + + + bind: function() { + var _this = this; + + this.listenTo($(document), { + touchstart: this.handleTouchStart, + touchcancel: this.handleTouchCancel, + touchend: this.handleTouchEnd, + mousedown: this.handleMouseDown, + mousemove: this.handleMouseMove, + mouseup: this.handleMouseUp, + click: this.handleClick, + selectstart: this.handleSelectStart, + contextmenu: this.handleContextMenu + }); + + // because we need to call preventDefault + // because https://www.chromestatus.com/features/5093566007214080 + // TODO: investigate performance because this is a global handler + window.addEventListener( + 'touchmove', + this.handleTouchMoveProxy = function(ev) { + _this.handleTouchMove($.Event(ev)); + }, + { passive: false } // allows preventDefault() + ); + + // attach a handler to get called when ANY scroll action happens on the page. + // this was impossible to do with normal on/off because 'scroll' doesn't bubble. + // http://stackoverflow.com/a/32954565/96342 + window.addEventListener( + 'scroll', + this.handleScrollProxy = function(ev) { + _this.handleScroll($.Event(ev)); + }, + true // useCapture + ); + }, + + unbind: function() { + this.stopListeningTo($(document)); + + window.removeEventListener( + 'touchmove', + this.handleTouchMoveProxy + ); + + window.removeEventListener( + 'scroll', + this.handleScrollProxy, + true // useCapture + ); + }, + + + // Touch Handlers + // ----------------------------------------------------------------------------------------------------------------- + + handleTouchStart: function(ev) { + + // if a previous touch interaction never ended with a touchend, then implicitly end it, + // but since a new touch interaction is about to begin, don't start the mouse ignore period. + this.stopTouch(ev, true); // skipMouseIgnore=true + + this.isTouching = true; + this.trigger('touchstart', ev); + }, + + handleTouchMove: function(ev) { + if (this.isTouching) { + this.trigger('touchmove', ev); + } + }, + + handleTouchCancel: function(ev) { + if (this.isTouching) { + this.trigger('touchcancel', ev); + + // Have touchcancel fire an artificial touchend. That way, handlers won't need to listen to both. + // If touchend fires later, it won't have any effect b/c isTouching will be false. + this.stopTouch(ev); + } + }, + + handleTouchEnd: function(ev) { + this.stopTouch(ev); + }, + + + // Mouse Handlers + // ----------------------------------------------------------------------------------------------------------------- + + handleMouseDown: function(ev) { + if (!this.shouldIgnoreMouse()) { + this.trigger('mousedown', ev); + } + }, + + handleMouseMove: function(ev) { + if (!this.shouldIgnoreMouse()) { + this.trigger('mousemove', ev); + } + }, + + handleMouseUp: function(ev) { + if (!this.shouldIgnoreMouse()) { + this.trigger('mouseup', ev); + } + }, + + handleClick: function(ev) { + if (!this.shouldIgnoreMouse()) { + this.trigger('click', ev); + } + }, + + + // Misc Handlers + // ----------------------------------------------------------------------------------------------------------------- + + handleSelectStart: function(ev) { + this.trigger('selectstart', ev); + }, + + handleContextMenu: function(ev) { + this.trigger('contextmenu', ev); + }, + + handleScroll: function(ev) { + this.trigger('scroll', ev); + }, + + + // Utils + // ----------------------------------------------------------------------------------------------------------------- + + stopTouch: function(ev, skipMouseIgnore) { + if (this.isTouching) { + this.isTouching = false; + this.trigger('touchend', ev); + + if (!skipMouseIgnore) { + this.startTouchMouseIgnore(); + } + } + }, + + startTouchMouseIgnore: function() { + var _this = this; + var wait = FC.touchMouseIgnoreWait; + + if (wait) { + this.mouseIgnoreDepth++; + setTimeout(function() { + _this.mouseIgnoreDepth--; + }, wait); + } + }, + + shouldIgnoreMouse: function() { + return this.isTouching || Boolean(this.mouseIgnoreDepth); + } + +}); + + +// Singleton +// --------------------------------------------------------------------------------------------------------------------- + +(function() { + var globalEmitter = null; + var neededCount = 0; + + + // gets the singleton + GlobalEmitter.get = function() { + + if (!globalEmitter) { + globalEmitter = new GlobalEmitter(); + globalEmitter.bind(); + } + + return globalEmitter; + }; + + + // called when an object knows it will need a GlobalEmitter in the near future. + GlobalEmitter.needed = function() { + GlobalEmitter.get(); // ensures globalEmitter + neededCount++; + }; + + + // called when the object that originally called needed() doesn't need a GlobalEmitter anymore. + GlobalEmitter.unneeded = function() { + neededCount--; + + if (!neededCount) { // nobody else needs it + globalEmitter.unbind(); + globalEmitter = null; + } + }; + +})(); + +;; + +/* Creates a clone of an element and lets it track the mouse as it moves +----------------------------------------------------------------------------------------------------------------------*/ + +var MouseFollower = Class.extend(ListenerMixin, { + + options: null, + + sourceEl: null, // the element that will be cloned and made to look like it is dragging + el: null, // the clone of `sourceEl` that will track the mouse + parentEl: null, // the element that `el` (the clone) will be attached to + + // the initial position of el, relative to the offset parent. made to match the initial offset of sourceEl + top0: null, + left0: null, + + // the absolute coordinates of the initiating touch/mouse action + y0: null, + x0: null, + + // the number of pixels the mouse has moved from its initial position + topDelta: null, + leftDelta: null, + + isFollowing: false, + isHidden: false, + isAnimating: false, // doing the revert animation? + + constructor: function(sourceEl, options) { + this.options = options = options || {}; + this.sourceEl = sourceEl; + this.parentEl = options.parentEl ? $(options.parentEl) : sourceEl.parent(); // default to sourceEl's parent + }, + + + // Causes the element to start following the mouse + start: function(ev) { + if (!this.isFollowing) { + this.isFollowing = true; + + this.y0 = getEvY(ev); + this.x0 = getEvX(ev); + this.topDelta = 0; + this.leftDelta = 0; + + if (!this.isHidden) { + this.updatePosition(); + } + + if (getEvIsTouch(ev)) { + this.listenTo($(document), 'touchmove', this.handleMove); + } + else { + this.listenTo($(document), 'mousemove', this.handleMove); + } + } + }, + + + // Causes the element to stop following the mouse. If shouldRevert is true, will animate back to original position. + // `callback` gets invoked when the animation is complete. If no animation, it is invoked immediately. + stop: function(shouldRevert, callback) { + var _this = this; + var revertDuration = this.options.revertDuration; + + function complete() { // might be called by .animate(), which might change `this` context + _this.isAnimating = false; + _this.removeElement(); + + _this.top0 = _this.left0 = null; // reset state for future updatePosition calls + + if (callback) { + callback(); + } + } + + if (this.isFollowing && !this.isAnimating) { // disallow more than one stop animation at a time + this.isFollowing = false; + + this.stopListeningTo($(document)); + + if (shouldRevert && revertDuration && !this.isHidden) { // do a revert animation? + this.isAnimating = true; + this.el.animate({ + top: this.top0, + left: this.left0 + }, { + duration: revertDuration, + complete: complete + }); + } + else { + complete(); + } + } + }, + + + // Gets the tracking element. Create it if necessary + getEl: function() { + var el = this.el; + + if (!el) { + el = this.el = this.sourceEl.clone() + .addClass(this.options.additionalClass || '') + .css({ + position: 'absolute', + visibility: '', // in case original element was hidden (commonly through hideEvents()) + display: this.isHidden ? 'none' : '', // for when initially hidden + margin: 0, + right: 'auto', // erase and set width instead + bottom: 'auto', // erase and set height instead + width: this.sourceEl.width(), // explicit height in case there was a 'right' value + height: this.sourceEl.height(), // explicit width in case there was a 'bottom' value + opacity: this.options.opacity || '', + zIndex: this.options.zIndex + }); + + // we don't want long taps or any mouse interaction causing selection/menus. + // would use preventSelection(), but that prevents selectstart, causing problems. + el.addClass('fc-unselectable'); + + el.appendTo(this.parentEl); + } + + return el; + }, + + + // Removes the tracking element if it has already been created + removeElement: function() { + if (this.el) { + this.el.remove(); + this.el = null; + } + }, + + + // Update the CSS position of the tracking element + updatePosition: function() { + var sourceOffset; + var origin; + + this.getEl(); // ensure this.el + + // make sure origin info was computed + if (this.top0 === null) { + sourceOffset = this.sourceEl.offset(); + origin = this.el.offsetParent().offset(); + this.top0 = sourceOffset.top - origin.top; + this.left0 = sourceOffset.left - origin.left; + } + + this.el.css({ + top: this.top0 + this.topDelta, + left: this.left0 + this.leftDelta + }); + }, + + + // Gets called when the user moves the mouse + handleMove: function(ev) { + this.topDelta = getEvY(ev) - this.y0; + this.leftDelta = getEvX(ev) - this.x0; + + if (!this.isHidden) { + this.updatePosition(); + } + }, + + + // Temporarily makes the tracking element invisible. Can be called before following starts + hide: function() { + if (!this.isHidden) { + this.isHidden = true; + if (this.el) { + this.el.hide(); + } + } + }, + + + // Show the tracking element after it has been temporarily hidden + show: function() { + if (this.isHidden) { + this.isHidden = false; + this.updatePosition(); + this.getEl().show(); + } + } + +}); + +;; + +/* +Embodies a div that has potential scrollbars +*/ +var Scroller = FC.Scroller = Class.extend({ + + el: null, // the guaranteed outer element + scrollEl: null, // the element with the scrollbars + overflowX: null, + overflowY: null, + + + constructor: function(options) { + options = options || {}; + this.overflowX = options.overflowX || options.overflow || 'auto'; + this.overflowY = options.overflowY || options.overflow || 'auto'; + }, + + + render: function() { + this.el = this.renderEl(); + this.applyOverflow(); + }, + + + renderEl: function() { + return (this.scrollEl = $('
')); + }, + + + // sets to natural height, unlocks overflow + clear: function() { + this.setHeight('auto'); + this.applyOverflow(); + }, + + + destroy: function() { + this.el.remove(); + }, + + + // Overflow + // ----------------------------------------------------------------------------------------------------------------- + + + applyOverflow: function() { + this.scrollEl.css({ + 'overflow-x': this.overflowX, + 'overflow-y': this.overflowY + }); + }, + + + // Causes any 'auto' overflow values to resolves to 'scroll' or 'hidden'. + // Useful for preserving scrollbar widths regardless of future resizes. + // Can pass in scrollbarWidths for optimization. + lockOverflow: function(scrollbarWidths) { + var overflowX = this.overflowX; + var overflowY = this.overflowY; + + scrollbarWidths = scrollbarWidths || this.getScrollbarWidths(); + + if (overflowX === 'auto') { + overflowX = ( + scrollbarWidths.top || scrollbarWidths.bottom || // horizontal scrollbars? + // OR scrolling pane with massless scrollbars? + this.scrollEl[0].scrollWidth - 1 > this.scrollEl[0].clientWidth + // subtract 1 because of IE off-by-one issue + ) ? 'scroll' : 'hidden'; + } + + if (overflowY === 'auto') { + overflowY = ( + scrollbarWidths.left || scrollbarWidths.right || // vertical scrollbars? + // OR scrolling pane with massless scrollbars? + this.scrollEl[0].scrollHeight - 1 > this.scrollEl[0].clientHeight + // subtract 1 because of IE off-by-one issue + ) ? 'scroll' : 'hidden'; + } + + this.scrollEl.css({ 'overflow-x': overflowX, 'overflow-y': overflowY }); + }, + + + // Getters / Setters + // ----------------------------------------------------------------------------------------------------------------- + + + setHeight: function(height) { + this.scrollEl.height(height); + }, + + + getScrollTop: function() { + return this.scrollEl.scrollTop(); + }, + + + setScrollTop: function(top) { + this.scrollEl.scrollTop(top); + }, + + + getClientWidth: function() { + return this.scrollEl[0].clientWidth; + }, + + + getClientHeight: function() { + return this.scrollEl[0].clientHeight; + }, + + + getScrollbarWidths: function() { + return getScrollbarWidths(this.scrollEl); + } + +}); + +;; +function Iterator(items) { + this.items = items || []; +} + + +/* Calls a method on every item passing the arguments through */ +Iterator.prototype.proxyCall = function(methodName) { + var args = Array.prototype.slice.call(arguments, 1); + var results = []; + + this.items.forEach(function(item) { + results.push(item[methodName].apply(item, args)); + }); + + return results; +}; + +;; + +var Interaction = Class.extend({ + + view: null, + component: null, + + + constructor: function(component) { + this.view = component._getView(); + this.component = component; + }, + + + opt: function(name) { + return this.view.opt(name); + }, + + + end: function() { + // subclasses can implement + } + +}); + +;; + +var DateClicking = Interaction.extend({ + + dragListener: null, + + + /* + component must implement: + - bindDateHandlerToEl + - getSafeHitFootprint + - getHitEl + */ + constructor: function(component) { + Interaction.call(this, component); + + this.dragListener = this.buildDragListener(); + }, + + + end: function() { + this.dragListener.endInteraction(); + }, + + + bindToEl: function(el) { + var component = this.component; + var dragListener = this.dragListener; + + component.bindDateHandlerToEl(el, 'mousedown', function(ev) { + if (!component.shouldIgnoreMouse()) { + dragListener.startInteraction(ev); + } + }); + + component.bindDateHandlerToEl(el, 'touchstart', function(ev) { + if (!component.shouldIgnoreTouch()) { + dragListener.startInteraction(ev); + } + }); + }, + + + // Creates a listener that tracks the user's drag across day elements, for day clicking. + buildDragListener: function() { + var _this = this; + var component = this.component; + var dayClickHit; // null if invalid dayClick + + var dragListener = new HitDragListener(component, { + scroll: this.opt('dragScroll'), + interactionStart: function() { + dayClickHit = dragListener.origHit; + }, + hitOver: function(hit, isOrig, origHit) { + // if user dragged to another cell at any point, it can no longer be a dayClick + if (!isOrig) { + dayClickHit = null; + } + }, + hitOut: function() { // called before mouse moves to a different hit OR moved out of all hits + dayClickHit = null; + }, + interactionEnd: function(ev, isCancelled) { + var componentFootprint; + + if (!isCancelled && dayClickHit) { + componentFootprint = component.getSafeHitFootprint(dayClickHit); + + if (componentFootprint) { + _this.view.triggerDayClick(componentFootprint, component.getHitEl(dayClickHit), ev); + } + } + } + }); + + // because dragListener won't be called with any time delay, "dragging" will begin immediately, + // which will kill any touchmoving/scrolling. Prevent this. + dragListener.shouldCancelTouchScroll = false; + + dragListener.scrollAlwaysKills = true; + + return dragListener; + } + +}); + +;; + +var DateSelecting = FC.DateSelecting = Interaction.extend({ + + dragListener: null, + + + /* + component must implement: + - bindDateHandlerToEl + - getSafeHitFootprint + - renderHighlight + - unrenderHighlight + */ + constructor: function(component) { + Interaction.call(this, component); + + this.dragListener = this.buildDragListener(); + }, + + + end: function() { + this.dragListener.endInteraction(); + }, + + + getDelay: function() { + var delay = this.opt('selectLongPressDelay'); + + if (delay == null) { + delay = this.opt('longPressDelay'); // fallback + } + + return delay; + }, + + + bindToEl: function(el) { + var _this = this; + var component = this.component; + var dragListener = this.dragListener; + + component.bindDateHandlerToEl(el, 'mousedown', function(ev) { + if (_this.opt('selectable') && !component.shouldIgnoreMouse()) { + dragListener.startInteraction(ev, { + distance: _this.opt('selectMinDistance') + }); + } + }); + + component.bindDateHandlerToEl(el, 'touchstart', function(ev) { + if (_this.opt('selectable') && !component.shouldIgnoreTouch()) { + dragListener.startInteraction(ev, { + delay: _this.getDelay() + }); + } + }); + + preventSelection(el); + }, + + + // Creates a listener that tracks the user's drag across day elements, for day selecting. + buildDragListener: function() { + var _this = this; + var component = this.component; + var selectionFootprint; // null if invalid selection + + var dragListener = new HitDragListener(component, { + scroll: this.opt('dragScroll'), + interactionStart: function() { + selectionFootprint = null; + }, + dragStart: function(ev) { + _this.view.unselect(ev); // since we could be rendering a new selection, we want to clear any old one + }, + hitOver: function(hit, isOrig, origHit) { + var origHitFootprint; + var hitFootprint; + + if (origHit) { // click needs to have started on a hit + + origHitFootprint = component.getSafeHitFootprint(origHit); + hitFootprint = component.getSafeHitFootprint(hit); + + if (origHitFootprint && hitFootprint) { + selectionFootprint = _this.computeSelection(origHitFootprint, hitFootprint); + } + else { + selectionFootprint = null; + } + + if (selectionFootprint) { + component.renderSelectionFootprint(selectionFootprint); + } + else if (selectionFootprint === false) { + disableCursor(); + } + } + }, + hitOut: function() { // called before mouse moves to a different hit OR moved out of all hits + selectionFootprint = null; + component.unrenderSelection(); + }, + hitDone: function() { // called after a hitOut OR before a dragEnd + enableCursor(); + }, + interactionEnd: function(ev, isCancelled) { + if (!isCancelled && selectionFootprint) { + // the selection will already have been rendered. just report it + _this.view.reportSelection(selectionFootprint, ev); + } + } + }); + + return dragListener; + }, + + + // Given the first and last date-spans of a selection, returns another date-span object. + // Subclasses can override and provide additional data in the span object. Will be passed to renderSelectionFootprint(). + // Will return false if the selection is invalid and this should be indicated to the user. + // Will return null/undefined if a selection invalid but no error should be reported. + computeSelection: function(footprint0, footprint1) { + var wholeFootprint = this.computeSelectionFootprint(footprint0, footprint1); + + if (wholeFootprint && !this.isSelectionFootprintAllowed(wholeFootprint)) { + return false; + } + + return wholeFootprint; + }, + + + // Given two spans, must return the combination of the two. + // TODO: do this separation of concerns (combining VS validation) for event dnd/resize too. + // Assumes both footprints are non-open-ended. + computeSelectionFootprint: function(footprint0, footprint1) { + var ms = [ + footprint0.unzonedRange.startMs, + footprint0.unzonedRange.endMs, + footprint1.unzonedRange.startMs, + footprint1.unzonedRange.endMs + ]; + + ms.sort(compareNumbers); + + return new ComponentFootprint( + new UnzonedRange(ms[0], ms[3]), + footprint0.isAllDay + ); + }, + + + isSelectionFootprintAllowed: function(componentFootprint) { + return this.component.dateProfile.validUnzonedRange.containsRange(componentFootprint.unzonedRange) && + this.view.calendar.isSelectionFootprintAllowed(componentFootprint); + } + +}); + +;; + +var EventDragging = FC.EventDragging = Interaction.extend({ + + eventPointing: null, + dragListener: null, + isDragging: false, + + + /* + component implements: + - bindSegHandlerToEl + - publiclyTrigger + - diffDates + - eventRangesToEventFootprints + - isEventInstanceGroupAllowed + */ + constructor: function(component, eventPointing) { + Interaction.call(this, component); + + this.eventPointing = eventPointing; + }, + + + end: function() { + if (this.dragListener) { + this.dragListener.endInteraction(); + } + }, + + + getSelectionDelay: function() { + var delay = this.opt('eventLongPressDelay'); + + if (delay == null) { + delay = this.opt('longPressDelay'); // fallback + } + + return delay; + }, + + + bindToEl: function(el) { + var component = this.component; + + component.bindSegHandlerToEl(el, 'mousedown', this.handleMousedown.bind(this)); + component.bindSegHandlerToEl(el, 'touchstart', this.handleTouchStart.bind(this)); + }, + + + handleMousedown: function(seg, ev) { + if (this.component.canStartDrag(seg, ev)) { + this.buildDragListener(seg).startInteraction(ev, { distance: 5 }); + } + }, + + + handleTouchStart: function(seg, ev) { + var component = this.component; + var settings = { + delay: this.view.isEventDefSelected(seg.footprint.eventDef) ? // already selected? + 0 : this.getSelectionDelay() + }; + + if (component.canStartDrag(seg, ev)) { + this.buildDragListener(seg).startInteraction(ev, settings); + } + else if (component.canStartSelection(seg, ev)) { + this.buildSelectListener(seg).startInteraction(ev, settings); + } + }, + + + // seg isn't draggable, but let's use a generic DragListener + // simply for the delay, so it can be selected. + // Has side effect of setting/unsetting `dragListener` + buildSelectListener: function(seg) { + var _this = this; + var view = this.view; + var eventDef = seg.footprint.eventDef; + var eventInstance = seg.footprint.eventInstance; // null for inverse-background events + + if (this.dragListener) { + return this.dragListener; + } + + var dragListener = this.dragListener = new DragListener({ + dragStart: function(ev) { + if ( + dragListener.isTouch && + !view.isEventDefSelected(eventDef) && + eventInstance + ) { + // if not previously selected, will fire after a delay. then, select the event + view.selectEventInstance(eventInstance); + } + }, + interactionEnd: function(ev) { + _this.dragListener = null; + } + }); + + return dragListener; + }, + + + // Builds a listener that will track user-dragging on an event segment. + // Generic enough to work with any type of Grid. + // Has side effect of setting/unsetting `dragListener` + buildDragListener: function(seg) { + var _this = this; + var component = this.component; + var view = this.view; + var calendar = view.calendar; + var eventManager = calendar.eventManager; + var el = seg.el; + var eventDef = seg.footprint.eventDef; + var eventInstance = seg.footprint.eventInstance; // null for inverse-background events + var isDragging; + var mouseFollower; // A clone of the original element that will move with the mouse + var eventDefMutation; + + if (this.dragListener) { + return this.dragListener; + } + + // Tracks mouse movement over the *view's* coordinate map. Allows dragging and dropping between subcomponents + // of the view. + var dragListener = this.dragListener = new HitDragListener(view, { + scroll: this.opt('dragScroll'), + subjectEl: el, + subjectCenter: true, + interactionStart: function(ev) { + seg.component = component; // for renderDrag + isDragging = false; + mouseFollower = new MouseFollower(seg.el, { + additionalClass: 'fc-dragging', + parentEl: view.el, + opacity: dragListener.isTouch ? null : _this.opt('dragOpacity'), + revertDuration: _this.opt('dragRevertDuration'), + zIndex: 2 // one above the .fc-view + }); + mouseFollower.hide(); // don't show until we know this is a real drag + mouseFollower.start(ev); + }, + dragStart: function(ev) { + if ( + dragListener.isTouch && + !view.isEventDefSelected(eventDef) && + eventInstance + ) { + // if not previously selected, will fire after a delay. then, select the event + view.selectEventInstance(eventInstance); + } + isDragging = true; + + // ensure a mouseout on the manipulated event has been reported + _this.eventPointing.handleMouseout(seg, ev); + + _this.segDragStart(seg, ev); + view.hideEventsWithId(seg.footprint.eventDef.id); + }, + hitOver: function(hit, isOrig, origHit) { + var isAllowed = true; + var origFootprint; + var footprint; + var mutatedEventInstanceGroup; + + // starting hit could be forced (DayGrid.limit) + if (seg.hit) { + origHit = seg.hit; + } + + // hit might not belong to this grid, so query origin grid + origFootprint = origHit.component.getSafeHitFootprint(origHit); + footprint = hit.component.getSafeHitFootprint(hit); + + if (origFootprint && footprint) { + eventDefMutation = _this.computeEventDropMutation(origFootprint, footprint, eventDef); + + if (eventDefMutation) { + mutatedEventInstanceGroup = eventManager.buildMutatedEventInstanceGroup( + eventDef.id, + eventDefMutation + ); + isAllowed = component.isEventInstanceGroupAllowed(mutatedEventInstanceGroup); + } + else { + isAllowed = false; + } + } + else { + isAllowed = false; + } + + if (!isAllowed) { + eventDefMutation = null; + disableCursor(); + } + + // if a valid drop location, have the subclass render a visual indication + if ( + eventDefMutation && + view.renderDrag( // truthy if rendered something + component.eventRangesToEventFootprints( + mutatedEventInstanceGroup.sliceRenderRanges(component.dateProfile.renderUnzonedRange, calendar) + ), + seg, + dragListener.isTouch + ) + ) { + mouseFollower.hide(); // if the subclass is already using a mock event "helper", hide our own + } + else { + mouseFollower.show(); // otherwise, have the helper follow the mouse (no snapping) + } + + if (isOrig) { + // needs to have moved hits to be a valid drop + eventDefMutation = null; + } + }, + hitOut: function() { // called before mouse moves to a different hit OR moved out of all hits + view.unrenderDrag(seg); // unrender whatever was done in renderDrag + mouseFollower.show(); // show in case we are moving out of all hits + eventDefMutation = null; + }, + hitDone: function() { // Called after a hitOut OR before a dragEnd + enableCursor(); + }, + interactionEnd: function(ev) { + delete seg.component; // prevent side effects + + // do revert animation if hasn't changed. calls a callback when finished (whether animation or not) + mouseFollower.stop(!eventDefMutation, function() { + if (isDragging) { + view.unrenderDrag(seg); + _this.segDragStop(seg, ev); + } + + view.showEventsWithId(seg.footprint.eventDef.id); + + if (eventDefMutation) { + // no need to re-show original, will rerender all anyways. esp important if eventRenderWait + view.reportEventDrop(eventInstance, eventDefMutation, el, ev); + } + }); + + _this.dragListener = null; + } + }); + + return dragListener; + }, + + + // Called before event segment dragging starts + segDragStart: function(seg, ev) { + this.isDragging = true; + this.component.publiclyTrigger('eventDragStart', { + context: seg.el[0], + args: [ + seg.footprint.getEventLegacy(), + ev, + {}, // jqui dummy + this.view + ] + }); + }, + + + // Called after event segment dragging stops + segDragStop: function(seg, ev) { + this.isDragging = false; + this.component.publiclyTrigger('eventDragStop', { + context: seg.el[0], + args: [ + seg.footprint.getEventLegacy(), + ev, + {}, // jqui dummy + this.view + ] + }); + }, + + + // DOES NOT consider overlap/constraint + computeEventDropMutation: function(startFootprint, endFootprint, eventDef) { + var eventDefMutation = new EventDefMutation(); + + eventDefMutation.setDateMutation( + this.computeEventDateMutation(startFootprint, endFootprint) + ); + + return eventDefMutation; + }, + + + computeEventDateMutation: function(startFootprint, endFootprint) { + var date0 = startFootprint.unzonedRange.getStart(); + var date1 = endFootprint.unzonedRange.getStart(); + var clearEnd = false; + var forceTimed = false; + var forceAllDay = false; + var dateDelta; + var dateMutation; + + if (startFootprint.isAllDay !== endFootprint.isAllDay) { + clearEnd = true; + + if (endFootprint.isAllDay) { + forceAllDay = true; + date0.stripTime(); + } + else { + forceTimed = true; + } + } + + dateDelta = this.component.diffDates(date1, date0); + + dateMutation = new EventDefDateMutation(); + dateMutation.clearEnd = clearEnd; + dateMutation.forceTimed = forceTimed; + dateMutation.forceAllDay = forceAllDay; + dateMutation.setDateDelta(dateDelta); + + return dateMutation; + } + +}); + +;; + +var EventResizing = FC.EventResizing = Interaction.extend({ + + eventPointing: null, + dragListener: null, + isResizing: false, + + + /* + component impements: + - bindSegHandlerToEl + - publiclyTrigger + - diffDates + - eventRangesToEventFootprints + - isEventInstanceGroupAllowed + - getSafeHitFootprint + */ + + + constructor: function(component, eventPointing) { + Interaction.call(this, component); + + this.eventPointing = eventPointing; + }, + + + end: function() { + if (this.dragListener) { + this.dragListener.endInteraction(); + } + }, + + + bindToEl: function(el) { + var component = this.component; + + component.bindSegHandlerToEl(el, 'mousedown', this.handleMouseDown.bind(this)); + component.bindSegHandlerToEl(el, 'touchstart', this.handleTouchStart.bind(this)); + }, + + + handleMouseDown: function(seg, ev) { + if (this.component.canStartResize(seg, ev)) { + this.buildDragListener(seg, $(ev.target).is('.fc-start-resizer')) + .startInteraction(ev, { distance: 5 }); + } + }, + + + handleTouchStart: function(seg, ev) { + if (this.component.canStartResize(seg, ev)) { + this.buildDragListener(seg, $(ev.target).is('.fc-start-resizer')) + .startInteraction(ev); + } + }, + + + // Creates a listener that tracks the user as they resize an event segment. + // Generic enough to work with any type of Grid. + buildDragListener: function(seg, isStart) { + var _this = this; + var component = this.component; + var view = this.view; + var calendar = view.calendar; + var eventManager = calendar.eventManager; + var el = seg.el; + var eventDef = seg.footprint.eventDef; + var eventInstance = seg.footprint.eventInstance; + var isDragging; + var resizeMutation; // zoned event date properties. falsy if invalid resize + + // Tracks mouse movement over the *grid's* coordinate map + var dragListener = this.dragListener = new HitDragListener(component, { + scroll: this.opt('dragScroll'), + subjectEl: el, + interactionStart: function() { + isDragging = false; + }, + dragStart: function(ev) { + isDragging = true; + + // ensure a mouseout on the manipulated event has been reported + _this.eventPointing.handleMouseout(seg, ev); + + _this.segResizeStart(seg, ev); + }, + hitOver: function(hit, isOrig, origHit) { + var isAllowed = true; + var origHitFootprint = component.getSafeHitFootprint(origHit); + var hitFootprint = component.getSafeHitFootprint(hit); + var mutatedEventInstanceGroup; + + if (origHitFootprint && hitFootprint) { + resizeMutation = isStart ? + _this.computeEventStartResizeMutation(origHitFootprint, hitFootprint, seg.footprint) : + _this.computeEventEndResizeMutation(origHitFootprint, hitFootprint, seg.footprint); + + if (resizeMutation) { + mutatedEventInstanceGroup = eventManager.buildMutatedEventInstanceGroup( + eventDef.id, + resizeMutation + ); + isAllowed = component.isEventInstanceGroupAllowed(mutatedEventInstanceGroup); + } + else { + isAllowed = false; + } + } + else { + isAllowed = false; + } + + if (!isAllowed) { + resizeMutation = null; + disableCursor(); + } + else if (resizeMutation.isEmpty()) { + // no change. (FYI, event dates might have zones) + resizeMutation = null; + } + + if (resizeMutation) { + view.hideEventsWithId(seg.footprint.eventDef.id); + view.renderEventResize( + component.eventRangesToEventFootprints( + mutatedEventInstanceGroup.sliceRenderRanges(component.dateProfile.renderUnzonedRange, calendar) + ), + seg + ); + } + }, + hitOut: function() { // called before mouse moves to a different hit OR moved out of all hits + resizeMutation = null; + }, + hitDone: function() { // resets the rendering to show the original event + view.unrenderEventResize(seg); + view.showEventsWithId(seg.footprint.eventDef.id); + enableCursor(); + }, + interactionEnd: function(ev) { + if (isDragging) { + _this.segResizeStop(seg, ev); + } + + if (resizeMutation) { // valid date to resize to? + // no need to re-show original, will rerender all anyways. esp important if eventRenderWait + view.reportEventResize(eventInstance, resizeMutation, el, ev); + } + + _this.dragListener = null; + } + }); + + return dragListener; + }, + + + // Called before event segment resizing starts + segResizeStart: function(seg, ev) { + this.isResizing = true; + this.component.publiclyTrigger('eventResizeStart', { + context: seg.el[0], + args: [ + seg.footprint.getEventLegacy(), + ev, + {}, // jqui dummy + this.view + ] + }); + }, + + + // Called after event segment resizing stops + segResizeStop: function(seg, ev) { + this.isResizing = false; + this.component.publiclyTrigger('eventResizeStop', { + context: seg.el[0], + args: [ + seg.footprint.getEventLegacy(), + ev, + {}, // jqui dummy + this.view + ] + }); + }, + + + // Returns new date-information for an event segment being resized from its start + computeEventStartResizeMutation: function(startFootprint, endFootprint, origEventFootprint) { + var origRange = origEventFootprint.componentFootprint.unzonedRange; + var startDelta = this.component.diffDates( + endFootprint.unzonedRange.getStart(), + startFootprint.unzonedRange.getStart() + ); + var dateMutation; + var eventDefMutation; + + if (origRange.getStart().add(startDelta) < origRange.getEnd()) { + + dateMutation = new EventDefDateMutation(); + dateMutation.setStartDelta(startDelta); + + eventDefMutation = new EventDefMutation(); + eventDefMutation.setDateMutation(dateMutation); + + return eventDefMutation; + } + + return false; + }, + + + // Returns new date-information for an event segment being resized from its end + computeEventEndResizeMutation: function(startFootprint, endFootprint, origEventFootprint) { + var origRange = origEventFootprint.componentFootprint.unzonedRange; + var endDelta = this.component.diffDates( + endFootprint.unzonedRange.getEnd(), + startFootprint.unzonedRange.getEnd() + ); + var dateMutation; + var eventDefMutation; + + if (origRange.getEnd().add(endDelta) > origRange.getStart()) { + + dateMutation = new EventDefDateMutation(); + dateMutation.setEndDelta(endDelta); + + eventDefMutation = new EventDefMutation(); + eventDefMutation.setDateMutation(dateMutation); + + return eventDefMutation; + } + + return false; + } + +}); + +;; + +var ExternalDropping = FC.ExternalDropping = Interaction.extend(ListenerMixin, { + + dragListener: null, + isDragging: false, // jqui-dragging an external element? boolean + + + /* + component impements: + - eventRangesToEventFootprints + - isEventInstanceGroupAllowed + - isExternalInstanceGroupAllowed + - renderDrag + - unrenderDrag + */ + + + end: function() { + if (this.dragListener) { + this.dragListener.endInteraction(); + } + }, + + + bindToDocument: function() { + this.listenTo($(document), { + dragstart: this.handleDragStart, // jqui + sortstart: this.handleDragStart // jqui + }); + }, + + + unbindFromDocument: function() { + this.stopListeningTo($(document)); + }, + + + // Called when a jQuery UI drag is initiated anywhere in the DOM + handleDragStart: function(ev, ui) { + var el; + var accept; + + if (this.opt('droppable')) { // only listen if this setting is on + el = $((ui ? ui.item : null) || ev.target); + + // Test that the dragged element passes the dropAccept selector or filter function. + // FYI, the default is "*" (matches all) + accept = this.opt('dropAccept'); + if ($.isFunction(accept) ? accept.call(el[0], el) : el.is(accept)) { + if (!this.isDragging) { // prevent double-listening if fired twice + this.listenToExternalDrag(el, ev, ui); + } + } + } + }, + + + // Called when a jQuery UI drag starts and it needs to be monitored for dropping + listenToExternalDrag: function(el, ev, ui) { + var _this = this; + var component = this.component; + var view = this.view; + var meta = getDraggedElMeta(el); // extra data about event drop, including possible event to create + var singleEventDef; // a null value signals an unsuccessful drag + + // listener that tracks mouse movement over date-associated pixel regions + var dragListener = _this.dragListener = new HitDragListener(component, { + interactionStart: function() { + _this.isDragging = true; + }, + hitOver: function(hit) { + var isAllowed = true; + var hitFootprint = hit.component.getSafeHitFootprint(hit); // hit might not belong to this grid + var mutatedEventInstanceGroup; + + if (hitFootprint) { + singleEventDef = _this.computeExternalDrop(hitFootprint, meta); + + if (singleEventDef) { + mutatedEventInstanceGroup = new EventInstanceGroup( + singleEventDef.buildInstances() + ); + isAllowed = meta.eventProps ? // isEvent? + component.isEventInstanceGroupAllowed(mutatedEventInstanceGroup) : + component.isExternalInstanceGroupAllowed(mutatedEventInstanceGroup); + } + else { + isAllowed = false; + } + } + else { + isAllowed = false; + } + + if (!isAllowed) { + singleEventDef = null; + disableCursor(); + } + + if (singleEventDef) { + component.renderDrag( // called without a seg parameter + component.eventRangesToEventFootprints( + mutatedEventInstanceGroup.sliceRenderRanges(component.dateProfile.renderUnzonedRange, view.calendar) + ) + ); + } + }, + hitOut: function() { + singleEventDef = null; // signal unsuccessful + }, + hitDone: function() { // Called after a hitOut OR before a dragEnd + enableCursor(); + component.unrenderDrag(); + }, + interactionEnd: function(ev) { + + if (singleEventDef) { // element was dropped on a valid hit + view.reportExternalDrop( + singleEventDef, + Boolean(meta.eventProps), // isEvent + Boolean(meta.stick), // isSticky + el, ev, ui + ); + } + + _this.isDragging = false; + _this.dragListener = null; + } + }); + + dragListener.startDrag(ev); // start listening immediately + }, + + + // Given a hit to be dropped upon, and misc data associated with the jqui drag (guaranteed to be a plain object), + // returns the zoned start/end dates for the event that would result from the hypothetical drop. end might be null. + // Returning a null value signals an invalid drop hit. + // DOES NOT consider overlap/constraint. + // Assumes both footprints are non-open-ended. + computeExternalDrop: function(componentFootprint, meta) { + var calendar = this.view.calendar; + var start = FC.moment.utc(componentFootprint.unzonedRange.startMs).stripZone(); + var end; + var eventDef; + + if (componentFootprint.isAllDay) { + // if dropped on an all-day span, and element's metadata specified a time, set it + if (meta.startTime) { + start.time(meta.startTime); + } + else { + start.stripTime(); + } + } + + if (meta.duration) { + end = start.clone().add(meta.duration); + } + + start = calendar.applyTimezone(start); + + if (end) { + end = calendar.applyTimezone(end); + } + + eventDef = SingleEventDef.parse( + $.extend({}, meta.eventProps, { + start: start, + end: end + }), + new EventSource(calendar) + ); + + return eventDef; + } + +}); + + +/* External-Dragging-Element Data +----------------------------------------------------------------------------------------------------------------------*/ + +// Require all HTML5 data-* attributes used by FullCalendar to have this prefix. +// A value of '' will query attributes like data-event. A value of 'fc' will query attributes like data-fc-event. +FC.dataAttrPrefix = ''; + +// Given a jQuery element that might represent a dragged FullCalendar event, returns an intermediate data structure +// to be used for Event Object creation. +// A defined `.eventProps`, even when empty, indicates that an event should be created. +function getDraggedElMeta(el) { + var prefix = FC.dataAttrPrefix; + var eventProps; // properties for creating the event, not related to date/time + var startTime; // a Duration + var duration; + var stick; + + if (prefix) { prefix += '-'; } + eventProps = el.data(prefix + 'event') || null; + + if (eventProps) { + if (typeof eventProps === 'object') { + eventProps = $.extend({}, eventProps); // make a copy + } + else { // something like 1 or true. still signal event creation + eventProps = {}; + } + + // pluck special-cased date/time properties + startTime = eventProps.start; + if (startTime == null) { startTime = eventProps.time; } // accept 'time' as well + duration = eventProps.duration; + stick = eventProps.stick; + delete eventProps.start; + delete eventProps.time; + delete eventProps.duration; + delete eventProps.stick; + } + + // fallback to standalone attribute values for each of the date/time properties + if (startTime == null) { startTime = el.data(prefix + 'start'); } + if (startTime == null) { startTime = el.data(prefix + 'time'); } // accept 'time' as well + if (duration == null) { duration = el.data(prefix + 'duration'); } + if (stick == null) { stick = el.data(prefix + 'stick'); } + + // massage into correct data types + startTime = startTime != null ? moment.duration(startTime) : null; + duration = duration != null ? moment.duration(duration) : null; + stick = Boolean(stick); + + return { eventProps: eventProps, startTime: startTime, duration: duration, stick: stick }; +} + +;; + +var EventPointing = FC.EventPointing = Interaction.extend({ + + mousedOverSeg: null, // the segment object the user's mouse is over. null if over nothing + + + /* + component must implement: + - publiclyTrigger + */ + + + bindToEl: function(el) { + var component = this.component; + + component.bindSegHandlerToEl(el, 'click', this.handleClick.bind(this)); + component.bindSegHandlerToEl(el, 'mouseenter', this.handleMouseover.bind(this)); + component.bindSegHandlerToEl(el, 'mouseleave', this.handleMouseout.bind(this)); + }, + + + handleClick: function(seg, ev) { + var res = this.component.publiclyTrigger('eventClick', { // can return `false` to cancel + context: seg.el[0], + args: [ seg.footprint.getEventLegacy(), ev, this.view ] + }); + + if (res === false) { + ev.preventDefault(); + } + }, + + + // Updates internal state and triggers handlers for when an event element is moused over + handleMouseover: function(seg, ev) { + if ( + !GlobalEmitter.get().shouldIgnoreMouse() && + !this.mousedOverSeg + ) { + this.mousedOverSeg = seg; + + // TODO: move to EventSelecting's responsibility + if (this.view.isEventDefResizable(seg.footprint.eventDef)) { + seg.el.addClass('fc-allow-mouse-resize'); + } + + this.component.publiclyTrigger('eventMouseover', { + context: seg.el[0], + args: [ seg.footprint.getEventLegacy(), ev, this.view ] + }); + } + }, + + + // Updates internal state and triggers handlers for when an event element is moused out. + // Can be given no arguments, in which case it will mouseout the segment that was previously moused over. + handleMouseout: function(seg, ev) { + if (this.mousedOverSeg) { + this.mousedOverSeg = null; + + // TODO: move to EventSelecting's responsibility + if (this.view.isEventDefResizable(seg.footprint.eventDef)) { + seg.el.removeClass('fc-allow-mouse-resize'); + } + + this.component.publiclyTrigger('eventMouseout', { + context: seg.el[0], + args: [ + seg.footprint.getEventLegacy(), + ev || {}, // if given no arg, make a mock mouse event + this.view + ] + }); + } + }, + + + end: function() { + if (this.mousedOverSeg) { + this.handleMouseout(this.mousedOverSeg); + } + } + +}); + +;; + +var StandardInteractionsMixin = FC.StandardInteractionsMixin = { + dateClickingClass: DateClicking, + dateSelectingClass: DateSelecting, + eventPointingClass: EventPointing, + eventDraggingClass: EventDragging, + eventResizingClass: EventResizing, + externalDroppingClass: ExternalDropping +}; + +;; + +var EventRenderer = FC.EventRenderer = Class.extend({ + + view: null, + component: null, + fillRenderer: null, // might remain null + + fgSegs: null, + bgSegs: null, + + // derived from options + eventTimeFormat: null, + displayEventTime: null, + displayEventEnd: null, + + + constructor: function(component, fillRenderer) { // fillRenderer is optional + this.view = component._getView(); + this.component = component; + this.fillRenderer = fillRenderer; + }, + + + opt: function(name) { + return this.view.opt(name); + }, + + + // Updates values that rely on options and also relate to range + rangeUpdated: function() { + var displayEventTime; + var displayEventEnd; + + this.eventTimeFormat = + this.opt('eventTimeFormat') || + this.opt('timeFormat') || // deprecated + this.computeEventTimeFormat(); + + displayEventTime = this.opt('displayEventTime'); + if (displayEventTime == null) { + displayEventTime = this.computeDisplayEventTime(); // might be based off of range + } + + displayEventEnd = this.opt('displayEventEnd'); + if (displayEventEnd == null) { + displayEventEnd = this.computeDisplayEventEnd(); // might be based off of range + } + + this.displayEventTime = displayEventTime; + this.displayEventEnd = displayEventEnd; + }, + + + render: function(eventsPayload) { + var dateProfile = this.component._getDateProfile(); + var eventDefId; + var instanceGroup; + var eventRanges; + var bgRanges = []; + var fgRanges = []; + + for (eventDefId in eventsPayload) { + instanceGroup = eventsPayload[eventDefId]; + + eventRanges = instanceGroup.sliceRenderRanges( + dateProfile.activeUnzonedRange + ); + + if (instanceGroup.getEventDef().hasBgRendering()) { + bgRanges.push.apply(bgRanges, eventRanges); + } + else { + fgRanges.push.apply(fgRanges, eventRanges); + } + } + + this.renderBgRanges(bgRanges); + this.renderFgRanges(fgRanges); + }, + + + unrender: function() { + this.unrenderBgRanges(); + this.unrenderFgRanges(); + }, + + + renderFgRanges: function(eventRanges) { + var eventFootprints = this.component.eventRangesToEventFootprints(eventRanges); + var segs = this.component.eventFootprintsToSegs(eventFootprints); + + // render an `.el` on each seg + // returns a subset of the segs. segs that were actually rendered + segs = this.renderFgSegEls(segs); + + if (this.renderFgSegs(segs) !== false) { // no failure? + this.fgSegs = segs; + } + }, + + + unrenderFgRanges: function() { + this.unrenderFgSegs(this.fgSegs || []); + this.fgSegs = null; + }, + + + renderBgRanges: function(eventRanges) { + var eventFootprints = this.component.eventRangesToEventFootprints(eventRanges); + var segs = this.component.eventFootprintsToSegs(eventFootprints); + + if (this.renderBgSegs(segs) !== false) { // no failure? + this.bgSegs = segs; + } + }, + + + unrenderBgRanges: function() { + this.unrenderBgSegs(); + this.bgSegs = null; + }, + + + getSegs: function() { + return (this.bgSegs || []).concat(this.fgSegs || []); + }, + + + // Renders foreground event segments onto the grid + renderFgSegs: function(segs) { + // subclasses must implement + // segs already has rendered els, and has been filtered. + + return false; // signal failure if not implemented + }, + + + // Unrenders all currently rendered foreground segments + unrenderFgSegs: function(segs) { + // subclasses must implement + }, + + + renderBgSegs: function(segs) { + var _this = this; + + if (this.fillRenderer) { + this.fillRenderer.renderSegs('bgEvent', segs, { + getClasses: function(seg) { + return _this.getBgClasses(seg.footprint.eventDef); + }, + getCss: function(seg) { + return { + 'background-color': _this.getBgColor(seg.footprint.eventDef) + }; + }, + filterEl: function(seg, el) { + return _this.filterEventRenderEl(seg.footprint, el); + } + }); + } + else { + return false; // signal failure if no fillRenderer + } + }, + + + unrenderBgSegs: function() { + if (this.fillRenderer) { + this.fillRenderer.unrender('bgEvent'); + } + }, + + + // Renders and assigns an `el` property for each foreground event segment. + // Only returns segments that successfully rendered. + renderFgSegEls: function(segs, disableResizing) { + var _this = this; + var hasEventRenderHandlers = this.view.hasPublicHandlers('eventRender'); + var html = ''; + var renderedSegs = []; + var i; + + if (segs.length) { // don't build an empty html string + + // build a large concatenation of event segment HTML + for (i = 0; i < segs.length; i++) { + this.beforeFgSegHtml(segs[i]); + html += this.fgSegHtml(segs[i], disableResizing); + } + + // Grab individual elements from the combined HTML string. Use each as the default rendering. + // Then, compute the 'el' for each segment. An el might be null if the eventRender callback returned false. + $(html).each(function(i, node) { + var seg = segs[i]; + var el = $(node); + + if (hasEventRenderHandlers) { // optimization + el = _this.filterEventRenderEl(seg.footprint, el); + } + + if (el) { + el.data('fc-seg', seg); // used by handlers + seg.el = el; + renderedSegs.push(seg); + } + }); + } + + return renderedSegs; + }, + + + beforeFgSegHtml: function(seg) { // hack + }, + + + // Generates the HTML for the default rendering of a foreground event segment. Used by renderFgSegEls() + fgSegHtml: function(seg, disableResizing) { + // subclasses should implement + }, + + + // Generic utility for generating the HTML classNames for an event segment's element + getSegClasses: function(seg, isDraggable, isResizable) { + var classes = [ + 'fc-event', + seg.isStart ? 'fc-start' : 'fc-not-start', + seg.isEnd ? 'fc-end' : 'fc-not-end' + ].concat(this.getClasses(seg.footprint.eventDef)); + + if (isDraggable) { + classes.push('fc-draggable'); + } + if (isResizable) { + classes.push('fc-resizable'); + } + + // event is currently selected? attach a className. + if (this.view.isEventDefSelected(seg.footprint.eventDef)) { + classes.push('fc-selected'); + } + + return classes; + }, + + + // Given an event and the default element used for rendering, returns the element that should actually be used. + // Basically runs events and elements through the eventRender hook. + filterEventRenderEl: function(eventFootprint, el) { + var legacy = eventFootprint.getEventLegacy(); + + var custom = this.view.publiclyTrigger('eventRender', { + context: legacy, + args: [ legacy, el, this.view ] + }); + + if (custom === false) { // means don't render at all + el = null; + } + else if (custom && custom !== true) { + el = $(custom); + } + + return el; + }, + + + // Compute the text that should be displayed on an event's element. + // `range` can be the Event object itself, or something range-like, with at least a `start`. + // If event times are disabled, or the event has no time, will return a blank string. + // If not specified, formatStr will default to the eventTimeFormat setting, + // and displayEnd will default to the displayEventEnd setting. + getTimeText: function(eventFootprint, formatStr, displayEnd) { + return this._getTimeText( + eventFootprint.eventInstance.dateProfile.start, + eventFootprint.eventInstance.dateProfile.end, + eventFootprint.componentFootprint.isAllDay, + formatStr, + displayEnd + ); + }, + + + _getTimeText: function(start, end, isAllDay, formatStr, displayEnd) { + if (formatStr == null) { + formatStr = this.eventTimeFormat; + } + + if (displayEnd == null) { + displayEnd = this.displayEventEnd; + } + + if (this.displayEventTime && !isAllDay) { + if (displayEnd && end) { + return this.view.formatRange( + { start: start, end: end }, + false, // allDay + formatStr + ); + } + else { + return start.format(formatStr); + } + } + + return ''; + }, + + + computeEventTimeFormat: function() { + return this.opt('smallTimeFormat'); + }, + + + computeDisplayEventTime: function() { + return true; + }, + + + computeDisplayEventEnd: function() { + return true; + }, + + + getBgClasses: function(eventDef) { + var classNames = this.getClasses(eventDef); + classNames.push('fc-bgevent'); + return classNames; + }, + + + getClasses: function(eventDef) { + var objs = this.getStylingObjs(eventDef); + var i; + var classNames = []; + + for (i = 0; i < objs.length; i++) { + classNames.push.apply( // append + classNames, + objs[i].eventClassName || objs[i].className || [] + ); + } + + return classNames; + }, + + + // Utility for generating event skin-related CSS properties + getSkinCss: function(eventDef) { + return { + 'background-color': this.getBgColor(eventDef), + 'border-color': this.getBorderColor(eventDef), + color: this.getTextColor(eventDef) + }; + }, + + + // Queries for caller-specified color, then falls back to default + getBgColor: function(eventDef) { + var objs = this.getStylingObjs(eventDef); + var i; + var val; + + for (i = 0; i < objs.length && !val; i++) { + val = objs[i].eventBackgroundColor || objs[i].eventColor || + objs[i].backgroundColor || objs[i].color; + } + + if (!val) { + val = this.opt('eventBackgroundColor') || this.opt('eventColor'); + } + + return val; + }, + + + // Queries for caller-specified color, then falls back to default + getBorderColor: function(eventDef) { + var objs = this.getStylingObjs(eventDef); + var i; + var val; + + for (i = 0; i < objs.length && !val; i++) { + val = objs[i].eventBorderColor || objs[i].eventColor || + objs[i].borderColor || objs[i].color; + } + + if (!val) { + val = this.opt('eventBorderColor') || this.opt('eventColor'); + } + + return val; + }, + + + // Queries for caller-specified color, then falls back to default + getTextColor: function(eventDef) { + var objs = this.getStylingObjs(eventDef); + var i; + var val; + + for (i = 0; i < objs.length && !val; i++) { + val = objs[i].eventTextColor || + objs[i].textColor; + } + + if (!val) { + val = this.opt('eventTextColor'); + } + + return val; + }, + + + getStylingObjs: function(eventDef) { + var objs = this.getFallbackStylingObjs(eventDef); + objs.unshift(eventDef); + return objs; + }, + + + getFallbackStylingObjs: function(eventDef) { + return [ eventDef.source ]; + }, + + + sortEventSegs: function(segs) { + segs.sort(proxy(this, 'compareEventSegs')); + }, + + + // A cmp function for determining which segments should take visual priority + compareEventSegs: function(seg1, seg2) { + var f1 = seg1.footprint.componentFootprint; + var r1 = f1.unzonedRange; + var f2 = seg2.footprint.componentFootprint; + var r2 = f2.unzonedRange; + + return r1.startMs - r2.startMs || // earlier events go first + (r2.endMs - r2.startMs) - (r1.endMs - r1.startMs) || // tie? longer events go first + f2.isAllDay - f1.isAllDay || // tie? put all-day events first (booleans cast to 0/1) + compareByFieldSpecs( + seg1.footprint.eventDef, + seg2.footprint.eventDef, + this.view.eventOrderSpecs + ); + } + +}); + +;; + +var BusinessHourRenderer = FC.BusinessHourRenderer = Class.extend({ + + component: null, + fillRenderer: null, + segs: null, + + + /* + component implements: + - eventRangesToEventFootprints + - eventFootprintsToSegs + */ + constructor: function(component, fillRenderer) { + this.component = component; + this.fillRenderer = fillRenderer; + }, + + + render: function(businessHourGenerator) { + var component = this.component; + var unzonedRange = component._getDateProfile().activeUnzonedRange; + + var eventInstanceGroup = businessHourGenerator.buildEventInstanceGroup( + component.hasAllDayBusinessHours, + unzonedRange + ); + + var eventFootprints = eventInstanceGroup ? + component.eventRangesToEventFootprints( + eventInstanceGroup.sliceRenderRanges(unzonedRange) + ) : + []; + + this.renderEventFootprints(eventFootprints); + }, + + + renderEventFootprints: function(eventFootprints) { + var segs = this.component.eventFootprintsToSegs(eventFootprints); + + this.renderSegs(segs); + this.segs = segs; + }, + + + renderSegs: function(segs) { + if (this.fillRenderer) { + this.fillRenderer.renderSegs('businessHours', segs, { + getClasses: function(seg) { + return [ 'fc-nonbusiness', 'fc-bgevent' ]; + } + }); + } + }, + + + unrender: function() { + if (this.fillRenderer) { + this.fillRenderer.unrender('businessHours'); + } + + this.segs = null; + }, + + + getSegs: function() { + return this.segs || []; + } + +}); + +;; + +var FillRenderer = FC.FillRenderer = Class.extend({ // use for highlight, background events, business hours + + fillSegTag: 'div', + component: null, + elsByFill: null, // a hash of jQuery element sets used for rendering each fill. Keyed by fill name. + + + constructor: function(component) { + this.component = component; + this.elsByFill = {}; + }, + + + renderFootprint: function(type, componentFootprint, props) { + this.renderSegs( + type, + this.component.componentFootprintToSegs(componentFootprint), + props + ); + }, + + + renderSegs: function(type, segs, props) { + var els; + + segs = this.buildSegEls(type, segs, props); // assignes `.el` to each seg. returns successfully rendered segs + els = this.attachSegEls(type, segs); + + if (els) { + this.reportEls(type, els); + } + + return segs; + }, + + + // Unrenders a specific type of fill that is currently rendered on the grid + unrender: function(type) { + var el = this.elsByFill[type]; + + if (el) { + el.remove(); + delete this.elsByFill[type]; + } + }, + + + // Renders and assigns an `el` property for each fill segment. Generic enough to work with different types. + // Only returns segments that successfully rendered. + buildSegEls: function(type, segs, props) { + var _this = this; + var html = ''; + var renderedSegs = []; + var i; + + if (segs.length) { + + // build a large concatenation of segment HTML + for (i = 0; i < segs.length; i++) { + html += this.buildSegHtml(type, segs[i], props); + } + + // Grab individual elements from the combined HTML string. Use each as the default rendering. + // Then, compute the 'el' for each segment. + $(html).each(function(i, node) { + var seg = segs[i]; + var el = $(node); + + // allow custom filter methods per-type + if (props.filterEl) { + el = props.filterEl(seg, el); + } + + if (el) { // custom filters did not cancel the render + el = $(el); // allow custom filter to return raw DOM node + + // correct element type? (would be bad if a non-TD were inserted into a table for example) + if (el.is(_this.fillSegTag)) { + seg.el = el; + renderedSegs.push(seg); + } + } + }); + } + + return renderedSegs; + }, + + + // Builds the HTML needed for one fill segment. Generic enough to work with different types. + buildSegHtml: function(type, seg, props) { + // custom hooks per-type + var classes = props.getClasses ? props.getClasses(seg) : []; + var css = cssToStr(props.getCss ? props.getCss(seg) : {}); + + return '<' + this.fillSegTag + + (classes.length ? ' class="' + classes.join(' ') + '"' : '') + + (css ? ' style="' + css + '"' : '') + + ' />'; + }, + + + // Should return wrapping DOM structure + attachSegEls: function(type, segs) { + // subclasses must implement + }, + + + reportEls: function(type, nodes) { + if (this.elsByFill[type]) { + this.elsByFill[type] = this.elsByFill[type].add(nodes); + } + else { + this.elsByFill[type] = $(nodes); + } + } + +}); + +;; + +var HelperRenderer = FC.HelperRenderer = Class.extend({ + + view: null, + component: null, + eventRenderer: null, + helperEls: null, + + + constructor: function(component, eventRenderer) { + this.view = component._getView(); + this.component = component; + this.eventRenderer = eventRenderer; + }, + + + renderComponentFootprint: function(componentFootprint) { + this.renderEventFootprints([ + this.fabricateEventFootprint(componentFootprint) + ]); + }, + + + renderEventDraggingFootprints: function(eventFootprints, sourceSeg, isTouch) { + this.renderEventFootprints( + eventFootprints, + sourceSeg, + 'fc-dragging', + isTouch ? null : this.view.opt('dragOpacity') + ); + }, + + + renderEventResizingFootprints: function(eventFootprints, sourceSeg, isTouch) { + this.renderEventFootprints( + eventFootprints, + sourceSeg, + 'fc-resizing' + ); + }, + + + renderEventFootprints: function(eventFootprints, sourceSeg, extraClassNames, opacity) { + var segs = this.component.eventFootprintsToSegs(eventFootprints); + var classNames = 'fc-helper ' + (extraClassNames || ''); + var i; + + // assigns each seg's el and returns a subset of segs that were rendered + segs = this.eventRenderer.renderFgSegEls(segs); + + for (i = 0; i < segs.length; i++) { + segs[i].el.addClass(classNames); + } + + if (opacity != null) { + for (i = 0; i < segs.length; i++) { + segs[i].el.css('opacity', opacity); + } + } + + this.helperEls = this.renderSegs(segs, sourceSeg); + }, + + + /* + Must return all mock event elements + */ + renderSegs: function(segs, sourceSeg) { + // Subclasses must implement + }, + + + unrender: function() { + if (this.helperEls) { + this.helperEls.remove(); + this.helperEls = null; + } + }, + + + fabricateEventFootprint: function(componentFootprint) { + var calendar = this.view.calendar; + var eventDateProfile = calendar.footprintToDateProfile(componentFootprint); + var dummyEvent = new SingleEventDef(new EventSource(calendar)); + var dummyInstance; + + dummyEvent.dateProfile = eventDateProfile; + dummyInstance = dummyEvent.buildInstance(); + + return new EventFootprint(componentFootprint, dummyEvent, dummyInstance); + } + +}); + +;; + +var Component = Model.extend({ + + el: null, + + + setElement: function(el) { + this.el = el; + this.bindGlobalHandlers(); + this.renderSkeleton(); + this.set('isInDom', true); + }, + + + removeElement: function() { + this.unset('isInDom'); + this.unrenderSkeleton(); + this.unbindGlobalHandlers(); + + this.el.remove(); + // NOTE: don't null-out this.el in case the View was destroyed within an API callback. + // We don't null-out the View's other jQuery element references upon destroy, + // so we shouldn't kill this.el either. + }, + + + bindGlobalHandlers: function() { + }, + + + unbindGlobalHandlers: function() { + }, + + + /* + NOTE: Can't have a `render` method. Read the deprecation notice in View::executeDateRender + */ + + + // Renders the basic structure of the view before any content is rendered + renderSkeleton: function() { + // subclasses should implement + }, + + + // Unrenders the basic structure of the view + unrenderSkeleton: function() { + // subclasses should implement + } + +}); + +;; + +var DateComponent = FC.DateComponent = Component.extend({ + + uid: null, + childrenByUid: null, + isRTL: false, // frequently accessed options + nextDayThreshold: null, // " + dateProfile: null, // hack + + eventRendererClass: null, + helperRendererClass: null, + businessHourRendererClass: null, + fillRendererClass: null, + + eventRenderer: null, + helperRenderer: null, + businessHourRenderer: null, + fillRenderer: null, + + hitsNeededDepth: 0, // necessary because multiple callers might need the same hits + + hasAllDayBusinessHours: false, // TODO: unify with largeUnit and isTimeScale? + + isDatesRendered: false, + + + constructor: function() { + Component.call(this); + + this.uid = String(DateComponent.guid++); + this.childrenByUid = {}; + + this.nextDayThreshold = moment.duration(this.opt('nextDayThreshold')); + this.isRTL = this.opt('isRTL'); + + if (this.fillRendererClass) { + this.fillRenderer = new this.fillRendererClass(this); + } + + if (this.eventRendererClass) { // fillRenderer is optional -----v + this.eventRenderer = new this.eventRendererClass(this, this.fillRenderer); + } + + if (this.helperRendererClass && this.eventRenderer) { + this.helperRenderer = new this.helperRendererClass(this, this.eventRenderer); + } + + if (this.businessHourRendererClass && this.fillRenderer) { + this.businessHourRenderer = new this.businessHourRendererClass(this, this.fillRenderer); + } + }, + + + addChild: function(child) { + if (!this.childrenByUid[child.uid]) { + this.childrenByUid[child.uid] = child; + + return true; + } + + return false; + }, + + + removeChild: function(child) { + if (this.childrenByUid[child.uid]) { + delete this.childrenByUid[child.uid]; + + return true; + } + + return false; + }, + + + // TODO: only do if isInDom? + // TODO: make part of Component, along with children/batch-render system? + updateSize: function(totalHeight, isAuto, isResize) { + this.callChildren('updateSize', arguments); + }, + + + // Options + // ----------------------------------------------------------------------------------------------------------------- + + + opt: function(name) { + return this._getView().opt(name); // default implementation + }, + + + publiclyTrigger: function(/**/) { + var calendar = this._getCalendar(); + + return calendar.publiclyTrigger.apply(calendar, arguments); + }, + + + hasPublicHandlers: function(/**/) { + var calendar = this._getCalendar(); + + return calendar.hasPublicHandlers.apply(calendar, arguments); + }, + + + // Date + // ----------------------------------------------------------------------------------------------------------------- + + + executeDateRender: function(dateProfile) { + this.dateProfile = dateProfile; // for rendering + this.renderDates(dateProfile); + this.isDatesRendered = true; + this.callChildren('executeDateRender', arguments); + }, + + + executeDateUnrender: function() { // wrapper + this.callChildren('executeDateUnrender', arguments); + this.dateProfile = null; + this.unrenderDates(); + this.isDatesRendered = false; + }, + + + // date-cell content only + renderDates: function(dateProfile) { + // subclasses should implement + }, + + + // date-cell content only + unrenderDates: function() { + // subclasses should override + }, + + + // Now-Indicator + // ----------------------------------------------------------------------------------------------------------------- + + + // Returns a string unit, like 'second' or 'minute' that defined how often the current time indicator + // should be refreshed. If something falsy is returned, no time indicator is rendered at all. + getNowIndicatorUnit: function() { + // subclasses should implement + }, + + + // Renders a current time indicator at the given datetime + renderNowIndicator: function(date) { + this.callChildren('renderNowIndicator', arguments); + }, + + + // Undoes the rendering actions from renderNowIndicator + unrenderNowIndicator: function() { + this.callChildren('unrenderNowIndicator', arguments); + }, + + + // Business Hours + // --------------------------------------------------------------------------------------------------------------- + + + renderBusinessHours: function(businessHourGenerator) { + if (this.businessHourRenderer) { + this.businessHourRenderer.render(businessHourGenerator); + } + + this.callChildren('renderBusinessHours', arguments); + }, + + + // Unrenders previously-rendered business-hours + unrenderBusinessHours: function() { + this.callChildren('unrenderBusinessHours', arguments); + + if (this.businessHourRenderer) { + this.businessHourRenderer.unrender(); + } + }, + + + // Event Displaying + // ----------------------------------------------------------------------------------------------------------------- + + + executeEventRender: function(eventsPayload) { + if (this.eventRenderer) { + this.eventRenderer.rangeUpdated(); // poorly named now + this.eventRenderer.render(eventsPayload); + } + else if (this.renderEvents) { // legacy + this.renderEvents(convertEventsPayloadToLegacyArray(eventsPayload)); + } + + this.callChildren('executeEventRender', arguments); + }, + + + executeEventUnrender: function() { + this.callChildren('executeEventUnrender', arguments); + + if (this.eventRenderer) { + this.eventRenderer.unrender(); + } + else if (this.destroyEvents) { // legacy + this.destroyEvents(); + } + }, + + + getBusinessHourSegs: function() { // recursive + var segs = this.getOwnBusinessHourSegs(); + + this.iterChildren(function(child) { + segs.push.apply(segs, child.getBusinessHourSegs()); + }); + + return segs; + }, + + + getOwnBusinessHourSegs: function() { + if (this.businessHourRenderer) { + return this.businessHourRenderer.getSegs(); + } + + return []; + }, + + + getEventSegs: function() { // recursive + var segs = this.getOwnEventSegs(); + + this.iterChildren(function(child) { + segs.push.apply(segs, child.getEventSegs()); + }); + + return segs; + }, + + + getOwnEventSegs: function() { // just for itself + if (this.eventRenderer) { + return this.eventRenderer.getSegs(); + } + + return []; + }, + + + // Event Rendering Triggering + // ----------------------------------------------------------------------------------------------------------------- + + + triggerAfterEventsRendered: function() { + this.triggerAfterEventSegsRendered( + this.getEventSegs() + ); + + this.publiclyTrigger('eventAfterAllRender', { + context: this, + args: [ this ] + }); + }, + + + triggerAfterEventSegsRendered: function(segs) { + var _this = this; + + // an optimization, because getEventLegacy is expensive + if (this.hasPublicHandlers('eventAfterRender')) { + segs.forEach(function(seg) { + var legacy; + + if (seg.el) { // necessary? + legacy = seg.footprint.getEventLegacy(); + + _this.publiclyTrigger('eventAfterRender', { + context: legacy, + args: [ legacy, seg.el, _this ] + }); + } + }); + } + }, + + + triggerBeforeEventsDestroyed: function() { + this.triggerBeforeEventSegsDestroyed( + this.getEventSegs() + ); + }, + + + triggerBeforeEventSegsDestroyed: function(segs) { + var _this = this; + + if (this.hasPublicHandlers('eventDestroy')) { + segs.forEach(function(seg) { + var legacy; + + if (seg.el) { // necessary? + legacy = seg.footprint.getEventLegacy(); + + _this.publiclyTrigger('eventDestroy', { + context: legacy, + args: [ legacy, seg.el, _this ] + }); + } + }); + } + }, + + + // Event Rendering Utils + // ----------------------------------------------------------------------------------------------------------------- + + + // Hides all rendered event segments linked to the given event + // RECURSIVE with subcomponents + showEventsWithId: function(eventDefId) { + + this.getEventSegs().forEach(function(seg) { + if ( + seg.footprint.eventDef.id === eventDefId && + seg.el // necessary? + ) { + seg.el.css('visibility', ''); + } + }); + + this.callChildren('showEventsWithId', arguments); + }, + + + // Shows all rendered event segments linked to the given event + // RECURSIVE with subcomponents + hideEventsWithId: function(eventDefId) { + + this.getEventSegs().forEach(function(seg) { + if ( + seg.footprint.eventDef.id === eventDefId && + seg.el // necessary? + ) { + seg.el.css('visibility', 'hidden'); + } + }); + + this.callChildren('hideEventsWithId', arguments); + }, + + + // Drag-n-Drop Rendering (for both events and external elements) + // --------------------------------------------------------------------------------------------------------------- + + + // Renders a visual indication of a event or external-element drag over the given drop zone. + // If an external-element, seg will be `null`. + // Must return elements used for any mock events. + renderDrag: function(eventFootprints, seg, isTouch) { + var renderedHelper = false; + + this.iterChildren(function(child) { + if (child.renderDrag(eventFootprints, seg, isTouch)) { + renderedHelper = true; + } + }); + + return renderedHelper; + }, + + + // Unrenders a visual indication of an event or external-element being dragged. + unrenderDrag: function() { + this.callChildren('unrenderDrag', arguments); + }, + + + // Event Resizing + // --------------------------------------------------------------------------------------------------------------- + + + // Renders a visual indication of an event being resized. + renderEventResize: function(eventFootprints, seg, isTouch) { + this.callChildren('renderEventResize', arguments); + }, + + + // Unrenders a visual indication of an event being resized. + unrenderEventResize: function() { + this.callChildren('unrenderEventResize', arguments); + }, + + + // Selection + // --------------------------------------------------------------------------------------------------------------- + + + // Renders a visual indication of the selection + // TODO: rename to `renderSelection` after legacy is gone + renderSelectionFootprint: function(componentFootprint) { + this.renderHighlight(componentFootprint); + + this.callChildren('renderSelectionFootprint', arguments); + }, + + + // Unrenders a visual indication of selection + unrenderSelection: function() { + this.unrenderHighlight(); + + this.callChildren('unrenderSelection', arguments); + }, + + + // Highlight + // --------------------------------------------------------------------------------------------------------------- + + + // Renders an emphasis on the given date range. Given a span (unzoned start/end and other misc data) + renderHighlight: function(componentFootprint) { + if (this.fillRenderer) { + this.fillRenderer.renderFootprint( + 'highlight', + componentFootprint, + { + getClasses: function() { + return [ 'fc-highlight' ]; + } + } + ); + } + + this.callChildren('renderHighlight', arguments); + }, + + + // Unrenders the emphasis on a date range + unrenderHighlight: function() { + if (this.fillRenderer) { + this.fillRenderer.unrender('highlight'); + } + + this.callChildren('unrenderHighlight', arguments); + }, + + + // Hit Areas + // --------------------------------------------------------------------------------------------------------------- + // just because all DateComponents support this interface + // doesn't mean they need to have their own internal coord system. they can defer to sub-components. + + + hitsNeeded: function() { + if (!(this.hitsNeededDepth++)) { + this.prepareHits(); + } + + this.callChildren('hitsNeeded', arguments); + }, + + + hitsNotNeeded: function() { + if (this.hitsNeededDepth && !(--this.hitsNeededDepth)) { + this.releaseHits(); + } + + this.callChildren('hitsNotNeeded', arguments); + }, + + + prepareHits: function() { + // subclasses can implement + }, + + + releaseHits: function() { + // subclasses can implement + }, + + + // Given coordinates from the topleft of the document, return data about the date-related area underneath. + // Can return an object with arbitrary properties (although top/right/left/bottom are encouraged). + // Must have a `grid` property, a reference to this current grid. TODO: avoid this + // The returned object will be processed by getHitFootprint and getHitEl. + queryHit: function(leftOffset, topOffset) { + var childrenByUid = this.childrenByUid; + var uid; + var hit; + + for (uid in childrenByUid) { + hit = childrenByUid[uid].queryHit(leftOffset, topOffset); + + if (hit) { + break; + } + } + + return hit; + }, + + + getSafeHitFootprint: function(hit) { + var footprint = this.getHitFootprint(hit); + + if (!this.dateProfile.activeUnzonedRange.containsRange(footprint.unzonedRange)) { + return null; + } + + return footprint; + }, + + + getHitFootprint: function(hit) { + }, + + + // Given position-level information about a date-related area within the grid, + // should return a jQuery element that best represents it. passed to dayClick callback. + getHitEl: function(hit) { + }, + + + /* Converting eventRange -> eventFootprint + ------------------------------------------------------------------------------------------------------------------*/ + + + eventRangesToEventFootprints: function(eventRanges) { + var eventFootprints = []; + var i; + + for (i = 0; i < eventRanges.length; i++) { + eventFootprints.push.apply( // append + eventFootprints, + this.eventRangeToEventFootprints(eventRanges[i]) + ); + } + + return eventFootprints; + }, + + + eventRangeToEventFootprints: function(eventRange) { + return [ eventRangeToEventFootprint(eventRange) ]; + }, + + + /* Converting componentFootprint/eventFootprint -> segs + ------------------------------------------------------------------------------------------------------------------*/ + + + eventFootprintsToSegs: function(eventFootprints) { + var segs = []; + var i; + + for (i = 0; i < eventFootprints.length; i++) { + segs.push.apply(segs, + this.eventFootprintToSegs(eventFootprints[i]) + ); + } + + return segs; + }, + + + // Given an event's span (unzoned start/end and other misc data), and the event itself, + // slices into segments and attaches event-derived properties to them. + // eventSpan - { start, end, isStart, isEnd, otherthings... } + eventFootprintToSegs: function(eventFootprint) { + var unzonedRange = eventFootprint.componentFootprint.unzonedRange; + var segs; + var i, seg; + + segs = this.componentFootprintToSegs(eventFootprint.componentFootprint); + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + + if (!unzonedRange.isStart) { + seg.isStart = false; + } + if (!unzonedRange.isEnd) { + seg.isEnd = false; + } + + seg.footprint = eventFootprint; + // TODO: rename to seg.eventFootprint + } + + return segs; + }, + + + componentFootprintToSegs: function(componentFootprint) { + return []; + }, + + + // Utils + // --------------------------------------------------------------------------------------------------------------- + + + callChildren: function(methodName, args) { + this.iterChildren(function(child) { + child[methodName].apply(child, args); + }); + }, + + + iterChildren: function(func) { + var childrenByUid = this.childrenByUid; + var uid; + + for (uid in childrenByUid) { + func(childrenByUid[uid]); + } + }, + + + _getCalendar: function() { // TODO: strip out. move to generic parent. + return this.calendar || this.view.calendar; + }, + + + _getView: function() { // TODO: strip out. move to generic parent. + return this.view; + }, + + + _getDateProfile: function() { + return this._getView().get('dateProfile'); + } + +}); + + +DateComponent.guid = 0; // TODO: better system for this? + + +// legacy + +function convertEventsPayloadToLegacyArray(eventsPayload) { + var eventDefId; + var eventInstances; + var legacyEvents = []; + var i; + + for (eventDefId in eventsPayload) { + eventInstances = eventsPayload[eventDefId].eventInstances; + + for (i = 0; i < eventInstances.length; i++) { + legacyEvents.push( + eventInstances[i].toLegacy() + ); + } + } + + return legacyEvents; +} + +;; + +DateComponent.mixin({ + + // Generates HTML for an anchor to another view into the calendar. + // Will either generate an
tag or a non-clickable tag, depending on enabled settings. + // `gotoOptions` can either be a moment input, or an object with the form: + // { date, type, forceOff } + // `type` is a view-type like "day" or "week". default value is "day". + // `attrs` and `innerHtml` are use to generate the rest of the HTML tag. + buildGotoAnchorHtml: function(gotoOptions, attrs, innerHtml) { + var date, type, forceOff; + var finalOptions; + + if ($.isPlainObject(gotoOptions)) { + date = gotoOptions.date; + type = gotoOptions.type; + forceOff = gotoOptions.forceOff; + } + else { + date = gotoOptions; // a single moment input + } + date = FC.moment(date); // if a string, parse it + + finalOptions = { // for serialization into the link + date: date.format('YYYY-MM-DD'), + type: type || 'day' + }; + + if (typeof attrs === 'string') { + innerHtml = attrs; + attrs = null; + } + + attrs = attrs ? ' ' + attrsToStr(attrs) : ''; // will have a leading space + innerHtml = innerHtml || ''; + + if (!forceOff && this.opt('navLinks')) { + return '' + + innerHtml + + ''; + } + else { + return '' + + innerHtml + + ''; + } + }, + + + getAllDayHtml: function() { + return this.opt('allDayHtml') || htmlEscape(this.opt('allDayText')); + }, + + + // Computes HTML classNames for a single-day element + getDayClasses: function(date, noThemeHighlight) { + var view = this._getView(); + var classes = []; + var today; + + if (!this.dateProfile.activeUnzonedRange.containsDate(date)) { + classes.push('fc-disabled-day'); // TODO: jQuery UI theme? + } + else { + classes.push('fc-' + dayIDs[date.day()]); + + if (view.isDateInOtherMonth(date, this.dateProfile)) { // TODO: use DateComponent subclass somehow + classes.push('fc-other-month'); + } + + today = view.calendar.getNow(); + + if (date.isSame(today, 'day')) { + classes.push('fc-today'); + + if (noThemeHighlight !== true) { + classes.push(view.calendar.theme.getClass('today')); + } + } + else if (date < today) { + classes.push('fc-past'); + } + else { + classes.push('fc-future'); + } + } + + return classes; + }, + + + // Utility for formatting a range. Accepts a range object, formatting string, and optional separator. + // Displays all-day ranges naturally, with an inclusive end. Takes the current isRTL into account. + // The timezones of the dates within `range` will be respected. + formatRange: function(range, isAllDay, formatStr, separator) { + var end = range.end; + + if (isAllDay) { + end = end.clone().subtract(1); // convert to inclusive. last ms of previous day + } + + return formatRange(range.start, end, formatStr, separator, this.isRTL); + }, + + + // Compute the number of the give units in the "current" range. + // Will return a floating-point number. Won't round. + currentRangeAs: function(unit) { + return this._getDateProfile().currentUnzonedRange.as(unit); + }, + + + // Returns the date range of the full days the given range visually appears to occupy. + // Returns a plain object with start/end, NOT an UnzonedRange! + computeDayRange: function(unzonedRange) { + var calendar = this._getCalendar(); + var startDay = calendar.msToUtcMoment(unzonedRange.startMs, true); // the beginning of the day the range starts + var end = calendar.msToUtcMoment(unzonedRange.endMs); + var endTimeMS = +end.time(); // # of milliseconds into `endDay` + var endDay = end.clone().stripTime(); // the beginning of the day the range exclusively ends + + // If the end time is actually inclusively part of the next day and is equal to or + // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`. + // Otherwise, leaving it as inclusive will cause it to exclude `endDay`. + if (endTimeMS && endTimeMS >= this.nextDayThreshold) { + endDay.add(1, 'days'); + } + + // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day. + if (endDay <= startDay) { + endDay = startDay.clone().add(1, 'days'); + } + + return { start: startDay, end: endDay }; + }, + + + // Does the given range visually appear to occupy more than one day? + isMultiDayRange: function(unzonedRange) { + var dayRange = this.computeDayRange(unzonedRange); + + return dayRange.end.diff(dayRange.start, 'days') > 1; + } + +}); + +;; + +var InteractiveDateComponent = FC.InteractiveDateComponent = DateComponent.extend({ + + dateClickingClass: null, + dateSelectingClass: null, + eventPointingClass: null, + eventDraggingClass: null, + eventResizingClass: null, + externalDroppingClass: null, + + dateClicking: null, + dateSelecting: null, + eventPointing: null, + eventDragging: null, + eventResizing: null, + externalDropping: null, + + // self-config, overridable by subclasses + segSelector: '.fc-event-container > *', // what constitutes an event element? + + // if defined, holds the unit identified (ex: "year" or "month") that determines the level of granularity + // of the date areas. if not defined, assumes to be day and time granularity. + // TODO: port isTimeScale into same system? + largeUnit: null, + + + constructor: function() { + DateComponent.call(this); + + if (this.dateSelectingClass) { + this.dateClicking = new this.dateClickingClass(this); + } + + if (this.dateSelectingClass) { + this.dateSelecting = new this.dateSelectingClass(this); + } + + if (this.eventPointingClass) { + this.eventPointing = new this.eventPointingClass(this); + } + + if (this.eventDraggingClass && this.eventPointing) { + this.eventDragging = new this.eventDraggingClass(this, this.eventPointing); + } + + if (this.eventResizingClass && this.eventPointing) { + this.eventResizing = new this.eventResizingClass(this, this.eventPointing); + } + + if (this.externalDroppingClass) { + this.externalDropping = new this.externalDroppingClass(this); + } + }, + + + // Sets the container element that the view should render inside of, does global DOM-related initializations, + // and renders all the non-date-related content inside. + setElement: function(el) { + DateComponent.prototype.setElement.apply(this, arguments); + + if (this.dateClicking) { + this.dateClicking.bindToEl(el); + } + + if (this.dateSelecting) { + this.dateSelecting.bindToEl(el); + } + + this.bindAllSegHandlersToEl(el); + }, + + + unrender: function() { + this.endInteractions(); + + DateComponent.prototype.unrender.apply(this, arguments); + }, + + + executeEventUnrender: function() { + this.endInteractions(); + + DateComponent.prototype.executeEventUnrender.apply(this, arguments); + }, + + + bindGlobalHandlers: function() { + DateComponent.prototype.bindGlobalHandlers.apply(this, arguments); + + if (this.externalDropping) { + this.externalDropping.bindToDocument(); + } + }, + + + unbindGlobalHandlers: function() { + DateComponent.prototype.unbindGlobalHandlers.apply(this, arguments); + + if (this.externalDropping) { + this.externalDropping.unbindFromDocument(); + } + }, + + + bindDateHandlerToEl: function(el, name, handler) { + var _this = this; + + // attach a handler to the grid's root element. + // jQuery will take care of unregistering them when removeElement gets called. + this.el.on(name, function(ev) { + if ( + !$(ev.target).is( + _this.segSelector + ',' + // directly on an event element + _this.segSelector + ' *,' + // within an event element + '.fc-more,' + // a "more.." link + 'a[data-goto]' // a clickable nav link + ) + ) { + return handler.call(_this, ev); + } + }); + }, + + + bindAllSegHandlersToEl: function(el) { + [ + this.eventPointing, + this.eventDragging, + this.eventResizing + ].forEach(function(eventInteraction) { + if (eventInteraction) { + eventInteraction.bindToEl(el); + } + }); + }, + + + bindSegHandlerToEl: function(el, name, handler) { + var _this = this; + + el.on(name, this.segSelector, function(ev) { + var seg = $(this).data('fc-seg'); // grab segment data. put there by View::renderEventsPayload + + if (seg && !_this.shouldIgnoreEventPointing()) { + return handler.call(_this, seg, ev); // context will be the Grid + } + }); + }, + + + shouldIgnoreMouse: function() { + // HACK + // This will still work even though bindDateHandlerToEl doesn't use GlobalEmitter. + return GlobalEmitter.get().shouldIgnoreMouse(); + }, + + + shouldIgnoreTouch: function() { + var view = this._getView(); + + // On iOS (and Android?) when a new selection is initiated overtop another selection, + // the touchend never fires because the elements gets removed mid-touch-interaction (my theory). + // HACK: simply don't allow this to happen. + // ALSO: prevent selection when an *event* is already raised. + return view.isSelected || view.selectedEvent; + }, + + + shouldIgnoreEventPointing: function() { + // only call the handlers if there is not a drag/resize in progress + return (this.eventDragging && this.eventDragging.isDragging) || + (this.eventResizing && this.eventResizing.isResizing); + }, + + + canStartSelection: function(seg, ev) { + return getEvIsTouch(ev) && + !this.canStartResize(seg, ev) && + (this.isEventDefDraggable(seg.footprint.eventDef) || + this.isEventDefResizable(seg.footprint.eventDef)); + }, + + + canStartDrag: function(seg, ev) { + return !this.canStartResize(seg, ev) && + this.isEventDefDraggable(seg.footprint.eventDef); + }, + + + canStartResize: function(seg, ev) { + var view = this._getView(); + var eventDef = seg.footprint.eventDef; + + return (!getEvIsTouch(ev) || view.isEventDefSelected(eventDef)) && + this.isEventDefResizable(eventDef) && + $(ev.target).is('.fc-resizer'); + }, + + + // Kills all in-progress dragging. + // Useful for when public API methods that result in re-rendering are invoked during a drag. + // Also useful for when touch devices misbehave and don't fire their touchend. + endInteractions: function() { + [ + this.dateClicking, + this.dateSelecting, + this.eventPointing, + this.eventDragging, + this.eventResizing + ].forEach(function(interaction) { + if (interaction) { + interaction.end(); + } + }); + }, + + + // Event Drag-n-Drop + // --------------------------------------------------------------------------------------------------------------- + + + // Computes if the given event is allowed to be dragged by the user + isEventDefDraggable: function(eventDef) { + return this.isEventDefStartEditable(eventDef); + }, + + + isEventDefStartEditable: function(eventDef) { + var isEditable = eventDef.isStartExplicitlyEditable(); + + if (isEditable == null) { + isEditable = this.opt('eventStartEditable'); + + if (isEditable == null) { + isEditable = this.isEventDefGenerallyEditable(eventDef); + } + } + + return isEditable; + }, + + + isEventDefGenerallyEditable: function(eventDef) { + var isEditable = eventDef.isExplicitlyEditable(); + + if (isEditable == null) { + isEditable = this.opt('editable'); + } + + return isEditable; + }, + + + // Event Resizing + // --------------------------------------------------------------------------------------------------------------- + + + // Computes if the given event is allowed to be resized from its starting edge + isEventDefResizableFromStart: function(eventDef) { + return this.opt('eventResizableFromStart') && this.isEventDefResizable(eventDef); + }, + + + // Computes if the given event is allowed to be resized from its ending edge + isEventDefResizableFromEnd: function(eventDef) { + return this.isEventDefResizable(eventDef); + }, + + + // Computes if the given event is allowed to be resized by the user at all + isEventDefResizable: function(eventDef) { + var isResizable = eventDef.isDurationExplicitlyEditable(); + + if (isResizable == null) { + isResizable = this.opt('eventDurationEditable'); + + if (isResizable == null) { + isResizable = this.isEventDefGenerallyEditable(eventDef); + } + } + return isResizable; + }, + + + // Event Mutation / Constraints + // --------------------------------------------------------------------------------------------------------------- + + + // Diffs the two dates, returning a duration, based on granularity of the grid + // TODO: port isTimeScale into this system? + diffDates: function(a, b) { + if (this.largeUnit) { + return diffByUnit(a, b, this.largeUnit); + } + else { + return diffDayTime(a, b); + } + }, + + + // is it allowed, in relation to the view's validRange? + // NOTE: very similar to isExternalInstanceGroupAllowed + isEventInstanceGroupAllowed: function(eventInstanceGroup) { + var view = this._getView(); + var dateProfile = this.dateProfile; + var eventFootprints = this.eventRangesToEventFootprints(eventInstanceGroup.getAllEventRanges()); + var i; + + for (i = 0; i < eventFootprints.length; i++) { + // TODO: just use getAllEventRanges directly + if (!dateProfile.validUnzonedRange.containsRange(eventFootprints[i].componentFootprint.unzonedRange)) { + return false; + } + } + + return view.calendar.isEventInstanceGroupAllowed(eventInstanceGroup); + }, + + + // NOTE: very similar to isEventInstanceGroupAllowed + // when it's a completely anonymous external drag, no event. + isExternalInstanceGroupAllowed: function(eventInstanceGroup) { + var view = this._getView(); + var dateProfile = this.dateProfile; + var eventFootprints = this.eventRangesToEventFootprints(eventInstanceGroup.getAllEventRanges()); + var i; + + for (i = 0; i < eventFootprints.length; i++) { + if (!dateProfile.validUnzonedRange.containsRange(eventFootprints[i].componentFootprint.unzonedRange)) { + return false; + } + } + + for (i = 0; i < eventFootprints.length; i++) { + // treat it as a selection + // TODO: pass in eventInstanceGroup instead + // because we don't want calendar's constraint system to depend on a component's + // determination of footprints. + if (!view.calendar.isSelectionFootprintAllowed(eventFootprints[i].componentFootprint)) { + return false; + } + } + + return true; + } + +}); + +;; + +/* +A set of rendering and date-related methods for a visual component comprised of one or more rows of day columns. +Prerequisite: the object being mixed into needs to be a *Grid* +*/ +var DayTableMixin = FC.DayTableMixin = { + + breakOnWeeks: false, // should create a new row for each week? + dayDates: null, // whole-day dates for each column. left to right + dayIndices: null, // for each day from start, the offset + daysPerRow: null, + rowCnt: null, + colCnt: null, + colHeadFormat: null, + + + // Populates internal variables used for date calculation and rendering + updateDayTable: function() { + var view = this.view; + var calendar = view.calendar; + var date = calendar.msToUtcMoment(this.dateProfile.renderUnzonedRange.startMs, true); + var end = calendar.msToUtcMoment(this.dateProfile.renderUnzonedRange.endMs, true); + var dayIndex = -1; + var dayIndices = []; + var dayDates = []; + var daysPerRow; + var firstDay; + var rowCnt; + + while (date.isBefore(end)) { // loop each day from start to end + if (view.isHiddenDay(date)) { + dayIndices.push(dayIndex + 0.5); // mark that it's between indices + } + else { + dayIndex++; + dayIndices.push(dayIndex); + dayDates.push(date.clone()); + } + date.add(1, 'days'); + } + + if (this.breakOnWeeks) { + // count columns until the day-of-week repeats + firstDay = dayDates[0].day(); + for (daysPerRow = 1; daysPerRow < dayDates.length; daysPerRow++) { + if (dayDates[daysPerRow].day() == firstDay) { + break; + } + } + rowCnt = Math.ceil(dayDates.length / daysPerRow); + } + else { + rowCnt = 1; + daysPerRow = dayDates.length; + } + + this.dayDates = dayDates; + this.dayIndices = dayIndices; + this.daysPerRow = daysPerRow; + this.rowCnt = rowCnt; + + this.updateDayTableCols(); + }, + + + // Computes and assigned the colCnt property and updates any options that may be computed from it + updateDayTableCols: function() { + this.colCnt = this.computeColCnt(); + this.colHeadFormat = this.opt('columnFormat') || this.computeColHeadFormat(); + }, + + + // Determines how many columns there should be in the table + computeColCnt: function() { + return this.daysPerRow; + }, + + + // Computes the ambiguously-timed moment for the given cell + getCellDate: function(row, col) { + return this.dayDates[ + this.getCellDayIndex(row, col) + ].clone(); + }, + + + // Computes the ambiguously-timed date range for the given cell + getCellRange: function(row, col) { + var start = this.getCellDate(row, col); + var end = start.clone().add(1, 'days'); + + return { start: start, end: end }; + }, + + + // Returns the number of day cells, chronologically, from the first of the grid (0-based) + getCellDayIndex: function(row, col) { + return row * this.daysPerRow + this.getColDayIndex(col); + }, + + + // Returns the numner of day cells, chronologically, from the first cell in *any given row* + getColDayIndex: function(col) { + if (this.isRTL) { + return this.colCnt - 1 - col; + } + else { + return col; + } + }, + + + // Given a date, returns its chronolocial cell-index from the first cell of the grid. + // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets. + // If before the first offset, returns a negative number. + // If after the last offset, returns an offset past the last cell offset. + // Only works for *start* dates of cells. Will not work for exclusive end dates for cells. + getDateDayIndex: function(date) { + var dayIndices = this.dayIndices; + var dayOffset = date.diff(this.dayDates[0], 'days'); + + if (dayOffset < 0) { + return dayIndices[0] - 1; + } + else if (dayOffset >= dayIndices.length) { + return dayIndices[dayIndices.length - 1] + 1; + } + else { + return dayIndices[dayOffset]; + } + }, + + + /* Options + ------------------------------------------------------------------------------------------------------------------*/ + + + // Computes a default column header formatting string if `colFormat` is not explicitly defined + computeColHeadFormat: function() { + // if more than one week row, or if there are a lot of columns with not much space, + // put just the day numbers will be in each cell + if (this.rowCnt > 1 || this.colCnt > 10) { + return 'ddd'; // "Sat" + } + // multiple days, so full single date string WON'T be in title text + else if (this.colCnt > 1) { + return this.opt('dayOfMonthFormat'); // "Sat 12/10" + } + // single day, so full single date string will probably be in title text + else { + return 'dddd'; // "Saturday" + } + }, + + + /* Slicing + ------------------------------------------------------------------------------------------------------------------*/ + + + // Slices up a date range into a segment for every week-row it intersects with + sliceRangeByRow: function(unzonedRange) { + var daysPerRow = this.daysPerRow; + var normalRange = this.view.computeDayRange(unzonedRange); // make whole-day range, considering nextDayThreshold + var rangeFirst = this.getDateDayIndex(normalRange.start); // inclusive first index + var rangeLast = this.getDateDayIndex(normalRange.end.clone().subtract(1, 'days')); // inclusive last index + var segs = []; + var row; + var rowFirst, rowLast; // inclusive day-index range for current row + var segFirst, segLast; // inclusive day-index range for segment + + for (row = 0; row < this.rowCnt; row++) { + rowFirst = row * daysPerRow; + rowLast = rowFirst + daysPerRow - 1; + + // intersect segment's offset range with the row's + segFirst = Math.max(rangeFirst, rowFirst); + segLast = Math.min(rangeLast, rowLast); + + // deal with in-between indices + segFirst = Math.ceil(segFirst); // in-between starts round to next cell + segLast = Math.floor(segLast); // in-between ends round to prev cell + + if (segFirst <= segLast) { // was there any intersection with the current row? + segs.push({ + row: row, + + // normalize to start of row + firstRowDayIndex: segFirst - rowFirst, + lastRowDayIndex: segLast - rowFirst, + + // must be matching integers to be the segment's start/end + isStart: segFirst === rangeFirst, + isEnd: segLast === rangeLast + }); + } + } + + return segs; + }, + + + // Slices up a date range into a segment for every day-cell it intersects with. + // TODO: make more DRY with sliceRangeByRow somehow. + sliceRangeByDay: function(unzonedRange) { + var daysPerRow = this.daysPerRow; + var normalRange = this.view.computeDayRange(unzonedRange); // make whole-day range, considering nextDayThreshold + var rangeFirst = this.getDateDayIndex(normalRange.start); // inclusive first index + var rangeLast = this.getDateDayIndex(normalRange.end.clone().subtract(1, 'days')); // inclusive last index + var segs = []; + var row; + var rowFirst, rowLast; // inclusive day-index range for current row + var i; + var segFirst, segLast; // inclusive day-index range for segment + + for (row = 0; row < this.rowCnt; row++) { + rowFirst = row * daysPerRow; + rowLast = rowFirst + daysPerRow - 1; + + for (i = rowFirst; i <= rowLast; i++) { + + // intersect segment's offset range with the row's + segFirst = Math.max(rangeFirst, i); + segLast = Math.min(rangeLast, i); + + // deal with in-between indices + segFirst = Math.ceil(segFirst); // in-between starts round to next cell + segLast = Math.floor(segLast); // in-between ends round to prev cell + + if (segFirst <= segLast) { // was there any intersection with the current row? + segs.push({ + row: row, + + // normalize to start of row + firstRowDayIndex: segFirst - rowFirst, + lastRowDayIndex: segLast - rowFirst, + + // must be matching integers to be the segment's start/end + isStart: segFirst === rangeFirst, + isEnd: segLast === rangeLast + }); + } + } + } + + return segs; + }, + + + /* Header Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + renderHeadHtml: function() { + var theme = this.view.calendar.theme; + + return '' + + '
' + + '' + + '' + + this.renderHeadTrHtml() + + '' + + '
' + + '
'; + }, + + + renderHeadIntroHtml: function() { + return this.renderIntroHtml(); // fall back to generic + }, + + + renderHeadTrHtml: function() { + return '' + + '' + + (this.isRTL ? '' : this.renderHeadIntroHtml()) + + this.renderHeadDateCellsHtml() + + (this.isRTL ? this.renderHeadIntroHtml() : '') + + ''; + }, + + + renderHeadDateCellsHtml: function() { + var htmls = []; + var col, date; + + for (col = 0; col < this.colCnt; col++) { + date = this.getCellDate(0, col); + htmls.push(this.renderHeadDateCellHtml(date)); + } + + return htmls.join(''); + }, + + + // TODO: when internalApiVersion, accept an object for HTML attributes + // (colspan should be no different) + renderHeadDateCellHtml: function(date, colspan, otherAttrs) { + var view = this.view; + var isDateValid = this.dateProfile.activeUnzonedRange.containsDate(date); // TODO: called too frequently. cache somehow. + var classNames = [ + 'fc-day-header', + view.calendar.theme.getClass('widgetHeader') + ]; + var innerHtml = htmlEscape(date.format(this.colHeadFormat)); + + // if only one row of days, the classNames on the header can represent the specific days beneath + if (this.rowCnt === 1) { + classNames = classNames.concat( + // includes the day-of-week class + // noThemeHighlight=true (don't highlight the header) + this.getDayClasses(date, true) + ); + } + else { + classNames.push('fc-' + dayIDs[date.day()]); // only add the day-of-week class + } + + return '' + + ' 1 ? + ' colspan="' + colspan + '"' : + '') + + (otherAttrs ? + ' ' + otherAttrs : + '') + + '>' + + (isDateValid ? + // don't make a link if the heading could represent multiple days, or if there's only one day (forceOff) + view.buildGotoAnchorHtml( + { date: date, forceOff: this.rowCnt > 1 || this.colCnt === 1 }, + innerHtml + ) : + // if not valid, display text, but no link + innerHtml + ) + + ''; + }, + + + /* Background Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + renderBgTrHtml: function(row) { + return '' + + '' + + (this.isRTL ? '' : this.renderBgIntroHtml(row)) + + this.renderBgCellsHtml(row) + + (this.isRTL ? this.renderBgIntroHtml(row) : '') + + ''; + }, + + + renderBgIntroHtml: function(row) { + return this.renderIntroHtml(); // fall back to generic + }, + + + renderBgCellsHtml: function(row) { + var htmls = []; + var col, date; + + for (col = 0; col < this.colCnt; col++) { + date = this.getCellDate(row, col); + htmls.push(this.renderBgCellHtml(date)); + } + + return htmls.join(''); + }, + + + renderBgCellHtml: function(date, otherAttrs) { + var view = this.view; + var isDateValid = this.dateProfile.activeUnzonedRange.containsDate(date); // TODO: called too frequently. cache somehow. + var classes = this.getDayClasses(date); + + classes.unshift('fc-day', view.calendar.theme.getClass('widgetContent')); + + return ''; + }, + + + /* Generic + ------------------------------------------------------------------------------------------------------------------*/ + + + // Generates the default HTML intro for any row. User classes should override + renderIntroHtml: function() { + }, + + + // TODO: a generic method for dealing with , RTL, intro + // when increment internalApiVersion + // wrapTr (scheduler) + + + /* Utils + ------------------------------------------------------------------------------------------------------------------*/ + + + // Applies the generic "intro" and "outro" HTML to the given cells. + // Intro means the leftmost cell when the calendar is LTR and the rightmost cell when RTL. Vice-versa for outro. + bookendCells: function(trEl) { + var introHtml = this.renderIntroHtml(); + + if (introHtml) { + if (this.isRTL) { + trEl.append(introHtml); + } + else { + trEl.prepend(introHtml); + } + } + } + +}; + +;; + +/* An abstract class from which other views inherit from +----------------------------------------------------------------------------------------------------------------------*/ + +var View = FC.View = InteractiveDateComponent.extend({ + + type: null, // subclass' view name (string) + name: null, // deprecated. use `type` instead + title: null, // the text that will be displayed in the header's title + + calendar: null, // owner Calendar object + viewSpec: null, + options: null, // hash containing all options. already merged with view-specific-options + + renderQueue: null, + batchRenderDepth: 0, + queuedScroll: null, + + isSelected: false, // boolean whether a range of time is user-selected or not + selectedEventInstance: null, + + eventOrderSpecs: null, // criteria for ordering events when they have same date/time + + // for date utils, computed from options + isHiddenDayHash: null, + + // now indicator + isNowIndicatorRendered: null, + initialNowDate: null, // result first getNow call + initialNowQueriedMs: null, // ms time the getNow was called + nowIndicatorTimeoutID: null, // for refresh timing of now indicator + nowIndicatorIntervalID: null, // " + + constructor: function(calendar, viewSpec) { + this.calendar = calendar; + this.viewSpec = viewSpec; + + // shortcuts + this.type = viewSpec.type; + this.options = viewSpec.options; + + // .name is deprecated + this.name = this.type; + + InteractiveDateComponent.call(this); + + this.initRenderQueue(); + this.initHiddenDays(); + this.bindBaseRenderHandlers(); + this.eventOrderSpecs = parseFieldSpecs(this.opt('eventOrder')); + + // legacy + if (this.initialize) { + this.initialize(); + } + }, + + + _getView: function() { + return this; + }, + + + // Retrieves an option with the given name + opt: function(name) { + return this.options[name]; + }, + + + /* Render Queue + ------------------------------------------------------------------------------------------------------------------*/ + + + initRenderQueue: function() { + this.renderQueue = new RenderQueue({ + event: this.opt('eventRenderWait') + }); + + this.renderQueue.on('start', this.onRenderQueueStart.bind(this)); + this.renderQueue.on('stop', this.onRenderQueueStop.bind(this)); + + this.on('before:change', this.startBatchRender); + this.on('change', this.stopBatchRender); + }, + + + onRenderQueueStart: function() { + this.calendar.freezeContentHeight(); + this.addScroll(this.queryScroll()); + }, + + + onRenderQueueStop: function() { + if (this.calendar.updateViewSize()) { // success? + this.popScroll(); + } + this.calendar.thawContentHeight(); + }, + + + startBatchRender: function() { + if (!(this.batchRenderDepth++)) { + this.renderQueue.pause(); + } + }, + + + stopBatchRender: function() { + if (!(--this.batchRenderDepth)) { + this.renderQueue.resume(); + } + }, + + + requestRender: function(func, namespace, actionType) { + this.renderQueue.queue(func, namespace, actionType); + }, + + + // given func will auto-bind to `this` + whenSizeUpdated: function(func) { + if (this.renderQueue.isRunning) { + this.renderQueue.one('stop', func.bind(this)); + } + else { + func.call(this); + } + }, + + + /* Title and Date Formatting + ------------------------------------------------------------------------------------------------------------------*/ + + + // Computes what the title at the top of the calendar should be for this view + computeTitle: function(dateProfile) { + var unzonedRange; + + // for views that span a large unit of time, show the proper interval, ignoring stray days before and after + if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) { + unzonedRange = dateProfile.currentUnzonedRange; + } + else { // for day units or smaller, use the actual day range + unzonedRange = dateProfile.activeUnzonedRange; + } + + return this.formatRange( + { + start: this.calendar.msToMoment(unzonedRange.startMs, dateProfile.isRangeAllDay), + end: this.calendar.msToMoment(unzonedRange.endMs, dateProfile.isRangeAllDay) + }, + dateProfile.isRangeAllDay, + this.opt('titleFormat') || this.computeTitleFormat(dateProfile), + this.opt('titleRangeSeparator') + ); + }, + + + // Generates the format string that should be used to generate the title for the current date range. + // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`. + computeTitleFormat: function(dateProfile) { + var currentRangeUnit = dateProfile.currentRangeUnit; + + if (currentRangeUnit == 'year') { + return 'YYYY'; + } + else if (currentRangeUnit == 'month') { + return this.opt('monthYearFormat'); // like "September 2014" + } + else if (dateProfile.currentUnzonedRange.as('days') > 1) { + return 'll'; // multi-day range. shorter, like "Sep 9 - 10 2014" + } + else { + return 'LL'; // one day. longer, like "September 9 2014" + } + }, + + + // Date Setting/Unsetting + // ----------------------------------------------------------------------------------------------------------------- + + + setDate: function(date) { + var currentDateProfile = this.get('dateProfile'); + var newDateProfile = this.buildDateProfile(date, null, true); // forceToValid=true + + if ( + !currentDateProfile || + !currentDateProfile.activeUnzonedRange.equals(newDateProfile.activeUnzonedRange) + ) { + this.set('dateProfile', newDateProfile); + } + }, + + + unsetDate: function() { + this.unset('dateProfile'); + }, + + + // Event Data + // ----------------------------------------------------------------------------------------------------------------- + + + fetchInitialEvents: function(dateProfile) { + var calendar = this.calendar; + var forceAllDay = dateProfile.isRangeAllDay && !this.usesMinMaxTime; + + return calendar.requestEvents( + calendar.msToMoment(dateProfile.activeUnzonedRange.startMs, forceAllDay), + calendar.msToMoment(dateProfile.activeUnzonedRange.endMs, forceAllDay) + ); + }, + + + bindEventChanges: function() { + this.listenTo(this.calendar, 'eventsReset', this.resetEvents); // TODO: make this a real event + }, + + + unbindEventChanges: function() { + this.stopListeningTo(this.calendar, 'eventsReset'); + }, + + + setEvents: function(eventsPayload) { + this.set('currentEvents', eventsPayload); + this.set('hasEvents', true); + }, + + + unsetEvents: function() { + this.unset('currentEvents'); + this.unset('hasEvents'); + }, + + + resetEvents: function(eventsPayload) { + this.startBatchRender(); + this.unsetEvents(); + this.setEvents(eventsPayload); + this.stopBatchRender(); + }, + + + // Date High-level Rendering + // ----------------------------------------------------------------------------------------------------------------- + + + requestDateRender: function(dateProfile) { + var _this = this; + + this.requestRender(function() { + _this.executeDateRender(dateProfile); + }, 'date', 'init'); + }, + + + requestDateUnrender: function() { + var _this = this; + + this.requestRender(function() { + _this.executeDateUnrender(); + }, 'date', 'destroy'); + }, + + + // if dateProfile not specified, uses current + executeDateRender: function(dateProfile) { + DateComponent.prototype.executeDateRender.apply(this, arguments); + + if (this.render) { + this.render(); // TODO: deprecate + } + + this.trigger('datesRendered'); + this.addScroll({ isDateInit: true }); + this.startNowIndicator(); // shouldn't render yet because updateSize will be called soon + }, + + + executeDateUnrender: function() { + this.unselect(); + this.stopNowIndicator(); + this.trigger('before:datesUnrendered'); + + if (this.destroy) { + this.destroy(); // TODO: deprecate + } + + DateComponent.prototype.executeDateUnrender.apply(this, arguments); + }, + + + // "Base" rendering + // ----------------------------------------------------------------------------------------------------------------- + + + bindBaseRenderHandlers: function() { + var _this = this; + + this.on('datesRendered', function() { + _this.whenSizeUpdated( + _this.triggerViewRender + ); + }); + + this.on('before:datesUnrendered', function() { + _this.triggerViewDestroy(); + }); + }, + + + triggerViewRender: function() { + this.publiclyTrigger('viewRender', { + context: this, + args: [ this, this.el ] + }); + }, + + + triggerViewDestroy: function() { + this.publiclyTrigger('viewDestroy', { + context: this, + args: [ this, this.el ] + }); + }, + + + // Event High-level Rendering + // ----------------------------------------------------------------------------------------------------------------- + + + requestEventsRender: function(eventsPayload) { + var _this = this; + + this.requestRender(function() { + _this.executeEventRender(eventsPayload); + _this.whenSizeUpdated( + _this.triggerAfterEventsRendered + ); + }, 'event', 'init'); + }, + + + requestEventsUnrender: function() { + var _this = this; + + this.requestRender(function() { + _this.triggerBeforeEventsDestroyed(); + _this.executeEventUnrender(); + }, 'event', 'destroy'); + }, + + + // Business Hour High-level Rendering + // ----------------------------------------------------------------------------------------------------------------- + + + requestBusinessHoursRender: function(businessHourGenerator) { + var _this = this; + + this.requestRender(function() { + _this.renderBusinessHours(businessHourGenerator); + }, 'businessHours', 'init'); + }, + + requestBusinessHoursUnrender: function() { + var _this = this; + + this.requestRender(function() { + _this.unrenderBusinessHours(); + }, 'businessHours', 'destroy'); + }, + + + // Misc view rendering utils + // ----------------------------------------------------------------------------------------------------------------- + + + // Binds DOM handlers to elements that reside outside the view container, such as the document + bindGlobalHandlers: function() { + InteractiveDateComponent.prototype.bindGlobalHandlers.apply(this, arguments); + + this.listenTo(GlobalEmitter.get(), { + touchstart: this.processUnselect, + mousedown: this.handleDocumentMousedown + }); + }, + + + // Unbinds DOM handlers from elements that reside outside the view container + unbindGlobalHandlers: function() { + InteractiveDateComponent.prototype.unbindGlobalHandlers.apply(this, arguments); + + this.stopListeningTo(GlobalEmitter.get()); + }, + + + /* Now Indicator + ------------------------------------------------------------------------------------------------------------------*/ + + + // Immediately render the current time indicator and begins re-rendering it at an interval, + // which is defined by this.getNowIndicatorUnit(). + // TODO: somehow do this for the current whole day's background too + startNowIndicator: function() { + var _this = this; + var unit; + var update; + var delay; // ms wait value + + if (this.opt('nowIndicator')) { + unit = this.getNowIndicatorUnit(); + if (unit) { + update = proxy(this, 'updateNowIndicator'); // bind to `this` + + this.initialNowDate = this.calendar.getNow(); + this.initialNowQueriedMs = +new Date(); + + // wait until the beginning of the next interval + delay = this.initialNowDate.clone().startOf(unit).add(1, unit) - this.initialNowDate; + this.nowIndicatorTimeoutID = setTimeout(function() { + _this.nowIndicatorTimeoutID = null; + update(); + delay = +moment.duration(1, unit); + delay = Math.max(100, delay); // prevent too frequent + _this.nowIndicatorIntervalID = setInterval(update, delay); // update every interval + }, delay); + } + + // rendering will be initiated in updateSize + } + }, + + + // rerenders the now indicator, computing the new current time from the amount of time that has passed + // since the initial getNow call. + updateNowIndicator: function() { + if ( + this.isDatesRendered && + this.initialNowDate // activated before? + ) { + this.unrenderNowIndicator(); // won't unrender if unnecessary + this.renderNowIndicator( + this.initialNowDate.clone().add(new Date() - this.initialNowQueriedMs) // add ms + ); + this.isNowIndicatorRendered = true; + } + }, + + + // Immediately unrenders the view's current time indicator and stops any re-rendering timers. + // Won't cause side effects if indicator isn't rendered. + stopNowIndicator: function() { + if (this.isNowIndicatorRendered) { + + if (this.nowIndicatorTimeoutID) { + clearTimeout(this.nowIndicatorTimeoutID); + this.nowIndicatorTimeoutID = null; + } + if (this.nowIndicatorIntervalID) { + clearTimeout(this.nowIndicatorIntervalID); + this.nowIndicatorIntervalID = null; + } + + this.unrenderNowIndicator(); + this.isNowIndicatorRendered = false; + } + }, + + + /* Dimensions + ------------------------------------------------------------------------------------------------------------------*/ + + + updateSize: function(totalHeight, isAuto, isResize) { + + if (this.setHeight) { // for legacy API + this.setHeight(totalHeight, isAuto); + } + else { + InteractiveDateComponent.prototype.updateSize.apply(this, arguments); + } + + this.updateNowIndicator(); + }, + + + /* Scroller + ------------------------------------------------------------------------------------------------------------------*/ + + + addScroll: function(scroll) { + var queuedScroll = this.queuedScroll || (this.queuedScroll = {}); + + $.extend(queuedScroll, scroll); + }, + + + popScroll: function() { + this.applyQueuedScroll(); + this.queuedScroll = null; + }, + + + applyQueuedScroll: function() { + if (this.queuedScroll) { + this.applyScroll(this.queuedScroll); + } + }, + + + queryScroll: function() { + var scroll = {}; + + if (this.isDatesRendered) { + $.extend(scroll, this.queryDateScroll()); + } + + return scroll; + }, + + + applyScroll: function(scroll) { + if (scroll.isDateInit && this.isDatesRendered) { + $.extend(scroll, this.computeInitialDateScroll()); + } + + if (this.isDatesRendered) { + this.applyDateScroll(scroll); + } + }, + + + computeInitialDateScroll: function() { + return {}; // subclasses must implement + }, + + + queryDateScroll: function() { + return {}; // subclasses must implement + }, + + + applyDateScroll: function(scroll) { + ; // subclasses must implement + }, + + + /* Event Drag-n-Drop + ------------------------------------------------------------------------------------------------------------------*/ + + + reportEventDrop: function(eventInstance, eventMutation, el, ev) { + var eventManager = this.calendar.eventManager; + var undoFunc = eventManager.mutateEventsWithId( + eventInstance.def.id, + eventMutation, + this.calendar + ); + var dateMutation = eventMutation.dateMutation; + + // update the EventInstance, for handlers + if (dateMutation) { + eventInstance.dateProfile = dateMutation.buildNewDateProfile( + eventInstance.dateProfile, + this.calendar + ); + } + + this.triggerEventDrop( + eventInstance, + // a drop doesn't necessarily mean a date mutation (ex: resource change) + (dateMutation && dateMutation.dateDelta) || moment.duration(), + undoFunc, + el, ev + ); + }, + + + // Triggers event-drop handlers that have subscribed via the API + triggerEventDrop: function(eventInstance, dateDelta, undoFunc, el, ev) { + this.publiclyTrigger('eventDrop', { + context: el[0], + args: [ + eventInstance.toLegacy(), + dateDelta, + undoFunc, + ev, + {}, // {} = jqui dummy + this + ] + }); + }, + + + /* External Element Drag-n-Drop + ------------------------------------------------------------------------------------------------------------------*/ + + + // Must be called when an external element, via jQuery UI, has been dropped onto the calendar. + // `meta` is the parsed data that has been embedded into the dragging event. + // `dropLocation` is an object that contains the new zoned start/end/allDay values for the event. + reportExternalDrop: function(singleEventDef, isEvent, isSticky, el, ev, ui) { + + if (isEvent) { + this.calendar.eventManager.addEventDef(singleEventDef, isSticky); + } + + this.triggerExternalDrop(singleEventDef, isEvent, el, ev, ui); + }, + + + // Triggers external-drop handlers that have subscribed via the API + triggerExternalDrop: function(singleEventDef, isEvent, el, ev, ui) { + + // trigger 'drop' regardless of whether element represents an event + this.publiclyTrigger('drop', { + context: el[0], + args: [ + singleEventDef.dateProfile.start.clone(), + ev, + ui, + this + ] + }); + + if (isEvent) { + // signal an external event landed + this.publiclyTrigger('eventReceive', { + context: this, + args: [ + singleEventDef.buildInstance().toLegacy(), + this + ] + }); + } + }, + + + /* Event Resizing + ------------------------------------------------------------------------------------------------------------------*/ + + + // Must be called when an event in the view has been resized to a new length + reportEventResize: function(eventInstance, eventMutation, el, ev) { + var eventManager = this.calendar.eventManager; + var undoFunc = eventManager.mutateEventsWithId( + eventInstance.def.id, + eventMutation, + this.calendar + ); + + // update the EventInstance, for handlers + eventInstance.dateProfile = eventMutation.dateMutation.buildNewDateProfile( + eventInstance.dateProfile, + this.calendar + ); + + this.triggerEventResize( + eventInstance, + eventMutation.dateMutation.endDelta, + undoFunc, + el, ev + ); + }, + + + // Triggers event-resize handlers that have subscribed via the API + triggerEventResize: function(eventInstance, durationDelta, undoFunc, el, ev) { + this.publiclyTrigger('eventResize', { + context: el[0], + args: [ + eventInstance.toLegacy(), + durationDelta, + undoFunc, + ev, + {}, // {} = jqui dummy + this + ] + }); + }, + + + /* Selection (time range) + ------------------------------------------------------------------------------------------------------------------*/ + + + // Selects a date span on the view. `start` and `end` are both Moments. + // `ev` is the native mouse event that begin the interaction. + select: function(footprint, ev) { + this.unselect(ev); + this.renderSelectionFootprint(footprint); + this.reportSelection(footprint, ev); + }, + + + renderSelectionFootprint: function(footprint, ev) { + if (this.renderSelection) { // legacy method in custom view classes + this.renderSelection( + footprint.toLegacy(this.calendar) + ); + } + else { + InteractiveDateComponent.prototype.renderSelectionFootprint.apply(this, arguments); + } + }, + + + // Called when a new selection is made. Updates internal state and triggers handlers. + reportSelection: function(footprint, ev) { + this.isSelected = true; + this.triggerSelect(footprint, ev); + }, + + + // Triggers handlers to 'select' + triggerSelect: function(footprint, ev) { + var dateProfile = this.calendar.footprintToDateProfile(footprint); // abuse of "Event"DateProfile? + + this.publiclyTrigger('select', { + context: this, + args: [ + dateProfile.start, + dateProfile.end, + ev, + this + ] + }); + }, + + + // Undoes a selection. updates in the internal state and triggers handlers. + // `ev` is the native mouse event that began the interaction. + unselect: function(ev) { + if (this.isSelected) { + this.isSelected = false; + if (this.destroySelection) { + this.destroySelection(); // TODO: deprecate + } + this.unrenderSelection(); + this.publiclyTrigger('unselect', { + context: this, + args: [ ev, this ] + }); + } + }, + + + /* Event Selection + ------------------------------------------------------------------------------------------------------------------*/ + + + selectEventInstance: function(eventInstance) { + if ( + !this.selectedEventInstance || + this.selectedEventInstance !== eventInstance + ) { + this.unselectEventInstance(); + + this.getEventSegs().forEach(function(seg) { + if ( + seg.footprint.eventInstance === eventInstance && + seg.el // necessary? + ) { + seg.el.addClass('fc-selected'); + } + }); + + this.selectedEventInstance = eventInstance; + } + }, + + + unselectEventInstance: function() { + if (this.selectedEventInstance) { + + this.getEventSegs().forEach(function(seg) { + if (seg.el) { // necessary? + seg.el.removeClass('fc-selected'); + } + }); + + this.selectedEventInstance = null; + } + }, + + + isEventDefSelected: function(eventDef) { + // event references might change on refetchEvents(), while selectedEventInstance doesn't, + // so compare IDs + return this.selectedEventInstance && this.selectedEventInstance.def.id === eventDef.id; + }, + + + /* Mouse / Touch Unselecting (time range & event unselection) + ------------------------------------------------------------------------------------------------------------------*/ + // TODO: move consistently to down/start or up/end? + // TODO: don't kill previous selection if touch scrolling + + + handleDocumentMousedown: function(ev) { + if (isPrimaryMouseButton(ev)) { + this.processUnselect(ev); + } + }, + + + processUnselect: function(ev) { + this.processRangeUnselect(ev); + this.processEventUnselect(ev); + }, + + + processRangeUnselect: function(ev) { + var ignore; + + // is there a time-range selection? + if (this.isSelected && this.opt('unselectAuto')) { + // only unselect if the clicked element is not identical to or inside of an 'unselectCancel' element + ignore = this.opt('unselectCancel'); + if (!ignore || !$(ev.target).closest(ignore).length) { + this.unselect(ev); + } + } + }, + + + processEventUnselect: function(ev) { + if (this.selectedEventInstance) { + if (!$(ev.target).closest('.fc-selected').length) { + this.unselectEventInstance(); + } + } + }, + + + /* Triggers + ------------------------------------------------------------------------------------------------------------------*/ + + + triggerBaseRendered: function() { + this.publiclyTrigger('viewRender', { + context: this, + args: [ this, this.el ] + }); + }, + + + triggerBaseUnrendered: function() { + this.publiclyTrigger('viewDestroy', { + context: this, + args: [ this, this.el ] + }); + }, + + + // Triggers handlers to 'dayClick' + // Span has start/end of the clicked area. Only the start is useful. + triggerDayClick: function(footprint, dayEl, ev) { + var dateProfile = this.calendar.footprintToDateProfile(footprint); // abuse of "Event"DateProfile? + + this.publiclyTrigger('dayClick', { + context: dayEl, + args: [ dateProfile.start, ev, this ] + }); + } + +}); + + +View.watch('displayingDates', [ 'isInDom', 'dateProfile' ], function(deps) { + this.requestDateRender(deps.dateProfile); +}, function() { + this.requestDateUnrender(); +}); + + +View.watch('displayingBusinessHours', [ 'displayingDates', 'businessHourGenerator' ], function(deps) { + this.requestBusinessHoursRender(deps.businessHourGenerator); +}, function() { + this.requestBusinessHoursUnrender(); +}); + + +View.watch('initialEvents', [ 'dateProfile' ], function(deps) { + return this.fetchInitialEvents(deps.dateProfile); +}); + + +View.watch('bindingEvents', [ 'initialEvents' ], function(deps) { + this.setEvents(deps.initialEvents); + this.bindEventChanges(); +}, function() { + this.unbindEventChanges(); + this.unsetEvents(); +}); + + +View.watch('displayingEvents', [ 'displayingDates', 'hasEvents' ], function() { + this.requestEventsRender(this.get('currentEvents')); +}, function() { + this.requestEventsUnrender(); +}); + + +View.watch('title', [ 'dateProfile' ], function(deps) { + return (this.title = this.computeTitle(deps.dateProfile)); // assign to View for legacy reasons +}); + + +View.watch('legacyDateProps', [ 'dateProfile' ], function(deps) { + var calendar = this.calendar; + var dateProfile = deps.dateProfile; + + // DEPRECATED, but we need to keep it updated... + this.start = calendar.msToMoment(dateProfile.activeUnzonedRange.startMs, dateProfile.isRangeAllDay); + this.end = calendar.msToMoment(dateProfile.activeUnzonedRange.endMs, dateProfile.isRangeAllDay); + this.intervalStart = calendar.msToMoment(dateProfile.currentUnzonedRange.startMs, dateProfile.isRangeAllDay); + this.intervalEnd = calendar.msToMoment(dateProfile.currentUnzonedRange.endMs, dateProfile.isRangeAllDay); +}); + +;; + +View.mixin({ + + usesMinMaxTime: false, // whether minTime/maxTime will affect the activeUnzonedRange. Views must opt-in. + + // DEPRECATED + start: null, // use activeUnzonedRange + end: null, // use activeUnzonedRange + intervalStart: null, // use currentUnzonedRange + intervalEnd: null, // use currentUnzonedRange + + + /* Date Range Computation + ------------------------------------------------------------------------------------------------------------------*/ + + + // Builds a structure with info about what the dates/ranges will be for the "prev" view. + buildPrevDateProfile: function(date) { + var dateProfile = this.get('dateProfile'); + var prevDate = date.clone().startOf(dateProfile.currentRangeUnit) + .subtract(dateProfile.dateIncrement); + + return this.buildDateProfile(prevDate, -1); + }, + + + // Builds a structure with info about what the dates/ranges will be for the "next" view. + buildNextDateProfile: function(date) { + var dateProfile = this.get('dateProfile'); + var nextDate = date.clone().startOf(dateProfile.currentRangeUnit) + .add(dateProfile.dateIncrement); + + return this.buildDateProfile(nextDate, 1); + }, + + + // Builds a structure holding dates/ranges for rendering around the given date. + // Optional direction param indicates whether the date is being incremented/decremented + // from its previous value. decremented = -1, incremented = 1 (default). + buildDateProfile: function(date, direction, forceToValid) { + var isDateAllDay = !date.hasTime(); + var validUnzonedRange; + var minTime = null; + var maxTime = null; + var currentInfo; + var isRangeAllDay; + var renderUnzonedRange; + var activeUnzonedRange; + var isValid; + + validUnzonedRange = this.buildValidRange(); + validUnzonedRange = this.trimHiddenDays(validUnzonedRange); + + if (forceToValid) { + date = this.calendar.msToUtcMoment( + validUnzonedRange.constrainDate(date), // returns MS + isDateAllDay + ); + } + + currentInfo = this.buildCurrentRangeInfo(date, direction); + isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit); + renderUnzonedRange = this.buildRenderRange( + this.trimHiddenDays(currentInfo.unzonedRange), + currentInfo.unit, + isRangeAllDay + ); + renderUnzonedRange = this.trimHiddenDays(renderUnzonedRange); + activeUnzonedRange = renderUnzonedRange.clone(); + + if (!this.opt('showNonCurrentDates')) { + activeUnzonedRange = activeUnzonedRange.intersect(currentInfo.unzonedRange); + } + + minTime = moment.duration(this.opt('minTime')); + maxTime = moment.duration(this.opt('maxTime')); + activeUnzonedRange = this.adjustActiveRange(activeUnzonedRange, minTime, maxTime); + activeUnzonedRange = activeUnzonedRange.intersect(validUnzonedRange); // might return null + + if (activeUnzonedRange) { + date = this.calendar.msToUtcMoment( + activeUnzonedRange.constrainDate(date), // returns MS + isDateAllDay + ); + } + + // it's invalid if the originally requested date is not contained, + // or if the range is completely outside of the valid range. + isValid = currentInfo.unzonedRange.intersectsWith(validUnzonedRange); + + return { + // constraint for where prev/next operations can go and where events can be dragged/resized to. + // an object with optional start and end properties. + validUnzonedRange: validUnzonedRange, + + // range the view is formally responsible for. + // for example, a month view might have 1st-31st, excluding padded dates + currentUnzonedRange: currentInfo.unzonedRange, + + // name of largest unit being displayed, like "month" or "week" + currentRangeUnit: currentInfo.unit, + + isRangeAllDay: isRangeAllDay, + + // dates that display events and accept drag-n-drop + // will be `null` if no dates accept events + activeUnzonedRange: activeUnzonedRange, + + // date range with a rendered skeleton + // includes not-active days that need some sort of DOM + renderUnzonedRange: renderUnzonedRange, + + // Duration object that denotes the first visible time of any given day + minTime: minTime, + + // Duration object that denotes the exclusive visible end time of any given day + maxTime: maxTime, + + isValid: isValid, + + date: date, + + // how far the current date will move for a prev/next operation + dateIncrement: this.buildDateIncrement(currentInfo.duration) + // pass a fallback (might be null) ^ + }; + }, + + + // Builds an object with optional start/end properties. + // Indicates the minimum/maximum dates to display. + // not responsible for trimming hidden days. + buildValidRange: function() { + return this.getUnzonedRangeOption('validRange', this.calendar.getNow()) || + new UnzonedRange(); // completely open-ended + }, + + + // Builds a structure with info about the "current" range, the range that is + // highlighted as being the current month for example. + // See buildDateProfile for a description of `direction`. + // Guaranteed to have `range` and `unit` properties. `duration` is optional. + // TODO: accept a MS-time instead of a moment `date`? + buildCurrentRangeInfo: function(date, direction) { + var duration = null; + var unit = null; + var unzonedRange = null; + var dayCount; + + if (this.viewSpec.duration) { + duration = this.viewSpec.duration; + unit = this.viewSpec.durationUnit; + unzonedRange = this.buildRangeFromDuration(date, direction, duration, unit); + } + else if ((dayCount = this.opt('dayCount'))) { + unit = 'day'; + unzonedRange = this.buildRangeFromDayCount(date, direction, dayCount); + } + else if ((unzonedRange = this.buildCustomVisibleRange(date))) { + unit = computeGreatestUnit(unzonedRange.getStart(), unzonedRange.getEnd()); + } + else { + duration = this.getFallbackDuration(); + unit = computeGreatestUnit(duration); + unzonedRange = this.buildRangeFromDuration(date, direction, duration, unit); + } + + return { duration: duration, unit: unit, unzonedRange: unzonedRange }; + }, + + + getFallbackDuration: function() { + return moment.duration({ days: 1 }); + }, + + + // Returns a new activeUnzonedRange to have time values (un-ambiguate) + // minTime or maxTime causes the range to expand. + adjustActiveRange: function(unzonedRange, minTime, maxTime) { + var start = unzonedRange.getStart(); + var end = unzonedRange.getEnd(); + + if (this.usesMinMaxTime) { + + if (minTime < 0) { + start.time(0).add(minTime); + } + + if (maxTime > 24 * 60 * 60 * 1000) { // beyond 24 hours? + end.time(maxTime - (24 * 60 * 60 * 1000)); + } + } + + return new UnzonedRange(start, end); + }, + + + // Builds the "current" range when it is specified as an explicit duration. + // `unit` is the already-computed computeGreatestUnit value of duration. + // TODO: accept a MS-time instead of a moment `date`? + buildRangeFromDuration: function(date, direction, duration, unit) { + var alignment = this.opt('dateAlignment'); + var start = date.clone(); + var end; + var dateIncrementInput; + var dateIncrementDuration; + + // if the view displays a single day or smaller + if (duration.as('days') <= 1) { + if (this.isHiddenDay(start)) { + start = this.skipHiddenDays(start, direction); + start.startOf('day'); + } + } + + // compute what the alignment should be + if (!alignment) { + dateIncrementInput = this.opt('dateIncrement'); + + if (dateIncrementInput) { + dateIncrementDuration = moment.duration(dateIncrementInput); + + // use the smaller of the two units + if (dateIncrementDuration < duration) { + alignment = computeDurationGreatestUnit(dateIncrementDuration, dateIncrementInput); + } + else { + alignment = unit; + } + } + else { + alignment = unit; + } + } + + start.startOf(alignment); + end = start.clone().add(duration); + + return new UnzonedRange(start, end); + }, + + + // Builds the "current" range when a dayCount is specified. + // TODO: accept a MS-time instead of a moment `date`? + buildRangeFromDayCount: function(date, direction, dayCount) { + var customAlignment = this.opt('dateAlignment'); + var runningCount = 0; + var start = date.clone(); + var end; + + if (customAlignment) { + start.startOf(customAlignment); + } + + start.startOf('day'); + start = this.skipHiddenDays(start, direction); + + end = start.clone(); + do { + end.add(1, 'day'); + if (!this.isHiddenDay(end)) { + runningCount++; + } + } while (runningCount < dayCount); + + return new UnzonedRange(start, end); + }, + + + // Builds a normalized range object for the "visible" range, + // which is a way to define the currentUnzonedRange and activeUnzonedRange at the same time. + // TODO: accept a MS-time instead of a moment `date`? + buildCustomVisibleRange: function(date) { + var visibleUnzonedRange = this.getUnzonedRangeOption( + 'visibleRange', + this.calendar.applyTimezone(date) // correct zone. also generates new obj that avoids mutations + ); + + if (visibleUnzonedRange && (visibleUnzonedRange.startMs === null || visibleUnzonedRange.endMs === null)) { + return null; + } + + return visibleUnzonedRange; + }, + + + // Computes the range that will represent the element/cells for *rendering*, + // but which may have voided days/times. + // not responsible for trimming hidden days. + buildRenderRange: function(currentUnzonedRange, currentRangeUnit, isRangeAllDay) { + return currentUnzonedRange.clone(); + }, + + + // Compute the duration value that should be added/substracted to the current date + // when a prev/next operation happens. + buildDateIncrement: function(fallback) { + var dateIncrementInput = this.opt('dateIncrement'); + var customAlignment; + + if (dateIncrementInput) { + return moment.duration(dateIncrementInput); + } + else if ((customAlignment = this.opt('dateAlignment'))) { + return moment.duration(1, customAlignment); + } + else if (fallback) { + return fallback; + } + else { + return moment.duration({ days: 1 }); + } + }, + + + // Remove days from the beginning and end of the range that are computed as hidden. + trimHiddenDays: function(inputUnzonedRange) { + var start = inputUnzonedRange.getStart(); + var end = inputUnzonedRange.getEnd(); + + if (start) { + start = this.skipHiddenDays(start); + } + + if (end) { + end = this.skipHiddenDays(end, -1, true); + } + + return new UnzonedRange(start, end); + }, + + + // For DateComponent::getDayClasses + isDateInOtherMonth: function(date, dateProfile) { + return false; + }, + + + // Arguments after name will be forwarded to a hypothetical function value + // WARNING: passed-in arguments will be given to generator functions as-is and can cause side-effects. + // Always clone your objects if you fear mutation. + getUnzonedRangeOption: function(name) { + var val = this.opt(name); + + if (typeof val === 'function') { + val = val.apply( + null, + Array.prototype.slice.call(arguments, 1) + ); + } + + if (val) { + return this.calendar.parseUnzonedRange(val); + } + }, + + + /* Hidden Days + ------------------------------------------------------------------------------------------------------------------*/ + + + // Initializes internal variables related to calculating hidden days-of-week + initHiddenDays: function() { + var hiddenDays = this.opt('hiddenDays') || []; // array of day-of-week indices that are hidden + var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool) + var dayCnt = 0; + var i; + + if (this.opt('weekends') === false) { + hiddenDays.push(0, 6); // 0=sunday, 6=saturday + } + + for (i = 0; i < 7; i++) { + if ( + !(isHiddenDayHash[i] = $.inArray(i, hiddenDays) !== -1) + ) { + dayCnt++; + } + } + + if (!dayCnt) { + throw 'invalid hiddenDays'; // all days were hidden? bad. + } + + this.isHiddenDayHash = isHiddenDayHash; + }, + + + // Is the current day hidden? + // `day` is a day-of-week index (0-6), or a Moment + isHiddenDay: function(day) { + if (moment.isMoment(day)) { + day = day.day(); + } + return this.isHiddenDayHash[day]; + }, + + + // Incrementing the current day until it is no longer a hidden day, returning a copy. + // DOES NOT CONSIDER validUnzonedRange! + // If the initial value of `date` is not a hidden day, don't do anything. + // Pass `isExclusive` as `true` if you are dealing with an end date. + // `inc` defaults to `1` (increment one day forward each time) + skipHiddenDays: function(date, inc, isExclusive) { + var out = date.clone(); + inc = inc || 1; + while ( + this.isHiddenDayHash[(out.day() + (isExclusive ? inc : 0) + 7) % 7] + ) { + out.add(inc, 'days'); + } + return out; + } + +}); + +;; + +/* Toolbar with buttons and title +----------------------------------------------------------------------------------------------------------------------*/ + +function Toolbar(calendar, toolbarOptions) { + var t = this; + + // exports + t.setToolbarOptions = setToolbarOptions; + t.render = render; + t.removeElement = removeElement; + t.updateTitle = updateTitle; + t.activateButton = activateButton; + t.deactivateButton = deactivateButton; + t.disableButton = disableButton; + t.enableButton = enableButton; + t.getViewsWithButtons = getViewsWithButtons; + t.el = null; // mirrors local `el` + + // locals + var el; + var viewsWithButtons = []; + + // method to update toolbar-specific options, not calendar-wide options + function setToolbarOptions(newToolbarOptions) { + toolbarOptions = newToolbarOptions; + } + + // can be called repeatedly and will rerender + function render() { + var sections = toolbarOptions.layout; + + if (sections) { + if (!el) { + el = this.el = $("
"); + } + else { + el.empty(); + } + el.append(renderSection('left')) + .append(renderSection('right')) + .append(renderSection('center')) + .append('
'); + } + else { + removeElement(); + } + } + + + function removeElement() { + if (el) { + el.remove(); + el = t.el = null; + } + } + + + function renderSection(position) { + var theme = calendar.theme; + var sectionEl = $('
'); + var buttonStr = toolbarOptions.layout[position]; + var calendarCustomButtons = calendar.opt('customButtons') || {}; + var calendarButtonTextOverrides = calendar.overrides.buttonText || {}; + var calendarButtonText = calendar.opt('buttonText') || {}; + + if (buttonStr) { + $.each(buttonStr.split(' '), function(i) { + var groupChildren = $(); + var isOnlyButtons = true; + var groupEl; + + $.each(this.split(','), function(j, buttonName) { + var customButtonProps; + var viewSpec; + var buttonClick; + var buttonIcon; // only one of these will be set + var buttonText; // " + var buttonInnerHtml; + var buttonClasses; + var buttonEl; + + if (buttonName == 'title') { + groupChildren = groupChildren.add($('

 

')); // we always want it to take up height + isOnlyButtons = false; + } + else { + + if ((customButtonProps = calendarCustomButtons[buttonName])) { + buttonClick = function(ev) { + if (customButtonProps.click) { + customButtonProps.click.call(buttonEl[0], ev); + } + }; + (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) || + (buttonIcon = theme.getIconClass(buttonName)) || + (buttonText = customButtonProps.text); // jshint ignore:line + } + else if ((viewSpec = calendar.getViewSpec(buttonName))) { + viewsWithButtons.push(buttonName); + buttonClick = function() { + calendar.changeView(buttonName); + }; + (buttonText = viewSpec.buttonTextOverride) || + (buttonIcon = theme.getIconClass(buttonName)) || + (buttonText = viewSpec.buttonTextDefault); // jshint ignore:line + } + else if (calendar[buttonName]) { // a calendar method + buttonClick = function() { + calendar[buttonName](); + }; + (buttonText = calendarButtonTextOverrides[buttonName]) || + (buttonIcon = theme.getIconClass(buttonName)) || + (buttonText = calendarButtonText[buttonName]); // jshint ignore:line + // ^ everything else is considered default + } + + if (buttonClick) { + + buttonClasses = [ + 'fc-' + buttonName + '-button', + theme.getClass('button'), + theme.getClass('stateDefault') + ]; + + if (buttonText) { + buttonInnerHtml = htmlEscape(buttonText); + } + else if (buttonIcon) { + buttonInnerHtml = ""; + } + + buttonEl = $( // type="button" so that it doesn't submit a form + '' + ) + .click(function(ev) { + // don't process clicks for disabled buttons + if (!buttonEl.hasClass(theme.getClass('stateDisabled'))) { + + buttonClick(ev); + + // after the click action, if the button becomes the "active" tab, or disabled, + // it should never have a hover class, so remove it now. + if ( + buttonEl.hasClass(theme.getClass('stateActive')) || + buttonEl.hasClass(theme.getClass('stateDisabled')) + ) { + buttonEl.removeClass(theme.getClass('stateHover')); + } + } + }) + .mousedown(function() { + // the *down* effect (mouse pressed in). + // only on buttons that are not the "active" tab, or disabled + buttonEl + .not('.' + theme.getClass('stateActive')) + .not('.' + theme.getClass('stateDisabled')) + .addClass(theme.getClass('stateDown')); + }) + .mouseup(function() { + // undo the *down* effect + buttonEl.removeClass(theme.getClass('stateDown')); + }) + .hover( + function() { + // the *hover* effect. + // only on buttons that are not the "active" tab, or disabled + buttonEl + .not('.' + theme.getClass('stateActive')) + .not('.' + theme.getClass('stateDisabled')) + .addClass(theme.getClass('stateHover')); + }, + function() { + // undo the *hover* effect + buttonEl + .removeClass(theme.getClass('stateHover')) + .removeClass(theme.getClass('stateDown')); // if mouseleave happens before mouseup + } + ); + + groupChildren = groupChildren.add(buttonEl); + } + } + }); + + if (isOnlyButtons) { + groupChildren + .first().addClass(theme.getClass('cornerLeft')).end() + .last().addClass(theme.getClass('cornerRight')).end(); + } + + if (groupChildren.length > 1) { + groupEl = $('
'); + if (isOnlyButtons) { + groupEl.addClass(theme.getClass('buttonGroup')); + } + groupEl.append(groupChildren); + sectionEl.append(groupEl); + } + else { + sectionEl.append(groupChildren); // 1 or 0 children + } + }); + } + + return sectionEl; + } + + + function updateTitle(text) { + if (el) { + el.find('h2').text(text); + } + } + + + function activateButton(buttonName) { + if (el) { + el.find('.fc-' + buttonName + '-button') + .addClass(calendar.theme.getClass('stateActive')); + } + } + + + function deactivateButton(buttonName) { + if (el) { + el.find('.fc-' + buttonName + '-button') + .removeClass(calendar.theme.getClass('stateActive')); + } + } + + + function disableButton(buttonName) { + if (el) { + el.find('.fc-' + buttonName + '-button') + .prop('disabled', true) + .addClass(calendar.theme.getClass('stateDisabled')); + } + } + + + function enableButton(buttonName) { + if (el) { + el.find('.fc-' + buttonName + '-button') + .prop('disabled', false) + .removeClass(calendar.theme.getClass('stateDisabled')); + } + } + + + function getViewsWithButtons() { + return viewsWithButtons; + } + +} + +;; + +var Calendar = FC.Calendar = Class.extend(EmitterMixin, ListenerMixin, { + + view: null, // current View object + viewsByType: null, // holds all instantiated view instances, current or not + currentDate: null, // unzoned moment. private (public API should use getDate instead) + theme: null, + businessHourGenerator: null, + loadingLevel: 0, // number of simultaneous loading tasks + + + constructor: function(el, overrides) { + + // declare the current calendar instance relies on GlobalEmitter. needed for garbage collection. + // unneeded() is called in destroy. + GlobalEmitter.needed(); + + this.el = el; + this.viewsByType = {}; + this.viewSpecCache = {}; + + this.initOptionsInternals(overrides); + this.initMomentInternals(); // needs to happen after options hash initialized + this.initCurrentDate(); + this.initEventManager(); + + this.constructed(); + }, + + + // useful for monkeypatching. TODO: BaseClass? + constructed: function() { + }, + + + // Public API + // ----------------------------------------------------------------------------------------------------------------- + + + getView: function() { + return this.view; + }, + + + publiclyTrigger: function(name, triggerInfo) { + var optHandler = this.opt(name); + var context; + var args; + + if ($.isPlainObject(triggerInfo)) { + context = triggerInfo.context; + args = triggerInfo.args; + } + else if ($.isArray(triggerInfo)) { + args = triggerInfo; + } + + if (context == null) { + context = this.el[0]; // fallback context + } + + if (!args) { + args = []; + } + + this.triggerWith(name, context, args); // Emitter's method + + if (optHandler) { + return optHandler.apply(context, args); + } + }, + + + hasPublicHandlers: function(name) { + return this.hasHandlers(name) || + this.opt(name); // handler specified in options + }, + + + // View + // ----------------------------------------------------------------------------------------------------------------- + + + // Given a view name for a custom view or a standard view, creates a ready-to-go View object + instantiateView: function(viewType) { + var spec = this.getViewSpec(viewType); + + return new spec['class'](this, spec); + }, + + + // Returns a boolean about whether the view is okay to instantiate at some point + isValidViewType: function(viewType) { + return Boolean(this.getViewSpec(viewType)); + }, + + + changeView: function(viewName, dateOrRange) { + + if (dateOrRange) { + + if (dateOrRange.start && dateOrRange.end) { // a range + this.recordOptionOverrides({ // will not rerender + visibleRange: dateOrRange + }); + } + else { // a date + this.currentDate = this.moment(dateOrRange).stripZone(); // just like gotoDate + } + } + + this.renderView(viewName); + }, + + + // Forces navigation to a view for the given date. + // `viewType` can be a specific view name or a generic one like "week" or "day". + zoomTo: function(newDate, viewType) { + var spec; + + viewType = viewType || 'day'; // day is default zoom + spec = this.getViewSpec(viewType) || this.getUnitViewSpec(viewType); + + this.currentDate = newDate.clone(); + this.renderView(spec ? spec.type : null); + }, + + + // Current Date + // ----------------------------------------------------------------------------------------------------------------- + + + initCurrentDate: function() { + var defaultDateInput = this.opt('defaultDate'); + + // compute the initial ambig-timezone date + if (defaultDateInput != null) { + this.currentDate = this.moment(defaultDateInput).stripZone(); + } + else { + this.currentDate = this.getNow(); // getNow already returns unzoned + } + }, + + + prev: function() { + var prevInfo = this.view.buildPrevDateProfile(this.currentDate); + + if (prevInfo.isValid) { + this.currentDate = prevInfo.date; + this.renderView(); + } + }, + + + next: function() { + var nextInfo = this.view.buildNextDateProfile(this.currentDate); + + if (nextInfo.isValid) { + this.currentDate = nextInfo.date; + this.renderView(); + } + }, + + + prevYear: function() { + this.currentDate.add(-1, 'years'); + this.renderView(); + }, + + + nextYear: function() { + this.currentDate.add(1, 'years'); + this.renderView(); + }, + + + today: function() { + this.currentDate = this.getNow(); // should deny like prev/next? + this.renderView(); + }, + + + gotoDate: function(zonedDateInput) { + this.currentDate = this.moment(zonedDateInput).stripZone(); + this.renderView(); + }, + + + incrementDate: function(delta) { + this.currentDate.add(moment.duration(delta)); + this.renderView(); + }, + + + // for external API + getDate: function() { + return this.applyTimezone(this.currentDate); // infuse the calendar's timezone + }, + + + // Loading Triggering + // ----------------------------------------------------------------------------------------------------------------- + + + // Should be called when any type of async data fetching begins + pushLoading: function() { + if (!(this.loadingLevel++)) { + this.publiclyTrigger('loading', [ true, this.view ]); + } + }, + + + // Should be called when any type of async data fetching completes + popLoading: function() { + if (!(--this.loadingLevel)) { + this.publiclyTrigger('loading', [ false, this.view ]); + } + }, + + + // Selection + // ----------------------------------------------------------------------------------------------------------------- + + + // this public method receives start/end dates in any format, with any timezone + select: function(zonedStartInput, zonedEndInput) { + this.view.select( + this.buildSelectFootprint.apply(this, arguments) + ); + }, + + + unselect: function() { // safe to be called before renderView + if (this.view) { + this.view.unselect(); + } + }, + + + // Given arguments to the select method in the API, returns a span (unzoned start/end and other info) + buildSelectFootprint: function(zonedStartInput, zonedEndInput) { + var start = this.moment(zonedStartInput).stripZone(); + var end; + + if (zonedEndInput) { + end = this.moment(zonedEndInput).stripZone(); + } + else if (start.hasTime()) { + end = start.clone().add(this.defaultTimedEventDuration); + } + else { + end = start.clone().add(this.defaultAllDayEventDuration); + } + + return new ComponentFootprint( + new UnzonedRange(start, end), + !start.hasTime() + ); + }, + + + // Misc + // ----------------------------------------------------------------------------------------------------------------- + + + // will return `null` if invalid range + parseUnzonedRange: function(rangeInput) { + var start = null; + var end = null; + + if (rangeInput.start) { + start = this.moment(rangeInput.start).stripZone(); + } + + if (rangeInput.end) { + end = this.moment(rangeInput.end).stripZone(); + } + + if (!start && !end) { + return null; + } + + if (start && end && end.isBefore(start)) { + return null; + } + + return new UnzonedRange(start, end); + }, + + + rerenderEvents: function() { // API method. destroys old events if previously rendered. + this.view.flash('displayingEvents'); + }, + + + initEventManager: function() { + var _this = this; + var eventManager = new EventManager(this); + var rawSources = this.opt('eventSources') || []; + var singleRawSource = this.opt('events'); + + this.eventManager = eventManager; + + if (singleRawSource) { + rawSources.unshift(singleRawSource); + } + + eventManager.on('release', function(eventsPayload) { + _this.trigger('eventsReset', eventsPayload); + }); + + eventManager.freeze(); + + rawSources.forEach(function(rawSource) { + var source = EventSourceParser.parse(rawSource, _this); + + if (source) { + eventManager.addSource(source); + } + }); + + eventManager.thaw(); + }, + + + requestEvents: function(start, end) { + return this.eventManager.requestEvents( + start, + end, + this.opt('timezone'), + !this.opt('lazyFetching') + ); + } + +}); + +;; +/* +Options binding/triggering system. +*/ +Calendar.mixin({ + + dirDefaults: null, // option defaults related to LTR or RTL + localeDefaults: null, // option defaults related to current locale + overrides: null, // option overrides given to the fullCalendar constructor + dynamicOverrides: null, // options set with dynamic setter method. higher precedence than view overrides. + optionsModel: null, // all defaults combined with overrides + + + initOptionsInternals: function(overrides) { + this.overrides = $.extend({}, overrides); // make a copy + this.dynamicOverrides = {}; + this.optionsModel = new Model(); + + this.populateOptionsHash(); + }, + + + // public getter/setter + option: function(name, value) { + var newOptionHash; + + if (typeof name === 'string') { + if (value === undefined) { // getter + return this.optionsModel.get(name); + } + else { // setter for individual option + newOptionHash = {}; + newOptionHash[name] = value; + this.setOptions(newOptionHash); + } + } + else if (typeof name === 'object') { // compound setter with object input + this.setOptions(name); + } + }, + + + // private getter + opt: function(name) { + return this.optionsModel.get(name); + }, + + + setOptions: function(newOptionHash) { + var optionCnt = 0; + var optionName; + + this.recordOptionOverrides(newOptionHash); // will trigger optionsModel watchers + + for (optionName in newOptionHash) { + optionCnt++; + } + + // special-case handling of single option change. + // if only one option change, `optionName` will be its name. + if (optionCnt === 1) { + if (optionName === 'height' || optionName === 'contentHeight' || optionName === 'aspectRatio') { + this.updateViewSize(true); // isResize=true + return; + } + else if (optionName === 'defaultDate') { + return; // can't change date this way. use gotoDate instead + } + else if (optionName === 'businessHours') { + return; // optionsModel already reacts to this + } + else if (optionName === 'timezone') { + this.view.flash('initialEvents'); + return; + } + } + + // catch-all. rerender the header and footer and rebuild/rerender the current view + this.renderHeader(); + this.renderFooter(); + + // even non-current views will be affected by this option change. do before rerender + // TODO: detangle + this.viewsByType = {}; + + this.reinitView(); + }, + + + // Computes the flattened options hash for the calendar and assigns to `this.options`. + // Assumes this.overrides and this.dynamicOverrides have already been initialized. + populateOptionsHash: function() { + var locale, localeDefaults; + var isRTL, dirDefaults; + var rawOptions; + + locale = firstDefined( // explicit locale option given? + this.dynamicOverrides.locale, + this.overrides.locale + ); + localeDefaults = localeOptionHash[locale]; + if (!localeDefaults) { // explicit locale option not given or invalid? + locale = Calendar.defaults.locale; + localeDefaults = localeOptionHash[locale] || {}; + } + + isRTL = firstDefined( // based on options computed so far, is direction RTL? + this.dynamicOverrides.isRTL, + this.overrides.isRTL, + localeDefaults.isRTL, + Calendar.defaults.isRTL + ); + dirDefaults = isRTL ? Calendar.rtlDefaults : {}; + + this.dirDefaults = dirDefaults; + this.localeDefaults = localeDefaults; + + rawOptions = mergeOptions([ // merge defaults and overrides. lowest to highest precedence + Calendar.defaults, // global defaults + dirDefaults, + localeDefaults, + this.overrides, + this.dynamicOverrides + ]); + populateInstanceComputableOptions(rawOptions); // fill in gaps with computed options + + this.optionsModel.reset(rawOptions); + }, + + + // stores the new options internally, but does not rerender anything. + recordOptionOverrides: function(newOptionHash) { + var optionName; + + for (optionName in newOptionHash) { + this.dynamicOverrides[optionName] = newOptionHash[optionName]; + } + + this.viewSpecCache = {}; // the dynamic override invalidates the options in this cache, so just clear it + this.populateOptionsHash(); // this.options needs to be recomputed after the dynamic override + } + +}); + +;; + +Calendar.mixin({ + + defaultAllDayEventDuration: null, + defaultTimedEventDuration: null, + localeData: null, + + + initMomentInternals: function() { + var _this = this; + + this.defaultAllDayEventDuration = moment.duration(this.opt('defaultAllDayEventDuration')); + this.defaultTimedEventDuration = moment.duration(this.opt('defaultTimedEventDuration')); + + // Called immediately, and when any of the options change. + // Happens before any internal objects rebuild or rerender, because this is very core. + this.optionsModel.watch('buildingMomentLocale', [ + '?locale', '?monthNames', '?monthNamesShort', '?dayNames', '?dayNamesShort', + '?firstDay', '?weekNumberCalculation' + ], function(opts) { + var weekNumberCalculation = opts.weekNumberCalculation; + var firstDay = opts.firstDay; + var _week; + + // normalize + if (weekNumberCalculation === 'iso') { + weekNumberCalculation = 'ISO'; // normalize + } + + var localeData = Object.create( // make a cheap copy + getMomentLocaleData(opts.locale) // will fall back to en + ); + + if (opts.monthNames) { + localeData._months = opts.monthNames; + } + if (opts.monthNamesShort) { + localeData._monthsShort = opts.monthNamesShort; + } + if (opts.dayNames) { + localeData._weekdays = opts.dayNames; + } + if (opts.dayNamesShort) { + localeData._weekdaysShort = opts.dayNamesShort; + } + + if (firstDay == null && weekNumberCalculation === 'ISO') { + firstDay = 1; + } + if (firstDay != null) { + _week = Object.create(localeData._week); // _week: { dow: # } + _week.dow = firstDay; + localeData._week = _week; + } + + if ( // whitelist certain kinds of input + weekNumberCalculation === 'ISO' || + weekNumberCalculation === 'local' || + typeof weekNumberCalculation === 'function' + ) { + localeData._fullCalendar_weekCalc = weekNumberCalculation; // moment-ext will know what to do with it + } + + _this.localeData = localeData; + + // If the internal current date object already exists, move to new locale. + // We do NOT need to do this technique for event dates, because this happens when converting to "segments". + if (_this.currentDate) { + _this.localizeMoment(_this.currentDate); // sets to localeData + } + }); + }, + + + // Builds a moment using the settings of the current calendar: timezone and locale. + // Accepts anything the vanilla moment() constructor accepts. + moment: function() { + var mom; + + if (this.opt('timezone') === 'local') { + mom = FC.moment.apply(null, arguments); + + // Force the moment to be local, because FC.moment doesn't guarantee it. + if (mom.hasTime()) { // don't give ambiguously-timed moments a local zone + mom.local(); + } + } + else if (this.opt('timezone') === 'UTC') { + mom = FC.moment.utc.apply(null, arguments); // process as UTC + } + else { + mom = FC.moment.parseZone.apply(null, arguments); // let the input decide the zone + } + + this.localizeMoment(mom); // TODO + + return mom; + }, + + + msToMoment: function(ms, forceAllDay) { + var mom = FC.moment.utc(ms); // TODO: optimize by using Date.UTC + + if (forceAllDay) { + mom.stripTime(); + } + else { + mom = this.applyTimezone(mom); // may or may not apply locale + } + + this.localizeMoment(mom); + + return mom; + }, + + + msToUtcMoment: function(ms, forceAllDay) { + var mom = FC.moment.utc(ms); // TODO: optimize by using Date.UTC + + if (forceAllDay) { + mom.stripTime(); + } + + this.localizeMoment(mom); + + return mom; + }, + + + // Updates the given moment's locale settings to the current calendar locale settings. + localizeMoment: function(mom) { + mom._locale = this.localeData; + }, + + + // Returns a boolean about whether or not the calendar knows how to calculate + // the timezone offset of arbitrary dates in the current timezone. + getIsAmbigTimezone: function() { + return this.opt('timezone') !== 'local' && this.opt('timezone') !== 'UTC'; + }, + + + // Returns a copy of the given date in the current timezone. Has no effect on dates without times. + applyTimezone: function(date) { + if (!date.hasTime()) { + return date.clone(); + } + + var zonedDate = this.moment(date.toArray()); + var timeAdjust = date.time() - zonedDate.time(); + var adjustedZonedDate; + + // Safari sometimes has problems with this coersion when near DST. Adjust if necessary. (bug #2396) + if (timeAdjust) { // is the time result different than expected? + adjustedZonedDate = zonedDate.clone().add(timeAdjust); // add milliseconds + if (date.time() - adjustedZonedDate.time() === 0) { // does it match perfectly now? + zonedDate = adjustedZonedDate; + } + } + + return zonedDate; + }, + + + /* + Assumes the footprint is non-open-ended. + */ + footprintToDateProfile: function(componentFootprint, ignoreEnd) { + var start = FC.moment.utc(componentFootprint.unzonedRange.startMs); + var end; + + if (!ignoreEnd) { + end = FC.moment.utc(componentFootprint.unzonedRange.endMs); + } + + if (componentFootprint.isAllDay) { + start.stripTime(); + + if (end) { + end.stripTime(); + } + } + else { + start = this.applyTimezone(start); + + if (end) { + end = this.applyTimezone(end); + } + } + + return new EventDateProfile(start, end, this); + }, + + + // Returns a moment for the current date, as defined by the client's computer or from the `now` option. + // Will return an moment with an ambiguous timezone. + getNow: function() { + var now = this.opt('now'); + if (typeof now === 'function') { + now = now(); + } + return this.moment(now).stripZone(); + }, + + + // Produces a human-readable string for the given duration. + // Side-effect: changes the locale of the given duration. + humanizeDuration: function(duration) { + return duration.locale(this.opt('locale')).humanize(); + }, + + + + // Event-Specific Date Utilities. TODO: move + // ----------------------------------------------------------------------------------------------------------------- + + + // Get an event's normalized end date. If not present, calculate it from the defaults. + getEventEnd: function(event) { + if (event.end) { + return event.end.clone(); + } + else { + return this.getDefaultEventEnd(event.allDay, event.start); + } + }, + + + // Given an event's allDay status and start date, return what its fallback end date should be. + // TODO: rename to computeDefaultEventEnd + getDefaultEventEnd: function(allDay, zonedStart) { + var end = zonedStart.clone(); + + if (allDay) { + end.stripTime().add(this.defaultAllDayEventDuration); + } + else { + end.add(this.defaultTimedEventDuration); + } + + if (this.getIsAmbigTimezone()) { + end.stripZone(); // we don't know what the tzo should be + } + + return end; + } + +}); + +;; + +Calendar.mixin({ + + viewSpecCache: null, // cache of view definitions (initialized in Calendar.js) + + + // Gets information about how to create a view. Will use a cache. + getViewSpec: function(viewType) { + var cache = this.viewSpecCache; + + return cache[viewType] || (cache[viewType] = this.buildViewSpec(viewType)); + }, + + + // Given a duration singular unit, like "week" or "day", finds a matching view spec. + // Preference is given to views that have corresponding buttons. + getUnitViewSpec: function(unit) { + var viewTypes; + var i; + var spec; + + if ($.inArray(unit, unitsDesc) != -1) { + + // put views that have buttons first. there will be duplicates, but oh well + viewTypes = this.header.getViewsWithButtons(); // TODO: include footer as well? + $.each(FC.views, function(viewType) { // all views + viewTypes.push(viewType); + }); + + for (i = 0; i < viewTypes.length; i++) { + spec = this.getViewSpec(viewTypes[i]); + if (spec) { + if (spec.singleUnit == unit) { + return spec; + } + } + } + } + }, + + + // Builds an object with information on how to create a given view + buildViewSpec: function(requestedViewType) { + var viewOverrides = this.overrides.views || {}; + var specChain = []; // for the view. lowest to highest priority + var defaultsChain = []; // for the view. lowest to highest priority + var overridesChain = []; // for the view. lowest to highest priority + var viewType = requestedViewType; + var spec; // for the view + var overrides; // for the view + var durationInput; + var duration; + var unit; + + // iterate from the specific view definition to a more general one until we hit an actual View class + while (viewType) { + spec = fcViews[viewType]; + overrides = viewOverrides[viewType]; + viewType = null; // clear. might repopulate for another iteration + + if (typeof spec === 'function') { // TODO: deprecate + spec = { 'class': spec }; + } + + if (spec) { + specChain.unshift(spec); + defaultsChain.unshift(spec.defaults || {}); + durationInput = durationInput || spec.duration; + viewType = viewType || spec.type; + } + + if (overrides) { + overridesChain.unshift(overrides); // view-specific option hashes have options at zero-level + durationInput = durationInput || overrides.duration; + viewType = viewType || overrides.type; + } + } + + spec = mergeProps(specChain); + spec.type = requestedViewType; + if (!spec['class']) { + return false; + } + + // fall back to top-level `duration` option + durationInput = durationInput || + this.dynamicOverrides.duration || + this.overrides.duration; + + if (durationInput) { + duration = moment.duration(durationInput); + + if (duration.valueOf()) { // valid? + + unit = computeDurationGreatestUnit(duration, durationInput); + + spec.duration = duration; + spec.durationUnit = unit; + + // view is a single-unit duration, like "week" or "day" + // incorporate options for this. lowest priority + if (duration.as(unit) === 1) { + spec.singleUnit = unit; + overridesChain.unshift(viewOverrides[unit] || {}); + } + } + } + + spec.defaults = mergeOptions(defaultsChain); + spec.overrides = mergeOptions(overridesChain); + + this.buildViewSpecOptions(spec); + this.buildViewSpecButtonText(spec, requestedViewType); + + return spec; + }, + + + // Builds and assigns a view spec's options object from its already-assigned defaults and overrides + buildViewSpecOptions: function(spec) { + spec.options = mergeOptions([ // lowest to highest priority + Calendar.defaults, // global defaults + spec.defaults, // view's defaults (from ViewSubclass.defaults) + this.dirDefaults, + this.localeDefaults, // locale and dir take precedence over view's defaults! + this.overrides, // calendar's overrides (options given to constructor) + spec.overrides, // view's overrides (view-specific options) + this.dynamicOverrides // dynamically set via setter. highest precedence + ]); + populateInstanceComputableOptions(spec.options); + }, + + + // Computes and assigns a view spec's buttonText-related options + buildViewSpecButtonText: function(spec, requestedViewType) { + + // given an options object with a possible `buttonText` hash, lookup the buttonText for the + // requested view, falling back to a generic unit entry like "week" or "day" + function queryButtonText(options) { + var buttonText = options.buttonText || {}; + return buttonText[requestedViewType] || + // view can decide to look up a certain key + (spec.buttonTextKey ? buttonText[spec.buttonTextKey] : null) || + // a key like "month" + (spec.singleUnit ? buttonText[spec.singleUnit] : null); + } + + // highest to lowest priority + spec.buttonTextOverride = + queryButtonText(this.dynamicOverrides) || + queryButtonText(this.overrides) || // constructor-specified buttonText lookup hash takes precedence + spec.overrides.buttonText; // `buttonText` for view-specific options is a string + + // highest to lowest priority. mirrors buildViewSpecOptions + spec.buttonTextDefault = + queryButtonText(this.localeDefaults) || + queryButtonText(this.dirDefaults) || + spec.defaults.buttonText || // a single string. from ViewSubclass.defaults + queryButtonText(Calendar.defaults) || + (spec.duration ? this.humanizeDuration(spec.duration) : null) || // like "3 days" + requestedViewType; // fall back to given view name + } + +}); + +;; + +Calendar.mixin({ + + el: null, + contentEl: null, + suggestedViewHeight: null, + ignoreUpdateViewSize: 0, + freezeContentHeightDepth: 0, + windowResizeProxy: null, + + + render: function() { + if (!this.contentEl) { + this.initialRender(); + } + else if (this.elementVisible()) { + // mainly for the public API + this.calcSize(); + this.renderView(); + } + }, + + + initialRender: function() { + var _this = this; + var el = this.el; + + el.addClass('fc'); + + // event delegation for nav links + el.on('click.fc', 'a[data-goto]', function(ev) { + var anchorEl = $(this); + var gotoOptions = anchorEl.data('goto'); // will automatically parse JSON + var date = _this.moment(gotoOptions.date); + var viewType = gotoOptions.type; + + // property like "navLinkDayClick". might be a string or a function + var customAction = _this.view.opt('navLink' + capitaliseFirstLetter(viewType) + 'Click'); + + if (typeof customAction === 'function') { + customAction(date, ev); + } + else { + if (typeof customAction === 'string') { + viewType = customAction; + } + _this.zoomTo(date, viewType); + } + }); + + // called immediately, and upon option change + this.optionsModel.watch('settingTheme', [ '?theme', '?themeSystem' ], function(opts) { + var themeClass = ThemeRegistry.getThemeClass(opts.themeSystem || opts.theme); + var theme = new themeClass(_this.optionsModel); + var widgetClass = theme.getClass('widget'); + + _this.theme = theme; + + if (widgetClass) { + el.addClass(widgetClass); + } + }, function() { + var widgetClass = _this.theme.getClass('widget'); + + _this.theme = null; + + if (widgetClass) { + el.removeClass(widgetClass); + } + }); + + this.optionsModel.watch('settingBusinessHourGenerator', [ '?businessHours' ], function(deps) { + _this.businessHourGenerator = new BusinessHourGenerator(deps.businessHours, _this); + + if (_this.view) { + _this.view.set('businessHourGenerator', _this.businessHourGenerator); + } + }, function() { + _this.businessHourGenerator = null; + }); + + // called immediately, and upon option change. + // HACK: locale often affects isRTL, so we explicitly listen to that too. + this.optionsModel.watch('applyingDirClasses', [ '?isRTL', '?locale' ], function(opts) { + el.toggleClass('fc-ltr', !opts.isRTL); + el.toggleClass('fc-rtl', opts.isRTL); + }); + + this.contentEl = $("
").prependTo(el); + + this.initToolbars(); + this.renderHeader(); + this.renderFooter(); + this.renderView(this.opt('defaultView')); + + if (this.opt('handleWindowResize')) { + $(window).resize( + this.windowResizeProxy = debounce( // prevents rapid calls + this.windowResize.bind(this), + this.opt('windowResizeDelay') + ) + ); + } + }, + + + destroy: function() { + if (this.view) { + this.clearView(); + } + + this.toolbarsManager.proxyCall('removeElement'); + this.contentEl.remove(); + this.el.removeClass('fc fc-ltr fc-rtl'); + + // removes theme-related root className + this.optionsModel.unwatch('settingTheme'); + this.optionsModel.unwatch('settingBusinessHourGenerator'); + + this.el.off('.fc'); // unbind nav link handlers + + if (this.windowResizeProxy) { + $(window).unbind('resize', this.windowResizeProxy); + this.windowResizeProxy = null; + } + + GlobalEmitter.unneeded(); + }, + + + elementVisible: function() { + return this.el.is(':visible'); + }, + + + // Render Queue + // ----------------------------------------------------------------------------------------------------------------- + + + bindViewHandlers: function(view) { + var _this = this; + + view.watch('titleForCalendar', [ 'title' ], function(deps) { // TODO: better system + if (view === _this.view) { // hack + _this.setToolbarsTitle(deps.title); + } + }); + + view.watch('dateProfileForCalendar', [ 'dateProfile' ], function(deps) { + if (view === _this.view) { // hack + _this.currentDate = deps.dateProfile.date; // might have been constrained by view dates + _this.updateToolbarButtons(deps.dateProfile); + } + }); + }, + + + unbindViewHandlers: function(view) { + this.stopListeningTo(view); + + view.unwatch('titleForCalendar'); + view.unwatch('dateProfileForCalendar'); + }, + + + // View Rendering + // ----------------------------------------------------------------------------------- + + + // Renders a view because of a date change, view-type change, or for the first time. + // If not given a viewType, keep the current view but render different dates. + // Accepts an optional scroll state to restore to. + renderView: function(viewType) { + var oldView = this.view; + var newView; + + this.freezeContentHeight(); + + if (oldView && viewType && oldView.type !== viewType) { + this.clearView(); + } + + // if viewType changed, or the view was never created, create a fresh view + if (!this.view && viewType) { + newView = this.view = + this.viewsByType[viewType] || + (this.viewsByType[viewType] = this.instantiateView(viewType)); + + this.bindViewHandlers(newView); + + newView.setElement( + $("
").appendTo(this.contentEl) + ); + + this.toolbarsManager.proxyCall('activateButton', viewType); + } + + if (this.view) { + + // prevent unnecessary change firing + if (this.view.get('businessHourGenerator') !== this.businessHourGenerator) { + this.view.set('businessHourGenerator', this.businessHourGenerator); + } + + this.view.setDate(this.currentDate); + } + + this.thawContentHeight(); + }, + + + // Unrenders the current view and reflects this change in the Header. + // Unregsiters the `view`, but does not remove from viewByType hash. + clearView: function() { + var currentView = this.view; + + this.toolbarsManager.proxyCall('deactivateButton', currentView.type); + + this.unbindViewHandlers(currentView); + + currentView.removeElement(); + + this.view = null; + }, + + + // Destroys the view, including the view object. Then, re-instantiates it and renders it. + // Maintains the same scroll state. + // TODO: maintain any other user-manipulated state. + reinitView: function() { + var oldView = this.view; + var scroll = oldView.queryScroll(); // wouldn't be so complicated if Calendar owned the scroll + this.freezeContentHeight(); + + this.clearView(); + this.calcSize(); + this.renderView(oldView.type); // needs the type to freshly render + + this.view.applyScroll(scroll); + this.thawContentHeight(); + }, + + + // Resizing + // ----------------------------------------------------------------------------------- + + + getSuggestedViewHeight: function() { + if (this.suggestedViewHeight === null) { + this.calcSize(); + } + return this.suggestedViewHeight; + }, + + + isHeightAuto: function() { + return this.opt('contentHeight') === 'auto' || this.opt('height') === 'auto'; + }, + + + updateViewSize: function(isResize) { + var view = this.view; + var scroll; + + if (!this.ignoreUpdateViewSize && view) { + + if (isResize) { + this.calcSize(); + scroll = view.queryScroll(); + } + + this.ignoreUpdateViewSize++; + + view.updateSize( + this.getSuggestedViewHeight(), + this.isHeightAuto(), + isResize + ); + + this.ignoreUpdateViewSize--; + + if (isResize) { + view.applyScroll(scroll); + } + + return true; // signal success + } + }, + + + calcSize: function() { + if (this.elementVisible()) { + this._calcSize(); + } + }, + + + _calcSize: function() { // assumes elementVisible + var contentHeightInput = this.opt('contentHeight'); + var heightInput = this.opt('height'); + + if (typeof contentHeightInput === 'number') { // exists and not 'auto' + this.suggestedViewHeight = contentHeightInput; + } + else if (typeof contentHeightInput === 'function') { // exists and is a function + this.suggestedViewHeight = contentHeightInput(); + } + else if (typeof heightInput === 'number') { // exists and not 'auto' + this.suggestedViewHeight = heightInput - this.queryToolbarsHeight(); + } + else if (typeof heightInput === 'function') { // exists and is a function + this.suggestedViewHeight = heightInput() - this.queryToolbarsHeight(); + } + else if (heightInput === 'parent') { // set to height of parent element + this.suggestedViewHeight = this.el.parent().height() - this.queryToolbarsHeight(); + } + else { + this.suggestedViewHeight = Math.round( + this.contentEl.width() / + Math.max(this.opt('aspectRatio'), .5) + ); + } + }, + + + windowResize: function(ev) { + if ( + ev.target === window && // so we don't process jqui "resize" events that have bubbled up + this.view && + this.view.isDatesRendered + ) { + if (this.updateViewSize(true)) { // isResize=true, returns true on success + this.publiclyTrigger('windowResize', [ this.view ]); + } + } + }, + + + /* Height "Freezing" + -----------------------------------------------------------------------------*/ + + + freezeContentHeight: function() { + if (!(this.freezeContentHeightDepth++)) { + this.forceFreezeContentHeight(); + } + }, + + + forceFreezeContentHeight: function() { + this.contentEl.css({ + width: '100%', + height: this.contentEl.height(), + overflow: 'hidden' + }); + }, + + + thawContentHeight: function() { + this.freezeContentHeightDepth--; + + // always bring back to natural height + this.contentEl.css({ + width: '', + height: '', + overflow: '' + }); + + // but if there are future thaws, re-freeze + if (this.freezeContentHeightDepth) { + this.forceFreezeContentHeight(); + } + } + +}); + +;; + +Calendar.mixin({ + + header: null, + footer: null, + toolbarsManager: null, + + + initToolbars: function() { + this.header = new Toolbar(this, this.computeHeaderOptions()); + this.footer = new Toolbar(this, this.computeFooterOptions()); + this.toolbarsManager = new Iterator([ this.header, this.footer ]); + }, + + + computeHeaderOptions: function() { + return { + extraClasses: 'fc-header-toolbar', + layout: this.opt('header') + }; + }, + + + computeFooterOptions: function() { + return { + extraClasses: 'fc-footer-toolbar', + layout: this.opt('footer') + }; + }, + + + // can be called repeatedly and Header will rerender + renderHeader: function() { + var header = this.header; + + header.setToolbarOptions(this.computeHeaderOptions()); + header.render(); + + if (header.el) { + this.el.prepend(header.el); + } + }, + + + // can be called repeatedly and Footer will rerender + renderFooter: function() { + var footer = this.footer; + + footer.setToolbarOptions(this.computeFooterOptions()); + footer.render(); + + if (footer.el) { + this.el.append(footer.el); + } + }, + + + setToolbarsTitle: function(title) { + this.toolbarsManager.proxyCall('updateTitle', title); + }, + + + updateToolbarButtons: function(dateProfile) { + var now = this.getNow(); + var view = this.view; + var todayInfo = view.buildDateProfile(now); + var prevInfo = view.buildPrevDateProfile(this.currentDate); + var nextInfo = view.buildNextDateProfile(this.currentDate); + + this.toolbarsManager.proxyCall( + (todayInfo.isValid && !dateProfile.currentUnzonedRange.containsDate(now)) ? + 'enableButton' : + 'disableButton', + 'today' + ); + + this.toolbarsManager.proxyCall( + prevInfo.isValid ? + 'enableButton' : + 'disableButton', + 'prev' + ); + + this.toolbarsManager.proxyCall( + nextInfo.isValid ? + 'enableButton' : + 'disableButton', + 'next' + ); + }, + + + queryToolbarsHeight: function() { + return this.toolbarsManager.items.reduce(function(accumulator, toolbar) { + var toolbarHeight = toolbar.el ? toolbar.el.outerHeight(true) : 0; // includes margin + return accumulator + toolbarHeight; + }, 0); + } + +}); + +;; + +/* +determines if eventInstanceGroup is allowed, +in relation to other EVENTS and business hours. +*/ +Calendar.prototype.isEventInstanceGroupAllowed = function(eventInstanceGroup) { + var eventDef = eventInstanceGroup.getEventDef(); + var eventFootprints = this.eventRangesToEventFootprints(eventInstanceGroup.getAllEventRanges()); + var i; + + var peerEventInstances = this.getPeerEventInstances(eventDef); + var peerEventRanges = peerEventInstances.map(eventInstanceToEventRange); + var peerEventFootprints = this.eventRangesToEventFootprints(peerEventRanges); + + var constraintVal = eventDef.getConstraint(); + var overlapVal = eventDef.getOverlap(); + + var eventAllowFunc = this.opt('eventAllow'); + + for (i = 0; i < eventFootprints.length; i++) { + if ( + !this.isFootprintAllowed( + eventFootprints[i].componentFootprint, + peerEventFootprints, + constraintVal, + overlapVal, + eventFootprints[i].eventInstance + ) + ) { + return false; + } + } + + if (eventAllowFunc) { + for (i = 0; i < eventFootprints.length; i++) { + if ( + eventAllowFunc( + eventFootprints[i].componentFootprint.toLegacy(this), + eventFootprints[i].getEventLegacy() + ) === false + ) { + return false; + } + } + } + + return true; +}; + + +Calendar.prototype.getPeerEventInstances = function(eventDef) { + return this.eventManager.getEventInstancesWithoutId(eventDef.id); +}; + + +Calendar.prototype.isSelectionFootprintAllowed = function(componentFootprint) { + var peerEventInstances = this.eventManager.getEventInstances(); + var peerEventRanges = peerEventInstances.map(eventInstanceToEventRange); + var peerEventFootprints = this.eventRangesToEventFootprints(peerEventRanges); + + var selectAllowFunc; + + if ( + this.isFootprintAllowed( + componentFootprint, + peerEventFootprints, + this.opt('selectConstraint'), + this.opt('selectOverlap') + ) + ) { + selectAllowFunc = this.opt('selectAllow'); + + if (selectAllowFunc) { + return selectAllowFunc(componentFootprint.toLegacy(this)) !== false; + } + else { + return true; + } + } + + return false; +}; + + +Calendar.prototype.isFootprintAllowed = function( + componentFootprint, + peerEventFootprints, + constraintVal, + overlapVal, + subjectEventInstance // optional +) { + var constraintFootprints; // ComponentFootprint[] + var overlapEventFootprints; // EventFootprint[] + + if (constraintVal != null) { + constraintFootprints = this.constraintValToFootprints(constraintVal, componentFootprint.isAllDay); + + if (!this.isFootprintWithinConstraints(componentFootprint, constraintFootprints)) { + return false; + } + } + + overlapEventFootprints = this.collectOverlapEventFootprints(peerEventFootprints, componentFootprint); + + if (overlapVal === false) { + if (overlapEventFootprints.length) { + return false; + } + } + else if (typeof overlapVal === 'function') { + if (!isOverlapsAllowedByFunc(overlapEventFootprints, overlapVal, subjectEventInstance)) { + return false; + } + } + + if (subjectEventInstance) { + if (!isOverlapEventInstancesAllowed(overlapEventFootprints, subjectEventInstance)) { + return false; + } + } + + return true; +}; + + +// Constraint +// ------------------------------------------------------------------------------------------------ + + +Calendar.prototype.isFootprintWithinConstraints = function(componentFootprint, constraintFootprints) { + var i; + + for (i = 0; i < constraintFootprints.length; i++) { + if (this.footprintContainsFootprint(constraintFootprints[i], componentFootprint)) { + return true; + } + } + + return false; +}; + + +Calendar.prototype.constraintValToFootprints = function(constraintVal, isAllDay) { + var eventInstances; + + if (constraintVal === 'businessHours') { + return this.buildCurrentBusinessFootprints(isAllDay); + } + else if (typeof constraintVal === 'object') { + eventInstances = this.parseEventDefToInstances(constraintVal); // handles recurring events + + if (!eventInstances) { // invalid input. fallback to parsing footprint directly + return this.parseFootprints(constraintVal); + } + else { + return this.eventInstancesToFootprints(eventInstances); + } + } + else if (constraintVal != null) { // an ID + eventInstances = this.eventManager.getEventInstancesWithId(constraintVal); + + return this.eventInstancesToFootprints(eventInstances); + } +}; + + +// returns ComponentFootprint[] +// uses current view's range +Calendar.prototype.buildCurrentBusinessFootprints = function(isAllDay) { + var view = this.view; + var businessHourGenerator = view.get('businessHourGenerator'); + var unzonedRange = view.dateProfile.activeUnzonedRange; + var eventInstanceGroup = businessHourGenerator.buildEventInstanceGroup(isAllDay, unzonedRange); + + if (eventInstanceGroup) { + return this.eventInstancesToFootprints(eventInstanceGroup.eventInstances); + } + else { + return []; + } +}; + + +// conversion util +Calendar.prototype.eventInstancesToFootprints = function(eventInstances) { + var eventRanges = eventInstances.map(eventInstanceToEventRange); + var eventFootprints = this.eventRangesToEventFootprints(eventRanges); + + return eventFootprints.map(eventFootprintToComponentFootprint); +}; + + +// Overlap +// ------------------------------------------------------------------------------------------------ + + +Calendar.prototype.collectOverlapEventFootprints = function(peerEventFootprints, targetFootprint) { + var overlapEventFootprints = []; + var i; + + for (i = 0; i < peerEventFootprints.length; i++) { + if ( + this.footprintsIntersect( + targetFootprint, + peerEventFootprints[i].componentFootprint + ) + ) { + overlapEventFootprints.push(peerEventFootprints[i]); + } + } + + return overlapEventFootprints; +}; + + +// optional subjectEventInstance +function isOverlapsAllowedByFunc(overlapEventFootprints, overlapFunc, subjectEventInstance) { + var i; + + for (i = 0; i < overlapEventFootprints.length; i++) { + if ( + !overlapFunc( + overlapEventFootprints[i].eventInstance.toLegacy(), + subjectEventInstance ? subjectEventInstance.toLegacy() : null + ) + ) { + return false; + } + } + + return true; +} + + +function isOverlapEventInstancesAllowed(overlapEventFootprints, subjectEventInstance) { + var subjectLegacyInstance = subjectEventInstance.toLegacy(); + var i; + var overlapEventInstance; + var overlapEventDef; + var overlapVal; + + for (i = 0; i < overlapEventFootprints.length; i++) { + overlapEventInstance = overlapEventFootprints[i].eventInstance; + overlapEventDef = overlapEventInstance.def; + + // don't need to pass in calendar, because don't want to consider global eventOverlap property, + // because we already considered that earlier in the process. + overlapVal = overlapEventDef.getOverlap(); + + if (overlapVal === false) { + return false; + } + else if (typeof overlapVal === 'function') { + if ( + !overlapVal( + overlapEventInstance.toLegacy(), + subjectLegacyInstance + ) + ) { + return false; + } + } + } + + return true; +} + + +// Conversion: eventDefs -> eventInstances -> eventRanges -> eventFootprints -> componentFootprints +// ------------------------------------------------------------------------------------------------ +// NOTE: this might seem like repetitive code with the Grid class, however, this code is related to +// constraints whereas the Grid code is related to rendering. Each approach might want to convert +// eventRanges -> eventFootprints in a different way. Regardless, there are opportunities to make +// this more DRY. + + +/* +Returns false on invalid input. +*/ +Calendar.prototype.parseEventDefToInstances = function(eventInput) { + var eventManager = this.eventManager; + var eventDef = EventDefParser.parse(eventInput, new EventSource(this)); + + if (!eventDef) { // invalid + return false; + } + + return eventDef.buildInstances(eventManager.currentPeriod.unzonedRange); +}; + + +Calendar.prototype.eventRangesToEventFootprints = function(eventRanges) { + var i; + var eventFootprints = []; + + for (i = 0; i < eventRanges.length; i++) { + eventFootprints.push.apply( // footprints + eventFootprints, + this.eventRangeToEventFootprints(eventRanges[i]) + ); + } + + return eventFootprints; +}; + + +Calendar.prototype.eventRangeToEventFootprints = function(eventRange) { + return [ eventRangeToEventFootprint(eventRange) ]; +}; + + +/* +Parses footprints directly. +Very similar to EventDateProfile::parse :( +*/ +Calendar.prototype.parseFootprints = function(rawInput) { + var start, end; + + if (rawInput.start) { + start = this.moment(rawInput.start); + + if (!start.isValid()) { + start = null; + } + } + + if (rawInput.end) { + end = this.moment(rawInput.end); + + if (!end.isValid()) { + end = null; + } + } + + return [ + new ComponentFootprint( + new UnzonedRange(start, end), + (start && !start.hasTime()) || (end && !end.hasTime()) // isAllDay + ) + ]; +}; + + +// Footprint Utils +// ---------------------------------------------------------------------------------------- + + +Calendar.prototype.footprintContainsFootprint = function(outerFootprint, innerFootprint) { + return outerFootprint.unzonedRange.containsRange(innerFootprint.unzonedRange); +}; + + +Calendar.prototype.footprintsIntersect = function(footprint0, footprint1) { + return footprint0.unzonedRange.intersectsWith(footprint1.unzonedRange); +}; + +;; + +Calendar.mixin({ + + // Sources + // ------------------------------------------------------------------------------------ + + + getEventSources: function() { + return this.eventManager.otherSources.slice(); // clone + }, + + + getEventSourceById: function(id) { + return this.eventManager.getSourceById( + EventSource.normalizeId(id) + ); + }, + + + addEventSource: function(sourceInput) { + var source = EventSourceParser.parse(sourceInput, this); + + if (source) { + this.eventManager.addSource(source); + } + }, + + + removeEventSources: function(sourceMultiQuery) { + var eventManager = this.eventManager; + var sources; + var i; + + if (sourceMultiQuery == null) { + this.eventManager.removeAllSources(); + } + else { + sources = eventManager.multiQuerySources(sourceMultiQuery); + + eventManager.freeze(); + + for (i = 0; i < sources.length; i++) { + eventManager.removeSource(sources[i]); + } + + eventManager.thaw(); + } + }, + + + removeEventSource: function(sourceQuery) { + var eventManager = this.eventManager; + var sources = eventManager.querySources(sourceQuery); + var i; + + eventManager.freeze(); + + for (i = 0; i < sources.length; i++) { + eventManager.removeSource(sources[i]); + } + + eventManager.thaw(); + }, + + + refetchEventSources: function(sourceMultiQuery) { + var eventManager = this.eventManager; + var sources = eventManager.multiQuerySources(sourceMultiQuery); + var i; + + eventManager.freeze(); + + for (i = 0; i < sources.length; i++) { + eventManager.refetchSource(sources[i]); + } + + eventManager.thaw(); + }, + + + // Events + // ------------------------------------------------------------------------------------ + + + refetchEvents: function() { + this.eventManager.refetchAllSources(); + }, + + + renderEvents: function(eventInputs, isSticky) { + this.eventManager.freeze(); + + for (var i = 0; i < eventInputs.length; i++) { + this.renderEvent(eventInputs[i], isSticky); + } + + this.eventManager.thaw(); + }, + + + renderEvent: function(eventInput, isSticky) { + var eventManager = this.eventManager; + var eventDef = EventDefParser.parse( + eventInput, + eventInput.source || eventManager.stickySource + ); + + if (eventDef) { + eventManager.addEventDef(eventDef, isSticky); + } + }, + + + // legacyQuery operates on legacy event instance objects + removeEvents: function(legacyQuery) { + var eventManager = this.eventManager; + var legacyInstances = []; + var idMap = {}; + var eventDef; + var i; + + if (legacyQuery == null) { // shortcut for removing all + eventManager.removeAllEventDefs(true); // persist=true + } + else { + eventManager.getEventInstances().forEach(function(eventInstance) { + legacyInstances.push(eventInstance.toLegacy()); + }); + + legacyInstances = filterLegacyEventInstances(legacyInstances, legacyQuery); + + // compute unique IDs + for (i = 0; i < legacyInstances.length; i++) { + eventDef = this.eventManager.getEventDefByUid(legacyInstances[i]._id); + idMap[eventDef.id] = true; + } + + eventManager.freeze(); + + for (i in idMap) { // reuse `i` as an "id" + eventManager.removeEventDefsById(i, true); // persist=true + } + + eventManager.thaw(); + } + }, + + + // legacyQuery operates on legacy event instance objects + clientEvents: function(legacyQuery) { + var legacyEventInstances = []; + + this.eventManager.getEventInstances().forEach(function(eventInstance) { + legacyEventInstances.push(eventInstance.toLegacy()); + }); + + return filterLegacyEventInstances(legacyEventInstances, legacyQuery); + }, + + + updateEvents: function(eventPropsArray) { + this.eventManager.freeze(); + + for (var i = 0; i < eventPropsArray.length; i++) { + this.updateEvent(eventPropsArray[i]); + } + + this.eventManager.thaw(); + }, + + + updateEvent: function(eventProps) { + var eventDef = this.eventManager.getEventDefByUid(eventProps._id); + var eventInstance; + var eventDefMutation; + + if (eventDef instanceof SingleEventDef) { + eventInstance = eventDef.buildInstance(); + + eventDefMutation = EventDefMutation.createFromRawProps( + eventInstance, + eventProps, // raw props + null // largeUnit -- who uses it? + ); + + this.eventManager.mutateEventsWithId(eventDef.id, eventDefMutation); // will release + } + } + +}); + + +function filterLegacyEventInstances(legacyEventInstances, legacyQuery) { + if (legacyQuery == null) { + return legacyEventInstances; + } + else if ($.isFunction(legacyQuery)) { + return legacyEventInstances.filter(legacyQuery); + } + else { // an event ID + legacyQuery += ''; // normalize to string + + return legacyEventInstances.filter(function(legacyEventInstance) { + // soft comparison because id not be normalized to string + return legacyEventInstance.id == legacyQuery || + legacyEventInstance._id === legacyQuery; // can specify internal id, but must exactly match + }); + } +} + +;; + +Calendar.defaults = { + + titleRangeSeparator: ' \u2013 ', // en dash + monthYearFormat: 'MMMM YYYY', // required for en. other locales rely on datepicker computable option + + defaultTimedEventDuration: '02:00:00', + defaultAllDayEventDuration: { days: 1 }, + forceEventDuration: false, + nextDayThreshold: '09:00:00', // 9am + + // display + columnHeader: true, + defaultView: 'month', + aspectRatio: 1.35, + header: { + left: 'title', + center: '', + right: 'today prev,next' + }, + weekends: true, + weekNumbers: false, + + weekNumberTitle: 'W', + weekNumberCalculation: 'local', + + //editable: false, + + //nowIndicator: false, + + scrollTime: '06:00:00', + minTime: '00:00:00', + maxTime: '24:00:00', + showNonCurrentDates: true, + + // event ajax + lazyFetching: true, + startParam: 'start', + endParam: 'end', + timezoneParam: 'timezone', + + timezone: false, + + //allDayDefault: undefined, + + // locale + isRTL: false, + buttonText: { + prev: "prev", + next: "next", + prevYear: "prev year", + nextYear: "next year", + year: 'year', // TODO: locale files need to specify this + today: 'today', + month: 'month', + week: 'week', + day: 'day' + }, + //buttonIcons: null, + + allDayText: 'all-day', + + // allows setting a min-height to the event segment to prevent short events overlapping each other + agendaEventMinHeight: 0, + + // jquery-ui theming + theme: false, + //themeButtonIcons: null, + + //eventResizableFromStart: false, + dragOpacity: .75, + dragRevertDuration: 500, + dragScroll: true, + + //selectable: false, + unselectAuto: true, + //selectMinDistance: 0, + + dropAccept: '*', + + eventOrder: 'title', + //eventRenderWait: null, + + eventLimit: false, + eventLimitText: 'more', + eventLimitClick: 'popover', + dayPopoverFormat: 'LL', + + handleWindowResize: true, + windowResizeDelay: 100, // milliseconds before an updateSize happens + + longPressDelay: 1000 + +}; + + +Calendar.englishDefaults = { // used by locale.js + dayPopoverFormat: 'dddd, MMMM D' +}; + + +Calendar.rtlDefaults = { // right-to-left defaults + header: { // TODO: smarter solution (first/center/last ?) + left: 'next,prev today', + center: '', + right: 'title' + }, + buttonIcons: { + prev: 'right-single-arrow', + next: 'left-single-arrow', + prevYear: 'right-double-arrow', + nextYear: 'left-double-arrow' + }, + themeButtonIcons: { + prev: 'circle-triangle-e', + next: 'circle-triangle-w', + nextYear: 'seek-prev', + prevYear: 'seek-next' + } +}; + +;; + +var localeOptionHash = FC.locales = {}; // initialize and expose + + +// TODO: document the structure and ordering of a FullCalendar locale file + + +// Initialize jQuery UI datepicker translations while using some of the translations +// Will set this as the default locales for datepicker. +FC.datepickerLocale = function(localeCode, dpLocaleCode, dpOptions) { + + // get the FullCalendar internal option hash for this locale. create if necessary + var fcOptions = localeOptionHash[localeCode] || (localeOptionHash[localeCode] = {}); + + // transfer some simple options from datepicker to fc + fcOptions.isRTL = dpOptions.isRTL; + fcOptions.weekNumberTitle = dpOptions.weekHeader; + + // compute some more complex options from datepicker + $.each(dpComputableOptions, function(name, func) { + fcOptions[name] = func(dpOptions); + }); + + // is jQuery UI Datepicker is on the page? + if ($.datepicker) { + + // Register the locale data. + // FullCalendar and MomentJS use locale codes like "pt-br" but Datepicker + // does it like "pt-BR" or if it doesn't have the locale, maybe just "pt". + // Make an alias so the locale can be referenced either way. + $.datepicker.regional[dpLocaleCode] = + $.datepicker.regional[localeCode] = // alias + dpOptions; + + // Alias 'en' to the default locale data. Do this every time. + $.datepicker.regional.en = $.datepicker.regional['']; + + // Set as Datepicker's global defaults. + $.datepicker.setDefaults(dpOptions); + } +}; + + +// Sets FullCalendar-specific translations. Will set the locales as the global default. +FC.locale = function(localeCode, newFcOptions) { + var fcOptions; + var momOptions; + + // get the FullCalendar internal option hash for this locale. create if necessary + fcOptions = localeOptionHash[localeCode] || (localeOptionHash[localeCode] = {}); + + // provided new options for this locales? merge them in + if (newFcOptions) { + fcOptions = localeOptionHash[localeCode] = mergeOptions([ fcOptions, newFcOptions ]); + } + + // compute locale options that weren't defined. + // always do this. newFcOptions can be undefined when initializing from i18n file, + // so no way to tell if this is an initialization or a default-setting. + momOptions = getMomentLocaleData(localeCode); // will fall back to en + $.each(momComputableOptions, function(name, func) { + if (fcOptions[name] == null) { + fcOptions[name] = func(momOptions, fcOptions); + } + }); + + // set it as the default locale for FullCalendar + Calendar.defaults.locale = localeCode; +}; + + +// NOTE: can't guarantee any of these computations will run because not every locale has datepicker +// configs, so make sure there are English fallbacks for these in the defaults file. +var dpComputableOptions = { + + buttonText: function(dpOptions) { + return { + // the translations sometimes wrongly contain HTML entities + prev: stripHtmlEntities(dpOptions.prevText), + next: stripHtmlEntities(dpOptions.nextText), + today: stripHtmlEntities(dpOptions.currentText) + }; + }, + + // Produces format strings like "MMMM YYYY" -> "September 2014" + monthYearFormat: function(dpOptions) { + return dpOptions.showMonthAfterYear ? + 'YYYY[' + dpOptions.yearSuffix + '] MMMM' : + 'MMMM YYYY[' + dpOptions.yearSuffix + ']'; + } + +}; + +var momComputableOptions = { + + // Produces format strings like "ddd M/D" -> "Fri 9/15" + dayOfMonthFormat: function(momOptions, fcOptions) { + var format = momOptions.longDateFormat('l'); // for the format like "M/D/YYYY" + + // strip the year off the edge, as well as other misc non-whitespace chars + format = format.replace(/^Y+[^\w\s]*|[^\w\s]*Y+$/g, ''); + + if (fcOptions.isRTL) { + format += ' ddd'; // for RTL, add day-of-week to end + } + else { + format = 'ddd ' + format; // for LTR, add day-of-week to beginning + } + return format; + }, + + // Produces format strings like "h:mma" -> "6:00pm" + mediumTimeFormat: function(momOptions) { // can't be called `timeFormat` because collides with option + return momOptions.longDateFormat('LT') + .replace(/\s*a$/i, 'a'); // convert AM/PM/am/pm to lowercase. remove any spaces beforehand + }, + + // Produces format strings like "h(:mm)a" -> "6pm" / "6:30pm" + smallTimeFormat: function(momOptions) { + return momOptions.longDateFormat('LT') + .replace(':mm', '(:mm)') + .replace(/(\Wmm)$/, '($1)') // like above, but for foreign locales + .replace(/\s*a$/i, 'a'); // convert AM/PM/am/pm to lowercase. remove any spaces beforehand + }, + + // Produces format strings like "h(:mm)t" -> "6p" / "6:30p" + extraSmallTimeFormat: function(momOptions) { + return momOptions.longDateFormat('LT') + .replace(':mm', '(:mm)') + .replace(/(\Wmm)$/, '($1)') // like above, but for foreign locales + .replace(/\s*a$/i, 't'); // convert to AM/PM/am/pm to lowercase one-letter. remove any spaces beforehand + }, + + // Produces format strings like "ha" / "H" -> "6pm" / "18" + hourFormat: function(momOptions) { + return momOptions.longDateFormat('LT') + .replace(':mm', '') + .replace(/(\Wmm)$/, '') // like above, but for foreign locales + .replace(/\s*a$/i, 'a'); // convert AM/PM/am/pm to lowercase. remove any spaces beforehand + }, + + // Produces format strings like "h:mm" -> "6:30" (with no AM/PM) + noMeridiemTimeFormat: function(momOptions) { + return momOptions.longDateFormat('LT') + .replace(/\s*a$/i, ''); // remove trailing AM/PM + } + +}; + + +// options that should be computed off live calendar options (considers override options) +// TODO: best place for this? related to locale? +// TODO: flipping text based on isRTL is a bad idea because the CSS `direction` might want to handle it +var instanceComputableOptions = { + + // Produces format strings for results like "Mo 16" + smallDayDateFormat: function(options) { + return options.isRTL ? + 'D dd' : + 'dd D'; + }, + + // Produces format strings for results like "Wk 5" + weekFormat: function(options) { + return options.isRTL ? + 'w[ ' + options.weekNumberTitle + ']' : + '[' + options.weekNumberTitle + ' ]w'; + }, + + // Produces format strings for results like "Wk5" + smallWeekFormat: function(options) { + return options.isRTL ? + 'w[' + options.weekNumberTitle + ']' : + '[' + options.weekNumberTitle + ']w'; + } + +}; + +// TODO: make these computable properties in optionsModel +function populateInstanceComputableOptions(options) { + $.each(instanceComputableOptions, function(name, func) { + if (options[name] == null) { + options[name] = func(options); + } + }); +} + + +// Returns moment's internal locale data. If doesn't exist, returns English. +function getMomentLocaleData(localeCode) { + return moment.localeData(localeCode) || moment.localeData('en'); +} + + +// Initialize English by forcing computation of moment-derived options. +// Also, sets it as the default. +FC.locale('en', Calendar.englishDefaults); + +;; + +var UnzonedRange = FC.UnzonedRange = Class.extend({ + + startMs: null, // if null, no start constraint + endMs: null, // if null, no end constraint + + // TODO: move these into footprint. + // Especially, doesn't make sense for null startMs/endMs. + isStart: true, + isEnd: true, + + constructor: function(startInput, endInput) { + + if (moment.isMoment(startInput)) { + startInput = startInput.clone().stripZone(); + } + + if (moment.isMoment(endInput)) { + endInput = endInput.clone().stripZone(); + } + + if (startInput) { + this.startMs = startInput.valueOf(); + } + + if (endInput) { + this.endMs = endInput.valueOf(); + } + }, + + intersect: function(otherRange) { + var startMs = this.startMs; + var endMs = this.endMs; + var newRange = null; + + if (otherRange.startMs !== null) { + if (startMs === null) { + startMs = otherRange.startMs; + } + else { + startMs = Math.max(startMs, otherRange.startMs); + } + } + + if (otherRange.endMs !== null) { + if (endMs === null) { + endMs = otherRange.endMs; + } + else { + endMs = Math.min(endMs, otherRange.endMs); + } + } + + if (startMs === null || endMs === null || startMs < endMs) { + newRange = new UnzonedRange(startMs, endMs); + newRange.isStart = this.isStart && startMs === this.startMs; + newRange.isEnd = this.isEnd && endMs === this.endMs; + } + + return newRange; + }, + + + intersectsWith: function(otherRange) { + return (this.endMs === null || otherRange.startMs === null || this.endMs > otherRange.startMs) && + (this.startMs === null || otherRange.endMs === null || this.startMs < otherRange.endMs); + }, + + + containsRange: function(innerRange) { + return (this.startMs === null || (innerRange.startMs !== null && innerRange.startMs >= this.startMs)) && + (this.endMs === null || (innerRange.endMs !== null && innerRange.endMs <= this.endMs)); + }, + + + // `date` can be a moment, a Date, or a millisecond time. + containsDate: function(date) { + var ms = date.valueOf(); + + return (this.startMs === null || ms >= this.startMs) && + (this.endMs === null || ms < this.endMs); + }, + + + // If the given date is not within the given range, move it inside. + // (If it's past the end, make it one millisecond before the end). + // `date` can be a moment, a Date, or a millisecond time. + // Returns a MS-time. + constrainDate: function(date) { + var ms = date.valueOf(); + + if (this.startMs !== null && ms < this.startMs) { + ms = this.startMs; + } + + if (this.endMs !== null && ms >= this.endMs) { + ms = this.endMs - 1; + } + + return ms; + }, + + + equals: function(otherRange) { + return this.startMs === otherRange.startMs && this.endMs === otherRange.endMs; + }, + + + clone: function() { + var range = new UnzonedRange(this.startMs, this.endMs); + + range.isStart = this.isStart; + range.isEnd = this.isEnd; + + return range; + }, + + + // Returns an ambig-zoned moment from startMs. + // BEWARE: returned moment is not localized. + // Formatting and start-of-week will be default. + getStart: function() { + if (this.startMs !== null) { + return FC.moment.utc(this.startMs).stripZone(); + } + }, + + // Returns an ambig-zoned moment from startMs. + // BEWARE: returned moment is not localized. + // Formatting and start-of-week will be default. + getEnd: function() { + if (this.endMs !== null) { + return FC.moment.utc(this.endMs).stripZone(); + } + }, + + + as: function(unit) { + return moment.utc(this.endMs).diff( + moment.utc(this.startMs), + unit, + true + ); + } + +}); + + +/* +SIDEEFFECT: will mutate eventRanges. +Will return a new array result. +Only works for non-open-ended ranges. +*/ +function invertUnzonedRanges(ranges, constraintRange) { + var invertedRanges = []; + var startMs = constraintRange.startMs; // the end of the previous range. the start of the new range + var i; + var dateRange; + + // ranges need to be in order. required for our date-walking algorithm + ranges.sort(compareUnzonedRanges); + + for (i = 0; i < ranges.length; i++) { + dateRange = ranges[i]; + + // add the span of time before the event (if there is any) + if (dateRange.startMs > startMs) { // compare millisecond time (skip any ambig logic) + invertedRanges.push( + new UnzonedRange(startMs, dateRange.startMs) + ); + } + + if (dateRange.endMs > startMs) { + startMs = dateRange.endMs; + } + } + + // add the span of time after the last event (if there is any) + if (startMs < constraintRange.endMs) { // compare millisecond time (skip any ambig logic) + invertedRanges.push( + new UnzonedRange(startMs, constraintRange.endMs) + ); + } + + return invertedRanges; +} + + +/* +Only works for non-open-ended ranges. +*/ +function compareUnzonedRanges(range1, range2) { + return range1.startMs - range2.startMs; // earlier ranges go first +} + +;; + +/* +Meant to be immutable +*/ +var ComponentFootprint = FC.ComponentFootprint = Class.extend({ + + unzonedRange: null, + isAllDay: false, // component can choose to ignore this + + + constructor: function(unzonedRange, isAllDay) { + this.unzonedRange = unzonedRange; + this.isAllDay = isAllDay; + }, + + + /* + Only works for non-open-ended ranges. + */ + toLegacy: function(calendar) { + return { + start: calendar.msToMoment(this.unzonedRange.startMs, this.isAllDay), + end: calendar.msToMoment(this.unzonedRange.endMs, this.isAllDay) + }; + } + +}); + +;; + +var EventPeriod = Class.extend(EmitterMixin, { + + start: null, + end: null, + timezone: null, + + unzonedRange: null, + + requestsByUid: null, + pendingCnt: 0, + + freezeDepth: 0, + stuntedReleaseCnt: 0, + releaseCnt: 0, + + eventDefsByUid: null, + eventDefsById: null, + eventInstanceGroupsById: null, + + + constructor: function(start, end, timezone) { + this.start = start; + this.end = end; + this.timezone = timezone; + + this.unzonedRange = new UnzonedRange( + start.clone().stripZone(), + end.clone().stripZone() + ); + + this.requestsByUid = {}; + this.eventDefsByUid = {}; + this.eventDefsById = {}; + this.eventInstanceGroupsById = {}; + }, + + + isWithinRange: function(start, end) { + // TODO: use a range util function? + return !start.isBefore(this.start) && !end.isAfter(this.end); + }, + + + // Requesting and Purging + // ----------------------------------------------------------------------------------------------------------------- + + + requestSources: function(sources) { + this.freeze(); + + for (var i = 0; i < sources.length; i++) { + this.requestSource(sources[i]); + } + + this.thaw(); + }, + + + requestSource: function(source) { + var _this = this; + var request = { source: source, status: 'pending' }; + + this.requestsByUid[source.uid] = request; + this.pendingCnt += 1; + + source.fetch(this.start, this.end, this.timezone).then(function(eventDefs) { + if (request.status !== 'cancelled') { + request.status = 'completed'; + request.eventDefs = eventDefs; + + _this.addEventDefs(eventDefs); + _this.pendingCnt--; + _this.tryRelease(); + } + }, function() { // failure + if (request.status !== 'cancelled') { + request.status = 'failed'; + + _this.pendingCnt--; + _this.tryRelease(); + } + }); + }, + + + purgeSource: function(source) { + var request = this.requestsByUid[source.uid]; + + if (request) { + delete this.requestsByUid[source.uid]; + + if (request.status === 'pending') { + request.status = 'cancelled'; + this.pendingCnt--; + this.tryRelease(); + } + else if (request.status === 'completed') { + request.eventDefs.forEach(this.removeEventDef.bind(this)); + } + } + }, + + + purgeAllSources: function() { + var requestsByUid = this.requestsByUid; + var uid, request; + var completedCnt = 0; + + for (uid in requestsByUid) { + request = requestsByUid[uid]; + + if (request.status === 'pending') { + request.status = 'cancelled'; + } + else if (request.status === 'completed') { + completedCnt++; + } + } + + this.requestsByUid = {}; + this.pendingCnt = 0; + + if (completedCnt) { + this.removeAllEventDefs(); // might release + } + }, + + + // Event Definitions + // ----------------------------------------------------------------------------------------------------------------- + + + getEventDefByUid: function(eventDefUid) { + return this.eventDefsByUid[eventDefUid]; + }, + + + getEventDefsById: function(eventDefId) { + var a = this.eventDefsById[eventDefId]; + + if (a) { + return a.slice(); // clone + } + + return []; + }, + + + addEventDefs: function(eventDefs) { + for (var i = 0; i < eventDefs.length; i++) { + this.addEventDef(eventDefs[i]); + } + }, + + + addEventDef: function(eventDef) { + var eventDefsById = this.eventDefsById; + var eventDefId = eventDef.id; + var eventDefs = eventDefsById[eventDefId] || (eventDefsById[eventDefId] = []); + var eventInstances = eventDef.buildInstances(this.unzonedRange); + var i; + + eventDefs.push(eventDef); + + this.eventDefsByUid[eventDef.uid] = eventDef; + + for (i = 0; i < eventInstances.length; i++) { + this.addEventInstance(eventInstances[i], eventDefId); + } + }, + + + removeEventDefsById: function(eventDefId) { + var _this = this; + + this.getEventDefsById(eventDefId).forEach(function(eventDef) { + _this.removeEventDef(eventDef); + }); + }, + + + removeAllEventDefs: function() { + var isEmpty = $.isEmptyObject(this.eventDefsByUid); + + this.eventDefsByUid = {}; + this.eventDefsById = {}; + this.eventInstanceGroupsById = {}; + + if (!isEmpty) { + this.tryRelease(); + } + }, + + + removeEventDef: function(eventDef) { + var eventDefsById = this.eventDefsById; + var eventDefs = eventDefsById[eventDef.id]; + + delete this.eventDefsByUid[eventDef.uid]; + + if (eventDefs) { + removeExact(eventDefs, eventDef); + + if (!eventDefs.length) { + delete eventDefsById[eventDef.id]; + } + + this.removeEventInstancesForDef(eventDef); + } + }, + + + // Event Instances + // ----------------------------------------------------------------------------------------------------------------- + + + getEventInstances: function() { // TODO: consider iterator + var eventInstanceGroupsById = this.eventInstanceGroupsById; + var eventInstances = []; + var id; + + for (id in eventInstanceGroupsById) { + eventInstances.push.apply(eventInstances, // append + eventInstanceGroupsById[id].eventInstances + ); + } + + return eventInstances; + }, + + + getEventInstancesWithId: function(eventDefId) { + var eventInstanceGroup = this.eventInstanceGroupsById[eventDefId]; + + if (eventInstanceGroup) { + return eventInstanceGroup.eventInstances.slice(); // clone + } + + return []; + }, + + + getEventInstancesWithoutId: function(eventDefId) { // TODO: consider iterator + var eventInstanceGroupsById = this.eventInstanceGroupsById; + var matchingInstances = []; + var id; + + for (id in eventInstanceGroupsById) { + if (id !== eventDefId) { + matchingInstances.push.apply(matchingInstances, // append + eventInstanceGroupsById[id].eventInstances + ); + } + } + + return matchingInstances; + }, + + + addEventInstance: function(eventInstance, eventDefId) { + var eventInstanceGroupsById = this.eventInstanceGroupsById; + var eventInstanceGroup = eventInstanceGroupsById[eventDefId] || + (eventInstanceGroupsById[eventDefId] = new EventInstanceGroup()); + + eventInstanceGroup.eventInstances.push(eventInstance); + + this.tryRelease(); + }, + + + removeEventInstancesForDef: function(eventDef) { + var eventInstanceGroupsById = this.eventInstanceGroupsById; + var eventInstanceGroup = eventInstanceGroupsById[eventDef.id]; + var removeCnt; + + if (eventInstanceGroup) { + removeCnt = removeMatching(eventInstanceGroup.eventInstances, function(currentEventInstance) { + return currentEventInstance.def === eventDef; + }); + + if (!eventInstanceGroup.eventInstances.length) { + delete eventInstanceGroupsById[eventDef.id]; + } + + if (removeCnt) { + this.tryRelease(); + } + } + }, + + + // Releasing and Freezing + // ----------------------------------------------------------------------------------------------------------------- + + + tryRelease: function() { + if (!this.pendingCnt) { + if (!this.freezeDepth) { + this.release(); + } + else { + this.stuntedReleaseCnt++; + } + } + }, + + + release: function() { + this.releaseCnt++; + this.trigger('release', this.eventInstanceGroupsById); + }, + + + whenReleased: function() { + var _this = this; + + if (this.releaseCnt) { + return Promise.resolve(this.eventInstanceGroupsById); + } + else { + return Promise.construct(function(onResolve) { + _this.one('release', onResolve); + }); + } + }, + + + freeze: function() { + if (!(this.freezeDepth++)) { + this.stuntedReleaseCnt = 0; + } + }, + + + thaw: function() { + if (!(--this.freezeDepth) && this.stuntedReleaseCnt && !this.pendingCnt) { + this.release(); + } + } + +}); + +;; + +var EventManager = Class.extend(EmitterMixin, ListenerMixin, { + + currentPeriod: null, + + calendar: null, + stickySource: null, + otherSources: null, // does not include sticky source + + + constructor: function(calendar) { + this.calendar = calendar; + this.stickySource = new ArrayEventSource(calendar); + this.otherSources = []; + }, + + + requestEvents: function(start, end, timezone, force) { + if ( + force || + !this.currentPeriod || + !this.currentPeriod.isWithinRange(start, end) || + timezone !== this.currentPeriod.timezone + ) { + this.setPeriod( // will change this.currentPeriod + new EventPeriod(start, end, timezone) + ); + } + + return this.currentPeriod.whenReleased(); + }, + + + // Source Adding/Removing + // ----------------------------------------------------------------------------------------------------------------- + + + addSource: function(eventSource) { + this.otherSources.push(eventSource); + + if (this.currentPeriod) { + this.currentPeriod.requestSource(eventSource); // might release + } + }, + + + removeSource: function(doomedSource) { + removeExact(this.otherSources, doomedSource); + + if (this.currentPeriod) { + this.currentPeriod.purgeSource(doomedSource); // might release + } + }, + + + removeAllSources: function() { + this.otherSources = []; + + if (this.currentPeriod) { + this.currentPeriod.purgeAllSources(); // might release + } + }, + + + // Source Refetching + // ----------------------------------------------------------------------------------------------------------------- + + + refetchSource: function(eventSource) { + var currentPeriod = this.currentPeriod; + + if (currentPeriod) { + currentPeriod.freeze(); + currentPeriod.purgeSource(eventSource); + currentPeriod.requestSource(eventSource); + currentPeriod.thaw(); + } + }, + + + refetchAllSources: function() { + var currentPeriod = this.currentPeriod; + + if (currentPeriod) { + currentPeriod.freeze(); + currentPeriod.purgeAllSources(); + currentPeriod.requestSources(this.getSources()); + currentPeriod.thaw(); + } + }, + + + // Source Querying + // ----------------------------------------------------------------------------------------------------------------- + + + getSources: function() { + return [ this.stickySource ].concat(this.otherSources); + }, + + + // like querySources, but accepts multple match criteria (like multiple IDs) + multiQuerySources: function(matchInputs) { + + // coerce into an array + if (!matchInputs) { + matchInputs = []; + } + else if (!$.isArray(matchInputs)) { + matchInputs = [ matchInputs ]; + } + + var matchingSources = []; + var i; + + // resolve raw inputs to real event source objects + for (i = 0; i < matchInputs.length; i++) { + matchingSources.push.apply( // append + matchingSources, + this.querySources(matchInputs[i]) + ); + } + + return matchingSources; + }, + + + // matchInput can either by a real event source object, an ID, or the function/URL for the source. + // returns an array of matching source objects. + querySources: function(matchInput) { + var sources = this.otherSources; + var i, source; + + // given a proper event source object + for (i = 0; i < sources.length; i++) { + source = sources[i]; + + if (source === matchInput) { + return [ source ]; + } + } + + // an ID match + source = this.getSourceById(EventSource.normalizeId(matchInput)); + if (source) { + return [ source ]; + } + + // parse as an event source + matchInput = EventSourceParser.parse(matchInput, this.calendar); + if (matchInput) { + + return $.grep(sources, function(source) { + return isSourcesEquivalent(matchInput, source); + }); + } + }, + + + /* + ID assumed to already be normalized + */ + getSourceById: function(id) { + return $.grep(this.otherSources, function(source) { + return source.id && source.id === id; + })[0]; + }, + + + // Event-Period + // ----------------------------------------------------------------------------------------------------------------- + + + setPeriod: function(eventPeriod) { + if (this.currentPeriod) { + this.unbindPeriod(this.currentPeriod); + this.currentPeriod = null; + } + + this.currentPeriod = eventPeriod; + this.bindPeriod(eventPeriod); + + eventPeriod.requestSources(this.getSources()); + }, + + + bindPeriod: function(eventPeriod) { + this.listenTo(eventPeriod, 'release', function(eventsPayload) { + this.trigger('release', eventsPayload); + }); + }, + + + unbindPeriod: function(eventPeriod) { + this.stopListeningTo(eventPeriod); + }, + + + // Event Getting/Adding/Removing + // ----------------------------------------------------------------------------------------------------------------- + + + getEventDefByUid: function(uid) { + if (this.currentPeriod) { + return this.currentPeriod.getEventDefByUid(uid); + } + }, + + + addEventDef: function(eventDef, isSticky) { + if (isSticky) { + this.stickySource.addEventDef(eventDef); + } + + if (this.currentPeriod) { + this.currentPeriod.addEventDef(eventDef); // might release + } + }, + + + removeEventDefsById: function(eventId) { + this.getSources().forEach(function(eventSource) { + eventSource.removeEventDefsById(eventId); + }); + + if (this.currentPeriod) { + this.currentPeriod.removeEventDefsById(eventId); // might release + } + }, + + + removeAllEventDefs: function() { + this.getSources().forEach(function(eventSource) { + eventSource.removeAllEventDefs(); + }); + + if (this.currentPeriod) { + this.currentPeriod.removeAllEventDefs(); + } + }, + + + // Event Mutating + // ----------------------------------------------------------------------------------------------------------------- + + + /* + Returns an undo function. + */ + mutateEventsWithId: function(eventDefId, eventDefMutation) { + var currentPeriod = this.currentPeriod; + var eventDefs; + var undoFuncs = []; + + if (currentPeriod) { + + currentPeriod.freeze(); + + eventDefs = currentPeriod.getEventDefsById(eventDefId); + eventDefs.forEach(function(eventDef) { + // add/remove esp because id might change + currentPeriod.removeEventDef(eventDef); + undoFuncs.push(eventDefMutation.mutateSingle(eventDef)); + currentPeriod.addEventDef(eventDef); + }); + + currentPeriod.thaw(); + + return function() { + currentPeriod.freeze(); + + for (var i = 0; i < eventDefs.length; i++) { + currentPeriod.removeEventDef(eventDefs[i]); + undoFuncs[i](); + currentPeriod.addEventDef(eventDefs[i]); + } + + currentPeriod.thaw(); + }; + } + + return function() { }; + }, + + + /* + copies and then mutates + */ + buildMutatedEventInstanceGroup: function(eventDefId, eventDefMutation) { + var eventDefs = this.getEventDefsById(eventDefId); + var i; + var defCopy; + var allInstances = []; + + for (i = 0; i < eventDefs.length; i++) { + defCopy = eventDefs[i].clone(); + + if (defCopy instanceof SingleEventDef) { + eventDefMutation.mutateSingle(defCopy); + + allInstances.push.apply(allInstances, // append + defCopy.buildInstances() + ); + } + } + + return new EventInstanceGroup(allInstances); + }, + + + // Freezing + // ----------------------------------------------------------------------------------------------------------------- + + + freeze: function() { + if (this.currentPeriod) { + this.currentPeriod.freeze(); + } + }, + + + thaw: function() { + if (this.currentPeriod) { + this.currentPeriod.thaw(); + } + } + +}); + + +// Methods that straight-up query the current EventPeriod for an array of results. +[ + 'getEventDefsById', + 'getEventInstances', + 'getEventInstancesWithId', + 'getEventInstancesWithoutId' +].forEach(function(methodName) { + + EventManager.prototype[methodName] = function() { + var currentPeriod = this.currentPeriod; + + if (currentPeriod) { + return currentPeriod[methodName].apply(currentPeriod, arguments); + } + + return []; + }; +}); + + +function isSourcesEquivalent(source0, source1) { + return source0.getPrimitive() == source1.getPrimitive(); +} + +;; + +var BUSINESS_HOUR_EVENT_DEFAULTS = { + start: '09:00', + end: '17:00', + dow: [ 1, 2, 3, 4, 5 ], // monday - friday + rendering: 'inverse-background' + // classNames are defined in businessHoursSegClasses +}; + + +var BusinessHourGenerator = FC.BusinessHourGenerator = Class.extend({ + + rawComplexDef: null, + calendar: null, // for anonymous EventSource + + + constructor: function(rawComplexDef, calendar) { + this.rawComplexDef = rawComplexDef; + this.calendar = calendar; + }, + + + buildEventInstanceGroup: function(isAllDay, unzonedRange) { + var eventDefs = this.buildEventDefs(isAllDay); + var eventInstanceGroup; + + if (eventDefs.length) { + eventInstanceGroup = new EventInstanceGroup( + eventDefsToEventInstances(eventDefs, unzonedRange) + ); + + // so that inverse-background rendering can happen even when no eventRanges in view + eventInstanceGroup.explicitEventDef = eventDefs[0]; + + return eventInstanceGroup; + } + }, + + + buildEventDefs: function(isAllDay) { + var rawComplexDef = this.rawComplexDef; + var rawDefs = []; + var requireDow = false; + var i; + var defs = []; + + if (rawComplexDef === true) { + rawDefs = [ {} ]; // will get BUSINESS_HOUR_EVENT_DEFAULTS verbatim + } + else if ($.isPlainObject(rawComplexDef)) { + rawDefs = [ rawComplexDef ]; + } + else if ($.isArray(rawComplexDef)) { + rawDefs = rawComplexDef; + requireDow = true; // every sub-definition NEEDS a day-of-week + } + + for (i = 0; i < rawDefs.length; i++) { + if (!requireDow || rawDefs[i].dow) { + defs.push( + this.buildEventDef(isAllDay, rawDefs[i]) + ); + } + } + + return defs; + }, + + + buildEventDef: function(isAllDay, rawDef) { + var fullRawDef = $.extend({}, BUSINESS_HOUR_EVENT_DEFAULTS, rawDef); + + if (isAllDay) { + fullRawDef.start = null; + fullRawDef.end = null; + } + + return RecurringEventDef.parse( + fullRawDef, + new EventSource(this.calendar) // dummy source + ); + } + +}); + +;; + +var EventDefParser = { + + parse: function(eventInput, source) { + if ( + isTimeString(eventInput.start) || moment.isDuration(eventInput.start) || + isTimeString(eventInput.end) || moment.isDuration(eventInput.end) + ) { + return RecurringEventDef.parse(eventInput, source); + } + else { + return SingleEventDef.parse(eventInput, source); + } + } + +}; + +;; + +var EventDef = FC.EventDef = Class.extend(ParsableModelMixin, { + + source: null, // required + + id: null, // normalized supplied ID + rawId: null, // unnormalized supplied ID + uid: null, // internal ID. new ID for every definition + + // NOTE: eventOrder sorting relies on these + title: null, + url: null, + rendering: null, + constraint: null, + overlap: null, + editable: null, + startEditable: null, + durationEditable: null, + color: null, + backgroundColor: null, + borderColor: null, + textColor: null, + + className: null, // an array. TODO: rename to className*s* (API breakage) + miscProps: null, + + + constructor: function(source) { + this.source = source; + this.className = []; + this.miscProps = {}; + }, + + + isAllDay: function() { + // subclasses must implement + }, + + + buildInstances: function(unzonedRange) { + // subclasses must implement + }, + + + clone: function() { + var copy = new this.constructor(this.source); + + copy.id = this.id; + copy.rawId = this.rawId; + copy.uid = this.uid; // not really unique anymore :( + + EventDef.copyVerbatimStandardProps(this, copy); + + copy.className = this.className.slice(); // copy + copy.miscProps = $.extend({}, this.miscProps); + + return copy; + }, + + + hasInverseRendering: function() { + return this.getRendering() === 'inverse-background'; + }, + + + hasBgRendering: function() { + var rendering = this.getRendering(); + + return rendering === 'inverse-background' || rendering === 'background'; + }, + + + getRendering: function() { + if (this.rendering != null) { + return this.rendering; + } + + return this.source.rendering; + }, + + + getConstraint: function() { + if (this.constraint != null) { + return this.constraint; + } + + if (this.source.constraint != null) { + return this.source.constraint; + } + + return this.source.calendar.opt('eventConstraint'); // what about View option? + }, + + + getOverlap: function() { + if (this.overlap != null) { + return this.overlap; + } + + if (this.source.overlap != null) { + return this.source.overlap; + } + + return this.source.calendar.opt('eventOverlap'); // what about View option? + }, + + + isStartExplicitlyEditable: function() { + if (this.startEditable !== null) { + return this.startEditable; + } + + return this.source.startEditable; + }, + + + isDurationExplicitlyEditable: function() { + if (this.durationEditable !== null) { + return this.durationEditable; + } + + return this.source.durationEditable; + }, + + + isExplicitlyEditable: function() { + if (this.editable !== null) { + return this.editable; + } + + return this.source.editable; + }, + + + toLegacy: function() { + var obj = $.extend({}, this.miscProps); + + obj._id = this.uid; + obj.source = this.source; + obj.className = this.className.slice(); // copy + obj.allDay = this.isAllDay(); + + if (this.rawId != null) { + obj.id = this.rawId; + } + + EventDef.copyVerbatimStandardProps(this, obj); + + return obj; + }, + + + applyManualStandardProps: function(rawProps) { + + if (rawProps.id != null) { + this.id = EventDef.normalizeId((this.rawId = rawProps.id)); + } + else { + this.id = EventDef.generateId(); + } + + if (rawProps._id != null) { // accept this prop, even tho somewhat internal + this.uid = String(rawProps._id); + } + else { + this.uid = EventDef.generateId(); + } + + // TODO: converge with EventSource + if ($.isArray(rawProps.className)) { + this.className = rawProps.className; + } + if (typeof rawProps.className === 'string') { + this.className = rawProps.className.split(/\s+/); + } + + return true; + }, + + + applyMiscProps: function(rawProps) { + $.extend(this.miscProps, rawProps); + } + +}); + +// finish initializing the mixin +EventDef.defineStandardProps = ParsableModelMixin_defineStandardProps; +EventDef.copyVerbatimStandardProps = ParsableModelMixin_copyVerbatimStandardProps; + + +// IDs +// --------------------------------------------------------------------------------------------------------------------- +// TODO: converge with EventSource + + +EventDef.uuid = 0; + + +EventDef.normalizeId = function(id) { + return String(id); +}; + + +EventDef.generateId = function() { + return '_fc' + (EventDef.uuid++); +}; + + +// Parsing +// --------------------------------------------------------------------------------------------------------------------- + + +EventDef.defineStandardProps({ + // not automatically assigned (`false`) + _id: false, + id: false, + className: false, + source: false, // will ignored + + // automatically assigned (`true`) + title: true, + url: true, + rendering: true, + constraint: true, + overlap: true, + editable: true, + startEditable: true, + durationEditable: true, + color: true, + backgroundColor: true, + borderColor: true, + textColor: true +}); + + +EventDef.parse = function(rawInput, source) { + var def = new this(source); + var calendarTransform = source.calendar.opt('eventDataTransform'); + var sourceTransform = source.eventDataTransform; + + if (calendarTransform) { + rawInput = calendarTransform(rawInput); + } + if (sourceTransform) { + rawInput = sourceTransform(rawInput); + } + + if (def.applyProps(rawInput)) { + return def; + } + + return false; +}; + +;; + +var SingleEventDef = EventDef.extend({ + + dateProfile: null, + + + /* + Will receive start/end params, but will be ignored. + */ + buildInstances: function() { + return [ this.buildInstance() ]; + }, + + + buildInstance: function() { + return new EventInstance( + this, // definition + this.dateProfile + ); + }, + + + isAllDay: function() { + return this.dateProfile.isAllDay(); + }, + + + clone: function() { + var def = EventDef.prototype.clone.call(this); + + def.dateProfile = this.dateProfile; + + return def; + }, + + + rezone: function() { + var calendar = this.source.calendar; + var dateProfile = this.dateProfile; + + this.dateProfile = new EventDateProfile( + calendar.moment(dateProfile.start), + dateProfile.end ? calendar.moment(dateProfile.end) : null, + calendar + ); + }, + + + /* + NOTE: if super-method fails, should still attempt to apply + */ + applyManualStandardProps: function(rawProps) { + var superSuccess = EventDef.prototype.applyManualStandardProps.apply(this, arguments); + var dateProfile = EventDateProfile.parse(rawProps, this.source); // returns null on failure + + if (dateProfile) { + this.dateProfile = dateProfile; + + // make sure `date` shows up in the legacy event objects as-is + if (rawProps.date != null) { + this.miscProps.date = rawProps.date; + } + + return superSuccess; + } + else { + return false; + } + } + +}); + + +// Parsing +// --------------------------------------------------------------------------------------------------------------------- + + +SingleEventDef.defineStandardProps({ // false = manually process + start: false, + date: false, // alias for 'start' + end: false, + allDay: false +}); + +;; + +var RecurringEventDef = EventDef.extend({ + + startTime: null, // duration + endTime: null, // duration, or null + dowHash: null, // object hash, or null + + + isAllDay: function() { + return !this.startTime && !this.endTime; + }, + + + buildInstances: function(unzonedRange) { + var calendar = this.source.calendar; + var unzonedDate = unzonedRange.getStart(); + var unzonedEnd = unzonedRange.getEnd(); + var zonedDayStart; + var instanceStart, instanceEnd; + var instances = []; + + while (unzonedDate.isBefore(unzonedEnd)) { + + // if everyday, or this particular day-of-week + if (!this.dowHash || this.dowHash[unzonedDate.day()]) { + + zonedDayStart = calendar.applyTimezone(unzonedDate); + instanceStart = zonedDayStart.clone(); + instanceEnd = null; + + if (this.startTime) { + instanceStart.time(this.startTime); + } + else { + instanceStart.stripTime(); + } + + if (this.endTime) { + instanceEnd = zonedDayStart.clone().time(this.endTime); + } + + instances.push( + new EventInstance( + this, // definition + new EventDateProfile(instanceStart, instanceEnd, calendar) + ) + ); + } + + unzonedDate.add(1, 'days'); + } + + return instances; + }, + + + setDow: function(dowNumbers) { + + if (!this.dowHash) { + this.dowHash = {}; + } + + for (var i = 0; i < dowNumbers.length; i++) { + this.dowHash[dowNumbers[i]] = true; + } + }, + + + clone: function() { + var def = EventDef.prototype.clone.call(this); + + if (def.startTime) { + def.startTime = moment.duration(this.startTime); + } + + if (def.endTime) { + def.endTime = moment.duration(this.endTime); + } + + if (this.dowHash) { + def.dowHash = $.extend({}, this.dowHash); + } + + return def; + }, + + + /* + NOTE: if super-method fails, should still attempt to apply + */ + applyProps: function(rawProps) { + var superSuccess = EventDef.prototype.applyProps.apply(this, arguments); + + if (rawProps.start) { + this.startTime = moment.duration(rawProps.start); + } + + if (rawProps.end) { + this.endTime = moment.duration(rawProps.end); + } + + if (rawProps.dow) { + this.setDow(rawProps.dow); + } + + return superSuccess; + } + +}); + + +// Parsing +// --------------------------------------------------------------------------------------------------------------------- + + +RecurringEventDef.defineStandardProps({ // false = manually process + start: false, + end: false, + dow: false +}); + +;; + +var EventInstance = Class.extend({ + + def: null, // EventDef + dateProfile: null, // EventDateProfile + + + constructor: function(def, dateProfile) { + this.def = def; + this.dateProfile = dateProfile; + }, + + + toLegacy: function() { + var dateProfile = this.dateProfile; + var obj = this.def.toLegacy(); + + obj.start = dateProfile.start.clone(); + obj.end = dateProfile.end ? dateProfile.end.clone() : null; + + return obj; + } + +}); + +;; + +/* +It's expected that there will be at least one EventInstance, +OR that an explicitEventDef is assigned. +*/ +var EventInstanceGroup = FC.EventInstanceGroup = Class.extend({ + + eventInstances: null, + explicitEventDef: null, // optional + + + constructor: function(eventInstances) { + this.eventInstances = eventInstances || []; + }, + + + getAllEventRanges: function(constraintRange) { + if (constraintRange) { + return this.sliceNormalRenderRanges(constraintRange); + } + else { + return this.eventInstances.map(eventInstanceToEventRange); + } + }, + + + sliceRenderRanges: function(constraintRange) { + if (this.isInverse()) { + return this.sliceInverseRenderRanges(constraintRange); + } + else { + return this.sliceNormalRenderRanges(constraintRange); + } + }, + + + sliceNormalRenderRanges: function(constraintRange) { + var eventInstances = this.eventInstances; + var i, eventInstance; + var slicedRange; + var slicedEventRanges = []; + + for (i = 0; i < eventInstances.length; i++) { + eventInstance = eventInstances[i]; + + slicedRange = eventInstance.dateProfile.unzonedRange.intersect(constraintRange); + + if (slicedRange) { + slicedEventRanges.push( + new EventRange( + slicedRange, + eventInstance.def, + eventInstance + ) + ); + } + } + + return slicedEventRanges; + }, + + + sliceInverseRenderRanges: function(constraintRange) { + var unzonedRanges = this.eventInstances.map(eventInstanceToUnzonedRange); + var ownerDef = this.getEventDef(); + + unzonedRanges = invertUnzonedRanges(unzonedRanges, constraintRange); + + return unzonedRanges.map(function(unzonedRange) { + return new EventRange(unzonedRange, ownerDef); // don't give an EventInstance + }); + }, + + + isInverse: function() { + return this.getEventDef().hasInverseRendering(); + }, + + + getEventDef: function() { + return this.explicitEventDef || this.eventInstances[0].def; + } + +}); + +;; + +/* +Meant to be immutable +*/ +var EventDateProfile = Class.extend({ + + start: null, + end: null, + unzonedRange: null, + + + constructor: function(start, end, calendar) { + this.start = start; + this.end = end || null; + this.unzonedRange = this.buildUnzonedRange(calendar); + }, + + + isAllDay: function() { // why recompute this every time? + return !(this.start.hasTime() || (this.end && this.end.hasTime())); + }, + + + /* + Needs a Calendar object + */ + buildUnzonedRange: function(calendar) { + var startMs = this.start.clone().stripZone().valueOf(); + var endMs = this.getEnd(calendar).stripZone().valueOf(); + + return new UnzonedRange(startMs, endMs); + }, + + + /* + Needs a Calendar object + */ + getEnd: function(calendar) { + return this.end ? + this.end.clone() : + // derive the end from the start and allDay. compute allDay if necessary + calendar.getDefaultEventEnd( + this.isAllDay(), + this.start + ); + } + +}); + + +EventDateProfile.isStandardProp = function(propName) { + return propName === 'start' || propName === 'date' || propName === 'end' || propName === 'allDay'; +}; + + +/* +Needs an EventSource object +*/ +EventDateProfile.parse = function(rawProps, source) { + var startInput = rawProps.start || rawProps.date; + var endInput = rawProps.end; + + if (!startInput) { + return false; + } + + var calendar = source.calendar; + var start = calendar.moment(startInput); + var end = endInput ? calendar.moment(endInput) : null; + var forcedAllDay = rawProps.allDay; + var forceEventDuration = calendar.opt('forceEventDuration'); + + if (!start.isValid()) { + return false; + } + + if (end && (!end.isValid() || !end.isAfter(start))) { + end = null; + } + + if (forcedAllDay == null) { + forcedAllDay = source.allDayDefault; + if (forcedAllDay == null) { + forcedAllDay = calendar.opt('allDayDefault'); + } + } + + if (forcedAllDay === true) { + start.stripTime(); + if (end) { + end.stripTime(); + } + } + else if (forcedAllDay === false) { + if (!start.hasTime()) { + start.time(0); + } + if (end && !end.hasTime()) { + end.time(0); + } + } + + if (!end && forceEventDuration) { + end = calendar.getDefaultEventEnd(!start.hasTime(), start); + } + + return new EventDateProfile(start, end, calendar); +}; + +;; + +var EventRange = Class.extend({ + + unzonedRange: null, + eventDef: null, + eventInstance: null, // optional + + + constructor: function(unzonedRange, eventDef, eventInstance) { + this.unzonedRange = unzonedRange; + this.eventDef = eventDef; + + if (eventInstance) { + this.eventInstance = eventInstance; + } + } + +}); + +;; + +var EventFootprint = FC.EventFootprint = Class.extend({ + + componentFootprint: null, + eventDef: null, + eventInstance: null, // optional + + + constructor: function(componentFootprint, eventDef, eventInstance) { + this.componentFootprint = componentFootprint; + this.eventDef = eventDef; + + if (eventInstance) { + this.eventInstance = eventInstance; + } + }, + + + getEventLegacy: function() { + return (this.eventInstance || this.eventDef).toLegacy(); + } + +}); + +;; + +var EventDefMutation = FC.EventDefMutation = Class.extend({ + + // won't ever be empty. will be null instead. + // callers should use setDateMutation for setting. + dateMutation: null, + + // hacks to get updateEvent/createFromRawProps to work. + // not undo-able and not considered in isEmpty. + eventDefId: null, // standard manual props + className: null, // " + verbatimStandardProps: null, + miscProps: null, + + + /* + eventDef assumed to be a SingleEventDef. + returns an undo function. + */ + mutateSingle: function(eventDef) { + var origDateProfile; + + if (this.dateMutation) { + origDateProfile = eventDef.dateProfile; + + eventDef.dateProfile = this.dateMutation.buildNewDateProfile( + origDateProfile, + eventDef.source.calendar + ); + } + + // can't undo + // TODO: more DRY with EventDef::applyManualStandardProps + if (this.eventDefId != null) { + eventDef.id = EventDef.normalizeId((eventDef.rawId = this.eventDefId)); + } + + // can't undo + // TODO: more DRY with EventDef::applyManualStandardProps + if (this.className) { + eventDef.className = this.className; + } + + // can't undo + if (this.verbatimStandardProps) { + SingleEventDef.copyVerbatimStandardProps( + this.verbatimStandardProps, // src + eventDef // dest + ); + } + + // can't undo + if (this.miscProps) { + eventDef.applyMiscProps(this.miscProps); + } + + if (origDateProfile) { + return function() { + eventDef.dateProfile = origDateProfile; + }; + } + else { + return function() { }; + } + }, + + + setDateMutation: function(dateMutation) { + if (dateMutation && !dateMutation.isEmpty()) { + this.dateMutation = dateMutation; + } + else { + this.dateMutation = null; + } + }, + + + isEmpty: function() { + return !this.dateMutation; + } + +}); + + +EventDefMutation.createFromRawProps = function(eventInstance, rawProps, largeUnit) { + var eventDef = eventInstance.def; + var dateProps = {}; + var standardProps = {}; + var miscProps = {}; + var verbatimStandardProps = {}; + var eventDefId = null; + var className = null; + var propName; + var dateProfile; + var dateMutation; + var defMutation; + + for (propName in rawProps) { + if (EventDateProfile.isStandardProp(propName)) { + dateProps[propName] = rawProps[propName]; + } + else if (eventDef.isStandardProp(propName)) { + standardProps[propName] = rawProps[propName]; + } + else if (eventDef.miscProps[propName] !== rawProps[propName]) { // only if changed + miscProps[propName] = rawProps[propName]; + } + } + + dateProfile = EventDateProfile.parse(dateProps, eventDef.source); + + if (dateProfile) { // no failure? + dateMutation = EventDefDateMutation.createFromDiff( + eventInstance.dateProfile, + dateProfile, + largeUnit + ); + } + + if (standardProps.id !== eventDef.id) { + eventDefId = standardProps.id; // only apply if there's a change + } + + if (!isArraysEqual(standardProps.className, eventDef.className)) { + className = standardProps.className; // only apply if there's a change + } + + EventDef.copyVerbatimStandardProps( + standardProps, // src + verbatimStandardProps // dest + ); + + defMutation = new EventDefMutation(); + defMutation.eventDefId = eventDefId; + defMutation.className = className; + defMutation.verbatimStandardProps = verbatimStandardProps; + defMutation.miscProps = miscProps; + + if (dateMutation) { + defMutation.dateMutation = dateMutation; + } + + return defMutation; +}; + +;; + +var EventDefDateMutation = Class.extend({ + + clearEnd: false, + forceTimed: false, + forceAllDay: false, + + // Durations. if 0-ms duration, will be null instead. + // Callers should not set this directly. + dateDelta: null, + startDelta: null, + endDelta: null, + + + /* + returns an undo function. + */ + buildNewDateProfile: function(eventDateProfile, calendar) { + var start = eventDateProfile.start.clone(); + var end = null; + var shouldRezone = false; + + if (eventDateProfile.end && !this.clearEnd) { + end = eventDateProfile.end.clone(); + } + // if there will be an end-date mutation, guarantee an end, + // ambigously-zoned according to the original allDay + else if (this.endDelta && !end) { + end = calendar.getDefaultEventEnd(eventDateProfile.isAllDay(), start); + } + + if (this.forceTimed) { + shouldRezone = true; + + if (!start.hasTime()) { + start.time(0); + } + + if (end && !end.hasTime()) { + end.time(0); + } + } + else if (this.forceAllDay) { + + if (start.hasTime()) { + start.stripTime(); + } + + if (end && end.hasTime()) { + end.stripTime(); + } + } + + if (this.dateDelta) { + shouldRezone = true; + + start.add(this.dateDelta); + + if (end) { + end.add(this.dateDelta); + } + } + + // do this before adding startDelta to start, so we can work off of start + if (this.endDelta) { + shouldRezone = true; + + end.add(this.endDelta); + } + + if (this.startDelta) { + shouldRezone = true; + + start.add(this.startDelta); + } + + if (shouldRezone) { + start = calendar.applyTimezone(start); + + if (end) { + end = calendar.applyTimezone(end); + } + } + + // TODO: okay to access calendar option? + if (!end && calendar.opt('forceEventDuration')) { + end = calendar.getDefaultEventEnd(eventDateProfile.isAllDay(), start); + } + + return new EventDateProfile(start, end, calendar); + }, + + + setDateDelta: function(dateDelta) { + if (dateDelta && dateDelta.valueOf()) { + this.dateDelta = dateDelta; + } + else { + this.dateDelta = null; + } + }, + + + setStartDelta: function(startDelta) { + if (startDelta && startDelta.valueOf()) { + this.startDelta = startDelta; + } + else { + this.startDelta = null; + } + }, + + + setEndDelta: function(endDelta) { + if (endDelta && endDelta.valueOf()) { + this.endDelta = endDelta; + } + else { + this.endDelta = null; + } + }, + + + isEmpty: function() { + return !this.clearEnd && !this.forceTimed && !this.forceAllDay && + !this.dateDelta && !this.startDelta && !this.endDelta; + } + +}); + + +EventDefDateMutation.createFromDiff = function(dateProfile0, dateProfile1, largeUnit) { + var clearEnd = dateProfile0.end && !dateProfile1.end; + var forceTimed = dateProfile0.isAllDay() && !dateProfile1.isAllDay(); + var forceAllDay = !dateProfile0.isAllDay() && dateProfile1.isAllDay(); + var dateDelta; + var endDiff; + var endDelta; + var mutation; + + // subtracts the dates in the appropriate way, returning a duration + function subtractDates(date1, date0) { // date1 - date0 + if (largeUnit) { + return diffByUnit(date1, date0, largeUnit); // poorly named + } + else if (dateProfile1.isAllDay()) { + return diffDay(date1, date0); // poorly named + } + else { + return diffDayTime(date1, date0); // poorly named + } + } + + dateDelta = subtractDates(dateProfile1.start, dateProfile0.start); + + if (dateProfile1.end) { + // use unzonedRanges because dateProfile0.end might be null + endDiff = subtractDates( + dateProfile1.unzonedRange.getEnd(), + dateProfile0.unzonedRange.getEnd() + ); + endDelta = endDiff.subtract(dateDelta); + } + + mutation = new EventDefDateMutation(); + mutation.clearEnd = clearEnd; + mutation.forceTimed = forceTimed; + mutation.forceAllDay = forceAllDay; + mutation.setDateDelta(dateDelta); + mutation.setEndDelta(endDelta); + + return mutation; +}; + +;; + +function eventDefsToEventInstances(eventDefs, unzonedRange) { + var eventInstances = []; + var i; + + for (i = 0; i < eventDefs.length; i++) { + eventInstances.push.apply(eventInstances, // append + eventDefs[i].buildInstances(unzonedRange) + ); + } + + return eventInstances; +} + + +function eventInstanceToEventRange(eventInstance) { + return new EventRange( + eventInstance.dateProfile.unzonedRange, + eventInstance.def, + eventInstance + ); +} + + +function eventRangeToEventFootprint(eventRange) { + return new EventFootprint( + new ComponentFootprint( + eventRange.unzonedRange, + eventRange.eventDef.isAllDay() + ), + eventRange.eventDef, + eventRange.eventInstance // might not exist + ); +} + + +function eventInstanceToUnzonedRange(eventInstance) { + return eventInstance.dateProfile.unzonedRange; +} + + +function eventFootprintToComponentFootprint(eventFootprint) { + return eventFootprint.componentFootprint; +} + +;; + +var EventSource = Class.extend(ParsableModelMixin, { + + calendar: null, + + id: null, // can stay null + uid: null, + color: null, + backgroundColor: null, + borderColor: null, + textColor: null, + className: null, // array + editable: null, + startEditable: null, + durationEditable: null, + rendering: null, + overlap: null, + constraint: null, + allDayDefault: null, + eventDataTransform: null, // optional function + + + // can we do away with calendar? at least for the abstract? + // useful for buildEventDef + constructor: function(calendar) { + this.calendar = calendar; + this.className = []; + this.uid = String(EventSource.uuid++); + }, + + + fetch: function(start, end, timezone) { + // subclasses must implement. must return a promise. + }, + + + removeEventDefsById: function(eventDefId) { + // optional for subclasses to implement + }, + + + removeAllEventDefs: function() { + // optional for subclasses to implement + }, + + + /* + For compairing/matching + */ + getPrimitive: function(otherSource) { + // subclasses must implement + }, + + + parseEventDefs: function(rawEventDefs) { + var i; + var eventDef; + var eventDefs = []; + + for (i = 0; i < rawEventDefs.length; i++) { + eventDef = EventDefParser.parse( + rawEventDefs[i], + this // source + ); + + if (eventDef) { + eventDefs.push(eventDef); + } + } + + return eventDefs; + }, + + + applyManualStandardProps: function(rawProps) { + + if (rawProps.id != null) { + this.id = EventSource.normalizeId(rawProps.id); + } + + // TODO: converge with EventDef + if ($.isArray(rawProps.className)) { + this.className = rawProps.className; + } + else if (typeof rawProps.className === 'string') { + this.className = rawProps.className.split(/\s+/); + } + + return true; + } + +}); + + +// finish initializing the mixin +EventSource.defineStandardProps = ParsableModelMixin_defineStandardProps; + + +// IDs +// --------------------------------------------------------------------------------------------------------------------- +// TODO: converge with EventDef + + +EventSource.uuid = 0; + + +EventSource.normalizeId = function(id) { + if (id) { + return String(id); + } + + return null; +}; + + +// Parsing +// --------------------------------------------------------------------------------------------------------------------- + + +EventSource.defineStandardProps({ + // manually process... + id: false, + className: false, + + // automatically transfer... + color: true, + backgroundColor: true, + borderColor: true, + textColor: true, + editable: true, + startEditable: true, + durationEditable: true, + rendering: true, + overlap: true, + constraint: true, + allDayDefault: true, + eventDataTransform: true +}); + + +/* +rawInput can be any data type! +*/ +EventSource.parse = function(rawInput, calendar) { + var source = new this(calendar); + + if (typeof rawInput === 'object') { + if (source.applyProps(rawInput)) { + return source; + } + } + + return false; +}; + + +FC.EventSource = EventSource; + +;; + +var EventSourceParser = { + + sourceClasses: [], + + + registerClass: function(EventSourceClass) { + this.sourceClasses.unshift(EventSourceClass); // give highest priority + }, + + + parse: function(rawInput, calendar) { + var sourceClasses = this.sourceClasses; + var i; + var eventSource; + + for (i = 0; i < sourceClasses.length; i++) { + eventSource = sourceClasses[i].parse(rawInput, calendar); + + if (eventSource) { + return eventSource; + } + } + } + +}; + + +FC.EventSourceParser = EventSourceParser; + +;; + +var ArrayEventSource = EventSource.extend({ + + rawEventDefs: null, // unparsed + eventDefs: null, + currentTimezone: null, + + + constructor: function(calendar) { + EventSource.apply(this, arguments); // super-constructor + this.eventDefs = []; // for if setRawEventDefs is never called + }, + + + setRawEventDefs: function(rawEventDefs) { + this.rawEventDefs = rawEventDefs; + this.eventDefs = this.parseEventDefs(rawEventDefs); + }, + + + fetch: function(start, end, timezone) { + var eventDefs = this.eventDefs; + var i; + + if ( + this.currentTimezone !== null && + this.currentTimezone !== timezone + ) { + for (i = 0; i < eventDefs.length; i++) { + if (eventDefs[i] instanceof SingleEventDef) { + eventDefs[i].rezone(); + } + } + } + + this.currentTimezone = timezone; + + return Promise.resolve(eventDefs); + }, + + + addEventDef: function(eventDef) { + this.eventDefs.push(eventDef); + }, + + + /* + eventDefId already normalized to a string + */ + removeEventDefsById: function(eventDefId) { + return removeMatching(this.eventDefs, function(eventDef) { + return eventDef.id === eventDefId; + }); + }, + + + removeAllEventDefs: function() { + this.eventDefs = []; + }, + + + getPrimitive: function() { + return this.rawEventDefs; + }, + + + applyManualStandardProps: function(rawProps) { + var superSuccess = EventSource.prototype.applyManualStandardProps.apply(this, arguments); + + this.setRawEventDefs(rawProps.events); + + return superSuccess; + } + +}); + + +ArrayEventSource.defineStandardProps({ + events: false // don't automatically transfer +}); + + +ArrayEventSource.parse = function(rawInput, calendar) { + var rawProps; + + // normalize raw input + if ($.isArray(rawInput.events)) { // extended form + rawProps = rawInput; + } + else if ($.isArray(rawInput)) { // short form + rawProps = { events: rawInput }; + } + + if (rawProps) { + return EventSource.parse.call(this, rawProps, calendar); + } + + return false; +}; + + +EventSourceParser.registerClass(ArrayEventSource); + +FC.ArrayEventSource = ArrayEventSource; + +;; + +var FuncEventSource = EventSource.extend({ + + func: null, + + + fetch: function(start, end, timezone) { + var _this = this; + + this.calendar.pushLoading(); + + return Promise.construct(function(onResolve) { + _this.func.call( + _this.calendar, + start.clone(), + end.clone(), + timezone, + function(rawEventDefs) { + _this.calendar.popLoading(); + + onResolve(_this.parseEventDefs(rawEventDefs)); + } + ); + }); + }, + + + getPrimitive: function() { + return this.func; + }, + + + applyManualStandardProps: function(rawProps) { + var superSuccess = EventSource.prototype.applyManualStandardProps.apply(this, arguments); + + this.func = rawProps.events; + + return superSuccess; + } + +}); + + +FuncEventSource.defineStandardProps({ + events: false // don't automatically transfer +}); + + +FuncEventSource.parse = function(rawInput, calendar) { + var rawProps; + + // normalize raw input + if ($.isFunction(rawInput.events)) { // extended form + rawProps = rawInput; + } + else if ($.isFunction(rawInput)) { // short form + rawProps = { events: rawInput }; + } + + if (rawProps) { + return EventSource.parse.call(this, rawProps, calendar); + } + + return false; +}; + + +EventSourceParser.registerClass(FuncEventSource); + +FC.FuncEventSource = FuncEventSource; + +;; + +var JsonFeedEventSource = EventSource.extend({ + + // these props must all be manually set before calling fetch + url: null, + startParam: null, + endParam: null, + timezoneParam: null, + ajaxSettings: null, // does not include url + + + fetch: function(start, end, timezone) { + var _this = this; + var ajaxSettings = this.ajaxSettings; + var onSuccess = ajaxSettings.success; + var onError = ajaxSettings.error; + var requestParams = this.buildRequestParams(start, end, timezone); + + // todo: eventually handle the promise's then, + // don't intercept success/error + // tho will be a breaking API change + + this.calendar.pushLoading(); + + return Promise.construct(function(onResolve, onReject) { + $.ajax($.extend( + {}, // destination + JsonFeedEventSource.AJAX_DEFAULTS, + ajaxSettings, + { + url: _this.url, + data: requestParams, + success: function(rawEventDefs) { + var callbackRes; + + _this.calendar.popLoading(); + + if (rawEventDefs) { + callbackRes = applyAll(onSuccess, this, arguments); // redirect `this` + + if ($.isArray(callbackRes)) { + rawEventDefs = callbackRes; + } + + onResolve(_this.parseEventDefs(rawEventDefs)); + } + else { + onReject(); + } + }, + error: function() { + _this.calendar.popLoading(); + + applyAll(onError, this, arguments); // redirect `this` + onReject(); + } + } + )); + }); + }, + + + buildRequestParams: function(start, end, timezone) { + var calendar = this.calendar; + var ajaxSettings = this.ajaxSettings; + var startParam, endParam, timezoneParam; + var customRequestParams; + var params = {}; + + startParam = this.startParam; + if (startParam == null) { + startParam = calendar.opt('startParam'); + } + + endParam = this.endParam; + if (endParam == null) { + endParam = calendar.opt('endParam'); + } + + timezoneParam = this.timezoneParam; + if (timezoneParam == null) { + timezoneParam = calendar.opt('timezoneParam'); + } + + // retrieve any outbound GET/POST $.ajax data from the options + if ($.isFunction(ajaxSettings.data)) { + // supplied as a function that returns a key/value object + customRequestParams = ajaxSettings.data(); + } + else { + // probably supplied as a straight key/value object + customRequestParams = ajaxSettings.data || {}; + } + + $.extend(params, customRequestParams); + + params[startParam] = start.format(); + params[endParam] = end.format(); + + if (timezone && timezone !== 'local') { + params[timezoneParam] = timezone; + } + + return params; + }, + + + getPrimitive: function() { + return this.url; + }, + + + applyMiscProps: function(rawProps) { + EventSource.prototype.applyMiscProps.apply(this, arguments); + + this.ajaxSettings = rawProps; + } + +}); + + +JsonFeedEventSource.AJAX_DEFAULTS = { + dataType: 'json', + cache: false +}; + + +JsonFeedEventSource.defineStandardProps({ + // automatically transfer (true)... + url: true, + startParam: true, + endParam: true, + timezoneParam: true +}); + + +JsonFeedEventSource.parse = function(rawInput, calendar) { + var rawProps; + + // normalize raw input + if (typeof rawInput.url === 'string') { // extended form + rawProps = rawInput; + } + else if (typeof rawInput === 'string') { // short form + rawProps = { url: rawInput }; + } + + if (rawProps) { + return EventSource.parse.call(this, rawProps, calendar); + } + + return false; +}; + + +EventSourceParser.registerClass(JsonFeedEventSource); + +FC.JsonFeedEventSource = JsonFeedEventSource; + +;; + +var ThemeRegistry = FC.ThemeRegistry = { + + themeClassHash: {}, + + + register: function(themeName, themeClass) { + this.themeClassHash[themeName] = themeClass; + }, + + + getThemeClass: function(themeSetting) { + if (!themeSetting) { + return StandardTheme; + } + else if (themeSetting === true) { + return JqueryUiTheme; + } + else { + return this.themeClassHash[themeSetting]; + } + } + +}; + +;; + +var Theme = FC.Theme = Class.extend({ + + classes: {}, + iconClasses: {}, + baseIconClass: '', + iconOverrideOption: null, + iconOverrideCustomButtonOption: null, + iconOverridePrefix: '', + + + constructor: function(optionsModel) { + this.optionsModel = optionsModel; + this.processIconOverride(); + }, + + + processIconOverride: function() { + if (this.iconOverrideOption) { + this.setIconOverride( + this.optionsModel.get(this.iconOverrideOption) + ); + } + }, + + + setIconOverride: function(iconOverrideHash) { + var iconClassesCopy; + var buttonName; + + if ($.isPlainObject(iconOverrideHash)) { + iconClassesCopy = $.extend({}, this.iconClasses); + + for (buttonName in iconOverrideHash) { + iconClassesCopy[buttonName] = this.applyIconOverridePrefix( + iconOverrideHash[buttonName] + ); + } + + this.iconClasses = iconClassesCopy; + } + else if (iconOverrideHash === false) { + this.iconClasses = {}; + } + }, + + + applyIconOverridePrefix: function(className) { + var prefix = this.iconOverridePrefix; + + if (prefix && className.indexOf(prefix) !== 0) { // if not already present + className = prefix + className; + } + + return className; + }, + + + getClass: function(key) { + return this.classes[key] || ''; + }, + + + getIconClass: function(buttonName) { + var className = this.iconClasses[buttonName]; + + if (className) { + return this.baseIconClass + ' ' + className; + } + + return ''; + }, + + + getCustomButtonIconClass: function(customButtonProps) { + var className; + + if (this.iconOverrideCustomButtonOption) { + className = customButtonProps[this.iconOverrideCustomButtonOption]; + + if (className) { + return this.baseIconClass + ' ' + this.applyIconOverridePrefix(className); + } + } + + return ''; + } + +}); + +;; + +var StandardTheme = Theme.extend({ + + classes: { + widget: 'fc-unthemed', + widgetHeader: 'fc-widget-header', + widgetContent: 'fc-widget-content', + + buttonGroup: 'fc-button-group', + button: 'fc-button', + cornerLeft: 'fc-corner-left', + cornerRight: 'fc-corner-right', + stateDefault: 'fc-state-default', + stateActive: 'fc-state-active', + stateDisabled: 'fc-state-disabled', + stateHover: 'fc-state-hover', + stateDown: 'fc-state-down', + + popoverHeader: 'fc-widget-header', + popoverContent: 'fc-widget-content', + + // day grid + headerRow: 'fc-widget-header', + dayRow: 'fc-widget-content', + + // list view + listView: 'fc-widget-content' + }, + + baseIconClass: 'fc-icon', + iconClasses: { + close: 'fc-icon-x', + prev: 'fc-icon-left-single-arrow', + next: 'fc-icon-right-single-arrow', + prevYear: 'fc-icon-left-double-arrow', + nextYear: 'fc-icon-right-double-arrow' + }, + + iconOverrideOption: 'buttonIcons', + iconOverrideCustomButtonOption: 'icon', + iconOverridePrefix: 'fc-icon-' + +}); + +ThemeRegistry.register('standard', StandardTheme); + +;; + +var JqueryUiTheme = Theme.extend({ + + classes: { + widget: 'ui-widget', + widgetHeader: 'ui-widget-header', + widgetContent: 'ui-widget-content', + + buttonGroup: 'fc-button-group', + button: 'ui-button', + cornerLeft: 'ui-corner-left', + cornerRight: 'ui-corner-right', + stateDefault: 'ui-state-default', + stateActive: 'ui-state-active', + stateDisabled: 'ui-state-disabled', + stateHover: 'ui-state-hover', + stateDown: 'ui-state-down', + + today: 'ui-state-highlight', + + popoverHeader: 'ui-widget-header', + popoverContent: 'ui-widget-content', + + // day grid + headerRow: 'ui-widget-header', + dayRow: 'ui-widget-content', + + // list view + listView: 'ui-widget-content' + }, + + baseIconClass: 'ui-icon', + iconClasses: { + close: 'ui-icon-closethick', + prev: 'ui-icon-circle-triangle-w', + next: 'ui-icon-circle-triangle-e', + prevYear: 'ui-icon-seek-prev', + nextYear: 'ui-icon-seek-next' + }, + + iconOverrideOption: 'themeButtonIcons', + iconOverrideCustomButtonOption: 'themeIcon', + iconOverridePrefix: 'ui-icon-' + +}); + +ThemeRegistry.register('jquery-ui', JqueryUiTheme); + +;; + +var BootstrapTheme = Theme.extend({ + + classes: { + widget: 'fc-bootstrap3', + + tableGrid: 'table-bordered', // avoid `table` class b/c don't want margins. only border color + tableList: 'table table-striped', // `table` class creates bottom margin but who cares + + buttonGroup: 'btn-group', + button: 'btn btn-default', + stateActive: 'active', + stateDisabled: 'disabled', + + today: 'alert alert-info', // the plain `info` class requires `.table`, too much to ask + + popover: 'panel panel-default', + popoverHeader: 'panel-heading', + popoverContent: 'panel-body', + + // day grid + headerRow: 'panel-default', // avoid `panel` class b/c don't want margins/radius. only border color + dayRow: 'panel-default', // " + + // list view + listView: 'panel panel-default' + }, + + baseIconClass: 'glyphicon', + iconClasses: { + close: 'glyphicon-remove', + prev: 'glyphicon-chevron-left', + next: 'glyphicon-chevron-right', + prevYear: 'glyphicon-backward', + nextYear: 'glyphicon-forward' + }, + + iconOverrideOption: 'bootstrapGlyphicons', + iconOverrideCustomButtonOption: 'bootstrapGlyphicon', + iconOverridePrefix: 'glyphicon-' + +}); + +ThemeRegistry.register('bootstrap3', BootstrapTheme); + +;; + +var DayGridFillRenderer = FillRenderer.extend({ + + fillSegTag: 'td', // override the default tag name + + + attachSegEls: function(type, segs) { + var nodes = []; + var i, seg; + var skeletonEl; + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + skeletonEl = this.renderFillRow(type, seg); + this.component.rowEls.eq(seg.row).append(skeletonEl); + nodes.push(skeletonEl[0]); + } + + return nodes; + }, + + + // Generates the HTML needed for one row of a fill. Requires the seg's el to be rendered. + renderFillRow: function(type, seg) { + var colCnt = this.component.colCnt; + var startCol = seg.leftCol; + var endCol = seg.rightCol + 1; + var className; + var skeletonEl; + var trEl; + + if (type === 'businessHours') { + className = 'bgevent'; + } + else { + className = type.toLowerCase(); + } + + skeletonEl = $( + '
' + + '
' + + '
' + ); + trEl = skeletonEl.find('tr'); + + if (startCol > 0) { + trEl.append(''); + } + + trEl.append( + seg.el.attr('colspan', endCol - startCol) + ); + + if (endCol < colCnt) { + trEl.append(''); + } + + this.component.bookendCells(trEl); + + return skeletonEl; + } +}); + +;; + +/* Event-rendering methods for the DayGrid class +----------------------------------------------------------------------------------------------------------------------*/ + +var DayGridEventRenderer = EventRenderer.extend({ + + dayGrid: null, + rowStructs: null, // an array of objects, each holding information about a row's foreground event-rendering + + + constructor: function(dayGrid) { + EventRenderer.apply(this, arguments); + + this.dayGrid = dayGrid; + }, + + + renderBgRanges: function(eventRanges) { + // don't render timed background events + eventRanges = $.grep(eventRanges, function(eventRange) { + return eventRange.eventDef.isAllDay(); + }); + + EventRenderer.prototype.renderBgRanges.call(this, eventRanges); + }, + + + // Renders the given foreground event segments onto the grid + renderFgSegs: function(segs) { + var rowStructs = this.rowStructs = this.renderSegRows(segs); + + // append to each row's content skeleton + this.dayGrid.rowEls.each(function(i, rowNode) { + $(rowNode).find('.fc-content-skeleton > table').append( + rowStructs[i].tbodyEl + ); + }); + }, + + + // Unrenders all currently rendered foreground event segments + unrenderFgSegs: function() { + var rowStructs = this.rowStructs || []; + var rowStruct; + + while ((rowStruct = rowStructs.pop())) { + rowStruct.tbodyEl.remove(); + } + + this.rowStructs = null; + }, + + + // Uses the given events array to generate elements that should be appended to each row's content skeleton. + // Returns an array of rowStruct objects (see the bottom of `renderSegRow`). + // PRECONDITION: each segment shoud already have a rendered and assigned `.el` + renderSegRows: function(segs) { + var rowStructs = []; + var segRows; + var row; + + segRows = this.groupSegRows(segs); // group into nested arrays + + // iterate each row of segment groupings + for (row = 0; row < segRows.length; row++) { + rowStructs.push( + this.renderSegRow(row, segRows[row]) + ); + } + + return rowStructs; + }, + + + // Given a row # and an array of segments all in the same row, render a element, a skeleton that contains + // the segments. Returns object with a bunch of internal data about how the render was calculated. + // NOTE: modifies rowSegs + renderSegRow: function(row, rowSegs) { + var colCnt = this.dayGrid.colCnt; + var segLevels = this.buildSegLevels(rowSegs); // group into sub-arrays of levels + var levelCnt = Math.max(1, segLevels.length); // ensure at least one level + var tbody = $(''); + var segMatrix = []; // lookup for which segments are rendered into which level+col cells + var cellMatrix = []; // lookup for all elements of the level+col matrix + var loneCellMatrix = []; // lookup for elements that only take up a single column + var i, levelSegs; + var col; + var tr; + var j, seg; + var td; + + // populates empty cells from the current column (`col`) to `endCol` + function emptyCellsUntil(endCol) { + while (col < endCol) { + // try to grab a cell from the level above and extend its rowspan. otherwise, create a fresh cell + td = (loneCellMatrix[i - 1] || [])[col]; + if (td) { + td.attr( + 'rowspan', + parseInt(td.attr('rowspan') || 1, 10) + 1 + ); + } + else { + td = $(''); + tr.append(td); + } + cellMatrix[i][col] = td; + loneCellMatrix[i][col] = td; + col++; + } + } + + for (i = 0; i < levelCnt; i++) { // iterate through all levels + levelSegs = segLevels[i]; + col = 0; + tr = $(''); + + segMatrix.push([]); + cellMatrix.push([]); + loneCellMatrix.push([]); + + // levelCnt might be 1 even though there are no actual levels. protect against this. + // this single empty row is useful for styling. + if (levelSegs) { + for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level + seg = levelSegs[j]; + + emptyCellsUntil(seg.leftCol); + + // create a container that occupies or more columns. append the event element. + td = $('').append(seg.el); + if (seg.leftCol != seg.rightCol) { + td.attr('colspan', seg.rightCol - seg.leftCol + 1); + } + else { // a single-column segment + loneCellMatrix[i][col] = td; + } + + while (col <= seg.rightCol) { + cellMatrix[i][col] = td; + segMatrix[i][col] = seg; + col++; + } + + tr.append(td); + } + } + + emptyCellsUntil(colCnt); // finish off the row + this.dayGrid.bookendCells(tr); + tbody.append(tr); + } + + return { // a "rowStruct" + row: row, // the row number + tbodyEl: tbody, + cellMatrix: cellMatrix, + segMatrix: segMatrix, + segLevels: segLevels, + segs: rowSegs + }; + }, + + + // Stacks a flat array of segments, which are all assumed to be in the same row, into subarrays of vertical levels. + // NOTE: modifies segs + buildSegLevels: function(segs) { + var levels = []; + var i, seg; + var j; + + // Give preference to elements with certain criteria, so they have + // a chance to be closer to the top. + this.sortEventSegs(segs); + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + + // loop through levels, starting with the topmost, until the segment doesn't collide with other segments + for (j = 0; j < levels.length; j++) { + if (!isDaySegCollision(seg, levels[j])) { + break; + } + } + // `j` now holds the desired subrow index + seg.level = j; + + // create new level array if needed and append segment + (levels[j] || (levels[j] = [])).push(seg); + } + + // order segments left-to-right. very important if calendar is RTL + for (j = 0; j < levels.length; j++) { + levels[j].sort(compareDaySegCols); + } + + return levels; + }, + + + // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's row + groupSegRows: function(segs) { + var segRows = []; + var i; + + for (i = 0; i < this.dayGrid.rowCnt; i++) { + segRows.push([]); + } + + for (i = 0; i < segs.length; i++) { + segRows[segs[i].row].push(segs[i]); + } + + return segRows; + }, + + + // Computes a default event time formatting string if `timeFormat` is not explicitly defined + computeEventTimeFormat: function() { + return this.opt('extraSmallTimeFormat'); // like "6p" or "6:30p" + }, + + + // Computes a default `displayEventEnd` value if one is not expliclty defined + computeDisplayEventEnd: function() { + return this.dayGrid.colCnt === 1; // we'll likely have space if there's only one day + }, + + + // Builds the HTML to be used for the default element for an individual segment + fgSegHtml: function(seg, disableResizing) { + var view = this.view; + var eventDef = seg.footprint.eventDef; + var isAllDay = seg.footprint.componentFootprint.isAllDay; + var isDraggable = view.isEventDefDraggable(eventDef); + var isResizableFromStart = !disableResizing && isAllDay && + seg.isStart && view.isEventDefResizableFromStart(eventDef); + var isResizableFromEnd = !disableResizing && isAllDay && + seg.isEnd && view.isEventDefResizableFromEnd(eventDef); + var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd); + var skinCss = cssToStr(this.getSkinCss(eventDef)); + var timeHtml = ''; + var timeText; + var titleHtml; + + classes.unshift('fc-day-grid-event', 'fc-h-event'); + + // Only display a timed events time if it is the starting segment + if (seg.isStart) { + timeText = this.getTimeText(seg.footprint); + if (timeText) { + timeHtml = '' + htmlEscape(timeText) + ''; + } + } + + titleHtml = + '' + + (htmlEscape(eventDef.title || '') || ' ') + // we always want one line of height + ''; + + return '' + + '
' + + (this.isRTL ? + titleHtml + ' ' + timeHtml : // put a natural space in between + timeHtml + ' ' + titleHtml // + ) + + '
' + + (isResizableFromStart ? + '
' : + '' + ) + + (isResizableFromEnd ? + '
' : + '' + ) + + ''; + } + +}); + + +// Computes whether two segments' columns collide. They are assumed to be in the same row. +function isDaySegCollision(seg, otherSegs) { + var i, otherSeg; + + for (i = 0; i < otherSegs.length; i++) { + otherSeg = otherSegs[i]; + + if ( + otherSeg.leftCol <= seg.rightCol && + otherSeg.rightCol >= seg.leftCol + ) { + return true; + } + } + + return false; +} + + +// A cmp function for determining the leftmost event +function compareDaySegCols(a, b) { + return a.leftCol - b.leftCol; +} + +;; + +var DayGridHelperRenderer = HelperRenderer.extend({ + + + // Renders a mock "helper" event. `sourceSeg` is the associated internal segment object. It can be null. + renderSegs: function(segs, sourceSeg) { + var helperNodes = []; + var rowStructs; + + // TODO: not good to call eventRenderer this way + rowStructs = this.eventRenderer.renderSegRows(segs); + + // inject each new event skeleton into each associated row + this.component.rowEls.each(function(row, rowNode) { + var rowEl = $(rowNode); // the .fc-row + var skeletonEl = $('
'); // will be absolutely positioned + var skeletonTopEl; + var skeletonTop; + + // If there is an original segment, match the top position. Otherwise, put it at the row's top level + if (sourceSeg && sourceSeg.row === row) { + skeletonTop = sourceSeg.el.position().top; + } + else { + skeletonTopEl = rowEl.find('.fc-content-skeleton tbody'); + if (!skeletonTopEl.length) { // when no events + skeletonTopEl = rowEl.find('.fc-content-skeleton table'); + } + + skeletonTop = skeletonTopEl.position().top; + } + + skeletonEl.css('top', skeletonTop) + .find('table') + .append(rowStructs[row].tbodyEl); + + rowEl.append(skeletonEl); + helperNodes.push(skeletonEl[0]); + }); + + return $(helperNodes); // must return the elements rendered + } + +}); + +;; + +/* A component that renders a grid of whole-days that runs horizontally. There can be multiple rows, one per week. +----------------------------------------------------------------------------------------------------------------------*/ + +var DayGrid = FC.DayGrid = InteractiveDateComponent.extend(StandardInteractionsMixin, DayTableMixin, { + + eventRendererClass: DayGridEventRenderer, + businessHourRendererClass: BusinessHourRenderer, + helperRendererClass: DayGridHelperRenderer, + fillRendererClass: DayGridFillRenderer, + + view: null, // TODO: make more general and/or remove + helperRenderer: null, + + cellWeekNumbersVisible: false, // display week numbers in day cell? + + bottomCoordPadding: 0, // hack for extending the hit area for the last row of the coordinate grid + + headContainerEl: null, // div that hold's the date header + rowEls: null, // set of fake row elements + cellEls: null, // set of whole-day elements comprising the row's background + + rowCoordCache: null, + colCoordCache: null, + + // isRigid determines whether the individual rows should ignore the contents and be a constant height. + // Relies on the view's colCnt and rowCnt. In the future, this component should probably be self-sufficient. + isRigid: false, + + hasAllDayBusinessHours: true, + + + constructor: function(view) { + this.view = view; // do first, for opt calls during initialization + + InteractiveDateComponent.call(this); + }, + + + // Slices up the given span (unzoned start/end with other misc data) into an array of segments + componentFootprintToSegs: function(componentFootprint) { + var segs = this.sliceRangeByRow(componentFootprint.unzonedRange); + var i, seg; + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + + if (this.isRTL) { + seg.leftCol = this.daysPerRow - 1 - seg.lastRowDayIndex; + seg.rightCol = this.daysPerRow - 1 - seg.firstRowDayIndex; + } + else { + seg.leftCol = seg.firstRowDayIndex; + seg.rightCol = seg.lastRowDayIndex; + } + } + + return segs; + }, + + + /* Date Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + renderDates: function(dateProfile) { + this.dateProfile = dateProfile; + this.updateDayTable(); + this.renderGrid(); + }, + + + unrenderDates: function() { + this.removeSegPopover(); + }, + + + // Renders the rows and columns into the component's `this.el`, which should already be assigned. + renderGrid: function() { + var view = this.view; + var rowCnt = this.rowCnt; + var colCnt = this.colCnt; + var html = ''; + var row; + var col; + + if (this.headContainerEl) { + this.headContainerEl.html(this.renderHeadHtml()); + } + + for (row = 0; row < rowCnt; row++) { + html += this.renderDayRowHtml(row, this.isRigid); + } + this.el.html(html); + + this.rowEls = this.el.find('.fc-row'); + this.cellEls = this.el.find('.fc-day, .fc-disabled-day'); + + this.rowCoordCache = new CoordCache({ + els: this.rowEls, + isVertical: true + }); + this.colCoordCache = new CoordCache({ + els: this.cellEls.slice(0, this.colCnt), // only the first row + isHorizontal: true + }); + + // trigger dayRender with each cell's element + for (row = 0; row < rowCnt; row++) { + for (col = 0; col < colCnt; col++) { + this.publiclyTrigger('dayRender', { + context: view, + args: [ + this.getCellDate(row, col), + this.getCellEl(row, col), + view + ] + }); + } + } + }, + + + // Generates the HTML for a single row, which is a div that wraps a table. + // `row` is the row number. + renderDayRowHtml: function(row, isRigid) { + var theme = this.view.calendar.theme; + var classes = [ 'fc-row', 'fc-week', theme.getClass('dayRow') ]; + + if (isRigid) { + classes.push('fc-rigid'); + } + + return '' + + '
' + + '
' + + '
' + + this.renderBgTrHtml(row) + + '
' + + '
' + + '
' + + '' + + (this.getIsNumbersVisible() ? + '' + + this.renderNumberTrHtml(row) + + '' : + '' + ) + + '
' + + '
' + + '
'; + }, + + + getIsNumbersVisible: function() { + return this.getIsDayNumbersVisible() || this.cellWeekNumbersVisible; + }, + + + getIsDayNumbersVisible: function() { + return this.rowCnt > 1; + }, + + + /* Grid Number Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + renderNumberTrHtml: function(row) { + return '' + + '' + + (this.isRTL ? '' : this.renderNumberIntroHtml(row)) + + this.renderNumberCellsHtml(row) + + (this.isRTL ? this.renderNumberIntroHtml(row) : '') + + ''; + }, + + + renderNumberIntroHtml: function(row) { + return this.renderIntroHtml(); + }, + + + renderNumberCellsHtml: function(row) { + var htmls = []; + var col, date; + + for (col = 0; col < this.colCnt; col++) { + date = this.getCellDate(row, col); + htmls.push(this.renderNumberCellHtml(date)); + } + + return htmls.join(''); + }, + + + // Generates the HTML for the s of the "number" row in the DayGrid's content skeleton. + // The number row will only exist if either day numbers or week numbers are turned on. + renderNumberCellHtml: function(date) { + var view = this.view; + var html = ''; + var isDateValid = this.dateProfile.activeUnzonedRange.containsDate(date); // TODO: called too frequently. cache somehow. + var isDayNumberVisible = this.getIsDayNumbersVisible() && isDateValid; + var classes; + var weekCalcFirstDoW; + + if (!isDayNumberVisible && !this.cellWeekNumbersVisible) { + // no numbers in day cell (week number must be along the side) + return ''; // will create an empty space above events :( + } + + classes = this.getDayClasses(date); + classes.unshift('fc-day-top'); + + if (this.cellWeekNumbersVisible) { + // To determine the day of week number change under ISO, we cannot + // rely on moment.js methods such as firstDayOfWeek() or weekday(), + // because they rely on the locale's dow (possibly overridden by + // our firstDay option), which may not be Monday. We cannot change + // dow, because that would affect the calendar start day as well. + if (date._locale._fullCalendar_weekCalc === 'ISO') { + weekCalcFirstDoW = 1; // Monday by ISO 8601 definition + } + else { + weekCalcFirstDoW = date._locale.firstDayOfWeek(); + } + } + + html += ''; + + if (this.cellWeekNumbersVisible && (date.day() == weekCalcFirstDoW)) { + html += view.buildGotoAnchorHtml( + { date: date, type: 'week' }, + { 'class': 'fc-week-number' }, + date.format('w') // inner HTML + ); + } + + if (isDayNumberVisible) { + html += view.buildGotoAnchorHtml( + date, + { 'class': 'fc-day-number' }, + date.date() // inner HTML + ); + } + + html += ''; + + return html; + }, + + + /* Hit System + ------------------------------------------------------------------------------------------------------------------*/ + + + prepareHits: function() { + this.colCoordCache.build(); + this.rowCoordCache.build(); + this.rowCoordCache.bottoms[this.rowCnt - 1] += this.bottomCoordPadding; // hack + }, + + + releaseHits: function() { + this.colCoordCache.clear(); + this.rowCoordCache.clear(); + }, + + + queryHit: function(leftOffset, topOffset) { + if (this.colCoordCache.isLeftInBounds(leftOffset) && this.rowCoordCache.isTopInBounds(topOffset)) { + var col = this.colCoordCache.getHorizontalIndex(leftOffset); + var row = this.rowCoordCache.getVerticalIndex(topOffset); + + if (row != null && col != null) { + return this.getCellHit(row, col); + } + } + }, + + + getHitFootprint: function(hit) { + var range = this.getCellRange(hit.row, hit.col); + + return new ComponentFootprint( + new UnzonedRange(range.start, range.end), + true // all-day? + ); + }, + + + getHitEl: function(hit) { + return this.getCellEl(hit.row, hit.col); + }, + + + /* Cell System + ------------------------------------------------------------------------------------------------------------------*/ + // FYI: the first column is the leftmost column, regardless of date + + + getCellHit: function(row, col) { + return { + row: row, + col: col, + component: this, // needed unfortunately :( + left: this.colCoordCache.getLeftOffset(col), + right: this.colCoordCache.getRightOffset(col), + top: this.rowCoordCache.getTopOffset(row), + bottom: this.rowCoordCache.getBottomOffset(row) + }; + }, + + + getCellEl: function(row, col) { + return this.cellEls.eq(row * this.colCnt + col); + }, + + + /* Event Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + // Unrenders all events currently rendered on the grid + unrenderEvents: function() { + this.removeSegPopover(); // removes the "more.." events popover + + InteractiveDateComponent.prototype.unrenderEvents.apply(this, arguments); + }, + + + // Retrieves all rendered segment objects currently rendered on the grid + getOwnEventSegs: function() { + return InteractiveDateComponent.prototype.getOwnEventSegs.apply(this, arguments) // get the segments from the super-method + .concat(this.popoverSegs || []); // append the segments from the "more..." popover + }, + + + /* Event Drag Visualization + ------------------------------------------------------------------------------------------------------------------*/ + + + // Renders a visual indication of an event or external element being dragged. + // `eventLocation` has zoned start and end (optional) + renderDrag: function(eventFootprints, seg, isTouch) { + var i; + + for (i = 0; i < eventFootprints.length; i++) { + this.renderHighlight(eventFootprints[i].componentFootprint); + } + + // render drags from OTHER components as helpers + if (eventFootprints.length && seg && seg.component !== this) { + this.helperRenderer.renderEventDraggingFootprints(eventFootprints, seg, isTouch); + + return true; // signal helpers rendered + } + }, + + + // Unrenders any visual indication of a hovering event + unrenderDrag: function(seg) { + this.unrenderHighlight(); + this.helperRenderer.unrender(); + }, + + + /* Event Resize Visualization + ------------------------------------------------------------------------------------------------------------------*/ + + + // Renders a visual indication of an event being resized + renderEventResize: function(eventFootprints, seg, isTouch) { + var i; + + for (i = 0; i < eventFootprints.length; i++) { + this.renderHighlight(eventFootprints[i].componentFootprint); + } + + this.helperRenderer.renderEventResizingFootprints(eventFootprints, seg, isTouch); + }, + + + // Unrenders a visual indication of an event being resized + unrenderEventResize: function(seg) { + this.unrenderHighlight(); + this.helperRenderer.unrender(); + } + +}); + +;; + +/* Methods relate to limiting the number events for a given day on a DayGrid +----------------------------------------------------------------------------------------------------------------------*/ +// NOTE: all the segs being passed around in here are foreground segs + +DayGrid.mixin({ + + segPopover: null, // the Popover that holds events that can't fit in a cell. null when not visible + popoverSegs: null, // an array of segment objects that the segPopover holds. null when not visible + + + removeSegPopover: function() { + if (this.segPopover) { + this.segPopover.hide(); // in handler, will call segPopover's removeElement + } + }, + + + // Limits the number of "levels" (vertically stacking layers of events) for each row of the grid. + // `levelLimit` can be false (don't limit), a number, or true (should be computed). + limitRows: function(levelLimit) { + var rowStructs = this.eventRenderer.rowStructs || []; + var row; // row # + var rowLevelLimit; + + for (row = 0; row < rowStructs.length; row++) { + this.unlimitRow(row); + + if (!levelLimit) { + rowLevelLimit = false; + } + else if (typeof levelLimit === 'number') { + rowLevelLimit = levelLimit; + } + else { + rowLevelLimit = this.computeRowLevelLimit(row); + } + + if (rowLevelLimit !== false) { + this.limitRow(row, rowLevelLimit); + } + } + }, + + + // Computes the number of levels a row will accomodate without going outside its bounds. + // Assumes the row is "rigid" (maintains a constant height regardless of what is inside). + // `row` is the row number. + computeRowLevelLimit: function(row) { + var rowEl = this.rowEls.eq(row); // the containing "fake" row div + var rowHeight = rowEl.height(); // TODO: cache somehow? + var trEls = this.eventRenderer.rowStructs[row].tbodyEl.children(); + var i, trEl; + var trHeight; + + function iterInnerHeights(i, childNode) { + trHeight = Math.max(trHeight, $(childNode).outerHeight()); + } + + // Reveal one level at a time and stop when we find one out of bounds + for (i = 0; i < trEls.length; i++) { + trEl = trEls.eq(i).removeClass('fc-limited'); // reset to original state (reveal) + + // with rowspans>1 and IE8, trEl.outerHeight() would return the height of the largest cell, + // so instead, find the tallest inner content element. + trHeight = 0; + trEl.find('> td > :first-child').each(iterInnerHeights); + + if (trEl.position().top + trHeight > rowHeight) { + return i; + } + } + + return false; // should not limit at all + }, + + + // Limits the given grid row to the maximum number of levels and injects "more" links if necessary. + // `row` is the row number. + // `levelLimit` is a number for the maximum (inclusive) number of levels allowed. + limitRow: function(row, levelLimit) { + var _this = this; + var rowStruct = this.eventRenderer.rowStructs[row]; + var moreNodes = []; // array of "more" links and DOM nodes + var col = 0; // col #, left-to-right (not chronologically) + var levelSegs; // array of segment objects in the last allowable level, ordered left-to-right + var cellMatrix; // a matrix (by level, then column) of all jQuery elements in the row + var limitedNodes; // array of temporarily hidden level and segment DOM nodes + var i, seg; + var segsBelow; // array of segment objects below `seg` in the current `col` + var totalSegsBelow; // total number of segments below `seg` in any of the columns `seg` occupies + var colSegsBelow; // array of segment arrays, below seg, one for each column (offset from segs's first column) + var td, rowspan; + var segMoreNodes; // array of "more" cells that will stand-in for the current seg's cell + var j; + var moreTd, moreWrap, moreLink; + + // Iterates through empty level cells and places "more" links inside if need be + function emptyCellsUntil(endCol) { // goes from current `col` to `endCol` + while (col < endCol) { + segsBelow = _this.getCellSegs(row, col, levelLimit); + if (segsBelow.length) { + td = cellMatrix[levelLimit - 1][col]; + moreLink = _this.renderMoreLink(row, col, segsBelow); + moreWrap = $('
').append(moreLink); + td.append(moreWrap); + moreNodes.push(moreWrap[0]); + } + col++; + } + } + + if (levelLimit && levelLimit < rowStruct.segLevels.length) { // is it actually over the limit? + levelSegs = rowStruct.segLevels[levelLimit - 1]; + cellMatrix = rowStruct.cellMatrix; + + limitedNodes = rowStruct.tbodyEl.children().slice(levelLimit) // get level elements past the limit + .addClass('fc-limited').get(); // hide elements and get a simple DOM-nodes array + + // iterate though segments in the last allowable level + for (i = 0; i < levelSegs.length; i++) { + seg = levelSegs[i]; + emptyCellsUntil(seg.leftCol); // process empty cells before the segment + + // determine *all* segments below `seg` that occupy the same columns + colSegsBelow = []; + totalSegsBelow = 0; + while (col <= seg.rightCol) { + segsBelow = this.getCellSegs(row, col, levelLimit); + colSegsBelow.push(segsBelow); + totalSegsBelow += segsBelow.length; + col++; + } + + if (totalSegsBelow) { // do we need to replace this segment with one or many "more" links? + td = cellMatrix[levelLimit - 1][seg.leftCol]; // the segment's parent cell + rowspan = td.attr('rowspan') || 1; + segMoreNodes = []; + + // make a replacement for each column the segment occupies. will be one for each colspan + for (j = 0; j < colSegsBelow.length; j++) { + moreTd = $('').attr('rowspan', rowspan); + segsBelow = colSegsBelow[j]; + moreLink = this.renderMoreLink( + row, + seg.leftCol + j, + [ seg ].concat(segsBelow) // count seg as hidden too + ); + moreWrap = $('
').append(moreLink); + moreTd.append(moreWrap); + segMoreNodes.push(moreTd[0]); + moreNodes.push(moreTd[0]); + } + + td.addClass('fc-limited').after($(segMoreNodes)); // hide original and inject replacements + limitedNodes.push(td[0]); + } + } + + emptyCellsUntil(this.colCnt); // finish off the level + rowStruct.moreEls = $(moreNodes); // for easy undoing later + rowStruct.limitedEls = $(limitedNodes); // for easy undoing later + } + }, + + + // Reveals all levels and removes all "more"-related elements for a grid's row. + // `row` is a row number. + unlimitRow: function(row) { + var rowStruct = this.eventRenderer.rowStructs[row]; + + if (rowStruct.moreEls) { + rowStruct.moreEls.remove(); + rowStruct.moreEls = null; + } + + if (rowStruct.limitedEls) { + rowStruct.limitedEls.removeClass('fc-limited'); + rowStruct.limitedEls = null; + } + }, + + + // Renders an element that represents hidden event element for a cell. + // Responsible for attaching click handler as well. + renderMoreLink: function(row, col, hiddenSegs) { + var _this = this; + var view = this.view; + + return $('') + .text( + this.getMoreLinkText(hiddenSegs.length) + ) + .on('click', function(ev) { + var clickOption = _this.opt('eventLimitClick'); + var date = _this.getCellDate(row, col); + var moreEl = $(this); + var dayEl = _this.getCellEl(row, col); + var allSegs = _this.getCellSegs(row, col); + + // rescope the segments to be within the cell's date + var reslicedAllSegs = _this.resliceDaySegs(allSegs, date); + var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date); + + if (typeof clickOption === 'function') { + // the returned value can be an atomic option + clickOption = _this.publiclyTrigger('eventLimitClick', { + context: view, + args: [ + { + date: date.clone(), + dayEl: dayEl, + moreEl: moreEl, + segs: reslicedAllSegs, + hiddenSegs: reslicedHiddenSegs + }, + ev, + view + ] + }); + } + + if (clickOption === 'popover') { + _this.showSegPopover(row, col, moreEl, reslicedAllSegs); + } + else if (typeof clickOption === 'string') { // a view name + view.calendar.zoomTo(date, clickOption); + } + }); + }, + + + // Reveals the popover that displays all events within a cell + showSegPopover: function(row, col, moreLink, segs) { + var _this = this; + var view = this.view; + var moreWrap = moreLink.parent(); // the
wrapper around the + var topEl; // the element we want to match the top coordinate of + var options; + + if (this.rowCnt == 1) { + topEl = view.el; // will cause the popover to cover any sort of header + } + else { + topEl = this.rowEls.eq(row); // will align with top of row + } + + options = { + className: 'fc-more-popover ' + view.calendar.theme.getClass('popover'), + content: this.renderSegPopoverContent(row, col, segs), + parentEl: view.el, // attach to root of view. guarantees outside of scrollbars. + top: topEl.offset().top, + autoHide: true, // when the user clicks elsewhere, hide the popover + viewportConstrain: this.opt('popoverViewportConstrain'), + hide: function() { + // kill everything when the popover is hidden + // notify events to be removed + if (_this.popoverSegs) { + _this.triggerBeforeEventSegsDestroyed(_this.popoverSegs); + } + _this.segPopover.removeElement(); + _this.segPopover = null; + _this.popoverSegs = null; + } + }; + + // Determine horizontal coordinate. + // We use the moreWrap instead of the to avoid border confusion. + if (this.isRTL) { + options.right = moreWrap.offset().left + moreWrap.outerWidth() + 1; // +1 to be over cell border + } + else { + options.left = moreWrap.offset().left - 1; // -1 to be over cell border + } + + this.segPopover = new Popover(options); + this.segPopover.show(); + + // the popover doesn't live within the grid's container element, and thus won't get the event + // delegated-handlers for free. attach event-related handlers to the popover. + this.bindAllSegHandlersToEl(this.segPopover.el); + + this.triggerAfterEventSegsRendered(segs); + }, + + + // Builds the inner DOM contents of the segment popover + renderSegPopoverContent: function(row, col, segs) { + var view = this.view; + var theme = view.calendar.theme; + var title = this.getCellDate(row, col).format(this.opt('dayPopoverFormat')); + var content = $( + '
' + + '' + + '' + + htmlEscape(title) + + '' + + '
' + + '
' + + '
' + + '
' + + '
' + ); + var segContainer = content.find('.fc-event-container'); + var i; + + // render each seg's `el` and only return the visible segs + segs = this.eventRenderer.renderFgSegEls(segs, true); // disableResizing=true + this.popoverSegs = segs; + + for (i = 0; i < segs.length; i++) { + + // because segments in the popover are not part of a grid coordinate system, provide a hint to any + // grids that want to do drag-n-drop about which cell it came from + this.hitsNeeded(); + segs[i].hit = this.getCellHit(row, col); + this.hitsNotNeeded(); + + segContainer.append(segs[i].el); + } + + return content; + }, + + + // Given the events within an array of segment objects, reslice them to be in a single day + resliceDaySegs: function(segs, dayDate) { + var dayStart = dayDate.clone(); + var dayEnd = dayStart.clone().add(1, 'days'); + var dayRange = new UnzonedRange(dayStart, dayEnd); + var newSegs = []; + var i, seg; + var slicedRange; + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + slicedRange = seg.footprint.componentFootprint.unzonedRange.intersect(dayRange); + + if (slicedRange) { + newSegs.push( + $.extend({}, seg, { + footprint: new EventFootprint( + new ComponentFootprint( + slicedRange, + seg.footprint.componentFootprint.isAllDay + ), + seg.footprint.eventDef, + seg.footprint.eventInstance + ), + isStart: seg.isStart && slicedRange.isStart, + isEnd: seg.isEnd && slicedRange.isEnd + }) + ); + } + } + + // force an order because eventsToSegs doesn't guarantee one + // TODO: research if still needed + this.eventRenderer.sortEventSegs(newSegs); + + return newSegs; + }, + + + // Generates the text that should be inside a "more" link, given the number of events it represents + getMoreLinkText: function(num) { + var opt = this.opt('eventLimitText'); + + if (typeof opt === 'function') { + return opt(num); + } + else { + return '+' + num + ' ' + opt; + } + }, + + + // Returns segments within a given cell. + // If `startLevel` is specified, returns only events including and below that level. Otherwise returns all segs. + getCellSegs: function(row, col, startLevel) { + var segMatrix = this.eventRenderer.rowStructs[row].segMatrix; + var level = startLevel || 0; + var segs = []; + var seg; + + while (level < segMatrix.length) { + seg = segMatrix[level][col]; + if (seg) { + segs.push(seg); + } + level++; + } + + return segs; + } + +}); + +;; + +/* An abstract class for the "basic" views, as well as month view. Renders one or more rows of day cells. +----------------------------------------------------------------------------------------------------------------------*/ +// It is a manager for a DayGrid subcomponent, which does most of the heavy lifting. +// It is responsible for managing width/height. + +var BasicView = FC.BasicView = View.extend({ + + scroller: null, + + dayGridClass: DayGrid, // class the dayGrid will be instantiated from (overridable by subclasses) + dayGrid: null, // the main subcomponent that does most of the heavy lifting + + weekNumberWidth: null, // width of all the week-number cells running down the side + + + constructor: function() { + View.apply(this, arguments); + + this.dayGrid = this.instantiateDayGrid(); + this.dayGrid.isRigid = this.hasRigidRows(); + + if (this.opt('weekNumbers')) { + if (this.opt('weekNumbersWithinDays')) { + this.dayGrid.cellWeekNumbersVisible = true; + this.dayGrid.colWeekNumbersVisible = false; + } + else { + this.dayGrid.cellWeekNumbersVisible = false; + this.dayGrid.colWeekNumbersVisible = true; + }; + } + + this.addChild(this.dayGrid); + + this.scroller = new Scroller({ + overflowX: 'hidden', + overflowY: 'auto' + }); + }, + + + // Generates the DayGrid object this view needs. Draws from this.dayGridClass + instantiateDayGrid: function() { + // generate a subclass on the fly with BasicView-specific behavior + // TODO: cache this subclass + var subclass = this.dayGridClass.extend(basicDayGridMethods); + + return new subclass(this); + }, + + + // Computes the date range that will be rendered. + buildRenderRange: function(currentUnzonedRange, currentRangeUnit, isRangeAllDay) { + var renderUnzonedRange = View.prototype.buildRenderRange.apply(this, arguments); // an UnzonedRange + var start = this.calendar.msToUtcMoment(renderUnzonedRange.startMs, isRangeAllDay); + var end = this.calendar.msToUtcMoment(renderUnzonedRange.endMs, isRangeAllDay); + + // year and month views should be aligned with weeks. this is already done for week + if (/^(year|month)$/.test(currentRangeUnit)) { + start.startOf('week'); + + // make end-of-week if not already + if (end.weekday()) { + end.add(1, 'week').startOf('week'); // exclusively move backwards + } + } + + return new UnzonedRange(start, end); + }, + + + executeDateRender: function(dateProfile) { + this.dayGrid.breakOnWeeks = /year|month|week/.test(dateProfile.currentRangeUnit); + + View.prototype.executeDateRender.apply(this, arguments); + }, + + + renderSkeleton: function() { + var dayGridContainerEl; + var dayGridEl; + + this.el.addClass('fc-basic-view').html(this.renderSkeletonHtml()); + + this.scroller.render(); + + dayGridContainerEl = this.scroller.el.addClass('fc-day-grid-container'); + dayGridEl = $('
').appendTo(dayGridContainerEl); + + this.el.find('.fc-body > tr > td').append(dayGridContainerEl); + + this.dayGrid.headContainerEl = this.el.find('.fc-head-container'); + this.dayGrid.setElement(dayGridEl); + }, + + + unrenderSkeleton: function() { + this.dayGrid.removeElement(); + this.scroller.destroy(); + }, + + + // Builds the HTML skeleton for the view. + // The day-grid component will render inside of a container defined by this HTML. + renderSkeletonHtml: function() { + var theme = this.calendar.theme; + + return '' + + '' + + (this.opt('columnHeader') ? + '' + + '' + + '' + + '' + + '' : + '' + ) + + '' + + '' + + '' + + '' + + '' + + '
 
'; + }, + + + // Generates an HTML attribute string for setting the width of the week number column, if it is known + weekNumberStyleAttr: function() { + if (this.weekNumberWidth !== null) { + return 'style="width:' + this.weekNumberWidth + 'px"'; + } + return ''; + }, + + + // Determines whether each row should have a constant height + hasRigidRows: function() { + var eventLimit = this.opt('eventLimit'); + + return eventLimit && typeof eventLimit !== 'number'; + }, + + + /* Dimensions + ------------------------------------------------------------------------------------------------------------------*/ + + + // Refreshes the horizontal dimensions of the view + updateSize: function(totalHeight, isAuto, isResize) { + var eventLimit = this.opt('eventLimit'); + var headRowEl = this.dayGrid.headContainerEl.find('.fc-row'); + var scrollerHeight; + var scrollbarWidths; + + // hack to give the view some height prior to dayGrid's columns being rendered + // TODO: separate setting height from scroller VS dayGrid. + if (!this.dayGrid.rowEls) { + if (!isAuto) { + scrollerHeight = this.computeScrollerHeight(totalHeight); + this.scroller.setHeight(scrollerHeight); + } + return; + } + + View.prototype.updateSize.apply(this, arguments); + + if (this.dayGrid.colWeekNumbersVisible) { + // Make sure all week number cells running down the side have the same width. + // Record the width for cells created later. + this.weekNumberWidth = matchCellWidths( + this.el.find('.fc-week-number') + ); + } + + // reset all heights to be natural + this.scroller.clear(); + uncompensateScroll(headRowEl); + + this.dayGrid.removeSegPopover(); // kill the "more" popover if displayed + + // is the event limit a constant level number? + if (eventLimit && typeof eventLimit === 'number') { + this.dayGrid.limitRows(eventLimit); // limit the levels first so the height can redistribute after + } + + // distribute the height to the rows + // (totalHeight is a "recommended" value if isAuto) + scrollerHeight = this.computeScrollerHeight(totalHeight); + this.setGridHeight(scrollerHeight, isAuto); + + // is the event limit dynamically calculated? + if (eventLimit && typeof eventLimit !== 'number') { + this.dayGrid.limitRows(eventLimit); // limit the levels after the grid's row heights have been set + } + + if (!isAuto) { // should we force dimensions of the scroll container? + + this.scroller.setHeight(scrollerHeight); + scrollbarWidths = this.scroller.getScrollbarWidths(); + + if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars? + + compensateScroll(headRowEl, scrollbarWidths); + + // doing the scrollbar compensation might have created text overflow which created more height. redo + scrollerHeight = this.computeScrollerHeight(totalHeight); + this.scroller.setHeight(scrollerHeight); + } + + // guarantees the same scrollbar widths + this.scroller.lockOverflow(scrollbarWidths); + } + }, + + + // given a desired total height of the view, returns what the height of the scroller should be + computeScrollerHeight: function(totalHeight) { + return totalHeight - + subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller + }, + + + // Sets the height of just the DayGrid component in this view + setGridHeight: function(height, isAuto) { + if (isAuto) { + undistributeHeight(this.dayGrid.rowEls); // let the rows be their natural height with no expanding + } + else { + distributeHeight(this.dayGrid.rowEls, height, true); // true = compensate for height-hogging rows + } + }, + + + /* Scroll + ------------------------------------------------------------------------------------------------------------------*/ + + + computeInitialDateScroll: function() { + return { top: 0 }; + }, + + + queryDateScroll: function() { + return { top: this.scroller.getScrollTop() }; + }, + + + applyDateScroll: function(scroll) { + if (scroll.top !== undefined) { + this.scroller.setScrollTop(scroll.top); + } + } + +}); + + +// Methods that will customize the rendering behavior of the BasicView's dayGrid +var basicDayGridMethods = { // not relly methods anymore + + + colWeekNumbersVisible: false, // display week numbers along the side? + + + // Generates the HTML that will go before the day-of week header cells + renderHeadIntroHtml: function() { + var view = this.view; + + if (this.colWeekNumbersVisible) { + return '' + + '' + + '' + // needed for matchCellWidths + htmlEscape(this.opt('weekNumberTitle')) + + '' + + ''; + } + + return ''; + }, + + + // Generates the HTML that will go before content-skeleton cells that display the day/week numbers + renderNumberIntroHtml: function(row) { + var view = this.view; + var weekStart = this.getCellDate(row, 0); + + if (this.colWeekNumbersVisible) { + return '' + + '' + + view.buildGotoAnchorHtml( // aside from link, important for matchCellWidths + { date: weekStart, type: 'week', forceOff: this.colCnt === 1 }, + weekStart.format('w') // inner HTML + ) + + ''; + } + + return ''; + }, + + + // Generates the HTML that goes before the day bg cells for each day-row + renderBgIntroHtml: function() { + var view = this.view; + + if (this.colWeekNumbersVisible) { + return ''; + } + + return ''; + }, + + + // Generates the HTML that goes before every other type of row generated by DayGrid. + // Affects helper-skeleton and highlight-skeleton rows. + renderIntroHtml: function() { + var view = this.view; + + if (this.colWeekNumbersVisible) { + return ''; + } + + return ''; + }, + + + getIsNumbersVisible: function() { + return DayGrid.prototype.getIsNumbersVisible.apply(this, arguments) || this.colWeekNumbersVisible; + } + +}; + +;; + +/* A month view with day cells running in rows (one-per-week) and columns +----------------------------------------------------------------------------------------------------------------------*/ + +var MonthView = FC.MonthView = BasicView.extend({ + + + // Computes the date range that will be rendered. + buildRenderRange: function(currentUnzonedRange, currentRangeUnit, isRangeAllDay) { + var renderUnzonedRange = BasicView.prototype.buildRenderRange.apply(this, arguments); + var start = this.calendar.msToUtcMoment(renderUnzonedRange.startMs, isRangeAllDay); + var end = this.calendar.msToUtcMoment(renderUnzonedRange.endMs, isRangeAllDay); + var rowCnt; + + // ensure 6 weeks + if (this.isFixedWeeks()) { + rowCnt = Math.ceil( // could be partial weeks due to hiddenDays + end.diff(start, 'weeks', true) // dontRound=true + ); + end.add(6 - rowCnt, 'weeks'); + } + + return new UnzonedRange(start, end); + }, + + + // Overrides the default BasicView behavior to have special multi-week auto-height logic + setGridHeight: function(height, isAuto) { + + // if auto, make the height of each row the height that it would be if there were 6 weeks + if (isAuto) { + height *= this.rowCnt / 6; + } + + distributeHeight(this.dayGrid.rowEls, height, !isAuto); // if auto, don't compensate for height-hogging rows + }, + + + isFixedWeeks: function() { + return this.opt('fixedWeekCount'); + }, + + + isDateInOtherMonth: function(date, dateProfile) { + return date.month() !== moment.utc(dateProfile.currentUnzonedRange.startMs).month(); // TODO: optimize + } + +}); + +;; + +fcViews.basic = { + 'class': BasicView +}; + +fcViews.basicDay = { + type: 'basic', + duration: { days: 1 } +}; + +fcViews.basicWeek = { + type: 'basic', + duration: { weeks: 1 } +}; + +fcViews.month = { + 'class': MonthView, + duration: { months: 1 }, // important for prev/next + defaults: { + fixedWeekCount: true + } +}; +;; + +var TimeGridFillRenderer = FillRenderer.extend({ + + + attachSegEls: function(type, segs) { + var timeGrid = this.component; + var containerEls; + + // TODO: more efficient lookup + if (type === 'bgEvent') { + containerEls = timeGrid.bgContainerEls; + } + else if (type === 'businessHours') { + containerEls = timeGrid.businessContainerEls; + } + else if (type === 'highlight') { + containerEls = timeGrid.highlightContainerEls; + } + + timeGrid.updateSegVerticals(segs); + timeGrid.attachSegsByCol(timeGrid.groupSegsByCol(segs), containerEls); + + return segs.map(function(seg) { + return seg.el[0]; + }); + } + +}); + +;; + +/* +Only handles foreground segs. +Does not own rendering. Use for low-level util methods by TimeGrid. +*/ +var TimeGridEventRenderer = EventRenderer.extend({ + + timeGrid: null, + + + constructor: function(timeGrid) { + EventRenderer.apply(this, arguments); + + this.timeGrid = timeGrid; + }, + + + renderFgSegs: function(segs) { + this.renderFgSegsIntoContainers(segs, this.timeGrid.fgContainerEls); + }, + + + // Given an array of foreground segments, render a DOM element for each, computes position, + // and attaches to the column inner-container elements. + renderFgSegsIntoContainers: function(segs, containerEls) { + var segsByCol; + var col; + + segsByCol = this.timeGrid.groupSegsByCol(segs); + + for (col = 0; col < this.timeGrid.colCnt; col++) { + this.updateFgSegCoords(segsByCol[col]); + } + + this.timeGrid.attachSegsByCol(segsByCol, containerEls); + }, + + + unrenderFgSegs: function() { + if (this.fgSegs) { // hack + this.fgSegs.forEach(function(seg) { + seg.el.remove(); + }); + } + }, + + + // Computes a default event time formatting string if `timeFormat` is not explicitly defined + computeEventTimeFormat: function() { + return this.opt('noMeridiemTimeFormat'); // like "6:30" (no AM/PM) + }, + + + // Computes a default `displayEventEnd` value if one is not expliclty defined + computeDisplayEventEnd: function() { + return true; + }, + + + // Renders the HTML for a single event segment's default rendering + fgSegHtml: function(seg, disableResizing) { + var view = this.view; + var calendar = view.calendar; + var componentFootprint = seg.footprint.componentFootprint; + var isAllDay = componentFootprint.isAllDay; + var eventDef = seg.footprint.eventDef; + var isDraggable = view.isEventDefDraggable(eventDef); + var isResizableFromStart = !disableResizing && seg.isStart && view.isEventDefResizableFromStart(eventDef); + var isResizableFromEnd = !disableResizing && seg.isEnd && view.isEventDefResizableFromEnd(eventDef); + var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd); + var skinCss = cssToStr(this.getSkinCss(eventDef)); + var timeText; + var fullTimeText; // more verbose time text. for the print stylesheet + var startTimeText; // just the start time text + + classes.unshift('fc-time-grid-event', 'fc-v-event'); + + // if the event appears to span more than one day... + if (view.isMultiDayRange(componentFootprint.unzonedRange)) { + // Don't display time text on segments that run entirely through a day. + // That would appear as midnight-midnight and would look dumb. + // Otherwise, display the time text for the *segment's* times (like 6pm-midnight or midnight-10am) + if (seg.isStart || seg.isEnd) { + var zonedStart = calendar.msToMoment(seg.startMs); + var zonedEnd = calendar.msToMoment(seg.endMs); + timeText = this._getTimeText(zonedStart, zonedEnd, isAllDay); + fullTimeText = this._getTimeText(zonedStart, zonedEnd, isAllDay, 'LT'); + startTimeText = this._getTimeText(zonedStart, zonedEnd, isAllDay, null, false); // displayEnd=false + } + } + else { + // Display the normal time text for the *event's* times + timeText = this.getTimeText(seg.footprint); + fullTimeText = this.getTimeText(seg.footprint, 'LT'); + startTimeText = this.getTimeText(seg.footprint, null, false); // displayEnd=false + } + + return '
' + + '
' + + (timeText ? + '
' + + '' + htmlEscape(timeText) + '' + + '
' : + '' + ) + + (eventDef.title ? + '
' + + htmlEscape(eventDef.title) + + '
' : + '' + ) + + '
' + + '
' + + /* TODO: write CSS for this + (isResizableFromStart ? + '
' : + '' + ) + + */ + (isResizableFromEnd ? + '
' : + '' + ) + + ''; + }, + + + // Given segments that are assumed to all live in the *same column*, + // compute their verical/horizontal coordinates and assign to their elements. + updateFgSegCoords: function(segs) { + this.timeGrid.computeSegVerticals(segs); // horizontals relies on this + this.computeFgSegHorizontals(segs); // compute horizontal coordinates, z-index's, and reorder the array + this.timeGrid.assignSegVerticals(segs); + this.assignFgSegHorizontals(segs); + }, + + + // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each. + // NOTE: Also reorders the given array by date! + computeFgSegHorizontals: function(segs) { + var levels; + var level0; + var i; + + this.sortEventSegs(segs); // order by certain criteria + levels = buildSlotSegLevels(segs); + computeForwardSlotSegs(levels); + + if ((level0 = levels[0])) { + + for (i = 0; i < level0.length; i++) { + computeSlotSegPressures(level0[i]); + } + + for (i = 0; i < level0.length; i++) { + this.computeFgSegForwardBack(level0[i], 0, 0); + } + } + }, + + + // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range + // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and + // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left. + // + // The segment might be part of a "series", which means consecutive segments with the same pressure + // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of + // segments behind this one in the current series, and `seriesBackwardCoord` is the starting + // coordinate of the first segment in the series. + computeFgSegForwardBack: function(seg, seriesBackwardPressure, seriesBackwardCoord) { + var forwardSegs = seg.forwardSegs; + var i; + + if (seg.forwardCoord === undefined) { // not already computed + + if (!forwardSegs.length) { + + // if there are no forward segments, this segment should butt up against the edge + seg.forwardCoord = 1; + } + else { + + // sort highest pressure first + this.sortForwardSegs(forwardSegs); + + // this segment's forwardCoord will be calculated from the backwardCoord of the + // highest-pressure forward segment. + this.computeFgSegForwardBack(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord); + seg.forwardCoord = forwardSegs[0].backwardCoord; + } + + // calculate the backwardCoord from the forwardCoord. consider the series + seg.backwardCoord = seg.forwardCoord - + (seg.forwardCoord - seriesBackwardCoord) / // available width for series + (seriesBackwardPressure + 1); // # of segments in the series + + // use this segment's coordinates to computed the coordinates of the less-pressurized + // forward segments + for (i=0; i seg2.top && seg1.top < seg2.bottom; +} + +;; + +var TimeGridHelperRenderer = HelperRenderer.extend({ + + + renderSegs: function(segs, sourceSeg) { + var helperNodes = []; + var i, seg; + var sourceEl; + + // TODO: not good to call eventRenderer this way + this.eventRenderer.renderFgSegsIntoContainers( + segs, + this.component.helperContainerEls + ); + + // Try to make the segment that is in the same row as sourceSeg look the same + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + + if (sourceSeg && sourceSeg.col === seg.col) { + sourceEl = sourceSeg.el; + seg.el.css({ + left: sourceEl.css('left'), + right: sourceEl.css('right'), + 'margin-left': sourceEl.css('margin-left'), + 'margin-right': sourceEl.css('margin-right') + }); + } + + helperNodes.push(seg.el[0]); + } + + return $(helperNodes); // must return the elements rendered + } + +}); + +;; + +/* A component that renders one or more columns of vertical time slots +----------------------------------------------------------------------------------------------------------------------*/ +// We mixin DayTable, even though there is only a single row of days + +var TimeGrid = FC.TimeGrid = InteractiveDateComponent.extend(StandardInteractionsMixin, DayTableMixin, { + + eventRendererClass: TimeGridEventRenderer, + businessHourRendererClass: BusinessHourRenderer, + helperRendererClass: TimeGridHelperRenderer, + fillRendererClass: TimeGridFillRenderer, + + view: null, // TODO: make more general and/or remove + helperRenderer: null, + + dayRanges: null, // UnzonedRange[], of start-end of each day + slotDuration: null, // duration of a "slot", a distinct time segment on given day, visualized by lines + snapDuration: null, // granularity of time for dragging and selecting + snapsPerSlot: null, + labelFormat: null, // formatting string for times running along vertical axis + labelInterval: null, // duration of how often a label should be displayed for a slot + + headContainerEl: null, // div that hold's the date header + colEls: null, // cells elements in the day-row background + slatContainerEl: null, // div that wraps all the slat rows + slatEls: null, // elements running horizontally across all columns + nowIndicatorEls: null, + + colCoordCache: null, + slatCoordCache: null, + + bottomRuleEl: null, // hidden by default + colContainerEls: null, // containers for each column + + // inner-containers for each column where different types of segs live + fgContainerEls: null, + bgContainerEls: null, + helperContainerEls: null, + highlightContainerEls: null, + businessContainerEls: null, + + // arrays of different types of displayed segments + helperSegs: null, + highlightSegs: null, + businessSegs: null, + + + constructor: function(view) { + this.view = view; // do first, for opt calls during initialization + + InteractiveDateComponent.call(this); // call the super-constructor + + this.processOptions(); + }, + + + // Slices up the given span (unzoned start/end with other misc data) into an array of segments + componentFootprintToSegs: function(componentFootprint) { + var segs = this.sliceRangeByTimes(componentFootprint.unzonedRange); + var i; + + for (i = 0; i < segs.length; i++) { + if (this.isRTL) { + segs[i].col = this.daysPerRow - 1 - segs[i].dayIndex; + } + else { + segs[i].col = segs[i].dayIndex; + } + } + + return segs; + }, + + + /* Date Handling + ------------------------------------------------------------------------------------------------------------------*/ + + + sliceRangeByTimes: function(unzonedRange) { + var segs = []; + var segRange; + var dayIndex; + + for (dayIndex = 0; dayIndex < this.daysPerRow; dayIndex++) { + + segRange = unzonedRange.intersect(this.dayRanges[dayIndex]); + + if (segRange) { + segs.push({ + startMs: segRange.startMs, + endMs: segRange.endMs, + isStart: segRange.isStart, + isEnd: segRange.isEnd, + dayIndex: dayIndex + }); + } + } + + return segs; + }, + + + /* Options + ------------------------------------------------------------------------------------------------------------------*/ + + + // Parses various options into properties of this object + processOptions: function() { + var slotDuration = this.opt('slotDuration'); + var snapDuration = this.opt('snapDuration'); + var input; + + slotDuration = moment.duration(slotDuration); + snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration; + + this.slotDuration = slotDuration; + this.snapDuration = snapDuration; + this.snapsPerSlot = slotDuration / snapDuration; // TODO: ensure an integer multiple? + + // might be an array value (for TimelineView). + // if so, getting the most granular entry (the last one probably). + input = this.opt('slotLabelFormat'); + if ($.isArray(input)) { + input = input[input.length - 1]; + } + + this.labelFormat = input || + this.opt('smallTimeFormat'); // the computed default + + input = this.opt('slotLabelInterval'); + this.labelInterval = input ? + moment.duration(input) : + this.computeLabelInterval(slotDuration); + }, + + + // Computes an automatic value for slotLabelInterval + computeLabelInterval: function(slotDuration) { + var i; + var labelInterval; + var slotsPerLabel; + + // find the smallest stock label interval that results in more than one slots-per-label + for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) { + labelInterval = moment.duration(AGENDA_STOCK_SUB_DURATIONS[i]); + slotsPerLabel = divideDurationByDuration(labelInterval, slotDuration); + if (isInt(slotsPerLabel) && slotsPerLabel > 1) { + return labelInterval; + } + } + + return moment.duration(slotDuration); // fall back. clone + }, + + + /* Date Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + renderDates: function(dateProfile) { + this.dateProfile = dateProfile; + this.updateDayTable(); + this.renderSlats(); + this.renderColumns(); + }, + + + renderSkeleton: function() { + var theme = this.view.calendar.theme; + + this.el.html( + '
' + + '
' + + '' + ); + + this.bottomRuleEl = this.el.find('hr'); + }, + + + renderSlats: function() { + var theme = this.view.calendar.theme; + + this.slatContainerEl = this.el.find('> .fc-slats') + .html( + '' + + this.renderSlatRowHtml() + + '
' + ); + + this.slatEls = this.slatContainerEl.find('tr'); + + this.slatCoordCache = new CoordCache({ + els: this.slatEls, + isVertical: true + }); + }, + + + // Generates the HTML for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL. + renderSlatRowHtml: function() { + var view = this.view; + var calendar = view.calendar; + var theme = calendar.theme; + var isRTL = this.isRTL; + var dateProfile = this.dateProfile; + var html = ''; + var slotTime = moment.duration(+dateProfile.minTime); // wish there was .clone() for durations + var slotIterator = moment.duration(0); + var slotDate; // will be on the view's first day, but we only care about its time + var isLabeled; + var axisHtml; + + // Calculate the time for each slot + while (slotTime < dateProfile.maxTime) { + slotDate = calendar.msToUtcMoment(dateProfile.renderUnzonedRange.startMs).time(slotTime); + isLabeled = isInt(divideDurationByDuration(slotIterator, this.labelInterval)); + + axisHtml = + '' + + (isLabeled ? + '' + // for matchCellWidths + htmlEscape(slotDate.format(this.labelFormat)) + + '' : + '' + ) + + ''; + + html += + '' + + (!isRTL ? axisHtml : '') + + '' + + (isRTL ? axisHtml : '') + + ""; + + slotTime.add(this.slotDuration); + slotIterator.add(this.slotDuration); + } + + return html; + }, + + + renderColumns: function() { + var dateProfile = this.dateProfile; + var theme = this.view.calendar.theme; + + this.dayRanges = this.dayDates.map(function(dayDate) { + return new UnzonedRange( + dayDate.clone().add(dateProfile.minTime), + dayDate.clone().add(dateProfile.maxTime) + ); + }); + + if (this.headContainerEl) { + this.headContainerEl.html(this.renderHeadHtml()); + } + + this.el.find('> .fc-bg').html( + '' + + this.renderBgTrHtml(0) + // row=0 + '
' + ); + + this.colEls = this.el.find('.fc-day, .fc-disabled-day'); + + this.colCoordCache = new CoordCache({ + els: this.colEls, + isHorizontal: true + }); + + this.renderContentSkeleton(); + }, + + + /* Content Skeleton + ------------------------------------------------------------------------------------------------------------------*/ + + + // Renders the DOM that the view's content will live in + renderContentSkeleton: function() { + var cellHtml = ''; + var i; + var skeletonEl; + + for (i = 0; i < this.colCnt; i++) { + cellHtml += + '' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + ''; + } + + skeletonEl = $( + '
' + + '' + + '' + cellHtml + '' + + '
' + + '
' + ); + + this.colContainerEls = skeletonEl.find('.fc-content-col'); + this.helperContainerEls = skeletonEl.find('.fc-helper-container'); + this.fgContainerEls = skeletonEl.find('.fc-event-container:not(.fc-helper-container)'); + this.bgContainerEls = skeletonEl.find('.fc-bgevent-container'); + this.highlightContainerEls = skeletonEl.find('.fc-highlight-container'); + this.businessContainerEls = skeletonEl.find('.fc-business-container'); + + this.bookendCells(skeletonEl.find('tr')); // TODO: do this on string level + this.el.append(skeletonEl); + }, + + + // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's col + groupSegsByCol: function(segs) { + var segsByCol = []; + var i; + + for (i = 0; i < this.colCnt; i++) { + segsByCol.push([]); + } + + for (i = 0; i < segs.length; i++) { + segsByCol[segs[i].col].push(segs[i]); + } + + return segsByCol; + }, + + + // Given segments grouped by column, insert the segments' elements into a parallel array of container + // elements, each living within a column. + attachSegsByCol: function(segsByCol, containerEls) { + var col; + var segs; + var i; + + for (col = 0; col < this.colCnt; col++) { // iterate each column grouping + segs = segsByCol[col]; + + for (i = 0; i < segs.length; i++) { + containerEls.eq(col).append(segs[i].el); + } + } + }, + + + /* Now Indicator + ------------------------------------------------------------------------------------------------------------------*/ + + + getNowIndicatorUnit: function() { + return 'minute'; // will refresh on the minute + }, + + + renderNowIndicator: function(date) { + // seg system might be overkill, but it handles scenario where line needs to be rendered + // more than once because of columns with the same date (resources columns for example) + var segs = this.componentFootprintToSegs( + new ComponentFootprint( + new UnzonedRange(date, date.valueOf() + 1), // protect against null range + false // all-day + ) + ); + var top = this.computeDateTop(date, date); + var nodes = []; + var i; + + // render lines within the columns + for (i = 0; i < segs.length; i++) { + nodes.push($('
') + .css('top', top) + .appendTo(this.colContainerEls.eq(segs[i].col))[0]); + } + + // render an arrow over the axis + if (segs.length > 0) { // is the current time in view? + nodes.push($('
') + .css('top', top) + .appendTo(this.el.find('.fc-content-skeleton'))[0]); + } + + this.nowIndicatorEls = $(nodes); + }, + + + unrenderNowIndicator: function() { + if (this.nowIndicatorEls) { + this.nowIndicatorEls.remove(); + this.nowIndicatorEls = null; + } + }, + + + /* Coordinates + ------------------------------------------------------------------------------------------------------------------*/ + + + updateSize: function(totalHeight, isAuto, isResize) { + InteractiveDateComponent.prototype.updateSize.apply(this, arguments); + + this.slatCoordCache.build(); + + if (isResize) { + this.updateSegVerticals( + [].concat(this.eventRenderer.getSegs(), this.businessSegs || []) + ); + } + }, + + + getTotalSlatHeight: function() { + return this.slatContainerEl.outerHeight(); + }, + + + // Computes the top coordinate, relative to the bounds of the grid, of the given date. + // `ms` can be a millisecond UTC time OR a UTC moment. + // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight. + computeDateTop: function(ms, startOfDayDate) { + return this.computeTimeTop( + moment.duration( + ms - startOfDayDate.clone().stripTime() + ) + ); + }, + + + // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration). + computeTimeTop: function(time) { + var len = this.slatEls.length; + var dateProfile = this.dateProfile; + var slatCoverage = (time - dateProfile.minTime) / this.slotDuration; // floating-point value of # of slots covered + var slatIndex; + var slatRemainder; + + // compute a floating-point number for how many slats should be progressed through. + // from 0 to number of slats (inclusive) + // constrained because minTime/maxTime might be customized. + slatCoverage = Math.max(0, slatCoverage); + slatCoverage = Math.min(len, slatCoverage); + + // an integer index of the furthest whole slat + // from 0 to number slats (*exclusive*, so len-1) + slatIndex = Math.floor(slatCoverage); + slatIndex = Math.min(slatIndex, len - 1); + + // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition. + // could be 1.0 if slatCoverage is covering *all* the slots + slatRemainder = slatCoverage - slatIndex; + + return this.slatCoordCache.getTopPosition(slatIndex) + + this.slatCoordCache.getHeight(slatIndex) * slatRemainder; + }, + + + // Refreshes the CSS top/bottom coordinates for each segment element. + // Works when called after initial render, after a window resize/zoom for example. + updateSegVerticals: function(segs) { + this.computeSegVerticals(segs); + this.assignSegVerticals(segs); + }, + + + // For each segment in an array, computes and assigns its top and bottom properties + computeSegVerticals: function(segs) { + var eventMinHeight = this.opt('agendaEventMinHeight'); + var i, seg; + var dayDate; + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + dayDate = this.dayDates[seg.dayIndex]; + + seg.top = this.computeDateTop(seg.startMs, dayDate); + seg.bottom = Math.max( + seg.top + eventMinHeight, + this.computeDateTop(seg.endMs, dayDate) + ); + } + }, + + + // Given segments that already have their top/bottom properties computed, applies those values to + // the segments' elements. + assignSegVerticals: function(segs) { + var i, seg; + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + seg.el.css(this.generateSegVerticalCss(seg)); + } + }, + + + // Generates an object with CSS properties for the top/bottom coordinates of a segment element + generateSegVerticalCss: function(seg) { + return { + top: seg.top, + bottom: -seg.bottom // flipped because needs to be space beyond bottom edge of event container + }; + }, + + + /* Hit System + ------------------------------------------------------------------------------------------------------------------*/ + + + prepareHits: function() { + this.colCoordCache.build(); + this.slatCoordCache.build(); + }, + + + releaseHits: function() { + this.colCoordCache.clear(); + // NOTE: don't clear slatCoordCache because we rely on it for computeTimeTop + }, + + + queryHit: function(leftOffset, topOffset) { + var snapsPerSlot = this.snapsPerSlot; + var colCoordCache = this.colCoordCache; + var slatCoordCache = this.slatCoordCache; + + if (colCoordCache.isLeftInBounds(leftOffset) && slatCoordCache.isTopInBounds(topOffset)) { + var colIndex = colCoordCache.getHorizontalIndex(leftOffset); + var slatIndex = slatCoordCache.getVerticalIndex(topOffset); + + if (colIndex != null && slatIndex != null) { + var slatTop = slatCoordCache.getTopOffset(slatIndex); + var slatHeight = slatCoordCache.getHeight(slatIndex); + var partial = (topOffset - slatTop) / slatHeight; // floating point number between 0 and 1 + var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat + var snapIndex = slatIndex * snapsPerSlot + localSnapIndex; + var snapTop = slatTop + (localSnapIndex / snapsPerSlot) * slatHeight; + var snapBottom = slatTop + ((localSnapIndex + 1) / snapsPerSlot) * slatHeight; + + return { + col: colIndex, + snap: snapIndex, + component: this, // needed unfortunately :( + left: colCoordCache.getLeftOffset(colIndex), + right: colCoordCache.getRightOffset(colIndex), + top: snapTop, + bottom: snapBottom + }; + } + } + }, + + + getHitFootprint: function(hit) { + var start = this.getCellDate(0, hit.col); // row=0 + var time = this.computeSnapTime(hit.snap); // pass in the snap-index + var end; + + start.time(time); + end = start.clone().add(this.snapDuration); + + return new ComponentFootprint( + new UnzonedRange(start, end), + false // all-day? + ); + }, + + + // Given a row number of the grid, representing a "snap", returns a time (Duration) from its start-of-day + computeSnapTime: function(snapIndex) { + return moment.duration(this.dateProfile.minTime + this.snapDuration * snapIndex); + }, + + + getHitEl: function(hit) { + return this.colEls.eq(hit.col); + }, + + + /* Event Drag Visualization + ------------------------------------------------------------------------------------------------------------------*/ + + + // Renders a visual indication of an event being dragged over the specified date(s). + // A returned value of `true` signals that a mock "helper" event has been rendered. + renderDrag: function(eventFootprints, seg, isTouch) { + var i; + + if (seg) { // if there is event information for this drag, render a helper event + + if (eventFootprints.length) { + this.helperRenderer.renderEventDraggingFootprints(eventFootprints, seg, isTouch); + + // signal that a helper has been rendered + return true; + } + } + else { // otherwise, just render a highlight + + for (i = 0; i < eventFootprints.length; i++) { + this.renderHighlight(eventFootprints[i].componentFootprint); + } + } + }, + + + // Unrenders any visual indication of an event being dragged + unrenderDrag: function(seg) { + this.unrenderHighlight(); + this.helperRenderer.unrender(); + }, + + + /* Event Resize Visualization + ------------------------------------------------------------------------------------------------------------------*/ + + + // Renders a visual indication of an event being resized + renderEventResize: function(eventFootprints, seg, isTouch) { + this.helperRenderer.renderEventResizingFootprints(eventFootprints, seg, isTouch); + }, + + + // Unrenders any visual indication of an event being resized + unrenderEventResize: function(seg) { + this.helperRenderer.unrender(); + }, + + + /* Selection + ------------------------------------------------------------------------------------------------------------------*/ + + + // Renders a visual indication of a selection. Overrides the default, which was to simply render a highlight. + renderSelectionFootprint: function(componentFootprint) { + if (this.opt('selectHelper')) { // this setting signals that a mock helper event should be rendered + this.helperRenderer.renderComponentFootprint(componentFootprint); + } + else { + this.renderHighlight(componentFootprint); + } + }, + + + // Unrenders any visual indication of a selection + unrenderSelection: function() { + this.helperRenderer.unrender(); + this.unrenderHighlight(); + } + +}); + +;; + +/* An abstract class for all agenda-related views. Displays one more columns with time slots running vertically. +----------------------------------------------------------------------------------------------------------------------*/ +// Is a manager for the TimeGrid subcomponent and possibly the DayGrid subcomponent (if allDaySlot is on). +// Responsible for managing width/height. + +var AgendaView = FC.AgendaView = View.extend({ + + scroller: null, + + timeGridClass: TimeGrid, // class used to instantiate the timeGrid. subclasses can override + timeGrid: null, // the main time-grid subcomponent of this view + + dayGridClass: DayGrid, // class used to instantiate the dayGrid. subclasses can override + dayGrid: null, // the "all-day" subcomponent. if all-day is turned off, this will be null + + axisWidth: null, // the width of the time axis running down the side + + // indicates that minTime/maxTime affects rendering + usesMinMaxTime: true, + + + constructor: function() { + View.apply(this, arguments); + + this.timeGrid = this.instantiateTimeGrid(); + this.addChild(this.timeGrid); + + if (this.opt('allDaySlot')) { // should we display the "all-day" area? + this.dayGrid = this.instantiateDayGrid(); // the all-day subcomponent of this view + this.addChild(this.dayGrid); + } + + this.scroller = new Scroller({ + overflowX: 'hidden', + overflowY: 'auto' + }); + }, + + + // Instantiates the TimeGrid object this view needs. Draws from this.timeGridClass + instantiateTimeGrid: function() { + var subclass = this.timeGridClass.extend(agendaTimeGridMethods); + + return new subclass(this); + }, + + + // Instantiates the DayGrid object this view might need. Draws from this.dayGridClass + instantiateDayGrid: function() { + var subclass = this.dayGridClass.extend(agendaDayGridMethods); + + return new subclass(this); + }, + + + /* Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + renderSkeleton: function() { + var timeGridWrapEl; + var timeGridEl; + + this.el.addClass('fc-agenda-view').html(this.renderSkeletonHtml()); + + this.scroller.render(); + + timeGridWrapEl = this.scroller.el.addClass('fc-time-grid-container'); + timeGridEl = $('
').appendTo(timeGridWrapEl); + + this.el.find('.fc-body > tr > td').append(timeGridWrapEl); + + this.timeGrid.headContainerEl = this.el.find('.fc-head-container'); + this.timeGrid.setElement(timeGridEl); + + if (this.dayGrid) { + this.dayGrid.setElement(this.el.find('.fc-day-grid')); + + // have the day-grid extend it's coordinate area over the
dividing the two grids + this.dayGrid.bottomCoordPadding = this.dayGrid.el.next('hr').outerHeight(); + } + }, + + + unrenderSkeleton: function() { + this.timeGrid.removeElement(); + + if (this.dayGrid) { + this.dayGrid.removeElement(); + } + + this.scroller.destroy(); + }, + + + // Builds the HTML skeleton for the view. + // The day-grid and time-grid components will render inside containers defined by this HTML. + renderSkeletonHtml: function() { + var theme = this.calendar.theme; + + return '' + + '' + + (this.opt('columnHeader') ? + '' + + '' + + '' + + '' + + '' : + '' + ) + + '' + + '' + + '' + + '' + + '' + + '
 
' + + (this.dayGrid ? + '
' + + '
' : + '' + ) + + '
'; + }, + + + // Generates an HTML attribute string for setting the width of the axis, if it is known + axisStyleAttr: function() { + if (this.axisWidth !== null) { + return 'style="width:' + this.axisWidth + 'px"'; + } + return ''; + }, + + + /* Now Indicator + ------------------------------------------------------------------------------------------------------------------*/ + + + getNowIndicatorUnit: function() { + return this.timeGrid.getNowIndicatorUnit(); + }, + + + /* Dimensions + ------------------------------------------------------------------------------------------------------------------*/ + + + // Adjusts the vertical dimensions of the view to the specified values + updateSize: function(totalHeight, isAuto, isResize) { + var eventLimit; + var scrollerHeight; + var scrollbarWidths; + + View.prototype.updateSize.apply(this, arguments); + + // make all axis cells line up, and record the width so newly created axis cells will have it + this.axisWidth = matchCellWidths(this.el.find('.fc-axis')); + + // hack to give the view some height prior to timeGrid's columns being rendered + // TODO: separate setting height from scroller VS timeGrid. + if (!this.timeGrid.colEls) { + if (!isAuto) { + scrollerHeight = this.computeScrollerHeight(totalHeight); + this.scroller.setHeight(scrollerHeight); + } + return; + } + + // set of fake row elements that must compensate when scroller has scrollbars + var noScrollRowEls = this.el.find('.fc-row:not(.fc-scroller *)'); + + // reset all dimensions back to the original state + this.timeGrid.bottomRuleEl.hide(); // .show() will be called later if this
is necessary + this.scroller.clear(); // sets height to 'auto' and clears overflow + uncompensateScroll(noScrollRowEls); + + // limit number of events in the all-day area + if (this.dayGrid) { + this.dayGrid.removeSegPopover(); // kill the "more" popover if displayed + + eventLimit = this.opt('eventLimit'); + if (eventLimit && typeof eventLimit !== 'number') { + eventLimit = AGENDA_ALL_DAY_EVENT_LIMIT; // make sure "auto" goes to a real number + } + if (eventLimit) { + this.dayGrid.limitRows(eventLimit); + } + } + + if (!isAuto) { // should we force dimensions of the scroll container? + + scrollerHeight = this.computeScrollerHeight(totalHeight); + this.scroller.setHeight(scrollerHeight); + scrollbarWidths = this.scroller.getScrollbarWidths(); + + if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars? + + // make the all-day and header rows lines up + compensateScroll(noScrollRowEls, scrollbarWidths); + + // the scrollbar compensation might have changed text flow, which might affect height, so recalculate + // and reapply the desired height to the scroller. + scrollerHeight = this.computeScrollerHeight(totalHeight); + this.scroller.setHeight(scrollerHeight); + } + + // guarantees the same scrollbar widths + this.scroller.lockOverflow(scrollbarWidths); + + // if there's any space below the slats, show the horizontal rule. + // this won't cause any new overflow, because lockOverflow already called. + if (this.timeGrid.getTotalSlatHeight() < scrollerHeight) { + this.timeGrid.bottomRuleEl.show(); + } + } + }, + + + // given a desired total height of the view, returns what the height of the scroller should be + computeScrollerHeight: function(totalHeight) { + return totalHeight - + subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller + }, + + + /* Scroll + ------------------------------------------------------------------------------------------------------------------*/ + + + // Computes the initial pre-configured scroll state prior to allowing the user to change it + computeInitialDateScroll: function() { + var scrollTime = moment.duration(this.opt('scrollTime')); + var top = this.timeGrid.computeTimeTop(scrollTime); + + // zoom can give weird floating-point values. rather scroll a little bit further + top = Math.ceil(top); + + if (top) { + top++; // to overcome top border that slots beyond the first have. looks better + } + + return { top: top }; + }, + + + queryDateScroll: function() { + return { top: this.scroller.getScrollTop() }; + }, + + + applyDateScroll: function(scroll) { + if (scroll.top !== undefined) { + this.scroller.setScrollTop(scroll.top); + } + }, + + + /* Hit Areas + ------------------------------------------------------------------------------------------------------------------*/ + // forward all hit-related method calls to the grids (dayGrid might not be defined) + + + getHitFootprint: function(hit) { + // TODO: hit.component is set as a hack to identify where the hit came from + return hit.component.getHitFootprint(hit); + }, + + + getHitEl: function(hit) { + // TODO: hit.component is set as a hack to identify where the hit came from + return hit.component.getHitEl(hit); + }, + + + /* Event Rendering + ------------------------------------------------------------------------------------------------------------------*/ + + + executeEventRender: function(eventsPayload) { + var dayEventsPayload = {}; + var timedEventsPayload = {}; + var id, eventInstanceGroup; + + // separate the events into all-day and timed + for (id in eventsPayload) { + eventInstanceGroup = eventsPayload[id]; + + if (eventInstanceGroup.getEventDef().isAllDay()) { + dayEventsPayload[id] = eventInstanceGroup; + } + else { + timedEventsPayload[id] = eventInstanceGroup; + } + } + + this.timeGrid.executeEventRender(timedEventsPayload); + + if (this.dayGrid) { + this.dayGrid.executeEventRender(dayEventsPayload); + } + }, + + + /* Dragging/Resizing Routing + ------------------------------------------------------------------------------------------------------------------*/ + + + // A returned value of `true` signals that a mock "helper" event has been rendered. + renderDrag: function(eventFootprints, seg, isTouch) { + var groups = groupEventFootprintsByAllDay(eventFootprints); + var renderedHelper = false; + + renderedHelper = this.timeGrid.renderDrag(groups.timed, seg, isTouch); + + if (this.dayGrid) { + renderedHelper = this.dayGrid.renderDrag(groups.allDay, seg, isTouch) || renderedHelper; + } + + return renderedHelper; + }, + + + renderEventResize: function(eventFootprints, seg, isTouch) { + var groups = groupEventFootprintsByAllDay(eventFootprints); + + this.timeGrid.renderEventResize(groups.timed, seg, isTouch); + + if (this.dayGrid) { + this.dayGrid.renderEventResize(groups.allDay, seg, isTouch); + } + }, + + + /* Selection + ------------------------------------------------------------------------------------------------------------------*/ + + + // Renders a visual indication of a selection + renderSelectionFootprint: function(componentFootprint) { + if (!componentFootprint.isAllDay) { + this.timeGrid.renderSelectionFootprint(componentFootprint); + } + else if (this.dayGrid) { + this.dayGrid.renderSelectionFootprint(componentFootprint); + } + } + +}); + + +// Methods that will customize the rendering behavior of the AgendaView's timeGrid +// TODO: move into TimeGrid +var agendaTimeGridMethods = { + + + // Generates the HTML that will go before the day-of week header cells + renderHeadIntroHtml: function() { + var view = this.view; + var calendar = view.calendar; + var weekStart = calendar.msToUtcMoment(this.dateProfile.renderUnzonedRange.startMs, true); + var weekText; + + if (this.opt('weekNumbers')) { + weekText = weekStart.format(this.opt('smallWeekFormat')); + + return '' + + '' + + view.buildGotoAnchorHtml( // aside from link, important for matchCellWidths + { date: weekStart, type: 'week', forceOff: this.colCnt > 1 }, + htmlEscape(weekText) // inner HTML + ) + + ''; + } + else { + return ''; + } + }, + + + // Generates the HTML that goes before the bg of the TimeGrid slot area. Long vertical column. + renderBgIntroHtml: function() { + var view = this.view; + + return ''; + }, + + + // Generates the HTML that goes before all other types of cells. + // Affects content-skeleton, helper-skeleton, highlight-skeleton for both the time-grid and day-grid. + renderIntroHtml: function() { + var view = this.view; + + return ''; + } + +}; + + +// Methods that will customize the rendering behavior of the AgendaView's dayGrid +var agendaDayGridMethods = { + + + // Generates the HTML that goes before the all-day cells + renderBgIntroHtml: function() { + var view = this.view; + + return '' + + '' + + '' + // needed for matchCellWidths + view.getAllDayHtml() + + '' + + ''; + }, + + + // Generates the HTML that goes before all other types of cells. + // Affects content-skeleton, helper-skeleton, highlight-skeleton for both the time-grid and day-grid. + renderIntroHtml: function() { + var view = this.view; + + return ''; + } + +}; + + +function groupEventFootprintsByAllDay(eventFootprints) { + var allDay = []; + var timed = []; + var i; + + for (i = 0; i < eventFootprints.length; i++) { + if (eventFootprints[i].componentFootprint.isAllDay) { + allDay.push(eventFootprints[i]); + } + else { + timed.push(eventFootprints[i]); + } + } + + return { allDay: allDay, timed: timed }; +} + +;; + +var AGENDA_ALL_DAY_EVENT_LIMIT = 5; + +// potential nice values for the slot-duration and interval-duration +// from largest to smallest +var AGENDA_STOCK_SUB_DURATIONS = [ + { hours: 1 }, + { minutes: 30 }, + { minutes: 15 }, + { seconds: 30 }, + { seconds: 15 } +]; + +fcViews.agenda = { + 'class': AgendaView, + defaults: { + allDaySlot: true, + slotDuration: '00:30:00', + slotEventOverlap: true // a bad name. confused with overlap/constraint system + } +}; + +fcViews.agendaDay = { + type: 'agenda', + duration: { days: 1 } +}; + +fcViews.agendaWeek = { + type: 'agenda', + duration: { weeks: 1 } +}; +;; + +/* +Responsible for the scroller, and forwarding event-related actions into the "grid". +*/ +var ListView = FC.ListView = View.extend({ + + segSelector: '.fc-list-item', // which elements accept event actions + //eventRendererClass is below + //eventPointingClass is below + + scroller: null, + contentEl: null, + + dayDates: null, // localized ambig-time moment array + dayRanges: null, // UnzonedRange[], of start-end of each day + + + constructor: function() { + View.apply(this, arguments); + + this.scroller = new Scroller({ + overflowX: 'hidden', + overflowY: 'auto' + }); + }, + + + renderSkeleton: function() { + this.el.addClass( + 'fc-list-view ' + + this.calendar.theme.getClass('listView') + ); + + this.scroller.render(); + this.scroller.el.appendTo(this.el); + + this.contentEl = this.scroller.scrollEl; // shortcut + }, + + + unrenderSkeleton: function() { + this.scroller.destroy(); // will remove the Grid too + }, + + + updateSize: function(totalHeight, isAuto, isResize) { + this.scroller.setHeight(this.computeScrollerHeight(totalHeight)); + }, + + + computeScrollerHeight: function(totalHeight) { + return totalHeight - + subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller + }, + + + renderDates: function(dateProfile) { + var calendar = this.calendar; + var dayStart = calendar.msToUtcMoment(dateProfile.renderUnzonedRange.startMs, true); + var viewEnd = calendar.msToUtcMoment(dateProfile.renderUnzonedRange.endMs, true); + var dayDates = []; + var dayRanges = []; + + while (dayStart < viewEnd) { + + dayDates.push(dayStart.clone()); + + dayRanges.push(new UnzonedRange( + dayStart, + dayStart.clone().add(1, 'day') + )); + + dayStart.add(1, 'day'); + } + + this.dayDates = dayDates; + this.dayRanges = dayRanges; + + // all real rendering happens in EventRenderer + }, + + + // slices by day + componentFootprintToSegs: function(footprint) { + var dayRanges = this.dayRanges; + var dayIndex; + var segRange; + var seg; + var segs = []; + + for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex++) { + segRange = footprint.unzonedRange.intersect(dayRanges[dayIndex]); + + if (segRange) { + seg = { + startMs: segRange.startMs, + endMs: segRange.endMs, + isStart: segRange.isStart, + isEnd: segRange.isEnd, + dayIndex: dayIndex + }; + + segs.push(seg); + + // detect when footprint won't go fully into the next day, + // and mutate the latest seg to the be the end. + if ( + !seg.isEnd && !footprint.isAllDay && + dayIndex + 1 < dayRanges.length && + footprint.unzonedRange.endMs < dayRanges[dayIndex + 1].startMs + this.nextDayThreshold + ) { + seg.endMs = footprint.unzonedRange.endMs; + seg.isEnd = true; + break; + } + } + } + + return segs; + }, + + + eventRendererClass: EventRenderer.extend({ + + + renderFgSegs: function(segs) { + if (!segs.length) { + this.component.renderEmptyMessage(); + } + else { + this.component.renderSegList(segs); + } + }, + + + // generates the HTML for a single event row + fgSegHtml: function(seg) { + var view = this.view; + var calendar = view.calendar; + var theme = calendar.theme; + var eventFootprint = seg.footprint; + var eventDef = eventFootprint.eventDef; + var componentFootprint = eventFootprint.componentFootprint; + var url = eventDef.url; + var classes = [ 'fc-list-item' ].concat(this.getClasses(eventDef)); + var bgColor = this.getBgColor(eventDef); + var timeHtml; + + if (componentFootprint.isAllDay) { + timeHtml = view.getAllDayHtml(); + } + // if the event appears to span more than one day + else if (view.isMultiDayRange(componentFootprint.unzonedRange)) { + if (seg.isStart || seg.isEnd) { // outer segment that probably lasts part of the day + timeHtml = htmlEscape(this._getTimeText( + calendar.msToMoment(seg.startMs), + calendar.msToMoment(seg.endMs), + componentFootprint.isAllDay + )); + } + else { // inner segment that lasts the whole day + timeHtml = view.getAllDayHtml(); + } + } + else { + // Display the normal time text for the *event's* times + timeHtml = htmlEscape(this.getTimeText(eventFootprint)); + } + + if (url) { + classes.push('fc-has-url'); + } + + return '' + + (this.displayEventTime ? + '' + + (timeHtml || '') + + '' : + '') + + '' + + '' + + '' + + '' + + '' + + htmlEscape(eventDef.title || '') + + '' + + '' + + ''; + }, + + + // like "4:00am" + computeEventTimeFormat: function() { + return this.opt('mediumTimeFormat'); + } + + }), + + + eventPointingClass: EventPointing.extend({ + + // for events with a url, the whole should be clickable, + // but it's impossible to wrap with an tag. simulate this. + handleClick: function(seg, ev) { + var url; + + EventPointing.prototype.handleClick.apply(this, arguments); // super. might prevent the default action + + // not clicking on or within an with an href + if (!$(ev.target).closest('a[href]').length) { + url = seg.footprint.eventDef.url; + + if (url && !ev.isDefaultPrevented()) { // jsEvent not cancelled in handler + window.location.href = url; // simulate link click + } + } + } + + }), + + + renderEmptyMessage: function() { + this.contentEl.html( + '
' + // TODO: try less wraps + '
' + + '
' + + htmlEscape(this.opt('noEventsMessage')) + + '
' + + '
' + + '
' + ); + }, + + + // render the event segments in the view + renderSegList: function(allSegs) { + var segsByDay = this.groupSegsByDay(allSegs); // sparse array + var dayIndex; + var daySegs; + var i; + var tableEl = $('
'); + var tbodyEl = tableEl.find('tbody'); + + for (dayIndex = 0; dayIndex < segsByDay.length; dayIndex++) { + daySegs = segsByDay[dayIndex]; + + if (daySegs) { // sparse array, so might be undefined + + // append a day header + tbodyEl.append(this.dayHeaderHtml(this.dayDates[dayIndex])); + + this.eventRenderer.sortEventSegs(daySegs); + + for (i = 0; i < daySegs.length; i++) { + tbodyEl.append(daySegs[i].el); // append event row + } + } + } + + this.contentEl.empty().append(tableEl); + }, + + + // Returns a sparse array of arrays, segs grouped by their dayIndex + groupSegsByDay: function(segs) { + var segsByDay = []; // sparse array + var i, seg; + + for (i = 0; i < segs.length; i++) { + seg = segs[i]; + (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = [])) + .push(seg); + } + + return segsByDay; + }, + + + // generates the HTML for the day headers that live amongst the event rows + dayHeaderHtml: function(dayDate) { + var mainFormat = this.opt('listDayFormat'); + var altFormat = this.opt('listDayAltFormat'); + + return '' + + '' + + (mainFormat ? + this.buildGotoAnchorHtml( + dayDate, + { 'class': 'fc-list-heading-main' }, + htmlEscape(dayDate.format(mainFormat)) // inner HTML + ) : + '') + + (altFormat ? + this.buildGotoAnchorHtml( + dayDate, + { 'class': 'fc-list-heading-alt' }, + htmlEscape(dayDate.format(altFormat)) // inner HTML + ) : + '') + + '' + + ''; + } + +}); + +;; + +fcViews.list = { + 'class': ListView, + buttonTextKey: 'list', // what to lookup in locale files + defaults: { + buttonText: 'list', // text to display for English + listDayFormat: 'LL', // like "January 1, 2016" + noEventsMessage: 'No events to display' + } +}; + +fcViews.listDay = { + type: 'list', + duration: { days: 1 }, + defaults: { + listDayFormat: 'dddd' // day-of-week is all we need. full date is probably in header + } +}; + +fcViews.listWeek = { + type: 'list', + duration: { weeks: 1 }, + defaults: { + listDayFormat: 'dddd', // day-of-week is more important + listDayAltFormat: 'LL' + } +}; + +fcViews.listMonth = { + type: 'list', + duration: { month: 1 }, + defaults: { + listDayAltFormat: 'dddd' // day-of-week is nice-to-have + } +}; + +fcViews.listYear = { + type: 'list', + duration: { year: 1 }, + defaults: { + listDayAltFormat: 'dddd' // day-of-week is nice-to-have + } +}; + +;; + +return FC; // export for Node/CommonJS +}); \ No newline at end of file diff --git a/librerias/calendar/fullcalendar.min.css b/librerias/calendar/fullcalendar.min.css new file mode 100755 index 0000000..450eb25 --- /dev/null +++ b/librerias/calendar/fullcalendar.min.css @@ -0,0 +1,5 @@ +/*! + * FullCalendar v3.6.1 Stylesheet + * Docs & License: https://fullcalendar.io/ + * (c) 2017 Adam Shaw + */.fc button,.fc table,body .fc{font-size:1em}.fc-bg,.fc-row .fc-bgevent-skeleton,.fc-row .fc-highlight-skeleton{bottom:0}.fc-icon,.fc-unselectable{-webkit-touch-callout:none;-khtml-user-select:none}.fc{direction:ltr;text-align:left}.fc-rtl{text-align:right}.fc th,.fc-basic-view td.fc-week-number,.fc-icon,.fc-toolbar{text-align:center}.fc-highlight{background:#bce8f1;opacity:.3}.fc-bgevent{background:#8fdf82;opacity:.3}.fc-nonbusiness{background:#d7d7d7}.fc button{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0;height:2.1em;padding:0 .6em;white-space:nowrap;cursor:pointer}.fc button::-moz-focus-inner{margin:0;padding:0}.fc-state-default{border:1px solid;background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.fc-state-default.fc-corner-left{border-top-left-radius:4px;border-bottom-left-radius:4px}.fc-state-default.fc-corner-right{border-top-right-radius:4px;border-bottom-right-radius:4px}.fc button .fc-icon{position:relative;top:-.05em;margin:0 .2em;vertical-align:middle}.fc-state-active,.fc-state-disabled,.fc-state-down,.fc-state-hover{color:#333;background-color:#e6e6e6}.fc-state-hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.fc-state-active,.fc-state-down{background-color:#ccc;background-image:none;box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.fc-state-disabled{cursor:default;background-image:none;opacity:.65;box-shadow:none}.fc-event.fc-draggable,.fc-event[href],.fc-popover .fc-header .fc-close,a[data-goto]{cursor:pointer}.fc-button-group{display:inline-block}.fc .fc-button-group>*{float:left;margin:0 0 0 -1px}.fc .fc-button-group>:first-child{margin-left:0}.fc-popover{position:absolute;box-shadow:0 2px 6px rgba(0,0,0,.15)}.fc-popover .fc-header{padding:2px 4px}.fc-popover .fc-header .fc-title{margin:0 2px}.fc-ltr .fc-popover .fc-header .fc-title,.fc-rtl .fc-popover .fc-header .fc-close{float:left}.fc-ltr .fc-popover .fc-header .fc-close,.fc-rtl .fc-popover .fc-header .fc-title{float:right}.fc-divider{border-style:solid;border-width:1px}hr.fc-divider{height:0;margin:0;padding:0 0 2px;border-width:1px 0}.fc-bg table,.fc-row .fc-bgevent-skeleton table,.fc-row .fc-highlight-skeleton table{height:100%}.fc-clear{clear:both}.fc-bg,.fc-bgevent-skeleton,.fc-helper-skeleton,.fc-highlight-skeleton{position:absolute;top:0;left:0;right:0}.fc table{width:100%;box-sizing:border-box;table-layout:fixed;border-collapse:collapse;border-spacing:0}.fc td,.fc th{border-style:solid;border-width:1px;padding:0;vertical-align:top}.fc td.fc-today{border-style:double}a[data-goto]:hover{text-decoration:underline}.fc .fc-row{border-style:solid;border-width:0}.fc-row table{border-left:0 hidden transparent;border-right:0 hidden transparent;border-bottom:0 hidden transparent}.fc-row:first-child table{border-top:0 hidden transparent}.fc-row{position:relative}.fc-row .fc-bg{z-index:1}.fc-row .fc-bgevent-skeleton td,.fc-row .fc-highlight-skeleton td{border-color:transparent}.fc-row .fc-bgevent-skeleton{z-index:2}.fc-row .fc-highlight-skeleton{z-index:3}.fc-row .fc-content-skeleton{position:relative;z-index:4;padding-bottom:2px}.fc-row .fc-helper-skeleton{z-index:5}.fc .fc-row .fc-content-skeleton table,.fc .fc-row .fc-content-skeleton td,.fc .fc-row .fc-helper-skeleton td{background:0 0;border-color:transparent}.fc-row .fc-content-skeleton td,.fc-row .fc-helper-skeleton td{border-bottom:0}.fc-row .fc-content-skeleton tbody td,.fc-row .fc-helper-skeleton tbody td{border-top:0}.fc-scroller{-webkit-overflow-scrolling:touch}.fc-icon,.fc-row.fc-rigid,.fc-time-grid-event{overflow:hidden}.fc-scroller>.fc-day-grid,.fc-scroller>.fc-time-grid{position:relative;width:100%}.fc-event{position:relative;display:block;font-size:.85em;line-height:1.3;border-radius:3px;border:1px solid #3a87ad}.fc-event,.fc-event-dot{background-color:#3a87ad}.fc-event,.fc-event:hover{color:#fff;text-decoration:none}.fc-not-allowed,.fc-not-allowed .fc-event{cursor:not-allowed}.fc-event .fc-bg{z-index:1;background:#fff;opacity:.25}.fc-event .fc-content{position:relative;z-index:2}.fc-event .fc-resizer{position:absolute;z-index:4;display:none}.fc-event.fc-allow-mouse-resize .fc-resizer,.fc-event.fc-selected .fc-resizer{display:block}.fc-event.fc-selected .fc-resizer:before{content:"";position:absolute;z-index:9999;top:50%;left:50%;width:40px;height:40px;margin-left:-20px;margin-top:-20px}.fc-event.fc-selected{z-index:9999!important;box-shadow:0 2px 5px rgba(0,0,0,.2)}.fc-event.fc-selected.fc-dragging{box-shadow:0 2px 7px rgba(0,0,0,.3)}.fc-h-event.fc-selected:before{content:"";position:absolute;z-index:3;top:-10px;bottom:-10px;left:0;right:0}.fc-ltr .fc-h-event.fc-not-start,.fc-rtl .fc-h-event.fc-not-end{margin-left:0;border-left-width:0;padding-left:1px;border-top-left-radius:0;border-bottom-left-radius:0}.fc-ltr .fc-h-event.fc-not-end,.fc-rtl .fc-h-event.fc-not-start{margin-right:0;border-right-width:0;padding-right:1px;border-top-right-radius:0;border-bottom-right-radius:0}.fc-ltr .fc-h-event .fc-start-resizer,.fc-rtl .fc-h-event .fc-end-resizer{cursor:w-resize;left:-1px}.fc-ltr .fc-h-event .fc-end-resizer,.fc-rtl .fc-h-event .fc-start-resizer{cursor:e-resize;right:-1px}.fc-h-event.fc-allow-mouse-resize .fc-resizer{width:7px;top:-1px;bottom:-1px}.fc-h-event.fc-selected .fc-resizer{border-radius:4px;border-width:1px;width:6px;height:6px;border-style:solid;border-color:inherit;background:#fff;top:50%;margin-top:-4px}.fc-ltr .fc-h-event.fc-selected .fc-start-resizer,.fc-rtl .fc-h-event.fc-selected .fc-end-resizer{margin-left:-4px}.fc-ltr .fc-h-event.fc-selected .fc-end-resizer,.fc-rtl .fc-h-event.fc-selected .fc-start-resizer{margin-right:-4px}.fc-day-grid-event{margin:1px 2px 0;padding:0 1px}tr:first-child>td>.fc-day-grid-event{margin-top:2px}.fc-day-grid-event.fc-selected:after{content:"";position:absolute;z-index:1;top:-1px;right:-1px;bottom:-1px;left:-1px;background:#000;opacity:.25}.fc-day-grid-event .fc-content{white-space:nowrap;overflow:hidden}.fc-day-grid-event .fc-time{font-weight:700}.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer,.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer{margin-left:-2px}.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer,.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer{margin-right:-2px}a.fc-more{margin:1px 3px;font-size:.85em;cursor:pointer;text-decoration:none}a.fc-more:hover{text-decoration:underline}.fc.fc-bootstrap3 a,.ui-widget .fc-event{text-decoration:none}.fc-limited{display:none}.fc-icon,.fc-toolbar .fc-center{display:inline-block}.fc-day-grid .fc-row{z-index:1}.fc-more-popover{z-index:2;width:220px}.fc-more-popover .fc-event-container{padding:10px}.fc-now-indicator{position:absolute;border:0 solid red}.fc-icon:after,.fc-toolbar button{position:relative}.fc-unselectable{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.fc-unthemed .fc-content,.fc-unthemed .fc-divider,.fc-unthemed .fc-list-heading td,.fc-unthemed .fc-list-view,.fc-unthemed .fc-popover,.fc-unthemed .fc-row,.fc-unthemed tbody,.fc-unthemed td,.fc-unthemed th,.fc-unthemed thead{border-color:#ddd}.fc-unthemed .fc-popover{background-color:#fff;border-width:1px;border-style:solid}.fc-unthemed .fc-divider,.fc-unthemed .fc-list-heading td,.fc-unthemed .fc-popover .fc-header{background:#eee}.fc-unthemed td.fc-today{background:#fcf8e3}.fc-unthemed .fc-disabled-day{background:#d7d7d7;opacity:.3}.fc-icon{height:1em;line-height:1em;font-size:1em;font-family:"Courier New",Courier,monospace;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.fc-icon-left-single-arrow:after{content:"\02039";font-weight:700;font-size:200%;top:-7%}.fc-icon-right-single-arrow:after{content:"\0203A";font-weight:700;font-size:200%;top:-7%}.fc-icon-left-double-arrow:after{content:"\000AB";font-size:160%;top:-7%}.fc-icon-right-double-arrow:after{content:"\000BB";font-size:160%;top:-7%}.fc-icon-left-triangle:after{content:"\25C4";font-size:125%;top:3%}.fc-icon-right-triangle:after{content:"\25BA";font-size:125%;top:3%}.fc-icon-down-triangle:after{content:"\25BC";font-size:125%;top:2%}.fc-icon-x:after{content:"\000D7";font-size:200%;top:6%}.fc-unthemed .fc-popover .fc-header .fc-close{color:#666;font-size:.9em;margin-top:2px}.fc-unthemed .fc-list-item:hover td{background-color:#f5f5f5}.ui-widget .fc-disabled-day{background-image:none}.fc-bootstrap3 .fc-time-grid .fc-slats table,.fc-time-grid .fc-slats .ui-widget-content{background:0 0}.fc-popover>.ui-widget-header+.ui-widget-content{border-top:0}.ui-widget .fc-event{color:#fff;font-weight:400}.ui-widget td.fc-axis{font-weight:400}.fc.fc-bootstrap3 a[data-goto]:hover{text-decoration:underline}.fc-bootstrap3 hr.fc-divider{border-color:inherit}.fc-bootstrap3 .fc-today.alert{border-radius:0}.fc-bootstrap3 .fc-popover .panel-body{padding:0}.fc-toolbar.fc-header-toolbar{margin-bottom:1em}.fc-toolbar.fc-footer-toolbar{margin-top:1em}.fc-toolbar .fc-left{float:left}.fc-toolbar .fc-right{float:right}.fc .fc-toolbar>*>*{float:left;margin-left:.75em}.fc .fc-toolbar>*>:first-child{margin-left:0}.fc-toolbar h2{margin:0}.fc-toolbar .fc-state-hover,.fc-toolbar .ui-state-hover{z-index:2}.fc-toolbar .fc-state-down{z-index:3}.fc-toolbar .fc-state-active,.fc-toolbar .ui-state-active{z-index:4}.fc-toolbar button:focus{z-index:5}.fc-view-container *,.fc-view-container :after,.fc-view-container :before{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.fc-view,.fc-view>table{position:relative;z-index:1}.fc-basicDay-view .fc-content-skeleton,.fc-basicWeek-view .fc-content-skeleton{padding-bottom:1em}.fc-basic-view .fc-body .fc-row{min-height:4em}.fc-row.fc-rigid .fc-content-skeleton{position:absolute;top:0;left:0;right:0}.fc-day-top.fc-other-month{opacity:.3}.fc-basic-view .fc-day-number,.fc-basic-view .fc-week-number{padding:2px}.fc-basic-view th.fc-day-number,.fc-basic-view th.fc-week-number{padding:0 2px}.fc-ltr .fc-basic-view .fc-day-top .fc-day-number{float:right}.fc-rtl .fc-basic-view .fc-day-top .fc-day-number{float:left}.fc-ltr .fc-basic-view .fc-day-top .fc-week-number{float:left;border-radius:0 0 3px}.fc-rtl .fc-basic-view .fc-day-top .fc-week-number{float:right;border-radius:0 0 0 3px}.fc-basic-view .fc-day-top .fc-week-number{min-width:1.5em;text-align:center;background-color:#f2f2f2;color:grey}.fc-basic-view td.fc-week-number>*{display:inline-block;min-width:1.25em}.fc-agenda-view .fc-day-grid{position:relative;z-index:2}.fc-agenda-view .fc-day-grid .fc-row{min-height:3em}.fc-agenda-view .fc-day-grid .fc-row .fc-content-skeleton{padding-bottom:1em}.fc .fc-axis{vertical-align:middle;padding:0 4px;white-space:nowrap}.fc-ltr .fc-axis{text-align:right}.fc-rtl .fc-axis{text-align:left}.fc-time-grid,.fc-time-grid-container{position:relative;z-index:1}.fc-time-grid{min-height:100%}.fc-time-grid table{border:0 hidden transparent}.fc-time-grid>.fc-bg{z-index:1}.fc-time-grid .fc-slats,.fc-time-grid>hr{position:relative;z-index:2}.fc-time-grid .fc-content-col{position:relative}.fc-time-grid .fc-content-skeleton{position:absolute;z-index:3;top:0;left:0;right:0}.fc-time-grid .fc-business-container{position:relative;z-index:1}.fc-time-grid .fc-bgevent-container{position:relative;z-index:2}.fc-time-grid .fc-highlight-container{z-index:3;position:relative}.fc-time-grid .fc-event-container{position:relative;z-index:4}.fc-time-grid .fc-now-indicator-line{z-index:5}.fc-time-grid .fc-helper-container{position:relative;z-index:6}.fc-time-grid .fc-slats td{height:1.5em;border-bottom:0}.fc-time-grid .fc-slats .fc-minor td{border-top-style:dotted}.fc-time-grid .fc-highlight{position:absolute;left:0;right:0}.fc-ltr .fc-time-grid .fc-event-container{margin:0 2.5% 0 2px}.fc-rtl .fc-time-grid .fc-event-container{margin:0 2px 0 2.5%}.fc-time-grid .fc-bgevent,.fc-time-grid .fc-event{position:absolute;z-index:1}.fc-time-grid .fc-bgevent{left:0;right:0}.fc-v-event.fc-not-start{border-top-width:0;padding-top:1px;border-top-left-radius:0;border-top-right-radius:0}.fc-v-event.fc-not-end{border-bottom-width:0;padding-bottom:1px;border-bottom-left-radius:0;border-bottom-right-radius:0}.fc-time-grid-event.fc-selected{overflow:visible}.fc-time-grid-event.fc-selected .fc-bg{display:none}.fc-time-grid-event .fc-content{overflow:hidden}.fc-time-grid-event .fc-time,.fc-time-grid-event .fc-title{padding:0 1px}.fc-time-grid-event .fc-time{font-size:.85em;white-space:nowrap}.fc-time-grid-event.fc-short .fc-content{white-space:nowrap}.fc-time-grid-event.fc-short .fc-time,.fc-time-grid-event.fc-short .fc-title{display:inline-block;vertical-align:top}.fc-time-grid-event.fc-short .fc-time span{display:none}.fc-time-grid-event.fc-short .fc-time:before{content:attr(data-start)}.fc-time-grid-event.fc-short .fc-time:after{content:"\000A0-\000A0"}.fc-time-grid-event.fc-short .fc-title{font-size:.85em;padding:0}.fc-time-grid-event.fc-allow-mouse-resize .fc-resizer{left:0;right:0;bottom:0;height:8px;overflow:hidden;line-height:8px;font-size:11px;font-family:monospace;text-align:center;cursor:s-resize}.fc-time-grid-event.fc-allow-mouse-resize .fc-resizer:after{content:"="}.fc-time-grid-event.fc-selected .fc-resizer{border-radius:5px;border-width:1px;width:8px;height:8px;border-style:solid;border-color:inherit;background:#fff;left:50%;margin-left:-5px;bottom:-5px}.fc-time-grid .fc-now-indicator-line{border-top-width:1px;left:0;right:0}.fc-time-grid .fc-now-indicator-arrow{margin-top:-5px}.fc-ltr .fc-time-grid .fc-now-indicator-arrow{left:0;border-width:5px 0 5px 6px;border-top-color:transparent;border-bottom-color:transparent}.fc-rtl .fc-time-grid .fc-now-indicator-arrow{right:0;border-width:5px 6px 5px 0;border-top-color:transparent;border-bottom-color:transparent}.fc-event-dot{display:inline-block;width:10px;height:10px;border-radius:5px}.fc-rtl .fc-list-view{direction:rtl}.fc-list-view{border-width:1px;border-style:solid}.fc .fc-list-table{table-layout:auto}.fc-list-table td{border-width:1px 0 0;padding:8px 14px}.fc-list-table tr:first-child td{border-top-width:0}.fc-list-heading{border-bottom-width:1px}.fc-list-heading td{font-weight:700}.fc-ltr .fc-list-heading-main{float:left}.fc-ltr .fc-list-heading-alt,.fc-rtl .fc-list-heading-main{float:right}.fc-rtl .fc-list-heading-alt{float:left}.fc-list-item.fc-has-url{cursor:pointer}.fc-list-item-marker,.fc-list-item-time{white-space:nowrap;width:1px}.fc-ltr .fc-list-item-marker{padding-right:0}.fc-rtl .fc-list-item-marker{padding-left:0}.fc-list-item-title a{text-decoration:none;color:inherit}.fc-list-item-title a[href]:hover{text-decoration:underline}.fc-list-empty-wrap2{position:absolute;top:0;left:0;right:0;bottom:0}.fc-list-empty-wrap1{width:100%;height:100%;display:table}.fc-list-empty{display:table-cell;vertical-align:middle;text-align:center}.fc-unthemed .fc-list-empty{background-color:#eee} \ No newline at end of file diff --git a/librerias/calendar/fullcalendar.min.js b/librerias/calendar/fullcalendar.min.js new file mode 100755 index 0000000..f43a7f3 --- /dev/null +++ b/librerias/calendar/fullcalendar.min.js @@ -0,0 +1,11 @@ +/*! + * FullCalendar v3.6.1 + * Docs & License: https://fullcalendar.io/ + * (c) 2017 Adam Shaw + */ +!function(t){"function"==typeof define&&define.amd?define(["jquery","moment"],t):"object"==typeof exports?module.exports=t(require("jquery"),require("moment")):t(jQuery,moment)}(function(t,e){function n(t){return j(t,qt)}function i(t,e){e.left&&t.css({"border-left-width":1,"margin-left":e.left-1}),e.right&&t.css({"border-right-width":1,"margin-right":e.right-1})}function r(t){t.css({"margin-left":"","margin-right":"","border-left-width":"","border-right-width":""})}function s(){t("body").addClass("fc-not-allowed")}function o(){t("body").removeClass("fc-not-allowed")}function a(e,n,i){var r=Math.floor(n/e.length),s=Math.floor(n-r*(e.length-1)),o=[],a=[],u=[],c=0;l(e),e.each(function(n,i){var l=n===e.length-1?s:r,h=t(i).outerHeight(!0);h *").each(function(e,i){var r=t(i).outerWidth();r>n&&(n=r)}),n++,e.width(n),n}function c(t,e){var n,i=t.add(e);return i.css({position:"relative",left:-1}),n=t.outerHeight()-e.outerHeight(),i.css({position:"",left:""}),n}function h(e){var n=e.css("position"),i=e.parents().filter(function(){var e=t(this);return/(auto|scroll)/.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==n&&i.length?i:t(e[0].ownerDocument||document)}function d(t,e){var n=t.offset(),i=n.left-(e?e.left:0),r=n.top-(e?e.top:0);return{left:i,right:i+t.outerWidth(),top:r,bottom:r+t.outerHeight()}}function f(t,e){var n=t.offset(),i=p(t),r=n.left+w(t,"border-left-width")+i.left-(e?e.left:0),s=n.top+w(t,"border-top-width")+i.top-(e?e.top:0);return{left:r,right:r+t[0].clientWidth,top:s,bottom:s+t[0].clientHeight}}function g(t,e){var n=t.offset(),i=n.left+w(t,"border-left-width")+w(t,"padding-left")-(e?e.left:0),r=n.top+w(t,"border-top-width")+w(t,"padding-top")-(e?e.top:0);return{left:i,right:i+t.width(),top:r,bottom:r+t.height()}}function p(t){var e,n=t[0].offsetWidth-t[0].clientWidth,i=t[0].offsetHeight-t[0].clientHeight;return n=v(n),i=v(i),e={left:0,right:0,top:0,bottom:i},m()&&"rtl"==t.css("direction")?e.left=n:e.right=n,e}function v(t){return t=Math.max(0,t),t=Math.round(t)}function m(){return null===Yt&&(Yt=y()),Yt}function y(){var e=t("
").css({position:"absolute",top:-1e3,left:0,border:0,padding:0,overflow:"scroll",direction:"rtl"}).appendTo("body"),n=e.children(),i=n.offset().left>e.offset().left;return e.remove(),i}function w(t,e){return parseFloat(t.css(e))||0}function D(t){return 1==t.which&&!t.ctrlKey}function b(t){var e=t.originalEvent.touches;return e&&e.length?e[0].pageX:t.pageX}function E(t){var e=t.originalEvent.touches;return e&&e.length?e[0].pageY:t.pageY}function S(t){return/^touch/.test(t.type)}function C(t){t.addClass("fc-unselectable").on("selectstart",T)}function R(t){t.removeClass("fc-unselectable").off("selectstart",T)}function T(t){t.preventDefault()}function I(t,e){var n={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)};return n.left=1&&at(r)));n++);return i}function N(t,e){var n=O(t);return"week"===n&&"object"==typeof e&&e.days&&(n="day"),n}function V(t,n,i){return null!=i?i.diff(n,t,!0):e.isDuration(n)?n.as(t):n.end.diff(n.start,t,!0)}function G(t,e,n){var i;return _(n)?(e-t)/n:(i=n.asMonths(),Math.abs(i)>=1&&at(i)?e.diff(t,"months",!0)/i:e.diff(t,"days",!0)/n.asDays())}function U(t,e){var n,i;return _(t)||_(e)?t/e:(n=t.asMonths(),i=e.asMonths(),Math.abs(n)>=1&&at(n)&&Math.abs(i)>=1&&at(i)?n/i:t.asDays()/e.asDays())}function W(t,n){var i;return _(t)?e.duration(t*n):(i=t.asMonths(),Math.abs(i)>=1&&at(i)?e.duration({months:i*n}):e.duration({days:t.asDays()*n}))}function _(t){return Boolean(t.hours()||t.minutes()||t.seconds()||t.milliseconds())}function q(t){return"[object Date]"===Object.prototype.toString.call(t)||t instanceof Date}function Y(t){return"string"==typeof t&&/^\d+\:\d+(?:\:\d+\.?(?:\d{3})?)?$/.test(t)}function j(t,e){var n,i,r,s,o,a,l={};if(e)for(n=0;n=0;s--)if("object"==typeof(o=t[s][i]))r.unshift(o);else if(void 0!==o){l[i]=o;break}r.length&&(l[i]=j(r))}for(n=t.length-1;n>=0;n--){a=t[n];for(i in a)i in l||(l[i]=a[i])}return l}function Z(t,e){for(var n in t)Q(t,n)&&(e[n]=t[n])}function Q(t,e){return Qt.call(t,e)}function $(e,n,i){if(t.isFunction(e)&&(e=[e]),e){var r,s;for(r=0;r/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/\n/g,"
")}function nt(t){return t.replace(/&.*?;/g,"")}function it(e){var n=[];return t.each(e,function(t,e){null!=e&&n.push(t+":"+e)}),n.join(";")}function rt(e){var n=[];return t.each(e,function(t,e){null!=e&&n.push(t+'="'+et(e)+'"')}),n.join(" ")}function st(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ot(t,e){return t-e}function at(t){return t%1==0}function lt(t,e){var n=t[e];return function(){return n.apply(t,arguments)}}function ut(t,e,n){var i,r,s,o,a,l=function(){var u=+new Date-o;u"),g.append(o("left")).append(o("right")).append(o("center")).append('
')):s()}function s(){g&&(g.remove(),g=f.el=null)}function o(i){var r=e.theme,s=t('
'),o=n.layout[i],a=e.opt("customButtons")||{},l=e.overrides.buttonText||{},u=e.opt("buttonText")||{};return o&&t.each(o.split(" "),function(n){var i,o=t(),c=!0;t.each(this.split(","),function(n,i){var s,h,d,f,g,v,m,y;"title"==i?(o=o.add(t("

 

")),c=!1):((s=a[i])?(d=function(t){s.click&&s.click.call(y[0],t)},(f=r.getCustomButtonIconClass(s))||(f=r.getIconClass(i))||(g=s.text)):(h=e.getViewSpec(i))?(p.push(i),d=function(){e.changeView(i)},(g=h.buttonTextOverride)||(f=r.getIconClass(i))||(g=h.buttonTextDefault)):e[i]&&(d=function(){e[i]()},(g=l[i])||(f=r.getIconClass(i))||(g=u[i])),d&&(m=["fc-"+i+"-button",r.getClass("button"),r.getClass("stateDefault")],g?v=et(g):f&&(v=""),y=t('").click(function(t){y.hasClass(r.getClass("stateDisabled"))||(d(t),(y.hasClass(r.getClass("stateActive"))||y.hasClass(r.getClass("stateDisabled")))&&y.removeClass(r.getClass("stateHover")))}).mousedown(function(){y.not("."+r.getClass("stateActive")).not("."+r.getClass("stateDisabled")).addClass(r.getClass("stateDown"))}).mouseup(function(){y.removeClass(r.getClass("stateDown"))}).hover(function(){y.not("."+r.getClass("stateActive")).not("."+r.getClass("stateDisabled")).addClass(r.getClass("stateHover"))},function(){y.removeClass(r.getClass("stateHover")).removeClass(r.getClass("stateDown"))}),o=o.add(y)))}),c&&o.first().addClass(r.getClass("cornerLeft")).end().last().addClass(r.getClass("cornerRight")).end(),o.length>1?(i=t("
"),c&&i.addClass(r.getClass("buttonGroup")),i.append(o),s.append(i)):s.append(o)}),s}function a(t){g&&g.find("h2").text(t)}function l(t){g&&g.find(".fc-"+t+"-button").addClass(e.theme.getClass("stateActive"))}function u(t){g&&g.find(".fc-"+t+"-button").removeClass(e.theme.getClass("stateActive"))}function c(t){g&&g.find(".fc-"+t+"-button").prop("disabled",!0).addClass(e.theme.getClass("stateDisabled"))}function h(t){g&&g.find(".fc-"+t+"-button").prop("disabled",!1).removeClass(e.theme.getClass("stateDisabled"))}function d(){return p}var f=this;f.setToolbarOptions=i,f.render=r,f.removeElement=s,f.updateTitle=a,f.activateButton=l,f.deactivateButton=u,f.disableButton=c,f.enableButton=h,f.getViewsWithButtons=d,f.el=null;var g,p=[]}function Et(t,e,n){var i;for(i=0;is&&r.push(new Ue(s,i.startMs)),i.endMs>s&&(s=i.endMs);return s=t.leftCol)return!0;return!1}function At(t,e){return t.leftCol-e.leftCol}function Lt(t){var e,n,i,r=[];for(e=0;ee.top&&t.tops&&(!l[o]||u.isSame(c,l[o]))&&(o-1!==s||"."!==f[o]);o--)v=f[o]+v;for(a=s;a<=o;a++)m+=f[a],y+=g[a];return(m||y)&&(w=r?y+i+m:m+i+y),d(p+w+v)}function r(t){return D[t]||(D[t]=s(t))}function s(t){var e=o(t);return{fakeFormatString:l(e),sameUnits:u(e)}}function o(t){for(var e,n=[],i=/\[([^\]]*)\]|\(([^\)]*)\)|(LTS|LT|(\w)\4*o?)|([^\w\[\(]+)/g;e=i.exec(t);)e[1]?n.push.apply(n,a(e[1])):e[2]?n.push({maybe:o(e[2])}):e[3]?n.push({token:e[3]}):e[5]&&n.push.apply(n,a(e[5]));return n}function a(t){return". "===t?["."," "]:[t]}function l(t){var e,n,i=[];for(e=0;er.value)&&(r=i);return r?r.unit:null}Wt.formatDate=t,Wt.formatRange=n,Wt.oldMomentFormat=e,Wt.queryMostGranularFormatUnit=f;var g="\v",p="",v="",m=new RegExp(v+"([^"+v+"]*)"+v,"g"),y={t:function(t){return e(t,"a").charAt(0)},T:function(t){return e(t,"A").charAt(0)}},w={Y:{value:1,unit:"year"},M:{value:2,unit:"month"},W:{value:3,unit:"week"},w:{value:3,unit:"week"},D:{value:4,unit:"day"},d:{value:4,unit:"day"}},D={}}();var ee=Wt.formatDate,ne=Wt.formatRange,ie=Wt.oldMomentFormat;Wt.Class=dt,dt.extend=function(){var t,e={};for(t=0;t0}},se=Wt.ListenerMixin=function(){var e=0;return{listenerId:null,listenTo:function(e,n,i){if("object"==typeof n)for(var r in n)n.hasOwnProperty(r)&&this.listenTo(e,r,n[r]);else"string"==typeof n&&e.on(n+"."+this.getListenerNamespace(),t.proxy(i,this))},stopListeningTo:function(t,e){t.off((e||"")+"."+this.getListenerNamespace())},getListenerNamespace:function(){return null==this.listenerId&&(this.listenerId=e++),"_listener"+this.listenerId}}}(),oe={standardPropMap:{},applyProps:function(t){var e,n=this.standardPropMap,i={},r={};for(e in t)!0===n[e]?this[e]=t[e]:!1===n[e]?i[e]=t[e]:r[e]=t[e];return this.applyMiscProps(r),this.applyManualStandardProps(i)},applyManualStandardProps:function(t){return!0},applyMiscProps:function(t){},isStandardProp:function(t){return t in this.standardPropMap}},ae=function(t){var e=this.prototype;e.hasOwnProperty("standardPropMap")||(e.standardPropMap=Object.create(e.standardPropMap)),Z(t,e.standardPropMap)},le=function(t,e){var n,i=this.prototype.standardPropMap;for(n in i)null!=t[n]&&!0===i[n]&&(e[n]=t[n])},ue=dt.extend(re,se,{_props:null,_watchers:null,_globalWatchArgs:{},constructor:function(){this._watchers={},this._props={},this.applyGlobalWatchers(),this.constructed()},constructed:function(){},applyGlobalWatchers:function(){var t,e=this._globalWatchArgs;for(t in e)this.watch.apply(this,e[t])},has:function(t){return t in this._props},get:function(t){return void 0===t?this._props:this._props[t]},set:function(t,e){var n;"string"==typeof t?(n={},n[t]=void 0===e?null:e):n=t,this.setProps(n)},reset:function(t){var e,n=this._props,i={};for(e in n)i[e]=void 0;for(e in t)i[e]=t[e];this.setProps(i)},unset:function(t){var e,n,i={};for(e="string"==typeof t?[t]:t,n=0;n=0;e--)switch(n=i[e],n.type){case"init":r=!1;case"add":case"remove":i.splice(e,1)}return r&&i.push(t),r}});Wt.RenderQueue=de;var fe=dt.extend(se,{isHidden:!0,options:null,el:null,margin:10,constructor:function(t){this.options=t||{}},show:function(){this.isHidden&&(this.el||this.render(),this.el.show(),this.position(),this.isHidden=!1,this.trigger("show"))},hide:function(){this.isHidden||(this.el.hide(),this.isHidden=!0,this.trigger("hide"))},render:function(){var e=this,n=this.options;this.el=t('
').addClass(n.className||"").css({top:0,left:0}).append(n.content).appendTo(n.parentEl),this.el.on("click",".fc-close",function(){e.hide()}),n.autoHide&&this.listenTo(t(document),"mousedown",this.documentMousedown)},documentMousedown:function(e){this.el&&!t(e.target).closest(this.el).length&&this.hide()},removeElement:function(){this.hide(),this.el&&(this.el.remove(),this.el=null),this.stopListeningTo(t(document),"mousedown")},position:function(){var e,n,i,r,s,o=this.options,a=this.el.offsetParent().offset(),l=this.el.outerWidth(),u=this.el.outerHeight(),c=t(window),d=h(this.el);r=o.top||0,s=void 0!==o.left?o.left:void 0!==o.right?o.right-l:0,d.is(window)||d.is(document)?(d=c,e=0,n=0):(i=d.offset(),e=i.top,n=i.left),e+=c.scrollTop(),n+=c.scrollLeft(),!1!==o.viewportConstrain&&(r=Math.min(r,e+d.outerHeight()-u-this.margin),r=Math.max(r,e+this.margin),s=Math.min(s,n+d.outerWidth()-l-this.margin),s=Math.max(s,n+this.margin)),this.el.css({top:r-a.top,left:s-a.left})},trigger:function(t){this.options[t]&&this.options[t].apply(this,Array.prototype.slice.call(arguments,1))}}),ge=Wt.CoordCache=dt.extend({els:null,forcedOffsetParentEl:null,origin:null,boundingRect:null,isHorizontal:!1,isVertical:!1,lefts:null,rights:null,tops:null,bottoms:null,constructor:function(e){this.els=t(e.els),this.isHorizontal=e.isHorizontal,this.isVertical=e.isVertical,this.forcedOffsetParentEl=e.offsetParent?t(e.offsetParent):null},build:function(){var t=this.forcedOffsetParentEl;!t&&this.els.length>0&&(t=this.els.eq(0).offsetParent()),this.origin=t?t.offset():null,this.boundingRect=this.queryBoundingRect(),this.isHorizontal&&this.buildElHorizontals(),this.isVertical&&this.buildElVerticals()},clear:function(){this.origin=null,this.boundingRect=null,this.lefts=null,this.rights=null,this.tops=null,this.bottoms=null},ensureBuilt:function(){this.origin||this.build()},buildElHorizontals:function(){var e=[],n=[];this.els.each(function(i,r){var s=t(r),o=s.offset().left,a=s.outerWidth();e.push(o),n.push(o+a)}),this.lefts=e,this.rights=n},buildElVerticals:function(){var e=[],n=[];this.els.each(function(i,r){var s=t(r),o=s.offset().top,a=s.outerHeight();e.push(o),n.push(o+a)}),this.tops=e,this.bottoms=n},getHorizontalIndex:function(t){this.ensureBuilt();var e,n=this.lefts,i=this.rights,r=n.length;for(e=0;e=n[e]&&t=n[e]&&t0&&(t=h(this.els.eq(0)),!t.is(document))?f(t):null},isPointInBounds:function(t,e){return this.isLeftInBounds(t)&&this.isTopInBounds(e)},isLeftInBounds:function(t){return!this.boundingRect||t>=this.boundingRect.left&&t=this.boundingRect.top&&t=i*i&&this.handleDistanceSurpassed(t),this.isDragging&&this.handleDrag(e,n,t)},handleDrag:function(t,e,n){this.trigger("drag",t,e,n),this.updateAutoScroll(n)},endDrag:function(t){this.isDragging&&(this.isDragging=!1,this.handleDragEnd(t))},handleDragEnd:function(t){this.trigger("dragEnd",t)},startDelay:function(t){var e=this;this.delay?this.delayTimeoutId=setTimeout(function(){e.handleDelayEnd(t)},this.delay):this.handleDelayEnd(t)},handleDelayEnd:function(t){this.isDelayEnded=!0,this.isDistanceSurpassed&&this.startDrag(t)},handleDistanceSurpassed:function(t){this.isDistanceSurpassed=!0,this.isDelayEnded&&this.startDrag(t)},handleTouchMove:function(t){this.isDragging&&this.shouldCancelTouchScroll&&t.preventDefault(),this.handleMove(t)},handleMouseMove:function(t){this.handleMove(t)},handleTouchScroll:function(t){this.isDragging&&!this.scrollAlwaysKills||this.endInteraction(t,!0)},trigger:function(t){this.options[t]&&this.options[t].apply(this,Array.prototype.slice.call(arguments,1)),this["_"+t]&&this["_"+t].apply(this,Array.prototype.slice.call(arguments,1))}});pe.mixin({isAutoScroll:!1,scrollBounds:null,scrollTopVel:null,scrollLeftVel:null,scrollIntervalId:null,scrollSensitivity:30,scrollSpeed:200,scrollIntervalMs:50,initAutoScroll:function(){var t=this.scrollEl;this.isAutoScroll=this.options.scroll&&t&&!t.is(window)&&!t.is(document),this.isAutoScroll&&this.listenTo(t,"scroll",ut(this.handleDebouncedScroll,100))},destroyAutoScroll:function(){this.endAutoScroll(),this.isAutoScroll&&this.stopListeningTo(this.scrollEl,"scroll")},computeScrollBounds:function(){this.isAutoScroll&&(this.scrollBounds=d(this.scrollEl))},updateAutoScroll:function(t){var e,n,i,r,s=this.scrollSensitivity,o=this.scrollBounds,a=0,l=0;o&&(e=(s-(E(t)-o.top))/s,n=(s-(o.bottom-E(t)))/s,i=(s-(b(t)-o.left))/s,r=(s-(o.right-b(t)))/s,e>=0&&e<=1?a=e*this.scrollSpeed*-1:n>=0&&n<=1&&(a=n*this.scrollSpeed),i>=0&&i<=1?l=i*this.scrollSpeed*-1:r>=0&&r<=1&&(l=r*this.scrollSpeed)),this.setScrollVel(a,l)},setScrollVel:function(t,e){this.scrollTopVel=t,this.scrollLeftVel=e,this.constrainScrollVel(),!this.scrollTopVel&&!this.scrollLeftVel||this.scrollIntervalId||(this.scrollIntervalId=setInterval(lt(this,"scrollIntervalFunc"),this.scrollIntervalMs))},constrainScrollVel:function(){var t=this.scrollEl;this.scrollTopVel<0?t.scrollTop()<=0&&(this.scrollTopVel=0):this.scrollTopVel>0&&t.scrollTop()+t[0].clientHeight>=t[0].scrollHeight&&(this.scrollTopVel=0),this.scrollLeftVel<0?t.scrollLeft()<=0&&(this.scrollLeftVel=0):this.scrollLeftVel>0&&t.scrollLeft()+t[0].clientWidth>=t[0].scrollWidth&&(this.scrollLeftVel=0)},scrollIntervalFunc:function(){var t=this.scrollEl,e=this.scrollIntervalMs/1e3;this.scrollTopVel&&t.scrollTop(t.scrollTop()+this.scrollTopVel*e),this.scrollLeftVel&&t.scrollLeft(t.scrollLeft()+this.scrollLeftVel*e),this.constrainScrollVel(),this.scrollTopVel||this.scrollLeftVel||this.endAutoScroll()},endAutoScroll:function(){this.scrollIntervalId&&(clearInterval(this.scrollIntervalId),this.scrollIntervalId=null,this.handleScrollEnd())},handleDebouncedScroll:function(){this.scrollIntervalId||this.handleScrollEnd()},handleScrollEnd:function(){}});var ve=pe.extend({component:null,origHit:null,hit:null,coordAdjust:null,constructor:function(t,e){pe.call(this,e),this.component=t},handleInteractionStart:function(t){var e,n,i,r=this.subjectEl;this.component.hitsNeeded(),this.computeScrollBounds(),t?(n={left:b(t),top:E(t)},i=n,r&&(e=d(r),i=H(i,e)),this.origHit=this.queryHit(i.left,i.top),r&&this.options.subjectCenter&&(this.origHit&&(e=I(this.origHit,e)||e),i=M(e)),this.coordAdjust=x(i,n)):(this.origHit=null,this.coordAdjust=null),pe.prototype.handleInteractionStart.apply(this,arguments)},handleDragStart:function(t){var e;pe.prototype.handleDragStart.apply(this,arguments),(e=this.queryHit(b(t),E(t)))&&this.handleHitOver(e)},handleDrag:function(t,e,n){var i;pe.prototype.handleDrag.apply(this,arguments),i=this.queryHit(b(n),E(n)),vt(i,this.hit)||(this.hit&&this.handleHitOut(),i&&this.handleHitOver(i))},handleDragEnd:function(){this.handleHitDone(),pe.prototype.handleDragEnd.apply(this,arguments)},handleHitOver:function(t){var e=vt(t,this.origHit);this.hit=t,this.trigger("hitOver",this.hit,e,this.origHit)},handleHitOut:function(){this.hit&&(this.trigger("hitOut",this.hit),this.handleHitDone(),this.hit=null)},handleHitDone:function(){this.hit&&this.trigger("hitDone",this.hit)},handleInteractionEnd:function(){pe.prototype.handleInteractionEnd.apply(this,arguments),this.origHit=null,this.hit=null,this.component.hitsNotNeeded()},handleScrollEnd:function(){pe.prototype.handleScrollEnd.apply(this,arguments),this.isDragging&&(this.component.releaseHits(),this.component.prepareHits())},queryHit:function(t,e){return this.coordAdjust&&(t+=this.coordAdjust.left,e+=this.coordAdjust.top),this.component.queryHit(t,e)}});Wt.touchMouseIgnoreWait=500;var me=dt.extend(se,re,{isTouching:!1,mouseIgnoreDepth:0,handleScrollProxy:null,bind:function(){var e=this;this.listenTo(t(document),{touchstart:this.handleTouchStart,touchcancel:this.handleTouchCancel,touchend:this.handleTouchEnd,mousedown:this.handleMouseDown,mousemove:this.handleMouseMove,mouseup:this.handleMouseUp,click:this.handleClick,selectstart:this.handleSelectStart,contextmenu:this.handleContextMenu}),window.addEventListener("touchmove",this.handleTouchMoveProxy=function(n){e.handleTouchMove(t.Event(n))},{passive:!1}),window.addEventListener("scroll",this.handleScrollProxy=function(n){e.handleScroll(t.Event(n))},!0)},unbind:function(){this.stopListeningTo(t(document)),window.removeEventListener("touchmove",this.handleTouchMoveProxy),window.removeEventListener("scroll",this.handleScrollProxy,!0)},handleTouchStart:function(t){this.stopTouch(t,!0),this.isTouching=!0,this.trigger("touchstart",t)},handleTouchMove:function(t){this.isTouching&&this.trigger("touchmove",t)},handleTouchCancel:function(t){this.isTouching&&(this.trigger("touchcancel",t),this.stopTouch(t))},handleTouchEnd:function(t){this.stopTouch(t)},handleMouseDown:function(t){this.shouldIgnoreMouse()||this.trigger("mousedown",t)},handleMouseMove:function(t){this.shouldIgnoreMouse()||this.trigger("mousemove",t)},handleMouseUp:function(t){this.shouldIgnoreMouse()||this.trigger("mouseup",t)},handleClick:function(t){this.shouldIgnoreMouse()||this.trigger("click",t)},handleSelectStart:function(t){this.trigger("selectstart",t)},handleContextMenu:function(t){this.trigger("contextmenu",t)},handleScroll:function(t){this.trigger("scroll",t)},stopTouch:function(t,e){this.isTouching&&(this.isTouching=!1,this.trigger("touchend",t),e||this.startTouchMouseIgnore())},startTouchMouseIgnore:function(){var t=this,e=Wt.touchMouseIgnoreWait;e&&(this.mouseIgnoreDepth++,setTimeout(function(){t.mouseIgnoreDepth--},e))},shouldIgnoreMouse:function(){return this.isTouching||Boolean(this.mouseIgnoreDepth)}});!function(){var t=null,e=0;me.get=function(){return t||(t=new me,t.bind()),t},me.needed=function(){me.get(),e++},me.unneeded=function(){--e||(t.unbind(),t=null)}}();var ye=dt.extend(se,{options:null,sourceEl:null,el:null,parentEl:null,top0:null,left0:null,y0:null,x0:null,topDelta:null,leftDelta:null,isFollowing:!1,isHidden:!1,isAnimating:!1,constructor:function(e,n){this.options=n=n||{},this.sourceEl=e,this.parentEl=n.parentEl?t(n.parentEl):e.parent()},start:function(e){this.isFollowing||(this.isFollowing=!0,this.y0=E(e),this.x0=b(e),this.topDelta=0,this.leftDelta=0,this.isHidden||this.updatePosition(),S(e)?this.listenTo(t(document),"touchmove",this.handleMove):this.listenTo(t(document),"mousemove",this.handleMove))},stop:function(e,n){function i(){r.isAnimating=!1,r.removeElement(),r.top0=r.left0=null,n&&n()}var r=this,s=this.options.revertDuration;this.isFollowing&&!this.isAnimating&&(this.isFollowing=!1,this.stopListeningTo(t(document)),e&&s&&!this.isHidden?(this.isAnimating=!0,this.el.animate({top:this.top0,left:this.left0},{duration:s,complete:i})):i())},getEl:function(){var t=this.el;return t||(t=this.el=this.sourceEl.clone().addClass(this.options.additionalClass||"").css({position:"absolute",visibility:"",display:this.isHidden?"none":"",margin:0,right:"auto",bottom:"auto",width:this.sourceEl.width(),height:this.sourceEl.height(),opacity:this.options.opacity||"",zIndex:this.options.zIndex}),t.addClass("fc-unselectable"),t.appendTo(this.parentEl)),t},removeElement:function(){this.el&&(this.el.remove(),this.el=null)},updatePosition:function(){var t,e;this.getEl(),null===this.top0&&(t=this.sourceEl.offset(),e=this.el.offsetParent().offset(),this.top0=t.top-e.top,this.left0=t.left-e.left),this.el.css({top:this.top0+this.topDelta,left:this.left0+this.leftDelta})},handleMove:function(t){this.topDelta=E(t)-this.y0,this.leftDelta=b(t)-this.x0,this.isHidden||this.updatePosition()},hide:function(){this.isHidden||(this.isHidden=!0,this.el&&this.el.hide())},show:function(){this.isHidden&&(this.isHidden=!1,this.updatePosition(),this.getEl().show())}}),we=Wt.Scroller=dt.extend({el:null,scrollEl:null,overflowX:null,overflowY:null,constructor:function(t){t=t||{},this.overflowX=t.overflowX||t.overflow||"auto",this.overflowY=t.overflowY||t.overflow||"auto"},render:function(){this.el=this.renderEl(),this.applyOverflow()},renderEl:function(){return this.scrollEl=t('
')},clear:function(){this.setHeight("auto"),this.applyOverflow()},destroy:function(){this.el.remove()},applyOverflow:function(){this.scrollEl.css({"overflow-x":this.overflowX,"overflow-y":this.overflowY})},lockOverflow:function(t){var e=this.overflowX,n=this.overflowY;t=t||this.getScrollbarWidths(),"auto"===e&&(e=t.top||t.bottom||this.scrollEl[0].scrollWidth-1>this.scrollEl[0].clientWidth?"scroll":"hidden"),"auto"===n&&(n=t.left||t.right||this.scrollEl[0].scrollHeight-1>this.scrollEl[0].clientHeight?"scroll":"hidden"),this.scrollEl.css({"overflow-x":e,"overflow-y":n})},setHeight:function(t){this.scrollEl.height(t)},getScrollTop:function(){return this.scrollEl.scrollTop()},setScrollTop:function(t){this.scrollEl.scrollTop(t)},getClientWidth:function(){return this.scrollEl[0].clientWidth},getClientHeight:function(){return this.scrollEl[0].clientHeight},getScrollbarWidths:function(){return p(this.scrollEl)}});yt.prototype.proxyCall=function(t){var e=Array.prototype.slice.call(arguments,1),n=[];return this.items.forEach(function(i){n.push(i[t].apply(i,e))}),n};var De=dt.extend({view:null,component:null,constructor:function(t){this.view=t._getView(),this.component=t},opt:function(t){return this.view.opt(t)},end:function(){}}),be=De.extend({dragListener:null,constructor:function(t){De.call(this,t),this.dragListener=this.buildDragListener()},end:function(){this.dragListener.endInteraction()},bindToEl:function(t){var e=this.component,n=this.dragListener;e.bindDateHandlerToEl(t,"mousedown",function(t){e.shouldIgnoreMouse()||n.startInteraction(t)}),e.bindDateHandlerToEl(t,"touchstart",function(t){e.shouldIgnoreTouch()||n.startInteraction(t)})},buildDragListener:function(){var t,e=this,n=this.component,i=new ve(n,{scroll:this.opt("dragScroll"),interactionStart:function(){t=i.origHit},hitOver:function(e,n,i){n||(t=null)},hitOut:function(){t=null},interactionEnd:function(i,r){var s;!r&&t&&(s=n.getSafeHitFootprint(t))&&e.view.triggerDayClick(s,n.getHitEl(t),i)}});return i.shouldCancelTouchScroll=!1,i.scrollAlwaysKills=!0,i}}),Ee=Wt.DateSelecting=De.extend({dragListener:null,constructor:function(t){De.call(this,t),this.dragListener=this.buildDragListener()},end:function(){this.dragListener.endInteraction()},getDelay:function(){var t=this.opt("selectLongPressDelay");return null==t&&(t=this.opt("longPressDelay")),t},bindToEl:function(t){var e=this,n=this.component,i=this.dragListener;n.bindDateHandlerToEl(t,"mousedown",function(t){e.opt("selectable")&&!n.shouldIgnoreMouse()&&i.startInteraction(t,{distance:e.opt("selectMinDistance")})}),n.bindDateHandlerToEl(t,"touchstart",function(t){e.opt("selectable")&&!n.shouldIgnoreTouch()&&i.startInteraction(t,{delay:e.getDelay()})}),C(t)},buildDragListener:function(){var t,e=this,n=this.component;return new ve(n,{scroll:this.opt("dragScroll"),interactionStart:function(){t=null},dragStart:function(t){e.view.unselect(t)},hitOver:function(i,r,o){var a,l;o&&(a=n.getSafeHitFootprint(o),l=n.getSafeHitFootprint(i),t=a&&l?e.computeSelection(a,l):null,t?n.renderSelectionFootprint(t):!1===t&&s())},hitOut:function(){t=null,n.unrenderSelection()},hitDone:function(){o()},interactionEnd:function(n,i){!i&&t&&e.view.reportSelection(t,n)}})},computeSelection:function(t,e){var n=this.computeSelectionFootprint(t,e);return!(n&&!this.isSelectionFootprintAllowed(n))&&n},computeSelectionFootprint:function(t,e){var n=[t.unzonedRange.startMs,t.unzonedRange.endMs,e.unzonedRange.startMs,e.unzonedRange.endMs];return n.sort(ot),new We(new Ue(n[0],n[3]),t.isAllDay)},isSelectionFootprintAllowed:function(t){return this.component.dateProfile.validUnzonedRange.containsRange(t.unzonedRange)&&this.view.calendar.isSelectionFootprintAllowed(t)}}),Se=Wt.EventDragging=De.extend({eventPointing:null,dragListener:null,isDragging:!1,constructor:function(t,e){De.call(this,t),this.eventPointing=e},end:function(){this.dragListener&&this.dragListener.endInteraction()},getSelectionDelay:function(){var t=this.opt("eventLongPressDelay");return null==t&&(t=this.opt("longPressDelay")),t},bindToEl:function(t){var e=this.component;e.bindSegHandlerToEl(t,"mousedown",this.handleMousedown.bind(this)),e.bindSegHandlerToEl(t,"touchstart",this.handleTouchStart.bind(this))},handleMousedown:function(t,e){this.component.canStartDrag(t,e)&&this.buildDragListener(t).startInteraction(e,{distance:5})},handleTouchStart:function(t,e){var n=this.component,i={delay:this.view.isEventDefSelected(t.footprint.eventDef)?0:this.getSelectionDelay()};n.canStartDrag(t,e)?this.buildDragListener(t).startInteraction(e,i):n.canStartSelection(t,e)&&this.buildSelectListener(t).startInteraction(e,i)},buildSelectListener:function(t){var e=this,n=this.view,i=t.footprint.eventDef,r=t.footprint.eventInstance;if(this.dragListener)return this.dragListener;var s=this.dragListener=new pe({dragStart:function(t){s.isTouch&&!n.isEventDefSelected(i)&&r&&n.selectEventInstance(r)},interactionEnd:function(t){e.dragListener=null}});return s},buildDragListener:function(t){var e,n,i,r=this,a=this.component,l=this.view,u=l.calendar,c=u.eventManager,h=t.el,d=t.footprint.eventDef,f=t.footprint.eventInstance;if(this.dragListener)return this.dragListener;var g=this.dragListener=new ve(l,{scroll:this.opt("dragScroll"),subjectEl:h,subjectCenter:!0,interactionStart:function(i){t.component=a,e=!1,n=new ye(t.el,{additionalClass:"fc-dragging",parentEl:l.el,opacity:g.isTouch?null:r.opt("dragOpacity"),revertDuration:r.opt("dragRevertDuration"),zIndex:2}),n.hide(),n.start(i)},dragStart:function(n){g.isTouch&&!l.isEventDefSelected(d)&&f&&l.selectEventInstance(f),e=!0,r.eventPointing.handleMouseout(t,n),r.segDragStart(t,n),l.hideEventsWithId(t.footprint.eventDef.id)},hitOver:function(e,o,h){var f,p,v,m=!0;t.hit&&(h=t.hit),f=h.component.getSafeHitFootprint(h),p=e.component.getSafeHitFootprint(e),f&&p?(i=r.computeEventDropMutation(f,p,d),i?(v=c.buildMutatedEventInstanceGroup(d.id,i),m=a.isEventInstanceGroupAllowed(v)):m=!1):m=!1,m||(i=null,s()),i&&l.renderDrag(a.eventRangesToEventFootprints(v.sliceRenderRanges(a.dateProfile.renderUnzonedRange,u)),t,g.isTouch)?n.hide():n.show(),o&&(i=null)},hitOut:function(){l.unrenderDrag(t),n.show(),i=null},hitDone:function(){o()},interactionEnd:function(s){delete t.component,n.stop(!i,function(){e&&(l.unrenderDrag(t),r.segDragStop(t,s)),l.showEventsWithId(t.footprint.eventDef.id),i&&l.reportEventDrop(f,i,h,s)}),r.dragListener=null}});return g},segDragStart:function(t,e){this.isDragging=!0,this.component.publiclyTrigger("eventDragStart",{context:t.el[0],args:[t.footprint.getEventLegacy(),e,{},this.view]})},segDragStop:function(t,e){this.isDragging=!1,this.component.publiclyTrigger("eventDragStop",{context:t.el[0],args:[t.footprint.getEventLegacy(),e,{},this.view]})},computeEventDropMutation:function(t,e,n){var i=new rn;return i.setDateMutation(this.computeEventDateMutation(t,e)),i},computeEventDateMutation:function(t,e){var n,i,r=t.unzonedRange.getStart(),s=e.unzonedRange.getStart(),o=!1,a=!1,l=!1;return t.isAllDay!==e.isAllDay&&(o=!0,e.isAllDay?(l=!0,r.stripTime()):a=!0),n=this.component.diffDates(s,r),i=new sn,i.clearEnd=o,i.forceTimed=a,i.forceAllDay=l,i.setDateDelta(n),i}}),Ce=Wt.EventResizing=De.extend({eventPointing:null,dragListener:null,isResizing:!1,constructor:function(t,e){De.call(this,t),this.eventPointing=e},end:function(){this.dragListener&&this.dragListener.endInteraction()},bindToEl:function(t){var e=this.component;e.bindSegHandlerToEl(t,"mousedown",this.handleMouseDown.bind(this)),e.bindSegHandlerToEl(t,"touchstart",this.handleTouchStart.bind(this))},handleMouseDown:function(e,n){this.component.canStartResize(e,n)&&this.buildDragListener(e,t(n.target).is(".fc-start-resizer")).startInteraction(n,{distance:5})},handleTouchStart:function(e,n){this.component.canStartResize(e,n)&&this.buildDragListener(e,t(n.target).is(".fc-start-resizer")).startInteraction(n)},buildDragListener:function(t,e){var n,i,r=this,a=this.component,l=this.view,u=l.calendar,c=u.eventManager,h=t.el,d=t.footprint.eventDef,f=t.footprint.eventInstance;return this.dragListener=new ve(a,{scroll:this.opt("dragScroll"),subjectEl:h,interactionStart:function(){n=!1},dragStart:function(e){n=!0,r.eventPointing.handleMouseout(t,e),r.segResizeStart(t,e)},hitOver:function(n,o,h){var f,g=!0,p=a.getSafeHitFootprint(h),v=a.getSafeHitFootprint(n);p&&v?(i=e?r.computeEventStartResizeMutation(p,v,t.footprint):r.computeEventEndResizeMutation(p,v,t.footprint),i?(f=c.buildMutatedEventInstanceGroup(d.id,i),g=a.isEventInstanceGroupAllowed(f)):g=!1):g=!1,g?i.isEmpty()&&(i=null):(i=null,s()),i&&(l.hideEventsWithId(t.footprint.eventDef.id),l.renderEventResize(a.eventRangesToEventFootprints(f.sliceRenderRanges(a.dateProfile.renderUnzonedRange,u)),t))},hitOut:function(){i=null},hitDone:function(){l.unrenderEventResize(t),l.showEventsWithId(t.footprint.eventDef.id),o()},interactionEnd:function(e){n&&r.segResizeStop(t,e),i&&l.reportEventResize(f,i,h,e),r.dragListener=null}})},segResizeStart:function(t,e){this.isResizing=!0,this.component.publiclyTrigger("eventResizeStart",{context:t.el[0],args:[t.footprint.getEventLegacy(),e,{},this.view]})},segResizeStop:function(t,e){this.isResizing=!1,this.component.publiclyTrigger("eventResizeStop",{context:t.el[0],args:[t.footprint.getEventLegacy(),e,{},this.view]})},computeEventStartResizeMutation:function(t,e,n){var i,r,s=n.componentFootprint.unzonedRange,o=this.component.diffDates(e.unzonedRange.getStart(),t.unzonedRange.getStart());return s.getStart().add(o)s.getStart()&&(i=new sn,i.setEndDelta(o),r=new rn,r.setDateMutation(i),r)}}),Re=Wt.ExternalDropping=De.extend(se,{dragListener:null,isDragging:!1,end:function(){this.dragListener&&this.dragListener.endInteraction()},bindToDocument:function(){this.listenTo(t(document),{dragstart:this.handleDragStart,sortstart:this.handleDragStart})},unbindFromDocument:function(){this.stopListeningTo(t(document))},handleDragStart:function(e,n){var i,r;this.opt("droppable")&&(i=t((n?n.item:null)||e.target),r=this.opt("dropAccept"),(t.isFunction(r)?r.call(i[0],i):i.is(r))&&(this.isDragging||this.listenToExternalDrag(i,e,n)))},listenToExternalDrag:function(t,e,n){var i,r=this,a=this.component,l=this.view,u=wt(t);(r.dragListener=new ve(a,{interactionStart:function(){r.isDragging=!0},hitOver:function(t){var e,n=!0,o=t.component.getSafeHitFootprint(t);o?(i=r.computeExternalDrop(o,u),i?(e=new Je(i.buildInstances()),n=u.eventProps?a.isEventInstanceGroupAllowed(e):a.isExternalInstanceGroupAllowed(e)):n=!1):n=!1,n||(i=null,s()),i&&a.renderDrag(a.eventRangesToEventFootprints(e.sliceRenderRanges(a.dateProfile.renderUnzonedRange,l.calendar)))},hitOut:function(){i=null},hitDone:function(){o(),a.unrenderDrag()},interactionEnd:function(e){i&&l.reportExternalDrop(i,Boolean(u.eventProps),Boolean(u.stick),t,e,n),r.isDragging=!1,r.dragListener=null}})).startDrag(e)},computeExternalDrop:function(e,n){var i,r=this.view.calendar,s=Wt.moment.utc(e.unzonedRange.startMs).stripZone();return e.isAllDay&&(n.startTime?s.time(n.startTime):s.stripTime()),n.duration&&(i=s.clone().add(n.duration)),s=r.applyTimezone(s),i&&(i=r.applyTimezone(i)),$e.parse(t.extend({},n.eventProps,{start:s,end:i}),new on(r))}});Wt.dataAttrPrefix="";var Te=Wt.EventPointing=De.extend({mousedOverSeg:null,bindToEl:function(t){var e=this.component;e.bindSegHandlerToEl(t,"click",this.handleClick.bind(this)),e.bindSegHandlerToEl(t,"mouseenter",this.handleMouseover.bind(this)),e.bindSegHandlerToEl(t,"mouseleave",this.handleMouseout.bind(this))},handleClick:function(t,e){!1===this.component.publiclyTrigger("eventClick",{context:t.el[0],args:[t.footprint.getEventLegacy(),e,this.view]})&&e.preventDefault()},handleMouseover:function(t,e){me.get().shouldIgnoreMouse()||this.mousedOverSeg||(this.mousedOverSeg=t,this.view.isEventDefResizable(t.footprint.eventDef)&&t.el.addClass("fc-allow-mouse-resize"),this.component.publiclyTrigger("eventMouseover",{context:t.el[0],args:[t.footprint.getEventLegacy(),e,this.view]}))},handleMouseout:function(t,e){this.mousedOverSeg&&(this.mousedOverSeg=null,this.view.isEventDefResizable(t.footprint.eventDef)&&t.el.removeClass("fc-allow-mouse-resize"),this.component.publiclyTrigger("eventMouseout",{context:t.el[0],args:[t.footprint.getEventLegacy(),e||{},this.view]}))},end:function(){this.mousedOverSeg&&this.handleMouseout(this.mousedOverSeg)}}),Ie=Wt.StandardInteractionsMixin={dateClickingClass:be,dateSelectingClass:Ee,eventPointingClass:Te,eventDraggingClass:Se,eventResizingClass:Ce,externalDroppingClass:Re},He=Wt.EventRenderer=dt.extend({view:null,component:null,fillRenderer:null,fgSegs:null,bgSegs:null,eventTimeFormat:null,displayEventTime:null,displayEventEnd:null,constructor:function(t,e){this.view=t._getView(),this.component=t,this.fillRenderer=e},opt:function(t){return this.view.opt(t)},rangeUpdated:function(){var t,e;this.eventTimeFormat=this.opt("eventTimeFormat")||this.opt("timeFormat")||this.computeEventTimeFormat(),t=this.opt("displayEventTime"),null==t&&(t=this.computeDisplayEventTime()),e=this.opt("displayEventEnd"),null==e&&(e=this.computeDisplayEventEnd()),this.displayEventTime=t,this.displayEventEnd=e},render:function(t){var e,n,i,r=this.component._getDateProfile(),s=[],o=[];for(e in t)n=t[e],i=n.sliceRenderRanges(r.activeUnzonedRange),n.getEventDef().hasBgRendering()?s.push.apply(s,i):o.push.apply(o,i);this.renderBgRanges(s),this.renderFgRanges(o)},unrender:function(){this.unrenderBgRanges(),this.unrenderFgRanges()},renderFgRanges:function(t){var e=this.component.eventRangesToEventFootprints(t),n=this.component.eventFootprintsToSegs(e);n=this.renderFgSegEls(n),!1!==this.renderFgSegs(n)&&(this.fgSegs=n)},unrenderFgRanges:function(){this.unrenderFgSegs(this.fgSegs||[]),this.fgSegs=null},renderBgRanges:function(t){var e=this.component.eventRangesToEventFootprints(t),n=this.component.eventFootprintsToSegs(e);!1!==this.renderBgSegs(n)&&(this.bgSegs=n)},unrenderBgRanges:function(){this.unrenderBgSegs(),this.bgSegs=null},getSegs:function(){return(this.bgSegs||[]).concat(this.fgSegs||[])},renderFgSegs:function(t){return!1},unrenderFgSegs:function(t){},renderBgSegs:function(t){var e=this;if(!this.fillRenderer)return!1;this.fillRenderer.renderSegs("bgEvent",t,{getClasses:function(t){return e.getBgClasses(t.footprint.eventDef)},getCss:function(t){return{"background-color":e.getBgColor(t.footprint.eventDef)}},filterEl:function(t,n){return e.filterEventRenderEl(t.footprint,n)}})},unrenderBgSegs:function(){this.fillRenderer&&this.fillRenderer.unrender("bgEvent")},renderFgSegEls:function(e,n){var i,r=this,s=this.view.hasPublicHandlers("eventRender"),o="",a=[];if(e.length){for(i=0;i"},attachSegEls:function(t,e){},reportEls:function(e,n){this.elsByFill[e]?this.elsByFill[e]=this.elsByFill[e].add(n):this.elsByFill[e]=t(n)}}),Pe=Wt.HelperRenderer=dt.extend({view:null,component:null,eventRenderer:null,helperEls:null,constructor:function(t,e){this.view=t._getView(),this.component=t,this.eventRenderer=e},renderComponentFootprint:function(t){this.renderEventFootprints([this.fabricateEventFootprint(t)])},renderEventDraggingFootprints:function(t,e,n){this.renderEventFootprints(t,e,"fc-dragging",n?null:this.view.opt("dragOpacity"))},renderEventResizingFootprints:function(t,e,n){this.renderEventFootprints(t,e,"fc-resizing")},renderEventFootprints:function(t,e,n,i){var r,s=this.component.eventFootprintsToSegs(t),o="fc-helper "+(n||"");for(s=this.eventRenderer.renderFgSegEls(s),r=0;r'+i+"
":""+i+""},getAllDayHtml:function(){return this.opt("allDayHtml")||et(this.opt("allDayText"))},getDayClasses:function(t,e){var n,i=this._getView(),r=[];return this.dateProfile.activeUnzonedRange.containsDate(t)?(r.push("fc-"+jt[t.day()]),i.isDateInOtherMonth(t,this.dateProfile)&&r.push("fc-other-month"),n=i.calendar.getNow(),t.isSame(n,"day")?(r.push("fc-today"),!0!==e&&r.push(i.calendar.theme.getClass("today"))):t=this.nextDayThreshold&&s.add(1,"days"),s<=n&&(s=n.clone().add(1,"days")),{start:n,end:s}},isMultiDayRange:function(t){var e=this.computeDayRange(t);return e.end.diff(e.start,"days")>1}});var ke=Wt.InteractiveDateComponent=Fe.extend({dateClickingClass:null,dateSelectingClass:null,eventPointingClass:null,eventDraggingClass:null,eventResizingClass:null,externalDroppingClass:null,dateClicking:null,dateSelecting:null,eventPointing:null,eventDragging:null,eventResizing:null,externalDropping:null,segSelector:".fc-event-container > *",largeUnit:null,constructor:function(){Fe.call(this),this.dateSelectingClass&&(this.dateClicking=new this.dateClickingClass(this)),this.dateSelectingClass&&(this.dateSelecting=new this.dateSelectingClass(this)),this.eventPointingClass&&(this.eventPointing=new this.eventPointingClass(this)),this.eventDraggingClass&&this.eventPointing&&(this.eventDragging=new this.eventDraggingClass(this,this.eventPointing)),this.eventResizingClass&&this.eventPointing&&(this.eventResizing=new this.eventResizingClass(this,this.eventPointing)),this.externalDroppingClass&&(this.externalDropping=new this.externalDroppingClass(this))},setElement:function(t){Fe.prototype.setElement.apply(this,arguments),this.dateClicking&&this.dateClicking.bindToEl(t),this.dateSelecting&&this.dateSelecting.bindToEl(t),this.bindAllSegHandlersToEl(t)},unrender:function(){this.endInteractions(),Fe.prototype.unrender.apply(this,arguments)},executeEventUnrender:function(){this.endInteractions(),Fe.prototype.executeEventUnrender.apply(this,arguments)},bindGlobalHandlers:function(){Fe.prototype.bindGlobalHandlers.apply(this,arguments),this.externalDropping&&this.externalDropping.bindToDocument()},unbindGlobalHandlers:function(){Fe.prototype.unbindGlobalHandlers.apply(this,arguments),this.externalDropping&&this.externalDropping.unbindFromDocument()},bindDateHandlerToEl:function(e,n,i){var r=this;this.el.on(n,function(e){if(!t(e.target).is(r.segSelector+","+r.segSelector+" *,.fc-more,a[data-goto]"))return i.call(r,e)})},bindAllSegHandlersToEl:function(t){[this.eventPointing,this.eventDragging,this.eventResizing].forEach(function(e){e&&e.bindToEl(t)})},bindSegHandlerToEl:function(e,n,i){var r=this;e.on(n,this.segSelector,function(e){var n=t(this).data("fc-seg");if(n&&!r.shouldIgnoreEventPointing())return i.call(r,n,e)})},shouldIgnoreMouse:function(){return me.get().shouldIgnoreMouse()},shouldIgnoreTouch:function(){var t=this._getView();return t.isSelected||t.selectedEvent},shouldIgnoreEventPointing:function(){return this.eventDragging&&this.eventDragging.isDragging||this.eventResizing&&this.eventResizing.isResizing},canStartSelection:function(t,e){return S(e)&&!this.canStartResize(t,e)&&(this.isEventDefDraggable(t.footprint.eventDef)||this.isEventDefResizable(t.footprint.eventDef))},canStartDrag:function(t,e){return!this.canStartResize(t,e)&&this.isEventDefDraggable(t.footprint.eventDef)},canStartResize:function(e,n){var i=this._getView(),r=e.footprint.eventDef;return(!S(n)||i.isEventDefSelected(r))&&this.isEventDefResizable(r)&&t(n.target).is(".fc-resizer")},endInteractions:function(){[this.dateClicking,this.dateSelecting,this.eventPointing,this.eventDragging,this.eventResizing].forEach(function(t){t&&t.end()})},isEventDefDraggable:function(t){return this.isEventDefStartEditable(t)},isEventDefStartEditable:function(t){var e=t.isStartExplicitlyEditable();return null==e&&null==(e=this.opt("eventStartEditable"))&&(e=this.isEventDefGenerallyEditable(t)),e},isEventDefGenerallyEditable:function(t){var e=t.isExplicitlyEditable();return null==e&&(e=this.opt("editable")),e},isEventDefResizableFromStart:function(t){return this.opt("eventResizableFromStart")&&this.isEventDefResizable(t)},isEventDefResizableFromEnd:function(t){return this.isEventDefResizable(t)},isEventDefResizable:function(t){var e=t.isDurationExplicitlyEditable();return null==e&&null==(e=this.opt("eventDurationEditable"))&&(e=this.isEventDefGenerallyEditable(t)),e},diffDates:function(t,e){return this.largeUnit?L(t,e,this.largeUnit):B(t,e)},isEventInstanceGroupAllowed:function(t){var e,n=this._getView(),i=this.dateProfile,r=this.eventRangesToEventFootprints(t.getAllEventRanges());for(e=0;e=e.length?e[e.length-1]+1:e[n]},computeColHeadFormat:function(){return this.rowCnt>1||this.colCnt>10?"ddd":this.colCnt>1?this.opt("dayOfMonthFormat"):"dddd"},sliceRangeByRow:function(t){var e,n,i,r,s,o=this.daysPerRow,a=this.view.computeDayRange(t),l=this.getDateDayIndex(a.start),u=this.getDateDayIndex(a.end.clone().subtract(1,"days")),c=[];for(e=0;e'+this.renderHeadTrHtml()+"
"},renderHeadIntroHtml:function(){return this.renderIntroHtml()},renderHeadTrHtml:function(){return""+(this.isRTL?"":this.renderHeadIntroHtml())+this.renderHeadDateCellsHtml()+(this.isRTL?this.renderHeadIntroHtml():"")+""},renderHeadDateCellsHtml:function(){var t,e,n=[];for(t=0;t1?' colspan="'+e+'"':"")+(n?" "+n:"")+">"+(r?i.buildGotoAnchorHtml({date:t,forceOff:this.rowCnt>1||1===this.colCnt},o):o)+""},renderBgTrHtml:function(t){return""+(this.isRTL?"":this.renderBgIntroHtml(t))+this.renderBgCellsHtml(t)+(this.isRTL?this.renderBgIntroHtml(t):"")+""},renderBgIntroHtml:function(t){return this.renderIntroHtml()},renderBgCellsHtml:function(t){var e,n,i=[];for(e=0;e"},renderIntroHtml:function(){},bookendCells:function(t){var e=this.renderIntroHtml();e&&(this.isRTL?t.append(e):t.prepend(e))}},Ae=Wt.View=ke.extend({type:null,name:null,title:null,calendar:null,viewSpec:null,options:null,renderQueue:null,batchRenderDepth:0,queuedScroll:null,isSelected:!1,selectedEventInstance:null,eventOrderSpecs:null,isHiddenDayHash:null,isNowIndicatorRendered:null,initialNowDate:null,initialNowQueriedMs:null,nowIndicatorTimeoutID:null,nowIndicatorIntervalID:null,constructor:function(t,e){this.calendar=t,this.viewSpec=e,this.type=e.type,this.options=e.options,this.name=this.type,ke.call(this),this.initRenderQueue(),this.initHiddenDays(),this.bindBaseRenderHandlers(),this.eventOrderSpecs=P(this.opt("eventOrder")),this.initialize&&this.initialize()},_getView:function(){return this},opt:function(t){return this.options[t]},initRenderQueue:function(){this.renderQueue=new de({event:this.opt("eventRenderWait")}),this.renderQueue.on("start",this.onRenderQueueStart.bind(this)),this.renderQueue.on("stop",this.onRenderQueueStop.bind(this)),this.on("before:change",this.startBatchRender),this.on("change",this.stopBatchRender)},onRenderQueueStart:function(){this.calendar.freezeContentHeight(),this.addScroll(this.queryScroll())},onRenderQueueStop:function(){this.calendar.updateViewSize()&&this.popScroll(),this.calendar.thawContentHeight()},startBatchRender:function(){this.batchRenderDepth++||this.renderQueue.pause()},stopBatchRender:function(){--this.batchRenderDepth||this.renderQueue.resume()},requestRender:function(t,e,n){this.renderQueue.queue(t,e,n)},whenSizeUpdated:function(t){this.renderQueue.isRunning?this.renderQueue.one("stop",t.bind(this)):t.call(this)},computeTitle:function(t){var e;return e=/^(year|month)$/.test(t.currentRangeUnit)?t.currentUnzonedRange:t.activeUnzonedRange,this.formatRange({start:this.calendar.msToMoment(e.startMs,t.isRangeAllDay),end:this.calendar.msToMoment(e.endMs,t.isRangeAllDay)},t.isRangeAllDay,this.opt("titleFormat")||this.computeTitleFormat(t),this.opt("titleRangeSeparator"))},computeTitleFormat:function(t){var e=t.currentRangeUnit;return"year"==e?"YYYY":"month"==e?this.opt("monthYearFormat"):t.currentUnzonedRange.as("days")>1?"ll":"LL"},setDate:function(t){var e=this.get("dateProfile"),n=this.buildDateProfile(t,null,!0);e&&e.activeUnzonedRange.equals(n.activeUnzonedRange)||this.set("dateProfile",n)},unsetDate:function(){this.unset("dateProfile")},fetchInitialEvents:function(t){var e=this.calendar,n=t.isRangeAllDay&&!this.usesMinMaxTime;return e.requestEvents(e.msToMoment(t.activeUnzonedRange.startMs,n),e.msToMoment(t.activeUnzonedRange.endMs,n))},bindEventChanges:function(){this.listenTo(this.calendar,"eventsReset",this.resetEvents)},unbindEventChanges:function(){this.stopListeningTo(this.calendar,"eventsReset")},setEvents:function(t){this.set("currentEvents",t),this.set("hasEvents",!0)},unsetEvents:function(){this.unset("currentEvents"),this.unset("hasEvents")},resetEvents:function(t){this.startBatchRender(),this.unsetEvents(),this.setEvents(t),this.stopBatchRender()},requestDateRender:function(t){var e=this;this.requestRender(function(){e.executeDateRender(t)},"date","init")},requestDateUnrender:function(){var t=this;this.requestRender(function(){t.executeDateUnrender()},"date","destroy")},executeDateRender:function(t){Fe.prototype.executeDateRender.apply(this,arguments),this.render&&this.render(),this.trigger("datesRendered"),this.addScroll({isDateInit:!0}),this.startNowIndicator()},executeDateUnrender:function(){this.unselect(),this.stopNowIndicator(),this.trigger("before:datesUnrendered"),this.destroy&&this.destroy(),Fe.prototype.executeDateUnrender.apply(this,arguments)},bindBaseRenderHandlers:function(){var t=this;this.on("datesRendered",function(){t.whenSizeUpdated(t.triggerViewRender)}),this.on("before:datesUnrendered",function(){t.triggerViewDestroy()})},triggerViewRender:function(){this.publiclyTrigger("viewRender",{context:this,args:[this,this.el]})},triggerViewDestroy:function(){this.publiclyTrigger("viewDestroy",{context:this,args:[this,this.el]})},requestEventsRender:function(t){var e=this;this.requestRender(function(){e.executeEventRender(t),e.whenSizeUpdated(e.triggerAfterEventsRendered)},"event","init")},requestEventsUnrender:function(){var t=this;this.requestRender(function(){t.triggerBeforeEventsDestroyed(),t.executeEventUnrender()},"event","destroy")},requestBusinessHoursRender:function(t){var e=this;this.requestRender(function(){e.renderBusinessHours(t)},"businessHours","init")},requestBusinessHoursUnrender:function(){var t=this;this.requestRender(function(){t.unrenderBusinessHours()},"businessHours","destroy")},bindGlobalHandlers:function(){ke.prototype.bindGlobalHandlers.apply(this,arguments),this.listenTo(me.get(),{touchstart:this.processUnselect,mousedown:this.handleDocumentMousedown})},unbindGlobalHandlers:function(){ke.prototype.unbindGlobalHandlers.apply(this,arguments),this.stopListeningTo(me.get())},startNowIndicator:function(){var t,n,i,r=this;this.opt("nowIndicator")&&(t=this.getNowIndicatorUnit())&&(n=lt(this,"updateNowIndicator"),this.initialNowDate=this.calendar.getNow(),this.initialNowQueriedMs=+new Date,i=this.initialNowDate.clone().startOf(t).add(1,t)-this.initialNowDate,this.nowIndicatorTimeoutID=setTimeout(function(){r.nowIndicatorTimeoutID=null,n(),i=+e.duration(1,t),i=Math.max(100,i),r.nowIndicatorIntervalID=setInterval(n,i)},i))},updateNowIndicator:function(){this.isDatesRendered&&this.initialNowDate&&(this.unrenderNowIndicator(),this.renderNowIndicator(this.initialNowDate.clone().add(new Date-this.initialNowQueriedMs)),this.isNowIndicatorRendered=!0)},stopNowIndicator:function(){this.isNowIndicatorRendered&&(this.nowIndicatorTimeoutID&&(clearTimeout(this.nowIndicatorTimeoutID),this.nowIndicatorTimeoutID=null),this.nowIndicatorIntervalID&&(clearTimeout(this.nowIndicatorIntervalID),this.nowIndicatorIntervalID=null),this.unrenderNowIndicator(),this.isNowIndicatorRendered=!1)},updateSize:function(t,e,n){this.setHeight?this.setHeight(t,e):ke.prototype.updateSize.apply(this,arguments),this.updateNowIndicator()},addScroll:function(e){var n=this.queuedScroll||(this.queuedScroll={});t.extend(n,e)},popScroll:function(){this.applyQueuedScroll(),this.queuedScroll=null},applyQueuedScroll:function(){this.queuedScroll&&this.applyScroll(this.queuedScroll)},queryScroll:function(){var e={};return this.isDatesRendered&&t.extend(e,this.queryDateScroll()),e},applyScroll:function(e){e.isDateInit&&this.isDatesRendered&&t.extend(e,this.computeInitialDateScroll()),this.isDatesRendered&&this.applyDateScroll(e)},computeInitialDateScroll:function(){return{}},queryDateScroll:function(){return{}},applyDateScroll:function(t){},reportEventDrop:function(t,n,i,r){var s=this.calendar.eventManager,o=s.mutateEventsWithId(t.def.id,n,this.calendar),a=n.dateMutation;a&&(t.dateProfile=a.buildNewDateProfile(t.dateProfile,this.calendar)),this.triggerEventDrop(t,a&&a.dateDelta||e.duration(),o,i,r)},triggerEventDrop:function(t,e,n,i,r){this.publiclyTrigger("eventDrop",{context:i[0],args:[t.toLegacy(),e,n,r,{},this]})},reportExternalDrop:function(t,e,n,i,r,s){e&&this.calendar.eventManager.addEventDef(t,n),this.triggerExternalDrop(t,e,i,r,s)},triggerExternalDrop:function(t,e,n,i,r){this.publiclyTrigger("drop",{context:n[0],args:[t.dateProfile.start.clone(),i,r,this]}),e&&this.publiclyTrigger("eventReceive",{context:this,args:[t.buildInstance().toLegacy(),this]})},reportEventResize:function(t,e,n,i){var r=this.calendar.eventManager,s=r.mutateEventsWithId(t.def.id,e,this.calendar);t.dateProfile=e.dateMutation.buildNewDateProfile(t.dateProfile,this.calendar),this.triggerEventResize(t,e.dateMutation.endDelta,s,n,i)},triggerEventResize:function(t,e,n,i,r){this.publiclyTrigger("eventResize",{context:i[0],args:[t.toLegacy(),e,n,r,{},this]})},select:function(t,e){this.unselect(e),this.renderSelectionFootprint(t),this.reportSelection(t,e)},renderSelectionFootprint:function(t,e){this.renderSelection?this.renderSelection(t.toLegacy(this.calendar)):ke.prototype.renderSelectionFootprint.apply(this,arguments)},reportSelection:function(t,e){this.isSelected=!0,this.triggerSelect(t,e)},triggerSelect:function(t,e){var n=this.calendar.footprintToDateProfile(t);this.publiclyTrigger("select",{context:this,args:[n.start,n.end,e,this]})},unselect:function(t){this.isSelected&&(this.isSelected=!1,this.destroySelection&&this.destroySelection(),this.unrenderSelection(),this.publiclyTrigger("unselect",{context:this,args:[t,this]}))},selectEventInstance:function(t){this.selectedEventInstance&&this.selectedEventInstance===t||(this.unselectEventInstance(),this.getEventSegs().forEach(function(e){e.footprint.eventInstance===t&&e.el&&e.el.addClass("fc-selected")}),this.selectedEventInstance=t)},unselectEventInstance:function(){this.selectedEventInstance&&(this.getEventSegs().forEach(function(t){t.el&&t.el.removeClass("fc-selected")}),this.selectedEventInstance=null)},isEventDefSelected:function(t){return this.selectedEventInstance&&this.selectedEventInstance.def.id===t.id},handleDocumentMousedown:function(t){D(t)&&this.processUnselect(t)},processUnselect:function(t){this.processRangeUnselect(t),this.processEventUnselect(t)},processRangeUnselect:function(e){var n;this.isSelected&&this.opt("unselectAuto")&&((n=this.opt("unselectCancel"))&&t(e.target).closest(n).length||this.unselect(e))},processEventUnselect:function(e){this.selectedEventInstance&&(t(e.target).closest(".fc-selected").length||this.unselectEventInstance())},triggerBaseRendered:function(){this.publiclyTrigger("viewRender",{context:this,args:[this,this.el]})},triggerBaseUnrendered:function(){this.publiclyTrigger("viewDestroy",{context:this,args:[this,this.el]})},triggerDayClick:function(t,e,n){var i=this.calendar.footprintToDateProfile(t);this.publiclyTrigger("dayClick",{context:e,args:[i.start,n,this]})}});Ae.watch("displayingDates",["isInDom","dateProfile"],function(t){this.requestDateRender(t.dateProfile)},function(){this.requestDateUnrender()}),Ae.watch("displayingBusinessHours",["displayingDates","businessHourGenerator"],function(t){this.requestBusinessHoursRender(t.businessHourGenerator)},function(){this.requestBusinessHoursUnrender()}),Ae.watch("initialEvents",["dateProfile"],function(t){return this.fetchInitialEvents(t.dateProfile)}),Ae.watch("bindingEvents",["initialEvents"],function(t){this.setEvents(t.initialEvents),this.bindEventChanges()},function(){this.unbindEventChanges(),this.unsetEvents()}),Ae.watch("displayingEvents",["displayingDates","hasEvents"],function(){this.requestEventsRender(this.get("currentEvents"))},function(){this.requestEventsUnrender()}),Ae.watch("title",["dateProfile"],function(t){return this.title=this.computeTitle(t.dateProfile)}),Ae.watch("legacyDateProps",["dateProfile"],function(t){var e=this.calendar,n=t.dateProfile;this.start=e.msToMoment(n.activeUnzonedRange.startMs,n.isRangeAllDay),this.end=e.msToMoment(n.activeUnzonedRange.endMs,n.isRangeAllDay),this.intervalStart=e.msToMoment(n.currentUnzonedRange.startMs,n.isRangeAllDay),this.intervalEnd=e.msToMoment(n.currentUnzonedRange.endMs,n.isRangeAllDay)}),Ae.mixin({usesMinMaxTime:!1,start:null,end:null,intervalStart:null,intervalEnd:null,buildPrevDateProfile:function(t){var e=this.get("dateProfile"),n=t.clone().startOf(e.currentRangeUnit).subtract(e.dateIncrement);return this.buildDateProfile(n,-1)},buildNextDateProfile:function(t){var e=this.get("dateProfile"),n=t.clone().startOf(e.currentRangeUnit).add(e.dateIncrement);return this.buildDateProfile(n,1)},buildDateProfile:function(t,n,i){var r,s,o,a,l,u,c=!t.hasTime(),h=null,d=null;return r=this.buildValidRange(),r=this.trimHiddenDays(r),i&&(t=this.calendar.msToUtcMoment(r.constrainDate(t),c)),s=this.buildCurrentRangeInfo(t,n),o=/^(year|month|week|day)$/.test(s.unit),a=this.buildRenderRange(this.trimHiddenDays(s.unzonedRange),s.unit,o),a=this.trimHiddenDays(a),l=a.clone(),this.opt("showNonCurrentDates")||(l=l.intersect(s.unzonedRange)),h=e.duration(this.opt("minTime")),d=e.duration(this.opt("maxTime")),l=this.adjustActiveRange(l,h,d),l=l.intersect(r),l&&(t=this.calendar.msToUtcMoment(l.constrainDate(t),c)),u=s.unzonedRange.intersectsWith(r),{validUnzonedRange:r,currentUnzonedRange:s.unzonedRange,currentRangeUnit:s.unit,isRangeAllDay:o,activeUnzonedRange:l,renderUnzonedRange:a,minTime:h,maxTime:d,isValid:u,date:t,dateIncrement:this.buildDateIncrement(s.duration)}},buildValidRange:function(){return this.getUnzonedRangeOption("validRange",this.calendar.getNow())||new Ue},buildCurrentRangeInfo:function(t,e){var n,i=null,r=null,s=null;return this.viewSpec.duration?(i=this.viewSpec.duration,r=this.viewSpec.durationUnit,s=this.buildRangeFromDuration(t,e,i,r)):(n=this.opt("dayCount"))?(r="day",s=this.buildRangeFromDayCount(t,e,n)):(s=this.buildCustomVisibleRange(t))?r=O(s.getStart(),s.getEnd()):(i=this.getFallbackDuration(),r=O(i),s=this.buildRangeFromDuration(t,e,i,r)),{duration:i,unit:r,unzonedRange:s}},getFallbackDuration:function(){return e.duration({days:1})},adjustActiveRange:function(t,e,n){var i=t.getStart(),r=t.getEnd();return this.usesMinMaxTime&&(e<0&&i.time(0).add(e),n>864e5&&r.time(n-864e5)),new Ue(i,r)},buildRangeFromDuration:function(t,n,i,r){var s,o,a,l=this.opt("dateAlignment"),u=t.clone();return i.as("days")<=1&&this.isHiddenDay(u)&&(u=this.skipHiddenDays(u,n),u.startOf("day")),l||(o=this.opt("dateIncrement"),o?(a=e.duration(o),l=a").prependTo(n),this.initToolbars(),this.renderHeader(),this.renderFooter(),this.renderView(this.opt("defaultView")),this.opt("handleWindowResize")&&t(window).resize(this.windowResizeProxy=ut(this.windowResize.bind(this),this.opt("windowResizeDelay")))},destroy:function(){this.view&&this.clearView(),this.toolbarsManager.proxyCall("removeElement"),this.contentEl.remove(),this.el.removeClass("fc fc-ltr fc-rtl"),this.optionsModel.unwatch("settingTheme"),this.optionsModel.unwatch("settingBusinessHourGenerator"),this.el.off(".fc"),this.windowResizeProxy&&(t(window).unbind("resize",this.windowResizeProxy),this.windowResizeProxy=null),me.unneeded()},elementVisible:function(){return this.el.is(":visible")},bindViewHandlers:function(t){var e=this;t.watch("titleForCalendar",["title"],function(n){t===e.view&&e.setToolbarsTitle(n.title)}),t.watch("dateProfileForCalendar",["dateProfile"],function(n){t===e.view&&(e.currentDate=n.dateProfile.date,e.updateToolbarButtons(n.dateProfile))})},unbindViewHandlers:function(t){this.stopListeningTo(t),t.unwatch("titleForCalendar"),t.unwatch("dateProfileForCalendar")},renderView:function(e){var n,i=this.view;this.freezeContentHeight(),i&&e&&i.type!==e&&this.clearView(),!this.view&&e&&(n=this.view=this.viewsByType[e]||(this.viewsByType[e]=this.instantiateView(e)),this.bindViewHandlers(n),n.setElement(t("
").appendTo(this.contentEl)),this.toolbarsManager.proxyCall("activateButton",e)),this.view&&(this.view.get("businessHourGenerator")!==this.businessHourGenerator&&this.view.set("businessHourGenerator",this.businessHourGenerator),this.view.setDate(this.currentDate)),this.thawContentHeight()},clearView:function(){var t=this.view;this.toolbarsManager.proxyCall("deactivateButton",t.type),this.unbindViewHandlers(t),t.removeElement(),this.view=null},reinitView:function(){var t=this.view,e=t.queryScroll();this.freezeContentHeight(),this.clearView(),this.calcSize(),this.renderView(t.type),this.view.applyScroll(e),this.thawContentHeight()},getSuggestedViewHeight:function(){return null===this.suggestedViewHeight&&this.calcSize(),this.suggestedViewHeight},isHeightAuto:function(){return"auto"===this.opt("contentHeight")||"auto"===this.opt("height")},updateViewSize:function(t){var e,n=this.view;if(!this.ignoreUpdateViewSize&&n)return t&&(this.calcSize(),e=n.queryScroll()),this.ignoreUpdateViewSize++,n.updateSize(this.getSuggestedViewHeight(),this.isHeightAuto(),t),this.ignoreUpdateViewSize--,t&&n.applyScroll(e),!0},calcSize:function(){this.elementVisible()&&this._calcSize()},_calcSize:function(){var t=this.opt("contentHeight"),e=this.opt("height");this.suggestedViewHeight="number"==typeof t?t:"function"==typeof t?t():"number"==typeof e?e-this.queryToolbarsHeight():"function"==typeof e?e()-this.queryToolbarsHeight():"parent"===e?this.el.parent().height()-this.queryToolbarsHeight():Math.round(this.contentEl.width()/Math.max(this.opt("aspectRatio"),.5))},windowResize:function(t){t.target===window&&this.view&&this.view.isDatesRendered&&this.updateViewSize(!0)&&this.publiclyTrigger("windowResize",[this.view])},freezeContentHeight:function(){this.freezeContentHeightDepth++||this.forceFreezeContentHeight()},forceFreezeContentHeight:function(){this.contentEl.css({width:"100%",height:this.contentEl.height(),overflow:"hidden"})},thawContentHeight:function(){this.freezeContentHeightDepth--,this.contentEl.css({width:"",height:"",overflow:""}),this.freezeContentHeightDepth&&this.forceFreezeContentHeight()}}),Le.mixin({header:null,footer:null,toolbarsManager:null,initToolbars:function(){this.header=new bt(this,this.computeHeaderOptions()),this.footer=new bt(this,this.computeFooterOptions()),this.toolbarsManager=new yt([this.header,this.footer])},computeHeaderOptions:function(){return{extraClasses:"fc-header-toolbar",layout:this.opt("header")}},computeFooterOptions:function(){return{extraClasses:"fc-footer-toolbar",layout:this.opt("footer")}},renderHeader:function(){var t=this.header;t.setToolbarOptions(this.computeHeaderOptions()),t.render(),t.el&&this.el.prepend(t.el)},renderFooter:function(){var t=this.footer;t.setToolbarOptions(this.computeFooterOptions()),t.render(),t.el&&this.el.append(t.el)},setToolbarsTitle:function(t){this.toolbarsManager.proxyCall("updateTitle",t)},updateToolbarButtons:function(t){var e=this.getNow(),n=this.view,i=n.buildDateProfile(e),r=n.buildPrevDateProfile(this.currentDate),s=n.buildNextDateProfile(this.currentDate);this.toolbarsManager.proxyCall(i.isValid&&!t.currentUnzonedRange.containsDate(e)?"enableButton":"disableButton","today"),this.toolbarsManager.proxyCall(r.isValid?"enableButton":"disableButton","prev"),this.toolbarsManager.proxyCall(s.isValid?"enableButton":"disableButton","next")},queryToolbarsHeight:function(){return this.toolbarsManager.items.reduce(function(t,e){return t+(e.el?e.el.outerHeight(!0):0)},0)}}),Le.prototype.isEventInstanceGroupAllowed=function(t){var e,n=t.getEventDef(),i=this.eventRangesToEventFootprints(t.getAllEventRanges()),r=this.getPeerEventInstances(n),s=r.map(Pt),o=this.eventRangesToEventFootprints(s),a=n.getConstraint(),l=n.getOverlap(),u=this.opt("eventAllow");for(e=0;et.startMs)&&(null===this.startMs||null===t.endMs||this.startMs=this.startMs)&&(null===this.endMs||null!==t.endMs&&t.endMs<=this.endMs)},containsDate:function(t){var e=t.valueOf();return(null===this.startMs||e>=this.startMs)&&(null===this.endMs||e=this.endMs&&(e=this.endMs-1),e},equals:function(t){return this.startMs===t.startMs&&this.endMs===t.endMs},clone:function(){var t=new Ue(this.startMs,this.endMs);return t.isStart=this.isStart,t.isEnd=this.isEnd,t},getStart:function(){if(null!==this.startMs)return Wt.moment.utc(this.startMs).stripZone()},getEnd:function(){if(null!==this.endMs)return Wt.moment.utc(this.endMs).stripZone()},as:function(t){return e.utc(this.endMs).diff(e.utc(this.startMs),t,!0)}}),We=Wt.ComponentFootprint=dt.extend({unzonedRange:null,isAllDay:!1,constructor:function(t,e){this.unzonedRange=t,this.isAllDay=e},toLegacy:function(t){return{start:t.msToMoment(this.unzonedRange.startMs,this.isAllDay),end:t.msToMoment(this.unzonedRange.endMs,this.isAllDay)}}}),_e=dt.extend(re,{start:null,end:null,timezone:null,unzonedRange:null,requestsByUid:null,pendingCnt:0,freezeDepth:0,stuntedReleaseCnt:0,releaseCnt:0,eventDefsByUid:null,eventDefsById:null,eventInstanceGroupsById:null,constructor:function(t,e,n){this.start=t,this.end=e,this.timezone=n,this.unzonedRange=new Ue(t.clone().stripZone(),e.clone().stripZone()),this.requestsByUid={},this.eventDefsByUid={},this.eventDefsById={},this.eventInstanceGroupsById={}},isWithinRange:function(t,e){return!t.isBefore(this.start)&&!e.isAfter(this.end)},requestSources:function(t){this.freeze();for(var e=0;e
'),s=r.find("tr"),a>0&&s.append(''),s.append(n.el.attr("colspan",l-a)),l'),this.component.bookendCells(s),r}}),mn=He.extend({dayGrid:null,rowStructs:null,constructor:function(t){He.apply(this,arguments),this.dayGrid=t},renderBgRanges:function(e){e=t.grep(e,function(t){return t.eventDef.isAllDay()}),He.prototype.renderBgRanges.call(this,e)},renderFgSegs:function(e){var n=this.rowStructs=this.renderSegRows(e);this.dayGrid.rowEls.each(function(e,i){t(i).find(".fc-content-skeleton > table").append(n[e].tbodyEl)})},unrenderFgSegs:function(){for(var t,e=this.rowStructs||[];t=e.pop();)t.tbodyEl.remove();this.rowStructs=null},renderSegRows:function(t){var e,n,i=[];for(e=this.groupSegRows(t),n=0;n"),a.append(c)),v[r][o]=c,m[r][o]=c,o++}var r,s,o,a,l,u,c,h=this.dayGrid.colCnt,d=this.buildSegLevels(n),f=Math.max(1,d.length),g=t(""),p=[],v=[],m=[];for(r=0;r"),p.push([]),v.push([]),m.push([]),s)for(l=0;l').append(u.el),u.leftCol!=u.rightCol?c.attr("colspan",u.rightCol-u.leftCol+1):m[r][o]=c;o<=u.rightCol;)v[r][o]=c,p[r][o]=u,o++;a.append(c)}i(h),this.dayGrid.bookendCells(a),g.append(a)}return{row:e,tbodyEl:g,cellMatrix:v,segMatrix:p,segLevels:d,segs:n}},buildSegLevels:function(t){var e,n,i,r=[];for(this.sortEventSegs(t),e=0;e'+et(n)+""),i=''+(et(s.title||"")||" ")+"",'
'+(this.isRTL?i+" "+d:d+" "+i)+"
"+(l?'
':"")+(u?'
':"")+""}}),yn=Pe.extend({renderSegs:function(e,n){var i,r=[];return i=this.eventRenderer.renderSegRows(e),this.component.rowEls.each(function(e,s){var o,a,l=t(s),u=t('
');n&&n.row===e?a=n.el.position().top:(o=l.find(".fc-content-skeleton tbody"),o.length||(o=l.find(".fc-content-skeleton table")),a=o.position().top),u.css("top",a).find("table").append(i[e].tbodyEl),l.append(u),r.push(u[0])}),t(r)}}),wn=Wt.DayGrid=ke.extend(Ie,Be,{eventRendererClass:mn,businessHourRendererClass:Me,helperRendererClass:yn,fillRendererClass:vn,view:null,helperRenderer:null,cellWeekNumbersVisible:!1,bottomCoordPadding:0,headContainerEl:null,rowEls:null,cellEls:null,rowCoordCache:null,colCoordCache:null,isRigid:!1,hasAllDayBusinessHours:!0,constructor:function(t){this.view=t,ke.call(this)},componentFootprintToSegs:function(t){var e,n,i=this.sliceRangeByRow(t.unzonedRange);for(e=0;e
'+this.renderBgTrHtml(t)+'
'+(this.getIsNumbersVisible()?""+this.renderNumberTrHtml(t)+"":"")+"
"},getIsNumbersVisible:function(){return this.getIsDayNumbersVisible()||this.cellWeekNumbersVisible},getIsDayNumbersVisible:function(){return this.rowCnt>1},renderNumberTrHtml:function(t){return""+(this.isRTL?"":this.renderNumberIntroHtml(t))+this.renderNumberCellsHtml(t)+(this.isRTL?this.renderNumberIntroHtml(t):"")+""},renderNumberIntroHtml:function(t){return this.renderIntroHtml()},renderNumberCellsHtml:function(t){var e,n,i=[];for(e=0;e",this.cellWeekNumbersVisible&&t.day()==n&&(r+=i.buildGotoAnchorHtml({date:t,type:"week"},{class:"fc-week-number"},t.format("w"))),o&&(r+=i.buildGotoAnchorHtml(t,{class:"fc-day-number"},t.date())),r+=""):""},prepareHits:function(){this.colCoordCache.build(),this.rowCoordCache.build(),this.rowCoordCache.bottoms[this.rowCnt-1]+=this.bottomCoordPadding},releaseHits:function(){this.colCoordCache.clear(),this.rowCoordCache.clear()},queryHit:function(t,e){if(this.colCoordCache.isLeftInBounds(t)&&this.rowCoordCache.isTopInBounds(e)){var n=this.colCoordCache.getHorizontalIndex(t),i=this.rowCoordCache.getVerticalIndex(e);if(null!=i&&null!=n)return this.getCellHit(i,n)}},getHitFootprint:function(t){var e=this.getCellRange(t.row,t.col);return new We(new Ue(e.start,e.end),!0)},getHitEl:function(t){return this.getCellEl(t.row,t.col)},getCellHit:function(t,e){return{row:t,col:e,component:this,left:this.colCoordCache.getLeftOffset(e),right:this.colCoordCache.getRightOffset(e),top:this.rowCoordCache.getTopOffset(t),bottom:this.rowCoordCache.getBottomOffset(t)}},getCellEl:function(t,e){return this.cellEls.eq(t*this.colCnt+e)},unrenderEvents:function(){this.removeSegPopover(),ke.prototype.unrenderEvents.apply(this,arguments)},getOwnEventSegs:function(){return ke.prototype.getOwnEventSegs.apply(this,arguments).concat(this.popoverSegs||[])},renderDrag:function(t,e,n){var i;for(i=0;i td > :first-child").each(n),r.position().top+s>a)return i;return!1},limitRow:function(e,n){function i(i){for(;E").append(y),d.append(m),b.push(m[0])),E++}var r,s,o,a,l,u,c,h,d,f,g,p,v,m,y,w=this,D=this.eventRenderer.rowStructs[e],b=[],E=0;if(n&&n').attr("rowspan",f),u=h[p],y=this.renderMoreLink(e,l.leftCol+p,[l].concat(u)),m=t("
").append(y),v.append(m),g.push(v[0]),b.push(v[0]);d.addClass("fc-limited").after(t(g)),o.push(d[0])}}i(this.colCnt),D.moreEls=t(b),D.limitedEls=t(o)}},unlimitRow:function(t){var e=this.eventRenderer.rowStructs[t];e.moreEls&&(e.moreEls.remove(),e.moreEls=null),e.limitedEls&&(e.limitedEls.removeClass("fc-limited"),e.limitedEls=null)},renderMoreLink:function(e,n,i){var r=this,s=this.view;return t('').text(this.getMoreLinkText(i.length)).on("click",function(o){var a=r.opt("eventLimitClick"),l=r.getCellDate(e,n),u=t(this),c=r.getCellEl(e,n),h=r.getCellSegs(e,n),d=r.resliceDaySegs(h,l),f=r.resliceDaySegs(i,l);"function"==typeof a&&(a=r.publiclyTrigger("eventLimitClick",{context:s,args:[{date:l.clone(),dayEl:c,moreEl:u,segs:d,hiddenSegs:f},o,s]})),"popover"===a?r.showSegPopover(e,n,u,d):"string"==typeof a&&s.calendar.zoomTo(l,a)})},showSegPopover:function(t,e,n,i){var r,s,o=this,a=this.view,l=n.parent();r=1==this.rowCnt?a.el:this.rowEls.eq(t),s={className:"fc-more-popover "+a.calendar.theme.getClass("popover"),content:this.renderSegPopoverContent(t,e,i),parentEl:a.el,top:r.offset().top,autoHide:!0,viewportConstrain:this.opt("popoverViewportConstrain"),hide:function(){o.popoverSegs&&o.triggerBeforeEventSegsDestroyed(o.popoverSegs),o.segPopover.removeElement(),o.segPopover=null,o.popoverSegs=null}},this.isRTL?s.right=l.offset().left+l.outerWidth()+1:s.left=l.offset().left-1,this.segPopover=new fe(s),this.segPopover.show(),this.bindAllSegHandlersToEl(this.segPopover.el),this.triggerAfterEventSegsRendered(i)},renderSegPopoverContent:function(e,n,i){var r,s=this.view,o=s.calendar.theme,a=this.getCellDate(e,n).format(this.opt("dayPopoverFormat")),l=t('
'+et(a)+'
'),u=l.find(".fc-event-container");for(i=this.eventRenderer.renderFgSegEls(i,!0),this.popoverSegs=i,r=0;r').appendTo(e),this.el.find(".fc-body > tr > td").append(e),this.dayGrid.headContainerEl=this.el.find(".fc-head-container"),this.dayGrid.setElement(n)},unrenderSkeleton:function(){this.dayGrid.removeElement(),this.scroller.destroy()},renderSkeletonHtml:function(){var t=this.calendar.theme;return''+(this.opt("columnHeader")?'':"")+'
 
'},weekNumberStyleAttr:function(){return null!==this.weekNumberWidth?'style="width:'+this.weekNumberWidth+'px"':""},hasRigidRows:function(){var t=this.opt("eventLimit");return t&&"number"!=typeof t},updateSize:function(t,e,n){var s,o,a=this.opt("eventLimit"),l=this.dayGrid.headContainerEl.find(".fc-row");if(!this.dayGrid.rowEls)return void(e||(s=this.computeScrollerHeight(t),this.scroller.setHeight(s)));Ae.prototype.updateSize.apply(this,arguments),this.dayGrid.colWeekNumbersVisible&&(this.weekNumberWidth=u(this.el.find(".fc-week-number"))),this.scroller.clear(),r(l),this.dayGrid.removeSegPopover(),a&&"number"==typeof a&&this.dayGrid.limitRows(a),s=this.computeScrollerHeight(t),this.setGridHeight(s,e),a&&"number"!=typeof a&&this.dayGrid.limitRows(a),e||(this.scroller.setHeight(s),o=this.scroller.getScrollbarWidths(),(o.left||o.right)&&(i(l,o),s=this.computeScrollerHeight(t),this.scroller.setHeight(s)),this.scroller.lockOverflow(o))},computeScrollerHeight:function(t){return t-c(this.el,this.scroller.el)},setGridHeight:function(t,e){e?l(this.dayGrid.rowEls):a(this.dayGrid.rowEls,t,!0)},computeInitialDateScroll:function(){return{top:0}},queryDateScroll:function(){return{top:this.scroller.getScrollTop()}},applyDateScroll:function(t){void 0!==t.top&&this.scroller.setScrollTop(t.top)}}),bn={colWeekNumbersVisible:!1,renderHeadIntroHtml:function(){var t=this.view;return this.colWeekNumbersVisible?'"+et(this.opt("weekNumberTitle"))+"":""},renderNumberIntroHtml:function(t){var e=this.view,n=this.getCellDate(t,0);return this.colWeekNumbersVisible?'"+e.buildGotoAnchorHtml({date:n,type:"week",forceOff:1===this.colCnt},n.format("w"))+"":""},renderBgIntroHtml:function(){var t=this.view;return this.colWeekNumbersVisible?'":""},renderIntroHtml:function(){var t=this.view +;return this.colWeekNumbersVisible?'":""},getIsNumbersVisible:function(){return wn.prototype.getIsNumbersVisible.apply(this,arguments)||this.colWeekNumbersVisible}},En=Wt.MonthView=Dn.extend({buildRenderRange:function(t,e,n){var i,r=Dn.prototype.buildRenderRange.apply(this,arguments),s=this.calendar.msToUtcMoment(r.startMs,n),o=this.calendar.msToUtcMoment(r.endMs,n);return this.isFixedWeeks()&&(i=Math.ceil(o.diff(s,"weeks",!0)),o.add(6-i,"weeks")),new Ue(s,o)},setGridHeight:function(t,e){e&&(t*=this.rowCnt/6),a(this.dayGrid.rowEls,t,!e)},isFixedWeeks:function(){return this.opt("fixedWeekCount")},isDateInOtherMonth:function(t,n){return t.month()!==e.utc(n.currentUnzonedRange.startMs).month()}});_t.basic={class:Dn},_t.basicDay={type:"basic",duration:{days:1}},_t.basicWeek={type:"basic",duration:{weeks:1}},_t.month={class:En,duration:{months:1},defaults:{fixedWeekCount:!0}};var Sn=xe.extend({attachSegEls:function(t,e){var n,i=this.component;return"bgEvent"===t?n=i.bgContainerEls:"businessHours"===t?n=i.businessContainerEls:"highlight"===t&&(n=i.highlightContainerEls),i.updateSegVerticals(e),i.attachSegsByCol(i.groupSegsByCol(e),n),e.map(function(t){return t.el[0]})}}),Cn=He.extend({timeGrid:null,constructor:function(t){He.apply(this,arguments),this.timeGrid=t},renderFgSegs:function(t){this.renderFgSegsIntoContainers(t,this.timeGrid.fgContainerEls)},renderFgSegsIntoContainers:function(t,e){var n,i;for(n=this.timeGrid.groupSegsByCol(t),i=0;i
'+(n?'
'+et(n)+"
":"")+(u.title?'
'+et(u.title)+"
":"")+'
'+(d?'
':"")+""},updateFgSegCoords:function(t){this.timeGrid.computeSegVerticals(t),this.computeFgSegHorizontals(t),this.timeGrid.assignSegVerticals(t),this.assignFgSegHorizontals(t)},computeFgSegHorizontals:function(t){var e,n,i;if(this.sortEventSegs(t),e=Lt(t),Ot(e),n=e[0]){for(i=0;i=0;n--)if(i=e.duration(Pn[n]),r=U(i,t),at(r)&&r>1)return i;return e.duration(t)},renderDates:function(t){this.dateProfile=t,this.updateDayTable(),this.renderSlats(),this.renderColumns()},renderSkeleton:function(){var t=this.view.calendar.theme;this.el.html('
'),this.bottomRuleEl=this.el.find("hr")},renderSlats:function(){var t=this.view.calendar.theme;this.slatContainerEl=this.el.find("> .fc-slats").html(''+this.renderSlatRowHtml()+"
"),this.slatEls=this.slatContainerEl.find("tr"),this.slatCoordCache=new ge({els:this.slatEls,isVertical:!0})},renderSlatRowHtml:function(){for(var t,n,i,r=this.view,s=r.calendar,o=s.theme,a=this.isRTL,l=this.dateProfile,u="",c=e.duration(+l.minTime),h=e.duration(0);c"+(n?""+et(t.format(this.labelFormat))+"":"")+"",u+='"+(a?"":i)+''+(a?i:"")+"",c.add(this.slotDuration),h.add(this.slotDuration);return u},renderColumns:function(){var t=this.dateProfile,e=this.view.calendar.theme;this.dayRanges=this.dayDates.map(function(e){return new Ue(e.clone().add(t.minTime),e.clone().add(t.maxTime))}),this.headContainerEl&&this.headContainerEl.html(this.renderHeadHtml()),this.el.find("> .fc-bg").html(''+this.renderBgTrHtml(0)+"
"),this.colEls=this.el.find(".fc-day, .fc-disabled-day"),this.colCoordCache=new ge({els:this.colEls,isHorizontal:!0}),this.renderContentSkeleton()},renderContentSkeleton:function(){var e,n,i="";for(e=0;e
';n=t('
'+i+"
"),this.colContainerEls=n.find(".fc-content-col"),this.helperContainerEls=n.find(".fc-helper-container"),this.fgContainerEls=n.find(".fc-event-container:not(.fc-helper-container)"),this.bgContainerEls=n.find(".fc-bgevent-container"),this.highlightContainerEls=n.find(".fc-highlight-container"),this.businessContainerEls=n.find(".fc-business-container"),this.bookendCells(n.find("tr")),this.el.append(n)},groupSegsByCol:function(t){var e,n=[];for(e=0;e
').css("top",r).appendTo(this.colContainerEls.eq(i[n].col))[0]);i.length>0&&s.push(t('
').css("top",r).appendTo(this.el.find(".fc-content-skeleton"))[0]),this.nowIndicatorEls=t(s)},unrenderNowIndicator:function(){this.nowIndicatorEls&&(this.nowIndicatorEls.remove(),this.nowIndicatorEls=null)},updateSize:function(t,e,n){ke.prototype.updateSize.apply(this,arguments),this.slatCoordCache.build(),n&&this.updateSegVerticals([].concat(this.eventRenderer.getSegs(),this.businessSegs||[]))},getTotalSlatHeight:function(){return this.slatContainerEl.outerHeight()},computeDateTop:function(t,n){return this.computeTimeTop(e.duration(t-n.clone().stripTime()))},computeTimeTop:function(t){var e,n,i=this.slatEls.length,r=this.dateProfile,s=(t-r.minTime)/this.slotDuration;return s=Math.max(0,s),s=Math.min(i,s),e=Math.floor(s),e=Math.min(e,i-1),n=s-e,this.slatCoordCache.getTopPosition(e)+this.slatCoordCache.getHeight(e)*n},updateSegVerticals:function(t){this.computeSegVerticals(t),this.assignSegVerticals(t)},computeSegVerticals:function(t){var e,n,i,r=this.opt("agendaEventMinHeight");for(e=0;e').appendTo(e),this.el.find(".fc-body > tr > td").append(e),this.timeGrid.headContainerEl=this.el.find(".fc-head-container"),this.timeGrid.setElement(n),this.dayGrid&&(this.dayGrid.setElement(this.el.find(".fc-day-grid")),this.dayGrid.bottomCoordPadding=this.dayGrid.el.next("hr").outerHeight())},unrenderSkeleton:function(){this.timeGrid.removeElement(),this.dayGrid&&this.dayGrid.removeElement(),this.scroller.destroy()},renderSkeletonHtml:function(){var t=this.calendar.theme;return''+(this.opt("columnHeader")?'':"")+'
 
'+(this.dayGrid?'

':"")+"
"},axisStyleAttr:function(){return null!==this.axisWidth?'style="width:'+this.axisWidth+'px"':""},getNowIndicatorUnit:function(){return this.timeGrid.getNowIndicatorUnit()},updateSize:function(t,e,n){var s,o,a;if(Ae.prototype.updateSize.apply(this,arguments),this.axisWidth=u(this.el.find(".fc-axis")),!this.timeGrid.colEls)return void(e||(o=this.computeScrollerHeight(t),this.scroller.setHeight(o)));var l=this.el.find(".fc-row:not(.fc-scroller *)");this.timeGrid.bottomRuleEl.hide(),this.scroller.clear(),r(l),this.dayGrid&&(this.dayGrid.removeSegPopover(),s=this.opt("eventLimit"),s&&"number"!=typeof s&&(s=xn),s&&this.dayGrid.limitRows(s)),e||(o=this.computeScrollerHeight(t),this.scroller.setHeight(o),a=this.scroller.getScrollbarWidths(),(a.left||a.right)&&(i(l,a),o=this.computeScrollerHeight(t),this.scroller.setHeight(o)),this.scroller.lockOverflow(a),this.timeGrid.getTotalSlatHeight()"+e.buildGotoAnchorHtml({date:i,type:"week",forceOff:this.colCnt>1},et(t))+""):'"},renderBgIntroHtml:function(){var t=this.view;return'"},renderIntroHtml:function(){return'"}},Mn={renderBgIntroHtml:function(){var t=this.view;return'"+t.getAllDayHtml()+""},renderIntroHtml:function(){return'"}},xn=5,Pn=[{hours:1},{minutes:30},{minutes:15},{seconds:30},{seconds:15}];_t.agenda={class:In,defaults:{allDaySlot:!0,slotDuration:"00:30:00",slotEventOverlap:!0}},_t.agendaDay={type:"agenda",duration:{days:1}},_t.agendaWeek={type:"agenda",duration:{weeks:1}};var zn=Wt.ListView=Ae.extend({segSelector:".fc-list-item",scroller:null,contentEl:null,dayDates:null,dayRanges:null,constructor:function(){Ae.apply(this,arguments),this.scroller=new we({overflowX:"hidden",overflowY:"auto"})},renderSkeleton:function(){this.el.addClass("fc-list-view "+this.calendar.theme.getClass("listView")),this.scroller.render(),this.scroller.el.appendTo(this.el),this.contentEl=this.scroller.scrollEl},unrenderSkeleton:function(){this.scroller.destroy()},updateSize:function(t,e,n){this.scroller.setHeight(this.computeScrollerHeight(t))},computeScrollerHeight:function(t){return t-c(this.el,this.scroller.el)},renderDates:function(t){for(var e=this.calendar,n=e.msToUtcMoment(t.renderUnzonedRange.startMs,!0),i=e.msToUtcMoment(t.renderUnzonedRange.endMs,!0),r=[],s=[];n'+(this.displayEventTime?''+(e||"")+"":"")+'"+et(o.title||"")+""},computeEventTimeFormat:function(){return this.opt("mediumTimeFormat")}}),eventPointingClass:Te.extend({handleClick:function(e,n){var i;Te.prototype.handleClick.apply(this,arguments),t(n.target).closest("a[href]").length||(i=e.footprint.eventDef.url)&&!n.isDefaultPrevented()&&(window.location.href=i)}}),renderEmptyMessage:function(){this.contentEl.html('
'+et(this.opt("noEventsMessage"))+"
")},renderSegList:function(e){var n,i,r,s=this.groupSegsByDay(e),o=t('
'),a=o.find("tbody");for(n=0;n'+(e?this.buildGotoAnchorHtml(t,{class:"fc-list-heading-main"},et(t.format(e))):"")+(n?this.buildGotoAnchorHtml(t,{class:"fc-list-heading-alt"},et(t.format(n))):"")+""}});return _t.list={class:zn,buttonTextKey:"list",defaults:{buttonText:"list",listDayFormat:"LL",noEventsMessage:"No events to display"}},_t.listDay={type:"list",duration:{days:1},defaults:{listDayFormat:"dddd"}},_t.listWeek={type:"list",duration:{weeks:1},defaults:{listDayFormat:"dddd",listDayAltFormat:"LL"}},_t.listMonth={type:"list",duration:{month:1},defaults:{listDayAltFormat:"dddd"}},_t.listYear={type:"list",duration:{year:1},defaults:{listDayAltFormat:"dddd"}},Wt}); \ No newline at end of file diff --git a/librerias/calendar/fullcalendar.print.css b/librerias/calendar/fullcalendar.print.css new file mode 100755 index 0000000..e9efc62 --- /dev/null +++ b/librerias/calendar/fullcalendar.print.css @@ -0,0 +1,208 @@ +/*! + * FullCalendar v3.6.1 Print Stylesheet + * Docs & License: https://fullcalendar.io/ + * (c) 2017 Adam Shaw + */ + +/* + * Include this stylesheet on your page to get a more printer-friendly calendar. + * When including this stylesheet, use the media='print' attribute of the tag. + * Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css. + */ + +.fc { + max-width: 100% !important; +} + + +/* Global Event Restyling +--------------------------------------------------------------------------------------------------*/ + +.fc-event { + background: #fff !important; + color: #000 !important; + page-break-inside: avoid; +} + +.fc-event .fc-resizer { + display: none; +} + + +/* Table & Day-Row Restyling +--------------------------------------------------------------------------------------------------*/ + +.fc th, +.fc td, +.fc hr, +.fc thead, +.fc tbody, +.fc-row { + border-color: #ccc !important; + background: #fff !important; +} + +/* kill the overlaid, absolutely-positioned components */ +/* common... */ +.fc-bg, +.fc-bgevent-skeleton, +.fc-highlight-skeleton, +.fc-helper-skeleton, +/* for timegrid. within cells within table skeletons... */ +.fc-bgevent-container, +.fc-business-container, +.fc-highlight-container, +.fc-helper-container { + display: none; +} + +/* don't force a min-height on rows (for DayGrid) */ +.fc tbody .fc-row { + height: auto !important; /* undo height that JS set in distributeHeight */ + min-height: 0 !important; /* undo the min-height from each view's specific stylesheet */ +} + +.fc tbody .fc-row .fc-content-skeleton { + position: static; /* undo .fc-rigid */ + padding-bottom: 0 !important; /* use a more border-friendly method for this... */ +} + +.fc tbody .fc-row .fc-content-skeleton tbody tr:last-child td { /* only works in newer browsers */ + padding-bottom: 1em; /* ...gives space within the skeleton. also ensures min height in a way */ +} + +.fc tbody .fc-row .fc-content-skeleton table { + /* provides a min-height for the row, but only effective for IE, which exaggerates this value, + making it look more like 3em. for other browers, it will already be this tall */ + height: 1em; +} + + +/* Undo month-view event limiting. Display all events and hide the "more" links +--------------------------------------------------------------------------------------------------*/ + +.fc-more-cell, +.fc-more { + display: none !important; +} + +.fc tr.fc-limited { + display: table-row !important; +} + +.fc td.fc-limited { + display: table-cell !important; +} + +.fc-popover { + display: none; /* never display the "more.." popover in print mode */ +} + + +/* TimeGrid Restyling +--------------------------------------------------------------------------------------------------*/ + +/* undo the min-height 100% trick used to fill the container's height */ +.fc-time-grid { + min-height: 0 !important; +} + +/* don't display the side axis at all ("all-day" and time cells) */ +.fc-agenda-view .fc-axis { + display: none; +} + +/* don't display the horizontal lines */ +.fc-slats, +.fc-time-grid hr { /* this hr is used when height is underused and needs to be filled */ + display: none !important; /* important overrides inline declaration */ +} + +/* let the container that holds the events be naturally positioned and create real height */ +.fc-time-grid .fc-content-skeleton { + position: static; +} + +/* in case there are no events, we still want some height */ +.fc-time-grid .fc-content-skeleton table { + height: 4em; +} + +/* kill the horizontal spacing made by the event container. event margins will be done below */ +.fc-time-grid .fc-event-container { + margin: 0 !important; +} + + +/* TimeGrid *Event* Restyling +--------------------------------------------------------------------------------------------------*/ + +/* naturally position events, vertically stacking them */ +.fc-time-grid .fc-event { + position: static !important; + margin: 3px 2px !important; +} + +/* for events that continue to a future day, give the bottom border back */ +.fc-time-grid .fc-event.fc-not-end { + border-bottom-width: 1px !important; +} + +/* indicate the event continues via "..." text */ +.fc-time-grid .fc-event.fc-not-end:after { + content: "..."; +} + +/* for events that are continuations from previous days, give the top border back */ +.fc-time-grid .fc-event.fc-not-start { + border-top-width: 1px !important; +} + +/* indicate the event is a continuation via "..." text */ +.fc-time-grid .fc-event.fc-not-start:before { + content: "..."; +} + +/* time */ + +/* undo a previous declaration and let the time text span to a second line */ +.fc-time-grid .fc-event .fc-time { + white-space: normal !important; +} + +/* hide the the time that is normally displayed... */ +.fc-time-grid .fc-event .fc-time span { + display: none; +} + +/* ...replace it with a more verbose version (includes AM/PM) stored in an html attribute */ +.fc-time-grid .fc-event .fc-time:after { + content: attr(data-full); +} + + +/* Vertical Scroller & Containers +--------------------------------------------------------------------------------------------------*/ + +/* kill the scrollbars and allow natural height */ +.fc-scroller, +.fc-day-grid-container, /* these divs might be assigned height, which we need to cleared */ +.fc-time-grid-container { /* */ + overflow: visible !important; + height: auto !important; +} + +/* kill the horizontal border/padding used to compensate for scrollbars */ +.fc-row { + border: 0 !important; + margin: 0 !important; +} + + +/* Button Controls +--------------------------------------------------------------------------------------------------*/ + +.fc-button-group, +.fc button { + display: none; /* don't display any button-related controls */ +} diff --git a/librerias/calendar/fullcalendar.print.min.css b/librerias/calendar/fullcalendar.print.min.css new file mode 100755 index 0000000..05241cf --- /dev/null +++ b/librerias/calendar/fullcalendar.print.min.css @@ -0,0 +1,5 @@ +/*! + * FullCalendar v3.6.1 Print Stylesheet + * Docs & License: https://fullcalendar.io/ + * (c) 2017 Adam Shaw + */.fc-bg,.fc-bgevent-container,.fc-bgevent-skeleton,.fc-business-container,.fc-event .fc-resizer,.fc-helper-container,.fc-helper-skeleton,.fc-highlight-container,.fc-highlight-skeleton{display:none}.fc tbody .fc-row,.fc-time-grid{min-height:0!important}.fc-time-grid .fc-event.fc-not-end:after,.fc-time-grid .fc-event.fc-not-start:before{content:"..."}.fc{max-width:100%!important}.fc-event{background:#fff!important;color:#000!important;page-break-inside:avoid}.fc hr,.fc tbody,.fc td,.fc th,.fc thead,.fc-row{border-color:#ccc!important;background:#fff!important}.fc tbody .fc-row{height:auto!important}.fc tbody .fc-row .fc-content-skeleton{position:static;padding-bottom:0!important}.fc tbody .fc-row .fc-content-skeleton tbody tr:last-child td{padding-bottom:1em}.fc tbody .fc-row .fc-content-skeleton table{height:1em}.fc-more,.fc-more-cell{display:none!important}.fc tr.fc-limited{display:table-row!important}.fc td.fc-limited{display:table-cell!important}.fc-agenda-view .fc-axis,.fc-popover{display:none}.fc-slats,.fc-time-grid hr{display:none!important}.fc button,.fc-button-group,.fc-time-grid .fc-event .fc-time span{display:none}.fc-time-grid .fc-content-skeleton{position:static}.fc-time-grid .fc-content-skeleton table{height:4em}.fc-time-grid .fc-event-container{margin:0!important}.fc-time-grid .fc-event{position:static!important;margin:3px 2px!important}.fc-time-grid .fc-event.fc-not-end{border-bottom-width:1px!important}.fc-time-grid .fc-event.fc-not-start{border-top-width:1px!important}.fc-time-grid .fc-event .fc-time{white-space:normal!important}.fc-time-grid .fc-event .fc-time:after{content:attr(data-full)}.fc-day-grid-container,.fc-scroller,.fc-time-grid-container{overflow:visible!important;height:auto!important}.fc-row{border:0!important;margin:0!important} \ No newline at end of file diff --git a/librerias/calendar/gcal.js b/librerias/calendar/gcal.js new file mode 100755 index 0000000..45863b0 --- /dev/null +++ b/librerias/calendar/gcal.js @@ -0,0 +1,288 @@ +/*! + * FullCalendar v3.6.1 Google Calendar Plugin + * Docs & License: https://fullcalendar.io/ + * (c) 2017 Adam Shaw + */ + +(function(factory) { + if (typeof define === 'function' && define.amd) { + define([ 'jquery' ], factory); + } + else if (typeof exports === 'object') { // Node/CommonJS + module.exports = factory(require('jquery')); + } + else { + factory(jQuery); + } +})(function($) { + + +var FC = $.fullCalendar; +var Promise = FC.Promise; +var EventSource = FC.EventSource; +var JsonFeedEventSource = FC.JsonFeedEventSource; +var EventSourceParser = FC.EventSourceParser; +var applyAll = FC.applyAll; + +;; + +var GcalEventSource = EventSource.extend({ + + // TODO: eventually remove "googleCalendar" prefix (API-breaking) + googleCalendarApiKey: null, + googleCalendarId: null, + googleCalendarError: null, // optional function + ajaxSettings: null, + + + constructor: function() { + EventSource.apply(this, arguments); + this.ajaxSettings = {}; + }, + + + fetch: function(start, end, timezone) { + var _this = this; + var url = this.buildUrl(); + var requestParams = this.buildRequestParams(start, end, timezone); + var ajaxSettings = this.ajaxSettings; + var onSuccess = ajaxSettings.success; + + if (!requestParams) { // could have failed + return Promise.reject(); + } + + return Promise.construct(function(onResolve, onReject) { + $.ajax($.extend( + {}, // destination + JsonFeedEventSource.AJAX_DEFAULTS, + ajaxSettings, + { + url: url, + data: requestParams, + success: function(responseData) { + var rawEventDefs; + var successRes; + + if (responseData.error) { + _this.reportError('Google Calendar API: ' + responseData.error.message, responseData.error.errors); + onReject(); + } + else if (responseData.items) { + rawEventDefs = _this.gcalItemsToRawEventDefs( + responseData.items, + requestParams.timeZone + ); + + successRes = applyAll( + onSuccess, + this, // forward `this` + // call the success handler(s) and allow it to return a new events array + [ rawEventDefs ].concat(Array.prototype.slice.call(arguments, 1)) + ); + + if ($.isArray(successRes)) { + rawEventDefs = successRes; + } + + onResolve(_this.parseEventDefs(rawEventDefs)); + } + } + } + )); + }); + }, + + + gcalItemsToRawEventDefs: function(items, gcalTimezone) { + var _this = this; + + return items.map(function(item) { + return _this.gcalItemToRawEventDef(item, gcalTimezone); + }); + }, + + + gcalItemToRawEventDef: function(item, gcalTimezone) { + var url = item.htmlLink || null; + + // make the URLs for each event show times in the correct timezone + if (url && gcalTimezone) { + url = injectQsComponent(url, 'ctz=' + gcalTimezone); + } + + return { + id: item.id, + title: item.summary, + start: item.start.dateTime || item.start.date, // try timed. will fall back to all-day + end: item.end.dateTime || item.end.date, // same + url: url, + location: item.location, + description: item.description + }; + }, + + + buildUrl: function() { + return GcalEventSource.API_BASE + '/' + + encodeURIComponent(this.googleCalendarId) + + '/events?callback=?'; // jsonp + }, + + + buildRequestParams: function(start, end, timezone) { + var apiKey = this.googleCalendarApiKey || this.calendar.opt('googleCalendarApiKey'); + var params; + + if (!apiKey) { + this.reportError("Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/"); + return null; + } + + // The API expects an ISO8601 datetime with a time and timezone part. + // Since the calendar's timezone offset isn't always known, request the date in UTC and pad it by a day on each + // side, guaranteeing we will receive all events in the desired range, albeit a superset. + // .utc() will set a zone and give it a 00:00:00 time. + if (!start.hasZone()) { + start = start.clone().utc().add(-1, 'day'); + } + if (!end.hasZone()) { + end = end.clone().utc().add(1, 'day'); + } + + params = $.extend( + this.ajaxSettings.data || {}, + { + key: apiKey, + timeMin: start.format(), + timeMax: end.format(), + singleEvents: true, + maxResults: 9999 + } + ); + + if (timezone && timezone !== 'local') { + // when sending timezone names to Google, only accepts underscores, not spaces + params.timeZone = timezone.replace(' ', '_'); + } + + return params; + }, + + + reportError: function(message, apiErrorObjs) { + var calendar = this.calendar; + var calendarOnError = calendar.opt('googleCalendarError'); + var errorObjs = apiErrorObjs || [ { message: message } ]; // to be passed into error handlers + + if (this.googleCalendarError) { + this.googleCalendarError.apply(calendar, errorObjs); + } + + if (calendarOnError) { + calendarOnError.apply(calendar, errorObjs); + } + + // print error to debug console + FC.warn.apply(null, [ message ].concat(apiErrorObjs || [])); + }, + + + getPrimitive: function() { + return this.googleCalendarId; + }, + + + applyManualStandardProps: function(rawProps) { + var superSuccess = EventSource.prototype.applyManualStandardProps.apply(this, arguments); + var googleCalendarId = rawProps.googleCalendarId; + + if (googleCalendarId == null && rawProps.url) { + googleCalendarId = parseGoogleCalendarId(rawProps.url); + } + + if (googleCalendarId != null) { + this.googleCalendarId = googleCalendarId; + + return superSuccess; + } + + return false; + }, + + + applyMiscProps: function(rawProps) { + $.extend(this.ajaxSettings, rawProps); + } + +}); + + +GcalEventSource.API_BASE = 'https://www.googleapis.com/calendar/v3/calendars'; + + +GcalEventSource.defineStandardProps({ + // manually process... + url: false, + googleCalendarId: false, + + // automatically transfer... + googleCalendarApiKey: true, + googleCalendarError: true +}); + + +GcalEventSource.parse = function(rawInput, calendar) { + var rawProps; + + if (typeof rawInput === 'object') { // long form. might fail in applyManualStandardProps + rawProps = rawInput; + } + else if (typeof rawInput === 'string') { // short form + rawProps = { url: rawInput }; // url will be parsed with parseGoogleCalendarId + } + + if (rawProps) { + return EventSource.parse.call(this, rawProps, calendar); + } + + return false; +}; + + +function parseGoogleCalendarId(url) { + var match; + + // detect if the ID was specified as a single string. + // will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars. + if (/^[^\/]+@([^\/\.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) { + return url; + } + // try to scrape it out of a V1 or V3 API feed URL + else if ( + (match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^\/]*)/.exec(url)) || + (match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^\/]*)/.exec(url)) + ) { + return decodeURIComponent(match[1]); + } +} + + +// Injects a string like "arg=value" into the querystring of a URL +function injectQsComponent(url, component) { + // inject it after the querystring but before the fragment + return url.replace(/(\?.*?)?(#|$)/, function(whole, qs, hash) { + return (qs ? qs + '&' : '?') + component + hash; + }); +} + + +// expose + +EventSourceParser.registerClass(GcalEventSource); + +FC.GcalEventSource = GcalEventSource; + +;; + +}); diff --git a/librerias/calendar/gcal.min.js b/librerias/calendar/gcal.min.js new file mode 100755 index 0000000..7861c3f --- /dev/null +++ b/librerias/calendar/gcal.min.js @@ -0,0 +1,6 @@ +/*! + * FullCalendar v3.6.1 Google Calendar Plugin + * Docs & License: https://fullcalendar.io/ + * (c) 2017 Adam Shaw + */ +!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){function r(e){var r;return/^[^\/]+@([^\/\.]+\.)*(google|googlemail|gmail)\.com$/.test(e)?e:(r=/^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^\/]*)/.exec(e))||(r=/^https?:\/\/www.google.com\/calendar\/feeds\/([^\/]*)/.exec(e))?decodeURIComponent(r[1]):void 0}function t(e,r){return e.replace(/(\?.*?)?(#|$)/,function(e,t,a){return(t?t+"&":"?")+r+a})}var a=e.fullCalendar,n=a.Promise,o=a.EventSource,l=a.JsonFeedEventSource,i=a.EventSourceParser,s=a.applyAll,c=o.extend({googleCalendarApiKey:null,googleCalendarId:null,googleCalendarError:null,ajaxSettings:null,constructor:function(){o.apply(this,arguments),this.ajaxSettings={}},fetch:function(r,t,a){var o=this,i=this.buildUrl(),c=this.buildRequestParams(r,t,a),d=this.ajaxSettings,u=d.success;return c?n.construct(function(r,t){e.ajax(e.extend({},l.AJAX_DEFAULTS,d,{url:i,data:c,success:function(a){var n,l;a.error?(o.reportError("Google Calendar API: "+a.error.message,a.error.errors),t()):a.items&&(n=o.gcalItemsToRawEventDefs(a.items,c.timeZone),l=s(u,this,[n].concat(Array.prototype.slice.call(arguments,1))),e.isArray(l)&&(n=l),r(o.parseEventDefs(n)))}}))}):n.reject()},gcalItemsToRawEventDefs:function(e,r){var t=this;return e.map(function(e){return t.gcalItemToRawEventDef(e,r)})},gcalItemToRawEventDef:function(e,r){var a=e.htmlLink||null;return a&&r&&(a=t(a,"ctz="+r)),{id:e.id,title:e.summary,start:e.start.dateTime||e.start.date,end:e.end.dateTime||e.end.date,url:a,location:e.location,description:e.description}},buildUrl:function(){return c.API_BASE+"/"+encodeURIComponent(this.googleCalendarId)+"/events?callback=?"},buildRequestParams:function(r,t,a){var n,o=this.googleCalendarApiKey||this.calendar.opt("googleCalendarApiKey");return o?(r.hasZone()||(r=r.clone().utc().add(-1,"day")),t.hasZone()||(t=t.clone().utc().add(1,"day")),n=e.extend(this.ajaxSettings.data||{},{key:o,timeMin:r.format(),timeMax:t.format(),singleEvents:!0,maxResults:9999}),a&&"local"!==a&&(n.timeZone=a.replace(" ","_")),n):(this.reportError("Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/"),null)},reportError:function(e,r){var t=this.calendar,n=t.opt("googleCalendarError"),o=r||[{message:e}];this.googleCalendarError&&this.googleCalendarError.apply(t,o),n&&n.apply(t,o),a.warn.apply(null,[e].concat(r||[]))},getPrimitive:function(){return this.googleCalendarId},applyManualStandardProps:function(e){var t=o.prototype.applyManualStandardProps.apply(this,arguments),a=e.googleCalendarId;return null==a&&e.url&&(a=r(e.url)),null!=a&&(this.googleCalendarId=a,t)},applyMiscProps:function(r){e.extend(this.ajaxSettings,r)}});c.API_BASE="https://www.googleapis.com/calendar/v3/calendars",c.defineStandardProps({url:!1,googleCalendarId:!1,googleCalendarApiKey:!0,googleCalendarError:!0}),c.parse=function(e,r){var t;return"object"==typeof e?t=e:"string"==typeof e&&(t={url:e}),!!t&&o.parse.call(this,t,r)},i.registerClass(c),a.GcalEventSource=c}); \ No newline at end of file diff --git a/librerias/calendar/index.php b/librerias/calendar/index.php new file mode 100755 index 0000000..e69de29 diff --git a/librerias/calendar/lib/jquery-ui.min.js b/librerias/calendar/lib/jquery-ui.min.js new file mode 100755 index 0000000..25398a1 --- /dev/null +++ b/librerias/calendar/lib/jquery-ui.min.js @@ -0,0 +1,13 @@ +/*! jQuery UI - v1.12.1 - 2016-09-14 +* http://jqueryui.com +* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)})(function(t){function e(t){for(var e=t.css("visibility");"inherit"===e;)t=t.parent(),e=t.css("visibility");return"hidden"!==e}function i(t){for(var e,i;t.length&&t[0]!==document;){if(e=t.css("position"),("absolute"===e||"relative"===e||"fixed"===e)&&(i=parseInt(t.css("zIndex"),10),!isNaN(i)&&0!==i))return i;t=t.parent()}return 0}function s(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},t.extend(this._defaults,this.regional[""]),this.regional.en=t.extend(!0,{},this.regional[""]),this.regional["en-US"]=t.extend(!0,{},this.regional.en),this.dpDiv=n(t("
"))}function n(e){var i="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return e.on("mouseout",i,function(){t(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&t(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&t(this).removeClass("ui-datepicker-next-hover")}).on("mouseover",i,o)}function o(){t.datepicker._isDisabledDatepicker(m.inline?m.dpDiv.parent()[0]:m.input[0])||(t(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),t(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&t(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&t(this).addClass("ui-datepicker-next-hover"))}function a(e,i){t.extend(e,i);for(var s in i)null==i[s]&&(e[s]=i[s]);return e}function r(t){return function(){var e=this.element.val();t.apply(this,arguments),this._refresh(),e!==this.element.val()&&this._trigger("change")}}t.ui=t.ui||{},t.ui.version="1.12.1";var h=0,l=Array.prototype.slice;t.cleanData=function(e){return function(i){var s,n,o;for(o=0;null!=(n=i[o]);o++)try{s=t._data(n,"events"),s&&s.remove&&t(n).triggerHandler("remove")}catch(a){}e(i)}}(t.cleanData),t.widget=function(e,i,s){var n,o,a,r={},h=e.split(".")[0];e=e.split(".")[1];var l=h+"-"+e;return s||(s=i,i=t.Widget),t.isArray(s)&&(s=t.extend.apply(null,[{}].concat(s))),t.expr[":"][l.toLowerCase()]=function(e){return!!t.data(e,l)},t[h]=t[h]||{},n=t[h][e],o=t[h][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new o(t,e)},t.extend(o,n,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),a=new i,a.options=t.widget.extend({},a.options),t.each(s,function(e,s){return t.isFunction(s)?(r[e]=function(){function t(){return i.prototype[e].apply(this,arguments)}function n(t){return i.prototype[e].apply(this,t)}return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}(),void 0):(r[e]=s,void 0)}),o.prototype=t.widget.extend(a,{widgetEventPrefix:n?a.widgetEventPrefix||e:e},r,{constructor:o,namespace:h,widgetName:e,widgetFullName:l}),n?(t.each(n._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete n._childConstructors):i._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var i,s,n=l.call(arguments,1),o=0,a=n.length;a>o;o++)for(i in n[o])s=n[o][i],n[o].hasOwnProperty(i)&&void 0!==s&&(e[i]=t.isPlainObject(s)?t.isPlainObject(e[i])?t.widget.extend({},e[i],s):t.widget.extend({},s):s);return e},t.widget.bridge=function(e,i){var s=i.prototype.widgetFullName||e;t.fn[e]=function(n){var o="string"==typeof n,a=l.call(arguments,1),r=this;return o?this.length||"instance"!==n?this.each(function(){var i,o=t.data(this,s);return"instance"===n?(r=o,!1):o?t.isFunction(o[n])&&"_"!==n.charAt(0)?(i=o[n].apply(o,a),i!==o&&void 0!==i?(r=i&&i.jquery?r.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+n+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+n+"'")}):r=void 0:(a.length&&(n=t.widget.extend.apply(null,[n].concat(a))),this.each(function(){var e=t.data(this,s);e?(e.option(n||{}),e._init&&e._init()):t.data(this,s,new i(n,this))})),r}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,i){i=t(i||this.defaultElement||this)[0],this.element=t(i),this.uuid=h++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},i!==this&&(t.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===i&&this.destroy()}}),this.document=t(i.style?i.ownerDocument:i.document||i),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+o.eventNamespace,c=h[2];c?n.on(l,c,r):i.on(l,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,h=/top|center|bottom/,l=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.widthi?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};l>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),h.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,h=n-r,l=r+e.collisionWidth-a-n;e.collisionWidth>a?h>0&&0>=l?(i=t.left+h+e.collisionWidth-a-n,t.left+=h-i):t.left=l>0&&0>=h?n:h>l?n+a-e.collisionWidth:n:h>0?t.left+=h:l>0?t.left-=l:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,h=n-r,l=r+e.collisionHeight-a-n;e.collisionHeight>a?h>0&&0>=l?(i=t.top+h+e.collisionHeight-a-n,t.top+=h-i):t.top=l>0&&0>=h?n:h>l?n+a-e.collisionHeight:n:h>0?t.top+=h:l>0?t.top-=l:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-h,u=l+e.collisionWidth-r-h,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-h,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=t.top-e.collisionPosition.marginTop,c=l-h,u=l+e.collisionHeight-r-h,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,g=-2*e.offset[1];0>c?(s=t.top+p+f+g+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+g)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+g-h,(i>0||u>a(i))&&(t.top+=p+f+g))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}});var c="ui-effects-",u="ui-effects-style",d="ui-effects-animated",p=t;t.effects={effect:{}},function(t,e){function i(t,e,i){var s=u[e.type]||{};return null==t?i||!e.def?null:e.def:(t=s.floor?~~t:parseFloat(t),isNaN(t)?e.def:s.mod?(t+s.mod)%s.mod:0>t?0:t>s.max?s.max:t)}function s(i){var s=l(),n=s._rgba=[];return i=i.toLowerCase(),f(h,function(t,o){var a,r=o.re.exec(i),h=r&&o.parse(r),l=o.space||"rgba";return h?(a=s[l](h),s[c[l].cache]=a[c[l].cache],n=s._rgba=a._rgba,!1):e}),n.length?("0,0,0,0"===n.join()&&t.extend(n,o.transparent),s):o[i]}function n(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var o,a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,h=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],l=t.Color=function(e,i,s,n){return new t.Color.fn.parse(e,i,s,n)},c={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},u={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},d=l.support={},p=t("

")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",d.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(c,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),l.fn=t.extend(l.prototype,{parse:function(n,a,r,h){if(n===e)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=t(n).css(a),a=e);var u=this,d=t.type(n),p=this._rgba=[];return a!==e&&(n=[n,a,r,h],d="array"),"string"===d?this.parse(s(n)||o._default):"array"===d?(f(c.rgba.props,function(t,e){p[e.idx]=i(n[e.idx],e)}),this):"object"===d?(n instanceof l?f(c,function(t,e){n[e.cache]&&(u[e.cache]=n[e.cache].slice())}):f(c,function(e,s){var o=s.cache;f(s.props,function(t,e){if(!u[o]&&s.to){if("alpha"===t||null==n[t])return;u[o]=s.to(u._rgba)}u[o][e.idx]=i(n[t],e,!0)}),u[o]&&0>t.inArray(null,u[o].slice(0,3))&&(u[o][3]=1,s.from&&(u._rgba=s.from(u[o])))}),this):e},is:function(t){var i=l(t),s=!0,n=this;return f(c,function(t,o){var a,r=i[o.cache];return r&&(a=n[o.cache]||o.to&&o.to(n._rgba)||[],f(o.props,function(t,i){return null!=r[i.idx]?s=r[i.idx]===a[i.idx]:e})),s}),s},_space:function(){var t=[],e=this;return f(c,function(i,s){e[s.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var s=l(t),n=s._space(),o=c[n],a=0===this.alpha()?l("transparent"):this,r=a[o.cache]||o.to(a._rgba),h=r.slice();return s=s[o.cache],f(o.props,function(t,n){var o=n.idx,a=r[o],l=s[o],c=u[n.type]||{};null!==l&&(null===a?h[o]=l:(c.mod&&(l-a>c.mod/2?a+=c.mod:a-l>c.mod/2&&(a-=c.mod)),h[o]=i((l-a)*e+a,n)))}),this[n](h)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=l(e)._rgba;return l(t.map(i,function(t,e){return(1-s)*n[e]+s*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),s=i.pop();return e&&i.push(~~(255*s)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),l.fn.parse.prototype=l.fn,c.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,s=t[0]/255,n=t[1]/255,o=t[2]/255,a=t[3],r=Math.max(s,n,o),h=Math.min(s,n,o),l=r-h,c=r+h,u=.5*c;return e=h===r?0:s===r?60*(n-o)/l+360:n===r?60*(o-s)/l+120:60*(s-n)/l+240,i=0===l?0:.5>=u?l/c:l/(2-c),[Math.round(e)%360,i,u,null==a?1:a]},c.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],s=t[2],o=t[3],a=.5>=s?s*(1+i):s+i-s*i,r=2*s-a;return[Math.round(255*n(r,a,e+1/3)),Math.round(255*n(r,a,e)),Math.round(255*n(r,a,e-1/3)),o]},f(c,function(s,n){var o=n.props,a=n.cache,h=n.to,c=n.from;l.fn[s]=function(s){if(h&&!this[a]&&(this[a]=h(this._rgba)),s===e)return this[a].slice();var n,r=t.type(s),u="array"===r||"object"===r?s:arguments,d=this[a].slice();return f(o,function(t,e){var s=u["object"===r?t:e.idx];null==s&&(s=d[e.idx]),d[e.idx]=i(s,e)}),c?(n=l(c(d)),n[a]=d,n):l(d)},f(o,function(e,i){l.fn[e]||(l.fn[e]=function(n){var o,a=t.type(n),h="alpha"===e?this._hsla?"hsla":"rgba":s,l=this[h](),c=l[i.idx];return"undefined"===a?c:("function"===a&&(n=n.call(this,c),a=t.type(n)),null==n&&i.empty?this:("string"===a&&(o=r.exec(n),o&&(n=c+parseFloat(o[2])*("+"===o[1]?1:-1))),l[i.idx]=n,this[h](l)))})})}),l.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var o,a,r="";if("transparent"!==n&&("string"!==t.type(n)||(o=s(n)))){if(n=l(o||n),!d.rgba&&1!==n._rgba[3]){for(a="backgroundColor"===i?e.parentNode:e;(""===r||"transparent"===r)&&a&&a.style;)try{r=t.css(a,"backgroundColor"),a=a.parentNode}catch(h){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{e.style[i]=n}catch(h){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=l(e.elem,i),e.end=l(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},l.hook(a),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,s){e["border"+s+"Color"]=t}),e}},o=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(p),function(){function e(e){var i,s,n=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,o={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(o[t.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(o[i]=n[i]);return o}function i(e,i){var s,o,a={};for(s in i)o=i[s],e[s]!==o&&(n[s]||(t.fx.step[s]||!isNaN(parseFloat(o)))&&(a[s]=o));return a}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(p.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(n,o,a,r){var h=t.speed(o,a,r);return this.queue(function(){var o,a=t(this),r=a.attr("class")||"",l=h.children?a.find("*").addBack():a;l=l.map(function(){var i=t(this);return{el:i,start:e(this)}}),o=function(){t.each(s,function(t,e){n[e]&&a[e+"Class"](n[e])})},o(),l=l.map(function(){return this.end=e(this.el[0]),this.diff=i(this.start,this.end),this}),a.attr("class",r),l=l.map(function(){var e=this,i=t.Deferred(),s=t.extend({},h,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,s),i.promise()}),t.when.apply(t,l.get()).done(function(){o(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),h.complete.call(a[0])})})},t.fn.extend({addClass:function(e){return function(i,s,n,o){return s?t.effects.animateClass.call(this,{add:i},s,n,o):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,s,n,o){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},s,n,o):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(e){return function(i,s,n,o,a){return"boolean"==typeof s||void 0===s?n?t.effects.animateClass.call(this,s?{add:i}:{remove:i},n,o,a):e.apply(this,arguments):t.effects.animateClass.call(this,{toggle:i},s,n,o)}}(t.fn.toggleClass),switchClass:function(e,i,s,n,o){return t.effects.animateClass.call(this,{add:i,remove:e},s,n,o)}})}(),function(){function e(e,i,s,n){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(n=s,s=i,i={}),t.isFunction(s)&&(n=s,s=null),i&&t.extend(e,i),s=s||i.duration,e.duration=t.fx.off?0:"number"==typeof s?s:s in t.fx.speeds?t.fx.speeds[s]:t.fx.speeds._default,e.complete=n||i.complete,e}function i(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"!=typeof e||e.effect?!1:!0:!0}function s(t,e){var i=e.outerWidth(),s=e.outerHeight(),n=/^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,o=n.exec(t)||["",0,i,s,0];return{top:parseFloat(o[1])||0,right:"auto"===o[2]?i:parseFloat(o[2]),bottom:"auto"===o[3]?s:parseFloat(o[3]),left:parseFloat(o[4])||0}}t.expr&&t.expr.filters&&t.expr.filters.animated&&(t.expr.filters.animated=function(e){return function(i){return!!t(i).data(d)||e(i)}}(t.expr.filters.animated)),t.uiBackCompat!==!1&&t.extend(t.effects,{save:function(t,e){for(var i=0,s=e.length;s>i;i++)null!==e[i]&&t.data(c+e[i],t[0].style[e[i]])},restore:function(t,e){for(var i,s=0,n=e.length;n>s;s++)null!==e[s]&&(i=t.data(c+e[s]),t.css(e[s],i))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},s=t("

").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:e.width(),height:e.height()},o=document.activeElement;try{o.id}catch(a){o=document.body}return e.wrap(s),(e[0]===o||t.contains(e[0],o))&&t(o).trigger("focus"),s=e.parent(),"static"===e.css("position")?(s.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,s){i[s]=e.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(n),s.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).trigger("focus")),e}}),t.extend(t.effects,{version:"1.12.1",define:function(e,i,s){return s||(s=i,i="effect"),t.effects.effect[e]=s,t.effects.effect[e].mode=i,s},scaledDimensions:function(t,e,i){if(0===e)return{height:0,width:0,outerHeight:0,outerWidth:0};var s="horizontal"!==i?(e||100)/100:1,n="vertical"!==i?(e||100)/100:1;return{height:t.height()*n,width:t.width()*s,outerHeight:t.outerHeight()*n,outerWidth:t.outerWidth()*s}},clipToBox:function(t){return{width:t.clip.right-t.clip.left,height:t.clip.bottom-t.clip.top,left:t.clip.left,top:t.clip.top}},unshift:function(t,e,i){var s=t.queue();e>1&&s.splice.apply(s,[1,0].concat(s.splice(e,i))),t.dequeue()},saveStyle:function(t){t.data(u,t[0].style.cssText)},restoreStyle:function(t){t[0].style.cssText=t.data(u)||"",t.removeData(u)},mode:function(t,e){var i=t.is(":hidden");return"toggle"===e&&(e=i?"show":"hide"),(i?"hide"===e:"show"===e)&&(e="none"),e},getBaseline:function(t,e){var i,s;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=t[1]/e.width}return{x:s,y:i}},createPlaceholder:function(e){var i,s=e.css("position"),n=e.position();return e.css({marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()),/^(static|relative)/.test(s)&&(s="absolute",i=t("<"+e[0].nodeName+">").insertAfter(e).css({display:/^(inline|ruby)/.test(e.css("display"))?"inline-block":"block",visibility:"hidden",marginTop:e.css("marginTop"),marginBottom:e.css("marginBottom"),marginLeft:e.css("marginLeft"),marginRight:e.css("marginRight"),"float":e.css("float")}).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).addClass("ui-effects-placeholder"),e.data(c+"placeholder",i)),e.css({position:s,left:n.left,top:n.top}),i},removePlaceholder:function(t){var e=c+"placeholder",i=t.data(e);i&&(i.remove(),t.removeData(e))},cleanUp:function(e){t.effects.restoreStyle(e),t.effects.removePlaceholder(e)},setTransition:function(e,i,s,n){return n=n||{},t.each(i,function(t,i){var o=e.cssUnit(i);o[0]>0&&(n[i]=o[0]*s+o[1])}),n}}),t.fn.extend({effect:function(){function i(e){function i(){r.removeData(d),t.effects.cleanUp(r),"hide"===s.mode&&r.hide(),a()}function a(){t.isFunction(h)&&h.call(r[0]),t.isFunction(e)&&e()}var r=t(this);s.mode=c.shift(),t.uiBackCompat===!1||o?"none"===s.mode?(r[l](),a()):n.call(r[0],s,i):(r.is(":hidden")?"hide"===l:"show"===l)?(r[l](),a()):n.call(r[0],s,a)}var s=e.apply(this,arguments),n=t.effects.effect[s.effect],o=n.mode,a=s.queue,r=a||"fx",h=s.complete,l=s.mode,c=[],u=function(e){var i=t(this),s=t.effects.mode(i,l)||o;i.data(d,!0),c.push(s),o&&("show"===s||s===o&&"hide"===s)&&i.show(),o&&"none"===s||t.effects.saveStyle(i),t.isFunction(e)&&e()};return t.fx.off||!n?l?this[l](s.duration,h):this.each(function(){h&&h.call(this)}):a===!1?this.each(u).each(i):this.queue(r,u).queue(r,i)},show:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="show",this.effect.call(this,n) +}}(t.fn.show),hide:function(t){return function(s){if(i(s))return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="hide",this.effect.call(this,n)}}(t.fn.hide),toggle:function(t){return function(s){if(i(s)||"boolean"==typeof s)return t.apply(this,arguments);var n=e.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),s=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(s=[parseFloat(i),e])}),s},cssClip:function(t){return t?this.css("clip","rect("+t.top+"px "+t.right+"px "+t.bottom+"px "+t.left+"px)"):s(this.css("clip"),this)},transfer:function(e,i){var s=t(this),n=t(e.to),o="fixed"===n.css("position"),a=t("body"),r=o?a.scrollTop():0,h=o?a.scrollLeft():0,l=n.offset(),c={top:l.top-r,left:l.left-h,height:n.innerHeight(),width:n.innerWidth()},u=s.offset(),d=t("
").appendTo("body").addClass(e.className).css({top:u.top-r,left:u.left-h,height:s.innerHeight(),width:s.innerWidth(),position:o?"fixed":"absolute"}).animate(c,e.duration,e.easing,function(){d.remove(),t.isFunction(i)&&i()})}}),t.fx.step.clip=function(e){e.clipInit||(e.start=t(e.elem).cssClip(),"string"==typeof e.end&&(e.end=s(e.end,e.elem)),e.clipInit=!0),t(e.elem).cssClip({top:e.pos*(e.end.top-e.start.top)+e.start.top,right:e.pos*(e.end.right-e.start.right)+e.start.right,bottom:e.pos*(e.end.bottom-e.start.bottom)+e.start.bottom,left:e.pos*(e.end.left-e.start.left)+e.start.left})}}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}();var f=t.effects;t.effects.define("blind","hide",function(e,i){var s={up:["bottom","top"],vertical:["bottom","top"],down:["top","bottom"],left:["right","left"],horizontal:["right","left"],right:["left","right"]},n=t(this),o=e.direction||"up",a=n.cssClip(),r={clip:t.extend({},a)},h=t.effects.createPlaceholder(n);r.clip[s[o][0]]=r.clip[s[o][1]],"show"===e.mode&&(n.cssClip(r.clip),h&&h.css(t.effects.clipToBox(r)),r.clip=a),h&&h.animate(t.effects.clipToBox(r),e.duration,e.easing),n.animate(r,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("bounce",function(e,i){var s,n,o,a=t(this),r=e.mode,h="hide"===r,l="show"===r,c=e.direction||"up",u=e.distance,d=e.times||5,p=2*d+(l||h?1:0),f=e.duration/p,g=e.easing,m="up"===c||"down"===c?"top":"left",_="up"===c||"left"===c,v=0,b=a.queue().length;for(t.effects.createPlaceholder(a),o=a.css(m),u||(u=a["top"===m?"outerHeight":"outerWidth"]()/3),l&&(n={opacity:1},n[m]=o,a.css("opacity",0).css(m,_?2*-u:2*u).animate(n,f,g)),h&&(u/=Math.pow(2,d-1)),n={},n[m]=o;d>v;v++)s={},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g).animate(n,f,g),u=h?2*u:u/2;h&&(s={opacity:0},s[m]=(_?"-=":"+=")+u,a.animate(s,f,g)),a.queue(i),t.effects.unshift(a,b,p+1)}),t.effects.define("clip","hide",function(e,i){var s,n={},o=t(this),a=e.direction||"vertical",r="both"===a,h=r||"horizontal"===a,l=r||"vertical"===a;s=o.cssClip(),n.clip={top:l?(s.bottom-s.top)/2:s.top,right:h?(s.right-s.left)/2:s.right,bottom:l?(s.bottom-s.top)/2:s.bottom,left:h?(s.right-s.left)/2:s.left},t.effects.createPlaceholder(o),"show"===e.mode&&(o.cssClip(n.clip),n.clip=s),o.animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("drop","hide",function(e,i){var s,n=t(this),o=e.mode,a="show"===o,r=e.direction||"left",h="up"===r||"down"===r?"top":"left",l="up"===r||"left"===r?"-=":"+=",c="+="===l?"-=":"+=",u={opacity:0};t.effects.createPlaceholder(n),s=e.distance||n["top"===h?"outerHeight":"outerWidth"](!0)/2,u[h]=l+s,a&&(n.css(u),u[h]=c+s,u.opacity=1),n.animate(u,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("explode","hide",function(e,i){function s(){b.push(this),b.length===u*d&&n()}function n(){p.css({visibility:"visible"}),t(b).remove(),i()}var o,a,r,h,l,c,u=e.pieces?Math.round(Math.sqrt(e.pieces)):3,d=u,p=t(this),f=e.mode,g="show"===f,m=p.show().css("visibility","hidden").offset(),_=Math.ceil(p.outerWidth()/d),v=Math.ceil(p.outerHeight()/u),b=[];for(o=0;u>o;o++)for(h=m.top+o*v,c=o-(u-1)/2,a=0;d>a;a++)r=m.left+a*_,l=a-(d-1)/2,p.clone().appendTo("body").wrap("
").css({position:"absolute",visibility:"visible",left:-a*_,top:-o*v}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:_,height:v,left:r+(g?l*_:0),top:h+(g?c*v:0),opacity:g?0:1}).animate({left:r+(g?0:l*_),top:h+(g?0:c*v),opacity:g?1:0},e.duration||500,e.easing,s)}),t.effects.define("fade","toggle",function(e,i){var s="show"===e.mode;t(this).css("opacity",s?0:1).animate({opacity:s?1:0},{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("fold","hide",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=e.size||15,h=/([0-9]+)%/.exec(r),l=!!e.horizFirst,c=l?["right","bottom"]:["bottom","right"],u=e.duration/2,d=t.effects.createPlaceholder(s),p=s.cssClip(),f={clip:t.extend({},p)},g={clip:t.extend({},p)},m=[p[c[0]],p[c[1]]],_=s.queue().length;h&&(r=parseInt(h[1],10)/100*m[a?0:1]),f.clip[c[0]]=r,g.clip[c[0]]=r,g.clip[c[1]]=0,o&&(s.cssClip(g.clip),d&&d.css(t.effects.clipToBox(g)),g.clip=p),s.queue(function(i){d&&d.animate(t.effects.clipToBox(f),u,e.easing).animate(t.effects.clipToBox(g),u,e.easing),i()}).animate(f,u,e.easing).animate(g,u,e.easing).queue(i),t.effects.unshift(s,_,4)}),t.effects.define("highlight","show",function(e,i){var s=t(this),n={backgroundColor:s.css("backgroundColor")};"hide"===e.mode&&(n.opacity=0),t.effects.saveStyle(s),s.css({backgroundImage:"none",backgroundColor:e.color||"#ffff99"}).animate(n,{queue:!1,duration:e.duration,easing:e.easing,complete:i})}),t.effects.define("size",function(e,i){var s,n,o,a=t(this),r=["fontSize"],h=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],l=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],c=e.mode,u="effect"!==c,d=e.scale||"both",p=e.origin||["middle","center"],f=a.css("position"),g=a.position(),m=t.effects.scaledDimensions(a),_=e.from||m,v=e.to||t.effects.scaledDimensions(a,0);t.effects.createPlaceholder(a),"show"===c&&(o=_,_=v,v=o),n={from:{y:_.height/m.height,x:_.width/m.width},to:{y:v.height/m.height,x:v.width/m.width}},("box"===d||"both"===d)&&(n.from.y!==n.to.y&&(_=t.effects.setTransition(a,h,n.from.y,_),v=t.effects.setTransition(a,h,n.to.y,v)),n.from.x!==n.to.x&&(_=t.effects.setTransition(a,l,n.from.x,_),v=t.effects.setTransition(a,l,n.to.x,v))),("content"===d||"both"===d)&&n.from.y!==n.to.y&&(_=t.effects.setTransition(a,r,n.from.y,_),v=t.effects.setTransition(a,r,n.to.y,v)),p&&(s=t.effects.getBaseline(p,m),_.top=(m.outerHeight-_.outerHeight)*s.y+g.top,_.left=(m.outerWidth-_.outerWidth)*s.x+g.left,v.top=(m.outerHeight-v.outerHeight)*s.y+g.top,v.left=(m.outerWidth-v.outerWidth)*s.x+g.left),a.css(_),("content"===d||"both"===d)&&(h=h.concat(["marginTop","marginBottom"]).concat(r),l=l.concat(["marginLeft","marginRight"]),a.find("*[width]").each(function(){var i=t(this),s=t.effects.scaledDimensions(i),o={height:s.height*n.from.y,width:s.width*n.from.x,outerHeight:s.outerHeight*n.from.y,outerWidth:s.outerWidth*n.from.x},a={height:s.height*n.to.y,width:s.width*n.to.x,outerHeight:s.height*n.to.y,outerWidth:s.width*n.to.x};n.from.y!==n.to.y&&(o=t.effects.setTransition(i,h,n.from.y,o),a=t.effects.setTransition(i,h,n.to.y,a)),n.from.x!==n.to.x&&(o=t.effects.setTransition(i,l,n.from.x,o),a=t.effects.setTransition(i,l,n.to.x,a)),u&&t.effects.saveStyle(i),i.css(o),i.animate(a,e.duration,e.easing,function(){u&&t.effects.restoreStyle(i)})})),a.animate(v,{queue:!1,duration:e.duration,easing:e.easing,complete:function(){var e=a.offset();0===v.opacity&&a.css("opacity",_.opacity),u||(a.css("position","static"===f?"relative":f).offset(e),t.effects.saveStyle(a)),i()}})}),t.effects.define("scale",function(e,i){var s=t(this),n=e.mode,o=parseInt(e.percent,10)||(0===parseInt(e.percent,10)?0:"effect"!==n?0:100),a=t.extend(!0,{from:t.effects.scaledDimensions(s),to:t.effects.scaledDimensions(s,o,e.direction||"both"),origin:e.origin||["middle","center"]},e);e.fade&&(a.from.opacity=1,a.to.opacity=0),t.effects.effect.size.call(this,a,i)}),t.effects.define("puff","hide",function(e,i){var s=t.extend(!0,{},e,{fade:!0,percent:parseInt(e.percent,10)||150});t.effects.effect.scale.call(this,s,i)}),t.effects.define("pulsate","show",function(e,i){var s=t(this),n=e.mode,o="show"===n,a="hide"===n,r=o||a,h=2*(e.times||5)+(r?1:0),l=e.duration/h,c=0,u=1,d=s.queue().length;for((o||!s.is(":visible"))&&(s.css("opacity",0).show(),c=1);h>u;u++)s.animate({opacity:c},l,e.easing),c=1-c;s.animate({opacity:c},l,e.easing),s.queue(i),t.effects.unshift(s,d,h+1)}),t.effects.define("shake",function(e,i){var s=1,n=t(this),o=e.direction||"left",a=e.distance||20,r=e.times||3,h=2*r+1,l=Math.round(e.duration/h),c="up"===o||"down"===o?"top":"left",u="up"===o||"left"===o,d={},p={},f={},g=n.queue().length;for(t.effects.createPlaceholder(n),d[c]=(u?"-=":"+=")+a,p[c]=(u?"+=":"-=")+2*a,f[c]=(u?"-=":"+=")+2*a,n.animate(d,l,e.easing);r>s;s++)n.animate(p,l,e.easing).animate(f,l,e.easing);n.animate(p,l,e.easing).animate(d,l/2,e.easing).queue(i),t.effects.unshift(n,g,h+1)}),t.effects.define("slide","show",function(e,i){var s,n,o=t(this),a={up:["bottom","top"],down:["top","bottom"],left:["right","left"],right:["left","right"]},r=e.mode,h=e.direction||"left",l="up"===h||"down"===h?"top":"left",c="up"===h||"left"===h,u=e.distance||o["top"===l?"outerHeight":"outerWidth"](!0),d={};t.effects.createPlaceholder(o),s=o.cssClip(),n=o.position()[l],d[l]=(c?-1:1)*u+n,d.clip=o.cssClip(),d.clip[a[h][1]]=d.clip[a[h][0]],"show"===r&&(o.cssClip(d.clip),o.css(l,d[l]),d.clip=s,d[l]=n),o.animate(d,{queue:!1,duration:e.duration,easing:e.easing,complete:i})});var f;t.uiBackCompat!==!1&&(f=t.effects.define("transfer",function(e,i){t(this).transfer(e,i)})),t.ui.focusable=function(i,s){var n,o,a,r,h,l=i.nodeName.toLowerCase();return"area"===l?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(l)?(r=!i.disabled,r&&(h=t(i).closest("fieldset")[0],h&&(r=!h.disabled))):r="a"===l?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,.\/:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.widget("ui.accordion",{version:"1.12.1",options:{active:0,animate:{},classes:{"ui-accordion-header":"ui-corner-top","ui-accordion-header-collapsed":"ui-corner-all","ui-accordion-content":"ui-corner-bottom"},collapsible:!1,event:"click",header:"> li > :first-child, > :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var e=this.options;this.prevShow=this.prevHide=t(),this._addClass("ui-accordion","ui-widget ui-helper-reset"),this.element.attr("role","tablist"),e.collapsible||e.active!==!1&&null!=e.active||(e.active=0),this._processPanels(),0>e.active&&(e.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():t()}},_createIcons:function(){var e,i,s=this.options.icons;s&&(e=t(""),this._addClass(e,"ui-accordion-header-icon","ui-icon "+s.header),e.prependTo(this.headers),i=this.active.children(".ui-accordion-header-icon"),this._removeClass(i,s.header)._addClass(i,null,s.activeHeader)._addClass(this.headers,"ui-accordion-icons"))},_destroyIcons:function(){this._removeClass(this.headers,"ui-accordion-icons"),this.headers.children(".ui-accordion-header-icon").remove()},_destroy:function(){var t;this.element.removeAttr("role"),this.headers.removeAttr("role aria-expanded aria-selected aria-controls tabIndex").removeUniqueId(),this._destroyIcons(),t=this.headers.next().css("display","").removeAttr("role aria-hidden aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&t.css("height","")},_setOption:function(t,e){return"active"===t?(this._activate(e),void 0):("event"===t&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(e)),this._super(t,e),"collapsible"!==t||e||this.options.active!==!1||this._activate(0),"icons"===t&&(this._destroyIcons(),e&&this._createIcons()),void 0)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t),this._toggleClass(null,"ui-state-disabled",!!t),this._toggleClass(this.headers.add(this.headers.next()),null,"ui-state-disabled",!!t)},_keydown:function(e){if(!e.altKey&&!e.ctrlKey){var i=t.ui.keyCode,s=this.headers.length,n=this.headers.index(e.target),o=!1;switch(e.keyCode){case i.RIGHT:case i.DOWN:o=this.headers[(n+1)%s];break;case i.LEFT:case i.UP:o=this.headers[(n-1+s)%s];break;case i.SPACE:case i.ENTER:this._eventHandler(e);break;case i.HOME:o=this.headers[0];break;case i.END:o=this.headers[s-1]}o&&(t(e.target).attr("tabIndex",-1),t(o).attr("tabIndex",0),t(o).trigger("focus"),e.preventDefault())}},_panelKeyDown:function(e){e.keyCode===t.ui.keyCode.UP&&e.ctrlKey&&t(e.currentTarget).prev().trigger("focus")},refresh:function(){var e=this.options;this._processPanels(),e.active===!1&&e.collapsible===!0||!this.headers.length?(e.active=!1,this.active=t()):e.active===!1?this._activate(0):this.active.length&&!t.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(e.active=!1,this.active=t()):this._activate(Math.max(0,e.active-1)):e.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){var t=this.headers,e=this.panels;this.headers=this.element.find(this.options.header),this._addClass(this.headers,"ui-accordion-header ui-accordion-header-collapsed","ui-state-default"),this.panels=this.headers.next().filter(":not(.ui-accordion-content-active)").hide(),this._addClass(this.panels,"ui-accordion-content","ui-helper-reset ui-widget-content"),e&&(this._off(t.not(this.headers)),this._off(e.not(this.panels)))},_refresh:function(){var e,i=this.options,s=i.heightStyle,n=this.element.parent();this.active=this._findActive(i.active),this._addClass(this.active,"ui-accordion-header-active","ui-state-active")._removeClass(this.active,"ui-accordion-header-collapsed"),this._addClass(this.active.next(),"ui-accordion-content-active"),this.active.next().show(),this.headers.attr("role","tab").each(function(){var e=t(this),i=e.uniqueId().attr("id"),s=e.next(),n=s.uniqueId().attr("id");e.attr("aria-controls",n),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(i.event),"fill"===s?(e=n.height(),this.element.siblings(":visible").each(function(){var i=t(this),s=i.css("position");"absolute"!==s&&"fixed"!==s&&(e-=i.outerHeight(!0))}),this.headers.each(function(){e-=t(this).outerHeight(!0)}),this.headers.next().each(function(){t(this).height(Math.max(0,e-t(this).innerHeight()+t(this).height()))}).css("overflow","auto")):"auto"===s&&(e=0,this.headers.next().each(function(){var i=t(this).is(":visible");i||t(this).show(),e=Math.max(e,t(this).css("height","").height()),i||t(this).hide()}).height(e))},_activate:function(e){var i=this._findActive(e)[0];i!==this.active[0]&&(i=i||this.active[0],this._eventHandler({target:i,currentTarget:i,preventDefault:t.noop}))},_findActive:function(e){return"number"==typeof e?this.headers.eq(e):t()},_setupEvents:function(e){var i={keydown:"_keydown"};e&&t.each(e.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(e){var i,s,n=this.options,o=this.active,a=t(e.currentTarget),r=a[0]===o[0],h=r&&n.collapsible,l=h?t():a.next(),c=o.next(),u={oldHeader:o,oldPanel:c,newHeader:h?t():a,newPanel:l};e.preventDefault(),r&&!n.collapsible||this._trigger("beforeActivate",e,u)===!1||(n.active=h?!1:this.headers.index(a),this.active=r?t():a,this._toggle(u),this._removeClass(o,"ui-accordion-header-active","ui-state-active"),n.icons&&(i=o.children(".ui-accordion-header-icon"),this._removeClass(i,null,n.icons.activeHeader)._addClass(i,null,n.icons.header)),r||(this._removeClass(a,"ui-accordion-header-collapsed")._addClass(a,"ui-accordion-header-active","ui-state-active"),n.icons&&(s=a.children(".ui-accordion-header-icon"),this._removeClass(s,null,n.icons.header)._addClass(s,null,n.icons.activeHeader)),this._addClass(a.next(),"ui-accordion-content-active")))},_toggle:function(e){var i=e.newPanel,s=this.prevShow.length?this.prevShow:e.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=i,this.prevHide=s,this.options.animate?this._animate(i,s,e):(s.hide(),i.show(),this._toggleComplete(e)),s.attr({"aria-hidden":"true"}),s.prev().attr({"aria-selected":"false","aria-expanded":"false"}),i.length&&s.length?s.prev().attr({tabIndex:-1,"aria-expanded":"false"}):i.length&&this.headers.filter(function(){return 0===parseInt(t(this).attr("tabIndex"),10)}).attr("tabIndex",-1),i.attr("aria-hidden","false").prev().attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_animate:function(t,e,i){var s,n,o,a=this,r=0,h=t.css("box-sizing"),l=t.length&&(!e.length||t.index()",delay:300,options:{icons:{submenu:"ui-icon-caret-1-e"},items:"> *",menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().attr({role:this.options.role,tabIndex:0}),this._addClass("ui-menu","ui-widget ui-widget-content"),this._on({"mousedown .ui-menu-item":function(t){t.preventDefault()},"click .ui-menu-item":function(e){var i=t(e.target),s=t(t.ui.safeActiveElement(this.document[0]));!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(e),e.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(e):!this.element.is(":focus")&&s.closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(e){if(!this.previousFilter){var i=t(e.target).closest(".ui-menu-item"),s=t(e.currentTarget);i[0]===s[0]&&(this._removeClass(s.siblings().children(".ui-state-active"),null,"ui-state-active"),this.focus(e,s))}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(t,e){var i=this.active||this.element.find(this.options.items).eq(0);e||this.focus(t,i)},blur:function(e){this._delay(function(){var i=!t.contains(this.element[0],t.ui.safeActiveElement(this.document[0]));i&&this.collapseAll(e)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){this._closeOnDocumentClick(t)&&this.collapseAll(t),this.mouseHandled=!1}})},_destroy:function(){var e=this.element.find(".ui-menu-item").removeAttr("role aria-disabled"),i=e.children(".ui-menu-item-wrapper").removeUniqueId().removeAttr("tabIndex role aria-haspopup");this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeAttr("role aria-labelledby aria-expanded aria-hidden aria-disabled tabIndex").removeUniqueId().show(),i.children().each(function(){var e=t(this);e.data("ui-menu-submenu-caret")&&e.remove()})},_keydown:function(e){var i,s,n,o,a=!0;switch(e.keyCode){case t.ui.keyCode.PAGE_UP:this.previousPage(e);break;case t.ui.keyCode.PAGE_DOWN:this.nextPage(e);break;case t.ui.keyCode.HOME:this._move("first","first",e);break;case t.ui.keyCode.END:this._move("last","last",e);break;case t.ui.keyCode.UP:this.previous(e);break;case t.ui.keyCode.DOWN:this.next(e);break;case t.ui.keyCode.LEFT:this.collapse(e);break;case t.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(e);break;case t.ui.keyCode.ENTER:case t.ui.keyCode.SPACE:this._activate(e);break;case t.ui.keyCode.ESCAPE:this.collapse(e);break;default:a=!1,s=this.previousFilter||"",o=!1,n=e.keyCode>=96&&105>=e.keyCode?""+(e.keyCode-96):String.fromCharCode(e.keyCode),clearTimeout(this.filterTimer),n===s?o=!0:n=s+n,i=this._filterMenuItems(n),i=o&&-1!==i.index(this.active.next())?this.active.nextAll(".ui-menu-item"):i,i.length||(n=String.fromCharCode(e.keyCode),i=this._filterMenuItems(n)),i.length?(this.focus(e,i),this.previousFilter=n,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}a&&e.preventDefault()},_activate:function(t){this.active&&!this.active.is(".ui-state-disabled")&&(this.active.children("[aria-haspopup='true']").length?this.expand(t):this.select(t))},refresh:function(){var e,i,s,n,o,a=this,r=this.options.icons.submenu,h=this.element.find(this.options.menus);this._toggleClass("ui-menu-icons",null,!!this.element.find(".ui-icon").length),s=h.filter(":not(.ui-menu)").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var e=t(this),i=e.prev(),s=t("").data("ui-menu-submenu-caret",!0);a._addClass(s,"ui-menu-icon","ui-icon "+r),i.attr("aria-haspopup","true").prepend(s),e.attr("aria-labelledby",i.attr("id"))}),this._addClass(s,"ui-menu","ui-widget ui-widget-content ui-front"),e=h.add(this.element),i=e.find(this.options.items),i.not(".ui-menu-item").each(function(){var e=t(this);a._isDivider(e)&&a._addClass(e,"ui-menu-divider","ui-widget-content")}),n=i.not(".ui-menu-item, .ui-menu-divider"),o=n.children().not(".ui-menu").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),this._addClass(n,"ui-menu-item")._addClass(o,"ui-menu-item-wrapper"),i.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!t.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(t,e){if("icons"===t){var i=this.element.find(".ui-menu-icon");this._removeClass(i,null,this.options.icons.submenu)._addClass(i,null,e.submenu)}this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t+""),this._toggleClass(null,"ui-state-disabled",!!t)},focus:function(t,e){var i,s,n;this.blur(t,t&&"focus"===t.type),this._scrollIntoView(e),this.active=e.first(),s=this.active.children(".ui-menu-item-wrapper"),this._addClass(s,null,"ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),n=this.active.parent().closest(".ui-menu-item").children(".ui-menu-item-wrapper"),this._addClass(n,null,"ui-state-active"),t&&"keydown"===t.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=e.children(".ui-menu"),i.length&&t&&/^mouse/.test(t.type)&&this._startOpening(i),this.activeMenu=e.parent(),this._trigger("focus",t,{item:e})},_scrollIntoView:function(e){var i,s,n,o,a,r;this._hasScroll()&&(i=parseFloat(t.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(t.css(this.activeMenu[0],"paddingTop"))||0,n=e.offset().top-this.activeMenu.offset().top-i-s,o=this.activeMenu.scrollTop(),a=this.activeMenu.height(),r=e.outerHeight(),0>n?this.activeMenu.scrollTop(o+n):n+r>a&&this.activeMenu.scrollTop(o+n-a+r))},blur:function(t,e){e||clearTimeout(this.timer),this.active&&(this._removeClass(this.active.children(".ui-menu-item-wrapper"),null,"ui-state-active"),this._trigger("blur",t,{item:this.active}),this.active=null)},_startOpening:function(t){clearTimeout(this.timer),"true"===t.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(t)},this.delay))},_open:function(e){var i=t.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(e.parents(".ui-menu")).hide().attr("aria-hidden","true"),e.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(e,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:t(e&&e.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(e),this._removeClass(s.find(".ui-state-active"),null,"ui-state-active"),this.activeMenu=s},this.delay)},_close:function(t){t||(t=this.active?this.active.parent():this.element),t.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false")},_closeOnDocumentClick:function(e){return!t(e.target).closest(".ui-menu").length},_isDivider:function(t){return!/[^\-\u2014\u2013\s]/.test(t.text())},collapse:function(t){var e=this.active&&this.active.parent().closest(".ui-menu-item",this.element);e&&e.length&&(this._close(),this.focus(t,e))},expand:function(t){var e=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();e&&e.length&&(this._open(e.parent()),this._delay(function(){this.focus(t,e)}))},next:function(t){this._move("next","first",t)},previous:function(t){this._move("prev","last",t)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(t,e,i){var s;this.active&&(s="first"===t||"last"===t?this.active["first"===t?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[t+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.find(this.options.items)[e]()),this.focus(i,s)},nextPage:function(e){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=t(this),0>i.offset().top-s-n}),this.focus(e,i)):this.focus(e,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())),void 0):(this.next(e),void 0)},previousPage:function(e){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=t(this),i.offset().top-s+n>0}),this.focus(e,i)):this.focus(e,this.activeMenu.find(this.options.items).first())),void 0):(this.next(e),void 0)},_hasScroll:function(){return this.element.outerHeight()",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,i,s,n=this.element[0].nodeName.toLowerCase(),o="textarea"===n,a="input"===n; +this.isMultiLine=o||!a&&this._isContentEditable(this.element),this.valueMethod=this.element[o||a?"val":"text"],this.isNewMenu=!0,this._addClass("ui-autocomplete-input"),this.element.attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return e=!0,s=!0,i=!0,void 0;e=!1,s=!1,i=!1;var o=t.ui.keyCode;switch(n.keyCode){case o.PAGE_UP:e=!0,this._move("previousPage",n);break;case o.PAGE_DOWN:e=!0,this._move("nextPage",n);break;case o.UP:e=!0,this._keyEvent("previous",n);break;case o.DOWN:e=!0,this._keyEvent("next",n);break;case o.ENTER:this.menu.active&&(e=!0,n.preventDefault(),this.menu.select(n));break;case o.TAB:this.menu.active&&this.menu.select(n);break;case o.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(e)return e=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),void 0;if(!i){var n=t.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(t){return s?(s=!1,t.preventDefault(),void 0):(this._searchTimeout(t),void 0)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){return this.cancelBlur?(delete this.cancelBlur,void 0):(clearTimeout(this.searching),this.close(t),this._change(t),void 0)}}),this._initSource(),this.menu=t("
    ").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance"),this._addClass(this.menu.element,"ui-autocomplete","ui-front"),this._on(this.menu.element,{mousedown:function(e){e.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,this.element[0]!==t.ui.safeActiveElement(this.document[0])&&this.element.trigger("focus")})},menufocus:function(e,i){var s,n;return this.isNewMenu&&(this.isNewMenu=!1,e.originalEvent&&/^mouse/.test(e.originalEvent.type))?(this.menu.blur(),this.document.one("mousemove",function(){t(e.target).trigger(e.originalEvent)}),void 0):(n=i.item.data("ui-autocomplete-item"),!1!==this._trigger("focus",e,{item:n})&&e.originalEvent&&/^key/.test(e.originalEvent.type)&&this._value(n.value),s=i.item.attr("aria-label")||n.value,s&&t.trim(s).length&&(this.liveRegion.children().hide(),t("
    ").text(s).appendTo(this.liveRegion)),void 0)},menuselect:function(e,i){var s=i.item.data("ui-autocomplete-item"),n=this.previous;this.element[0]!==t.ui.safeActiveElement(this.document[0])&&(this.element.trigger("focus"),this.previous=n,this._delay(function(){this.previous=n,this.selectedItem=s})),!1!==this._trigger("select",e,{item:s})&&this._value(s.value),this.term=this._value(),this.close(e),this.selectedItem=s}}),this.liveRegion=t("
    ",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).appendTo(this.document[0].body),this._addClass(this.liveRegion,null,"ui-helper-hidden-accessible"),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(t,e){this._super(t,e),"source"===t&&this._initSource(),"appendTo"===t&&this.menu.element.appendTo(this._appendTo()),"disabled"===t&&e&&this.xhr&&this.xhr.abort()},_isEventTargetInWidget:function(e){var i=this.menu.element[0];return e.target===this.element[0]||e.target===i||t.contains(i,e.target)},_closeOnClickOutside:function(t){this._isEventTargetInWidget(t)||this.close()},_appendTo:function(){var e=this.options.appendTo;return e&&(e=e.jquery||e.nodeType?t(e):this.document.find(e).eq(0)),e&&e[0]||(e=this.element.closest(".ui-front, dialog")),e.length||(e=this.document[0].body),e},_initSource:function(){var e,i,s=this;t.isArray(this.options.source)?(e=this.options.source,this.source=function(i,s){s(t.ui.autocomplete.filter(e,i.term))}):"string"==typeof this.options.source?(i=this.options.source,this.source=function(e,n){s.xhr&&s.xhr.abort(),s.xhr=t.ajax({url:i,data:e,dataType:"json",success:function(t){n(t)},error:function(){n([])}})}):this.source=this.options.source},_searchTimeout:function(t){clearTimeout(this.searching),this.searching=this._delay(function(){var e=this.term===this._value(),i=this.menu.element.is(":visible"),s=t.altKey||t.ctrlKey||t.metaKey||t.shiftKey;(!e||e&&!i&&!s)&&(this.selectedItem=null,this.search(null,t))},this.options.delay)},search:function(t,e){return t=null!=t?t:this._value(),this.term=this._value(),t.length").append(t("
    ").text(i.label)).appendTo(e)},_move:function(t,e){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(t)||this.menu.isLastItem()&&/^next/.test(t)?(this.isMultiLine||this._value(this.term),this.menu.blur(),void 0):(this.menu[t](e),void 0):(this.search(null,e),void 0)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(t,e){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(t,e),e.preventDefault())},_isContentEditable:function(t){if(!t.length)return!1;var e=t.prop("contentEditable");return"inherit"===e?this._isContentEditable(t.parent()):"true"===e}}),t.extend(t.ui.autocomplete,{escapeRegex:function(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(e,i){var s=RegExp(t.ui.autocomplete.escapeRegex(i),"i");return t.grep(e,function(t){return s.test(t.label||t.value||t)})}}),t.widget("ui.autocomplete",t.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(t){return t+(t>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(e){var i;this._superApply(arguments),this.options.disabled||this.cancelSearch||(i=e&&e.length?this.options.messages.results(e.length):this.options.messages.noResults,this.liveRegion.children().hide(),t("
    ").text(i).appendTo(this.liveRegion))}}),t.ui.autocomplete;var g=/ui-corner-([a-z]){2,6}/g;t.widget("ui.controlgroup",{version:"1.12.1",defaultElement:"
    ",options:{direction:"horizontal",disabled:null,onlyVisible:!0,items:{button:"input[type=button], input[type=submit], input[type=reset], button, a",controlgroupLabel:".ui-controlgroup-label",checkboxradio:"input[type='checkbox'], input[type='radio']",selectmenu:"select",spinner:".ui-spinner-input"}},_create:function(){this._enhance()},_enhance:function(){this.element.attr("role","toolbar"),this.refresh()},_destroy:function(){this._callChildMethod("destroy"),this.childWidgets.removeData("ui-controlgroup-data"),this.element.removeAttr("role"),this.options.items.controlgroupLabel&&this.element.find(this.options.items.controlgroupLabel).find(".ui-controlgroup-label-contents").contents().unwrap()},_initWidgets:function(){var e=this,i=[];t.each(this.options.items,function(s,n){var o,a={};return n?"controlgroupLabel"===s?(o=e.element.find(n),o.each(function(){var e=t(this);e.children(".ui-controlgroup-label-contents").length||e.contents().wrapAll("")}),e._addClass(o,null,"ui-widget ui-widget-content ui-state-default"),i=i.concat(o.get()),void 0):(t.fn[s]&&(a=e["_"+s+"Options"]?e["_"+s+"Options"]("middle"):{classes:{}},e.element.find(n).each(function(){var n=t(this),o=n[s]("instance"),r=t.widget.extend({},a);if("button"!==s||!n.parent(".ui-spinner").length){o||(o=n[s]()[s]("instance")),o&&(r.classes=e._resolveClassesValues(r.classes,o)),n[s](r);var h=n[s]("widget");t.data(h[0],"ui-controlgroup-data",o?o:n[s]("instance")),i.push(h[0])}})),void 0):void 0}),this.childWidgets=t(t.unique(i)),this._addClass(this.childWidgets,"ui-controlgroup-item")},_callChildMethod:function(e){this.childWidgets.each(function(){var i=t(this),s=i.data("ui-controlgroup-data");s&&s[e]&&s[e]()})},_updateCornerClass:function(t,e){var i="ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all",s=this._buildSimpleOptions(e,"label").classes.label;this._removeClass(t,null,i),this._addClass(t,null,s)},_buildSimpleOptions:function(t,e){var i="vertical"===this.options.direction,s={classes:{}};return s.classes[e]={middle:"",first:"ui-corner-"+(i?"top":"left"),last:"ui-corner-"+(i?"bottom":"right"),only:"ui-corner-all"}[t],s},_spinnerOptions:function(t){var e=this._buildSimpleOptions(t,"ui-spinner");return e.classes["ui-spinner-up"]="",e.classes["ui-spinner-down"]="",e},_buttonOptions:function(t){return this._buildSimpleOptions(t,"ui-button")},_checkboxradioOptions:function(t){return this._buildSimpleOptions(t,"ui-checkboxradio-label")},_selectmenuOptions:function(t){var e="vertical"===this.options.direction;return{width:e?"auto":!1,classes:{middle:{"ui-selectmenu-button-open":"","ui-selectmenu-button-closed":""},first:{"ui-selectmenu-button-open":"ui-corner-"+(e?"top":"tl"),"ui-selectmenu-button-closed":"ui-corner-"+(e?"top":"left")},last:{"ui-selectmenu-button-open":e?"":"ui-corner-tr","ui-selectmenu-button-closed":"ui-corner-"+(e?"bottom":"right")},only:{"ui-selectmenu-button-open":"ui-corner-top","ui-selectmenu-button-closed":"ui-corner-all"}}[t]}},_resolveClassesValues:function(e,i){var s={};return t.each(e,function(n){var o=i.options.classes[n]||"";o=t.trim(o.replace(g,"")),s[n]=(o+" "+e[n]).replace(/\s+/g," ")}),s},_setOption:function(t,e){return"direction"===t&&this._removeClass("ui-controlgroup-"+this.options.direction),this._super(t,e),"disabled"===t?(this._callChildMethod(e?"disable":"enable"),void 0):(this.refresh(),void 0)},refresh:function(){var e,i=this;this._addClass("ui-controlgroup ui-controlgroup-"+this.options.direction),"horizontal"===this.options.direction&&this._addClass(null,"ui-helper-clearfix"),this._initWidgets(),e=this.childWidgets,this.options.onlyVisible&&(e=e.filter(":visible")),e.length&&(t.each(["first","last"],function(t,s){var n=e[s]().data("ui-controlgroup-data");if(n&&i["_"+n.widgetName+"Options"]){var o=i["_"+n.widgetName+"Options"](1===e.length?"only":s);o.classes=i._resolveClassesValues(o.classes,n),n.element[n.widgetName](o)}else i._updateCornerClass(e[s](),s)}),this._callChildMethod("refresh"))}}),t.widget("ui.checkboxradio",[t.ui.formResetMixin,{version:"1.12.1",options:{disabled:null,label:null,icon:!0,classes:{"ui-checkboxradio-label":"ui-corner-all","ui-checkboxradio-icon":"ui-corner-all"}},_getCreateOptions:function(){var e,i,s=this,n=this._super()||{};return this._readType(),i=this.element.labels(),this.label=t(i[i.length-1]),this.label.length||t.error("No label found for checkboxradio widget"),this.originalLabel="",this.label.contents().not(this.element[0]).each(function(){s.originalLabel+=3===this.nodeType?t(this).text():this.outerHTML}),this.originalLabel&&(n.label=this.originalLabel),e=this.element[0].disabled,null!=e&&(n.disabled=e),n},_create:function(){var t=this.element[0].checked;this._bindFormResetHandler(),null==this.options.disabled&&(this.options.disabled=this.element[0].disabled),this._setOption("disabled",this.options.disabled),this._addClass("ui-checkboxradio","ui-helper-hidden-accessible"),this._addClass(this.label,"ui-checkboxradio-label","ui-button ui-widget"),"radio"===this.type&&this._addClass(this.label,"ui-checkboxradio-radio-label"),this.options.label&&this.options.label!==this.originalLabel?this._updateLabel():this.originalLabel&&(this.options.label=this.originalLabel),this._enhance(),t&&(this._addClass(this.label,"ui-checkboxradio-checked","ui-state-active"),this.icon&&this._addClass(this.icon,null,"ui-state-hover")),this._on({change:"_toggleClasses",focus:function(){this._addClass(this.label,null,"ui-state-focus ui-visual-focus")},blur:function(){this._removeClass(this.label,null,"ui-state-focus ui-visual-focus")}})},_readType:function(){var e=this.element[0].nodeName.toLowerCase();this.type=this.element[0].type,"input"===e&&/radio|checkbox/.test(this.type)||t.error("Can't create checkboxradio on element.nodeName="+e+" and element.type="+this.type)},_enhance:function(){this._updateIcon(this.element[0].checked)},widget:function(){return this.label},_getRadioGroup:function(){var e,i=this.element[0].name,s="input[name='"+t.ui.escapeSelector(i)+"']";return i?(e=this.form.length?t(this.form[0].elements).filter(s):t(s).filter(function(){return 0===t(this).form().length}),e.not(this.element)):t([])},_toggleClasses:function(){var e=this.element[0].checked;this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",e),this.options.icon&&"checkbox"===this.type&&this._toggleClass(this.icon,null,"ui-icon-check ui-state-checked",e)._toggleClass(this.icon,null,"ui-icon-blank",!e),"radio"===this.type&&this._getRadioGroup().each(function(){var e=t(this).checkboxradio("instance");e&&e._removeClass(e.label,"ui-checkboxradio-checked","ui-state-active")})},_destroy:function(){this._unbindFormResetHandler(),this.icon&&(this.icon.remove(),this.iconSpace.remove())},_setOption:function(t,e){return"label"!==t||e?(this._super(t,e),"disabled"===t?(this._toggleClass(this.label,null,"ui-state-disabled",e),this.element[0].disabled=e,void 0):(this.refresh(),void 0)):void 0},_updateIcon:function(e){var i="ui-icon ui-icon-background ";this.options.icon?(this.icon||(this.icon=t(""),this.iconSpace=t(" "),this._addClass(this.iconSpace,"ui-checkboxradio-icon-space")),"checkbox"===this.type?(i+=e?"ui-icon-check ui-state-checked":"ui-icon-blank",this._removeClass(this.icon,null,e?"ui-icon-blank":"ui-icon-check")):i+="ui-icon-blank",this._addClass(this.icon,"ui-checkboxradio-icon",i),e||this._removeClass(this.icon,null,"ui-icon-check ui-state-checked"),this.icon.prependTo(this.label).after(this.iconSpace)):void 0!==this.icon&&(this.icon.remove(),this.iconSpace.remove(),delete this.icon)},_updateLabel:function(){var t=this.label.contents().not(this.element[0]);this.icon&&(t=t.not(this.icon[0])),this.iconSpace&&(t=t.not(this.iconSpace[0])),t.remove(),this.label.append(this.options.label)},refresh:function(){var t=this.element[0].checked,e=this.element[0].disabled;this._updateIcon(t),this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",t),null!==this.options.label&&this._updateLabel(),e!==this.options.disabled&&this._setOptions({disabled:e})}}]),t.ui.checkboxradio,t.widget("ui.button",{version:"1.12.1",defaultElement:"").addClass(this._triggerClass).html(o?t("").attr({src:o,alt:n,title:n}):n)),e[r?"before":"after"](i.trigger),i.trigger.on("click",function(){return t.datepicker._datepickerShowing&&t.datepicker._lastInput===e[0]?t.datepicker._hideDatepicker():t.datepicker._datepickerShowing&&t.datepicker._lastInput!==e[0]?(t.datepicker._hideDatepicker(),t.datepicker._showDatepicker(e[0])):t.datepicker._showDatepicker(e[0]),!1}))},_autoSize:function(t){if(this._get(t,"autoSize")&&!t.inline){var e,i,s,n,o=new Date(2009,11,20),a=this._get(t,"dateFormat");a.match(/[DM]/)&&(e=function(t){for(i=0,s=0,n=0;t.length>n;n++)t[n].length>i&&(i=t[n].length,s=n);return s},o.setMonth(e(this._get(t,a.match(/MM/)?"monthNames":"monthNamesShort"))),o.setDate(e(this._get(t,a.match(/DD/)?"dayNames":"dayNamesShort"))+20-o.getDay())),t.input.attr("size",this._formatDate(t,o).length)}},_inlineDatepicker:function(e,i){var s=t(e);s.hasClass(this.markerClassName)||(s.addClass(this.markerClassName).append(i.dpDiv),t.data(e,"datepicker",i),this._setDate(i,this._getDefaultDate(i),!0),this._updateDatepicker(i),this._updateAlternate(i),i.settings.disabled&&this._disableDatepicker(e),i.dpDiv.css("display","block"))},_dialogDatepicker:function(e,i,s,n,o){var r,h,l,c,u,d=this._dialogInst;return d||(this.uuid+=1,r="dp"+this.uuid,this._dialogInput=t(""),this._dialogInput.on("keydown",this._doKeyDown),t("body").append(this._dialogInput),d=this._dialogInst=this._newInst(this._dialogInput,!1),d.settings={},t.data(this._dialogInput[0],"datepicker",d)),a(d.settings,n||{}),i=i&&i.constructor===Date?this._formatDate(d,i):i,this._dialogInput.val(i),this._pos=o?o.length?o:[o.pageX,o.pageY]:null,this._pos||(h=document.documentElement.clientWidth,l=document.documentElement.clientHeight,c=document.documentElement.scrollLeft||document.body.scrollLeft,u=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[h/2-100+c,l/2-150+u]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),d.settings.onSelect=s,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),t.blockUI&&t.blockUI(this.dpDiv),t.data(this._dialogInput[0],"datepicker",d),this},_destroyDatepicker:function(e){var i,s=t(e),n=t.data(e,"datepicker");s.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),t.removeData(e,"datepicker"),"input"===i?(n.append.remove(),n.trigger.remove(),s.removeClass(this.markerClassName).off("focus",this._showDatepicker).off("keydown",this._doKeyDown).off("keypress",this._doKeyPress).off("keyup",this._doKeyUp)):("div"===i||"span"===i)&&s.removeClass(this.markerClassName).empty(),m===n&&(m=null))},_enableDatepicker:function(e){var i,s,n=t(e),o=t.data(e,"datepicker");n.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),"input"===i?(e.disabled=!1,o.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().removeClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=t.map(this._disabledInputs,function(t){return t===e?null:t}))},_disableDatepicker:function(e){var i,s,n=t(e),o=t.data(e,"datepicker");n.hasClass(this.markerClassName)&&(i=e.nodeName.toLowerCase(),"input"===i?(e.disabled=!0,o.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().addClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=t.map(this._disabledInputs,function(t){return t===e?null:t}),this._disabledInputs[this._disabledInputs.length]=e)},_isDisabledDatepicker:function(t){if(!t)return!1;for(var e=0;this._disabledInputs.length>e;e++)if(this._disabledInputs[e]===t)return!0;return!1},_getInst:function(e){try{return t.data(e,"datepicker")}catch(i){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(e,i,s){var n,o,r,h,l=this._getInst(e);return 2===arguments.length&&"string"==typeof i?"defaults"===i?t.extend({},t.datepicker._defaults):l?"all"===i?t.extend({},l.settings):this._get(l,i):null:(n=i||{},"string"==typeof i&&(n={},n[i]=s),l&&(this._curInst===l&&this._hideDatepicker(),o=this._getDateDatepicker(e,!0),r=this._getMinMaxDate(l,"min"),h=this._getMinMaxDate(l,"max"),a(l.settings,n),null!==r&&void 0!==n.dateFormat&&void 0===n.minDate&&(l.settings.minDate=this._formatDate(l,r)),null!==h&&void 0!==n.dateFormat&&void 0===n.maxDate&&(l.settings.maxDate=this._formatDate(l,h)),"disabled"in n&&(n.disabled?this._disableDatepicker(e):this._enableDatepicker(e)),this._attachments(t(e),l),this._autoSize(l),this._setDate(l,o),this._updateAlternate(l),this._updateDatepicker(l)),void 0)},_changeDatepicker:function(t,e,i){this._optionDatepicker(t,e,i)},_refreshDatepicker:function(t){var e=this._getInst(t);e&&this._updateDatepicker(e)},_setDateDatepicker:function(t,e){var i=this._getInst(t);i&&(this._setDate(i,e),this._updateDatepicker(i),this._updateAlternate(i))},_getDateDatepicker:function(t,e){var i=this._getInst(t);return i&&!i.inline&&this._setDateFromField(i,e),i?this._getDate(i):null},_doKeyDown:function(e){var i,s,n,o=t.datepicker._getInst(e.target),a=!0,r=o.dpDiv.is(".ui-datepicker-rtl");if(o._keyEvent=!0,t.datepicker._datepickerShowing)switch(e.keyCode){case 9:t.datepicker._hideDatepicker(),a=!1;break;case 13:return n=t("td."+t.datepicker._dayOverClass+":not(."+t.datepicker._currentClass+")",o.dpDiv),n[0]&&t.datepicker._selectDay(e.target,o.selectedMonth,o.selectedYear,n[0]),i=t.datepicker._get(o,"onSelect"),i?(s=t.datepicker._formatDate(o),i.apply(o.input?o.input[0]:null,[s,o])):t.datepicker._hideDatepicker(),!1;case 27:t.datepicker._hideDatepicker();break;case 33:t.datepicker._adjustDate(e.target,e.ctrlKey?-t.datepicker._get(o,"stepBigMonths"):-t.datepicker._get(o,"stepMonths"),"M");break;case 34:t.datepicker._adjustDate(e.target,e.ctrlKey?+t.datepicker._get(o,"stepBigMonths"):+t.datepicker._get(o,"stepMonths"),"M");break;case 35:(e.ctrlKey||e.metaKey)&&t.datepicker._clearDate(e.target),a=e.ctrlKey||e.metaKey;break;case 36:(e.ctrlKey||e.metaKey)&&t.datepicker._gotoToday(e.target),a=e.ctrlKey||e.metaKey;break;case 37:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,r?1:-1,"D"),a=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&t.datepicker._adjustDate(e.target,e.ctrlKey?-t.datepicker._get(o,"stepBigMonths"):-t.datepicker._get(o,"stepMonths"),"M");break;case 38:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,-7,"D"),a=e.ctrlKey||e.metaKey;break;case 39:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,r?-1:1,"D"),a=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&t.datepicker._adjustDate(e.target,e.ctrlKey?+t.datepicker._get(o,"stepBigMonths"):+t.datepicker._get(o,"stepMonths"),"M");break;case 40:(e.ctrlKey||e.metaKey)&&t.datepicker._adjustDate(e.target,7,"D"),a=e.ctrlKey||e.metaKey;break;default:a=!1}else 36===e.keyCode&&e.ctrlKey?t.datepicker._showDatepicker(this):a=!1;a&&(e.preventDefault(),e.stopPropagation())},_doKeyPress:function(e){var i,s,n=t.datepicker._getInst(e.target);return t.datepicker._get(n,"constrainInput")?(i=t.datepicker._possibleChars(t.datepicker._get(n,"dateFormat")),s=String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),e.ctrlKey||e.metaKey||" ">s||!i||i.indexOf(s)>-1):void 0},_doKeyUp:function(e){var i,s=t.datepicker._getInst(e.target);if(s.input.val()!==s.lastVal)try{i=t.datepicker.parseDate(t.datepicker._get(s,"dateFormat"),s.input?s.input.val():null,t.datepicker._getFormatConfig(s)),i&&(t.datepicker._setDateFromField(s),t.datepicker._updateAlternate(s),t.datepicker._updateDatepicker(s))}catch(n){}return!0},_showDatepicker:function(e){if(e=e.target||e,"input"!==e.nodeName.toLowerCase()&&(e=t("input",e.parentNode)[0]),!t.datepicker._isDisabledDatepicker(e)&&t.datepicker._lastInput!==e){var s,n,o,r,h,l,c;s=t.datepicker._getInst(e),t.datepicker._curInst&&t.datepicker._curInst!==s&&(t.datepicker._curInst.dpDiv.stop(!0,!0),s&&t.datepicker._datepickerShowing&&t.datepicker._hideDatepicker(t.datepicker._curInst.input[0])),n=t.datepicker._get(s,"beforeShow"),o=n?n.apply(e,[e,s]):{},o!==!1&&(a(s.settings,o),s.lastVal=null,t.datepicker._lastInput=e,t.datepicker._setDateFromField(s),t.datepicker._inDialog&&(e.value=""),t.datepicker._pos||(t.datepicker._pos=t.datepicker._findPos(e),t.datepicker._pos[1]+=e.offsetHeight),r=!1,t(e).parents().each(function(){return r|="fixed"===t(this).css("position"),!r}),h={left:t.datepicker._pos[0],top:t.datepicker._pos[1]},t.datepicker._pos=null,s.dpDiv.empty(),s.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),t.datepicker._updateDatepicker(s),h=t.datepicker._checkOffset(s,h,r),s.dpDiv.css({position:t.datepicker._inDialog&&t.blockUI?"static":r?"fixed":"absolute",display:"none",left:h.left+"px",top:h.top+"px"}),s.inline||(l=t.datepicker._get(s,"showAnim"),c=t.datepicker._get(s,"duration"),s.dpDiv.css("z-index",i(t(e))+1),t.datepicker._datepickerShowing=!0,t.effects&&t.effects.effect[l]?s.dpDiv.show(l,t.datepicker._get(s,"showOptions"),c):s.dpDiv[l||"show"](l?c:null),t.datepicker._shouldFocusInput(s)&&s.input.trigger("focus"),t.datepicker._curInst=s)) +}},_updateDatepicker:function(e){this.maxRows=4,m=e,e.dpDiv.empty().append(this._generateHTML(e)),this._attachHandlers(e);var i,s=this._getNumberOfMonths(e),n=s[1],a=17,r=e.dpDiv.find("."+this._dayOverClass+" a");r.length>0&&o.apply(r.get(0)),e.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),n>1&&e.dpDiv.addClass("ui-datepicker-multi-"+n).css("width",a*n+"em"),e.dpDiv[(1!==s[0]||1!==s[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),e.dpDiv[(this._get(e,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),e===t.datepicker._curInst&&t.datepicker._datepickerShowing&&t.datepicker._shouldFocusInput(e)&&e.input.trigger("focus"),e.yearshtml&&(i=e.yearshtml,setTimeout(function(){i===e.yearshtml&&e.yearshtml&&e.dpDiv.find("select.ui-datepicker-year:first").replaceWith(e.yearshtml),i=e.yearshtml=null},0))},_shouldFocusInput:function(t){return t.input&&t.input.is(":visible")&&!t.input.is(":disabled")&&!t.input.is(":focus")},_checkOffset:function(e,i,s){var n=e.dpDiv.outerWidth(),o=e.dpDiv.outerHeight(),a=e.input?e.input.outerWidth():0,r=e.input?e.input.outerHeight():0,h=document.documentElement.clientWidth+(s?0:t(document).scrollLeft()),l=document.documentElement.clientHeight+(s?0:t(document).scrollTop());return i.left-=this._get(e,"isRTL")?n-a:0,i.left-=s&&i.left===e.input.offset().left?t(document).scrollLeft():0,i.top-=s&&i.top===e.input.offset().top+r?t(document).scrollTop():0,i.left-=Math.min(i.left,i.left+n>h&&h>n?Math.abs(i.left+n-h):0),i.top-=Math.min(i.top,i.top+o>l&&l>o?Math.abs(o+r):0),i},_findPos:function(e){for(var i,s=this._getInst(e),n=this._get(s,"isRTL");e&&("hidden"===e.type||1!==e.nodeType||t.expr.filters.hidden(e));)e=e[n?"previousSibling":"nextSibling"];return i=t(e).offset(),[i.left,i.top]},_hideDatepicker:function(e){var i,s,n,o,a=this._curInst;!a||e&&a!==t.data(e,"datepicker")||this._datepickerShowing&&(i=this._get(a,"showAnim"),s=this._get(a,"duration"),n=function(){t.datepicker._tidyDialog(a)},t.effects&&(t.effects.effect[i]||t.effects[i])?a.dpDiv.hide(i,t.datepicker._get(a,"showOptions"),s,n):a.dpDiv["slideDown"===i?"slideUp":"fadeIn"===i?"fadeOut":"hide"](i?s:null,n),i||n(),this._datepickerShowing=!1,o=this._get(a,"onClose"),o&&o.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),t.blockUI&&(t.unblockUI(),t("body").append(this.dpDiv))),this._inDialog=!1)},_tidyDialog:function(t){t.dpDiv.removeClass(this._dialogClass).off(".ui-datepicker-calendar")},_checkExternalClick:function(e){if(t.datepicker._curInst){var i=t(e.target),s=t.datepicker._getInst(i[0]);(i[0].id!==t.datepicker._mainDivId&&0===i.parents("#"+t.datepicker._mainDivId).length&&!i.hasClass(t.datepicker.markerClassName)&&!i.closest("."+t.datepicker._triggerClass).length&&t.datepicker._datepickerShowing&&(!t.datepicker._inDialog||!t.blockUI)||i.hasClass(t.datepicker.markerClassName)&&t.datepicker._curInst!==s)&&t.datepicker._hideDatepicker()}},_adjustDate:function(e,i,s){var n=t(e),o=this._getInst(n[0]);this._isDisabledDatepicker(n[0])||(this._adjustInstDate(o,i+("M"===s?this._get(o,"showCurrentAtPos"):0),s),this._updateDatepicker(o))},_gotoToday:function(e){var i,s=t(e),n=this._getInst(s[0]);this._get(n,"gotoCurrent")&&n.currentDay?(n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear):(i=new Date,n.selectedDay=i.getDate(),n.drawMonth=n.selectedMonth=i.getMonth(),n.drawYear=n.selectedYear=i.getFullYear()),this._notifyChange(n),this._adjustDate(s)},_selectMonthYear:function(e,i,s){var n=t(e),o=this._getInst(n[0]);o["selected"+("M"===s?"Month":"Year")]=o["draw"+("M"===s?"Month":"Year")]=parseInt(i.options[i.selectedIndex].value,10),this._notifyChange(o),this._adjustDate(n)},_selectDay:function(e,i,s,n){var o,a=t(e);t(n).hasClass(this._unselectableClass)||this._isDisabledDatepicker(a[0])||(o=this._getInst(a[0]),o.selectedDay=o.currentDay=t("a",n).html(),o.selectedMonth=o.currentMonth=i,o.selectedYear=o.currentYear=s,this._selectDate(e,this._formatDate(o,o.currentDay,o.currentMonth,o.currentYear)))},_clearDate:function(e){var i=t(e);this._selectDate(i,"")},_selectDate:function(e,i){var s,n=t(e),o=this._getInst(n[0]);i=null!=i?i:this._formatDate(o),o.input&&o.input.val(i),this._updateAlternate(o),s=this._get(o,"onSelect"),s?s.apply(o.input?o.input[0]:null,[i,o]):o.input&&o.input.trigger("change"),o.inline?this._updateDatepicker(o):(this._hideDatepicker(),this._lastInput=o.input[0],"object"!=typeof o.input[0]&&o.input.trigger("focus"),this._lastInput=null)},_updateAlternate:function(e){var i,s,n,o=this._get(e,"altField");o&&(i=this._get(e,"altFormat")||this._get(e,"dateFormat"),s=this._getDate(e),n=this.formatDate(i,s,this._getFormatConfig(e)),t(o).val(n))},noWeekends:function(t){var e=t.getDay();return[e>0&&6>e,""]},iso8601Week:function(t){var e,i=new Date(t.getTime());return i.setDate(i.getDate()+4-(i.getDay()||7)),e=i.getTime(),i.setMonth(0),i.setDate(1),Math.floor(Math.round((e-i)/864e5)/7)+1},parseDate:function(e,i,s){if(null==e||null==i)throw"Invalid arguments";if(i="object"==typeof i?""+i:i+"",""===i)return null;var n,o,a,r,h=0,l=(s?s.shortYearCutoff:null)||this._defaults.shortYearCutoff,c="string"!=typeof l?l:(new Date).getFullYear()%100+parseInt(l,10),u=(s?s.dayNamesShort:null)||this._defaults.dayNamesShort,d=(s?s.dayNames:null)||this._defaults.dayNames,p=(s?s.monthNamesShort:null)||this._defaults.monthNamesShort,f=(s?s.monthNames:null)||this._defaults.monthNames,g=-1,m=-1,_=-1,v=-1,b=!1,y=function(t){var i=e.length>n+1&&e.charAt(n+1)===t;return i&&n++,i},w=function(t){var e=y(t),s="@"===t?14:"!"===t?20:"y"===t&&e?4:"o"===t?3:2,n="y"===t?s:1,o=RegExp("^\\d{"+n+","+s+"}"),a=i.substring(h).match(o);if(!a)throw"Missing number at position "+h;return h+=a[0].length,parseInt(a[0],10)},k=function(e,s,n){var o=-1,a=t.map(y(e)?n:s,function(t,e){return[[e,t]]}).sort(function(t,e){return-(t[1].length-e[1].length)});if(t.each(a,function(t,e){var s=e[1];return i.substr(h,s.length).toLowerCase()===s.toLowerCase()?(o=e[0],h+=s.length,!1):void 0}),-1!==o)return o+1;throw"Unknown name at position "+h},x=function(){if(i.charAt(h)!==e.charAt(n))throw"Unexpected literal at position "+h;h++};for(n=0;e.length>n;n++)if(b)"'"!==e.charAt(n)||y("'")?x():b=!1;else switch(e.charAt(n)){case"d":_=w("d");break;case"D":k("D",u,d);break;case"o":v=w("o");break;case"m":m=w("m");break;case"M":m=k("M",p,f);break;case"y":g=w("y");break;case"@":r=new Date(w("@")),g=r.getFullYear(),m=r.getMonth()+1,_=r.getDate();break;case"!":r=new Date((w("!")-this._ticksTo1970)/1e4),g=r.getFullYear(),m=r.getMonth()+1,_=r.getDate();break;case"'":y("'")?x():b=!0;break;default:x()}if(i.length>h&&(a=i.substr(h),!/^\s+/.test(a)))throw"Extra/unparsed characters found in date: "+a;if(-1===g?g=(new Date).getFullYear():100>g&&(g+=(new Date).getFullYear()-(new Date).getFullYear()%100+(c>=g?0:-100)),v>-1)for(m=1,_=v;;){if(o=this._getDaysInMonth(g,m-1),o>=_)break;m++,_-=o}if(r=this._daylightSavingAdjust(new Date(g,m-1,_)),r.getFullYear()!==g||r.getMonth()+1!==m||r.getDate()!==_)throw"Invalid date";return r},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:1e7*60*60*24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925)),formatDate:function(t,e,i){if(!e)return"";var s,n=(i?i.dayNamesShort:null)||this._defaults.dayNamesShort,o=(i?i.dayNames:null)||this._defaults.dayNames,a=(i?i.monthNamesShort:null)||this._defaults.monthNamesShort,r=(i?i.monthNames:null)||this._defaults.monthNames,h=function(e){var i=t.length>s+1&&t.charAt(s+1)===e;return i&&s++,i},l=function(t,e,i){var s=""+e;if(h(t))for(;i>s.length;)s="0"+s;return s},c=function(t,e,i,s){return h(t)?s[e]:i[e]},u="",d=!1;if(e)for(s=0;t.length>s;s++)if(d)"'"!==t.charAt(s)||h("'")?u+=t.charAt(s):d=!1;else switch(t.charAt(s)){case"d":u+=l("d",e.getDate(),2);break;case"D":u+=c("D",e.getDay(),n,o);break;case"o":u+=l("o",Math.round((new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-new Date(e.getFullYear(),0,0).getTime())/864e5),3);break;case"m":u+=l("m",e.getMonth()+1,2);break;case"M":u+=c("M",e.getMonth(),a,r);break;case"y":u+=h("y")?e.getFullYear():(10>e.getFullYear()%100?"0":"")+e.getFullYear()%100;break;case"@":u+=e.getTime();break;case"!":u+=1e4*e.getTime()+this._ticksTo1970;break;case"'":h("'")?u+="'":d=!0;break;default:u+=t.charAt(s)}return u},_possibleChars:function(t){var e,i="",s=!1,n=function(i){var s=t.length>e+1&&t.charAt(e+1)===i;return s&&e++,s};for(e=0;t.length>e;e++)if(s)"'"!==t.charAt(e)||n("'")?i+=t.charAt(e):s=!1;else switch(t.charAt(e)){case"d":case"m":case"y":case"@":i+="0123456789";break;case"D":case"M":return null;case"'":n("'")?i+="'":s=!0;break;default:i+=t.charAt(e)}return i},_get:function(t,e){return void 0!==t.settings[e]?t.settings[e]:this._defaults[e]},_setDateFromField:function(t,e){if(t.input.val()!==t.lastVal){var i=this._get(t,"dateFormat"),s=t.lastVal=t.input?t.input.val():null,n=this._getDefaultDate(t),o=n,a=this._getFormatConfig(t);try{o=this.parseDate(i,s,a)||n}catch(r){s=e?"":s}t.selectedDay=o.getDate(),t.drawMonth=t.selectedMonth=o.getMonth(),t.drawYear=t.selectedYear=o.getFullYear(),t.currentDay=s?o.getDate():0,t.currentMonth=s?o.getMonth():0,t.currentYear=s?o.getFullYear():0,this._adjustInstDate(t)}},_getDefaultDate:function(t){return this._restrictMinMax(t,this._determineDate(t,this._get(t,"defaultDate"),new Date))},_determineDate:function(e,i,s){var n=function(t){var e=new Date;return e.setDate(e.getDate()+t),e},o=function(i){try{return t.datepicker.parseDate(t.datepicker._get(e,"dateFormat"),i,t.datepicker._getFormatConfig(e))}catch(s){}for(var n=(i.toLowerCase().match(/^c/)?t.datepicker._getDate(e):null)||new Date,o=n.getFullYear(),a=n.getMonth(),r=n.getDate(),h=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,l=h.exec(i);l;){switch(l[2]||"d"){case"d":case"D":r+=parseInt(l[1],10);break;case"w":case"W":r+=7*parseInt(l[1],10);break;case"m":case"M":a+=parseInt(l[1],10),r=Math.min(r,t.datepicker._getDaysInMonth(o,a));break;case"y":case"Y":o+=parseInt(l[1],10),r=Math.min(r,t.datepicker._getDaysInMonth(o,a))}l=h.exec(i)}return new Date(o,a,r)},a=null==i||""===i?s:"string"==typeof i?o(i):"number"==typeof i?isNaN(i)?s:n(i):new Date(i.getTime());return a=a&&"Invalid Date"==""+a?s:a,a&&(a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0)),this._daylightSavingAdjust(a)},_daylightSavingAdjust:function(t){return t?(t.setHours(t.getHours()>12?t.getHours()+2:0),t):null},_setDate:function(t,e,i){var s=!e,n=t.selectedMonth,o=t.selectedYear,a=this._restrictMinMax(t,this._determineDate(t,e,new Date));t.selectedDay=t.currentDay=a.getDate(),t.drawMonth=t.selectedMonth=t.currentMonth=a.getMonth(),t.drawYear=t.selectedYear=t.currentYear=a.getFullYear(),n===t.selectedMonth&&o===t.selectedYear||i||this._notifyChange(t),this._adjustInstDate(t),t.input&&t.input.val(s?"":this._formatDate(t))},_getDate:function(t){var e=!t.currentYear||t.input&&""===t.input.val()?null:this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay));return e},_attachHandlers:function(e){var i=this._get(e,"stepMonths"),s="#"+e.id.replace(/\\\\/g,"\\");e.dpDiv.find("[data-handler]").map(function(){var e={prev:function(){t.datepicker._adjustDate(s,-i,"M")},next:function(){t.datepicker._adjustDate(s,+i,"M")},hide:function(){t.datepicker._hideDatepicker()},today:function(){t.datepicker._gotoToday(s)},selectDay:function(){return t.datepicker._selectDay(s,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return t.datepicker._selectMonthYear(s,this,"M"),!1},selectYear:function(){return t.datepicker._selectMonthYear(s,this,"Y"),!1}};t(this).on(this.getAttribute("data-event"),e[this.getAttribute("data-handler")])})},_generateHTML:function(t){var e,i,s,n,o,a,r,h,l,c,u,d,p,f,g,m,_,v,b,y,w,k,x,C,D,I,T,P,M,S,H,z,O,A,N,W,E,F,L,R=new Date,B=this._daylightSavingAdjust(new Date(R.getFullYear(),R.getMonth(),R.getDate())),Y=this._get(t,"isRTL"),j=this._get(t,"showButtonPanel"),q=this._get(t,"hideIfNoPrevNext"),K=this._get(t,"navigationAsDateFormat"),U=this._getNumberOfMonths(t),V=this._get(t,"showCurrentAtPos"),$=this._get(t,"stepMonths"),X=1!==U[0]||1!==U[1],G=this._daylightSavingAdjust(t.currentDay?new Date(t.currentYear,t.currentMonth,t.currentDay):new Date(9999,9,9)),Q=this._getMinMaxDate(t,"min"),J=this._getMinMaxDate(t,"max"),Z=t.drawMonth-V,te=t.drawYear;if(0>Z&&(Z+=12,te--),J)for(e=this._daylightSavingAdjust(new Date(J.getFullYear(),J.getMonth()-U[0]*U[1]+1,J.getDate())),e=Q&&Q>e?Q:e;this._daylightSavingAdjust(new Date(te,Z,1))>e;)Z--,0>Z&&(Z=11,te--);for(t.drawMonth=Z,t.drawYear=te,i=this._get(t,"prevText"),i=K?this.formatDate(i,this._daylightSavingAdjust(new Date(te,Z-$,1)),this._getFormatConfig(t)):i,s=this._canAdjustMonth(t,-1,te,Z)?""+i+"":q?"":""+i+"",n=this._get(t,"nextText"),n=K?this.formatDate(n,this._daylightSavingAdjust(new Date(te,Z+$,1)),this._getFormatConfig(t)):n,o=this._canAdjustMonth(t,1,te,Z)?""+n+"":q?"":""+n+"",a=this._get(t,"currentText"),r=this._get(t,"gotoCurrent")&&t.currentDay?G:B,a=K?this.formatDate(a,r,this._getFormatConfig(t)):a,h=t.inline?"":"",l=j?"
    "+(Y?h:"")+(this._isInRange(t,r)?"":"")+(Y?"":h)+"
    ":"",c=parseInt(this._get(t,"firstDay"),10),c=isNaN(c)?0:c,u=this._get(t,"showWeek"),d=this._get(t,"dayNames"),p=this._get(t,"dayNamesMin"),f=this._get(t,"monthNames"),g=this._get(t,"monthNamesShort"),m=this._get(t,"beforeShowDay"),_=this._get(t,"showOtherMonths"),v=this._get(t,"selectOtherMonths"),b=this._getDefaultDate(t),y="",k=0;U[0]>k;k++){for(x="",this.maxRows=4,C=0;U[1]>C;C++){if(D=this._daylightSavingAdjust(new Date(te,Z,t.selectedDay)),I=" ui-corner-all",T="",X){if(T+="
    "}for(T+="
    "+(/all|left/.test(I)&&0===k?Y?o:s:"")+(/all|right/.test(I)&&0===k?Y?s:o:"")+this._generateMonthYearHeader(t,Z,te,Q,J,k>0||C>0,f,g)+"
    "+"",P=u?"":"",w=0;7>w;w++)M=(w+c)%7,P+="";for(T+=P+"",S=this._getDaysInMonth(te,Z),te===t.selectedYear&&Z===t.selectedMonth&&(t.selectedDay=Math.min(t.selectedDay,S)),H=(this._getFirstDayOfMonth(te,Z)-c+7)%7,z=Math.ceil((H+S)/7),O=X?this.maxRows>z?this.maxRows:z:z,this.maxRows=O,A=this._daylightSavingAdjust(new Date(te,Z,1-H)),N=0;O>N;N++){for(T+="",W=u?"":"",w=0;7>w;w++)E=m?m.apply(t.input?t.input[0]:null,[A]):[!0,""],F=A.getMonth()!==Z,L=F&&!v||!E[0]||Q&&Q>A||J&&A>J,W+="",A.setDate(A.getDate()+1),A=this._daylightSavingAdjust(A);T+=W+""}Z++,Z>11&&(Z=0,te++),T+="
    "+this._get(t,"weekHeader")+"=5?" class='ui-datepicker-week-end'":"")+">"+""+p[M]+"
    "+this._get(t,"calculateWeek")(A)+""+(F&&!_?" ":L?""+A.getDate()+"":""+A.getDate()+"")+"
    "+(X?"
    "+(U[0]>0&&C===U[1]-1?"
    ":""):""),x+=T}y+=x}return y+=l,t._keyEvent=!1,y},_generateMonthYearHeader:function(t,e,i,s,n,o,a,r){var h,l,c,u,d,p,f,g,m=this._get(t,"changeMonth"),_=this._get(t,"changeYear"),v=this._get(t,"showMonthAfterYear"),b="
    ",y="";if(o||!m)y+=""+a[e]+"";else{for(h=s&&s.getFullYear()===i,l=n&&n.getFullYear()===i,y+=""}if(v||(b+=y+(!o&&m&&_?"":" ")),!t.yearshtml)if(t.yearshtml="",o||!_)b+=""+i+"";else{for(u=this._get(t,"yearRange").split(":"),d=(new Date).getFullYear(),p=function(t){var e=t.match(/c[+\-].*/)?i+parseInt(t.substring(1),10):t.match(/[+\-].*/)?d+parseInt(t,10):parseInt(t,10);return isNaN(e)?d:e},f=p(u[0]),g=Math.max(f,p(u[1]||"")),f=s?Math.max(f,s.getFullYear()):f,g=n?Math.min(g,n.getFullYear()):g,t.yearshtml+="",b+=t.yearshtml,t.yearshtml=null}return b+=this._get(t,"yearSuffix"),v&&(b+=(!o&&m&&_?"":" ")+y),b+="
    "},_adjustInstDate:function(t,e,i){var s=t.selectedYear+("Y"===i?e:0),n=t.selectedMonth+("M"===i?e:0),o=Math.min(t.selectedDay,this._getDaysInMonth(s,n))+("D"===i?e:0),a=this._restrictMinMax(t,this._daylightSavingAdjust(new Date(s,n,o)));t.selectedDay=a.getDate(),t.drawMonth=t.selectedMonth=a.getMonth(),t.drawYear=t.selectedYear=a.getFullYear(),("M"===i||"Y"===i)&&this._notifyChange(t)},_restrictMinMax:function(t,e){var i=this._getMinMaxDate(t,"min"),s=this._getMinMaxDate(t,"max"),n=i&&i>e?i:e;return s&&n>s?s:n},_notifyChange:function(t){var e=this._get(t,"onChangeMonthYear");e&&e.apply(t.input?t.input[0]:null,[t.selectedYear,t.selectedMonth+1,t])},_getNumberOfMonths:function(t){var e=this._get(t,"numberOfMonths");return null==e?[1,1]:"number"==typeof e?[1,e]:e},_getMinMaxDate:function(t,e){return this._determineDate(t,this._get(t,e+"Date"),null)},_getDaysInMonth:function(t,e){return 32-this._daylightSavingAdjust(new Date(t,e,32)).getDate()},_getFirstDayOfMonth:function(t,e){return new Date(t,e,1).getDay()},_canAdjustMonth:function(t,e,i,s){var n=this._getNumberOfMonths(t),o=this._daylightSavingAdjust(new Date(i,s+(0>e?e:n[0]*n[1]),1));return 0>e&&o.setDate(this._getDaysInMonth(o.getFullYear(),o.getMonth())),this._isInRange(t,o)},_isInRange:function(t,e){var i,s,n=this._getMinMaxDate(t,"min"),o=this._getMinMaxDate(t,"max"),a=null,r=null,h=this._get(t,"yearRange");return h&&(i=h.split(":"),s=(new Date).getFullYear(),a=parseInt(i[0],10),r=parseInt(i[1],10),i[0].match(/[+\-].*/)&&(a+=s),i[1].match(/[+\-].*/)&&(r+=s)),(!n||e.getTime()>=n.getTime())&&(!o||e.getTime()<=o.getTime())&&(!a||e.getFullYear()>=a)&&(!r||r>=e.getFullYear())},_getFormatConfig:function(t){var e=this._get(t,"shortYearCutoff");return e="string"!=typeof e?e:(new Date).getFullYear()%100+parseInt(e,10),{shortYearCutoff:e,dayNamesShort:this._get(t,"dayNamesShort"),dayNames:this._get(t,"dayNames"),monthNamesShort:this._get(t,"monthNamesShort"),monthNames:this._get(t,"monthNames")}},_formatDate:function(t,e,i,s){e||(t.currentDay=t.selectedDay,t.currentMonth=t.selectedMonth,t.currentYear=t.selectedYear);var n=e?"object"==typeof e?e:this._daylightSavingAdjust(new Date(s,i,e)):this._daylightSavingAdjust(new Date(t.currentYear,t.currentMonth,t.currentDay));return this.formatDate(this._get(t,"dateFormat"),n,this._getFormatConfig(t))}}),t.fn.datepicker=function(e){if(!this.length)return this;t.datepicker.initialized||(t(document).on("mousedown",t.datepicker._checkExternalClick),t.datepicker.initialized=!0),0===t("#"+t.datepicker._mainDivId).length&&t("body").append(t.datepicker.dpDiv);var i=Array.prototype.slice.call(arguments,1);return"string"!=typeof e||"isDisabled"!==e&&"getDate"!==e&&"widget"!==e?"option"===e&&2===arguments.length&&"string"==typeof arguments[1]?t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this[0]].concat(i)):this.each(function(){"string"==typeof e?t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this].concat(i)):t.datepicker._attachDatepicker(this,e)}):t.datepicker["_"+e+"Datepicker"].apply(t.datepicker,[this[0]].concat(i))},t.datepicker=new s,t.datepicker.initialized=!1,t.datepicker.uuid=(new Date).getTime(),t.datepicker.version="1.12.1",t.datepicker,t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var _=!1;t(document).on("mouseup",function(){_=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!_){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,n="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),_=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,_=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.ui.safeBlur=function(e){e&&"body"!==e.nodeName.toLowerCase()&&t(e).trigger("blur")},t.widget("ui.draggable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this._addClass("ui-draggable"),this._setHandleClassName(),this._mouseInit()},_setOption:function(t,e){this._super(t,e),"handle"===t&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(e){var i=this.options;return this.helper||i.disabled||t(e.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(e),this.handle?(this._blurActiveElement(e),this._blockFrames(i.iframeFix===!0?"iframe":i.iframeFix),!0):!1)},_blockFrames:function(e){this.iframeBlocks=this.document.find(e).map(function(){var e=t(this);return t("
    ").css("position","absolute").appendTo(e.parent()).outerWidth(e.outerWidth()).outerHeight(e.outerHeight()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(e){var i=t.ui.safeActiveElement(this.document[0]),s=t(e.target);s.closest(i).length||t.ui.safeBlur(i)},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter(function(){return"fixed"===t(this).css("position")}).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(e),this.originalPosition=this.position=this._generatePosition(e,!1),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this._mouseDrag(e,!0),t.ui.ddmanager&&t.ui.ddmanager.dragStart(this,e),!0)},_refreshOffsets:function(t){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:t.pageX-this.offset.left,top:t.pageY-this.offset.top}},_mouseDrag:function(e,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(e,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",e,s)===!1)return this._mouseUp(new t.Event("mouseup",e)),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=this,s=!1;return t.ui.ddmanager&&!this.options.dropBehaviour&&(s=t.ui.ddmanager.drop(this,e)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",e)!==!1&&i._clear()}):this._trigger("stop",e)!==!1&&this._clear(),!1},_mouseUp:function(e){return this._unblockFrames(),t.ui.ddmanager&&t.ui.ddmanager.dragStop(this,e),this.handleElement.is(e.target)&&this.element.trigger("focus"),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp(new t.Event("mouseup",{target:this.element[0]})):this._clear(),this},_getHandle:function(e){return this.options.handle?!!t(e.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this._addClass(this.handleElement,"ui-draggable-handle")},_removeHandleClassName:function(){this._removeClass(this.handleElement,"ui-draggable-handle")},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper),n=s?t(i.helper.apply(this.element[0],[e])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return n.parents("body").length||n.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s&&n[0]===this.element[0]&&this._setPositionRelative(),n[0]===this.element[0]||/(fixed|absolute)/.test(n.css("position"))||n.css("position","absolute"),n},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_isRootNode:function(t){return/(html|body)/i.test(t.tagName)||t===this.document[0]},_getParentOffset:function(){var e=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var t=this.element.position(),e=this._isRootNode(this.scrollParent[0]);return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+(e?0:this.scrollParent.scrollTop()),left:t.left-(parseInt(this.helper.css("left"),10)||0)+(e?0:this.scrollParent.scrollLeft())} +},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options,o=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[t(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,t(window).scrollLeft()+t(window).width()-this.helperProportions.width-this.margins.left,t(window).scrollTop()+(t(window).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,t(o).width()-this.helperProportions.width-this.margins.left,(t(o).height()||o.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=t(n.containment),s=i[0],s&&(e=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(e?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(t,e){e||(e=this.position);var i="absolute"===t?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:e.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:e.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(t,e){var i,s,n,o,a=this.options,r=this._isRootNode(this.scrollParent[0]),h=t.pageX,l=t.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),e&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.lefti[2]&&(h=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(l=i[3]+this.offset.click.top)),a.grid&&(n=a.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/a.grid[1])*a.grid[1]:this.originalPageY,l=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-a.grid[1]:n+a.grid[1]:n,o=a.grid[0]?this.originalPageX+Math.round((h-this.originalPageX)/a.grid[0])*a.grid[0]:this.originalPageX,h=i?o-this.offset.click.left>=i[0]||o-this.offset.click.left>i[2]?o:o-this.offset.click.left>=i[0]?o-a.grid[0]:o+a.grid[0]:o),"y"===a.axis&&(h=this.originalPageX),"x"===a.axis&&(l=this.originalPageY)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(e,i,s){return s=s||this._uiHash(),t.ui.plugin.call(this,e,[i,s,this],!0),/^(drag|start|stop)/.test(e)&&(this.positionAbs=this._convertPositionTo("absolute"),s.offset=this.positionAbs),t.Widget.prototype._trigger.call(this,e,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i,s){var n=t.extend({},i,{item:s.element});s.sortables=[],t(s.options.connectToSortable).each(function(){var i=t(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push(i),i.refreshPositions(),i._trigger("activate",e,n))})},stop:function(e,i,s){var n=t.extend({},i,{item:s.element});s.cancelHelperRemoval=!1,t.each(s.sortables,function(){var t=this;t.isOver?(t.isOver=0,s.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,n))})},drag:function(e,i,s){t.each(s.sortables,function(){var n=!1,o=this;o.positionAbs=s.positionAbs,o.helperProportions=s.helperProportions,o.offset.click=s.offset.click,o._intersectsWith(o.containerCache)&&(n=!0,t.each(s.sortables,function(){return this.positionAbs=s.positionAbs,this.helperProportions=s.helperProportions,this.offset.click=s.offset.click,this!==o&&this._intersectsWith(this.containerCache)&&t.contains(o.element[0],this.element[0])&&(n=!1),n})),n?(o.isOver||(o.isOver=1,s._parent=i.helper.parent(),o.currentItem=i.helper.appendTo(o.element).data("ui-sortable-item",!0),o.options._helper=o.options.helper,o.options.helper=function(){return i.helper[0]},e.target=o.currentItem[0],o._mouseCapture(e,!0),o._mouseStart(e,!0,!0),o.offset.click.top=s.offset.click.top,o.offset.click.left=s.offset.click.left,o.offset.parent.left-=s.offset.parent.left-o.offset.parent.left,o.offset.parent.top-=s.offset.parent.top-o.offset.parent.top,s._trigger("toSortable",e),s.dropped=o.element,t.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,o.fromOutside=s),o.currentItem&&(o._mouseDrag(e),i.position=o.position)):o.isOver&&(o.isOver=0,o.cancelHelperRemoval=!0,o.options._revert=o.options.revert,o.options.revert=!1,o._trigger("out",e,o._uiHash(o)),o._mouseStop(e,!0),o.options.revert=o.options._revert,o.options.helper=o.options._helper,o.placeholder&&o.placeholder.remove(),i.helper.appendTo(s._parent),s._refreshOffsets(e),i.position=s._generatePosition(e,!0),s._trigger("fromSortable",e),s.dropped=!1,t.each(s.sortables,function(){this.refreshPositions()}))})}}),t.ui.plugin.add("draggable","cursor",{start:function(e,i,s){var n=t("body"),o=s.options;n.css("cursor")&&(o._cursor=n.css("cursor")),n.css("cursor",o.cursor)},stop:function(e,i,s){var n=s.options;n._cursor&&t("body").css("cursor",n._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("opacity")&&(o._opacity=n.css("opacity")),n.css("opacity",o.opacity)},stop:function(e,i,s){var n=s.options;n._opacity&&t(i.helper).css("opacity",n._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(e,i,s){var n=s.options,o=!1,a=s.scrollParentNotHidden[0],r=s.document[0];a!==r&&"HTML"!==a.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+a.offsetHeight-e.pageY=0;d--)h=s.snapElements[d].left-s.margins.left,l=h+s.snapElements[d].width,c=s.snapElements[d].top-s.margins.top,u=c+s.snapElements[d].height,h-g>_||m>l+g||c-g>b||v>u+g||!t.contains(s.snapElements[d].item.ownerDocument,s.snapElements[d].item)?(s.snapElements[d].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=!1):("inner"!==f.snapMode&&(n=g>=Math.abs(c-b),o=g>=Math.abs(u-v),a=g>=Math.abs(h-_),r=g>=Math.abs(l-m),n&&(i.position.top=s._convertPositionTo("relative",{top:c-s.helperProportions.height,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left)),p=n||o||a||r,"outer"!==f.snapMode&&(n=g>=Math.abs(c-v),o=g>=Math.abs(u-b),a=g>=Math.abs(h-m),r=g>=Math.abs(l-_),n&&(i.position.top=s._convertPositionTo("relative",{top:c,left:0}).top),o&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top),a&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left)),!s.snapElements[d].snapping&&(n||o||a||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,e,t.extend(s._uiHash(),{snapItem:s.snapElements[d].item})),s.snapElements[d].snapping=n||o||a||r||p)}}),t.ui.plugin.add("draggable","stack",{start:function(e,i,s){var n,o=s.options,a=t.makeArray(t(o.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)});a.length&&(n=parseInt(t(a[0]).css("zIndex"),10)||0,t(a).each(function(e){t(this).css("zIndex",n+e)}),this.css("zIndex",n+a.length))}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i,s){var n=t(i.helper),o=s.options;n.css("zIndex")&&(o._zIndex=n.css("zIndex")),n.css("zIndex",o.zIndex)},stop:function(e,i,s){var n=s.options;n._zIndex&&t(i.helper).css("zIndex",n._zIndex)}}),t.ui.draggable,t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
    ").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t("
    "),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,h=this._change[o];return this._updatePrevProperties(),h?(i=h.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,h,l=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,h=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,l.animate||this.element.css(t.extend(a,{top:h,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!l.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidtht.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,h=this.originalPosition.top+this.originalSize.height,l=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&l&&(t.left=r-e.minWidth),s&&l&&(t.left=r-e.maxWidth),a&&c&&(t.top=h-e.minHeight),n&&c&&(t.top=h-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
    "),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-a},l=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(h,c&&l?{top:c,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,h=t(this).resizable("instance"),l=h.options,c=h.element,u=l.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(h.containerElement=t(d),/document/.test(u)||u===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=h._num(e.css("padding"+s))}),h.containerOffset=e.offset(),h.containerPosition=e.position(),h.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,o=h.containerSize.width,a=h._hasScroll(d,"left")?d.scrollWidth:o,r=h._hasScroll(d)?d.scrollHeight:n,h.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,h=a.containerOffset,l=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=h),l.left<(a._helper?h.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-h.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?h.left:0),l.top<(a._helper?h.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-h.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?h.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-h.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-h.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),h=a.outerWidth()-e.sizeDiff.width,l=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,c=h[1]||1,u=Math.round((n.width-o.width)/l)*l,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,g=s.maxWidth&&p>s.maxWidth,m=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=h,_&&(p+=l),v&&(f+=c),g&&(p-=l),m&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-l)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-l>0?(i.size.width=p,i.position.left=a.left-u):(p=l-e.width,i.size.width=p,i.position.left=a.left+o.width-p))}}),t.ui.resizable,t.widget("ui.dialog",{version:"1.12.1",options:{appendTo:"body",autoOpen:!0,buttons:[],classes:{"ui-dialog":"ui-corner-all","ui-dialog-titlebar":"ui-corner-all"},closeOnEscape:!0,closeText:"Close",draggable:!0,hide:null,height:"auto",maxHeight:null,maxWidth:null,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(e){var i=t(this).css(e).offset().top;0>i&&t(this).css("top",e.top-i)}},resizable:!0,show:null,title:null,width:300,beforeClose:null,close:null,drag:null,dragStart:null,dragStop:null,focus:null,open:null,resize:null,resizeStart:null,resizeStop:null},sizeRelatedOptions:{buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},resizableRelatedOptions:{maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},_create:function(){this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,minHeight:this.element[0].style.minHeight,maxHeight:this.element[0].style.maxHeight,height:this.element[0].style.height},this.originalPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.originalTitle=this.element.attr("title"),null==this.options.title&&null!=this.originalTitle&&(this.options.title=this.originalTitle),this.options.disabled&&(this.options.disabled=!1),this._createWrapper(),this.element.show().removeAttr("title").appendTo(this.uiDialog),this._addClass("ui-dialog-content","ui-widget-content"),this._createTitlebar(),this._createButtonPane(),this.options.draggable&&t.fn.draggable&&this._makeDraggable(),this.options.resizable&&t.fn.resizable&&this._makeResizable(),this._isOpen=!1,this._trackFocus()},_init:function(){this.options.autoOpen&&this.open()},_appendTo:function(){var e=this.options.appendTo;return e&&(e.jquery||e.nodeType)?t(e):this.document.find(e||"body").eq(0)},_destroy:function(){var t,e=this.originalPosition;this._untrackInstance(),this._destroyOverlay(),this.element.removeUniqueId().css(this.originalCss).detach(),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),t=e.parent.children().eq(e.index),t.length&&t[0]!==this.element[0]?t.before(this.element):e.parent.append(this.element)},widget:function(){return this.uiDialog +},disable:t.noop,enable:t.noop,close:function(e){var i=this;this._isOpen&&this._trigger("beforeClose",e)!==!1&&(this._isOpen=!1,this._focusedElement=null,this._destroyOverlay(),this._untrackInstance(),this.opener.filter(":focusable").trigger("focus").length||t.ui.safeBlur(t.ui.safeActiveElement(this.document[0])),this._hide(this.uiDialog,this.options.hide,function(){i._trigger("close",e)}))},isOpen:function(){return this._isOpen},moveToTop:function(){this._moveToTop()},_moveToTop:function(e,i){var s=!1,n=this.uiDialog.siblings(".ui-front:visible").map(function(){return+t(this).css("z-index")}).get(),o=Math.max.apply(null,n);return o>=+this.uiDialog.css("z-index")&&(this.uiDialog.css("z-index",o+1),s=!0),s&&!i&&this._trigger("focus",e),s},open:function(){var e=this;return this._isOpen?(this._moveToTop()&&this._focusTabbable(),void 0):(this._isOpen=!0,this.opener=t(t.ui.safeActiveElement(this.document[0])),this._size(),this._position(),this._createOverlay(),this._moveToTop(null,!0),this.overlay&&this.overlay.css("z-index",this.uiDialog.css("z-index")-1),this._show(this.uiDialog,this.options.show,function(){e._focusTabbable(),e._trigger("focus")}),this._makeFocusTarget(),this._trigger("open"),void 0)},_focusTabbable:function(){var t=this._focusedElement;t||(t=this.element.find("[autofocus]")),t.length||(t=this.element.find(":tabbable")),t.length||(t=this.uiDialogButtonPane.find(":tabbable")),t.length||(t=this.uiDialogTitlebarClose.filter(":tabbable")),t.length||(t=this.uiDialog),t.eq(0).trigger("focus")},_keepFocus:function(e){function i(){var e=t.ui.safeActiveElement(this.document[0]),i=this.uiDialog[0]===e||t.contains(this.uiDialog[0],e);i||this._focusTabbable()}e.preventDefault(),i.call(this),this._delay(i)},_createWrapper:function(){this.uiDialog=t("
    ").hide().attr({tabIndex:-1,role:"dialog"}).appendTo(this._appendTo()),this._addClass(this.uiDialog,"ui-dialog","ui-widget ui-widget-content ui-front"),this._on(this.uiDialog,{keydown:function(e){if(this.options.closeOnEscape&&!e.isDefaultPrevented()&&e.keyCode&&e.keyCode===t.ui.keyCode.ESCAPE)return e.preventDefault(),this.close(e),void 0;if(e.keyCode===t.ui.keyCode.TAB&&!e.isDefaultPrevented()){var i=this.uiDialog.find(":tabbable"),s=i.filter(":first"),n=i.filter(":last");e.target!==n[0]&&e.target!==this.uiDialog[0]||e.shiftKey?e.target!==s[0]&&e.target!==this.uiDialog[0]||!e.shiftKey||(this._delay(function(){n.trigger("focus")}),e.preventDefault()):(this._delay(function(){s.trigger("focus")}),e.preventDefault())}},mousedown:function(t){this._moveToTop(t)&&this._focusTabbable()}}),this.element.find("[aria-describedby]").length||this.uiDialog.attr({"aria-describedby":this.element.uniqueId().attr("id")})},_createTitlebar:function(){var e;this.uiDialogTitlebar=t("
    "),this._addClass(this.uiDialogTitlebar,"ui-dialog-titlebar","ui-widget-header ui-helper-clearfix"),this._on(this.uiDialogTitlebar,{mousedown:function(e){t(e.target).closest(".ui-dialog-titlebar-close")||this.uiDialog.trigger("focus")}}),this.uiDialogTitlebarClose=t("").button({label:t("").text(this.options.closeText).html(),icon:"ui-icon-closethick",showLabel:!1}).appendTo(this.uiDialogTitlebar),this._addClass(this.uiDialogTitlebarClose,"ui-dialog-titlebar-close"),this._on(this.uiDialogTitlebarClose,{click:function(t){t.preventDefault(),this.close(t)}}),e=t("").uniqueId().prependTo(this.uiDialogTitlebar),this._addClass(e,"ui-dialog-title"),this._title(e),this.uiDialogTitlebar.prependTo(this.uiDialog),this.uiDialog.attr({"aria-labelledby":e.attr("id")})},_title:function(t){this.options.title?t.text(this.options.title):t.html(" ")},_createButtonPane:function(){this.uiDialogButtonPane=t("
    "),this._addClass(this.uiDialogButtonPane,"ui-dialog-buttonpane","ui-widget-content ui-helper-clearfix"),this.uiButtonSet=t("
    ").appendTo(this.uiDialogButtonPane),this._addClass(this.uiButtonSet,"ui-dialog-buttonset"),this._createButtons()},_createButtons:function(){var e=this,i=this.options.buttons;return this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),t.isEmptyObject(i)||t.isArray(i)&&!i.length?(this._removeClass(this.uiDialog,"ui-dialog-buttons"),void 0):(t.each(i,function(i,s){var n,o;s=t.isFunction(s)?{click:s,text:i}:s,s=t.extend({type:"button"},s),n=s.click,o={icon:s.icon,iconPosition:s.iconPosition,showLabel:s.showLabel,icons:s.icons,text:s.text},delete s.click,delete s.icon,delete s.iconPosition,delete s.showLabel,delete s.icons,"boolean"==typeof s.text&&delete s.text,t("",s).button(o).appendTo(e.uiButtonSet).on("click",function(){n.apply(e.element[0],arguments)})}),this._addClass(this.uiDialog,"ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog),void 0)},_makeDraggable:function(){function e(t){return{position:t.position,offset:t.offset}}var i=this,s=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(s,n){i._addClass(t(this),"ui-dialog-dragging"),i._blockFrames(),i._trigger("dragStart",s,e(n))},drag:function(t,s){i._trigger("drag",t,e(s))},stop:function(n,o){var a=o.offset.left-i.document.scrollLeft(),r=o.offset.top-i.document.scrollTop();s.position={my:"left top",at:"left"+(a>=0?"+":"")+a+" "+"top"+(r>=0?"+":"")+r,of:i.window},i._removeClass(t(this),"ui-dialog-dragging"),i._unblockFrames(),i._trigger("dragStop",n,e(o))}})},_makeResizable:function(){function e(t){return{originalPosition:t.originalPosition,originalSize:t.originalSize,position:t.position,size:t.size}}var i=this,s=this.options,n=s.resizable,o=this.uiDialog.css("position"),a="string"==typeof n?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:s.maxWidth,maxHeight:s.maxHeight,minWidth:s.minWidth,minHeight:this._minHeight(),handles:a,start:function(s,n){i._addClass(t(this),"ui-dialog-resizing"),i._blockFrames(),i._trigger("resizeStart",s,e(n))},resize:function(t,s){i._trigger("resize",t,e(s))},stop:function(n,o){var a=i.uiDialog.offset(),r=a.left-i.document.scrollLeft(),h=a.top-i.document.scrollTop();s.height=i.uiDialog.height(),s.width=i.uiDialog.width(),s.position={my:"left top",at:"left"+(r>=0?"+":"")+r+" "+"top"+(h>=0?"+":"")+h,of:i.window},i._removeClass(t(this),"ui-dialog-resizing"),i._unblockFrames(),i._trigger("resizeStop",n,e(o))}}).css("position",o)},_trackFocus:function(){this._on(this.widget(),{focusin:function(e){this._makeFocusTarget(),this._focusedElement=t(e.target)}})},_makeFocusTarget:function(){this._untrackInstance(),this._trackingInstances().unshift(this)},_untrackInstance:function(){var e=this._trackingInstances(),i=t.inArray(this,e);-1!==i&&e.splice(i,1)},_trackingInstances:function(){var t=this.document.data("ui-dialog-instances");return t||(t=[],this.document.data("ui-dialog-instances",t)),t},_minHeight:function(){var t=this.options;return"auto"===t.height?t.minHeight:Math.min(t.minHeight,t.height)},_position:function(){var t=this.uiDialog.is(":visible");t||this.uiDialog.show(),this.uiDialog.position(this.options.position),t||this.uiDialog.hide()},_setOptions:function(e){var i=this,s=!1,n={};t.each(e,function(t,e){i._setOption(t,e),t in i.sizeRelatedOptions&&(s=!0),t in i.resizableRelatedOptions&&(n[t]=e)}),s&&(this._size(),this._position()),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",n)},_setOption:function(e,i){var s,n,o=this.uiDialog;"disabled"!==e&&(this._super(e,i),"appendTo"===e&&this.uiDialog.appendTo(this._appendTo()),"buttons"===e&&this._createButtons(),"closeText"===e&&this.uiDialogTitlebarClose.button({label:t("").text(""+this.options.closeText).html()}),"draggable"===e&&(s=o.is(":data(ui-draggable)"),s&&!i&&o.draggable("destroy"),!s&&i&&this._makeDraggable()),"position"===e&&this._position(),"resizable"===e&&(n=o.is(":data(ui-resizable)"),n&&!i&&o.resizable("destroy"),n&&"string"==typeof i&&o.resizable("option","handles",i),n||i===!1||this._makeResizable()),"title"===e&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var t,e,i,s=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0}),s.minWidth>s.width&&(s.width=s.minWidth),t=this.uiDialog.css({height:"auto",width:s.width}).outerHeight(),e=Math.max(0,s.minHeight-t),i="number"==typeof s.maxHeight?Math.max(0,s.maxHeight-t):"none","auto"===s.height?this.element.css({minHeight:e,maxHeight:i,height:"auto"}):this.element.height(Math.max(0,s.height-t)),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var e=t(this);return t("
    ").css({position:"absolute",width:e.outerWidth(),height:e.outerHeight()}).appendTo(e.parent()).offset(e.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(e){return t(e.target).closest(".ui-dialog").length?!0:!!t(e.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var e=!0;this._delay(function(){e=!1}),this.document.data("ui-dialog-overlays")||this._on(this.document,{focusin:function(t){e||this._allowInteraction(t)||(t.preventDefault(),this._trackingInstances()[0]._focusTabbable())}}),this.overlay=t("
    ").appendTo(this._appendTo()),this._addClass(this.overlay,null,"ui-widget-overlay ui-front"),this._on(this.overlay,{mousedown:"_keepFocus"}),this.document.data("ui-dialog-overlays",(this.document.data("ui-dialog-overlays")||0)+1)}},_destroyOverlay:function(){if(this.options.modal&&this.overlay){var t=this.document.data("ui-dialog-overlays")-1;t?this.document.data("ui-dialog-overlays",t):(this._off(this.document,"focusin"),this.document.removeData("ui-dialog-overlays")),this.overlay.remove(),this.overlay=null}}}),t.uiBackCompat!==!1&&t.widget("ui.dialog",t.ui.dialog,{options:{dialogClass:""},_createWrapper:function(){this._super(),this.uiDialog.addClass(this.options.dialogClass)},_setOption:function(t,e){"dialogClass"===t&&this.uiDialog.removeClass(this.options.dialogClass).addClass(e),this._superApply(arguments)}}),t.ui.dialog,t.widget("ui.droppable",{version:"1.12.1",widgetEventPrefix:"drop",options:{accept:"*",addClasses:!0,greedy:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var e,i=this.options,s=i.accept;this.isover=!1,this.isout=!0,this.accept=t.isFunction(s)?s:function(t){return t.is(s)},this.proportions=function(){return arguments.length?(e=arguments[0],void 0):e?e:e={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},this._addToManager(i.scope),i.addClasses&&this._addClass("ui-droppable")},_addToManager:function(e){t.ui.ddmanager.droppables[e]=t.ui.ddmanager.droppables[e]||[],t.ui.ddmanager.droppables[e].push(this)},_splice:function(t){for(var e=0;t.length>e;e++)t[e]===this&&t.splice(e,1)},_destroy:function(){var e=t.ui.ddmanager.droppables[this.options.scope];this._splice(e)},_setOption:function(e,i){if("accept"===e)this.accept=t.isFunction(i)?i:function(t){return t.is(i)};else if("scope"===e){var s=t.ui.ddmanager.droppables[this.options.scope];this._splice(s),this._addToManager(i)}this._super(e,i)},_activate:function(e){var i=t.ui.ddmanager.current;this._addActiveClass(),i&&this._trigger("activate",e,this.ui(i))},_deactivate:function(e){var i=t.ui.ddmanager.current;this._removeActiveClass(),i&&this._trigger("deactivate",e,this.ui(i))},_over:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._addHoverClass(),this._trigger("over",e,this.ui(i)))},_out:function(e){var i=t.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this._removeHoverClass(),this._trigger("out",e,this.ui(i)))},_drop:function(e,i){var s=i||t.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var i=t(this).droppable("instance");return i.options.greedy&&!i.options.disabled&&i.options.scope===s.options.scope&&i.accept.call(i.element[0],s.currentItem||s.element)&&v(s,t.extend(i,{offset:i.element.offset()}),i.options.tolerance,e)?(n=!0,!1):void 0}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this._removeActiveClass(),this._removeHoverClass(),this._trigger("drop",e,this.ui(s)),this.element):!1):!1},ui:function(t){return{draggable:t.currentItem||t.element,helper:t.helper,position:t.position,offset:t.positionAbs}},_addHoverClass:function(){this._addClass("ui-droppable-hover")},_removeHoverClass:function(){this._removeClass("ui-droppable-hover")},_addActiveClass:function(){this._addClass("ui-droppable-active")},_removeActiveClass:function(){this._removeClass("ui-droppable-active")}});var v=t.ui.intersect=function(){function t(t,e,i){return t>=e&&e+i>t}return function(e,i,s,n){if(!i.offset)return!1;var o=(e.positionAbs||e.position.absolute).left+e.margins.left,a=(e.positionAbs||e.position.absolute).top+e.margins.top,r=o+e.helperProportions.width,h=a+e.helperProportions.height,l=i.offset.left,c=i.offset.top,u=l+i.proportions().width,d=c+i.proportions().height;switch(s){case"fit":return o>=l&&u>=r&&a>=c&&d>=h;case"intersect":return o+e.helperProportions.width/2>l&&u>r-e.helperProportions.width/2&&a+e.helperProportions.height/2>c&&d>h-e.helperProportions.height/2;case"pointer":return t(n.pageY,c,i.proportions().height)&&t(n.pageX,l,i.proportions().width);case"touch":return(a>=c&&d>=a||h>=c&&d>=h||c>a&&h>d)&&(o>=l&&u>=o||r>=l&&u>=r||l>o&&r>u);default:return!1}}}();t.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(e,i){var s,n,o=t.ui.ddmanager.droppables[e.options.scope]||[],a=i?i.type:null,r=(e.currentItem||e.element).find(":data(ui-droppable)").addBack();t:for(s=0;o.length>s;s++)if(!(o[s].options.disabled||e&&!o[s].accept.call(o[s].element[0],e.currentItem||e.element))){for(n=0;r.length>n;n++)if(r[n]===o[s].element[0]){o[s].proportions().height=0;continue t}o[s].visible="none"!==o[s].element.css("display"),o[s].visible&&("mousedown"===a&&o[s]._activate.call(o[s],i),o[s].offset=o[s].element.offset(),o[s].proportions({width:o[s].element[0].offsetWidth,height:o[s].element[0].offsetHeight}))}},drop:function(e,i){var s=!1;return t.each((t.ui.ddmanager.droppables[e.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&v(e,this,this.options.tolerance,i)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],e.currentItem||e.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(e,i){e.element.parentsUntil("body").on("scroll.droppable",function(){e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)})},drag:function(e,i){e.options.refreshPositions&&t.ui.ddmanager.prepareOffsets(e,i),t.each(t.ui.ddmanager.droppables[e.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,o,a=v(e,this,this.options.tolerance,i),r=!a&&this.isover?"isout":a&&!this.isover?"isover":null;r&&(this.options.greedy&&(n=this.options.scope,o=this.element.parents(":data(ui-droppable)").filter(function(){return t(this).droppable("instance").options.scope===n}),o.length&&(s=t(o[0]).droppable("instance"),s.greedyChild="isover"===r)),s&&"isover"===r&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[r]=!0,this["isout"===r?"isover":"isout"]=!1,this["isover"===r?"_over":"_out"].call(this,i),s&&"isout"===r&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(e,i){e.element.parentsUntil("body").off("scroll.droppable"),e.options.refreshPositions||t.ui.ddmanager.prepareOffsets(e,i)}},t.uiBackCompat!==!1&&t.widget("ui.droppable",t.ui.droppable,{options:{hoverClass:!1,activeClass:!1},_addActiveClass:function(){this._super(),this.options.activeClass&&this.element.addClass(this.options.activeClass)},_removeActiveClass:function(){this._super(),this.options.activeClass&&this.element.removeClass(this.options.activeClass)},_addHoverClass:function(){this._super(),this.options.hoverClass&&this.element.addClass(this.options.hoverClass)},_removeHoverClass:function(){this._super(),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass)}}),t.ui.droppable,t.widget("ui.progressbar",{version:"1.12.1",options:{classes:{"ui-progressbar":"ui-corner-all","ui-progressbar-value":"ui-corner-left","ui-progressbar-complete":"ui-corner-right"},max:100,value:0,change:null,complete:null},min:0,_create:function(){this.oldValue=this.options.value=this._constrainedValue(),this.element.attr({role:"progressbar","aria-valuemin":this.min}),this._addClass("ui-progressbar","ui-widget ui-widget-content"),this.valueDiv=t("
    ").appendTo(this.element),this._addClass(this.valueDiv,"ui-progressbar-value","ui-widget-header"),this._refreshValue()},_destroy:function(){this.element.removeAttr("role aria-valuemin aria-valuemax aria-valuenow"),this.valueDiv.remove()},value:function(t){return void 0===t?this.options.value:(this.options.value=this._constrainedValue(t),this._refreshValue(),void 0)},_constrainedValue:function(t){return void 0===t&&(t=this.options.value),this.indeterminate=t===!1,"number"!=typeof t&&(t=0),this.indeterminate?!1:Math.min(this.options.max,Math.max(this.min,t))},_setOptions:function(t){var e=t.value;delete t.value,this._super(t),this.options.value=this._constrainedValue(e),this._refreshValue()},_setOption:function(t,e){"max"===t&&(e=Math.max(this.min,e)),this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t),this._toggleClass(null,"ui-state-disabled",!!t)},_percentage:function(){return this.indeterminate?100:100*(this.options.value-this.min)/(this.options.max-this.min)},_refreshValue:function(){var e=this.options.value,i=this._percentage();this.valueDiv.toggle(this.indeterminate||e>this.min).width(i.toFixed(0)+"%"),this._toggleClass(this.valueDiv,"ui-progressbar-complete",null,e===this.options.max)._toggleClass("ui-progressbar-indeterminate",null,this.indeterminate),this.indeterminate?(this.element.removeAttr("aria-valuenow"),this.overlayDiv||(this.overlayDiv=t("
    ").appendTo(this.valueDiv),this._addClass(this.overlayDiv,"ui-progressbar-overlay"))):(this.element.attr({"aria-valuemax":this.options.max,"aria-valuenow":e}),this.overlayDiv&&(this.overlayDiv.remove(),this.overlayDiv=null)),this.oldValue!==e&&(this.oldValue=e,this._trigger("change")),e===this.options.max&&this._trigger("complete")}}),t.widget("ui.selectable",t.ui.mouse,{version:"1.12.1",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var e=this;this._addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){e.elementPos=t(e.element[0]).offset(),e.selectees=t(e.options.filter,e.element[0]),e._addClass(e.selectees,"ui-selectee"),e.selectees.each(function(){var i=t(this),s=i.offset(),n={left:s.left-e.elementPos.left,top:s.top-e.elementPos.top};t.data(this,"selectable-item",{element:this,$element:i,left:n.left,top:n.top,right:n.left+i.outerWidth(),bottom:n.top+i.outerHeight(),startselected:!1,selected:i.hasClass("ui-selected"),selecting:i.hasClass("ui-selecting"),unselecting:i.hasClass("ui-unselecting")})})},this.refresh(),this._mouseInit(),this.helper=t("
    "),this._addClass(this.helper,"ui-selectable-helper")},_destroy:function(){this.selectees.removeData("selectable-item"),this._mouseDestroy()},_mouseStart:function(e){var i=this,s=this.options;this.opos=[e.pageX,e.pageY],this.elementPos=t(this.element[0]).offset(),this.options.disabled||(this.selectees=t(s.filter,this.element[0]),this._trigger("start",e),t(s.appendTo).append(this.helper),this.helper.css({left:e.pageX,top:e.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=t.data(this,"selectable-item");s.startselected=!0,e.metaKey||e.ctrlKey||(i._removeClass(s.$element,"ui-selected"),s.selected=!1,i._addClass(s.$element,"ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",e,{unselecting:s.element}))}),t(e.target).parents().addBack().each(function(){var s,n=t.data(this,"selectable-item");return n?(s=!e.metaKey&&!e.ctrlKey||!n.$element.hasClass("ui-selected"),i._removeClass(n.$element,s?"ui-unselecting":"ui-selected")._addClass(n.$element,s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",e,{selecting:n.element}):i._trigger("unselecting",e,{unselecting:n.element}),!1):void 0}))},_mouseDrag:function(e){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,o=this.opos[0],a=this.opos[1],r=e.pageX,h=e.pageY;return o>r&&(i=r,r=o,o=i),a>h&&(i=h,h=a,a=i),this.helper.css({left:o,top:a,width:r-o,height:h-a}),this.selectees.each(function(){var i=t.data(this,"selectable-item"),l=!1,c={};i&&i.element!==s.element[0]&&(c.left=i.left+s.elementPos.left,c.right=i.right+s.elementPos.left,c.top=i.top+s.elementPos.top,c.bottom=i.bottom+s.elementPos.top,"touch"===n.tolerance?l=!(c.left>r||o>c.right||c.top>h||a>c.bottom):"fit"===n.tolerance&&(l=c.left>o&&r>c.right&&c.top>a&&h>c.bottom),l?(i.selected&&(s._removeClass(i.$element,"ui-selected"),i.selected=!1),i.unselecting&&(s._removeClass(i.$element,"ui-unselecting"),i.unselecting=!1),i.selecting||(s._addClass(i.$element,"ui-selecting"),i.selecting=!0,s._trigger("selecting",e,{selecting:i.element}))):(i.selecting&&((e.metaKey||e.ctrlKey)&&i.startselected?(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,s._addClass(i.$element,"ui-selected"),i.selected=!0):(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,i.startselected&&(s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",e,{unselecting:i.element}))),i.selected&&(e.metaKey||e.ctrlKey||i.startselected||(s._removeClass(i.$element,"ui-selected"),i.selected=!1,s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",e,{unselecting:i.element})))))}),!1}},_mouseStop:function(e){var i=this;return this.dragged=!1,t(".ui-unselecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",e,{unselected:s.element})}),t(".ui-selecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-selecting")._addClass(s.$element,"ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",e,{selected:s.element})}),this._trigger("stop",e),this.helper.remove(),!1}}),t.widget("ui.selectmenu",[t.ui.formResetMixin,{version:"1.12.1",defaultElement:"",widgetEventPrefix:"spin",options:{classes:{"ui-spinner":"ui-corner-all","ui-spinner-down":"ui-corner-br","ui-spinner-up":"ui-corner-tr"},culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),""!==this.value()&&this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var e=this._super(),i=this.element;return t.each(["min","max","step"],function(t,s){var n=i.attr(s);null!=n&&n.length&&(e[s]=n)}),e},_events:{keydown:function(t){this._start(t)&&this._keydown(t)&&t.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(t){return this.cancelBlur?(delete this.cancelBlur,void 0):(this._stop(),this._refresh(),this.previous!==this.element.val()&&this._trigger("change",t),void 0)},mousewheel:function(t,e){if(e){if(!this.spinning&&!this._start(t))return!1;this._spin((e>0?1:-1)*this.options.step,t),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(t)},100),t.preventDefault()}},"mousedown .ui-spinner-button":function(e){function i(){var e=this.element[0]===t.ui.safeActiveElement(this.document[0]);e||(this.element.trigger("focus"),this.previous=s,this._delay(function(){this.previous=s}))}var s;s=this.element[0]===t.ui.safeActiveElement(this.document[0])?this.previous:this.element.val(),e.preventDefault(),i.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,i.call(this)}),this._start(e)!==!1&&this._repeat(null,t(e.currentTarget).hasClass("ui-spinner-up")?1:-1,e)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(e){return t(e.currentTarget).hasClass("ui-state-active")?this._start(e)===!1?!1:(this._repeat(null,t(e.currentTarget).hasClass("ui-spinner-up")?1:-1,e),void 0):void 0},"mouseleave .ui-spinner-button":"_stop"},_enhance:function(){this.uiSpinner=this.element.attr("autocomplete","off").wrap("").parent().append("")},_draw:function(){this._enhance(),this._addClass(this.uiSpinner,"ui-spinner","ui-widget ui-widget-content"),this._addClass("ui-spinner-input"),this.element.attr("role","spinbutton"),this.buttons=this.uiSpinner.children("a").attr("tabIndex",-1).attr("aria-hidden",!0).button({classes:{"ui-button":""}}),this._removeClass(this.buttons,"ui-corner-all"),this._addClass(this.buttons.first(),"ui-spinner-button ui-spinner-up"),this._addClass(this.buttons.last(),"ui-spinner-button ui-spinner-down"),this.buttons.first().button({icon:this.options.icons.up,showLabel:!1}),this.buttons.last().button({icon:this.options.icons.down,showLabel:!1}),this.buttons.height()>Math.ceil(.5*this.uiSpinner.height())&&this.uiSpinner.height()>0&&this.uiSpinner.height(this.uiSpinner.height())},_keydown:function(e){var i=this.options,s=t.ui.keyCode;switch(e.keyCode){case s.UP:return this._repeat(null,1,e),!0;case s.DOWN:return this._repeat(null,-1,e),!0;case s.PAGE_UP:return this._repeat(null,i.page,e),!0;case s.PAGE_DOWN:return this._repeat(null,-i.page,e),!0}return!1},_start:function(t){return this.spinning||this._trigger("start",t)!==!1?(this.counter||(this.counter=1),this.spinning=!0,!0):!1},_repeat:function(t,e,i){t=t||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,e,i)},t),this._spin(e*this.options.step,i)},_spin:function(t,e){var i=this.value()||0;this.counter||(this.counter=1),i=this._adjustValue(i+t*this._increment(this.counter)),this.spinning&&this._trigger("spin",e,{value:i})===!1||(this._value(i),this.counter++)},_increment:function(e){var i=this.options.incremental;return i?t.isFunction(i)?i(e):Math.floor(e*e*e/5e4-e*e/500+17*e/200+1):1},_precision:function(){var t=this._precisionOf(this.options.step);return null!==this.options.min&&(t=Math.max(t,this._precisionOf(this.options.min))),t},_precisionOf:function(t){var e=""+t,i=e.indexOf(".");return-1===i?0:e.length-i-1},_adjustValue:function(t){var e,i,s=this.options;return e=null!==s.min?s.min:0,i=t-e,i=Math.round(i/s.step)*s.step,t=e+i,t=parseFloat(t.toFixed(this._precision())),null!==s.max&&t>s.max?s.max:null!==s.min&&s.min>t?s.min:t},_stop:function(t){this.spinning&&(clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",t))},_setOption:function(t,e){var i,s,n;return"culture"===t||"numberFormat"===t?(i=this._parse(this.element.val()),this.options[t]=e,this.element.val(this._format(i)),void 0):(("max"===t||"min"===t||"step"===t)&&"string"==typeof e&&(e=this._parse(e)),"icons"===t&&(s=this.buttons.first().find(".ui-icon"),this._removeClass(s,null,this.options.icons.up),this._addClass(s,null,e.up),n=this.buttons.last().find(".ui-icon"),this._removeClass(n,null,this.options.icons.down),this._addClass(n,null,e.down)),this._super(t,e),void 0)},_setOptionDisabled:function(t){this._super(t),this._toggleClass(this.uiSpinner,null,"ui-state-disabled",!!t),this.element.prop("disabled",!!t),this.buttons.button(t?"disable":"enable")},_setOptions:r(function(t){this._super(t)}),_parse:function(t){return"string"==typeof t&&""!==t&&(t=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(t,10,this.options.culture):+t),""===t||isNaN(t)?null:t},_format:function(t){return""===t?"":window.Globalize&&this.options.numberFormat?Globalize.format(t,this.options.numberFormat,this.options.culture):t},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},isValid:function(){var t=this.value();return null===t?!1:t===this._adjustValue(t)},_value:function(t,e){var i;""!==t&&(i=this._parse(t),null!==i&&(e||(i=this._adjustValue(i)),t=this._format(i))),this.element.val(t),this._refresh()},_destroy:function(){this.element.prop("disabled",!1).removeAttr("autocomplete role aria-valuemin aria-valuemax aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:r(function(t){this._stepUp(t)}),_stepUp:function(t){this._start()&&(this._spin((t||1)*this.options.step),this._stop())},stepDown:r(function(t){this._stepDown(t)}),_stepDown:function(t){this._start()&&(this._spin((t||1)*-this.options.step),this._stop())},pageUp:r(function(t){this._stepUp((t||1)*this.options.page)}),pageDown:r(function(t){this._stepDown((t||1)*this.options.page)}),value:function(t){return arguments.length?(r(this._value).call(this,t),void 0):this._parse(this.element.val())},widget:function(){return this.uiSpinner}}),t.uiBackCompat!==!1&&t.widget("ui.spinner",t.ui.spinner,{_enhance:function(){this.uiSpinner=this.element.attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml())},_uiSpinnerHtml:function(){return""},_buttonHtml:function(){return""}}),t.ui.spinner,t.widget("ui.tabs",{version:"1.12.1",delay:300,options:{active:null,classes:{"ui-tabs":"ui-corner-all","ui-tabs-nav":"ui-corner-all","ui-tabs-panel":"ui-corner-bottom","ui-tabs-tab":"ui-corner-top"},collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_isLocal:function(){var t=/#.*$/;return function(e){var i,s;i=e.href.replace(t,""),s=location.href.replace(t,"");try{i=decodeURIComponent(i)}catch(n){}try{s=decodeURIComponent(s)}catch(n){}return e.hash.length>1&&i===s}}(),_create:function(){var e=this,i=this.options;this.running=!1,this._addClass("ui-tabs","ui-widget ui-widget-content"),this._toggleClass("ui-tabs-collapsible",null,i.collapsible),this._processTabs(),i.active=this._initialActive(),t.isArray(i.disabled)&&(i.disabled=t.unique(i.disabled.concat(t.map(this.tabs.filter(".ui-state-disabled"),function(t){return e.tabs.index(t)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(i.active):t(),this._refresh(),this.active.length&&this.load(i.active)},_initialActive:function(){var e=this.options.active,i=this.options.collapsible,s=location.hash.substring(1);return null===e&&(s&&this.tabs.each(function(i,n){return t(n).attr("aria-controls")===s?(e=i,!1):void 0}),null===e&&(e=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===e||-1===e)&&(e=this.tabs.length?0:!1)),e!==!1&&(e=this.tabs.index(this.tabs.eq(e)),-1===e&&(e=i?!1:0)),!i&&e===!1&&this.anchors.length&&(e=0),e},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):t()}},_tabKeydown:function(e){var i=t(t.ui.safeActiveElement(this.document[0])).closest("li"),s=this.tabs.index(i),n=!0;if(!this._handlePageNav(e)){switch(e.keyCode){case t.ui.keyCode.RIGHT:case t.ui.keyCode.DOWN:s++;break;case t.ui.keyCode.UP:case t.ui.keyCode.LEFT:n=!1,s--;break;case t.ui.keyCode.END:s=this.anchors.length-1;break;case t.ui.keyCode.HOME:s=0;break;case t.ui.keyCode.SPACE:return e.preventDefault(),clearTimeout(this.activating),this._activate(s),void 0;case t.ui.keyCode.ENTER:return e.preventDefault(),clearTimeout(this.activating),this._activate(s===this.options.active?!1:s),void 0;default:return}e.preventDefault(),clearTimeout(this.activating),s=this._focusNextTab(s,n),e.ctrlKey||e.metaKey||(i.attr("aria-selected","false"),this.tabs.eq(s).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",s)},this.delay))}},_panelKeydown:function(e){this._handlePageNav(e)||e.ctrlKey&&e.keyCode===t.ui.keyCode.UP&&(e.preventDefault(),this.active.trigger("focus"))},_handlePageNav:function(e){return e.altKey&&e.keyCode===t.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):e.altKey&&e.keyCode===t.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):void 0},_findNextTab:function(e,i){function s(){return e>n&&(e=0),0>e&&(e=n),e}for(var n=this.tabs.length-1;-1!==t.inArray(s(),this.options.disabled);)e=i?e+1:e-1;return e},_focusNextTab:function(t,e){return t=this._findNextTab(t,e),this.tabs.eq(t).trigger("focus"),t},_setOption:function(t,e){return"active"===t?(this._activate(e),void 0):(this._super(t,e),"collapsible"===t&&(this._toggleClass("ui-tabs-collapsible",null,e),e||this.options.active!==!1||this._activate(0)),"event"===t&&this._setupEvents(e),"heightStyle"===t&&this._setupHeightStyle(e),void 0)},_sanitizeSelector:function(t){return t?t.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var e=this.options,i=this.tablist.children(":has(a[href])");e.disabled=t.map(i.filter(".ui-state-disabled"),function(t){return i.index(t)}),this._processTabs(),e.active!==!1&&this.anchors.length?this.active.length&&!t.contains(this.tablist[0],this.active[0])?this.tabs.length===e.disabled.length?(e.active=!1,this.active=t()):this._activate(this._findNextTab(Math.max(0,e.active-1),!1)):e.active=this.tabs.index(this.active):(e.active=!1,this.active=t()),this._refresh()},_refresh:function(){this._setOptionDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-hidden":"true"}),this.active.length?(this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}),this._addClass(this.active,"ui-tabs-active","ui-state-active"),this._getPanelForTab(this.active).show().attr({"aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var e=this,i=this.tabs,s=this.anchors,n=this.panels;this.tablist=this._getList().attr("role","tablist"),this._addClass(this.tablist,"ui-tabs-nav","ui-helper-reset ui-helper-clearfix ui-widget-header"),this.tablist.on("mousedown"+this.eventNamespace,"> li",function(e){t(this).is(".ui-state-disabled")&&e.preventDefault()}).on("focus"+this.eventNamespace,".ui-tabs-anchor",function(){t(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this.tabs=this.tablist.find("> li:has(a[href])").attr({role:"tab",tabIndex:-1}),this._addClass(this.tabs,"ui-tabs-tab","ui-state-default"),this.anchors=this.tabs.map(function(){return t("a",this)[0]}).attr({role:"presentation",tabIndex:-1}),this._addClass(this.anchors,"ui-tabs-anchor"),this.panels=t(),this.anchors.each(function(i,s){var n,o,a,r=t(s).uniqueId().attr("id"),h=t(s).closest("li"),l=h.attr("aria-controls");e._isLocal(s)?(n=s.hash,a=n.substring(1),o=e.element.find(e._sanitizeSelector(n))):(a=h.attr("aria-controls")||t({}).uniqueId()[0].id,n="#"+a,o=e.element.find(n),o.length||(o=e._createPanel(a),o.insertAfter(e.panels[i-1]||e.tablist)),o.attr("aria-live","polite")),o.length&&(e.panels=e.panels.add(o)),l&&h.data("ui-tabs-aria-controls",l),h.attr({"aria-controls":a,"aria-labelledby":r}),o.attr("aria-labelledby",r)}),this.panels.attr("role","tabpanel"),this._addClass(this.panels,"ui-tabs-panel","ui-widget-content"),i&&(this._off(i.not(this.tabs)),this._off(s.not(this.anchors)),this._off(n.not(this.panels)))},_getList:function(){return this.tablist||this.element.find("ol, ul").eq(0)},_createPanel:function(e){return t("
    ").attr("id",e).data("ui-tabs-destroy",!0)},_setOptionDisabled:function(e){var i,s,n;for(t.isArray(e)&&(e.length?e.length===this.anchors.length&&(e=!0):e=!1),n=0;s=this.tabs[n];n++)i=t(s),e===!0||-1!==t.inArray(n,e)?(i.attr("aria-disabled","true"),this._addClass(i,null,"ui-state-disabled")):(i.removeAttr("aria-disabled"),this._removeClass(i,null,"ui-state-disabled"));this.options.disabled=e,this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,e===!0)},_setupEvents:function(e){var i={};e&&t.each(e.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(!0,this.anchors,{click:function(t){t.preventDefault()}}),this._on(this.anchors,i),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(e){var i,s=this.element.parent();"fill"===e?(i=s.height(),i-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var e=t(this),s=e.css("position");"absolute"!==s&&"fixed"!==s&&(i-=e.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){i-=t(this).outerHeight(!0)}),this.panels.each(function(){t(this).height(Math.max(0,i-t(this).innerHeight()+t(this).height()))}).css("overflow","auto")):"auto"===e&&(i=0,this.panels.each(function(){i=Math.max(i,t(this).height("").height())}).height(i))},_eventHandler:function(e){var i=this.options,s=this.active,n=t(e.currentTarget),o=n.closest("li"),a=o[0]===s[0],r=a&&i.collapsible,h=r?t():this._getPanelForTab(o),l=s.length?this._getPanelForTab(s):t(),c={oldTab:s,oldPanel:l,newTab:r?t():o,newPanel:h};e.preventDefault(),o.hasClass("ui-state-disabled")||o.hasClass("ui-tabs-loading")||this.running||a&&!i.collapsible||this._trigger("beforeActivate",e,c)===!1||(i.active=r?!1:this.tabs.index(o),this.active=a?t():o,this.xhr&&this.xhr.abort(),l.length||h.length||t.error("jQuery UI Tabs: Mismatching fragment identifier."),h.length&&this.load(this.tabs.index(o),e),this._toggle(e,c))},_toggle:function(e,i){function s(){o.running=!1,o._trigger("activate",e,i)}function n(){o._addClass(i.newTab.closest("li"),"ui-tabs-active","ui-state-active"),a.length&&o.options.show?o._show(a,o.options.show,s):(a.show(),s())}var o=this,a=i.newPanel,r=i.oldPanel;this.running=!0,r.length&&this.options.hide?this._hide(r,this.options.hide,function(){o._removeClass(i.oldTab.closest("li"),"ui-tabs-active","ui-state-active"),n()}):(this._removeClass(i.oldTab.closest("li"),"ui-tabs-active","ui-state-active"),r.hide(),n()),r.attr("aria-hidden","true"),i.oldTab.attr({"aria-selected":"false","aria-expanded":"false"}),a.length&&r.length?i.oldTab.attr("tabIndex",-1):a.length&&this.tabs.filter(function(){return 0===t(this).attr("tabIndex")}).attr("tabIndex",-1),a.attr("aria-hidden","false"),i.newTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_activate:function(e){var i,s=this._findActive(e);s[0]!==this.active[0]&&(s.length||(s=this.active),i=s.find(".ui-tabs-anchor")[0],this._eventHandler({target:i,currentTarget:i,preventDefault:t.noop}))},_findActive:function(e){return e===!1?t():this.tabs.eq(e)},_getIndex:function(e){return"string"==typeof e&&(e=this.anchors.index(this.anchors.filter("[href$='"+t.ui.escapeSelector(e)+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.tablist.removeAttr("role").off(this.eventNamespace),this.anchors.removeAttr("role tabIndex").removeUniqueId(),this.tabs.add(this.panels).each(function(){t.data(this,"ui-tabs-destroy")?t(this).remove():t(this).removeAttr("role tabIndex aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded")}),this.tabs.each(function(){var e=t(this),i=e.data("ui-tabs-aria-controls");i?e.attr("aria-controls",i).removeData("ui-tabs-aria-controls"):e.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(e){var i=this.options.disabled;i!==!1&&(void 0===e?i=!1:(e=this._getIndex(e),i=t.isArray(i)?t.map(i,function(t){return t!==e?t:null}):t.map(this.tabs,function(t,i){return i!==e?i:null})),this._setOptionDisabled(i))},disable:function(e){var i=this.options.disabled;if(i!==!0){if(void 0===e)i=!0;else{if(e=this._getIndex(e),-1!==t.inArray(e,i))return;i=t.isArray(i)?t.merge([e],i).sort():[e]}this._setOptionDisabled(i)}},load:function(e,i){e=this._getIndex(e);var s=this,n=this.tabs.eq(e),o=n.find(".ui-tabs-anchor"),a=this._getPanelForTab(n),r={tab:n,panel:a},h=function(t,e){"abort"===e&&s.panels.stop(!1,!0),s._removeClass(n,"ui-tabs-loading"),a.removeAttr("aria-busy"),t===s.xhr&&delete s.xhr};this._isLocal(o[0])||(this.xhr=t.ajax(this._ajaxSettings(o,i,r)),this.xhr&&"canceled"!==this.xhr.statusText&&(this._addClass(n,"ui-tabs-loading"),a.attr("aria-busy","true"),this.xhr.done(function(t,e,n){setTimeout(function(){a.html(t),s._trigger("load",i,r),h(n,e)},1)}).fail(function(t,e){setTimeout(function(){h(t,e)},1)})))},_ajaxSettings:function(e,i,s){var n=this;return{url:e.attr("href").replace(/#.*$/,""),beforeSend:function(e,o){return n._trigger("beforeLoad",i,t.extend({jqXHR:e,ajaxSettings:o},s))}}},_getPanelForTab:function(e){var i=t(e).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+i))}}),t.uiBackCompat!==!1&&t.widget("ui.tabs",t.ui.tabs,{_processTabs:function(){this._superApply(arguments),this._addClass(this.tabs,"ui-tab")}}),t.ui.tabs,t.widget("ui.tooltip",{version:"1.12.1",options:{classes:{"ui-tooltip":"ui-corner-all ui-widget-shadow"},content:function(){var e=t(this).attr("title")||"";return t("").text(e).html()},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,track:!1,close:null,open:null},_addDescribedBy:function(e,i){var s=(e.attr("aria-describedby")||"").split(/\s+/);s.push(i),e.data("ui-tooltip-id",i).attr("aria-describedby",t.trim(s.join(" ")))},_removeDescribedBy:function(e){var i=e.data("ui-tooltip-id"),s=(e.attr("aria-describedby")||"").split(/\s+/),n=t.inArray(i,s);-1!==n&&s.splice(n,1),e.removeData("ui-tooltip-id"),s=t.trim(s.join(" ")),s?e.attr("aria-describedby",s):e.removeAttr("aria-describedby")},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.liveRegion=t("
    ").attr({role:"log","aria-live":"assertive","aria-relevant":"additions"}).appendTo(this.document[0].body),this._addClass(this.liveRegion,null,"ui-helper-hidden-accessible"),this.disabledTitles=t([])},_setOption:function(e,i){var s=this;this._super(e,i),"content"===e&&t.each(this.tooltips,function(t,e){s._updateContent(e.element)})},_setOptionDisabled:function(t){this[t?"_disable":"_enable"]()},_disable:function(){var e=this;t.each(this.tooltips,function(i,s){var n=t.Event("blur");n.target=n.currentTarget=s.element[0],e.close(n,!0)}),this.disabledTitles=this.disabledTitles.add(this.element.find(this.options.items).addBack().filter(function(){var e=t(this);return e.is("[title]")?e.data("ui-tooltip-title",e.attr("title")).removeAttr("title"):void 0}))},_enable:function(){this.disabledTitles.each(function(){var e=t(this);e.data("ui-tooltip-title")&&e.attr("title",e.data("ui-tooltip-title"))}),this.disabledTitles=t([])},open:function(e){var i=this,s=t(e?e.target:this.element).closest(this.options.items);s.length&&!s.data("ui-tooltip-id")&&(s.attr("title")&&s.data("ui-tooltip-title",s.attr("title")),s.data("ui-tooltip-open",!0),e&&"mouseover"===e.type&&s.parents().each(function(){var e,s=t(this);s.data("ui-tooltip-open")&&(e=t.Event("blur"),e.target=e.currentTarget=this,i.close(e,!0)),s.attr("title")&&(s.uniqueId(),i.parents[this.id]={element:this,title:s.attr("title")},s.attr("title",""))}),this._registerCloseHandlers(e,s),this._updateContent(s,e))},_updateContent:function(t,e){var i,s=this.options.content,n=this,o=e?e.type:null;return"string"==typeof s||s.nodeType||s.jquery?this._open(e,t,s):(i=s.call(t[0],function(i){n._delay(function(){t.data("ui-tooltip-open")&&(e&&(e.type=o),this._open(e,t,i))})}),i&&this._open(e,t,i),void 0)},_open:function(e,i,s){function n(t){l.of=t,a.is(":hidden")||a.position(l)}var o,a,r,h,l=t.extend({},this.options.position);if(s){if(o=this._find(i))return o.tooltip.find(".ui-tooltip-content").html(s),void 0;i.is("[title]")&&(e&&"mouseover"===e.type?i.attr("title",""):i.removeAttr("title")),o=this._tooltip(i),a=o.tooltip,this._addDescribedBy(i,a.attr("id")),a.find(".ui-tooltip-content").html(s),this.liveRegion.children().hide(),h=t("
    ").html(a.find(".ui-tooltip-content").html()),h.removeAttr("name").find("[name]").removeAttr("name"),h.removeAttr("id").find("[id]").removeAttr("id"),h.appendTo(this.liveRegion),this.options.track&&e&&/^mouse/.test(e.type)?(this._on(this.document,{mousemove:n}),n(e)):a.position(t.extend({of:i},this.options.position)),a.hide(),this._show(a,this.options.show),this.options.track&&this.options.show&&this.options.show.delay&&(r=this.delayedShow=setInterval(function(){a.is(":visible")&&(n(l.of),clearInterval(r))},t.fx.interval)),this._trigger("open",e,{tooltip:a})}},_registerCloseHandlers:function(e,i){var s={keyup:function(e){if(e.keyCode===t.ui.keyCode.ESCAPE){var s=t.Event(e);s.currentTarget=i[0],this.close(s,!0)}}};i[0]!==this.element[0]&&(s.remove=function(){this._removeTooltip(this._find(i).tooltip)}),e&&"mouseover"!==e.type||(s.mouseleave="close"),e&&"focusin"!==e.type||(s.focusout="close"),this._on(!0,i,s)},close:function(e){var i,s=this,n=t(e?e.currentTarget:this.element),o=this._find(n);return o?(i=o.tooltip,o.closing||(clearInterval(this.delayedShow),n.data("ui-tooltip-title")&&!n.attr("title")&&n.attr("title",n.data("ui-tooltip-title")),this._removeDescribedBy(n),o.hiding=!0,i.stop(!0),this._hide(i,this.options.hide,function(){s._removeTooltip(t(this))}),n.removeData("ui-tooltip-open"),this._off(n,"mouseleave focusout keyup"),n[0]!==this.element[0]&&this._off(n,"remove"),this._off(this.document,"mousemove"),e&&"mouseleave"===e.type&&t.each(this.parents,function(e,i){t(i.element).attr("title",i.title),delete s.parents[e]}),o.closing=!0,this._trigger("close",e,{tooltip:i}),o.hiding||(o.closing=!1)),void 0):(n.removeData("ui-tooltip-open"),void 0)},_tooltip:function(e){var i=t("
    ").attr("role","tooltip"),s=t("
    ").appendTo(i),n=i.uniqueId().attr("id");return this._addClass(s,"ui-tooltip-content"),this._addClass(i,"ui-tooltip","ui-widget ui-widget-content"),i.appendTo(this._appendTo(e)),this.tooltips[n]={element:e,tooltip:i}},_find:function(t){var e=t.data("ui-tooltip-id");return e?this.tooltips[e]:null},_removeTooltip:function(t){t.remove(),delete this.tooltips[t.attr("id")]},_appendTo:function(t){var e=t.closest(".ui-front, dialog");return e.length||(e=this.document[0].body),e},_destroy:function(){var e=this;t.each(this.tooltips,function(i,s){var n=t.Event("blur"),o=s.element;n.target=n.currentTarget=o[0],e.close(n,!0),t("#"+i).remove(),o.data("ui-tooltip-title")&&(o.attr("title")||o.attr("title",o.data("ui-tooltip-title")),o.removeData("ui-tooltip-title"))}),this.liveRegion.remove()}}),t.uiBackCompat!==!1&&t.widget("ui.tooltip",t.ui.tooltip,{options:{tooltipClass:null},_tooltip:function(){var t=this._superApply(arguments);return this.options.tooltipClass&&t.tooltip.addClass(this.options.tooltipClass),t}}),t.ui.tooltip}); \ No newline at end of file diff --git a/librerias/calendar/lib/jquery.min.js b/librerias/calendar/lib/jquery.min.js new file mode 100755 index 0000000..644d35e --- /dev/null +++ b/librerias/calendar/lib/jquery.min.js @@ -0,0 +1,4 @@ +/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext;function B(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()}var C=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,D=/^.[^:#\[\.,]*$/;function E(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):D.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(E(this,a||[],!1))},not:function(a){return this.pushStack(E(this,a||[],!0))},is:function(a){return!!E(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var F,G=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,H=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||F,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:G.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),C.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};H.prototype=r.fn,F=r(d);var I=/^(?:parents|prev(?:Until|All))/,J={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function K(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return K(a,"nextSibling")},prev:function(a){return K(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return B(a,"iframe")?a.contentDocument:(B(a,"template")&&(a=a.content||a),r.merge([],a.childNodes))}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(J[a]||r.uniqueSort(e),I.test(a)&&e.reverse()),this.pushStack(e)}});var L=/[^\x20\t\r\n\f]+/g;function M(a){var b={};return r.each(a.match(L)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?M(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=e||a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function N(a){return a}function O(a){throw a}function P(a,b,c,d){var e;try{a&&r.isFunction(e=a.promise)?e.call(a).done(b).fail(c):a&&r.isFunction(e=a.then)?e.call(a,b,c):b.apply(void 0,[a].slice(d))}catch(a){c.apply(void 0,[a])}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b=f&&(d!==O&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:N,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:N)),c[2][3].add(g(0,a,r.isFunction(d)?d:O))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(P(a,g.done(h(c)).resolve,g.reject,!b),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)P(e[c],h(c),g.reject);return g.promise()}});var Q=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&Q.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var R=r.Deferred();r.fn.ready=function(a){return R.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||R.resolveWith(d,[r]))}}),r.ready.then=R.then;function S(){d.removeEventListener("DOMContentLoaded",S), +a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h1,null,!0)},removeData:function(a){return this.each(function(){X.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=W.get(a,b),c&&(!d||Array.isArray(c)?d=W.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return W.get(a,c)||W.access(a,c,{empty:r.Callbacks("once memory").add(function(){W.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length\x20\t\r\n\f]+)/i,la=/^$|\/(?:java|ecma)script/i,ma={option:[1,""],thead:[1,"","
    "],col:[2,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],_default:[0,"",""]};ma.optgroup=ma.option,ma.tbody=ma.tfoot=ma.colgroup=ma.caption=ma.thead,ma.th=ma.td;function na(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&B(a,b)?r.merge([a],c):c}function oa(a,b){for(var c=0,d=a.length;c-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=na(l.appendChild(f),"script"),j&&oa(g),c){k=0;while(f=g[k++])la.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var ra=d.documentElement,sa=/^key/,ta=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ua=/^([^.]*)(?:\.(.+)|)/;function va(){return!0}function wa(){return!1}function xa(){try{return d.activeElement}catch(a){}}function ya(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ya(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=wa;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(ra,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(L)||[""],j=b.length;while(j--)h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.hasData(a)&&W.get(a);if(q&&(i=q.events)){b=(b||"").match(L)||[""],j=b.length;while(j--)if(h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&W.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(W.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i\x20\t\r\n\f]*)[^>]*)\/>/gi,Aa=/\s*$/g;function Ea(a,b){return B(a,"table")&&B(11!==b.nodeType?b:b.firstChild,"tr")?r(">tbody",a)[0]||a:a}function Fa(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Ga(a){var b=Ca.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ha(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(W.hasData(a)&&(f=W.access(a),g=W.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c1&&"string"==typeof q&&!o.checkClone&&Ba.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ja(f,b,c,d)});if(m&&(e=qa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(na(e,"script"),Fa),i=h.length;l")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=na(h),f=na(a),d=0,e=f.length;d0&&oa(g,!i&&na(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(U(c)){if(b=c[W.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[W.expando]=void 0}c[X.expando]&&(c[X.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ka(this,a,!0)},remove:function(a){return Ka(this,a)},text:function(a){return T(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.appendChild(a)}})},prepend:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(na(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return T(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!Aa.test(a)&&!ma[(ka.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c1)}});function _a(a,b,c,d,e){return new _a.prototype.init(a,b,c,d,e)}r.Tween=_a,_a.prototype={constructor:_a,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=_a.propHooks[this.prop];return a&&a.get?a.get(this):_a.propHooks._default.get(this)},run:function(a){var b,c=_a.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):_a.propHooks._default.set(this),this}},_a.prototype.init.prototype=_a.prototype,_a.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},_a.propHooks.scrollTop=_a.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=_a.prototype.init,r.fx.step={};var ab,bb,cb=/^(?:toggle|show|hide)$/,db=/queueHooks$/;function eb(){bb&&(d.hidden===!1&&a.requestAnimationFrame?a.requestAnimationFrame(eb):a.setTimeout(eb,r.fx.interval),r.fx.tick())}function fb(){return a.setTimeout(function(){ab=void 0}),ab=r.now()}function gb(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ca[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function hb(a,b,c){for(var d,e=(kb.tweeners[b]||[]).concat(kb.tweeners["*"]),f=0,g=e.length;f1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?lb:void 0)),void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b), +null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=mb[g],mb[g]=e,e=null!=c(a,b,d)?g:null,mb[g]=f),e}});var nb=/^(?:input|select|textarea|button)$/i,ob=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return T(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):nb.test(a.nodeName)||ob.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function pb(a){var b=a.match(L)||[];return b.join(" ")}function qb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,qb(this)))});if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,qb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,qb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(L)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=qb(this),b&&W.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":W.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+pb(qb(c))+" ").indexOf(b)>-1)return!0;return!1}});var rb=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":Array.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(rb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:pb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(Array.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var sb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!sb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,sb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(W.get(h,"events")||{})[b.type]&&W.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&U(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!U(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=W.access(d,b);e||d.addEventListener(a,c,!0),W.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=W.access(d,b)-1;e?W.access(d,b,e):(d.removeEventListener(a,c,!0),W.remove(d,b))}}});var tb=a.location,ub=r.now(),vb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var wb=/\[\]$/,xb=/\r?\n/g,yb=/^(?:submit|button|image|reset|file)$/i,zb=/^(?:input|select|textarea|keygen)/i;function Ab(a,b,c,d){var e;if(Array.isArray(b))r.each(b,function(b,e){c||wb.test(a)?d(a,e):Ab(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)Ab(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(Array.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)Ab(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&zb.test(this.nodeName)&&!yb.test(a)&&(this.checked||!ja.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:Array.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(xb,"\r\n")}}):{name:b.name,value:c.replace(xb,"\r\n")}}).get()}});var Bb=/%20/g,Cb=/#.*$/,Db=/([?&])_=[^&]*/,Eb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Fb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Gb=/^(?:GET|HEAD)$/,Hb=/^\/\//,Ib={},Jb={},Kb="*/".concat("*"),Lb=d.createElement("a");Lb.href=tb.href;function Mb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(L)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Nb(a,b,c,d){var e={},f=a===Jb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Ob(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Pb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Qb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:tb.href,type:"GET",isLocal:Fb.test(tb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Kb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Ob(Ob(a,r.ajaxSettings),b):Ob(r.ajaxSettings,a)},ajaxPrefilter:Mb(Ib),ajaxTransport:Mb(Jb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Eb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||tb.href)+"").replace(Hb,tb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(L)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Lb.protocol+"//"+Lb.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Nb(Ib,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Gb.test(o.type),f=o.url.replace(Cb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(Bb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(vb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Db,"$1"),n=(vb.test(f)?"&":"?")+"_="+ub++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Kb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Nb(Jb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Pb(o,y,d)),v=Qb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Rb={0:200,1223:204},Sb=r.ajaxSettings.xhr();o.cors=!!Sb&&"withCredentials"in Sb,o.ajax=Sb=!!Sb,r.ajaxTransport(function(b){var c,d;if(o.cors||Sb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Rb[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("