diff --git a/demos/calendar/js/calendar.js b/demos/calendar/js/calendar.js index 9a7b330d..5f2c01cb 100644 --- a/demos/calendar/js/calendar.js +++ b/demos/calendar/js/calendar.js @@ -202,6 +202,6 @@ Ox.load('UI', {debug: true, hideScreen: true, showScreen: true, theme: 'modern'} height: window.innerHeight, width: window.innerWidth, zoom: 4 - }).appendTo(Ox.UI.$body); + }).appendTo(Ox.UI.$body).gainFocus(); }); \ No newline at end of file diff --git a/source/Ox.UI/js/Calendar/Ox.Calendar.js b/source/Ox.UI/js/Calendar/Ox.Calendar.js index ed5aec09..5b638d63 100644 --- a/source/Ox.UI/js/Calendar/Ox.Calendar.js +++ b/source/Ox.UI/js/Calendar/Ox.Calendar.js @@ -583,10 +583,10 @@ Ox.Calendar = function(options, self) { } function getEventElement(event, zoom) { - var left = getPosition(event.start, zoom), + var left = Math.max(getPosition(event.start, zoom), -10000), paddingLeft = (event.type && left < 0 ? -left : 0), - width = Math.max(getPosition(event.end, zoom) - left, 1) - paddingLeft; - //textLeft = (left < 0 ? -left : 0); + width = Ox.limit(getPosition(event.end, zoom) - left, 1, 20000) - paddingLeft; + //Ox.print('LEFT', left, 'WIDTH', width) return new Ox.Element() .addClass('OxEvent' + (event.type ? ' Ox' + Ox.toTitleCase(event.type) : '' ) + @@ -601,20 +601,6 @@ Ox.Calendar = function(options, self) { id: event.id }) .html(' ' + event.name + ' ') - /* - .append( - $('
') - .addClass('OxEventText') - .css({ - position: 'absolute', - width: (width - 4) + 'px', - height: '12px', - padding: '2px', - paddingLeft: textLeft + 'px', - }) - .html(' ' + event.name) - ); - */ } function getEventElementById(id) { @@ -914,8 +900,8 @@ Ox.Calendar = function(options, self) { } function zoomTo(zoom) { - self.options.zoom = zoom; - self.$zoomInput.options({value: zoom}); + self.options.zoom = Ox.limit(zoom, 0, self.maxZoom); + self.$zoomInput.options({value: self.options.zoom}); renderCalendar(); } @@ -933,7 +919,7 @@ Ox.Calendar = function(options, self) { } function getZoom() { var zoom; - Ox.loop(32, 0, function(z) { + Ox.loop(self.maxZoom, 0, function(z) { var calendarDuration = getEventDuration(getCalendarEvent(z)); if (calendarDuration > eventDuration) { zoom = z;