Index: trunk/extensions/RecordAdmin/recordadmin.js |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +window.raRecordForms = function () { |
| 3 | + for( i = 0; i < window.forms.length; i++ ) { |
| 4 | + var type = forms[i]; |
| 5 | + var form = document.getElementById( type + '-form' ); |
| 6 | + var tags = [ 'input', 'select', 'textarea' ]; |
| 7 | + for( j = 0; j < tags.length; j++ ) { |
| 8 | + var inputs = form.getElementsByTagName( tags[j] ); |
| 9 | + for( k = 0; k < inputs.length; k++ ) { |
| 10 | + var input = jQuery( inputs[k] ); |
| 11 | + if( input.attr('type') != 'checkbox' || input.attr('checked') ) { |
| 12 | + var multi = input.val(); |
| 13 | + if( typeof( multi ) == 'object' ) multi = multi.join('\\n'); |
| 14 | + var key = type + ':' + inputs[k].getAttribute('name'); |
| 15 | + var hidden = jQuery( document.createElement( 'input' ) ); |
| 16 | + hidden.attr( 'name', key ); |
| 17 | + hidden.attr( 'type', 'hidden' ); |
| 18 | + hidden.val( multi ); |
| 19 | + jQuery( '#editform' ).append( hidden ); |
| 20 | + } |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | +}; |
| 25 | + |
| 26 | +jQuery( '#editform' ).attr( 'onsubmit', 'raRecordForms()' ); |
Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php |
— | — | @@ -108,36 +108,20 @@ |
109 | 109 | $editPage->editFormTextTop = $tabset; |
110 | 110 | |
111 | 111 | # JS to add an onSubmit method that adds the record forms contents to hidden values in the edit form |
112 | | - $wgOut->addScript( "<script type='$wgJsMimeType'> |
113 | | - function raRecordForms() { |
114 | | - var forms = [ $jsFormsList ]; |
115 | | - for( i = 0; i < forms.length; i++ ) { |
116 | | - var type = forms[i]; |
117 | | - var form = document.getElementById( type + '-form' ); |
118 | | - var tags = [ 'input', 'select', 'textarea' ]; |
119 | | - for( j = 0; j < tags.length; j++ ) { |
120 | | - var inputs = form.getElementsByTagName( tags[j] ); |
121 | | - for( k = 0; k < inputs.length; k++ ) { |
122 | | - var input = jQuery( inputs[k] ); |
123 | | - if( input.attr('type') != 'checkbox' || input.attr('checked') ) { |
124 | | - var multi = input.val(); |
125 | | - if( typeof( multi ) == 'object' ) multi = multi.join('\\n'); |
126 | | - var key = type + ':' + inputs[k].getAttribute('name'); |
127 | | - var hidden = jQuery( document.createElement( 'input' ) ); |
128 | | - hidden.attr( 'name', key ); |
129 | | - hidden.attr( 'type', 'hidden' ); |
130 | | - hidden.val( multi ); |
131 | | - jQuery( '#editform' ).append( hidden ); |
132 | | - } |
133 | | - } |
134 | | - } |
| 112 | + if( is_callable( array( $wgOut, 'addModules' ) ) ) { |
| 113 | + $wgOut->addModules( 'ext.recordadmin' ); |
| 114 | + } else { |
| 115 | + global $wgRecordAdminExtPath; |
| 116 | + $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"$wgRecordAdminExtPath/recordadmin.js\"></script>" ); |
| 117 | + $wgOut->addScript( "<script type=\"$wgJsMimeType\"> |
| 118 | + function raAddRecordFormSubmit() { |
| 119 | + jQuery( '#editform' ).attr( 'onsubmit', 'raRecordForms()' ); |
135 | 120 | } |
136 | | - } |
137 | | - function raAddToSubmit() { |
138 | | - jQuery( '#editform' ).attr( 'onsubmit', 'raRecordForms()' ); |
139 | | - } |
140 | | - addOnloadHook( raAddToSubmit ); |
141 | | - </script>" ); |
| 121 | + addOnloadHook( raAddRecordFormSubmit );</script>" |
| 122 | + ); |
| 123 | + } |
| 124 | + $wgOut->addScript( "<script type=\"$wgJsMimeType\">var forms = [ $jsFormsList ];</script>" ); |
| 125 | + |
142 | 126 | } |
143 | 127 | |
144 | 128 | |
Index: trunk/extensions/RecordAdmin/RecordAdmin.php |
— | — | @@ -10,8 +10,10 @@ |
11 | 11 | * @author Siebrand Mazeland |
12 | 12 | * @licence GNU General Public Licence 2.0 or later |
13 | 13 | */ |
14 | | -define( 'RECORDADMIN_VERSION', '1.2.10, 2011-08-01' ); |
| 14 | +define( 'RECORDADMIN_VERSION', '1.3.0, 2011-08-03' ); |
15 | 15 | |
| 16 | +$wgRecordAdminExtPath = preg_replace( "|^.*(/extensions/.*$)|", "$wgScriptPath$1", dirname( __FILE__ ) ); |
| 17 | + |
16 | 18 | $dir = dirname( __FILE__ ) . '/'; |
17 | 19 | $wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'RecordAdmin.i18n.php'; |
18 | 20 | $wgExtensionAliasesFiles['RecordAdmin'] = $dir . 'RecordAdmin.alias.php'; |
— | — | @@ -35,7 +37,16 @@ |
36 | 38 | |
37 | 39 | $wgExtensionFunctions[] = 'wfSetupRecordAdmin'; |
38 | 40 | function wfSetupRecordAdmin() { |
39 | | - global $wgRecordAdmin; |
| 41 | + global $wgRecordAdmin, $wgResourceModules, $wgRecordAdminExtPath; |
| 42 | + |
| 43 | + $wgResourceModules['ext.recordadmin'] = array( |
| 44 | + 'scripts' => array( 'recordadmin.js' ), |
| 45 | + 'styles' => array(), |
| 46 | + 'dependencies' => array( 'jquery' ), |
| 47 | + 'localBasePath' => dirname( __FILE__ ), |
| 48 | + 'remoteExtPath' => $wgRecordAdminExtPath |
| 49 | + ); |
| 50 | + |
40 | 51 | $wgRecordAdmin = new RecordAdmin(); |
41 | 52 | } |
42 | 53 | |