[22516] | 1 |
|
---|
| 2 | console.log("Loading gui_div.js\n");
|
---|
| 3 |
|
---|
[24202] | 4 | /* DOCUMENT SPECIFIC FUNCTIONS */
|
---|
[23312] | 5 |
|
---|
[24202] | 6 | function displayTOC(checkbox)
|
---|
| 7 | {
|
---|
| 8 | if (checkbox.checked == true)
|
---|
| 9 | {
|
---|
| 10 | console.log("Show the TOC!");
|
---|
| 11 | displaySideBar(true);
|
---|
| 12 | $("#tableOfContents").css("display", "block");
|
---|
| 13 | }
|
---|
| 14 | else
|
---|
| 15 | {
|
---|
| 16 | console.log("Hide the TOC!");
|
---|
| 17 | $("#tableOfContents").css("display", "none");
|
---|
| 18 | if ($("#coverImage").css("display") == "none")
|
---|
| 19 | displaySideBar(false);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | return;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | function displayBookCover(checkbox)
|
---|
| 26 | {
|
---|
| 27 | if (checkbox.checked == true)
|
---|
| 28 | {
|
---|
| 29 | console.log("Show the book cover!");
|
---|
| 30 | displaySideBar(true);
|
---|
| 31 | $("#coverImage").css("display", "block");
|
---|
| 32 | }
|
---|
| 33 | else
|
---|
| 34 | {
|
---|
| 35 | console.log("Hide the book cover!");
|
---|
| 36 | $("#coverImage").css("display", "none");
|
---|
| 37 | if ($("#tableOfContents").css("display") == "none")
|
---|
| 38 | displaySideBar(false);
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | return;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | function displaySideBar(toggle)
|
---|
| 45 | {
|
---|
| 46 | if (toggle == true)
|
---|
| 47 | {
|
---|
| 48 | console.log("Show the sidebar!");
|
---|
| 49 | $("#rightSidebar").css("display", "block");
|
---|
| 50 | }
|
---|
| 51 | else
|
---|
| 52 | {
|
---|
| 53 | console.log("Hide the sidebar!");
|
---|
| 54 | $("#rightSidebar").css("display", "none");
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | return;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | function checkDocumentRadio()
|
---|
| 61 | {
|
---|
| 62 | var selection = $('input[name="documentChanges"]'); //document.quiz.colour;
|
---|
| 63 |
|
---|
| 64 | for (i=0; i<selection.length; i++)
|
---|
| 65 |
|
---|
| 66 | if (selection[i].checked == true)
|
---|
| 67 | return selection[i].value;
|
---|
| 68 |
|
---|
| 69 | return "this";
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | function saveDocumentChanges()
|
---|
| 73 | {
|
---|
| 74 | console.log("Saving changes to "+checkDocumentRadio());
|
---|
[24243] | 75 | console.log("TOC="+$('input[name="TOC"]').attr('checked'));
|
---|
| 76 | console.log("Cover Image="+$('input[name="bookCover"]').attr('checked'));
|
---|
[24202] | 77 |
|
---|
[24243] | 78 | var myurl = document.URL;
|
---|
[24202] | 79 |
|
---|
[24243] | 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", "&");
|
---|
[24202] | 85 |
|
---|
[24869] | 86 | var post_url = "http://localhost:8383/greenstone3/dev?a=f&sa=saveDocument&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service;
|
---|
[24243] | 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 | }
|
---|
| 95 |
|
---|
[24202] | 96 | /* FUNCTIONS FOR FORMAT EDITING */
|
---|
| 97 |
|
---|
[24869] | 98 | // Ensures that a change to a text field is remembered
|
---|
[23551] | 99 | function onTextChange(item, text)
|
---|
| 100 | {
|
---|
[24136] | 101 | console.log("I have set "+item+".value to "+text);
|
---|
[23551] | 102 | item.setAttribute("value",text);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[24869] | 105 | // Ensures that a change to a select field is remembered
|
---|
[24136] | 106 | function onSelectChange(item)
|
---|
| 107 | {
|
---|
| 108 | console.log("I have set "+item.value+".selected to selected");
|
---|
| 109 | for (var i=0; i<item.options.length; i++)
|
---|
| 110 | {
|
---|
| 111 | if(item.selectedIndex == i)
|
---|
| 112 | item.options[i].setAttribute("selected", "selected");
|
---|
| 113 | else
|
---|
| 114 | item.options[i].removeAttribute("selected");
|
---|
| 115 | }
|
---|
| 116 | //item.options[item.selectedIndex].selected = "selected";
|
---|
| 117 | //item.setAttribute("selected","selected");
|
---|
| 118 | }
|
---|
[23551] | 119 |
|
---|
[23489] | 120 | function getSubstring(str, first, last)
|
---|
| 121 | {
|
---|
| 122 | var first_index = str.indexOf(first)+first.length+1;
|
---|
| 123 | var last_index = str.indexOf(last, first_index);
|
---|
| 124 |
|
---|
[24243] | 125 | if(last_index == -1)
|
---|
| 126 | last_index = str.length;
|
---|
| 127 |
|
---|
[23489] | 128 | var substring = str.substring(first_index, last_index);
|
---|
| 129 |
|
---|
| 130 | console.log(substring);
|
---|
| 131 |
|
---|
| 132 | return substring;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | function getFormatStatement()
|
---|
| 136 | {
|
---|
| 137 | var formatDiv = document.getElementById('formatStatement');
|
---|
| 138 | var formatStatement = innerXHTML(formatDiv);
|
---|
| 139 | return formatStatement;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[24202] | 142 | function checkClassifierRadio()
|
---|
| 143 | {
|
---|
| 144 | var selection = $('input[name="classifiers"]'); //document.quiz.colour;
|
---|
| 145 |
|
---|
| 146 | for (i=0; i<selection.length; i++)
|
---|
| 147 |
|
---|
| 148 | if (selection[i].checked == true)
|
---|
| 149 | return selection[i].value;
|
---|
| 150 |
|
---|
| 151 | return "this";
|
---|
| 152 |
|
---|
| 153 | }
|
---|
| 154 |
|
---|
[23489] | 155 | function updateFormatStatement()
|
---|
| 156 | {
|
---|
| 157 | var formatStatement = getFormatStatement();
|
---|
| 158 |
|
---|
[24202] | 159 | var thisOrAll = checkClassifierRadio();
|
---|
| 160 | console.log(thisOrAll);
|
---|
[23489] | 161 | var myurl = document.URL;
|
---|
| 162 |
|
---|
| 163 | var collection_name = getSubstring(myurl, "&c", "&");
|
---|
[24202] | 164 | var service_name = getSubstring(myurl, "&s", "&");
|
---|
| 165 |
|
---|
| 166 | if(thisOrAll == "all")
|
---|
| 167 | service_name = "AllClassifierBrowse";
|
---|
| 168 |
|
---|
[23489] | 169 | var classifier_name = null;
|
---|
| 170 |
|
---|
| 171 | if(service_name == "ClassifierBrowse")
|
---|
| 172 | classifier_name = getSubstring(myurl, "&cl", "&");
|
---|
| 173 |
|
---|
[24869] | 174 | var post_url = "http://localhost:8383/greenstone3/dev?a=f&sa=update&c=" + collection_name +"&s=" + service_name;
|
---|
[23489] | 175 |
|
---|
[23405] | 176 | if(classifier_name != null)
|
---|
| 177 | post_url = post_url + "&cl=" + classifier_name;
|
---|
| 178 |
|
---|
| 179 | $.post(post_url, {data: formatStatement}, function(data) {
|
---|
[23336] | 180 | //$('.result').innerHTML = data; //html(data);
|
---|
[24202] | 181 |
|
---|
| 182 | // 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.
|
---|
| 183 | console.log("Successfully updated");
|
---|
| 184 | //console.log(data);
|
---|
[23333] | 185 | }, 'html');
|
---|
[23489] | 186 | }
|
---|
[23333] | 187 |
|
---|
[23489] | 188 | function saveFormatStatement()
|
---|
| 189 | {
|
---|
| 190 | var formatStatement = getFormatStatement();
|
---|
[24202] | 191 | var thisOrAll = checkClassifierRadio();
|
---|
[23489] | 192 |
|
---|
| 193 | var myurl = document.URL;
|
---|
| 194 |
|
---|
| 195 | var collection_name = getSubstring(myurl, "&c", "&");
|
---|
| 196 | var service_name = getSubstring(myurl, "&s", "&");
|
---|
| 197 | var classifier_name = null;
|
---|
| 198 |
|
---|
[24202] | 199 | if(thisOrAll == "all")
|
---|
| 200 | service_name = "AllClassifierBrowse";
|
---|
| 201 |
|
---|
[23489] | 202 | if(service_name == "ClassifierBrowse")
|
---|
| 203 | classifier_name = getSubstring(myurl, "&cl", "&");
|
---|
| 204 |
|
---|
[24869] | 205 | var post_url = "http://localhost:8383/greenstone3/dev?a=f&sa=save&c=" + collection_name +"&s=" + service_name;
|
---|
[23489] | 206 |
|
---|
| 207 | if(classifier_name != null)
|
---|
| 208 | post_url = post_url + "&cl=" + classifier_name;
|
---|
| 209 |
|
---|
| 210 | $.post(post_url, {data: formatStatement}, function(data) {
|
---|
[24202] | 211 | // 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.
|
---|
| 212 | console.log("Successfully saved");
|
---|
[23489] | 213 | }, 'html');
|
---|
| 214 | }
|
---|
| 215 |
|
---|
[24202] | 216 | function getXSLT(classname)
|
---|
| 217 | {
|
---|
| 218 | var myurl = document.URL;
|
---|
| 219 |
|
---|
| 220 | var collection_name = getSubstring(myurl, "&c", "&");
|
---|
| 221 | var document_id = getSubstring(myurl, "&d", "&");
|
---|
| 222 | var document_type = getSubstring(myurl, "&dt", "&");
|
---|
| 223 | var prev_action = getSubstring(myurl, "&p.a", "&");
|
---|
| 224 | var prev_service = getSubstring(myurl, "&p.s", "&");
|
---|
| 225 |
|
---|
[24869] | 226 | var post_url = "http://localhost:8383/greenstone3/dev?a=d&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service + "&o=skinandlib";
|
---|
[24202] | 227 |
|
---|
| 228 | $.post(post_url, {data: classname}, function(data) {
|
---|
| 229 | console.log("Success, we have received data");
|
---|
| 230 | classname = "." + classname;
|
---|
[24243] | 231 | console.log(classname);
|
---|
[24202] | 232 | var content = $( data ).find(classname);
|
---|
| 233 | console.log(content.xml());
|
---|
| 234 | $("#XSLTcode").val(content.xml());
|
---|
| 235 | }, 'xml');
|
---|
| 236 | }
|
---|
| 237 |
|
---|
[23312] | 238 | function traverse(node, formatstring)
|
---|
| 239 | {
|
---|
| 240 |
|
---|
| 241 | if(node.nodeName=='DIV')
|
---|
| 242 | {
|
---|
| 243 | console.log("Found a div" +node.nodeName+","+node.nodeType);
|
---|
| 244 | formatstring = formatstring + find_class(node);
|
---|
| 245 | console.log(formatstring);
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | var children = $(node).children();
|
---|
| 249 | for(var i=0; i < children.length; i++)
|
---|
| 250 | formatstring = formatstring + traverse(children[i], formatstring);
|
---|
| 251 |
|
---|
| 252 | return formatstring;
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | function find_class(current)
|
---|
| 256 | {
|
---|
| 257 | var classes = current.className.split(' ');
|
---|
| 258 | var none = "";
|
---|
| 259 | for(var i = 0; i < classes.length; i++)
|
---|
| 260 | {
|
---|
| 261 | switch(classes[i])
|
---|
| 262 | {
|
---|
| 263 | case 'gsf_template':
|
---|
| 264 | return create_gsf_template(current);
|
---|
| 265 | default:
|
---|
| 266 | {
|
---|
| 267 | console.log("Class not found");
|
---|
| 268 | return none;
|
---|
| 269 | }
|
---|
| 270 | }
|
---|
| 271 | }
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | function create_gsf_template(current)
|
---|
| 275 | {
|
---|
| 276 | // find match text which is an input with class match
|
---|
| 277 | var match = $(current).find('.match')[0].value;
|
---|
| 278 | console.log(match);
|
---|
| 279 |
|
---|
| 280 | // find mode text which is an input with class mode
|
---|
| 281 | var mode = $(current).find('.mode')[0].value;
|
---|
| 282 | console.log(mode);
|
---|
| 283 |
|
---|
| 284 | // "<gsf:template match=\"classifierNode\" mode=\"horizontal\">"
|
---|
| 285 | var gsf = "<gsf:template match=\"" + match + "\"";
|
---|
| 286 | if(mode != "vertical")
|
---|
| 287 | gsf = gsf + " mode=\"" + mode + "\"";
|
---|
| 288 | gsf = gsf + ">";
|
---|
| 289 |
|
---|
| 290 | return gsf;
|
---|
| 291 |
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | /*
|
---|
[23276] | 295 | $("#iframe").ready(function(){
|
---|
| 296 | console.log("iframe is ready ...");
|
---|
| 297 | var iframe = document.getElementById('iframe');
|
---|
| 298 | var iframe_document = iframe.document;
|
---|
| 299 |
|
---|
| 300 | if(iframe.contentDocument)
|
---|
| 301 | {
|
---|
| 302 | iframe_document = iframe.contentDocument; // For NS6
|
---|
| 303 | console.log("Chose content document");
|
---|
| 304 | }
|
---|
| 305 | else if(iframe.contentWindow)
|
---|
| 306 | {
|
---|
| 307 | iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
|
---|
| 308 | console.log("Chose content window");
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | console.log(iframe_document.documentElement.innerHTML); //document.documentElement.outerHTML
|
---|
| 312 |
|
---|
| 313 | $(iframe_document.documentElement.innerHTML).find('a').each(function() {
|
---|
| 314 | console.log("data "+$(this).data('href'));
|
---|
| 315 | console.log("getAttribute "+$(this).getAttribute('href'));
|
---|
| 316 | console.log("attr "+$(this).attr('href'));
|
---|
| 317 | console.log("this.href "+this.href);
|
---|
| 318 | var original = this.href; //$(this).attr('href');
|
---|
| 319 | // check if greenstone link ie. starts with format
|
---|
| 320 | //var original = $(this).data('href');
|
---|
| 321 | var modified = original.toString().concat("&excerptid=gs_content");
|
---|
| 322 | console.log(modified);
|
---|
| 323 | this.href = modified;
|
---|
| 324 | //$(this).attr('href',modified);
|
---|
| 325 | //$(this).data('href', modified);
|
---|
| 326 | //console.log($(this).attr('href'));
|
---|
| 327 | console.log("data "+$(this).data('href'));
|
---|
| 328 | console.log("getAttribute "+$(this).getAttribute('href'));
|
---|
| 329 | console.log("attr "+$(this).attr('href'));
|
---|
| 330 | console.log("this.href "+this.href);
|
---|
| 331 | console.log("**********");
|
---|
| 332 |
|
---|
| 333 | });
|
---|
| 334 | }); */
|
---|
[23298] | 335 | /*
|
---|
| 336 | function loadXMLDoc()
|
---|
| 337 | {
|
---|
| 338 | if (window.XMLHttpRequest)
|
---|
| 339 | {// code for IE7+, Firefox, Chrome, Opera, Safari
|
---|
| 340 | xmlhttp=new XMLHttpRequest();
|
---|
| 341 | }
|
---|
| 342 | else
|
---|
| 343 | {// code for IE6, IE5
|
---|
| 344 | xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | xmlhttp.onreadystatechange=function()
|
---|
| 348 | {
|
---|
| 349 | console.log("state changed to " + xmlhttp.readyState);
|
---|
| 350 | console.log("status is " + xmlhttp.status);
|
---|
| 351 | if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
---|
| 352 | {
|
---|
| 353 | console.log("get code");
|
---|
| 354 | console.log(xmlhttp.responseText);
|
---|
| 355 | document.getElementById("gs_content").innerHTML=xmlhttp.responseText;
|
---|
| 356 | }
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | xmlhttp.open("GET","http://localhost:8080/greenstone3/format?a=b&rt=s&s=ClassifierBrowse&c=simpleht&cl=CL1&excerptid=gs_content",true);
|
---|
| 360 | //xmlhttp.open("GET","http://www.cs.waikato.ac.nz",true);
|
---|
| 361 | //xmlhttp.open("GET","http://wand.net.nz/~sjb48/index.html",true);
|
---|
| 362 | xmlhttp.send();
|
---|
| 363 | }
|
---|
| 364 | */
|
---|
[22474] | 365 | $(document).ready(function(){
|
---|
| 366 |
|
---|
[22516] | 367 | console.log("Document ready function\n");
|
---|
[24417] | 368 |
|
---|
[24869] | 369 | CURRENT_SELECT_VALUE = ""; //global - gets set by ui.draggable
|
---|
[23135] | 370 |
|
---|
[24202] | 371 | /* DOCUMENT SPECIFIC FUNCTIONS */
|
---|
| 372 |
|
---|
| 373 | $('.sectionHeader').click(function () {
|
---|
| 374 | console.log('section Header click *');
|
---|
| 375 | getXSLT("sectionHeader");
|
---|
| 376 | return false; //don't event bubble
|
---|
| 377 | });
|
---|
| 378 |
|
---|
| 379 | $('.sectionContainer').click(function () {
|
---|
| 380 | console.log('section Container click *');
|
---|
| 381 | getXSLT("sectionContainer");
|
---|
| 382 | return false; // don't event bubble
|
---|
| 383 | });
|
---|
[24417] | 384 |
|
---|
| 385 | var collection = "";
|
---|
| 386 |
|
---|
| 387 | var regex = new RegExp("[?&]c=");
|
---|
| 388 | var matches = regex.exec(document.URL);
|
---|
| 389 | if(matches != null)
|
---|
| 390 | {
|
---|
| 391 | var startIndex = matches.index;
|
---|
| 392 | var endIndex = document.URL.indexOf("&", startIndex + 1);
|
---|
| 393 |
|
---|
| 394 | if(endIndex == -1)
|
---|
| 395 | {
|
---|
| 396 | endIndex = document.URL.length;
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 | collection = document.URL.substring(startIndex, endIndex);
|
---|
| 400 | }
|
---|
[24202] | 401 |
|
---|
[24420] | 402 | //Retrieve the collection metadataset using ajax
|
---|
[24417] | 403 | $.ajax
|
---|
| 404 | ({
|
---|
| 405 | type: "GET",
|
---|
| 406 | url: "?a=g&s=CoverageMetadataRetrieve&o=xml&rt=r&c=" + collection,
|
---|
| 407 | success: function(data)
|
---|
| 408 | {
|
---|
[24420] | 409 | var str = "<select name=\"meta_select\" onChange=\"onSelectChange(this)\">";
|
---|
| 410 |
|
---|
| 411 | var selectorArea = document.getElementById("metadataSelector");
|
---|
[24417] | 412 | var metadataSets = data.getElementsByTagName("metadataSet");
|
---|
| 413 | for(var i = 0; i < metadataSets.length; i++)
|
---|
| 414 | {
|
---|
| 415 | var metadata = metadataSets[i].getElementsByTagName("metadata");
|
---|
| 416 | for(var j = 0; j < metadata.length; j++)
|
---|
| 417 | {
|
---|
[24420] | 418 | var metaValue = metadataSets[i].getAttribute("name") + "." + metadata[j].getAttribute("name");
|
---|
| 419 | str += "<option value=\"" + metaValue + "\">" + metaValue + "</option>";
|
---|
[24417] | 420 | }
|
---|
| 421 | }
|
---|
[24420] | 422 |
|
---|
| 423 | str += "</select>";
|
---|
| 424 |
|
---|
| 425 | selectorArea.innerHTML = str;
|
---|
| 426 | gsf_metadata_element = str;
|
---|
[24417] | 427 | }
|
---|
| 428 | });
|
---|
[24869] | 429 |
|
---|
[24900] | 430 | $.ui.plugin.add("draggable", "cursor", {
|
---|
| 431 | start: function(event, ui) {
|
---|
| 432 | var t = $('body'), o = $(this).data('draggable').options;
|
---|
| 433 | if (t.css("cursor")) o._cursor = t.css("cursor");
|
---|
| 434 | t.css("cursor", o.cursor);
|
---|
| 435 | },
|
---|
| 436 | stop: function(event, ui) {
|
---|
| 437 | var o = $(this).data('draggable').options;
|
---|
| 438 | if (o._cursor) $('body').css("cursor", o._cursor);
|
---|
| 439 | }
|
---|
| 440 | });
|
---|
| 441 |
|
---|
[24869] | 442 | $.ui.draggable.prototype._createHelper = function(event) {
|
---|
| 443 |
|
---|
| 444 | var o = this.options;
|
---|
| 445 | var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
|
---|
| 446 |
|
---|
| 447 | var select = $(this.element).find('select');
|
---|
| 448 | var value = select.attr('value');
|
---|
| 449 | console.log("Found "+value+" in helper");
|
---|
| 450 | CURRENT_SELECT_VALUE = value;
|
---|
| 451 | helper.find('select').attr('value', value);
|
---|
| 452 |
|
---|
| 453 | if(!helper.parents('body').length)
|
---|
| 454 | helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
|
---|
| 455 |
|
---|
| 456 | if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
|
---|
| 457 | helper.css("position", "absolute");
|
---|
| 458 |
|
---|
| 459 | return helper;
|
---|
| 460 |
|
---|
| 461 | };
|
---|
[24420] | 462 |
|
---|
[24442] | 463 | $.ui.sortable.prototype._removeCurrentsFromItems = function() {
|
---|
| 464 | //console.log("IN _removeCurrentsFromItems FUNCTION");
|
---|
| 465 | //console.log("this = " + this.currentItem[0].getAttribute('class'));
|
---|
| 466 | var list = this.currentItem.find(":data(sortable-item)");
|
---|
| 467 |
|
---|
| 468 | var i = 0;
|
---|
| 469 | while (i<this.items.length) {
|
---|
| 470 | var found_match = false;
|
---|
| 471 | for (var j=0; j<list.length; j++) {
|
---|
| 472 | if(this.items[i])
|
---|
| 473 | {
|
---|
| 474 | if(list[j] == this.items[i].item[0]) {
|
---|
| 475 | //console.log("Item to splice = " + this.items[i].item[0].getAttribute('class'));
|
---|
| 476 | this.items.splice(i,1);
|
---|
| 477 | found_match = true;
|
---|
| 478 | break;
|
---|
| 479 | }
|
---|
| 480 | }
|
---|
| 481 | };
|
---|
| 482 | if (!found_match)
|
---|
| 483 | i++;
|
---|
| 484 | else
|
---|
| 485 | break;
|
---|
| 486 | }
|
---|
| 487 | };
|
---|
| 488 |
|
---|
[24420] | 489 | $.ui.plugin.add("draggable", "connectToSortable", {
|
---|
| 490 | start: function(event, ui) {
|
---|
| 491 | //console.log("FUNCTION start draggable connectToSortable");
|
---|
| 492 | var inst = $(this).data("draggable"), o = inst.options,
|
---|
| 493 | uiSortable = $.extend({}, ui, { item: inst.element });
|
---|
| 494 | inst.sortables = [];
|
---|
| 495 | $(o.connectToSortable).each(function() {
|
---|
| 496 | var sortable = $.data(this, 'sortable');
|
---|
| 497 | if (sortable && !sortable.options.disabled) {
|
---|
| 498 | inst.sortables.push({
|
---|
| 499 | instance: sortable,
|
---|
| 500 | shouldRevert: sortable.options.revert
|
---|
| 501 | });
|
---|
| 502 | sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
|
---|
| 503 | sortable._trigger("activate", event, uiSortable);
|
---|
| 504 | }
|
---|
| 505 | });
|
---|
[24417] | 506 |
|
---|
[24420] | 507 | },
|
---|
| 508 | stop: function(event, ui) {
|
---|
| 509 |
|
---|
| 510 | //console.log("FUNCTION stop draggable connectToSortable");
|
---|
| 511 | //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
|
---|
| 512 | var inst = $(this).data("draggable"),
|
---|
| 513 | uiSortable = $.extend({}, ui, { item: inst.element });
|
---|
| 514 |
|
---|
| 515 | $.each(inst.sortables, function() {
|
---|
| 516 | if(this.instance.isOver) {
|
---|
| 517 |
|
---|
| 518 | this.instance.isOver = 0;
|
---|
| 519 |
|
---|
| 520 | inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
|
---|
| 521 | this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
|
---|
| 522 |
|
---|
| 523 | //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
|
---|
| 524 | if(this.shouldRevert) this.instance.options.revert = true;
|
---|
| 525 |
|
---|
| 526 | //Trigger the stop of the sortable
|
---|
| 527 | //console.log("Draggable tells sortable to stop");
|
---|
| 528 | this.instance._mouseStop(event);
|
---|
| 529 |
|
---|
| 530 | this.instance.options.helper = this.instance.options._helper;
|
---|
| 531 |
|
---|
| 532 | //If the helper has been the original item, restore properties in the sortable
|
---|
| 533 | if(inst.options.helper == 'original')
|
---|
| 534 | this.instance.currentItem.css({ top: 'auto', left: 'auto' });
|
---|
| 535 |
|
---|
| 536 | } else {
|
---|
| 537 | this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
|
---|
| 538 | this.instance._trigger("deactivate", event, uiSortable);
|
---|
| 539 | }
|
---|
| 540 |
|
---|
| 541 | });
|
---|
| 542 |
|
---|
| 543 | },
|
---|
| 544 | drag: function(event, ui) {
|
---|
| 545 | //console.log("FUNCTION drag draggable connectToSortable");
|
---|
| 546 |
|
---|
| 547 | var inst = $(this).data("draggable"), self = this;
|
---|
| 548 |
|
---|
| 549 | var checkPos = function(o) {
|
---|
| 550 | var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
|
---|
| 551 | var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
|
---|
| 552 | var itemHeight = o.height, itemWidth = o.width;
|
---|
| 553 | var itemTop = o.top, itemLeft = o.left;
|
---|
| 554 |
|
---|
| 555 | return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
|
---|
| 556 | };
|
---|
| 557 |
|
---|
| 558 | var intersecting_items = new Array();
|
---|
| 559 |
|
---|
| 560 | $.each(inst.sortables, function(i) {
|
---|
| 561 |
|
---|
| 562 | //Copy over some variables to allow calling the sortable's native _intersectsWith
|
---|
| 563 | this.instance.positionAbs = inst.positionAbs;
|
---|
| 564 | this.instance.helperProportions = inst.helperProportions;
|
---|
| 565 | this.instance.offset.click = inst.offset.click;
|
---|
| 566 |
|
---|
| 567 | if(this.instance._intersectsWith(this.instance.containerCache)) {
|
---|
| 568 |
|
---|
| 569 | //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
|
---|
| 570 | //if(!this.instance.isOver) {
|
---|
| 571 |
|
---|
| 572 | //console.log('Line 1113');
|
---|
| 573 |
|
---|
| 574 | // this.instance.isOver = 1;
|
---|
| 575 |
|
---|
| 576 | intersecting_items.push(this.instance); // sam
|
---|
| 577 | //} //sam
|
---|
| 578 |
|
---|
| 579 | //Now we fake the start of dragging for the sortable instance,
|
---|
| 580 | //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
|
---|
| 581 | //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
|
---|
| 582 | //sam this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
|
---|
| 583 | //sam this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
|
---|
| 584 | //sam this.instance.options.helper = function() { return ui.helper[0]; };
|
---|
| 585 |
|
---|
| 586 | //sam event.target = this.instance.currentItem[0];
|
---|
| 587 | //sam this.instance._mouseCapture(event, true);
|
---|
| 588 | //sam this.instance._mouseStart(event, true, true);
|
---|
| 589 |
|
---|
| 590 | //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
|
---|
| 591 | //sam this.instance.offset.click.top = inst.offset.click.top;
|
---|
| 592 | //sam this.instance.offset.click.left = inst.offset.click.left;
|
---|
| 593 | //sam this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
|
---|
| 594 | //sam this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
|
---|
| 595 |
|
---|
| 596 | //sam inst._trigger("toSortable", event);
|
---|
| 597 | //sam inst.dropped = this.instance.element; //draggable revert needs that
|
---|
| 598 | //hack so receive/update callbacks work (mostly)
|
---|
| 599 | //sam inst.currentItem = inst.element;
|
---|
| 600 | //sam this.instance.fromOutside = inst;
|
---|
| 601 |
|
---|
| 602 | //sam brace
|
---|
| 603 |
|
---|
| 604 | //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
|
---|
| 605 | //sam if(this.instance.currentItem) this.instance._mouseDrag(event);
|
---|
| 606 |
|
---|
| 607 | } else {
|
---|
| 608 |
|
---|
| 609 | //If it doesn't intersect with the sortable, and it intersected before,
|
---|
| 610 | //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
|
---|
| 611 | if(this.instance.isOver) {
|
---|
| 612 |
|
---|
| 613 | console.log("UNSETTING ISOVER");
|
---|
| 614 | console.log("ON ITEM="+this.instance.currentItem[0].getAttribute('class'))
|
---|
| 615 | this.instance.isOver = 0;
|
---|
| 616 | this.instance.cancelHelperRemoval = true;
|
---|
| 617 |
|
---|
| 618 | //Prevent reverting on this forced stop
|
---|
| 619 | this.instance.options.revert = false;
|
---|
| 620 |
|
---|
| 621 | // The out event needs to be triggered independently
|
---|
| 622 | this.instance._trigger('out', event, this.instance._uiHash(this.instance));
|
---|
| 623 |
|
---|
| 624 | this.instance._mouseStop(event, true);
|
---|
| 625 | this.instance.options.helper = this.instance.options._helper;
|
---|
| 626 |
|
---|
| 627 | //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
|
---|
| 628 | //console.log("DO WE GET HERE?");
|
---|
| 629 | this.instance.currentItem.remove();
|
---|
| 630 | if(this.instance.placeholder) this.instance.placeholder.remove();
|
---|
| 631 |
|
---|
| 632 | inst._trigger("fromSortable", event);
|
---|
| 633 | inst.dropped = false; //draggable revert needs that
|
---|
| 634 |
|
---|
| 635 | }
|
---|
| 636 |
|
---|
| 637 | }
|
---|
| 638 | });
|
---|
| 639 |
|
---|
| 640 | //sam
|
---|
| 641 | //console.log("Contents of intersecting_items");
|
---|
| 642 | var innermostContainer = null, innermostIndex = null;
|
---|
| 643 | for (i=0;i<intersecting_items.length;i++)
|
---|
| 644 | {
|
---|
| 645 | //console.log('ITEM: '+intersecting_items[i].element[0].getAttribute('class'));
|
---|
| 646 |
|
---|
| 647 | if(innermostContainer && $.ui.contains(intersecting_items[i].element[0], innermostContainer.element[0]))
|
---|
| 648 | continue;
|
---|
| 649 |
|
---|
| 650 | innermostContainer = intersecting_items[i];
|
---|
| 651 | innermostIndex = i;
|
---|
| 652 |
|
---|
| 653 | }
|
---|
| 654 |
|
---|
| 655 | for (i=0;i<intersecting_items.length;i++)
|
---|
| 656 | {
|
---|
| 657 | if(intersecting_items[i] != innermostContainer)
|
---|
| 658 | if(intersecting_items[i].isOver) {
|
---|
| 659 |
|
---|
| 660 | console.log("UNSETTING ISOVER");
|
---|
| 661 | console.log("ON ITEM="+intersecting_items[i].currentItem[0].getAttribute('class'))
|
---|
| 662 | intersecting_items[i].isOver = 0;
|
---|
| 663 | intersecting_items[i].cancelHelperRemoval = true;
|
---|
| 664 |
|
---|
| 665 | //Prevent reverting on this forced stop
|
---|
| 666 | intersecting_items[i].options.revert = false;
|
---|
| 667 |
|
---|
| 668 | // The out event needs to be triggered independently
|
---|
| 669 | intersecting_items[i]._trigger('out', event, intersecting_items[i]._uiHash(intersecting_items[i]));
|
---|
| 670 |
|
---|
| 671 | intersecting_items[i]._mouseStop(event, true);
|
---|
| 672 | intersecting_items[i].options.helper = intersecting_items[i].options._helper;
|
---|
| 673 |
|
---|
| 674 | //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
|
---|
| 675 | //console.log("DO WE GET HERE?");
|
---|
| 676 | if(intersecting_items[i].currentItem) intersecting_items[i].currentItem.remove();
|
---|
| 677 | if(intersecting_items[i].placeholder) intersecting_items[i].placeholder.remove();
|
---|
| 678 |
|
---|
| 679 | inst._trigger("fromSortable", event);
|
---|
| 680 | inst.dropped = false; //draggable revert needs that
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | intersecting_items[i].isOver = 0;
|
---|
| 684 |
|
---|
| 685 | }
|
---|
| 686 |
|
---|
| 687 | if(innermostContainer && !innermostContainer.isOver)
|
---|
| 688 | {
|
---|
| 689 | console.log("INNER="+innermostContainer.element[0].getAttribute('class'));
|
---|
| 690 | console.log("SETTING ISOVER");
|
---|
| 691 | innermostContainer.isOver = 1;
|
---|
| 692 |
|
---|
| 693 | //Now we fake the start of dragging for the sortable instance,
|
---|
| 694 | //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
|
---|
| 695 | //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
|
---|
| 696 |
|
---|
| 697 | if(innermostContainer.currentItem) innermostContainer.currentItem.remove();
|
---|
| 698 | if(innermostContainer.placeholder) innermostContainer.placeholder.remove();
|
---|
| 699 |
|
---|
| 700 | innermostContainer.currentItem = $(self).clone().appendTo(innermostContainer.element).data("sortable-item", true);
|
---|
| 701 |
|
---|
| 702 | innermostContainer.options._helper = innermostContainer.options.helper; //Store helper option to later restore it
|
---|
| 703 | innermostContainer.options.helper = function() { return ui.helper[0]; };
|
---|
| 704 |
|
---|
| 705 | console.log("EVENT TARGET="+innermostContainer.currentItem[0].getAttribute('class'));
|
---|
| 706 | event.target = innermostContainer.currentItem[0];
|
---|
| 707 | innermostContainer._mouseCapture(event, true);
|
---|
| 708 | innermostContainer._mouseStart(event, true, true);
|
---|
| 709 |
|
---|
| 710 | //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
|
---|
| 711 | innermostContainer.offset.click.top = inst.offset.click.top;
|
---|
| 712 | innermostContainer.offset.click.left = inst.offset.click.left;
|
---|
| 713 | innermostContainer.offset.parent.left -= inst.offset.parent.left - innermostContainer.offset.parent.left;
|
---|
| 714 | innermostContainer.offset.parent.top -= inst.offset.parent.top - innermostContainer.offset.parent.top;
|
---|
| 715 |
|
---|
| 716 | inst._trigger("toSortable", event);
|
---|
| 717 | inst.dropped = innermostContainer.element; //draggable revert needs that
|
---|
| 718 | //hack so receive/update callbacks work (mostly)
|
---|
| 719 | inst.currentItem = inst.element;
|
---|
| 720 | innermostContainer.fromOutside = inst;
|
---|
| 721 |
|
---|
| 722 | //sam brace
|
---|
| 723 | }
|
---|
| 724 |
|
---|
| 725 | if(innermostContainer)
|
---|
| 726 | {
|
---|
| 727 | //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
|
---|
| 728 | if(innermostContainer.currentItem) innermostContainer._mouseDrag(event);
|
---|
| 729 | }
|
---|
| 730 |
|
---|
| 731 | }
|
---|
| 732 | });
|
---|
| 733 |
|
---|
[24136] | 734 | /*
|
---|
[23276] | 735 | var iframe = document.getElementById('iframe');
|
---|
| 736 | var iframe_document = iframe.document;
|
---|
| 737 |
|
---|
| 738 | if(iframe.contentDocument)
|
---|
| 739 | {
|
---|
| 740 | iframe_document = iframe.contentDocument; // For NS6
|
---|
| 741 | console.log("Chose content document");
|
---|
| 742 | }
|
---|
| 743 | else if(iframe.contentWindow)
|
---|
| 744 | {
|
---|
| 745 | iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
|
---|
| 746 | console.log("Chose content window");
|
---|
| 747 | }
|
---|
[23298] | 748 |
|
---|
| 749 | // Edit the hrefs in preview_html - search for <a href="format?a=b&rt=r&s=ClassifierBrowse&c=simpleht&cl=CL1.2">
|
---|
| 750 | var start_index = 0;
|
---|
| 751 | var end_index = 0;
|
---|
| 752 | while(start_index != -1)
|
---|
| 753 | {
|
---|
| 754 | start_index = preview_html.indexOf("href=\"format", start_index);
|
---|
| 755 | console.log("start index = " + start_index);
|
---|
| 756 | if(start_index != -1)
|
---|
| 757 | {
|
---|
| 758 | end_index = preview_html.indexOf("\">", start_index);
|
---|
| 759 | console.log("end_index = " + end_index);
|
---|
| 760 | a = preview_html.substring(0,end_index);
|
---|
| 761 | b = preview_html.substring(end_index);
|
---|
[23312] | 762 | preview_html = a.concat("&excerptid=results", b);
|
---|
[23298] | 763 | console.log(preview_html);
|
---|
[23312] | 764 | start_index = end_index + "&excerptid=results\">".length;
|
---|
[23298] | 765 | }
|
---|
| 766 | }
|
---|
| 767 |
|
---|
[23312] | 768 | // Split the html code in to three parts
|
---|
| 769 | var first_index = preview_html.indexOf("<ul id=\"results\"");
|
---|
| 770 | console.log("First index is "+first_index);
|
---|
| 771 | var second_index = preview_html.indexOf("</ul>", first_index) + "</ul>".length;
|
---|
| 772 | console.log("Second index is "+second_index);
|
---|
| 773 |
|
---|
| 774 | var first_half = preview_html.substring(0, first_index);
|
---|
| 775 | var iframe_code = preview_html.substring(first_index, second_index);
|
---|
| 776 | var second_half = preview_html.substring(second_index);
|
---|
| 777 |
|
---|
| 778 | //$('#my_categories').innerHTML = first_half.concat(second_half);
|
---|
| 779 | document.getElementById("my_categories").innerHTML = first_half.concat(second_half);
|
---|
| 780 |
|
---|
[23276] | 781 | // Put the content in the iframe
|
---|
| 782 | if(initialised_iframe == "false")
|
---|
| 783 | {
|
---|
| 784 | console.log("Initialised iframe with preview html");
|
---|
[23298] | 785 | console.log(preview_html);
|
---|
[23276] | 786 | iframe_document.open();
|
---|
[23312] | 787 | iframe_document.writeln(iframe_code); //.concat("&excerptid=gs_content"));
|
---|
[23276] | 788 | iframe_document.close();
|
---|
| 789 | initialised_iframe = "true";
|
---|
| 790 | }
|
---|
[24136] | 791 | */
|
---|
[23298] | 792 |
|
---|
| 793 | /*
|
---|
[23276] | 794 | $(iframe_document.documentElement.innerHTML).find('a').each(function() {
|
---|
| 795 | console.log("data "+$(this).data('href'));
|
---|
| 796 | console.log("getAttribute "+this.getAttribute('href'));
|
---|
| 797 | console.log("attr "+$(this).attr('href'));
|
---|
| 798 | console.log("this.href "+this.href);
|
---|
| 799 | var original = this.href; //$(this).attr('href');
|
---|
| 800 | // check if greenstone link ie. starts with format
|
---|
| 801 | //var original = $(this).data('href');
|
---|
| 802 | var modified = original.toString().concat("&excerptid=gs_content");
|
---|
| 803 | console.log("* *");
|
---|
| 804 | console.log(modified);
|
---|
| 805 | console.log("* *");
|
---|
| 806 | //this.href = modified;
|
---|
| 807 | //$(this).attr('href',modified);
|
---|
| 808 | //$(this).data('href', modified);
|
---|
| 809 | $(this).attr({ 'href': modified });
|
---|
| 810 | //console.log($(this).attr('href'));
|
---|
| 811 | console.log("data "+$(this).data('href'));
|
---|
| 812 | console.log("getAttribute "+this.getAttribute('href'));
|
---|
| 813 | console.log("attr "+$(this).attr('href'));
|
---|
| 814 | console.log("this.href "+this.href);
|
---|
| 815 | console.log("***********************");
|
---|
| 816 | });
|
---|
| 817 | */
|
---|
| 818 |
|
---|
[22598] | 819 | /******************************************/
|
---|
| 820 | /* DRAGGABLES */
|
---|
| 821 | /******************************************/
|
---|
[22516] | 822 |
|
---|
[23276] | 823 | $(".draggable_gsf_template").draggable({
|
---|
[23046] | 824 | cursor: 'crosshair',
|
---|
[22598] | 825 | connectToSortable: '#formatStatement',
|
---|
| 826 | helper: 'clone',
|
---|
| 827 | revert: 'invalid'
|
---|
| 828 | });
|
---|
| 829 |
|
---|
[23276] | 830 | $(".draggable_table").draggable({
|
---|
[23046] | 831 | cursor: 'crosshair',
|
---|
[22569] | 832 | connectToSortable: '.gsf_template',
|
---|
| 833 | helper: 'clone',
|
---|
[22598] | 834 | revert: 'invalid'
|
---|
| 835 | });
|
---|
[22516] | 836 |
|
---|
[23276] | 837 | $(".draggable_tr").draggable({
|
---|
[23046] | 838 | cursor: 'crosshair',
|
---|
[22598] | 839 | connectToSortable: '.gsf_table',
|
---|
| 840 | helper: 'clone',
|
---|
| 841 | revert: 'invalid'
|
---|
| 842 | })
|
---|
[22569] | 843 |
|
---|
[23276] | 844 | $(".draggable_td").draggable({
|
---|
[23046] | 845 | cursor: 'crosshair',
|
---|
[22676] | 846 | //connectToSortable: '.td',
|
---|
[22598] | 847 | helper: 'clone',
|
---|
| 848 | revert: 'invalid'
|
---|
| 849 | })
|
---|
| 850 |
|
---|
[23298] | 851 | $(".draggable_gsf_text").draggable({
|
---|
[23046] | 852 | cursor: 'crosshair',
|
---|
[23298] | 853 | connectToSortable: '.td-div, .gsf_when, .gsf_otherwise, .gsf_link, .gsf_choose_metadata, .gsf_default',
|
---|
[22598] | 854 | helper: 'clone',
|
---|
| 855 | revert: 'invalid'
|
---|
[22569] | 856 | });
|
---|
| 857 |
|
---|
[23255] | 858 | $(".draggable_gsf_choose_metadata").draggable({
|
---|
[23046] | 859 | cursor: 'crosshair',
|
---|
[23276] | 860 | connectToSortable: '.td-div, .gsf_link, .gsf_when, .gsf_otherwise',
|
---|
[22598] | 861 | helper: 'clone',
|
---|
| 862 | revert: 'invalid'
|
---|
| 863 | });
|
---|
| 864 |
|
---|
[23046] | 865 | //$(".element_type_gsf_metadata").draggable({
|
---|
[23135] | 866 | $(".draggable_gsf_metadata").draggable({
|
---|
[23046] | 867 | cursor: 'crosshair',
|
---|
[23276] | 868 | connectToSortable: '.gsf_choose_metadata, .gsf_when, .gsf_otherwise, .gsf_link, .td-div',
|
---|
[22598] | 869 | helper: 'clone',
|
---|
| 870 | revert: 'invalid'
|
---|
| 871 | });
|
---|
| 872 |
|
---|
[23135] | 873 | $(".draggable_gsf_link").draggable({
|
---|
[23046] | 874 | cursor: 'crosshair',
|
---|
[23276] | 875 | connectToSortable: '.td-div, .gsf_when, .gsf_otherwise, .gsf_link',
|
---|
[22598] | 876 | helper: 'clone',
|
---|
| 877 | revert: 'invalid'
|
---|
| 878 | });
|
---|
| 879 |
|
---|
| 880 | // switch, when, otherwise, icon
|
---|
[23255] | 881 | $(".draggable_gsf_switch").draggable({
|
---|
[23046] | 882 | cursor: 'crosshair',
|
---|
[23276] | 883 | connectToSortable: '.td-div, .gsf_link',
|
---|
[22598] | 884 | helper: 'clone',
|
---|
| 885 | revert: 'invalid'
|
---|
| 886 | });
|
---|
| 887 |
|
---|
[23255] | 888 | $(".draggable_gsf_when").draggable({
|
---|
[23046] | 889 | cursor: 'crosshair',
|
---|
[22598] | 890 | connectToSortable: '.gsf_switch',
|
---|
| 891 | helper: 'clone',
|
---|
| 892 | revert: 'invalid'
|
---|
| 893 | });
|
---|
| 894 |
|
---|
[23255] | 895 | $(".draggable_gsf_otherwise").draggable({
|
---|
[23046] | 896 | cursor: 'crosshair',
|
---|
[22598] | 897 | connectToSortable: '.gsf_switch',
|
---|
| 898 | helper: 'clone',
|
---|
| 899 | revert: 'invalid'
|
---|
| 900 | });
|
---|
| 901 |
|
---|
[23255] | 902 | $(".draggable_gsf_icon").draggable({
|
---|
[23046] | 903 | cursor: 'crosshair',
|
---|
[23298] | 904 | connectToSortable: '.td-div, .gsf_link, .gsf_choose, .gsf_when, .gsf_otherwise',
|
---|
[22598] | 905 | helper: 'clone',
|
---|
| 906 | revert: 'invalid'
|
---|
| 907 | });
|
---|
| 908 |
|
---|
[22516] | 909 |
|
---|
[22598] | 910 | /******************************************/
|
---|
| 911 | /* SORTABLES */
|
---|
| 912 | /******************************************/
|
---|
| 913 |
|
---|
[22933] | 914 | bind_td_sortable();
|
---|
[22598] | 915 | bind_all_sortables();
|
---|
| 916 |
|
---|
[22516] | 917 | $('#formatStatement').sortable({
|
---|
[22569] | 918 | cursor: 'pointer',
|
---|
| 919 | tolerance: 'pointer',
|
---|
| 920 | items: '.gsf_template',
|
---|
[22598] | 921 | placeholder:'placeholder',
|
---|
[22516] | 922 | //'nested':'div'
|
---|
[22598] | 923 | stop: function(event, ui) {
|
---|
| 924 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('css_gsf_template')) { replace_with(ui.item,gsf_template_element); }
|
---|
| 925 | }
|
---|
[22516] | 926 | });
|
---|
[22676] | 927 |
|
---|
| 928 | $('div.gsf_template').children(".block,.table").slideUp(300);
|
---|
[22598] | 929 | });
|
---|
| 930 |
|
---|
| 931 | /*******************************************************************************/
|
---|
| 932 |
|
---|
| 933 | function bind_all_sortables()
|
---|
| 934 | {
|
---|
[22768] | 935 | console.log('function bind_all_sortables()');
|
---|
[22598] | 936 | bind_template_sortable();
|
---|
| 937 | bind_choose_metadata_sortable();
|
---|
| 938 | bind_link_sortable();
|
---|
| 939 | bind_switch_sortable();
|
---|
| 940 | bind_when_sortable();
|
---|
| 941 | bind_otherwise_sortable();
|
---|
| 942 |
|
---|
[22676] | 943 | bind_tables();
|
---|
| 944 |
|
---|
[22598] | 945 | bind_block_mouseover();
|
---|
| 946 | bind_minmax_remove();
|
---|
| 947 | }
|
---|
| 948 |
|
---|
[22676] | 949 | function bind_tables()
|
---|
| 950 | {
|
---|
[22768] | 951 | console.log('function bind_tables()');
|
---|
[22676] | 952 |
|
---|
[24202] | 953 | $('#sectionHeader').click(function () {
|
---|
| 954 | console.log('section Header click *');
|
---|
| 955 | return true;
|
---|
| 956 | });
|
---|
[22768] | 957 |
|
---|
[24202] | 958 | $('#sectionContainer').click(function () {
|
---|
| 959 | console.log('section Container click *');
|
---|
| 960 | return true;
|
---|
[22768] | 961 | });
|
---|
| 962 |
|
---|
[22829] | 963 | $(".td-div").resizable({
|
---|
[22676] | 964 | alsoResize: 'parent',
|
---|
| 965 | handles: 'w,e',
|
---|
| 966 | stop: function(event, ui) {
|
---|
[22768] | 967 | console.log('Resize table on stop');
|
---|
| 968 | resize_tables($(this));
|
---|
[22676] | 969 | }, });
|
---|
| 970 |
|
---|
| 971 | $(".droppable").droppable({
|
---|
| 972 | accept: '.element_type_td',
|
---|
| 973 | tolerance: 'pointer',
|
---|
[24243] | 974 | activate: function(event, ui) { $(this).addClass("droppable_hl");},
|
---|
| 975 | deactivate: function(event, ui) { $(this).removeClass("droppable_hl"); },
|
---|
[22676] | 976 | drop: function(event, ui) {
|
---|
[22829] | 977 | var neverempty = document.createElement("div");
|
---|
| 978 | neverempty.setAttribute("class","neverempty block");
|
---|
| 979 | neverempty.setAttribute("style","height:50px");
|
---|
| 980 | neverempty.setAttribute("style","display:block");
|
---|
| 981 | var text = document.createTextNode('NEVER EMPTY');
|
---|
| 982 | neverempty.appendChild(text);
|
---|
[22676] | 983 | var td = document.createElement("td");
|
---|
[24243] | 984 | var div = document.createElement("div");
|
---|
[22676] | 985 | div.setAttribute("title","td-div");
|
---|
[22829] | 986 | div.setAttribute("class","td-div block");
|
---|
[22768] | 987 | div.setAttribute("style","margin-left:0px");
|
---|
[22676] | 988 | div.setAttribute("width","25px");
|
---|
| 989 | td.appendChild(div);
|
---|
[22829] | 990 | div.appendChild(neverempty);
|
---|
[22676] | 991 | var sep = document.createElement("td");
|
---|
| 992 | sep.setAttribute("class","droppable");
|
---|
| 993 | sep.setAttribute("width","10px");
|
---|
| 994 | $(this).after(sep);
|
---|
| 995 | $(this).after(td);
|
---|
| 996 | bind_tables();
|
---|
[22768] | 997 | resize_tables($(this));
|
---|
| 998 | bind_td_sortable();
|
---|
[22829] | 999 | bind_block_mouseover();
|
---|
[22676] | 1000 | }
|
---|
| 1001 | });
|
---|
| 1002 |
|
---|
| 1003 | }
|
---|
| 1004 |
|
---|
[22598] | 1005 | function replace_with(item, me)
|
---|
| 1006 | {
|
---|
[23135] | 1007 | // Search me for select
|
---|
| 1008 | if(me.search("select") != -1)
|
---|
| 1009 | {
|
---|
| 1010 | // If select exists, then find CURRENT_SELECT_VALUE
|
---|
[24869] | 1011 | if(me.search(CURRENT_SELECT_VALUE) != -1)
|
---|
| 1012 | {
|
---|
| 1013 | var index = me.search(CURRENT_SELECT_VALUE);
|
---|
| 1014 | if(index == -1)
|
---|
| 1015 | console.log("Did not find " + CURRENT_SELECT_VALUE);
|
---|
| 1016 | else
|
---|
| 1017 | {
|
---|
| 1018 | console.log("Found " + CURRENT_SELECT_VALUE + " at index " + index);
|
---|
| 1019 | index = index + CURRENT_SELECT_VALUE.length + 1;
|
---|
| 1020 | console.log("Attempt inserting select at new index "+index);
|
---|
| 1021 | a = me.substring(0,index);
|
---|
| 1022 | b = me.substring(index);
|
---|
| 1023 | me = a.concat("selected",b);
|
---|
| 1024 | }
|
---|
| 1025 | }
|
---|
[23135] | 1026 | }
|
---|
| 1027 |
|
---|
[22598] | 1028 | item.replaceWith(me); //'<div class="element element-txt">This text box has been added!</div>');
|
---|
[22676] | 1029 |
|
---|
[22768] | 1030 | resize_tables(item);
|
---|
| 1031 |
|
---|
| 1032 | bind_all_sortables();
|
---|
| 1033 | }
|
---|
| 1034 |
|
---|
| 1035 | function resize_tables(item)
|
---|
| 1036 | {
|
---|
| 1037 | var max_height = 0;
|
---|
[22676] | 1038 | (item.parents('.table')).each(function(index) {
|
---|
| 1039 | $(this).children().children().children().each(function() {
|
---|
[22768] | 1040 | var sum_one = 0;
|
---|
| 1041 | var sum_two = 0;
|
---|
| 1042 | $(this).children('.block').each(function() { sum_one = sum_one + $(this).height();
|
---|
| 1043 | $(this).children('.block').each(function() { sum_two = sum_two + $(this).height(); } );
|
---|
| 1044 | console.log("My height is " + $(this).height() + ", sum height 2 is " + sum_two);
|
---|
| 1045 | });
|
---|
| 1046 | console.log("My height is " + $(this).height() + ", sum height 1 is " + sum_one);
|
---|
| 1047 | if (sum_two > max_height)
|
---|
| 1048 | max_height = sum_two;
|
---|
[22676] | 1049 | });
|
---|
| 1050 | });
|
---|
[22768] | 1051 | equalHeights(item,max_height);
|
---|
[22598] | 1052 | }
|
---|
| 1053 |
|
---|
| 1054 | function bind_template_sortable()
|
---|
| 1055 | {
|
---|
[22933] | 1056 | //console.log('function bind_template_sortable()');
|
---|
[22569] | 1057 | $('.gsf_template').sortable({
|
---|
[22516] | 1058 | 'cursor':'pointer',
|
---|
[22987] | 1059 | 'tolerance': 'pointer',
|
---|
[22933] | 1060 | 'items':'.table', //.gsf_choose_metadata, .gsf_metadata',
|
---|
[22598] | 1061 | 'placeholder':'placeholder',
|
---|
| 1062 | //'nested':'.gsf:metadata'
|
---|
| 1063 | stop: function(event, ui) {
|
---|
[23276] | 1064 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_table')) { replace_with(ui.item, "<table class=\"table\" border=\"2\"></table>"); }
|
---|
| 1065 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
| 1066 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 1067 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 1068 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
[22598] | 1069 | }
|
---|
| 1070 | });
|
---|
| 1071 |
|
---|
[22768] | 1072 | $('.gsf_template').click(function () {
|
---|
| 1073 | console.log('gsf_template class click');
|
---|
| 1074 | return false;
|
---|
[22598] | 1075 | });
|
---|
[22569] | 1076 |
|
---|
[22598] | 1077 | }
|
---|
[22474] | 1078 |
|
---|
[22598] | 1079 | function bind_td_sortable()
|
---|
| 1080 | {
|
---|
[23046] | 1081 |
|
---|
| 1082 | $('tr').sortable({
|
---|
| 1083 | 'cursor':'pointer',
|
---|
| 1084 | 'tolerance': 'intersect',
|
---|
| 1085 | 'items':'.column',
|
---|
| 1086 | 'placeholder':'placeholder_td',
|
---|
| 1087 | 'connectWith':'column'});
|
---|
| 1088 |
|
---|
[22829] | 1089 | $('.td-div').sortable({
|
---|
[22516] | 1090 | 'cursor':'pointer',
|
---|
[22987] | 1091 | 'tolerance': 'pointer',
|
---|
[22768] | 1092 | 'items':'.gsf_metadata, .gsf_choose_metadata, .gsf_link, .gsf_switch',
|
---|
[22598] | 1093 | 'placeholder':'placeholder',
|
---|
[22676] | 1094 | receive: function(event, ui) { alert("Attempted to receive"); },
|
---|
[22598] | 1095 | stop: function(event, ui) {
|
---|
[23276] | 1096 | // gsf metadata
|
---|
| 1097 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 1098 | // gsf choose metadata
|
---|
| 1099 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
| 1100 | // gsf link
|
---|
| 1101 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 1102 | // gsf switch
|
---|
| 1103 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
[22676] | 1104 |
|
---|
[22598] | 1105 | }
|
---|
| 1106 |
|
---|
[22516] | 1107 | });
|
---|
[22768] | 1108 |
|
---|
[22829] | 1109 | $('.td-div').click(function () {
|
---|
[22933] | 1110 | //console.log('td class click');
|
---|
[22829] | 1111 | return true;
|
---|
[22768] | 1112 | });
|
---|
| 1113 |
|
---|
| 1114 |
|
---|
| 1115 |
|
---|
[22598] | 1116 | }
|
---|
| 1117 |
|
---|
[22829] | 1118 |
|
---|
[22598] | 1119 | function bind_choose_metadata_sortable()
|
---|
| 1120 | {
|
---|
[22933] | 1121 | //console.log('function bind_choose_metadata_sortable()');
|
---|
[22598] | 1122 | $('.gsf_choose_metadata').sortable({
|
---|
[22516] | 1123 | 'cursor':'pointer',
|
---|
[22987] | 1124 | 'tolerance': 'pointer',
|
---|
[23276] | 1125 | 'items':'.gsf_metadata, .gsf_text, .gsf_default',
|
---|
[22516] | 1126 | 'placeholder':'placeholder',
|
---|
[22598] | 1127 | 'connectWith':'.gsf_choose_metadata',
|
---|
[22516] | 1128 | //'nested':'.gsf:metadata'
|
---|
[22598] | 1129 | stop: function(event, ui) {
|
---|
[23276] | 1130 | // gsf metadata
|
---|
| 1131 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 1132 | // gsf text
|
---|
| 1133 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
| 1134 | // gsf default
|
---|
| 1135 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_default')) { replace_with(ui.item, gsf_default_element); }
|
---|
[23135] | 1136 |
|
---|
[23046] | 1137 | bind_all_sortables();
|
---|
[22598] | 1138 | }
|
---|
[22516] | 1139 | });
|
---|
[22598] | 1140 | }
|
---|
| 1141 |
|
---|
| 1142 | function bind_link_sortable()
|
---|
| 1143 | {
|
---|
[22933] | 1144 | //console.log('function bind_link_sortable()');
|
---|
[22569] | 1145 | $('.gsf_link').sortable({
|
---|
[22516] | 1146 | 'cursor':'pointer',
|
---|
[22987] | 1147 | 'tolerance': 'pointer',
|
---|
[23276] | 1148 | 'items':'.leaf, .gsf_link, .gsf_switch, .gsf_choose',
|
---|
[22676] | 1149 | 'placeholder':'placeholder',
|
---|
[22829] | 1150 | 'connectWith':'.gsf_link',
|
---|
[22516] | 1151 | //'nested':'.gsf:metadata'
|
---|
[22676] | 1152 | stop: function(event, ui) {
|
---|
[23276] | 1153 | // gsf icon
|
---|
| 1154 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 1155 | // gsf text
|
---|
| 1156 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
|
---|
| 1157 | // gsf metadata
|
---|
| 1158 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 1159 | // gsf link
|
---|
| 1160 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 1161 | // gsf switch
|
---|
| 1162 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
|
---|
| 1163 | // gsf choose
|
---|
| 1164 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
|
---|
[22676] | 1165 | }
|
---|
[22516] | 1166 | });
|
---|
[22598] | 1167 | }
|
---|
[22516] | 1168 |
|
---|
[22598] | 1169 | function bind_switch_sortable()
|
---|
| 1170 | {
|
---|
[22933] | 1171 | //console.log('function bind_switch_sortable()');
|
---|
[22569] | 1172 | $('.gsf_switch').sortable({
|
---|
[22516] | 1173 | 'cursor':'pointer',
|
---|
[22987] | 1174 | 'tolerance': 'pointer',
|
---|
[23276] | 1175 | 'items':'.gsf_metadata, .gsf_when, .gsf_otherwise, .gsf_text',
|
---|
[22598] | 1176 | 'placeholder':'placeholder',
|
---|
[22933] | 1177 | 'connectWith':'.gsf_switch',
|
---|
[22516] | 1178 | //'nested':'.gsf:metadata'
|
---|
[22598] | 1179 | stop: function(event, ui) {
|
---|
[23276] | 1180 | // gsf when
|
---|
| 1181 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_when')) { replace_with(ui.item, gsf_when_element); }
|
---|
| 1182 | // gsf otherwise
|
---|
| 1183 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_otherwise')) { replace_with(ui.item, gsf_otherwise_element); }
|
---|
| 1184 | // gsf metadata
|
---|
| 1185 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 1186 | // gsf text
|
---|
| 1187 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
[22598] | 1188 | }
|
---|
[22516] | 1189 | });
|
---|
[22598] | 1190 | }
|
---|
[22516] | 1191 |
|
---|
[22598] | 1192 | function bind_when_sortable()
|
---|
| 1193 | {
|
---|
[22933] | 1194 | //console.log('function bind_when_sortable()');
|
---|
[22569] | 1195 | $('.gsf_when').sortable({
|
---|
[22516] | 1196 | 'cursor':'pointer',
|
---|
[22987] | 1197 | 'tolerance': 'pointer',
|
---|
[23276] | 1198 | 'items':'.leaf, .gsf_link, .gsf_choose',
|
---|
[22598] | 1199 | 'placeholder':'placeholder',
|
---|
[22516] | 1200 | //'nested':'.gsf:metadata'
|
---|
[22598] | 1201 | stop: function(event, ui) {
|
---|
[23276] | 1202 | // gsf metadata
|
---|
| 1203 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 1204 | // gsf icon
|
---|
| 1205 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 1206 | // gsf text
|
---|
| 1207 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); }
|
---|
| 1208 | // gsf link
|
---|
| 1209 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 1210 | // gsf choose
|
---|
| 1211 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); }
|
---|
[22598] | 1212 | }
|
---|
[22516] | 1213 | });
|
---|
[22598] | 1214 | }
|
---|
[22516] | 1215 |
|
---|
[22598] | 1216 | function bind_otherwise_sortable()
|
---|
| 1217 | {
|
---|
[22933] | 1218 | //console.log('function bind_otherwise_sortable()');
|
---|
[22569] | 1219 | $('.gsf_otherwise').sortable({
|
---|
[22516] | 1220 | 'cursor':'pointer',
|
---|
[22987] | 1221 | 'tolerance': 'pointer',
|
---|
[23276] | 1222 | 'items':'.leaf, .gsf_link, .gsf_choose',
|
---|
[22598] | 1223 | 'placeholder':'placeholder',
|
---|
[22516] | 1224 | //'nested':'.gsf:metadata'
|
---|
[22598] | 1225 | stop: function(event, ui) {
|
---|
[23276] | 1226 | // gsf metadata
|
---|
| 1227 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
|
---|
| 1228 | // gsf text
|
---|
| 1229 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
|
---|
| 1230 | // gsf icon
|
---|
| 1231 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
|
---|
| 1232 | // gsf link
|
---|
| 1233 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
|
---|
| 1234 | // gsf choose
|
---|
| 1235 | if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); }
|
---|
[22598] | 1236 | }
|
---|
[22516] | 1237 | });
|
---|
[22598] | 1238 | }
|
---|
[22516] | 1239 |
|
---|
[22598] | 1240 | function bind_block_mouseover()
|
---|
| 1241 | {
|
---|
[22933] | 1242 | //console.log('function bind_block_mouseover()');
|
---|
[22598] | 1243 | $(".block").mouseover(function()
|
---|
[22516] | 1244 | {
|
---|
[22474] | 1245 | $(this).parents().css("border", "");
|
---|
[23046] | 1246 | $(this).css("border", "2px solid blue");
|
---|
[22516] | 1247 | return false;
|
---|
[22474] | 1248 | }).mouseout(function(){
|
---|
| 1249 | $(this).css("border", "");
|
---|
[22516] | 1250 | return false;
|
---|
[22474] | 1251 | });
|
---|
[22598] | 1252 | }
|
---|
[22474] | 1253 |
|
---|
[22598] | 1254 | function bind_minmax_remove()
|
---|
| 1255 | {
|
---|
[22768] | 1256 | console.log('function bind_minmax_remove()');
|
---|
[22598] | 1257 | $('a.minmax').bind('click', toggleContent);
|
---|
| 1258 | $('a.remove').bind('click', removeContent);
|
---|
| 1259 | };
|
---|
[22474] | 1260 |
|
---|
| 1261 | var removeContent = (function () {
|
---|
[22933] | 1262 | //console.log('var removeContent = (function ()');
|
---|
[22768] | 1263 | // this -> a -> td -> tr -> tbody -> table -> div
|
---|
[23046] | 1264 | //$(this).parent().parent().parent().parent().parent().remove();
|
---|
| 1265 | $(this).closest(".block").remove();
|
---|
[22474] | 1266 | });
|
---|
| 1267 |
|
---|
| 1268 |
|
---|
| 1269 | var toggleContent = function(e)
|
---|
| 1270 | {
|
---|
[22768] | 1271 | console.log('parent: ' + $(this).html());
|
---|
[22676] | 1272 | if ($(this).html() == '[+]'){ //targetContent.css('display') == 'none') {
|
---|
[23046] | 1273 | $(this).closest(".block").children(".table, .block").slideDown(300);
|
---|
[22474] | 1274 | $(this).html('[-]');
|
---|
[22768] | 1275 | $(this).removeClass("ui-icon-plusthick");
|
---|
| 1276 | $(this).addClass("ui-icon-minusthick");
|
---|
[22474] | 1277 | } else {
|
---|
[23046] | 1278 | $(this).closest(".block").children(".table, .block").slideUp(300);
|
---|
[22474] | 1279 | $(this).html('[+]');
|
---|
[22768] | 1280 | $(this).removeClass("ui-icon-minusthick");
|
---|
| 1281 | $(this).addClass("ui-icon-plusthick");
|
---|
[22474] | 1282 | }
|
---|
| 1283 | return false;
|
---|
| 1284 | };
|
---|
| 1285 |
|
---|
| 1286 | function serialize(s)
|
---|
| 1287 | {
|
---|
| 1288 | serial = $.SortSerialize(s);
|
---|
| 1289 | alert(serial.hash);
|
---|
| 1290 | };
|
---|
| 1291 |
|
---|
[22768] | 1292 | function equalHeights(item, height) {
|
---|
[22933] | 1293 | //console.log('function equalHeights(item, height)');
|
---|
[22768] | 1294 | (item.parents('.table')).each(function(index) {
|
---|
| 1295 | $(this).children().children().children().each(function() {
|
---|
| 1296 | $(this).height(height);
|
---|
| 1297 | $(this).children().height(height);
|
---|
| 1298 | });
|
---|
[22569] | 1299 | });
|
---|
| 1300 | };
|
---|
| 1301 |
|
---|