Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

ProgressEvent.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. // If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
  22. // Feature test: See if we can instantiate a native ProgressEvent;
  23. // if so, use that approach,
  24. // otherwise fill-in with our own implementation.
  25. //
  26. // NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
  27. var ProgressEvent = (function () {
  28. /*
  29. var createEvent = function(data) {
  30. var event = document.createEvent('Events');
  31. event.initEvent('ProgressEvent', false, false);
  32. if (data) {
  33. for (var i in data) {
  34. if (data.hasOwnProperty(i)) {
  35. event[i] = data[i];
  36. }
  37. }
  38. if (data.target) {
  39. // TODO: cannot call <some_custom_object>.dispatchEvent
  40. // need to first figure out how to implement EventTarget
  41. }
  42. }
  43. return event;
  44. };
  45. try {
  46. var ev = createEvent({type:"abort",target:document});
  47. return function ProgressEvent(type, data) {
  48. data.type = type;
  49. return createEvent(data);
  50. };
  51. } catch(e){
  52. */
  53. return function ProgressEvent (type, dict) {
  54. this.type = type;
  55. this.bubbles = false;
  56. this.cancelBubble = false;
  57. this.cancelable = false;
  58. this.lengthComputable = false;
  59. this.loaded = dict && dict.loaded ? dict.loaded : 0;
  60. this.total = dict && dict.total ? dict.total : 0;
  61. this.target = dict && dict.target ? dict.target : null;
  62. };
  63. // }
  64. })();
  65. module.exports = ProgressEvent;