Ejemplo n.º 1
0
            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
Ejemplo n.º 2
0
            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
Ejemplo n.º 3
0
def _refresh_win(responseText, ok_button):
    refr_obj = jQuery(ok_button).closest('.refr_object')
    popup_activator = jQuery("#" + refr_obj.attr("related-object"))
    if responseText and "RETURN_OK" in responseText:
        if refr_obj.hasClass('modal'):
            if jQuery("div.dialog-form").hasClass('show'):
                dialog = "div.dialog-form"
            else:
                if jQuery("div.dialog-form-delete").hasClass('show'):
                    dialog = "div.dialog-form-delete"
                else:
                    dialog = "div.dialog-form-info"

            def hide_dialog_form():
                jQuery(dialog).modal('hide')

            jQuery(dialog).fadeTo("slow", 0.5)
            if not refresh_fragment(popup_activator, hide_dialog_form, True):
                refresh_fragment(popup_activator, hide_dialog_form, False)
        else:
            if refr_obj.hasClass('inline_dialog'):
                inline_dialog = refr_obj
            else:
                inline_dialog = refr_obj.find('.inline_dialog')
            if inline_dialog.length > 0:
                inline_dialog.remove()

            if not refresh_fragment(popup_activator, None, True):
                return refresh_fragment(popup_activator, None, False)
    else:
        if refr_obj.hasClass('modal'):
            mount_html(jQuery("div.dialog-data"), responseText)
        else:
            mount_html(ok_button.closest('.refr_target'), responseText)
Ejemplo n.º 4
0
 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,
     )
Ejemplo n.º 5
0
def _refresh_win(responseText, ok_button):
    refr_obj = jQuery(ok_button).closest('.refr_object')
    popup_activator = jQuery("#"+refr_obj.attr("related-object"))
    if responseText and "RETURN_OK" in responseText:
        if refr_obj.hasClass('modal'):
            if jQuery("div.dialog-form").hasClass('show'):
                dialog = "div.dialog-form"
            else:
                if jQuery("div.dialog-form-delete").hasClass('show') :
                    dialog = "div.dialog-form-delete"
                else:
                    dialog = "div.dialog-form-info"

            def hide_dialog_form():
                jQuery(dialog).modal('hide')

            jQuery(dialog).fadeTo( "slow", 0.5 )
            if not refresh_fragment(popup_activator, hide_dialog_form, True):
                refresh_fragment(popup_activator, hide_dialog_form, False)
        else:
            if refr_obj.hasClass('inline_dialog'):
                inline_dialog = refr_obj
            else:
                inline_dialog = refr_obj.find('.inline_dialog')
            if inline_dialog.length>0:
                inline_dialog.remove()

            if not refresh_fragment(popup_activator, None, True):
                return refresh_fragment(popup_activator, None, False)
    else:
        if refr_obj.hasClass('modal'):
            mount_html(jQuery("div.dialog-data"), responseText)
        else:
            mount_html(ok_button.closest('.refr_target'),responseText)
Ejemplo n.º 6
0
 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,
     )
Ejemplo n.º 7
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
Ejemplo n.º 8
0
        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
Ejemplo n.º 9
0
        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
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
def _refresh_win_and_ret(responseText, ok_button):
    if responseText and "RETURN_OK" in responseText:
        related_object = jQuery(ok_button).closest(".refr_object").attr('related-object')
        popup_activator = jQuery("#"+related_object)
        if jQuery(ok_button).closest(".refr_object").hasClass('show'):
            jQuery("div.dialog-form").modal('hide')
        else:
            jQuery(ok_button).closest(".refr_object").remove()
        if popup_activator and popup_activator.data('edit_ret_function'):
            window.RET_CONTROL = popup_activator.data('ret_control')
            window.EDIT_RET_FUNCTION = popup_activator.data('edit_ret_function')
            #q = jQuery(responseText)
            q = jQuery("<div>" + responseText + "</div>").find("script")
            eval(q.text())
    else:
        mount_html(jQuery("div.dialog-data"), responseText)
