1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Use JsShrink if jsxmin is not available

Summary: If `jsxmin` is not available, use a pure PHP implementation instead (JsShrink).

Test Plan:
  - Ran `arc lint --lintall` on all JS and fixed every relevant warning.
  - Forced minification on and browsed around the site using JS behaviors. Didn't hit anything problematic.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5670
This commit is contained in:
epriestley 2013-05-18 17:04:22 -07:00
parent b09dc9cad8
commit 0569218201
94 changed files with 598 additions and 501 deletions

View file

@ -6,5 +6,6 @@
"phutil_libraries" : { "phutil_libraries" : {
"phabricator" : "src/" "phabricator" : "src/"
}, },
"lint.xhpast.naminghook" : "PhabricatorSymbolNameLinter" "lint.xhpast.naminghook" : "PhabricatorSymbolNameLinter",
"lint.jshint.config" : "support/jshint/jshintconfig"
} }

45
externals/JsShrink/jsShrink.php vendored Normal file
View file

@ -0,0 +1,45 @@
<?php
/** Remove spaces and comments from JavaScript code
* @param string code with commands terminated by semicolon
* @return string shrinked code
* @link http://vrana.github.com/JsShrink/
* @author Jakub Vrana, http://www.vrana.cz/
* @copyright 2007 Jakub Vrana
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
function jsShrink($input) {
return preg_replace_callback('(
(?:
(^|[-+\([{}=,:;!%^&*|?~]|/(?![/*])|return|throw) # context before regexp
(?:\s|//[^\n]*+\n|/\*(?:[^*]|\*(?!/))*+\*/)* # optional space
(/(?![/*])(?:\\\\[^\n]|[^[\n/\\\\]|\[(?:\\\\[^\n]|[^]])++)+/) # regexp
|(^
|\'(?:\\\\.|[^\n\'\\\\])*\'
|"(?:\\\\.|[^\n"\\\\])*"
|([0-9A-Za-z_$]+)
|([-+]+)
|.
)
)(?:\s|//[^\n]*+\n|/\*(?:[^*]|\*(?!/))*+\*/)* # optional space
)sx', 'jsShrinkCallback', "$input\n");
}
function jsShrinkCallback($match) {
static $last = '';
$match += array_fill(1, 5, null); // avoid E_NOTICE
list(, $context, $regexp, $result, $word, $operator) = $match;
if ($word != '') {
$result = ($last == 'word' ? "\n" : ($last == 'return' ? " " : "")) . $result;
$last = ($word == 'return' || $word == 'throw' || $word == 'break' ? 'return' : 'word');
} elseif ($operator) {
$result = ($last == $operator[0] ? "\n" : "") . $result;
$last = $operator[0];
} else {
if ($regexp) {
$result = $context . ($context == '/' ? "\n" : "") . $regexp;
}
$last = '';
}
return $result;
}

23
externals/JsShrink/readme.txt vendored Normal file
View file

@ -0,0 +1,23 @@
JsShrink - Remove spaces and comments from JavaScript code
Available in PHP and JavaScript
Requires statements ending by semicolon, use JSHint or JSLint to verify.
http://vrana.github.com/JsShrink/
Usage PHP:
<?php
include "jsShrink.php";
echo jsShrink($code);
?>
Usage JavaScript:
<script type="text/javascript" src="jsShrink.js"></script>
<script type="text/javascript">
textarea.value = jsShrink(code);
</script>
Note:
Google Closure Compiler is much more powerful and efficient tool.
JsShrink was created for those looking for PHP or JavaScript only solution.
Most other JS minifiers are not able to process valid JavaScript code:
http://php.vrana.cz/minifikace-javascriptu.php#srovnani

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,9 @@ final class CelerityResourceTransformer {
return $this; return $this;
} }
/**
* @phutil-external-symbol function jsShrink
*/
public function transformResource($path, $data) { public function transformResource($path, $data) {
$type = self::getResourceType($path); $type = self::getResourceType($path);
@ -70,17 +73,25 @@ final class CelerityResourceTransformer {
$data = trim($data); $data = trim($data);
break; break;
case 'js': case 'js':
$root = dirname(phutil_get_library_root('phabricator'));
$bin = $root.'/externals/javelin/support/jsxmin/jsxmin';
if (@file_exists($bin)) { // If `jsxmin` is available, use it. jsxmin is the Javelin minifier and
$future = new ExecFuture('%s __DEV__:0', $bin); // produces the smallest output, but is complicated to build.
if (Filesystem::binaryExists('jsxmin')) {
$future = new ExecFuture('jsxmin __DEV__:0');
$future->write($data); $future->write($data);
list($err, $result) = $future->resolve(); list($err, $result) = $future->resolve();
if (!$err) { if (!$err) {
$data = $result; $data = $result;
break;
} }
} }
// If `jsxmin` is not available, use `JsShrink`, which doesn't compress
// quite as well but is always available.
$root = dirname(phutil_get_library_root('phabricator'));
require_once $root.'/externals/JsShrink/jsShrink.php';
$data = jsShrink($data);
break; break;
} }

View file

@ -37,16 +37,35 @@ class PhabricatorLintEngine extends PhutilLintEngine {
$javelin_linter = new PhabricatorJavelinLinter(); $javelin_linter = new PhabricatorJavelinLinter();
$linters[] = $javelin_linter; $linters[] = $javelin_linter;
$jshint_linter = new ArcanistJSHintLinter();
$linters[] = $jshint_linter;
foreach ($paths as $path) { foreach ($paths as $path) {
if (!preg_match('/\.js$/', $path)) {
continue;
}
if (strpos($path, 'externals/JsShrink') !== false) {
// Ignore warnings in JsShrink tests.
continue;
}
if (strpos($path, 'externals/raphael') !== false) {
// Ignore Raphael.
continue;
}
$jshint_linter->addPath($path);
$jshint_linter->addData($path, $this->loadData($path));
if (strpos($path, 'support/aphlict/') !== false) { if (strpos($path, 'support/aphlict/') !== false) {
// This stuff is Node.js, not Javelin, so don't apply the Javelin // This stuff is Node.js, not Javelin, so don't apply the Javelin
// linter. // linter.
continue; continue;
} }
if (preg_match('/\.js$/', $path)) {
$javelin_linter->addPath($path); $javelin_linter->addPath($path);
$javelin_linter->addData($path, $this->loadData($path)); $javelin_linter->addData($path, $this->loadData($path));
}
} }
return $linters; return $linters;

View file

@ -78,7 +78,7 @@ final class PhabricatorJavelinLinter extends ArcanistLinter {
} }
private function shouldIgnorePath($path) { private function shouldIgnorePath($path) {
return preg_match('@/__tests__/|externals/javelinjs/src/docs/@', $path); return preg_match('@/__tests__/|externals/javelin/docs/@', $path);
} }
public function lintPath($path) { public function lintPath($path) {
@ -167,12 +167,17 @@ final class PhabricatorJavelinLinter extends ArcanistLinter {
continue; continue;
} }
$symbol_path = 'webroot'.$symbol_info['disk']; if (preg_match('/\\.css$/', $symbol_info['disk'])) {
list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath( // If JS requires CSS, just assume everything is fine.
$symbol_path);
if (array_intersect_key($req_install, $external_classes)) {
$need = array_diff_key($need, $req_install);
unset($requires[$key]); unset($requires[$key]);
} else {
$symbol_path = 'webroot'.$symbol_info['disk'];
list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath(
$symbol_path);
if (array_intersect_key($req_install, $external_classes)) {
$need = array_diff_key($need, $req_install);
unset($requires[$key]);
}
} }
} }

View file

@ -35,7 +35,7 @@ function parse_command_line_arguments(argv) {
return config; return config;
} }
if (process.getuid() != 0) { if (process.getuid() !== 0) {
console.log( console.log(
"ERROR: "+ "ERROR: "+
"This server must be run as root because it needs to bind to privileged "+ "This server must be run as root because it needs to bind to privileged "+
@ -118,8 +118,8 @@ var MAX_ID = 9007199254740991;//2^53 -1
// you want to write something pretty be my guest // you want to write something pretty be my guest
function generate_id() { function generate_id() {
if (typeof generate_id.current_id == 'undefined' if (typeof generate_id.current_id == 'undefined' ||
|| generate_id.current_id > MAX_ID) { generate_id.current_id > MAX_ID) {
generate_id.current_id = 0; generate_id.current_id = 0;
} }
return generate_id.current_id++; return generate_id.current_id++;
@ -132,15 +132,15 @@ var send_server = net.createServer(function(socket) {
socket.on('connect', function() { socket.on('connect', function() {
clients[client_id] = socket; clients[client_id] = socket;
current_connections++; current_connections++;
log(client_name + 'connected\t\t(' log(client_name + 'connected\t\t(' +
+ current_connections + ' current connections)'); current_connections + ' current connections)');
}); });
socket.on('close', function() { socket.on('close', function() {
delete clients[client_id]; delete clients[client_id];
current_connections--; current_connections--;
log(client_name + 'closed\t\t(' log(client_name + 'closed\t\t(' +
+ current_connections + ' current connections)'); current_connections + ' current connections)');
}); });
socket.on('timeout', function() { socket.on('timeout', function() {

View file

@ -0,0 +1,5 @@
{
"expr" : true,
"loopfunc" : true,
"sub" : true
}

View file

@ -337,7 +337,7 @@ JX.install('Event', {
JX.Event.prototype.toString = function() { JX.Event.prototype.toString = function() {
var path = '['+this.getPath().join(', ')+']'; var path = '['+this.getPath().join(', ')+']';
return 'Event<'+this.getType()+', '+path+', '+this.getTarget()+'>'; return 'Event<'+this.getType()+', '+path+', '+this.getTarget()+'>';
} };
} }
} }
}); });

View file

@ -32,7 +32,7 @@
return; return;
} }
holding_queues[name] = []; holding_queues[name] = [];
JX[name] = function() { holding_queues[name].push(arguments); } JX[name] = function() { holding_queues[name].push(arguments); };
} }
JX.flushHoldingQueue = function(name, fn) { JX.flushHoldingQueue = function(name, fn) {
@ -40,7 +40,7 @@
fn.apply(null, holding_queues[name][ii]); fn.apply(null, holding_queues[name][ii]);
} }
holding_queues[name] = {}; holding_queues[name] = {};
} };
makeHoldingQueue('install'); makeHoldingQueue('install');
makeHoldingQueue('behavior'); makeHoldingQueue('behavior');
@ -107,7 +107,7 @@
return false; return false;
} }
} }
} };
JX.enableDispatch = function(target, type) { JX.enableDispatch = function(target, type) {
if (__DEV__) { if (__DEV__) {
@ -165,7 +165,8 @@
} }
} }
for (var ii = 0; ii < document_events.length; ++ii) { var ii;
for (ii = 0; ii < document_events.length; ++ii) {
JX.enableDispatch(root, document_events[ii]); JX.enableDispatch(root, document_events[ii]);
} }
@ -182,7 +183,7 @@
]; ];
for (var ii = 0; ii < window_events.length; ++ii) { for (ii = 0; ii < window_events.length; ++ii) {
JX.enableDispatch(window, window_events[ii]); JX.enableDispatch(window, window_events[ii]);
} }
@ -212,7 +213,7 @@
'<script' + '<script' +
' defer="defer"' + ' defer="defer"' +
' onreadystatechange="' + ready + '"' + ' onreadystatechange="' + ready + '"' +
'><\/sc' + 'ript\>'); '><\/sc' + 'ript' + '>');
} }
JX.onload = function(func) { JX.onload = function(func) {
@ -221,5 +222,6 @@
} else { } else {
onload.push(func); onload.push(func);
} }
} };
})(); })();

