/* fore.st is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. fore.st is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with fore.st. If not, see < http://www.gnu.org/licenses/ >. (C) 2022- by rainbownapkin, */ //---Global Variables--- CURRENTFPANEL = null; //---Global Functions--- function closeFPanel(cb){//close and null out fpanel, cb function to call when panel is closed $("#fpaneldiv").hide("slide", 250,function(){ if(typeof CURRENTFPANEL.ccall === 'function'){ CURRENTFPANEL.ccall(); } $("#fpcontdiv").empty(); $("#fptitle").html("null Panel"); $("#closefpanel").prop("title", "Close null panel."); CURRENTFPANEL = null; if(typeof cb === 'function'){ cb(); } }); } function sizeFPDiv(){//set inner div height to fix overflow $("#fpaneldiv").outerWidth($("#chatwrap").outerWidth() * 0.7); $("#fpcontdiv").outerHeight($("#fpaneldiv").height() - $("#fptitlediv").outerHeight()); if(CURRENTFPANEL != null){ CURRENTFPANEL.size(); } } function panelbtn(panel){ if($("#fpaneldiv").is(":visible")){//if panel is visible difClose = CURRENTFPANEL != panel;//set difclose to if CURRENTPANEL is the same one attatched to the button we're clicking closeFPanel(function(){//closem panel if(difClose){//if panel.popMenu(panel.data);//pop da panel } }); }else{//else panel.popMenu(panel.data);//pop that bitch son } } //---base panel--- function fpmenu(title, elm, data, ocall, ccall){//fpmenu constructor this.title = title;//title of menu this.elm = elm;//elements to insert (good for simple menus) this.data = data;//menu data (not used for all menus) this.ocall = ocall;//function to call upon menu opening (used for more advanced menus) this.ccall = ccall;//function to call upon menu closing } fpmenu.prototype.popMenu = function(idata){//POP goes the weasal! if(CURRENTFPANEL != null) if(typeof CURRENTFPANEL.ccall === 'function'){ CURRENTFPANEL.ccall(); } this.data = idata//set data $("#fpcontdiv").empty();//empty content div $("#fptitle").html(this.title + " Panel");//set panel tittle $("#closefpanel").prop("title", "Close " + this.title + " panel.");//set close button hover text $("#fpcontdiv").append(this.elm);//append element array this.ocall(this.data);//run open function CURRENTFPANEL = this; $("#fpaneldiv").show("slide", 250, function() {sizeFPDiv()});//show panel and correct size once open } fpmenu.prototype.size = function(){ }; //---base nested menu bar--- function nmenu(title,p,menus,elm){//nested menu constructor(title(defaults to formatted parent title), parent, menu object array,append element(defaults to #fpcontdiv) this.title = (title == null ? p.title.toLowerCase().replace(' ','-') + "-nested" : title); this.parent = p; this.menus = menus; this.elm = (elm == null ? $("#fpcontdiv") : elm); } nmenu.prototype.popMenu = function(){//instantiate nested menu, to be thrown at end of ocall melm = $("
").attr("id",this.title).addClass("nmenu");//create nmenu div par = this.parent; this.elm.append(melm.append( $("