[22516] | 1 |
|
---|
| 2 | console.log("Loading gui_div.js\n");
|
---|
| 3 |
|
---|
[23276] | 4 | var initialised_iframe = "false";
|
---|
[23312] | 5 |
|
---|
[23489] | 6 | //function createFormatStatement()
|
---|
| 7 | //{
|
---|
[23312] | 8 |
|
---|
[23489] | 9 | //var formatDiv = document.getElementById('formatStatement');
|
---|
| 10 | //var formatStatement = innerXHTML(formatDiv);
|
---|
[23340] | 11 | //console.log(formatStatement);
|
---|
[23312] | 12 |
|
---|
[23405] | 13 | // find collection name
|
---|
[23336] | 14 |
|
---|
[23489] | 15 | //var myurl = document.URL;
|
---|
| 16 | //console.log(myurl);
|
---|
| 17 | //var first = myurl.indexOf("&c")+3;
|
---|
| 18 | //var last = myurl.indexOf("&", first);
|
---|
[23405] | 19 |
|
---|
[23489] | 20 | //var collection_name = getSubstring(myurl, "&c", "&"); //myurl.substring(first,last); ///&c=(.*)&/.exec(myurl);
|
---|
| 21 | //console.log(collection_name);
|
---|
[23405] | 22 |
|
---|
[23489] | 23 | //first = myurl.indexOf("&s")+3;
|
---|
| 24 | //last = myurl.indexOf("&", first);
|
---|
[23405] | 25 |
|
---|
[23489] | 26 | //var service_name = myurl.substring(first,last);
|
---|
| 27 | //console.log(service_name);
|
---|
[23405] | 28 |
|
---|
[23489] | 29 | //var classifier_name = null;
|
---|
[23405] | 30 |
|
---|
[23489] | 31 | //if(service_name == "ClassifierBrowse")
|
---|
| 32 | //{
|
---|
| 33 | // first = myurl.indexOf("&cl")+4;
|
---|
| 34 | // last = myurl.indexOf("&", first);
|
---|
[23405] | 35 |
|
---|
[23489] | 36 | // classifier_name = myurl.substring(first,last);
|
---|
| 37 | // console.log(classifier_name);
|
---|
| 38 | //}
|
---|
[23405] | 39 |
|
---|
[23333] | 40 | //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;
|
---|
| 41 |
|
---|
| 42 | //jQuery.post( url, [ data ], [ success(data, textStatus, XMLHttpRequest) ], [ dataType ] )
|
---|
| 43 |
|
---|
[23360] | 44 | // How do I find out my collection name?
|
---|
| 45 |
|
---|
[23489] | 46 | function getSubstring(str, first, last)
|
---|
| 47 | {
|
---|
| 48 | var first_index = str.indexOf(first)+first.length+1;
|
---|
| 49 | var last_index = str.indexOf(last, first_index);
|
---|
| 50 |
|
---|
| 51 | var substring = str.substring(first_index, last_index);
|
---|
| 52 |
|
---|
| 53 | console.log(substring);
|
---|
| 54 |
|
---|
| 55 | return substring;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | function getFormatStatement()
|
---|
| 59 | {
|
---|
| 60 | var formatDiv = document.getElementById('formatStatement');
|
---|
| 61 | var formatStatement = innerXHTML(formatDiv);
|
---|
| 62 | return formatStatement;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | function updateFormatStatement()
|
---|
| 66 | {
|
---|
| 67 | var formatStatement = getFormatStatement();
|
---|
| 68 |
|
---|
| 69 | var myurl = document.URL;
|
---|
| 70 |
|
---|
| 71 | var collection_name = getSubstring(myurl, "&c", "&");
|
---|
| 72 | var service_name = getSubstring(myurl, "&s", "&");
|
---|
| 73 | var classifier_name = null;
|
---|
| 74 |
|
---|
| 75 | if(service_name == "ClassifierBrowse")
|
---|
| 76 | classifier_name = getSubstring(myurl, "&cl", "&");
|
---|
| 77 |
|
---|
| 78 | var post_url = "http://localhost:8080/greenstone3/format?a=f&sa=update&c=" + collection_name +"&s=" + service_name;
|
---|
| 79 |
|
---|
[23405] | 80 | if(classifier_name != null)
|
---|
| 81 | post_url = post_url + "&cl=" + classifier_name;
|
---|
| 82 |
|
---|
| 83 | $.post(post_url, {data: formatStatement}, function(data) {
|
---|
[23336] | 84 | //$('.result').innerHTML = data; //html(data);
|
---|
[23333] | 85 | console.log("Success, we have received data");
|
---|
| 86 | console.log(data);
|
---|
| 87 | }, 'html');
|
---|
[23489] | 88 | }
|
---|
[23333] | 89 |
|
---|
[23489] | 90 | function saveFormatStatement()
|
---|
| 91 | {
|
---|
| 92 | var formatStatement = getFormatStatement();
|
---|
| 93 |
|
---|
| 94 | var myurl = document.URL;
|
---|
| 95 |
|
---|
| 96 | var collection_name = getSubstring(myurl, "&c", "&");
|
---|
| 97 | var service_name = getSubstring(myurl, "&s", "&");
|
---|
| 98 | var classifier_name = null;
|
---|
| 99 |
|
---|
| 100 | if(service_name == "ClassifierBrowse")
|
---|
| 101 | classifier_name = getSubstring(myurl, "&cl", "&");
|
---|
| 102 |
|
---|
| 103 | var post_url = "http://localhost:8080/greenstone3/format?a=f&sa=save&c=" + collection_name +"&s=" + service_name;
|
---|
| 104 |
|
---|
| 105 | if(classifier_name != null)
|
---|
| 106 | post_url = post_url + "&cl=" + classifier_name;
|
---|
| 107 |
|
---|
| 108 | $.post(post_url, {data: formatStatement}, function(data) {
|
---|
| 109 | //$('.result').innerHTML = data; //html(data);
|
---|
| 110 | console.log("Success, we have received data");
|
---|
| 111 | console.log(data);
|
---|
| 112 | }, 'html');
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[23333] | 115 | /*
|
---|
| 116 | $.ajax({
|
---|
| 117 | type: "POST",
|
---|
| 118 | url: "http://localhost:8080/greenstone3/format?a=s&sa=s",
|
---|
| 119 | data: formatStatement,
|
---|
| 120 | processData: false,
|
---|
| 121 | success: function(data) {
|
---|
| 122 | //$('.result').html(data);
|
---|
| 123 | console.log("Success, we have received data");
|
---|
| 124 | //console.log(data);
|
---|
| 125 | }
|
---|
| 126 | });
|
---|
| 127 | */
|
---|
| 128 | /*
|
---|
| 129 | $.ajax({
|
---|
| 130 | url: myurl,
|
---|
| 131 | success: function(data) {
|
---|
| 132 | //$('.result').html(data);
|
---|
| 133 | console.log("Success, we have received data");
|
---|
| 134 | console.log(data);
|
---|
| 135 | }
|
---|
| 136 | });
|
---|
| 137 | */
|
---|
| 138 | //if(formatStatement.hasChildNodes())
|
---|
| 139 | //{
|
---|
| 140 | //var formatstring = traverse(formatStatement, "");
|
---|
| 141 | //console.log(formatstring);
|
---|
| 142 |
|
---|
[23312] | 143 | // var children = $(formatStatement).children('div');
|
---|
| 144 | // for(var i=0; i < children.length; i++)
|
---|
| 145 | // traverse(children[i], formatstring)
|
---|
| 146 |
|
---|
| 147 | /*
|
---|
| 148 | var children = formatStatement.childNodes; //[]getChildNodes();
|
---|
| 149 | var current;
|
---|
| 150 | for(var i = 0; i < formatStatement.childNodes.length; i++)
|
---|
| 151 | {
|
---|
| 152 | current = formatStatement.childNodes[i];
|
---|
| 153 | //console.log(current.nodeName);
|
---|
| 154 | //console.log(current.nodeType);
|
---|
| 155 | if(current.nodeName=='DIV')
|
---|
| 156 | {
|
---|
| 157 | //console.log(current);
|
---|
| 158 | //console.log(current.className);
|
---|
| 159 | var gsf = find_class(current);
|
---|
| 160 | console.log(gsf);
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
| 163 | */
|
---|
[23333] | 164 | //}
|
---|
[23489] | 165 | //}
|
---|
[23312] | 166 |
|
---|
| 167 | function traverse(node, formatstring)
|
---|
| 168 | {
|
---|
| 169 | //console.log("node=("+node.nodeName+","+node.nodeType+")");
|
---|
| 170 |
|
---|
| 171 | if(node.nodeName=='DIV')
|
---|
| 172 | {
|
---|
| 173 | console.log("Found a div" +node.nodeName+","+node.nodeType);
|
---|
| 174 | formatstring = formatstring + find_class(node);
|
---|
| 175 | console.log(formatstring);
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | var children = $(node).children();
|
---|
| 179 | for(var i=0; i < children.length; i++)
|
---|
| 180 | formatstring = formatstring + traverse(children[i], formatstring);
|
---|
| 181 |
|
---|
| 182 | return formatstring;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 |
|
---|
[23276] | 186 | /*
|
---|
[23312] | 187 | console.log("node=("+node.nodeName+","+node.nodeType+")");
|
---|
| 188 |
|
---|
| 189 | if(node.children.length == 0) //hasChildNodes())
|
---|
| 190 | {
|
---|
| 191 | console.log("No children so return");
|
---|
| 192 | return "";
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 | if(node.nodeName=='DIV')
|
---|
| 196 | {
|
---|
| 197 | console.log("Found a div");
|
---|
| 198 | formatstring = formatstring + find_class(node);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | for(var i = 0; i < node.children.length; i++)
|
---|
| 202 | return recursiveTraverse(node.children[i], formatstring);
|
---|
| 203 |
|
---|
| 204 |
|
---|
| 205 | return formatstring;
|
---|
| 206 | }
|
---|
| 207 | */
|
---|
| 208 |
|
---|
| 209 | function find_class(current)
|
---|
| 210 | {
|
---|
| 211 | var classes = current.className.split(' ');
|
---|
| 212 | var none = "";
|
---|
| 213 | for(var i = 0; i < classes.length; i++)
|
---|
| 214 | {
|
---|
| 215 | switch(classes[i])
|
---|
| 216 | {
|
---|
| 217 | case 'gsf_template':
|
---|
| 218 | return create_gsf_template(current);
|
---|
| 219 | default:
|
---|
| 220 | {
|
---|
| 221 | console.log("Class not found");
|
---|
| 222 | return none;
|
---|
| 223 | }
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | function create_gsf_template(current)
|
---|
| 229 | {
|
---|
| 230 | // find match text which is an input with class match
|
---|
| 231 | var match = $(current).find('.match')[0].value;
|
---|
| 232 | console.log(match);
|
---|
| 233 |
|
---|
| 234 | // find mode text which is an input with class mode
|
---|
| 235 | var mode = $(current).find('.mode')[0].value;
|
---|
| 236 | console.log(mode);
|
---|
| 237 |
|
---|
| 238 | // "<gsf:template match=\"classifierNode\" mode=\"horizontal\">"
|
---|
| 239 | var gsf = "<gsf:template match=\"" + match + "\"";
|
---|
| 240 | if(mode != "vertical")
|
---|
| 241 | gsf = gsf + " mode=\"" + mode + "\"";
|
---|
| 242 | gsf = gsf + ">";
|
---|
| 243 |
|
---|
| 244 | return gsf;
|
---|
| 245 |
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | /*
|
---|
[23276] | 249 | $("#iframe").ready(function(){
|
---|
| 250 | console.log("iframe is ready ...");
|
---|
| 251 | var iframe = document.getElementById('iframe');
|
---|
| 252 | var iframe_document = iframe.document;
|
---|
| 253 |
|
---|
| 254 | if(iframe.contentDocument)
|
---|
| 255 | {
|
---|
| 256 | iframe_document = iframe.contentDocument; // For NS6
|
---|
| 257 | console.log("Chose content document");
|
---|
| 258 | }
|
---|
| 259 | else if(iframe.contentWindow)
|
---|
| 260 | {
|
---|
| 261 | iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
|
---|
| 262 | console.log("Chose content window");
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | console.log(iframe_document.documentElement.innerHTML); //document.documentElement.outerHTML
|
---|
| 266 |
|
---|
| 267 | $(iframe_document.documentElement.innerHTML).find('a').each(function() {
|
---|
| 268 | console.log("data "+$(this).data('href'));
|
---|
| 269 | console.log("getAttribute "+$(this).getAttribute('href'));
|
---|
| 270 | console.log("attr "+$(this).attr('href'));
|
---|
| 271 | console.log("this.href "+this.href);
|
---|
| 272 | var original = this.href; //$(this).attr('href');
|
---|
| 273 | // check if greenstone link ie. starts with format
|
---|
| 274 | //var original = $(this).data('href');
|
---|
| 275 | var modified = original.toString().concat("&excerptid=gs_content");
|
---|
| 276 | console.log(modified);
|
---|
| 277 | this.href = modified;
|
---|
| 278 | //$(this).attr('href',modified);
|
---|
| 279 | //$(this).data('href', modified);
|
---|
| 280 | //console.log($(this).attr('href'));
|
---|
| 281 | console.log("data "+$(this).data('href'));
|
---|
| 282 | console.log("getAttribute "+$(this).getAttribute('href'));
|
---|
| 283 | console.log("attr "+$(this).attr('href'));
|
---|
| 284 | console.log("this.href "+this.href);
|
---|
| 285 | console.log("**********");
|
---|
| 286 |
|
---|
| 287 | });
|
---|
| 288 | }); */
|
---|
[23298] | 289 | /*
|
---|
| 290 | function loadXMLDoc()
|
---|
| 291 | {
|
---|
| 292 | if (window.XMLHttpRequest)
|
---|
| 293 | {// code for IE7+, Firefox, Chrome, Opera, Safari
|
---|
| 294 | xmlhttp=new XMLHttpRequest();
|
---|
| 295 | }
|
---|
| 296 | else
|
---|
| 297 | {// code for IE6, IE5
|
---|
| 298 | xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | xmlhttp.onreadystatechange=function()
|
---|
| 302 | {
|
---|
| 303 | console.log("state changed to " + xmlhttp.readyState);
|
---|
| 304 | console.log("status is " + xmlhttp.status);
|
---|
| 305 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
| 306 | {
|
---|
| 307 | console.log("get code");
|
---|
| 308 | console.log(xmlhttp.responseText);
|
---|
| 309 | document.getElementById("gs_content").innerHTML=xmlhttp.responseText;
|
---|
| 310 | }
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | xmlhttp.open("GET","http://localhost:8080/greenstone3/format?a=b&rt=s&s=ClassifierBrowse&c=simpleht&cl=CL1&excerptid=gs_content",true);
|
---|
| 314 | //xmlhttp.open("GET","http://www.cs.waikato.ac.nz",true);
|
---|
| 315 | //xmlhttp.open("GET","http://wand.net.nz/~sjb48/index.html",true);
|
---|
| 316 | xmlhttp.send();
|
---|
| 317 | }
|
---|
| 318 | */
|
---|
[22474] | 319 | $(document).ready(function(){
|
---|
| 320 |
|
---|
[22516] | 321 | console.log("Document ready function\n");
|
---|
| 322 |
|
---|
[23135] | 323 | var CURRENT_SELECT_VALUE = "";
|
---|
| 324 |
|
---|
[23276] | 325 | var iframe = document.getElementById('iframe');
|
---|
| 326 | var iframe_document = iframe.document;
|
---|
| 327 |
|
---|
| 328 | if(iframe.contentDocument)
|
---|
| 329 | {
|
---|
| 330 | iframe_document = iframe.contentDocument; // For NS6
|
---|
| 331 | console.log("Chose content document");
|
---|
| 332 | }
|
---|
| 333 | else if(iframe.contentWindow)
|
---|
| 334 | {
|
---|
| 335 | iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
|
---|
| 336 | console.log("Chose content window");
|
---|
| 337 | }
|
---|
[23298] | 338 |
|
---|
| 339 | // Edit the hrefs in preview_html - search for <a href="format?a=b&rt=r&s=ClassifierBrowse&c=simpleht&cl=CL1.2">
|
---|
| 340 | var start_index = 0;
|
---|
| 341 | var end_index = 0;
|
---|
| 342 | while(start_index != -1)
|
---|
| 343 | {
|
---|
| 344 | start_index = preview_html.indexOf("href=\"format", start_index);
|
---|
| 345 | console.log("start index = " + start_index);
|
---|
| 346 | if(start_index != -1)
|
---|
| 347 | {
|
---|
| 348 | end_index = preview_html.indexOf("\">", start_index);
|
---|
| 349 | console.log("end_index = " + end_index);
|
---|
| 350 | a = preview_html.substring(0,end_index);
|
---|
| 351 | b = preview_html.substring(end_index);
|
---|
[23312] | 352 | preview_html = a.concat("&excerptid=results", b);
|
---|
[23298] | 353 | console.log(preview_html);
|
---|
[23312] | 354 | start_index = end_index + "&excerptid=results\">".length;
|
---|
[23298] | 355 | }
|
---|
| 356 | }
|
---|
| 357 |
|
---|
[23312] | 358 | // Split the html code in to three parts
|
---|
| 359 | var first_index = preview_html.indexOf("<ul id=\"results\"");
|
---|
| 360 | console.log("First index is "+first_index);
|
---|
| 361 | var second_index = preview_html.indexOf("</ul>", first_index) + "</ul>".length;
|
---|
| 362 | console.log("Second index is "+second_index);
|
---|
| 363 |
|
---|
| 364 | var first_half = preview_html.substring(0, first_index);
|
---|
| 365 | var iframe_code = preview_html.substring(first_index, second_index);
|
---|
| 366 | var second_half = preview_html.substring(second_index);
|
---|
| 367 |
|
---|
| 368 | //$('#my_categories').innerHTML = first_half.concat(second_half);
|
---|
| 369 | document.getElementById("my_categories").innerHTML = first_half.concat(second_half);
|
---|
| 370 |
|
---|
[23276] | 371 | // Put the content in the iframe
|
---|
| 372 | if(initialised_iframe == "false")
|
---|
| 373 | {
|
---|
| 374 | console.log("Initialised iframe with preview html");
|
---|
[23298] | 375 | console.log(preview_html);
|
---|
[23276] | 376 | iframe_document.open();
|
---|
[23312] | 377 | iframe_document.writeln(iframe_code); //.concat("&excerptid=gs_content"));
|
---|
[23276] | 378 | iframe_document.close();
|
---|
| 379 | initialised_iframe = "true";
|
---|
| 380 | }
|
---|
[23298] | 381 |
|
---|
| 382 | /*
|
---|
[23276] | 383 | $(iframe_document.documentElement.innerHTML).find('a').each(function() {
|
---|
| 384 | console.log("data "+$(this).data('href'));
|
---|
| 385 | console.log("getAttribute "+this.getAttribute('href'));
|
---|
| 386 | console.log("attr "+$(this).attr('href'));
|
---|
| 387 | console.log("this.href "+this.href);
|
---|
| 388 | var original = this.href; //$(this).attr('href');
|
---|
| 389 | // check if greenstone link ie. starts with format
|
---|
| 390 | //var original = $(this).data('href');
|
---|
| 391 | var modified = original.toString().concat("&excerptid=gs_content");
|
---|
| 392 | console.log("* *");
|
---|
| 393 | console.log(modified);
|
---|
| 394 | console.log("* *");
|
---|
| 395 | //this.href = modified;
|
---|
| 396 | //$(this).attr('href',modified);
|
---|
| 397 | //$(this).data('href', modified);
|
---|
| 398 | $(this).attr({ 'href': modified });
|
---|
| 399 | //console.log($(this).attr('href'));
|
---|
| 400 | console.log("data "+$(this).data('href'));
|
---|
| 401 | console.log("getAttribute "+this.getAttribute('href'));
|
---|
| 402 | console.log("attr "+$(this).attr('href'));
|
---|
| 403 | console.log("this.href "+this.href);
|
---|
| 404 | console.log("***********************");
|
---|
| 405 | });
|
---|
| 406 | */
|
---|
| 407 |
|
---|
[22598] | 408 | /******************************************/
|
---|
| 409 | /* DRAGGABLES */
|
---|
| 410 | /******************************************/
|
---|
[22516] | 411 |
|
---|
[23276] | 412 | $(".draggable_gsf_template").draggable({
|
---|
[23046] | 413 | cursor: 'crosshair',
|
---|
[22598] | 414 | connectToSortable: '#formatStatement',
|
---|
| 415 | helper: 'clone',
|
---|
| 416 | revert: 'invalid'
|
---|
| 417 | });
|
---|
| 418 |
|
---|
[23276] | 419 | $(".draggable_table").draggable({
|
---|
[23046] | 420 | cursor: 'crosshair',
|
---|
[22569] | 421 | connectToSortable: '.gsf_template',
|
---|
| 422 | helper: 'clone',
|
---|
[22598] | 423 | revert: 'invalid'
|
---|
| 424 | });
|
---|
[22516] | 425 |
|
---|
[23276] | 426 | $(".draggable_tr").draggable({
|
---|
[23046] | 427 | cursor: 'crosshair',
|
---|
[22598] | 428 | connectToSortable: '.gsf_table',
|
---|
| 429 | helper: 'clone',
|
---|
| 430 | revert: 'invalid'
|
---|
| 431 | })
|
---|
[22569] | 432 |
|
---|
[23276] | 433 | $(".draggable_td").draggable({
|
---|
[23046] | 434 | cursor: 'crosshair',
|
---|
[22676] | 435 | //connectToSortable: '.td',
|
---|
[22598] | 436 | helper: 'clone',
|
---|
| 437 | revert: 'invalid'
|
---|
| 438 | })
|
---|
| 439 |
|
---|
[23298] | 440 | $(".draggable_gsf_text").draggable({
|
---|
[23046] | 441 | cursor: 'crosshair',
|
---|
[23298] | 442 | connectToSortable: '.td-div, .gsf_when, .gsf_otherwise, .gsf_link, .gsf_choose_metadata, .gsf_default',
|
---|
[22598] | 443 | helper: 'clone',
|
---|
| 444 | revert: 'invalid'
|
---|
[22569] | 445 | });
|
---|
| 446 |
|
---|
[23255] | 447 | $(".draggable_gsf_choose_metadata").draggable({
|
---|
[23046] | 448 | cursor: 'crosshair',
|
---|
[23276] | 449 | connectToSortable: '.td-div, .gsf_link, .gsf_when, .gsf_otherwise',
|
---|
[22598] | 450 | helper: 'clone',
|
---|
| 451 | revert: 'invalid'
|
---|
| 452 | });
|
---|
| 453 |
|
---|
[23046] | 454 | //$(".element_type_gsf_metadata").draggable({
|
---|
[23135] | 455 | $(".draggable_gsf_metadata").draggable({
|
---|
[23046] | 456 | cursor: 'crosshair',
|
---|
[23276] | 457 | connectToSortable: '.gsf_choose_metadata, .gsf_when, .gsf_otherwise, .gsf_link, .td-div',
|
---|
[22598] | 458 | helper: 'clone',
|
---|
| 459 | revert: 'invalid'
|
---|
| 460 | });
|
---|
| 461 |
|
---|
[23135] | 462 | $(".draggable_gsf_link").draggable({
|
---|
[23046] | 463 | cursor: 'crosshair',
|
---|
[23276] | 464 | connectToSortable: '.td-div, .gsf_when, .gsf_otherwise, .gsf_link',
|
---|
[22598] | 465 | helper: 'clone',
|
---|
| 466 | revert: 'invalid'
|
---|
| 467 | });
|
---|
| 468 |
|
---|
| 469 | // switch, when, otherwise, icon
|
---|
[23255] | 470 | $(".draggable_gsf_switch").draggable({
|
---|
[23046] | 471 | cursor: 'crosshair',
|
---|
[23276] | 472 | connectToSortable: '.td-div, .gsf_link',
|
---|
[22598] | 473 | helper: 'clone',
|
---|
| 474 | revert: 'invalid'
|
---|
| 475 | });
|
---|
| 476 |
|
---|
[23255] | 477 | $(".draggable_gsf_when").draggable({
|
---|
[23046] | 478 | cursor: 'crosshair',
|
---|
[22598] | 479 | connectToSortable: '.gsf_switch',
|
---|
| 480 | helper: 'clone',
|
---|
| 481 | revert: 'invalid'
|
---|
| 482 | });
|
---|
| 483 |
|
---|
[23255] | 484 | $(".draggable_gsf_otherwise").draggable({
|
---|
[23046] | 485 | cursor: 'crosshair',
|
---|
[22598] | 486 | connectToSortable: '.gsf_switch',
|
---|
| 487 | helper: 'clone',
|
---|
| 488 | revert: 'invalid'
|
---|
| 489 | });
|
---|
| 490 |
|
---|
[23255] | 491 | $(".draggable_gsf_icon").draggable({
|
---|
[23046] | 492 | cursor: 'crosshair',
|
---|
[23298] | 493 | connectToSortable: '.td-div, .gsf_link, .gsf_choose, .gsf_when, .gsf_otherwise',
|
---|
[22598] | 494 | helper: 'clone',
|
---|
| 495 | revert: 'invalid'
|
---|
| 496 | });
|
---|
| 497 |
|
---|
[22516] | 498 |
|
---|
[22598] | 499 | /******************************************/
|
---|
| 500 | /* SORTABLES */
|
---|
| 501 | /******************************************/
|
---|
| 502 |
|
---|
[22933] | 503 | bind_td_sortable();
|
---|
[22598] | 504 | bind_all_sortables();
|
---|
| 505 |
|
---|
[22516] | 506 | $('#formatStatement').sortable({
|
---|
[22569] | 507 | cursor: 'pointer',
|
---|
| 508 | tolerance: 'pointer',
|
---|
| 509 | items: '.gsf_template',
|
---|
[22598] | 510 | placeholder:'placeholder',
|
---|
[22516] | 511 | //'nested':'div'
|
---|
[22598] | 512 | stop: function(event, ui) {
|
---|
| 513 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('css_gsf_template')) { replace_with(ui.item,gsf_template_element); }
|
---|
| 514 | }
|
---|
[22516] | 515 | });
|
---|
[22676] | 516 |
|
---|
| 517 | $('div.gsf_template').children(".block,.table").slideUp(300);
|
---|
[22598] | 518 | });
|
---|
| 519 |
|
---|
| 520 | /*******************************************************************************/
|
---|
| 521 |
|
---|
| 522 | function bind_all_sortables()
|
---|
| 523 | {
|
---|
[22768] | 524 | console.log('function bind_all_sortables()');
|
---|
[22598] | 525 | bind_template_sortable();
|
---|
[22676] | 526 | //bind_table_sortable();
|
---|
| 527 | //bind_tr_sortable();
|
---|
| 528 | //bind_td_sortable();
|
---|
[22598] | 529 | bind_choose_metadata_sortable();
|
---|
| 530 | bind_link_sortable();
|
---|
| 531 | bind_switch_sortable();
|
---|
| 532 | bind_when_sortable();
|
---|
| 533 | bind_otherwise_sortable();
|
---|
| 534 |
|
---|
[22676] | 535 | bind_tables();
|
---|
| 536 |
|
---|
[22598] | 537 | bind_block_mouseover();
|
---|
| 538 | bind_minmax_remove();
|
---|
| 539 | }
|
---|
| 540 |
|
---|
[22676] | 541 | function bind_tables()
|
---|
| 542 | {
|
---|
[22768] | 543 | console.log('function bind_tables()');
|
---|
| 544 | //$('.tr').resize_tables($(this)); //equalHeights();
|
---|
[22676] | 545 |
|
---|
[22768] | 546 |
|
---|
| 547 | $('td').click(function () {
|
---|
[22829] | 548 | console.log('td click *');
|
---|
[22768] | 549 | return false;
|
---|
| 550 | });
|
---|
| 551 |
|
---|
[22829] | 552 | $(".td-div").resizable({
|
---|
[22676] | 553 | alsoResize: 'parent',
|
---|
| 554 | //containment: 'parent',
|
---|
| 555 | handles: 'w,e',
|
---|
| 556 | stop: function(event, ui) {
|
---|
[22768] | 557 | console.log('Resize table on stop');
|
---|
| 558 | resize_tables($(this));
|
---|
| 559 | //$(this).parent().parent().equalHeights();
|
---|
[22676] | 560 | }, });
|
---|
| 561 |
|
---|
[23046] | 562 | //$(".droppable").sortable({
|
---|
| 563 | // 'cursor':'pointer',
|
---|
| 564 | // 'tolerance': 'pointer',
|
---|
| 565 | // 'items':'.column, .td-div',
|
---|
| 566 | // 'placeholder':'placeholder'
|
---|
| 567 | //});
|
---|
| 568 |
|
---|
[22676] | 569 | $(".droppable").droppable({
|
---|
| 570 | accept: '.element_type_td',
|
---|
| 571 | tolerance: 'pointer',
|
---|
[22768] | 572 | activate: function(event, ui) { $(this).addClass("droppable_hl");}, // console.log("droppable activated")},
|
---|
| 573 | deactivate: function(event, ui) { $(this).removeClass("droppable_hl"); }, // console.log("droppable deactivated")},
|
---|
[22676] | 574 | drop: function(event, ui) {
|
---|
[23046] | 575 | //if ($(this).hasClass("ui-draggable"))
|
---|
| 576 | //if (ui.helper.hasClass("ui-draggable"))
|
---|
| 577 | //{
|
---|
[22829] | 578 | var neverempty = document.createElement("div");
|
---|
| 579 | neverempty.setAttribute("class","neverempty block");
|
---|
| 580 | neverempty.setAttribute("style","height:50px");
|
---|
| 581 | neverempty.setAttribute("style","display:block");
|
---|
| 582 | var text = document.createTextNode('NEVER EMPTY');
|
---|
| 583 | neverempty.appendChild(text);
|
---|
[22676] | 584 | var td = document.createElement("td");
|
---|
| 585 | var div = document.createElement("div"); // class=\"td block\" title=\"td-div\"");
|
---|
| 586 | div.setAttribute("title","td-div");
|
---|
[22829] | 587 | div.setAttribute("class","td-div block");
|
---|
[22768] | 588 | div.setAttribute("style","margin-left:0px");
|
---|
[22676] | 589 | div.setAttribute("width","25px");
|
---|
| 590 | td.appendChild(div);
|
---|
[22829] | 591 | div.appendChild(neverempty);
|
---|
[22676] | 592 | var sep = document.createElement("td");
|
---|
| 593 | sep.setAttribute("class","droppable");
|
---|
| 594 | sep.setAttribute("width","10px");
|
---|
| 595 | $(this).after(sep);
|
---|
| 596 | $(this).after(td);
|
---|
| 597 | bind_tables();
|
---|
[22768] | 598 | resize_tables($(this));
|
---|
| 599 | bind_td_sortable();
|
---|
[22829] | 600 | bind_block_mouseover();
|
---|
[22676] | 601 | //bind_all_sortables();
|
---|
[23046] | 602 | //}
|
---|
| 603 | //else
|
---|
| 604 | //{
|
---|
| 605 | // console.log("Attempting to add");
|
---|
| 606 | //$(this).appendTo(ui.draggable[0]);
|
---|
| 607 | // $(this).prepend(ui.draggable[0]);
|
---|
| 608 | //$(ui.draggable[0]).appendTo($(this));
|
---|
| 609 | //}
|
---|
[22676] | 610 | }
|
---|
| 611 | });
|
---|
| 612 |
|
---|
| 613 | }
|
---|
| 614 |
|
---|
[22598] | 615 | function replace_with(item, me)
|
---|
| 616 | {
|
---|
[23135] | 617 | // Search me for select
|
---|
| 618 | if(me.search("select") != -1)
|
---|
| 619 | {
|
---|
| 620 | // If select exists, then find CURRENT_SELECT_VALUE
|
---|
| 621 | var index = me.search(CURRENT_SELECT_VALUE);
|
---|
| 622 | if(index == -1)
|
---|
| 623 | console.log("Did not find " + CURRENT_SELECT_VALUE);
|
---|
| 624 | else
|
---|
| 625 | console.log("Found " + CURRENT_SELECT_VALUE + " at index " + index);
|
---|
| 626 | index = index + CURRENT_SELECT_VALUE.length + 1;
|
---|
| 627 | console.log("Attempt inserting select at new index "+index);
|
---|
| 628 | a = me.substring(0,index);
|
---|
| 629 | b = me.substring(index);
|
---|
| 630 | me = a.concat("selected",b);
|
---|
| 631 | }
|
---|
| 632 |
|
---|
[22933] | 633 | //console.log('function replace_with(item, me)');
|
---|
[22598] | 634 | item.replaceWith(me); //'<div class="element element-txt">This text box has been added!</div>');
|
---|
[23135] | 635 | //item.find('select').attr("value", CURRENT_SELECT_VALUE);
|
---|
[22676] | 636 |
|
---|
[23135] | 637 |
|
---|
| 638 | //if(select != null){
|
---|
| 639 | // console.log("Attempting to select " + CURRENT_SELECT_VALUE);
|
---|
| 640 | // console.log("length = "+select.length);
|
---|
| 641 | // for(index = 0; index < select.length; index++) {
|
---|
| 642 | // console.log(select[index].value);
|
---|
| 643 | // if(select[index].value == CURRENT_SELECT_VALUE)
|
---|
| 644 | // console.log("Found "+CURRENT_SELECT_VALUE+" at index " + index);
|
---|
| 645 | // select.selectedIndex = index;
|
---|
| 646 | // }
|
---|
| 647 | // }
|
---|
| 648 |
|
---|
[22768] | 649 | resize_tables(item);
|
---|
| 650 |
|
---|
| 651 | bind_all_sortables();
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | function resize_tables(item)
|
---|
| 655 | {
|
---|
[22933] | 656 | //console.log('function resize_tables(item)');
|
---|
[22768] | 657 | var max_height = 0;
|
---|
[22676] | 658 | (item.parents('.table')).each(function(index) {
|
---|
| 659 | $(this).children().children().children().each(function() {
|
---|
[22768] | 660 | var sum_one = 0;
|
---|
| 661 | var sum_two = 0;
|
---|
| 662 | $(this).children('.block').each(function() { sum_one = sum_one + $(this).height();
|
---|
| 663 | $(this).children('.block').each(function() { sum_two = sum_two + $(this).height(); } );
|
---|
| 664 | console.log("My height is " + $(this).height() + ", sum height 2 is " + sum_two);
|
---|
| 665 | });
|
---|
| 666 | console.log("My height is " + $(this).height() + ", sum height 1 is " + sum_one);
|
---|
| 667 | if (sum_two > max_height)
|
---|
| 668 | max_height = sum_two;
|
---|
[22676] | 669 | });
|
---|
| 670 | });
|
---|
[22768] | 671 | equalHeights(item,max_height);
|
---|
[22598] | 672 | }
|
---|
| 673 |
|
---|
| 674 | function bind_template_sortable()
|
---|
| 675 | {
|
---|
[22933] | 676 | //console.log('function bind_template_sortable()');
|
---|
[22569] | 677 | $('.gsf_template').sortable({
|
---|
[22516] | 678 | 'cursor':'pointer',
|
---|
[22987] | 679 | 'tolerance': 'pointer',
|
---|
[22933] | 680 | 'items':'.table', //.gsf_choose_metadata, .gsf_metadata',
|
---|
[22598] | 681 | 'placeholder':'placeholder',
|
---|
| 682 | //'nested':'.gsf:metadata'
|
---|
| 683 | stop: function(event, ui) {
|
---|
| 684 | //if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('css_table')) { replace_with(ui.item, "<table border=\"1\" width=\"100%\" height=\"50px\"><tr><td><div class=\"td block\" title=\"td-div\">XXXXXXXXXXXXXXXXXXXXXXXX</div></td></tr></table>"); }
|
---|
[23276] | 685 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_table')) { replace_with(ui.item, "<table class=\"table\" border=\"2\"></table>"); }
|
---|
| 686 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
| 687 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 688 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 689 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
[22598] | 690 | }
|
---|
| 691 | });
|
---|
| 692 |
|
---|
[22768] | 693 | $('.gsf_template').click(function () {
|
---|
| 694 | console.log('gsf_template class click');
|
---|
| 695 | return false;
|
---|
[22598] | 696 | });
|
---|
[22569] | 697 |
|
---|
[22598] | 698 | }
|
---|
[22474] | 699 |
|
---|
[22598] | 700 | function bind_td_sortable()
|
---|
| 701 | {
|
---|
[23046] | 702 |
|
---|
| 703 | $('tr').sortable({
|
---|
| 704 | 'cursor':'pointer',
|
---|
| 705 | 'tolerance': 'intersect',
|
---|
| 706 | 'items':'.column',
|
---|
| 707 | 'placeholder':'placeholder_td',
|
---|
| 708 | 'connectWith':'column'});
|
---|
| 709 |
|
---|
| 710 | //$('.column').sortable({
|
---|
| 711 | // connectWith:['.column'],
|
---|
| 712 | // placeholder: 'placeholder',
|
---|
| 713 | // items:'td-div'
|
---|
| 714 | //});
|
---|
| 715 |
|
---|
| 716 |
|
---|
| 717 | //$('.column').sortable({
|
---|
| 718 | // 'cursor':'pointer',
|
---|
| 719 | // 'tolerance': 'pointer',
|
---|
| 720 | // 'items':'.td-div',
|
---|
| 721 | // 'placeholder':'placeholder',
|
---|
| 722 | // 'connectWith':'.column'
|
---|
| 723 | //'nested':'.gsf:metadata'
|
---|
| 724 | //receive: function(event, ui) { alert("Attempted to receive"); },
|
---|
| 725 | //stop: function(event, ui) {
|
---|
| 726 | // if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 727 |
|
---|
| 728 | //});
|
---|
| 729 |
|
---|
[22933] | 730 | //console.log('function bind_td_sortable()');
|
---|
[22829] | 731 | $('.td-div').sortable({
|
---|
[22516] | 732 | 'cursor':'pointer',
|
---|
[22987] | 733 | 'tolerance': 'pointer',
|
---|
[22768] | 734 | 'items':'.gsf_metadata, .gsf_choose_metadata, .gsf_link, .gsf_switch',
|
---|
[22598] | 735 | 'placeholder':'placeholder',
|
---|
[23046] | 736 | //'connectWith':'.td-div',
|
---|
[22516] | 737 | //'nested':'.gsf:metadata'
|
---|
[22676] | 738 | receive: function(event, ui) { alert("Attempted to receive"); },
|
---|
[22598] | 739 | stop: function(event, ui) {
|
---|
[23276] | 740 | // gsf metadata
|
---|
| 741 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 742 | // gsf choose metadata
|
---|
| 743 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
| 744 | // gsf link
|
---|
| 745 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 746 | // gsf switch
|
---|
| 747 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
[22676] | 748 |
|
---|
[22598] | 749 | }
|
---|
| 750 |
|
---|
[22516] | 751 | });
|
---|
[22768] | 752 |
|
---|
[22829] | 753 | $('.td-div').click(function () {
|
---|
[22933] | 754 | //console.log('td class click');
|
---|
[22829] | 755 | return true;
|
---|
[22768] | 756 | });
|
---|
| 757 |
|
---|
| 758 |
|
---|
| 759 |
|
---|
[22598] | 760 | }
|
---|
| 761 |
|
---|
[22829] | 762 |
|
---|
[22598] | 763 | function bind_choose_metadata_sortable()
|
---|
| 764 | {
|
---|
[22933] | 765 | //console.log('function bind_choose_metadata_sortable()');
|
---|
[22598] | 766 | $('.gsf_choose_metadata').sortable({
|
---|
[22516] | 767 | 'cursor':'pointer',
|
---|
[22987] | 768 | 'tolerance': 'pointer',
|
---|
[23276] | 769 | 'items':'.gsf_metadata, .gsf_text, .gsf_default',
|
---|
[22516] | 770 | 'placeholder':'placeholder',
|
---|
[22598] | 771 | 'connectWith':'.gsf_choose_metadata',
|
---|
[22516] | 772 | //'nested':'.gsf:metadata'
|
---|
[22598] | 773 | stop: function(event, ui) {
|
---|
[23276] | 774 | // gsf metadata
|
---|
| 775 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 776 | // gsf text
|
---|
| 777 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
| 778 | // gsf default
|
---|
| 779 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_default')) { replace_with(ui.item, gsf_default_element); }
|
---|
[23135] | 780 |
|
---|
[23046] | 781 | bind_all_sortables();
|
---|
[22598] | 782 | }
|
---|
[22516] | 783 | });
|
---|
[22598] | 784 | }
|
---|
| 785 |
|
---|
| 786 | function bind_link_sortable()
|
---|
| 787 | {
|
---|
[22933] | 788 | //console.log('function bind_link_sortable()');
|
---|
[22569] | 789 | $('.gsf_link').sortable({
|
---|
[22516] | 790 | 'cursor':'pointer',
|
---|
[22987] | 791 | 'tolerance': 'pointer',
|
---|
[23276] | 792 | 'items':'.leaf, .gsf_link, .gsf_switch, .gsf_choose',
|
---|
[22676] | 793 | 'placeholder':'placeholder',
|
---|
[22829] | 794 | 'connectWith':'.gsf_link',
|
---|
[22516] | 795 | //'nested':'.gsf:metadata'
|
---|
[22676] | 796 | stop: function(event, ui) {
|
---|
[23276] | 797 | // gsf icon
|
---|
| 798 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 799 | // gsf text
|
---|
| 800 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
|
---|
| 801 | // gsf metadata
|
---|
| 802 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 803 | // gsf link
|
---|
| 804 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 805 | // gsf switch
|
---|
| 806 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
| 807 | // gsf choose
|
---|
| 808 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
[22676] | 809 | }
|
---|
[22516] | 810 | });
|
---|
[22598] | 811 | }
|
---|
[22516] | 812 |
|
---|
[22598] | 813 | function bind_switch_sortable()
|
---|
| 814 | {
|
---|
[22933] | 815 | //console.log('function bind_switch_sortable()');
|
---|
[22569] | 816 | $('.gsf_switch').sortable({
|
---|
[22516] | 817 | 'cursor':'pointer',
|
---|
[22987] | 818 | 'tolerance': 'pointer',
|
---|
[23276] | 819 | 'items':'.gsf_metadata, .gsf_when, .gsf_otherwise, .gsf_text',
|
---|
[22598] | 820 | 'placeholder':'placeholder',
|
---|
[22933] | 821 | 'connectWith':'.gsf_switch',
|
---|
[22516] | 822 | //'nested':'.gsf:metadata'
|
---|
[22598] | 823 | stop: function(event, ui) {
|
---|
[23276] | 824 | // gsf when
|
---|
| 825 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_when')) { replace_with(ui.item, gsf_when_element); }
|
---|
| 826 | // gsf otherwise
|
---|
| 827 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_otherwise')) { replace_with(ui.item, gsf_otherwise_element); }
|
---|
| 828 | // gsf metadata
|
---|
| 829 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 830 | // gsf text
|
---|
| 831 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
[22598] | 832 | }
|
---|
[22516] | 833 | });
|
---|
[22598] | 834 | }
|
---|
[22516] | 835 |
|
---|
[22598] | 836 | function bind_when_sortable()
|
---|
| 837 | {
|
---|
[22933] | 838 | //console.log('function bind_when_sortable()');
|
---|
[22569] | 839 | $('.gsf_when').sortable({
|
---|
[22516] | 840 | 'cursor':'pointer',
|
---|
[22987] | 841 | 'tolerance': 'pointer',
|
---|
[23276] | 842 | 'items':'.leaf, .gsf_link, .gsf_choose',
|
---|
[22598] | 843 | 'placeholder':'placeholder',
|
---|
[22516] | 844 | //'nested':'.gsf:metadata'
|
---|
[22598] | 845 | stop: function(event, ui) {
|
---|
[23276] | 846 | // gsf metadata
|
---|
| 847 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 848 | // gsf icon
|
---|
| 849 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 850 | // gsf text
|
---|
| 851 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
| 852 | // gsf link
|
---|
| 853 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 854 | // gsf choose
|
---|
| 855 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); }
|
---|
[22598] | 856 | }
|
---|
[22516] | 857 | });
|
---|
[22598] | 858 | }
|
---|
[22516] | 859 |
|
---|
[22598] | 860 | function bind_otherwise_sortable()
|
---|
| 861 | {
|
---|
[22933] | 862 | //console.log('function bind_otherwise_sortable()');
|
---|
[22569] | 863 | $('.gsf_otherwise').sortable({
|
---|
[22516] | 864 | 'cursor':'pointer',
|
---|
[22987] | 865 | 'tolerance': 'pointer',
|
---|
[23276] | 866 | 'items':'.leaf, .gsf_link, .gsf_choose',
|
---|
[22598] | 867 | 'placeholder':'placeholder',
|
---|
[22516] | 868 | //'nested':'.gsf:metadata'
|
---|
[22598] | 869 | stop: function(event, ui) {
|
---|
[23276] | 870 | // gsf metadata
|
---|
| 871 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 872 | // gsf text
|
---|
| 873 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
|
---|
| 874 | // gsf icon
|
---|
| 875 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 876 | // gsf link
|
---|
| 877 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 878 | // gsf choose
|
---|
| 879 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); }
|
---|
[22598] | 880 | }
|
---|
[22516] | 881 | });
|
---|
[22598] | 882 | }
|
---|
[22516] | 883 |
|
---|
[22598] | 884 | function bind_block_mouseover()
|
---|
| 885 | {
|
---|
[22933] | 886 | //console.log('function bind_block_mouseover()');
|
---|
[22598] | 887 | $(".block").mouseover(function()
|
---|
[22516] | 888 | {
|
---|
[22474] | 889 | $(this).parents().css("border", "");
|
---|
[23046] | 890 | $(this).css("border", "2px solid blue");
|
---|
[22516] | 891 | return false;
|
---|
[22474] | 892 | }).mouseout(function(){
|
---|
| 893 | $(this).css("border", "");
|
---|
[22516] | 894 | return false;
|
---|
[22474] | 895 | });
|
---|
[22598] | 896 | }
|
---|
[22474] | 897 |
|
---|
[22598] | 898 | function bind_minmax_remove()
|
---|
| 899 | {
|
---|
[22768] | 900 | console.log('function bind_minmax_remove()');
|
---|
[22598] | 901 | $('a.minmax').bind('click', toggleContent);
|
---|
| 902 | $('a.remove').bind('click', removeContent);
|
---|
| 903 | };
|
---|
[22474] | 904 |
|
---|
| 905 | var removeContent = (function () {
|
---|
[22933] | 906 | //console.log('var removeContent = (function ()');
|
---|
[22768] | 907 | // this -> a -> td -> tr -> tbody -> table -> div
|
---|
[23046] | 908 | //$(this).parent().parent().parent().parent().parent().remove();
|
---|
| 909 | $(this).closest(".block").remove();
|
---|
[22474] | 910 | });
|
---|
| 911 |
|
---|
| 912 |
|
---|
| 913 | var toggleContent = function(e)
|
---|
| 914 | {
|
---|
[22933] | 915 | //console.log('var toggleContent = function(e)');
|
---|
[22768] | 916 | console.log('parent: ' + $(this).html());
|
---|
[22676] | 917 | if ($(this).html() == '[+]'){ //targetContent.css('display') == 'none') {
|
---|
[23046] | 918 | //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideDown(300);
|
---|
| 919 | //$(this).parents().children(".block,.table").stopPropagation().slideDown(300);
|
---|
| 920 | //var x = $(this).parent().parent().parent().parent().parent();
|
---|
| 921 | //var y = $(this).parent().parent().parent().parent().parent().children(".block,.table");
|
---|
| 922 | //var z = $(this).closest(".block").children(".table, .block");
|
---|
| 923 | $(this).closest(".block").children(".table, .block").slideDown(300);
|
---|
[22474] | 924 | $(this).html('[-]');
|
---|
[22768] | 925 | $(this).removeClass("ui-icon-plusthick");
|
---|
| 926 | $(this).addClass("ui-icon-minusthick");
|
---|
[22474] | 927 | } else {
|
---|
[23046] | 928 | //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideUp(300);
|
---|
| 929 | //$(this).parents().children(".block,.table").slideUp(300);
|
---|
| 930 | $(this).closest(".block").children(".table, .block").slideUp(300);
|
---|
[22474] | 931 | $(this).html('[+]');
|
---|
[22768] | 932 | $(this).removeClass("ui-icon-minusthick");
|
---|
| 933 | $(this).addClass("ui-icon-plusthick");
|
---|
[22474] | 934 | }
|
---|
| 935 | return false;
|
---|
| 936 | };
|
---|
| 937 |
|
---|
| 938 | function serialize(s)
|
---|
| 939 | {
|
---|
| 940 | serial = $.SortSerialize(s);
|
---|
| 941 | alert(serial.hash);
|
---|
| 942 | };
|
---|
| 943 |
|
---|
[22768] | 944 | function equalHeights(item, height) {
|
---|
[22933] | 945 | //console.log('function equalHeights(item, height)');
|
---|
[22768] | 946 | (item.parents('.table')).each(function(index) {
|
---|
| 947 | $(this).children().children().children().each(function() {
|
---|
| 948 | $(this).height(height);
|
---|
| 949 | $(this).children().height(height);
|
---|
| 950 | });
|
---|
[22569] | 951 | });
|
---|
| 952 | };
|
---|
| 953 |
|
---|