[Tynstep-svn] r244 - in trunk/step: step-core step-core/src/main/java/com/tyndalehouse/step/core/service/impl step-parent step-web step-web/src/main/java/com/tyndalehouse/step/models/timeline/simile step-web/src/main/java/com/tyndalehouse/step/rest/controllers step-web/src/main/webapp/js

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Thu Apr 19 06:07:53 MST 2012


Author: ChrisBurrell
Date: 2012-04-19 06:07:52 -0700 (Thu, 19 Apr 2012)
New Revision: 244

Modified:
   trunk/step/step-core/
   trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java
   trunk/step/step-parent/pom.xml
   trunk/step/step-web/pom.xml
   trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/timeline/simile/SimileTimelineTranslatorImpl.java
   trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/TimelineController.java
   trunk/step/step-web/src/main/webapp/js/timeline.js
Log:
committing changes to timeline


Property changes on: trunk/step/step-core
___________________________________________________________________
Modified: svn:ignore
   - .checkstyle
.checkstyle.config.xml
.classpath
.fbprefs
.pmd
.project
.settings
target
.checkstyle.config.test.xml
.LICENSE.txt

   + .checkstyle
.checkstyle.config.xml
.classpath
.fbprefs
.pmd
.project
.settings
target
.checkstyle.config.test.xml
.LICENSE.txt

db-drop.sql

