Skip to content

Commit

Permalink
Update button state when in area of corresponding formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed May 6, 2011
1 parent d94e463 commit d44424f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
22 changes: 18 additions & 4 deletions examples/format.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/test.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<head>
<link rel="stylesheet" href="Aristo/jquery-ui-1.8.7.custom.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<link rel="stylesheet" href="Aristo/jquery-ui-1.8.7.custom.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script src="hallo.js"></script>
<script src="format.js"></script>
Expand Down
12 changes: 11 additions & 1 deletion format.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
_create: ->
widget = this
buttonset = jQuery "<span></span>"
for format in @options.formattings
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()
Expand All @@ -21,9 +21,19 @@
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)

0 comments on commit d44424f

Please sign in to comment.