From: Michael J. Rubinsky Date: Wed, 17 Nov 2010 19:41:00 +0000 (-0500) Subject: first stab at populating month view. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=78f6da3e67e55ced2bb4810950e41b9bd09dd783;p=horde.git first stab at populating month view. To do this, semi-implemented caching by porting some of kronolith.js cache code to jquery. Cache still isn't used right now other than as a container to hold current month view, i.e. it's not reused. Still todo: Reuse cache data, validate ajax response for view/request. Tweak month view css Load *initial* month view data (currently it's only triggered after the first month change). --- diff --git a/kronolith/js/mobile.js b/kronolith/js/mobile.js index bb2cc51bd..da75ff485 100644 --- a/kronolith/js/mobile.js +++ b/kronolith/js/mobile.js @@ -1,5 +1,5 @@ /** - * kronolithmobile.js - Base mobile application logic. + * mobile.js - Base mobile application logic. * * Copyright 2010 The Horde Project (http://www.horde.org/) * @@ -12,12 +12,33 @@ * @license http://www.fsf.org/copyleft/gpl.html GPL * @package Kronolith */ - KronolithMobile = { + var KronolithMobile = { + /** + * List of calendars we are displaying + **/ calendars: [], + + /** + * List of calendars that are currently loaded for the current view + **/ loadedCalendars: [], + + /** + * List of events being displayed on the day view + **/ events: [], - eventCache: [], + + /** + * Event cache. For now, only used for month view. + */ + ecache: {}, + cacheStart: null, + cacheEnd: null, + /** + * The currently displayed view + **/ + view: 'day', /** * Perform an Ajax action @@ -38,19 +59,23 @@ * @param Date start * @param Date end */ - loadEvents: function(start, end) + loadEvents: function(start, end, view) { KronolithMobile.loadedCalendars = []; KronolithMobile.events = []; + start = start.toString('yyyyMMdd'); + end = end.toString('yyyyMMdd'); for (cal in KronolithMobile.calendars) { cal = KronolithMobile.calendars[cal]; KronolithMobile.doAction('listEvents', { - 'start': start.toString('yyyyMMdd'), - 'end': end.toString("yyyyMMdd"), - 'cal': cal[0] + '|' + cal[1] + 'start': start, + 'end': end, + 'cal': cal[0] + '|' + cal[1], + 'view': view, + 'sig': start + end + (Math.random() + '').slice(2) }, - KronolithMobile.listEventsCallback + KronolithMobile.loadEventsCallback ); } }, @@ -68,37 +93,58 @@ }, /** - * Callback for the listEvents AJAX request. For now, assume we are in + * Callback for the loadEvents AJAX request. For now, assume we are in * day view, wait for all calendar responses to be received and then build * the event elements in the listview. * + * @TODO: Event caching/view signature checking + * * @param object data The ajax response. */ - listEventsCallback: function(data) + loadEventsCallback: function(data) { - var list; + var start = KronolithMobile.parseDate(data.response.sig.substr(0, 8)), + end = KronolithMobile.parseDate(data.response.sig.substr(8, 8)), + dates = [start, end], list, events; data = data.response; KronolithMobile.loadedCalendars.push(data.cal); - if (data.events) { - $.each(data.events, function(datestring, events) { - $.each(events, function(index, event) { - KronolithMobile.events.push({ 'e': event, 'id': index, 'cal': data.cal }); + + if (KronolithMobile.view == 'day') { + if (data.events) { + $.each(data.events, function(datestring, events) { + $.each(events, function(index, event) { + KronolithMobile.events.push({ 'e': event, 'id': index, 'cal': data.cal }); + }); }); - }); - } + } - if (KronolithMobile.loadedCalendars.length == KronolithMobile.calendars.length) { - var events = KronolithMobile.sortEvents(KronolithMobile.events); - list = $('