Ejemplo n.º 13
0
def _refresh_win_and_ret(responseText, ok_button):
    if responseText and "RETURN_OK" in responseText:
        related_object = jQuery(ok_button).closest(".refr_object").attr(
            'related-object')
        popup_activator = jQuery("#" + related_object)
        if jQuery(ok_button).closest(".refr_object").hasClass('show'):
            jQuery("div.dialog-form").modal('hide')
        else:
            jQuery(ok_button).closest(".refr_object").remove()
        if popup_activator and popup_activator.data('edit_ret_function'):
            window.RET_CONTROL = popup_activator.data('ret_control')
            window.EDIT_RET_FUNCTION = popup_activator.data(
                'edit_ret_function')
            #q = jQuery(responseText)
            q = jQuery("<div>" + responseText + "</div>").find("script")
            eval(q.text())
    else:
        mount_html(jQuery("div.dialog-data"), responseText)
Ejemplo n.º 14
0
    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)
Ejemplo n.º 15
0
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")
Ejemplo n.º 16
0
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")
Ejemplo n.º 17
0
    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)
Ejemplo n.º 18
0
def _on_error(request, settings):
    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 settings.status == 200:
        return

    if settings.responseText:
        start = settings.responseText.indexOf("<body>")
        end = settings.responseText.lastIndexOf("</body>")
        if start > 0 and end > 0:
            mount_html(
                jQuery("#dialog-data-error"),
                settings.responseText.substring(start + 6, end - 1),
            )
            jQuery("#dialog-form-error").modal()
        else:
            mount_html(jQuery("#dialog-data-error"), settings.responseText)
            jQuery("#dialog-form-error").modal()
Ejemplo n.º 19
0
def _on_error(request, settings):
    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 settings.status == 200:
        return

    if settings.responseText:
        start = settings.responseText.indexOf("<body>")
        end = settings.responseText.lastIndexOf("</body>")
        if start > 0 and end > 0:
            mount_html(
                jQuery("#dialog-data-error"),
                settings.responseText.substring(start + 6, end - 1),
            )
            jQuery("#dialog-form-error").modal()
        else:
            mount_html(jQuery("#dialog-data-error"), settings.responseText)
            jQuery("#dialog-form-error").modal()
Ejemplo n.º 20
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
Ejemplo n.º 21
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
Ejemplo n.º 22
0
 def _refr2(data):
     mount_html(target, data)
     if fun:
         fun()
Ejemplo n.º 23
0
    def new_page(self, title_alternate, data, href):
        _id = "tab" + self.id

        tmp = jQuery(data).find('header').find("title").text()
        title =jQuery.trim(tmp)
        if not title:
            title = title_alternate
        title2 = jQuery.trim(title)
        menu_item = TabMenuItem(_id, title2, href, data)
        self.titles[title2] = menu_item
        menu_pos = vsprintf(
            "<li id='li_%s' class ='nav-item'><a href='#%s' class='nav-link bg-info' data-toggle='tab' role='tab' title='%s'>%s &nbsp &nbsp</a> <button id = 'button_%s' class='close btn btn-outline-danger btn-xs' title='remove page' type='button'><span class='fa fa-times'></span></button></li>",
            [_id, _id, title2, title2, _id])

        append_left =jQuery("#tabs2").hasClass('append-left')

        if append_left:
            jQuery('#tabs2').prepend(menu_pos)
        else:
            jQuery('#tabs2').append(menu_pos)
        jQuery('#tabs2_content').append(sprintf("<div class='tab-pane container-fluid refr_target refr_object win-content page' id='%s'></div>", _id) )

        window.ACTIVE_PAGE = Page(_id, jQuery('#'+_id))
        self.active_item = menu_item

        #mount_html(jQuery('#'+_id),data)

        if window.PUSH_STATE:
            history_push_state(title2, href)


        def _on_show_tab(e):
            nonlocal menu_item
            window.ACTIVE_PAGE = Page(_id, jQuery('#'+_id), menu_item)

            menu = get_menu()
            menu_item = menu.titles[jQuery.trim(e.target.text)]
            self.active_item = menu_item
            if window.PUSH_STATE:
                history_push_state(menu_item.title, menu_item.url)
        if append_left:
            jQuery('#tabs2 a:first').on('shown.bs.tab', _on_show_tab)
            jQuery('#tabs2 a:first').tab('show')
        else:
            jQuery('#tabs2 a:last').on('shown.bs.tab', _on_show_tab)
            jQuery('#tabs2 a:last').tab('show')

        mount_html(jQuery('#' + _id), data)

        def _on_button_click(event):
            get_menu().remove_page(jQuery(this).attr('id').replace('button_',''))

        jQuery(sprintf('#button_%s', _id)).click(_on_button_click)

        scripts = jQuery('#'+_id+' script')

        def _local_fun( index, element ):
            eval(this.innerHTML)

        scripts.each(_local_fun)
        self.id += 1

        return _id
