'use strict'; $.fn.reverse = [].reverse; function getSides(obj, includeBorder) { var result = {}; if (includeBorder) { result.n = obj.offset().top; result.w = obj.offset().left; result.s = result.n + obj.outerHeight(); result.e = result.w + obj.outerWidth(); } else { result.n = obj.offset().top + parseFloat(obj.css('border-top-width')); result.w = obj.offset().left + parseFloat(obj.css('border-left-width')); result.s = result.n + obj.innerHeight(); result.e = result.w + obj.innerWidth(); } result.top = result.n; result.left = result.w; result.bottom = result.s; result.right = result.e; return result; } function rectanglesIdentical(r1, r2) { return ((Math.floor(Math.abs(r1.n - r2.n)) <= 1) && (Math.floor(Math.abs(r1.s - r2.s)) <= 1) && (Math.floor(Math.abs(r1.e - r2.e)) <= 1) && (Math.floor(Math.abs(r1.w - r2.w)) <= 1)); } function rectanglesOverlap(r1, r2) { instead of <= and >=). ?> return ((Math.round(r1.n - r2.s) < 0) && (Math.round(r1.s - r2.n) > 0) && (Math.round(r1.w - r2.e) < 0) && (Math.round(r1.e - r2.w) > 0)); } function getClosestSide(rectangles, side) { var result = null; rectangles.forEach(function(rectangle) { if (result === null) { result = rectangle[side]; } else if ((side === 'e') || (side === 's')) { result = Math.max(result, rectangle[side]); } else { result = Math.min(result, rectangle[side]); } }); return result; } function getDataName(jqObject) { var possibleNames = ['room', 'date', 'seconds']; for (var i=0; i function uiDummyClone(ui) { return $('
') .css('position', 'absolute') .appendTo($('body')) .offset(ui.position) .width(ui.size.width) .height(ui.size.height); } var Table = { selector: ".dwm_main", borderLeftWidth: undefined, borderTopWidth: undefined, bookedMap: [], grid: {}, getBookingParams: function(el) { var rtl = ($(Table.selector).css('direction').toLowerCase() === 'rtl'), params = {}, data, tolerance = 2, cell = {x: {}, y: {}}, i, axis; cell.x.start = el.offset().left; cell.y.start = el.offset().top; cell.x.end = cell.x.start + el.outerWidth(); cell.y.end = cell.y.start + el.outerHeight(); for (axis in cell) { if (cell.hasOwnProperty(axis)) { data = Table.grid[axis].data; if (params[Table.grid[axis].key] === undefined) { params[Table.grid[axis].key] = []; } if (rtl && (axis==='x')) { for (i = data.length - 1; i >= 0; i--) { if ((data[i].coord + tolerance) < cell[axis].start) { if ((Table.grid[axis].key === 'seconds') || (params[Table.grid[axis].key].length === 0)) { params[Table.grid[axis].key].push(data[i].value); } break; } if ((data[i].coord + tolerance) < cell[axis].end) { params[Table.grid[axis].key].push(data[i].value); } } } else { for (i=0; i cell[axis].end) { if ((Table.grid[axis].key === 'seconds') || (params[Table.grid[axis].key].length === 0)) { params[Table.grid[axis].key].push(data[i].value); } break; } if ((data[i].coord + tolerance) > cell[axis].start) { params[Table.grid[axis].key].push(data[i].value); } } } } } return params; }, getRowNumber: function(y) { for (var i=0; i= Table.grid.y.data[i].coord) && (y < Table.grid.y.data[i+1].coord)) { return i; } } return null; }, clearRowLabels: function() { if (Table.highlightRowLabels.rows !== undefined) { for (var i=0; i < Table.highlightRowLabels.rows.length; i++) { Table.highlightRowLabels.rows[i].removeClass('selected'); } } }, highlightRowLabels: function (el) { if (Table.highlightRowLabels.rows === undefined) { Table.highlightRowLabels.rows = []; $(Table.selector).find('tbody tr').each(function() { Table.highlightRowLabels.rows.push($(this).find('th')); }); } var elStartRow = Table.getRowNumber(el.offset().top); var elEndRow = Table.getRowNumber(el.offset().top + el.outerHeight()); for (var i=0; i init: function() { var table = $(Table.selector); var container = table.parent(); Table.bookedMap = []; table.find('td.booked:visible').add(table.find('.not_allowed').parent()).each(function() { Table.bookedMap.push(getSides($(this))); }); Table.size(); Table.sizeTbodyViewport(); }, outside: function(p) { var headBottoms = $(Table.selector).find('thead').map(function() { return $(this).offset().top + $(this).outerHeight(); }).get(); if (p.y < (Math.max.apply(null, headBottoms))) { return true; } return ((p.x < Table.grid.x.data[0].coord) || (p.y < Table.grid.y.data[0].coord) || (p.x > Table.grid.x.data[Table.grid.x.data.length - 1].coord) || (p.y > Table.grid.y.data[Table.grid.y.data.length - 1].coord) ); }, overlapsBooked: function overlapsBooked(rectangle, stopAtFirst, ignoreRectangle) { var result = []; for (var i=0; i setClipPath: function(ui) { const top = Table.tbodyViewport.top - ui.position.top; const right = ui.position.left + ui.size.width - Table.tbodyViewport.right; const bottom = ui.position.top + ui.size.height - Table.tbodyViewport.bottom; const left = Table.tbodyViewport.left - ui.position.left; let path = 'none'; if ((top > 0) || (right > 0) || (bottom > 0) || (left > 0)) { let offsets = []; offsets.push((top > 0) ? top + 'px' : '0'); offsets.push((right > 0) ? right + 'px' : '0'); offsets.push((bottom > 0) ? bottom + 'px' : '0'); offsets.push((left > 0) ? left + 'px' : '0'); path = 'inset(' + offsets.join(' ') + ')'; } ui.helper.css('clip-path', path); }, scrollContainerBy: function(xCoord, yCoord) { var container = $(Table.selector).parent(); container[0].scrollBy({ top: yCoord, left: xCoord, behavior: 'instant' }); }, scrollDelta: function(e) { const scrollGapX = Math.min(30, Math.floor((Table.tbodyViewport.right - Table.tbodyViewport.left)/2)); const scrollGapY = Math.min(30, Math.floor((Table.tbodyViewport.bottom - Table.tbodyViewport.top)/2)); const table = $(Table.selector); const tableContainer = table.parent(); let result = {x: 0, y: 0}; if ((e.pageY - Table.tbodyViewport.top) < scrollGapY) { result.y = -Math.min(scrollGapY, tableContainer.scrollTop()); } else if ((Table.tbodyViewport.bottom - e.pageY) < scrollGapY) { result.y = Math.min(scrollGapY, table.outerHeight() - tableContainer.outerHeight() - tableContainer.scrollTop()); result.y = Math.max(result.y, 0); if (result.y < 1) { result.y = 0; } } if ((e.pageX - Table.tbodyViewport.left) < scrollGapX) { result.x = -Math.min(scrollGapX, tableContainer.scrollLeft()); } else if ((Table.tbodyViewport.right - e.pageX) < scrollGapX) { result.x = Math.min(scrollGapX, table.outerWidth() - tableContainer.outerWidth() - tableContainer.scrollLeft()); result.x = Math.max(result.x, 0); if (result.x < 1) { result.x = 0; } } return result; }, size: function() { if ((args.view === 'year') || ((args.view === 'week') && args.view_all)) { return; } var table = $(Table.selector); var td = table.find('tbody tr:first-child td:first-of-type'); Table.borderLeftWidth = parseFloat(td.css('border-left-width')); Table.borderTopWidth = parseFloat(td.css('border-top-width')); var rtl = ((table.css('direction') !== undefined) && (table.css('direction').toLowerCase() === 'rtl')); var resolution = table.data('resolution'); Table.grid.x = {}; Table.grid.x.data = []; var columns = table.find('thead tr:first-child th:visible').not('.first_last'); if (rtl) { columns.reverse(); } columns.each(function() { if (Table.grid.x.key === undefined) { Table.grid.x.key = getDataName($(this)); } Table.grid.x.data.push({coord: $(this).offset().left, value: $(this).data(Table.grid.x.key)}); }); if (rtl) { columns.filter(':first').each(function() { var value = null; if (Table.grid.x.key === 'seconds') { value = Table.grid.x.data[0].value + resolution; } var edge = $(this).offset().left; Table.grid.x.data.unshift({coord: edge, value: value}); }); } columns.filter(':last').each(function() { var value = null; if (Table.grid.x.key === 'seconds') { value = Table.grid.x.data[Table.grid.x.data.length - 1].value + resolution; } var edge = $(this).offset().left + $(this).outerWidth(); Table.grid.x.data.push({coord: edge, value: value}); }); Table.grid.y = {}; Table.grid.y.data = []; var rows = table.find('tbody th:first-child'); rows.each(function() { if (Table.grid.y.key === undefined) { Table.grid.y.key = getDataName($(this)); } Table.grid.y.data.push({coord: $(this).offset().top, value: $(this).data(Table.grid.y.key)}); }); rows.filter(':last').each(function() { var value = null; if (Table.grid.y.key === 'seconds') { value = Table.grid.y.data[Table.grid.y.data.length - 1].value + resolution; } Table.grid.y.data.push({coord: $(this).offset().top + $(this).outerHeight(), value: value}); }); }, sizeTbodyViewport: function() { const table = $(Table.selector); const tableContainer = table.parent(); const thead = table.find('thead'); const tfoot = table.find('tfoot'); const tfootHeight = (tfoot.length) ? tfoot.outerHeight() : 0; const tbodyFirstRowTh = table.find('tbody tr:first th'); const tbodyRightTh = tbodyFirstRowTh.eq(2); const tbodyRightThWidth = (tbodyRightTh.length) ? tbodyRightTh.outerWidth() : 0; Table.tbodyViewport = { top: tableContainer.offset().top + thead.outerHeight(), left: tableContainer.offset().left + tbodyFirstRowTh.first().outerWidth(), bottom: tableContainer.offset().top + tableContainer.outerHeight() - tfootHeight, right: tableContainer.offset().left + tableContainer.outerWidth() - tbodyRightThWidth }; }, snapDelta: function (obj, side, force) { if (!['top', 'left', 'bottom', 'right'].includes(side)) { throw new Error("Invalid argument '" + side + "' for parameter side.") } let result = { top: 0, left: 0, width: 0, height: 0 }; const snapGap = 35, tolerance = 2, isLR = (side === 'left') || (side === 'right'), data = (isLR) ? Table.grid.x.data : Table.grid.y.data; let topLeft, bottomRight, gap, gapTopLeft, gapBottomRight; let rectangle = obj.offset(); rectangle.bottom = rectangle.top + obj.innerHeight(); rectangle.right = rectangle.left + obj.innerWidth(); const outerWidth = rectangle.right - rectangle.left, outerHeight = rectangle.bottom - rectangle.top, thisCoord = rectangle[side]; for (let i=0; i<(data.length -1); i++) { topLeft = data[i].coord; bottomRight = data[i+1].coord; if (side === 'left') { topLeft += Table.borderLeftWidth; bottomRight += Table.borderLeftWidth; } else if (side === 'top') { topLeft += Table.borderTopWidth; bottomRight += Table.borderTopWidth; } gapTopLeft = thisCoord - topLeft; gapBottomRight = bottomRight - thisCoord; if (((gapTopLeft > 0) && (gapBottomRight > 0)) || ((i === 0) && (gapTopLeft < 0)) || ((i === (data.length-2)) && (gapBottomRight < 0)) ) { gap = bottomRight - topLeft; if ((force && ((side === 'top') || (side === 'left'))) || (!force && (gapTopLeft <= gap/2) && (gapTopLeft < snapGap))) { switch (side) { case 'top': result.top = topLeft - rectangle.top; result.height = gapTopLeft; break; case 'left': result.left = topLeft - rectangle.left; result.width = gapTopLeft; break; case 'bottom': if ((outerHeight - gapTopLeft) < tolerance) { result.height = gapBottomRight; } else { result.height = -gapTopLeft; } break; case 'right': if ((outerWidth - gapTopLeft) < tolerance) { result.width = gapBottomRight; } else { result.width = -gapTopLeft; } break; } return result; } if ((force && ((side === 'bottom') || (side === 'right'))) || (!force && (gapBottomRight <= gap/2) && (gapBottomRight < snapGap))) { switch (side) { case 'top': if ((outerHeight - gapBottomRight) < tolerance) { result.top = topLeft - rectangle.top; result.height = gapTopLeft; } else { result.top = bottomRight - rectangle.top; result.height = -gapBottomRight; } break; case 'left': if ((outerWidth - gapBottomRight) < tolerance) { result.left = topLeft - rectangle.left; result.width = gapTopLeft; } else { result.left = bottomRight - rectangle.left; result.width = -gapBottomRight; } break; case 'bottom': result.height = gapBottomRight; break; case 'right': result.width = gapBottomRight; break; } return result; } } } return result; }, snapToGrid: function (obj, side, force) { const delta = this.snapDelta(obj, side, force); if ((delta.top !== 0) || (delta.left !==0)) { const offset = obj.offset(); obj.offset({top: offset.top + delta.top, left: offset.left + delta.left}); } if (delta.width !== 0) { obj.outerWidth(obj.outerWidth() + delta.width); } if (delta.height !== 0) { obj.outerHeight(obj.outerHeight() + delta.height); } }, snapUiToGrid: function (ui, side, force) { const obj = uiDummyClone(ui); const delta = this.snapDelta(obj, side, force); obj.remove(); ui.position.top += delta.top; ui.position.left += delta.left; ui.size.width += delta.width; ui.size.height += delta.height; } }; function addScrollPosition(location, object, originalScroll) { if (object.isHScrollable()) { location += '&left=' + encodeURIComponent(Math.min(object.scrollLeft(), originalScroll.left)); } if (object.isVScrollable()) { location += '&top=' + encodeURIComponent(Math.min(object.scrollTop(), originalScroll.top)); } return location; } $.widget('ui.resizable', $.ui.resizable, { options: { scrollableContainer: null, scrollDelta: null }, _mouseDrag: function(event) { if (this.options.scrollableContainer && this.options.scrollDelta) { const delta = this.options.scrollDelta.call(this, event); if (delta.x || delta.y) { this.options.scrollableContainer[0].scrollBy({ top: delta.y, left: delta.x, behavior: 'instant' }); ['originalMousePosition', 'originalPosition', 'position', 'prevPosition'].forEach((property) => { if (delta.x) { this[property].left -= delta.x; } if (delta.y) { this[property].top -= delta.y; } }); const helperOffset = this.helper.offset(); this.helper.css({ top: (helperOffset.top - delta.y) + 'px', left: (helperOffset.left - delta.x) + 'px' }); Table.size(); } } // Invoke the parent widget's _mouseDrag(). return this._super(event); } }); $(document).on('page_ready', function() { if (args.kiosk) { return; } $(Table.selector).on('tableload', function() { var table = $(this); var tableContainer = table.parent(); if ((args.view === 'year') || (args.view === 'month') || ((args.view === 'week') && args.view_all) || table.find('tbody').data('empty')) { return; } Table.init(); var mouseDown = false; var downHandler = function(e) { if ($(e.target).hasClass('not_allowed')) { return; } mouseDown = true; downHandler.originalScroll = { left: tableContainer.scrollLeft(), top: tableContainer.scrollTop() }; table.addClass('resizing'); var jqTarget = $(e.target); if (e.target.nodeName.toLowerCase() === "img") { jqTarget = jqTarget.parent(); } downHandler.origin = jqTarget.offset(); downHandler.firstPosition = {x: e.pageX, y: e.pageY}; or the so play safe and get all possibilities ?> downHandler.originalLink = jqTarget.find('a').addBack('a').attr('href'); downHandler.box = $('
'); if (!args.isBookAdmin) { if (((args.view === 'week') && ) || ((args.view === 'day') && )) { var slotHeight = jqTarget.outerHeight(); downHandler.maxHeightSet = true; downHandler.box.css('max-height', slotHeight + 'px'); var slotWidth = jqTarget.outerWidth(); downHandler.maxWidthSet = true; downHandler.box.css('max-width', slotWidth + 'px'); } } tableContainer.append(downHandler.box); downHandler.box.offset(downHandler.origin); }; var moveHandler = function(e) { if (!mouseDown) { return; } if ((downHandler.maxWidthSet && (e.pageX < downHandler.origin.left)) || (downHandler.maxHeightSet && (e.pageY < downHandler.origin.top))) { return; } const box = downHandler.box; const oldBoxOffset = box.offset(); const oldBoxWidth = box.outerWidth(); const oldBoxHeight = box.outerHeight(); const delta = Table.scrollDelta(e); if (delta.x || delta.y) { Table.scrollContainerBy(delta.x, delta.y); Table.size(); downHandler.firstPosition.x -= delta.x; downHandler.firstPosition.y -= delta.y; oldBoxOffset.left -= delta.x; oldBoxOffset.top -= delta.y; } if (e.pageX < downHandler.firstPosition.x) { if (e.pageY < downHandler.firstPosition.y) { box.offset({top: e.pageY, left: e.pageX}); } else { box.offset({top: downHandler.firstPosition.y, left: e.pageX}); } } else if (e.pageY < downHandler.firstPosition.y) { box.offset({top: e.pageY, left: downHandler.firstPosition.x}); } else { box.offset({top: downHandler.firstPosition.y, left: downHandler.firstPosition.x}); } box.width(Math.abs(e.pageX - downHandler.firstPosition.x)); box.height(Math.abs(e.pageY - downHandler.firstPosition.y)); const draggingDown = (e.pageY > downHandler.firstPosition.y); const draggingRight = (e.pageX > downHandler.firstPosition.x); Table.snapToGrid(box, 'top', draggingDown); Table.snapToGrid(box, 'left', draggingRight); Table.snapToGrid(box, 'bottom', !draggingDown); Table.snapToGrid(box, 'right', !draggingRight); if (Table.overlapsBooked(getSides(box), true).length) { box.offset(oldBoxOffset) .width(oldBoxWidth) .height(oldBoxHeight); } if (Table.outside({x: e.pageX, y: e.pageY})) { if (!moveHandler.outside) { box.addClass('outside'); moveHandler.outside = true; Table.clearRowLabels(); } } else if (moveHandler.outside) { box.removeClass('outside'); moveHandler.outside = false; } if (!moveHandler.outside) { Table.highlightRowLabels(box); } }; var upHandler = function(e) { if (!mouseDown) { return; } mouseDown = false; e.preventDefault(); var tolerance = 2; var box = downHandler.box; var params = Table.getBookingParams(box); $(document).off('mousemove',moveHandler); $(document).off('mouseup', upHandler); if (Table.outside({x: e.pageX, y: e.pageY})) { box.remove(); $(Table.selector).removeClass('resizing'); return; } else if ((Math.abs(e.pageX - downHandler.firstPosition.x) <= tolerance) && (Math.abs(e.pageY - downHandler.firstPosition.y) <= tolerance)) { if (downHandler.originalLink !== undefined) { window.location = addScrollPosition(downHandler.originalLink, tableContainer, downHandler.originalScroll); } else { box.remove(); $(Table.selector).removeClass('resizing'); } return; } var queryString = 'drag=1'; queryString += '&area=' + args.area; queryString += '&start_seconds=' + params.seconds[0]; queryString += '&end_seconds=' + params.seconds[params.seconds.length - 1]; if (args.view === 'day') { for (var i=0; i { queryString += '&rooms[]=' + args.room; queryString += '&start_date=' + params.date[0]; queryString += '&end_date=' + params.date[params.date.length - 1]; } if (args.site) { queryString += '&site=' + encodeURIComponent(args.site); } window.location = addScrollPosition('edit_entry.php?' + queryString, tableContainer, downHandler.originalScroll); }; var resize = function(event, ui) { var closest, rectangle = {}, sides = {n: false, s: false, e: false, w: false}; if (Math.round(ui.position.top - ui.originalPosition.top) === 0) { rectangle.n = ui.position.top; } else { rectangle.n = event.pageY; sides.n = true; } if (Math.round(ui.position.left - ui.originalPosition.left) === 0) { rectangle.w = ui.position.left; } else { rectangle.w = event.pageX; sides.w = true; } if (Math.round((ui.position.top + ui.size.height) - (ui.originalPosition.top + ui.originalSize.height)) === 0) { rectangle.s = ui.position.top + ui.size.height; } else { rectangle.s = event.pageY; sides.s = true; } if (Math.round((ui.position.left + ui.size.width) - (ui.originalPosition.left + ui.originalSize.width)) === 0) { rectangle.e = ui.position.left + ui.size.width; } else { rectangle.e = event.pageX; sides.e = true; } const originalRectangle = { n: ui.originalPosition.top, s: ui.originalPosition.top + ui.originalSize.height, w: ui.originalPosition.left, e: ui.originalPosition.left + ui.originalSize.width }; var overlappedElements = Table.overlapsBooked(rectangle, false, originalRectangle); if (!overlappedElements.length) { ui.element.resizable('option', {maxHeight: null, maxWidth: null}); } else { if (sides.n) { closest = getClosestSide(overlappedElements, 's'); if (event.pageY <= closest) { ui.position.top = closest + Table.borderTopWidth; ui.element.resizable('option', 'maxHeight', ui.originalSize.height + ui.originalPosition.top - ui.position.top); } else { ui.element.resizable('option', 'maxHeight', null); } } if (sides.w) { closest = getClosestSide(overlappedElements, 'e'); if (event.pageX <= closest) { ui.position.left = closest + Table.borderLeftWidth; ui.element.resizable('option', 'maxWidth', ui.originalSize.width + ui.originalPosition.left - ui.position.left); } else { ui.element.resizable('option', 'maxWidth', null); } } if (sides.s) { closest = getClosestSide(overlappedElements, 'n'); if (event.pageY >= closest) { ui.element.resizable('option', 'maxHeight', closest - ui.originalPosition.top); } else { ui.element.resizable('option', 'maxHeight', null); } } if (sides.e) { closest = getClosestSide(overlappedElements, 'w'); if (event.pageX >= closest) { ui.element.resizable('option', 'maxWidth', closest - ui.originalPosition.left); } else { ui.element.resizable('option', 'maxWidth', null); } } } if (sides.w) { Table.snapUiToGrid(ui, 'left'); } if (sides.e) { Table.snapUiToGrid(ui, 'right'); } if (sides.n) { Table.snapUiToGrid(ui, 'top'); } if (sides.s) { Table.snapUiToGrid(ui, 'bottom'); } const obj = uiDummyClone(ui); Table.highlightRowLabels(obj); obj.remove(); Table.setClipPath(ui); }; var resizeStart = function(event, ui) { resizeStart.originalOffset = ui.element.offset(); resizeStart.oldParams = Table.getBookingParams(ui.originalElement.find('a')); table.addClass('resizing'); }; var resizeStop = function(event, ui) { ['left', 'right', 'top', 'bottom'].forEach(function(side) { Table.snapUiToGrid(ui, side, true); }); const originalRectangle = { n: ui.originalPosition.top, s: ui.originalPosition.top + ui.originalSize.height, w: ui.originalPosition.left, e: ui.originalPosition.left + ui.originalSize.width }; if (rectanglesIdentical(originalRectangle, getSides(ui.helper))) { ui.element.css({width: '100%', height: '100%'}); $(Table.selector).removeClass('resizing'); return; } var data = {csrf_token: getCSRFToken(), commit: 1}, booking = ui.element.find('a'); data.id = booking.data('id'); data.type = booking.data('type'); var oldParams = resizeStart.oldParams; var newParams = Table.getBookingParams(booking); if (newParams.seconds !== undefined) { if (newParams.seconds[0] !== oldParams.seconds[0]) { data.start_seconds = newParams.seconds[0]; } if (newParams.seconds[newParams.seconds.length - 1] !== oldParams.seconds[oldParams.seconds.length - 1]) { data.end_seconds = newParams.seconds[newParams.seconds.length - 1]; data.end_seconds -= 60; } } data.view = args.view; data.view_all = args.view_all; if (args.view === 'day') { data.start_date = args.pageDate; } else { data.start_date = newParams.date[0]; var onlyAdminCanBookRepeat = ; if (args.isBookAdmin || !onlyAdminCanBookRepeat) { if (newParams.date.length > 1) { data.rep_type = ; data.rep_interval = 1; data.rep_end_date = newParams.date[newParams.date.length - 1]; } } } data.end_date = data.start_date; data.rooms = (typeof newParams.room === 'undefined') ? args.room : newParams.room; data.timetohighlight = ; booking.addClass('saving') .after(''); if(args.site) { data.site = args.site; } $.post('edit_entry_handler.php', data, function(result) { table.empty() .html(result.table_innerhtml) .trigger('tableload'); if (!result.valid_booking) { var alertMessage = ''; if (result.conflicts.length > 0) { alertMessage += '' + ": \n\n"; var conflictsList = getErrorList(result.conflicts); alertMessage += conflictsList.text; } if (result.violations.errors.length > 0) { if (result.conflicts.length > 0) { alertMessage += "\n\n"; } alertMessage += '' + ": \n\n"; var rulesList = getErrorList(result.violations.errors); alertMessage += rulesList.text; } window.alert(alertMessage); } }, 'json') .fail(function() { booking.removeClass('saving') .next().remove(); ui.element.offset(resizeStart.originalOffset) .width(ui.originalSize.width) .height(ui.originalSize.height); $('table.dwm_main').trigger('tableload'); setTimeout(function() { alert(""); }, 250 ); }); }; table.find('td.new').each(function() { $(this).find('a').on('click', function(event) { event.preventDefault(); }); $(this).on('mousedown', function(event) { event.preventDefault(); downHandler(event); $(document).on('mousemove', moveHandler); $(document).on('mouseup', upHandler); }); }); table.find('.writable') .each(function() { var directions = {times: {plus: true, minus: true}, other: {plus: true, minus: true}}; if ($(this).hasClass('series')) { directions.other = {plus: false, minus: false}; } if (!args.isBookAdmin) { if (((args.view === 'week') && ) || ((args.view === 'day') && )) { directions.other = {plus: false, minus: false}; } if ($(this).hasClass('multiday_start') || $(this).hasClass('multiday_end')) { directions.times = {plus: false, minus: false}; } } if ($(this).hasClass('multiday_start')) { directions.times.minus = false; directions.other = {plus: false, minus: false}; } if ($(this).hasClass('multiday_end')) { directions.times.plus = false; directions.other = {plus: false, minus: false}; } var aHandles = []; if (directions.times.plus) { aHandles.push(''); } if (directions.times.minus) { aHandles.push(''); } if (directions.other.plus) { aHandles.push(''); } if (directions.other.minus) { aHandles.push(''); } ['nw', 'ne', 'se', 'sw'].forEach(function(corner) { if ((aHandles.indexOf(corner[0]) >= 0) && (aHandles.indexOf(corner[1]) >= 0)) { aHandles.push(corner); } }); var handles = aHandles.join(','); if (handles) { $(this).resizable({ handles: handles, helper: 'resizable-helper', start: resizeStart, resize: resize, stop: resizeStop, scrollableContainer: tableContainer, scrollDelta: Table.scrollDelta }); } $(this).css('background-color', 'transparent'); }); $('.ui-resizable-handle') .on('mouseenter', function(e) { if (!mouseDown) { if ($(this).is(':hover')) { table.addClass('resizing'); } else { table.removeClass('resizing'); } } }) .on('mouseleave', function() { if (!mouseDown) { table.removeClass('resizing'); } }) .on('mousedown', function() { mouseDown = true; if ($(this).is(':hover')) { table.addClass('resizing'); } }) .on('mouseup', function() { mouseDown = false; if (!$(this).is(':hover')) { table.removeClass('resizing'); } }) .first().trigger('mouseenter'); }).trigger('tableload'); $(window).on('resize', throttle(function(event) { if (event.target === this) { Table.init(); } }, 50)); $(Table.selector).parent().on('scroll', throttle(function() { Table.init(); })); });