~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/oeb/polish/preview.coffee

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
ImportĀ upstreamĀ versionĀ 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
        elem = elem.parentNode
18
18
    return false
19
19
 
20
 
previous_sibling = (node) ->
21
 
    node = node.previousSibling
22
 
    while node and node.nodeType != Node.ELEMENT_NODE
23
 
        node = node.previousSibling
24
 
    return node
25
 
 
26
20
is_block = (elem) ->
27
21
    style = window.getComputedStyle(elem)
28
22
    return style.display in ['block', 'flex-box', 'box']
88
82
 
89
83
    report_split: (node) =>
90
84
        loc = []
 
85
        totals = []
91
86
        parent = find_containing_block(node)
92
87
        while parent and parent.tagName.toLowerCase() != 'body'
 
88
            totals.push(parent.parentNode.children.length)
93
89
            num = 0
94
 
            sibling = previous_sibling(parent)
 
90
            sibling = parent.previousElementSibling
95
91
            while sibling
96
92
                num += 1
97
 
                sibling = previous_sibling(sibling)
 
93
                sibling = sibling.previousElementSibling
98
94
            loc.push(num)
99
95
            parent = parent.parentNode
100
96
        loc.reverse()
101
 
        window.py_bridge.request_split(JSON.stringify(loc))
 
97
        totals.reverse()
 
98
        window.py_bridge.request_split(JSON.stringify(loc), JSON.stringify(totals))
102
99
 
103
100
    onload: () =>
104
101
        window.document.body.addEventListener('click', this.onclick, true)