1. Takafumi Arakaki
  2. neorg

Commits

Takafumi Arakaki  committed 877f278

Added docstrings to neorg.coffee

  • Participants
  • Parent commits b4d2787
  • Branches default

Comments (0)

Files changed (1)

File neorg/static/neorg.coffee

View file
+#### Open neighboring image
+#
+# The first argument `arrow` must be a string in `arrowKeyArray`.
 neorgCBOpen = (arrow) ->
   ctd = $.colorbox.element().parent()
   if arrow == "left"
   oa = otd.children("a.neorg-gene-image-link").first()
   oa.click() if oa.length
 
+
+#### Helper function for `bindKeydownToNeorgCBOpen`
 bindKeydown = (key, func) ->
   $(document).bind "keydown.neorg." + key, key, func
 
+
+#### Bind arrow keys using [jquery.hotkeys]
+#
+# [jquery.hotkeys]: https://github.com/tzuryby/jquery.hotkeys/
 bindKeydownToNeorgCBOpen = (key) ->
   bindKeydown key, (e) ->
     e.preventDefault()
     neorgCBOpen key
 
+
+#### Unbind arrow keys; called via colorbox's `onClosed`
 unBindKeydown = (key) ->
   $(document).unbind "keydown.neorg." + key
 
 arrowKeyArray = [ "left", "right", "up", "down" ]
 
+
+#### Setting for [colorbox] plugin
+#
+# [colorbox]: http://jacklmoore.com/colorbox/
 neorgCBSetting =
   title: ->
     $(this).attr "title", $(this).prev("p").text()
       unBindKeydown arrowKeyArray[i]
 
 
+#### Colorize dictdiff table using [jquery.heatcolor] plugin
+#
+# [jquery.heatcolor]: http://www.jnathanson.com/blog/client/jquery/heatcolor/
 neorgDictDiffInit = ->
   $("table.neorg-dictdiff").each ->
     ncolsList = ($(e).find("td").length for e in $(this).find("tr"))
         .heatcolor -> $(this).text()
 
 
+#### Dynamically load text area to edit current page
+#
+# This function will be invoked by clicking `a.page-action-edit`
 neorgEdit = ->
   $("#edit-form-wrapper").html "<p>Loading...</p>"
   $.ajax
   return false
 
 
+#### Initialize everything for a neorg page
+#
 neorgInit = ->
   $(".neorg-gene-image-link").colorbox neorgCBSetting
 
   $("#edit-form-textarea").focus()
 
 
-# export functions as global function
-# see: http://stackoverflow.com/questions/4214731/
+#### Export `neorgInit` as a global function
+# see: <http://stackoverflow.com/questions/4214731/>
 root = exports ? this
 root.neorgInit = neorgInit