Index: branches/concurrency/resources/jquery/jquery.concurrency.js |
— | — | @@ -0,0 +1,55 @@ |
| 2 | +/** |
| 3 | + * Base jQuery plugin for Concurrency |
| 4 | + * |
| 5 | + * @author Rob Moen |
| 6 | + * |
| 7 | + * Checkout Example: |
| 8 | + |
| 9 | + $.concurrency.check( { |
| 10 | + ccaction: 'checkout', |
| 11 | + resourcetype: 'application-specific-string', |
| 12 | + record: 123 |
| 13 | + }, function( result ){ |
| 14 | + if( result == 'failure' ) { |
| 15 | + //checkout failed because item is already checked out. do something useful here. |
| 16 | + } else if (result == 'success') { |
| 17 | + //successfully checked out item. do something useful here. |
| 18 | + } |
| 19 | + } ); |
| 20 | + */ |
| 21 | + |
| 22 | +(function ( $ ) { |
| 23 | + $.concurrency = { |
| 24 | + /* |
| 25 | + * Checkin our checkout an object via API |
| 26 | + * @param Object = { |
| 27 | + ccaction: (string) 'checkout' or 'checkin' |
| 28 | + resourcetype: (string) 'application-specific-string' |
| 29 | + record: (int) resource id |
| 30 | + callback: (function) handle results |
| 31 | + } |
| 32 | + */ |
| 33 | + check: function( params, callback ) { |
| 34 | + params = $.extend({ |
| 35 | + action: 'concurrency', |
| 36 | + token: mw.user.tokens.get( 'editToken' ), |
| 37 | + format: 'json' |
| 38 | + }, params); |
| 39 | + |
| 40 | + return $.ajax( { |
| 41 | + type: 'POST', |
| 42 | + url: mw.util.wikiScript( 'api' ), |
| 43 | + data: params, |
| 44 | + success: function( data ){ |
| 45 | + if ( typeof callback === 'function' ){ |
| 46 | + if ( data && data.concurrency.result ) { |
| 47 | + callback( data.concurrency.result ); |
| 48 | + } |
| 49 | + } |
| 50 | + }, |
| 51 | + dataType: 'json' |
| 52 | + } ); |
| 53 | + } |
| 54 | + }; |
| 55 | + |
| 56 | +})( jQuery ); |
\ No newline at end of file |
Property changes on: branches/concurrency/resources/jquery/jquery.concurrency.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 57 | + native |
Index: branches/concurrency/resources/Resources.php |
— | — | @@ -105,6 +105,10 @@ |
106 | 106 | 'jquery.collapsibleTabs' => array( |
107 | 107 | 'scripts' => 'resources/jquery/jquery.collapsibleTabs.js', |
108 | 108 | ), |
| 109 | + 'jquery.concurrency' => array( |
| 110 | + 'scripts' => 'resources/jquery/jquery.concurrency.js', |
| 111 | + 'dependencies' => array( 'mediawiki.util', 'mediawiki.user' ) |
| 112 | + ), |
109 | 113 | 'jquery.color' => array( |
110 | 114 | 'scripts' => 'resources/jquery/jquery.color.js', |
111 | 115 | 'dependencies' => 'jquery.colorUtil', |