Permalink
Browse files

Fixes and tests for navigation-sequence bugs

  • Loading branch information...
1 parent 84dbc8d commit 137763063b77468a0a463e08ef500823e9bd6fb7 @nrabinowitz committed May 27, 2012
@@ -1,55 +0,0 @@
-/*
- * Book Place View
- */
-(function(gv) {
- var View = gv.View,
- state = gv.state;
-
- // View: BookPlaceView (master view for the book place detail screen)
- gv.BookPlaceView = View.extend({
- el: '#book-place-view',
-
- initialize: function(opts) {
- var view = this;
- // set child classes
- view.childClasses = [
- gv.NavigationView,
- gv.BookTitleView,
- gv.PlaceSummaryView,
- gv.RelatedPlacesView,
- gv.BookPlaceMapView,
- gv.BookPlaceFlickrView
- ];
- // bind state
- this.bindState('change:placeid', this.refresh, this);
- // super initialization kicks off model fetch
- BookView.prototype.initialize.call(this);
- },
-
- refresh: function() {
- this.children.forEach(function(child) {
- child.clear();
- });
- // create child views and render
- this.updateViews().render();
- },
-
- // UI Events
-
- events: {
- 'click span.change-this': 'uiOpenForm'
- },
-
- uiOpenForm: function() {
- // set the place to edit in the state
- state.set({ changelinkid: state.get('placeid') });
- // instantiate and open form
- if (!this.form) {
- this.form = new gv.ChangeFormView({ model: this.model, placeOnly: true });
- }
- this.form.open();
- }
-
- });
-
-}(gv));
@@ -11,7 +11,7 @@ define(['gv', 'views/BookView', 'views/PlaceFrequencyBarsView'],
className: 'infowindow',
template: '#info-window-template',
- initialize: function(opts) {
+ initialize: function() {
var view = this;
// listen for state changes
view.bindState('change:placeid', view.render, view);
@@ -21,8 +21,10 @@ define(['gv', 'views/BookView', 'views/PlaceFrequencyBarsView'],
},
clear: function() {
- this.freqBars && this.freqBars.clear();
- BookView.prototype.clear.call(this);
+ var view = this;
+ view.map && view.map.closeBubble();
+ view.freqBars && view.freqBars.clear();
+ BookView.prototype.clear.call(view);
},
// render and update functions
@@ -40,9 +42,7 @@ define(['gv', 'views/BookView', 'views/PlaceFrequencyBarsView'],
placeId = state.get('placeid'),
place;
// if no map has been set, give up
- if (!map) {
- return;
- }
+ if (!map) return;
// if there's no place selected, close the window
if (!placeId) {
map.closeBubble();
@@ -84,18 +84,23 @@ define(['gv', 'views/BookView', 'views/PlaceFrequencyBarsView'],
renderNextPrevControl: function() {
var view = this,
- book = view.model,
pageId = state.get('pageid'),
- placeId = state.get('placeid'),
- prev = view.prev = book.prevPlaceRef(pageId, placeId),
- next = view.next = book.nextPlaceRef(pageId, placeId);
- view.$('.prev').toggleClass('on', !!prev);
- view.$('.next').toggleClass('on', !!next);
- view.$('.controls').toggle(!!(prev || next));
+ placeId = state.get('placeid');
+ view.ready(function() {
+ var book = view.model,
+ prev = view.prev = book.prevPlaceRef(pageId, placeId),
+ next = view.next = book.nextPlaceRef(pageId, placeId);
+ view.$('.prev').toggleClass('on', !!prev);
+ view.$('.next').toggleClass('on', !!next);
+ view.$('.controls').toggle(!!(prev || next));
+ });
},
renderBarHighlight: function() {
- this.freqBars && this.freqBars.updateHighlight();
+ var view = this;
+ view.ready(function() {
+ view.freqBars && view.freqBars.updateHighlight();
+ });
},
getPoint: function() {
@@ -13,6 +13,7 @@ define(['gv', 'views/BookView', 'views/PageView', 'views/ChangeLinkView'],
initialize: function() {
var view = this;
view.changeLink = new ChangeLinkView();
+ view.render = view.bindReady('render');
// listen for state changes
view.bindState('change:pageid', view.render, view);
},
@@ -32,36 +32,42 @@ define(['gv', 'views/BookView', 'views/InfoWindowView'], function(gv, BookView,
initialize: function() {
var view = this;
- view.infoWindowView = new InfoWindowView({ model: view.model });
- // listen for state changes
- view.bindState('change:pageid', view.updateTimeline, view);
- view.bindState('change:mapzoom', view.updateMapZoom, view);
- view.bindState('change:mapcenter', view.updateMapCenter, view);
- view.bindState('change:maptypeid', view.updateMapTypeId, view);
- view.bindState('change:autoplay', view.updateAutoplay, view);
- view.bindState('change:autoplay', view.renderAutoplayControls, view);
- // cancel autoplay on other UI events
- view.bindState('change:topview', view.stopAutoplay, view);
- view.bindState('change:placeid', view.stopAutoplay, view);
- view.bindState('change:pageid', view.stopAutoplay, view);
+ view.infoWindowView = new InfoWindowView();
},
clear: function() {
this.infoWindowView.clear();
BookView.prototype.clear.call(this);
},
+ getLabeller: function() {
+ var view = this;
+ view.labelUtils = view.labelUtils || new LabelUtils(
+ bandInfo, view.model.labels(), function() { return false; }
+ );
+ return view.labelUtils;
+ },
+
render: function() {
var view = this,
book = view.model,
// create themes by frequency
colorScale = d3.scale.quantize()
.domain([1, book.places.first().get('frequency')])
.range(colorThemes),
- // add custom labeller
- labelUtils = view.labelUtils = new LabelUtils(
- bandInfo, book.labels(), function() { return false; }
- );
+ labelUtils = view.getLabeller();
+
+ // listen for state changes
+ view.bindState('change:pageid', view.updateTimeline, view);
+ view.bindState('change:mapzoom', view.updateMapZoom, view);
+ view.bindState('change:mapcenter', view.updateMapCenter, view);
+ view.bindState('change:maptypeid', view.updateMapTypeId, view);
+ view.bindState('change:autoplay', view.updateAutoplay, view);
+ view.bindState('change:autoplay', view.renderAutoplayControls, view);
+ // cancel autoplay on other UI events
+ view.bindState('change:topview', view.stopAutoplay, view);
+ view.bindState('change:placeid', view.stopAutoplay, view);
+ view.bindState('change:pageid', view.stopAutoplay, view);
// render template HTML
view.$el.html(view.template);
@@ -292,7 +298,8 @@ define(['gv', 'views/BookView', 'views/InfoWindowView'], function(gv, BookView,
// go to a specific page
scrollTo: function(pageId, animate) {
var view = this,
- d = view.labelUtils.labelToDate(pageId);
+ labelUtils = view.getLabeller(),
+ d = labelUtils.labelToDate(pageId);
// stop anything that's running
if (view.animation) {
view.animation.stop();
Submodule backbone-spf updated from 69ff5f to 2f4325
View
@@ -20,8 +20,12 @@ casper.describe = function(msg) {
// helpers
-casper.waitForSelector = function(selector, msg) {
- this.waitUntilVisible(selector, function() {
+casper.waitForSelector = function(selector, msg, negate) {
+ this.waitFor(function() {
+ var toBool = negate ? '!' : '!!';
+ f = new Function("return " + toBool + "$('" + selector + ":visible').length");
+ return casper.evaluate(f)
+ }, function() {
t.pass(msg || 'Selector ' + selector + ' found');
}, function() {
t.fail(msg || 'Selector ' + selector + ' not found');
@@ -32,6 +36,9 @@ casper.waitForSelector = function(selector, msg) {
casper.waitForInfoWindow = function(msg) {
return this.waitForSelector('div.infowindow', msg || "Info window is open");
};
+casper.waitForInfoWindowClose = function(msg) {
+ return this.waitForSelector('div.infowindow', msg || "Info window is closed", true);
+};
casper.closeInfoWindow = function() {
// no way to easily access the close button
@@ -74,6 +74,7 @@ casper
.then(function() {
this.click('.related-places-view p:nth-child(4) span');
})
+ .waitForSelector('.place-summary-view h3:contains(Hispania)')
.then(function() {
t.assertRoute('book/2/place/1027',
"Route is correct");
@@ -316,6 +316,7 @@ casper
.then(function() {
this.closeInfoWindow();
})
+ .waitForInfoWindowClose()
.then(function() {
t.assertRoute(/^book\/2\/read\/2$/, 'Reading route correct, no place');
t.assertDoesNotExist('div.infowindow',
@@ -354,6 +355,7 @@ casper
.then(function() {
this.closeInfoWindow();
})
+ .waitForInfoWindowClose()
.back()
.waitForInfoWindow('Info window re-opens on back')
.then(function() {

0 comments on commit 1377630

Please sign in to comment.