source: main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js@ 33217

Last change on this file since 33217 was 33217, checked in by wy59, 5 years ago
  1. Undoing the change to doc.pm committed in revision 33185: not storing all combinations of precision for Lat and Long in CoordShorts. Instead, Dr Bainbridge fixed up map-scripts.js to ensure that the requested precision (num decimal places) for Lat and Lng in a CoordShort are now the same. The chosen precision for both is set to whichever of the two is more zoomed out, which work out to be whichever of the two has fewer decimal places. 2. Dr Bainbridge and Martin set min-height when mapEnabled to ensure the footer didn't interfere in the map. 3. classifier-scripts' httpRequest() renamed to httpBrowseRequest() and map's getSubClassifier() renamed to httpMapBrowseRequest().
  • Property svn:executable set to *
File size: 3.6 KB
Line 
1var inProgress = new Array();
2var openClassifiers = new Array();
3var busy = false;
4
5function isExpanded(sectionID)
6{
7 var divElem = gs.jqGet("div" + sectionID);
8 if(!divElem.css("display") || divElem.css("display") != "none")
9 {
10 return true;
11 }
12 return false;
13}
14
15function toggleSection(sectionID)
16{
17 var section = gs.jqGet("div" + sectionID);
18 var sectionToggle = gs.jqGet("toggle" + sectionID);
19
20 if(sectionToggle == undefined)
21 {
22 return;
23 }
24
25 //If the div exists
26 // Test if 'section' exists.
27 // ==> Because we're using jQuery to do this we need to test the length of the object returned
28 // http://stackoverflow.com/questions/920236/how-can-i-detect-if-a-selector-returns-null
29 if(section.length !== 0)
30 {
31 if(isExpanded(sectionID))
32 {
33 section.css("display", "none");
34 sectionToggle.attr("src", gs.imageURLs.expand);
35
36 if(openClassifiers[sectionID].length !== 0) //if(openClassifiers[sectionID] != undefined)
37 {
38 delete openClassifiers[sectionID];
39 }
40 }
41 else
42 {
43 section.css("display", "block");
44 sectionToggle.attr("src", gs.imageURLs.collapse);
45 openClassifiers[sectionID] = true;
46 }
47 updateOpenClassifiers();
48 if(typeof mapEnabled !== 'undefined' && mapEnabled){
49 //console.log("Classifier scripts -> updateMap()");
50 updateMap();
51 }
52 }
53 else
54 {
55 httpBrowseRequest(sectionID);
56 }
57}
58
59function updateOpenClassifiers()
60{
61 var oc = "";
62 var first = true;
63 for(var key in openClassifiers)
64 {
65 if(first)
66 {
67 first = false;
68 }
69 else
70 {
71 oc += ",";
72 }
73
74 oc += key;
75 }
76
77 if(oc != undefined && oc != "")
78 {
79 window.location.hash = oc;
80 }
81}
82
83function openStoredClassifiers()
84{
85 if(window.location.hash != undefined && window.location.hash.length > 1)
86 {
87 var toOpen = window.location.hash.substring(1,window.location.hash.length).split(",");
88 var loopFunction = function(sectionArray, index)
89 {
90 if(!busy && index < sectionArray.length)
91 {
92 busy = true;
93 toggleSection(sectionArray[index]);
94 setTimeout(function()
95 {
96 loopFunction(sectionArray, index + 1);
97 }, 25);
98
99 return true;
100 }
101
102 setTimeout(function()
103 {
104 loopFunction(sectionArray, index);
105 }, 25);
106 return false;
107 }
108
109 if(toOpen.length > 0)
110 {
111 loopFunction(toOpen, 0);
112 }
113 }
114}
115
116function httpBrowseRequest(sectionID)
117{
118 if(!inProgress[sectionID])
119 {
120 inProgress[sectionID] = true;
121
122 var sectionToggle = gs.jqGet("toggle" + sectionID);
123 sectionToggle.attr("src", gs.imageURLs.loading);
124
125 var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/browse/" + sectionID.replace(/\./g, "/") + "?excerptid=div" + sectionID;
126
127 if(gs.cgiParams.berrybasket == "on")
128 {
129 url = url + "&berrybasket=on";
130 }
131
132 if(url.indexOf("#") != -1)
133 {
134 url = url.substring(0, url.indexOf("#"));
135 }
136
137 $.ajax(url)
138 .success(function(data)
139 {
140 var newDiv = $("<div>");
141 var sibling = gs.jqGet("title" + sectionID);
142 sibling.after(newDiv);
143
144 newDiv.html(data);
145 sectionToggle.attr("src", gs.imageURLs.collapse);
146 openClassifiers[sectionID] = true;
147
148 if(gs.cgiParams.berrybasket == "on")
149 {
150 checkout();
151 }
152 else if(gs.cgiParams.documentbasket == "on")
153 {
154 dmcheckout();
155 }
156 updateOpenClassifiers();
157 if(typeof mapEnabled !== 'undefined'){
158 httpMapBrowseRequest(sectionID);
159 }
160 })
161 .error(function()
162 {
163 sectionToggle.attr("src", gs.imageURLs.expand);
164 })
165 .complete(function()
166 {
167 inProgress[sectionID] = false;
168 busy = false;
169 });
170 }
171}
Note: See TracBrowser for help on using the repository browser.