                                (.-target evt)))
                              evt))))
 
-(defn menu-container-el? [el]
-  (= (.-id el) "menu-container"))
-
 (defn make-menu-builder-sortable [feeds documents]
   (let [menu-container-el (dom/getElement "menu-container")]
     (ui/to-sortable-tree (dom/getElement menu-container-el)

                           documents))))

(defn menu-item-dialog-callback [feeds documents parent-el e]
  (if (= "ok" (.-key e))
    (let [nested (classes/has parent-el "new-node")
          new-link-details (menu-item-link-details-from-dialog!)
          menu-container-el (dom/getElement "menu-container")
          active-el (or parent-el menu-container-el)]
      (validate-link-label! (:label new-link-details))
      (if (classes/has (dom/getElement "add-link-status") "error")
        (do
          (. e (preventDefault))
          (when-not (menu-container-el? active-el)
            (dom/removeNode active-el)))
        (do
          (classes/remove parent-el "new-node")
          (let [dummy-el (dom/createElement "ul")]
            (set! (.-innerHTML dummy-el)
                  (ui/render-template-as-string tpl/menu-item-li
                                                new-link-details))

                       (:language feed)
                       (:name feed)))))))]
         
         (let [save-button-el (dom/getElement "save-document")]
           (events/listen save-button-el
                          "click"
                          (fn [e]
                            (set! (.-innerHTML save-button-el) "Saving...")
                            (set! (.-disabled save-button-el) true)
                            (validate-title-and-get-save-fn)))))

       (cond
        (= mode :image)
