mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
Moved hacking controllers and views
They are now official files.
This commit is contained in:
43
js/views/navBar.js
Normal file
43
js/views/navBar.js
Normal file
@ -0,0 +1,43 @@
|
||||
(function(window, document, ionic) {
|
||||
|
||||
NavBar = function(opts) {
|
||||
this.el = opts.el;
|
||||
|
||||
this._titleEl = this.el.querySelector('.title');
|
||||
};
|
||||
|
||||
NavBar.prototype = {
|
||||
shouldGoBack: function() {},
|
||||
|
||||
setTitle: function(title) {
|
||||
if(!this._titleEl) {
|
||||
return;
|
||||
}
|
||||
this._titleEl.innerHTML = title;
|
||||
},
|
||||
|
||||
showBackButton: function(shouldShow) {
|
||||
var _this = this;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
})(this, document, ion = this.ionic || {});
|
||||
|
||||
Reference in New Issue
Block a user