Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moved placeholer to `widget/`

added application widget

start router on `hub/start`
  • Loading branch information...
commit ce167fe18be5f8adb7d9670620ac3a22cc675534 1 parent 25d2639
@mikaelkaron mikaelkaron authored
View
2  src/route/placeholder.js
@@ -3,7 +3,7 @@
* @license TroopJS 0.0.1 Copyright 2012, Mikael Karon <mikael@karon.se>
* Released under the MIT license.
*/
-define([ "compose", "../component/placeholder" ], function RoutePlaceholderModule(Compose, Placeholder) {
+define([ "compose", "../widget/placeholder" ], function RoutePlaceholderModule(Compose, Placeholder) {
return Placeholder.extend(function RoutePlaceholderWidget($element, name) {
var self = this;
var re = RegExp($element.data("route"));
View
6 src/route/router.js
@@ -31,9 +31,11 @@ define([ "compose", "../component/widget", "../util/uri", "callbacks" ], functio
callbacks.remove(callback);
}
});
-
- self.trigger("hashchange");
}, {
+ "hub/start" : function start(topic) {
+ this.trigger("hashchange");
+ },
+
"dom/hashchange" : function onHashChange(topic, $event) {
this.publish("route", URI($event.target.location.hash.replace(/^#/, "")));
}
View
26 src/widget/application.js
@@ -0,0 +1,26 @@
+/*!
+ * TroopJS widget/application component
+ * @license TroopJS 0.0.1 Copyright 2012, Mikael Karon <mikael@karon.se>
+ * Released under the MIT license.
+ */
+define([ "compose", "../component/widget" ], function ApplicationModule(Compose, Widget) {
+ return Widget.extend(function ApplicationWidget($element, name) {
+ var self = this;
+
+ Compose.call(self, {
+ "build/application" : function build() {
+ self
+ .weave($element)
+ .publish("start", name);
+ },
+
+ "destroy/application" : function destroy() {
+ var self = this;
+
+ self
+ .publish("stop", name)
+ .unweave($element);
+ }
+ });
+ });
+});
View
4 src/component/placeholder.js → src/widget/placeholder.js
@@ -1,9 +1,9 @@
/*!
- * TroopJS widget placeholder component
+ * TroopJS widget/placeholder component
* @license TroopJS 0.0.1 Copyright 2012, Mikael Karon <mikael@karon.se>
* Released under the MIT license.
*/
-define([ "compose", "./widget", "jquery" ], function WidgetPlaceholderModule(Compose, Widget, $) {
+define([ "compose", "../component/widget", "jquery" ], function WidgetPlaceholderModule(Compose, Widget, $) {
var NULL = null;
var UNDEFINED = undefined;
var ARRAY = Array;
Please sign in to comment.
Something went wrong with that request. Please try again.