3914768085
The logic for the hand tool is implemented in a separate project, maintained at https://github.com/Rob--W/grab-to-pan.js Integration notes - Added toggle as an entry under the Secondary toolbar - Added shortcut "h" to toggle hand tool (to-do: document this in wiki after merge). This shortcut is also used in Adobe's Acrobat Reader. To-do: localizations for: hand_tool_enable.title= hand_tool_enable_label= hand_tool_disable.title= hand_tool_disable_label= To-do (wish): persistence of hand tool preference, preferably a global setting. secondaryToolbarButton-handTool.png created by Stephen Horlander <shorlander@mozilla.com>
63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
/* Copyright 2013 Mozilla Foundation
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
/* globals mozL10n, GrabToPan, PDFView */
|
|
|
|
'use strict';
|
|
|
|
//#include grab_to_pan.js
|
|
var HandTool = {
|
|
initialize: function handToolInitialize(options) {
|
|
var toggleHandTool = options.toggleHandTool;
|
|
this.handTool = new GrabToPan({
|
|
element: options.container,
|
|
onActiveChanged: function(isActive) {
|
|
if (isActive) {
|
|
toggleHandTool.title =
|
|
mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
|
|
toggleHandTool.firstElementChild.textContent =
|
|
mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
|
|
} else {
|
|
toggleHandTool.title =
|
|
mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
|
|
toggleHandTool.firstElementChild.textContent =
|
|
mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
|
|
}
|
|
}
|
|
});
|
|
toggleHandTool.addEventListener('click', this.handTool.toggle, false);
|
|
// TODO: Read global prefs and call this.handTool.activate() if needed.
|
|
},
|
|
|
|
toggle: function handToolToggle() {
|
|
this.handTool.toggle();
|
|
},
|
|
|
|
enterPresentationMode: function handToolEnterPresentationMode() {
|
|
if (this.handTool.active) {
|
|
this.wasActive = true;
|
|
this.handTool.deactivate();
|
|
}
|
|
},
|
|
|
|
exitPresentationMode: function handToolExitPresentationMode() {
|
|
if (this.wasActive) {
|
|
this.wasActive = null;
|
|
this.handTool.activate();
|
|
}
|
|
}
|
|
};
|