[22516] | 1 |
|
---|
| 2 | console.log("Loading gui_div.js\n");
|
---|
| 3 |
|
---|
[23276] | 4 | var initialised_iframe = "false";
|
---|
| 5 | /*
|
---|
| 6 | $("#iframe").ready(function(){
|
---|
| 7 | console.log("iframe is ready ...");
|
---|
| 8 | var iframe = document.getElementById('iframe');
|
---|
| 9 | var iframe_document = iframe.document;
|
---|
| 10 |
|
---|
| 11 | if(iframe.contentDocument)
|
---|
| 12 | {
|
---|
| 13 | iframe_document = iframe.contentDocument; // For NS6
|
---|
| 14 | console.log("Chose content document");
|
---|
| 15 | }
|
---|
| 16 | else if(iframe.contentWindow)
|
---|
| 17 | {
|
---|
| 18 | iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
|
---|
| 19 | console.log("Chose content window");
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | console.log(iframe_document.documentElement.innerHTML); //document.documentElement.outerHTML
|
---|
| 23 |
|
---|
| 24 | $(iframe_document.documentElement.innerHTML).find('a').each(function() {
|
---|
| 25 | console.log("data "+$(this).data('href'));
|
---|
| 26 | console.log("getAttribute "+$(this).getAttribute('href'));
|
---|
| 27 | console.log("attr "+$(this).attr('href'));
|
---|
| 28 | console.log("this.href "+this.href);
|
---|
| 29 | var original = this.href; //$(this).attr('href');
|
---|
| 30 | // check if greenstone link ie. starts with format
|
---|
| 31 | //var original = $(this).data('href');
|
---|
| 32 | var modified = original.toString().concat("&excerptid=gs_content");
|
---|
| 33 | console.log(modified);
|
---|
| 34 | this.href = modified;
|
---|
| 35 | //$(this).attr('href',modified);
|
---|
| 36 | //$(this).data('href', modified);
|
---|
| 37 | //console.log($(this).attr('href'));
|
---|
| 38 | console.log("data "+$(this).data('href'));
|
---|
| 39 | console.log("getAttribute "+$(this).getAttribute('href'));
|
---|
| 40 | console.log("attr "+$(this).attr('href'));
|
---|
| 41 | console.log("this.href "+this.href);
|
---|
| 42 | console.log("**********");
|
---|
| 43 |
|
---|
| 44 | });
|
---|
| 45 | }); */
|
---|
[23298] | 46 | /*
|
---|
| 47 | function loadXMLDoc()
|
---|
| 48 | {
|
---|
| 49 | if (window.XMLHttpRequest)
|
---|
| 50 | {// code for IE7+, Firefox, Chrome, Opera, Safari
|
---|
| 51 | xmlhttp=new XMLHttpRequest();
|
---|
| 52 | }
|
---|
| 53 | else
|
---|
| 54 | {// code for IE6, IE5
|
---|
| 55 | xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | xmlhttp.onreadystatechange=function()
|
---|
| 59 | {
|
---|
| 60 | console.log("state changed to " + xmlhttp.readyState);
|
---|
| 61 | console.log("status is " + xmlhttp.status);
|
---|
| 62 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
| 63 | {
|
---|
| 64 | console.log("get code");
|
---|
| 65 | console.log(xmlhttp.responseText);
|
---|
| 66 | document.getElementById("gs_content").innerHTML=xmlhttp.responseText;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | xmlhttp.open("GET","http://localhost:8080/greenstone3/format?a=b&rt=s&s=ClassifierBrowse&c=simpleht&cl=CL1&excerptid=gs_content",true);
|
---|
| 71 | //xmlhttp.open("GET","http://www.cs.waikato.ac.nz",true);
|
---|
| 72 | //xmlhttp.open("GET","http://wand.net.nz/~sjb48/index.html",true);
|
---|
| 73 | xmlhttp.send();
|
---|
| 74 | }
|
---|
| 75 | */
|
---|
[22474] | 76 | $(document).ready(function(){
|
---|
| 77 |
|
---|
[22516] | 78 | console.log("Document ready function\n");
|
---|
| 79 |
|
---|
[23135] | 80 | var CURRENT_SELECT_VALUE = "";
|
---|
| 81 |
|
---|
[23276] | 82 | var iframe = document.getElementById('iframe');
|
---|
| 83 | var iframe_document = iframe.document;
|
---|
| 84 |
|
---|
| 85 | if(iframe.contentDocument)
|
---|
| 86 | {
|
---|
| 87 | iframe_document = iframe.contentDocument; // For NS6
|
---|
| 88 | console.log("Chose content document");
|
---|
| 89 | }
|
---|
| 90 | else if(iframe.contentWindow)
|
---|
| 91 | {
|
---|
| 92 | iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
|
---|
| 93 | console.log("Chose content window");
|
---|
| 94 | }
|
---|
[23298] | 95 |
|
---|
| 96 | // Edit the hrefs in preview_html - search for <a href="format?a=b&rt=r&s=ClassifierBrowse&c=simpleht&cl=CL1.2">
|
---|
| 97 | var start_index = 0;
|
---|
| 98 | var end_index = 0;
|
---|
| 99 | while(start_index != -1)
|
---|
| 100 | {
|
---|
| 101 | start_index = preview_html.indexOf("href=\"format", start_index);
|
---|
| 102 | console.log("start index = " + start_index);
|
---|
| 103 | if(start_index != -1)
|
---|
| 104 | {
|
---|
| 105 | end_index = preview_html.indexOf("\">", start_index);
|
---|
| 106 | console.log("end_index = " + end_index);
|
---|
| 107 | a = preview_html.substring(0,end_index);
|
---|
| 108 | b = preview_html.substring(end_index);
|
---|
| 109 | preview_html = a.concat("&excerptid=gs_content", b);
|
---|
| 110 | console.log(preview_html);
|
---|
| 111 | start_index = end_index + "&excerptid=gs_content\">".length;
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[23276] | 115 | // Put the content in the iframe
|
---|
| 116 | if(initialised_iframe == "false")
|
---|
| 117 | {
|
---|
| 118 | console.log("Initialised iframe with preview html");
|
---|
[23298] | 119 | console.log(preview_html);
|
---|
[23276] | 120 | iframe_document.open();
|
---|
| 121 | iframe_document.writeln(preview_html); //.concat("&excerptid=gs_content"));
|
---|
| 122 | iframe_document.close();
|
---|
| 123 | initialised_iframe = "true";
|
---|
| 124 | }
|
---|
[23298] | 125 |
|
---|
| 126 | /*
|
---|
[23276] | 127 | $(iframe_document.documentElement.innerHTML).find('a').each(function() {
|
---|
| 128 | console.log("data "+$(this).data('href'));
|
---|
| 129 | console.log("getAttribute "+this.getAttribute('href'));
|
---|
| 130 | console.log("attr "+$(this).attr('href'));
|
---|
| 131 | console.log("this.href "+this.href);
|
---|
| 132 | var original = this.href; //$(this).attr('href');
|
---|
| 133 | // check if greenstone link ie. starts with format
|
---|
| 134 | //var original = $(this).data('href');
|
---|
| 135 | var modified = original.toString().concat("&excerptid=gs_content");
|
---|
| 136 | console.log("* *");
|
---|
| 137 | console.log(modified);
|
---|
| 138 | console.log("* *");
|
---|
| 139 | //this.href = modified;
|
---|
| 140 | //$(this).attr('href',modified);
|
---|
| 141 | //$(this).data('href', modified);
|
---|
| 142 | $(this).attr({ 'href': modified });
|
---|
| 143 | //console.log($(this).attr('href'));
|
---|
| 144 | console.log("data "+$(this).data('href'));
|
---|
| 145 | console.log("getAttribute "+this.getAttribute('href'));
|
---|
| 146 | console.log("attr "+$(this).attr('href'));
|
---|
| 147 | console.log("this.href "+this.href);
|
---|
| 148 | console.log("***********************");
|
---|
| 149 | });
|
---|
| 150 | */
|
---|
| 151 |
|
---|
[22598] | 152 | /******************************************/
|
---|
| 153 | /* DRAGGABLES */
|
---|
| 154 | /******************************************/
|
---|
[22516] | 155 |
|
---|
[23276] | 156 | $(".draggable_gsf_template").draggable({
|
---|
[23046] | 157 | cursor: 'crosshair',
|
---|
[22598] | 158 | connectToSortable: '#formatStatement',
|
---|
| 159 | helper: 'clone',
|
---|
| 160 | revert: 'invalid'
|
---|
| 161 | });
|
---|
| 162 |
|
---|
[23276] | 163 | $(".draggable_table").draggable({
|
---|
[23046] | 164 | cursor: 'crosshair',
|
---|
[22569] | 165 | connectToSortable: '.gsf_template',
|
---|
| 166 | helper: 'clone',
|
---|
[22598] | 167 | revert: 'invalid'
|
---|
| 168 | });
|
---|
[22516] | 169 |
|
---|
[23276] | 170 | $(".draggable_tr").draggable({
|
---|
[23046] | 171 | cursor: 'crosshair',
|
---|
[22598] | 172 | connectToSortable: '.gsf_table',
|
---|
| 173 | helper: 'clone',
|
---|
| 174 | revert: 'invalid'
|
---|
| 175 | })
|
---|
[22569] | 176 |
|
---|
[23276] | 177 | $(".draggable_td").draggable({
|
---|
[23046] | 178 | cursor: 'crosshair',
|
---|
[22676] | 179 | //connectToSortable: '.td',
|
---|
[22598] | 180 | helper: 'clone',
|
---|
| 181 | revert: 'invalid'
|
---|
| 182 | })
|
---|
| 183 |
|
---|
[23298] | 184 | $(".draggable_gsf_text").draggable({
|
---|
[23046] | 185 | cursor: 'crosshair',
|
---|
[23298] | 186 | connectToSortable: '.td-div, .gsf_when, .gsf_otherwise, .gsf_link, .gsf_choose_metadata, .gsf_default',
|
---|
[22598] | 187 | helper: 'clone',
|
---|
| 188 | revert: 'invalid'
|
---|
[22569] | 189 | });
|
---|
| 190 |
|
---|
[23255] | 191 | $(".draggable_gsf_choose_metadata").draggable({
|
---|
[23046] | 192 | cursor: 'crosshair',
|
---|
[23276] | 193 | connectToSortable: '.td-div, .gsf_link, .gsf_when, .gsf_otherwise',
|
---|
[22598] | 194 | helper: 'clone',
|
---|
| 195 | revert: 'invalid'
|
---|
| 196 | });
|
---|
| 197 |
|
---|
[23046] | 198 | //$(".element_type_gsf_metadata").draggable({
|
---|
[23135] | 199 | $(".draggable_gsf_metadata").draggable({
|
---|
[23046] | 200 | cursor: 'crosshair',
|
---|
[23276] | 201 | connectToSortable: '.gsf_choose_metadata, .gsf_when, .gsf_otherwise, .gsf_link, .td-div',
|
---|
[22598] | 202 | helper: 'clone',
|
---|
| 203 | revert: 'invalid'
|
---|
| 204 | });
|
---|
| 205 |
|
---|
[23135] | 206 | $(".draggable_gsf_link").draggable({
|
---|
[23046] | 207 | cursor: 'crosshair',
|
---|
[23276] | 208 | connectToSortable: '.td-div, .gsf_when, .gsf_otherwise, .gsf_link',
|
---|
[22598] | 209 | helper: 'clone',
|
---|
| 210 | revert: 'invalid'
|
---|
| 211 | });
|
---|
| 212 |
|
---|
| 213 | // switch, when, otherwise, icon
|
---|
[23255] | 214 | $(".draggable_gsf_switch").draggable({
|
---|
[23046] | 215 | cursor: 'crosshair',
|
---|
[23276] | 216 | connectToSortable: '.td-div, .gsf_link',
|
---|
[22598] | 217 | helper: 'clone',
|
---|
| 218 | revert: 'invalid'
|
---|
| 219 | });
|
---|
| 220 |
|
---|
[23255] | 221 | $(".draggable_gsf_when").draggable({
|
---|
[23046] | 222 | cursor: 'crosshair',
|
---|
[22598] | 223 | connectToSortable: '.gsf_switch',
|
---|
| 224 | helper: 'clone',
|
---|
| 225 | revert: 'invalid'
|
---|
| 226 | });
|
---|
| 227 |
|
---|
[23255] | 228 | $(".draggable_gsf_otherwise").draggable({
|
---|
[23046] | 229 | cursor: 'crosshair',
|
---|
[22598] | 230 | connectToSortable: '.gsf_switch',
|
---|
| 231 | helper: 'clone',
|
---|
| 232 | revert: 'invalid'
|
---|
| 233 | });
|
---|
| 234 |
|
---|
[23255] | 235 | $(".draggable_gsf_icon").draggable({
|
---|
[23046] | 236 | cursor: 'crosshair',
|
---|
[23298] | 237 | connectToSortable: '.td-div, .gsf_link, .gsf_choose, .gsf_when, .gsf_otherwise',
|
---|
[22598] | 238 | helper: 'clone',
|
---|
| 239 | revert: 'invalid'
|
---|
| 240 | });
|
---|
| 241 |
|
---|
[22516] | 242 |
|
---|
[22598] | 243 | /******************************************/
|
---|
| 244 | /* SORTABLES */
|
---|
| 245 | /******************************************/
|
---|
| 246 |
|
---|
[22933] | 247 | bind_td_sortable();
|
---|
[22598] | 248 | bind_all_sortables();
|
---|
| 249 |
|
---|
[22516] | 250 | $('#formatStatement').sortable({
|
---|
[22569] | 251 | cursor: 'pointer',
|
---|
| 252 | tolerance: 'pointer',
|
---|
| 253 | items: '.gsf_template',
|
---|
[22598] | 254 | placeholder:'placeholder',
|
---|
[22516] | 255 | //'nested':'div'
|
---|
[22598] | 256 | stop: function(event, ui) {
|
---|
| 257 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('css_gsf_template')) { replace_with(ui.item,gsf_template_element); }
|
---|
| 258 | }
|
---|
[22516] | 259 | });
|
---|
[22676] | 260 |
|
---|
| 261 | $('div.gsf_template').children(".block,.table").slideUp(300);
|
---|
[22598] | 262 | });
|
---|
| 263 |
|
---|
| 264 | /*******************************************************************************/
|
---|
| 265 |
|
---|
| 266 | function bind_all_sortables()
|
---|
| 267 | {
|
---|
[22768] | 268 | console.log('function bind_all_sortables()');
|
---|
[22598] | 269 | bind_template_sortable();
|
---|
[22676] | 270 | //bind_table_sortable();
|
---|
| 271 | //bind_tr_sortable();
|
---|
| 272 | //bind_td_sortable();
|
---|
[22598] | 273 | bind_choose_metadata_sortable();
|
---|
| 274 | bind_link_sortable();
|
---|
| 275 | bind_switch_sortable();
|
---|
| 276 | bind_when_sortable();
|
---|
| 277 | bind_otherwise_sortable();
|
---|
| 278 |
|
---|
[22676] | 279 | bind_tables();
|
---|
| 280 |
|
---|
[22598] | 281 | bind_block_mouseover();
|
---|
| 282 | bind_minmax_remove();
|
---|
| 283 | }
|
---|
| 284 |
|
---|
[22676] | 285 | function bind_tables()
|
---|
| 286 | {
|
---|
[22768] | 287 | console.log('function bind_tables()');
|
---|
| 288 | //$('.tr').resize_tables($(this)); //equalHeights();
|
---|
[22676] | 289 |
|
---|
[22768] | 290 |
|
---|
| 291 | $('td').click(function () {
|
---|
[22829] | 292 | console.log('td click *');
|
---|
[22768] | 293 | return false;
|
---|
| 294 | });
|
---|
| 295 |
|
---|
[22829] | 296 | $(".td-div").resizable({
|
---|
[22676] | 297 | alsoResize: 'parent',
|
---|
| 298 | //containment: 'parent',
|
---|
| 299 | handles: 'w,e',
|
---|
| 300 | stop: function(event, ui) {
|
---|
[22768] | 301 | console.log('Resize table on stop');
|
---|
| 302 | resize_tables($(this));
|
---|
| 303 | //$(this).parent().parent().equalHeights();
|
---|
[22676] | 304 | }, });
|
---|
| 305 |
|
---|
[23046] | 306 | //$(".droppable").sortable({
|
---|
| 307 | // 'cursor':'pointer',
|
---|
| 308 | // 'tolerance': 'pointer',
|
---|
| 309 | // 'items':'.column, .td-div',
|
---|
| 310 | // 'placeholder':'placeholder'
|
---|
| 311 | //});
|
---|
| 312 |
|
---|
[22676] | 313 | $(".droppable").droppable({
|
---|
| 314 | accept: '.element_type_td',
|
---|
| 315 | tolerance: 'pointer',
|
---|
[22768] | 316 | activate: function(event, ui) { $(this).addClass("droppable_hl");}, // console.log("droppable activated")},
|
---|
| 317 | deactivate: function(event, ui) { $(this).removeClass("droppable_hl"); }, // console.log("droppable deactivated")},
|
---|
[22676] | 318 | drop: function(event, ui) {
|
---|
[23046] | 319 | //if ($(this).hasClass("ui-draggable"))
|
---|
| 320 | //if (ui.helper.hasClass("ui-draggable"))
|
---|
| 321 | //{
|
---|
[22829] | 322 | var neverempty = document.createElement("div");
|
---|
| 323 | neverempty.setAttribute("class","neverempty block");
|
---|
| 324 | neverempty.setAttribute("style","height:50px");
|
---|
| 325 | neverempty.setAttribute("style","display:block");
|
---|
| 326 | var text = document.createTextNode('NEVER EMPTY');
|
---|
| 327 | neverempty.appendChild(text);
|
---|
[22676] | 328 | var td = document.createElement("td");
|
---|
| 329 | var div = document.createElement("div"); // class=\"td block\" title=\"td-div\"");
|
---|
| 330 | div.setAttribute("title","td-div");
|
---|
[22829] | 331 | div.setAttribute("class","td-div block");
|
---|
[22768] | 332 | div.setAttribute("style","margin-left:0px");
|
---|
[22676] | 333 | div.setAttribute("width","25px");
|
---|
| 334 | td.appendChild(div);
|
---|
[22829] | 335 | div.appendChild(neverempty);
|
---|
[22676] | 336 | var sep = document.createElement("td");
|
---|
| 337 | sep.setAttribute("class","droppable");
|
---|
| 338 | sep.setAttribute("width","10px");
|
---|
| 339 | $(this).after(sep);
|
---|
| 340 | $(this).after(td);
|
---|
| 341 | bind_tables();
|
---|
[22768] | 342 | resize_tables($(this));
|
---|
| 343 | bind_td_sortable();
|
---|
[22829] | 344 | bind_block_mouseover();
|
---|
[22676] | 345 | //bind_all_sortables();
|
---|
[23046] | 346 | //}
|
---|
| 347 | //else
|
---|
| 348 | //{
|
---|
| 349 | // console.log("Attempting to add");
|
---|
| 350 | //$(this).appendTo(ui.draggable[0]);
|
---|
| 351 | // $(this).prepend(ui.draggable[0]);
|
---|
| 352 | //$(ui.draggable[0]).appendTo($(this));
|
---|
| 353 | //}
|
---|
[22676] | 354 | }
|
---|
| 355 | });
|
---|
| 356 |
|
---|
| 357 | }
|
---|
| 358 |
|
---|
[22598] | 359 | function replace_with(item, me)
|
---|
| 360 | {
|
---|
[23135] | 361 | // Search me for select
|
---|
| 362 | if(me.search("select") != -1)
|
---|
| 363 | {
|
---|
| 364 | // If select exists, then find CURRENT_SELECT_VALUE
|
---|
| 365 | var index = me.search(CURRENT_SELECT_VALUE);
|
---|
| 366 | if(index == -1)
|
---|
| 367 | console.log("Did not find " + CURRENT_SELECT_VALUE);
|
---|
| 368 | else
|
---|
| 369 | console.log("Found " + CURRENT_SELECT_VALUE + " at index " + index);
|
---|
| 370 | index = index + CURRENT_SELECT_VALUE.length + 1;
|
---|
| 371 | console.log("Attempt inserting select at new index "+index);
|
---|
| 372 | a = me.substring(0,index);
|
---|
| 373 | b = me.substring(index);
|
---|
| 374 | me = a.concat("selected",b);
|
---|
| 375 | }
|
---|
| 376 |
|
---|
[22933] | 377 | //console.log('function replace_with(item, me)');
|
---|
[22598] | 378 | item.replaceWith(me); //'<div class="element element-txt">This text box has been added!</div>');
|
---|
[23135] | 379 | //item.find('select').attr("value", CURRENT_SELECT_VALUE);
|
---|
[22676] | 380 |
|
---|
[23135] | 381 |
|
---|
| 382 | //if(select != null){
|
---|
| 383 | // console.log("Attempting to select " + CURRENT_SELECT_VALUE);
|
---|
| 384 | // console.log("length = "+select.length);
|
---|
| 385 | // for(index = 0; index < select.length; index++) {
|
---|
| 386 | // console.log(select[index].value);
|
---|
| 387 | // if(select[index].value == CURRENT_SELECT_VALUE)
|
---|
| 388 | // console.log("Found "+CURRENT_SELECT_VALUE+" at index " + index);
|
---|
| 389 | // select.selectedIndex = index;
|
---|
| 390 | // }
|
---|
| 391 | // }
|
---|
| 392 |
|
---|
[22768] | 393 | resize_tables(item);
|
---|
| 394 |
|
---|
| 395 | bind_all_sortables();
|
---|
| 396 | }
|
---|
| 397 |
|
---|
| 398 | function resize_tables(item)
|
---|
| 399 | {
|
---|
[22933] | 400 | //console.log('function resize_tables(item)');
|
---|
[22768] | 401 | var max_height = 0;
|
---|
[22676] | 402 | (item.parents('.table')).each(function(index) {
|
---|
| 403 | $(this).children().children().children().each(function() {
|
---|
[22768] | 404 | var sum_one = 0;
|
---|
| 405 | var sum_two = 0;
|
---|
| 406 | $(this).children('.block').each(function() { sum_one = sum_one + $(this).height();
|
---|
| 407 | $(this).children('.block').each(function() { sum_two = sum_two + $(this).height(); } );
|
---|
| 408 | console.log("My height is " + $(this).height() + ", sum height 2 is " + sum_two);
|
---|
| 409 | });
|
---|
| 410 | console.log("My height is " + $(this).height() + ", sum height 1 is " + sum_one);
|
---|
| 411 | if (sum_two > max_height)
|
---|
| 412 | max_height = sum_two;
|
---|
[22676] | 413 | });
|
---|
| 414 | });
|
---|
[22768] | 415 | equalHeights(item,max_height);
|
---|
[22598] | 416 | }
|
---|
| 417 |
|
---|
| 418 | function bind_template_sortable()
|
---|
| 419 | {
|
---|
[22933] | 420 | //console.log('function bind_template_sortable()');
|
---|
[22569] | 421 | $('.gsf_template').sortable({
|
---|
[22516] | 422 | 'cursor':'pointer',
|
---|
[22987] | 423 | 'tolerance': 'pointer',
|
---|
[22933] | 424 | 'items':'.table', //.gsf_choose_metadata, .gsf_metadata',
|
---|
[22598] | 425 | 'placeholder':'placeholder',
|
---|
| 426 | //'nested':'.gsf:metadata'
|
---|
| 427 | stop: function(event, ui) {
|
---|
| 428 | //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] | 429 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_table')) { replace_with(ui.item, "<table class=\"table\" border=\"2\"></table>"); }
|
---|
| 430 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
| 431 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 432 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 433 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
[22598] | 434 | }
|
---|
| 435 | });
|
---|
| 436 |
|
---|
[22768] | 437 | $('.gsf_template').click(function () {
|
---|
| 438 | console.log('gsf_template class click');
|
---|
| 439 | return false;
|
---|
[22598] | 440 | });
|
---|
[22569] | 441 |
|
---|
[22598] | 442 | }
|
---|
[22474] | 443 |
|
---|
[22598] | 444 | function bind_td_sortable()
|
---|
| 445 | {
|
---|
[23046] | 446 |
|
---|
| 447 | $('tr').sortable({
|
---|
| 448 | 'cursor':'pointer',
|
---|
| 449 | 'tolerance': 'intersect',
|
---|
| 450 | 'items':'.column',
|
---|
| 451 | 'placeholder':'placeholder_td',
|
---|
| 452 | 'connectWith':'column'});
|
---|
| 453 |
|
---|
| 454 | //$('.column').sortable({
|
---|
| 455 | // connectWith:['.column'],
|
---|
| 456 | // placeholder: 'placeholder',
|
---|
| 457 | // items:'td-div'
|
---|
| 458 | //});
|
---|
| 459 |
|
---|
| 460 |
|
---|
| 461 | //$('.column').sortable({
|
---|
| 462 | // 'cursor':'pointer',
|
---|
| 463 | // 'tolerance': 'pointer',
|
---|
| 464 | // 'items':'.td-div',
|
---|
| 465 | // 'placeholder':'placeholder',
|
---|
| 466 | // 'connectWith':'.column'
|
---|
| 467 | //'nested':'.gsf:metadata'
|
---|
| 468 | //receive: function(event, ui) { alert("Attempted to receive"); },
|
---|
| 469 | //stop: function(event, ui) {
|
---|
| 470 | // if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 471 |
|
---|
| 472 | //});
|
---|
| 473 |
|
---|
[22933] | 474 | //console.log('function bind_td_sortable()');
|
---|
[22829] | 475 | $('.td-div').sortable({
|
---|
[22516] | 476 | 'cursor':'pointer',
|
---|
[22987] | 477 | 'tolerance': 'pointer',
|
---|
[22768] | 478 | 'items':'.gsf_metadata, .gsf_choose_metadata, .gsf_link, .gsf_switch',
|
---|
[22598] | 479 | 'placeholder':'placeholder',
|
---|
[23046] | 480 | //'connectWith':'.td-div',
|
---|
[22516] | 481 | //'nested':'.gsf:metadata'
|
---|
[22676] | 482 | receive: function(event, ui) { alert("Attempted to receive"); },
|
---|
[22598] | 483 | stop: function(event, ui) {
|
---|
[23276] | 484 | // gsf metadata
|
---|
| 485 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 486 | // gsf choose metadata
|
---|
| 487 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
| 488 | // gsf link
|
---|
| 489 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 490 | // gsf switch
|
---|
| 491 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
[22676] | 492 |
|
---|
[22598] | 493 | }
|
---|
| 494 |
|
---|
[22516] | 495 | });
|
---|
[22768] | 496 |
|
---|
[22829] | 497 | $('.td-div').click(function () {
|
---|
[22933] | 498 | //console.log('td class click');
|
---|
[22829] | 499 | return true;
|
---|
[22768] | 500 | });
|
---|
| 501 |
|
---|
| 502 |
|
---|
| 503 |
|
---|
[22598] | 504 | }
|
---|
| 505 |
|
---|
[22829] | 506 |
|
---|
[22598] | 507 | function bind_choose_metadata_sortable()
|
---|
| 508 | {
|
---|
[22933] | 509 | //console.log('function bind_choose_metadata_sortable()');
|
---|
[22598] | 510 | $('.gsf_choose_metadata').sortable({
|
---|
[22516] | 511 | 'cursor':'pointer',
|
---|
[22987] | 512 | 'tolerance': 'pointer',
|
---|
[23276] | 513 | 'items':'.gsf_metadata, .gsf_text, .gsf_default',
|
---|
[22516] | 514 | 'placeholder':'placeholder',
|
---|
[22598] | 515 | 'connectWith':'.gsf_choose_metadata',
|
---|
[22516] | 516 | //'nested':'.gsf:metadata'
|
---|
[22598] | 517 | stop: function(event, ui) {
|
---|
[23276] | 518 | // gsf metadata
|
---|
| 519 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 520 | // gsf text
|
---|
| 521 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
| 522 | // gsf default
|
---|
| 523 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_default')) { replace_with(ui.item, gsf_default_element); }
|
---|
[23135] | 524 |
|
---|
[23046] | 525 | bind_all_sortables();
|
---|
[22598] | 526 | }
|
---|
[22516] | 527 | });
|
---|
[22598] | 528 | }
|
---|
| 529 |
|
---|
| 530 | function bind_link_sortable()
|
---|
| 531 | {
|
---|
[22933] | 532 | //console.log('function bind_link_sortable()');
|
---|
[22569] | 533 | $('.gsf_link').sortable({
|
---|
[22516] | 534 | 'cursor':'pointer',
|
---|
[22987] | 535 | 'tolerance': 'pointer',
|
---|
[23276] | 536 | 'items':'.leaf, .gsf_link, .gsf_switch, .gsf_choose',
|
---|
[22676] | 537 | 'placeholder':'placeholder',
|
---|
[22829] | 538 | 'connectWith':'.gsf_link',
|
---|
[22516] | 539 | //'nested':'.gsf:metadata'
|
---|
[22676] | 540 | stop: function(event, ui) {
|
---|
[23276] | 541 | // gsf icon
|
---|
| 542 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 543 | // gsf text
|
---|
| 544 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
|
---|
| 545 | // gsf metadata
|
---|
| 546 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 547 | // gsf link
|
---|
| 548 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 549 | // gsf switch
|
---|
| 550 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
| 551 | // gsf choose
|
---|
| 552 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
[22676] | 553 | }
|
---|
[22516] | 554 | });
|
---|
[22598] | 555 | }
|
---|
[22516] | 556 |
|
---|
[22598] | 557 | function bind_switch_sortable()
|
---|
| 558 | {
|
---|
[22933] | 559 | //console.log('function bind_switch_sortable()');
|
---|
[22569] | 560 | $('.gsf_switch').sortable({
|
---|
[22516] | 561 | 'cursor':'pointer',
|
---|
[22987] | 562 | 'tolerance': 'pointer',
|
---|
[23276] | 563 | 'items':'.gsf_metadata, .gsf_when, .gsf_otherwise, .gsf_text',
|
---|
[22598] | 564 | 'placeholder':'placeholder',
|
---|
[22933] | 565 | 'connectWith':'.gsf_switch',
|
---|
[22516] | 566 | //'nested':'.gsf:metadata'
|
---|
[22598] | 567 | stop: function(event, ui) {
|
---|
[23276] | 568 | // gsf when
|
---|
| 569 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_when')) { replace_with(ui.item, gsf_when_element); }
|
---|
| 570 | // gsf otherwise
|
---|
| 571 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_otherwise')) { replace_with(ui.item, gsf_otherwise_element); }
|
---|
| 572 | // gsf metadata
|
---|
| 573 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 574 | // gsf text
|
---|
| 575 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
[22598] | 576 | }
|
---|
[22516] | 577 | });
|
---|
[22598] | 578 | }
|
---|
[22516] | 579 |
|
---|
[22598] | 580 | function bind_when_sortable()
|
---|
| 581 | {
|
---|
[22933] | 582 | //console.log('function bind_when_sortable()');
|
---|
[22569] | 583 | $('.gsf_when').sortable({
|
---|
[22516] | 584 | 'cursor':'pointer',
|
---|
[22987] | 585 | 'tolerance': 'pointer',
|
---|
[23276] | 586 | 'items':'.leaf, .gsf_link, .gsf_choose',
|
---|
[22598] | 587 | 'placeholder':'placeholder',
|
---|
[22516] | 588 | //'nested':'.gsf:metadata'
|
---|
[22598] | 589 | stop: function(event, ui) {
|
---|
[23276] | 590 | // gsf metadata
|
---|
| 591 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 592 | // gsf icon
|
---|
| 593 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 594 | // gsf text
|
---|
| 595 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
| 596 | // gsf link
|
---|
| 597 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 598 | // gsf choose
|
---|
| 599 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); }
|
---|
[22598] | 600 | }
|
---|
[22516] | 601 | });
|
---|
[22598] | 602 | }
|
---|
[22516] | 603 |
|
---|
[22598] | 604 | function bind_otherwise_sortable()
|
---|
| 605 | {
|
---|
[22933] | 606 | //console.log('function bind_otherwise_sortable()');
|
---|
[22569] | 607 | $('.gsf_otherwise').sortable({
|
---|
[22516] | 608 | 'cursor':'pointer',
|
---|
[22987] | 609 | 'tolerance': 'pointer',
|
---|
[23276] | 610 | 'items':'.leaf, .gsf_link, .gsf_choose',
|
---|
[22598] | 611 | 'placeholder':'placeholder',
|
---|
[22516] | 612 | //'nested':'.gsf:metadata'
|
---|
[22598] | 613 | stop: function(event, ui) {
|
---|
[23276] | 614 | // gsf metadata
|
---|
| 615 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 616 | // gsf text
|
---|
| 617 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
|
---|
| 618 | // gsf icon
|
---|
| 619 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 620 | // gsf link
|
---|
| 621 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 622 | // gsf choose
|
---|
| 623 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); }
|
---|
[22598] | 624 | }
|
---|
[22516] | 625 | });
|
---|
[22598] | 626 | }
|
---|
[22516] | 627 |
|
---|
[22598] | 628 | function bind_block_mouseover()
|
---|
| 629 | {
|
---|
[22933] | 630 | //console.log('function bind_block_mouseover()');
|
---|
[22598] | 631 | $(".block").mouseover(function()
|
---|
[22516] | 632 | {
|
---|
[22474] | 633 | $(this).parents().css("border", "");
|
---|
[23046] | 634 | $(this).css("border", "2px solid blue");
|
---|
[22516] | 635 | return false;
|
---|
[22474] | 636 | }).mouseout(function(){
|
---|
| 637 | $(this).css("border", "");
|
---|
[22516] | 638 | return false;
|
---|
[22474] | 639 | });
|
---|
[22598] | 640 | }
|
---|
[22474] | 641 |
|
---|
[22598] | 642 | function bind_minmax_remove()
|
---|
| 643 | {
|
---|
[22768] | 644 | console.log('function bind_minmax_remove()');
|
---|
[22598] | 645 | $('a.minmax').bind('click', toggleContent);
|
---|
| 646 | $('a.remove').bind('click', removeContent);
|
---|
| 647 | };
|
---|
[22474] | 648 |
|
---|
| 649 | var removeContent = (function () {
|
---|
[22933] | 650 | //console.log('var removeContent = (function ()');
|
---|
[22768] | 651 | // this -> a -> td -> tr -> tbody -> table -> div
|
---|
[23046] | 652 | //$(this).parent().parent().parent().parent().parent().remove();
|
---|
| 653 | $(this).closest(".block").remove();
|
---|
[22474] | 654 | });
|
---|
| 655 |
|
---|
| 656 |
|
---|
| 657 | var toggleContent = function(e)
|
---|
| 658 | {
|
---|
[22933] | 659 | //console.log('var toggleContent = function(e)');
|
---|
[22768] | 660 | console.log('parent: ' + $(this).html());
|
---|
[22676] | 661 | if ($(this).html() == '[+]'){ //targetContent.css('display') == 'none') {
|
---|
[23046] | 662 | //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideDown(300);
|
---|
| 663 | //$(this).parents().children(".block,.table").stopPropagation().slideDown(300);
|
---|
| 664 | //var x = $(this).parent().parent().parent().parent().parent();
|
---|
| 665 | //var y = $(this).parent().parent().parent().parent().parent().children(".block,.table");
|
---|
| 666 | //var z = $(this).closest(".block").children(".table, .block");
|
---|
| 667 | $(this).closest(".block").children(".table, .block").slideDown(300);
|
---|
[22474] | 668 | $(this).html('[-]');
|
---|
[22768] | 669 | $(this).removeClass("ui-icon-plusthick");
|
---|
| 670 | $(this).addClass("ui-icon-minusthick");
|
---|
[22474] | 671 | } else {
|
---|
[23046] | 672 | //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideUp(300);
|
---|
| 673 | //$(this).parents().children(".block,.table").slideUp(300);
|
---|
| 674 | $(this).closest(".block").children(".table, .block").slideUp(300);
|
---|
[22474] | 675 | $(this).html('[+]');
|
---|
[22768] | 676 | $(this).removeClass("ui-icon-minusthick");
|
---|
| 677 | $(this).addClass("ui-icon-plusthick");
|
---|
[22474] | 678 | }
|
---|
| 679 | return false;
|
---|
| 680 | };
|
---|
| 681 |
|
---|
| 682 | function serialize(s)
|
---|
| 683 | {
|
---|
| 684 | serial = $.SortSerialize(s);
|
---|
| 685 | alert(serial.hash);
|
---|
| 686 | };
|
---|
| 687 |
|
---|
[22768] | 688 | function equalHeights(item, height) {
|
---|
[22933] | 689 | //console.log('function equalHeights(item, height)');
|
---|
[22768] | 690 | (item.parents('.table')).each(function(index) {
|
---|
| 691 | $(this).children().children().children().each(function() {
|
---|
| 692 | $(this).height(height);
|
---|
| 693 | $(this).children().height(height);
|
---|
| 694 | });
|
---|
[22569] | 695 | });
|
---|
| 696 | };
|
---|
| 697 |
|
---|