coffeescript-ui
Version:
Coffeescript User Interface System
75 lines (54 loc) • 1.98 kB
text/coffeescript
###
* coffeescript-ui - Coffeescript User Interface System (CUI)
* Copyright (c) 2013 - 2016 Programmfabrik GmbH
* MIT Licence
* https://github.com/programmfabrik/coffeescript-ui, http://www.coffeescript-ui.org
###
class CUI.ListViewTreeRowMove extends CUI.ListViewRowMove
initOpts: ->
super()
rowMoveWithinNodesOnly:
check: Boolean
get_init_helper_pos: (node, gd) ->
pos = super(node, gd)
= []
height = .getRowHeight()
for row, idx in .getRowsToMove()
row_i = row.getRowIdx()
.push(row_i)
height += .getRowHeight(row_i)
pos.height = height
pos
showHorizontalTargetMarker: (cell) ->
= [.before_row_i]
= [.after_row_i]
node =
# console.debug "moving node", .cell.row_i, node.getChildIdx(), node.getRowIdx()
if (ci = node.getChildIdx()) < node.father.children.length-1
.push(node.father.children[ci+1].getRowIdx())
if not
= null
CUI.dom.hideElement()
else
CUI.dom.showElement()
CUI.dom.setStyle ,
left: .left
top: .top
width: .width
height: .height
allowRowMove: ->
allow = true
# console.debug .row_i, .after, , ,
if .row_i in or
(.row_i in and .after) or
(.row_i in and not .after)
return false
[ from_node, to_node, new_father ] = .getNodesForMove(, .row_i, .after)
if and new_father
return false
# ask the source node, if it is ok to move it
if not from_node.allowRowMove(to_node, new_father, .after)
return false
return true