Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Created June 4, 2013 13:33
Show Gist options
  • Save knownasilya/5705951 to your computer and use it in GitHub Desktop.
Save knownasilya/5705951 to your computer and use it in GitHub Desktop.
Toggle Visibility
App.SidebarContentView = Ember.ContainerView.extend({
classNames: ["content"],
classNameBindings: ["isVisible"],
isVisible: false,
childViews: ["searchView", "overlayView", "contactView"],
searchView: App.MapSearchView,
overlayView: App.MapOverlayView,
contactView: App.MapContactView,
changeView: function (viewProperty) {
var arr = this.get("childViews");
arr.forEach(function (item) {
var view = this.get(viewProperty);
if(item === view) {
item.set("isVisible", true);
}
else {
item.set("isVisible", false);
}
}, this);
}
});
App.SidebarView = Ember.View.extend({
templateName: "sidebar",
elementId: "sidebar",
controller: App.SidebarController,
childViews: ["sidebarContentView"],
sidebarContentView: App.SidebarContentView.create(),
classNameBindings: ["position", "isVisible"],
position: "right",
isVisible: true,
isPinned: false,
settings: null,
init: function () {
this._super();
var settings = App.get("settings").map.sidebar;
this.set("position", settings.position);
this.set("isVisible", settings.visible);
this.set("isPinned", settings.pinned);
this.set("settings", settings);
},
click: function (event) {
var id = $(event.target).closest("a").attr("id"),
viewProperty = id.split("-")[1] + "View";
this.get("sidebarContentView").changeView(viewProperty);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment