diff --git a/CHANGES.md b/CHANGES.md index ddcc3f4..df8b8fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,13 @@ +## 0.3.1 + +### New features: + +* debugging Drab functions directly from `IEx` console +* display information when handler die, different for prod and dev + + ## 0.3.0 + ### API Changes and Depreciations: * Drab.Query.select API changed: now `select(:val)` returns first value instead of the list, but all jQuery methods diff --git a/README.md b/README.md index 34d7c60..e09d91f 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ end ```elixir def deps do - [{:drab, "~> 0.3"}] + [{:drab, "~> 0.3.1"}] end ``` diff --git a/TODO.md b/TODO.md index 9ee3318..1d27298 100644 --- a/TODO.md +++ b/TODO.md @@ -1,19 +1,11 @@ -## 0.3.1 -Changes: -* display information when handler die (like error 500 page), different for prod and dev (Drab.Core) -* Drab.socket() returns current socket, so you can test Drab from iex console - ## 0.4.0 Changes: ## Bugs: -* Drab.Modal returns some sizzle on the second run, and do not wait, when debugging - all wrong while debugging -* all debugging function return stuff ater drab.modal, check flush after launching any modal * Ignoring unmatched topic "drab:/drab" in DrabPoc.UserSocket ## Future Changes: -* *** use GenServer, Luke! * rewrite Drab.Query - use meta, Luke! * tests, tests, tests * benchmarks diff --git a/lib/drab.ex b/lib/drab.ex index 1d939a7..b08374b 100644 --- a/lib/drab.ex +++ b/lib/drab.ex @@ -49,16 +49,12 @@ defmodule Drab do When started with iex (`iex -S mix phoenix.server`) Drab shows the helpful message on how to debug its functions: - Started Drab for /drab, handling events in DrabPoc.PageCommander - You may debug Drab functions in IEx by copy/paste the following: - import Drab.Core - import Drab.Query - import Drab.Modal - import Drab.Waiter + Started Drab for /drab/docs, handling events in DrabPoc.DocsCommander + You may debug Drab functions in IEx by copy/paste the following: + import Drab.Core; import Drab.Query; import Drab.Modal; import Drab.Waiter + socket = GenServer.call(pid("0.413.0"), :get_socket) - socket = GenServer.call(pid("0.634.0"), :get_socket) - - Examples: + Examples: socket |> select(:htmls, from: "h4") socket |> execjs("alert('hello from IEx!')") socket |> alert("Title", "Sure?", buttons: [ok: "Azaliż", cancel: "Poniechaj"]) diff --git a/lib/drab/channel.ex b/lib/drab/channel.ex index e3e1cb8..53b8f9b 100644 --- a/lib/drab/channel.ex +++ b/lib/drab/channel.ex @@ -71,12 +71,12 @@ defmodule Drab.Channel do pid_string = Regex.named_captures(~r/#PID<(?.*)>/, p) |> Map.get("pid") Logger.debug """ - Started Drab for #{socket.assigns.__url_path}, handling events in #{inspect(commander)} - You may debug Drab functions in IEx by copy/paste the following: - #{Enum.map(modules, fn module -> "import #{inspect(module)}" end) |> Enum.join("\n")} + Started Drab for #{socket.assigns.__url_path}, handling events in #{inspect(commander)} + You may debug Drab functions in IEx by copy/paste the following: + #{Enum.map(modules, fn module -> "import #{inspect(module)}" end) |> Enum.join("; ")} socket = GenServer.call(pid("#{pid_string}"), :get_socket) - Examples: + Examples: socket |> select(:htmls, from: "h4") socket |> execjs("alert('hello from IEx!')") socket |> alert("Title", "Sure?", buttons: [ok: "Azaliż", cancel: "Poniechaj"]) diff --git a/priv/templates/drab/drab.modal.js b/priv/templates/drab/drab.modal.js index 8f8fd97..5f54500 100644 --- a/priv/templates/drab/drab.modal.js +++ b/priv/templates/drab/drab.modal.js @@ -26,15 +26,17 @@ Drab.on_connect(function(resp, drab) { drab.channel.on("modal", function(message) { $modal = $(MODAL) $(MODAL_FORM).on("submit", function() { + $(MODAL).data("clicked", true) // prevents double send modal_button_clicked(message, "ok") return false // prevent submit }) $(MODAL_BUTTONS).on("click", function() { - $(this).data("clicked", true) + $(MODAL).data("clicked", true) modal_button_clicked(message, $(this).attr("name")) }) $modal.on("hidden.bs.modal", function() { - if (!$(MODAL_BUTTON_OK).data("clicked")) { + clearTimeout(drab.modal_timeout_function) + if (!$(MODAL).data("clicked")) { // if it is not an OK button (prevent double send) modal_button_clicked(message, "cancel") } @@ -46,10 +48,12 @@ Drab.on_connect(function(resp, drab) { clearTimeout(drab.modal_timeout_function) } drab.modal_timeout_function = setTimeout(function() { + $(MODAL).data("clicked", true) // prevents double send modal_button_clicked(message, "cancel") }, message.timeout) } - // set focus on form + + // set focus on the form $modal.on("shown.bs.modal", function() { $(MODAL_FORM + " :input").first().focus() })