simple toggle stuff

This commit is contained in:
Adam Bradley
2013-09-27 15:11:47 -05:00
parent d03d3aa106
commit d4f385f290
10 changed files with 594 additions and 527 deletions

View File

@ -1,42 +1,44 @@
(function(ionic) {
ionic.views.NavBar = function(opts) {
this.el = opts.el;
ionic.views.NavBar = function(opts) {
this.el = opts.el;
this._titleEl = this.el.querySelector('.title');
};
this._titleEl = this.el.querySelector('.title');
};
ionic.views.NavBar.prototype = {
shouldGoBack: function() {},
ionic.views.NavBar.prototype = {
shouldGoBack: function() {},
setTitle: function(title) {
if(!this._titleEl) {
return;
}
this._titleEl.innerHTML = title;
},
setTitle: function(title) {
if(!this._titleEl) {
return;
}
this._titleEl.innerHTML = title;
},
showBackButton: function(shouldShow) {
var _this = this;
showBackButton: function(shouldShow) {
var _this = this;
if(!this._currentBackButton) {
var back = document.createElement('a');
back.className = 'button back';
back.innerHTML = 'Back';
if(!this._currentBackButton) {
var back = document.createElement('a');
back.className = 'button back';
back.innerHTML = 'Back';
this._currentBackButton = back;
this._currentBackButton.onclick = function(event) {
_this.shouldGoBack && _this.shouldGoBack();
this._currentBackButton = back;
this._currentBackButton.onclick = function(event) {
_this.shouldGoBack && _this.shouldGoBack();
}
}
if(shouldShow && !this._currentBackButton.parentNode) {
// Prepend the back button
this.el.insertBefore(this._currentBackButton, this.el.firstChild);
} else if(!shouldShow && this._currentBackButton.parentNode) {
// Remove the back button if it's there
this._currentBackButton.parentNode.removeChild(this._currentBackButton);
}
}
};
if(shouldShow && !this._currentBackButton.parentNode) {
// Prepend the back button
this.el.insertBefore(this._currentBackButton, this.el.firstChild);
} else if(!shouldShow && this._currentBackButton.parentNode) {
// Remove the back button if it's there
this._currentBackButton.parentNode.removeChild(this._currentBackButton);
}
}
};
})(window.ionic);
})(ionic);