- Timestamp:
- 2011-07-08T14:01:45+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js
r24202 r24243 58 58 } 59 59 60 61 60 function checkDocumentRadio() 62 61 { … … 74 73 { 75 74 console.log("Saving changes to "+checkDocumentRadio()); 76 } 77 78 75 console.log("TOC="+$('input[name="TOC"]').attr('checked')); 76 console.log("Cover Image="+$('input[name="bookCover"]').attr('checked')); 77 78 var myurl = document.URL; 79 80 var collection_name = getSubstring(myurl, "&c", "&"); 81 var document_id = getSubstring(myurl, "&d", "&"); 82 var document_type = getSubstring(myurl, "&dt", "&"); 83 var prev_action = getSubstring(myurl, "&p.a", "&"); 84 var prev_service = getSubstring(myurl, "&p.s", "&"); 85 86 var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=saveDocument&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service; 87 88 // XML will be automatically wrapped in <display><format> tags when saved to collection config 89 var xml = '<format><gsf:option name="TOC" value="'+$('input[name="TOC"]').attr('checked')+'"/><gsf:option name="coverImage" value="'+$('input[name="bookCover"]').attr('checked')+'"/></format>'; 90 91 $.post(post_url, {data: xml}, function(data) { 92 console.log("Success, we have received data"); 93 }, 'xml'); 94 } 79 95 80 96 /* FUNCTIONS FOR FORMAT EDITING */ … … 100 116 } 101 117 102 //function createFormatStatement()103 //{104 105 //var formatDiv = document.getElementById('formatStatement');106 //var formatStatement = innerXHTML(formatDiv);107 //console.log(formatStatement);108 109 // find collection name110 111 //var myurl = document.URL;112 //console.log(myurl);113 //var first = myurl.indexOf("&c")+3;114 //var last = myurl.indexOf("&", first);115 116 //var collection_name = getSubstring(myurl, "&c", "&"); //myurl.substring(first,last); ///&c=(.*)&/.exec(myurl);117 //console.log(collection_name);118 119 //first = myurl.indexOf("&s")+3;120 //last = myurl.indexOf("&", first);121 122 //var service_name = myurl.substring(first,last);123 //console.log(service_name);124 125 //var classifier_name = null;126 127 //if(service_name == "ClassifierBrowse")128 //{129 // first = myurl.indexOf("&cl")+4;130 // last = myurl.indexOf("&", first);131 132 // classifier_name = myurl.substring(first,last);133 // console.log(classifier_name);134 //}135 136 //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;137 138 //jQuery.post( url, [ data ], [ success(data, textStatus, XMLHttpRequest) ], [ dataType ] )139 140 // How do I find out my collection name?141 142 118 function getSubstring(str, first, last) 143 119 { 144 120 var first_index = str.indexOf(first)+first.length+1; 145 121 var last_index = str.indexOf(last, first_index); 122 123 if(last_index == -1) 124 last_index = str.length; 146 125 147 126 var substring = str.substring(first_index, last_index); … … 228 207 229 208 $.post(post_url, {data: formatStatement}, function(data) { 230 //$('.result').innerHTML = data; //html(data);231 232 209 // An error is returned because there is no valid XSLT for a format update action, there probably shouldn't be one so we ignore what the post returns. 233 210 console.log("Successfully saved"); 234 //console.log(data);235 211 }, 'html'); 236 212 } … … 245 221 var prev_action = getSubstring(myurl, "&p.a", "&"); 246 222 var prev_service = getSubstring(myurl, "&p.s", "&"); 247 //var classifier_name = null; 248 249 //if(service_name == "ClassifierBrowse") 250 // classifier_name = getSubstring(myurl, "&cl", "&"); 251 252 253 //var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=getXSLT&c=" + collection_name +"&s=" + service_name+"&d=" + document_id + "&o=skinandlib"; 223 254 224 var post_url = "http://localhost:8989/greenstone3/format?a=d&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service + "&o=skinandlib"; 255 225 256 //if(classifier_name != null)257 // post_url = post_url + "&cl=" + classifier_name;258 259 226 $.post(post_url, {data: classname}, function(data) { 260 //$('.result').innerHTML = data; //html(data);261 227 console.log("Success, we have received data"); 262 //console.log(data);263 228 classname = "." + classname; 264 console.log(classname); //data.getElementsByTagName("div"));229 console.log(classname); 265 230 var content = $( data ).find(classname); 266 231 console.log(content.xml()); … … 269 234 } 270 235 271 /*272 $.ajax({273 type: "POST",274 url: "http://localhost:8080/greenstone3/format?a=s&sa=s",275 data: formatStatement,276 processData: false,277 success: function(data) {278 //$('.result').html(data);279 console.log("Success, we have received data");280 //console.log(data);281 }282 });283 */284 /*285 $.ajax({286 url: myurl,287 success: function(data) {288 //$('.result').html(data);289 console.log("Success, we have received data");290 console.log(data);291 }292 });293 */294 //if(formatStatement.hasChildNodes())295 //{296 //var formatstring = traverse(formatStatement, "");297 //console.log(formatstring);298 299 // var children = $(formatStatement).children('div');300 // for(var i=0; i < children.length; i++)301 // traverse(children[i], formatstring)302 303 /*304 var children = formatStatement.childNodes; //[]getChildNodes();305 var current;306 for(var i = 0; i < formatStatement.childNodes.length; i++)307 {308 current = formatStatement.childNodes[i];309 //console.log(current.nodeName);310 //console.log(current.nodeType);311 if(current.nodeName=='DIV')312 {313 //console.log(current);314 //console.log(current.className);315 var gsf = find_class(current);316 console.log(gsf);317 }318 }319 */320 //}321 //}322 323 236 function traverse(node, formatstring) 324 237 { 325 //console.log("node=("+node.nodeName+","+node.nodeType+")");326 238 327 239 if(node.nodeName=='DIV') … … 339 251 } 340 252 341 342 /*343 console.log("node=("+node.nodeName+","+node.nodeType+")");344 345 if(node.children.length == 0) //hasChildNodes())346 {347 console.log("No children so return");348 return "";349 }350 351 if(node.nodeName=='DIV')352 {353 console.log("Found a div");354 formatstring = formatstring + find_class(node);355 }356 357 for(var i = 0; i < node.children.length; i++)358 return recursiveTraverse(node.children[i], formatstring);359 360 361 return formatstring;362 }363 */364 365 253 function find_class(current) 366 254 { … … 696 584 console.log('function bind_all_sortables()'); 697 585 bind_template_sortable(); 698 //bind_table_sortable();699 //bind_tr_sortable();700 //bind_td_sortable();701 586 bind_choose_metadata_sortable(); 702 587 bind_link_sortable(); … … 714 599 { 715 600 console.log('function bind_tables()'); 716 //$('.tr').resize_tables($(this)); //equalHeights();717 601 718 602 $('#sectionHeader').click(function () { … … 728 612 $(".td-div").resizable({ 729 613 alsoResize: 'parent', 730 //containment: 'parent',731 614 handles: 'w,e', 732 615 stop: function(event, ui) { 733 616 console.log('Resize table on stop'); 734 617 resize_tables($(this)); 735 //$(this).parent().parent().equalHeights();736 618 }, }); 737 738 //$(".droppable").sortable({739 // 'cursor':'pointer',740 // 'tolerance': 'pointer',741 // 'items':'.column, .td-div',742 // 'placeholder':'placeholder'743 //});744 619 745 620 $(".droppable").droppable({ 746 621 accept: '.element_type_td', 747 622 tolerance: 'pointer', 748 activate: function(event, ui) { $(this).addClass("droppable_hl");}, // console.log("droppable activated")},749 deactivate: function(event, ui) { $(this).removeClass("droppable_hl"); }, // console.log("droppable deactivated")},623 activate: function(event, ui) { $(this).addClass("droppable_hl");}, 624 deactivate: function(event, ui) { $(this).removeClass("droppable_hl"); }, 750 625 drop: function(event, ui) { 751 //if ($(this).hasClass("ui-draggable"))752 //if (ui.helper.hasClass("ui-draggable"))753 //{754 626 var neverempty = document.createElement("div"); 755 627 neverempty.setAttribute("class","neverempty block"); … … 759 631 neverempty.appendChild(text); 760 632 var td = document.createElement("td"); 761 var div = document.createElement("div"); // class=\"td block\" title=\"td-div\"");633 var div = document.createElement("div"); 762 634 div.setAttribute("title","td-div"); 763 635 div.setAttribute("class","td-div block"); … … 775 647 bind_td_sortable(); 776 648 bind_block_mouseover(); 777 //bind_all_sortables();778 //}779 //else780 //{781 // console.log("Attempting to add");782 //$(this).appendTo(ui.draggable[0]);783 // $(this).prepend(ui.draggable[0]);784 //$(ui.draggable[0]).appendTo($(this));785 //}786 649 } 787 650 }); … … 807 670 } 808 671 809 //console.log('function replace_with(item, me)');810 672 item.replaceWith(me); //'<div class="element element-txt">This text box has been added!</div>'); 811 //item.find('select').attr("value", CURRENT_SELECT_VALUE);812 813 814 //if(select != null){815 // console.log("Attempting to select " + CURRENT_SELECT_VALUE);816 // console.log("length = "+select.length);817 // for(index = 0; index < select.length; index++) {818 // console.log(select[index].value);819 // if(select[index].value == CURRENT_SELECT_VALUE)820 // console.log("Found "+CURRENT_SELECT_VALUE+" at index " + index);821 // select.selectedIndex = index;822 // }823 // }824 673 825 674 resize_tables(item); … … 830 679 function resize_tables(item) 831 680 { 832 //console.log('function resize_tables(item)');833 681 var max_height = 0; 834 682 (item.parents('.table')).each(function(index) { … … 858 706 //'nested':'.gsf:metadata' 859 707 stop: function(event, ui) { 860 //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>"); }861 708 if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_table')) { replace_with(ui.item, "<table class=\"table\" border=\"2\"></table>"); } 862 709 if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); } … … 884 731 'connectWith':'column'}); 885 732 886 //$('.column').sortable({887 // connectWith:['.column'],888 // placeholder: 'placeholder',889 // items:'td-div'890 //});891 892 893 //$('.column').sortable({894 // 'cursor':'pointer',895 // 'tolerance': 'pointer',896 // 'items':'.td-div',897 // 'placeholder':'placeholder',898 // 'connectWith':'.column'899 //'nested':'.gsf:metadata'900 //receive: function(event, ui) { alert("Attempted to receive"); },901 //stop: function(event, ui) {902 // if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }903 904 //});905 906 //console.log('function bind_td_sortable()');907 733 $('.td-div').sortable({ 908 734 'cursor':'pointer', … … 910 736 'items':'.gsf_metadata, .gsf_choose_metadata, .gsf_link, .gsf_switch', 911 737 'placeholder':'placeholder', 912 //'connectWith':'.td-div',913 //'nested':'.gsf:metadata'914 738 receive: function(event, ui) { alert("Attempted to receive"); }, 915 739 stop: function(event, ui) { … … 1089 913 var toggleContent = function(e) 1090 914 { 1091 //console.log('var toggleContent = function(e)');1092 915 console.log('parent: ' + $(this).html()); 1093 916 if ($(this).html() == '[+]'){ //targetContent.css('display') == 'none') { 1094 //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideDown(300);1095 //$(this).parents().children(".block,.table").stopPropagation().slideDown(300);1096 //var x = $(this).parent().parent().parent().parent().parent();1097 //var y = $(this).parent().parent().parent().parent().parent().children(".block,.table");1098 //var z = $(this).closest(".block").children(".table, .block");1099 917 $(this).closest(".block").children(".table, .block").slideDown(300); 1100 918 $(this).html('[-]'); … … 1102 920 $(this).addClass("ui-icon-minusthick"); 1103 921 } else { 1104 //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideUp(300);1105 //$(this).parents().children(".block,.table").slideUp(300);1106 922 $(this).closest(".block").children(".table, .block").slideUp(300); 1107 923 $(this).html('[+]');
Note:
See TracChangeset
for help on using the changeset viewer.