<commit_before>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2015-2017 <NAME> <<EMAIL>>
;; Copyright (c) 2015-2017 <NAME> <<EMAIL>>

(ns uxbox.main.ui.workspace.header
  (:require [beicon.core :as rx]
            [uxbox.config :as cfg]
            [uxbox.util.router :as r]
            [potok.core :as ptk]
            [uxbox.main.store :as st]
            [uxbox.main.refs :as refs]
            [uxbox.main.data.workspace :as dw]
            [uxbox.main.data.history :as udh]
            [uxbox.main.data.lightbox :as udl]
            [uxbox.main.ui.workspace.clipboard]
            [uxbox.builtins.icons :as i]
            [uxbox.main.ui.users :as ui.u]
            [uxbox.main.ui.navigation :as nav]
            [uxbox.util.mixins :as mx :include-macros true]
            [uxbox.util.geom.point :as gpt]
            [uxbox.util.math :as mth]))

;; --- Zoom Widget

(mx/defc zoom-widget
  {:mixins [mx/reactive mx/static]}
  []
  (let [zoom (mx/react refs/selected-zoom)
        increase #(st/emit! (dw/increase-zoom))
        decrease #(st/emit! (dw/decrease-zoom))]
    [:ul.options-view
     [:li.zoom-input
      [:span.add-zoom {:on-click increase} "+"]
      [:span (str (mth/round (* 100 zoom)) "%")]
      [:span.remove-zoom {:on-click decrease} "-"]]]))

;; --- Header Component

(defn on-view-clicked
  [event project page]
  (let [token (:share-token project)
        index (:index page)
        url (str cfg/viewurl "#/" token "/" index)]
    (js/open url "new tab" "")))

(mx/defc header
  {:mixins [mx/static mx/reactive]}
  []
  (let [project (mx/react refs/selected-project)
        page (mx/react refs/selected-page)
        flags (mx/react refs/flags)
        toggle #(st/emit! (dw/toggle-flag %))
        on-undo #(st/emit! (udh/backwards-to-previous-version))
        on-redo #(st/emit! (udh/forward-to-next-version))
        on-image #(udl/open! :import-image)<commit_msg>Refresh the view app page each time user clicks on preview button.<commit_after>;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2015-2017 <NAME> <<EMAIL>>
;; Copyright (c) 2015-2017 <NAME> <<EMAIL>>

(ns uxbox.main.ui.workspace.header
  (:require [beicon.core :as rx]
            [uxbox.config :as cfg]
            [uxbox.util.router :as r]
            [potok.core :as ptk]
            [uxbox.main.store :as st]
            [uxbox.main.refs :as refs]
            [uxbox.main.data.workspace :as dw]
            [uxbox.main.data.history :as udh]
            [uxbox.main.data.lightbox :as udl]
            [uxbox.main.ui.workspace.clipboard]
            [uxbox.builtins.icons :as i]
            [uxbox.main.ui.users :as ui.u]
            [uxbox.main.ui.navigation :as nav]
            [uxbox.util.mixins :as mx :include-macros true]
            [uxbox.util.geom.point :as gpt]
            [uxbox.util.math :as mth]))

;; --- Zoom Widget

(mx/defc zoom-widget
  {:mixins [mx/reactive mx/static]}
  []
  (let [zoom (mx/react refs/selected-zoom)
        increase #(st/emit! (dw/increase-zoom))
        decrease #(st/emit! (dw/decrease-zoom))]
    [:ul.options-view
     [:li.zoom-input
      [:span.add-zoom {:on-click increase} "+"]
      [:span (str (mth/round (* 100 zoom)) "%")]
      [:span.remove-zoom {:on-click decrease} "-"]]]))

;; --- Header Component

(defn on-view-clicked
  [event project page]
  (let [token (:share-token project)
        index (:index page)
        rval (rand-int 1000000)
        url (str cfg/viewurl "?v=" rval "#/" token "/" index)]
    (js/open url "new tab" "")))

(mx/defc header
  {:mixins [mx/static mx/reactive]}
  []
  (let [project (mx/react refs/selected-project)
        page (mx/react refs/selected-page)
        flags (mx/react refs/flags)
        toggle #(st/emit! (dw/toggle-flag %))
        on-undo #(st/emit! (udh/backwards-to-previous-version))
        on-redo #(st/emit! (udh/forward-to-next-version))
        on-image #(udl/open! :import-image)
{'fraction_non_alphanumeric': 0.16422840962718263, 'fraction_numerical': 0.012505899008966493, 'mean_word_length': 2.283501161890008, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6030823', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1494, 'n_words': 367}