retrospring/app/assets/javascripts/application.js.erb.coffee

89 lines
2.4 KiB
CoffeeScript
Raw Normal View History

2020-04-19 21:08:58 +02:00
#= require jquery3
2014-11-10 18:19:04 +01:00
#= require jquery_ujs
2014-11-11 18:16:09 +01:00
#= require jquery.turbolinks
2014-11-10 18:19:04 +01:00
#= require turbolinks
2020-04-19 21:08:58 +02:00
#= require popper
2014-11-10 18:19:04 +01:00
#= require bootstrap
#= require nprogress
#= require nprogress-turbolinks
#= require growl
2014-12-21 22:29:52 +01:00
#= require cheet
2014-12-29 15:47:10 +01:00
#= require jquery.guillotine
2015-05-12 23:53:42 +02:00
#= require jquery.particleground
2017-03-31 22:49:38 +02:00
#= require sweetalert
2015-06-08 16:49:47 +02:00
#= require js.cookie
#= require i18n
2017-04-02 09:07:59 +02:00
#= require_tree ./i18n
#= require tinycolor-min
#= require jquery.minicolors
# local requires to be seen by everyone:
#= require_tree ./answerbox
#= require_tree ./questionbox
#= require groups
#= require inbox
#= require memes
#= require notifications
#= require pagination
#= require question
#= require settings
#= require user
2015-04-22 04:59:10 +02:00
#= require report
2015-06-21 09:03:29 +02:00
#= require locale-box
#= require util
# not required:
# _tree ./moderation
2014-11-10 18:19:04 +01:00
NProgress.configure
showSpinner: false
2014-11-10 18:19:04 +01:00
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) ->
args =
2015-06-08 16:49:47 +02:00
title: translate((if success then 'frontend.success.title' else 'frontend.error.title'))
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"
_ready = ->
if typeof sweetAlertInitialize != "undefined"
sweetAlertInitialize()
if document.getElementById('particles')?
jumbo = $ '.j2-jumbo'
bodyColorOrig = jumbo.css 'background-color'
bodyColor = doppler 0.25, bodyColorOrig
console.log bodyColor, bodyColorOrig
particleground document.getElementById('particles'),
dotColor: bodyColor
lineColor: bodyColor
2015-09-20 15:16:24 +02:00
density: 23000
2015-05-12 23:53:42 +02:00
2020-04-19 23:27:50 +02:00
$(".alert-announcement").each ->
aId = $(this)[0].dataset.announcementId
unless (window.localStorage.getItem("announcement#{aId}"))
$(this).toggleClass("hidden")
$(document).on "click", ".alert-announcement button.close", (evt) ->
announcement = event.target.closest(".alert-announcement")
aId = announcement.dataset.announcementId
window.localStorage.setItem("announcement#{aId}", true)
2015-06-13 16:53:11 +02:00
$(document).ready _ready
$(document).on 'page:load', _ready