Skip to content

Commit

Permalink
Close #34
Browse files Browse the repository at this point in the history
  • Loading branch information
yishn committed Dec 27, 2015
1 parent b48315f commit c716145
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
3 changes: 2 additions & 1 deletion modules/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ exports
.default('sound.enable', true)
.default('view.comments_height', 50)
.default('view.comments_minheight', 20)
.default('view.leftsidebar_width', 250)
.default('view.fuzzy_stone_placement', true)
.default('view.show_leftsidebar', false)
.default('view.show_comments', false)
.default('view.show_coordinates', false)
.default('view.show_variations', true)
.default('view.show_graph', false)
.default('view.leftsidebar_width', 250)
.default('view.leftsidebar_minwidth', 100)
.default('view.sidebar_width', 200)
.default('view.sidebar_minwidth', 100)
.default('window.height', 648)
Expand Down
36 changes: 27 additions & 9 deletions view/index.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function setLeftSidebarWidth(width) {
$('main').setStyle('left', width)
}

function getShowLeftSidebarWidth() {
function getLeftSidebarWidth() {
return $('leftsidebar').getStyle('width').toInt()
}

Expand Down Expand Up @@ -957,22 +957,29 @@ document.addEvent('domready', function() {

$$('.verticalresizer').addEvent('mousedown', function() {
if (event.button != 0) return
this.getParent().store('initposx', new Tuple(event.x, getSidebarWidth()))
this.getParent().store('initposx', new Tuple(event.x, this.getParent().getStyle('width').toInt()))
})

$$('#sidebar .horizontalresizer').addEvent('mousedown', function() {
if (event.button != 0) return
$('sidebar').store('initposy', new Tuple(event.y, getCommentHeight()))
$('properties').setStyle('transition', 'none')
})

document.body.addEvent('mouseup', function() {
var initPosX = $('sidebar').retrieve('initposx')
var sidebarInitPosX = $('sidebar').retrieve('initposx')
var leftSidebarInitPosX = $('leftsidebar').retrieve('initposx')
var initPosY = $('sidebar').retrieve('initposy')
if (!initPosX && !initPosY) return

if (initPosX) {
if (!sidebarInitPosX && !leftSidebarInitPosX && !initPosY) return

if (sidebarInitPosX) {
$('sidebar').store('initposx', null)
setting.set('view.sidebar_width', getSidebarWidth())
} else if (leftSidebarInitPosX) {
$('leftsidebar').store('initposx', null)
setting.set('view.leftsidebar_width', getLeftSidebarWidth())
return
} else if (initPosY) {
$('sidebar').store('initposy', null)
$('properties').setStyle('transition', '')
Expand All @@ -983,16 +990,27 @@ document.addEvent('domready', function() {
if ($('graph').retrieve('sigma'))
$('graph').retrieve('sigma').renderers[0].resize().render()
}).addEvent('mousemove', function() {
var initPosX = $('sidebar').retrieve('initposx')
var sidebarInitPosX = $('sidebar').retrieve('initposx')
var leftSidebarInitPosX = $('leftsidebar').retrieve('initposx')
var initPosY = $('sidebar').retrieve('initposy')
if (!initPosX && !initPosY) return

if (initPosX) {
initPosX.unpack(function(initX, initWidth) {
if (!sidebarInitPosX && !leftSidebarInitPosX && !initPosY) return

if (sidebarInitPosX) {
sidebarInitPosX.unpack(function(initX, initWidth) {
var newwidth = Math.max(initWidth - event.x + initX, setting.get('view.sidebar_minwidth'))
setSidebarWidth(newwidth)
resizeBoard()
})
} else if (leftSidebarInitPosX) {
leftSidebarInitPosX.unpack(function(initX, initWidth) {
var newwidth = Math.max(initWidth + event.x - initX, setting.get('view.leftsidebar_minwidth'))
setLeftSidebarWidth(newwidth)
resizeBoard()
})

$('console').retrieve('scrollbar').update()
return
} else if (initPosY) {
initPosY.unpack(function(initY, initHeight) {
var newheight = Math.min(Math.max(
Expand Down

0 comments on commit c716145

Please sign in to comment.