# text nodes don't have getBoundingClientRect(), so use selection api to find
# it.
-get_el_bounds = (el) ->
+get_el_bounds = window.bounds = (el) ->
if el.getBoundingClientRect?
rect = el.getBoundingClientRect()
else
@cursor_el = null
@cursor_visible = false
@poll_for_blur_timeout = null
- @iframe_offset = null
+ @wrap2_offset = null
@iframe_height = null
opt_fragment = @options.fragment ? true
@parser_opts = {}
if @options.on_init?
@options.on_init()
overlay_event_to_inner_xy: (e) ->
- unless @iframe_offset?
- @iframe_offset = get_el_bounds @iframe
- x = e.pageX # TODO ?cross-browserify
- y = e.pageY + @wrap2.scrollTop # TODO ?cross-browserify
- # TODO adjust for scrolling
- return x: x - @iframe_offset.x, y: y - @iframe_offset.y
+ unless @wrap2_offset?
+ @wrap2_offset = get_el_bounds @wrap2
+ x = e.pageX - overlay_padding
+ y = e.pageY - overlay_padding + @wrap2.scrollTop
+ return x: x - @wrap2_offset.x, y: y - @wrap2_offset.y
onclick: (e) ->
xy = @overlay_event_to_inner_xy e
new_cursor = find_loc_cursor_position @tree, xy