<commit_before>-----------------------------------------------------------------------------
-- |
-- Module      :  Handler.Home.UIButtons
-- Copyright   :  (c) <NAME>
-- License     :  MIT
--
-- Maintainer  :  <NAME> <<EMAIL>>
-- Stability   :  experimental
--
-----------------------------------------------------------------------------

module Handler.Home.UIButtons
  ( uiButtons
  ) where

import Import
import Text.Julius

-- | Rotating circular progress bar.
--   Exposes:
--     * #helpbutton
--     * #fullscreenbutton
--     * #submitbutton
--     * #toolboxbutton
--     * #clearbutton
--     * #evaluatebutton
uiButtons :: Maybe (ScenarioProblemId, UserId) -> Handler (Widget, Widget)
uiButtons mscpuid = do

  popupSubmitId <- newIdent
  popupShareId <- newIdent
  sfGeometry <- newIdent
  sfPreview <- newIdent
  submitForm <- newIdent
  previewcontainer <- newIdent

  textAreaDesc <- newIdent

  let popupSubmit = do
        toWidgetBody
              [hamlet|
                <script>
                  (function() {
                  if (document.getElementById("facebook-jssdk")) return;
                  var fbdiv = document.createElement("div");
                  fbdiv.id = "fb-root";
                  document.body.insertBefore(fbdiv, document.body.firstChild);
                  var js = document.createElement("script");
                  js.id = "facebook-jssdk";
                  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=1837721753181850";
                  document.body.insertBefore(js, document.body.firstChild);}());

                <div style="display: none;" aria-hidden="true" class="modal modal-va-middle fade" ##{popupSubmitId} role="dialog" tabindex="-1">
                  <div class="modal-dialog modal-xs">
                    <div class="modal-content">
                      <div class="modal-heading">
                        <p class="modal-title">
                          Submit your design
                      <div class="modal-inner">
                        <div ##{previewcontainer}>
                        <form ##{submitForm} method="post">
                          <input type="hidden" ##{sfGeometry} name="geometry">
                          <input type="hidden" ##{sfPreview} name="preview">
                          <div class="form-group form-group-label">
                            <label.floating-label for="#{textAreaDesc}">Share your ideas
                            <textarea.form-control.textarea-autosize form="#{submitForm}" id="#{textAreaDesc}" rows="1" name="description">
                      <div class="modal-footer">
                        <p class="text-right">
                          <a.btn.btn-flat.btn-brand-accent.waves-attach.waves-effect data-dismiss="modal">
                            Cancel
                          <a.btn.btn-flat.btn-brand-accent.waves-attach.waves-effect data-dismiss="modal" onclick="$('##{submitForm}').submit();">
                            Save


                $case mscpuid
                  $of Nothing
                  $of Just (pId, uId)
                    <div style="display: none;" aria-hidden="true" class="modal modal-va-middle fade" ##{popupShareId} role="dialog" tabindex="-1">
                      <div class="modal-dialog modal-xs">
                        <div class="modal-content">
                          <div class="modal-heading">
                            <p class="modal-title">
                              Share your design with others
                          <div class="modal-inner">
                            <p class="text">
                              You can share the following link that refers to the last saved version of your design:
                            <code>
                              @{SubmissionViewerR pId uId}
                            <p class="text">
                              Alternatively, use your favourite button:
                            <div style="text-align:center">
                              <a.shareButton onclick="FB.ui({method: 'share',mobile_iframe: true, href: '@{SubmissionViewerR pId uId}'}, function(response){});">
                                <img src="@{StaticR img_fbIcon_png}" style="width:40px;height:40px;" title="Share on Facebook" alt="Share on Facebook">
                              <a.shareButton href="http://vk.com/share.php?url=@{SubmissionViewerR pId uId}" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
                                <img src="@{StaticR img_vkIcon_png}" style="width:40px;height:40px;" title="Share on Vkontakte" alt="Share on Vkontakte">
                              <a.shareButton onclick="window.open('https://twitter.com/intent/tweet?url=' + encodeURIComponent('@{SubmissionViewerR pId uId}') + '&text=' + encodeURIComponent('Check out this design on #quakit!') + '&hashtags=mooc,edx,ethz,chairia,urbandesign', 'popUpWindow','height=400,width=600,left=10,top=10,,scrollbars=yes,menubar=no')">
                                <img src="@{StaticR img_twitterIcon_png}" style="width:40px;height:40px;" title="Tweet the link" alt="Tweet the link">
                              <a.shareButton href="https://plus.google.com/share?url=@{SubmissionViewerR pId uId}" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
                                <img src="@{StaticR img_gIcon_png}" style="width:40px;height:40px;" title="Share on Google" alt="Share on Google">
                          <div class="modal-footer">
                            <p class="text-right">
                              <a.btn.btn-flat.btn-brand-accent.waves-attach.waves-effect data-dismiss="modal">
                                Close
              |]
      uiButtonsG = do
        uiButton <- newIdent
        guiElement <- newIdent
        guiplaceholder <- newIdent
        idleplaceholder <- newIdent
        activeplaceholder <- newIdent
        btn <- newIdent

        serviceClear <- newIdent
        serviceRun <- newIdent
        submitbutton <- newIdent

        toWidgetHead
          [cassius|<commit_msg>Fixed small typos<commit_after>-----------------------------------------------------------------------------
-- |
-- Module      :  Handler.Home.UIButtons
-- Copyright   :  (c) <NAME>
-- License     :  MIT
--
-- Maintainer  :  <NAME> <<EMAIL>>
-- Stability   :  experimental
--
-----------------------------------------------------------------------------

module Handler.Home.UIButtons
  ( uiButtons
  ) where

import Import
import Text.Julius

-- | Rotating circular progress bar.
--   Exposes:
--     * #helpbutton
--     * #fullscreenbutton
--     * #submitbutton
--     * #toolboxbutton
--     * #clearbutton
--     * #evaluatebutton
uiButtons :: Maybe (ScenarioProblemId, UserId) -> Handler (Widget, Widget)
uiButtons mscpuid = do

  popupSubmitId <- newIdent
  popupShareId <- newIdent
  sfGeometry <- newIdent
  sfPreview <- newIdent
  submitForm <- newIdent
  previewcontainer <- newIdent

  textAreaDesc <- newIdent

  let popupSubmit = do
        toWidgetBody
              [hamlet|
                <script>
                  (function() {
                  if (document.getElementById("facebook-jssdk")) return;
                  var fbdiv = document.createElement("div");
                  fbdiv.id = "fb-root";
                  document.body.insertBefore(fbdiv, document.body.firstChild);
                  var js = document.createElement("script");
                  js.id = "facebook-jssdk";
                  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=1837721753181850";
                  document.body.insertBefore(js, document.body.firstChild);}());

                <div style="display: none;" aria-hidden="true" class="modal modal-va-middle fade" ##{popupSubmitId} role="dialog" tabindex="-1">
                  <div class="modal-dialog modal-xs">
                    <div class="modal-content">
                      <div class="modal-heading">
                        <p class="modal-title">
                          Submit your design
                      <div class="modal-inner">
                        <div ##{previewcontainer}>
                        <form ##{submitForm} method="post">
                          <input type="hidden" ##{sfGeometry} name="geometry">
                          <input type="hidden" ##{sfPreview} name="preview">
                          <div class="form-group form-group-label">
                            <label.floating-label for="#{textAreaDesc}">Share your ideas
                            <textarea.form-control.textarea-autosize form="#{submitForm}" id="#{textAreaDesc}" rows="1" name="description">
                      <div class="modal-footer">
                        <p class="text-right">
                          <a.btn.btn-flat.btn-brand-accent.waves-attach.waves-effect data-dismiss="modal">
                            Cancel
                          <a.btn.btn-flat.btn-brand-accent.waves-attach.waves-effect data-dismiss="modal" onclick="$('##{submitForm}').submit();">
                            Save


                $case mscpuid
                  $of Nothing
                  $of Just (pId, uId)
                    <div style="display: none;" aria-hidden="true" class="modal modal-va-middle fade" ##{popupShareId} role="dialog" tabindex="-1">
                      <div class="modal-dialog modal-xs">
                        <div class="modal-content">
                          <div class="modal-heading">
                            <p class="modal-title">
                              Share this design with others
                          <div class="modal-inner">
                            <p class="text">
                              You can share the following link that refers to the last saved version of this design:
                            <code>
                              @{SubmissionViewerR pId uId}
                            <p class="text">
                              Alternatively, use your favourite button:
                            <div style="text-align:center">
                              <a.shareButton onclick="FB.ui({method: 'share',mobile_iframe: true, href: '@{SubmissionViewerR pId uId}'}, function(response){});">
                                <img src="@{StaticR img_fbIcon_png}" style="width:40px;height:40px;" title="Share on Facebook" alt="Share on Facebook">
                              <a.shareButton href="http://vk.com/share.php?url=@{SubmissionViewerR pId uId}" onclick="javascript:window.open(this.href, 'popUpWindow', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=700,width=500,left=20,top=10');return false;">
                                <img src="@{StaticR img_vkIcon_png}" style="width:40px;height:40px;" title="Share on Vkontakte" alt="Share on Vkontakte">
                              <a.shareButton onclick="window.open('https://twitter.com/intent/tweet?url=' + encodeURIComponent('@{SubmissionViewerR pId uId}') + '&text=' + encodeURIComponent('Check out this design on #quakit!') + '&hashtags=mooc,edx,ethz,chairia,urbandesign', 'popUpWindow', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=700,width=500,left=20,top=10');return false;">
                                <img src="@{StaticR img_twitterIcon_png}" style="width:40px;height:40px;" title="Tweet the link" alt="Tweet the link">
                              <a.shareButton href="https://plus.google.com/share?url=@{SubmissionViewerR pId uId}" onclick="javascript:window.open(this.href, 'popUpWindow', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=700,width=500,left=20,top=10');return false;">
                                <img src="@{StaticR img_gIcon_png}" style="width:40px;height:40px;" title="Share on Google" alt="Share on Google">
                          <div class="modal-footer">
                            <p class="text-right">
                              <a.btn.btn-flat.btn-brand-accent.waves-attach.waves-effect data-dismiss="modal">
                                Close
              |]
      uiButtonsG = do
        uiButton <- newIdent
        guiElement <- newIdent
        guiplaceholder <- newIdent
        idleplaceholder <- newIdent
        activeplaceholder <- newIdent
        btn <- newIdent

        serviceClear <- newIdent
        serviceRun <- newIdent
        submitbutton <- newIdent

        toWidgetHead
          [cassius|
{'fraction_non_alphanumeric': 0.15001977066034006, 'fraction_numerical': 0.010122578094108343, 'mean_word_length': 1.6662449926207041, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 0, '>': 91, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7582188', 'n_tokens_mistral': 3495, 'n_tokens_neox': 3276, 'n_words': 631}