Created
March 23, 2016 18:28
-
-
Save pwilms/1382d606c05671584c58 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains 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({ | |
attributeBindings: ["draggable"], | |
classNames: ["a-handle"], | |
draggable: true, | |
dragStart(e) { | |
this.set("origX", e.originalEvent.clientX); | |
this.set("origWidth", parseInt(this.$().closest("th,td").css("width").replace(/px$/, ""), 10)); | |
}, | |
drag(e) { | |
const newX = e.originalEvent.clientX; | |
if (newX > 0) { | |
this.sendAction("resize", | |
this.get("origWidth") - this.get("origX") + newX); | |
} | |
}, | |
dragEnd(e) { | |
this.set("origX", false); | |
} | |
}); |
This file contains 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; | |
export default Ember.Controller.extend({ | |
actions: { | |
resize(column, width) { | |
if (width > 10) { | |
const fullWidth = this.get("fullWidth"); | |
if (column === "a") { | |
let newBWidth = fullWidth - this.get("cWidthPx") - width; | |
if (newBWidth > 10) { | |
this.set("aWidthPx", width); | |
this.set("bWidthPx", newBWidth); | |
} | |
} else { | |
let newCWidth = fullWidth - this.get("aWidthPx") - width; | |
if (newCWidth > 10) { | |
this.set("bWidthPx", width); | |
this.set("cWidthPx", newCWidth); | |
} | |
} | |
} | |
} | |
}, | |
aWidthPx: 150, | |
aWidth: computed("aWidthPx", function() { | |
return `width: ${this.get("aWidthPx")}px`; | |
}), | |
bWidthPx: 150, | |
bWidth: computed("bWidthPx", function() { | |
return `width: ${this.get("bWidthPx")}px`; | |
}), | |
cWidthPx: 150, | |
cWidth: computed("cWidthPx", function() { | |
return `width: ${this.get("cWidthPx")}px`; | |
}), | |
fullWidth: 450, | |
fullWidthStyle: computed("fullWidth", function() { | |
return `width: ${this.get("fullWidth")}px`; | |
}), | |
appName: 'Ember Twiddle' | |
}); |
This file contains 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
* { | |
box-sizing: border-box; | |
} | |
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.a-handle { | |
display:block; | |
width:1px; | |
height: 100%; | |
background: transparent; | |
float: right; | |
cursor: ew-resize | |
} | |
table { | |
border-collapse: collapse; | |
} | |
table, td, th, tr { | |
padding: 0; | |
margin: 0; | |
} | |
td, th { | |
border: 1px solid black | |
} | |
.ellipsis{ | |
width: auto; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
white-space: nowrap; | |
} |
This file contains 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.6.5", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.0/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment