[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/datasource-xmlschema/ -> datasource-xmlschema.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('datasource-xmlschema', function (Y, NAME) {
   9  
  10  /**
  11   * Extends DataSource with schema-parsing on XML data.
  12   *
  13   * @module datasource
  14   * @submodule datasource-xmlschema
  15   */
  16  
  17  /**
  18   * Adds schema-parsing to the DataSource Utility.
  19   * @class DataSourceXMLSchema
  20   * @extends Plugin.Base
  21   */
  22  var DataSourceXMLSchema = function() {
  23      DataSourceXMLSchema.superclass.constructor.apply(this, arguments);
  24  };
  25  
  26  Y.mix(DataSourceXMLSchema, {
  27      /**
  28       * The namespace for the plugin. This will be the property on the host which
  29       * references the plugin instance.
  30       *
  31       * @property NS
  32       * @type String
  33       * @static
  34       * @final
  35       * @value "schema"
  36       */
  37      NS: "schema",
  38  
  39      /**
  40       * Class name.
  41       *
  42       * @property NAME
  43       * @type String
  44       * @static
  45       * @final
  46       * @value "dataSourceXMLSchema"
  47       */
  48      NAME: "dataSourceXMLSchema",
  49  
  50      /////////////////////////////////////////////////////////////////////////////
  51      //
  52      // DataSourceXMLSchema Attributes
  53      //
  54      /////////////////////////////////////////////////////////////////////////////
  55  
  56      ATTRS: {
  57          schema: {
  58              //value: {}
  59          }
  60      }
  61  });
  62  
  63  Y.extend(DataSourceXMLSchema, Y.Plugin.Base, {
  64      /**
  65      * Internal init() handler.
  66      *
  67      * @method initializer
  68      * @param config {Object} Config object.
  69      * @private
  70      */
  71      initializer: function(config) {
  72          this.doBefore("_defDataFn", this._beforeDefDataFn);
  73      },
  74  
  75      /**
  76       * Parses raw data into a normalized response.
  77       *
  78       * @method _beforeDefDataFn
  79       * @param tId {Number} Unique transaction ID.
  80       * @param request {Object} The request.
  81       * @param callback {Object} The callback object with the following properties:
  82       *     <dl>
  83       *         <dt>success (Function)</dt> <dd>Success handler.</dd>
  84       *         <dt>failure (Function)</dt> <dd>Failure handler.</dd>
  85       *     </dl>
  86       * @param data {Object} Raw data.
  87       * @protected
  88       */
  89      _beforeDefDataFn: function(e) {
  90          var schema = this.get('schema'),
  91              payload = e.details[0],
  92              // TODO: Do I need to sniff for DS.IO + responseXML.nodeType 9?
  93              data = Y.XML.parse(e.data.responseText) || e.data;
  94  
  95          payload.response = Y.DataSchema.XML.apply.call(this, schema, data) || {
  96              meta: {},
  97              results: data
  98          };
  99  
 100          this.get("host").fire("response", payload);
 101  
 102          return new Y.Do.Halt("DataSourceXMLSchema plugin halted _defDataFn");
 103      }
 104  });
 105  
 106  Y.namespace('Plugin').DataSourceXMLSchema = DataSourceXMLSchema;
 107  
 108  
 109  }, '3.17.2', {"requires": ["datasource-local", "plugin", "datatype-xml", "dataschema-xml"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1