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

6 lines
12 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",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"},this.EVENTS={onTopicChanged:null},this.TRANSLATIONS={"Search term too short":"Search term too short","No results":"No results","Please enter 3 or more characters":"Please enter 3 or 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){window.open(t,o)},e.prototype.DoShowTopic=function(e,t,o){var n=this;this.$elTopicContainer.load(o+" "+this.options.elTopicContent,function(e,r,i){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.SelectTopicInToc(s,t,!1),n.DoScrollToAnchorIfNeeded(),n.DoHighlightText(n.searchTerm),imageMapResize(),n.doOnTopicChanged(o)})},e.prototype.DoHandleLink=function(e,t,o,n,r){"_blank"==n||this.isExternalLink(o)||!0===r?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&&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.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 3 or 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(),r=String(n.val());if(e.$elSearchInfo.hide(),o.delete_node(e.$elTreeSearch.find("li").toArray()),r.length<3)e.$elSearchInfo.html(e._("Search term too short")+". "+e._("Please enter 3 or more characters")+"."),e.$elSearchInfo.show();else if(window.bSearchDataLoaded)if(oWl){e.searchEngine.ParseInput(r);var i=e.searchEngine.PerformSearch(oWl);if(0==i.length)e.$elSearchInfo.html(e._("No results")+". "+e._("Please enter 3 or more characters")+"."),e.$elSearchInfo.show();else for(var a="",s=0;s<i.length;s++){a=e.fixURI(aTl[i[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+" ("+i[s][1]+")",a_attr:{href:aTl[i[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"),r=null;n&&(r={url:n,dataType:"json"}),$(o).on("changed.jstree",function(t,o,n,r){if("select_node"===o.action){var i=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){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,i,l,!1)}}).on("ready.jstree",function(t,n){e.SelectTopicInToc("","",!0);var r=parseInt($(o).data("openlvl"),10);r&&e.OpenTreeToLevel($(o),r)}).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:r,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("","",!1),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()}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 r=o.get_node($(this).attr("id"));r.parents.length<=t&&o.open_node(r)})}}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.scrollIntoView()},this.options.animationDelay+50))},e}();e.App=n}(Hnd||(Hnd={}));