Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -147,15 +147,21 @@ |
148 | 148 | } |
149 | 149 | |
150 | 150 | if ( false ) { // count( $instructors ) == 1 |
151 | | - return $instList[0]; |
| 151 | + $html = $instList[0]; |
152 | 152 | } |
153 | 153 | else { |
154 | | - return '<ul id="ep-course-instructors"><li>' . implode( '</li><li>', $instList ) . '</li></ul>'; |
| 154 | + $html = '<ul><li>' . implode( '</li><li>', $instList ) . '</li></ul>'; |
155 | 155 | } |
156 | 156 | } |
157 | 157 | else { |
158 | | - return wfMsgHtml( 'ep-course-no-instructors' ); |
| 158 | + $html = wfMsgHtml( 'ep-course-no-instructors' ); |
159 | 159 | } |
| 160 | + |
| 161 | + return Html::rawElement( |
| 162 | + 'div', |
| 163 | + array( 'id' => 'ep-course-instructors' ), |
| 164 | + $html |
| 165 | + ); |
160 | 166 | } |
161 | 167 | |
162 | 168 | /** |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -377,6 +377,7 @@ |
378 | 378 | 'ep-instructor-add-cancel-button', |
379 | 379 | 'ep-instructor-summary-input', |
380 | 380 | 'ep-instructor-name-input', |
| 381 | + 'ep-course-no-instructors', |
381 | 382 | ), |
382 | 383 | ); |
383 | 384 | |
Index: trunk/extensions/EducationProgram/resources/ep.instructor.js |
— | — | @@ -37,7 +37,14 @@ |
38 | 38 | $remove.remove(); |
39 | 39 | $cancel.button( 'option', 'label', ep.msg( 'ep-instructor-close-button' ) ); |
40 | 40 | $cancel.focus(); |
41 | | - $this.closest( 'li' ).remove(); |
| 41 | + |
| 42 | + $li = $this.closest( 'li' ); |
| 43 | + $ul = $li.closest( 'ul' ); |
| 44 | + $li.remove(); |
| 45 | + |
| 46 | + if ( $ul.find( 'li' ).length < 1 ) { |
| 47 | + $ul.closest( 'div' ).text( mw.msg( 'ep-course-no-instructors' ) ); |
| 48 | + } |
42 | 49 | } ).fail( function() { |
43 | 50 | $remove.button( 'option', 'disabled', false ); |
44 | 51 | $remove.button( 'option', 'label', ep.msg( 'ep-instructor-remove-retry' ) ); |
— | — | @@ -101,14 +108,16 @@ |
102 | 109 | 'type': 'text', |
103 | 110 | 'size': 30, |
104 | 111 | 'maxlength': 250, |
105 | | - 'id': 'ep-instructor-nameinput' |
| 112 | + 'id': 'ep-instructor-nameinput', |
| 113 | + 'name': 'ep-instructor-nameinput' |
106 | 114 | } ); |
107 | 115 | |
108 | 116 | this.summaryInput = $( '<input>' ).attr( { |
109 | 117 | 'type': 'text', |
110 | 118 | 'size': 60, |
111 | 119 | 'maxlength': 250, |
112 | | - 'id': 'ep-instructor-summaryinput' |
| 120 | + 'id': 'ep-instructor-summaryinput', |
| 121 | + 'name': 'ep-instructor-summaryinput' |
113 | 122 | } ); |
114 | 123 | |
115 | 124 | this.getName = function() { |
— | — | @@ -138,7 +147,14 @@ |
139 | 148 | $cancel.focus(); |
140 | 149 | |
141 | 150 | // TODO: link name to user page and show control links |
142 | | - $( '#ep-course-instructors' ).append( $( '<li>' ).text( _this.getName() ) ) |
| 151 | + $ul = $( '#ep-course-instructors' ).find( 'ul' ); |
| 152 | + |
| 153 | + if ( $ul.length < 1 ) { |
| 154 | + $ul = $( '<ul>' ); |
| 155 | + $( '#ep-course-instructors' ).html( $ul ); |
| 156 | + } |
| 157 | + |
| 158 | + $ul.append( $( '<li>' ).text( _this.getName() ) ) |
143 | 159 | } ).fail( function() { |
144 | 160 | // TODO: implement nicer handling for fails caused by invalid user name |
145 | 161 | |