From 453f226b18ff60f1e7fa5af4787c9b3ab7570f39 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 27 May 2011 13:55:48 +0200 Subject: [PATCH] click selects, second click pans, doubleclick zooms --- demos/calendar/js/calendar.js | 8 ++++++++ source/Ox.UI/js/Calendar/Ox.Calendar.js | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/demos/calendar/js/calendar.js b/demos/calendar/js/calendar.js index 2f9367f6..47f43218 100644 --- a/demos/calendar/js/calendar.js +++ b/demos/calendar/js/calendar.js @@ -105,17 +105,24 @@ Ox.load('UI', {debug: true, hideScreen: true, showScreen: true, theme: 'modern'} {name: 'Marie Curie', start: '1867-11-07', end: '1934-07-04', type: 'person'}, {name: 'Mahatma Gandhi', start: '1869-10-02', end: '1948-01-30', type: 'person'}, {name: 'Vladimir Lenin', start: '1870-04-22', end: '1924-01-21', type: 'person'}, + {name: 'Rosa Luxemburg', start: '1871-03-05', end: '1919-01-15', type: 'person'}, + {name: 'Karl Liebknecht', start: '1871-08-13', end: '1919-01-15', type: 'person'}, {name: 'Winston Churchill', start: '1874-11-30', end: '1965-01-24', type: 'person'}, + {name: 'Mata Hari', start: '1876-08-07', end: '1917-10-15', type: 'person'}, + {name: 'Lise Meitner', start: '1878-11-07', end: '1968-10-27', type: 'person'}, {name: 'Josef Stalin', start: '1878-12-18', end: '1953-03-05', type: 'person'}, {name: 'Albert Einstein', start: '1879-03-14', end: '1955-04-18', type: 'person'}, {name: 'Pablo Picasso', start: '1881-10-25', end: '1973-04-08', type: 'person'}, {name: 'Theodor Roosevelt', start: '1882-01-30', end: '1945-04-12', type: 'person'}, {name: 'James Joyce', start: '1882-02-02', end: '1941-01-13', type: 'person'}, + {name: 'Emmy Noether', start: '1882-03-23', end: '1935-04-14', type: 'person'}, {name: 'Franz Kafka', start: '1883-07-03', end: '1924-06-03', type: 'person'}, {name: 'Adolf Hitler', start: '1889-04-20', end: '1945-04-30', type: 'person'}, {name: 'Charles de Gaulle', start: '1890-11-22', end: '1970-11-09', type: 'person'}, {name: 'Walter Benjamin', start: '1892-07-15', end: '1940-09-26', type: 'person'}, {name: 'Mao Zedong', start: '1893-12-26', end: '1976-09-09', type: 'person'}, + {name: 'Antonin Artaud', start: '1896-09-04', end: '1948-03-04', type: 'person'}, + {name: 'Bertolt Brecht', start: '1898-02-10', end: '1956-08-14', type: 'person'}, {name: 'Al Capone', start: '1899-01-17', end: '1947-01-25', type: 'person'}, {name: 'Alfred Hitchcock', start: '1899-08-13', end: '1980-04-29', type: 'person'}, {name: 'Werner Heisenberg', start: '1901-12-05', end: '1976-02-01', type: 'person'}, @@ -159,6 +166,7 @@ Ox.load('UI', {debug: true, hideScreen: true, showScreen: true, theme: 'modern'} {name: 'World Trade Center', start: '1973-04-04', end: '2001-09-11', type: 'place'}, + {name: 'Stone Age', start: '-10000', end: '-3000', type: 'other'}, {name: 'Bronze Age', start: '-3000', end: '-1000', type: 'other'}, {name: 'Iron Age', start: '-1000', end: '500', type: 'other'}, {name: 'Middle Ages', start: '500', end: '1350', type: 'other'}, diff --git a/source/Ox.UI/js/Calendar/Ox.Calendar.js b/source/Ox.UI/js/Calendar/Ox.Calendar.js index 8df65e4f..1bec0b51 100644 --- a/source/Ox.UI/js/Calendar/Ox.Calendar.js +++ b/source/Ox.UI/js/Calendar/Ox.Calendar.js @@ -423,7 +423,12 @@ Ox.Calendar = function(options, self) { } function doubleclick(event, e) { - if ($(e.target).is(':not(.OxLine > .OxEvent)')) { + var $target = $(e.target), + id = $target.data('id'); + if ($target.is('.OxLine > .OxEvent')) { + selectEvent(id, $target); + zoomToSelected(); + } else { if (self.options.zoom < self.maxZoom) { self.options.date = new Date( (+self.options.date + +getMouseDate(e)) / 2 @@ -969,7 +974,11 @@ Ox.Calendar = function(options, self) { var $target = $(e.target), id = $target.data('id'); if ($target.is('.OxLine > .OxEvent')) { - selectEvent(id, $target); + if (id == self.options.selected) { + panToSelected(); + } else { + selectEvent(id, $target); + } } else { selectEvent(''); panTo(getMouseDate(e));