| |   |
| diff --git a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/app-assistant.js b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/app-assistant.js |
| index 2ae0e7f..72afed5 100644 |
| --- a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/app-assistant.js |
| +++ b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/app-assistant.js |
| @@ -2,6 +2,12 @@ |
| /*global Mojo, Class, $L, Template, WordAssistant, ExcelAssistant, PowerPointAssistant */ |
| /*jslint rhino:true, undef:true */ |
| |
| +PDFVIEW = {}; |
| +PDFVIEW.prefs = { |
| + openLastDoc: false, |
| + autoRotate: false |
| +}; |
| + |
| function AppAssistant(appController) |
| { |
| } |
| @@ -21,6 +27,13 @@ AppAssistant.prototype.handleLaunch = function(params) { |
| |
| if (Mojo.Controller.appInfo.noWindow) |
| { |
| + var cookieModel = new Mojo.Model.Cookie('preferences'); |
| + var cookie = cookieModel.get(); |
| + if (cookie) { |
| + PDFVIEW.prefs.openLastDoc = cookie.openLastDoc; |
| + PDFVIEW.prefs.autoRotate = cookie.autoRotate; |
| + } |
| + |
| var f = function(stageController) { |
| |
| if (launchParams.target) { |
| 1 | 32 | diff --git a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js |
| index 708a648..bfb8e84 100644 |
| index 708a648..9eee05a 100644 |
| 3 | 34 | --- a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js |
| 4 | 35 | +++ b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js |
| @@ -16,13 +16,19 @@ var DocumentAssistant = Class.create({ |
| @@ -9,6 +9,7 @@ var DocumentAssistant = Class.create({ |
| items: [ |
| { label:$L('Open'), command:'file-open-cmd' }, |
| { label:$L('Save As...'), command:'file-saveas-cmd' }, |
| + { label:$L('Preferences'), command:'prefs-cmd' }, |
| { label:$L('Share'), command:'share-cmd' }, |
| { label:$L('Find'), command:'find-cmd', chosen:false }, |
| { label:$L('Bookmarks'), command:'pdf-outline', chosen:false }, |
| @@ -16,13 +17,19 @@ var DocumentAssistant = Class.create({ |
| 6 | 45 | ]}, |
| 7 | 46 | |
| 8 | 47 | cmdMenuModel: { visible: false, items: [ |
| … | … | |
| 62 | 62 | ]}, |
| 63 | 63 | |
| 64 | 64 | numericMap: { |
| @@ -43,6 +49,13 @@ var DocumentAssistant = Class.create({ |
| @@ -43,6 +50,13 @@ var DocumentAssistant = Class.create({ |
| 66 | 66 | |
| 67 | 67 | deactivate: function() { |
| 68 | 68 | this.findField.mojo.blur(); |
| … | … | |
| 76 | 76 | }, |
| 77 | 77 | |
| 78 | 78 | initialize: function(parameters) { |
| @@ -52,6 +65,7 @@ var DocumentAssistant = Class.create({ |
| @@ -52,6 +66,7 @@ var DocumentAssistant = Class.create({ |
| 80 | 80 | this.document_noext = undefined; |
| 81 | 81 | this.saveShowing = false; |
| 82 | 82 | this.currentpage = 1; |
| … | … | |
| 84 | 84 | this.wrongpasscount = -1; |
| 85 | 85 | this.jumptimeout = undefined; |
| 86 | 86 | this.outline_depth = 1; |
| @@ -70,6 +84,7 @@ var DocumentAssistant = Class.create({ |
| @@ -70,6 +85,8 @@ var DocumentAssistant = Class.create({ |
| 88 | 88 | this._loadingSpinnerTimeout = null; |
| 89 | 89 | this._spinnerShowTime = 0; |
| 90 | 90 | this.documentPassword = null; |
| 91 | 91 | + this.currentOrientation = "up"; |
| + this.autoRotate = PDFVIEW.prefs.autoRotate; |
| 92 | 93 | |
| 93 | 94 | // Variables need for find / search |
| 94 | 95 | this.findShowing = false; |
| @@ -97,6 +112,14 @@ var DocumentAssistant = Class.create({ |
| @@ -97,6 +114,23 @@ var DocumentAssistant = Class.create({ |
| 96 | 97 | this.filename = this.filename.substr(7); |
| 97 | 98 | } |
| 98 | 99 | |
| + var lastDocModel = new Mojo.Model.Cookie('lastdoc'); |
| + lastDocModel.put({ |
| + lastdoc: this.filename |
| + }); |
| + |
| 99 | 105 | + this.cookieModel = new Mojo.Model.Cookie(this.filename); |
| 100 | 106 | + var cookie = this.cookieModel.get(); |
| 101 | 107 | + if (cookie) { |
| 102 | 108 | + this.currentpage = cookie.currentpage; |
| 103 | 109 | + this.lastjumpsource = cookie.lastjumpsource; |
| + this.currentOrientation = cookie.currentOrientation; |
| + if (!this.autoRotate) { |
| + this.currentOrientation = cookie.currentOrientation; |
| + } |
| 105 | 113 | + } |
| 106 | 114 | + |
| + this.cmdMenuModel.items[0].items[0].disabled = this.autoRotate; |
| + |
| 107 | 117 | Mojo.Log.info("Filename = '%s'", this.filename); |
| 108 | 118 | }, |
| 109 | 119 | |
| @@ -105,13 +128,16 @@ var DocumentAssistant = Class.create({ |
| @@ -105,13 +139,16 @@ var DocumentAssistant = Class.create({ |
| 111 | 121 | |
| 112 | 122 | try { |
| 113 | 123 | |
| … | … | |
| 136 | 136 | |
| 137 | 137 | // Set up the command buttons (footer) |
| 138 | 138 | this.controller.setupWidget(Mojo.Menu.commandMenu, |
| @@ -241,6 +267,27 @@ var DocumentAssistant = Class.create({ |
| */ |
| }, |
| @@ -220,9 +257,7 @@ var DocumentAssistant = Class.create({ |
| 142 | 140 | |
| orientationChanged: function(orientation) { |
| |
| - return; |
| -/* |
| - if (this.currentOrientation === orientation) |
| + if (!this.autoRotate || this.currentOrientation === orientation) |
| { |
| return; |
| } |
| @@ -238,7 +273,27 @@ var DocumentAssistant = Class.create({ |
| |
| // Re-create the adapter |
| this.dosetup(); |
| -*/ |
| + }, |
| + |
| 143 | 157 | + rotateView: function() { |
| 144 | 158 | + var orientation; |
| 145 | 159 | + if (this.currentOrientation === "left") { |
| … | … | |
| 173 | 173 | + |
| 174 | 174 | + // Re-create the adapter |
| 175 | 175 | + this.dosetup(); |
| + }, |
| + |
| }, |
| |
| 178 | 178 | NeedPassword: function(docid) { |
| @@ -332,8 +387,8 @@ var DocumentAssistant = Class.create({ |
| 179 | 180 | |
| this.document_id = docid; |
| @@ -332,8 +379,8 @@ var DocumentAssistant = Class.create({ |
| |
| 183 | 181 | if (this.currentpage !== undefined) { |
| 184 | 182 | |
| 185 | 183 | - this.cmdMenuModel.items[1].items[0].disabled = (this.currentpage == 1); |
| … | … | |
| 187 | 187 | this.controller.modelChanged(this.cmdMenuModel); |
| 188 | 188 | |
| 189 | 189 | // rebind key event |
| @@ -375,6 +422,13 @@ var DocumentAssistant = Class.create({ |
| @@ -375,6 +430,13 @@ var DocumentAssistant = Class.create({ |
| 191 | 191 | this.JumpToPage( this.currentpage ); |
| 192 | 192 | }, |
| 193 | 193 | |
| … | … | |
| 201 | 201 | forceFootChange: function () { |
| 202 | 202 | |
| 203 | 203 | var goto_page = parseInt(this.controller.get('page_foot_cur_ent').value, 10); |
| @@ -462,7 +516,7 @@ var DocumentAssistant = Class.create({ |
| @@ -462,7 +524,7 @@ var DocumentAssistant = Class.create({ |
| 205 | 205 | |
| 206 | 206 | // Set up the command buttons (footer) |
| 207 | 207 | var page_len = (this.pagecount+'').length; |
| … | … | |
| 210 | 210 | this.controller.modelChanged(this.cmdMenuModel); |
| 211 | 211 | |
| 212 | 212 | this.controller.setMenuVisible(Mojo.Menu.commandMenu, true); |
| @@ -568,6 +622,7 @@ var DocumentAssistant = Class.create({ |
| @@ -568,6 +630,7 @@ var DocumentAssistant = Class.create({ |
| 214 | 214 | |
| 215 | 215 | if (e.keyCode == Mojo.Char.enter) { |
| 216 | 216 | var goto_page = parseInt(this.controller.get('page_foot_cur_ent').value, 10); |
| … | … | |
| 218 | 218 | this.JumpToPage(goto_page); |
| 219 | 219 | this.showFootPageOf(); |
| 220 | 220 | } |
| @@ -783,7 +838,7 @@ var DocumentAssistant = Class.create({ |
| @@ -783,7 +846,7 @@ var DocumentAssistant = Class.create({ |
| 222 | 222 | var splittext = this.filename.split('/'); |
| 223 | 223 | this.document_name = splittext[splittext.length-1]; |
| 224 | 224 | this.document_noext = this.document_name.substr(0, this.document_name.indexOf('.pdf')); |
| … | … | |
| 227 | 227 | new_obj.eventListener = this; |
| 228 | 228 | |
| 229 | 229 | this.adapter = new_obj; |
| @@ -860,6 +915,14 @@ var DocumentAssistant = Class.create({ |
| @@ -809,9 +872,10 @@ var DocumentAssistant = Class.create({ |
| openFilePicker: function () { |
| |
| // Right now lets just open a new window and send it to the recent scene |
| + var openParams = { disableOpenLast: true }; |
| this.controller.serviceRequest('palm://com.palm.applicationManager', { |
| method: 'open', |
| - parameters: { 'id': 'com.palm.app.pdfviewer' } |
| + parameters: { 'id': 'com.palm.app.pdfviewer', params: openParams } |
| }); |
| }, |
| |
| @@ -835,6 +899,10 @@ var DocumentAssistant = Class.create({ |
| this.saveAsDialog(); |
| break; |
| |
| + case 'prefs-cmd': |
| + this.controller.stageController.pushScene('preferences', this); |
| + break; |
| + |
| case 'share-cmd': |
| this.shareDocument(); |
| break; |
| @@ -860,6 +928,14 @@ var DocumentAssistant = Class.create({ |
| 231 | 254 | this.showFootPageOf(); |
| 232 | 255 | break; |
| 233 | 256 | |
| … | … | |
| 265 | 265 | case 'pdf-outline': |
| 266 | 266 | |
| 267 | 267 | // Create the PDF outline/bookmarks |
| @@ -919,7 +982,7 @@ var DocumentAssistant = Class.create({ |
| @@ -919,7 +995,7 @@ var DocumentAssistant = Class.create({ |
| 269 | 269 | var menuAssistant = this.controller._menu.assistant; |
| 270 | 270 | menuAssistant.viewSpacerHeight = 0; |
| 271 | 271 | |
| … | … | |
| 274 | 274 | } |
| 275 | 275 | }, |
| 276 | 276 | |
| @@ -1281,7 +1344,7 @@ SaveAsDialogAssistant = Class.create({ |
| @@ -1281,7 +1357,7 @@ SaveAsDialogAssistant = Class.create({ |
| 278 | 278 | this.documentAssistant.document_name = save_input; |
| 279 | 279 | this.documentAssistant.document_noext = this.documentAssistant.document_name.substr(0, this.documentAssistant.document_name.indexOf('.pdf')); |
| 280 | 280 | |
| … | … | |
| 283 | 283 | |
| 284 | 284 | } |
| 285 | 285 | catch(e) |
| diff --git a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/preferences-assistant.js b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/preferences-assistant.js |
| new file mode 100644 |
| index 0000000..e8fa320 |
| --- /dev/null |
| +++ b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/preferences-assistant.js |
| @@ -0,0 +1,44 @@ |
| +function PreferencesAssistant() { |
| +} |
| + |
| +PreferencesAssistant.prototype.setup = function() { |
| + this.controller.setupWidget('lastDoc', |
| + this.lastDocAttributes = { |
| + trueLabel: $L('On'), |
| + falseLabel: $L('Off') |
| + }, |
| + this.lastDocModel = { |
| + value: PDFVIEW.prefs.openLastDoc, |
| + disabled: false |
| + }); |
| + |
| + this.controller.setupWidget('autoRotate', |
| + this.autoRotateAttributes = { |
| + trueLabel: $L('On'), |
| + falseLabel: $L('Off') |
| + }, |
| + this.autoRotateModel = { |
| + value: PDFVIEW.prefs.autoRotate, |
| + disabled: false |
| + }); |
| + |
| + this.prefsappMenuModel = { |
| + visible: true, |
| + items: [ |
| + Mojo.Menu.editItem, |
| + { label: $L("Help") + "...", command: Mojo.Menu.helpCmd, disabled: true } |
| + ] |
| + }; |
| + this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems: true}, this.prefsappMenuModel); |
| + this.controller.setInitialFocusedElement(null); |
| +} |
| + |
| +PreferencesAssistant.prototype.deactivate = function(event) { |
| + this.cookieModel = new Mojo.Model.Cookie('preferences'); |
| + PDFVIEW.prefs.openLastDoc = this.lastDocModel.value; |
| + PDFVIEW.prefs.autoRotate = this.autoRotateModel.value; |
| + this.cookieModel.put({ |
| + openLastDoc: PDFVIEW.prefs.openLastDoc, |
| + autoRotate: PDFVIEW.prefs.autoRotate |
| + }); |
| +} |
| diff --git a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/recent-assistant.js b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/recent-assistant.js |
| index ad54e64..d1ae625 100644 |
| --- a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/recent-assistant.js |
| +++ b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/recent-assistant.js |
| @@ -56,6 +56,17 @@ var RecentAssistant = Class.create({ |
| { |
| //Mojo.Log.info("RecentAssistant: activate"); |
| |
| + if (!this.disableOpenLast && PDFVIEW.prefs.openLastDoc && this.lastdoc != null) { |
| + this.disableOpenLast = true; |
| + // Push the new document scene |
| + var args = { name: 'document', disableSceneScroller: true }; |
| + var params = { hidemode: 'none', filename: this.lastdoc }; |
| + |
| + this.controller.stageController.pushScene(args, params); |
| + } else { |
| + |
| + this.disableOpenLast = true;; |
| + |
| var params = { |
| // Only show files |
| kind: 'file', |
| @@ -78,10 +89,21 @@ var RecentAssistant = Class.create({ |
| |
| Mojo.FilePicker.pickFile(params, this.controller.stageController); |
| |
| + } |
| }, |
| |
| - initialize: function() |
| + initialize: function(parameters) |
| { |
| + this.disableOpenLast = false; |
| + this.lastdoc = null; |
| + this.cookieModel = new Mojo.Model.Cookie('lastdoc'); |
| + var cookie = this.cookieModel.get(); |
| + if (cookie) { |
| + this.lastdoc = cookie.lastdoc; |
| + } |
| + if (parameters.launchParams) { |
| + this.disableOpenLast = parameters.launchParams.disableOpenLast; |
| + } |
| //Mojo.Log.info("RecentAssistant: initialize"); |
| }, |
| |
| 286 | 381 | diff --git a/usr/palm/applications/com.palm.app.pdfviewer/app/views/document/command_bar.html b/usr/palm/applications/com.palm.app.pdfviewer/app/views/document/command_bar.html |
| 287 | 382 | index 8fe00ff..96851f0 100644 |
| 288 | 383 | --- a/usr/palm/applications/com.palm.app.pdfviewer/app/views/document/command_bar.html |
| … | … | |
| 411 | 411 | <div id="my_spinner" x-mojo-element="Spinner"> </div> |
| 412 | 412 | - <div id="documentname" x-mojo-loc="" class="truncating-text"></div> |
| 413 | 413 | </div> |
| diff --git a/usr/palm/applications/com.palm.app.pdfviewer/app/views/preferences/preferences-scene.html b/usr/palm/applications/com.palm.app.pdfviewer/app/views/preferences/preferences-scene.html |
| new file mode 100644 |
| index 0000000..caa5024 |
| --- /dev/null |
| +++ b/usr/palm/applications/com.palm.app.pdfviewer/app/views/preferences/preferences-scene.html |
| @@ -0,0 +1,41 @@ |
| +<div id="prefs_view" class="prefs-main"> |
| + <div class="palm-page-header"> |
| + <div class="header-icon pdfview"></div> |
| + <div class="header-text"> |
| + <span x-mojo-loc=''>Preferences</span> |
| + </div> |
| + </div> |
| + |
| + <div class="palm-group"> |
| + <div class="palm-group-title"> |
| + <span x-mojo-loc=''>Startup</span> |
| + </div> |
| + <div class="palm-list"> |
| + <div class="palm-row single"> |
| + <div class="palm-row-wrapper"> |
| + <div x-mojo-element="ToggleButton" id="lastDoc"></div> |
| + <div class="title capitalize" x-mojo-loc='' id='lastDocLabel'>Load last document on startup</div> |
| + </div> |
| + </div> |
| + </div> |
| + </div> |
| + |
| + <div class="palm-group"> |
| + <div class="palm-group-title"> |
| + <span x-mojo-loc=''>Rotation</span> |
| + </div> |
| + <div class="palm-list"> |
| + <div class="palm-row single"> |
| + <div class="palm-row-wrapper"> |
| + <div x-mojo-element="ToggleButton" id="autoRotate"></div> |
| + <div class="title capitalize" x-mojo-loc=''>Use accelerometer for rotation</div> |
| + </div> |
| + </div> |
| + </div> |
| + </div> |
| + |
| + <div class="palm-info-text single" x-mojo-loc=''> |
| + Changes will take effect next time a document is opened. |
| + </div> |
| + |
| +</div> |
| diff --git a/usr/palm/applications/com.palm.app.pdfviewer/sources.json b/usr/palm/applications/com.palm.app.pdfviewer/sources.json |
| index ef04afe..b213095 100644 |
| --- a/usr/palm/applications/com.palm.app.pdfviewer/sources.json |
| +++ b/usr/palm/applications/com.palm.app.pdfviewer/sources.json |
| @@ -6,5 +6,6 @@ |
| { "source": "app\/controllers\/error-assistant.js" }, |
| { "source": "app\/controllers\/pagetext-assistant.js" }, |
| { "source": "app\/controllers\/password-assistant.js" }, |
| + { "source": "app\/controllers\/preferences-assistant.js" }, |
| { "source": "javascripts\/widget_find.js" } |
| ] |
| 414 | 472 | diff --git a/usr/palm/applications/com.palm.app.pdfviewer/stylesheets/pdf-viewer.css b/usr/palm/applications/com.palm.app.pdfviewer/stylesheets/pdf-viewer.css |
| index 572f564..8872a4d 100644 |
| index 572f564..76dabb2 100644 |
| 416 | 474 | --- a/usr/palm/applications/com.palm.app.pdfviewer/stylesheets/pdf-viewer.css |
| 417 | 475 | +++ b/usr/palm/applications/com.palm.app.pdfviewer/stylesheets/pdf-viewer.css |
| 418 | 476 | @@ -166,7 +166,7 @@ div.foot-page |
| … | … | |
| 499 | 499 | color: white; |
| 500 | 500 | font-size: 14px; |
| 501 | 501 | font-style: normal; |
| @@ -200,3 +210,46 @@ span.foot-page-cnt |
| @@ -200,3 +210,52 @@ span.foot-page-cnt |
| 503 | 503 | text-transform: none; |
| 504 | 504 | text-decoration: none; |
| 505 | 505 | } |
| … | … | |
| 545 | 545 | +.palm-menu-group .palm-menu-label.palm-disabled:last-child, |
| 546 | 546 | +.palm-menu-group .palm-menu-button.palm-disabled:last-child { |
| 547 | 547 | + -webkit-border-image: url(../images/textfield-noshadow.png) 0 20 0 20 stretch stretch; |
| +} |
| + |
| +.palm-page-header .header-icon.pdfview { |
| + width: 32px; |
| + height: 32px; |
| + background: url(../images/pdfsmall.png) center center no-repeat; |
| 548 | 554 | +} |