Merge pull request #1785 from bendiy/4_6_x
[xtuple] / enyo-client / application / source / preliminaries.js
1 /*jshint bitwise:true, indent:2, curly:true, eqeqeq:true, immed:true,
2 latedef:true, newcap:true, noarg:true, regexp:true, undef:true,
3 trailing:true, white:true*/
4 /*global XT:true, enyo:true, window:true, location: true */
5
6 XT = typeof XT !== 'undefined' ? XT : {};
7
8 (function () {
9
10   XT.getBaseUrl = function () {
11     return location.protocol + "//" + location.hostname + (location.port && ":" + location.port);
12   };
13
14   XT.getOrganizationPath = function () {
15     return "/" + window.location.pathname.split("/")[1];
16   };
17
18   XT.logout = function () {
19     if (window.onbeforeunload) {
20       // if we've set up a "are you sure you want to leave?" warning, disable that
21       // here. Presumably we've already asked if they want to leave.
22       // delete window.onbeforeunload; // doesn't work
23       window.onbeforeunload = undefined;
24     }
25     window.location = XT.getOrganizationPath() + "/logout";
26   };
27
28   XT.setVersion = function (version, qualifier) {
29     // default to the core version
30     version = version || XT.session.config.version;
31
32     var aboutVersionLabel = XT.app.$.postbooks.$.navigator.$.aboutVersion,
33       versionText = "_version".loc() + " " + version;
34
35     if (qualifier) {
36       versionText = ("_" + qualifier).loc() + " " + versionText;
37     }
38     if (aboutVersionLabel.getContent()) {
39       versionText = aboutVersionLabel.getContent() + "<br>" + versionText;
40     }
41
42     aboutVersionLabel.setContent(versionText);
43   };
44
45 }());