Last active
May 1, 2017 19:12
-
-
Save code0100fun/57d89f9c977aad728c000a873e7e83f2 to your computer and use it in GitHub Desktop.
Ember.js Properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| const { computed } = Ember; | |
| function value(x) { | |
| if (typeof x === 'undefined') { | |
| return false; | |
| } else if (x === null) { | |
| return false; | |
| } else { | |
| return true; | |
| } | |
| } | |
| const MyComponent = Ember.Component.extend({ | |
| initProp: null, | |
| extProp: 1, | |
| init() { | |
| this._super(...arguments); | |
| this.set('initProp', 0); | |
| }, | |
| initPropThis: computed(function() { | |
| return value(this.initProp); | |
| }), | |
| initPropGet: computed(function() { | |
| return value(this.get('initProp')); | |
| }), | |
| initPropThisProto: computed(function() { | |
| return value(this.constructor.proto().initProp); | |
| }), | |
| initPropCtorProto: computed(function() { | |
| return value(MyComponent.proto().initProp); | |
| }), | |
| initPropThisCtor: computed(function() { | |
| return value(this.constructor.initProp); | |
| }), | |
| initPropCtor: computed(function() { | |
| return value(MyComponent.initProp); | |
| }), | |
| extPropThis: computed(function() { | |
| return value(this.extProp); | |
| }), | |
| extPropGet: computed(function() { | |
| return value(this.get('extProp')); | |
| }), | |
| extPropThisProto: computed(function() { | |
| return value(this.constructor.proto().extProp); | |
| }), | |
| extPropCtorProto: computed(function() { | |
| return value(MyComponent.proto().extProp); | |
| }), | |
| extPropThisCtor: computed(function() { | |
| return value(this.constructor.extProp); | |
| }), | |
| extPropCtor: computed(function() { | |
| return value(MyComponent.extProp); | |
| }), | |
| ctorPropThis: computed(function() { | |
| return value(this.ctorProp); | |
| }), | |
| ctorPropGet: computed(function() { | |
| return value(this.get('ctorProp')); | |
| }), | |
| ctorPropThisProto: computed(function() { | |
| return value(this.constructor.proto().ctorProp); | |
| }), | |
| ctorPropCtorProto: computed(function() { | |
| return value(MyComponent.proto().ctorProp); | |
| }), | |
| ctorPropThisCtor: computed(function() { | |
| return value(this.constructor.ctorProp); | |
| }), | |
| ctorPropCtor: computed(function() { | |
| return value(MyComponent.ctorProp); | |
| }), | |
| classPropThis: computed(function() { | |
| return value(this.classProp); | |
| }), | |
| classPropGet: computed(function() { | |
| return value(this.get('classProp')); | |
| }), | |
| classPropThisProto: computed(function() { | |
| return value(this.constructor.proto().classProp); | |
| }), | |
| classPropCtorProto: computed(function() { | |
| return value(MyComponent.proto().classProp); | |
| }), | |
| classPropThisCtor: computed(function() { | |
| return value(this.constructor.classProp); | |
| }), | |
| classPropCtor: computed(function() { | |
| return value(MyComponent.classProp); | |
| }), | |
| propNames: ['initProp', 'extProp', 'classProp', 'ctorProp'], | |
| accessTypes: ['This', 'Get', 'ThisProto', 'CtorProto', 'ThisCtor', 'Ctor'], | |
| }); | |
| MyComponent.ctorProp = 2; | |
| MyComponent.reopenClass({ | |
| classProp: 3 | |
| }); | |
| export default MyComponent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| padding: 10px; | |
| } | |
| .success { | |
| color: green; | |
| } | |
| .error { | |
| color: red; | |
| } | |
| table th { | |
| text-align: center; | |
| } | |
| table td { | |
| width: 50px; | |
| text-align: center; | |
| } | |
| .hljs-string { | |
| color: #333 !important; | |
| background: #f8f8f8 !important; | |
| } | |
| pre { | |
| background: inherit !important; | |
| padding: 0 !important; | |
| } | |
| /* | |
| github.com style (c) Vasily Polovnyov <vast@whiteants.net> | |
| */ | |
| .hljs { | |
| display: block !important; | |
| overflow-x: auto !important; | |
| padding: 0.5em !important; | |
| color: #333 !important; | |
| background: #f8f8f8 !important; | |
| } | |
| .hljs-comment, | |
| .hljs-quote { | |
| color: #998 !important; | |
| font-style: italic !important; | |
| } | |
| .hljs-keyword, | |
| .hljs-selector-tag, | |
| .hljs-subst { | |
| color: #333 !important; | |
| font-weight: bold !important; | |
| } | |
| .hljs-number, | |
| .hljs-literal, | |
| .hljs-variable, | |
| .hljs-template-variable, | |
| .hljs-tag .hljs-attr { | |
| color: #008080 !important; | |
| } | |
| .hljs-string, | |
| .hljs-doctag { | |
| color: #d14 !important; | |
| } | |
| .hljs-title, | |
| .hljs-section, | |
| .hljs-selector-id { | |
| color: #900 !important; | |
| font-weight: bold !important; | |
| } | |
| .hljs-subst { | |
| font-weight: normal !important; | |
| } | |
| .hljs-type, | |
| .hljs-class .hljs-title { | |
| color: #458 !important; | |
| font-weight: bold !important; | |
| } | |
| .hljs-tag, | |
| .hljs-name, | |
| .hljs-attribute { | |
| color: #000080 !important; | |
| font-weight: normal !important; | |
| } | |
| .hljs-regexp, | |
| .hljs-link { | |
| color: #009926 !important; | |
| } | |
| .hljs-symbol, | |
| .hljs-bullet { | |
| color: #990073 !important; | |
| } | |
| .hljs-built_in, | |
| .hljs-builtin-name { | |
| color: #0086b3 !important; | |
| } | |
| .hljs-meta { | |
| color: #999 !important; | |
| font-weight: bold !important; | |
| } | |
| .hljs-deletion { | |
| background: #fdd !important; | |
| } | |
| .hljs-addition { | |
| background: #dfd !important; | |
| } | |
| .hljs-emphasis { | |
| font-style: italic !important; | |
| } | |
| .hljs-strong { | |
| font-weight: bold !important; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.12.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "2.12.0", | |
| "ember-template-compiler": "2.12.0", | |
| "ember-testing": "2.12.0" | |
| }, | |
| "addons": { | |
| "ember-data": "2.12.1", | |
| "ember-bootstrap": "0.11.3", | |
| "markdown-code-highlighting": "0.1.0", | |
| "ember-truth-helpers": "1.3.0" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment