Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: phacility/javelin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fb9944cff2e2398ace77d2556f8b65edf88ebd58
Choose a base ref
...
head repository: phacility/javelin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 748eac2b2fb3f210dc68506d2bc36f96a6b0d77f
Choose a head ref
  • 9 commits
  • 9 files changed
  • 7 contributors

Commits on Mar 13, 2012

  1. Throw when calling getData() before data has been provided by mergeDa…

    …ta()
    
    Summary: See https://www.facebook.com/groups/104578302983740/210002262441343/
    
    Test Plan: N/A
    
    Reviewers: hedger, tomo, mroch
    
    Reviewed By: hedger
    
    CC: aran, epriestley
    
    Differential Revision: https://secure.phabricator.com/D1879
    epriestley committed Mar 13, 2012
    Copy the full SHA
    e19e107 View commit details

Commits on Mar 26, 2012

  1. Fix bug in tic-tac-toe example

    Summary: JX.JSON.serialize got renamed to JX.JSON.stringify
    
    Test Plan: Played tic-tac-toe
    
    Reviewers: epriestley
    
    Reviewed By: epriestley
    
    CC: aran, epriestley
    
    Differential Revision: https://secure.phabricator.com/D2014
    Nick Harper committed Mar 26, 2012
    Copy the full SHA
    ee83d95 View commit details
  2. [javelinsymbols] -- Add support to javelinsymbols for JX.behavior()

    Summary:
    Currently javelinsymbols can detect the installation of a class...but not behaviors. This adds support to the javelinsymbols processor to identify behavior-registrations and specify them using a new '*' directive.
    
    I plan to use javelinsymbols for a project to implicitly identify a unique name for a given JS resource based on the JX.install()s and JX.behavior()s calls that exist in the file.
    
    Test Plan: Compiled and ran javlinesymbols against a file with a JX.install(), a file with JX.behavior(), and a file with both to verify the output was as expected.
    
    Reviewers: leebyron, epriestley, jg
    
    Reviewed By: epriestley
    
    CC: aran, epriestley
    
    Differential Revision: https://secure.phabricator.com/D2023
    jeffmo committed Mar 26, 2012
    Copy the full SHA
    469619c View commit details
  3. Merge pull request #15 from jeffmo/javelinsymbols_behavior_support

    [javelinsymbols] -- Add support to javelinsymbols for JX.behavior()
    Evan Priestley committed Mar 26, 2012
    Copy the full SHA
    005ca26 View commit details

Commits on Mar 29, 2012

  1. include input elements w/ type="tel" or "number" when encoding form v…

    …alue
    
    Summary: Right now JX.DOM.convertFormToDictionary will skip over input
    elements with type="tel" (or type="number"), which are valid values for
    that attribute according to http://dev.w3.org/html5/markup/input.number.html
    and http://dev.w3.org/html5/markup/input.tel.html.
    
    This makes convertFormToListOfPairs include those input elements.
    
    Test Plan: used in subsequent change which uses input type="tel" in
    conjunction with JX.DOM.convertFormToDictionary.
    bhiller committed Mar 29, 2012
    Copy the full SHA
    04a9742 View commit details
  2. Merge pull request #16 from benhiller/master

    include input elements w/ type="tel" or "number" when encoding form value
    Evan Priestley committed Mar 29, 2012
    Copy the full SHA
    36c4de4 View commit details

Commits on Apr 2, 2012

  1. Typeahead: separate the name field from the field we complete on

    Summary:
    Let typeahead datasources provide an optional field: tokenizable.  If present,
    the typeahead tokenizes and completes on this field instead of name, but still
    uses the name when inputting data into the <input>.
    
    For example, I can have an input for Phabricator commit identifiers, and build
    typeahead from (commit-identifier, commit-message-summary-line) pairs.  The
    'display' field formats both prettily, the 'name' is the commit-identifier, and
    the 'tokenizable' contains both commit-identifier and commit-message
    concatenated.  The typeahead lets me search both, but the resulting value in
    the <input> is just the commit-identifier.
    
    Test Plan:
    Made an example as described above which queries all my commits to a
    repo from the past week.
    
    Reviewers: epriestley
    
    Reviewed By: epriestley
    
    CC: aran
    
    Differential Revision: https://secure.phabricator.com/D2070
    Edward Speyer committed Apr 2, 2012
    Copy the full SHA
    85e9369 View commit details

