fceux/web/help/js/app.min.js

6 lines
13 KiB
JavaScript

"use strict";/*!
* HelpNDoc HTML template
* Copyright (C) IBE Software - All rights reserved.
* Can only be used in documentation generated by HelpNDoc: http://www.helpndoc.com
*/
var __extends=this&&this.__extends||function(){var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])})(t,o)};return function(t,o){function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}}(),Exception=function(e){function t(t){var o=e.call(this,t)||this;return o.message=t,o.name="Exception",o.message=t,o}return __extends(t,e),t.prototype.toString=function(){return"["+this.name+']: "'+this.message+'"'},t}(Error),EInvalidHtmlElement=function(e){function t(t){var o=e.call(this,t)||this;return o.message=t,o.name="EInvalidHtmlElement",o}return __extends(t,e),t}(Exception),Hnd;!function(e){var t=function(){function e(){}return e}();e.AppOptions=t;var o=function(){function e(){}return e}();e.AppEvents=o;var n=function(){function e(e){this.DEFAULTS={animationDelay:200,elHeadroom:"header",elInlineTocContainer:"#inline-toc",elMask:".mask",elModal:"#hndModal",elSearchForm:"#search-form",elSearchInfo:"#search-info",elSearchInput:"#input-search",elToggler:".hnd-toggle",elTopicContainer:"article",elTopicContent:"#topic-content",elTreeContainers:".tree-container",elTreeSearch:"#search-tree",classNavExpandedSmall:"sm-nav-expanded",classNavExpandedMedium:"md-nav-expanded",inlineTocHeadings:"h1,h2,h3",searchEngineMinChars:3},this.EVENTS={onTopicChanged:null},this.TRANSLATIONS={"Search term too short":"Search term too short","No results":"No results","Please enter more characters":"Please enter more characters","Word list not ready yet. Please wait until the word list is fully downloaded":"Word list not ready yet. Please wait until the word list is fully downloaded","Incorrect or corrupt search data. Please check your HelpNDoc template":"Incorrect or corrupt search data. Please check your HelpNDoc template","Related topics...":"Related topics...","Loading...":"Loading...",Close:"Close"},this.options=$.extend({},this.DEFAULTS,e),this.Init()}return e.prototype._=function(e){var t=this.TRANSLATIONS[e];return t||e},e.prototype.doOnJsTreeError=function(e,t){console.error("JSTree Error",t);var o=e.find(".jstree-loading");o&&(t.error&&"ajax"==t.error?o.html('<strong>Loading Error</strong>: Please make sure your web-server is correctly configured to serve JSON files. <a href="https://www.helpndoc.com/sites/default/files/documentation/html/Tableofcontentsisemptyorloadingi.html">Learn more...</a>'):o.html("<strong>Error</strong>: please check your web-developer console for more information."))},e.prototype.doOnTopicChanged=function(e){this.EVENTS.onTopicChanged&&("string"==typeof e&&""!==e||(e=$(this.options.elTopicContent).data("hnd-id")+".html"),this.EVENTS.onTopicChanged(e))},e.prototype.doProcessParameters=function(){var e=URI(location.href),t=e.search(!0);t.tab&&""!=t.tab&&$("#tab-"+t.tab).tab("show"),t.search&&void 0!==t.search&&""!=t.search&&(this.$elSearchInput.val(t.search),this.$elSearchInput.keyup(),this.$elSearchForm.submit())},e.prototype.fixURI=function(e){return e.replace(/\%u00A0/g,"%20")},e.prototype.getAnchor=function(){return window.location.hash.substr(1)},e.prototype.isExternalLink=function(e){var t=function(e){return 0===e.indexOf("//")&&(e=location.protocol+e),e.toLowerCase().replace(/([a-z])?:\/\//,"$1").split("/")[0]};return(e.indexOf(":")>-1||e.indexOf("//")>-1)&&t(location.href)!==t(e)||-1==["htm","html"].indexOf(new URI(e).suffix().toLowerCase())},e.prototype.DoShowExternalUrl=function(e,t,o){"mailto:"==t.substring(0,7).toLowerCase()?location.href=t:window.open(t,o)},e.prototype.DoShowTopic=function(e,t,o){var n=this;this.$elTopicContainer.load(o+" "+this.options.elTopicContent,function(e,i,r){var a=$(n.options.elTopicContent),s=a.data("hnd-id");if(window.history.pushState({id:s,title:t},t,o),"undefined"!=typeof ga&&ga)try{if(void 0!==ga.getAll&&ga.getAll&&ga.getAll()[0]){ga.getAll()[0].send("pageview",location.pathname)}else ga("send","pageview",location.pathname)}catch(e){console.error("[HND-APP] An error occurred while using Google Analytics tracking code =>",e.toString())}n.DoUpdateInlineToc(),n.SelectTopicInToc(s,t,!0),n.DoScrollToAnchorIfNeeded(),n.DoHighlightText(n.searchTerm),imageMapResize(),n.doOnTopicChanged(o)})},e.prototype.DoHandleLink=function(e,t,o,n,i){"_blank"==n||this.isExternalLink(o)||!0===i?this.DoShowExternalUrl(t,o,n):this.DoShowTopic(e,t,o)},e.prototype.DoHighlightText=function(e){try{this.$elTopicContainer.unmark(),e&&""!==e&&this.$elTopicContainer.mark(e,{accuracy:"complementary",diacritics:!1})}catch(e){console.error("[HND-APP] An error occurred while highlighting the search term =>",e.toString())}},e.prototype.DoScrollToAnchorIfNeeded=function(){var e=decodeURIComponent(this.getAnchor());if(""!==e){var t=$("a[name='"+e+"']");if(t&&t.length||(t=$("a[name='"+e.toLowerCase()+"']")),t&&t.length||(t=$("#"+e)),t&&void 0!==t&&t.offset&&t.offset()){var o=this.$elHeadroom.position().top<0?0:this.$elHeadroom.outerHeight(!0)+5;$("html,body").animate({scrollTop:t.offset().top-o},"fast")}else console.error("[HND-APP] Unkonwn or invalid anchor =>",e)}else $("html,body").animate({scrollTop:0},"fast")},e.prototype.DoUpdateInlineToc=function(){var e=this.options.inlineTocHeadings,t=$(this.options.elInlineTocContainer),o=e.split(","),n=0,i=[t];$(this.$elTopicContainer).find(e).attr("id",function(e,t){return t||function(e){0===e.length&&(e="heading");for(var t=e.replace(/[^a-zA-Z0-9]+/g,"_"),o="",n=1;null!==document.getElementById(t+o);)o="_"+n++;return t+o}($(this).text())}).each(function(){var e=$(this),t=$.map(o,function(t,o){return e.is(t)?o:void 0})[0];if(t>n){var r=i[0].children("li:last")[0];r&&i.unshift($("<ul/>").appendTo(r))}else i.splice(0,Math.min(n-t,Math.max(i.length-1,0)));$("<li/>").appendTo(i[0]).append($("<a/>").text(e.text()).attr("href","#"+e.attr("id"))),n=t})},e.prototype.InitHeadRoom=function(){if(this.$elHeadroom=$(this.options.elHeadroom),!this.$elHeadroom.length)throw new EInvalidHtmlElement("Invalid headroom element ["+this.options.elHeadroom+"]");new Headroom(this.$elHeadroom.get(0),{offset:100,tolerance:5,classes:{initial:"animated",pinned:"slideDown",unpinned:"slideUp"},onUnpin:function(){$("body").addClass("header-up")},onPin:function(){$("body").removeClass("header-up")}}).init()},e.prototype.InitMask=function(){var e=this;this.$elMask=$(this.options.elMask),this.$elMask.on("click",function(t){var o=e.$elMask.data("toggle");o&&$("body").removeClass(o)})},e.prototype.InitModal=function(){this.$elModal=$(this.options.elModal),this.$elModal.find(".modal-title").html(this._("Related topics...")),this.$elModal.find(".modal-btn-close").html(this._("Close")),this.$elModal.modal({show:!1})},e.prototype.InitResponsiveClasses=function(){function e(){var e="",o=$(window).width();if(o<768?e="mode-xs":o<992?e="mode-sm":o<1200?e="mode-md":o>=1200&&(e="mode-lg"),e!=t){if($("body").removeClass(["mode-xs","mode-sm","mode-md","mode-lg"]).addClass(e),"mode-xs"==e)$("header").css("padding-left",""),$("#main").css("margin-left",""),$("#panel-left").css("width","");else if("mode-xs"==t){var n=$("#hnd-splitter").offset().left;$("header").css("padding-left",n+14),$("#main").css("margin-left",n),$("#panel-left").css("width",n)}t=e}}var t="";e(),$(window).on("resize",function(){e()})},e.prototype.InitSplitter=function(){var e=0,t=parseInt($("nav").css("width"),10),o=$("#hnd-splitter");o&&o.length&&interact("#hnd-splitter").draggable({cursorChecker:function(){return"ew-resize"},startAxis:"xy",lockAxis:"x",listeners:{move:function(t){e+=t.dx,t.target.style.transform="translateX("+e+"px)"},end:function(o){$("header").css("padding-left",t+14+e),$("#main").css("margin-left",t+e),$("#panel-left").css("width",t+e)}}})},e.prototype.InitSearchEngine=function(){this.searchEngine=new HndJsSe},e.prototype.InitSearchForm=function(){var e=this;this.$elTreeSearch=$(this.options.elTreeSearch).first(),this.$elSearchForm=$(this.options.elSearchForm),this.$elSearchInfo=$(this.options.elSearchInfo),this.$elSearchInput=$(this.options.elSearchInput),this.$elSearchInfo.html(this._("Please enter more characters")+"."),this.$elSearchInfo.show(),this.$elSearchInput.on("keyup",function(t){e.searchTerm=String(e.$elSearchInput.val()),e.DoHighlightText(e.searchTerm)}),this.$elSearchForm.on("submit",function(t){t.preventDefault();var o=e.$elTreeSearch.jstree(!0),n=$(t.target).find('input[type="text"]').first(),i=String(n.val());if(e.$elSearchInfo.hide(),o.delete_node(e.$elTreeSearch.find("li").toArray()),i.length<e.options.searchEngineMinChars)e.$elSearchInfo.html(e._("Search term too short")+". "+e._("Please enter more characters")+"."),e.$elSearchInfo.show();else if(window.bSearchDataLoaded)if(oWl){e.searchEngine.ParseInput(i);var r=e.searchEngine.PerformSearch(oWl);if(0==r.length)e.$elSearchInfo.html(e._("No results")+". "+e._("Please enter more characters")+"."),e.$elSearchInfo.show();else for(var a="",s=0;s<r.length;s++){a=e.fixURI(aTl[r[s][0]][1]);try{a=decodeURIComponent(a)}catch(e){try{a=unescape(a)}catch(e){console.warn("Node text contains illegal characters :",a)}}o.create_node("#",{parent:"#",text:a+" ("+r[s][1]+")",a_attr:{href:aTl[r[s][0]][0]}})}}else e.$elSearchInfo.html(e._("Incorrect or corrupt search data. Please check your HelpNDoc template")),e.$elSearchInfo.show();else e.$elSearchInfo.html(e._("Word list not ready yet. Please wait until the word list is fully downloaded.")),e.$elSearchInfo.show()})},e.prototype.InitToggler=function(){var e=this;this.$elToggler=$(this.options.elToggler),this.$elToggler.on("click",function(t){var o=window.matchMedia("(max-width: 768px)").matches?e.options.classNavExpandedSmall:e.options.classNavExpandedMedium;$("body").toggleClass(o)})},e.prototype.InitTrees=function(){var e=this;this.$elTreeContainers=$(this.options.elTreeContainers),this.$elTreeContainers.each(function(t,o){var n=$(o).data("url"),i=null;n&&(i={url:n,dataType:"json"}),$(o).on("changed.jstree",function(t,o,n,i){if("select_node"===o.action){var r=o.node.a_attr.href,a=o.node.id,s=o.node.text,l=o.node.a_attr.target||"_self",c=$(o.event.target).data("related");if(c&&c.length){c.sort(function(e,t){var o=e.title.toUpperCase(),n=t.title.toUpperCase();return o<n?-1:o>n?1:0});for(var h='<ul class="relative-list">',d=0;d<c.length;d++)h=h+'<li><a href="'+c[d].url+'">'+c[d].title+"</a></li>";h+="</ul>",e.$elModal.find(".modal-body").html(h),e.$elModal.modal("show")}else $("body").removeClass("sm-nav-expanded"),e.DoHandleLink(a,s,r,l,!1)}}).on("ready.jstree",function(t,n){e.SelectTopicInToc("","",!0);var i=parseInt($(o).data("openlvl"),10);i&&e.OpenTreeToLevel($(o),i)}).jstree({core:{animation:e.options.animationDelay,check_callback:$(o).is($(e.options.elTreeSearch)),multiple:!1,strings:{"Loading ...":e._("Loading...")},themes:{dots:!1,responsive:!0},data:i,error:function(t){e.doOnJsTreeError($(o),t)}},types:{default:{icon:"icon-default"}},plugins:["types"]})})},e.prototype.InitHistory=function(){var e=this;window.onpopstate=function(t){e.$elTopicContainer.load(window.location+" "+e.options.elTopicContent,function(t,o,n){e.SelectTopicInToc("","",!0),e.DoScrollToAnchorIfNeeded()})}},e.prototype.InitLinks=function(){var e=this,t=function(t){t.preventDefault();var o=t.currentTarget;e.$elModal&&e.$elModal.modal("hide"),$("body").removeClass("sm-nav-expanded"),e.DoHandleLink("","",o.href,o.target,!0===t.ctrlKey)};this.$elTopicContainer.on("click","a",t),$(".modal-body").on("click","a",t)},e.prototype.Init=function(){if(this.$elTopicContainer=$(this.options.elTopicContainer),!this.$elTopicContainer)throw new EInvalidHtmlElement("Invalid topic container element ["+this.options.elTopicContainer+"]")},e.prototype.Boot=function(){try{this.InitTrees(),this.InitLinks(),this.InitHistory(),this.InitToggler(),this.InitMask(),this.InitModal(),this.InitSearchEngine(),this.InitSearchForm(),this.InitHeadRoom(),this.InitSplitter(),this.InitResponsiveClasses(),this.doOnTopicChanged(),this.doProcessParameters(),this.DoUpdateInlineToc()}catch(e){console.error("[HND-APP] An error occurred while booting the application =>",e.toString())}},e.prototype.OpenTreeToLevel=function(e,t){try{if(t){var o=$(e).jstree(!0);o&&$(o.get_json("#",{no_a_attr:!0,no_children:!1,no_data:!0,no_id:!1,no_li_attr:!0,no_state:!0,flat:!0})).each(function(e,n){var i=o.get_node($(this).attr("id"));i.parents.length<=t&&o.open_node(i)})}}catch(e){console.error("[HND-APP] An error occurred while opening the tree =>",e.toString())}},e.prototype.SelectTopicInToc=function(e,t,o){void 0===o&&(o=!1),"string"==typeof e&&""!==e||(e=$(this.options.elTopicContent).data("hnd-id")),"string"==typeof t&&""!==t||(t=$(this.options.elTopicContent).data("hnd-title")),"string"==typeof e&&""!==e&&(this.$elTreeContainers.jstree("deselect_all",!0),this.$elTreeContainers.jstree("select_node",e,!0,!1),t&&""!==t&&(document.title=t),o&&setTimeout(function(){var t=document.getElementById(e+"_anchor");t&&t.focus()},this.options.animationDelay+50))},e}();e.App=n}(Hnd||(Hnd={}));