Esempio n. 1
0
def refresh_fragment(data_item_to_refresh, fun=None, only_table=False, data=None, remove_pagination=False):
    only_table_href = False
    refr_block = data_item_to_refresh.closest('.refr_object')
    if refr_block.hasClass('refr_target'):
        target = refr_block
    else:
        target = refr_block.find('.refr_target')
        if target.length>1:
            target = jQuery(target[0])

    if only_table:
        datatable = target.find('table[name=tabsort].datatable')
        if datatable.length>0:
            datatable_refresh(datatable)
            target.find('.inline_dialog').remove()
            if fun:
                fun()
            return True
        datatable = target.find('table[name=tabsort].tabsort')
        if datatable.length > 0:
           only_table_href = True
           target.find('.inline_dialog').remove()
           target = datatable.closest('div.tableframe')
        else:
            return False

    if data:
        mount_html(target, data)
        if fun:
            fun()
    else:
        if refr_block.hasClass('refr_source'):
            src = refr_block
        else:
            src = refr_block.find('.refr_source')
        if src.length > 0:
            src = jQuery(src[0])
            href = src.attr('href')

            if remove_pagination:
                href = remove_page_from_href(href)

            if src.prop("tagName") == 'FORM':
                def _refr2(data):
                    mount_html(target, data)
                    if fun:
                        fun()
                ajax_post(corect_href(href, only_table_href), src.serialize(), _refr2)
            else:
                def _on_load(responseText):
                    if fun:
                        fun()
                ajax_load(target, corect_href(href, only_table_href), _on_load)
        else:
            if fun:
                fun()
    return True
Esempio n. 2
0
def only_get(url, elem, e):
    href = url
    href2 = corect_href(url)
    target = "refresh_obj"
    src_obj = jQuery(elem)

    refr_block = src_obj.closest('.refr_object')
    if refr_block.hasClass('refr_source'):
        src = refr_block
    else:
        src = refr_block.find('.refr_source')
    if src.length > 0:
        src.attr('href', href2)
        src.attr('action', href2)

    def _on_data(data):
        nonlocal href, src_obj, target

        if (data and "_parent_refr" in data and 'YES' in data or 'OK' in data):
            if not refresh_fragment(jQuery(elem), None, True):
                return refresh_fragment(jQuery(elem), None, False)

    if src_obj.hasClass("page-link"):
        ajax_submit(src, _on_data)
    else:
        ajax_get(href2, _on_data)
Esempio n. 3
0
def on_popup_in_form(elem):
    jQuery(elem).attr("data-style", "zoom-out")
    jQuery(elem).attr("data-spinner-color", "#FF0000")
    window.WAIT_ICON = Ladda.create(elem)
    if window.WAIT_ICON:
        window.WAIT_ICON.start()

    jQuery('body').addClass('shown_inline_dialog')
    jQuery(elem).closest('div.Dialog').find(".inline_dialog").remove()

    window.COUNTER = window.COUNTER + 1
    id = window.COUNTER

    href2 = corect_href(jQuery(elem).attr("href"))
    new_fragment = jQuery("<div class='refr_source refr_object inline_dialog hide' id='IDIAL_"+id+"' href='"+href2+"'>" + INLINE_TABLE_HTML.replace("{{title}}",elem.getAttribute('title')) + "</div>")
    new_fragment.insertAfter(jQuery(elem).closest("div.form-group"))
    elem2 = new_fragment.find(".refr_target")

    def _on_load(responseText, status, response):
        jQuery('#IDIAL_'+id).hide()
        jQuery('#IDIAL_'+id).removeClass('hide')
        jQuery('#IDIAL_'+id).show("slow")
        if status!='error':
            _dialog_loaded(False, elem2)
            on_dialog_load()
        if window.WAIT_ICON:
            window.WAIT_ICON.stop()
            window.WAIT_ICON = None
    ajax_load(elem2, href2, _on_load)

    return False
