Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
PDFVIewer js cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyMcMillan committed Oct 27, 2012
1 parent f31f9ab commit 60c88f7
Showing 1 changed file with 61 additions and 82 deletions.
143 changes: 61 additions & 82 deletions iOS/PDFViewer/www/PDFViewer.js
@@ -1,89 +1,68 @@
//PDFViewer based on ChildBrowser
//PDFViewer based on ChildBrowser

/* MIT licensed */
// (c) 2010 Jesse MacFadyen, Nitobi


(function() {

var cordovaRef = window.PhoneGap || window.Cordova || window.cordova; // old to new fallbacks

function PDFViewer() {
// Does nothing
}

// Callback when the location of the page changes
// called from native
PDFViewer._onLocationChange = function(newLoc)
{
window.plugins.PDFViewer.onLocationChange(newLoc);
};

// Callback when the user chooses the 'Done' button
// called from native
PDFViewer._onClose = function()
{
window.plugins.PDFViewer.onClose();
};

// Callback when the user chooses the 'open in Safari' button
// called from native
PDFViewer._onOpenExternal = function()
{
window.plugins.PDFViewer.onOpenExternal();
};

// Pages loaded into the PDFViewer can execute callback scripts, so be careful to
// check location, and make sure it is a location you trust.
// Warning ... don't exec arbitrary code, it's risky and could fuck up your app.
// called from native
PDFViewer._onJSCallback = function(js,loc)
{
// Not Implemented
//window.plugins.PDFViewer.onJSCallback(js,loc);
};


var cordovaRef = window.PhoneGap || window.Cordova || window.cordova; // old to new fallbacks

function PDFViewer() {
// Does nothing
}


// Callback when the user chooses the 'Done' button
// called from native
PDFViewer._onClose = function()
{
window.plugins.PDFViewer.onClose();
};



/* The interface that you will use to access functionality */

// Show a webpage, will result in a callback to onLocationChange
PDFViewer.prototype.showWebPage = function(loc)
{
cordovaRef.exec("PDFViewerCommand.showPDF", loc);
};

// close the browser, will NOT result in close callback
PDFViewer.prototype.close = function()
{
cordovaRef.exec("PDFViewerCommand.close");
};

// Not Implemented
PDFViewer.prototype.jsExec = function(jsString)
{
// Not Implemented!!
//PhoneGap.exec("PDFViewerCommand.jsExec",jsString);
};

// Note: this plugin does NOT install itself, call this method some time after deviceready to install it
// it will be returned, and also available globally from window.plugins.PDFViewer
PDFViewer.install = function()
{
if(!window.plugins) {
window.plugins = {};
}
if ( ! window.plugins.PDFViewer ) {
window.plugins.PDFViewer = new PDFViewer();
}

};


if (cordovaRef && cordovaRef.addConstructor) {
cordovaRef.addConstructor(PDFViewer.install);
} else {
console.log("PDFViewer Cordova Plugin could not be installed.");
return null;
}


})();
// Show a webpage, will result in a callback to onLocationChange
PDFViewer.prototype.showPDF = function(loc)
{
cordovaRef.exec("PDFViewerCommand.showPDF", loc);
};
// close the browser, will NOT result in close callback
PDFViewer.prototype.close = function()
{
cordovaRef.exec("PDFViewerCommand.close");
};
// Not Implemented
PDFViewer.prototype.jsExec = function(jsString)
{
// Not Implemented!!
//PhoneGap.exec("PDFViewerCommand.jsExec",jsString);
};
// Note: this plugin does NOT install itself, call this method some time after deviceready to install it
// it will be returned, and also available globally from window.plugins.PDFViewer
PDFViewer.install = function()
{
if(!window.plugins) {
window.plugins = {};
}
if ( ! window.plugins.PDFViewer ) {
window.plugins.PDFViewer = new PDFViewer();
}
};
if (cordovaRef && cordovaRef.addConstructor) {
cordovaRef.addConstructor(PDFViewer.install);
} else {
console.log("PDFViewer Cordova Plugin could not be installed.");
return null;
}
})();

0 comments on commit 60c88f7

Please sign in to comment.