Index: trunk/extensions/CreateAPage/js/CreateAPage.js |
— | — | @@ -1101,7 +1101,7 @@ |
1102 | 1102 | |
1103 | 1103 | for ( var i = 0; i < wgCreateAPageElementsForJavaScript.length; i++ ) { |
1104 | 1104 | jQuery( '#' + wgCreateAPageElementsForJavaScript[i] ).click( function( e ) { |
1105 | | - CreateAPage.switchTemplate( e, wgCreateAPageElementsForJavaScript[i] ); |
| 1105 | + CreateAPage.switchTemplate( e, wgCreateAPageElementsForJavaScript[i], this ); |
1106 | 1106 | }); |
1107 | 1107 | } |
1108 | 1108 | |
— | — | @@ -1119,10 +1119,12 @@ |
1120 | 1120 | * |
1121 | 1121 | * @param e Event |
1122 | 1122 | * @param elementId String: name of the createplate template (i.e. |
1123 | | - * cp-template-Name) |
| 1123 | + * cp-template-Name) -- actually doesn't seem to work, which is why we pass |
| 1124 | + * fullElement into this function and use it to get the ID instead |
| 1125 | + * @param fullElement |
1124 | 1126 | */ |
1125 | | - switchTemplate: function( e, elementId ) { |
1126 | | - CreateAPage.myId = elementId; |
| 1127 | + switchTemplate: function( e, elementId, fullElement ) { |
| 1128 | + CreateAPage.myId = fullElement.id; |
1127 | 1129 | e.preventDefault(); |
1128 | 1130 | |
1129 | 1131 | document.getElementById( 'cp-multiedit' ).innerHTML = |
— | — | @@ -1137,7 +1139,7 @@ |
1138 | 1140 | data: { |
1139 | 1141 | action: 'ajax', |
1140 | 1142 | rs: 'axMultiEditParse', |
1141 | | - template: elementId.replace( 'cp-template-', '' ) |
| 1143 | + template: fullElement.id.replace( 'cp-template-', '' ) |
1142 | 1144 | }, |
1143 | 1145 | success: function( data, textStatus, jqXHR ) { |
1144 | 1146 | document.getElementById( 'cp-multiedit' ).innerHTML = ''; |
— | — | @@ -1150,24 +1152,15 @@ |
1151 | 1153 | document.getElementById( 'cp-multiedit' ).innerHTML = res; |
1152 | 1154 | } |
1153 | 1155 | |
1154 | | - // @todo FIXME: need to add some code to remove the |
1155 | | - // 'templateFrameSelected' class from other templates except |
1156 | | - // the currently selected one |
1157 | | - // |
1158 | | - // I tried this above the addClass( 'templateFrameSelected' ) |
1159 | | - // stuff, but it didn't work (when you would select the 2nd |
1160 | | - // template, the class would be given to the 3rd template |
1161 | | - // instead...lol wut): |
1162 | | - // |
1163 | | - // jQuery( '.templateFrameSelected' ).each( function( index ) { |
1164 | | - // jQuery( this ).removeClass( 'templateFrameSelected' ); |
1165 | | - // }); |
1166 | 1156 | var elements = wgCreateAPageElementsForJavaScript; |
1167 | 1157 | for ( var i in elements ) { |
1168 | 1158 | jQuery( '#' + elements[i] ).addClass( 'templateFrame' ); |
| 1159 | + if ( jQuery( '#' + elements[i] ).hasClass( 'templateFrameSelected' ) ) { |
| 1160 | + jQuery( '#' + elements[i] ).removeClass( 'templateFrameSelected' ); |
| 1161 | + } |
1169 | 1162 | } |
1170 | 1163 | |
1171 | | - // ...and make the recently selected createplate active! |
| 1164 | + // Make the recently selected createplate active! |
1172 | 1165 | jQuery( '#' + CreateAPage.myId ).addClass( 'templateFrameSelected' ); |
1173 | 1166 | |
1174 | 1167 | var infoboxToggle = jQuery( '#cp-infobox-toggle' ); |