[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/resources/src/mediawiki.api/ -> mediawiki.api.parse.js (source)

   1  /**
   2   * @class mw.Api.plugin.parse
   3   */
   4  ( function ( mw, $ ) {
   5  
   6      $.extend( mw.Api.prototype, {
   7          /**
   8           * Convenience method for 'action=parse'.
   9           *
  10           * @param {string} wikitext
  11           * @param {Function} [ok] Success callback (deprecated)
  12           * @param {Function} [err] Error callback (deprecated)
  13           * @return {jQuery.Promise}
  14           * @return {Function} return.done
  15           * @return {string} return.done.data Parsed HTML of `wikitext`.
  16           */
  17          parse: function ( wikitext, ok, err ) {
  18              var apiPromise = this.get( {
  19                  action: 'parse',
  20                  contentmodel: 'wikitext',
  21                  text: wikitext
  22              } );
  23  
  24              // Backwards compatibility (< MW 1.20)
  25              if ( ok || err ) {
  26                  mw.track( 'mw.deprecate', 'api.cbParam' );
  27                  mw.log.warn( 'Use of mediawiki.api callback params is deprecated. Use the Promise instead.' );
  28              }
  29  
  30              return apiPromise
  31                  .then( function ( data ) {
  32                      return data.parse.text['*'];
  33                  } )
  34                  .done( ok )
  35                  .fail( err )
  36                  .promise( { abort: apiPromise.abort } );
  37          }
  38      } );
  39  
  40      /**
  41       * @class mw.Api
  42       * @mixins mw.Api.plugin.parse
  43       */
  44  
  45  }( mediaWiki, jQuery ) );


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1