Commit 9e54b11266d5e7cb437647448eab29e22d675d36

  • avatar
  • Daniel Beames <webos @dbso…er.com>
  • Thu Jan 07 07:24:14 CET 2010
pdf-viewer-pdf-redux for 1.3.5
  
1Copyright (c) 2009 akamil <akamil@gmail.com>
2
3Permission is hereby granted, free of charge, to any person
4obtaining a copy of this software and associated documentation
5files (the "Software"), to deal in the Software without
6restriction, including without limitation the rights to use,
7copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the
9Software is furnished to do so, subject to the following
10conditions:
11
12The above copyright notice and this permission notice shall be
13included in all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
  
1This patch makes multiple changes to the PDF View app to increase its usability:
2- Remove title bar.
3- Make footer buttons translucent.
4- Make page number transparent except when selected.
5- Add button to rotate view between portrait and landscape.
6- Add a "back" button to jump to previous location in a document.
7- Keep track of rotation of and location in a document for 30 days and restore them when reloading the document.
8Index: /usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js
9===================================================================
10--- .orig/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js
11+++ /usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js
12@@ -16,13 +16,19 @@ var DocumentAssistant = Class.create({
13 ]},
14
15 cmdMenuModel: { visible: false, items: [
16+ { items: [
17+ { icon:'sync', command:'rotate-cmd' }
18+ ]},
19 {},
20 { items: [
21 { icon:'back', command:'prev-cmd' },
22 { template: 'document/command_bar', command: 'edit-cmd' },
23 { icon:'forward', command:'next-cmd' }
24 ]},
25- {}
26+ {},
27+ { items: [
28+ { icon:'refresh', command:'last-cmd' }
29+ ]}
30 ]},
31
32 numericMap: {
33@@ -43,6 +49,13 @@ var DocumentAssistant = Class.create({
34
35 deactivate: function() {
36 this.findField.mojo.blur();
37+ var time = new Date();
38+ time.setMonth(time.getMonth()+1);
39+ this.cookieModel.put({
40+ currentpage: this.currentpage,
41+ lastjumpsource: this.lastjumpsource,
42+ currentOrientation: this.currentOrientation
43+ }, time);
44 },
45
46 initialize: function(parameters) {
47@@ -52,6 +65,7 @@ var DocumentAssistant = Class.create({
48 this.document_noext = undefined;
49 this.saveShowing = false;
50 this.currentpage = 1;
51+ this.lastjumpsource = 1;
52 this.wrongpasscount = -1;
53 this.jumptimeout = undefined;
54 this.outline_depth = 1;
55@@ -70,6 +84,7 @@ var DocumentAssistant = Class.create({
56 this._loadingSpinnerTimeout = null;
57 this._spinnerShowTime = 0;
58 this.documentPassword = null;
59+ this.currentOrientation = "up";
60
61 // Variables need for find / search
62 this.findShowing = false;
63@@ -97,6 +112,14 @@ var DocumentAssistant = Class.create({
64 this.filename = this.filename.substr(7);
65 }
66
67+ this.cookieModel = new Mojo.Model.Cookie(this.filename);
68+ var cookie = this.cookieModel.get();
69+ if (cookie) {
70+ this.currentpage = cookie.currentpage;
71+ this.lastjumpsource = cookie.lastjumpsource;
72+ this.currentOrientation = cookie.currentOrientation;
73+ }
74+
75 Mojo.Log.info("Filename = '%s'", this.filename);
76 },
77
78@@ -105,13 +128,16 @@ var DocumentAssistant = Class.create({
79
80 try {
81
82+ // Force landscape view.
83+ this.controller.stageController.setWindowOrientation(this.currentOrientation);
84+
85 this.spinnerRunning = false;
86
87 // Set up the view buttons (header)
88- var viewMenuModel = { visible: false, items: [ { template: 'document/header_bar' } ] };
89+ /*var viewMenuModel = { visible: false, items: [ { template: 'document/header_bar' } ] };
90 this.controller.setupWidget(Mojo.Menu.viewMenu,
91 {menuClass:'no-fade'},
92- viewMenuModel);
93+ viewMenuModel);*/
94
95 // Set up the command buttons (footer)
96 this.controller.setupWidget(Mojo.Menu.commandMenu,
97@@ -221,7 +247,7 @@ var DocumentAssistant = Class.create({
98 orientationChanged: function(orientation) {
99
100 return;
101- if (this.currentOrientation === orientation)
102+ if (this.currentOrientation === orientation)
103 {
104 return;
105 }
106@@ -240,6 +266,27 @@ var DocumentAssistant = Class.create({
107
108 },
109
110+ rotateView: function() {
111+ var orientation;
112+ if (this.currentOrientation === "left") {
113+ orientation = "up";
114+ } else {
115+ orientation = "left";
116+ }
117+
118+ // Replace the adapter with an empty div during the rotate
119+ var viewerObject = this.controller.get('viewerObject');
120+ var emptyDiv = this.controller.document.createElement('div');
121+ emptyDiv.id = 'viewerObject';
122+ viewerObject.parentNode.replaceChild(emptyDiv, viewerObject);
123+
124+ this.currentOrientation = orientation;
125+ this.controller.window.PalmSystem.setWindowOrientation(orientation);
126+
127+ // Re-create the adapter
128+ this.dosetup();
129+ },
130+
131 NeedPassword: function(docid) {
132
133 this.document_id = docid;
134@@ -331,8 +378,8 @@ var DocumentAssistant = Class.create({
135
136 if (this.currentpage !== undefined) {
137
138- this.cmdMenuModel.items[1].items[0].disabled = (this.currentpage == 1);
139- this.cmdMenuModel.items[1].items[2].disabled = (this.currentpage == this.pagecount);
140+ this.cmdMenuModel.items[2].items[0].disabled = (this.currentpage == 1);
141+ this.cmdMenuModel.items[2].items[2].disabled = (this.currentpage == this.pagecount);
142 this.controller.modelChanged(this.cmdMenuModel);
143
144 // rebind key event
145@@ -373,6 +420,13 @@ var DocumentAssistant = Class.create({
146 this.JumpToPage( this.currentpage );
147 },
148
149+ goToLastJumpSource: function () {
150+ var target = this.lastjumpsource;
151+ this.lastjumpsource = this.currentpage;
152+ this.currentpage = target;
153+ this.JumpToPage( this.currentpage );
154+ },
155+
156 forceFootChange: function () {
157
158 var goto_page = parseInt(this.controller.get('page_foot_cur_ent').value, 10);
159@@ -460,7 +514,7 @@ var DocumentAssistant = Class.create({
160
161 // Set up the command buttons (footer)
162 var page_len = (this.pagecount+'').length
163- this.cmdMenuModel.items[1].items[1].width = 60 + (page_len * 15);
164+ this.cmdMenuModel.items[2].items[1].width = 60 + (page_len * 15);
165 this.controller.modelChanged(this.cmdMenuModel);
166
167 this.controller.setMenuVisible(Mojo.Menu.commandMenu, true);
168@@ -565,6 +619,7 @@ var DocumentAssistant = Class.create({
169
170 if (e.keyCode == Mojo.Char.enter) {
171 var goto_page = parseInt(this.controller.get('page_foot_cur_ent').value, 10);
172+ this.lastjumpsource = this.currentpage;
173 this.JumpToPage(goto_page);
174 this.showFootPageOf();
175 }
176@@ -773,7 +828,7 @@ var DocumentAssistant = Class.create({
177 var splittext = this.filename.split('/');
178 this.document_name = splittext[splittext.length-1];
179 this.document_noext = this.document_name.substr(0, this.document_name.indexOf('.pdf'));
180- this.controller.get('documentname').innerHTML = this.document_noext;
181+ //this.controller.get('documentname').innerHTML = this.document_noext;
182 new_obj.eventListener = this;
183
184 this.adapter = new_obj;
185@@ -850,6 +905,14 @@ var DocumentAssistant = Class.create({
186 this.showFootPageOf();
187 break;
188
189+ case 'last-cmd':
190+ this.goToLastJumpSource();
191+ break;
192+
193+ case 'rotate-cmd':
194+ this.rotateView();
195+ break;
196+
197 case 'pdf-outline':
198
199 // Create the PDF outline/bookmarks
200@@ -909,7 +972,7 @@ var DocumentAssistant = Class.create({
201 var menuAssistant = this.controller._menu.assistant;
202 menuAssistant.viewSpacerHeight = 0;
203
204- this.controller.setMenuVisible(Mojo.Menu.viewMenu, visible);
205+ //this.controller.setMenuVisible(Mojo.Menu.viewMenu, visible);
206 }
207 },
208
209@@ -1271,7 +1334,7 @@ SaveAsDialogAssistant = Class.create({
210 this.documentAssistant.document_name = save_input;
211 this.documentAssistant.document_noext = this.documentAssistant.document_name.substr(0, this.documentAssistant.document_name.indexOf('.pdf'));
212
213- this.documentAssistant.controller.get('documentname').innerHTML = this.documentAssistant.document_noext;
214+ //this.documentAssistant.controller.get('documentname').innerHTML = this.documentAssistant.document_noext;
215
216 }
217 catch(e)
218Index: /usr/palm/applications/com.palm.app.pdfviewer/app/views/document/command_bar.html
219===================================================================
220--- .orig/usr/palm/applications/com.palm.app.pdfviewer/app/views/document/command_bar.html
221+++ /usr/palm/applications/com.palm.app.pdfviewer/app/views/document/command_bar.html
222@@ -6,7 +6,7 @@
223 </div>
224 <div id="page_foot_ent" class="foot-page" style="display: none;">
225 <input id="page_foot_cur_ent" class="foot-page-ent" />
226- <span class="foot-page-cnt">&nbsp;/&nbsp;</span>
227- <span id="page_foot_cnt_ent" class="foot-page-cnt"></span>
228+ <span class="foot-page-cnt-inp">&nbsp;/&nbsp;</span>
229+ <span id="page_foot_cnt_ent" class="foot-page-cnt-inp"></span>
230 </div>
231 </div>
232Index: /usr/palm/applications/com.palm.app.pdfviewer/app/views/document/document-scene.html
233===================================================================
234--- .orig/usr/palm/applications/com.palm.app.pdfviewer/app/views/document/document-scene.html
235+++ /usr/palm/applications/com.palm.app.pdfviewer/app/views/document/document-scene.html
236@@ -1,4 +1,4 @@
237-<div id="header" style="height:56px;">
238+<div id="header" style="height:0px;">
239 <div id="findField" name="findField" x-mojo-element="Find"> </div>
240 </div>
241
242Index: /usr/palm/applications/com.palm.app.pdfviewer/app/views/document/header_bar.html
243===================================================================
244--- .orig/usr/palm/applications/com.palm.app.pdfviewer/app/views/document/header_bar.html
245+++ /usr/palm/applications/com.palm.app.pdfviewer/app/views/document/header_bar.html
246@@ -1,4 +1,3 @@
247 <div id="topHead" class="palm-header left">
248 <div id="my_spinner" x-mojo-element="Spinner"> </div>
249- <div id="documentname" x-mojo-loc="" class="truncating-text"></div>
250 </div>
251Index: /usr/palm/applications/com.palm.app.pdfviewer/stylesheets/pdf-viewer.css
252===================================================================
253--- .orig/usr/palm/applications/com.palm.app.pdfviewer/stylesheets/pdf-viewer.css
254+++ /usr/palm/applications/com.palm.app.pdfviewer/stylesheets/pdf-viewer.css
255@@ -166,7 +166,7 @@ div.foot-page
256
257 span.foot-page-cur
258 {
259- color: white;
260+ color: transparent;
261 font-size: 14px;
262 font-style: normal;
263 font-weight: bold;
264@@ -193,6 +193,16 @@ input.foot-page-ent
265
266 span.foot-page-cnt
267 {
268+ color: transparent;
269+ font-size: 14px;
270+ font-style: normal;
271+ font-weight: bold;
272+ text-transform: none;
273+ text-decoration: none;
274+}
275+
276+span.foot-page-cnt-inp
277+{
278 color: white;
279 font-size: 14px;
280 font-style: normal;
281@@ -200,3 +210,46 @@ span.foot-page-cnt
282 text-transform: none;
283 text-decoration: none;
284 }
285+
286+/* Grouped buttons */
287+
288+.palm-menu-group .palm-menu-button,
289+.palm-menu-group .palm-menu-label,
290+.palm-menu-group .palm-menu-text {
291+ top: 0px;
292+ -webkit-border-image: url(../images/textfield-noshadow.png) 0 20 0 20 stretch stretch;
293+}
294+
295+.palm-menu-group .palm-menu-button:first-child,
296+.palm-menu-group .palm-menu-label:first-child,
297+.palm-menu-group .palm-menu-text:first-child {
298+ -webkit-border-image: url(../images/textfield-noshadow.png) 0 20 0 20 stretch stretch;
299+ padding-left: 10px;
300+}
301+
302+.palm-menu-group .palm-menu-button:last-child,
303+.palm-menu-group .palm-menu-label:last-child,
304+.palm-menu-group .palm-menu-text:last-child {
305+ -webkit-border-image: url(../images/textfield-noshadow.png) 0 20 0 20 stretch stretch;
306+ padding-right: 10px;
307+}
308+
309+/* Disabled states for menu system buttons. */
310+
311+.palm-menu-group .palm-menu-text.palm-disabled,
312+.palm-menu-group .palm-menu-label.palm-disabled,
313+.palm-menu-group .palm-menu-button.palm-disabled {
314+ -webkit-border-image: url(../images/textfield-noshadow.png) 0 20 0 20 stretch stretch;
315+}
316+
317+.palm-menu-group .palm-menu-text.palm-disabled:first-child,
318+.palm-menu-group .palm-menu-label.palm-disabled:first-child,
319+.palm-menu-group .palm-menu-button.palm-disabled:first-child {
320+ -webkit-border-image: url(../images/textfield-noshadow.png) 0 20 0 20 stretch stretch;
321+}
322+
323+.palm-menu-group .palm-menu-text.palm-disabled:last-child,
324+.palm-menu-group .palm-menu-label.palm-disabled:last-child,
325+.palm-menu-group .palm-menu-button.palm-disabled:last-child {
326+ -webkit-border-image: url(../images/textfield-noshadow.png) 0 20 0 20 stretch stretch;
327+}