Welcome to mirror list, hosted at ThFree Co, Russian Federation.

firstrunwizard.js « js - github.com/nextcloud/firstrunwizard.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 39d4fa4414e595bcbe2b858ef1edac4842e47237 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
(function() {
	if (!OCA.FirstRunWizard) {
		OCA.FirstRunWizard = {};
	}
	OCA.FirstRunWizard.Wizard = {

		initialize: function () {

		},
		getTotal: function() {
			return this.$pages.length;
		},
		getCurrent: function () {
			return $('#firstrunwizard .page.active').index('#firstrunwizard .page');
		},
		isLast: function() {
			return this.getCurrent() >= this.getTotal()-1;
		},
		isFirst: function() {
			return this.getCurrent() === 0;
		},
		updateTitle: function() {
			var active = $('#firstrunwizard .page.active');
			var header = this.$wizard.find('.firstrunwizard-header');
			header.find('h1').text(active.data('title'));
			header.find('p').text(active.data('subtitle'));
		},
		goNext: function() {
			if (this.isLast()) {
				return;
			}
			var active = $('#firstrunwizard .page.active');
			var next = active.next();
			this.$prev.show();
			if (this.getCurrent() < this.getTotal()-1) {
				active.hide().removeClass('active');
				next.show().addClass('active');
			}

			this.$position.find('li').removeClass('active');
			this.$position.find('>li:nth-child(' + (this.getCurrent()+1) + ')').addClass('active');

			if (this.isLast()) {
				this.$next.hide();
				this.$finish.show();
			} else {
				this.$next.show();
				this.$finish.hide();
			}
			this.updateTitle();
			$.colorbox.resize();
		},
		goPrevious: function() {
			if (this.isFirst()) {
				return;
			}
			var active = $('#firstrunwizard .page.active');
			var prev = active.prev();
			active.hide().removeClass('active');
			prev.show().addClass('active');
			this.$next.show();
			this.$finish.hide();
			if (!this.isFirst()) {
				active.hide().removeClass('active');
				prev.show().addClass('active');
			}

			this.$position.find('li').removeClass('active');
			this.$position.find('>li:nth-child(' + (this.getCurrent()+1) + ')').addClass('active');

			if (this.isFirst()) {
				this.$prev.hide();
			} else {
				this.$prev.show();
			}
			this.updateTitle();
			$.colorbox.resize();
		},
		handleKeydown: function(e) {
			switch (e.keyCode) {
				case 37: // arrow left
					this.goPrevious();
					break;
				case 13:
				case 39:
					this.goNext();
					break;
				case 27:
					this.closeWizard();
					break;
			}
		},
		onComplete: function() {
			this.$wizard = $('#firstrunwizard');
			this.$finish = this.$wizard.find('#finish');
			this.$prev = this.$wizard.find('#prev');
			this.$next = this.$wizard.find('#next');
			this.$pages = this.$wizard.find('.page');
			this.$position = this.$wizard.find('.position-indicator');

			this.$finish.hide();
			this.$pages.hide();
			this.$prev.hide();
			this.$pages.first().fadeIn().addClass('active');
			$.colorbox.resize();
			var self = this;
			this.$pages.each(function() {
				self.$position.append('<li></li>');
			});
			this.$position.find('>li:first-child').addClass('active');

			this.$wizard.on('click', '#next', this.goNext.bind(this));
			this.$wizard.on('click', '#prev', this.goPrevious.bind(this));
			this.$wizard.on('click', '#finish', this.closeWizard.bind(this));
			this.$wizard.on('click', '#closeWizard', this.closeWizard.bind(this));
			$('body').off('keydown', this.handleKeydown).on('keydown', this.handleKeydown.bind(this));
			this.updateTitle();
		},
		closeWizard: function() {
			$('body').off('keydown', this.handleKeydown);
			$.colorbox.close();
		},

		showFirstRunWizard: function(){
			var self = this;
			$.colorbox({
				opacity: 0.7,
				transition: 'elastic',
				speed: 100,
				width: '80%',
				height: '80%',
				maxWidth: '900px',
				href: OC.generateUrl('/apps/firstrunwizard/wizard'),
				onClosed : function() {
					$.ajax({
						url: OC.generateUrl('/apps/firstrunwizard/wizard'),
						type: 'delete'
					});
				},
				onComplete: self.onComplete.bind(self),
			});
		}
	};
})();

$(document).ready(function() {
	$('#showWizard').on('click', function () {
		OCA.FirstRunWizard.Wizard.showFirstRunWizard();
	});

	$('#expanddiv a[href="#about"]').on('click', function () {
		OCA.FirstRunWizard.Wizard.showFirstRunWizard();
		$(this).find('div').remove();
		$(this).find('img').show();
		OC.hideMenus(function(){return false;});
		return false;
	});
});