From 191164ed4c451edc61bb5e10d4b6deba8cbb3a71 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Fri, 19 Oct 2012 12:14:02 -0600 Subject: [PATCH] Add `$.fn.command` method which ensures event is documented For now, we auto-generate the documentation string by humanizing the event name. In the future, we may provide the option to provide more documentation, such as info about any arguments to the event, extended documentation, etc. --- src/app/root-view.coffee | 10 +++++----- src/stdlib/jquery-extensions.coffee | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 3f98d2d0f..6a8162eb5 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -74,11 +74,11 @@ class RootView extends View @project.setPath(path) unless @project.getRootDirectory() @setTitle(path) - @on 'root-view:increase-font-size', => @setFontSize(@getFontSize() + 1) - @on 'root-view:decrease-font-size', => @setFontSize(@getFontSize() - 1) - @on 'root-view:focus-next-pane', => @focusNextPane() - @on 'root-view:save-all', => @saveAll() - @on 'root-view:toggle-invisibles', => @setShowInvisibles(not @showInvisibles) + @command 'root-view:increase-font-size', => @setFontSize(@getFontSize() + 1) + @command 'root-view:decrease-font-size', => @setFontSize(@getFontSize() - 1) + @command 'root-view:focus-next-pane', => @focusNextPane() + @command 'root-view:save-all', => @saveAll() + @command 'root-view:toggle-invisibles', => @setShowInvisibles(not @showInvisibles) afterAttach: (onDom) -> @focus() if onDom diff --git a/src/stdlib/jquery-extensions.coffee b/src/stdlib/jquery-extensions.coffee index 928e15c0a..8e0259b57 100644 --- a/src/stdlib/jquery-extensions.coffee +++ b/src/stdlib/jquery-extensions.coffee @@ -65,3 +65,10 @@ $.fn.events = -> _.extend(@parent().events(), events) else events + +$.fn.command = (args...) -> + eventName = args[0] + documentation = {} + documentation[eventName] = _.humanizeEventName(eventName) + @document(documentation) + @on(args...)