API

API

Reader V3 web API

Source:

Members

(static) linkClick

Simulates a click on a specific link For any page, also not currently displayed

Author:
  • Alessandro Cipolletti
Source:
Example
// Click on first link of page 10
elementWindow.postMessage("linkClick/page/10/index/0", "*");

(static) share

Share on social page

Author:
  • Ronny Tite
Source:
Example
// Share on tacebook page
elementWindow.postMessage("share/network/facebook", "*")
// Share on Twitter page
elementWindow.postMessage("share/network/twitter", "*")
// Share on Pinterest page
elementWindow.postMessage("share/network/pinterest", "*")
// Share on Tumblr page
elementWindow.postMessage("share/network/tumblr", "*")
// Share on Google + page
elementWindow.postMessage("share/network/googleplus", "*")
// Share on Linkedin page
elementWindow.postMessage("share/network/linkedin", "*")

Methods

(static) broadcast(args) → {boolean}

Send a json string to all iframes link with a postMessage Available arguments:

  • mode:
    • "all" send message to all iframe, also the sender
    • "others" send message to all iframe except the sender
  • data:
    • a valid json string
Parameters:
Name Type Description
args Object

The object list

Since:
  • 3.18
Author:
  • Alessandro Cipolletti
Source:
Returns:

return true on success and false on failure

Type
boolean
Example
// (into an iframe link) send a json to all others iframe's links
window.parent.postMessage('broadcast/mode/others/data/{"hello": "world"}', "*");
// to see received json message into the target iframe
window.addEventListener("message", function (e) {
  console.log(e.data);
});

(static) debugDisable() → {boolean}

Disable the debug mode to hide error logs

Author:
  • Bruno Sabot
Source:
Returns:

Always true

Type
boolean
Example
// Disable the debug mode
elementWindow.postMessage("debugDisable", "*");

(static) debugEnable() → {boolean}

Enable the debug mode to see error logs

Author:
  • Bruno Sabot
Source:
Returns:

Always true

Type
boolean
Example
// Enable the debug mode
elementWindow.postMessage("debugEnable", "*");

(static) debugGetState() → {boolean}

Get the current debug state

Author:
  • Bruno Sabot
Source:
Returns:

The current debug state

Type
boolean
Example
// Get the current debug state
window.addEventListener("message", function (event) {
  if (event.data.method === "debugGetState") {
    console.log("debug state is : " + event.data.result);
  }
}, false);
elementWindow.postMessage("debugGetState", "*");

(static) debugToggle() → {boolean}

Toggle the debug mode state

Author:
  • Bruno Sabot
Source:
Returns:

Always true

Type
boolean
Example
// Toggle the debug mode
elementWindow.postMessage("debugToggle", "*");

(static) deviceType() → {string}

Display the device type

Since:
  • 3.18
Author:
  • Ronny Tite
Source:
Returns:

Device type

Type
string
Example
// Display the device type (desktop, tablet, phablet, phone, unknown)
window.addEventListener("message", function (event) {
  if (event.data.method === "deviceType") {
    console.log("This device is a " + event.data.result);
  }
}, false);
elementWindow.postMessage("deviceType", "*");

(static) lightboxClose()

Close the lightbox

Since:
  • 3.18
Author:
  • Ronny Tite
Source:
Example
// Close the menu
elementWindow.postMessage("lightboxClose", "*");

(static) lightboxOpen(args) → {boolean}

Load a lightbox with an url in an iFrame Available arguments:

  • title:
    • the title of the lightbox, if title is not defined , it will be a blank title.
  • url: (Mandatory)
    • The url of the iFrame we want to load , this url need to be encoded;
  • header:
    • Define if the header is visible or not
    • By default, set to "true"
    • Set header to false to hide the header
Parameters:
Name Type Description
args Object

The object list

Since:
  • 3.18
Author:
  • Ronny Tite
Source:
Returns:

return true on success and false on failure

Type
boolean
Example
// Define the arguments
var lightboxTitle = "test";
var lightboxUrl = encodeURIComponent('http://www.webpublication.fr');
var header = false;
// Open the lightbox without title
elementWindow.postMessage("lightboxOpen/url/" + lightboxUrl,"*")
// Open the lightbox with a title with header
elementWindow.postMessage("lightboxOpen/title/" + lightboxTitle + "/url/" + lightboxUrl,"*")
// Open the lightbox without header
elementWindow.postMessage("lightboxOpen/header/false/url/" + lightboxUrl,"*")

