Last active
June 13, 2017 09:20
-
-
Save ctusch/ab0fe8ed38f975a4cd4ca6a1aac81055 to your computer and use it in GitHub Desktop.
insertBefore failed
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.Component.extend({ | |
| }); |
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.Component.extend({ | |
| }); |
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.Component.extend({ | |
| gridstackOptions: {cellHeight: 10,verticalMargin: 20,float: true}, | |
| didInsertElement() { | |
| Ember.run.scheduleOnce('afterRender', this, function() { | |
| this._initGridstack(); | |
| }); | |
| }, | |
| _initGridstack: function() { | |
| var options = { | |
| cellHeight: '', | |
| verticalMargin: '', | |
| float: '' | |
| }; | |
| Ember.$('body').append('<div class="gridstack-vars"></div>'); | |
| Ember.$.each(options, function(key) { | |
| Ember.$('.gridstack-vars').append('<span class="' + key + '"></span>'); | |
| }); | |
| Ember.$('.gridstack-vars').children('span').each(function() { | |
| var value; | |
| value = Ember.$(this).css('font-family').toString().replace(/["']/g, '').trim(); // both '' and "" are needeed for cross-browser compat | |
| if (!value) { | |
| value = null; | |
| } | |
| options[Ember.$(this).attr('class')] = value; | |
| }); | |
| this.set('gridstackOptions.cellHeight', 80); | |
| this.set('gridstackOptions.verticalMargin', 10); | |
| this.set('gridstackOptions.float', true); | |
| Ember.$('.gridstack-vars').remove(); | |
| var gridstack = Ember.$('.grid-stack').gridstack(this.get('gridstackOptions')); | |
| var self = this; | |
| if(this.get('editModeService.editMode') === false) { | |
| //Ember.$('#gridstack-' + this.get('id')).data('gridstack').disable(); // disable if not in editMode | |
| } | |
| gridstack.on('dragstop', function () { | |
| self.toggleProperty('gridItemChanged'); | |
| }); | |
| gridstack.on('resizestop', function () { | |
| self.toggleProperty('gridItemChanged'); | |
| }); | |
| }, | |
| observeChildrenChanged: function() { | |
| Ember.run.scheduleOnce('afterRender', this, function() { | |
| this._reinitGridstack(); | |
| }); | |
| }.observes('model.componentName'), | |
| _reinitGridstack: function() { //takes int consideration that there might be nested gridstacks | |
| var containerId = this.get('id'); | |
| var self = this; | |
| var gridstack = Ember.$('.grid-stack'); | |
| var children = gridstack.children(); | |
| if(this.get('model.boardlets') && this.get('model.boardlets').length === 0) { // if no children, just reinit | |
| gridstack.gridstack(this.get('gridstackOptions')); | |
| gridstack.data('gridstack').grid.nodes = []; // cleanup previous state, to make sure insertion starts at (0,0), reinit does not reinit the gridstack model | |
| return; | |
| } | |
| gridstack.wrap('<div class = "gridstack-helper">'); | |
| children.unwrap(); | |
| gridstack = Ember.$('.gridstack-helper'); | |
| gridstack.removeClass('gridstack-helper'); | |
| gridstack.addClass('grid-stack'); | |
| gridstack = Ember.$('.grid-stack').gridstack(this.get('gridstackOptions')); | |
| debugger; | |
| if(!this.get('editModeService.editMode')) { // if editMode false deactivate | |
| if(gridstack && gridstack.data('gridstack')) { | |
| //gridstack.data('gridstack').disable(); | |
| } | |
| } | |
| gridstack.on('dragstop', function () { | |
| self.toggleProperty('gridItemChanged'); | |
| }); | |
| gridstack.on('resizestop', function () { | |
| self.toggleProperty('gridItemChanged'); | |
| }); | |
| } | |
| }); |
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
| import Ember from 'ember'; | |
| import config from './config/environment'; | |
| const Router = Ember.Router.extend({ | |
| location: 'none', | |
| rootURL: config.rootURL | |
| }); | |
| Router.map(function() { | |
| this.route('sub', { path: 'sub/:id' }); | |
| }); | |
| export default Router; |
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.Route.extend({ | |
| model(params) { | |
| switch(params.id) { | |
| case "1": | |
| return { componentName: 'component-a' }; | |
| case "2": | |
| return { componentName: 'component-b' }; | |
| } | |
| } | |
| }); |
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", | |
| "lodash": "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js", | |
| "gridstack": "https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.2.6/gridstack.js", | |
| "ember": "2.12.0", | |
| "ember-template-compiler": "2.12.0", | |
| "ember-testing": "2.12.0" | |
| }, | |
| "addons": { | |
| "ember-data": "2.12.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment