Allow JS.Resource.load to work when the resource list is empty

Summary: Currently if you pass an empty resource array to the JX.Resource.load function it doesn't call the callback unless another resource is loaded after it. This diff adds a check to call the callback at the correct time.

Test Plan:
tested in console

before:

JX.Resource.load([], function() { console.log('called'); });
undefined
JX.Resource.load(['http://alpjor.com/test.css'], function() { console.log('called2'); });
undefined
called
called2

after:

JX.Resource.load([], function() { console.log('called'); });
undefined
called
JX.Resource.load(['http://alpjor.com/test.css'], function() { console.log('called2'); });
undefined
called2

Reviewers: cpojer, jeffmo

Reviewed By: cpojer

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D2291
Document extra parameters retrieved by arguments

Summary: Also crosslink `JX.DOM.hide` and `JX.DOM.show`.

Test Plan: /docs/class/JX.DOM.html#method_hide

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2349
Provide onStateChange event from JX.Request

Summary: Currently JX.Request only allows async responses to be processed when the request object has completed. There are a number of use cases for allowing processing to occur during a async response and not just after it, such as handling http chunked encoded response, showing request progress bars, detecting stalled requests, etc. This diff adds a 'statechange' event so that subclasses and consumers of JX.Request can bind to it here.

Test Plan:
in console:

var req = new JX.Request('/');
undefined
req.listen('statechange', function(req) { console.log(req.getTransport().readyState); });
Object
req.send();
1
undefined
2
3
4

Reviewers: epriestley, jeffmo

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2364
Add upload progress event to JX.Request, include request-type metadata in File uploads

Summary:
  - Adds an "uploadprogress" event to JX.Request so we can draw upload progress indicators.
  - When sending files, we currently encode "__ajax__=true" into POST data and then discard it. Instead, put it in GET data.
  - Move the file + data check to a slightly more logical place in the file.

Test Plan: Used JX.Request with code that draws upload indicators and depends on request type.

Reviewers: btrahan, vrana, jungejason

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T875

Differential Revision: https://secure.phabricator.com/D2384
[JX.Request] Add toggle for the expectation of a CSRF guard in the response

Summary:
I am working on a project that needs to send out an XHR to the FB platform API.

The FB API doesn't return responses that are pre-pended with a CSRF guard, so I need to be able to toggle the expectation of that on the request object.

Test Plan: Copied this change into the code that tries to execute this API request an saw things work with and without toggling .setExpectCSRFGuard().

Reviewers: epriestley, leebyron, al

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2573
Upgrade javelin to libphutil v2

Summary: Converted using `arc liberate --upgrade`.

Test Plan:
  diviner .

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2606
Depend on class autoloading

Test Plan:
  ./sync-to-facebook.php test

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D2613
Minor, the name of this property was not correct.
Rename Javelin PHP class to JavelinHelper

Summary:
We use the same name in Phabricator which explodes HPHP compiler because we have Javelin linked there to `externals/`.

I considered other solutions like renaming the Phabricator class, making a function from the only method `initBehavior()` but this seems that it will cause smallest troubles.

Test Plan: Played Tic Tac Tao until I won.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D2693
Optimizing JX.Keys with native Object.Keys if available
Merge pull request #17 from lifeinafolder/optimization

Optimizing JX.Keys with native Object.Keys if available
Add CORS support and non-JSON response support to JX.Request

Summary:
 CORS
- supports XHR w/ withCredentials and XDomainRequest as transport
- added a flag 'CORS' to toggle this

non-JSON response
- added a property responseType to allow 'JSON', 'TEXT' and 'XML' as the response type
- added a responseHandler property to handle response of non-JSON format

Test Plan:
1. rebuild packages;
2. go to sandbox page that loads javelin;
3. test request in chrome javascript console:

  window['call_result'] = '';
  var req = new JX.Request('http://bango.net/idxml/?bango=12345').setCORS(true).setMethod('GET').setExpectCSRFGuard(false).setResponseType('XML').setResponseHandler(function(resp){window.call_result = resp;});
  req.send();

4. verified the request was sucessful and the result is expected.

Reviewers: jeffmo, vrana, epriestley, aran, leebyron, erling

Reviewed By: epriestley

CC: Korvin

Differential Revision: https://secure.phabricator.com/D2697
Merge pull request #19 from yliang6/master

Add CORS support and non-JSON response support to JX.Request
Typeahead control stops responding after item tapped - Mobile Safari

Summary:
Mobile Safari has a strange bug. When the Typeahead control is rendered
within an iframe, once one of the typeahead items is tapped, the input
box stops accepting keypresses. (New characters, as well as keys like
backspace, are ignored). This also affects the Tokenizer control, in
that once one token is chosen, the user cannot type additional tokens.

This seems to be caused by calling e.prevent() within the Mousedown
event of the typeahead items, though it's unclear why. Removing that
line doesn't seem to cause any negative effects - the items lose focus
and are hidden as part of the mousedown.

I also included a fix for a 2nd bug that blocked testing this fix:
the placeholder code currently clears the typeahead contents when it
loses focus, which can result in the loss of user input.

Test Plan:
 1. View typeahead control, rendered within an iframe, on mobile safari.
 2. Begin typing, and tap one of the suggestions.

Reviewers: yungsters, jg, epriestley

Reviewed By: epriestley

CC: phunt, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2762
Improve error handling in javelin lib - Resource.js (fail to download)

Summary: See title

Test Plan:
1. Basic tests to verify onscuccess is executed correctly
2. Simulating download failures

Reviewers: jeffmo, epriestley

Reviewed By: epriestley

CC: aran, epriestley, cpojer

Differential Revision: https://secure.phabricator.com/D2960
Fix a typo (thanks @andreys!).
Updating to HTML5 for data-attributes.
Merge pull request #27 from tonycoco/patch-1

Updating to HTML5 for data-attributes.
Fix TypeaheadSource not considering excludeids

Summary:
Previously, TypeaheadSource doesn't consider the excludeids
that are updated after the datasource has been created. It should also
check for it every time the match results is called so that it supports adding/removing exclude ids on lookup time.

Test Plan:
Try to insert an exclude id via javascript after datasource
has been initialized. Type in the name, make sure the name is now not included in the typeahead

Reviewers: linjeffrey, jeffmo, epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D3108
Reload less aggressively in URI.go

Summary:
Firefox (and maybe also other browsers) does ignore-the-cache reload (Ctrl+F5) on `window.location.reload`.
Replace this by assignment to `window.location`.
We can't use `window.location = window.location` because it does nothing if there is a hash.

Test Plan: Flagged a revision, checked the files transfered.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3135