Created
July 18, 2012 12:36
-
-
Save hojberg/3135950 to your computer and use it in GitHub Desktop.
Mediator/layout/master view example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('location-search-view', function (Y) { | |
/** | |
@class LocationSearchView | |
@extends View | |
@constructor | |
**/ | |
Y.LocationSearchView = Y.Base.create('view', | |
Y.View, | |
[], | |
{ | |
initializer: function () { | |
this.get('locationListView').after('select', this._afterLocationSelect, this); | |
}, | |
/** | |
@method _afterLocationSelect | |
@description pan to a location when it is selected | |
@param {EventFacade} ev | |
@protected | |
**/ | |
_afterLocationSelect: function (ev) { | |
this.get('mapView').panTo( ev.model ); | |
}, | |
/** | |
@method render | |
@description builds the layout for searching locations | |
@chainable | |
**/ | |
render: function () { | |
var container = this.get('container'); | |
container.append( | |
this.get('MapView').render().get('container') | |
); | |
container.append( | |
this.get('locationListView').render().get('container') | |
); | |
} | |
}, | |
{ | |
ATTRS: { | |
/** | |
@attribute mapView | |
@type {MapView} | |
**/ | |
mapView: { | |
valueFn: function () { | |
return new Y.MapView(); | |
} | |
}, | |
/** | |
@attribute locationListView | |
@type {LocationListView} | |
**/ | |
locationListView: { | |
valueFn: function () { | |
return new Y.LocationListView({ | |
modelList: new Y.LocationList() | |
}); | |
} | |
} | |
} | |
}); | |
}, '1.0.0', { requires: ['location-list', 'location-list-view', 'map-view'] }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment