mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
e5ce70e175
Saving post as draft, or publishing Added HBS parser for some client tmpls Parsing paginated posts Added grunt watch for hbs parsing on updates
65 lines
No EOL
1.8 KiB
JavaScript
65 lines
No EOL
1.8 KiB
JavaScript
/*globals window, _, $, Backbone */
|
|
(function ($) {
|
|
"use strict";
|
|
|
|
_.extend(Backbone.View.prototype, {
|
|
|
|
// Adds a subview to the current view, which will
|
|
// ensure its removal when this view is removed,
|
|
// or when view.removeSubviews is called
|
|
addSubview: function (view) {
|
|
if (!(view instanceof Backbone.View)) {
|
|
throw new Error("Subview must be a Backbone.View");
|
|
}
|
|
this.subviews = this.subviews || [];
|
|
this.subviews.push(view);
|
|
return view;
|
|
},
|
|
|
|
// Removes any subviews associated with this view
|
|
// by `addSubview`, which will in-turn remove any
|
|
// children of those views, and so on.
|
|
removeSubviews: function () {
|
|
var i, l, children = this.subviews;
|
|
if (!children) {
|
|
return this;
|
|
}
|
|
for (i = 0, l = children.length; i < l; i += 1) {
|
|
children[i].remove();
|
|
}
|
|
this.subviews = [];
|
|
return this;
|
|
},
|
|
|
|
// Extends the view's remove, by calling `removeSubviews`
|
|
// if any subviews exist.
|
|
remove: function () {
|
|
if (this.subviews) {
|
|
this.removeSubviews();
|
|
}
|
|
return Backbone.View.prototype.remove.apply(this, arguments);
|
|
}
|
|
|
|
});
|
|
|
|
var Ghost = {
|
|
Layout : {},
|
|
Views : {},
|
|
Collections : {},
|
|
Models : {},
|
|
|
|
settings: {
|
|
apiRoot: '/api/v0.1'
|
|
},
|
|
|
|
// This is a helper object to denote legacy things in the
|
|
// middle of being transitioned.
|
|
temporary: {},
|
|
|
|
currentView: null,
|
|
router: null
|
|
};
|
|
|
|
window.Ghost = Ghost;
|
|
|
|
}()); |