def on_popup_delete(url, elem, e): if can_popup(): jQuery("div.dialog-data-delete").closest(".refr_object").attr( "related-object", jQuery(elem).uid()) def _on_load(responseText, status, response): jQuery('div.dialog-form-delete').modal() jQuery("div.dialog-form-delete").fadeTo("fast", 1) ajax_load(jQuery("div.dialog-data-delete"), jQuery(elem).attr("href"), _on_load) else: jQuery(".inline_dialog").remove() elem2 = jQuery( "<tr class='refr_object inline_dialog'><td colspan='20'>" + INLINE_DIALOG_DELETE_HTML + "</td></tr>") elem2.insertAfter(jQuery(elem).parents("tr")) elem2.find(".refr_object").attr("related-object", jQuery(elem).uid()) def _on_load2(): pass ajax_load(jQuery("div.dialog-data-inner"), jQuery(elem).attr("href"), _on_load2) return False
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)
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
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
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)
def on_popup_info(url, elem, e): if can_popup(): def _on_load(responseText, status, response): jQuery('div.dialog-form-info').modal() ajax_load(jQuery("div.dialog-data-info"),jQuery(elem).attr("href"), _on_load) else: jQuery(".inline_dialog").remove() jQuery("<tr class='refr_object inline_dialog'><td colspan='20'>" + INLINE_DIALOG_INFO_HTML + "</td></tr>").insertAfter(jQuery(elem).parents("tr")) def _on_load2(responseText, status, response): pass ajax_load(jQuery("div.dialog-data-inner"),jQuery(elem).attr("href"), _on_load2) return False
def _init_start_wiki_page(): if ( start_page and start_page != "None" and window.location.pathname == base_path ): def _on_load(responseText, status, response): pass ajax_load( jQuery("#wiki_start"), base_path + start_page + "?only_content&schtml=1", _on_load, )
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
def on_popup_delete(url, elem, e): if can_popup(): jQuery("div.dialog-data-delete").closest(".refr_object").attr("related-object", jQuery(elem).uid()) def _on_load(responseText, status, response): jQuery('div.dialog-form-delete').modal() jQuery("div.dialog-form-delete").fadeTo( "fast", 1) ajax_load(jQuery("div.dialog-data-delete"),jQuery(elem).attr("href"), _on_load) else: jQuery(".inline_dialog").remove() elem2 = jQuery("<tr class='refr_object inline_dialog'><td colspan='20'>" + INLINE_DIALOG_DELETE_HTML + "</td></tr>") elem2.insertAfter(jQuery(elem).parents("tr")) elem2.find(".refr_object").attr("related-object", jQuery(elem).uid()) def _on_load2(): pass ajax_load(jQuery("div.dialog-data-inner"),jQuery(elem).attr("href"), _on_load2) return False
def on_popup_info(url, elem, e): if can_popup(): def _on_load(responseText, status, response): jQuery('div.dialog-form-info').modal() ajax_load(jQuery("div.dialog-data-info"), jQuery(elem).attr("href"), _on_load) else: jQuery(".inline_dialog").remove() jQuery("<tr class='refr_object inline_dialog'><td colspan='20'>" + INLINE_DIALOG_INFO_HTML + "</td></tr>").insertAfter( jQuery(elem).parents("tr")) def _on_load2(responseText, status, response): pass ajax_load(jQuery("div.dialog-data-inner"), jQuery(elem).attr("href"), _on_load2) return False
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
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
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
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
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