1
+ /*global Handlebars */
2
+
1
3
Conductor . require ( '/vendor/jquery.js' ) ;
4
+ Conductor . require ( '/example/libs/handlebars-1.0.0-rc.3.js' ) ;
2
5
Conductor . requireCSS ( '/example/cards/tutorial/ad_card.css' ) ;
3
6
4
7
var RSVP = Conductor . Oasis . RSVP ;
5
- var destinationUrl = window . location . protocol + "//" + window . location . hostname + ":" + ( parseInt ( window . location . port , 10 ) + 2 ) ;
8
+ var crossOrigin = window . location . protocol + "//" + window . location . hostname + ":" + ( parseInt ( window . location . port , 10 ) + 2 ) ,
9
+ videoCardUrl = crossOrigin + '/example/cards/tutorial/youtube_card.html' ;
10
+ var videoSelectTemplate = '<div id="selectWrapper">Load Video: <select id="videoSelect">{{#each videoIds}}<option value="{{this}}">{{this}}</option>{{/each}}</select></div>' ;
6
11
7
12
var card = Conductor . card ( {
8
13
videoIds : [ '4d8ZDSyFS2g' , 'EquPUW83D-Q' ] ,
@@ -52,21 +57,23 @@ var card = Conductor.card({
52
57
} ,
53
58
54
59
childCards : [
55
- { url : destinationUrl + '/example/cards/tutorial/youtube_card.html' , id : '1' , options : { capabilities : [ 'video' ] } } ,
56
- { url : destinationUrl + '/example/cards/tutorial/survey_card.html' , id : '1' , options : { capabilities : [ 'survey' ] } }
60
+ { url : videoCardUrl , id : '1' , options : { capabilities : [ 'video' ] } } ,
61
+ { url : crossOrigin + '/example/cards/tutorial/survey_card.html' , id : '1' , options : { capabilities : [ 'survey' ] } }
57
62
] ,
58
63
59
64
loadDataForChildCards : function ( data ) {
60
65
var videoCardOptions = this . childCards [ 0 ] ,
61
66
surveyCardOptions = this . childCards [ 1 ] ;
62
67
63
- videoCardOptions . data = { videoId : data . videoId } ;
68
+ this . videoId = this . videoIds [ 0 ] ;
69
+ videoCardOptions . data = { videoId : this . videoId } ;
64
70
} ,
65
71
66
- activate : function ( data ) {
72
+ activate : function ( ) {
67
73
Conductor . Oasis . RSVP . EventTarget . mixin ( this ) ;
74
+ this . consumers . height . autoUpdate = false ;
68
75
69
- this . videoId = data . videoId ;
76
+ videoSelectTemplate = Handlebars . compile ( videoSelectTemplate ) ;
70
77
this . videoCard = this . childCards [ 0 ] . card ;
71
78
this . surveyCard = this . childCards [ 1 ] . card ;
72
79
} ,
@@ -107,8 +114,25 @@ var card = Conductor.card({
107
114
} ,
108
115
109
116
initializeDOM : function ( ) {
110
- this . videoCard . appendTo ( document . body ) ;
111
- this . surveyCard . appendTo ( document . body ) ;
117
+ var card = this ;
118
+
119
+ $ ( videoSelectTemplate ( this ) ) . appendTo ( 'body' ) ;
120
+ $ ( '#videoSelect' ) . change ( function ( ) {
121
+ card . changeVideo ( $ ( this ) . val ( ) ) ;
122
+ } ) ;
123
+
124
+ this . selectWrapperDiv = $ ( '#selectWrapper' ) ;
125
+ this . cardWrapperDiv = $ ( '<div id="cardWrapper"></div>' ) ;
126
+ this . cardWrapperDiv . appendTo ( 'body' ) ;
127
+ this . videoCard . appendTo ( this . cardWrapperDiv [ 0 ] ) ;
128
+ this . surveyCard . appendTo ( this . cardWrapperDiv [ 0 ] ) ;
129
+ } ,
130
+
131
+ changeVideo : function ( videoId ) {
132
+ this . videoId = videoId ;
133
+ console . log ( 'Change the video to ' + videoId ) ;
134
+ this . conductor . loadData ( videoCardUrl , '1' , { videoId : this . videoId } ) ;
135
+ this . render ( 'video' ) ;
112
136
} ,
113
137
114
138
getDimensions : function ( ) {
@@ -125,5 +149,7 @@ var card = Conductor.card({
125
149
width : window . innerWidth
126
150
} ;
127
151
}
152
+
153
+ this . cardWrapperDiv . height ( this . _dimensions . height - this . selectWrapperDiv . height ( ) ) ;
128
154
}
129
155
} ) ;
0 commit comments