View file

@ -247,7 +247,7 @@ JX.bind = function(context, func, more) {
return function() { return function() {
return func.apply(context || window, bound.concat(JX.$A(arguments))); return func.apply(context || window, bound.concat(JX.$A(arguments)));
} };
}; };
@ -320,7 +320,7 @@ if (__DEV__) {
*/ */
JX.log = function(message) { JX.log = function(message) {
window.console.log(message); window.console.log(message);
} };
window.alert = (function(native_alert) { window.alert = (function(native_alert) {
var recent_alerts = []; var recent_alerts = [];
@ -349,7 +349,7 @@ if (__DEV__) {
native_alert(msg); native_alert(msg);
} }
in_alert = false; in_alert = false;
} };
})(window.alert); })(window.alert);
} }

View file

@ -3,6 +3,7 @@
* @provides javelin-reactor-dom * @provides javelin-reactor-dom
* @requires javelin-dom * @requires javelin-dom
* javelin-dynval * javelin-dynval
* javelin-reactor
* javelin-reactornode * javelin-reactornode
* javelin-install * javelin-install
* javelin-util * javelin-util

View file

@ -5,7 +5,9 @@
* *
* @provides javelin-view-html * @provides javelin-view-html
* @requires javelin-install * @requires javelin-install
* javelin-view * javelin-dom
* javelin-view-visitor
* javelin-util
*/ */
JX.install('HTMLView', { JX.install('HTMLView', {
@ -26,7 +28,7 @@ JX.install('HTMLView', {
validate: function(view, children) { validate: function(view, children) {
var spec = this._getHTMLSpec(); var spec = this._getHTMLSpec();
if (!view.getName() in spec) { if (!(view.getName() in spec)) {
throw new Error("invalid tag"); throw new Error("invalid tag");
} }

View file

@ -82,8 +82,11 @@ JX.install('View', {
var result = []; var result = [];
var should_repack = false; var should_repack = false;
for(var ii = 0; ii < this._childKeys.length; ii++) { var ii;
var key = this._childKeys[ii]; var key;
for (ii = 0; ii < this._childKeys.length; ii++) {
key = this._childKeys[ii];
if (this._rawChildren[key] === undefined) { if (this._rawChildren[key] === undefined) {
should_repack = true; should_repack = true;
} else { } else {
@ -93,8 +96,8 @@ JX.install('View', {
if (should_repack) { if (should_repack) {
var new_child_keys = []; var new_child_keys = [];
for(var ii = 0; ii < this._childKeys.length; ii++) { for (ii = 0; ii < this._childKeys.length; ii++) {
var key = this._childKeys[ii]; key = this._childKeys[ii];
if (this._rawChildren[key] !== undefined) { if (this._rawChildren[key] !== undefined) {
new_child_keys.push(key); new_child_keys.push(key);
} }

View file

@ -42,7 +42,7 @@
* @provides javelin-view-interpreter * @provides javelin-view-interpreter
* @requires javelin-view * @requires javelin-view
* javelin-install * javelin-install
* * javelin-dom
*/ */
JX.install('ViewInterpreter', { JX.install('ViewInterpreter', {
@ -65,7 +65,7 @@ JX.install('ViewInterpreter', {
result.addChildren(children); result.addChildren(children);
return result; return result;
} };
} }
} }
}); });

View file

@ -48,6 +48,7 @@
* @requires javelin-behavior * @requires javelin-behavior
* javelin-dom * javelin-dom
* javelin-view-renderer * javelin-view-renderer
* javelin-install
*/ */
@ -72,11 +73,12 @@ JX.install('ViewPlaceholder', {
statics: { statics: {
register: function(wait_on_token, token, cb) { register: function(wait_on_token, token, cb) {
var ready_q = []; var ready_q = [];
var waiting;
if (!wait_on_token || wait_on_token in JX.ViewPlaceholder.ready) { if (!wait_on_token || wait_on_token in JX.ViewPlaceholder.ready) {
ready_q.push({token: token, cb: cb}); ready_q.push({token: token, cb: cb});
} else { } else {
var waiting = JX.ViewPlaceholder.waiting; waiting = JX.ViewPlaceholder.waiting;
waiting[wait_on_token] = waiting[wait_on_token] || []; waiting[wait_on_token] = waiting[wait_on_token] || [];
waiting[wait_on_token].push({token: token, cb: cb}); waiting[wait_on_token].push({token: token, cb: cb});
} }
@ -84,7 +86,7 @@ JX.install('ViewPlaceholder', {
while(ready_q.length) { while(ready_q.length) {
var ready = ready_q.shift(); var ready = ready_q.shift();
var waiting = JX.ViewPlaceholder.waiting[ready.token]; waiting = JX.ViewPlaceholder.waiting[ready.token];
if (waiting) { if (waiting) {
for (var ii = 0; ii < waiting.length; ii++) { for (var ii = 0; ii < waiting.length; ii++) {
ready_q.push(waiting[ii]); ready_q.push(waiting[ii]);

View file

@ -1,6 +1,7 @@
/** /**
* @provides javelin-view-renderer * @provides javelin-view-renderer
* @requires javelin-install * @requires javelin-install
* javelin-util
*/ */
JX.install('ViewRenderer', { JX.install('ViewRenderer', {

View file

@ -13,11 +13,11 @@ describe('JX.ViewRenderer', function() {
parent.addChild(child); parent.addChild(child);
child.render = function(_) { child.render = function(_) {
child_rendered = true; child_rendered = true;
} };
parent.render = function(rendered_children) { parent.render = function(rendered_children) {
child_rendered_first = child_rendered; child_rendered_first = child_rendered;
} };
JX.ViewRenderer.render(parent); JX.ViewRenderer.render(parent);
expect(child_rendered_first).toBe(true); expect(child_rendered_first).toBe(true);

View file

@ -102,8 +102,8 @@ JX.install('HTML', {
var tags = ['legend', 'thead', 'tbody', 'tfoot', 'column', 'colgroup', var tags = ['legend', 'thead', 'tbody', 'tfoot', 'column', 'colgroup',
'caption', 'tr', 'th', 'td', 'option']; 'caption', 'tr', 'th', 'td', 'option'];
var evil_stuff = new RegExp('^\\s*<(' + tags.join('|') + ')\\b', 'i'); var evil_stuff = new RegExp('^\\s*<(' + tags.join('|') + ')\\b', 'i');
var match = null; var match = str.match(evil_stuff);
if (match = str.match(evil_stuff)) { if (match) {
JX.$E( JX.$E(
'new JX.HTML("<' + match[1] + '>..."): ' + 'new JX.HTML("<' + match[1] + '>..."): ' +
'call initializes an HTML object with an invalid partial fragment ' + 'call initializes an HTML object with an invalid partial fragment ' +
@ -725,8 +725,10 @@ JX.install('DOM', {
* @return void * @return void
*/ */
show : function() { show : function() {
var ii;
if (__DEV__) { if (__DEV__) {
for (var ii = 0; ii < arguments.length; ++ii) { for (ii = 0; ii < arguments.length; ++ii) {
if (!arguments[ii]) { if (!arguments[ii]) {
JX.$E( JX.$E(
'JX.DOM.show(...): ' + 'JX.DOM.show(...): ' +
@ -735,7 +737,7 @@ JX.install('DOM', {
} }
} }
for (var ii = 0; ii < arguments.length; ++ii) { for (ii = 0; ii < arguments.length; ++ii) {
arguments[ii].style.display = ''; arguments[ii].style.display = '';
} }
}, },
@ -750,8 +752,10 @@ JX.install('DOM', {
* @return void * @return void
*/ */
hide : function() { hide : function() {
var ii;
if (__DEV__) { if (__DEV__) {
for (var ii = 0; ii < arguments.length; ++ii) { for (ii = 0; ii < arguments.length; ++ii) {
if (!arguments[ii]) { if (!arguments[ii]) {
JX.$E( JX.$E(
'JX.DOM.hide(...): ' + 'JX.DOM.hide(...): ' +
@ -760,7 +764,7 @@ JX.install('DOM', {
} }
} }
for (var ii = 0; ii < arguments.length; ++ii) { for (ii = 0; ii < arguments.length; ++ii) {
arguments[ii].style.display = 'none'; arguments[ii].style.display = 'none';
} }
}, },

View file

@ -71,7 +71,7 @@ JX.install('Mask', {
document.body.appendChild(self._mask); document.body.appendChild(self._mask);
} }
self._adjustType(mask_type) self._adjustType(mask_type);
JX.Mask._stack.push(mask_type); JX.Mask._stack.push(mask_type);
}, },

View file

@ -201,7 +201,7 @@ JX.install('Request', {
'JX.Request("'+this.getURI()+'", ...): '+ 'JX.Request("'+this.getURI()+'", ...): '+
'server returned an empty response.'); 'server returned an empty response.');
} }
if (expect_guard && xport.responseText.indexOf('for (;;);') != 0) { if (expect_guard && xport.responseText.indexOf('for (;;);') !== 0) {
JX.$E( JX.$E(
'JX.Request("'+this.getURI()+'", ...): '+ 'JX.Request("'+this.getURI()+'", ...): '+
'server returned an invalid response.'); 'server returned an invalid response.');
@ -405,7 +405,7 @@ JX.install('Request', {
recurse(obj, ii); recurse(obj, ii);
} }
} else if (obj && typeof obj == 'object') { } else if (obj && typeof obj == 'object') {
if (obj.__html != null) { if (('__html' in obj) && (obj.__html !== null)) {
parent[index] = JX.$H(obj.__html); parent[index] = JX.$H(obj.__html);
} else { } else {
for (var key in obj) { for (var key in obj) {

View file

@ -1,9 +1,8 @@
/** /**
* @provides javelin-resource * @provides javelin-resource
* @requires javelin-magical-init * @requires javelin-util
* javelin-stratcom
* javelin-util
* javelin-uri * javelin-uri
* javelin-install
* *
* @javelin * @javelin
*/ */

View file

@ -54,7 +54,7 @@ JX.install('URI', {
_defaultQuerySerializer : function(obj) { _defaultQuerySerializer : function(obj) {
var kv_pairs = []; var kv_pairs = [];
for (var key in obj) { for (var key in obj) {
if (obj[key] != null) { if (obj[key] !== null) {
var value = encodeURIComponent(obj[key]); var value = encodeURIComponent(obj[key]);
kv_pairs.push(encodeURIComponent(key) + (value ? '=' + value : '')); kv_pairs.push(encodeURIComponent(key) + (value ? '=' + value : ''));
} }

View file

@ -164,13 +164,9 @@ JX.install('Vector', {
*/ */
setDim : function(node) { setDim : function(node) {
node.style.width = node.style.width =
(this.x === null) (this.x === null) ? '' : (parseInt(this.x, 10) + 'px');
? ''
: (parseInt(this.x, 10) + 'px');
node.style.height = node.style.height =
(this.y === null) (this.y === null) ? '' : (parseInt(this.y, 10) + 'px');
? ''
: (parseInt(this.y, 10) + 'px');
return this; return this;
}, },

View file

@ -282,7 +282,7 @@ JX.install('Workflow', {
JX.Workflow._pop(); JX.Workflow._pop();
e.prevent(); e.prevent();
}; }
JX.Stratcom.listen('keydown', null, close_dialog_when_user_presses_escape); JX.Stratcom.listen('keydown', null, close_dialog_when_user_presses_escape);
} }

View file

@ -262,7 +262,7 @@ describe('Javelin URI', function() {
expect(uri.toString()).toEqual('/?clown=town'); expect(uri.toString()).toEqual('/?clown=town');
}); });
it('can remove non existant query data', function() { it('can remove non existent query data', function() {
var uri = JX.$U('/?key=value'); var uri = JX.$U('/?key=value');
uri.addQueryParams({'magic' : null}); uri.addQueryParams({'magic' : null});
expect(uri.getQueryParams()).toEqual({ expect(uri.getQueryParams()).toEqual({

View file

@ -1,6 +1,7 @@
/** /**
* @provides javelin-behavior * @provides javelin-behavior
* @requires javelin-magical-init * @requires javelin-magical-init
* javelin-util
* *
* @javelin-installs JX.behavior * @javelin-installs JX.behavior
* @javelin-installs JX.initBehaviors * @javelin-installs JX.initBehaviors

View file

@ -345,7 +345,7 @@ JX.install('Tokenizer', {
case 'delete': case 'delete':
if (!this._focus.value.length) { if (!this._focus.value.length) {
var tok; var tok;
while (tok = this._tokens.pop()) { while ((tok = this._tokens.pop())) {
if (this._remove(tok, true)) { if (this._remove(tok, true)) {
break; break;
} }

View file

@ -1,7 +1,6 @@
/** /**
* @requires javelin-install * @requires javelin-install
* javelin-util * javelin-util
* javelin-stratcom
* javelin-request * javelin-request
* javelin-typeahead-source * javelin-typeahead-source
* @provides javelin-typeahead-ondemand-source * @provides javelin-typeahead-ondemand-source

View file

@ -1,7 +1,6 @@
/** /**
* @requires javelin-install * @requires javelin-install
* javelin-util * javelin-util
* javelin-stratcom
* javelin-request * javelin-request
* javelin-typeahead-source * javelin-typeahead-source
* @provides javelin-typeahead-preloaded-source * @provides javelin-typeahead-preloaded-source

View file

@ -282,7 +282,8 @@ JX.install('TypeaheadSource', {
sortHits : function(value, hits) { sortHits : function(value, hits) {
var objs = []; var objs = [];
for (var ii = 0; ii < hits.length; ii++) { var ii;
for (ii = 0; ii < hits.length; ii++) {
objs.push(this._raw[hits[ii]]); objs.push(this._raw[hits[ii]]);
} }
@ -299,7 +300,7 @@ JX.install('TypeaheadSource', {
handler(value, objs, default_comparator); handler(value, objs, default_comparator);
hits.splice(0, hits.length); hits.splice(0, hits.length);
for (var ii = 0; ii < objs.length; ii++) { for (ii = 0; ii < objs.length; ii++) {
hits.push(objs[ii].id); hits.push(objs[ii].id);
} }
}, },

View file

@ -1,6 +1,7 @@
/** /**
* @provides raphael-g * @provides raphael-g
* @do-not-minify * @do-not-minify
* @nolint
*/ */
/*! /*!
* g.Raphael 0.5 - Charting library, based on Raphaël * g.Raphael 0.5 - Charting library, based on Raphaël

View file

@ -1,6 +1,7 @@
/** /**
* @provides raphael-g-line * @provides raphael-g-line
* @do-not-minify * @do-not-minify
* @nolint
*/ */
/*! /*!
* g.Raphael 0.5 - Charting library, based on Raphaël * g.Raphael 0.5 - Charting library, based on Raphaël

View file

@ -1,6 +1,7 @@
/** /**
* @provides raphael-core * @provides raphael-core
* @do-not-minify * @do-not-minify
* @nolint
*/ */
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël 2.0.1 - JavaScript Vector Library │ \\ // │ Raphaël 2.0.1 - JavaScript Vector Library │ \\

View file

@ -29,12 +29,10 @@ JX.behavior('aphlict-dropdown', function(config) {
return; return;
} }
request = new JX.Request('/notification/panel/', function(response) { request = new JX.Request('/notification/panel/', function(response) {
var display = (response.number > 999) var display = (response.number > 999) ? "\u221E" : response.number;
? "\u221E"
: response.number;
JX.DOM.setContent(count, display); JX.DOM.setContent(count, display);
if (response.number == 0) { if (response.number === 0) {
JX.DOM.alterClass(bubble, 'alert-unread', false); JX.DOM.alterClass(bubble, 'alert-unread', false);
} else { } else {
JX.DOM.alterClass(bubble, 'alert-unread', true); JX.DOM.alterClass(bubble, 'alert-unread', true);
@ -102,7 +100,7 @@ JX.behavior('aphlict-dropdown', function(config) {
visible = !visible; visible = !visible;
e.kill(); e.kill();
} }
) );
JX.Stratcom.listen('notification-panel-update', null, function() { JX.Stratcom.listen('notification-panel-update', null, function() {
dirty = true; dirty = true;

View file

@ -29,9 +29,7 @@ JX.behavior('aphlict-listen', function(config) {
.send(); .send();
} else if (__DEV__) { } else if (__DEV__) {
if (config.debug) { if (config.debug) {
var details = message var details = message ? JX.JSON.stringify(message) : '';
? JX.JSON.stringify(message)
: '';
new JX.Notification() new JX.Notification()
.setContent('(Aphlict) [' + type + '] ' + details) .setContent('(Aphlict) [' + type + '] ' + details)
@ -65,7 +63,7 @@ JX.behavior('aphlict-listen', function(config) {
.setContent('Page updated, click to reload.') .setContent('Page updated, click to reload.')
.alterClassName('jx-notification-alert', true) .alterClassName('jx-notification-alert', true)
.setDuration(0); .setDuration(0);
reload.listen('activate', function(e) { JX.$U().go(); }) reload.listen('activate', function(e) { JX.$U().go(); });
reload.show(); reload.show();
showing_reload = true; showing_reload = true;
@ -80,11 +78,11 @@ JX.behavior('aphlict-listen', function(config) {
// Add Flash object to page // Add Flash object to page
JX.$(config.containerID).innerHTML = JX.$(config.containerID).innerHTML =
'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' +
+ '<param name="movie" value="/rsrc/swf/aphlict.swf" />' '<param name="movie" value="/rsrc/swf/aphlict.swf" />' +
+ '<param name="allowScriptAccess" value="always" />' '<param name="allowScriptAccess" value="always" />' +
+ '<param name="wmode" value="opaque" />' '<param name="wmode" value="opaque" />' +
+ '<embed src="/rsrc/swf/aphlict.swf" wmode="opaque"' '<embed src="/rsrc/swf/aphlict.swf" wmode="opaque"' +
+ 'width="0" height="0" id="' + config.id + '">' 'width="0" height="0" id="' + config.id + '">' +
+ '</embed></object>'; //Evan sanctioned '</embed></object>'; //Evan sanctioned
}); });

View file

@ -21,15 +21,19 @@ JX.behavior('conpherence-widget-pane', function(config) {
var root = JX.DOM.find(document, 'div', 'conpherence-layout'); var root = JX.DOM.find(document, 'div', 'conpherence-layout');
var widgetPane = JX.DOM.find(root, 'div', 'conpherence-widget-pane'); var widgetPane = JX.DOM.find(root, 'div', 'conpherence-widget-pane');
var i;
var tag_data;
var node;
for (var widget in config.widgetRegistery) { for (var widget in config.widgetRegistery) {
// device-only widgets are *always shown* on the desktop // device-only widgets are *always shown* on the desktop
if (config.widgetRegistery[widget] == config.devicesOnly) { if (config.widgetRegistery[widget] == config.devicesOnly) {
if (is_desktop) { if (is_desktop) {
JX.$(widget).style.display = 'block'; JX.$(widget).style.display = 'block';
if (config.widgetExtraNodes[widget]) { if (config.widgetExtraNodes[widget]) {
for (var i in config.widgetExtraNodes[widget]) { for (i in config.widgetExtraNodes[widget]) {
var tag_data = config.widgetExtraNodes[widget][i]; tag_data = config.widgetExtraNodes[widget][i];
var node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil); node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil);
node.style.display = tag_data.desktopstyle; node.style.display = tag_data.desktopstyle;
} }
} }
@ -48,9 +52,9 @@ JX.behavior('conpherence-widget-pane', function(config) {
widgetPane.style.height = '100%'; widgetPane.style.height = '100%';
} }
if (config.widgetExtraNodes[widget]) { if (config.widgetExtraNodes[widget]) {
for (var i in config.widgetExtraNodes[widget]) { for (i in config.widgetExtraNodes[widget]) {
var tag_data = config.widgetExtraNodes[widget][i]; tag_data = config.widgetExtraNodes[widget][i];
var node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil); node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil);
node.style.display = tag_data.showstyle; node.style.display = tag_data.showstyle;
} }
} }
@ -75,9 +79,9 @@ JX.behavior('conpherence-widget-pane', function(config) {
); );
JX.$(widget).style.display = 'none'; JX.$(widget).style.display = 'none';
if (config.widgetExtraNodes[widget]) { if (config.widgetExtraNodes[widget]) {
for (var i in config.widgetExtraNodes[widget]) { for (i in config.widgetExtraNodes[widget]) {
var tag_data = config.widgetExtraNodes[widget][i]; tag_data = config.widgetExtraNodes[widget][i];
var node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil); node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil);
node.style.display = tag_data.hidestyle; node.style.display = tag_data.hidestyle;
} }
} }

View file

@ -2,7 +2,6 @@
* @provides javelin-behavior-countdown-timer * @provides javelin-behavior-countdown-timer
* @requires javelin-behavior * @requires javelin-behavior
* javelin-dom * javelin-dom
* javelin-util
*/ */
JX.behavior('countdown-timer', function(config) { JX.behavior('countdown-timer', function(config) {

View file

@ -162,8 +162,9 @@ JX.install('DifferentialInlineCommentEditor', {
return; return;
} }
var textarea;
try { try {
var textarea = JX.DOM.find( textarea = JX.DOM.find(
document.body, // TODO: use getDialogRootNode() when available document.body, // TODO: use getDialogRootNode() when available
'textarea', 'textarea',
'differential-inline-comment-edit-textarea'); 'differential-inline-comment-edit-textarea');
@ -180,16 +181,15 @@ JX.install('DifferentialInlineCommentEditor', {
// If the user hasn't edited the text (i.e., no change from original for // If the user hasn't edited the text (i.e., no change from original for
// 'edit' or no text at all), don't offer them an undo. // 'edit' or no text at all), don't offer them an undo.
if (text == this.getOriginalText() || text == '') { if (text == this.getOriginalText() || text === '') {
return; return;
} }
// Save the text so we can 'undo' back to it. // Save the text so we can 'undo' back to it.
this._undoText = text; this._undoText = text;
var template = this.getOnRight() var templates = this.getTemplates();
? this.getTemplates().r var template = this.getOnRight() ? templates.r : templates.l;
: this.getTemplates().l;
template = JX.$N('div', JX.$H(template)); template = JX.$N('div', JX.$H(template));
// NOTE: Operation order matters here; we can't remove anything until // NOTE: Operation order matters here; we can't remove anything until

View file

@ -1,7 +1,7 @@
/** /**
* @provides javelin-behavior-differential-comment-jump * @provides javelin-behavior-differential-comment-jump
* @requires javelin-behavior * @requires javelin-behavior
* javelin-util * javelin-stratcom
* javelin-dom * javelin-dom
*/ */
@ -20,7 +20,7 @@ JX.behavior('differential-comment-jump', function(config) {
} }
} }
JX.Stratcom.invoke('differential-toggle-file-request', null, { JX.Stratcom.invoke('differential-toggle-file-request', null, {
element: jumpto, element: jumpto
}); });
JX.DOM.scrollTo(jumpto); JX.DOM.scrollTo(jumpto);
e.kill(); e.kill();

View file

@ -13,7 +13,8 @@ JX.behavior('differential-feedback-preview', function(config) {
var action = JX.$(config.action); var action = JX.$(config.action);
var content = JX.$(config.content); var content = JX.$(config.content);
var previewTokenizers = {}; var previewTokenizers = {};
for (var field in config.previewTokenizers) { var field;
for (field in config.previewTokenizers) {
var tokenizer = JX.$(config.previewTokenizers[field]); var tokenizer = JX.$(config.previewTokenizers[field]);
previewTokenizers[field] = JX.Stratcom.getData(tokenizer).tokenizer; previewTokenizers[field] = JX.Stratcom.getData(tokenizer).tokenizer;
} }
@ -46,7 +47,7 @@ JX.behavior('differential-feedback-preview', function(config) {
JX.DOM.listen(content, 'keydown', null, trigger); JX.DOM.listen(content, 'keydown', null, trigger);
JX.DOM.listen(action, 'change', null, trigger); JX.DOM.listen(action, 'change', null, trigger);
for (var field in previewTokenizers) { for (field in previewTokenizers) {
previewTokenizers[field].listen('change', trigger); previewTokenizers[field].listen('change', trigger);
} }

View file

@ -57,7 +57,7 @@ JX.behavior('differential-dropdown-menus', function(config) {
var visible_item = new JX.PhabricatorMenuItem('', function () { var visible_item = new JX.PhabricatorMenuItem('', function () {
JX.Stratcom.invoke('differential-toggle-file', null, { JX.Stratcom.invoke('differential-toggle-file', null, {
diff: JX.DOM.scry(JX.$(data.containerID), 'table', 'differential-diff'), diff: JX.DOM.scry(JX.$(data.containerID), 'table', 'differential-diff')
}); });
}); });
menu.addItem(visible_item); menu.addItem(visible_item);

View file

@ -197,7 +197,7 @@ JX.behavior('differential-edit-inline-comments', function(config) {
var node = e.getNode('differential-inline-comment'); var node = e.getNode('differential-inline-comment');
handle_inline_action(node, op); handle_inline_action(node, op);
} };
var handle_inline_action = function(node, op) { var handle_inline_action = function(node, op) {
var data = JX.Stratcom.getData(node); var data = JX.Stratcom.getData(node);
@ -243,7 +243,7 @@ JX.behavior('differential-edit-inline-comments', function(config) {
.start(); .start();
set_link_state(true); set_link_state(true);
} };
for (var op in {'edit' : 1, 'delete' : 1, 'reply' : 1}) { for (var op in {'edit' : 1, 'delete' : 1, 'reply' : 1}) {
JX.Stratcom.listen( JX.Stratcom.listen(

View file

@ -130,9 +130,12 @@ JX.behavior('differential-keyboard-navigation', function(config) {
selection_end = blocks[focus][1]; selection_end = blocks[focus][1];
manager.scrollTo(selection_begin); manager.scrollTo(selection_begin);
(refreshFocus = function() {
refreshFocus = function() {
manager.focusOn(selection_begin, selection_end); manager.focusOn(selection_begin, selection_end);
})(); };
refreshFocus();
return; return;
} else { } else {

View file

@ -97,7 +97,7 @@ JX.behavior('differential-populate', function(config) {
var diff; var diff;
try { try {
diff = JX.$(meta.id); diff = JX.$(meta.id);
} catch (e) { } catch (ex) {
// Already loaded. // Already loaded.
} }
if (diff) { if (diff) {

View file

@ -42,7 +42,7 @@ JX.behavior('differential-show-all-comments', function(config) {
try { try {
var target = JX.$(window.location.hash.replace(/^#/, '')); var target = JX.$(window.location.hash.replace(/^#/, ''));
window.scrollTo(0, target.offsetTop); window.scrollTo(0, target.offsetTop);
} catch (e) { } catch (ex) {
} }
} }
}); });

View file

@ -21,7 +21,7 @@ JX.behavior('audit-preview', function(config) {
action: action.value, action: action.value,
content: content.value content: content.value
}; };
} };
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
var trigger = JX.bind(request, request.trigger); var trigger = JX.bind(request, request.trigger);

View file

@ -20,7 +20,7 @@ JX.behavior('diffusion-commit-graph', function(config) {
'#00cccc', '#00cccc',
'#00cc33', '#00cc33',
'#66cc00', '#66cc00',
'#cc9900', '#cc9900'
]; ];
return colors[c % colors.length]; return colors[c % colors.length];
} }
@ -48,9 +48,9 @@ JX.behavior('diffusion-commit-graph', function(config) {
var data = JX.Stratcom.getData(nodes[ii]); var data = JX.Stratcom.getData(nodes[ii]);
var cell = 12; // Width of each thread. var cell = 12; // Width of each thread.
function xpos(col) { var xpos = function(col) {
return (col * cell) + (cell / 2); return (col * cell) + (cell / 2);
} };
var h = 26; var h = 26;
var w = cell * config.count; var w = cell * config.count;
@ -71,8 +71,11 @@ JX.behavior('diffusion-commit-graph', function(config) {
// a parent). We use this to figure out where to draw the join/split lines. // a parent). We use this to figure out where to draw the join/split lines.
var origin = null; var origin = null;
for (var jj = 0; jj < data.line.length; jj++) { var jj;
var c = data.line.charAt(jj); var x;
var c;
for (jj = 0; jj < data.line.length; jj++) {
c = data.line.charAt(jj);
switch (c) { switch (c) {
case 'o': case 'o':
case '^': case '^':
@ -84,9 +87,9 @@ JX.behavior('diffusion-commit-graph', function(config) {
// Draw all the join lines. These start at some column at the top of the // Draw all the join lines. These start at some column at the top of the
// canvas and join the commit's column. They indicate branching. // canvas and join the commit's column. They indicate branching.
for (var jj = 0; jj < data.join.length; jj++) { for (jj = 0; jj < data.join.length; jj++) {
var join = data.join[jj]; var join = data.join[jj];
var x = xpos(join); x = xpos(join);
cxt.beginPath(); cxt.beginPath();
cxt.moveTo(x, 0); cxt.moveTo(x, 0);
cxt.bezierCurveTo(x, h/4, origin, h/4, origin, h/2); cxt.bezierCurveTo(x, h/4, origin, h/4, origin, h/2);
@ -96,9 +99,9 @@ JX.behavior('diffusion-commit-graph', function(config) {
// Draw all the split lines. These start at the commit and end at some // Draw all the split lines. These start at the commit and end at some
// column on the bottom of the canvas. They indicate merging. // column on the bottom of the canvas. They indicate merging.
for (var jj = 0; jj < data.split.length; jj++) { for (jj = 0; jj < data.split.length; jj++) {
var split = data.split[jj]; var split = data.split[jj];
var x = xpos(split); x = xpos(split);
cxt.beginPath(); cxt.beginPath();
cxt.moveTo(origin, h/2); cxt.moveTo(origin, h/2);
cxt.bezierCurveTo(origin, 3*h/4, x, 3*h/4, x, h); cxt.bezierCurveTo(origin, 3*h/4, x, 3*h/4, x, h);
@ -108,13 +111,16 @@ JX.behavior('diffusion-commit-graph', function(config) {
// Draw the vertical lines (a branch with no activity at this commit) and // Draw the vertical lines (a branch with no activity at this commit) and
// the commit circles. // the commit circles.
for (var jj = 0; jj < data.line.length; jj++) { for (jj = 0; jj < data.line.length; jj++) {
var c = data.line.charAt(jj); c = data.line.charAt(jj);
switch (c) { switch (c) {
case 'o': case 'o':
case '^': case '^':
origin = xpos(jj);
case '|': case '|':
if (c == 'o' || c == '^') {
origin = xpos(jj);
}
cxt.beginPath(); cxt.beginPath();
cxt.moveTo(xpos(jj), (c == '^' ? h/2 : 0)); cxt.moveTo(xpos(jj), (c == '^' ? h/2 : 0));
cxt.lineTo(xpos(jj), h); cxt.lineTo(xpos(jj), h);

View file

@ -1,7 +1,6 @@
/** /**
* @provides javelin-behavior-diffusion-jump-to * @provides javelin-behavior-diffusion-jump-to
* @requires javelin-behavior * @requires javelin-behavior
* javelin-util
* javelin-vector * javelin-vector
* javelin-dom * javelin-dom
*/ */

View file

@ -79,7 +79,7 @@ JX.behavior('maniphest-batch-editor', function(config) {
vfunc = function() { return status_select.value; }; vfunc = function() { return status_select.value; };
break; break;
} }
}; }
JX.DOM.listen(action_select, 'change', null, update); JX.DOM.listen(action_select, 'change', null, update);
update(); update();

View file

@ -14,11 +14,11 @@ JX.behavior('maniphest-batch-selector', function(config) {
var get_id = function(task) { var get_id = function(task) {
return JX.Stratcom.getData(task).taskID; return JX.Stratcom.getData(task).taskID;
} };
var is_selected = function(task) { var is_selected = function(task) {
return (get_id(task) in selected); return (get_id(task) in selected);
} };
// Change the selected state of a task. // Change the selected state of a task.
@ -50,7 +50,7 @@ JX.behavior('maniphest-batch-selector', function(config) {
for (var ii = 0; ii < inputs.length; ii++) { for (var ii = 0; ii < inputs.length; ii++) {
change(inputs[ii], to); change(inputs[ii], to);
} }
} };
// Clear any document text selection after toggling a task via shift click, // Clear any document text selection after toggling a task via shift click,
// since errant clicks tend to start selecting various ranges otherwise. // since errant clicks tend to start selecting various ranges otherwise.
@ -65,7 +65,7 @@ JX.behavior('maniphest-batch-selector', function(config) {
} else if (document.selection) { } else if (document.selection) {
document.selection.empty(); document.selection.empty();
} }
} };
// Update the status text showing how many tasks are selected, and the button // Update the status text showing how many tasks are selected, and the button
// state. // state.
@ -73,7 +73,7 @@ JX.behavior('maniphest-batch-selector', function(config) {
var update = function() { var update = function() {
var count = JX.keys(selected).length; var count = JX.keys(selected).length;
var status; var status;
if (count == 0) { if (count === 0) {
status = 'Shift-Click to Select Tasks'; status = 'Shift-Click to Select Tasks';
} else if (status == 1) { } else if (status == 1) {
status = '1 Selected Task'; status = '1 Selected Task';
@ -83,7 +83,7 @@ JX.behavior('maniphest-batch-selector', function(config) {
JX.DOM.setContent(JX.$(config.status), status); JX.DOM.setContent(JX.$(config.status), status);
var submit = JX.$(config.submit); var submit = JX.$(config.submit);
var disable = (count == 0); var disable = (count === 0);
submit.disabled = disable; submit.disabled = disable;
JX.DOM.alterClass(submit, 'disabled', disable); JX.DOM.alterClass(submit, 'disabled', disable);
}; };

View file

@ -19,7 +19,7 @@ JX.behavior('maniphest-description-preview', function(config) {
return { return {
description : textarea.value description : textarea.value
}; };
} };
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
var trigger = JX.bind(request, request.trigger); var trigger = JX.bind(request, request.trigger);

View file

@ -12,7 +12,7 @@ JX.behavior('maniphest-transaction-controls', function(config) {
for (var k in config.tokenizers) { for (var k in config.tokenizers) {
var tconfig = config.tokenizers[k]; var tconfig = config.tokenizers[k];
tokenizers[k] = JX.Prefab.buildTokenizer(tconfig).tokenizer; tokenizers[k] = JX.Prefab.buildTokenizer(tconfig).tokenizer;
tokenizers[k].start() tokenizers[k].start();
} }
JX.DOM.listen( JX.DOM.listen(

View file

@ -48,7 +48,7 @@ JX.behavior('maniphest-transaction-preview', function(config) {
action : selected, action : selected,
value : value || '' value : value || ''
}; };
} };
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
var trigger = JX.bind(request, request.trigger); var trigger = JX.bind(request, request.trigger);

View file

@ -18,9 +18,9 @@ JX.behavior('phame-post-preview', function(config) {
if (!sync_titles) { if (!sync_titles) {
return; return;
} }
var title_string = new String(title.value); var title_string = title.value;
phame_title.value = normalizeSlug(title_string); phame_title.value = normalizeSlug(title_string);
} };
var phameTitleKeyupCallback = function (e) { var phameTitleKeyupCallback = function (e) {
// stop sync'ing once user edits phame_title directly // stop sync'ing once user edits phame_title directly
@ -38,11 +38,11 @@ JX.behavior('phame-post-preview', function(config) {
phame_title.focus(); phame_title.focus();
phame_title.setSelectionRange(position, position); phame_title.setSelectionRange(position, position);
} }
} };
var phameTitleBlurCallback = function (e) { var phameTitleBlurCallback = function (e) {
phame_title.value = normalizeSlug(phame_title.value); phame_title.value = normalizeSlug(phame_title.value);
} };
// This is a sort of implementation of PhabricatorSlug::normalize // This is a sort of implementation of PhabricatorSlug::normalize
var normalizeSlug = function (slug, spare_trailing_underscore) { var normalizeSlug = function (slug, spare_trailing_underscore) {
@ -53,7 +53,7 @@ JX.behavior('phame-post-preview', function(config) {
s = s.replace(/_$/g, ''); s = s.replace(/_$/g, '');
} }
return s; return s;
} };
var callback = function(r) { var callback = function(r) {
JX.DOM.setContent(JX.$(config.preview), JX.$H(r)); JX.DOM.setContent(JX.$(config.preview), JX.$H(r));
@ -65,7 +65,7 @@ JX.behavior('phame-post-preview', function(config) {
title : title.value, title : title.value,
phame_title : phame_title.value phame_title : phame_title.value
}; };
} };
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
var trigger = JX.bind(request, request.trigger); var trigger = JX.bind(request, request.trigger);

View file

@ -76,10 +76,11 @@ JX.behavior('pholio-mock-view', function(config) {
} }
function clear_stage() { function clear_stage() {
for (var ii = 0; ii < reticles.length; ii++) { var ii;
for (ii = 0; ii < reticles.length; ii++) {
JX.DOM.remove(reticles[ii]); JX.DOM.remove(reticles[ii]);
} }
for (var ii = 0; ii < cards.length; ii++) { for (ii = 0; ii < cards.length; ii++) {
JX.DOM.remove(cards[ii]); JX.DOM.remove(cards[ii]);
} }
reticles = []; reticles = [];
@ -160,7 +161,7 @@ JX.behavior('pholio-mock-view', function(config) {
if (!active_image) { if (!active_image) {
return; return;
} }
var idx = get_image_index(active_image.id) var idx = get_image_index(active_image.id);
idx = (idx + delta + config.images.length) % config.images.length; idx = (idx + delta + config.images.length) % config.images.length;
select_image(config.images[idx].id); select_image(config.images[idx].id);
} }
@ -324,7 +325,7 @@ JX.behavior('pholio-mock-view', function(config) {
).setPos(dialog); ).setPos(dialog);
JX.DOM.focus(JX.DOM.find(dialog, 'textarea')); JX.DOM.focus(JX.DOM.find(dialog, 'textarea'));
} };
new JX.Workflow('/pholio/inline/save/', data) new JX.Workflow('/pholio/inline/save/', data)
.setHandler(handler) .setHandler(handler)
@ -343,14 +344,15 @@ JX.behavior('pholio-mock-view', function(config) {
var width = end.x - start.x; var width = end.x - start.x;
var height = end.y - start.y; var height = end.y - start.y;
var addon;
if (width < min_size) { if (width < min_size) {
var addon = (min_size-width)/2; addon = (min_size-width)/2;
start.x = Math.max(0, start.x - addon); start.x = Math.max(0, start.x - addon);
end.x = Math.min(active_image.tag.naturalWidth, end.x + addon); end.x = Math.min(active_image.tag.naturalWidth, end.x + addon);
if (start.x == 0) { if (start.x === 0) {
end.x = Math.min(min_size, active_image.tag.naturalWidth); end.x = Math.min(min_size, active_image.tag.naturalWidth);
} else if (end.x == active_image.tag.naturalWidth) { } else if (end.x == active_image.tag.naturalWidth) {
start.x = Math.max(0, active_image.tag.naturalWidth - min_size); start.x = Math.max(0, active_image.tag.naturalWidth - min_size);
@ -358,12 +360,12 @@ JX.behavior('pholio-mock-view', function(config) {
} }
if (height < min_size) { if (height < min_size) {
var addon = (min_size-height)/2; addon = (min_size-height)/2;
start.y = Math.max(0, start.y - addon); start.y = Math.max(0, start.y - addon);
end.y = Math.min(active_image.tag.naturalHeight, end.y + addon); end.y = Math.min(active_image.tag.naturalHeight, end.y + addon);
if (start.y == 0) { if (start.y === 0) {
end.y = Math.min(min_size, active_image.tag.naturalHeight); end.y = Math.min(min_size, active_image.tag.naturalHeight);
} else if (end.y == active_image.tag.naturalHeight) { } else if (end.y == active_image.tag.naturalHeight) {
start.y = Math.max(0, active_image.tag.naturalHeight - min_size); start.y = Math.max(0, active_image.tag.naturalHeight - min_size);

View file

@ -19,7 +19,7 @@ JX.behavior('phriction-document-preview', function(config) {
return { return {
document : textarea.value document : textarea.value
}; };
} };
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
var trigger = JX.bind(request, request.trigger); var trigger = JX.bind(request, request.trigger);

View file

@ -28,7 +28,7 @@ JX.behavior('ponder-votebox', function(config) {
JX.DOM.alterClass(upv, 'ponder-vote-active', (data.vote > 0)); JX.DOM.alterClass(upv, 'ponder-vote-active', (data.vote > 0));
var downv = JX.DOM.find(root, 'a', 'downvote'); var downv = JX.DOM.find(root, 'a', 'downvote');
JX.DOM.alterClass(downv, 'ponder-vote-active', (data.vote < 0)) JX.DOM.alterClass(downv, 'ponder-vote-active', (data.vote < 0));
JX.DOM.setContent( JX.DOM.setContent(
JX.DOM.find(root, 'div', 'ponder-vote-count'), JX.DOM.find(root, 'div', 'ponder-vote-count'),
@ -36,7 +36,7 @@ JX.behavior('ponder-votebox', function(config) {
new JX.Request(e.getTarget().href, JX.bag) new JX.Request(e.getTarget().href, JX.bag)
.setData({vote: data.vote}) .setData({vote: data.vote})
.send() .send();
} }
JX.Stratcom.listen( JX.Stratcom.listen(

View file

@ -2,15 +2,14 @@
* @provides javelin-behavior-releeph-preview-branch * @provides javelin-behavior-releeph-preview-branch
* @requires javelin-behavior * @requires javelin-behavior
* javelin-dom * javelin-dom
* javelin-stratcom
* javelin-uri * javelin-uri
* javelin-util * javelin-request
*/ */
JX.behavior('releeph-preview-branch', function(config) { JX.behavior('releeph-preview-branch', function(config) {
var uri = JX.$U(config.uri); var uri = JX.$U(config.uri);
for (param_name in config.params.static) { for (var param_name in config.params.static) {
var value = config.params.static[param_name]; var value = config.params.static[param_name];
uri.setQueryParam(param_name, value); uri.setQueryParam(param_name, value);
} }
@ -20,7 +19,7 @@ JX.behavior('releeph-preview-branch', function(config) {
var dynamics = config.params.dynamic; var dynamics = config.params.dynamic;
function renderPreview() { function renderPreview() {
for (param_name in dynamics) { for (var param_name in dynamics) {
var node_id = dynamics[param_name]; var node_id = dynamics[param_name];
var input = JX.$(node_id); var input = JX.$(node_id);
uri.setQueryParam(param_name, input.value); uri.setQueryParam(param_name, input.value);
@ -33,7 +32,7 @@ JX.behavior('releeph-preview-branch', function(config) {
renderPreview(); renderPreview();
for (ii in dynamics) { for (var ii in dynamics) {
var node_id = dynamics[ii]; var node_id = dynamics[ii];
var input = JX.$(node_id); var input = JX.$(node_id);
JX.DOM.listen( JX.DOM.listen(

View file

@ -3,7 +3,7 @@
* @requires javelin-behavior * @requires javelin-behavior
* javelin-dom * javelin-dom
* javelin-stratcom * javelin-stratcom
* javelin-util * javelin-request
* phabricator-keyboard-shortcut * phabricator-keyboard-shortcut
* phabricator-notification * phabricator-notification
*/ */
@ -45,8 +45,8 @@ JX.behavior('releeph-request-state-change', function(config) {
function keynavMarkup() { function keynavMarkup() {
var headers = getRequestHeaderNodes(); var headers = getRequestHeaderNodes();
for (ii in headers) { for (var k in headers) {
JX.DOM.alterClass(headers[ii], 'focus', ii == keynav_cursor); JX.DOM.alterClass(headers[k], 'focus', k == keynav_cursor);
} }
} }

View file

@ -1,15 +1,10 @@
/** /**
* @provides javelin-behavior-releeph-request-typeahead * @provides javelin-behavior-releeph-request-typeahead
* @requires javelin-behavior * @requires javelin-behavior
* javelin-util
* javelin-dom * javelin-dom
* javelin-typeahead * javelin-typeahead
* javelin-tokenizer
* javelin-typeahead-preloaded-source
* javelin-typeahead-ondemand-source * javelin-typeahead-ondemand-source
* javelin-dom * javelin-dom
* javelin-stratcom
* javelin-util
*/ */
JX.behavior('releeph-request-typeahead', function(config) { JX.behavior('releeph-request-typeahead', function(config) {
@ -48,7 +43,7 @@ JX.behavior('releeph-request-typeahead', function(config) {
'div', 'div',
{ className: 'summary' }, { className: 'summary' },
summary summary
), )
] ]
); );

View file

@ -1,7 +1,7 @@
/** /**
* @provides javelin-behavior-slowvote-embed * @provides javelin-behavior-slowvote-embed
* @requires javelin-behavior * @requires javelin-behavior
* javelin-util * javelin-request
* javelin-stratcom * javelin-stratcom
* javelin-dom * javelin-dom
*/ */

View file

@ -36,7 +36,7 @@ JX.behavior('phabricator-transaction-comment-form', function(config) {
[ [
JX.$H(response.spacer), JX.$H(response.spacer),
JX.$H(response.xactions.join(response.spacer)), JX.$H(response.xactions.join(response.spacer)),
JX.$H(response.spacer), JX.$H(response.spacer)
]); ]);
JX.DOM.show(panel); JX.DOM.show(panel);
} }

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-javelin-view * @provides phabricator-uiexample-javelin-view
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
*/ */

View file

@ -1,9 +1,9 @@
/** /**
* @provides phabricator-uiexample-reactor-button * @provides phabricator-uiexample-reactor-button
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-util
* javelin-dynval
* javelin-reactor-dom * javelin-reactor-dom
*/ */

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-checkbox * @provides phabricator-uiexample-reactor-checkbox
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
*/ */

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-focus * @provides phabricator-uiexample-reactor-focus
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
*/ */

View file

@ -1,9 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-input * @provides phabricator-uiexample-reactor-input
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
* javelin-view-html * javelin-view-html
* javelin-view-interpreter * javelin-view-interpreter

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-mouseover * @provides phabricator-uiexample-reactor-mouseover
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
*/ */

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-radio * @provides phabricator-uiexample-reactor-radio
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
*/ */

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-select * @provides phabricator-uiexample-reactor-select
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
*/ */
@ -14,7 +12,7 @@ JX.install('ReactorSelectExample', {
var select = JX.$N('select', {}, [ var select = JX.$N('select', {}, [
JX.$N('option', { value: 'goat' }, 'Goat'), JX.$N('option', { value: 'goat' }, 'Goat'),
JX.$N('option', { value: 'bat' }, 'Bat'), JX.$N('option', { value: 'bat' }, 'Bat'),
JX.$N('option', { value: 'duck' }, 'Duck'), JX.$N('option', { value: 'duck' }, 'Duck')
]); ]);
return [select, JX.RDOM.$DT(JX.RDOM.select(select))]; return [select, JX.RDOM.$DT(JX.RDOM.select(select))];

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-sendclass * @provides phabricator-uiexample-reactor-sendclass
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
*/ */

View file

@ -1,8 +1,6 @@
/** /**
* @provides phabricator-uiexample-reactor-sendproperties * @provides phabricator-uiexample-reactor-sendproperties
* @requires javelin-install * @requires javelin-install
* javelin-view
* javelin-util
* javelin-dom * javelin-dom
* javelin-reactor-dom * javelin-reactor-dom
*/ */

View file

@ -62,8 +62,10 @@ JX.behavior('phabricator-gesture-example', function(config) {
cxt.fillStyle = '#dfdfdf'; cxt.fillStyle = '#dfdfdf';
cxt.fillRect(0, 0, d.x, d.y); cxt.fillRect(0, 0, d.x, d.y);
for (var ii = 0; ii < strokes.length; ii++) { var s;
var s = strokes[ii]; var ii;
for (ii = 0; ii < strokes.length; ii++) {
s = strokes[ii];
cxt.strokeStyle = 'rgba(0, 0, 0, 0.50)'; cxt.strokeStyle = 'rgba(0, 0, 0, 0.50)';
cxt.beginPath(); cxt.beginPath();
cxt.moveTo(s[0], s[1]); cxt.moveTo(s[0], s[1]);
@ -71,8 +73,8 @@ JX.behavior('phabricator-gesture-example', function(config) {
cxt.stroke(); cxt.stroke();
} }
for (var ii = 0; ii < current.length; ii++) { for (ii = 0; ii < current.length; ii++) {
var s = current[ii]; s = current[ii];
cxt.strokeStyle = 'rgba(255, 0, 0, 1)'; cxt.strokeStyle = 'rgba(255, 0, 0, 1)';
cxt.beginPath(); cxt.beginPath();
cxt.moveTo(s[0], s[1]); cxt.moveTo(s[0], s[1]);

View file

@ -2,7 +2,6 @@
* @requires phabricator-notification * @requires phabricator-notification
* javelin-stratcom * javelin-stratcom
* javelin-behavior * javelin-behavior
* javelin-uri
* @provides javelin-behavior-phabricator-notification-example * @provides javelin-behavior-phabricator-notification-example
*/ */

View file

@ -41,13 +41,13 @@ JX.install('PhabricatorDragAndDropFileUpload', {
_node : null, _node : null,
_depth : 0, _depth : 0,
_updateDepth : function(delta) { _updateDepth : function(delta) {
if (this._depth == 0 && delta > 0) { if (this._depth === 0 && delta > 0) {
this.invoke('didBeginDrag'); this.invoke('didBeginDrag');
} }
this._depth += delta; this._depth += delta;
if (this._depth == 0 && delta < 0) { if (this._depth === 0 && delta < 0) {
this.invoke('didEndDrag'); this.invoke('didEndDrag');
} }
}, },

View file

@ -36,11 +36,12 @@ JX.install('PhabricatorFileUpload', {
.setDuration(0) .setDuration(0)
.show(); .show();
var content;
switch (this.getStatus()) { switch (this.getStatus()) {
case 'done': case 'done':
var link = JX.$N('a', {href: this.getURI()}, 'F' + this.getID()); var link = JX.$N('a', {href: this.getURI()}, 'F' + this.getID());
var content = [ content = [
JX.$N('strong', {}, ['Upload Complete (', link, ')']), JX.$N('strong', {}, ['Upload Complete (', link, ')']),
JX.$N('br'), JX.$N('br'),
this.getName() this.getName()
@ -53,7 +54,7 @@ JX.install('PhabricatorFileUpload', {
this._notification = null; this._notification = null;
break; break;
case 'error': case 'error':
var content = [ content = [
JX.$N('strong', {}, 'Upload Failure'), JX.$N('strong', {}, 'Upload Failure'),
JX.$N('br'), JX.$N('br'),
this.getName(), this.getName(),
@ -89,7 +90,7 @@ JX.install('PhabricatorFileUpload', {
return null; return null;
} }
var ratio = this.getUploadedBytes() / this.getTotalBytes(); var ratio = this.getUploadedBytes() / this.getTotalBytes();
return parseInt(100 * ratio) + '%'; return parseInt(100 * ratio, 10) + '%';
}, },
_renderFileSize : function() { _renderFileSize : function() {
if (!this.getTotalBytes()) { if (!this.getTotalBytes()) {

View file

@ -86,12 +86,12 @@ JX.install('Hovercard', {
// TODO: Fix southern graceful align // TODO: Fix southern graceful align
var margin = 20; var margin = 20;
// We can't shift left by ~$margin or more here due to Pholio, Phriction // We can't shift left by ~$margin or more here due to Pholio, Phriction
var x = parseInt(p.x) - margin / 2; var x = parseInt(p.x, 10) - margin / 2;
var y = parseInt(p.y - n.y) - margin; var y = parseInt(p.y - n.y, 10) - margin;
// If more in the center, we can safely center // If more in the center, we can safely center
if (x > (n.x / 2) + margin) { if (x > (n.x / 2) + margin) {
x = parseInt(p.x - (n.x / 2) + d.x); x = parseInt(p.x - (n.x / 2) + d.x, 10);
} }
// Temporarily disabled, since it gives weird results (you can only see // Temporarily disabled, since it gives weird results (you can only see

View file

@ -46,8 +46,10 @@ JX.install('Prefab', {
* *
*/ */
buildTokenizer : function(config) { buildTokenizer : function(config) {
var root;
try { try {
var root = config.root || JX.$(config.id); root = config.root || JX.$(config.id);
} catch (ex) { } catch (ex) {
// If the root element does not exist, just return without building // If the root element does not exist, just return without building
// anything. This happens in some cases -- like Conpherence -- where we // anything. This happens in some cases -- like Conpherence -- where we

View file

@ -54,20 +54,20 @@ JX.install('Tooltip', {
switch (align) { switch (align) {
case 'N': case 'N':
node.style.left = parseInt(p.x - ((n.x - d.x) / 2)) + 'px'; node.style.left = parseInt(p.x - ((n.x - d.x) / 2), 10) + 'px';
node.style.top = parseInt(p.y - n.y) + 'px'; node.style.top = parseInt(p.y - n.y, 10) + 'px';
break; break;
case 'E': case 'E':
node.style.left = parseInt(p.x + d.x) + 'px'; node.style.left = parseInt(p.x + d.x, 10) + 'px';
node.style.top = parseInt(p.y - ((n.y - d.y) / 2)) + 'px'; node.style.top = parseInt(p.y - ((n.y - d.y) / 2), 10) + 'px';
break; break;
case 'S': case 'S':
node.style.left = parseInt(p.x - ((n.x - d.x) / 2)) + 'px'; node.style.left = parseInt(p.x - ((n.x - d.x) / 2), 10) + 'px';
node.style.top = parseInt(p.y + d.y + 5) + 'px'; node.style.top = parseInt(p.y + d.y + 5, 10) + 'px';
break; break;
case 'W': case 'W':
node.style.left = parseInt(p.x - n.x - 5) + 'px'; node.style.left = parseInt(p.x - n.x - 5, 10) + 'px';
node.style.top = parseInt(p.y - ((n.y - d.y) / 2)) + 'px'; node.style.top = parseInt(p.y - ((n.y - d.y) / 2), 10) + 'px';
break; break;
} }
}, },

View file

@ -29,7 +29,7 @@ JX.behavior('phabricator-active-nav', function(config) {
'phabricator-active-nav-focus', 'phabricator-active-nav-focus',
selected); selected);
} }
} };
/** /**
@ -49,7 +49,8 @@ JX.behavior('phabricator-active-nav', function(config) {
// Sort the markers by Y position, descending. // Sort the markers by Y position, descending.
var markinfo = []; var markinfo = [];
for (var ii = 0; ii < markers.length; ii++) { var ii;
for (ii = 0; ii < markers.length; ii++) {
markinfo.push({ markinfo.push({
marker: markers[ii], marker: markers[ii],
position: JX.$V(markers[ii]).y - 15 position: JX.$V(markers[ii]).y - 15
@ -60,7 +61,7 @@ JX.behavior('phabricator-active-nav', function(config) {
// Find the first marker above the current scroll position, or the first // Find the first marker above the current scroll position, or the first
// marker in the document if we're above all the markers. // marker in the document if we're above all the markers.
var active = null; var active = null;
for (var ii = 0; ii < markinfo.length; ii++) { for (ii = 0; ii < markinfo.length; ii++) {
active = markinfo[ii].marker; active = markinfo[ii].marker;
if (markinfo[ii].position <= scroll_position) { if (markinfo[ii].position <= scroll_position) {
break; break;
@ -72,13 +73,13 @@ JX.behavior('phabricator-active-nav', function(config) {
// If we get above the first marker, select it. // If we get above the first marker, select it.
selectnav(active && JX.Stratcom.getData(active).anchor); selectnav(active && JX.Stratcom.getData(active).anchor);
} };
var pending = null; var pending = null;
var onviewportchange = function(e) { var onviewportchange = function(e) {
pending && clearTimeout(pending); pending && clearTimeout(pending);
pending = setTimeout(updateposition, 100); pending = setTimeout(updateposition, 100);
} };
JX.Stratcom.listen('scroll', null, onviewportchange); JX.Stratcom.listen('scroll', null, onviewportchange);
JX.Stratcom.listen('resize', null, onviewportchange); JX.Stratcom.listen('resize', null, onviewportchange);

View file

@ -76,7 +76,7 @@ JX.behavior('fancy-datepicker', function(config) {
m: JX.DOM.find(root, 'select', 'month-input'), m: JX.DOM.find(root, 'select', 'month-input'),
d: JX.DOM.find(root, 'select', 'day-input') d: JX.DOM.find(root, 'select', 'day-input')
}; };
} };
var read_date = function() { var read_date = function() {
var i = get_inputs(); var i = get_inputs();
@ -97,7 +97,7 @@ JX.behavior('fancy-datepicker', function(config) {
picker.firstChild, picker.firstChild,
[ [
render_month(), render_month(),
render_day(), render_day()
]); ]);
}; };
@ -114,7 +114,7 @@ JX.behavior('fancy-datepicker', function(config) {
} }
return JX.$N('td', {meta: {value: value}, className: class_name}, label); return JX.$N('td', {meta: {value: value}, className: class_name}, label);
} };
// Render the top bar which allows you to pick a month and year. // Render the top bar which allows you to pick a month and year.
@ -152,7 +152,8 @@ JX.behavior('fancy-datepicker', function(config) {
// First, render the weekday names. // First, render the weekday names.
var weekdays = 'SMTWTFS'; var weekdays = 'SMTWTFS';
var weekday_names = []; var weekday_names = [];
for (var ii = 0; ii < weekdays.length; ii++) { var ii;
for (ii = 0; ii < weekdays.length; ii++) {
weekday_names.push(cell(weekdays.charAt(ii), null, false, 'day-name')); weekday_names.push(cell(weekdays.charAt(ii), null, false, 'day-name'));
} }
weeks.push(JX.$N('tr', {}, weekday_names)); weeks.push(JX.$N('tr', {}, weekday_names));
@ -168,7 +169,7 @@ JX.behavior('fancy-datepicker', function(config) {
var today = new Date(); var today = new Date();
for (var ii = 1; ii <= 31; ii++) { for (ii = 1; ii <= 31; ii++) {
var date = new Date(value_y, value_m - 1, ii); var date = new Date(value_y, value_m - 1, ii);
if (date.getMonth() != (value_m - 1)) { if (date.getMonth() != (value_m - 1)) {
// We've spilled over into the next month, so stop rendering. // We've spilled over into the next month, so stop rendering.
@ -183,7 +184,7 @@ JX.behavior('fancy-datepicker', function(config) {
if (is_today) { if (is_today) {
classes.push('today'); classes.push('today');
} }
if (date.getDay() == 0 || date.getDay() == 6) { if (date.getDay() === 0 || date.getDay() == 6) {
classes.push('weekend'); classes.push('weekend');
} }
@ -191,7 +192,7 @@ JX.behavior('fancy-datepicker', function(config) {
} }
// Slice the days into weeks. // Slice the days into weeks.
for (var ii = 0; ii < days.length; ii += 7) { for (ii = 0; ii < days.length; ii += 7) {
weeks.push(JX.$N('tr', {}, days.slice(ii, ii + 7))); weeks.push(JX.$N('tr', {}, days.slice(ii, ii + 7)));
} }
@ -216,7 +217,7 @@ JX.behavior('fancy-datepicker', function(config) {
switch (p[0]) { switch (p[0]) {
case 'm': case 'm':
// User clicked left or right month selection buttons. // User clicked left or right month selection buttons.
value_m = value_m + parseInt(p[1]); value_m = value_m + parseInt(p[1], 10);
if (value_m > 12) { if (value_m > 12) {
value_m -= 12; value_m -= 12;
value_y++; value_y++;
@ -227,7 +228,7 @@ JX.behavior('fancy-datepicker', function(config) {
break; break;
case 'd': case 'd':
// User clicked a day. // User clicked a day.
value_d = parseInt(p[1]); value_d = parseInt(p[1], 10);
write_date(); write_date();
// Wait a moment to close the selector so they can see the effect // Wait a moment to close the selector so they can see the effect

View file

@ -41,7 +41,7 @@ JX.behavior('global-drag-and-drop', function(config) {
files.push(f); files.push(f);
pending--; pending--;
if (pending == 0 && !errors) { if (pending === 0 && !errors) {
// If whatever the user dropped in has finished uploading, send them to // If whatever the user dropped in has finished uploading, send them to
// their uploads. // their uploads.
var uri; var uri;

View file

@ -13,7 +13,7 @@ JX.behavior('phabricator-hovercards', function(config) {
// We listen for mousemove instead of mouseover to handle the case when user // We listen for mousemove instead of mouseover to handle the case when user
// scrolls with keyboard. We don't want to display hovercard if node gets // scrolls with keyboard. We don't want to display hovercard if node gets
// under the mouse cursor randomly placed somewhere on the screen. This // under the mouse cursor randomly placed somewhere on the screen. This
// unfortunatelly doesn't work in Google Chrome which triggers both mousemove // unfortunately doesn't work in Google Chrome which triggers both mousemove
// and mouseover in this case but works in other browsers. // and mouseover in this case but works in other browsers.
JX.Stratcom.listen( JX.Stratcom.listen(
'mousemove', 'mousemove',

View file

@ -157,7 +157,7 @@ JX.behavior('lightbox-attachments', function (config) {
img.onload = function() { img.onload = function() {
JX.DOM.alterClass(img, 'loading', false); JX.DOM.alterClass(img, 'loading', false);
JX.Busy.done(); JX.Busy.done();
} };
img.src = img_uri; img.src = img_uri;
} }

View file

@ -79,7 +79,7 @@ JX.behavior('phabricator-object-selector', function(config) {
var cells = [ var cells = [
JX.$N('td', {}, view_object_link), JX.$N('td', {}, view_object_link),
JX.$N('th', {}, select_object_link), JX.$N('th', {}, select_object_link),
JX.$N('td', {}, select_object_button), JX.$N('td', {}, select_object_button)
]; ];
var table = JX.$N( var table = JX.$N(
@ -109,7 +109,7 @@ JX.behavior('phabricator-object-selector', function(config) {
function sendQuery() { function sendQuery() {
query_timer = null; query_timer = null;
JX.DOM.setContent(JX.$(config.results), renderNote('Loading...')) JX.DOM.setContent(JX.$(config.results), renderNote('Loading...'));
new JX.Request(config.uri, JX.bind(null, onreceive, ++n)) new JX.Request(config.uri, JX.bind(null, onreceive, ++n))
.setData({ .setData({
filter: JX.$(config.filter).value, filter: JX.$(config.filter).value,

View file

@ -37,7 +37,7 @@ JX.behavior('phabricator-oncopy', function() {
var pos; var pos;
for (var ii = 0; ii < lines.length; ii++) { for (var ii = 0; ii < lines.length; ii++) {
pos = lines[ii].indexOf(zws); pos = lines[ii].indexOf(zws);
if (pos == -1 && ii != 0) { if (pos == -1 && ii !== 0) {
continue; continue;
} }
result.push(lines[ii].substring(pos + 1)); result.push(lines[ii].substring(pos + 1));
@ -76,5 +76,5 @@ JX.behavior('phabricator-oncopy', function() {
// to work or give me any errors. So you lose your selection when you // to work or give me any errors. So you lose your selection when you
// copy. Oh well? // copy. Oh well?
} }
} };
}); });

View file

@ -6,6 +6,8 @@
* javelin-dom * javelin-dom
* javelin-magical-init * javelin-magical-init
* javelin-vector * javelin-vector
* javelin-request
* javelin-util
* @javelin * @javelin
*/ */
@ -46,7 +48,6 @@ JX.behavior('phabricator-nav', function(config) {
element: background, element: background,
parameter: 'width', parameter: 'width',
start: JX.Vector.getDim(background).x, start: JX.Vector.getDim(background).x,
start: JX.Vector.getDim(background).x,
minWidth: 1 minWidth: 1
}, },
{ {
@ -74,8 +75,9 @@ JX.behavior('phabricator-nav', function(config) {
var dx = JX.$V(e).x - dragging.x; var dx = JX.$V(e).x - dragging.x;
var panel; var panel;
var k;
for (var k = 0; k < track.length; k++) { for (k = 0; k < track.length; k++) {
panel = track[k]; panel = track[k];
if (!panel.minWidth) { if (!panel.minWidth) {
continue; continue;
@ -86,7 +88,7 @@ JX.behavior('phabricator-nav', function(config) {
} }
} }
for (var k = 0; k < track.length; k++) { for (k = 0; k < track.length; k++) {
panel = track[k]; panel = track[k];
var v = (panel.start + (dx * (panel.scale || 1))); var v = (panel.start + (dx * (panel.scale || 1)));
panel.element.style[panel.parameter] = v + 'px'; panel.element.style[panel.parameter] = v + 'px';
@ -115,7 +117,7 @@ JX.behavior('phabricator-nav', function(config) {
JX.DOM.alterClass(main, 'has-local-nav', !collapsed); JX.DOM.alterClass(main, 'has-local-nav', !collapsed);
JX.DOM.alterClass(main, 'has-drag-nav', !collapsed); JX.DOM.alterClass(main, 'has-drag-nav', !collapsed);
resetdrag(); resetdrag();
new JX.Request('/settings/adjust/', JX.Bag) new JX.Request('/settings/adjust/', JX.bag)
.setData({ key : 'nav-collapsed', value : (collapsed ? 1 : 0) }) .setData({ key : 'nav-collapsed', value : (collapsed ? 1 : 0) })
.send(); .send();
}); });

View file

@ -119,11 +119,11 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
// Now, select just the middle part. For instance, if the user clicked // Now, select just the middle part. For instance, if the user clicked
// "B" to create bold text, we insert '**bold**' but just select the word // "B" to create bold text, we insert '**bold**' but just select the word
// "bold" so if they type stuff they'll be editing the bold text. // "bold" so if they type stuff they'll be editing the bold text.
var r = JX.TextAreaUtils.getSelectionRange(area); var range = JX.TextAreaUtils.getSelectionRange(area);
JX.TextAreaUtils.setSelectionRange( JX.TextAreaUtils.setSelectionRange(
area, area,
r.start + l.length, range.start + l.length,
r.start + l.length + m.length); range.start + l.length + m.length);
} }
function assist(area, action, root) { function assist(area, action, root) {
@ -152,16 +152,16 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
sel = ["List Item"]; sel = ["List Item"];
} }
sel = sel.join("\n" + ch); sel = sel.join("\n" + ch);
update(area, ((r.start == 0) ? "" : "\n\n") + ch, sel, "\n\n"); update(area, ((r.start === 0) ? "" : "\n\n") + ch, sel, "\n\n");
break; break;
case 'code': case 'code':
sel = sel || "foreach ($list as $item) {\n work_miracles($item);\n}"; sel = sel || "foreach ($list as $item) {\n work_miracles($item);\n}";
sel = sel.split("\n"); sel = sel.split("\n");
sel = " " + sel.join("\n "); sel = " " + sel.join("\n ");
update(area, ((r.start == 0) ? "" : "\n\n"), sel, "\n\n"); update(area, ((r.start === 0) ? "" : "\n\n"), sel, "\n\n");
break; break;
case 'table': case 'table':
update(area, (r.start == 0 ? '' : '\n\n') + '| ', sel || 'data', ' |'); update(area, (r.start === 0 ? '' : '\n\n') + '| ', sel || 'data', ' |');
break; break;
case 'meme': case 'meme':
new JX.Workflow('/macro/meme/create/') new JX.Workflow('/macro/meme/create/')
@ -170,7 +170,7 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
area, area,
'', '',
sel, sel,
(r.start == 0 ? '' : '\n\n') + response.text + '\n\n'); (r.start === 0 ? '' : '\n\n') + response.text + '\n\n');
}) })
.start(); .start();
break; break;

View file

@ -54,5 +54,6 @@ JX.behavior('refresh-csrf', function(config) {
JX.Request.listen('finally', function(r) { JX.Request.listen('finally', function(r) {
JX.Busy.done(); JX.Busy.done();
}) });
}); });

View file

@ -13,10 +13,11 @@ JX.behavior('phabricator-reveal-content', function(config) {
function(e) { function(e) {
e.kill(); e.kill();
var nodes = e.getNodeData('reveal-content'); var nodes = e.getNodeData('reveal-content');
for (var ii = 0; ii < nodes.showIDs.length; ii++) { var ii;
for (ii = 0; ii < nodes.showIDs.length; ii++) {
JX.DOM.show(JX.$(nodes.showIDs[ii])); JX.DOM.show(JX.$(nodes.showIDs[ii]));
} }
for (var ii = 0; ii < nodes.hideIDs.length; ii++) { for (ii = 0; ii < nodes.hideIDs.length; ii++) {
JX.DOM.hide(JX.$(nodes.hideIDs[ii])); JX.DOM.hide(JX.$(nodes.hideIDs[ii]));
} }
}); });

View file

@ -16,7 +16,7 @@ JX.behavior('phabricator-search-typeahead', function(config) {
function transform(object) { function transform(object) {
var attr = { var attr = {
className: 'phabricator-main-search-typeahead-result' className: 'phabricator-main-search-typeahead-result'
} };
if (object[6]) { if (object[6]) {
attr.style = {backgroundImage: 'url('+object[6]+')'}; attr.style = {backgroundImage: 'url('+object[6]+')'};
@ -59,7 +59,8 @@ JX.behavior('phabricator-search-typeahead', function(config) {
var tokens = this.tokenize(value); var tokens = this.tokenize(value);
for (var ii = 0; ii < list.length; ii++) { var ii;
for (ii = 0; ii < list.length; ii++) {
var item = list[ii]; var item = list[ii];
if (!item.priority) { if (!item.priority) {
continue; continue;
@ -91,7 +92,7 @@ JX.behavior('phabricator-search-typeahead', function(config) {
// we show 3 applications, then 3 users, etc. // we show 3 applications, then 3 users, etc.
var type_count = 0; var type_count = 0;
var current_type = null; var current_type = null;
for (var ii = 0; ii < list.length; ii++) { for (ii = 0; ii < list.length; ii++) {
if (list.length <= config.limit) { if (list.length <= config.limit) {
break; break;
} }

View file

@ -1,6 +1,7 @@
/** /**
* @provides phabricator-phtize * @provides phabricator-phtize
* @requires javelin-util * @requires javelin-util
* @javelin-installs JX.phtize
* @javelin * @javelin
*/ */