Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (34 sloc) 1.46 KB
# Hallo - a rich text editing jQuery UI widget
# (c) 2011 Henri Bergius, IKS Consortium
# Hallo may be freely distributed under the MIT license
((jQuery) ->
jQuery.widget "IKS.halloformat",
options:
editable: null
toolbar: null
uuid: ""
formattings: ["bold", "italic"]
_create: ->
widget = this
buttonset = jQuery "<span></span>"
buttonize = (format) =>
label = format.substr(0, 1).toUpperCase()
id = "#{@options.uuid}-#{format}"
buttonset.append jQuery("<input id=\"#{id}\" type=\"checkbox\" /><label for=\"#{id}\">#{label}</label>").button()
button = jQuery "##{id}", buttonset
button.attr "hallo-command", format
button.bind "change", (event) ->
format = jQuery(this).attr "hallo-command"
widget.options.editable.execute format
@element.bind "keyup paste change", ->
if document.queryCommandState format
button.attr "checked", true
button.button "refresh"
else
button.attr "checked", false
button.button "refresh"
buttonize format for format in @options.formattings
buttonset.buttonset()
@options.toolbar.append buttonset
_init: ->
)(jQuery)