summaryrefslogtreecommitdiffstats
path: root/web/statusbar.js
blob: 28e5ba4333363a3e44284203e181f95e95df901d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * Copyright (c) 2012-2014 Kaarle Ritvanen
 * See LICENSE file for license details
 */

define(["acf2/dom", "jquery"], function(dom, $) {
    function set(status, msg, mode) {
	$("#status").prop("class", status);
	dom.setText($("#status p"), msg);
	$("#logout").prop("class", mode ? "hidden" : null);
	$("#status div").prop("class", mode == "txn" ? null : "hidden");
	$("#commit").prop("disabled", status == "invalid");
    }

    function setError(msg, mode) { set("invalid", msg, mode); }

    return {
	reset: function() { set(null, ""); },
	setError: setError,
	validationReady: function(txnValid) {
	    if (txnValid)
		set("changed", "You have uncommitted changes", "txn");
	    else setError("Some values need checking", "txn");
	}
    };
});