Apache-UploadMeter

 view release on metacpan or  search on metacpan

javascript.pod  view on Meta::CPAN


=back

=back

=head3 UploadMeter.Responders

In addition to adding handlers to individual UploadMeter objects, as described
above, you can also add global callbacks which will be called for *every* uploadmeter
on the page.  This might be useful, for example, for Web 2.0 applications that
allow for multiple asynchronous uploads in separate requests.  In such a case,
rather than registering identical handlers for each UploadMeter instance,
you can register a single function globally and it will be called for the appropriate
callback for all UploadMeter instances running on the page.

Callbacks that are registered this way will receive, as the first parameter,
the UploadMeter object of the instance which is currently calling into it.

=head3 Util

The Util namespace is not an object, but rather a namespace to group some helper

lib/Apache/UploadMeter/Resources/JavaScript.pm  view on Meta::CPAN

  onComplete: function() {
    Ajax.activeRequestCount--;
  }
});

Ajax.Base = function() {};
Ajax.Base.prototype = {
  setOptions: function(options) {
    this.options = {
      method:       'post',
      asynchronous: true,
      contentType:  'application/x-www-form-urlencoded',
      encoding:     'UTF-8',
      parameters:   ''
    }
    Object.extend(this.options, options || {});

    this.options.method = this.options.method.toLowerCase();
    if (typeof this.options.parameters == 'string')
      this.options.parameters = this.options.parameters.toQueryParams();
  }

lib/Apache/UploadMeter/Resources/JavaScript.pm  view on Meta::CPAN

    if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='

    // when GET, append parameters to URL
    if (this.method == 'get' && params)
      this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params;

    try {
      Ajax.Responders.dispatch('onCreate', this, this.transport);

      this.transport.open(this.method.toUpperCase(), this.url,
        this.options.asynchronous);

      if (this.options.asynchronous)
        setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10);

      this.transport.onreadystatechange = this.onStateChange.bind(this);
      this.setRequestHeaders();

      var body = this.method == 'post' ? (this.options.postBody || params) : null;

      this.transport.send(body);

      /* Force Firefox to handle ready state 4 for synchronous requests */
      if (!this.options.asynchronous && this.transport.overrideMimeType)
        this.onStateChange();

    }
    catch (e) {
      this.dispatchException(e);
    }
  },

  onStateChange: function() {
    var readyState = this.transport.readyState;



( run in 0.300 second using v1.01-cache-2.11-cpan-0d8aa00de5b )