var log = false; ReflowReaderFrame = function(parentId, id, documentPath, templatePath, articleId, enginePath) { if(log) console.log("Reader - constructor", parentId, id); this.id = id; this.documentPath = documentPath; this.templatePath = templatePath; this.startingArticle = articleId; this.enginePath = enginePath; if(!enginePath) this.enginePath = "reflow/core/reader.html"; this.iframe = document.createElement('iframe'); this.iframe.id = id; this.iframe.scolling = 'auto'; this.iframe.overflow = 'hidden'; this.iframe.frameborder = 0; this.iframe.style.position = 'relative'; this.iframe.style.display = "block"; this.iframe.style.backgroundColor = "white"; this.setRect(); this.parentDiv = document.getElementById(parentId); if(this.parentDiv){ if(log) console.log("Reader - constructor, parentDiv=",this.parentDiv); this.parentDiv.appendChild(this.iframe); }else{ if(log) console.log("Reader - constructor, parent div not found..."); } }; //Methods ReflowReaderFrame.prototype.setRect = function() { this.iframe.style.left = 0; this.iframe.style.top = 0; this.iframe.width = "100%"; this.iframe.height = "100%"; }; ReflowReaderFrame.prototype.onReaderLoaded= function(){ this.iframe.contentWindow.AF.notificatorHandler = this; }; ReflowReaderFrame.prototype.reload = function() { var obj = this; this.iframe.addEventListener("load", function (){obj.onReaderLoaded.apply(obj)}, true); var src = this.enginePath + "?documentUrl=" + this.documentPath + "&templateUrl=" +this.templatePath; if(this.startingArticle){ src += "&articleId="+ this.startingArticle; this.startingArticle = null; } this.iframe.src = src; }; ReflowReaderFrame.prototype.changeArticle = function(articleId) { if( this.iframe.contentWindow.AF.reader){ this.iframe.contentWindow.AF.reader.gotoArticle(articleId); } }; ReflowReaderFrame.prototype.handleReaderNotification = function(notification) { if(log) console.log("handleReaderNotification",notification); handleReflowReaderNotification(this.id, notification); }; var reflowReaderFrames = new Object(); function createReflowReaderFrame(id, documentPath, templatePath, articleId, enginePath) { if(log) console.log("createReflowReaderFrame",id,documentPath); if(reflowReaderFrames[id]) { return; } reflowReaderFrames[id] = new ReflowReaderFrame("reflowReaderFrame", id, documentPath, templatePath, articleId, enginePath); } function showReflowReaderFrame(id) { if(log) console.log("showReflowReaderFrame",id); if (reflowReaderFrames[id]) { if( reflowReaderFrames[id].parentDiv) { if(reflowReaderFrames[id].parentDiv.style.display != "block") reflowReaderFrames[id].parentDiv.style.display = "block"; reflowReaderFrames[id].parentDiv.style.visibility = "visible"; reflowReaderFrames[id].parentDiv.style.zIndex = "1"; } } } function hideReflowReaderFrame(id) { if(log) console.log("hideReflowReaderFrame",id); if (reflowReaderFrames[id]) { if( reflowReaderFrames[id].parentDiv) { reflowReaderFrames[id].parentDiv.style.display = "none"; reflowReaderFrames[id].parentDiv.style.visibility = "hidden"; reflowReaderFrames[id].parentDiv.style.zIndex = "-1"; } } } function reloadReflowReaderFrame(id) { if(log) console.log("reloadReflowReaderFrame",id); if (reflowReaderFrames[id]) { reflowReaderFrames[id].reload(); } } function removeReflowReaderFrame(id) { if(log) console.log("removeReflowReaderFrame",id); if (reflowReaderFrames[id]) { reflowReaderFrames[id].remove(); reflowReaderFrames[id] = null; } } function changeReflowReaderFrameArticle(id, articleId) { if(log) console.log("removeReflowReaderFrameArticle",id); if (reflowReaderFrames[id]) { reflowReaderFrames[id].changeArticle(articleId); } } if(log) console.log("reflowHelper.js -> script executed");