Ember 1.12 support

This commit is contained in:
Robin Ward
2015-08-11 17:34:02 -04:00
parent 02a968bd27
commit 22844b9e46
39 changed files with 10322 additions and 61875 deletions

View File

@ -3,7 +3,7 @@ var DiscourseResolver = require('discourse/ember/resolver').default;
// Allow us to import Ember
define('ember', ['exports'], function(__exports__) {
__exports__["default"] = Ember;
__exports__.default = Ember;
});
window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
@ -16,7 +16,7 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
// if it's a non relative URL, return it.
if (!/^\/[^\/]/.test(url)) return url;
var u = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri);
var u = Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri;
if (u[u.length-1] === '/') u = u.substring(0, u.length-1);
if (url.indexOf(u) !== -1) return url;
@ -66,7 +66,7 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
// The classes of buttons to show on a post
postButtons: function() {
return Discourse.SiteSettings.post_menu.split("|").map(function(i) {
return (i.replace(/\+/, '').capitalize());
return i.replace(/\+/, '').capitalize();
});
}.property(),
@ -109,12 +109,26 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
$('noscript').remove();
// Load any ES6 initializers
Ember.keys(requirejs._eak_seen).forEach(function(key) {
if (/\/pre\-initializers\//.test(key)) {
var module = require(key, null, null, true);
if (!module) { throw new Error(key + ' must export an initializer.'); }
Discourse.initializer(module.default);
}
});
Ember.keys(requirejs._eak_seen).forEach(function(key) {
if (/\/initializers\//.test(key)) {
var module = require(key, null, null, true);
if (!module) { throw new Error(key + ' must export an initializer.'); }
Discourse.initializer(module.default);
var init = module.default;
var oldInitialize = init.initialize;
init.initialize = function(app) {
oldInitialize.call(this, app.container, app);
};
Discourse.instanceInitializer(init);
}
});
@ -125,17 +139,22 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
return desired && Discourse.get("currentAssetVersion") !== desired;
}.property("currentAssetVersion", "desiredAssetVersion"),
assetVersion: function(prop, val) {
if(val) {
if(this.get("currentAssetVersion")){
this.set("desiredAssetVersion", val);
} else {
this.set("currentAssetVersion", val);
}
}
return this.get("currentAssetVersion");
}.property()
assetVersion: Ember.computed({
get: function() {
return this.get("currentAssetVersion");
},
set: function(key, val) {
if(val) {
if (this.get("currentAssetVersion")) {
this.set("desiredAssetVersion", val);
} else {
this.set("currentAssetVersion", val);
}
}
return this.get("currentAssetVersion");
}
})
});
// TODO: Remove this, it is in for backwards compatibiltiy with plugins
@ -159,5 +178,3 @@ proxyDep('URL', function() { return require('discourse/lib/url').default });
proxyDep('Quote', function() { return require('discourse/lib/quote').default });
proxyDep('debounce', function() { return require('discourse/lib/debounce').default });
proxyDep('View', function() { return Ember.View }, "Use `Ember.View` instead");
proxyDep('Controller', function() { return Ember.Controller }, "Use `Ember.Controller` instead");
proxyDep('ObjectController', function() { return Ember.ObjectController }, "Use `Ember.Controller` instead");