         (case @resource-input-mode
           :file_input (do
                         (init-resources :file_input resource-atom)
-                        [:div [resources-grid :file_input resource-atom state]])
+                        [:div [resources-grid :file_input resource-atom state data init-data]])
           :page_input (do
                         (init-resources :page_input resource-atom)
-                        [:div [resources-grid :page_input resource-atom state]])
-          :url_input [:div {:style {:margin-bottom "10px"}}
-                      [input {:name "evidence-url" :atom evidence-url-atom :type "url"}]
-                      [:button {:type "button"
-                                :class "btn btn-primary"
-                                :disabled (not (url? @evidence-url-atom))
-                                :on-click #(do
-                                             (.preventDefault %)
-                                             (reset! show-url? true)
-                                             (reset! resource-input-mode nil))}
-                       (t :core/Add)]]
+                        [:div [resources-grid :page_input resource-atom state data init-data]])
+          :url_input [:div.resource-container {:style {:margin-bottom "10px"}}
+                      [input {:name "evidence-url" :atom evidence-url-atom :type "url" :placeholder "http://"}]]
           nil)]])))
-
 
 (defn evidence-form [data state init-data]
   (let [settings-tab (first (plugin-fun (session/get :plugins) "settings" "settings_tab_content"))
         evidence-name-atom (cursor state [:evidence :name])
         evidence-description-atom (cursor state [:evidence :description])
         evidence-url-atom (cursor state [:evidence :url])
-        page-input-enabled? (cursor state [:page_input])
         message (cursor state [:evidence :message])
-        show-url? (cursor state [:evidence :show_url])
-        file-input-enabled? (cursor state [:file_input])
-        resource-input-mode (cursor state [:input_mode])
-        show-form (cursor state [:show_form])
+        input-mode (cursor state [:input_mode])
         {:keys [image_file name]} data]
 
     [:div {:id "badge-settings" :class "row flip"}

            (translate-text message)]
           [:div
            [:i {:class "fa fa-cog fa-spin fa-2x"}]
            [:span " " (translate-text message)]])]
   ])

(defn upload-file [files-atom state]
  (let [files (:files @files-atom)

            [salava.core.ui.helper :refer [plugin-fun path-for hyperlink base-url]]
            [salava.core.ui.ajax-utils :as ajax]
            [salava.core.time :refer [date-from-unix-time]]
            [clojure.string :refer [blank? includes? split trim starts-with?]]
            [salava.file.icons :refer [file-icon]]
            [salava.file.ui.my :refer [send-file]]))

(defn url? [s]
  (when-not (blank? s)
    (not (blank? (re-find #"^http" (str (trim s)))))))


(defn toggle-input-mode [key state]
  (let [key-atom (cursor state [:input_mode])]
    (do (reset! key-atom nil) (reset! key-atom key))))

(defn delete-evidence! [id data state init-data]
  (let [init-settings (first (plugin-fun (session/get :plugins) "modal" "show_settings_dialog"))]
    (ajax/DELETE
      (path-for (str "/obpv1/badge/evidence/" id))
      { :params {:user_badge_id (:id data)}
        :handler (fn [r]
                   (when (= "success" (:status r))
                     (init-settings (:id data) state init-data "settings")))})))


(defn init-resources [key resource-atom]
  (let [url (case key
              :page_input "/obpv1/page"
              :file_input "/obpv1/file")]
    (ajax/GET
      (path-for url true)
      {:handler (fn [data]
                  (reset! resource-atom data))})))

(defn init-evidence-form [evidence state show-url?]
  (let [ {:keys [id name url description]} evidence
         evidence { :id (:id evidence)
                    :name (:name evidence)
                    :url (:url evidence)
                    :description (:description evidence)}]
    (swap! state assoc :evidence evidence)))


(defn set-page-visibility-to-private [page-id]
  (ajax/POST
    (path-for (str "/obpv1/page/toggle_visibility/" page-id))
    {:params {:visibility "public"}
     :handler (fn [data]
                (prn data))}))

(defn save-badge-evidence [data state init-data]
  (let [{:keys [id name description url visibility resource_id]} (:evidence @state)
        badge-id (:id data)
        init-settings (first (plugin-fun (session/get :plugins) "modal" "show_settings_dialog"))]
    (swap! state assoc :evidence {:message nil})
    (if (blank? url)
      (swap! state assoc :evidence {:message [:div.alert.alert-warning [:p "Resource field can't be empty!"]]})

      (do
        (if (= "private" visibility) (set-page-visibility-to-private resource_id))
        (ajax/POST
          (path-for (str "/obpv1/badge/evidence/" badge-id))
          {:params {:id id
                    :name (if name (trim name))
                    :description description
                    :url (if url (trim url))}
           :handler (fn [resp]
                      (when (= "success" (:status resp))
                        (init-settings (:id data) state init-data "settings")))})))))

;;;;

(defn input [input-data textarea?]
  (let [{:keys [name atom placeholder type error-message-atom rows cols]} input-data]
