Skip to content

Instantly share code, notes, and snippets.

@hojberg
Created July 18, 2012 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hojberg/3135950 to your computer and use it in GitHub Desktop.
Save hojberg/3135950 to your computer and use it in GitHub Desktop.
Mediator/layout/master view example
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