diff options
Diffstat (limited to 'ishtar_common/static/js/ishtar.js')
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 318c17315..00a9b66a0 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -37,6 +37,19 @@ function get_next_table_id(){} function get_previous_table_id(){} var shortcut_url = ''; +var datatables_i18n; +var current_modal; + +var datatables_default = { + "processing": true, + "serverSide": true, + "scrollX": true, + "scrollY": true, + "searching": false, + "info": false, + "scrollCollapse": true +}; + var advanced_menu = false; var shortcut_menu_hide = false; var activate_all_search_url = '/activate-all-search/'; @@ -47,8 +60,8 @@ var shortcut_menu_hide_url = '/hide-shortcut-menu/' var shortcut_menu_show_url = '/show-shortcut-menu/' function init_shortcut_menu(html){ - $("#progress").hide(); - $("#context_menu").html(html); + close_wait(); + $("#context-menu").html(html); $(".chosen-select").chosen(); if (advanced_menu) { init_advanced_shortcut_fields(); @@ -174,7 +187,7 @@ function display_info(msg){ function load_shortcut_menu(){ if (!shortcut_url) return; - $("#progress").show(); + $('.modal-progress').modal('show'); $.ajax({ url: shortcut_url, cache: false, @@ -182,7 +195,7 @@ function load_shortcut_menu(){ init_shortcut_menu(html); }, error:function(XMLHttpRequest, textStatus, errorThrows){ - $("#progress").hide(); + close_wait(); } }); } @@ -195,13 +208,12 @@ $(document).ready(function(){ $('#to_bottom_arrow').hide(); $('#to_top_arrow').hide(); } - $('#language_selector').change(function(){ - $('#language_form').submit(); + $('#language-selector a').click(function(){ + $('#language-selector input[name="language"]').val( + $(this).attr("data-lang")); + $('#language-form').submit(); }); load_shortcut_menu(); - if ($.isFunction($(".prettyPhoto a").prettyPhoto)){ - $(".prettyPhoto a").prettyPhoto({'social_tools':''}); - } $('#current_items select').change(function(){ $(this).attr('class', $(this).children("option:selected").attr('class')); }); @@ -237,12 +249,11 @@ $(document).on("click", '.help_display', function(){ }); $(document).on("click", '#progress-content', function(){ - $('#progress').hide(); + $('.modal-progress').hide(); }); function long_wait(){ - $('#progress').addClass('long'); - $('#progress').show(); + $('.modal-progress').modal('show'); $('.progress-1').show('slow'); setTimeout(function(){ $('.progress-1').hide('slow'); @@ -262,22 +273,43 @@ function long_wait(){ }, 240000); } +function close_wait(){ + $('.modal-progress').modal('hide'); + if (current_modal){ + $('body').addClass('modal-open'); + } +} + var last_window; -function load_window(url, speed, on_success){ - $("#progress").show(); +function load_window(url, speed, on_success, no_jump){ + $('.modal-progress').modal('show'); $.ajax({ url: url, cache: false, success:function(html){ - $("#progress").hide(); - $("#window").append(html); + close_wait(); + $(".previous_page").remove(); + $(".next_page").remove(); + var register_id = $(html).find(".card-header").attr("data-sheet-id"); + var current_sheet = $('[data-sheet-id="' + register_id + '"]'); + if (current_sheet.length){ + $(".collapse").removeClass('show'); + current_sheet.parent().find('.collapse').addClass('show'); + } else { + $("#window").append(html); + } $("#"+last_window).show(); - $("a[rel^='prettyPhoto']").prettyPhoto({'social_tools':''}); + if (!no_jump){ + // jump to this window + var url = location.href; + location.href = "#" + last_window; + history.replaceState(null, null, url); + } if (on_success) on_success(); }, error:function(XMLHttpRequest, textStatus, errorThrows){ - $("#progress").hide(); + close_wait(); } }); } @@ -297,15 +329,15 @@ function load_current_window(url, model_name){ } function load_url(url){ - $("#progress").show(); + $('.modal-progress').modal('show'); $.ajax({ url: url, cache: false, success:function(html){ - $("#progress").hide(); + close_wait(); }, error:function(XMLHttpRequest, textStatus, errorThrows){ - $("#progress").hide(); + close_wait(); } }); } |