Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tree: a8acb0ecf2
Fetching contributors…

Cannot retrieve contributors at this time

76 lines (61 sloc) 2.186 kB
# Hallo - a rich text editing jQuery UI widget
# (c) 2011 Henri Bergius, IKS Consortium
# Hallo may be freely distributed under the MIT license
# Fixed toolbar plugin
((jQuery) ->
jQuery.widget 'Hallo.halloToolbarFixed',
toolbar: null
parentElement: 'body'
editable: null
toolbar: null
_create: ->
@toolbar = @options.toolbar
jQuery(@options.parentElement).append @toolbar
jQuery(window).resize (event) =>
# Make sure the toolbar has not got the full width of the editable
# element when floating is set to true
if @options.parentElement is 'body'
el = jQuery(@element)
widthToAdd = parseFloat el.css('padding-left')
widthToAdd += parseFloat el.css('padding-right')
widthToAdd += parseFloat el.css('border-left-width')
widthToAdd += parseFloat el.css('border-right-width')
widthToAdd += (parseFloat el.css('outline-width')) * 2
widthToAdd += (parseFloat el.css('outline-offset')) * 2
jQuery(@toolbar).css "width", el.width() + widthToAdd
_getPosition: (event, selection) ->
return position =
top: 0
left: 0
_getCaretPosition: (range) ->
tmpSpan = jQuery "<span/>"
newRange =rangy.createRange()
newRange.setStart range.endContainer, range.endOffset
newRange.insertNode tmpSpan.get 0
position =
top: tmpSpan.offset().top
left: tmpSpan.offset().left
return position
setPosition: ->
return unless @options.parentElement is 'body'
@toolbar.css 'position', 'absolute'
@toolbar.css 'top', @element.offset().top - @toolbar.outerHeight()
@toolbar.css 'left', @element.offset().left + 10
_updatePosition: (position) ->
_bindEvents: ->
# catch activate -> show
@element.on 'halloactivated', (event, data) =>
# catch deactivate -> hide
@element.on 'hallodeactivated', (event, data) =>
) jQuery
Jump to Line
Something went wrong with that request. Please try again.