Mercurial > kallithea
comparison rhodecode/templates/pullrequests/pullrequest.html @ 3512:ff3f10a6a203 beta
pullrequest: just replace children of other_ref when other_repo changes
We were inserting a full select statement as innerHTML of a select and would
thus get nested select statements. IE did not render that correctly ... and
other browsers did strange things.
Instead we now create a in memory DOM object and move the optgroups. After
appending children to the selector we have to set selectedIndex on all
browsers.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 07 Mar 2013 19:00:28 +0100 |
parents | 2053053e0882 |
children | a2a61978752f |
comparison
equal
deleted
inserted
replaced
3511:e1568c0bac1f | 3512:ff3f10a6a203 |
---|---|
159 YUD.get('pull_request_overview_url').href = url; // shouldn't have as_form ... but ... | 159 YUD.get('pull_request_overview_url').href = url; // shouldn't have as_form ... but ... |
160 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display',''); | 160 YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display',''); |
161 ypjax(url,'pull_request_overview', function(data){ | 161 ypjax(url,'pull_request_overview', function(data){ |
162 var sel_box = YUQ('#pull_request_form #other_repo')[0]; | 162 var sel_box = YUQ('#pull_request_form #other_repo')[0]; |
163 var repo_name = sel_box.options[sel_box.selectedIndex].value; | 163 var repo_name = sel_box.options[sel_box.selectedIndex].value; |
164 YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description']; | |
165 // replace options of other_ref with the ones for the current other_repo | |
166 var other_ref_selector = YUD.get('other_ref'); | |
167 var new_select = YUD.createElementFromMarkup(other_repos_info[repo_name]['revs']); | |
168 var new_selectedIndex = new_select.selectedIndex; | |
169 other_ref_selector.innerHTML = ""; // clear old options | |
170 while (new_select.length > 0){ // children will be popped when appened to other_ref_selector | |
171 other_ref_selector.appendChild(new_select.children[0]); | |
172 } | |
173 // browsers lost track of selected when appendChild was used | |
174 other_ref_selector.selectedIndex = new_selectedIndex; | |
175 // reset && add the reviewer based on selected repo | |
164 var _data = other_repos_info[repo_name]; | 176 var _data = other_repos_info[repo_name]; |
165 YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description']; | |
166 YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs']; | |
167 // select back the revision that was just compared | |
168 setSelectValue(YUD.get('other_ref'), rev_data['other_ref']); | |
169 // reset && add the reviewer based on selected repo | |
170 YUD.get('review_members').innerHTML = ''; | 177 YUD.get('review_members').innerHTML = ''; |
171 addReviewMember(_data.user.user_id, _data.user.firstname, | 178 addReviewMember(_data.user.user_id, _data.user.firstname, |
172 _data.user.lastname, _data.user.username, | 179 _data.user.lastname, _data.user.username, |
173 _data.user.gravatar_link); | 180 _data.user.gravatar_link); |
174 }) | 181 }) |
180 loadPreview(); | 187 loadPreview(); |
181 }); | 188 }); |
182 | 189 |
183 YUE.on('other_repo', 'change', function(e){ | 190 YUE.on('other_repo', 'change', function(e){ |
184 var repo_name = e.currentTarget.value; | 191 var repo_name = e.currentTarget.value; |
185 // replace the <select> of changed repo | |
186 YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs']; | |
187 loadPreview(); | 192 loadPreview(); |
188 }); | 193 }); |
189 | 194 |
190 YUE.on('other_ref', 'change', function(e){ | 195 YUE.on('other_ref', 'change', function(e){ |
191 loadPreview(); | 196 loadPreview(); |