Skip to content

Commit

Permalink
working XLIFF parsing and displaying segments in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishokamp committed Jan 24, 2014
1 parent 7ae1cd8 commit fea8776
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
17 changes: 16 additions & 1 deletion app/scripts/aceEditor/AceCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@

define(['controllers/controllers'], function(controllers) {

controllers.controller('AceCtrl', ['$scope', function($scope) {
controllers.controller('AceCtrl', ['$scope', 'Document', function($scope, Document) {

$scope.fullDoc = Document;

$scope.setText = function(text) {
var editor = $scope.editor;
if (editor) {
editor.setValue(text);
}
};

$scope.setModel = function(index) {
var segName = seg + index;
$scope.segName = $scope.segments[index];
return segName;
}

$scope.getSelection = function() {
var editor = $scope.editor;
Expand Down
16 changes: 16 additions & 0 deletions app/scripts/contentArea/contentArea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';
// Holds all of the translation pairs and handles the interface with the Document service
define(['controllers/controllers'], function(controllers) {

controllers.controller('ContentAreaCtrl', ['$scope', 'Document', function($scope, Document) {
$scope.segments = Document.segments;
$scope.$watch(function() {
return Document.segments.length;
},
function() {
$scope.segments = Document.segments;
//$scope.$apply();
});

}]);
});
1 change: 1 addition & 0 deletions app/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ require(
'services/xliffParser',
'services/document',
'glossary/glossaryFileUpload',
'contentArea/contentArea'
// TODO: ngFileSelect (local directive) has the same name as the library ngFileSelect
//'directives/ngFileSelect',
],
Expand Down
11 changes: 6 additions & 5 deletions app/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ <h3 class="text-muted">editor_components</h3>
<h3 class="text-primary" ng-controller="UploadCtrl">Testing ngFileUpload</h3>
<!-- the upload control should be the same regardless of the UI component -->
<div ng-controller="UploadCtrl">
<!-- TODO: add the ngFileUpload input templates here -->
<!-- <input type="text" ng-model="file"> -->
<input type="file" ng-file-select="onFileSelect($files)" >
<!-- <input type="file" ng-file-select="onFileSelect($files)" multiple> -->
Expand All @@ -23,6 +22,7 @@ <h3 class="text-primary" ng-controller="UploadCtrl">Testing ngFileUpload</h3>
<div ng-file-drop-available="dropSupported=true"
ng-show="!dropSupported">HTML5 Drop File is not supported!</div>
-->

<!-- <button ng-click="upload.abort()">Cancel Upload</button> -->
<ul>
<li ng-repeat="segment in parsed">{{segment}}</li>
Expand Down Expand Up @@ -51,13 +51,14 @@ <h3 class="text-primary">Testing Ace with directives - TODO: add Document servic
</div>
</div>

<div class="container">
<div class="row">

<div class="container" ng-controller="ContentAreaCtrl">
<div ng-repeat="seg in segments" class="row">
<!-- WORKING: insert text from xliff into editors
<!-- TODO: add feature where dragging a word or phrase to target area translates it automatically -->
<div class="edit-area source-area col-md-6" ng-controller="AceCtrl">
<h3>Source Area</h3>
<p>TODO: draggables currently cannot revert inside the edit area</p>
<div class="ace_editor" ui-ace="{ onLoad : aceLoaded }"></div>
<div class="ace_editor" ui-ace="{ onLoad : aceLoaded }" ng-model="fullDoc.segments[$index]"></div>
<button ng-click="getSelection()">get selection</button>
</div>

Expand Down

0 comments on commit fea8776

Please sign in to comment.