From df0d9be4a5f8d9f5431b7041b7a749cbe83f858f Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 28 Nov 2012 11:02:56 -0800 Subject: [PATCH] Add close button and title bar for b2g. --- make.js | 1 + web/viewer-b2g.css | 8 ++++++ web/viewer-snippet-b2g-activity-header.html | 6 +++++ web/viewer-snippet-b2g.html | 2 ++ web/viewer.html | 3 +++ web/viewer.js | 28 ++++++++++----------- 6 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 web/viewer-b2g.css create mode 100644 web/viewer-snippet-b2g-activity-header.html diff --git a/make.js b/make.js index ab183ec37..a5145875f 100644 --- a/make.js +++ b/make.js @@ -522,6 +522,7 @@ target.b2g = function() { defines: defines, copy: [ [COMMON_WEB_FILES, B2G_BUILD_CONTENT_DIR + '/web'], + ['web/viewer-b2g.css', B2G_BUILD_CONTENT_DIR + '/web'], ['web/locale.properties', B2G_BUILD_CONTENT_DIR + '/web'], ['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web'] ], diff --git a/web/viewer-b2g.css b/web/viewer-b2g.css new file mode 100644 index 000000000..1b6f749af --- /dev/null +++ b/web/viewer-b2g.css @@ -0,0 +1,8 @@ +html { + /* Font size is needed to make the activity bar the corect size. */ + font-size: 10px; +} + +#outerContainer { + position: relative; +} diff --git a/web/viewer-snippet-b2g-activity-header.html b/web/viewer-snippet-b2g-activity-header.html new file mode 100644 index 000000000..041643896 --- /dev/null +++ b/web/viewer-snippet-b2g-activity-header.html @@ -0,0 +1,6 @@ +
+
+ +

+
+
diff --git a/web/viewer-snippet-b2g.html b/web/viewer-snippet-b2g.html index be2c883bd..84e95eea9 100644 --- a/web/viewer-snippet-b2g.html +++ b/web/viewer-snippet-b2g.html @@ -1,5 +1,7 @@ + + diff --git a/web/viewer.html b/web/viewer.html index 3d6bec6a4..e69f5aca6 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -78,6 +78,9 @@ limitations under the License. + + +
diff --git a/web/viewer.js b/web/viewer.js index db6ff2f3e..259dda22b 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -912,14 +912,21 @@ var PDFView = { setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { this.url = url; try { - document.title = decodeURIComponent(getFileName(url)) || url; + this.setTitle(decodeURIComponent(getFileName(url)) || url); } catch (e) { // decodeURIComponent may throw URIError, // fall back to using the unprocessed url in that case - document.title = url; + this.setTitle(url); } }, + setTitle: function pdfViewSetTitle(title) { + document.title = title; +//#if B2G +// document.getElementById('activityTitle').textContent = title; +//#endif + }, + open: function pdfViewOpen(url, scale, password) { var parameters = {password: password}; if (typeof url === 'string') { // URL @@ -1291,7 +1298,7 @@ var PDFView = { pdfTitle = info['Title']; if (pdfTitle) - document.title = pdfTitle + ' - ' + document.title; + self.setTitle(pdfTitle + ' - ' + document.title); }); }, @@ -3242,17 +3249,10 @@ window.addEventListener('afterprint', function afterPrint(evt) { //#if B2G //window.navigator.mozSetMessageHandler('activity', function(activity) { // var url = activity.source.data.url; -// // Temporarily get the data here since the cross domain xhr is broken in -// // the worker currently, see bug 761227. -// var params = { -// url: url, -// error: function(e) { -// PDFView.error(mozL10n.get('loading_error', null, -// 'An error occurred while loading the PDF.'), e); -// } -// }; -// PDFJS.getPdf(params, function successCallback(data) { -// PDFView.open(data, 0); +// PDFView.open(url); +// var cancelButton = document.getElementById('activityClose'); +// cancelButton.addEventListener('click', function() { +// activity.postResult('close'); // }); //}); //#endif