(static) menuClose() → {boolean}

Close the menu

Author:
  • Alessandro Cipolletti
Source:
Returns:

Always true

Type
boolean
Example
// Close the menu
elementWindow.postMessage("menuClose", "*");

(static) menuOpen() → {boolean}

Open the menu

Author:
  • Alessandro Cipolletti
Source:
Returns:

Always true

Type
boolean
Example
// Open the menu
elementWindow.postMessage("menuOpen", "*");

(static) menuToggle() → {boolean}

Toggle the menu state

Author:
  • Alessandro Cipolletti
Source:
Returns:

Always true

Type
boolean
Example
// Toggle the menu state
elementWindow.postMessage("menuToggle", "*");

(static) pageCount() → {integer}

Get the amount of pages in the publication

Author:
  • Bruno Sabot
Source:
Returns:

The amount of pages in the publication

Type
integer
Example
// Get the current debug state
window.addEventListener("message", function (event) {
  if (event.data.method === "pageCount") {
    console.log("There is " + event.data.result + " pages in the publication");
  }
}, false);
elementWindow.postMessage("pageCount", "*");

(static) pageLoad(args) → {boolean}

Load a specific page on the publication

The number argument is always used before the name argument

Available arguments:

  • number:
    • load a page number, starting from 1 to the latest page.
    • If the number is higher than the page size, it goes to the latest
    • If the number is lower than one, it does nothing
  • name:
    • The name can be one of next, previous, first or last and goes to the associated page
Parameters:
Name Type Description
args Object

The object list

Author:
  • Bruno Sabot
Source:
Returns:

return true on success and false on failure

Type
boolean
Example
// Go to page 10
elementWindow.postMessage("pageLoad/number/10", "*");
// Go to the next page
elementWindow.postMessage("pageLoad/name/next", "*");
// Go to the previous page
elementWindow.postMessage("pageLoad/name/previous", "*");
// Go to the first page
elementWindow.postMessage("pageLoad/name/first", "*");
// Go to the last page
elementWindow.postMessage("pageLoad/name/last", "*");

(static) pdfDownload() → {boolean}

Download the PDF

Author:
  • Bruno Sabot
Source:
Returns:

return true on success and false on failure

Type
boolean
Example
// Download the PDF
elementWindow.postMessage("pdfDownload", "*");

(static) pdfGetUrl() → {String}

Get the pdf url

Author:
  • Alessandro Cipolletti
Source:
Returns:

return the global url to publication's pdf

Type
String
Example
// if you want to open the pdf of the publication contained inside an iframe
window.addEventListener("message", function (e) {
  if (e.data.method === "pdfGetUrl") {
    location.href = e.data.result;
  }
}, false);
iframeElement.contentWindow.postMessage("pdfGetUrl", "*");

(static) searchOpen() → {boolean}

Open the search panel

Author:
  • Bruno Sabot
Source:
Returns:

return true on success and false on failure

Type
boolean
Example
// Open the search panel
elementWindow.postMessage("searchOpen", "*");

(static) thumbnailOpen() → {boolean}

Open the thumbnails page

Author:
  • Ronny Tite
Source:
Returns:

return true on success and false on failure

Type
boolean
Example
// Open the thumbnails page
elementWindow.postMessage("thumbnailOpen", "*");

(static) viewportGetScale() → {float}

Get the viewport scale value used in the publication that allows the use of retina images

Author:
  • Bruno Sabot
Source:
Returns:

The publication viewport scale

Type
float
Example
// Get the viewport scale
window.addEventListener("message", function (event) {
  if (event.data.method === "viewportGetScale") {
    console.log("The viewport scale value of the publication is " + event.data.result);
  }
}, false);
elementWindow.postMessage("viewportGetScale", "*");

(static) welcomepageOpen() → {boolean}

Open the startup panel

Since:
  • 3.18
Author:
  • Bruno Sabot
Source:
Returns:

return true on success and false on failure

Type
boolean
Example
// Open the startup panel
elementWindow.postMessage("welcomepageOpen", "*");