checking in template additions
authorSeth Woodworth <seth@sethish.com>
Tue, 28 May 2013 05:14:50 +0000 (01:14 -0400)
committerSeth Woodworth <seth@sethish.com>
Tue, 28 May 2013 05:14:50 +0000 (01:14 -0400)
karmaworld/assets/vendor/js/viewer.js
karmaworld/templates/notes/note_detail.html
karmaworld/templates/partial/pdfembed.html [new file with mode: 0644]

index 44c2945ad18ebcbca8fd286c1bfb64ce9d48b9c7..ff678d409643292b0d0711b491e78a3a6b8042c2 100644 (file)
@@ -18,7 +18,7 @@
 
 'use strict';
 
-var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
+//var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
 var DEFAULT_SCALE = 'auto';
 var DEFAULT_SCALE_DELTA = 1.1;
 var UNKNOWN_SCALE = 0;
@@ -43,7 +43,7 @@ var FindStates = {
   FIND_PENDING: 3
 };
 
-  PDFJS.workerSrc = 'pdf.js';
+  PDFJS.workerSrc = '/static/vendor/js/pdf.js';
 
 var mozL10n = document.mozL10n || document.webL10n;
 
@@ -608,17 +608,15 @@ var PDFFindBar = {
         break;
 
       case FindStates.FIND_NOTFOUND:
-        findMsg = mozL10n.get('find_not_found', null, 'Phrase not found');
+        findMsg = 'Phrase not found';
         notFound = true;
         break;
 
       case FindStates.FIND_WRAPPED:
         if (previous) {
-          findMsg = mozL10n.get('find_reached_top', null,
-                      'Reached top of document, continued from bottom');
+          findMsg = 'Reached top of document, continued from bottom';
         } else {
-          findMsg = mozL10n.get('find_reached_bottom', null,
-                                'Reached end of document, continued from top');
+          findMsg = 'Reached end of document, continued from top';
         }
         break;
     }
