Dashboard sipadu mbip
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

datasource-xmlschema-debug.js 2.7KB

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