def jquery_ready(): jQuery(document).ajaxError(_on_error) def _on_hide(e): mount_html( jQuery(this).find("div.dialog-data"), "<div class='alert alert-info' role='alert'>Sending data - please wait</div>", False, False, ) jQuery("div.dialog-form").on("hide.bs.modal", _on_hide) def _local_fun(): console.log("collapsed") jQuery(".navbar-ex1-collapse").on("hidden.bs.collapse", _local_fun) if window.APPLICATION_TEMPLATE == "traditional": window.ACTIVE_PAGE = Page(0, jQuery("#body_body")) # __new__(Vue({'el': '#body_body'})) else: if window.APPLICATION_TEMPLATE == "modern": txt = jQuery(".page").html() txt2 = jQuery.trim(txt) if txt2: txt = jQuery.trim(jQuery(".page")[0].outerHTML) jQuery(".page").remove() menu = get_menu() menu.new_page(jQuery("title").text(), txt, window.location.href) else: window.ACTIVE_PAGE = Page(0, jQuery("#body_body")) if window.APPLICATION_TEMPLATE == "to_print": __new__(Vue({"el": "#body_body"}))
def _standard_on_data(data): nonlocal href, src_obj if data and "_parent_refr" in data: refresh_fragment(src_obj) else: if window.APPLICATION_TEMPLATE == "modern": mount_html(window.ACTIVE_PAGE.page, data) window.ACTIVE_PAGE.set_href(href) else: mount_html(jQuery("#body_body"), data) window.ACTIVE_PAGE.set_href(href) get_menu().get_active_item().url = href if window.PUSH_STATE: history_push_state("title", href)
def _on_data(data): nonlocal href, src_obj, target if (data and "_parent_refr" in data) or target in ("refresh_obj", "refresh_page"): if target == "refresh_obj": if 'only_table' in href: if not refresh_fragment(src_obj, None, True, data): refresh_fragment(src_obj, None, False, data) else: refresh_fragment(src_obj, None, False, data) else: refresh_fragment(src_obj, None, False, data) else: if window.APPLICATION_TEMPLATE == 'modern': mount_html(window.ACTIVE_PAGE.page, data) window.ACTIVE_PAGE.set_href(href) else: mount_html(jQuery('#body_body'), data) window.ACTIVE_PAGE.set_href(href) get_menu().get_active_item().url = href if window.PUSH_STATE: history_push_state("title", href)
def _on_popstate(e): if e.state: window.PUSH_STATE = False if window.APPLICATION_TEMPLATE == "modern": menu = get_menu().activate(e.state, False) else: x = e.state mount_html(jQuery("#body_body"), LZString.decompress(x[0])) window.ACTIVE_PAGE = Page(0, jQuery("#body_body")) window.ACTIVE_PAGE.set_href(document.location) if window.APPLICATION_TEMPLATE == "standard": jQuery("a.menu-href").removeClass("btn-warning") jQuery("#" + x[1]).addClass("btn-warning") window.PUSH_STATE = True else: if window.APPLICATION_TEMPLATE == "modern": pass else: mount_html(jQuery("#body_body"), "", False, False) window.ACTIVE_PAGE = None if window.APPLICATION_TEMPLATE == "standard": jQuery("a.menu-href").removeClass("btn-warning")
def _on_menu_href(elem, title=None, url=None, txt=None): if window.APPLICATION_TEMPLATE != "traditional": if not title: title = jQuery.trim(jQuery(elem).text()) if txt: value = jQuery("<div>" + txt + "</div>").find("head").find("title").text() if value: title = value menu = get_menu() classname = jQuery(elem).attr("class") if classname and "btn" in classname: if window.WAIT_ICON: window.WAIT_ICON.stop() jQuery(elem).attr("data-style", "zoom-out") jQuery(elem).attr("data-spinner-color", "#FF0000") window.WAIT_ICON = Ladda.create(elem) else: window.WAIT_ICON = None if window.APPLICATION_TEMPLATE == "modern" and menu.is_open(title): menu.activate(title) else: if url: href = url else: href = jQuery(elem).attr("href") href2 = corect_href(href) def _on_new_win(data): nonlocal href, href2, title jQuery("#wiki_start").hide() if window.APPLICATION_TEMPLATE == "modern": id = menu.new_page(title, data, href2) else: mount_html(jQuery("#body_body"), data) window.ACTIVE_PAGE = Page(0, jQuery("#body_body")) window.ACTIVE_PAGE.set_href(href2) if window.PUSH_STATE: id = jQuery(elem).attr("id") if not id: id = "menu_id_" + window.MENU_ID window.MENU_ID = window.MENU_ID + 1 jQuery(elem).attr("id", id) history_push_state(title, href, [data, id]) if window.WAIT_ICON: window.WAIT_ICON.stop() window.WAIT_ICON = None if window.WAIT_ICON2: jQuery("#loading-indicator").hide() window.WAIT_ICON2 = False if ( window.APPLICATION_TEMPLATE == "standard" and classname and "btn" in classname ): jQuery("a.menu-href").removeClass("btn-warning") jQuery(elem).addClass("btn-warning") if txt: _on_new_win(txt) else: if window.WAIT_ICON: window.WAIT_ICON.start() else: window.WAIT_ICON2 = True jQuery("#loading-indicator").show() ajax_get(href2, _on_new_win) jQuery(".navbar-ex1-collapse").collapse("hide") jQuery(".auto-hide").trigger("click") return False