2020-12-24 18:33:49 -08:00
|
|
|
import 'core-js/stable'
|
|
|
|
import 'regenerator-runtime/runtime'
|
|
|
|
|
|
|
|
import './jquery'
|
2020-12-25 05:47:13 -08:00
|
|
|
import './bootstrap'
|
2020-12-24 18:33:49 -08:00
|
|
|
import {} from 'jquery-ujs'
|
|
|
|
import 'jquery.turbolinks/src/jquery.turbolinks'
|
|
|
|
import 'jquery.guillotine'
|
|
|
|
import 'particleground/jquery.particleground.min'
|
|
|
|
import 'jquery.growl'
|
|
|
|
import NProgress from 'nprogress'
|
|
|
|
import Cookies from 'js-cookie'
|
|
|
|
|
2020-12-25 06:07:47 -08:00
|
|
|
# this file is generated by Rails
|
|
|
|
import I18n from './i18n'
|
|
|
|
|
2020-12-24 18:33:49 -08:00
|
|
|
import './answerbox'
|
|
|
|
import './questionbox'
|
|
|
|
import './inbox'
|
|
|
|
import './memes'
|
|
|
|
import './notifications'
|
|
|
|
import './pagination'
|
|
|
|
import './question'
|
|
|
|
import './settings'
|
|
|
|
import './user'
|
|
|
|
import './report'
|
|
|
|
import './locale-box'
|
|
|
|
import './util'
|
|
|
|
|
2020-04-19 12:08:58 -07:00
|
|
|
#= require jquery3
|
2014-11-10 09:19:04 -08:00
|
|
|
#= require jquery_ujs
|
2014-11-11 09:16:09 -08:00
|
|
|
#= require jquery.turbolinks
|
2014-11-10 09:19:04 -08:00
|
|
|
#= require turbolinks
|
2020-04-19 12:08:58 -07:00
|
|
|
#= require popper
|
2014-11-10 09:19:04 -08:00
|
|
|
#= require bootstrap
|
2015-01-13 10:49:43 -08:00
|
|
|
#= require nprogress
|
|
|
|
#= require nprogress-turbolinks
|
2014-11-28 12:35:44 -08:00
|
|
|
#= require growl
|
2014-12-21 13:29:52 -08:00
|
|
|
#= require cheet
|
2014-12-29 06:47:10 -08:00
|
|
|
#= require jquery.guillotine
|
2015-05-12 14:53:42 -07:00
|
|
|
#= require jquery.particleground
|
2017-03-31 13:49:38 -07:00
|
|
|
#= require sweetalert
|
2015-06-08 07:49:47 -07:00
|
|
|
#= require js.cookie
|
2015-06-08 07:01:16 -07:00
|
|
|
#= require i18n
|
2017-04-02 00:07:59 -07:00
|
|
|
#= require_tree ./i18n
|
2015-07-29 08:08:07 -07:00
|
|
|
#= require tinycolor-min
|
2015-08-25 11:27:06 -07:00
|
|
|
#= require jquery.minicolors
|
2015-02-03 08:31:04 -08:00
|
|
|
# local requires to be seen by everyone:
|
|
|
|
#= require_tree ./answerbox
|
|
|
|
#= require_tree ./questionbox
|
2020-05-25 09:04:54 -07:00
|
|
|
#= require lists
|
2015-02-03 08:31:04 -08:00
|
|
|
#= require inbox
|
|
|
|
#= require memes
|
|
|
|
#= require notifications
|
|
|
|
#= require pagination
|
|
|
|
#= require question
|
|
|
|
#= require settings
|
|
|
|
#= require user
|
2015-04-21 19:59:10 -07:00
|
|
|
#= require report
|
2015-06-21 00:03:29 -07:00
|
|
|
#= require locale-box
|
2020-12-24 18:33:49 -08:00
|
|
|
|
2015-02-03 08:31:04 -08:00
|
|
|
# not required:
|
|
|
|
# _tree ./moderation
|
2014-11-10 09:19:04 -08:00
|
|
|
|
2015-01-13 10:49:43 -08:00
|
|
|
NProgress.configure
|
|
|
|
showSpinner: false
|
2014-11-10 09:19:04 -08:00
|
|
|
|
2015-06-08 07:49:47 -07: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 06:42:34 -08:00
|
|
|
window.showNotification = (text, success=true) ->
|
2014-11-28 12:35:44 -08:00
|
|
|
args =
|
2015-06-08 07:49:47 -07:00
|
|
|
title: translate((if success then 'frontend.success.title' else 'frontend.error.title'))
|
2014-11-28 12:35:44 -08:00
|
|
|
message: text
|
|
|
|
if success
|
|
|
|
$.growl.notice args
|
|
|
|
else
|
|
|
|
$.growl.error args
|
2014-11-11 09:02:59 -08:00
|
|
|
|
2015-06-08 07:49:47 -07: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 09:19:04 -08:00
|
|
|
$(document).on "click", "button#create-account", ->
|
|
|
|
Turbolinks.visit "/sign_up"
|
2015-01-03 10:43:51 -08:00
|
|
|
|
|
|
|
_ready = ->
|
2015-04-22 17:56:29 -07:00
|
|
|
if typeof sweetAlertInitialize != "undefined"
|
|
|
|
sweetAlertInitialize()
|
2015-01-03 10:43:51 -08:00
|
|
|
|
2015-05-26 22:41:38 -07:00
|
|
|
if document.getElementById('particles')?
|
2015-07-29 08:08:07 -07:00
|
|
|
jumbo = $ '.j2-jumbo'
|
|
|
|
bodyColorOrig = jumbo.css 'background-color'
|
|
|
|
bodyColor = doppler 0.25, bodyColorOrig
|
|
|
|
console.log bodyColor, bodyColorOrig
|
2015-05-26 22:41:38 -07:00
|
|
|
particleground document.getElementById('particles'),
|
2015-07-29 08:08:07 -07:00
|
|
|
dotColor: bodyColor
|
|
|
|
lineColor: bodyColor
|
2015-09-20 06:16:24 -07:00
|
|
|
density: 23000
|
2015-05-12 14:53:42 -07:00
|
|
|
|
2020-05-07 11:36:14 -07:00
|
|
|
$(".announcement").each ->
|
2020-04-19 14:27:50 -07:00
|
|
|
aId = $(this)[0].dataset.announcementId
|
|
|
|
unless (window.localStorage.getItem("announcement#{aId}"))
|
2020-05-07 11:36:14 -07:00
|
|
|
$(this).toggleClass("d-none")
|
2020-04-19 14:27:50 -07:00
|
|
|
|
2020-05-07 11:36:14 -07:00
|
|
|
$(document).on "click", ".announcement button.close", (evt) ->
|
|
|
|
announcement = event.target.closest(".announcement")
|
2020-04-19 14:27:50 -07:00
|
|
|
aId = announcement.dataset.announcementId
|
|
|
|
window.localStorage.setItem("announcement#{aId}", true)
|
|
|
|
|
2015-06-13 07:53:11 -07:00
|
|
|
|
2015-01-03 10:43:51 -08:00
|
|
|
$(document).ready _ready
|
2015-01-07 10:58:43 -08:00
|
|
|
$(document).on 'page:load', _ready
|