summaryrefslogtreecommitdiff
path: root/ishtar_common/static/js/ishtar.js
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/static/js/ishtar.js')
-rw-r--r--ishtar_common/static/js/ishtar.js76
1 files changed, 70 insertions, 6 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js
index fecefe0a9..70b056c63 100644
--- a/ishtar_common/static/js/ishtar.js
+++ b/ishtar_common/static/js/ishtar.js
@@ -38,22 +38,25 @@ function manage_async_link(event){
function get_next_table_id(){}
function get_previous_table_id(){}
+var current_operation_change = function(){
+ $.post('/' + url_path + 'update-current-item/',
+ {item:'operation', value:$("#current_operation").val()},
+ load_shortcut_menu
+ );
+};
+
function init_shortcut_menu(html){
$("#progress").hide();
$("#context_menu").html(html);
$(".chosen-select").chosen();
+ chosen_ajaxify("current_operation", '/get-operation-cached/?cached_label=',
+ current_operation_change);
$("#current_file").change(function(){
$.post('/' + url_path + 'update-current-item/',
{item:'file', value:$("#current_file").val()},
load_shortcut_menu
);
});
- $("#current_operation").change(function(){
- $.post('/' + url_path + 'update-current-item/',
- {item:'operation', value:$("#current_operation").val()},
- load_shortcut_menu
- );
- });
$("#current_contextrecord").change(function(){
$.post('/' + url_path + 'update-current-item/',
{item:'contextrecord', value:$("#current_contextrecord").val()},
@@ -267,3 +270,64 @@ function show_hide_flex(id){
$(id).hide();
}
}
+
+var delay = (function(){
+ var timer = 0;
+ return function(callback, ms){
+ clearTimeout (timer);
+ timer = setTimeout(callback, ms);
+ };
+})();
+
+
+function chosen_ajaxify(id, ajax_url, current_change_callback){
+ $('div#' + id + '_chosen .chosen-search input').keyup(function(){
+ var keyword = $('div#' + id + '_chosen .chosen-search input').val();
+ var keyword_pattern = new RegExp(keyword, 'gi');
+ $('div#' + id + '_chosen ul.chosen-results').empty();
+ $("#"+id).empty();
+ delay(function(){
+ $.ajax({
+ url: ajax_url + keyword,
+ dataType: "json",
+ success: function(response){
+ $('#'+id).append('<option value="">--</option>');
+ $.map(response['rows'], function(item){
+ $('#'+id).append('<option value="' + item['id'] + '">' + item['cached_label'] + '</option>');
+ });
+ $("#"+id).trigger("chosen:updated");
+ $('div#' + id + '_chosen .chosen-search input').val(keyword);
+ $('div#' + id + '_chosen').removeClass('chosen-container-single-nosearch');
+ $('div#' + id + '_chosen .chosen-search input').removeAttr('readonly');
+ $('div#' + id + '_chosen .chosen-search input').focus();
+ /*
+ $('div#' + id + '_chosen .active-result').each(function(){
+ var html = $('div#' + id + '_chosen ul.chosen-results').html();
+ $('div#' + id + '_chosen ul.chosen-results').html(html.replace(keyword_pattern, function(matched){
+ return '<em>' + matched + '</em>';
+ }));
+ });*/
+ $("#" + id).change(current_change_callback);
+ }
+ });
+ }, 1000);
+ });
+}
+
+
+var activate_all_search_msg = "Searches in the shortcut menu deals with all items.";
+var activate_own_search_msg = "Searches in the shortcut menu deals with only your items.";
+
+function activate_all_search(){
+ $('.activate_all_search').removeClass('disabled');
+ $('.activate_own_search').addClass('disabled');
+ display_info(activate_all_search_msg);
+ return false;
+}
+
+function activate_own_search(){
+ $('.activate_own_search').removeClass('disabled');
+ $('.activate_all_search').addClass('disabled');
+ display_info(activate_own_search_msg);
+ return false;
+}