2020-12-25 03:33:49 +01:00
|
|
|
import 'core-js/stable'
|
|
|
|
import 'regenerator-runtime/runtime'
|
|
|
|
|
2020-12-25 21:53:14 +01:00
|
|
|
import '../legacy/jquery'
|
2020-12-25 03:33:49 +01:00
|
|
|
import {} from 'jquery-ujs'
|
2021-02-26 22:41:46 +01:00
|
|
|
import 'popper.js'
|
|
|
|
import 'bootstrap'
|
2020-12-25 03:33:49 +01:00
|
|
|
import 'jquery.guillotine'
|
|
|
|
import 'particleground/jquery.particleground.min'
|
|
|
|
import 'jquery.growl'
|
2021-02-27 21:43:43 +01:00
|
|
|
import 'jquery-minicolors'
|
2020-12-25 15:50:34 +01:00
|
|
|
import 'sweetalert'
|
2020-12-25 03:33:49 +01:00
|
|
|
import Cookies from 'js-cookie'
|
2020-12-25 15:35:29 +01:00
|
|
|
import moment from 'moment'
|
2020-12-25 03:33:49 +01:00
|
|
|
|
2020-12-25 16:22:44 +01:00
|
|
|
require('nprogress/nprogress.css')
|
|
|
|
require('jquery.growl/stylesheets/jquery.growl.css')
|
|
|
|
require('jquery.guillotine/css/jquery.guillotine.css')
|
|
|
|
require('sweetalert/dist/sweetalert.css')
|
2021-02-27 21:43:43 +01:00
|
|
|
require('jquery-minicolors/jquery.minicolors.css')
|
2020-12-25 16:22:44 +01:00
|
|
|
|
2020-12-25 15:07:47 +01:00
|
|
|
# this file is generated by Rails
|
2020-12-25 21:53:14 +01:00
|
|
|
import I18n from '../legacy/i18n'
|
|
|
|
|
|
|
|
import '../legacy/answerbox'
|
|
|
|
import '../legacy/questionbox'
|
|
|
|
import '../legacy/inbox'
|
|
|
|
import '../legacy/memes'
|
|
|
|
import '../legacy/notifications'
|
|
|
|
import '../legacy/pagination'
|
|
|
|
import '../legacy/question'
|
|
|
|
import '../legacy/settings'
|
|
|
|
import '../legacy/report'
|
|
|
|
import '../legacy/locale-box'
|
|
|
|
import '../legacy/util'
|
2020-12-25 03:33:49 +01:00
|
|
|
|
2020-12-25 15:35:29 +01:00
|
|
|
window.moment = moment
|
|
|
|
|
2015-06-08 16:49:47 +02:00
|
|
|
window.translate = (scope, options) ->
|
|
|
|
# for some reason I18n errors when calling it by assign proxy, so we got to wrap it
|
|
|
|
I18n.translate(scope, options)
|
|
|
|
|
2014-12-08 15:42:34 +01:00
|
|
|
window.showNotification = (text, success=true) ->
|
2014-11-28 21:35:44 +01:00
|
|
|
args =
|
2015-06-08 16:49:47 +02:00
|
|
|
title: translate((if success then 'frontend.success.title' else 'frontend.error.title'))
|
2014-11-28 21:35:44 +01:00
|
|
|
message: text
|
|
|
|
if success
|
|
|
|
$.growl.notice args
|
|
|
|
else
|
|
|
|
$.growl.error args
|
2014-11-11 18:02:59 +01:00
|
|
|
|
2015-06-08 16:49:47 +02:00
|
|
|
I18n.defaultLocale = 'en';
|
|
|
|
I18n.locale = Cookies.get('hl') || 'en';
|
|
|
|
|
|
|
|
window.showNotificationXHRError = (jqxhr, status, error) ->
|
|
|
|
console.log jqxhr, status, error
|
|
|
|
showNotification translate('frontend.error.message'), false
|
|
|
|
|
2014-11-10 18:19:04 +01:00
|
|
|
$(document).on "click", "button#create-account", ->
|
|
|
|
Turbolinks.visit "/sign_up"
|
2015-01-03 19:43:51 +01:00
|
|
|
|
|
|
|
_ready = ->
|
2015-04-23 02:56:29 +02:00
|
|
|
if typeof sweetAlertInitialize != "undefined"
|
|
|
|
sweetAlertInitialize()
|
2015-01-03 19:43:51 +01:00
|
|
|
|
2015-05-27 07:41:38 +02:00
|
|
|
if document.getElementById('particles')?
|
2015-07-29 17:08:07 +02:00
|
|
|
jumbo = $ '.j2-jumbo'
|
|
|
|
bodyColorOrig = jumbo.css 'background-color'
|
|
|
|
bodyColor = doppler 0.25, bodyColorOrig
|
|
|
|
console.log bodyColor, bodyColorOrig
|
2015-05-27 07:41:38 +02:00
|
|
|
particleground document.getElementById('particles'),
|
2015-07-29 17:08:07 +02:00
|
|
|
dotColor: bodyColor
|
|
|
|
lineColor: bodyColor
|
2015-09-20 15:16:24 +02:00
|
|
|
density: 23000
|
2015-05-12 23:53:42 +02:00
|
|
|
|
2020-05-07 20:36:14 +02:00
|
|
|
$(".announcement").each ->
|
2020-04-19 23:27:50 +02:00
|
|
|
aId = $(this)[0].dataset.announcementId
|
|
|
|
unless (window.localStorage.getItem("announcement#{aId}"))
|
2020-05-07 20:36:14 +02:00
|
|
|
$(this).toggleClass("d-none")
|
2020-04-19 23:27:50 +02:00
|
|
|
|
2020-05-07 20:36:14 +02:00
|
|
|
$(document).on "click", ".announcement button.close", (evt) ->
|
|
|
|
announcement = event.target.closest(".announcement")
|
2020-04-19 23:27:50 +02:00
|
|
|
aId = announcement.dataset.announcementId
|
|
|
|
window.localStorage.setItem("announcement#{aId}", true)
|
|
|
|
|
2015-06-13 16:53:11 +02:00
|
|
|
|
2015-01-03 19:43:51 +01:00
|
|
|
$(document).ready _ready
|
2021-02-26 22:41:46 +01:00
|
|
|
$(document).on 'turbolinks:load', _ready
|
|
|
|
|
|
|
|
$(document).on 'turbolinks:render', ->
|
2021-02-26 22:50:49 +01:00
|
|
|
$('.dropdown-toggle').dropdown()
|
|
|
|
$('[data-toggle="tooltip"]').tooltip()
|