Skip to content

Commit

Permalink
worked on selecting in annotation editor
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Feb 1, 2013
1 parent f84d1bc commit d633d03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
33 changes: 25 additions & 8 deletions app/assets/javascripts/angular/directives/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@
}

function updateUnitConversions(scope, imageWidth, imageHeight) {
var conversions = unitConversions(scope.model.media.sampleRate, scope.model.media.window, imageWidth, imageHeight)
var conversions = unitConversions(scope.model.media.sampleRate, scope.model.media.window, imageWidth, imageHeight);

var PRECISION = 6;

return {
conversions : conversions,
Expand Down Expand Up @@ -432,25 +434,40 @@
}
});

/**
* A cross record element checker
*/
bawds.directive('bawChecked', function() {


return {
restict: 'A',
require: 'ngModel',
link: function radioInputType(scope, element, attr, ctrl) {
// make the name unique, if not defined
if (isUndefined(attr.name)) {
if (angularCopies.isUndefined(attr.name)) {
element.attr('name', Number.Unique());
}

element.bind('click', function() {
if (element[0].checked) {

function updateModel() {
// if value is defined, then when checked, set to value
// otherwise just use true/false
var value = angularCopies.isUndefined(attr.value) && element[0].checked || (element[0].checked && attr.value || null) ;
if ( value != ctrl.$viewValue) {
scope.$apply(function() {
ctrl.$setViewValue(attr.value);
ctrl.$setViewValue(value);
});
}
}
});


element.bind('click', updateModel);

element.bind('change', updateModel);

ctrl.$render = function() {
var value = attr.value;
var value = angularCopies.isUndefined(attr.value) ? true : attr.value;

element[0].checked = (value == ctrl.$viewValue);
};

Expand Down
3 changes: 2 additions & 1 deletion app/assets/templates/listen.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ <h3>Annotations</h3>
<tbody>
<tr ng-repeat="ae in model.audioEvents">
<td>
<input type="radio" ng-checked="ae._selected" ng-model="ae._selected" name="selectionRadioGroup" >
<!--<input type="radio" ng-checked="ae._selected" ng-model="ae._selected" name="selectionRadioGroup" >-->
<input type="radio" baw-checked ng-model="ae._selected" name="selectionRadioGroup" >
</td>
<td colspan="{{ae.id && 1 || 2}}">
{{ae.id}}
Expand Down

0 comments on commit d633d03

Please sign in to comment.