Commits on Apr 12, 2012

  1. Fix filenames of sync-facebook

    Summary: Does this belong to Javelin repository at all?
    
    Test Plan: Read.
    
    Reviewers: epriestley
    
    Reviewed By: epriestley
    
    CC: aran
    
    Differential Revision: https://secure.phabricator.com/D2212
    vrana committed Apr 12, 2012
    Copy the full SHA
    851995a View commit details

Commits on Apr 17, 2012

  1. Support IE8

    Summary: [[ https://secure.phabricator.com/D714#inline-1387 | D714#inline-1387 ]]
    
    Test Plan: Open Phabricator in IE8.
    
    Reviewers: tomo, epriestley
    
    Reviewed By: epriestley
    
    CC: aran, epriestley
    
    Differential Revision: https://secure.phabricator.com/D2250
    vrana committed Apr 17, 2012
    Copy the full SHA
    748eac2 View commit details
2 changes: 1 addition & 1 deletion example/php-tictactoe/tic-tac-toe.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ JX.behavior('tic-tac-toe', function() {
changeState(board, 'play');
}
})
.setData({game: JX.JSON.serialize(game)})
.setData({game: JX.JSON.stringify(game)})
.send();
});

2 changes: 1 addition & 1 deletion scripts/sync-to-facebook.php
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
require_once 'sync-spec.php';

if ($argc != 2) {
echo "usage: sync-to-facebook <php_root>\n";
echo "usage: sync-to-facebook.php <php_root>\n";
exit(1);
}

6 changes: 6 additions & 0 deletions src/core/Stratcom.js
Original file line number Diff line number Diff line change
@@ -582,6 +582,12 @@ JX.install('Stratcom', {
var index = meta_id[1];
if (block && (index in block)) {
return block[index];
} else if (__DEV__) {
JX.$E(
'JX.Stratcom.getData(<node>): Tried to access data (block ' +
meta_id[0] + ', index ' + index + ') that was not present. This ' +
'probably means you are calling getData() before the block ' +
'is provided by mergeData().');
}
}

17 changes: 17 additions & 0 deletions src/core/__tests__/stratcom.js
Original file line number Diff line number Diff line change
@@ -149,6 +149,23 @@ describe('Stratcom Tests', function() {
});
});

it('should throw when accessing data in an unloaded block', function() {
ensure__DEV__(true, function() {

var n = JX.$N('div');
n.setAttribute('data-meta', '9999999_9999999');

var caught;
try {
JX.Stratcom.getData(n);
} catch (error) {
caught = error;
}

expect(caught instanceof Error).toEqual(true);
});
});

// it('can set data serializer', function() {
// var uri = new JX.URI('http://www.facebook.com/home.php?key=value');
// uri.setQuerySerializer(JX.PHPQuerySerializer.serialize);
4 changes: 2 additions & 2 deletions src/docs/facebook.diviner
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ Now you should be able to build the individual binaries:

To synchronize Javelin **from** Facebook trunk, run the synchronize script:

javelin/ $ ./scripts/synchronize-from-facebook.php ~/www
javelin/ $ ./scripts/sync-from-facebook.php ~/www

...where ##~/www## is the root you want to pull Javelin files from. The script
will copy files out of ##html/js/javelin## and build packages, and leave the
@@ -44,7 +44,7 @@ then push, diff, or send a pull request.
To synchronize Javelin **to** Facebook trunk, run the, uh, reverse-synchronize
script:

javelin/ $ ./scripts/synchronize-to-facebook.php ~/www
javelin/ $ ./scripts/sync-to-facebook.php ~/www

