Skip to content
This repository has been archived by the owner on Aug 11, 2018. It is now read-only.

Add check if component already registered #1

Merged
merged 1 commit into from
Sep 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions addon/action-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ import Em from 'ember';
import WithConfigMixin from 'ember-idx-utils/mixin/with-config';
import Modal from 'ember-idx-modal/modal';
var computed = Em.computed;
var COMPONENT_NAME = 'view:em-wysiwyg-action-link-modal';

export default Em.Component.extend(WithConfigMixin, {
tagName: 'a',
classNameBindings: ['styleClasses', 'activeClasses'],
linkHref: '',
initModal: (function() {
var container = this.get('container');
container.register('view:em-wysiwyg-action-link-modal', Modal.extend({
layoutName: 'components/em-wysiwyg-action-link-modal',
configName: 'bs',
_parentView: this,
linkHref: computed.alias('parentView.linkHref'),
actions: {
addLink: function() {
this.get('parentView').send('addLink');
if(!container.lookupFactory(COMPONENT_NAME)) {
container._registry.register(COMPONENT_NAME, Modal.extend({
layoutName: 'components/em-wysiwyg-action-link-modal',
configName: 'bs',
_parentView: this,
linkHref: computed.alias('parentView.linkHref'),
actions: {
addLink: function() {
this.get('parentView').send('addLink');
}
}
}
}));
this.set('modal', container.lookup('view:em-wysiwyg-action-link-modal'));
}));
}
this.set('modal', container.lookup(COMPONENT_NAME));
return this.get('modal').append();
}).on('init'),
styleClasses: (function() {
Expand Down Expand Up @@ -70,4 +73,4 @@ export default Em.Component.extend(WithConfigMixin, {
};
})(this));
}).on('init')
});
});
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"ember-cli": "0.1.4",
"ember-cli-content-security-policy": "0.3.0",
"ember-cli-dependency-checker": "0.0.6",
"ember-cli-esnext": "0.1.1",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.1.2",
Expand All @@ -43,7 +42,9 @@
"configPath": "tests/dummy/config"
},
"dependencies": {
"ember-idx-utils": "^0.2.2",
"ember-idx-modal": "^0.1.3"
"broccoli-babel-transpiler": "^5.4.5",
"ember-cli-babel": "^5.1.5",
"ember-idx-modal": "^0.1.3",
"ember-idx-utils": "^0.2.2"
}
}
6 changes: 4 additions & 2 deletions tests/dummy/app/initializers/hightlightjs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Em from 'ember';
import Config from 'ember-idx-utils/config';
import UtilsConfig from 'ember-idx-utils/config';
/*global hljs*/

var Config;

export default {
name: 'hightlightjs',
initialize: function() {
//In real app we don't need this coz the initializer of modal will be merged into the app and will run automatically
Em.Config = Config = Config.create();
Em.Config = Config = UtilsConfig.create();
var defaultConfig = Config.getConfig('bs');

if (!defaultConfig) {
Expand Down