[TIC-Web] source clean up
[archive/20170607/tools/tic.git] / public / src / js / main.js
1 define([
2     'jquery',
3     'bootstrap',
4     'bootstrap-treeview',
5     'js/util',
6     'js/page/package',
7     'js/page/settings',
8     'js/page/image',
9     'js/logger'
10 ], function (
11     $,
12     bootstrap,
13     bootstrapTreeview,
14     Util,
15     Package,
16     Settings,
17     Image,
18     Logger
19 ) {
20     'use strict';
21
22     var logger = Logger('main.js');
23
24     function init() {
25         logger.info("init");
26
27         Util.showLoadingDialog(true);
28
29         Settings.updatePackage()
30         .then(Package.updatePackageTree)
31         .then(function () {
32             Util.showLoadingDialog(false);
33         })
34         .catch(function (reason) {
35             logger.error(reason);
36             Util.showLoadingDialog(false);
37             Util.showAlertDialog('Failed to load package list.<br>Please check the tic-core.');
38         });
39
40         // Keep the state of the active item on navbar
41         $(".navbar a").on("click", function() {
42             $(".navbar").find(".active").removeClass("active");
43             $(this).parent().addClass("active");
44         });
45
46     }
47
48     $(document).ready(function () {
49         init();
50     });
51
52 });