Add proper resizing of scrollable Notebook area
Resizing needed to be 100% of the height, but css would not work. Jquery is now used.
This commit is contained in:
parent
54d64cc124
commit
03238ad179
4 changed files with 85 additions and 18 deletions
|
|
@ -74,7 +74,7 @@ function wrapState(ComposedComponent) {
|
||||||
return StateWrapper;
|
return StateWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectableList = wrapState(SelectableList);
|
SelectableList = wrapState(SelectableList)
|
||||||
|
|
||||||
const DefaultRawTheme = Styles.LightRawTheme
|
const DefaultRawTheme = Styles.LightRawTheme
|
||||||
|
|
||||||
|
|
@ -133,19 +133,57 @@ export default class LibraryNav extends React.Component {
|
||||||
{'state': 'displaying', 'title': 'FieldNotes', 'notes': 10}
|
{'state': 'displaying', 'title': 'FieldNotes', 'notes': 10}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
this.sortNotebooks(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compareNotebooks = (a, b) => {
|
||||||
|
let atitle = a.title.toLowerCase()
|
||||||
|
let btitle = b.title.toLowerCase()
|
||||||
|
|
||||||
|
if(atitle > btitle)
|
||||||
|
return 1
|
||||||
|
if(atitle < btitle)
|
||||||
|
return -1
|
||||||
|
return 0
|
||||||
|
};
|
||||||
|
|
||||||
|
sortNotebooks = (notset) => {
|
||||||
|
this.state.notebooks.sort(this.compareNotebooks)
|
||||||
|
if (!notset){
|
||||||
|
this.setState({notebooks: this.state.notebooks})
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
static get childContextTypes(){
|
static get childContextTypes(){
|
||||||
return {muiTheme: React.PropTypes.object}
|
return {muiTheme: React.PropTypes.object}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getChildContext() {
|
getChildContext() {
|
||||||
return {
|
return {
|
||||||
muiTheme: getMuiTheme(DefaultRawTheme)
|
muiTheme: getMuiTheme(DefaultRawTheme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entriesTapped = (i, item, type, ev) => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
starredTapped = (i, item, type, ev) => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
recentsTapped = (i, item, type, ev) => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
trashTapped = (i, item, type, ev) => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
allNotesTapped = (i, item, type, ev) => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
blank(){
|
blank(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -159,6 +197,7 @@ export default class LibraryNav extends React.Component {
|
||||||
nb.title = notebookName
|
nb.title = notebookName
|
||||||
nb.state = 'displaying'
|
nb.state = 'displaying'
|
||||||
this.setState({notebooks: this.state.notebooks})
|
this.setState({notebooks: this.state.notebooks})
|
||||||
|
this.sortNotebooks()
|
||||||
}
|
}
|
||||||
else if(nb.title){
|
else if(nb.title){
|
||||||
nb.state = 'displaying'
|
nb.state = 'displaying'
|
||||||
|
|
@ -168,29 +207,39 @@ export default class LibraryNav extends React.Component {
|
||||||
|
|
||||||
addNotebookTapped = () => {
|
addNotebookTapped = () => {
|
||||||
var nbs = this.state.notebooks
|
var nbs = this.state.notebooks
|
||||||
nbs.push({'state': 'editing',
|
nbs.splice(0, 0, {'state': 'editing',
|
||||||
'title': '',
|
'title': '',
|
||||||
'notes': 0})
|
'notes': 0})
|
||||||
this.setState({notebooks: nbs})
|
this.setState({notebooks: nbs})
|
||||||
};
|
};
|
||||||
|
|
||||||
newNotebookTyped = (i) => {
|
newNotebookTyped = (i) => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
menuItemClicked = (i, ev) => {
|
menuItemClicked = (i, ev) => {
|
||||||
|
var item = this.state.navItems[i]
|
||||||
|
var type = 'leftClick'
|
||||||
var nativeEvent = ev.nativeEvent
|
var nativeEvent = ev.nativeEvent
|
||||||
if(nativeEvent.button == 2){
|
if(nativeEvent.button == 2){
|
||||||
//Right click
|
//Right click
|
||||||
|
type = 'rightClick'
|
||||||
}
|
}
|
||||||
|
item.clicked(i, item, type, ev)
|
||||||
};
|
};
|
||||||
|
|
||||||
renameTapped = (i) => {
|
renameTapped = (i) => {
|
||||||
var nbs = this.state.notebooks
|
var nbs = this.state.notebooks
|
||||||
nbs[i].state = 'editing'
|
nbs[i].state = 'editing'
|
||||||
this.setState({notebooks: nbs})
|
this.setState({notebooks: nbs}, () => {
|
||||||
|
console.log(i)
|
||||||
|
var nbsx = this.state.notebooks
|
||||||
this.props.closeContextMenu()
|
this.props.closeContextMenu()
|
||||||
//ReactDOM.findDOMNode(this.refs[nbs[i].title+i]).click()
|
//this.refs['textField'+i].focus()
|
||||||
|
//$(ReactDOM.findDOMNode(this.refs['listItem'+i])).click()
|
||||||
|
//console.log(node.find(':input'))
|
||||||
|
//node.find(':input')[0].focus()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTapped = (i) => {
|
deleteTapped = (i) => {
|
||||||
|
|
@ -232,7 +281,7 @@ export default class LibraryNav extends React.Component {
|
||||||
render(){
|
render(){
|
||||||
return (
|
return (
|
||||||
<div id={this.props.id} className={this.props.className || ""}>
|
<div id={this.props.id} className={this.props.className || ""}>
|
||||||
<SelectableList subheader="Library">
|
<SelectableList id="main-nav" subheader="Library">
|
||||||
{this.state.navItems.map((item, i) => {
|
{this.state.navItems.map((item, i) => {
|
||||||
return <ListItem
|
return <ListItem
|
||||||
primaryText={item.name}
|
primaryText={item.name}
|
||||||
|
|
@ -246,7 +295,7 @@ export default class LibraryNav extends React.Component {
|
||||||
</SelectableList>
|
</SelectableList>
|
||||||
<Divider />
|
<Divider />
|
||||||
<div>
|
<div>
|
||||||
<List subheader={<div>
|
<List id="nblist" subheader={<div>
|
||||||
<div className="inline">NoteBooks</div>
|
<div className="inline">NoteBooks</div>
|
||||||
<IconButton
|
<IconButton
|
||||||
onTouchTap={this.addNotebookTapped}
|
onTouchTap={this.addNotebookTapped}
|
||||||
|
|
@ -257,7 +306,7 @@ export default class LibraryNav extends React.Component {
|
||||||
color={colors.grey500}/>
|
color={colors.grey500}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>}>
|
</div>}>
|
||||||
<div>
|
<div id="notebook-list">
|
||||||
|
|
||||||
{this.state.notebooks.map((notebook, i) =>{
|
{this.state.notebooks.map((notebook, i) =>{
|
||||||
var l = null
|
var l = null
|
||||||
|
|
|
||||||
5
app/static/jquery-1.12.0.min.js
vendored
Normal file
5
app/static/jquery-1.12.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
index.html
12
index.html
|
|
@ -13,6 +13,8 @@
|
||||||
<div id="main">
|
<div id="main">
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
window.$ = window.jQuery = require('./app/static/jquery-1.12.0.min.js');
|
||||||
|
$(document).ready(function(){
|
||||||
document.addEventListener("keydown", function (e) {
|
document.addEventListener("keydown", function (e) {
|
||||||
if (e.which === 123) {
|
if (e.which === 123) {
|
||||||
require('remote').getCurrentWindow().toggleDevTools();
|
require('remote').getCurrentWindow().toggleDevTools();
|
||||||
|
|
@ -23,12 +25,16 @@
|
||||||
function resize()
|
function resize()
|
||||||
{
|
{
|
||||||
var heights = window.innerHeight;
|
var heights = window.innerHeight;
|
||||||
document.getElementById("main").style.height = heights + "px";
|
$("#main").height(heights+"px");
|
||||||
|
var h = $('#main-nav').outerHeight(true);
|
||||||
|
var subheaderHeight = $('#nblist > div:first-child').outerHeight(true);
|
||||||
|
$('#notebook-list').height(heights-h-subheaderHeight);
|
||||||
}
|
}
|
||||||
resize();
|
resize();
|
||||||
window.onresize = function() {
|
$(window).resize(function() {
|
||||||
resize();
|
resize();
|
||||||
};
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="dist/bundle.js"></script>
|
<script type="text/javascript" src="dist/bundle.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
body, html{
|
body, html{
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
#main{
|
#main{
|
||||||
}
|
}
|
||||||
|
|
@ -25,3 +26,9 @@ body, html{
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
#nblist{
|
||||||
|
padding-bottom: 0px !important;
|
||||||
|
}
|
||||||
|
#notebook-list{
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue