Skip to content

Commit 6abcf22

Browse files
author
AZhurav1ev
committed
Added possibility to set arrow color
1 parent 00b2708 commit 6abcf22

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/*
2-
lib/*
2+
lib/*
3+
bootstrap_test
4+
package-lock.json

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var enjoyhint_script_steps = [
8484

8585
#### Properties of the step configuration
8686
* `"event selector" : "description"` - to describe a step you should set an event type, selecte element and add description for this element (hint)
87+
* `markerColor` - the color of a marker that accepts all CSS colors.
8788
* `keyCode` - the code of a button, which triggers the next EnjoyHint step upon a click. Defined by the “key” event. (“key #block” : “hello”).
8889
* `event_selector` - if you need to attach an event (that was set in "event" property) to other selector, you can use this one
8990
* `timeout` - delay before the moment, when an element is highlighted
@@ -112,7 +113,7 @@ var enjoyhint_script_steps = [
112113

113114

114115
#### Non-standard events:
115-
**auto** - for example, you need to click on the same button on the second step imediatelly after the first step and go to the next step after it. Then you can use "auto" in the "event_type" property and "click" in "event" property.
116+
* `auto` - for example, you need to click on the same button on the second step imediatelly after the first step and go to the next step after it. Then you can use "auto" in the "event_type" property and "click" in "event" property.
116117
* `custom` - this value is very usefull if you need to go to the next step by event in your app code. For example, you want to go to the next step only after some data have been loaded in your application. Then you should use the "custom" event_type and the "trigger" method of the EnjoyHint instance.
117118
```javascript
118119
//Example of using custom event_type
@@ -169,6 +170,7 @@ var enjoyhint_script_steps = [
169170
* Add responsive design
170171
* Add mobile support
171172
* Add possibility to go back to previous step
173+
* Add possibility to select the color of a marker
172174

173175

174176

enjoyhint.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
center_x: coords.x,
274274
center_y: coords.y,
275275
text: step_data.description,
276+
arrowColor: step_data.arrowColor,
276277
top: step_data.top,
277278
bottom: step_data.bottom,
278279
left: step_data.left,
@@ -582,7 +583,8 @@
582583
var polilyne = $(
583584
makeSVG("path", {
584585
style: "fill:none; stroke:rgb(255,255,255); stroke-width:2",
585-
d: "M0,0 c30,11 30,9 0,20"
586+
d: "M0,0 c30,11 30,9 0,20",
587+
id: "poliline"
586588
})
587589
);
588590

@@ -997,6 +999,24 @@
997999
};
9981000
};
9991001

1002+
that.setMarkerColor = function(color){
1003+
1004+
function isValidColor(value) {
1005+
const temp = new Option().style;
1006+
temp.color = value;
1007+
return temp.color !== '';
1008+
}
1009+
1010+
if (isValidColor(color)){
1011+
return [$("#poliline"), $("#enjoyhint_arrpw_line")].forEach(function(element){
1012+
element.css("stroke", that.stepData.arrowColor);
1013+
});
1014+
}
1015+
1016+
$("#poliline").css("stroke", "rgb(255,255,255)")
1017+
console.log("Error: invalid color name property - " + color);
1018+
}
1019+
10001020
that.renderArrow = function(data) {
10011021
var x_from = data.x_from || 0;
10021022
var y_from = data.y_from || 0;
@@ -1041,6 +1061,13 @@
10411061
id: "enjoyhint_arrpw_line"
10421062
})
10431063
);
1064+
1065+
$("#poliline").css("stroke", "rgb(255, 255, 255)");
1066+
1067+
if(that.stepData.arrowColor) {
1068+
that.setMarkerColor(that.stepData.arrowColor)
1069+
}
1070+
10441071
that.enjoyhint.removeClass(that.cl.svg_transparent);
10451072
}, that.options.animation_time / 2);
10461073
};

0 commit comments

Comments
 (0)