Skip to content

Commit f37a881

Browse files
committed
Open stroke dropdown on click instead of focus
1 parent e6846e9 commit f37a881

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

app/shared/ui/pattern-player/pattern-player.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@
3636
</td>
3737
<td ng-repeat="(i,a) in utils.getNumber(pattern.length*pattern.time) track by $index" class="stroke" ng-class="getStrokeClass(i)">
3838
<span ng-if="!editable" class="stroke-inner" uib-tooltip="{{config.strokesDescription[pattern[instrumentKey][i]]}}">{{config.strokes[pattern[instrumentKey][i]] || ' '}}</span>
39-
<a ng-if="editable && !strokeDropdownOpen" href="javascript:" tabindex="0" class="stroke-inner" uib-tooltip="{{config.strokesDescription[pattern[instrumentKey][i]]}}" uib-popover-template="'app/shared/ui/pattern-player/pattern-player-stroke-dropdown.html'" popover-placement="bottom" popover-trigger="focus">{{config.strokes[pattern[instrumentKey][i]] || ' '}}</a>
39+
<a ng-if="editable"
40+
href="javascript:" class="stroke-inner"
41+
uib-tooltip="{{config.strokesDescription[pattern[instrumentKey][i]]}}"
42+
uib-popover-template="'app/shared/ui/pattern-player/pattern-player-stroke-dropdown.html'"
43+
popover-placement="bottom" popover-trigger="manual"
44+
popover-is-open="currentStrokeDropdown[0] == instrumentKey && currentStrokeDropdown[1] == i"
45+
ng-click="clickStroke(instrumentKey, i)">
46+
{{config.strokes[pattern[instrumentKey][i]] || ' '}}
47+
</a>
4048
</td>
4149
</tr>
4250
</tbody>

app/shared/ui/pattern-player/pattern-player.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ angular.module("beatbox")
1111
transclude: true
1212
};
1313
})
14-
.controller("bbPatternController", function($scope, $element, bbPlayer, bbConfig, bbUtils, ng) {
14+
.controller("bbPatternController", function($scope, $element, bbPlayer, bbConfig, bbUtils, ng, $) {
1515
$scope.config = bbConfig;
1616
$scope.utils = bbUtils;
1717

@@ -138,4 +138,26 @@ angular.module("beatbox")
138138
ng.copy($scope.originalPattern, $scope.pattern);
139139
});
140140
};
141+
142+
$scope.clickStroke = function(instrumentKey, i) {
143+
if(ng.equals($scope.currentStrokeDropdown, [ instrumentKey, i ]))
144+
$scope.currentStrokeDropdown = null;
145+
else
146+
$scope.currentStrokeDropdown = [ instrumentKey, i ];
147+
};
148+
149+
var clickHandler = function(e) {
150+
var el = $(e.target);
151+
if(el.closest(".stroke-inner").length == 0 && $scope.currentStrokeDropdown != null ) {
152+
$scope.$apply(function() {
153+
$scope.currentStrokeDropdown = null;
154+
});
155+
}
156+
};
157+
158+
$(document).click(clickHandler);
159+
160+
$scope.$on("$destroy", function() {
161+
$(document).off("click", clickHandler);
162+
});
141163
});

0 commit comments

Comments
 (0)