Show More
@@ -122,8 +122,31 b'' | |||||
122 |
|
122 | |||
123 | var other_repos_info = ${c.other_repos_info|n}; |
|
123 | var other_repos_info = ${c.other_repos_info|n}; | |
124 |
|
124 | |||
|
125 | var otherrepoChanged = function(){ | |||
|
126 | var sel_box = YUQ('#pull_request_form #other_repo')[0]; | |||
|
127 | var repo_name = sel_box.options[sel_box.selectedIndex].value; | |||
|
128 | ||||
|
129 | YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description']; | |||
|
130 | // replace options of other_ref with the ones for the current other_repo | |||
|
131 | var other_ref_selector = YUD.get('other_ref'); | |||
|
132 | var new_select = YUD.createElementFromMarkup(other_repos_info[repo_name]['revs']); | |||
|
133 | var new_selectedIndex = new_select.selectedIndex; | |||
|
134 | other_ref_selector.innerHTML = ""; // clear old options | |||
|
135 | while (new_select.length > 0){ // children will be popped when appened to other_ref_selector | |||
|
136 | other_ref_selector.appendChild(new_select.children[0]); | |||
|
137 | } | |||
|
138 | // browsers lost track of selected when appendChild was used | |||
|
139 | other_ref_selector.selectedIndex = new_selectedIndex; | |||
|
140 | ||||
|
141 | // reset && add the reviewer based on selected repo | |||
|
142 | var _data = other_repos_info[repo_name]; | |||
|
143 | YUD.get('review_members').innerHTML = ''; | |||
|
144 | addReviewMember(_data.user.user_id, _data.user.firstname, | |||
|
145 | _data.user.lastname, _data.user.username, | |||
|
146 | _data.user.gravatar_link); | |||
|
147 | } | |||
|
148 | ||||
125 | var loadPreview = function(){ |
|
149 | var loadPreview = function(){ | |
126 | YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none'); |
|
|||
127 | //url template |
|
150 | //url template | |
128 | var url = "${h.url('compare_url', |
|
151 | var url = "${h.url('compare_url', | |
129 | repo_name='__other_repo__', |
|
152 | repo_name='__other_repo__', | |
@@ -160,28 +183,6 b'' | |||||
160 |
|
183 | |||
161 | YUD.get('pull_request_overview_url').href = url; // shouldn't have as_form ... but ... |
|
184 | YUD.get('pull_request_overview_url').href = url; // shouldn't have as_form ... but ... | |
162 | YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display',''); |
|
185 | YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display',''); | |
163 |
|
||||
164 | var sel_box = YUQ('#pull_request_form #other_repo')[0]; |
|
|||
165 | var repo_name = sel_box.options[sel_box.selectedIndex].value; |
|
|||
166 |
|
||||
167 | YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description']; |
|
|||
168 | // replace options of other_ref with the ones for the current other_repo |
|
|||
169 | var other_ref_selector = YUD.get('other_ref'); |
|
|||
170 | var new_select = YUD.createElementFromMarkup(other_repos_info[repo_name]['revs']); |
|
|||
171 | var new_selectedIndex = new_select.selectedIndex; |
|
|||
172 | other_ref_selector.innerHTML = ""; // clear old options |
|
|||
173 | while (new_select.length > 0){ // children will be popped when appened to other_ref_selector |
|
|||
174 | other_ref_selector.appendChild(new_select.children[0]); |
|
|||
175 | } |
|
|||
176 | // browsers lost track of selected when appendChild was used |
|
|||
177 | other_ref_selector.selectedIndex = new_selectedIndex; |
|
|||
178 |
|
||||
179 | // reset && add the reviewer based on selected repo |
|
|||
180 | var _data = other_repos_info[repo_name]; |
|
|||
181 | YUD.get('review_members').innerHTML = ''; |
|
|||
182 | addReviewMember(_data.user.user_id, _data.user.firstname, |
|
|||
183 | _data.user.lastname, _data.user.username, |
|
|||
184 | _data.user.gravatar_link); |
|
|||
185 | } |
|
186 | } | |
186 |
|
187 | |||
187 | ## refresh automatically when something changes (org_repo can't change) |
|
188 | ## refresh automatically when something changes (org_repo can't change) | |
@@ -191,7 +192,7 b'' | |||||
191 | }); |
|
192 | }); | |
192 |
|
193 | |||
193 | YUE.on('other_repo', 'change', function(e){ |
|
194 | YUE.on('other_repo', 'change', function(e){ | |
194 | var repo_name = e.currentTarget.value; |
|
195 | otherrepoChanged(); | |
195 | loadPreview(); |
|
196 | loadPreview(); | |
196 | }); |
|
197 | }); | |
197 |
|
198 | |||
@@ -199,8 +200,9 b'' | |||||
199 | loadPreview(); |
|
200 | loadPreview(); | |
200 | }); |
|
201 | }); | |
201 |
|
202 | |||
|
203 | otherrepoChanged(); | |||
202 | //lazy load overview after 0.5s |
|
204 | //lazy load overview after 0.5s | |
203 | setTimeout(loadPreview, 500) |
|
205 | setTimeout(loadPreview, 500); | |
204 |
|
206 | |||
205 | </script> |
|
207 | </script> | |
206 |
|
208 |
General Comments 0
You need to be logged in to leave comments.
Login now