progressevent.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2011 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview A wrapper for the HTML5 File ProgressEvent objects.
  16. *
  17. */
  18. goog.provide('goog.fs.ProgressEvent');
  19. goog.require('goog.events.Event');
  20. /**
  21. * A wrapper for the progress events emitted by the File APIs.
  22. *
  23. * @param {!ProgressEvent} event The underlying event object.
  24. * @param {!Object} target The file access object emitting the event.
  25. * @extends {goog.events.Event}
  26. * @constructor
  27. * @final
  28. */
  29. goog.fs.ProgressEvent = function(event, target) {
  30. goog.fs.ProgressEvent.base(this, 'constructor', event.type, target);
  31. /**
  32. * The underlying event object.
  33. * @type {!ProgressEvent}
  34. * @private
  35. */
  36. this.event_ = event;
  37. };
  38. goog.inherits(goog.fs.ProgressEvent, goog.events.Event);
  39. /**
  40. * @return {boolean} Whether or not the total size of the of the file being
  41. * saved is known.
  42. */
  43. goog.fs.ProgressEvent.prototype.isLengthComputable = function() {
  44. return this.event_.lengthComputable;
  45. };
  46. /**
  47. * @return {number} The number of bytes saved so far.
  48. */
  49. goog.fs.ProgressEvent.prototype.getLoaded = function() {
  50. return this.event_.loaded;
  51. };
  52. /**
  53. * @return {number} The total number of bytes in the file being saved.
  54. */
  55. goog.fs.ProgressEvent.prototype.getTotal = function() {
  56. return this.event_.total;
  57. };