Permalink
Browse files

You can now pass a function to the queryState option on hallobutton

  • Loading branch information...
1 parent 82dca67 commit 8a44835bbdb6f92a02810605f15f4b444d72a6c0 @madwire committed Nov 30, 2012
Showing with 15 additions and 6 deletions.
  1. +15 −6 src/widgets/button.coffee
View
@@ -41,12 +41,21 @@
_init: ->
@button = @_prepareButton() unless @button
@element.append @button
- queryState = (event) =>
- return unless @options.command
- try
- @checked document.queryCommandState @options.command
- catch e
- return
+
+ if @options.queryState == true
+ queryState = (event) =>
+ return unless @options.command
+ try
+ if @options.commandValue
+ value = document.queryCommandValue @options.command
+ compared = value.match(new RegExp(@options.commandValue,"i"))
+ @checked(if compared then true else false)
+ else
+ @checked document.queryCommandState @options.command
+ catch e
+ return
+ else
+ queryState = @options.queryState
if @options.command
@button.on 'click', (event) =>

0 comments on commit 8a44835

Please sign in to comment.