Created
September 7, 2010 19:02
-
-
Save charlesjolley/568864 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
An Accessory is an embeddable mini-application. It can have its own set of controllers, | |
states, and views. Accessories are useful pattern for building independent, reusable plugins | |
inside of your application. | |
*/ | |
SC.Accessory = SC.Object.extend({ | |
/** | |
This should point to the main application object to give the accessory some context. | |
*/ | |
application: null, | |
/** | |
Set this to the content you want the accessory to manage (if you want). | |
*/ | |
content: null, | |
/** | |
The accessory will set the mainView to a view you can display within your application. | |
You should put this into a pane if you want to show it independently. | |
*/ | |
mainView: null, | |
/** | |
The main() function is called when the accessory is first init'd. Like a regular app. | |
*/ | |
main: function() { .. } | |
}); | |
This file contains 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
MyApp.CalendarAccessory = SC.Accessory.extend({ | |
/** | |
Content should be set to a DateTime object. | |
*/ | |
content: null, | |
// TODO: somehow this needs to auto-instantiate when the accessory is created... | |
contentController: SC.ObjectController.extend({ | |
contentBinding: '.owner.content' | |
}), | |
main: function() { | |
// setup mainView - this makes the app come alive | |
this.set('mainView', MyApp.CalendarAccessory.getPath('mainPage.mainView')); | |
} | |
}); |
This file contains 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
var accessory = SC.Accessory.create({ | |
application: MyApp, | |
content: someDate | |
}); | |
this.getPath('mainPage.mainPane.someContainer').set('content', accessory.get('mainView')); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment