k4slide 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/k4slide.css +1 -1
- data/assets/k4slide.js +197 -187
- data/assets-src/javascripts/lib/k4/slide/config.js +3 -3
- data/assets-src/javascripts/lib/k4/slide/controller.js +74 -17
- data/assets-src/javascripts/lib/k4/slide/slide.js +24 -9
- data/assets-src/stylesheets/k4slide.scss +68 -6
- data/assets-src/stylesheets/{themes → lib}/_mixin.scss +0 -0
- data/assets-src/stylesheets/themes/base.scss +2 -62
- data/assets-src/stylesheets/transitions/_mixin.scss +13 -0
- data/assets-src/stylesheets/transitions/slide.scss +8 -0
- data/example/example.html +198 -188
- data/example/example.md +1 -0
- data/lib/k4slide/tasks.rb +1 -2
- data/lib/k4slide/version.rb +1 -1
- metadata +5 -4
- data/assets-src/stylesheets/themes/_config.scss +0 -4
@@ -26,8 +26,8 @@ k4.slide.Config.DEFAULT_CONFIG = {
|
|
26
26
|
},
|
27
27
|
'slide': {
|
28
28
|
'pattern': 'div[role="slide"]',
|
29
|
-
'width':
|
30
|
-
'height':
|
29
|
+
'width': 1024,
|
30
|
+
'height': 768,
|
31
31
|
'ratio': 1.0,
|
32
32
|
'class': {
|
33
33
|
'current': 'current',
|
@@ -69,7 +69,7 @@ k4.slide.Config.prototype.set= function(key, val) {
|
|
69
69
|
if (i == lastIndex) {
|
70
70
|
tmp[k] = val;
|
71
71
|
} else {
|
72
|
-
tmp =
|
72
|
+
tmp = tmp[k];
|
73
73
|
}
|
74
74
|
}, this);
|
75
75
|
};
|
@@ -34,9 +34,9 @@ k4.slide.Controller = function(config) {
|
|
34
34
|
this.current_ = 0;
|
35
35
|
|
36
36
|
/**
|
37
|
-
* @type {goog.
|
37
|
+
* @type {goog.History}
|
38
38
|
*/
|
39
|
-
this.history_ =
|
39
|
+
this.history_ = new goog.History();
|
40
40
|
}
|
41
41
|
goog.inherits(k4.slide.Controller, goog.ui.Component);
|
42
42
|
|
@@ -91,18 +91,27 @@ k4.slide.Controller.prototype.calculateSlideSizeAndPosition_ = function() {
|
|
91
91
|
if (aspectRatio > slideAspect) {
|
92
92
|
toHeight = Math.floor(winHeight - (winMargin * 2));
|
93
93
|
slideRatio = toHeight / slideHeight;
|
94
|
+
toWidth = slideWidth * slideRatio;
|
94
95
|
} else {
|
95
96
|
toWidth = Math.floor(winWidth - (winMargin * 2));
|
96
97
|
slideRatio = toWidth / slideWidth;
|
98
|
+
toHeight = slideHeight * slideRatio;
|
97
99
|
isHorizonal = false;
|
98
100
|
}
|
99
101
|
c.set('slide.ratio', slideRatio);
|
100
102
|
|
101
103
|
// position
|
104
|
+
// current
|
102
105
|
var slideTop = Math.round((winHeight - slideHeight) / 2);
|
103
106
|
var slideLeft = Math.round((winWidth - slideWidth) / 2);
|
104
|
-
c.set('slide.top', slideTop);
|
105
|
-
c.set('slide.left', slideLeft)
|
107
|
+
c.set('slide.current.top', slideTop);
|
108
|
+
c.set('slide.current.left', slideLeft);
|
109
|
+
// next
|
110
|
+
var nextLeft = ((winWidth + slideWidth) / 2) + (toWidth - slideWidth) + c.get('window.margin');
|
111
|
+
c.set('slide.next.left', nextLeft);
|
112
|
+
// prev
|
113
|
+
var prevLeft = ((winWidth - slideWidth) / 2) - (toWidth) - c.get('window.margin');
|
114
|
+
c.set('slide.prev.left', prevLeft);
|
106
115
|
|
107
116
|
// set ratio
|
108
117
|
this.setSlideScale_();
|
@@ -110,13 +119,21 @@ k4.slide.Controller.prototype.calculateSlideSizeAndPosition_ = function() {
|
|
110
119
|
|
111
120
|
k4.slide.Controller.prototype.setSlideScale_ = function() {
|
112
121
|
var c = this.config_;
|
122
|
+
var sTop = c.get('slide.current.top');
|
123
|
+
var sLeft = c.get('slide.current.left');
|
124
|
+
var nLeft = c.get('slide.next.left');
|
125
|
+
var pLeft = c.get('slide.prev.left');
|
113
126
|
var ratio = c.get('slide.ratio');
|
114
127
|
|
115
128
|
var installStyles = [
|
129
|
+
'div.current{top:'+ sTop.toString() +'px; left:'+ sLeft.toString() +'px;}',
|
130
|
+
'div.next{top:'+ sTop.toString() +'px; left:'+ nLeft.toString() +'px;}',
|
131
|
+
'div.prev{top:'+ sTop.toString() +'px; left:'+ pLeft.toString() +'px;}',
|
116
132
|
'div[role="slide"]{',
|
117
133
|
'-webkit-transform: scale('+ ratio.toString() +');}',
|
118
134
|
'-moz-transform: scale('+ ratio.toString() +');',
|
119
|
-
'}'
|
135
|
+
'}',
|
136
|
+
''
|
120
137
|
].join("");
|
121
138
|
goog.style.installStyles(installStyles);
|
122
139
|
};
|
@@ -192,28 +209,52 @@ k4.slide.Controller.prototype.getPrev = function() {
|
|
192
209
|
* @return {k4.slide.|null|undefined}
|
193
210
|
*/
|
194
211
|
k4.slide.Controller.prototype.updateTitle = function() {
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
var page = el.getAttribute('page');
|
201
|
-
if (page) {
|
202
|
-
this.history_.setToken(page);
|
203
|
-
}
|
204
|
-
}
|
212
|
+
var c = this.getCurrent();
|
213
|
+
if (c) {
|
214
|
+
var p = c.getPage();
|
215
|
+
if (p) {
|
216
|
+
this.setToken(p);
|
205
217
|
}
|
206
218
|
}
|
207
219
|
};
|
208
220
|
|
221
|
+
/**
|
222
|
+
* Get current slide object
|
223
|
+
* @return {k4.slide.|null|undefined}
|
224
|
+
*/
|
225
|
+
k4.slide.Controller.prototype.getCurrentPageNumber = function() {
|
226
|
+
var page = 0;
|
227
|
+
if (this.history_) {
|
228
|
+
page = parseInt(this.history_.getToken(), 10);
|
229
|
+
}
|
230
|
+
return page;
|
231
|
+
};
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Get current slide object
|
235
|
+
* @return {k4.slide.|null|undefined}
|
236
|
+
*/
|
237
|
+
k4.slide.Controller.prototype.setToken = function(val) {
|
238
|
+
if (this.history_) {
|
239
|
+
this.history_.setToken(val);
|
240
|
+
}
|
241
|
+
};
|
209
242
|
|
210
243
|
/**
|
211
244
|
* start presentation
|
212
245
|
*/
|
213
246
|
k4.slide.Controller.prototype.start = function() {
|
247
|
+
var l = 0;
|
214
248
|
if (goog.isArrayLike(this.slides_) && this.slides_.length > 0) {
|
215
|
-
|
216
|
-
|
249
|
+
goog.array.forEach(this.slides_, function(s, i, a) {
|
250
|
+
if (i == l) {
|
251
|
+
s.toCurrent();
|
252
|
+
} else if (i < l) {
|
253
|
+
s.toPrev();
|
254
|
+
} else if (i > l) {
|
255
|
+
s.toNext();
|
256
|
+
}
|
257
|
+
}, this);
|
217
258
|
}
|
218
259
|
};
|
219
260
|
|
@@ -227,6 +268,7 @@ k4.slide.Controller.prototype.next = function() {
|
|
227
268
|
currentSlide.toPrev();
|
228
269
|
nextSlide.toCurrent();
|
229
270
|
this.current_++;
|
271
|
+
this.updateTitle();
|
230
272
|
}
|
231
273
|
};
|
232
274
|
|
@@ -240,6 +282,21 @@ k4.slide.Controller.prototype.back = function() {
|
|
240
282
|
currentSlide.toNext();
|
241
283
|
prevSlide.toCurrent();
|
242
284
|
this.current_--;
|
285
|
+
this.updateTitle();
|
286
|
+
}
|
287
|
+
};
|
288
|
+
|
289
|
+
/**
|
290
|
+
* goto
|
291
|
+
*/
|
292
|
+
k4.slide.Controller.prototype.goTo = function(page) {
|
293
|
+
var currentSlide = this.getCurrent();
|
294
|
+
var gotoSlide = this.slides_[parseInt(page, 10)];
|
295
|
+
if (gotoSlide) {
|
296
|
+
currentSlide.toNext();
|
297
|
+
prevSlide.toCurrent();
|
298
|
+
this.current_--;
|
299
|
+
this.updateTitle();
|
243
300
|
}
|
244
301
|
};
|
245
302
|
|
@@ -2,6 +2,7 @@ goog.provide('k4.slide.Slide');
|
|
2
2
|
|
3
3
|
goog.require('goog.dom.classes');
|
4
4
|
goog.require('goog.style');
|
5
|
+
goog.require('goog.string');
|
5
6
|
goog.require('goog.math.Size');
|
6
7
|
goog.require('goog.math.Coordinate');
|
7
8
|
goog.require('goog.ui.Component');
|
@@ -38,9 +39,8 @@ k4.slide.Slide.prototype.init_ = function() {
|
|
38
39
|
// size
|
39
40
|
this.setSizeByConfig();
|
40
41
|
// position
|
41
|
-
this.setPositionByConfig();
|
42
|
-
|
43
|
-
goog.style.showElement(el, false);
|
42
|
+
// this.setPositionByConfig();
|
43
|
+
this.hide();
|
44
44
|
};
|
45
45
|
|
46
46
|
/**
|
@@ -85,7 +85,8 @@ k4.slide.Slide.prototype.setPositionByConfig = function() {
|
|
85
85
|
*/
|
86
86
|
k4.slide.Slide.prototype.show = function() {
|
87
87
|
var el = this.getElement();
|
88
|
-
goog.style.
|
88
|
+
goog.style.setOpacity(el, 1);
|
89
|
+
// goog.style.showElement(el, true);
|
89
90
|
};
|
90
91
|
|
91
92
|
/**
|
@@ -93,7 +94,8 @@ k4.slide.Slide.prototype.show = function() {
|
|
93
94
|
*/
|
94
95
|
k4.slide.Slide.prototype.hide = function() {
|
95
96
|
var el = this.getElement();
|
96
|
-
goog.style.
|
97
|
+
goog.style.setOpacity(el, 0);
|
98
|
+
// goog.style.showElement(el, false);
|
97
99
|
};
|
98
100
|
|
99
101
|
/**
|
@@ -140,17 +142,30 @@ k4.slide.Slide.prototype.toCurrent = function() {
|
|
140
142
|
k4.slide.Slide.prototype.applyClasses = function(addClasses, opt_removeClasses) {
|
141
143
|
var el = this.getElement();
|
142
144
|
|
145
|
+
if (goog.isArrayLike(opt_removeClasses)) {
|
146
|
+
goog.array.forEach(opt_removeClasses, function(cls, i, arr) {
|
147
|
+
goog.dom.classes.remove(el, cls);
|
148
|
+
}, this);
|
149
|
+
}
|
150
|
+
|
143
151
|
if (goog.isArrayLike(addClasses)) {
|
144
152
|
goog.array.forEach(addClasses, function(cls, i, arr) {
|
145
153
|
goog.dom.classes.add(el, cls);
|
146
154
|
}, this);
|
147
155
|
}
|
156
|
+
};
|
148
157
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
158
|
+
/**
|
159
|
+
* return config instance.
|
160
|
+
*/
|
161
|
+
k4.slide.Slide.prototype.getPage = function() {
|
162
|
+
var page = null;
|
163
|
+
var el = this.getElement();
|
164
|
+
if (el) {
|
165
|
+
page = el.getAttribute('page');
|
166
|
+
page = (!goog.string.isEmpty(page)) ? parseInt(page, 10) : null;
|
153
167
|
}
|
168
|
+
return page;
|
154
169
|
};
|
155
170
|
|
156
171
|
/**
|
@@ -1,11 +1,73 @@
|
|
1
1
|
// base.css
|
2
2
|
|
3
|
-
|
3
|
+
$bg-color: #FFF;
|
4
|
+
$font-color: #333;
|
5
|
+
$border-color: #666;
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
@import 'themes/base';
|
8
|
+
@import 'transitions/slide';
|
9
|
+
|
10
|
+
body {
|
11
|
+
background-color: $bg-color;
|
12
|
+
color: $font-color;
|
13
|
+
overflow: hidden;
|
14
|
+
|
15
|
+
* {
|
16
|
+
font-size: 18pt;
|
17
|
+
color: $font-color;
|
18
|
+
}
|
9
19
|
}
|
10
20
|
|
11
|
-
|
21
|
+
div[role="slide"] {
|
22
|
+
padding: 2%;
|
23
|
+
box-sizing: border-box;
|
24
|
+
background-color: #FFFFFF;
|
25
|
+
|
26
|
+
$radius: 1%;
|
27
|
+
border-radius: $radius;
|
28
|
+
-webkit-border-radius: $radius;
|
29
|
+
-moz-border-radius: $radius;
|
30
|
+
|
31
|
+
> h1, h2, h3, h4, h5, ul, ol, li {
|
32
|
+
margin: 0px;
|
33
|
+
padding: 0px;
|
34
|
+
}
|
35
|
+
|
36
|
+
&[slide-level="1"], &[slide-level="2"] {
|
37
|
+
> h1, h2 {
|
38
|
+
@include horizonal-centerize;
|
39
|
+
margin-top: 40% * 3 / 4;
|
40
|
+
margin-bottom: 5% * 3 / 4;
|
41
|
+
padding-left: 1%;
|
42
|
+
font-size: 140%;
|
43
|
+
}
|
44
|
+
> h1 {
|
45
|
+
border-bottom: 1px solid $border-color;
|
46
|
+
border-left: 10px solid $border-color;
|
47
|
+
}
|
48
|
+
> h2 {
|
49
|
+
border-left: 10px solid $border-color;
|
50
|
+
}
|
51
|
+
> ul, ol {
|
52
|
+
text-align: right;
|
53
|
+
list-style-type: none;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
&[slide-level="3"] {
|
58
|
+
> h3 {
|
59
|
+
border-bottom: 1px solid $border-color;
|
60
|
+
font-size: 120%;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
&:last-child {
|
65
|
+
> h3 {
|
66
|
+
display: none;
|
67
|
+
}
|
68
|
+
> p {
|
69
|
+
@include horizonal-centerize;
|
70
|
+
text-align: center;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
File without changes
|
@@ -1,68 +1,8 @@
|
|
1
1
|
//
|
2
2
|
|
3
|
-
@import "_mixin.scss";
|
4
|
-
@import "_config.scss";
|
3
|
+
@import "../lib/_mixin.scss";
|
5
4
|
|
6
5
|
|
7
|
-
body {
|
8
|
-
background-color: #000000;
|
9
|
-
color: #FFFFFF;
|
10
|
-
* {
|
11
|
-
font-size: 18pt;
|
12
|
-
color: $font-color;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
6
|
div[role="slide"] {
|
17
|
-
|
18
|
-
box-sizing: border-box;
|
19
|
-
background-color: #FFFFFF;
|
20
|
-
|
21
|
-
$radius: 1%;
|
22
|
-
border-radius: $radius;
|
23
|
-
-webkit-border-radius: $radius;
|
24
|
-
-moz-border-radius: $radius;
|
25
|
-
|
26
|
-
> h1, h2, h3, h4, h5, ul, ol, li {
|
27
|
-
margin: 0px;
|
28
|
-
padding: 0px;
|
29
|
-
}
|
30
|
-
|
31
|
-
&[slide-level="1"], &[slide-level="2"] {
|
32
|
-
> h1, h2 {
|
33
|
-
@include horizonal-centerize;
|
34
|
-
margin-top: 40% * 3 / 4;
|
35
|
-
margin-bottom: 5% * 3 / 4;
|
36
|
-
padding-left: 1%;
|
37
|
-
font-size: 140%;
|
38
|
-
}
|
39
|
-
> h1 {
|
40
|
-
border-bottom: 1px solid $border-color;
|
41
|
-
border-left: 10px solid $border-color;
|
42
|
-
}
|
43
|
-
> h2 {
|
44
|
-
border-left: 10px solid $border-color;
|
45
|
-
}
|
46
|
-
> ul, ol {
|
47
|
-
text-align: right;
|
48
|
-
list-style-type: none;
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
&[slide-level="3"] {
|
53
|
-
> h3 {
|
54
|
-
border-bottom: 1px solid $border-color;
|
55
|
-
font-size: 120%;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
&:last-child {
|
60
|
-
> h3 {
|
61
|
-
display: none;
|
62
|
-
}
|
63
|
-
> p {
|
64
|
-
@include horizonal-centerize;
|
65
|
-
text-align: center;
|
66
|
-
}
|
67
|
-
}
|
7
|
+
position: absolute;
|
68
8
|
}
|