[24520] | 1 | var inProgress = new Array();
|
---|
| 2 | var openClassifiers = new Array();
|
---|
| 3 | var busy = false;
|
---|
| 4 |
|
---|
| 5 | function isExpanded(sectionID)
|
---|
| 6 | {
|
---|
[26396] | 7 | var divElem = gs.jqGet("div" + sectionID);
|
---|
| 8 | if(!divElem.css("display") || divElem.css("display") != "none")
|
---|
[24520] | 9 | {
|
---|
| 10 | return true;
|
---|
| 11 | }
|
---|
| 12 | return false;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | function toggleSection(sectionID)
|
---|
| 16 | {
|
---|
[26396] | 17 | var section = gs.jqGet("div" + sectionID);
|
---|
| 18 | var sectionToggle = gs.jqGet("toggle" + sectionID);
|
---|
[24520] | 19 |
|
---|
| 20 | if(sectionToggle == undefined)
|
---|
| 21 | {
|
---|
| 22 | return;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
[26396] | 25 | //If the div exists
|
---|
| 26 | if(section.length)
|
---|
[24520] | 27 | {
|
---|
| 28 | if(isExpanded(sectionID))
|
---|
| 29 | {
|
---|
[26396] | 30 | section.css("display", "none");
|
---|
| 31 | sectionToggle.attr("src", gs.imageURLs.expand);
|
---|
| 32 |
|
---|
[24520] | 33 | if(openClassifiers[sectionID] != undefined)
|
---|
| 34 | {
|
---|
| 35 | delete openClassifiers[sectionID];
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | else
|
---|
| 39 | {
|
---|
[26396] | 40 | section.css("display", "block");
|
---|
| 41 | sectionToggle.attr("src", gs.imageURLs.collapse);
|
---|
[24520] | 42 | openClassifiers[sectionID] = true;
|
---|
| 43 | }
|
---|
| 44 | updateOpenClassifiers();
|
---|
| 45 | }
|
---|
| 46 | else
|
---|
| 47 | {
|
---|
| 48 | httpRequest(sectionID);
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | function updateOpenClassifiers()
|
---|
| 53 | {
|
---|
| 54 | var oc = "";
|
---|
| 55 | var first = true;
|
---|
| 56 | for(var key in openClassifiers)
|
---|
| 57 | {
|
---|
| 58 | if(first)
|
---|
| 59 | {
|
---|
| 60 | first = false;
|
---|
| 61 | }
|
---|
| 62 | else
|
---|
| 63 | {
|
---|
| 64 | oc += ",";
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | oc += key;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | if(oc != undefined)
|
---|
| 71 | {
|
---|
| 72 | window.location.hash = oc;
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | function openStoredClassifiers()
|
---|
| 77 | {
|
---|
| 78 | if(window.location.hash != undefined && window.location.hash.length > 1)
|
---|
| 79 | {
|
---|
| 80 | var toOpen = window.location.hash.substring(1,window.location.hash.length).split(",");
|
---|
| 81 | var loopFunction = function(sectionArray, index)
|
---|
| 82 | {
|
---|
| 83 | if(!busy && index < sectionArray.length)
|
---|
| 84 | {
|
---|
| 85 | busy = true;
|
---|
| 86 | toggleSection(sectionArray[index]);
|
---|
| 87 | setTimeout(function()
|
---|
| 88 | {
|
---|
| 89 | loopFunction(sectionArray, index + 1);
|
---|
[24555] | 90 | }, 25);
|
---|
[24520] | 91 |
|
---|
[24555] | 92 | return true;
|
---|
[24520] | 93 | }
|
---|
| 94 |
|
---|
| 95 | setTimeout(function()
|
---|
| 96 | {
|
---|
| 97 | loopFunction(sectionArray, index);
|
---|
[24555] | 98 | }, 25);
|
---|
[24520] | 99 | return false;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | if(toOpen.length > 0)
|
---|
| 103 | {
|
---|
| 104 | loopFunction(toOpen, 0);
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | function httpRequest(sectionID)
|
---|
| 110 | {
|
---|
| 111 | if(!inProgress[sectionID])
|
---|
| 112 | {
|
---|
| 113 | inProgress[sectionID] = true;
|
---|
[25010] | 114 | var httpRequest = new gs.functions.ajaxRequest();
|
---|
[24520] | 115 |
|
---|
[26396] | 116 | var sectionToggle = gs.jqGet("toggle" + sectionID);
|
---|
| 117 | sectionToggle.attr("src", gs.imageURLs.loading);
|
---|
[25442] | 118 |
|
---|
| 119 | var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/browse/" + sectionID.replace(/\./g, "/") + "?excerptid=div" + sectionID;
|
---|
[24520] | 120 |
|
---|
[29277] | 121 | if(gs.cgiParams.berrybasket == "on")
|
---|
[24520] | 122 | {
|
---|
| 123 | url = url + "&berrybasket=on";
|
---|
[29277] | 124 | }
|
---|
[24520] | 125 |
|
---|
[24521] | 126 | if(url.indexOf("#") != -1)
|
---|
| 127 | {
|
---|
| 128 | url = url.substring(0, url.indexOf("#"));
|
---|
| 129 | }
|
---|
[26396] | 130 |
|
---|
| 131 | $.ajax(url)
|
---|
| 132 | .success(function(data)
|
---|
[24520] | 133 | {
|
---|
[26396] | 134 | var newDiv = $("<div>");
|
---|
| 135 | var sibling = gs.jqGet("title" + sectionID);
|
---|
| 136 | sibling.after(newDiv);
|
---|
| 137 |
|
---|
| 138 | newDiv.html(data);
|
---|
| 139 | sectionToggle.attr("src", gs.imageURLs.collapse);
|
---|
| 140 | openClassifiers[sectionID] = true;
|
---|
| 141 |
|
---|
[29277] | 142 | if(gs.cgiParams.berrybasket == "on")
|
---|
[24520] | 143 | {
|
---|
[26396] | 144 | checkout();
|
---|
[24520] | 145 | }
|
---|
[26396] | 146 | else if(gs.cgiParams.documentbasket == "on")
|
---|
| 147 | {
|
---|
| 148 | dmcheckout();
|
---|
| 149 | }
|
---|
| 150 | updateOpenClassifiers();
|
---|
| 151 | })
|
---|
| 152 | .error(function()
|
---|
| 153 | {
|
---|
| 154 | sectionToggle.attr("src", gs.imageURLs.expand);
|
---|
| 155 | })
|
---|
| 156 | .complete(function()
|
---|
| 157 | {
|
---|
| 158 | inProgress[sectionID] = false;
|
---|
| 159 | busy = false;
|
---|
| 160 | });
|
---|
[24520] | 161 | }
|
---|
| 162 | } |
---|