-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(audioButtons): begin to componentize audio buttons play/pause an…
…d volume slider
- Loading branch information
Showing
8 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/components/directives/audioButtons/_volumeControl.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
//noinspection CssInvalidHtmlTagReference | ||
.volume-control { | ||
|
||
width: 150px; | ||
|
||
#volumeControl-mute { | ||
|
||
span { | ||
@extend .glyphicon; | ||
font-size: 13.6px; | ||
&:before { | ||
@extend .glyphicon-volume-up:before; | ||
} | ||
|
||
} | ||
|
||
&.muted { | ||
span { | ||
&:before { | ||
@extend .glyphicon-volume-off:before; | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
#volumeControl-slider { | ||
|
||
-webkit-appearance: none; | ||
margin-left:-1px; | ||
position:relative; | ||
|
||
&:focus{ | ||
z-index:1; | ||
} | ||
|
||
// track | ||
$track-height : 2px; | ||
$thumb-size: 10px; | ||
@mixin track { | ||
background-color: $btn-default-color; | ||
border: none; | ||
height: $track-height; | ||
|
||
} | ||
|
||
&::-ms-track { | ||
|
||
color: transparent; | ||
border: none; | ||
@include track; | ||
} | ||
&::-moz-range-track { | ||
@include track; | ||
} | ||
&::-webkit-slider-runnable-track { | ||
@include track; | ||
} | ||
|
||
|
||
// thumb | ||
@mixin thumb { | ||
background: none ; | ||
//background-color: blue; | ||
background-color: $btn-default-bg; | ||
width: $thumb-size; | ||
height: $thumb-size; | ||
border: solid $btn-default-color 1px; | ||
@include rounded-corners(50%); | ||
@include vendor-prefix(box-sizing, border-box); | ||
} | ||
|
||
&::-ms-thumb { | ||
@include thumb; | ||
} | ||
&::-moz-range-thumb { | ||
@include thumb; | ||
} | ||
&::-webkit-slider-thumb { | ||
-webkit-appearance: none; | ||
margin-top: - ($thumb-size / 2 ) + ($track-height/2); | ||
@include thumb; | ||
|
||
} | ||
|
||
// before | ||
&::-ms-fill-lower { | ||
border: none; | ||
background:none; | ||
} | ||
|
||
&::-ms-ticks-before { | ||
display: none; | ||
border: none; | ||
background:none; | ||
} | ||
|
||
// after | ||
&::-ms-fill-upper { | ||
border: none; | ||
background:none; | ||
|
||
} | ||
|
||
&::-ms-ticks-after { | ||
display: none; | ||
border: none; | ||
background:none; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
/* | ||
glyphicon glyphicon-volume-down | ||
glyphicon glyphicon-volume-off | ||
glyphicon glyphicon-volume-up | ||
.decipher-tags-taglist .icon-remove { | ||
@extend .glyphicon; | ||
&:before { | ||
@extend .glyphicon-remove:before; | ||
} | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var audioButtons = audioButtons || angular.module("bawApp.components.audioButtons", []); | ||
|
||
|
||
audioButtons.component("playButton", { | ||
templateUrl: "components/directives/audioButtons/playButton.tpl.html", | ||
controller: [ | ||
"$scope", | ||
"AudioEvent", | ||
"baw.models.AudioEvent", | ||
function ($scope, AudioEventService, AudioEvent) { | ||
|
||
var self = this; | ||
|
||
$scope.audioElement = self.audioElement; | ||
|
||
/** | ||
* Toggles play/pause state when play/pause button is pressed | ||
*/ | ||
$scope.togglePlayState = function togglePlay() { | ||
if ($scope.audioElement.isPlaying) { | ||
$scope.audioElement.pause(); | ||
} | ||
else { | ||
$scope.audioElement.play(); | ||
} | ||
}; | ||
|
||
|
||
}], | ||
bindings: { | ||
audioElement: "=" | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<button ng-disabled="!audioModel.audioElement.canPlay" | ||
class="btn btn-default" | ||
ng-click="togglePlayState()" | ||
title="{{ audioModel.audioElement.isPlaying && 'Pause' || 'Play' }}"> | ||
<span ng-class="{'glyphicon-pause': audioModel.audioElement.isPlaying}" | ||
class="glyphicon glyphicon-play"></span> | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
var audioButtons = audioButtons || angular.module("bawApp.components.audioButtons", []); | ||
|
||
|
||
|
||
audioButtons.component("volumeSlider", { | ||
templateUrl: "components/directives/audioButtons/volumeSlider.tpl.html", | ||
controller: [ | ||
"$scope", | ||
"AudioEvent", | ||
"baw.models.AudioEvent", | ||
function ($scope, AudioEventService, AudioEvent) { | ||
|
||
var self = this; | ||
$scope.audioElement = self.audioElement; | ||
|
||
$scope.muted = self.audioElement.muted; | ||
$scope.volume = self.audioElement.volume; | ||
$scope.displayVolume = self.audioElement.volume * 100; | ||
|
||
|
||
// $scope.$watch("displayVolume", function (newVal, oldVal) { | ||
// | ||
// }); | ||
|
||
$scope.$watch(function () { return self.audioElement.volume; }, function (newVal, oldVal) { | ||
$scope.displayVolume = newVal * 100; | ||
}); | ||
|
||
|
||
// /** | ||
// * Update volume value on scope if volume of audioModel changes | ||
// * TODO: is this necessary? carried over from componentizing listen page volume directive | ||
// */ | ||
// $scope.$watch(function(){ | ||
// return $scope.audioElement ? $scope.audioElement.volume : null; | ||
// }, function volumeChanged(newValue, oldValue) { | ||
// $scope.audioElement.volume = newValue ? newValue * 100 : null; | ||
// }); | ||
|
||
// | ||
// /** | ||
// * Update muted value on scope when muted value on audioModel changes | ||
// * TODO: is this necessary? carried over from componentizing listen-page volume directive | ||
// */ | ||
// $scope.$watch(function(){ | ||
// return $scope.audioElement ? $scope.audioElement.muted : null; | ||
// }, function mutedChanged(newValue, oldValue) { | ||
// //$scope.audioElement.muted = newValue; | ||
// }); | ||
|
||
/** | ||
* toggles the value for muted on the audio model | ||
*/ | ||
$scope.toggleMute = function () { | ||
$scope.audioElement.muted = !$scope.audioElement.muted; | ||
}; | ||
|
||
/** | ||
* changes the value of the volume on the audioModel when the slider is changed | ||
*/ | ||
$scope.sliderChanged = function () { | ||
self.audioElement.volume = $scope.displayVolume / 100; | ||
}; | ||
|
||
|
||
}], | ||
bindings: { | ||
audioElement: "=" | ||
} | ||
}); | ||
|
18 changes: 18 additions & 0 deletions
18
src/components/directives/audioButtons/volumeSlider.tpl.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
<div class="volume-control"> | ||
<div class="input-group-btn"> | ||
<button id="volumeControl-mute" | ||
class="btn btn-default" | ||
ng-click="toggleMute()" | ||
ng-class="{muted: muted}" title="{{muted && 'Unmute' || 'Mute'}}"> | ||
<span></span> | ||
</button> | ||
</div> | ||
<input id="volumeControl-slider" | ||
class="form-control" | ||
type="range" ng-model="displayVolume" | ||
max="100" min="0" | ||
ng-disabled="muted" | ||
ng-change="sliderChanged()" | ||
title="{{ 'Volume ' + (displayVolume | number:0) }}"> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters