Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve inline docs

  • Loading branch information...
commit d11f7312a02a23fc10494a8e6fb729df09bb5ca5 1 parent 97ab81c
@kugaevsky authored
View
10 lib/generators/mousetrap/install/install_generator.rb
@@ -2,16 +2,20 @@ module Mousetrap
# Mousetrap rails generators module
module Generators
+
+ # Install generator implementation
class InstallGenerator < ::Rails::Generators::Base
desc "Copy Mousetrap default files"
source_root File.expand_path('../templates', __FILE__)
- # Copy keybindings scripts to assets folder
+ # Copy keybindings scripts to assets folder. This coffescript file
+ # provides unobtrusive way to use HTML5 data attributes for
+ # binding click and focus events to DOM elements.
def copy_mousetrap
copy_file "keybindings.js.coffee", "app/assets/javascripts/keybindings.js.coffee"
end
- # Inject moustrap scripts to application.js
+ # Inject mousetrap scripts to manifest file `application.js`
def add_javascript_assets
if File.exist?('app/assets/javascripts/application.js')
insert_into_file "app/assets/javascripts/application.js", "//= require mousetrap\n", :after => "jquery_ujs\n"
@@ -20,7 +24,7 @@ def add_javascript_assets
end
end
- # Inject moustrap styles to application.css
+ # Inject mousetrap styles to manifest file `application.css`
def add_css_assets
if File.exist?('app/assets/stylesheets/application.css')
insert_into_file "app/assets/stylesheets/application.css", "*= require mousetrap\n ", :before => "*= require_tree ."
View
2  lib/generators/mousetrap/install/templates/keybindings.js.coffee
@@ -24,7 +24,7 @@ $ ->
window.mouseTrapRails =
showOnLoad: false # Show/hide hotkey hints by default (on page load). Mostly for debugging purposes.
toggleKeys: 'alt+shift+h' # Keys combo to toggle hints visibility.
- keysShown: false
+ keysShown: false # State of hotkey hints
toggleHints: ->
$('a[data-keybinding]').each (i, el) ->
$el = $(el)
Please sign in to comment.
Something went wrong with that request. Please try again.