 (ns ixinfestor.omut
+
+  (:import [goog.dom query])
 
   (:require-macros [cljs.core.async.macros :refer [go]])
   (:require [cljs.core.async :refer [put! chan <!]]
             [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
 
+            [goog.dom.classes :as aclasses]
             ;;[sablono.core :as html :refer-macros [html]]
 
             [ixinfestor.net :as ixnet]
 
             ))
-
 
 
 


(defn modal-show [app]
  (om/transact!
   app [:show]
   (fn [i] (if i (inc i) 0))))

(defn modal-hide [app]
  (om/transact!
   app [:show]
   (fn [_] false)))

(defonce modal-id-seq (atom 0))
(defn- modal-id- []
  (str "modal-" (swap! modal-id-seq inc)))

(defn modal [app owner {:keys [id
                               label
                               header
                               body
                               footer
                               class+]
                        :or {id (modal-id-)
                             label "Пустая пометка"
                             header (dom/h4 #js {:className "modal-title"} "Пустой заголовок")
                             body (dom/p #js {:className "text-info"}
                                         "Пустое пространство диалога. Можно наполнить элементами")

                                                     :data-dismiss "modal"}
                                                "Закрыть")
                             class+ ""}}]
  (reify
    om/IInitState
    (init-state [_]
      {:id (get-modal-id)})
    om/IWillUnmount
    (will-unmount [_]
      (swap! modals-status disj (om/get-state owner :id)))
    om/IRenderState
    (render-state [this {id :id}]
      (println "modal id:" id)
      (let [show? (:show app)]
        (swap! modals-status (if show? conj disj) id)
        (dom/div #js {:aria-hidden "true"
                      :aria-labelledby label
                      :style (if show?
                               #js {:display "block" :paddingLeft 0}
                               #js {:display "none" })
                      :className (if show? "modal in" "modal")
                      :role "dialog"
                      :tabIndex "-1"}
                 (dom/div #js {:className (str "modal-dialog " class+)}
                          (dom/div #js {:className "modal-content"}
                                   (dom/div #js {:className "modal-header"} header)
                                   (dom/div #js {:className "modal-body"}   body)
                                   (dom/div #js {:className "modal-footer"} footer))))))))



