[1219] | 1 | /** |
---|
[1234] | 2 | * @fileOverview This is the main file, contains main app function (jquery-initialization). |
---|
[1219] | 3 | * The app main function runs setup functionality, which covers this domains: |
---|
[1234] | 4 | * <dl> |
---|
| 5 | * <dt>the variable initialization<dt> |
---|
| 6 | * <dd>functions from mdservice_searchclause.js, mdservice_widget.js, mdservice_ui_helpers.js</dd> |
---|
| 7 | * <dt>loadData()</dt> |
---|
| 8 | * <dd>loading data from repository and creating particular client-side representations - functions from <a>mdservice_ui_load.js</a></dd> |
---|
| 9 | * <dt>creating of ui-layout</dt> |
---|
| 10 | * <dd>i.e. split UI to individual panes - functions from mdservice_ui_layout.js</dd> |
---|
| 11 | * <dt>addFunctionality()</dt> |
---|
| 12 | * <dd>bind handlers to events of ui-elements (function directly in mdservice_ui.js)</dd> |
---|
| 13 | * </dl> |
---|
[1219] | 14 | * @author |
---|
| 15 | * @version |
---|
| 16 | */ |
---|
[1125] | 17 | |
---|
| 18 | $(function(){ |
---|
| 19 | // turn on debugging (see jquery.xslTransform.js) |
---|
| 20 | var DEBUG = false; |
---|
| 21 | |
---|
[1569] | 22 | // check for jQuery |
---|
[1125] | 23 | try{ |
---|
| 24 | jQuery; |
---|
| 25 | }catch(e){ |
---|
| 26 | alert('You need to include jQuery!'); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | /////// INIT VARIABLE SETTINGS |
---|
[1177] | 30 | url_params = getUrlVars(); |
---|
[1350] | 31 | workspace = new Workspace(); |
---|
[1569] | 32 | |
---|
[1125] | 33 | // create widgets |
---|
[1558] | 34 | columns_widget = new ListWidget($('#columns-widget'), "columns"); |
---|
| 35 | collections_widget = new ListWidget($('#collections-widget'), "collections"); |
---|
| 36 | listwidgetset.add(columns_widget); |
---|
| 37 | listwidgetset.add(collections_widget); |
---|
| 38 | |
---|
[1125] | 39 | //////////// LOAD DATA |
---|
| 40 | loadData(); |
---|
| 41 | addFunctionality(); |
---|
| 42 | |
---|
| 43 | ////////////// CREATE UI-LAYOUT |
---|
| 44 | createBlock('base',''); |
---|
| 45 | createLayouts('base'); |
---|
| 46 | |
---|
[1569] | 47 | // ??autocomplete correction |
---|
[1177] | 48 | initDetailFloat(); |
---|
| 49 | searchclauseset.addsearchclause(new SearchClause("","",""),"",0,0); |
---|
[1569] | 50 | createInfos(); |
---|
[1233] | 51 | detailcaller.calldetail(undefined, "info"); |
---|
[1177] | 52 | |
---|
[1125] | 53 | }); |
---|
| 54 | |
---|
[1229] | 55 | function createInfos(){ |
---|
| 56 | var info = "<span class='cmd cmd_info'></span>"; |
---|
| 57 | $('.cmds-ui-block').children('.header').append(info); |
---|
| 58 | createTooltip($('.cmds-ui-block').children('.header')); |
---|
| 59 | |
---|
| 60 | $('.cmds-ui-block').children('.header').children('.cmd_info').click(function(){ |
---|
[1233] | 61 | //var a = $(this).parent().next().attr('id'); |
---|
| 62 | //var uri = window.location.pathname + "static/info.xml"; |
---|
| 63 | //$.get(uri,{"id":a}, showDetail,'html'); |
---|
| 64 | detailcaller.calldetail($(this)); |
---|
[1229] | 65 | return false; |
---|
| 66 | }); |
---|
| 67 | } |
---|
[1125] | 68 | |
---|
[1229] | 69 | |
---|
[1125] | 70 | function getSelectedRepository(){ |
---|
[1918] | 71 | return $('select[name="x-context"]').find("option:selected").val(); |
---|
[1569] | 72 | } |
---|
[1125] | 73 | |
---|
[1561] | 74 | function getInputMode(){ |
---|
| 75 | if ($('#searchclauselist').is(":visible")){ |
---|
| 76 | return 'complex'; |
---|
| 77 | } |
---|
| 78 | return 'simple'; |
---|
| 79 | } |
---|
[1569] | 80 | |
---|
[1234] | 81 | /** |
---|
| 82 | * This function is called during the initialization sequence and binds event-handlers to events of ui-elements. |
---|
| 83 | * @function |
---|
| 84 | */ |
---|
[1125] | 85 | function addFunctionality(){ |
---|
[1561] | 86 | |
---|
[1918] | 87 | //change context_selects |
---|
[1919] | 88 | $('select[name=x-context]').live('change',function(event){ |
---|
| 89 | event.preventDefault(); |
---|
[1918] | 90 | //delete the autocomplete arrays, reset the index input values |
---|
| 91 | //element_autocomplete.splice(0, element_autocomplete.length); |
---|
[1919] | 92 | //element_autocomplete_explain.splice(0, element_autocomplete_explain.length ); |
---|
| 93 | |
---|
| 94 | //searchclauseset.clear(); |
---|
[1918] | 95 | //load new |
---|
| 96 | loadTermsAutocompleteExplain(); |
---|
[1919] | 97 | searchclauseset.initAutocomplete(false); |
---|
[1918] | 98 | }); |
---|
| 99 | |
---|
[1561] | 100 | //switch the input simple query vs complex query |
---|
| 101 | $('#switch-input').live('click',function(){ |
---|
| 102 | $('#searchclauselist').toggle(); |
---|
| 103 | $('#input-simplequery').toggle(); |
---|
| 104 | if (getInputMode() == 'complex'){ |
---|
| 105 | searchclauseset.sctext = $('#input-simplequery').attr("value"); |
---|
| 106 | searchclauseset.buildfromquerystring(); |
---|
| 107 | } else { |
---|
[1584] | 108 | $('#input-simplequery').attr("value",searchclauseset.buildsctext()); |
---|
[1561] | 109 | } |
---|
| 110 | }); |
---|
| 111 | |
---|
[1153] | 112 | // DEL COMMAND |
---|
[1215] | 113 | /* |
---|
| 114 | $('.ui-dialog-titlebar .cmd_del').live('click',function(){ |
---|
| 115 | var did; |
---|
| 116 | if ($(this).closest('.ui-dialog').length > 0){ |
---|
| 117 | did = $(this).closest('.ui-dialog').find('.detail-wrapper').attr('id'); |
---|
| 118 | } |
---|
| 119 | if (did != undefined){ |
---|
| 120 | detail = detailcaller.getdetail(did); |
---|
| 121 | detail.close(); |
---|
| 122 | } |
---|
| 123 | $(this).closest('.ui-dialog').hide(); |
---|
| 124 | }) |
---|
| 125 | */ |
---|
[1234] | 126 | /** |
---|
[1236] | 127 | * Remove a query from queryset |
---|
| 128 | * FIXME: shouldn't this primarily delete the query-object from the queryset? |
---|
| 129 | * @event |
---|
| 130 | * @name clickQueryremove |
---|
[1234] | 131 | */ |
---|
[1153] | 132 | $('.query_header .cmd_del').live('click', function(){ |
---|
| 133 | $(this).closest('.query_wrapper').remove(); |
---|
| 134 | }); |
---|
[1125] | 135 | |
---|
[1169] | 136 | //TODO dialog |
---|
| 137 | $('.detail-header .cmd_del').live('click', function(){ |
---|
[1153] | 138 | var did, detail; |
---|
[1125] | 139 | |
---|
[1153] | 140 | if ($(this).parent().hasClass('detail-header')){ |
---|
| 141 | var dw = $(this).closest('.detail-wrapper'); |
---|
| 142 | did = dw.attr('id'); |
---|
| 143 | dw.hide(); |
---|
[1125] | 144 | } |
---|
[1153] | 145 | else { |
---|
[1156] | 146 | if ($(this).parent().siblings('.ui-dialog-content').length > 0){ |
---|
| 147 | did = $(this).parent().siblings('.ui-dialog-content').find('.detail-wrapper').attr('id'); |
---|
| 148 | } |
---|
[1153] | 149 | } |
---|
| 150 | if (did != undefined){ |
---|
| 151 | detail = detailcaller.getdetail(did); |
---|
| 152 | detail.close(); |
---|
| 153 | } |
---|
| 154 | }); |
---|
| 155 | |
---|
| 156 | // DETAIL-CALLER |
---|
| 157 | $('.detail-caller a').live('click', function(event) { |
---|
| 158 | event.preventDefault(); |
---|
| 159 | }); |
---|
| 160 | // open detail (from result-set, but also already within detail-view (ResourceRef, IsPartOf) |
---|
| 161 | $('.result a.internal, .mdrecord-detail a.internal').live('click', function(event) { |
---|
| 162 | event.preventDefault(); |
---|
[1125] | 163 | |
---|
[1574] | 164 | var uri = $(this).attr('href'); |
---|
[1233] | 165 | detailcaller.calldetail(undefined, "record", uri); |
---|
[1125] | 166 | }); |
---|
[1153] | 167 | |
---|
[1260] | 168 | $('.detail-content a').live('click', function(event) { |
---|
| 169 | |
---|
[1266] | 170 | if ($(this).attr("target") == "_blank"){ |
---|
| 171 | return true; |
---|
[1260] | 172 | } else { |
---|
[1266] | 173 | event.preventDefault(); |
---|
| 174 | var uri = $(this).attr('href'); // + " body"; |
---|
| 175 | if ($(this).attr("class") == "query"){ |
---|
| 176 | var urlparams = getUrlVars(uri); |
---|
| 177 | loadQueryFromUriParams(urlparams); |
---|
| 178 | } else { |
---|
| 179 | var type; |
---|
| 180 | if ($(this).attr("class") == "bookmark"){ |
---|
| 181 | type = "record"; |
---|
| 182 | } else { |
---|
| 183 | type = $(this).parents('.detail-wrapper').attr("id"); |
---|
| 184 | type = type.substring(7,type.length); |
---|
| 185 | } |
---|
| 186 | // $.get(uri, showDetail,'html'); */ |
---|
| 187 | detailcaller.calldetail(undefined, type, uri); |
---|
| 188 | } |
---|
[1260] | 189 | } |
---|
| 190 | }); |
---|
[1153] | 191 | $('.result a.external, .mdrecord-detail a.external').live('click', function(event) { |
---|
| 192 | |
---|
| 193 | //event.preventDefault(); |
---|
| 194 | var uri = $(this).attr('href'); // + " body"; |
---|
| 195 | notifyUser('resource-link: ' + uri,'debug' ); |
---|
| 196 | // $.get(uri, showDetail,'html'); */ |
---|
[1125] | 197 | }); |
---|
[1153] | 198 | /* |
---|
| 199 | $('.result .cmd_detail').live('click', function(event) { |
---|
| 200 | //var qid = $(this).closest('.query_wrapper').attr('id'); |
---|
| 201 | //var query = queryset.getQuery(qid); |
---|
| 202 | |
---|
| 203 | var uri = $(this).parent().find("a").attr('href'); // + " body"; |
---|
| 204 | $.get(uri, showDetail,'html'); |
---|
| 205 | }); |
---|
| 206 | */ |
---|
| 207 | $(".detail-caller, .cmd_detail").live('click',function(event) { |
---|
| 208 | event.preventDefault(); |
---|
| 209 | detailcaller.calldetail($(this)); |
---|
| 210 | |
---|
| 211 | }); |
---|
[1229] | 212 | $(".detail-caller-inline").live('click',function(event) { |
---|
| 213 | event.preventDefault(); |
---|
| 214 | $(this).parent().children('.detail').toggle(); |
---|
| 215 | $(this).children('.cmd_down, .cmd_up').toggleClass('cmd_down cmd_up'); |
---|
| 216 | |
---|
| 217 | }); |
---|
| 218 | |
---|
[1574] | 219 | |
---|
| 220 | |
---|
[1918] | 221 | $('.cmd_sc_autocomplete').live('click', function(event) { |
---|
| 222 | var i = $(this).closest('.sc-i').attr('id'); |
---|
| 223 | var j = $(this).closest('.sc-j').attr('id'); |
---|
| 224 | searchclauseset.searchclauses[i][j].initAutocomplete($(this).hasClass('cmd_sca_explain')); |
---|
| 225 | $(this).toggleClass('cmd_sca_explain cmd_sca_smc'); |
---|
| 226 | }); |
---|
| 227 | |
---|
[1153] | 228 | // cmd_up cmd_down |
---|
| 229 | $('.cmd_up').live('click', function(event) { |
---|
| 230 | if ($(this).closest('.detail-wrapper').length > 0 ) { |
---|
| 231 | $(this).closest('.detail-wrapper').find('.detail-content').hide(); |
---|
| 232 | } else { |
---|
| 233 | $(this).closest('.query_wrapper').find('.result').hide(); |
---|
| 234 | } |
---|
| 235 | $(this).toggleClass('cmd_down cmd_up'); |
---|
| 236 | }); |
---|
| 237 | $('.cmd_down').live('click', function(event) { |
---|
| 238 | if ($(this).closest('.detail-wrapper').length > 0 ) { |
---|
| 239 | $(this).closest('.detail-wrapper').find('.detail-content').show(); |
---|
| 240 | } else { |
---|
| 241 | $(this).closest('.query_wrapper').find('.result').show(); |
---|
| 242 | } |
---|
| 243 | $(this).toggleClass('cmd_down cmd_up'); |
---|
| 244 | }); |
---|
| 245 | |
---|
[1273] | 246 | $('.cmd_publish').live('click', function(event){ |
---|
| 247 | var query = $(this).parent().data('query'); |
---|
[1435] | 248 | if (query != undefined){ // query |
---|
| 249 | query.publish(); |
---|
| 250 | } else { // bookmarksets |
---|
| 251 | var json = workspace.getTypedElement('user','bookmarkset'); |
---|
| 252 | var id = parseInt($('#bts_select').find("option:selected").val()); |
---|
| 253 | var bsjson = json[id]; |
---|
| 254 | $.get("/MDService2/virtualcollection/USER/" + bsjson.id,"", function(data){ |
---|
| 255 | if (bsjson.vcrid == 0){ |
---|
| 256 | var id = parseInt($(data).children().children('virtualcollectionid').text()); |
---|
| 257 | bsjson.vcrid = id; |
---|
| 258 | workspace.savequeryset(bsjson, 1); |
---|
| 259 | } |
---|
| 260 | }); |
---|
| 261 | } |
---|
| 262 | |
---|
[1273] | 263 | }); |
---|
[1177] | 264 | |
---|
[1153] | 265 | ////////////////////////////////////////////// |
---|
[1125] | 266 | $('#searchretrieve').submit( function(event) { |
---|
| 267 | event.preventDefault(); |
---|
| 268 | //hideWelcomeMessage(); |
---|
[1584] | 269 | var query; |
---|
[1561] | 270 | if (getInputMode() == 'complex'){ |
---|
[1584] | 271 | query = searchclauseset.buildsctext(); |
---|
[1561] | 272 | } else { |
---|
[1584] | 273 | query = $('#input-simplequery').attr("value"); |
---|
[1561] | 274 | } |
---|
[1174] | 275 | // TODO we dont use columns-widget |
---|
| 276 | var columns = "";//columns_widget.getColumnsListText(); |
---|
[1215] | 277 | var collections = collections_widget.widgets; //searchclauseset.sctext; |
---|
[1429] | 278 | //var ws = $('#input-withsummary').attr("checked"); |
---|
[1125] | 279 | |
---|
| 280 | notifyUser("processing query"); |
---|
| 281 | |
---|
| 282 | if (jQuery.trim(query).length == 0){ |
---|
| 283 | query = null; |
---|
| 284 | } |
---|
[1584] | 285 | var q = new Query(collections, columns, query); //actions.collections.current, query ); |
---|
[1136] | 286 | q.repository = getSelectedRepository(); |
---|
[1429] | 287 | //if (ws) { |
---|
| 288 | // q.options = "withSummary"; |
---|
| 289 | //} |
---|
[1125] | 290 | notifyUser("submit_query:" + q.query_uri(),'debug'); |
---|
| 291 | queryset.addquery(q); |
---|
| 292 | }); |
---|
| 293 | |
---|
[1153] | 294 | $('.autocomplete-select-caller').live('click', function(event) { |
---|
[1125] | 295 | |
---|
| 296 | $(this).closest(".index-context").prev().parent().find(".autocomplete-input").val($(this).text()).change(); |
---|
| 297 | $(this).closest(".index-context").hide(); |
---|
| 298 | }); |
---|
| 299 | $('.autocomplete-select-caller a').live('click', function(event) { |
---|
| 300 | event.preventDefault(); |
---|
| 301 | }); |
---|
| 302 | |
---|
| 303 | |
---|
| 304 | $('.comp_detail input').live('keyup', function(event) { |
---|
| 305 | $('#srquery').val( |
---|
| 306 | $(this).parent().children('span.cmdelem_name').text() |
---|
| 307 | + "=" + $(this).val() ); |
---|
| 308 | }); |
---|
| 309 | |
---|
| 310 | |
---|
| 311 | $('a.open-in-context').live('click', function(event) { |
---|
| 312 | event.preventDefault(); |
---|
| 313 | var uri = $(this).attr('href'); |
---|
| 314 | /* notifyUser("open_incontext:" + uri); |
---|
| 315 | $(this).after("<div class='ui-context-dialog cmds-ui-block' ></div>"); |
---|
| 316 | var trg = $(this).next(".ui-context-dialog"); |
---|
| 317 | trg.show(); |
---|
| 318 | $(trg).load(uri); //function(event) { } */ |
---|
| 319 | var contextual_uri = uri.replace('htmlpage','htmldetail'); |
---|
| 320 | |
---|
| 321 | $.get(contextual_uri, showDetail,'html'); |
---|
| 322 | }); |
---|
| 323 | |
---|
| 324 | // RECORDSET searchRetrieve |
---|
| 325 | /* |
---|
| 326 | $('#searchretrieve').submit( function(event) { |
---|
| 327 | event.preventDefault(); |
---|
| 328 | //hideWelcomeMessage(); |
---|
| 329 | searchclauseset.buildsctext(); |
---|
| 330 | notifyUser(searchclauseset.sctext,'debug'); |
---|
| 331 | //submit_query ($('#columns_list').attr("value"),searchclauseset.sctext, $('#input-simplequery').attr("value")); |
---|
| 332 | submit_query (columns_widget.getColumnsListText(),searchclauseset.sctext, $('#input-simplequery').attr("value"), $('#input-withsummary').attr("checked")); |
---|
| 333 | }); |
---|
| 334 | */ |
---|
| 335 | $('#columns-widget .cmd_save').click(function(event) { |
---|
| 336 | var terms = [{}]; |
---|
| 337 | |
---|
| 338 | var id = $("#ts_select option").size(); |
---|
| 339 | var name = "termset_" + id; |
---|
| 340 | |
---|
| 341 | columns_widget.getListWidget().find('.list-item').each(function(i,elem){ |
---|
| 342 | terms[i] = $(elem).text(); |
---|
| 343 | }); |
---|
| 344 | |
---|
| 345 | var dt = new Date(); |
---|
| 346 | var str_time = dateFormat(dt);//dt.toString("dd/mm/yyyy HH:mm:ss"); |
---|
| 347 | var jsont = {"name":name, "time" : str_time, "Terms" :terms}; |
---|
| 348 | if (jsonw["WorkspaceProfile"]["CustomTermsets"] == undefined) { |
---|
| 349 | jsonw["WorkspaceProfile"]["CustomTermsets"] = [{}]; |
---|
| 350 | } |
---|
| 351 | jsonw["WorkspaceProfile"]["CustomTermsets"][id] = jsont; |
---|
| 352 | |
---|
[1252] | 353 | //saveWorkspace("USER"); |
---|
| 354 | Workspace.save("USER"); |
---|
[1125] | 355 | loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]); |
---|
| 356 | //createTermsUI(jsonw["WorkspaceProfile"]["CustomTermsets"][id],$('#userterms')); |
---|
| 357 | $("#ts_select option").removeAttr("selected"); |
---|
| 358 | $("#ts_select option").last().attr("selected","selected"); |
---|
| 359 | $('#ts_input').attr("value",name); |
---|
| 360 | createTermsUI(jsonw["WorkspaceProfile"]["CustomTermsets"][id],$('#userterms')); |
---|
| 361 | }); |
---|
| 362 | |
---|
| 363 | /* |
---|
| 364 | $('#querylist .query_header').find('.cmd_del').live('click', function(event) { |
---|
| 365 | //showTermDetail($(this).parent().text()); |
---|
| 366 | |
---|
| 367 | queryset.removequery($(this).closest('.query_wrapper').attr('id')); |
---|
| 368 | |
---|
| 369 | }); |
---|
| 370 | */ |
---|
| 371 | /* |
---|
| 372 | $('#querylist .cmd_up').live('click', function(event) { |
---|
| 373 | $(this).closest('.query_wrapper').find('.result').hide(); |
---|
| 374 | $(this).toggleClass('cmd_down cmd_up'); |
---|
| 375 | }); |
---|
| 376 | |
---|
| 377 | */ |
---|
[1234] | 378 | |
---|
| 379 | $('#detail_query .cmds .cmd_save').live('click', function(event) { |
---|
[1388] | 380 | //qid = $(this).data('query').listid; |
---|
| 381 | qid = $(this).data('qid'); |
---|
[1234] | 382 | notifyUser("here I would save query: " + qid, "debug"); |
---|
[1388] | 383 | var q = queryset.getQuery(qid); |
---|
| 384 | q.save(); |
---|
[1273] | 385 | //Workspace.saveQuery($(this).data('query')); |
---|
[1234] | 386 | }); |
---|
[1388] | 387 | $('#detail_query .cmds .cmd_savenew').live('click', function(event) { |
---|
| 388 | //qid = $(this).data('query').listid; |
---|
| 389 | qid = $(this).data('qid'); |
---|
| 390 | notifyUser("here I would savenew query: " + qid, "debug"); |
---|
| 391 | var q = queryset.getQuery(qid); |
---|
| 392 | q.id = 0; |
---|
| 393 | q.save(); |
---|
| 394 | //Workspace.saveQuery($(this).data('query')); |
---|
| 395 | }); |
---|
[1234] | 396 | |
---|
| 397 | /** |
---|
| 398 | * FIXME: this should only invoke appropriate query-function storing the query to workspaceprofile |
---|
| 399 | */ |
---|
[1125] | 400 | $('#querylist .cmd_save').live('click', function(event) { |
---|
[1350] | 401 | // bookmark |
---|
| 402 | if ($(this).parents('.result').length > 0){ |
---|
| 403 | qstring = $(this).parent().find("a").attr('href'); |
---|
| 404 | qstring = qstring.substring(18,qstring.length); |
---|
| 405 | |
---|
[1584] | 406 | var q = new Query([],"",qstring); |
---|
[1350] | 407 | q.bookmark = 1; |
---|
| 408 | q.save(); |
---|
| 409 | |
---|
| 410 | } |
---|
| 411 | }); |
---|
[1125] | 412 | |
---|
[1234] | 413 | /** |
---|
| 414 | * FIXME: this looks like a typo: #queryslist -> #querylist |
---|
| 415 | */ |
---|
[1125] | 416 | $('#queryslist .cmd_reload').live('click', function(event) { |
---|
| 417 | var qid = $(this).closest('.query_wrapper').attr("id"); |
---|
| 418 | |
---|
| 419 | queryset.resubmit(qid); |
---|
| 420 | |
---|
| 421 | }); |
---|
| 422 | |
---|
| 423 | |
---|
[1153] | 424 | |
---|
[1125] | 425 | $('.cmd_sc_delete').live('click', function(event) { |
---|
| 426 | var i = $(this).closest('.sc-i').attr('id'); |
---|
| 427 | var j = $(this).closest('.sc-j').attr('id'); |
---|
| 428 | //notifyUser(i + j,'debug'); |
---|
| 429 | searchclauseset.removesearchclause(i,j); |
---|
| 430 | |
---|
| 431 | }); |
---|
| 432 | $('.cmd_add_and').live('click', function(event) { |
---|
| 433 | //showTermDetail($(this).parent().text()); |
---|
| 434 | //$(this).next().hide(); |
---|
| 435 | $(this).attr("value","AND"); |
---|
| 436 | var searchclause = new SearchClause("","",""); |
---|
| 437 | var i = $(this).closest('.sc-i').attr('id'); |
---|
| 438 | var j = $(this).closest('.sc-j').attr('id'); |
---|
| 439 | //notifyUser(i + j,'debug'); |
---|
| 440 | searchclauseset.addsearchclause(searchclause,"and",i,j); |
---|
| 441 | |
---|
| 442 | }); |
---|
| 443 | $('.cmd_add_or').live('click', function(event) { |
---|
| 444 | //showTermDetail($(this).parent().text()); |
---|
| 445 | //$(this).next().hide(); |
---|
| 446 | var i,j; |
---|
| 447 | $(this).attr("value","OR"); |
---|
| 448 | var searchclause = new SearchClause("","",""); |
---|
| 449 | searchclauseset.addsearchclause(searchclause,"or",$(this).closest('.sc-i').attr('id'),$(this).closest('.sc-j').attr('id')); |
---|
| 450 | |
---|
| 451 | }); |
---|
| 452 | |
---|
[1384] | 453 | ///// QUERYSETS |
---|
[1125] | 454 | $('#qts_save').click(function(){ |
---|
| 455 | var id = $("#qts_select option:selected").val(); |
---|
| 456 | //notifyUser($('#qts_input').val() + $('#qts_input').text(),'debug'); |
---|
[1350] | 457 | workspace.user_json["WorkspaceProfile"]["Querysets"][id]["name"] = $('#qts_input').val(); |
---|
[1384] | 458 | //workspace.save("USER"); |
---|
| 459 | workspace.savequeryset(workspace.user_json["WorkspaceProfile"]["Querysets"][id],0); |
---|
[1350] | 460 | |
---|
[1125] | 461 | $("#qts_select option:selected").text( $('#qts_input').val()); |
---|
[1350] | 462 | |
---|
[1125] | 463 | }); |
---|
| 464 | $('#qts_add').click(function(){ |
---|
[1384] | 465 | //var new_name = "new_queryset"; |
---|
[1125] | 466 | |
---|
[1384] | 467 | //workspace.addqueryset(new_name); |
---|
| 468 | //var id = workspace.user_json["WorkspaceProfile"]["Querysets"].length-1; |
---|
| 469 | //workspace.savequeryset(workspace.user_json["WorkspaceProfile"]["Querysets"][id],0); |
---|
| 470 | //workspace.save("USER"); |
---|
| 471 | var q = workspace.addelement('queryset'); |
---|
| 472 | workspace.savequeryset(q, 0); |
---|
[1350] | 473 | //todo |
---|
[1125] | 474 | var id = $('#qts_select option').size(); |
---|
[1384] | 475 | $("#qts_select").append(new Option(q["name"], id)); |
---|
[1125] | 476 | $("#qts_select").find('option').attr("selected","false"); |
---|
| 477 | $("#qts_select").find('option').last().attr("selected","true"); |
---|
[1384] | 478 | $('#qts_input').val(q["name"]); |
---|
[1125] | 479 | }); |
---|
| 480 | $('#qts_delete').click(function(){ |
---|
[1384] | 481 | var qsid = parseInt($("#qts_select option:selected").val()); |
---|
| 482 | workspace.removeelement("queryset", qsid); |
---|
| 483 | workspace.save("USER"); |
---|
| 484 | //update |
---|
| 485 | loadQuerysets("user"); |
---|
| 486 | }); |
---|
| 487 | |
---|
| 488 | //BOOKMARKSETS |
---|
| 489 | $('#bts_save').click(function(){ |
---|
| 490 | var id = $("#bts_select option:selected").val(); |
---|
| 491 | workspace.user_json["WorkspaceProfile"]["Bookmarksets"][id]["name"] = $('#bts_input').val(); |
---|
| 492 | workspace.savequeryset(workspace.user_json["WorkspaceProfile"]["Bookmarksets"][id],1); |
---|
[1125] | 493 | |
---|
[1384] | 494 | $("#bts_select option:selected").text( $('#bts_input').val()); |
---|
| 495 | }); |
---|
| 496 | $('#bts_add').click(function(){ |
---|
| 497 | var b = workspace.addelement('bookmarkset'); |
---|
| 498 | //var id = workspace.user_json["WorkspaceProfile"]["Bookmarksets"].length-1; |
---|
| 499 | //workspace.savequeryset(workspace.user_json["WorkspaceProfile"]["Bookmarksets"][id],1); |
---|
| 500 | workspace.savequeryset(b,1); |
---|
[1125] | 501 | |
---|
[1384] | 502 | var id = $('#bts_select option').size(); |
---|
| 503 | $("#bts_select").append(new Option(b["name"], id)); |
---|
| 504 | $("#bts_select").find('option').attr("selected","false"); |
---|
| 505 | $("#bts_select").find('option').last().attr("selected","true"); |
---|
| 506 | $('#bts_input').val(b["name"]); |
---|
| 507 | }); |
---|
| 508 | $('#bts_delete').click(function(){ |
---|
| 509 | var bsid = parseInt($("#bts_select option:selected").val()); |
---|
[1125] | 510 | |
---|
[1384] | 511 | workspace.removeelement("bookmarkset", bsid); |
---|
[1350] | 512 | workspace.save("USER"); |
---|
| 513 | //update |
---|
[1384] | 514 | loadBookmarksets("user"); |
---|
[1125] | 515 | }); |
---|
[1384] | 516 | |
---|
| 517 | //////////////////////////////////////////////// |
---|
[1125] | 518 | $('#ts_save').click(function(){ |
---|
| 519 | var id = $("#ts_select option:selected").val(); |
---|
| 520 | //notifyUser($('#qts_input').val() + $('#qts_input').text(),'debug'); |
---|
| 521 | jsonw["WorkspaceProfile"]["CustomTermsets"][id]["name"] = $('#ts_input').val(); |
---|
| 522 | |
---|
| 523 | $("#ts_select option:selected").text( $('#ts_input').val()); |
---|
[1252] | 524 | //saveWorkspace("USER"); |
---|
| 525 | Workspace.save("USER"); |
---|
[1125] | 526 | }); |
---|
| 527 | $('#ts_add').click(function(){ |
---|
| 528 | var new_name = "new_termset"; |
---|
| 529 | |
---|
| 530 | var id = $('#ts_select option').size(); |
---|
| 531 | var dt = new Date(); |
---|
| 532 | var str_time = dateFormat(dt);//dt.toString("yyyy-MM-dd HH:mm:ss"); |
---|
| 533 | |
---|
| 534 | if (id == 0){ |
---|
| 535 | jsonw["WorkspaceProfile"]["CustomTermsets"] = [{}]; |
---|
| 536 | } |
---|
| 537 | |
---|
| 538 | jsonw["WorkspaceProfile"]["CustomTermsets"][id] = {"name":new_name,"created":str_time , "Terms" : "null"}; |
---|
| 539 | |
---|
[1252] | 540 | //saveWorkspace("USER"); |
---|
| 541 | Workspace.save("USER"); |
---|
[1125] | 542 | //todo |
---|
| 543 | |
---|
| 544 | //loadWorkspace(jsonw["WorkspaceProfile"]["Querysets"]); |
---|
| 545 | $("#ts_select").append(new Option(new_name, id)); |
---|
| 546 | $("#ts_select").find('option').attr("selected","false"); |
---|
| 547 | $("#ts_select").find('option').last().attr("selected","true"); |
---|
| 548 | $('#ts_input').val(new_name); |
---|
[1252] | 549 | createTermsUI(jsonw["WorkspaceProfile"]["CustomTermsets"][id],$('#userterms')); |
---|
[1125] | 550 | }); |
---|
| 551 | $('#ts_delete').click(function(){ |
---|
| 552 | var count = $("#ts_select option").size(); |
---|
| 553 | |
---|
| 554 | //if (count > 1){ |
---|
| 555 | var id = parseInt($("#ts_select option:selected").val()); |
---|
| 556 | var size = jsonw["WorkspaceProfile"].CustomTermsets.length; |
---|
| 557 | |
---|
| 558 | for (var i=id;i<size-1;i++){ |
---|
| 559 | jsonw["WorkspaceProfile"].CustomTermsets[i] = jsonw["WorkspaceProfile"].CustomTermsets[i+1]; |
---|
| 560 | } |
---|
| 561 | |
---|
| 562 | delete jsonw["WorkspaceProfile"].CustomTermsets[size-1]; |
---|
| 563 | jsonw["WorkspaceProfile"]["CustomTermsets"].length = size-1; |
---|
| 564 | // set null string , if 0 termsets |
---|
| 565 | if (count == 1) { |
---|
| 566 | jsonw["WorkspaceProfile"]["CustomTermsets"] = "null"; |
---|
| 567 | } |
---|
[1252] | 568 | //saveWorkspace("USER"); |
---|
| 569 | Workspace.save("USER"); |
---|
[1125] | 570 | loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]); |
---|
| 571 | }); |
---|
| 572 | |
---|
| 573 | $('#userterms .cmd_load').live('click',function(event){ |
---|
| 574 | var term = String.trim($(this).parent().find('a').text()); |
---|
| 575 | columns_widget.add(new ListItem(term)); |
---|
| 576 | |
---|
| 577 | }); |
---|
| 578 | $('#userterms .cmd_del').live('click', function(event){ |
---|
| 579 | var id = parseInt($("#ts_select option:selected").val()); |
---|
| 580 | var str = $(this).parent().find('a').attr("href"); |
---|
| 581 | var iq = parseInt(str.substring(10)); |
---|
| 582 | var size = jsonw["WorkspaceProfile"]["CustomTermsets"][id]["Terms"].length; |
---|
| 583 | |
---|
| 584 | for (var i=iq;i<size-1;i++){ |
---|
| 585 | jsonw["WorkspaceProfile"]["CustomTermsets"][id]["Terms"][i] = jsonw["WorkspaceProfile"]["CustomTermsets"][id]["Terms"][i+1]; |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | delete jsonw["WorkspaceProfile"]["CustomTermsets"][id]["Terms"][size-1]; |
---|
| 589 | jsonw["WorkspaceProfile"]["CustomTermsets"][id]["Terms"].length = size-1; |
---|
| 590 | |
---|
| 591 | if (size == 1){ |
---|
| 592 | jsonw["WorkspaceProfile"]["CustomTermsets"][id]["Terms"] = "null"; |
---|
| 593 | } |
---|
| 594 | |
---|
[1252] | 595 | //saveWorkspace("USER"); |
---|
| 596 | Workspace.save("USER"); |
---|
[1125] | 597 | loadTermsets(jsonw["WorkspaceProfile"]["CustomTermsets"]); |
---|
| 598 | //$("#ts_select option").remove(); |
---|
| 599 | //$("#ts_select option").first().attr("selected","true"); |
---|
| 600 | }); |
---|
| 601 | |
---|
| 602 | |
---|
| 603 | $('#collections .cmd_load').live('click',function(event){ |
---|
| 604 | //hideWelcomeMessage(); |
---|
| 605 | var collection_text = ""; |
---|
| 606 | var coll = $(this).parent(); |
---|
[1215] | 607 | var collections = []; |
---|
| 608 | //collections.splice(0, collections.length); |
---|
[1125] | 609 | collections[0] = new Collection($(coll).attr("handle"), String.trim($(coll).children('a').text())); |
---|
[1215] | 610 | var columns = columns_widget.getListText();//$('#columns_list').attr("value"); |
---|
| 611 | //var collections = collections_widget.getListText(); |
---|
[1584] | 612 | var query = new Query(collections,columns,""); |
---|
[1125] | 613 | query.repository = getSelectedRepository(); |
---|
| 614 | |
---|
| 615 | //searchclauseset.clear(); |
---|
| 616 | queryset.addquery(query); |
---|
| 617 | //$('#collection_list').attr("value",query.getcollectiontext("name")); |
---|
| 618 | collections_widget.load(query.collection); |
---|
| 619 | |
---|
| 620 | }); |
---|
| 621 | $('#serverqueries .cmd_load').live('click',function(event){ |
---|
| 622 | |
---|
[1350] | 623 | //var id = parseInt( $("#serverqts_select option:selected").val()); |
---|
| 624 | //var str = $(this).parent().find('a').attr("href"); |
---|
| 625 | //var iq = parseInt(str.substring(9)); |
---|
| 626 | //var json = jQuery.parseJSON($("#serverqs").attr("data")); |
---|
| 627 | //var q = json["WorkspaceProfile"]["Querysets"][id]["Queries"][iq]; |
---|
[1125] | 628 | |
---|
[1384] | 629 | var q = $(this).closest('.cmds-elem-plus').data("query");//json"); |
---|
[1125] | 630 | loadQuery(q); |
---|
| 631 | }); |
---|
| 632 | $('#userqueries .cmd_load').live('click',function(event){ |
---|
[1384] | 633 | var q = $(this).closest('.cmds-elem-plus').data("query");//json"); |
---|
[1125] | 634 | loadQuery(q); |
---|
| 635 | }); |
---|
| 636 | $('#userqueries .cmd_del').live('click', function(event){ |
---|
| 637 | //var count = $("#userqueries li").size(); |
---|
[1384] | 638 | /* |
---|
[1125] | 639 | var id = parseInt($("#qts_select option:selected").val()); |
---|
| 640 | var str = $(this).parent().find('a').attr("href"); |
---|
| 641 | var iq = parseInt(str.substring(7)); |
---|
[1350] | 642 | var size = workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"].length; |
---|
[1125] | 643 | |
---|
| 644 | for (var i=iq;i<size-1;i++){ |
---|
[1350] | 645 | workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"][i] = workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"][i+1]; |
---|
[1125] | 646 | } |
---|
| 647 | |
---|
[1350] | 648 | delete workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"][size-1]; |
---|
| 649 | workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"].length = size-1; |
---|
[1125] | 650 | |
---|
| 651 | if (size == 1){ |
---|
[1350] | 652 | workspace.user_json["WorkspaceProfile"]["Querysets"][id]["Queries"] = "null"; |
---|
[1125] | 653 | } |
---|
[1384] | 654 | */ |
---|
[1252] | 655 | //saveWorkspace("USER"); |
---|
[1384] | 656 | var id2 = parseInt($("#qts_select option:selected").val()); |
---|
| 657 | var id1 = parseInt( $(this).parent().find('a').attr("href").substring(7)); |
---|
| 658 | workspace.removeelement("query", id1, id2); |
---|
| 659 | workspace.save("user"); |
---|
[1350] | 660 | loadQuerysets("user"); |
---|
[1125] | 661 | //$("#qs_select option").remove(); |
---|
| 662 | //$("#qs_select option").first().attr("selected","true"); |
---|
| 663 | }); |
---|
| 664 | |
---|
[1429] | 665 | $('.detail-wrapper .cmd_withsummary').live('click',function(event){ |
---|
| 666 | var detail = $(this).closest('.detail-wrapper').data('detail'); |
---|
| 667 | var query = detail.query; |
---|
| 668 | // aaaload new query |
---|
| 669 | query.summaryinfo(); |
---|
| 670 | // copy summary data |
---|
| 671 | //detailcaller.calldetail($(query.container).find('.result-header').find('.cmd_detail')); |
---|
| 672 | }); |
---|
| 673 | |
---|
[1384] | 674 | $('#bookmarks .cmd_load').live('click',function(event){ |
---|
| 675 | var q = $(this).closest('.cmds-elem-plus').data("query");//json"); |
---|
| 676 | var uri = "/MDService2/record/htmldetail/" + q.query; |
---|
| 677 | detailcaller.calldetail(undefined, "record", uri); |
---|
| 678 | }); |
---|
| 679 | $('#bookmarks .cmd_del').live('click', function(event){ |
---|
| 680 | var id2 = parseInt($("#bts_select option:selected").val()); |
---|
| 681 | var id1 = parseInt( $(this).parent().find('a').attr("href").substring(7)); |
---|
| 682 | workspace.removeelement("bookmark", id1, id2); |
---|
| 683 | workspace.save("user"); |
---|
| 684 | loadBookmarksets(); |
---|
| 685 | }); |
---|
| 686 | |
---|
[1125] | 687 | |
---|
| 688 | $('.ui-dialog-titlebar-del').live('click', function(event){ |
---|
| 689 | //$('#detail-float').dialog('close'); |
---|
| 690 | var t = $(this).parents('.ui-widget').children('.ui-dialog-content'); |
---|
| 691 | $(t).dialog('close'); |
---|
| 692 | }); |
---|
| 693 | |
---|
| 694 | $('.ui-dialog-titlebar-up').live('click', function(event){ |
---|
| 695 | var t = $(this).parents('.ui-widget').children('.ui-dialog-content'); |
---|
| 696 | |
---|
| 697 | $(this).parents('.ui-widget').attr("tempheight",$(this).parents('.ui-widget').height()); |
---|
| 698 | //notifyUser("up(height):" + $(this).parents('.ui-widget').height(),'debug'); |
---|
| 699 | $(this).parents('.ui-widget').height(30); |
---|
| 700 | //notifyUser("up(tempheight):" + $(this).parents('.ui-widget').attr("tempheight"),'debug'); |
---|
| 701 | |
---|
| 702 | |
---|
| 703 | //$(t).find(".ui-dialog-buttonpane:first, .ui-dialog-content").stop({clearQueue:true}).fadeOut(300); |
---|
| 704 | //$(t).stop({clearQueue:true}).animate({height:'0px'},300); |
---|
| 705 | |
---|
| 706 | $(this).removeClass('cmd_up ui-dialog-titlebar-up'); |
---|
| 707 | $(this).addClass('cmd_down ui-dialog-titlebar-down'); |
---|
| 708 | }); |
---|
| 709 | $('.ui-dialog-titlebar-down').live('click', function(event){ |
---|
| 710 | var t = $(this).parents('.ui-widget').children('.ui-dialog-content'); |
---|
| 711 | |
---|
| 712 | var h = $(this).parents('.ui-widget').attr("tempheight"); |
---|
| 713 | //notifyUser("down(tempheight):" + h,'debug'); |
---|
| 714 | $(this).parents('.ui-widget').height(parseInt(h)); |
---|
| 715 | //notifyUser("down(height):" + $(this).parents('.ui-widget').height(),'debug'); |
---|
| 716 | |
---|
| 717 | |
---|
| 718 | //$(this).parents('.ui-widget').attr("tempheight",$(this).parents('.ui-widget').height()); |
---|
| 719 | //$(t).find(".ui-dialog-content, .ui-dialog-buttonpane:first").stop({clearQueue:true}).fadeIn(800) |
---|
| 720 | //.end().stop({clearQueue:true}).animate({height:'100%'},300); |
---|
| 721 | |
---|
| 722 | $(this).removeClass('cmd_down ui-dialog-titlebar-down'); |
---|
| 723 | $(this).addClass('cmd_up ui-dialog-titlebar-up'); |
---|
| 724 | }); |
---|
| 725 | |
---|
| 726 | } |
---|
| 727 | |
---|
[1177] | 728 | function initDetailFloat(){ |
---|
| 729 | $("#detail-float").dialog({ autoOpen: false}); |
---|
| 730 | $("#detail-float").dialog(); |
---|
| 731 | $("#detail-float").tabs(); |
---|
| 732 | }; |
---|
[1584] | 733 | |
---|
[1588] | 734 | function submit_query (columns, query, ws) { |
---|
[1125] | 735 | notifyUser("processing query"); |
---|
| 736 | |
---|
| 737 | if (jQuery.trim(query).length == 0){ |
---|
| 738 | query = null; |
---|
| 739 | } |
---|
[1588] | 740 | |
---|
[1584] | 741 | var q = new Query(collections, columns, query); //actions.collections.current, query ); |
---|
[1125] | 742 | q.repository = getSelectedRepository(); |
---|
| 743 | if (ws) { |
---|
| 744 | q.options = "withSummary"; |
---|
| 745 | } |
---|
| 746 | notifyUser("submit_query:" + q.query_uri(),'debug'); |
---|
| 747 | queryset.addquery(q); |
---|
| 748 | //notifyUser("container" + q.container.attr('id')); |
---|
| 749 | //$("#querylist").append("sdfdsf"); |
---|
| 750 | } |
---|
| 751 | |
---|
[1234] | 752 | /** |
---|
| 753 | * allows to add ui-containers into the detail-pane. |
---|
| 754 | * |
---|
| 755 | * Most of it is just to ensure a defined ordering: |
---|
| 756 | * 1. info, 2. index, 3. query, 4. record |
---|
| 757 | */ |
---|
[1153] | 758 | function addToDetailList(elem, did){ |
---|
| 759 | var exists = false; |
---|
[1223] | 760 | var index_elem = undefined; |
---|
| 761 | var query_elem = undefined; |
---|
| 762 | var record_elem = undefined; |
---|
[1233] | 763 | var info_elem = undefined; |
---|
[1223] | 764 | |
---|
[1153] | 765 | $('#detailblock').children('.content').children().each(function(){ |
---|
| 766 | if ($(this).attr("id") == did){ |
---|
| 767 | exists = true; |
---|
| 768 | } |
---|
[1223] | 769 | if ($(this).attr("id") == "detail_index"){ |
---|
| 770 | index_elem = this; |
---|
| 771 | } |
---|
| 772 | if ($(this).attr("id") == "detail_query"){ |
---|
| 773 | query_elem = this; |
---|
| 774 | } |
---|
| 775 | if ($(this).attr("id") == "detail_record"){ |
---|
| 776 | record_elem = this; |
---|
| 777 | } |
---|
[1233] | 778 | if ($(this).attr("id") == "detail_info"){ |
---|
| 779 | info_elem = this; |
---|
| 780 | } |
---|
[1153] | 781 | }); |
---|
| 782 | if (!exists) { |
---|
[1223] | 783 | if (did == "detail_record") { |
---|
| 784 | $('#detailblock').children('.content').append(elem); |
---|
| 785 | } else { |
---|
[1233] | 786 | if (did == "detail_info") { |
---|
[1223] | 787 | $('#detailblock').children('.content').prepend(elem); |
---|
| 788 | } else { |
---|
[1233] | 789 | if (did == "detail_index") { |
---|
| 790 | if (info_elem != undefined) { |
---|
| 791 | $(info_elem).after(elem); |
---|
[1223] | 792 | } else { |
---|
| 793 | if (record_elem != undefined) { |
---|
| 794 | $(record_elem).before(elem); |
---|
| 795 | } else { |
---|
| 796 | $('#detailblock').children('.content').prepend(elem); |
---|
| 797 | } |
---|
| 798 | } |
---|
| 799 | } else { |
---|
[1233] | 800 | if (did == "detail_query") { |
---|
| 801 | if (index_elem != undefined) { |
---|
| 802 | $(index_elem).after(elem); |
---|
| 803 | } else { |
---|
| 804 | if (record_elem != undefined) { |
---|
| 805 | $(record_elem).before(elem); |
---|
| 806 | } else { |
---|
[1235] | 807 | $('#detailblock').children('.content').append(elem); |
---|
[1233] | 808 | } |
---|
| 809 | } |
---|
| 810 | } else { |
---|
| 811 | $('#detailblock').children('.content').append(elem); |
---|
| 812 | } |
---|
[1223] | 813 | } |
---|
| 814 | } |
---|
| 815 | } |
---|
| 816 | |
---|
[1153] | 817 | } else { |
---|
| 818 | $('#detailblock').children('.content').children().each(function(){ |
---|
| 819 | if ($(this).attr("id") == did){ |
---|
| 820 | $(this).show(); |
---|
| 821 | } |
---|
| 822 | }); |
---|
| 823 | } |
---|
[1125] | 824 | } |
---|
[1153] | 825 | |
---|
[1125] | 826 | function addToSClist (div, i, j, rel) { |
---|
| 827 | |
---|
| 828 | var x; |
---|
| 829 | |
---|
| 830 | //notifyUser(i + "," + j + "," + rel); |
---|
| 831 | if (rel == ""){ |
---|
| 832 | x = $('<div />').addClass("sc-i").addClass("and_level"); |
---|
| 833 | $(div).appendTo($(x).appendTo($('#searchclauselist'))); |
---|
| 834 | $(x).attr("id",i); |
---|
| 835 | } else { |
---|
| 836 | if (rel == "and") { |
---|
| 837 | x = $('<div />').addClass("sc-i").addClass("and_level"); |
---|
| 838 | $(x).attr("id",i); |
---|
| 839 | $(div).appendTo($(x).appendTo($('#searchclauselist'))); |
---|
| 840 | } else { |
---|
| 841 | $(div).appendTo($('#searchclauselist').children()[i]); |
---|
| 842 | } |
---|
| 843 | } |
---|
| 844 | |
---|
| 845 | //$('#searchclauselist').append($(li)); |
---|
| 846 | |
---|
| 847 | } |
---|
| 848 | |
---|
| 849 | function addToQuerylist (x) { |
---|
| 850 | $("#querylist").prepend(x); |
---|
| 851 | } |
---|
| 852 | |
---|
| 853 | function addToNotifylist (x) { |
---|
| 854 | $("#notifylist").prepend(x); |
---|
| 855 | } |
---|
| 856 | |
---|
| 857 | function createTooltip(parentwidget) { |
---|
| 858 | |
---|
| 859 | var ccmd; |
---|
| 860 | if (parentwidget == null) { |
---|
| 861 | ccmd = $('.cmd'); |
---|
| 862 | } else { |
---|
| 863 | ccmd = $(parentwidget).find('.cmd'); |
---|
| 864 | } |
---|
| 865 | $(ccmd).mouseover(function(){ |
---|
| 866 | // command name |
---|
| 867 | var cmd = $(this).attr("class"); |
---|
| 868 | cmd = cmd.substring(cmd.indexOf("cmd_")); |
---|
| 869 | cmd = cmd.split(" ")[0]; |
---|
| 870 | |
---|
| 871 | // command place |
---|
| 872 | var place = ""; |
---|
| 873 | if ($(this).parents('.content').length > 0) { |
---|
| 874 | place = $(this).parents('.content').attr("id") + "."; |
---|
| 875 | } |
---|
| 876 | if ($(this).parents('.block').length > 0) { |
---|
| 877 | place = $(this).parents('.block').attr("id") + "."; |
---|
| 878 | } |
---|
| 879 | |
---|
| 880 | |
---|
| 881 | // find tho tooltiptext |
---|
| 882 | var a = place + cmd; |
---|
| 883 | |
---|
| 884 | if (tooltiptable[a] != null) { |
---|
| 885 | s = tooltiptable[a]; |
---|
| 886 | } else { |
---|
| 887 | if (tooltiptable[cmd] != null) { |
---|
| 888 | s = tooltiptable[cmd]; |
---|
| 889 | } else { |
---|
| 890 | s = a; |
---|
| 891 | } |
---|
| 892 | } |
---|
| 893 | tooltip.show(s); |
---|
| 894 | }); |
---|
| 895 | $(ccmd).mouseout(function(){ |
---|
| 896 | tooltip.hide(); |
---|
| 897 | }); |
---|
| 898 | |
---|
| 899 | }; |
---|
[1384] | 900 | function loadQuery(query){ |
---|
| 901 | query.repository = getSelectedRepository(); |
---|
| 902 | queryset.addquery(query); |
---|
| 903 | |
---|
| 904 | searchclauseset.sctext = query.query; |
---|
| 905 | notifyUser(searchclauseset.sctext,'debug'); |
---|
| 906 | searchclauseset.buildfromquerystring(); |
---|
[1125] | 907 | |
---|
[1384] | 908 | //collections = query.collection; |
---|
| 909 | collections_widget.load(query.collection); |
---|
| 910 | columns_widget.load(query.columns.split(',')); |
---|
[1584] | 911 | $('#input-simplequery').attr("value",query.query); |
---|
[1384] | 912 | $('#input-withsummary').attr("checked",(query.options != null)); |
---|
| 913 | updateCollectionTree(); |
---|
| 914 | |
---|
| 915 | }; |
---|
| 916 | /* |
---|
[1266] | 917 | function loadQuery(q){ |
---|
| 918 | if (q["bookmark"] == "1") { |
---|
| 919 | var uri = "/MDService2/record/htmldetail/" + q["querystring"]; |
---|
| 920 | detailcaller.calldetail(undefined, "record", uri); |
---|
| 921 | //var uri = "/MDService2/record/htmldetail/" + q["querystring"]; |
---|
| 922 | //showDetail(null,'html'); |
---|
| 923 | //$.get(uri, showDetail,'html'); |
---|
| 924 | } else { |
---|
| 925 | //hideWelcomeMessage(); |
---|
| 926 | var query = new Query([],"","",""); |
---|
| 927 | query.load(q); |
---|
| 928 | query.repository = getSelectedRepository(); |
---|
| 929 | queryset.addquery(query); |
---|
| 930 | |
---|
| 931 | searchclauseset.sctext = query.query; |
---|
| 932 | notifyUser(searchclauseset.sctext,'debug'); |
---|
| 933 | searchclauseset.buildfromquerystring(); |
---|
[1153] | 934 | |
---|
[1266] | 935 | //collections = query.collection; |
---|
| 936 | collections_widget.load(query.collection); |
---|
| 937 | columns_widget.load(query.columns.split(',')); |
---|
[1588] | 938 | $('#input-simplequery').attr("value",query.query); |
---|
[1266] | 939 | $('#input-withsummary').attr("checked",(query.options != null)); |
---|
| 940 | updateCollectionTree(); |
---|
| 941 | } |
---|
| 942 | |
---|
| 943 | } |
---|
[1384] | 944 | */ |
---|
[1266] | 945 | function loadQueryFromUriParams(local_uri){ |
---|
| 946 | var url; |
---|
| 947 | |
---|
| 948 | if (local_uri == undefined){ |
---|
| 949 | url = url_params; |
---|
| 950 | } else { |
---|
| 951 | url = local_uri; |
---|
| 952 | } |
---|
[1558] | 953 | //TODO new params |
---|
[1266] | 954 | var q = url["q"]; |
---|
[1561] | 955 | if (url["query"] == undefined){ |
---|
| 956 | q = url["q"]; |
---|
| 957 | } |
---|
| 958 | else { |
---|
| 959 | q = url["query"]; |
---|
| 960 | } |
---|
| 961 | |
---|
[1266] | 962 | var collection = url["collection"]; |
---|
[1561] | 963 | var startItem = url["startRecord"]; |
---|
| 964 | var maximumItems = url["maximumRecords"]; |
---|
[1266] | 965 | var repository = url["repository"]; |
---|
| 966 | var columns = url["columns"]; |
---|
[1561] | 967 | if ((q != undefined) || (collection != undefined)) { |
---|
[1266] | 968 | if (q == undefined) { |
---|
| 969 | q = ""; |
---|
| 970 | } else { |
---|
| 971 | q = Url.decode(q); |
---|
[1588] | 972 | } |
---|
[1266] | 973 | if (columns == undefined) { |
---|
| 974 | columns = ""; |
---|
| 975 | } |
---|
| 976 | if (startItem == undefined) { |
---|
| 977 | startItem = 1; |
---|
| 978 | } |
---|
| 979 | if (maximumItems == undefined) { |
---|
| 980 | maximumItems = 10; |
---|
| 981 | } |
---|
| 982 | if (repository == undefined) { |
---|
| 983 | repository = getSelectedRepository(); |
---|
| 984 | } |
---|
| 985 | if (collection == undefined){ |
---|
| 986 | collection = ""; |
---|
| 987 | } |
---|
| 988 | var collections = []; |
---|
| 989 | if (collection.length > 0 ){ |
---|
| 990 | var coll = collection.split(","); |
---|
| 991 | $.each(coll,function(i,item){ |
---|
| 992 | var n; |
---|
| 993 | n = $('#collections').find(".folder:[handle='"+item+"']").text(); |
---|
| 994 | var simple_collection = new Collection(item, n); |
---|
| 995 | collections[i] = simple_collection; |
---|
| 996 | }); |
---|
| 997 | } |
---|
| 998 | |
---|
[1561] | 999 | var query = new Query(collections, columns, q); |
---|
[1266] | 1000 | query.startItem = startItem; |
---|
| 1001 | query.maximumItems = maximumItems; |
---|
| 1002 | query.repository = repository; |
---|
| 1003 | |
---|
| 1004 | |
---|
| 1005 | queryset.addquery(query); |
---|
| 1006 | |
---|
| 1007 | searchclauseset.sctext = query.query; |
---|
| 1008 | notifyUser(searchclauseset.sctext,'debug'); |
---|
| 1009 | searchclauseset.buildfromquerystring(); |
---|
| 1010 | |
---|
| 1011 | //collections = query.collection; |
---|
| 1012 | collections_widget.load(query.collection); |
---|
| 1013 | columns_widget.load(query.columns.split(',')); |
---|
[1588] | 1014 | $('#input-simplequery').attr("value",query.query); |
---|
[1266] | 1015 | $('#input-withsummary').attr("checked",(query.options != null)); |
---|
| 1016 | updateCollectionTree(); |
---|
| 1017 | |
---|
| 1018 | } |
---|
| 1019 | |
---|
| 1020 | } |
---|
| 1021 | |
---|