mirror of
https://github.com/discourse/discourse.git
synced 2025-02-12 03:59:29 +08:00
33 lines
810 B
JavaScript
33 lines
810 B
JavaScript
![]() |
(function() {
|
||
|
|
||
|
Discourse.StaticController = Ember.Controller.extend({
|
||
|
content: null,
|
||
|
loadPath: function(path) {
|
||
|
var $preloaded, text,
|
||
|
_this = this;
|
||
|
this.set('content', null);
|
||
|
/* Load from <noscript> if we have it.
|
||
|
*/
|
||
|
|
||
|
$preloaded = jQuery("noscript[data-path=\"" + path + "\"]");
|
||
|
if ($preloaded.length) {
|
||
|
text = $preloaded.text();
|
||
|
text = text.replace(/<header[\s\S]*<\/header\>/, '');
|
||
|
return this.set('content', text);
|
||
|
} else {
|
||
|
return jQuery.ajax({
|
||
|
url: "" + path + ".json",
|
||
|
success: function(result) {
|
||
|
return _this.set('content', result);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
Discourse.StaticController.reopenClass({
|
||
|
pages: ['faq', 'tos', 'privacy']
|
||
|
});
|
||
|
|
||
|
}).call(this);
|