Esempio n. 4
0
 def _load_subform(index, obj):
     content = jQuery(this).find(".subform_content")
     if content.length>0:
         href = jQuery(this).attr("href")
         def _finish():
             pass
         ajax_load(content, corect_href(href), _finish)
Esempio n. 5
0
    def _load_subform(index, obj):
        content = jQuery(this).find(".subform_content")
        if content.length > 0:
            href = jQuery(this).attr("href")

            def _finish():
                pass

            ajax_load(content, corect_href(href), _finish)
Esempio n. 6
0
def on_popup_inline(url, elem, e):
    jelem = jQuery(elem)
    if jelem.hasClass('edit'):
        return on_popup_edit_new(url, elem, e)
    if jelem.hasClass('delete'):
        return on_popup_delete(url, elem, e)
    if jelem.hasClass('info'):
        return on_popup_delete(url, elem, e)

    jelem.attr("data-style", "zoom-out")
    jelem.attr("data-spinner-color", "#FF0000")
    window.WAIT_ICON = Ladda.create(elem)
    if window.WAIT_ICON:
        window.WAIT_ICON.start()

    jQuery('body').addClass('shown_inline_dialog')

    jelem.closest('table').find(".inline_dialog").remove()

    window.COUNTER = window.COUNTER + 1
    id = window.COUNTER

    href2 = corect_href(jQuery(elem).attr("href"))

    new_fragment = jQuery(
        "<tr class='refr_source refr_object inline_dialog hide' id='IDIAL_" +
        id + "' href='" + href2 + "'><td colspan='20'>" +
        INLINE_TABLE_HTML.replace("{{title}}", elem.getAttribute('title')) +
        "</td></tr>")
    new_fragment.insertAfter(jQuery(elem).closest("tr"))

    elem2 = new_fragment.find(".refr_target")

    def _on_load(responseText, status, response):
        nonlocal new_fragment
        new_fragment.removeClass('hide')
        if status != 'error':
            _dialog_loaded(False, elem2)
            on_dialog_load()
        if window.WAIT_ICON:
            window.WAIT_ICON.stop()
            window.WAIT_ICON = None

    ajax_load(elem2, href2, _on_load)
    return False
Esempio n. 7
0
def refresh_current_object(url, elem, e):
    href = url
    href2 = corect_href(url)
    target = "refresh_obj"
    src_obj = jQuery(elem)

    refr_block = src_obj.closest('.refr_object')
    if refr_block.hasClass('refr_source'):
        src = refr_block
    else:
        src = refr_block.find('.refr_source')
    if src.length > 0:
        src.attr('href', href2)
        src.attr('action', href2)

    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)

    if src_obj.hasClass("page-link"):
        ajax_submit(src, _on_data)
    else:
        ajax_get(href2, _on_data)
Esempio n. 8
0
def refresh_current_object(url, elem, e):
    href = url
    href2 = corect_href(url)
    target = "refresh_obj"
    src_obj = jQuery(elem)

    refr_block = src_obj.closest('.refr_object')
    if refr_block.hasClass('refr_source'):
        src = refr_block
    else:
        src = refr_block.find('.refr_source')
    if src.length>0:
        src.attr('href', href2)
        src.attr('action', href2)

    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)

    if src_obj.hasClass("page-link"):
        ajax_submit(src, _on_data)
    else:
        ajax_get(href2, _on_data)
Esempio n. 9
0
def on_popup_inline(url, elem, e):
    jelem = jQuery(elem)
    if jelem.hasClass('edit'):
        return on_popup_edit_new(url, elem, e)
    if jelem.hasClass('delete'):
        return on_popup_delete(url, elem, e)
    if jelem.hasClass('info'):
        return on_popup_delete(url, elem, e)

    jelem.attr("data-style", "zoom-out")
    jelem.attr("data-spinner-color", "#FF0000")
    window.WAIT_ICON = Ladda.create(elem)
    if window.WAIT_ICON:
        window.WAIT_ICON.start()

    jQuery('body').addClass('shown_inline_dialog')

    jelem.closest('table').find(".inline_dialog").remove()

    window.COUNTER = window.COUNTER    + 1
    id = window.COUNTER

    href2 = corect_href(jQuery(elem).attr("href"))

    new_fragment = jQuery("<tr class='refr_source refr_object inline_dialog hide' id='IDIAL_"+id+"' href='"+href2+"'><td colspan='20'>" + INLINE_TABLE_HTML.replace("{{title}}",elem.getAttribute('title')) + "</td></tr>")
    new_fragment.insertAfter(jQuery(elem).closest("tr"))

    elem2 = new_fragment.find(".refr_target")

    def _on_load(responseText, status, response):
        nonlocal new_fragment
        new_fragment.removeClass('hide')
        if status!='error':
            _dialog_loaded(False, elem2)
            on_dialog_load()
        if window.WAIT_ICON:
            window.WAIT_ICON.stop()
            window.WAIT_ICON = None
    ajax_load(elem2, href2, _on_load)
    return False
Esempio n. 10
0
def on_popup_in_form(elem):
    jQuery(elem).attr("data-style", "zoom-out")
    jQuery(elem).attr("data-spinner-color", "#FF0000")
    window.WAIT_ICON = Ladda.create(elem)
    if window.WAIT_ICON:
        window.WAIT_ICON.start()

    jQuery('body').addClass('shown_inline_dialog')
    jQuery(elem).closest('div.Dialog').find(".inline_dialog").remove()

    window.COUNTER = window.COUNTER + 1
    id = window.COUNTER

    href2 = corect_href(jQuery(elem).attr("href"))
    new_fragment = jQuery(
        "<div class='refr_source refr_object inline_dialog hide' id='IDIAL_" +
        id + "' href='" + href2 + "'>" +
        INLINE_TABLE_HTML.replace("{{title}}", elem.getAttribute('title')) +
        "</div>")
    new_fragment.insertAfter(jQuery(elem).closest("div.form-group"))
    elem2 = new_fragment.find(".refr_target")

    def _on_load(responseText, status, response):
        jQuery('#IDIAL_' + id).hide()
        jQuery('#IDIAL_' + id).removeClass('hide')
        jQuery('#IDIAL_' + id).show("slow")
        if status != 'error':
            _dialog_loaded(False, elem2)
            on_dialog_load()
        if window.WAIT_ICON:
            window.WAIT_ICON.stop()
            window.WAIT_ICON = None

    ajax_load(elem2, href2, _on_load)

    return False
Esempio n. 11
0
    def _on_submit(e):
        self = jQuery(this)
        if jQuery(this).hasClass("DialogForm"):
            e.preventDefault()
            on_edit_ok(False, jQuery(this))
            return

        if jQuery(this).attr("target") == "_blank":
            jQuery(this).attr("enctype", "multipart/form-data").attr(
                "encoding", "multipart/form-data"
            )
            return True

        if jQuery(this).attr("target") == "_self":
            return True

        if jQuery(this).attr("target") == "refresh_obj":
            if refresh_fragment(jQuery(this), None, True, None, True):
                return False

        data = jQuery(this).serialize()

        if data and "pdf=on" in data:
            jQuery(this).attr("target", "_blank")
            jQuery(this).attr("enctype", "multipart/form-data").attr(
                "encoding", "multipart/form-data"
            )
            return True
        if data and "odf=on" in data:
            jQuery(this).attr("target", "_blank")
            jQuery(this).attr("enctype", "multipart/form-data").attr(
                "encoding", "multipart/form-data"
            )
            return True

        e.preventDefault()

        submit_button = jQuery(this).find('button[type="submit"]')
        if submit_button.length > 0:
            submit_button.attr("data-style", "zoom-out")
            submit_button.attr("data-spinner-color", "#FF0000")
            window.WAIT_ICON = Ladda.create(submit_button[0])
            window.WAIT_ICON.start()
        else:
            window.WAIT_ICON2 = True
            jQuery("#loading-indicator").show()

        href = jQuery(this).attr("action")
        if href:
            jQuery(this).attr("action", corect_href(remove_page_from_href(href)))

        def _on_submit2(data):
            nonlocal href, self
            if window.ACTIVE_PAGE:
                mount_html(window.ACTIVE_PAGE.page, data)
            else:
                _on_menu_href(self, self.attr("title"), None, data)

            if window.WAIT_ICON:
                window.WAIT_ICON.stop()
            if window.WAIT_ICON2:
                jQuery("#loading-indicator").hide()
                window.WAIT_ICON2 = False

        ajax_submit(jQuery(this), _on_submit2)
Esempio n. 12
0
def on_delete_ok(form):
    def _on_data(data):
        _refresh_win(data, form);
    ajax_post(corect_href(form.attr('action')), form.serialize(), _on_data )
    return False
Esempio n. 13
0
def on_popup_edit_new(url, elem, e):
    if e:
        target = jQuery(e.currentTarget).attr('target')
    else:
        target = "popup"

    if url:
        href2 = corect_href(url)
    else:
        href2 = corect_href(jQuery(elem).attr("href"))

    jQuery(elem).attr("data-style", "zoom-out")
    jQuery(elem).attr("data-spinner-color", "#FF0000")
    window.WAIT_ICON = Ladda.create(elem)
    if can_popup() and not target=='inline' and not jQuery(elem).hasClass('inline') and not (jQuery(elem).attr('name') and '_inline' in jQuery(elem).attr('name')) :
        jQuery('#ModalLabel').html(jQuery(elem).attr('title'))

        elem2 = jQuery("div.dialog-data")
        elem2.closest(".refr_object").attr("related-object", jQuery(elem).uid())

        def _on_load(responseText, status, response):
            _dialog_loaded(True, elem2)
            on_dialog_load()
        ajax_load(elem2, href2, _on_load)
    else:
        jQuery('body').addClass('shown_inline_dialog')
        if window.WAIT_ICON:
            window.WAIT_ICON.start()
        if jQuery(elem).hasClass('new-row'):
            elem2 = jQuery(sprintf("<div class='refr_source refr_object inline_dialog tr hide' href='%s'>", href2) + INLINE_DIALOG_UPDATE_HTML + "</div>")
            new_position=jQuery(elem).closest('.refr_object').find('div.new_row')
            if new_position.length>0:
                elem2.insertAfter(jQuery(new_position[0]))
            else:
                elem2.insertAfter(jQuery(elem).closest("div.tr"))
        else:
            in_table = False
            for obj in [jQuery(elem).parent(), jQuery(elem).parent().parent() ]:
                for c in ['td_action', 'td_information']:
                    if obj.hasClass(c):
                        in_table = True
                        break
            if in_table:
                elem2 = jQuery(sprintf("<tr class='refr_source refr_object inline_dialog hide' href='%s'><td colspan='20'>", href2) + INLINE_DIALOG_UPDATE_HTML + "</td></tr>")
                elem2.insertAfter(jQuery(elem).closest("tr"))
            else:
                test = jQuery(elem).closest('form')
                if test.length > 0:
                    elem2 = jQuery(sprintf("<div class='refr_source refr_object inline_dialog hide' href='%s'>", href2) + INLINE_DIALOG_UPDATE_HTML + "</div>")
                    elem2.insertAfter(jQuery(elem).closest("div.form-group"))
                else:
                    elem2 = jQuery(sprintf("<div class='refr_source refr_object inline_dialog tr hide' href='%s'>",
                                           href2) + INLINE_DIALOG_UPDATE_HTML + "</div>")
                    new_position = jQuery(elem).closest('.refr_object').find('div.new_row')
                    if new_position.length > 0:
                        elem2.insertAfter(jQuery(new_position[0]))
                    else:
                        elem2.insertAfter(jQuery(elem).closest("div.tr"))
        mount_html(elem2.find('.modal-title'), jQuery(elem).attr('title'), False, False)
        #elem2.find(".refr_object").attr("related-object", jQuery(elem).uid())
        elem2.attr("related-object", jQuery(elem).uid())
        elem3 = elem2.find("div.dialog-data-inner")

        def _on_load2(responseText, status, response):
            elem2.hide()
            elem2.removeClass('hide')
            elem2.show("slow")
            if status!='error':
                _dialog_loaded(False, elem3)
                on_dialog_load()
            if window.WAIT_ICON:
                window.WAIT_ICON.stop()
                window.WAIT_ICON = None
        ajax_load(elem3,href2, _on_load2)

    return False
Esempio n. 14
0
def on_popup_edit_new(url, elem, e):
    if e:
        target = jQuery(e.currentTarget).attr('target')
    else:
        target = "popup"

    if url:
        href2 = corect_href(url)
    else:
        href2 = corect_href(jQuery(elem).attr("href"))

    jQuery(elem).attr("data-style", "zoom-out")
    jQuery(elem).attr("data-spinner-color", "#FF0000")
    window.WAIT_ICON = Ladda.create(elem)
    if can_popup() and not target == 'inline' and not jQuery(elem).hasClass(
            'inline') and not (jQuery(elem).attr('name')
                               and '_inline' in jQuery(elem).attr('name')):
        jQuery('#ModalLabel').html(jQuery(elem).attr('title'))

        elem2 = jQuery("div.dialog-data")
        elem2.closest(".refr_object").attr("related-object",
                                           jQuery(elem).uid())

        def _on_load(responseText, status, response):
            _dialog_loaded(True, elem2)
            on_dialog_load()

        ajax_load(elem2, href2, _on_load)
    else:
        jQuery('body').addClass('shown_inline_dialog')
        if window.WAIT_ICON:
            window.WAIT_ICON.start()
        if jQuery(elem).hasClass('new-row'):
            elem2 = jQuery(
                sprintf(
                    "<div class='refr_source refr_object inline_dialog tr hide' href='%s'>",
                    href2) + INLINE_DIALOG_UPDATE_HTML + "</div>")
            new_position = jQuery(elem).closest('.refr_object').find(
                'div.new_row')
            if new_position.length > 0:
                elem2.insertAfter(jQuery(new_position[0]))
            else:
                elem2.insertAfter(jQuery(elem).closest("div.tr"))
        else:
            in_table = False
            for obj in [jQuery(elem).parent(), jQuery(elem).parent().parent()]:
                for c in ['td_action', 'td_information']:
                    if obj.hasClass(c):
                        in_table = True
                        break
            if in_table:
                elem2 = jQuery(
                    sprintf(
                        "<tr class='refr_source refr_object inline_dialog hide' href='%s'><td colspan='20'>",
                        href2) + INLINE_DIALOG_UPDATE_HTML + "</td></tr>")
                elem2.insertAfter(jQuery(elem).closest("tr"))
            else:
                test = jQuery(elem).closest('form')
                if test.length > 0:
                    elem2 = jQuery(
                        sprintf(
                            "<div class='refr_source refr_object inline_dialog hide' href='%s'>",
                            href2) + INLINE_DIALOG_UPDATE_HTML + "</div>")
                    elem2.insertAfter(jQuery(elem).closest("div.form-group"))
                else:
                    elem2 = jQuery(
                        sprintf(
                            "<div class='refr_source refr_object inline_dialog tr hide' href='%s'>",
                            href2) + INLINE_DIALOG_UPDATE_HTML + "</div>")
                    new_position = jQuery(elem).closest('.refr_object').find(
                        'div.new_row')
                    if new_position.length > 0:
                        elem2.insertAfter(jQuery(new_position[0]))
                    else:
                        elem2.insertAfter(jQuery(elem).closest("div.tr"))
        mount_html(elem2.find('.modal-title'),
                   jQuery(elem).attr('title'), False, False)
        #elem2.find(".refr_object").attr("related-object", jQuery(elem).uid())
        elem2.attr("related-object", jQuery(elem).uid())
        elem3 = elem2.find("div.dialog-data-inner")

        def _on_load2(responseText, status, response):
            elem2.hide()
            elem2.removeClass('hide')
            elem2.show("slow")
            if status != 'error':
                _dialog_loaded(False, elem3)
                on_dialog_load()
            if window.WAIT_ICON:
                window.WAIT_ICON.stop()
                window.WAIT_ICON = None

        ajax_load(elem3, href2, _on_load2)

    return False
