Completed
Push — master ( 12feb0...ebcfa0 )
by Maxence
02:25
created

mood.app.js ➔ Navigation   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
nc 1
nop 0
1
/*
2
 * Mood
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2017
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
/** global: OC */
27
/** global: OCA */
28
29
/** global: nav */
30
/** global: actions */
31
/** global: elements */
32
33
const circles = OCA.Circles.api;
34
const api = OCA.Mood.api;
35
let curr = {
36
	mood: '',
37
	circles: [],
38
	shares: [],
39
	sharesDisplayed: false,
40
	requestingInfos: false,
41
	websiteInfos: {},
42
43
	isShared: function (share) {
44
		return ($.inArray(share, curr.shares) > -1);
45
	},
46
47
	addShare: function (share) {
48
		if (!curr.isShared(share)) {
49
			curr.shares.push(share);
50
		}
51
	},
52
53
	remShare: function (share) {
54
		const e = curr.shares.indexOf(share);
55
		if (e > -1) {
56
			curr.shares.splice(e, 1);
57
		}
58
	},
59
60
	switchShare: function (share) {
61
		if (curr.isShared(share)) {
62
			curr.remShare(share);
63
		} else {
64
			curr.addShare(share);
65
		}
66
	}
67
};
68
69
const Navigation = function () {
70
71
	$.extend(Navigation.prototype, curr);
72
	$.extend(Navigation.prototype, nav);
73
	$.extend(Navigation.prototype, elements);
74
	$.extend(Navigation.prototype, actions);
75
76
	this.init();
77
};
78
79
Navigation.prototype = {
80
81
	init: function () {
82
		elements.integrateMoodToActivity();
83
		elements.initElements();
84
		elements.initUI();
85
		elements.initExperienceMood();
86
87
		nav.initNavigation();
88
		nav.initCircles();
89
	}
90
};
91
92
93
OCA.Mood.Navigation = Navigation;
94
95
$(document).ready(function () {
96
	OCA.Mood.navigation = new Navigation();
97
});
98
99