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