Created
August 10, 2016 02:29
-
-
Save antenando/d86a78e4578a58b1a871275c169b9b5e to your computer and use it in GitHub Desktop.
Enter Dragula
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({ | |
init: () => console.clear() | |
}); |
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({ | |
beforeModel() { | |
this.transitionTo('example-one'); | |
} | |
}); |
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({ | |
actions: { | |
dropReport: (el, target, source, sibling) => { | |
console.log("Dragged:", el); | |
console.log("Target container:", target); | |
console.log("Source container:", source); | |
console.log("Sibling:", sibling); | |
} | |
} | |
}); |
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: () => [ | |
{ | |
name: "Eludoid Epv", | |
avatar: "https://robohash.org/EludoidEpv.png?size=75x75" | |
}, | |
{ | |
name: "Amol Uyzator", | |
avatar: "https://robohash.org/AmolUyzator.png?size=75x75" | |
}, | |
{ | |
name: "Uhx Iforoid", | |
avatar: "https://robohash.org/UhxIforoid.png?size=75x75" | |
}, | |
{ | |
name: "Egator Azok", | |
avatar: "https://robohash.org/EgatorAzok.png?size=75x75" | |
}, | |
{ | |
name: "Oted Axun", | |
avatar: "https://robohash.org/OtedAxun.png?size=75x75" | |
} | |
] | |
}); | |
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({ | |
actions: { | |
dropReport: (el, target, source, sibling) => { | |
console.log("Dragged:", el); | |
console.log("Target container:", target); | |
console.log("Source container:", source); | |
console.log("Sibling:", sibling); | |
} | |
} | |
}); |
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: () => ({ | |
one: [ | |
{ | |
name: "Eludoid Epv", | |
avatar: "https://robohash.org/EludoidEpv.png?size=75x75" | |
}, | |
{ | |
name: "Amol Uyzator", | |
avatar: "https://robohash.org/AmolUyzator.png?size=75x75" | |
} | |
], | |
two: [ | |
{ | |
name: "Uhx Iforoid", | |
avatar: "https://robohash.org/UhxIforoid.png?size=75x75" | |
} | |
], | |
three: [ | |
{ | |
name: "Egator Azok", | |
avatar: "https://robohash.org/EgatorAzok.png?size=75x75" | |
}, | |
{ | |
name: "Oted Axun", | |
avatar: "https://robohash.org/OtedAxun.png?size=75x75" | |
} | |
] | |
}) | |
}); |
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({ | |
actions: { | |
dropReport: (el, target, source, sibling) => { | |
console.log("Dragged:", el); | |
console.log("Target container:", target); | |
console.log("Source container:", source); | |
console.log("Sibling:", sibling); | |
} | |
} | |
}); |
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: () => ({ | |
one: [ | |
{ | |
name: "Eludoid Epv", | |
avatar: "https://robohash.org/EludoidEpv.png?size=75x75" | |
}, | |
{ | |
name: "Amol Uyzator", | |
avatar: "https://robohash.org/AmolUyzator.png?size=75x75" | |
}, | |
{ | |
name: "Uhx Iforoid", | |
avatar: "https://robohash.org/UhxIforoid.png?size=75x75" | |
} | |
], | |
two: [ | |
{ | |
name: "Egator Azok", | |
avatar: "https://robohash.org/EgatorAzok.png?size=75x75" | |
}, | |
{ | |
name: "Oted Axun", | |
avatar: "https://robohash.org/OtedAxun.png?size=75x75" | |
} | |
] | |
}) | |
}); |
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'; | |
var Router = Ember.Router.extend({ | |
location: config.locationType | |
}); | |
Router.map(function() { | |
this.route("example-one"); | |
this.route("example-two"); | |
this.route("example-three"); | |
}); | |
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'; | |
// {{#simple-drag-and-drop dropped="action" containerSelector="css-selector" options=object}} | |
// Containers are found in this body using containerSelector. | |
// By default children of containers can be dragged onto all containers, but | |
// this can be adjusted via options. | |
// When a child element is dropped, "action" is called up the ancestor chain | |
// with arguments el, target, source,sibling: | |
// el -> the element dragged | |
// target -> the container dropped onto | |
// source -> the container dragged from | |
// sibling -> the element after the dropped element | |
// {{/static-drag-and-drop}} | |
export default Ember.Component.extend({ | |
willInsertElement: function() { | |
let drake = window.dragula(this.dragulaContainers(), this.dragulaOptions()); | |
drake.on("drop", (el, target, source, sibling) => { | |
this.sendAction("dropped", el, target, source, sibling); | |
}); | |
this.set("drake", drake); | |
console.log("New drake created, container count:", drake.containers.length); | |
}, | |
willDestroyElement: function() { | |
this.get("drake").destroy(); | |
this.set("drake", null); | |
console.log("Existing drake removed"); | |
}, | |
dragulaContainers: function() { | |
if (this.containerSelector === undefined) { | |
return []; | |
} else { | |
return this.$(this.containerSelector).get(); | |
} | |
}, | |
dragulaOptions: function() { | |
return this.options || {}; | |
} | |
}); |
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 { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.nav { | |
margin: 24px; | |
text-align: center; | |
} | |
.nav a { | |
color: white; | |
background-color: lightgray; | |
text-decoration: none; | |
padding: 8px; | |
} | |
.nav a.active, .nav a:hover { | |
background-color: gray; | |
} | |
.forty-percent { | |
width: 40%; | |
} | |
.container-group { | |
vertical-align: top; | |
border: solid #AAA 2px; | |
padding: 0 8px; | |
margin: 8px; | |
display: inline-block; | |
} | |
.container { | |
border: solid lightgray 2px; | |
padding: 0 16px; | |
margin: 16px 8px; | |
min-height: 16px; | |
} | |
.item { | |
color: gray; | |
text-align: center; | |
background-color: #EFEFEF; | |
border: solid lightgray 1px; | |
margin: 16px 0; | |
} | |
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.4.11", | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.13/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.10/ember-template-compiler.js", | |
"dragula": "https://cdnjs.cloudflare.com/ajax/libs/dragula/3.5.1/dragula.min.js", | |
"dragula-css": "https://cdnjs.cloudflare.com/ajax/libs/dragula/3.5.1/dragula.min.css" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment