Changeset 5302 for SMC


Ignore:
Timestamp:
05/27/14 21:42:29 (10 years ago)
Author:
xnrn@gmx.net
Message:

added cql-widget (replicated from foreign repo)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SMC/trunk/SMC/src/web/scripts/js/query_input/qi.js

    r3433 r5302  
    6666                  new_input = genAutocomplete (key, param);   
    6767                  break;
     68               case "cql":
     69                  var cql_elems = genCQLInput(key, param);
     70                  new_input = cql_elems[0];
     71                  new_widget = cql_elems[1];
     72                  break;
    6873                case "link":
    6974                  new_input = genLink (key, param);   
     
    8186            $(new_input).data("key", key)
    8287                        .addClass("type-" + param.widget)
    83                         .attr("id", settings.input_prefix + key)
    84                         .data("param-object", param);
    85                  
     88                             .attr("id", settings.input_prefix + key)
     89                             .data("param-object", param);
     90                    
    8691            if (param.widget!="link") {
    8792                 // set initial valuelink
     
    119124    }
    120125   
    121     /**
    122     generate a link to current state  based on the settings
    123    PLANNED?: accept a function reference from opts (.onmousedown)
    124     */
    125126    function genLink(key, param_settings) {
    126127         
     
    129130       
    130131            $(a).mousedown(function(e) {
    131                     $(this).attr("target", "_blank");
    132                     $(this).attr("href", generateLink());
    133              });
     132                $(this).attr("target", "_blank");
     133                $(this).attr("href", generateLink());
     134         });
    134135        return a;
    135136    }
     
    143144    }
    144145       
    145     /** generating ou own comboboxes, because very annoying trying to use some of existing jquery plugins (easyui.combo, combobox, jquery-ui.autocomplete) */
     146    /** generating our own comboboxes, because very annoying trying to use some of existing jquery plugins (easyui.combo, combobox, jquery-ui.autocomplete) */
    146147    function genCombo (key, param_settings) {
    147148   
    148         var select = $("<select id='widget-" + key + "' />")
    149             select.attr("id", settings.input_prefix + key)
    150         param_settings.values.forEach(function(v) { $(select).append("<option value='" + v +"' >" + v + "</option>") });
     149        var select = $("<select id='widget-" + key + "' />");
     150            //select.attr("id", settings.input_prefix + key)
     151           
     152       if (param_settings.static_source) {
     153              //var scanURL = settings.fcs_source +  param_settings.index
     154              var source_url = param_settings.static_source.replace(/&amp;/g,'&');
     155              // if static source - try to retrieve the data
     156              $.getJSON(source_url, function(data) {
     157                    param_settings.values = data.terms
     158                    param_settings.values.forEach(function(v) { $(select).append("<option value='" + v.value +"' >" + v.label + "</option>") });
     159                    //console.log($(input).autocomplete().source);
     160              });
     161       
     162             //param_settings.source = fcsScan;
     163        } else if (param_settings.values) {
     164            //    $(input).autocomplete(param_settings);
     165            if (typeof  param_settings.values[0] ==='object') {// accept format with value and label
     166                  param_settings.values.forEach(function(v) { $(select).append("<option value='" + v.value +"' >" + v.label + "</option>") });
     167               } else {
     168                   param_settings.values.forEach(function(v) { $(select).append("<option value='" + v +"' >" + v + "</option>") });
     169             }
     170        } else { /* if no values,  rather make a textbox out of it? */
     171          //select =
     172        }
     173       
     174        select.attr("id", settings.input_prefix + key)
    151175        return select;
    152176    }
     
    157181        var input = $("<input />");
    158182         $(input).attr("name",key)
    159         
     183   //     console.log(key, param_settings.static_source);
    160184        if (param_settings.static_source) {
    161185              //var scanURL = settings.fcs_source +  param_settings.index
    162               var scanURL = param_settings.static_source.replace(/&amp;/g,'&');
     186              var source_url = param_settings.static_source.replace(/&amp;/g,'&');
    163187              // if static source - try to retrieve the data
    164               $.getJSON(scanURL, function(data) {
     188              $.getJSON(source_url, function(data) {
    165189                    param_settings.source = data.terms
    166190                    $(input).autocomplete(param_settings);
    167                   //  console.log($(input).autocomplete("option","source").length);
     191                    //console.log($(input).autocomplete().source);
    168192              });
    169193       
     
    176200    }
    177201
     202   
    178203    function fcsScan(request, response) {
    179204        response( $.ui.autocomplete.filter(
Note: See TracChangeset for help on using the changeset viewer.