Ejemplo n.º 24
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
Ejemplo n.º 25
0
 def _refr2(data):
     mount_html(target, data)
     if fun:
         fun()
Ejemplo n.º 26
0
    def new_page(self, title_alternate, data, href):
        _id = "tab" + self.id

        tmp = jQuery(data).find('header').find("title").text()
        title = jQuery.trim(tmp)
        if not title:
            title = title_alternate
        title2 = jQuery.trim(title)
        menu_item = TabMenuItem(_id, title2, href, data)
        self.titles[title2] = menu_item
        menu_pos = vsprintf(
            "<li id='li_%s' class ='nav-item'><a href='#%s' class='nav-link bg-info' data-toggle='tab' role='tab' title='%s'>%s &nbsp &nbsp</a> <button id = 'button_%s' class='close btn btn-outline-danger btn-xs' title='remove page' type='button'><span class='fa fa-times'></span></button></li>",
            [_id, _id, title2, title2, _id])

        append_left = jQuery("#tabs2").hasClass('append-left')

        if append_left:
            jQuery('#tabs2').prepend(menu_pos)
        else:
            jQuery('#tabs2').append(menu_pos)
        jQuery('#tabs2_content').append(
            sprintf(
                "<div class='tab-pane container-fluid refr_target refr_object win-content page' id='%s'></div>",
                _id))

        window.ACTIVE_PAGE = Page(_id, jQuery('#' + _id))
        self.active_item = menu_item

        #mount_html(jQuery('#'+_id),data)

        if window.PUSH_STATE:
            history_push_state(title2, href)

        def _on_show_tab(e):
            nonlocal menu_item
            window.ACTIVE_PAGE = Page(_id, jQuery('#' + _id), menu_item)

            menu = get_menu()
            menu_item = menu.titles[jQuery.trim(e.target.text)]
            self.active_item = menu_item
            if window.PUSH_STATE:
                history_push_state(menu_item.title, menu_item.url)

        if append_left:
            jQuery('#tabs2 a:first').on('shown.bs.tab', _on_show_tab)
            jQuery('#tabs2 a:first').tab('show')
        else:
            jQuery('#tabs2 a:last').on('shown.bs.tab', _on_show_tab)
            jQuery('#tabs2 a:last').tab('show')

        mount_html(jQuery('#' + _id), data)

        def _on_button_click(event):
            get_menu().remove_page(
                jQuery(this).attr('id').replace('button_', ''))

        jQuery(sprintf('#button_%s', _id)).click(_on_button_click)

        scripts = jQuery('#' + _id + ' script')

        def _local_fun(index, element):
            eval(this.innerHTML)

        scripts.each(_local_fun)
        self.id += 1

        return _id