var EXPORTED_SYMBOLS = ["extLoader"];
var extLoader = { //This name is fix!
oldPointer: null, //This pointer is used to overwrite QFN default keyboard function
pointers: null, //QFN will load this by QuickFoxNotes main object
info: {
GUID: "01f11a36-baf8-4121-b87f-a72646454dfe",
name: "Fullscreen",
developer: "InBasic",
description: "A distraction-free writing; Use F11 to toggle between Window mode and distraction-free mode",
version: "0.4",
qfnVersion: ["2.4C", "*"],
ffVersion: ["3.*", "*"]
},
css: " \
.bld { \
font-weight: bold; \
margin-bottom: 10px; \
} \
.fullscreen-vbox-right, \
.fullscreen-vbox-left { \
background: black; color: \
Turquoise; text-align:center; \
width: 200px; \
} \
",
xul: "\
\
\
\
\
\
\
\
\
\
\
",
initialize: function () {
var window = this.pointers.window;
var document = this.pointers.document;
//
document.getElementById("editor-toolsmenu-extensions").collapsed = false;
//Detect if QFN is opened in Window mode or not; This item only works in Window mode
var windowMode = this.pointers.api.isWindowMode();
document.getElementById("editor-tools-menu-fullscreen").setAttribute("disabled", !windowMode);
//Handle F11 and overwite ESC
this.oldPointer = this.pointers.QFN.keyPress;
this.pointers.QFN.keyPress = this.ctrlESC;
//Handle tab switch
document.getElementById("editor-tabbox-tabs").addEventListener("select", function () {extLoader.renderTabs()}, false);
this.renderTabs();
},
/*Extension's functions (Optional)*/
switchFullscreen: function (active) {
var window = this.pointers.window;
var document = this.pointers.document;
var fullscreen = document.getElementById("editor-tools-menu-fullscreen");
if (fullscreen.getAttribute("disabled") == "true") //Only work for Window mode
return;
if (!active) { //Set active if it is not set by caller
active = (fullscreen.getAttribute('checked') ? false : true);
fullscreen[(active ? "set" : "remove") + "Attribute"]('checked', 'true');
}
window.setTimeout('window.fullScreen = ' + active, 1);
document.getElementById("top-toolbar").collapsed = active;
document.getElementById("fullscreen-vbox-left").collapsed = !active;
document.getElementById("fullscreen-vbox-right").collapsed = !active;
//Hide all borders
document.getElementById("editor-tabbox-tabpanels").setAttribute("class", active ? "plain" : "");
},
/*Overwrite default keyboard function*/
ctrlESC: function (e) {
var window = extLoader.pointers.window;
var document = extLoader.pointers.document;
if (e.keyCode == 122) {
extLoader.switchFullscreen();
return false;
}
if (e.keyCode == 27) {
var fullscreen = document.getElementById("editor-tools-menu-fullscreen");
var active = (fullscreen.getAttribute('checked') ? false : true);
if (!active) {
extLoader.switchFullscreen();
return false;
}
}
return extLoader.oldPointer.apply(extLoader.pointers.QFN, arguments); //Mofidy pointer to original object!
},
/*Overwrite default render tab*/
renderTabs: function () {
var window = extLoader.pointers.window;
var document = extLoader.pointers.document;
var title = "[" + (extLoader.pointers.QFN.tabs.selectedIndex)+ "/" +
(extLoader.pointers.QFN.currentNumberOfPanels - 1) + "] " +
extLoader.pointers.QFN.group.readLabel(extLoader.pointers.QFN.tabs.selectedItem);
document.getElementById("fullscreen-title").value = title;
}
}