Skip to content

Commit e3ed6c6

Browse files
author
sshulzhitskaya
committed
#104: make background transparent and change collor from white to transparent, added possability to change button's text
1 parent c9ddc7e commit e3ed6c6

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

src/enjoyhint.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
var EnjoyHint = function (_options) {
1+
//TODO: localization support
2+
/**
3+
*
4+
* @param {*} configs
5+
*/
6+
var EnjoyHint = function (configs) {
7+
28

39
var $event_element;
410
var that = this;
11+
var _options = configs || {};
12+
var BTN_NEXT_TEXT = _options.btnNextText || "Next";
13+
var BTN_SKIP_TEXT = _options.btnSkipText || "Skip";
14+
15+
var SHAPE_BACKGROUND_COLOR = _options.backgroundColor || "rgba(0,0,0,0.6)";
16+
17+
18+
var body = 'body';// TODO: Is it possible case when we need to define enjoyhint somewhere else?
519

620
var defaults = {
721

@@ -26,7 +40,7 @@ var EnjoyHint = function (_options) {
2640
var data = [];
2741
var current_step = 0;
2842

29-
$body = $('body');
43+
$body = $(body);
3044

3145

3246
/********************* PRIVATE METHODS ***************************************/
@@ -41,7 +55,7 @@ var EnjoyHint = function (_options) {
4155
$body.css({'overflow':'hidden'});
4256

4357
$(document).on("touchmove",lockTouch);
44-
58+
4559
$body.enjoyhint({
4660

4761
onNextClick: function () {
@@ -53,7 +67,8 @@ var EnjoyHint = function (_options) {
5367

5468
options.onSkip();
5569
skipAll();
56-
}
70+
},
71+
fill: SHAPE_BACKGROUND_COLOR
5772
});
5873
};
5974

@@ -75,9 +90,9 @@ var EnjoyHint = function (_options) {
7590
var $skipBtn = $('.enjoyhint_skip_btn');
7691

7792
$nextBtn.removeClass(that.nextUserClass);
78-
$nextBtn.text("Next");
93+
$nextBtn.text(BTN_NEXT_TEXT);
7994
$skipBtn.removeClass(that.skipUserClass);
80-
$skipBtn.text("Skip");
95+
$skipBtn.text(BTN_SKIP_TEXT);
8196
};
8297

8398
var stepAction = function () {
@@ -331,7 +346,7 @@ var EnjoyHint = function (_options) {
331346

332347
$body.enjoyhint('redo_events_near_rect', $event_element[0].getBoundingClientRect());
333348
}
334-
});
349+
}, false);
335350

336351
that.stop = function() {
337352

@@ -383,14 +398,17 @@ var EnjoyHint = function (_options) {
383398
};
384399

385400
that.setScript = function (_data) {
386-
387-
if (_data) {
388-
389-
data = _data;
401+
if(!(_data instanceof Array) && _data.length < 1){
402+
throw new Error("Configurations list isn't correct.")
390403
}
404+
405+
data = _data;
391406
};
392407

393408
//support deprecated API methods
409+
/**
410+
* Configure data list
411+
*/
394412
that.set = function (_data) {
395413

396414
that.setScript(_data);

src/jquery.enjoyhint.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
-webkit-box-sizing: content-box;
4343
-moz-box-sizing: content-box;
4444
box-sizing: content-box;
45-
width: 100px;
4645
height: 40px;
4746
cursor: pointer;
4847
margin: 0 auto;
@@ -85,7 +84,6 @@
8584
-webkit-box-sizing: content-box;
8685
-moz-box-sizing: content-box;
8786
box-sizing: content-box;
88-
width: 100px;
8987
height: 40px;
9088
cursor: pointer;
9189
margin: 0 auto;

src/jquery.enjoyhint.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) {
132132
});
133133

134134
that.layer = new Kinetic.Layer();
135+
135136
that.rect = new Kinetic.Rect({
136-
fill: 'rgba(0,0,0,0.6)',
137+
fill: options.fill,
137138
width: that.canvas_size.w,
138139
height: that.canvas_size.h
139140
});
@@ -362,7 +363,7 @@ CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) {
362363
}
363364

364365
that.rect = new Kinetic.Rect({
365-
fill: 'rgba(0,0,0,0.6)',
366+
fill: options.fill,
366367
width: window.innerWidth,
367368
height: window.innerHeight
368369
});
@@ -1141,7 +1142,6 @@ CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) {
11411142

11421143
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
11431144
} else if (typeof method === 'object' || !method) {
1144-
11451145
return methods.init.apply(this, arguments);
11461146
} else {
11471147

0 commit comments

Comments
 (0)