...where ##~/www## is the root you want to push Javelin files to. The script
will copy files out of the working copy into your ##www## and leave you with a
3 changes: 2 additions & 1 deletion src/lib/DOM.js
Original file line number Diff line number Diff line change
@@ -536,7 +536,8 @@ JX.install('DOM', {
var type = elements[ii].type;
var tag = elements[ii].tagName;
if ((type in {radio: 1, checkbox: 1} && elements[ii].checked) ||
type in {text: 1, hidden: 1, password: 1, email: 1} ||
type in {text: 1, hidden: 1, password: 1, email: 1, tel: 1,
number: 1} ||
tag in {TEXTAREA: 1, SELECT: 1}) {
data.push([elements[ii].name, elements[ii].value]);
}
18 changes: 11 additions & 7 deletions src/lib/behavior.js
Original file line number Diff line number Diff line change
@@ -42,15 +42,19 @@ JX.behavior = function(name, control_function) {
'initialization function is not a function.');
}
// IE does not enumerate over these properties
var enumerables = [
'toString', 'hasOwnProperty', 'valueOf', 'isPrototypeOf',
'propertyIsEnumerable', 'toLocaleString', 'constructor'
];
if (~enumerables.indexOf(name)) {
var enumerables = {
toString: true,
hasOwnProperty: true,
valueOf: true,
isPrototypeOf: true,
propertyIsEnumerable: true,
toLocaleString: true,
constructor: true
};
if (enumerables[name]) {
JX.$E(
'JX.behavior("' + name + '", <garbage>): ' +
'do not use any of these properties as behaviors: ' +
enumerables.join(', ')
'do not use this property as a behavior.'
);
}
}
9 changes: 8 additions & 1 deletion src/lib/control/typeahead/source/TypeaheadSource.js
Original file line number Diff line number Diff line change
@@ -55,8 +55,15 @@ JX.install('TypeaheadSource', {
* - **name**: the string used for matching against user input.
* - **uri**: the URI corresponding with the object (must be present
* but need not be meaningful)
*
* You can also give:
* - **display**: the text or nodes to show in the DOM. Usually just the
* same as ##name##.
* - **tokenizable**: if you want to tokenize something other than the
* ##name##, for the typeahead to complete on, specify it here. A
* selected entry from the typeahead will still insert the ##name##
* into the input, but the ##tokenizable## field lets you complete on
* non-name things.
*
* The default transformer expects a three element list with elements
* [name, uri, id]. It assigns the first element to both ##name## and
@@ -167,7 +174,7 @@ JX.install('TypeaheadSource', {
}

this._raw[obj.id] = obj;
var t = this.tokenize(obj.name);
var t = this.tokenize(obj.tokenizable || obj.name);
for (var jj = 0; jj < t.length; ++jj) {
this._lookup[t[jj]] = this._lookup[t[jj]] || [];
this._lookup[t[jj]].push(obj.id);
42 changes: 27 additions & 15 deletions support/javelinsymbols/javelinsymbols.cpp
Original file line number Diff line number Diff line change
@@ -17,31 +17,39 @@ typedef map<string, int> symbol_t;

string get_static_member_symbol(Node *node);

void find_symbols(Node *node, symbol_t &installs, symbol_t &uses) {
void find_symbols(Node *node, symbol_t &installs, symbol_t &behaviors,
symbol_t &uses) {
if (node == NULL) {
return;
}

if (typeid(*node) == typeid(NodeStaticMemberExpression)) {
string symbol = get_static_member_symbol(node);
if (symbol[0] == 'J' && symbol[1] == 'X' && symbol[2] == '.') {
uses[symbol] = node->lineno();
}
}

if (typeid(*node) == typeid(NodeFunctionCall)) {
Node *call = *node->childNodes().begin();
if (static_cast<NodeStaticMemberExpression *>(call)) {
if (get_static_member_symbol(call) == "JX.install") {
NodeArgList *args = static_cast<NodeArgList*>(*(++node->childNodes().begin()));
NodeStringLiteral* lit = static_cast<NodeStringLiteral*>(*args->childNodes().begin());
installs[lit->unquoted_value()] = node->lineno();
string symbol = get_static_member_symbol(call);
if (symbol == "JX.install" || symbol == "JX.behavior") {
NodeArgList *args =
static_cast<NodeArgList*>(*(++node->childNodes().begin()));
NodeStringLiteral* lit =
static_cast<NodeStringLiteral*>(*args->childNodes().begin());
if (symbol == "JX.install") {
installs[lit->unquoted_value()] = node->lineno();
} else {
behaviors[lit->unquoted_value()] = node->lineno();
}
}
}
}

for_nodes(node, ii) {
find_symbols(*ii, installs, uses);
find_symbols(*ii, installs, behaviors, uses);
}
}

@@ -65,26 +73,30 @@ string get_static_member_symbol(Node *node) {
symbol += get_static_member_symbol(*ii);
}
}

return symbol;
}

int main(int argc, char* argv[]) {
try {
NodeProgram root(stdin); // parses

symbol_t installs;
symbol_t behaviors;
symbol_t uses;
find_symbols(&root, installs, uses);

find_symbols(&root, installs, behaviors, uses);

for (symbol_t::iterator ii = installs.begin(); ii != installs.end(); ++ii) {
cout << "+" << ii->first << ":" << ii->second << endl;
}
for (symbol_t::iterator ii = behaviors.begin(); ii != behaviors.end(); ++ii) {
cout << "*" << ii->first << ":" << ii->second << endl;
}
for (symbol_t::iterator ii = uses.begin(); ii != uses.end(); ++ii) {
cout << "?" << ii->first << ":" << ii->second << endl;
}

} catch (ParseException ex) {
printf("Parse Error: %s\n", ex.what());
return 1;