www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

basicViewer.js (2226B)


      1 /*
      2     ***** BEGIN LICENSE BLOCK *****
      3     
      4     Copyright © 2011 Center for History and New Media
      5                      George Mason University, Fairfax, Virginia, USA
      6                      http://zotero.org
      7     
      8     This file is part of Zotero.
      9     
     10     Zotero is free software: you can redistribute it and/or modify
     11     it under the terms of the GNU Affero General Public License as published by
     12     the Free Software Foundation, either version 3 of the License, or
     13     (at your option) any later version.
     14     
     15     Zotero is distributed in the hope that it will be useful,
     16     but WITHOUT ANY WARRANTY; without even the implied warranty of
     17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18     GNU Affero General Public License for more details.
     19     
     20     You should have received a copy of the GNU Affero General Public License
     21     along with Zotero.  If not, see <http://www.gnu.org/licenses/>.
     22     
     23     ***** END LICENSE BLOCK *****
     24 */
     25 
     26 var browser;
     27 function loadURI() {
     28 	browser.loadURI.apply(browser, arguments);
     29 }
     30 
     31 window.addEventListener("load", function() {
     32 	browser = document.getElementById('my-browser');
     33 	
     34 	// align page title with title of shown document
     35 	browser.addEventListener("pageshow", function() {
     36 		document.title = (browser.contentDocument.title
     37 			? browser.contentDocument.title
     38 			: browser.contentDocument.location.href);
     39 	}, false);
     40 	
     41 	// show document
     42 	browser.loadURI.apply(browser, window.arguments);
     43 	
     44 	// XXX Why is this necessary to make the scroll bars appear?
     45 	window.setTimeout(function() {
     46 		document.getElementById("my-browser").style.overflow = "auto";
     47 	}, 0);
     48 }, false);
     49 
     50 window.addEventListener("keypress", function (event) {
     51 	// Cmd-R/Ctrl-R (with or without Shift) to reload
     52 	if (((Zotero.isMac && event.metaKey && !event.ctrlKey)
     53 			|| (!Zotero.isMac && event.ctrlKey))
     54 			&& !event.altKey && event.which == 114) {
     55 		browser.reloadWithFlags(browser.webNavigation.LOAD_FLAGS_BYPASS_CACHE);
     56 	}
     57 });
     58 
     59 // Handle <label class="text-link />
     60 window.addEventListener("click", function (event) {
     61 	if (event.originalTarget.localName == 'label'
     62 			&& event.originalTarget.classList.contains('text-link')) {
     63 		Zotero.launchURL(event.originalTarget.getAttribute('href'));
     64 	}
     65 });