Esempio n. 15
0
def on_delete_ok(form):
    def _on_data(data):
        _refresh_win(data, form)

    ajax_post(corect_href(form.attr('action')), form.serialize(), _on_data)
    return False
Esempio n. 16
0
    def _on_click(e):
        nonlocal event_tab

        target = jQuery(e.currentTarget).attr('target')
        if target == "_blank" or target == '_parent':
            return True

        src_obj = jQuery(this)

        if 'xlink:href' in e.currentTarget.attributes:
            href = jQuery(this).attr('xlink:href')
        else:
            href = jQuery(this).attr("href")

        if href and '#' in href:
            return True

        if not href:
            return True

        href = process_href(href, src_obj)

        for pos in event_tab:
            if pos[0] == '*' or pos[0] == target:
                if pos[1] == '*' or src_obj.hasClass(pos[1]):
                    if pos[3]:
                        url = corect_href(href, True)
                    elif pos[2]:
                        url = corect_href(href, False)
                    else:
                        url = href
                    e.preventDefault()
                    pos[4](url, this, e)
                    return True

        e.preventDefault()

        href2 = corect_href(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 not refresh_fragment(src_obj, None, True):
                        refresh_fragment(src_obj)
                else:
                    refresh_fragment(src_obj)
            else:
                if window.APPLICATION_TEMPLATE == 'modern':
                    if window.ACTIVE_PAGE:
                        mount_html(window.ACTIVE_PAGE.page, data)
                    else:
                        mount_html(jQuery('#wiki_start'), data)
                        return
                    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)

        ajax_get(href2, _on_data)
Esempio n. 17
0
    def _on_submit(e):
        self = jQuery(this)
        if jQuery(this).hasClass("DialogForm"):
            e.preventDefault()
            on_edit_ok(False, jQuery(this))
            return

        if jQuery(this).attr("target") == "_blank":
            jQuery(this).attr("enctype", "multipart/form-data").attr(
                "encoding", "multipart/form-data"
            )
            return True

        if jQuery(this).attr("target") == "_self":
            return True

        if jQuery(this).attr("target") == "refresh_obj":
            if refresh_fragment(jQuery(this), None, True, None, True):
                return False

        data = jQuery(this).serialize()

        if data and "pdf=on" in data:
            jQuery(this).attr("target", "_blank")
            jQuery(this).attr("enctype", "multipart/form-data").attr(
                "encoding", "multipart/form-data"
            )
            return True
        if data and "odf=on" in data:
            jQuery(this).attr("target", "_blank")
            jQuery(this).attr("enctype", "multipart/form-data").attr(
                "encoding", "multipart/form-data"
            )
            return True

        e.preventDefault()

        submit_button = jQuery(this).find('button[type="submit"]')
        if submit_button.length > 0:
            submit_button.attr("data-style", "zoom-out")
            submit_button.attr("data-spinner-color", "#FF0000")
            window.WAIT_ICON = Ladda.create(submit_button[0])
            window.WAIT_ICON.start()
        else:
            window.WAIT_ICON2 = True
            jQuery("#loading-indicator").show()

        href = jQuery(this).attr("action")
        if href:
            jQuery(this).attr("action", corect_href(remove_page_from_href(href)))

        def _on_submit2(data):
            nonlocal href, self
            if window.ACTIVE_PAGE:
                mount_html(window.ACTIVE_PAGE.page, data)
            else:
                _on_menu_href(self, self.attr("title"), None, data)

            if window.WAIT_ICON:
                window.WAIT_ICON.stop()
            if window.WAIT_ICON2:
                jQuery("#loading-indicator").hide()
                window.WAIT_ICON2 = False

        ajax_submit(jQuery(this), _on_submit2)
