Skip to content

Commit

Permalink
Ember 1.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Aug 13, 2015
1 parent 02a968b commit 22844b9
Show file tree
Hide file tree
Showing 39 changed files with 10,467 additions and 62,020 deletions.
2 changes: 1 addition & 1 deletion .jshintignore → .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ vendor/
test/javascripts/helpers/
test/javascripts/test_helper.js
test/javascripts/test_helper.js
test/javascripts/fixtures
app/assets/javascripts/ember-addons/

105 changes: 105 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"env": {
"jasmine": true,
"node": true,
"mocha": true,
"browser": true,
"builtin": true
},
ecmaVersion: 7,
"globals":
{"Ember":true,
"jQuery":true,
"$":true,
"RSVP":true,
"Discourse":true,
"Em":true,
"PreloadStore":true,
"Handlebars":true,
"I18n":true,
"bootbox":true,
"module":true,
"moduleFor":true,
"moduleForComponent":true,
"Pretender":true,
"sandbox":true,
"controllerFor":true,
"test":true,
"ok":true,
"not":true,
"expect":true,
"equal":true,
"visit":true,
"andThen":true,
"click":true,
"currentPath":true,
"currentRouteName":true,
"currentURL":true,
"fillIn":true,
"keyEvent":true,
"triggerEvent":true,
"count":true,
"exists":true,
"visible":true,
"invisible":true,
"asyncRender":true,
"selectDropdown":true,
"asyncTestDiscourse":true,
"fixture":true,
"find":true,
"sinon":true,
"moment":true,
"start":true,
"_":true,
"alert":true,
"containsInstance":true,
"deepEqual":true,
"notEqual":true,
"define":true,
"require":true,
"requirejs":true,
"hasModule":true,
"Blob":true,
"File":true},
"rules": {
"block-scoped-var": 2,
"dot-notation": 0,
"eqeqeq": [
2,
"allow-null"
],
"guard-for-in": 2,
"no-bitwise": 2,
"no-caller": 2,
"no-cond-assign": 0,
"no-debugger": 2,
"no-empty": 0,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-parens": 0,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-new": 2,
"no-plusplus": 0,
"no-proto": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-undef": 2,
"no-unused-vars": 2,
"no-with": 2,
"semi": [
0,
"never"
],
"strict": 0,
"valid-typeof": 2,
"wrap-iife": [
2,
"inside"
]
},
"parser": "babel-eslint"
}
83 changes: 0 additions & 83 deletions .jshintrc

This file was deleted.

8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ GEM
multi_json (~> 1.0)
aws-sdk-resources (2.0.45)
aws-sdk-core (= 2.0.45)
babel-source (4.6.6)
babel-transpiler (0.6.0)
babel-source (>= 4.0, < 5)
babel-source (5.8.19)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
barber (0.9.0)
ember-source (>= 1.0, < 2)
Expand Down Expand Up @@ -86,7 +86,7 @@ GEM
ember-source (>= 1.1.0)
jquery-rails (>= 1.0.17)
railties (>= 3.1)
ember-source (1.11.3.1)
ember-source (1.12.1)
erubis (2.7.0)
eventmachine (1.0.7)
excon (0.45.3)
Expand Down
24 changes: 14 additions & 10 deletions app/assets/javascripts/admin/components/site-setting.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import BufferedContent from 'discourse/mixins/buffered-content';
import ScrollTop from 'discourse/mixins/scroll-top';
import SiteSetting from 'admin/models/site-setting';
import { propertyNotEqual } from 'discourse/lib/computed';
import computed from 'ember-addons/ember-computed-decorators';

const CustomTypes = ['bool', 'enum', 'list', 'url_list', 'host_list'];

Expand All @@ -20,27 +21,30 @@ export default Ember.Component.extend(BufferedContent, ScrollTop, {
}
}.property('buffered.value'),

typeClass: function() {
@computed('partialType')
typeClass() {
return this.get('partialType').replace("_", "-");
}.property('partialType'),
},

enabled: function(key, value) {
if (arguments.length > 1) {
@computed('buffered.value')
enabled: {
get() {
const bufferedValue = this.get('buffered.value');
if (Ember.isEmpty(bufferedValue)) { return false; }
return bufferedValue === 'true';
},
set(key, value) {
this.set('buffered.value', value ? 'true' : 'false');
}

const bufferedValue = this.get('buffered.value');
if (Ember.isEmpty(bufferedValue)) { return false; }
return bufferedValue === 'true';
}.property('buffered.value'),
},

settingName: function() {
return this.get('setting.setting').replace(/\_/g, ' ');
}.property('setting.setting'),

partialType: function() {
let type = this.get('setting.type');
return (CustomTypes.indexOf(type) !== -1) ? type : 'string';
return CustomTypes.indexOf(type) !== -1 ? type : 'string';
}.property('setting.type'),

partialName: function() {
Expand Down
49 changes: 33 additions & 16 deletions app/assets/javascripts/discourse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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;
Expand Down Expand Up @@ -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(),

Expand Down Expand Up @@ -109,33 +109,52 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {

$('noscript').remove();

// Load any ES6 initializers
Ember.keys(requirejs._eak_seen).forEach(function(key) {
if (/\/initializers\//.test(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.'); }

var init = module.default;
var oldInitialize = init.initialize;
init.initialize = function(app) {
oldInitialize.call(this, app.container, app);
};

Discourse.instanceInitializer(init);
}
});

},

requiresRefresh: function(){
var desired = Discourse.get("desiredAssetVersion");
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);

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");
}
return this.get("currentAssetVersion");
}.property()

})
});

// TODO: Remove this, it is in for backwards compatibiltiy with plugins
Expand All @@ -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");
Loading

0 comments on commit 22844b9

Please sign in to comment.