Skip to content

Commit c20d055

Browse files
authored
Merge pull request #57 from mlabarca/master
Looks solid @mlabarca , thanks! Changes: * Allow passing a custom button label
2 parents a4918d8 + 890410a commit c20d055

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ and use one of the two configurations:
130130
- `icon` (optional) - Any walkthrough type. If set to any of the predefined values ("single_tap", "double_tap", "swipe_down", "swipe_left", "swipe_right", "swipe_up"), in such case the icon will be bound to focus element (if exists), make sure to add 'ng-walkthrough.tap_icons.js' following instructions above. any other icon can be used and will be loaded from supplied folder
131131
- `main-caption` (optional) - Any walkthrough type. This is the text that will be displayed in the walk-through. Text can be formatted
132132
- `use-button` (optional) - Any walkthrough type. set to 'true' you want a button displayed that most be clicked in order to close walkthrough, otherwise clicking anywhere while walkthrough displayed will close it
133+
- `button-caption` (optional) - Customize the text of the dismiss button if present, default is "Got it!".
133134
- `walkthrough-hero-image` (optional) - Any walkthrough type. Image to display in walkthrough rigth below caption text
134135
- `icon-padding-left` (optional) - Any walkthrough type. Add padding to the icon from the left in percentage
135136
- `icon-padding-top` (optional) - Any walkthrough type. Add padding to the icon from the top in pixels

ng-walkthrough.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ angular.module('ng-walkthrough', [])
7676
hasBackdrop: '=?',
7777
hasGlow: '=?',
7878
useButton: '=?',
79+
buttonCaption: '@?',
7980
walkthroughHeroImage: '@?',
8081
iconPaddingLeft: '@?',
8182
iconPaddingTop: '@?',
@@ -198,7 +199,7 @@ angular.module('ng-walkthrough', [])
198199
scope.closeIcon = close_icon;
199200
},100);
200201
scope.walkthroughIcon = getIcon(scope.icon);
201-
scope.buttonCaption = BUTTON_CAPTION_DONE;
202+
scope.buttonCaption = scope.buttonCaption || BUTTON_CAPTION_DONE;
202203
if (scope.hasBackdrop === undefined){
203204
scope.hasBackdrop = (scope.walkthroughType !== "tip");
204205
}

test/ng-walkthroughSpec.js

+18
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ describe('ng-walkthrough Directive', function() {
127127
expect($scope.isActive).toBe(false);
128128
});
129129

130+
it("Should create a walkthrough button with the custom label provided", function(){
131+
//Arrange
132+
setFixtures('<walkthrough' +
133+
' walkthrough-type="transparency"' +
134+
' is-active="isActive"' +
135+
' use-button=true' +
136+
' button-caption="CUSTOM-LABEL">' +
137+
'</walkthrough>');
138+
$compile($("body"))($scope);
139+
$scope.isActive = true;
140+
$scope.$digest();
141+
142+
var walkthroughButton = $('.walkthrough-done-button');
143+
144+
//Assert
145+
expect(walkthroughButton.text()).toEqual("CUSTOM-LABEL");
146+
});
147+
130148
it("Should not close the walkthrough upon click anywhere other than close button when attribute 'use-button' set to 'true'", function(){
131149
//Arrange
132150
//Arrange

0 commit comments

Comments
 (0)