Ember initialize hooks

This commit is contained in:
2014-09-30 08:40:28 +02:00
parent 3b5651de47
commit 3d4aab4d67
3 changed files with 18 additions and 8 deletions
@@ -12,19 +12,16 @@
rootElement: '#ember-app-container'
obtain_token: (message)->
message ||= ''
# frame = $('<iframe></iframe>').addClass('obtain-token-frame').attr 'src', $obtain_token_url
# frame.css width: $('body').outerWidth(), height: $('body').outerHeight()
# $('body').append frame
# window.location = "#{$obtain_token_url}"
auth_win = window.open $obtain_token_url, "_blank", "location=no"
auth_win.addEventListener "loadstart", (event)->
if event.url.match 'close_window'
user_id = event.url.match(/user_id=([\w+-]+)/)[1]
auth_token = event.url.match(/auth_token=([\w-]+)/)[1]
auth_token = event.url.match(/authentication_token=([\w-]+)/)[1]
Qstorage.setItem 'user_id', user_id
Qstorage.setItem 'auth_token', token
Qstorage.setItem 'auth_token', auth_token
auth_win.close()
true
App.deferReadiness()
Ember.$.ajaxPrefilter (options) ->
if options.type.toUpperCase() == 'GET'
if auth_token = Qstorage.getItem('auth_token')
@@ -31,5 +31,8 @@ html lang="en"
var $platform = 'web'
var $log = function(params){console.log('App log:'); console.log(params);console.log('=======================================')};
= javascript_include_tag "user/flat/application"
- unless Rails.env.user_app?
javascript:
App.advanceReadiness()
body
#ember-app-container
+11 -1
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require 'active_support/all'
require 'uglifier'
require 'fileutils'
def replace_files(files, &block)
Array.wrap(files).each do |file|
@@ -29,7 +30,16 @@ def gsub_all_scripts(find, replace)
end
end
def remove(*files)
files = files.first if files.first.is_a? Array
files.each do |file|
FileUtils.rm_rf(File.join('public/assets', file))
end
end
remove 'user/app/application.js' # embedded in flat/application
gsub_file 'user/foundation/application.css', /url\(("?)\/assets/, 'url(\1../..'
gsub_all_scripts 'src="/assets', 'src="./assets'
compress_js 'user/flat/application.js', 'user/app/application.js'
compress_js 'user/flat/application.js'