diff --git a/airtime_mvc/public/css/fullcalendar.css b/airtime_mvc/public/css/fullcalendar.css index f37cd1ea1..1f02ba428 100644 --- a/airtime_mvc/public/css/fullcalendar.css +++ b/airtime_mvc/public/css/fullcalendar.css @@ -1,7 +1,12 @@ -/*! - * FullCalendar v1.6.2 Stylesheet - * Docs & License: http://arshaw.com/fullcalendar/ - * (c) 2013 Adam Shaw +/* + * FullCalendar v1.5.4 Stylesheet + * + * Copyright (c) 2011 Adam Shaw + * Dual licensed under the MIT and GPL licenses, located in + * MIT-LICENSE.txt and GPL-LICENSE.txt respectively. + * + * Date: Tue Sep 4 23:38:33 2012 -0700 + * */ @@ -74,8 +79,11 @@ html .fc, margin-right: -1px; } -.fc-header .fc-corner-right, /* non-theme */ -.fc-header .ui-corner-right { /* theme */ +.fc-header .fc-corner-right { + margin-right: 1px; /* back to normal */ + } + +.fc-header .ui-corner-right { margin-right: 0; /* back to normal */ } @@ -116,17 +124,17 @@ html .fc, .fc-widget-header, /* , usually */ .fc-widget-content { /* , usually */ - border: 1px solid #ddd; + border: 1px solid #ccc; } .fc-state-highlight { /* today cell */ /* TODO: add .fc-today to */ - background: #fcf8e3; + background: #ffc; } .fc-cell-overlay { /* semi-transparent rectangle while dragging */ - background: #bce8f1; - opacity: .3; - filter: alpha(opacity=30); /* for IE */ + background: #9cf; + opacity: .2; + filter: alpha(opacity=20); /* for IE */ } @@ -137,54 +145,43 @@ html .fc, .fc-button { position: relative; display: inline-block; - padding: 0 .6em; - overflow: hidden; - height: 1.9em; - line-height: 1.9em; - white-space: nowrap; cursor: pointer; } .fc-state-default { /* non-theme */ - border: 1px solid; + border-style: solid; + border-width: 1px 0; } - -.fc-state-default.fc-corner-left { /* non-theme */ - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; + +.fc-button-inner { + position: relative; + float: left; + overflow: hidden; } - -.fc-state-default.fc-corner-right { /* non-theme */ - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; + +.fc-state-default .fc-button-inner { /* non-theme */ + border-style: solid; + border-width: 0 1px; } - -/* - Our default prev/next buttons use HTML entities like ‹ › « » - and we'll try to make them look good cross-browser. -*/ - -.fc-text-arrow { - margin: 0 .1em; - font-size: 2em; - font-family: "Courier New", Courier, monospace; - vertical-align: baseline; /* for IE7 */ - } - -.fc-button-prev .fc-text-arrow, -.fc-button-next .fc-text-arrow { /* for ‹ › */ - font-weight: bold; + +.fc-button-content { + position: relative; + float: left; + height: 1.9em; + line-height: 1.9em; + padding: 0 .6em; + white-space: nowrap; } /* icon (for jquery ui) */ -.fc-button .fc-icon-wrap { +.fc-button-content .fc-icon-wrap { position: relative; float: left; top: 50%; } -.fc-button .ui-icon { +.fc-button-content .ui-icon { position: relative; float: left; margin-top: -50%; @@ -192,89 +189,107 @@ html .fc, *top: -50%; } -/* - 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); +/* gloss effect */ + +.fc-state-default .fc-button-effect { + position: absolute; + top: 50%; + left: 0; } - + +.fc-state-default .fc-button-effect span { + position: absolute; + top: -100px; + left: 0; + width: 500px; + height: 100px; + border-width: 100px 0 0 1px; + border-style: solid; + border-color: #fff; + background: #444; + opacity: .09; + filter: alpha(opacity=9); + } + +/* button states (determines colors) */ + +.fc-state-default, +.fc-state-default .fc-button-inner { + border-style: solid; + border-color: #ccc #bbb #aaa; + background: #F3F3F3; + color: #000; + } + .fc-state-hover, +.fc-state-hover .fc-button-inner { + border-color: #999; + } + .fc-state-down, +.fc-state-down .fc-button-inner { + border-color: #555; + background: #777; + } + .fc-state-active, -.fc-state-disabled { - color: #333333; - background-color: #e6e6e6; +.fc-state-active .fc-button-inner { + border-color: #555; + background: #777; + color: #fff; } - -.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-disabled, +.fc-state-disabled .fc-button-inner { + color: #999; + border-color: #ddd; } - -.fc-state-down, -.fc-state-active { - background-color: #cccccc; - background-image: none; - outline: 0; - 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; - filter: alpha(opacity=65); - box-shadow: none; } - + +.fc-state-disabled .fc-button-effect { + display: none; + } + /* Global Event Styles ------------------------------------------------------------------------*/ .fc-event { - border: 1px solid #3a87ad; /* default BORDER color */ - background-color: #3a87ad; /* default BACKGROUND color */ - color: #fff; /* default TEXT color */ + border-style: solid; + border-width: 0; font-size: .85em; cursor: default; } - -a.fc-event { - text-decoration: none; - } a.fc-event, .fc-event-draggable { cursor: pointer; } +a.fc-event { + text-decoration: none; + } + .fc-rtl .fc-event { text-align: right; } - + +.fc-event-skin { + border-color: #36c; /* default BORDER color */ + background-color: #36c; /* default BACKGROUND color */ + color: #fff; /* default TEXT color */ + } + .fc-event-inner { + position: relative; width: 100%; height: 100%; + border-style: solid; + border-width: 0; overflow: hidden; } @@ -283,7 +298,7 @@ a.fc-event, padding: 0 1px; } -.fc .ui-resizable-handle { +.fc .ui-resizable-handle { /*** TODO: don't use ui-resizable anymore, change class ***/ display: block; position: absolute; z-index: 99999; @@ -301,20 +316,6 @@ a.fc-event, border-width: 1px 0; margin-bottom: 1px; } - -.fc-ltr .fc-event-hori.fc-event-start, -.fc-rtl .fc-event-hori.fc-event-end { - border-left-width: 1px; - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; - } - -.fc-ltr .fc-event-hori.fc-event-end, -.fc-rtl .fc-event-hori.fc-event-start { - border-right-width: 1px; - border-top-right-radius: 3px; - border-bottom-right-radius: 3px; - } /* resizable */ @@ -340,6 +341,66 @@ a.fc-event, +/* Fake Rounded Corners (for buttons and events) +------------------------------------------------------------*/ + +.fc-corner-left { + margin-left: 1px; + } + +.fc-corner-left .fc-button-inner, +.fc-corner-left .fc-event-inner { + margin-left: -1px; + } + +.fc-corner-right { + margin-right: 1px; + } + +.fc-corner-right .fc-button-inner, +.fc-corner-right .fc-event-inner { + margin-right: -1px; + } + +.fc-corner-top { + margin-top: 1px; + } + +.fc-corner-top .fc-event-inner { + margin-top: -1px; + } + +.fc-corner-bottom { + margin-bottom: 1px; + } + +.fc-corner-bottom .fc-event-inner { + margin-bottom: -1px; + } + + + +/* Fake Rounded Corners SPECIFICALLY FOR EVENTS +-----------------------------------------------------------------*/ + +.fc-corner-left .fc-event-inner { + border-left-width: 1px; + } + +.fc-corner-right .fc-event-inner { + border-right-width: 1px; + } + +.fc-corner-top .fc-event-inner { + border-top-width: 1px; + } + +.fc-corner-bottom .fc-event-inner { + border-bottom-width: 1px; + } + + + /* Reusable Separate-border Table ------------------------------------------------------------*/ @@ -375,15 +436,6 @@ table.fc-border-separate { .fc-grid th { text-align: center; } - -.fc .fc-week-number { - width: 22px; - text-align: center; - } - -.fc .fc-week-number div { - padding: 0 2px; - } .fc-grid .fc-day-number { float: right; @@ -440,10 +492,6 @@ table.fc-border-separate { white-space: nowrap; font-weight: normal; } - -.fc-agenda .fc-week-number { - font-weight: bold; - } .fc-agenda .fc-day-content { padding: 2px 2px 1px; @@ -518,28 +566,19 @@ table.fc-border-separate { .fc-event-vert { border-width: 0 1px; } - -.fc-event-vert.fc-event-start { - border-top-width: 1px; - border-top-left-radius: 3px; - border-top-right-radius: 3px; - } - -.fc-event-vert.fc-event-end { - border-bottom-width: 1px; - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; + +.fc-event-vert .fc-event-head, +.fc-event-vert .fc-event-content { + position: relative; + z-index: 2; + width: 100%; + overflow: hidden; } .fc-event-vert .fc-event-time { white-space: nowrap; font-size: 10px; } - -.fc-event-vert .fc-event-inner { - position: relative; - z-index: 2; - } .fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay */ position: absolute; @@ -549,8 +588,8 @@ table.fc-border-separate { width: 100%; height: 100%; background: #fff; - opacity: .25; - filter: alpha(opacity=25); + opacity: .3; + filter: alpha(opacity=30); } .fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */ diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index d593f40ae..883b430b6 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -444,28 +444,28 @@ function getCurrentShow(){ * is switching from week view to day view (and vice versa) * the icon may already be there from previous view */ - $el.siblings().remove("span[class=small-icon now-playing]"); + $el.siblings().remove("span.now-playing"); if (!$el.siblings().hasClass("small-icon now-playing")) { if ($el.siblings().hasClass("small-icon recording")) { /* Without removing recording icon, the now playing * icon will overwrite it. */ - $el.siblings().remove("span[class=small-icon recording]"); + $el.siblings().remove("span.recording"); $el.before(''); } else if ($el.siblings().hasClass("small-icon rebroadcast")) { /* Without removing rebroadcast icon, the now playing * icon will overwrite it. */ - $el.siblings().remove("span[class=small-icon rebroadcast]"); + $el.siblings().remove("span.rebroadcast"); $el.before(''); } else { $el.before(''); } } } else if (view_name === 'month') { - if (!$("span[class*=fc-event-title]").siblings().hasClass("small-icon now-playing")) { + if (!$("span[class*=fc-event-title]").siblings().hasClass("now-playing")) { $("span[class*=fc-event-title]").after(''); } } @@ -475,7 +475,7 @@ function getCurrentShow(){ id = $(this).parents("div.fc-event").data("event").id; if (id != json.si_id) { - $(this).remove("span[small-icon now-playing]"); + $(this).remove("span.now-playing"); } }); diff --git a/airtime_mvc/public/js/fullcalendar/fullcalendar.js b/airtime_mvc/public/js/fullcalendar/fullcalendar.js index af3124ea8..d59de77c8 100644 --- a/airtime_mvc/public/js/fullcalendar/fullcalendar.js +++ b/airtime_mvc/public/js/fullcalendar/fullcalendar.js @@ -1,20 +1,23 @@ -/*! - * FullCalendar v1.6.2 - * Docs & License: http://arshaw.com/fullcalendar/ - * (c) 2013 Adam Shaw - */ - -/* +/** + * @preserve + * FullCalendar v1.5.4 + * http://arshaw.com/fullcalendar/ + * * Use fullcalendar.css for basic styling. * For event drag & drop, requires jQuery UI draggable. * For event resizing, requires jQuery UI resizable. + * + * Copyright (c) 2011 Adam Shaw + * Dual licensed under the MIT and GPL licenses, located in + * MIT-LICENSE.txt and GPL-LICENSE.txt respectively. + * + * Date: Tue Sep 4 23:38:33 2012 -0700 + * */ (function($, undefined) { -;; - var defaults = { // display @@ -26,9 +29,6 @@ var defaults = { right: 'today prev,next' }, weekends: true, - weekNumbers: false, - weekNumberCalculation: 'iso', - weekNumberTitle: 'W', // editing //editable: false, @@ -66,10 +66,10 @@ var defaults = { dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'], buttonText: { - prev: "", - next: "", - prevYear: "«", - nextYear: "»", + prev: ' ◄ ', + next: ' ► ', + prevYear: ' << ', + nextYear: ' >> ', today: 'today', month: 'month', week: 'week', @@ -98,10 +98,10 @@ var rtlDefaults = { right: 'title' }, buttonText: { - prev: "", - next: "", - prevYear: "»", - nextYear: "«" + prev: ' ► ', + next: ' ◄ ', + prevYear: ' >> ', + nextYear: ' << ' }, buttonIcons: { prev: 'circle-triangle-e', @@ -111,9 +111,7 @@ var rtlDefaults = { -;; - -var fc = $.fullCalendar = { version: "1.6.2" }; +var fc = $.fullCalendar = { version: "1.5.4" }; var fcViews = fc.views = {}; @@ -179,8 +177,6 @@ function setDefaults(d) { -;; - function Calendar(element, options, eventSources) { var t = this; @@ -262,9 +258,6 @@ function Calendar(element, options, eventSources) { if (options.isRTL) { element.addClass('fc-rtl'); } - else { - element.addClass('fc-ltr'); - } if (options.theme) { element.addClass('ui-widget'); } @@ -681,8 +674,6 @@ function Calendar(element, options, eventSources) { } -;; - function Header(calendar, options) { var t = this; @@ -756,47 +747,54 @@ function Header(calendar, options) { var text = smartProperty(options.buttonText, buttonName); // why are we using smartProperty here? var button = $( "" + - (icon ? - "" + - "" + - "" : - text - ) + + "" + + "" + + (icon ? + "" + + "" + + "" : + text + ) + + "" + + "" + + "" + "" - ) - .click(function() { - if (!button.hasClass(tm + '-state-disabled')) { - buttonClick(); - } - }) - .mousedown(function() { - button - .not('.' + tm + '-state-active') - .not('.' + tm + '-state-disabled') - .addClass(tm + '-state-down'); - }) - .mouseup(function() { - button.removeClass(tm + '-state-down'); - }) - .hover( - function() { + ); + if (button) { + button + .click(function() { + if (!button.hasClass(tm + '-state-disabled')) { + buttonClick(); + } + }) + .mousedown(function() { button .not('.' + tm + '-state-active') .not('.' + tm + '-state-disabled') - .addClass(tm + '-state-hover'); - }, - function() { - button - .removeClass(tm + '-state-hover') - .removeClass(tm + '-state-down'); - } - ) - .appendTo(e); - disableTextSelection(button); - if (!prevButton) { - button.addClass(tm + '-corner-left'); + .addClass(tm + '-state-down'); + }) + .mouseup(function() { + button.removeClass(tm + '-state-down'); + }) + .hover( + function() { + button + .not('.' + tm + '-state-active') + .not('.' + tm + '-state-disabled') + .addClass(tm + '-state-hover'); + }, + function() { + button + .removeClass(tm + '-state-hover') + .removeClass(tm + '-state-down'); + } + ) + .appendTo(e); + if (!prevButton) { + button.addClass(tm + '-corner-left'); + } + prevButton = button; } - prevButton = button; } } }); @@ -841,8 +839,6 @@ function Header(calendar, options) { } -;; - fc.sourceNormalizers = []; fc.sourceFetchers = []; @@ -918,16 +914,6 @@ function EventManager(options, _sources) { _fetchEventSource(source, function(events) { if (fetchID == currentFetchID) { if (events) { - - if (options.eventDataTransform) { - events = $.map(events, options.eventDataTransform); - } - if (source.eventDataTransform) { - events = $.map(events, source.eventDataTransform); - } - // TODO: this technique is not ideal for static array event sources. - // For arrays, we'll want to process all events right in the beginning, then never again. - for (var i=0; i seg2.start && seg1.start < seg2.end; +} + + + +/* Event Sorting +-----------------------------------------------------------------------------*/ + + +// event rendering utilities +function sliceSegs(events, visEventEnds, start, end) { + var segs = [], + i, len=events.length, event, + eventStart, eventEnd, + segStart, segEnd, + isStart, isEnd; + for (i=0; i start && eventStart < end) { + if (eventStart < start) { + segStart = cloneDate(start); + isStart = false; + }else{ + segStart = eventStart; + isStart = true; + } + if (eventEnd > end) { + segEnd = cloneDate(end); + isEnd = false; + }else{ + segEnd = eventEnd; + isEnd = true; + } + segs.push({ + event: event, + start: segStart, + end: segEnd, + isStart: isStart, + isEnd: isEnd, + msLength: segEnd - segStart + }); + } + } + return segs.sort(segCmp); +} + + +// event rendering calculation utilities +function stackSegs(segs) { + var levels = [], + i, len = segs.length, seg, + j, collide, k; + for (i=0; i" + + "" + + ""; + for (i=0; i"; // need fc- for setDayID + } + s += + "" + + "" + + ""; + for (i=0; i"; + for (j=0; j" + // need fc- for setDayID + "
" + + (showNumbers ? + "
" : + '' + ) + + "
" + + "
 
" + + "
" + + "
" + + ""; + } + s += + ""; + } + s += + "" + + ""; + table = $(s).appendTo(element); + + head = table.find('thead'); + headCells = head.find('th'); + body = table.find('tbody'); + bodyRows = body.find('tr'); + bodyCells = body.find('td'); + bodyFirstCells = bodyCells.filter(':first-child'); + bodyCellTopInners = bodyRows.eq(0).find('div.fc-day-content div'); + + markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's + markFirstLast(bodyRows); // marks first+last td's + bodyRows.eq(0).addClass('fc-first'); // fc-last is done in updateCells + + dayBind(bodyCells); + daySegmentContainer = $("
") .appendTo(element); } - function buildTable() { - var html = buildTableHTML(); - - lockHeight(); // the unlock happens later, in setHeight()... - if (table) { - table.remove(); - } - table = $(html).appendTo(element); - - head = table.find('thead'); - headCells = head.find('.fc-day-header'); - body = table.find('tbody'); - bodyRows = body.find('tr'); - bodyCells = body.find('.fc-day'); - bodyFirstCells = bodyRows.find('td:first-child'); - - firstRowCellInners = bodyRows.eq(0).find('.fc-day > div'); - firstRowCellContentInners = bodyRows.eq(0).find('.fc-day-content > div'); - - markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's - markFirstLast(bodyRows); // marks first+last td's - bodyRows.eq(0).addClass('fc-first'); - bodyRows.filter(':last').addClass('fc-last'); - - bodyCells.each(function(i, _cell) { - var date = cellToDate( - Math.floor(i / colCnt), - i % colCnt - ); - trigger('dayRender', t, date, $(_cell)); - }); - - dayBind(bodyCells); - } - - - - /* HTML Building - -----------------------------------------------------------*/ - - - function buildTableHTML() { - var html = - "" + - buildHeadHTML() + - buildBodyHTML() + - "
"; - - return html; - } - - - function buildHeadHTML() { - var headerClass = tm + "-widget-header"; - var html = ''; - var col; - var date; - - html += ""; - - if (showWeekNumbers) { - html += - "" + - htmlEscape(weekNumberTitle) + - ""; - } - - for (col=0; col" + - htmlEscape(formatDate(date, colFormat)) + - ""; - } - - html += ""; - - return html; - } - - - function buildBodyHTML() { - var contentClass = tm + "-widget-content"; - var html = ''; - var row; - var col; - var date; - - html += ""; - - for (row=0; row" + - "
" + - htmlEscape(formatDate(date, weekNumberFormat)) + - "
" + - ""; - } - - for (col=0; col" + - "
"; - - if (showNumbers) { - html += "
" + date.getDate() + "
"; - } - - html += - "
" + - "
 
" + - "
" + - "
" + - ""; - - return html; + + bodyCells.each(function(i, _cell) { + cell = $(_cell); + date = indexDate(i); + if (date.getMonth() == month) { + cell.removeClass('fc-other-month'); + }else{ + cell.addClass('fc-other-month'); + } + if (+date == +today) { + cell.addClass(tm + '-state-highlight fc-today'); + }else{ + cell.removeClass(tm + '-state-highlight fc-today'); + } + cell.find('div.fc-day-number').text(date.getDate()); + if (dowDirty) { + setDayID(cell, date); + } + }); + + bodyRows.each(function(i, _row) { + row = $(_row); + if (i < rowCnt) { + row.show(); + if (i == rowCnt-1) { + row.addClass('fc-last'); + }else{ + row.removeClass('fc-last'); + } + }else{ + row.hide(); + } + }); } - - - - /* Dimensions - -----------------------------------------------------------*/ + function setHeight(height) { @@ -2378,21 +2348,13 @@ function BasicView(element, calendar, viewName) { } }); - unlockHeight(); } function setWidth(width) { viewWidth = width; - colPositions.clear(); colContentPositions.clear(); - - weekNumberWidth = 0; - if (showWeekNumbers) { - weekNumberWidth = head.find('th.fc-week-number').outerWidth(); - } - - colWidth = Math.floor((viewWidth - weekNumberWidth) / colCnt); + colWidth = Math.floor(viewWidth / colCnt); setOuterWidth(headCells.slice(0, -1), colWidth); } @@ -2410,7 +2372,8 @@ function BasicView(element, calendar, viewName) { function dayClick(ev) { if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick - var date = parseISO8601($(this).data('date')); + var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data + var date = indexDate(index); trigger('dayClick', this, date, true, ev); } } @@ -2419,30 +2382,35 @@ function BasicView(element, calendar, viewName) { /* Semi-transparent Overlay Helpers ------------------------------------------------------*/ - // TODO: should be consolidated with AgendaView's methods - - + + function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive - if (refreshCoordinateGrid) { coordinateGrid.build(); } - - var segments = rangeToSegments(overlayStart, overlayEnd); - - for (var i=0; i" + + "" + + "" + + " "; + for (i=0; i"; // fc- needed for setDayID + } + s += + " " + + "" + + "" + + "" + + "" + + " "; + for (i=0; i" + // fc- needed for setDayID + "
" + + "
" + + "
 
" + + "
" + + "
" + + ""; + } + s += + " " + + "" + + "" + + ""; + dayTable = $(s).appendTo(element); + dayHead = dayTable.find('thead'); + dayHeadCells = dayHead.find('th').slice(1, -1); + dayBody = dayTable.find('tbody'); + dayBodyCells = dayBody.find('td').slice(0, -1); + dayBodyCellInners = dayBodyCells.find('div.fc-day-content div'); + dayBodyFirstCell = dayBodyCells.eq(0); + dayBodyFirstCellStretcher = dayBodyFirstCell.find('> div'); + + markFirstLast(dayHead.add(dayHead.find('tr'))); + markFirstLast(dayBody.add(dayBody.find('tr'))); + + axisFirstCells = dayHead.find('th:first'); + gutterCells = dayTable.find('.fc-agenda-gutter'); slotLayer = $("
") @@ -2935,6 +3040,9 @@ function AgendaView(element, calendar, viewName) { dayBind(allDayRow.find('td')); + axisFirstCells = axisFirstCells.add(allDayTable.find('th:first')); + gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter')); + slotLayer.append( "
" + "
" + @@ -2951,13 +3059,13 @@ function AgendaView(element, calendar, viewName) { $("
") .appendTo(slotLayer); - slotContainer = + slotContent = $("
") .appendTo(slotScroller); slotSegmentContainer = $("
") - .appendTo(slotContainer); + .appendTo(slotContent); s = "" + @@ -2983,162 +3091,37 @@ function AgendaView(element, calendar, viewName) { s += "" + "
"; - slotTable = $(s).appendTo(slotContainer); + slotTable = $(s).appendTo(slotContent); slotTableFirstInner = slotTable.find('div:first'); slotBind(slotTable.find('td')); - } - - - - /* Build Day Table - -----------------------------------------------------------------------*/ - - - function buildDayTable() { - var html = buildDayTableHTML(); - - if (dayTable) { - dayTable.remove(); - } - dayTable = $(html).appendTo(element); - - dayHead = dayTable.find('thead'); - dayHeadCells = dayHead.find('th').slice(1, -1); // exclude gutter - dayBody = dayTable.find('tbody'); - dayBodyCells = dayBody.find('td').slice(0, -1); // exclude gutter - dayBodyCellInners = dayBodyCells.find('> div'); - dayBodyCellContentInners = dayBodyCells.find('.fc-day-content > div'); - - dayBodyFirstCell = dayBodyCells.eq(0); - dayBodyFirstCellStretcher = dayBodyCellInners.eq(0); - markFirstLast(dayHead.add(dayHead.find('tr'))); - markFirstLast(dayBody.add(dayBody.find('tr'))); - - // TODO: now that we rebuild the cells every time, we should call dayRender + axisFirstCells = axisFirstCells.add(slotTable.find('th:first')); } - - - function buildDayTableHTML() { - var html = - "" + - buildDayTableHeadHTML() + - buildDayTableBodyHTML() + - "
"; - - return html; - } - - - function buildDayTableHeadHTML() { - var headerClass = tm + "-widget-header"; - var date; - var html = ''; - var weekText; - var col; - - html += - "" + - ""; - - if (showWeekNumbers) { - weekText = formatDate(date, weekNumberFormat); - if (rtl) { - weekText += weekNumberTitle; - } - else { - weekText = weekNumberTitle + weekText; - } - html += - "" + - htmlEscape(weekText) + - ""; - } - else { - html += " "; - } - - for (col=0; col" + - htmlEscape(formatDate(date, colFormat)) + - ""; - } - - html += - " " + - "" + - ""; - - return html; - } - - - function buildDayTableBodyHTML() { - var headerClass = tm + "-widget-header"; // TODO: make these when updateOptions() called - var contentClass = tm + "-widget-content"; + + + + function updateCells() { + var i; + var headCell; + var bodyCell; var date; var today = clearTime(new Date()); - var col; - var cellsHTML; - var cellHTML; - var classNames; - var html = ''; - - html += - "" + - "" + - " "; - - cellsHTML = ''; - - for (col=0; col" + - "
" + - "
" + - "
 
" + - "
" + - "
" + - ""; - - cellsHTML += cellHTML; + setDayID(headCell.add(bodyCell), date); } - - html += cellsHTML; - html += - " " + - "" + - ""; - - return html; } - - - // TODO: data-date on the cells - - /* Dimensions - -----------------------------------------------------------------------*/ - function setHeight(height, dateChanged) { if (height === undefined) { @@ -3153,7 +3136,7 @@ function AgendaView(element, calendar, viewName) { height - headHeight, // when scrollbars slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border ); - + dayBodyFirstCellStretcher .height(bodyHeight - vsides(dayBodyFirstCell)); @@ -3162,9 +3145,6 @@ function AgendaView(element, calendar, viewName) { slotScroller.height(bodyHeight - allDayHeight - 1); slotHeight = slotTableFirstInner.height() + 1; // +1 for border - - snapRatio = opt('slotMinutes') / snapMinutes; - snapHeight = slotHeight / snapRatio; if (dateChanged) { resetScroll(); @@ -3172,16 +3152,10 @@ function AgendaView(element, calendar, viewName) { } + function setWidth(width) { viewWidth = width; - colPositions.clear(); colContentPositions.clear(); - - var axisFirstCells = dayHead.find('th:first'); - if (allDayTable) { - axisFirstCells = axisFirstCells.add(allDayTable.find('th:first')); - } - axisFirstCells = axisFirstCells.add(slotTable.find('th:first')); axisWidth = 0; setOuterWidth( @@ -3193,12 +3167,8 @@ function AgendaView(element, calendar, viewName) { axisWidth ); - var gutterCells = dayTable.find('.fc-agenda-gutter'); - if (allDayTable) { - gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter')); - } - var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7) + //slotTable.width(slotTableWidth); gutterWidth = slotScroller.width() - slotTableWidth; if (gutterWidth) { @@ -3220,10 +3190,6 @@ function AgendaView(element, calendar, viewName) { - /* Scrolling - -----------------------------------------------------------------------*/ - - function resetScroll() { var d0 = zeroDate(); var scrollDate = cloneDate(d0); @@ -3267,7 +3233,7 @@ function AgendaView(element, calendar, viewName) { function slotClick(ev) { if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth)); - var date = cellToDate(0, col); + var date = colDate(col); var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data if (rowMatch) { var mins = parseInt(rowMatch[1]) * opt('slotMinutes'); @@ -3285,26 +3251,26 @@ function AgendaView(element, calendar, viewName) { /* Semi-transparent Overlay Helpers -----------------------------------------------------*/ - // TODO: should be consolidated with BasicView's methods - - - function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive + + function renderDayOverlay(startDate, endDate, refreshCoordinateGrid) { // endDate is exclusive if (refreshCoordinateGrid) { coordinateGrid.build(); } - - var segments = rangeToSegments(overlayStart, overlayEnd); - - for (var i=0; i= 0) { - addMinutes(d, minMinute + slotIndex * snapMinutes); + addMinutes(d, minMinute + slotIndex * opt('slotMinutes')); } return d; } + function colDate(col) { // returns dates with 00:00:00 + return addDays(cloneDate(t.visStart), col*dis+dit); + } + + + function cellIsAllDay(cell) { + return opt('allDaySlot') && !cell.row; + } + + + function dayOfWeekCol(dayOfWeek) { + return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt)*dis+dit; + } + + + + // get the Y coordinate of the given time on the given day (both Date objects) function timePosition(day, time) { // both date objects. day holds 00:00 of current day day = cloneDate(day, true); @@ -3444,6 +3422,14 @@ function AgendaView(element, calendar, viewName) { } + function allDayBounds() { + return { + left: axisWidth, + right: viewWidth - gutterWidth + } + } + + function getAllDayRow(index) { return allDayRow; } @@ -3486,9 +3472,9 @@ function AgendaView(element, calendar, viewName) { var helperOption = opt('selectHelper'); coordinateGrid.build(); if (helperOption) { - var col = dateToCell(startDate).col; + var col = dayDiff(startDate, t.visStart) * dis + dit; if (col >= 0 && col < colCnt) { // only works when times are on same day - var rect = coordinateGrid.rect(0, col, 0, col, slotContainer); // only for horizontal coords + var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords var top = timePosition(startDate, startDate); var bottom = timePosition(startDate, endDate); if (bottom > top) { // protect against selections that are entirely before or after visible range @@ -3503,7 +3489,7 @@ function AgendaView(element, calendar, viewName) { rect.zIndex = 8; selectionHelper = $(helperRes) .css(rect) - .appendTo(slotContainer); + .appendTo(slotContent); } }else{ rect.isStart = true; // conside rect a "seg" now @@ -3522,7 +3508,7 @@ function AgendaView(element, calendar, viewName) { } if (selectionHelper) { slotBind(selectionHelper); - slotContainer.append(selectionHelper); + slotContent.append(selectionHelper); setOuterWidth(selectionHelper, rect.width, true); // needs to be after appended setOuterHeight(selectionHelper, rect.height, true); } @@ -3549,15 +3535,15 @@ function AgendaView(element, calendar, viewName) { var dates; hoverListener.start(function(cell, origCell) { clearSelection(); - if (cell && cell.col == origCell.col && !getIsCellAllDay(cell)) { - var d1 = realCellToDate(origCell); - var d2 = realCellToDate(cell); + if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) { + var d1 = cellDate(origCell); + var d2 = cellDate(cell); dates = [ d1, - addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes + addMinutes(cloneDate(d1), opt('slotMinutes')), d2, - addMinutes(cloneDate(d2), snapMinutes) - ].sort(dateCompare); + addMinutes(cloneDate(d2), opt('slotMinutes')) + ].sort(cmp); renderSlotSelection(dates[0], dates[3]); }else{ dates = null; @@ -3574,10 +3560,10 @@ function AgendaView(element, calendar, viewName) { }); } } - - + + function reportDayClick(date, allDay, ev) { - trigger('dayClick', dayBodyCells[dateToCell(date).col], date, allDay, ev); + trigger('dayClick', dayBodyCells[dayOfWeekCol(date.getDay())], date, allDay, ev); } @@ -3590,10 +3576,10 @@ function AgendaView(element, calendar, viewName) { hoverListener.start(function(cell) { clearOverlays(); if (cell) { - if (getIsCellAllDay(cell)) { + if (cellIsAllDay(cell)) { renderCellOverlay(cell.row, cell.col, cell.row, cell.col); }else{ - var d1 = realCellToDate(cell); + var d1 = cellDate(cell); var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes')); renderSlotOverlay(d1, d2); } @@ -3606,29 +3592,30 @@ function AgendaView(element, calendar, viewName) { var cell = hoverListener.stop(); clearOverlays(); if (cell) { - trigger('drop', _dragElement, realCellToDate(cell), getIsCellAllDay(cell), ev, ui); + trigger('drop', _dragElement, cellDate(cell), cellIsAllDay(cell), ev, ui); } } - + } -;; - function AgendaEventRenderer() { var t = this; // exports t.renderEvents = renderEvents; + t.compileDaySegs = compileDaySegs; // for DayEventRenderer t.clearEvents = clearEvents; t.slotSegHtml = slotSegHtml; + t.bindDaySeg = bindDaySeg; // imports DayEventRenderer.call(t); var opt = t.opt; var trigger = t.trigger; + //var setOverflowHidden = t.setOverflowHidden; var isEventDraggable = t.isEventDraggable; var isEventResizable = t.isEventResizable; var eventEnd = t.eventEnd; @@ -3644,13 +3631,12 @@ function AgendaEventRenderer() { var timePosition = t.timePosition; var colContentLeft = t.colContentLeft; var colContentRight = t.colContentRight; - var cellToDate = t.cellToDate; - var segmentCompare = t.segmentCompare; + var renderDaySegs = t.renderDaySegs; + var resizableDayEvent = t.resizableDayEvent; // TODO: streamline binding architecture var getColCnt = t.getColCnt; var getColWidth = t.getColWidth; - var getSnapHeight = t.getSnapHeight; - var getSnapMinutes = t.getSnapMinutes; - var getSlotContainer = t.getSlotContainer; + var getSlotHeight = t.getSlotHeight; + var getBodyContent = t.getBodyContent; var reportEventElement = t.reportEventElement; var showEvents = t.showEvents; var hideEvents = t.hideEvents; @@ -3658,15 +3644,10 @@ function AgendaEventRenderer() { var eventResize = t.eventResize; var renderDayOverlay = t.renderDayOverlay; var clearOverlays = t.clearOverlays; - var renderDayEvents = t.renderDayEvents; var calendar = t.calendar; var formatDate = calendar.formatDate; var formatDates = calendar.formatDates; - - - // overrides - t.draggableDayEvent = draggableDayEvent; - + /* Rendering @@ -3685,15 +3666,11 @@ function AgendaEventRenderer() { slotEvents.push(events[i]); } } - if (opt('allDaySlot')) { - renderDayEvents(dayEvents, modifiedEventId); + renderDaySegs(compileDaySegs(dayEvents), modifiedEventId); setHeight(); // no params means set to viewHeight } - renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId); - - trigger('eventAfterAllRender'); } @@ -3702,33 +3679,39 @@ function AgendaEventRenderer() { getDaySegmentContainer().empty(); getSlotSegmentContainer().empty(); } - + + + function compileDaySegs(events) { + var levels = stackSegs(sliceSegs(events, $.map(events, exclEndDay), t.visStart, t.visEnd)), + i, levelCnt=levels.length, level, + j, seg, + segs=[]; + for (i=0; i start && eventStart < end) { - if (eventStart < start) { - segStart = cloneDate(start); - isStart = false; - }else{ - segStart = eventStart; - isStart = true; - } - if (eventEnd > end) { - segEnd = cloneDate(end); - isEnd = false; - }else{ - segEnd = eventEnd; - isEnd = true; - } - segs.push({ - event: event, - start: segStart, - end: segEnd, - isStart: isStart, - isEnd: isEnd, - msLength: segEnd - segStart - }); - } - } - return segs.sort(segmentCompare); - } - - + + function slotEventEnd(event) { if (event.end) { return cloneDate(event.end); @@ -3792,8 +3737,6 @@ function AgendaEventRenderer() { // renders events in the 'time slots' at the bottom - // TODO: when we refactor this, when user returns `false` eventRender, don't have empty space - // TODO: refactor will include using pixels to detect collisions instead of dates (handy for seg cmp) function renderSlotSegs(segs, modifiedEventId) { @@ -3810,15 +3753,21 @@ function AgendaEventRenderer() { eventElements, eventElement, triggerRes, - titleElement, + vsideCache={}, + hsideCache={}, + key, val, + contentElement, height, slotSegmentContainer = getSlotSegmentContainer(), - rtl, dis; + rtl, dis, dit, + colCnt = getColCnt(); if (rtl = opt('isRTL')) { dis = -1; + dit = colCnt - 1; }else{ dis = 1; + dit = 0; } // calculate position/dimensions, create html @@ -3830,8 +3779,8 @@ function AgendaEventRenderer() { colI = seg.col; levelI = seg.level; forward = seg.forward || 0; - leftmost = colContentLeft(colI); - availWidth = colContentRight(colI) - leftmost; + leftmost = colContentLeft(colI*dis + dit); + availWidth = colContentRight(colI*dis + dit) - leftmost; availWidth = Math.min(availWidth-6, availWidth*.95); // TODO: move this to CSS if (levelI) { // indented and thin @@ -3892,11 +3841,13 @@ function AgendaEventRenderer() { for (i=0; i" + - "
" + + "
" + + "
" + "
" + htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) + "
" + + "
" + + "
" + "
" + htmlEscape(event.title) + "
" + "
" + - "
"; + "
" + + "
"; // close inner if (seg.isEnd && isEventResizable(event)) { html += "
=
"; @@ -3969,6 +3925,18 @@ function AgendaEventRenderer() { } + function bindDaySeg(event, eventElement, seg) { + if (isEventDraggable(event)) { + draggableDayEvent(event, eventElement, seg.isStart); + } + if (seg.isEnd && isEventResizable(event)) { + resizableDayEvent(event, eventElement, seg); + } + eventElementHandlers(event, eventElement); + // needs to be after, because resizableDayEvent might stopImmediatePropagation on click + } + + function bindSlotSeg(event, eventElement, seg) { var timeElement = eventElement.find('div.fc-event-time'); if (isEventDraggable(event)) { @@ -3987,19 +3955,16 @@ function AgendaEventRenderer() { // when event starts out FULL-DAY - // overrides DayEventRenderer's version because it needs to account for dragging elements - // to and from the slot area. - function draggableDayEvent(event, eventElement, seg) { - var isStart = seg.isStart; + function draggableDayEvent(event, eventElement, isStart) { var origWidth; var revert; - var allDay = true; + var allDay=true; var dayDelta; + var dis = opt('isRTL') ? -1 : 1; var hoverListener = getHoverListener(); var colWidth = getColWidth(); - var snapHeight = getSnapHeight(); - var snapMinutes = getSnapMinutes(); + var slotHeight = getSlotHeight(); var minMinute = getMinMinute(); eventElement.draggable({ zIndex: 9, @@ -4009,13 +3974,12 @@ function AgendaEventRenderer() { trigger('eventDragStart', eventElement, event, ev, ui); hideEvents(event, eventElement); origWidth = eventElement.width(); - hoverListener.start(function(cell, origCell) { + hoverListener.start(function(cell, origCell, rowDelta, colDelta) { clearOverlays(); if (cell) { + //setOverflowHidden(true); revert = false; - var origDate = cellToDate(0, origCell.col); - var date = cellToDate(0, cell.col); - dayDelta = dayDiff(date, origDate); + dayDelta = colDelta * dis; if (!cell.row) { // on full-days renderDayOverlay( @@ -4031,9 +3995,9 @@ function AgendaEventRenderer() { eventElement.width(colWidth - 10); // don't use entire width setOuterHeight( eventElement, - snapHeight * Math.round( - (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) / - snapMinutes + slotHeight * Math.round( + (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) + / opt('slotMinutes') ) ); eventElement.draggable('option', 'grid', [colWidth, 1]); @@ -4046,6 +4010,7 @@ function AgendaEventRenderer() { revert = revert || (allDay && !dayDelta); }else{ resetElement(); + //setOverflowHidden(false); revert = true; } eventElement.draggable('option', 'revert', revert); @@ -4064,13 +4029,14 @@ function AgendaEventRenderer() { // changed! var minuteDelta = 0; if (!allDay) { - minuteDelta = Math.round((eventElement.offset().top - getSlotContainer().offset().top) / snapHeight) - * snapMinutes + minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / slotHeight) + * opt('slotMinutes') + minMinute - (event.start.getHours() * 60 + event.start.getMinutes()); } eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui); } + //setOverflowHidden(false); } }); function resetElement() { @@ -4089,19 +4055,19 @@ function AgendaEventRenderer() { function draggableSlotEvent(event, eventElement, timeElement) { var origPosition; - var allDay = false; + var allDay=false; var dayDelta; var minuteDelta; var prevMinuteDelta; + var dis = opt('isRTL') ? -1 : 1; var hoverListener = getHoverListener(); var colCnt = getColCnt(); var colWidth = getColWidth(); - var snapHeight = getSnapHeight(); - var snapMinutes = getSnapMinutes(); + var slotHeight = getSlotHeight(); eventElement.draggable({ zIndex: 9, scroll: false, - grid: [colWidth, snapHeight], + grid: [colWidth, slotHeight], axis: colCnt==1 ? 'y' : false, opacity: opt('dragOpacity'), revertDuration: opt('dragRevertDuration'), @@ -4110,13 +4076,11 @@ function AgendaEventRenderer() { hideEvents(event, eventElement); origPosition = eventElement.position(); minuteDelta = prevMinuteDelta = 0; - hoverListener.start(function(cell, origCell) { + hoverListener.start(function(cell, origCell, rowDelta, colDelta) { eventElement.draggable('option', 'revert', !cell); clearOverlays(); if (cell) { - var origDate = cellToDate(0, origCell.col); - var date = cellToDate(0, cell.col); - dayDelta = dayDiff(date, origDate); + dayDelta = colDelta * dis; if (opt('allDaySlot') && !cell.row) { // over full days if (!allDay) { @@ -4137,7 +4101,7 @@ function AgendaEventRenderer() { }, ev, 'drag'); }, drag: function(ev, ui) { - minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes; + minuteDelta = Math.round((ui.position.top - origPosition.top) / slotHeight) * opt('slotMinutes'); if (minuteDelta != prevMinuteDelta) { if (!allDay) { updateTimeText(minuteDelta); @@ -4174,7 +4138,7 @@ function AgendaEventRenderer() { // convert back to original slot-event if (allDay) { timeElement.css('display', ''); // show() was causing display=inline - eventElement.draggable('option', 'grid', [colWidth, snapHeight]); + eventElement.draggable('option', 'grid', [colWidth, slotHeight]); allDay = false; } } @@ -4187,39 +4151,38 @@ function AgendaEventRenderer() { function resizableSlotEvent(event, eventElement, timeElement) { - var snapDelta, prevSnapDelta; - var snapHeight = getSnapHeight(); - var snapMinutes = getSnapMinutes(); + var slotDelta, prevSlotDelta; + var slotHeight = getSlotHeight(); eventElement.resizable({ handles: { - s: '.ui-resizable-handle' + s: 'div.ui-resizable-s' }, - grid: snapHeight, + grid: slotHeight, start: function(ev, ui) { - snapDelta = prevSnapDelta = 0; + slotDelta = prevSlotDelta = 0; hideEvents(event, eventElement); eventElement.css('z-index', 9); trigger('eventResizeStart', this, event, ev, ui); }, resize: function(ev, ui) { // don't rely on ui.size.height, doesn't take grid into account - snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight); - if (snapDelta != prevSnapDelta) { + slotDelta = Math.round((Math.max(slotHeight, eventElement.height()) - ui.originalSize.height) / slotHeight); + if (slotDelta != prevSlotDelta) { timeElement.text( formatDates( event.start, - (!snapDelta && !event.end) ? null : // no change, so don't display time range - addMinutes(eventEnd(event), snapMinutes*snapDelta), + (!slotDelta && !event.end) ? null : // no change, so don't display time range + addMinutes(eventEnd(event), opt('slotMinutes')*slotDelta), opt('timeFormat') ) ); - prevSnapDelta = snapDelta; + prevSlotDelta = slotDelta; } }, stop: function(ev, ui) { trigger('eventResizeStop', this, event, ev, ui); - if (snapDelta) { - eventResize(this, event, 0, snapMinutes*snapDelta, ev, ui); + if (slotDelta) { + eventResize(this, event, 0, opt('slotMinutes')*slotDelta, ev, ui); }else{ eventElement.css('z-index', 8); showEvents(event, eventElement); @@ -4233,45 +4196,6 @@ function AgendaEventRenderer() { } - -/* Agenda Event Segment Utilities ------------------------------------------------------------------------------*/ -// TODO: maybe somehow consolidate this with DayEventRenderer's segment system - - -function stackAgendaSegs(segs) { - var levels = [], - i, len = segs.length, seg, - j, collide, k; - for (i=0; i0; i--) { @@ -4280,7 +4204,7 @@ function countForwardSegs(levels) { segForward = level[j]; for (k=0; k seg2.start && seg1.start < seg2.end; -} - - -;; function View(element, calendar, viewName) { @@ -4307,6 +4225,7 @@ function View(element, calendar, viewName) { t.name = viewName; t.opt = opt; t.trigger = trigger; + //t.setOverflowHidden = setOverflowHidden; t.isEventDraggable = isEventDraggable; t.isEventResizable = isEventResizable; t.reportEvents = reportEvents; @@ -4339,7 +4258,7 @@ function View(element, calendar, viewName) { function opt(name, viewNameOverride) { var v = options[name]; - if ($.isPlainObject(v)) { + if (typeof v == 'object') { return smartProperty(v, viewNameOverride || viewName); } return v; @@ -4353,11 +4272,13 @@ function View(element, calendar, viewName) { ); } - - - /* Event Editable Boolean Calculations - - ------------------------------------------------------------------------------*/ + + /* + function setOverflowHidden(bool) { + element.css('overflow', bool ? 'hidden' : ''); + } + */ + function isEventDraggable(event) { return isEventEditable(event) && !opt('disableDragging'); @@ -4543,311 +4464,17 @@ function View(element, calendar, viewName) { normalizeEvent(e, options); } } - - - - // ==================================================================================================== - // Utilities for day "cells" - // ==================================================================================================== - // The "basic" views are completely made up of day cells. - // The "agenda" views have day cells at the top "all day" slot. - // This was the obvious common place to put these utilities, but they should be abstracted out into - // a more meaningful class (like DayEventRenderer). - // ==================================================================================================== - - - // For determining how a given "cell" translates into a "date": - // - // 1. Convert the "cell" (row and column) into a "cell offset" (the # of the cell, cronologically from the first). - // Keep in mind that column indices are inverted with isRTL. This is taken into account. - // - // 2. Convert the "cell offset" to a "day offset" (the # of days since the first visible day in the view). - // - // 3. Convert the "day offset" into a "date" (a JavaScript Date object). - // - // The reverse transformation happens when transforming a date into a cell. - - - // exports - t.isHiddenDay = isHiddenDay; - t.skipHiddenDays = skipHiddenDays; - t.getCellsPerWeek = getCellsPerWeek; - t.dateToCell = dateToCell; - t.dateToDayOffset = dateToDayOffset; - t.dayOffsetToCellOffset = dayOffsetToCellOffset; - t.cellOffsetToCell = cellOffsetToCell; - t.cellToDate = cellToDate; - t.cellToCellOffset = cellToCellOffset; - t.cellOffsetToDayOffset = cellOffsetToDayOffset; - t.dayOffsetToDate = dayOffsetToDate; - t.rangeToSegments = rangeToSegments; - t.segmentCompare = segmentCompare; - - - // internals - var hiddenDays = 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 cellsPerWeek; - var dayToCellMap = []; // hash from dayIndex -> cellIndex, for one week - var cellToDayMap = []; // hash from cellIndex -> dayIndex, for one week - var isRTL = opt('isRTL'); - - - // initialize important internal variables - (function() { - - if (opt('weekends') === false) { - hiddenDays.push(0, 6); // 0=sunday, 6=saturday - } - - // Loop through a hypothetical week and determine which - // days-of-week are hidden. Record in both hashes (one is the reverse of the other). - for (var dayIndex=0, cellIndex=0; dayIndex<7; dayIndex++) { - dayToCellMap[dayIndex] = cellIndex; - isHiddenDayHash[dayIndex] = $.inArray(dayIndex, hiddenDays) != -1; - if (!isHiddenDayHash[dayIndex]) { - cellToDayMap[cellIndex] = dayIndex; - cellIndex++; - } - } - - cellsPerWeek = cellIndex; - if (!cellsPerWeek) { - throw 'invalid hiddenDays'; // all days were hidden? bad. - } - - })(); - - - // Is the current day hidden? - // `day` is a day-of-week index (0-6), or a Date object - function isHiddenDay(day) { - if (typeof day == 'object') { - day = day.getDay(); - } - return isHiddenDayHash[day]; - } - - - function getCellsPerWeek() { - return cellsPerWeek; - } - - - // Keep incrementing the current day until it is no longer a hidden day. - // 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) - function skipHiddenDays(date, inc, isExclusive) { - inc = inc || 1; - while ( - isHiddenDayHash[ ( date.getDay() + (isExclusive ? inc : 0) + 7 ) % 7 ] - ) { - addDays(date, inc); - } - } - - - // - // TRANSFORMATIONS: cell -> cell offset -> day offset -> date - // - - // cell -> date (combines all transformations) - // Possible arguments: - // - row, col - // - { row:#, col: # } - function cellToDate() { - var cellOffset = cellToCellOffset.apply(null, arguments); - var dayOffset = cellOffsetToDayOffset(cellOffset); - var date = dayOffsetToDate(dayOffset); - return date; - } - - // cell -> cell offset - // Possible arguments: - // - row, col - // - { row:#, col:# } - function cellToCellOffset(row, col) { - var colCnt = t.getColCnt(); - - // rtl variables. wish we could pre-populate these. but where? - var dis = isRTL ? -1 : 1; - var dit = isRTL ? colCnt - 1 : 0; - - if (typeof row == 'object') { - col = row.col; - row = row.row; - } - var cellOffset = row * colCnt + (col * dis + dit); // column, adjusted for RTL (dis & dit) - - return cellOffset; - } - - // cell offset -> day offset - function cellOffsetToDayOffset(cellOffset) { - var day0 = t.visStart.getDay(); // first date's day of week - cellOffset += dayToCellMap[day0]; // normlize cellOffset to beginning-of-week - return Math.floor(cellOffset / cellsPerWeek) * 7 // # of days from full weeks - + cellToDayMap[ // # of days from partial last week - (cellOffset % cellsPerWeek + cellsPerWeek) % cellsPerWeek // crazy math to handle negative cellOffsets - ] - - day0; // adjustment for beginning-of-week normalization - } - - // day offset -> date (JavaScript Date object) - function dayOffsetToDate(dayOffset) { - var date = cloneDate(t.visStart); - addDays(date, dayOffset); - return date; - } - - - // - // TRANSFORMATIONS: date -> day offset -> cell offset -> cell - // - - // date -> cell (combines all transformations) - function dateToCell(date) { - var dayOffset = dateToDayOffset(date); - var cellOffset = dayOffsetToCellOffset(dayOffset); - var cell = cellOffsetToCell(cellOffset); - return cell; - } - - // date -> day offset - function dateToDayOffset(date) { - return dayDiff(date, t.visStart); - } - - // day offset -> cell offset - function dayOffsetToCellOffset(dayOffset) { - var day0 = t.visStart.getDay(); // first date's day of week - dayOffset += day0; // normalize dayOffset to beginning-of-week - return Math.floor(dayOffset / 7) * cellsPerWeek // # of cells from full weeks - + dayToCellMap[ // # of cells from partial last week - (dayOffset % 7 + 7) % 7 // crazy math to handle negative dayOffsets - ] - - dayToCellMap[day0]; // adjustment for beginning-of-week normalization - } - - // cell offset -> cell (object with row & col keys) - function cellOffsetToCell(cellOffset) { - var colCnt = t.getColCnt(); - - // rtl variables. wish we could pre-populate these. but where? - var dis = isRTL ? -1 : 1; - var dit = isRTL ? colCnt - 1 : 0; - - var row = Math.floor(cellOffset / colCnt); - var col = ((cellOffset % colCnt + colCnt) % colCnt) * dis + dit; // column, adjusted for RTL (dis & dit) - return { - row: row, - col: col - }; - } - - - // - // Converts a date range into an array of segment objects. - // "Segments" are horizontal stretches of time, sliced up by row. - // A segment object has the following properties: - // - row - // - cols - // - isStart - // - isEnd - // - function rangeToSegments(startDate, endDate) { - var rowCnt = t.getRowCnt(); - var colCnt = t.getColCnt(); - var segments = []; // array of segments to return - - // day offset for given date range - var rangeDayOffsetStart = dateToDayOffset(startDate); - var rangeDayOffsetEnd = dateToDayOffset(endDate); // exclusive - - // first and last cell offset for the given date range - // "last" implies inclusivity - var rangeCellOffsetFirst = dayOffsetToCellOffset(rangeDayOffsetStart); - var rangeCellOffsetLast = dayOffsetToCellOffset(rangeDayOffsetEnd) - 1; - - // loop through all the rows in the view - for (var row=0; row