Index: /main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js (revision 33145)
+++ /main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js (revision 33146)
@@ -11,17 +11,4 @@
}
return false;
-}
-
-// TODO: Is there a better solution
-function _basicToggleSection(sectionID) {
- // Leave this function here, even though it's empty.
- // This function is here because:
- // - it mirrors the identically named version in document_scripts
- // - and this allows map_scripts to override it without knowing whether it's
- // overriding classifier_scripts::toggleSection() or document_scripts::toggleSection().
-
- // This method is not meant to call toggleSection. If anything it would be the other way around
- // (as occurs in doc_scripts.js). But this method has to remain empty for classifier_scripts.js
- // since map_scripts largely repeats classifier_scripts.js::toggleSection() code.
}
@@ -59,4 +46,7 @@
}
updateOpenClassifiers();
+ if(typeof mapEnabled !== 'undefined'){
+ updateMap();
+ }
}
else
@@ -163,5 +153,8 @@
dmcheckout();
}
- updateOpenClassifiers();
+ updateOpenClassifiers();
+ if(typeof mapEnabled !== 'undefined'){
+ getSubClassifier(sectionID);
+ }
})
.error(function()
Index: /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js (revision 33145)
+++ /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js (revision 33146)
@@ -1,41 +1,3 @@
/** Javascript file for viewing documents */
-
-//-------TODO--------//
-// map-scripts.js needs these, but non-map viewing does not. Yet if we add these to map_scripts,
-// then in classifier mode, map_scripts will use classifier_scripts.js which already has these
-// So for now, we add them into this file for when map_scripts is in doc view mode and includes document_scripts.js.
-// It seems suboptimal, as these variables and function will be wasted when in regular non-map mode.
-// But unable to think of any other solution at present.
-var inProgress = new Array();
-var openClassifiers = new Array();
-var busy = false;
-
-
-
-function updateOpenClassifiers()
-{
- var oc = "";
- var first = true;
- for(var key in openClassifiers)
- {
- if(first)
- {
- first = false;
- }
- else
- {
- oc += ",";
- }
-
- oc += key;
- }
-
- if(oc != undefined)
- {
- window.location.hash = oc;
- }
-}
-
-//---------------//
/** NOTE, this file uses inline templates which look for httpPath, assocfilepath, Source, Thumb, Title metadata. These need to be added into any xsl file that uses this javascript (using if they are not already being collected. */
@@ -187,12 +149,6 @@
}
-// TODO:
-// DO NOT "MERGE" _basicToggleSection into toggleSection!
-// map_scripts.js calls _basicToggleSection as it redefines toggleSection() to do (more) stuff.
+
function toggleSection(sectionID, callback, tocDisabled)
-{
- _basicToggleSection(sectionID, callback, tocDisabled);
-}
-function _basicToggleSection(sectionID, callback, tocDisabled)
{
var docElem = gs.jqGet("doc" + sectionID);
Index: /main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js (revision 33145)
+++ /main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js (revision 33146)
@@ -1,2 +1,4 @@
+var mapEnabled = true; // variable to detect when map-scripts have been included into document_scripts.js and classifier_scripts.js
+
//var newLat, newLng = 0;
var _docList = new Array();
@@ -18,5 +20,4 @@
function initializeMapScripts()
{
- modifyFunctions();
setUpMap();
@@ -876,108 +877,2 @@
return indexName + ":" + beforeDec + "+AND+" + indexName + ":" + afterDec;
}
-
-// This function "overrides" (or rather, redefines) toggleSection in both classifier_scripts.js and document_scripts.js
-// However, classifier_scripts.js::toggleSection() only took one parameter, sectionID, whereas
-// document_scripts.js::toggleSection() took 3 params (sectionID, callback, tocDisabled).
-// So to be compatible with both, need map-scripts::toggleSection() here to support all 3 in that order.
-function modifyFunctions()
-{
- toggleSection = function(sectionID, callback, tocDisabled)
- {
- _basicToggleSection(sectionID, callback, tocDisabled);
-
- var section = gs.jqGet("div" + sectionID);
- var sectionToggle = gs.jqGet("toggle" + sectionID);
-
- if(sectionToggle == undefined)
- {
- return;
- }
-
- //If the div exists
- // Test if 'section' exists.
- // ==> Because we're using jQuery to do this we need to test the length of the object returned
- // http://stackoverflow.com/questions/920236/how-can-i-detect-if-a-selector-returns-null
- if(section.length !== 0)
- {
- if(isExpanded(sectionID))
- {
- section.css("display", "none");
- sectionToggle.attr("src", gs.imageURLs.expand);
-
- if(openClassifiers[sectionID].length !== 0) //if(openClassifiers[sectionID] != undefined)
- {
- delete openClassifiers[sectionID];
- }
- }
- else
- {
- section.css("display", "block");
- sectionToggle.attr("src", gs.imageURLs.collapse);
- openClassifiers[sectionID] = true;
- }
- updateOpenClassifiers();
- updateMap();
- }
- else
- {
- httpRequest(sectionID);
- }
-
- }
-
- httpRequest = function(sectionID)
- {
- if(!inProgress[sectionID])
- {
- inProgress[sectionID] = true;
-
- var sectionToggle = gs.jqGet("toggle" + sectionID);
- sectionToggle.attr("src", gs.imageURLs.loading);
-
- var url = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/browse/" + sectionID.replace(/\./g, "/") + "?excerptid=div" + sectionID;
-
- if(gs.cgiParams.berrybasket == "on")
- {
- url = url + "&berrybasket=on";
- }
-
- if(url.indexOf("#") != -1)
- {
- url = url.substring(0, url.indexOf("#"));
- }
-
- $.ajax(url)
- .success(function(responseText)
- {
- var newDiv = $("
");
- var sibling = gs.jqGet("title" + sectionID);
- sibling.after(newDiv);
-
- newDiv.html(responseText);
- sectionToggle.attr("src", gs.imageURLs.collapse);
- openClassifiers[sectionID] = true;
-
- if(gs.cgiParams.berrybasket == "on")
- {
- checkout();
- }
- else if(gs.cgiParams.documentbasket == "on")
- {
- dmcheckout();
- }
- updateOpenClassifiers();
- getSubClassifier(sectionID);
- })
- .error(function()
- {
- sectionToggle.attr("src", gs.imageURLs.expand);
- })
- .complete(function()
- {
- inProgress[sectionID] = false;
- busy = false;
- });
- }
- }
-}