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

83 lines
2.0 KiB
CoffeeScript
Raw Normal View History

2014-11-10 09:19:04 -08:00
#= require jquery
#= require jquery_ujs
2014-11-11 09:16:09 -08:00
#= require jquery.turbolinks
2014-11-10 09:19:04 -08:00
#= require turbolinks
#= require bootstrap
2015-06-13 07:53:11 -07:00
#= require twemoji
#= require nprogress
#= require nprogress-turbolinks
#= 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
2015-01-03 07:54:10 -08:00
#= require sweet-alert
2015-06-08 07:49:47 -07:00
#= require js.cookie
#= require i18n
2015-06-08 07:50:59 -07:00
#= require i18n/translations
# local requires to be seen by everyone:
#= require_tree ./answerbox
#= require_tree ./questionbox
#= require groups
#= require inbox
#= require memes
#= require notifications
#= require pagination
#= require piwik
#= 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
# not required:
# _tree ./moderation
2014-11-10 09:19:04 -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) ->
args =
2015-06-08 07:49:47 -07: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 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"
_ready = ->
if typeof sweetAlertInitialize != "undefined"
sweetAlertInitialize()
if document.getElementById('particles')?
particleground document.getElementById('particles'),
dotColor: '#5e35b1'
lineColor: '#5e35b1'
2015-05-12 14:53:42 -07:00
2015-06-13 07:53:11 -07:00
if twemoji?
twemoji.parse document.body,
size: 16
callback: (icon, options) ->
switch icon
# copyright, registered, trademark
when 'a9' or 'ae' or '2122'
false
else
''.concat(options.base, options.size, '/', icon, options.ext)
$(document).ready _ready
$(document).on 'page:load', _ready