Esempio n. 18
0
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
Esempio n. 19
0
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
Esempio n. 20
0
    def _on_click(e):
        nonlocal event_tab

        target = jQuery(e.currentTarget).attr('target')
        if target == "_blank" or target == '_parent':
            return True

        src_obj = jQuery(this)

        if 'xlink:href' in e.currentTarget.attributes:
            href = jQuery(this).attr('xlink:href')
        else:
            href = jQuery(this).attr("href")

        if href and '#' in href:
            return True

        if not href:
            return True

        href = process_href(href, src_obj)

        for pos in event_tab:
            if pos[0] == '*' or pos[0] == target:
                if pos[1] == '*' or src_obj.hasClass(pos[1]):
                    if pos[3]:
                        url = corect_href(href, True)
                    elif pos[2]:
                        url = corect_href(href, False)
                    else:
                        url = href
                    e.preventDefault()
                    pos[4](url, this, e)
                    return True

        e.preventDefault()

        href2 = corect_href(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 not refresh_fragment(src_obj, None, True):
                        refresh_fragment(src_obj)
                else:
                    refresh_fragment(src_obj)
            else:
                if window.APPLICATION_TEMPLATE == 'modern':
                    if window.ACTIVE_PAGE:
                        mount_html(window.ACTIVE_PAGE.page, data)
                    else:
                        mount_html(jQuery('#wiki_start'), data)
                        return
                    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)
        ajax_get(href2,_on_data)
Esempio n. 21
0
def refresh_fragment(data_item_to_refresh,
                     fun=None,
                     only_table=False,
                     data=None,
                     remove_pagination=False):
    only_table_href = False
    refr_block = data_item_to_refresh.closest('.refr_object')
    if refr_block.hasClass('refr_target'):
        target = refr_block
    else:
        target = refr_block.find('.refr_target')
        if target.length > 1:
            target = jQuery(target[0])

    if only_table:
        datatable = target.find('table[name=tabsort].datatable')
        if datatable.length > 0:
            datatable_refresh(datatable)
            target.find('.inline_dialog').remove()
            if fun:
                fun()
            return True
        datatable = target.find('table[name=tabsort].tabsort')
        if datatable.length > 0:
            only_table_href = True
            target.find('.inline_dialog').remove()
            target = datatable.closest('div.tableframe')
        else:
            return False

    if data:
        mount_html(target, data)
        if fun:
            fun()
    else:
        if refr_block.hasClass('refr_source'):
            src = refr_block
        else:
            src = refr_block.find('.refr_source')
        if src.length > 0:
            src = jQuery(src[0])
            href = src.attr('href')

            if remove_pagination:
                href = remove_page_from_href(href)

            if src.prop("tagName") == 'FORM':

                def _refr2(data):
                    mount_html(target, data)
                    if fun:
                        fun()

                ajax_post(corect_href(href, only_table_href), src.serialize(),
                          _refr2)
            else:

                def _on_load(responseText):
                    if fun:
                        fun()

                ajax_load(target, corect_href(href, only_table_href), _on_load)
        else:
            if fun:
                fun()
    return True