                      (set! SHORTENING-IN-PROGRESS
                            (dissoc SHORTENING-IN-PROGRESS currentUrl)))}))
 
-(defn- get-short-url-jq-evt-handler-maker
-  "Returns a function suitable for a jQuery event handler; the returned function
-   tries to obtain a short url and sets the result in the #url-shortener
-   <input>"
-  [$urlShortenerInput localStorage & [actionAfterDone]]
-  (fn []
-    (let [currentUrl (aget js/document "URL")
-          localStorageKey (str "shortUrl-" currentUrl)
-
-          mbShortUrl (and localStorage
-                          (.getItem localStorage localStorageKey))]
-      (cond mbShortUrl
-            ; the set! on `SHORTENING-IN-PROGRESS` is carried out to clear away
-            ; any actions that may have been added by the :else part of this
-            ; `cond` after the url has been shortened
-            (do (set! SHORTENING-IN-PROGRESS
-                      (dissoc SHORTENING-IN-PROGRESS currentUrl))
-                (.val $urlShortenerInput mbShortUrl)
-                (if actionAfterDone
-                    (do-action-after-url-shortening mbShortUrl actionAfterDone)))
-
-            (not (contains? SHORTENING-IN-PROGRESS currentUrl))
-            (do (add-url-and-action-to-shortening-in-progress currentUrl
-                                                              actionAfterDone)
-                (make-request-to-get-short-url currentUrl actionAfterDone
-                                               $urlShortenerInput localStorage
-                                               localStorageKey))
-
-            ; currentUrl in `SHORTENING-IN-PROGRESS`.
-            ; add `actionAfterDone` to the set of actions to perform
-            :else
-            (add-url-and-action-to-shortening-in-progress currentUrl
-                                                          actionAfterDone)))))
+(defn- get-short-url-jq-evt-handler-maker-maker
+  "Returns a function f1 that takes in an optional action. function f1 after
+   taking the action, returns a function f2 suitable for a jQuery event handler.
+   f2 tries to obtain a short url, sets the resulting short url in the
+   #url-shortener <input>, and performs any actions associated with the url
+   submitted for shortening."
+  [$urlShortenerInput localStorage]
+  (fn [& [actionAfterDone]]
+    (fn []
+      (let [currentUrl      (aget js/document "URL")
+            localStorageKey (str "shortUrl-" currentUrl)
+            mbShortUrl      (and localStorage
+                                 (.getItem localStorage localStorageKey))]
+        (cond mbShortUrl
+              ; the set! on `SHORTENING-IN-PROGRESS` is carried out to clear away
+              ; any actions that may have been added by the :else part of this
+              ; `cond` after the url has been shortened
+              (do (set! SHORTENING-IN-PROGRESS
+                        (dissoc SHORTENING-IN-PROGRESS currentUrl))
+                  (.val $urlShortenerInput mbShortUrl)
+                  (if actionAfterDone
+                      (do-action-after-url-shortening mbShortUrl
+                                                      actionAfterDone)))
+
+              (not (contains? SHORTENING-IN-PROGRESS currentUrl))
+              (do (add-url-and-action-to-shortening-in-progress currentUrl
+                                                                actionAfterDone)
+                  (make-request-to-get-short-url currentUrl actionAfterDone
+                                                 $urlShortenerInput localStorage
+                                                 localStorageKey))
+
+              ; currentUrl in `SHORTENING-IN-PROGRESS`.
+              ; add `actionAfterDone` to the set of actions to perform
+              :else
+              (add-url-and-action-to-shortening-in-progress currentUrl
+                                                            actionAfterDone))))))
 
 (defn- qtip-for-sharing-button
   "Add qtip for social sharing buttons"

(defn- short-url-setup
  "Setup url shortening"
  []
  (let [ZeroClipboard       (aget js/window "ZeroClipboard")

        ; NOTE: This `ZeroClipboard.config` must be performed before we create
        ;       a new instance of ZeroClipboard.

                         (str "http://cdnjs.cloudflare.com/ajax/libs"
                              "/zeroclipboard/2.1.1/ZeroClipboard.swf")))

        $copy-to-clipboard      ($ :#copy-to-clipboard)
        ; setup the `copy shorturl` button
        localStorage            (aget js/window "localStorage")
        zcbClient               (ZeroClipboard. $copy-to-clipboard)
        $urlShortenerInput      ($ :#url-shortener)
        $share-via-email        ($ :#share-via-email)
        $share-via-twitter      ($ :#share-via-twitter)

        get-short-url-evt-handler-maker
        (get-short-url-jq-evt-handler-maker-maker $urlShortenerInput
                                                  localStorage)

        get-short-url-no-action (get-short-url-evt-handler-maker)
        qtipOrgCopyText         "Copy to Clipboard"

        qtipApi
        (-> $copy-to-clipboard
