rewrite print to use ng-show and ng-class
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 5 Mar 2013 15:32:22 +0000 (16:32 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 5 Mar 2013 15:32:25 +0000 (16:32 +0100)
This allows much better copy/paste into libreoffice preserving line
wraps along the way. When copy/pasting from Firefox, you won't get
centered lines, but they do work from Chrome, go figure!

app/js/controllers.js
app/partials/list.html.ep
app/registration/view.html.ep

index 092e07e..b98fb99 100644 (file)
@@ -311,14 +311,17 @@ function ListCtrl($scope, $log, Registration, RegistrationTypes, $filter, ValidS
                $scope.pager.page = 1;
        }
 
-       $scope.print_hide = function(v) {
-               $log.info('print_hide', v);
-               if ( v ) {
-                       angular.element('.print-hide').hide();
-                       angular.element('.print-add-center').addClass('print-center');
-               } else {
-                       angular.element('.print-hide').show();
-                       angular.element('.print-add-center').removeClass('print-center');
+       $scope.print = {
+               layout: false,
+               center: '',
+               toggle: function(v) {
+                       $log.info('print_hide', v);
+                       $scope.print.layout = ! $scope.print.layout;
+                       if ( v ) {
+                               $scope.print.center = 'print-center';
+                       } else {
+                               $scope.print.center = '';
+                       }
                }
        }
 }
index d7c974b..586de49 100644 (file)
@@ -60,7 +60,7 @@ All results on single page <b>(can be slow!)</b>
 </label>
 
 <label>
-<input type="checkbox" ng-model="print_hide_status" ng-click="print_hide(print_hide_status)" >
+<input type="checkbox" ng-model="print_hide_status" ng-click="print.toggle(print_hide_status)" >
 Hide parts for print
 </label>
 
index be6d902..70d2ee2 100644 (file)
@@ -1,4 +1,4 @@
-<dt class="print-hide">
+<dt ng-show="! print.layout">
 % if ( my $before = stash('before') ) {
 %= $before->()
 % }
@@ -15,7 +15,7 @@
 
 <dd>
 
-       <p class="well print-hide">
+       <p class="well" ng-show="! print.layout">
         {{registration.user.firstname}}
         {{registration.user.surname}}
         <em>{{registration.user.organization}}</em>,
  </p>
 </p>
 
-<h3 ng-show="registration.work.title" class="print-add-center">
+<h3 ng-show="registration.work.title" ng-class="print.center">
 {{registration.work.title}}
 </h3>
 
-<p ng-repeat="author in registration.work.persons" class="print-add-center">
+<p ng-repeat="author in registration.work.persons" ng-class="print.center">
  {{author.firstname}}
- {{author.surname}}<span class="print-hide">,</span>
- <em class="print-add-center">{{author.organization}}</em>
- <tt class="print-hide">&lt;{{author.email}}&gt;</tt>
+ {{author.surname}}<span ng-show="! print.layout">,</span>
+ <br ng-show="print.layout">
+ <em ng-class="print.center">{{author.organization}}</em>
+ <tt ng-show="! print.layout">&lt;{{author.email}}&gt;</tt>
 </p>
 
 <p class="abstract">{{registration.work.abstract}}</p>