Skip to content

Commit d4270c7

Browse files
committed
Merge pull request mozilla#2415 from brendandahl/gaia-activity-bar
Add close button and title bar for b2g.
2 parents 9bf3180 + df0d9be commit d4270c7

File tree

6 files changed

+34
-14
lines changed

6 files changed

+34
-14
lines changed

make.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ target.b2g = function() {
522522
defines: defines,
523523
copy: [
524524
[COMMON_WEB_FILES, B2G_BUILD_CONTENT_DIR + '/web'],
525+
['web/viewer-b2g.css', B2G_BUILD_CONTENT_DIR + '/web'],
525526
['web/locale.properties', B2G_BUILD_CONTENT_DIR + '/web'],
526527
['external/webL10n/l10n.js', B2G_BUILD_CONTENT_DIR + '/web']
527528
],

web/viewer-b2g.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
html {
2+
/* Font size is needed to make the activity bar the corect size. */
3+
font-size: 10px;
4+
}
5+
6+
#outerContainer {
7+
position: relative;
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<section role="region" id="activityHeader" class="skin-organic">
2+
<header>
3+
<button id="activityClose"><span class="icon icon-close"></span></button>
4+
<h1 id="activityTitle"></h1>
5+
</header>
6+
</section>

web/viewer-snippet-b2g.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<!-- This snippet is used in b2g, see Makefile -->
22
<link rel="resource" type="application/l10n" href="locale.properties"/>
3+
<link rel="stylesheet" href="/shared/style/headers.css" type="text/css" />
4+
<link rel="stylesheet" href="viewer-b2g.css" type="text/css" />
35
<script type="text/javascript" src="l10n.js"></script>
46
<script type="text/javascript" src="../build/pdf.js"></script>
57
<script type="text/javascript" src="/shared/js/async_storage.js"></script>

web/viewer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
</head>
7979

8080
<body>
81+
<!--#if B2G-->
82+
<!--#include viewer-snippet-b2g-activity-header.html-->
83+
<!--#endif-->
8184
<div id="outerContainer">
8285

8386
<div id="sidebarContainer">

web/viewer.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -912,14 +912,21 @@ var PDFView = {
912912
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
913913
this.url = url;
914914
try {
915-
document.title = decodeURIComponent(getFileName(url)) || url;
915+
this.setTitle(decodeURIComponent(getFileName(url)) || url);
916916
} catch (e) {
917917
// decodeURIComponent may throw URIError,
918918
// fall back to using the unprocessed url in that case
919-
document.title = url;
919+
this.setTitle(url);
920920
}
921921
},
922922

923+
setTitle: function pdfViewSetTitle(title) {
924+
document.title = title;
925+
//#if B2G
926+
// document.getElementById('activityTitle').textContent = title;
927+
//#endif
928+
},
929+
923930
open: function pdfViewOpen(url, scale, password) {
924931
var parameters = {password: password};
925932
if (typeof url === 'string') { // URL
@@ -1291,7 +1298,7 @@ var PDFView = {
12911298
pdfTitle = info['Title'];
12921299

12931300
if (pdfTitle)
1294-
document.title = pdfTitle + ' - ' + document.title;
1301+
self.setTitle(pdfTitle + ' - ' + document.title);
12951302
});
12961303
},
12971304

@@ -3242,17 +3249,10 @@ window.addEventListener('afterprint', function afterPrint(evt) {
32423249
//#if B2G
32433250
//window.navigator.mozSetMessageHandler('activity', function(activity) {
32443251
// var url = activity.source.data.url;
3245-
// // Temporarily get the data here since the cross domain xhr is broken in
3246-
// // the worker currently, see bug 761227.
3247-
// var params = {
3248-
// url: url,
3249-
// error: function(e) {
3250-
// PDFView.error(mozL10n.get('loading_error', null,
3251-
// 'An error occurred while loading the PDF.'), e);
3252-
// }
3253-
// };
3254-
// PDFJS.getPdf(params, function successCallback(data) {
3255-
// PDFView.open(data, 0);
3252+
// PDFView.open(url);
3253+
// var cancelButton = document.getElementById('activityClose');
3254+
// cancelButton.addEventListener('click', function() {
3255+
// activity.postResult('close');
32563256
// });
32573257
//});
32583258
//#endif

0 commit comments

Comments
 (0)