Skip to content

Commit

Permalink
decent prototype of dynamic toolbar toggled from nav
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishokamp committed Aug 29, 2014
1 parent abdbdad commit 1deb846
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
10 changes: 1 addition & 9 deletions app/scripts/contentArea/contentArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,18 @@ angular.module('controllers').controller('ContentAreaCtrl',
['$scope', 'Document', 'session', '$location', '$state', '$stateParams', '$modal', '$rootScope', '$log',
function($scope, Document, session, $location, $state, $stateParams, $modal, $rootScope, $log) {

// Working - make sure that we get the project from the server before this controller is initialized
// if (Document.segments.length === 0) {
// $state.go('projects.list');
// }

// TODO: focus the edit area -- edit areas call the translation memory onFocus
// start by focusing project.currentSegment


$scope.language = Document.targetLang;
$scope.numSegments = Document.segments.length;
// each segment is a reference to the segment in the Document service
$scope.segments = Document.segments;

// this fires once the view content has completely loaded
$rootScope.$on('repeat-finished', function (event) {
session.focusNextSegment();
var segmentId = $stateParams.segmentId;
if (segmentId) {
var anchorElem = document.getElementById('segment-' + segmentId);
$log.log(anchorElem);
if (anchorElem) {
var top = anchorElem.offsetTop;
$("body").animate({scrollTop: top-60}, "slow");
Expand Down
3 changes: 0 additions & 3 deletions app/scripts/directives/target-area.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
<div class="inline">
<button logger="copy-source-punctuation" ng-click="copySourcePunctuation($index)" tooltip="copy punctuation from source" tooltip-placement="bottom" ng-disabled="segmentState.completed" class="btn btn-primary cat-glyph" ng-show="session.showSmartButtons"><span class="glyphicon glyphicon-share-alt"></span></button>
</div>
<div class="inline">
<button logger="toggle-toolbar" ng-click="toggleToolbar()" tooltip="toggle toolbar" tooltip-placement="bottom" ng-disabled="segmentState.completed" class="btn btn-primary cat-glyph"><span class="glyphicon glyphicon-wrench"></span></button>
</div>
<div class="inline">
<button logger="remove-extra-whitespace" ng-click="removeExtraWhitespace()" tooltip="remove extra whitespace" tooltip-placement="bottom" ng-disabled="segmentState.completed" class="btn btn-primary cat-glyph"><span class="glyphicon glyphicon-flash"></span></button>
</div>
Expand Down
12 changes: 6 additions & 6 deletions app/scripts/directives/toolbar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
angular.module('directives').directive('toolbar', ['session', '$log', '$timeout', function(session, $log, $timeout) {
angular.module('directives').directive('toolbar', ['session', '$log', function(session, $log) {
return {
restrict: 'E',
scope: {
visible: '='
},
templateUrl: 'scripts/directives/toolbar.html',
link: function($scope, el, attrs){
$log.log('ATTRS');
$log.log(attrs);
$scope.$watch(
function () {
return session.activeSegment;
Expand All @@ -23,6 +18,11 @@ angular.module('directives').directive('toolbar', ['session', '$log', '$timeout'
$(above).after(el);
}
);

// when the directive gets initialized
var index = session.activeSegment;
var above = $('#segment-' + index);
$(above).after(el);
}
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ angular.module('services')

// Functions controlling movement through the document
// order of segments
activeSegment: 0,
activeSegment: undefined,
getNextSegment: function() {
if (SegmentOrder.order.length === 0)
SegmentOrder.getOrder(Document.segments);
Expand Down
5 changes: 3 additions & 2 deletions app/views/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

<!-- this is a singleton directive containing the toolbar -->
<!-- TODO: active-segment should be passed into the directive -->
<toolbar class="info-toolbar" visible="visible.toolbar"></toolbar>
<toolbar class="info-toolbar" ng-show="visible.toolbar"></toolbar>

<!-- translation area -->
<div class="edit-area-wrapper" ng-controller="ContentAreaCtrl" ng-show="tabs[0].active">
<!-- repeat for each segment -->
<!-- working - how to identify each segment uniquely -->
<div class="segment row" ng-class="{ pending: !segmentState.completed, completed: segmentState.completed}"
<div class="segment row"
ng-class="{ pending: !segmentState.completed, completed: segmentState.completed}"
id="segment-{{$index}}"
ng-controller="SegmentAreaCtrl"
ng-repeat="seg in segments"
Expand Down

0 comments on commit 1deb846

Please sign in to comment.