@@ -1213,8 +1211,7 @@ var PDFView = {
           break;
         case 'complete':
           if (!args.data) {
-            PDFView.error(mozL10n.get('loading_error', null,
-                          'An error occurred while loading the PDF.'), e);
+            PDFView.error( 'An error occurred while loading the PDF.', e);
             break;
           }
           PDFView.open(args.data, 0);
@@ -1263,12 +1260,10 @@ var PDFView = {
     var self = this;
     self.loading = true;
     var passwordNeeded = function passwordNeeded(updatePassword, reason) {
-      var promptString = mozL10n.get('request_password', null,
-                                'PDF is protected by a password:');
+      var promptString = 'PDF is protected by a password:';
 
       if (reason === PDFJS.PasswordResponses.INCORRECT_PASSWORD) {
-        promptString += '\n' + mozL10n.get('invalid_password', null,
-                                'Invalid Password.');
+        promptString += '\n' + 'Invalid Password.';
       }
 
       password = prompt(promptString);
@@ -1283,19 +1278,16 @@ var PDFView = {
         self.loading = false;
       },
       function getDocumentError(message, exception) {
-        var loadingErrorMessage = mozL10n.get('loading_error', null,
-          'An error occurred while loading the PDF.');
+        var loadingErrorMessage = 'An error occurred while loading the PDF.';
 
         if (exception && exception.name === 'InvalidPDFException') {
           // change error message also for other builds
-          var loadingErrorMessage = mozL10n.get('invalid_file_error', null,
-                                        'Invalid or corrupted PDF file.');
+          var loadingErrorMessage = 'Invalid or corrupted PDF file.';
         }
 
         if (exception && exception.name === 'MissingPDFException') {
           // special message for missing PDF's
-          var loadingErrorMessage = mozL10n.get('missing_file_error', null,
-                                        'Missing PDF file.');
+          var loadingErrorMessage = 'Missing PDF file.';
 
         }
 
@@ -1450,27 +1442,19 @@ var PDFView = {
    *                            and optionally a 'stack' property.
    */
   error: function pdfViewError(message, moreInfo) {
-    var moreInfoText = mozL10n.get('error_version_info',
-      {version: PDFJS.version || '?', build: PDFJS.build || '?'},
-      'PDF.js v{{version}} (build: {{build}})') + '\n';
+    var moreInfoText = 'PDF.js v{{version}} (build: {{build}})';
     if (moreInfo) {
-      moreInfoText +=
-        mozL10n.get('error_message', {message: moreInfo.message},
-        'Message: {{message}}');
+      moreInfoText += 'Message: {{message}}' + moreInfo.message;
       if (moreInfo.stack) {
         moreInfoText += '\n' +
-          mozL10n.get('error_stack', {stack: moreInfo.stack},
-          'Stack: {{stack}}');
+          'Stack: {{stack}}' + moreInfo.stack;
       } else {
         if (moreInfo.filename) {
           moreInfoText += '\n' +
-            mozL10n.get('error_file', {file: moreInfo.filename},
-            'File: {{file}}');
+            'File: {{file}}' + moreInfo.filename
         }
         if (moreInfo.lineNumber) {
-          moreInfoText += '\n' +
-            mozL10n.get('error_line', {line: moreInfo.lineNumber},
-            'Line: {{line}}');
+          moreInfoText += '\n' + 'Line: {{line}}' + moreInfo.lineNumber;
         }
       }
     }
@@ -1553,7 +1537,7 @@ var PDFView = {
     var pagesCount = pdfDocument.numPages;
     var id = pdfDocument.fingerprint;
     document.getElementById('numPages').textContent =
-      mozL10n.get('page_of', {pageCount: pagesCount}, 'of {{pageCount}}');
+      'of ' + pagesCount;
     document.getElementById('pageNumber').max = pagesCount;
 
     PDFView.documentFingerprint = id;
@@ -1994,8 +1978,7 @@ var PDFView = {
 
   beforePrint: function pdfViewSetupBeforePrint() {
     if (!this.supportsPrinting) {
-      var printMessage = mozL10n.get('printing_not_supported', null,
-          'Warning: Printing is not fully supported by this browser.');
+      var printMessage = 'Warning: Printing is not fully supported by this browser.';
       this.error(printMessage);
       return;
     }
@@ -2012,8 +1995,7 @@ var PDFView = {
       }
     }
     if (alertNotReady) {
-      var notReadyMessage = mozL10n.get('printing_not_ready', null,
-          'Warning: The PDF is not fully loaded for printing.');
+      var notReadyMessage = 'Warning: The PDF is not fully loaded for printing.';
       window.alert(notReadyMessage);
       return;
     }
@@ -2305,7 +2287,7 @@ var PageView = function pageView(container, id, scale,
         }
 
         var element = annotation.getHtmlElement(pdfPage.commonObjs);
-        mozL10n.translate(element);
+        //mozL10n.translate(element);
 
         data = annotation.getData();
         var rect = data.rect;
@@ -2502,8 +2484,7 @@ var PageView = function pageView(container, id, scale,
       }
 
       if (error) {
-        PDFView.error(mozL10n.get('rendering_error', null,
-          'An error occurred while rendering the page.'), error);
+        PDFView.error('An error occurred while rendering the page.', error);
       }
 
       self.stats = pdfPage.stats;
@@ -2632,7 +2613,7 @@ var PageView = function pageView(container, id, scale,
 var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
   var anchor = document.createElement('a');
   anchor.href = PDFView.getAnchorUrl('#page=' + id);
-  anchor.title = mozL10n.get('thumb_page_title', {page: id}, 'Page {{page}}');
+  anchor.title = 'Page ' + id;
   anchor.onclick = function stopNavigation() {
     PDFView.page = id;
     return false;
@@ -2720,8 +2701,7 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
     canvas.width = this.canvasWidth;
     canvas.height = this.canvasHeight;
     canvas.className = 'thumbnailImage';
-    canvas.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
-      {page: id}, 'Thumbnail of Page {{page}}'));
+    canvas.setAttribute('aria-label', 'Thumbnail of Page ' + id);
 
     div.setAttribute('data-loaded', true);
 
@@ -3259,10 +3239,12 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
     PDFJS.disableFontFace = (hashParams['disableFontFace'] === 'true');
   }
 
-  var locale = navigator.language;
-  if ('locale' in hashParams)
-    locale = hashParams['locale'];
-  mozL10n.setLanguage(locale);
+  /*
+   *var locale = navigator.language;
+   *if ('locale' in hashParams)
+   *  locale = hashParams['locale'];
+   *mozL10n.setLanguage(locale);
+   */
 
   if ('textLayer' in hashParams) {
     switch (hashParams['textLayer']) {
@@ -3539,7 +3521,7 @@ function selectScaleOption(value) {
 }
 
 window.addEventListener('localized', function localized(evt) {
-  document.getElementsByTagName('html')[0].dir = mozL10n.getDirection();
+  document.getElementsByTagName('html')[0].dir = 'ltr';
 
   // Adjust the width of the zoom box to fit the content.
   PDFView.animationStartedPromise.then(
index e797918e9538d35dbb2086b61cfb9b28ed250ee8..b6e80f862318fd430b2e1e2dec87a00d33f8cff9 100644 (file)
 
     </div><!-- /course_header -->
     <div id="note_container">
+      {% if  note.file_type == 'pdf' %}
+        <!-- Add pdf.js -->
+        <script>
+          //var DEFAULT_URL = '{{ note.note_file.url }}';
+          var DEFAULT_URL = '{{ STATIC_URL }}Letter_to_Ishman_Click_5-14.pdf';
+        </script>
+        <script type="text/javascript" src="{{ STATIC_URL }}vendor/js/pdf.js"></script>
+        <script src="{{ STATIC_URL }}vendor/js/viewer.js"></script>
+        <link rel="stylesheet" href="{{ STATIC_URL }}vendor/css/viewer.css"> <!-- pdfjs.css -->
+        {% include 'partial/pdfembed.html' %}
+
+      {% else %} {# note.filetype == 'pdf' #}
 
       <div class="row">
         <div class="eight columns centered body_copy">
           {% if note.html %}
-          <div class="note-text">
-            <iframe style="border:none; width:100%;" id="noteframe" src="/raw/{{ note.id }}" onload="autoResize('noteframe')">
-            </iframe>
-          </div> <!-- .note-text -->
-          {% else %}
-          <div class="note-error">
-            This document's content is currently unavailable. Please try again later.
-          </div>
-          {% endif %}
+            <div class="note-text">
+              <iframe style="border:none; width:100%;" id="noteframe" src="/raw/{{ note.id }}" onload="autoResize('noteframe')">
+              </iframe>
+            </div> <!-- .note-text -->
+
+          {% else %} {# note.html #}
+            <div class="note-error">
+              This document's content is currently unavailable. Please try again later.
+            </div>
+          {% endif %} {# note.html #}
+
+      {% endif %} {# note.filetype == 'pdf' #}
 
         </div><!-- /body_copy -->
       </div>
diff --git a/karmaworld/templates/partial/pdfembed.html b/karmaworld/templates/partial/pdfembed.html
new file mode 100644 (file)
index 0000000..158e9b1
--- /dev/null
@@ -0,0 +1,173 @@
+{% comment %}
+<!-- Embed a pdf in HTML using pdf.js -->
+<div id="outerContainer" class="loadingInProgress">
+  <div id="mainContainer">
+    <div id="viewerContainer">
+      <div id="viewer" contextmenu="viewerContextMenu">asdf</div>
+    </div>
+  </div> <!-- mainContainer -->
+</div> <!-- outerContainer -->
+{% endcomment %}
+<!-- PDFviewer start -->
+    <div id="outerContainer" class="loadingInProgress">
+
+      <div id="sidebarContainer">
+        <div id="toolbarSidebar">
+          <div class="splitToolbarButton toggled">
+            <button id="viewThumbnail" class="toolbarButton group toggled" title="Show Thumbnails" tabindex="2" data-l10n-id="thumbs">
+               <span data-l10n-id="thumbs_label">Thumbnails</span>
+            </button>
+            <button id="viewOutline" class="toolbarButton group" title="Show Document Outline" tabindex="3" data-l10n-id="outline">
+               <span data-l10n-id="outline_label">Document Outline</span>
+            </button>
+          </div>
+        </div>
+        <div id="sidebarContent">
+          <div id="thumbnailView">
+          </div>
+          <div id="outlineView" class="hidden">
+          </div>
+        </div>
+      </div>  <!-- sidebarContainer -->
+
+      <div id="mainContainer">
+        <div class="findbar hidden doorHanger hiddenSmallView" id="findbar">
+          <label for="findInput" class="toolbarLabel" data-l10n-id="find_label">Find:</label>
+          <input id="findInput" class="toolbarField" tabindex="21">
+          <div class="splitToolbarButton">
+            <button class="toolbarButton findPrevious" title="" id="findPrevious" tabindex="22" data-l10n-id="find_previous">
+              <span data-l10n-id="find_previous_label">Previous</span>
+            </button>
+            <div class="splitToolbarButtonSeparator"></div>
+            <button class="toolbarButton findNext" title="" id="findNext" tabindex="23" data-l10n-id="find_next">
+              <span data-l10n-id="find_next_label">Next</span>
+            </button>
+          </div>
+          <input type="checkbox" id="findHighlightAll" class="toolbarField">
+          <label for="findHighlightAll" class="toolbarLabel" tabindex="24" data-l10n-id="find_highlight">Highlight all</label>
+          <input type="checkbox" id="findMatchCase" class="toolbarField">
+          <label for="findMatchCase" class="toolbarLabel" tabindex="25" data-l10n-id="find_match_case_label">Match case</label>
+          <span id="findMsg" class="toolbarLabel"></span>
+        </div>
+        <div class="toolbar">
+          <div id="toolbarContainer">
+            <div id="toolbarViewer">
+              <div id="toolbarViewerLeft">
+                <button id="sidebarToggle" class="toolbarButton" title="Toggle Sidebar" tabindex="4" data-l10n-id="toggle_sidebar">
+                  <span data-l10n-id="toggle_sidebar_label">Toggle Sidebar</span>
+                </button>
+                <div class="toolbarButtonSpacer"></div>
+                <button id="viewFind" class="toolbarButton group hiddenSmallView" title="Find in Document" tabindex="5" data-l10n-id="findbar">
+                   <span data-l10n-id="findbar_label">Find</span>
+                </button>
+                <div class="splitToolbarButton">
+                  <button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="6" data-l10n-id="previous">
+                    <span data-l10n-id="previous_label">Previous</span>
+                  </button>
+                  <div class="splitToolbarButtonSeparator"></div>
+                  <button class="toolbarButton pageDown" title="Next Page" id="next" tabindex="7" data-l10n-id="next">
+                    <span data-l10n-id="next_label">Next</span>
+                  </button>
+                </div>
+                <label id="pageNumberLabel" class="toolbarLabel" for="pageNumber" data-l10n-id="page_label">Page: </label>
+                <input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1" tabindex="8">
+                </input>
+                <span id="numPages" class="toolbarLabel"></span>
+              </div>
+              <div id="toolbarViewerRight">
+                <input id="fileInput" class="fileInput" type="file" oncontextmenu="return false;" style="visibility: hidden; position: fixed; right: 0; top: 0" />
+
+                <button id="presentationMode" class="toolbarButton presentationMode hiddenSmallView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
+                  <span data-l10n-id="presentation_mode_label">Presentation Mode</span>
+                </button>
+
+                <button id="openFile" class="toolbarButton openFile hiddenSmallView" title="Open File" tabindex="13" data-l10n-id="open_file">
+                   <span data-l10n-id="open_file_label">Open</span>
+                </button>
+
+                <button id="print" class="toolbarButton print" title="Print" tabindex="14" data-l10n-id="print">
+                  <span data-l10n-id="print_label">Print</span>
+                </button>
+
+                <button id="download" class="toolbarButton download" title="Download" tabindex="15" data-l10n-id="download">
+                  <span data-l10n-id="download_label">Download</span>
+                </button>
+                <!-- <div class="toolbarButtonSpacer"></div> -->
+                <a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="16" data-l10n-id="bookmark"><span data-l10n-id="bookmark_label">Current View</span></a>
+              </div>
+              <div class="outerCenter">
+                <div class="innerCenter" id="toolbarViewerMiddle">
+                  <div class="splitToolbarButton">
+                    <button id="zoomOut" class="toolbarButton zoomOut" title="Zoom Out" tabindex="9" data-l10n-id="zoom_out">
+                      <span data-l10n-id="zoom_out_label">Zoom Out</span>
+                    </button>
+                    <div class="splitToolbarButtonSeparator"></div>
+                    <button id="zoomIn" class="toolbarButton zoomIn" title="Zoom In" tabindex="10" data-l10n-id="zoom_in">
+                      <span data-l10n-id="zoom_in_label">Zoom In</span>
+                     </button>
+                  </div>
+                  <span id="scaleSelectContainer" class="dropdownToolbarButton">
+                     <select id="scaleSelect" title="Zoom" oncontextmenu="return false;" tabindex="11" data-l10n-id="zoom">
+                      <option id="pageAutoOption" value="auto" selected="selected" data-l10n-id="page_scale_auto">Automatic Zoom</option>
+                      <option id="pageActualOption" value="page-actual" data-l10n-id="page_scale_actual">Actual Size</option>
+                      <option id="pageFitOption" value="page-fit" data-l10n-id="page_scale_fit">Fit Page</option>
+                      <option id="pageWidthOption" value="page-width" data-l10n-id="page_scale_width">Full Width</option>
+                      <option id="customScaleOption" value="custom"></option>
+                      <option value="0.5">50%</option>
+                      <option value="0.75">75%</option>
+                      <option value="1">100%</option>
+                      <option value="1.25">125%</option>
+                      <option value="1.5">150%</option>
+                      <option value="2">200%</option>
+                    </select>
+                  </span>
+                </div>
+              </div>
+            </div>
+            <div id="loadingBar">
+              <div class="progress">
+                <div class="glimmer">
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+
+        <menu type="context" id="viewerContextMenu">
+          <menuitem id="firstPage" label="First Page"
+                    data-l10n-id="first_page" ></menuitem>
+          <menuitem id="lastPage" label="Last Page"
+                    data-l10n-id="last_page" ></menuitem>
+          <menuitem id="pageRotateCcw" label="Rotate Counter-Clockwise"
+                    data-l10n-id="page_rotate_ccw" ></menuitem>
+          <menuitem id="pageRotateCw" label="Rotate Clockwise"
+                    data-l10n-id="page_rotate_cw" ></menuitem>
+        </menu>
+
+        <div id="viewerContainer">
+          <div id="viewer" contextmenu="viewerContextMenu"></div>
+        </div>
+
+        <div id="errorWrapper" hidden='true'>
+          <div id="errorMessageLeft">
+            <span id="errorMessage"></span>
+            <button id="errorShowMore" onclick="" oncontextmenu="return false;" data-l10n-id="error_more_info">
+              More Information
+            </button>
+            <button id="errorShowLess" onclick="" oncontextmenu="return false;" data-l10n-id="error_less_info" hidden='true'>
+              Less Information
+            </button>
+          </div>
+          <div id="errorMessageRight">
+            <button id="errorClose" oncontextmenu="return false;" data-l10n-id="error_close">
+              Close
+            </button>
+          </div>
+          <div class="clearBoth"></div>
+          <textarea id="errorMoreInfo" hidden='true' readonly="readonly"></textarea>
+        </div>
+      </div> <!-- mainContainer -->
+
+    </div> <!-- outerContainer -->
+    <div id="printContainer"></div>
+<!-- PDFviewer end -->