File tree Expand file tree Collapse file tree
app/assets/javascripts/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .DS_Store
2+ public /v1
Original file line number Diff line number Diff line change 1+ ## Heroku 10 seconds setup
2+
3+ heroku create myapp
4+ heroku addons:add mongohq:sandbox
5+ git push heroku master
6+ heroku open
Original file line number Diff line number Diff line change 1+ namespace :assets do
2+ task :precompile do
3+ require 'fileutils'
4+ require './app'
5+
6+ FileUtils . mkdir_p ( settings . root + '/public/v1' )
7+ File . open ( settings . root + '/public/v1/abba.js' , 'w+' ) do |file |
8+ file . write settings . sprockets [ 'client/index' ] . to_s
9+ end
10+ end
11+ end
Original file line number Diff line number Diff line change 1717 } , settings . environment . to_s )
1818
1919 set :sprockets , Sprockets ::Environment . new
20- settings . sprockets . append_path ' app/assets/javascripts'
20+ settings . sprockets . append_path ( settings . root + '/ app/assets/javascripts')
2121end
2222
2323helpers do
Original file line number Diff line number Diff line change 11class @Abba
2- @endpoint : ' http://localhost:4050 '
2+ @endpoint : ' http://localhost:4567 '
33
44 constructor : (name , options = {}) ->
55 unless name
@@ -111,4 +111,17 @@ class @Abba
111111 key = decodeURIComponent (cookie .substr (0 , index))
112112 value = decodeURIComponent (cookie .substr (index + 1 ))
113113 return value if key is name
114- null
114+ null
115+
116+ do ->
117+ host = (url ) ->
118+ # IE6 only resolves resolves hrefs using innerHTML
119+ parent = document .createElement (' div' )
120+ parent .innerHTML = " <a href=\" #{ url} \" >x</a>"
121+ parser = parent .firstChild
122+ " #{ parser .host } "
123+
124+ # Find Abba's endpoint from the script tag
125+ scripts = document .getElementsByTagName (' script' )
126+ scripts = (script .src for script in scripts when / abba\. js$ / .test (script .src ))
127+ Abba .endpoint = " //#{ host (scripts[0 ])} " if scripts[0 ]
Original file line number Diff line number Diff line change 11< script src ="/v1/abba.js " type ="text/javascript " charset ="utf-8 "> </ script >
22
33< script type ="text/javascript " charset ="utf-8 ">
4- Abba ( 'alert test' ) . complete ( ) ;
5- </ script >
4+ Abba ( 'My Checkout' ) . complete ( ) ;
5+ </ script >
6+
7+ < h1 > Test complete!</ h1 >
Original file line number Diff line number Diff line change 11< script src ="/v1/abba.js " type ="text/javascript " charset ="utf-8 "> </ script >
2+ < script src ="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js "> </ script >
3+
4+ < div id ="tests ">
5+ < div id ="control "> < h1 > The control was chosen!</ h1 > </ div >
6+ < div id ="variant1 "> < h1 > 'Variant 1' was chosen!</ h1 > </ div >
7+ < div id ="variant2 "> < h1 > 'Variant 2' was chosen!</ h1 > </ div >
8+ </ div >
29
310< script type ="text/javascript " charset ="utf-8 ">
4- Abba ( 'alert test' )
11+ $ ( '#tests' ) . children ( ) . hide ( )
12+
13+ Abba ( 'My Checkout' )
514 . control ( function ( ) {
6- alert ( ' control') ;
15+ $ ( '# control') . show ( ) ;
716 } )
8- . a ( function ( ) {
9- alert ( 'a' ) ;
17+ . variant ( 'Variant 1' , function ( ) {
18+ $ ( '#variant1' ) . show ( ) ;
1019 } )
11- . b ( function ( ) {
12- alert ( 'b' ) ;
20+ . variant ( 'Variant 2' , function ( ) {
21+ $ ( '#variant2' ) . show ( ) ;
1322 } )
1423 . start ( ) ;
15- </ script >
24+ </ script >
25+
26+ < p >
27+ < a href ="complete.html "> Now complete the test.</ a >
28+ </ p >
You can’t perform that action at this time.
0 commit comments