mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 22:40:55 +01:00
0569218201
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
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-ponder-votebox
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-util
|
|
* javelin-stratcom
|
|
* javelin-request
|
|
*/
|
|
|
|
JX.behavior('ponder-votebox', function(config) {
|
|
|
|
function handle_vote(e, vote) {
|
|
e.kill();
|
|
|
|
var root = e.getNode('ponder-votable');
|
|
var data = e.getNodeData('ponder-votable');
|
|
|
|
if (data.vote != vote) {
|
|
data.vote = vote;
|
|
data.count += vote;
|
|
} else {
|
|
// User is undoing their vote.
|
|
data.vote = 0;
|
|
data.count -= vote;
|
|
}
|
|
|
|
var upv = JX.DOM.find(root, 'a', 'upvote');
|
|
JX.DOM.alterClass(upv, 'ponder-vote-active', (data.vote > 0));
|
|
|
|
var downv = JX.DOM.find(root, 'a', 'downvote');
|
|
JX.DOM.alterClass(downv, 'ponder-vote-active', (data.vote < 0));
|
|
|
|
JX.DOM.setContent(
|
|
JX.DOM.find(root, 'div', 'ponder-vote-count'),
|
|
data.count);
|
|
|
|
new JX.Request(e.getTarget().href, JX.bag)
|
|
.setData({vote: data.vote})
|
|
.send();
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'downvote',
|
|
function(e) {
|
|
handle_vote(e, -1);
|
|
});
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'upvote',
|
|
function(e) {
|
|
handle_vote(e, 1);
|
|
});
|
|
});
|