|
@@ -10,6 +10,7 @@
|
|
|
this.$elem.find('a').click(function(e) {
|
|
this.$elem.find('a').click(function(e) {
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
var $link = $(this);
|
|
var $link = $(this);
|
|
|
|
|
+ console.log('menu item clicked', $link.prop('href'));
|
|
|
var originalColor = $link.css('backgroundColor');
|
|
var originalColor = $link.css('backgroundColor');
|
|
|
// self.toggleMenu();
|
|
// self.toggleMenu();
|
|
|
$link.animate({
|
|
$link.animate({
|
|
@@ -32,6 +33,29 @@
|
|
|
part.$elem.html( Mustache.render( part.tmpl, data ) );
|
|
part.$elem.html( Mustache.render( part.tmpl, data ) );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ _ws.makeView = function(elemId, props) {
|
|
|
|
|
+ var v = {};
|
|
|
|
|
+ props = props || {};
|
|
|
|
|
+
|
|
|
|
|
+ v.$elem = $('#' + elemId);
|
|
|
|
|
+ v.partName = _.camelCase(elemId);
|
|
|
|
|
+ _ws.ui[v.partName] = v;
|
|
|
|
|
+
|
|
|
|
|
+ if(! props.render) {
|
|
|
|
|
+ var $tmplEl = $('script[data-tmpl-for="' + elemId + '"]');
|
|
|
|
|
+ v.tmpl = $tmplEl.html();
|
|
|
|
|
+ v.render = (function(data) {
|
|
|
|
|
+ var eventBinder = eventBinders[v.partName];
|
|
|
|
|
+ this.$elem.html( Mustache.render( this.tmpl, data ) );
|
|
|
|
|
+ if(eventBinder) {
|
|
|
|
|
+ eventBinder = eventBinder.bind(this);
|
|
|
|
|
+ console.log('bind events for', v.partName);
|
|
|
|
|
+ eventBinder();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).bind(v);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Initialize an empty object to be populated as follows:
|
|
* Initialize an empty object to be populated as follows:
|
|
@@ -43,6 +67,8 @@
|
|
|
// Iterate over the template script elements
|
|
// Iterate over the template script elements
|
|
|
var $templateElems = $('script[data-tmpl-for]');
|
|
var $templateElems = $('script[data-tmpl-for]');
|
|
|
$templateElems.each(function(idx, el) {
|
|
$templateElems.each(function(idx, el) {
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// Get the script element content and target element id
|
|
// Get the script element content and target element id
|
|
|
var $script = $(el);
|
|
var $script = $(el);
|