db-create.sql


Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java	2012-04-18 19:02:04 UTC (rev 243)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java	2012-04-19 13:07:52 UTC (rev 244)
@@ -392,12 +392,15 @@
      * @return the list of matching names
      */
     private List<String> getBooksFromVersification(final String bookStart, final Versification versification) {
+        final String searchPattern = bookStart.toLowerCase();
+
         final List<String> matchingNames = new ArrayList<String>();
         final BibleBookList books = versification.getBooks();
         for (final BibleBook book : books) {
-            if (book.getLongName().startsWith(bookStart) || book.getPreferredName().startsWith(bookStart)
-                    || book.getShortName().startsWith(bookStart)) {
-                matchingNames.add(book.getLongName());
+            if (book.getLongName().toLowerCase().startsWith(searchPattern)
+                    || book.getPreferredName().toLowerCase().startsWith(searchPattern)
+                    || book.getShortName().toLowerCase().startsWith(searchPattern)) {
+                matchingNames.add(book.getShortName());
             }
         }
         return matchingNames;

Modified: trunk/step/step-parent/pom.xml
===================================================================
--- trunk/step/step-parent/pom.xml	2012-04-18 19:02:04 UTC (rev 243)
+++ trunk/step/step-parent/pom.xml	2012-04-19 13:07:52 UTC (rev 244)
@@ -20,9 +20,9 @@
 		<db.driver>org.apache.derby.jdbc.EmbeddedDriver</db.driver>
 		<db.connection.string>jdbc:derby:${db.directory}</db.connection.string>
 
-		<h2.version>1.3.148</h2.version>
-		<derby.version>10.5.3.0_1</derby.version>
-		<junit.version>4.8.2</junit.version>
+		<h2.version>1.3.166</h2.version>
+		<derby.version>10.8.2.2</derby.version>
+		<junit.version>4.10</junit.version>
 
 		<!-- jsword dependencies -->
 		<jsword.version>1.6.1-SNAPSHOT</jsword.version>
@@ -30,34 +30,34 @@
 		<javatar.version>2.5</javatar.version>
 
 		<jackson-mapper-asl.version>1.6.2</jackson-mapper-asl.version>
-		<org.slf4j.version>1.6.1</org.slf4j.version>
+		<org.slf4j.version>1.6.4</org.slf4j.version>
 		<servlet-api.version>2.5</servlet-api.version>
 		<jsp-api.version>2.1</jsp-api.version>
 		<jstl.version>1.2</jstl.version>
-		<pjl-comp-filter.version>1.6.4</pjl-comp-filter.version>
-		<guice.version>2.1.8</guice.version>
-		<guice-servlet.version>2.9.1</guice-servlet.version>
-		<opencsv.version>2.1</opencsv.version>
+		<pjl-comp-filter.version>1.7</pjl-comp-filter.version>
+		<guice.version>3.0.0</guice.version>
+		<guice-servlet.version>3.0</guice-servlet.version>
+		<opencsv.version>2.3</opencsv.version>
 		<jetty.version>6.1.26</jetty.version>
 
 		<joda-time.version>2.1</joda-time.version>
-		<ebean.version>2.7.2</ebean.version>
-		<ehcache.version>2.4.2</ehcache.version>
+		<ebean.version>2.7.5</ebean.version>
+		<ehcache.version>2.5.2</ehcache.version>
 		<lucene.version>3.0.3</lucene.version>
 
 		<!-- Commons -->
 		<commons-beanutils.version>1.8.3</commons-beanutils.version>
-		<commons-lang.version>2.5</commons-lang.version>
+		<commons-lang.version>2.6</commons-lang.version>
 		<commons-collections.version>3.2.1</commons-collections.version>
 		<commons-configuration.version>1.6</commons-configuration.version>
-		<commons-dbcp.version>1.3</commons-dbcp.version>
+		<commons-dbcp.version>1.4</commons-dbcp.version>
 		<commons-io.version>1.4</commons-io.version>
-		<commons-codec.version>1.4</commons-codec.version>
-		<commons-dbutils.version>1.3</commons-dbutils.version>
+		<commons-codec.version>1.6</commons-codec.version>
+		<commons-dbutils.version>1.4</commons-dbutils.version>
 		<commons-httpclient.version>3.1</commons-httpclient.version>
 
 		<!-- testing dependencies -->
-		<mockito.version>1.8.5</mockito.version>
+		<mockito.version>1.9.0</mockito.version>
 	</properties>
 
 	<url>http://crosswire.org/wiki/Frontends:TyndaleStep</url>
@@ -187,7 +187,7 @@
 			</dependency>
 
 			<dependency>
-				<groupId>org.sonatype.sisu.inject</groupId>
+				<groupId>com.google.inject.extensions</groupId>
 				<artifactId>guice-servlet</artifactId>
 				<version>${guice-servlet.version}</version>
 			</dependency>

Modified: trunk/step/step-web/pom.xml
===================================================================
--- trunk/step/step-web/pom.xml	2012-04-18 19:02:04 UTC (rev 243)
+++ trunk/step/step-web/pom.xml	2012-04-19 13:07:52 UTC (rev 244)
@@ -66,7 +66,7 @@
 			<artifactId>guice</artifactId>
 		</dependency>
 		<dependency>
-			<groupId>org.sonatype.sisu.inject</groupId>
+			<groupId>com.google.inject.extensions</groupId>
 			<artifactId>guice-servlet</artifactId>
 		</dependency>
 

Modified: trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/timeline/simile/SimileTimelineTranslatorImpl.java
===================================================================
--- trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/timeline/simile/SimileTimelineTranslatorImpl.java	2012-04-18 19:02:04 UTC (rev 243)
+++ trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/timeline/simile/SimileTimelineTranslatorImpl.java	2012-04-19 13:07:52 UTC (rev 244)
@@ -32,7 +32,7 @@
             e.setTitle(te.getSummary());
             e.setDescription(te.getSummary());
             e.setStart(te.getFromDate().toString());
-            e.setEventId(e.getEventId());
+            e.setEventId(te.getId());
 
             if (te.getHotSpot() != null) {
                 e.setHotSpotId(te.getHotSpot().getId());

Modified: trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/TimelineController.java
===================================================================
--- trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/TimelineController.java	2012-04-18 19:02:04 UTC (rev 243)
+++ trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/TimelineController.java	2012-04-19 13:07:52 UTC (rev 244)
@@ -83,6 +83,8 @@
      * @param from the from date, left-bound
      * @param to the to date, right-bound
      * @return a list of timeline events in format digestable by the UI
+     * 
+     *         TODO going to have to cache this more appropriately, as we'll otherwise hammer the database
      */
     @Cacheable(true)
     public DigestableTimeline getEventsInPeriod(final String from, final String to) {

Modified: trunk/step/step-web/src/main/webapp/js/timeline.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/timeline.js	2012-04-18 19:02:04 UTC (rev 243)
+++ trunk/step/step-web/src/main/webapp/js/timeline.js	2012-04-19 13:07:52 UTC (rev 244)
@@ -19,7 +19,6 @@
 	$(rootElement).hear("show-timeline", function(selfElement, data) {
 		self.passageId = data.passageId;
 		self.active = true;
-		console.log("Showing timeline on passage " + self.passageId);
 
 		// first show the bottom pane...
 		if(!this.initialised) {
@@ -33,32 +32,39 @@
 }
 
 TimelineWidget.prototype.initAndLoad = function() {
+	var self = this;
+	
 	//set up the theme
 	this.theme = Timeline.ClassicTheme.create();
     this.theme.event.bubble.width = 250;
     this.eventSource = new Timeline.DefaultEventSource();
      
-	// let's start with 1 band for now
+    if(!this.initialised) {
+		// let's start with 1 band for now
+	    this.bands = [ Timeline.createBandInfo({
+	       	 trackGap:      100,
+	            width:          "100%", 
+	            intervalUnit:   Timeline.DateTime.WEEK, 
+	            intervalPixels: 150,
+	            eventSource: this.eventSource,
+	            theme: this.theme,
+	        }) ];
 	
-	//setup bands
-    this.bands = [
-	                 Timeline.createBandInfo({
-	                	 trackGap:      100,
-	                     width:          "100%", 
-	                     intervalUnit:   Timeline.DateTime.WEEK, 
-	                     intervalPixels: 150,
-	                     eventSource: this.eventSource,
-	                     theme: this.theme,
-	                 })];
+		//set up timeline
+		this.tl = Timeline.create(this.rootElement[0], this.bands, Timeline.HORIZONTAL);
 
-	//set up timeline
-	this.tl = Timeline.create(this.rootElement[0], this.bands, Timeline.HORIZONTAL);
+		//set up scrollers
+		this.tl.getBand(0).addOnScrollListener(function(band) {
+			self.intelligentScroll(band);
+        });
+		
+		this.initToolbar();
+		
+		// set status as successfully intialised
+		this.initialised = true;
+    }
 	
-	this.initToolbar();
-	
-	// set status as successfully intialised
-	this.initialised = true;
-	this.onLoad();
+    this.onLoad();
 };
 
 
@@ -69,7 +75,6 @@
 	//we only add the event if it is not already on our timeline... 
 
 	if(!(item.eventId in this.currentEvents)) {
-
 		var event = new Timeline.DefaultEventSource.Event({
 			'start' : Timeline.DateTime.parseIso8601DateTime(item.start), 
 			'end' : Timeline.DateTime.parseIso8601DateTime(item.end), 
@@ -79,6 +84,7 @@
 		});
 	
 		this.eventSource.add(event);
+		this.currentEvents[item.eventId] = true;
 	}
 }
 
@@ -102,32 +108,73 @@
 
 	//load events from server
 	$.getSafe(TIMELINE_GET_EVENTS_FROM_REFERENCE + reference, function(data, url) {
-		console.log("Now have " + data.events.length + " to show.");
 		
 		//move timeline to different date
 		//assuming first band is main band
-		self.tl.getBand(0).scrollToCenter(Timeline.DateTime.parseIso8601DateTime(data.suggestedDate));
-		self.addMultipleEventsAndRefresh(data);
 		
-
+		if(data.suggestedDate) {
+			self.tl.getBand(0).setCenterVisibleDate(Timeline.DateTime.parseIso8601DateTime(data.suggestedDate));
+			self.addMultipleEventsAndRefresh(data);			
+		}
+		
 		// now that we have repositioned the timeline, we can try and 
 		// get the other events within the visible time period
-	    $.getSafe(TIMELINE_GET_EVENTS_IN_PERIOD +  
-	    				self.tl.getBand(0).getMinVisibleDate().toISOString() + "/" + 
-	    				self.tl.getBand(0).getMaxVisibleDate().toISOString(), 
-	    				function(data, url) {
-	    	self.addMultipleEventsAndRefresh(data);
-	    });
+		self.showVisibleEvents(self.tl.getBand(0));
 	});
-}
+};
+
+/**
+ * Shows currently visible events on the timeline and refreshes the layout
+ */
+TimelineWidget.prototype.showVisibleEvents = function(band) {
+	var self = this;
 	
+	$.getSafe(TIMELINE_GET_EVENTS_IN_PERIOD +  
+					band.getMinVisibleDate().toISOString() + "/" + 
+					band.getMaxVisibleDate().toISOString(), 
+					function(data, url) {
+		self.addMultipleEventsAndRefresh(data);
+		self.lastRecordedOffset = band.getViewOffset();
+	});
+};
 
-TimelineWidget.prototype.addToolbarIcon = function(toolbar, id, text, iconName) {
-	var html = "<a id='" + id + "'>" + text + "</a>";
+/**
+ * this asks for new events only if we do not already have asked for a similar window
+ * 
+ * say 100px if we can work that out...
+ * 
+ */
+TimelineWidget.prototype.intelligentScroll = function(band) {
+	if(!this.lastRecordedOffset) {
+		this.lastRecordedOffset = 0;
+	}
+	
+	//we lookup from the server if we've moved more than 50px!
+	var currentOffset = band.getViewOffset();
+	var diffOffset = Math.abs(this.lastRecordedOffset - currentOffset);
+	
+	if(diffOffset >= 100) {
+		this.showVisibleEvents(band);		
+	}
+};
+
+
+TimelineWidget.prototype.addToolbarIcon = function(html, toolbar, id, text, iconName) {
 	toolbar.append(html);
 	$("#" + id, toolbar).button({ text: false, icons: { primary: iconName }});
 };
 
+TimelineWidget.prototype.addToolbarButton = function(toolbar, id, text, iconName) {
+	var html = "<a id='" + id + "'>" + text + "</a>";
+	this.addToolbarIcon(html, toolbar, id, text, iconName);
+}
+
+TimelineWidget.prototype.addToolbarToggle = function(toolbar, id, text, iconName) {
+	var html = "<input type='checkbox' id='" + id + "' /><label for='" + id + "'>" + text + "</label>";
+	this.addToolbarIcon(html, toolbar, id, text, iconName);
+};
+
+
 /**
  * Creates a toolbar for the timeline component
  */
@@ -135,12 +182,15 @@
 	var self = this;
 	
 	var toolbar = $("#bottomModuleHeader")
-	this.addToolbarIcon(toolbar, "scrollTimelineLeft", "Scroll left", 'ui-icon-seek-prev');
-	this.addToolbarIcon(toolbar, "scrollTimelineRight", "Scroll right", 'ui-icon-seek-next');
-	this.addToolbarIcon(toolbar, "zoomInTimeline", "Zoom in", 'ui-icon-zoomin');
-	this.addToolbarIcon(toolbar, "zoomOutTimeline", "Zoom out", 'ui-icon-zoomout');
-	this.addToolbarIcon(toolbar, "scrollTimelineToDate", "Scroll to date", 'ui-icon-search');
+	this.addToolbarButton(toolbar, "scrollTimelineLeft", "Scroll left", 'ui-icon-seek-prev');
+	this.addToolbarButton(toolbar, "scrollTimelineRight", "Scroll right", 'ui-icon-seek-next');
+	this.addToolbarButton(toolbar, "zoomInTimeline", "Zoom in", 'ui-icon-zoomin');
+	this.addToolbarButton(toolbar, "zoomOutTimeline", "Zoom out", 'ui-icon-zoomout');
+	this.addToolbarButton(toolbar, "scrollTimelineToDate", "Scroll to date", 'ui-icon-search');
+	this.addToolbarButton(toolbar, "linkToPassage", "Link passage", 'ui-icon-pin-s');
+
 	
+	
 	$("#bottomModuleHeader #scrollTimelineLeft").click(function() {
 			var mainBand = self.tl.getBand(0);
 			mainBand.scrollToCenter(mainBand.getMinVisibleDate());
@@ -150,6 +200,15 @@
 		var mainBand = self.tl.getBand(0);
 		mainBand.scrollToCenter(mainBand.getMaxVisibleDate());
 	});
+	
+	$("#bottomModuleHeader #linkToPassage").click(function() {
+		if($(this).text() === "Link to passage") {
+			$(this).button("option", {icons: { primary: "ui-icon-pin-s" }, label: "Unlink from passage"});
+		} else {	
+			$(this).button("option", {icons: { primary: "ui-icon-pin-w" }, label: "Link to passage"});
+		}
+	
+	});
 };
 
 
@@ -172,7 +231,11 @@
 	if (resizeTimerID == null) {
         resizeTimerID = window.setTimeout(function() {
             resizeTimerID = null;
-            self.tl.layout();
+
+            if(self.tl) {
+            	self.tl.layout();
+            }
+            
         }, 500);
     }
 }




More information about the Tynstep-svn mailing list