Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Finished, but not tested

Mike McGann323cbeb8113b
diff --git a/etc/ant/css.build.xml b/etc/ant/css.build.xml
index f8c6eb985..4a8154267 100644
--- a/etc/ant/css.build.xml
+++ b/etc/ant/css.build.xml
@@ -2,30 +2,30 @@
<filelist id="css.files" dir="${build.web.dir}">
<file name="ext/jquery.mobile/jquery.mobile.css"/>
-
+
<file name="ext/yui/combo-container-min.css"/>
-
+
<file name="ext/openlayers/theme/default/style.css"/>
<file name="ext/openlayers/openlayers.example.style.css"/>
<file name="ext/openlayers/openlayers.style.mobile-jq.css"/>
-
+
<file name="ext/jquery.dd/dd.css"/>
<file name="ext/jquery.dd/skin2.css"/>
<file name="ext/joyride/joyride.css"/>
<file name="ext/jcrop/jcrop.css"/>
- <file name="ext/jscrollpane/jquery.jscrollpane.css"/>
-
- <file name="ext/mobiscroll/mobiscroll.core.css"/>
- <file name="ext/mobiscroll/mobiscroll.jqm.css"/>
- <file name="ext/mobiscroll/mobiscroll.android.css"/>
- <file name="ext/mobiscroll/mobiscroll.android-ics.css"/>
- <file name="ext/mobiscroll/mobiscroll.ios.css"/>
- <file name="ext/mobiscroll/mobiscroll.sense-ui.css"/>
- <file name="ext/mobiscroll/mobiscroll.wp.css"/>
- <file name="ext/mobiscroll/mobiscroll.animation.css"/>
-
- <file name="css/palette.css"/>
+ <file name="ext/jscrollpane/jquery.jscrollpane.css"/>
+
+ <file name="ext/mobiscroll/mobiscroll.core.css"/>
+ <file name="ext/mobiscroll/mobiscroll.jqm.css"/>
+ <file name="ext/mobiscroll/mobiscroll.android.css"/>
+ <file name="ext/mobiscroll/mobiscroll.android-ics.css"/>
+ <file name="ext/mobiscroll/mobiscroll.ios.css"/>
+ <file name="ext/mobiscroll/mobiscroll.sense-ui.css"/>
+ <file name="ext/mobiscroll/mobiscroll.wp.css"/>
+ <file name="ext/mobiscroll/mobiscroll.animation.css"/>
+
+ <file name="css/palette.css"/>
<file name="css/map.css"/>
<file name="css/dateSpan.css"/>
<file name="css/menuPicker.css"/>
@@ -35,12 +35,13 @@
<file name="css/sote.css"/>
<file name="css/splash.css"/>
<file name="css/products.css"/>
- <file name="css/pages.css"/>
- <file name="css/about.css"/>
- <file name="css/indicator.css"/>
- <file name="css/events.css"/>
- <file name="css/dataDownload.css"/>
+ <file name="css/projection.css/"/>
+ <file name="css/pages.css"/>
+ <file name="css/about.css"/>
+ <file name="css/indicator.css"/>
+ <file name="css/events.css"/>
+ <file name="css/dataDownload.css"/>
</filelist>
-
+
</project>
\ No newline at end of file
diff --git a/etc/ant/js.build.xml b/etc/ant/js.build.xml
index f25f44bb0..48b7345f0 100644
--- a/etc/ant/js.build.xml
+++ b/etc/ant/js.build.xml
@@ -9,7 +9,7 @@
<file name="ext/jscrollpane/jquery.mousewheel.js"/>
<file name="ext/jscrollpane/mwheelIntent.js"/>
- <file name="ext/jscrollpane/jquery.jscrollpane.min.js"/>
+ <file name="ext/jscrollpane/jquery.jscrollpane.js"/>
<file name="ext/mobiscroll/mobiscroll.core.js"/>
<file name="ext/mobiscroll/mobiscroll.datetime.js"/>
@@ -60,13 +60,7 @@
<file name="js/datePicker.js"/>
<file name="js/rubberBand.js"/>
<file name="js/imageDownload.js"/>
- <file name="js/menuPicker.js"/>
- <file name="js/accordionPicker.js"/>
<file name="js/list.js"/>
- <file name="js/bank.js"/>
- <file name="js/switch.js"/>
- <file name="js/selector.js"/>
- <file name="js/products.js"/>
<file name="js/sote.js"/>
<file name="js/events.js"/>
@@ -82,6 +76,12 @@
<file name="js/Worldview/AjaxCache.js"/>
<file name="js/Worldview/AjaxJoin.js"/>
+ <file name="js/Worldview/Models/Layers.js"/>
+ <file name="js/Worldview/Models/Projection.js"/>
+
+ <file name="js/Worldview/Legacy/switch.js"/>
+ <file name="js/Worldview/Legacy/bank.js"/>
+
<file name="js/Worldview/Palette.js"/>
<file name="js/Worldview/Palette/ColorBar.js"/>
<file name="js/Worldview/Palette/Palette.js"/>
@@ -151,6 +151,10 @@
<file name="js/Worldview/DataDownload/DownloadListPanel.js"/>
<file name="js/Worldview/DataDownload/BulkDownloadPage.js"/>
+ <file name="js/Worldview/Widget/Projection.js"/>
+ <file name="js/Worldview/Widget/LayerSideBar.js"/>
+ <file name="js/Worldview/Widget/ActiveLayers.js"/>
+ <file name="js/Worldview/Widget/AddLayers.js"/>
<file name="js/Worldview/Widget/Map.js"/>
<file name="js/Worldview/Widget/Palette.js"/>
<file name="js/Worldview/Widget/WorldviewMap.js"/>
diff --git a/src/data/config.json b/src/data/config.json
index 0b09d25ee..8f9395de6 100644
--- a/src/data/config.json
+++ b/src/data/config.json
@@ -134,9 +134,7 @@
"grump-v1-population-count_2000"
],
"projections": [
- "geographic",
- "arctic",
- "antarctic"
+ "geographic"
]
},
"Fires": {
diff --git a/src/index.html b/src/index.html
index 009a1151e..9de114713 100644
--- a/src/index.html
+++ b/src/index.html
@@ -128,13 +128,8 @@
<!-- link.dev --> <script type="text/javascript" src="js/datePicker.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/rubberBand.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/imageDownload.js"></script>
- <!-- link.dev --> <script type="text/javascript" src="js/menuPicker.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/accordionPicker.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/list.js"></script>
- <!-- link.dev --> <!--<script type="text/javascript" src="js/bank.js"></script>-->
- <!-- link.dev --> <script type="text/javascript" src="js/switch.js"></script>
- <!-- link.dev --> <script type="text/javascript" src="js/selector.js"></script>
- <!-- link.dev --> <script type="text/javascript" src="js/products.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/sote.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/events.js"></script>
diff --git a/src/js/Worldview/Widget/LayerSideBar.js b/src/js/Worldview/Widget/LayerSideBar.js
index 99c4f457a..c1df0cc73 100644
--- a/src/js/Worldview/Widget/LayerSideBar.js
+++ b/src/js/Worldview/Widget/LayerSideBar.js
@@ -65,43 +65,60 @@ Worldview.Widget.LayerSideBar = function(layersModel) {
var $container = $(self.selector);
$container.empty().addClass("products");
- var html =
- "<ul id='" + self.id + "tabs'>" +
- "<li class='layerPicker first'>" +
- "<a href='#products' class='activetab tab'>" +
- HTML_TAB_ACTIVE_SELECTED +
- "</a>" +
- "</li>" +
- "<li class='layerPicker second'>" +
- "<a href='#selectorbox' class='addlayerstab tab'>" +
- HTML_TAB_ADD_UNSELECTED +
- "</a>" +
- "</li>" +
- "<li class='layerPicker third'>" +
- "<a href='#DataDownload' class='tab'>" +
- HTML_TAB_DOWNLOAD_UNSELECTED +
- "</a>" +
- "</li>" +
- "</ul>" +
-
- "<div id='" + self.id + "toggleButtonHolder'" +
- "class='toggleButtonHolder'>" +
- "<a class='accordionToggler atcollapse arrow' " +
- "title='Hide'></a>" +
- "</a>" +
- "</div>" +
-
- "<div id='products'></div>" +
- "<div id='selectorbox'></div>" +
- "<div id='DataDownload'></div>";
-
- $container.html(html);
+ var $tabs = $("<ul></ul>")
+ .attr("id", self.id + "tabs");
+
+ var $activeTab = $("<li></li>")
+ .addClass("layerPicker")
+ .addClass("first");
+ var $activeLink = $("<a></a>")
+ .attr("href", "#products")
+ .addClass("activetab")
+ .addClass("tab")
+ .html(HTML_TAB_ACTIVE_SELECTED);
+ $activeTab.append($activeLink);
+ $tabs.append($activeTab);
+
+ var $addTab = $("<li></li>")
+ .addClass("layerPicker")
+ .addClass("second");
+ var $addLink = $("<a></a>")
+ .attr("href", "#selectorbox")
+ .addClass("tab")
+ .html(HTML_TAB_ADD_UNSELECTED);
+ $addTab.append($addLink);
+ $tabs.append($addTab);
+
+ var $downloadTab = $("<li></li>")
+ .addClass("layerPicker")
+ .addClass("third");
+ var $downloadLink = $("<a></a>")
+ .attr("href", "#DataDownload")
+ .addClass("tab")
+ .html(HTML_TAB_DOWNLOAD_UNSELECTED);
+ $downloadTab.append($downloadLink);
+ $tabs.append($downloadTab);
+ $container.append($tabs);
+
+ var $collapseContainer = $("<div></div>")
+ .attr("id", self.id + "toggleButtonHolder")
+ .addClass("toggleButtonHolder");
+ var $collapseButton = $("<a></a>")
+ .addClass("accordionToggler")
+ .addClass("atcollapse")
+ .addClass("arrow")
+ .attr("title", "Hide");
+ $collapseContainer.append($collapseButton);
+ $container.append($collapseContainer);
+
+ $container.append($("<div id='products'></div>"))
+ .append($("<div id='selectorbox'></div>"))
+ .append($("<div id='DataDownload'></div>"));
$container.tabs({
show: onTabChange
});
-
$('.accordionToggler').bind('click', slide);
};
diff --git a/src/js/accordionPicker.js b/src/js/accordionPicker.js
deleted file mode 100644
index 8f0fa18d2..000000000
--- a/src/js/accordionPicker.js
+++ /dev/null
@@ -1,514 +0,0 @@
-SOTE.namespace("SOTE.widget.AccordionPicker");
-
-SOTE.widget.AccordionPicker.prototype = new SOTE.widget.Component;
-
-/**
- * A selection device classifying radio buttons/checkboxes into categories that are displayed in Accordion form.
- * Radio buttons allow single selection accross categories. Checkboxes allow multiple selections accross categories.
- * Radio selections cannot span multiple categories.
- *
- * @module SOTE.widget
- * @class AccordionPicker
- * @constructor
- * @this {AccordionPicker}
- * @param {String} containerId is the container id of the div in which to render the object
- * @param {Object} [config] is a hash allowing configuration of this component
- * @config {Object[]} [items] a JS Array of JS Objects: items.category[i..n].key, items.category[i..n].value
- * , items.category[i..n].action, items.type[i..n] representing the available options
- * @config {String} [selected] the key of the initially selected option(s)
- * @augments SOTE.widget.Component
- *
-*/
-SOTE.widget.AccordionPicker = function(containerId, config){
- //Get the ID of the container element
- this.container=document.getElementById(containerId);
- if (this.container==null){
- this.setStatus("Error: element '"+containerId+"' not found!",true);
- return;
- }
- this.id = containerId;
- //Store the container's ID
- this.containerId=containerId;
-
- //Define an object for holding configuration
- if (config===undefined){
- config={};
- }
-
- if(config.dataSourceUrl === undefined){
- config.dataSourceUrl = null;
- }
-
- if(config.items === undefined){
- config.items = null;
- }
-
- if(config.selected === undefined){
- config.selected = null;
- }
-
- this.value = "";
- //this.items = config.items;
- this.selected = config.selected;
- this.expanded = null;
- this.initRenderComplete = false;
- this.dataSourceUrl = config.dataSourceUrl;
- this.statusStr = "";
- this.init();
- this.updateComponent("");
-
-};
-
-/**
- * Displays all options in HTML in an Accordion format (see JQuery UI Accordion) with the selected states being indicated
- * by radio button and checkbox selection. All callbacks should be set. The component UI should be rendered
- * with controllers to call the events.
- *
- *
- * @this {AccordionPicker}
- *
-*/
-SOTE.widget.AccordionPicker.prototype.init = function(){
-
- this.render();
-
- if(REGISTRY){
- REGISTRY.register(this.id,this);
- }
- else{
- alert("No REGISTRY found! Cannot register AccordionPicker!");
- }
-
-
-};
-
-/**
- * Renders the UI accordion from this.items
- *
- *
- * @this {AccordionPicker}
- *
-*/
-SOTE.widget.AccordionPicker.prototype.render = function(){
- if(this.items === undefined){return false;}
- this.container.innerHTML = "";
- var htmlExpanded;
- var selected;
- var defaultSelection = null;
- var accordion = document.createElement("form");
- accordion.setAttribute("class","accordion");
- accordion.setAttribute("id",this.id+"accordion");
- for(var category in this.items){
- if(category === "expanded"){
- if(this.items[category] !== undefined && this.items[category] !== ""){
- htmlExpanded = this.items[category].replace(" ","");
- }
- continue;
- }
- if(category === "selected"){
- selected = this.items[category];
- continue;
- }
- var htmlCategory = category.replace(" ","");
- var catHeader = document.createElement("a");
- catHeader.setAttribute("href","#");
- catHeader.setAttribute("id",this.id+htmlCategory );
- catHeader.innerHTML = "<span>"+category+"</span>";
- accordion.appendChild(catHeader);
- var catList = document.createElement("ul");
- for(var i=0; i < this.items[category].length; i++){
- var item = this.items[category][i];
- var catListItem = document.createElement("li");
- if(item.type !== "single" && item.type !== "multi"){
- alert("Invalid list item!");
- }
- else {
- var id = this.id + htmlCategory + "Item" + i;
- var disabled = (item.disabled !== undefined && item.disabled === true)? "disabled":"";
- var type = (item.type === "single")? "radio":"checkbox";
- catListItem.innerHTML = "<input value='"+item.value+"' class='accordionFormItem' name='"+this.id+item.type+"' id='"+id+"' type='"+type+"'"+" "+disabled+"/>";
- catListItem.innerHTML += "<label for='"+id+"'><span class='accordionLabel'>"+item.label+"</span><span class='accordionSub'>"+item.sublabel+"</span></label>";
- catList.appendChild(catListItem);
- }
- }
- accordion.appendChild(catList);
- }
- this.container.appendChild(accordion);
- var accordionToggler = document.createElement("a");
- accordionToggler.setAttribute("class","accordionToggler atcollapse");
- this.isCollapsed = false;
- var e = new Object();
- e.data = new Object();
- e.data.self = this;
- //SOTE.widget.AccordionPicker.toggle(e,null);
- this.container.appendChild(accordionToggler);
- $('.accordionToggler').bind('click',{self:this},SOTE.widget.AccordionPicker.toggle);
- $('.accordion').accordion();
- $('.accordion').bind('accordionchange',{self:this},SOTE.widget.AccordionPicker.handleCategorySwitch);
- //$('.accordion').accordion("option","collapsible",true);
- $('.accordionFormItem').bind('click',{self:this},SOTE.widget.AccordionPicker.handleSelection);
-
- if(selected !== undefined && selected !== ""){
- this.setValue(htmlExpanded + "." + selected);
- }
-
- /*if(htmlExpanded !== undefined){
- $('.accordion').accordion("activate","#"+this.id+htmlExpanded);
- this.expanded = this.id + htmlExpanded;
- var activeBox = document.getElementById(this.id+htmlExpanded+"Item"+"0");
- if(activeBox !== null) activeBox.checked = true;
- this.fire();
- }*/
-
-/* else {
- this.setValue(defaultSelection);
- }*/
-
- // Mark the component as ready in the registry if called via init()
- if ((this.initRenderComplete === false) && REGISTRY) {
- this.initRenderComplete = true;
- REGISTRY.markComponentReady(this.id);
- }
-
-
-
-};
-
-SOTE.widget.AccordionPicker.handleSelection = function(e){
- var self = e.data.self;
- self.syncCheckboxes(e.target);
- self.value = SOTE.util.extractFromQuery(self.id,self.getValue());
- self.fire();
-};
-
-SOTE.widget.AccordionPicker.toggle = function(e,ui){
- var self = e.data.self;
- if(self.isCollapsed){
- $('.accordionToggler').removeClass('atexpand').addClass('atcollapse');
- $('.accordionToggler').attr("title","Hide Products");
- $('.accordion').css('display','block');
- self.isCollapsed = false;
- }
- else{
- $('.accordionToggler').removeClass('atcollapse').addClass('atexpand');
- $('.accordionToggler').attr("title","Show Products");
- $('.accordion').css('display','none');
- self.isCollapsed = true;
- }
-};
-
-SOTE.widget.AccordionPicker.handleCategorySwitch = function(e,ui){
- var self = e.data.self;
- var oldCategory = (ui.oldHeader[0].id);
- var newCategory = (ui.newHeader[0].id);
- var checkedRadio = null;
- var anyChecked = false;
-
- if(self.expanded !== newCategory){
- self.expanded = newCategory;
- var radioButtons = document.getElementsByName(self.id+"single");
- for(var i=0; i<radioButtons.length; ++i){
- if(radioButtons[i].disabled === false && radioButtons[i].id.indexOf(oldCategory) != -1 && radioButtons[i].checked === true){
- checkedRadio = radioButtons[i].value;
- }
- }
- if(checkedRadio !== null){
- for(var i=0; i<radioButtons.length; ++i){
- if(radioButtons[i].disabled === false && radioButtons[i].id.indexOf(newCategory) != -1 && radioButtons[i].value === checkedRadio){
- radioButtons[i].checked = true;
- anyChecked = true;
- }
- }
- }
-
- /*if(!anyChecked){
- var activeBox = document.getElementById(newCategory+"Item"+"0");
- var radioString = new String(self.id+"single");
- if(activeBox !== null && activeBox.name == radioString) self.setValue(self.expanded + "." + activeBox.value);
- }*/
-
- var categoryTest;
- }
- $('.accordion').blur();
-
-};
-
-
-/**
- * Fires an event to the registry when the state of the component is changed
- *
- * @this {AccordionPicker}
- *
-*/
-SOTE.widget.AccordionPicker.prototype.fire = function(){
-
- if(REGISTRY){
- REGISTRY.fire(this);
- }
- else{
- alert("No REGISTRY found! Cannot fire to REGISTRY from AccordionPicker!");
- }
-
-};
-
-/**
- * Sets the selected option(s) in the AccordionPicker from the passed in value(s), if valid
- * [containerId]=[options] (options is a dot delimited string with the first item containing
- * a single select item, and the remaining items containing the multi-select items).
- *
- * @this {AccordionPicker}
- * @param {String} value is a dot delimited string of the key(s) of the option(s) to be set as selected
- * @returns {boolean} true or false depending on if the new value(s) validates
- *
-*/
-SOTE.widget.AccordionPicker.prototype.setValue = function(values){
- var selectedItems = values.split(".");
- var expanded = selectedItems[0];
- var base = selectedItems[1];
- var radioButtons = document.getElementsByName(this.id+"single");
- var found = false;
-
- var expandedName = expanded;
- var reg = new RegExp(this.id+"(.+)");
- if(reg.test(expanded) == false){
- expandedName = this.id + expanded;
- }
- if(this.expanded === null || this.expanded !== expandedName) {
- $('.accordion').accordion("activate","#"+expandedName);
- this.expanded = expandedName;
- }
-
- for(var i=0; i < radioButtons.length; ++i){
- if(radioButtons[i].value === base && radioButtons[i].disabled === false && radioButtons[i].id.indexOf(expanded) != -1 ){
- radioButtons[i].checked = true;
- found = true;
- break;
- }
- }
-
- if(!found){
- for(var i=0; i < radioButtons.length; ++i){
- if(radioButtons[i].value === base && radioButtons[i].disabled === false){
- radioButtons[i].checked = true;
- }
- }
- }
-
-
- var checkboxes = document.getElementsByName(this.id+"multi");
-
- for(var i=0; i < checkboxes.length; ++i){
- for(var j=1; j < selectedItems.length; ++j){
- if(checkboxes[i].value === selectedItems[j] && checkboxes[i].disabled === false){
- checkboxes[i].checked = true;
- }
- }
- }
-
- this.value = values;
- this.fire();
- $('.accordion').blur();
- return this.validate();
-
-};
-
-/**
- * Sets the selected option(s) in the AccordionPicker from the passed in value(s), if valid
- * [containerId]=[options] (options is a dot delimited string with the first item containing
- * a single select item, and the remaining items containing the multi-select items).
- *
- * @this {AccordionPicker}
- * @param {String} value is a dot delimited string of the key(s) of the option(s) to be set as selected
- * @returns {boolean} true or false depending on if the new value(s) validates
- *
-*/
-SOTE.widget.AccordionPicker.prototype.syncCheckboxes = function(targetEl){
- var targetState = targetEl.checked;
- var checkboxes = document.getElementsByName(this.id+"multi");
-
- for(var i=0; i < checkboxes.length; ++i){
- if(checkboxes[i].value === targetEl.value && checkboxes[i].disabled === false){
- checkboxes[i].checked = targetState;
- }
- }
-
- return;
-
-};
-
-/**
- * Gets the currently selected option(s) [containerId]=[options]
- *
- * @this {AccordionPicker}
- * @returns {String} [container]=[options], options being a dot delimited string
- * representing the key(s) of the currently selected option(s)
- *
-*/
-SOTE.widget.AccordionPicker.prototype.getValue = function(){
- var selected = new Array();
- var added = new Object();
- var radioButtons = document.getElementsByName(this.id+"single");
-
- for(var i=0; i < radioButtons.length; ++i){
- if(radioButtons[i].checked === true){
- selected.push(radioButtons[i].value);
- break;
- }
- }
-
- if(selected.length === 0){ selected.push(""); };
-
- var checkboxes = document.getElementsByName(this.id+"multi");
-
- for(var i=0; i < checkboxes.length; ++i){
- if(checkboxes[i].checked === true){
- if(! (checkboxes[i].value in added) ){
- selected.push(checkboxes[i].value);
- added[checkboxes[i].value] = 1;
- }
- }
- }
-
- var reg = new RegExp(this.id+"(.+)");
-
- var expanded = reg.exec(this.expanded);
-
- var value = expanded[1] + "." + selected.join(".");
- return this.id + "=" + value;
-};
-
-/**
- * Change the component based on dependencies (i.e. Available Options, Selected)
- *
- * @this {AccordionPicker}
- * @param {String} querystring contains all values of dependencies (from registry)
- * @returns {boolean} true or false depending on if the selected value still validats with criteria change
- *
-*/
-SOTE.widget.AccordionPicker.prototype.updateComponent = function(querystring){
- var qs = (querystring === undefined)? "":querystring;
- SOTE.util.getJSON(
- this.dataSourceUrl+"?"+querystring,
- {self:this,qs:querystring},
- SOTE.widget.AccordionPicker.handleUpdateSuccess,
- SOTE.widget.AccordionPicker.handleUpdateFailure
- );
-};
-
-/**
- * Static function to handle a successful retrieval from the data accessor
- *
- * @this {AccordionPicker}
- * @param {Object,String,Object,Object} data is the data passed back from the call, status is the response status, xhr is the applicable xmlhttprequest object, args are the custom arguments passed
- *
-*/
-SOTE.widget.AccordionPicker.handleUpdateSuccess = function(data,status,xhr,args){
- var expanded = SOTE.util.extractFromQuery("hazard",args.qs);
- data.expanded = (expanded !== undefined && expanded !== "" && expanded !== null)? expanded:data.expanded;
- data.selected = (data.selected === undefined || data.selected === "")? SOTE.util.extractFromQuery(args.self.id,args.self.getValue()):data.selected;
- args.self.items = data;
- args.self.render();
-};
-
-/**
- * Static function to handle a failed retrieval from the data accessor
- *
- * @this {AccordionPicker}
- * @param {Object,String,String,Object} xhr is the applicable xmlhttprequest object, status is the response status, error is the thrown error, args are the custom arguments passed
- *
-*/
-SOTE.widget.AccordionPicker.handleUpdateFailure = function(xhr,status,error,args){
- alert("Failed to load data accessor: " + error);
-};
-
-
-/**
- * Sets the selected option(s) from the query string [containerId]=[options]
- *
- * @this {AccordionPicker}
- * @param {String} qs contains the querystring
- * @returns {boolean} true or false depending on whether the new option validates
- *
-*/
-SOTE.widget.AccordionPicker.prototype.loadFromQuery = function(qs){
- return this.setValue(SOTE.util.extractFromQuery(this.id,qs));
-};
-
-/**
- * Validates that the selected option(s) is not null, only one radio button is selected cross category
- * and all options are within the scope of available options
- *
- * @this {AccordionPicker}
- * @returns {boolean} true or false depending on whether the selected option(s) meet the validation criteria
-*/
-SOTE.widget.AccordionPicker.prototype.validate = function(){
- var isValid = true;
- var radioCount = 0;
- var radioButtons = document.getElementsByName(this.id+"single");
-
- for(var i=0; i < radioButtons.length; ++i){
- if(radioButtons[i].checked === true){
- ++radioCount;
- }
- if(radioButtons[i].disabled === true && radioButtons[i].checked === true){
- this.setStatus("Disabled items cannot be selected!");
- isValid = false;
- }
- }
-
- if(radioCount > 1){
- isValid = false;
- this.setStatus("Multiple single-select items selected!");
- }
-
- return isValid;
-
-};
-
-/**
- * Sets the data accessor that provides state change instructions given dependencies
- *
- * @this {AccordionPicker}
- * @param {String} datasourceurl is the relative location of the data accessor
- *
-*/
-SOTE.widget.AccordionPicker.prototype.setDataSourceUrl = function(dataSourceUrl){
- this.dataSourceUrl = dataSourceUrl;
-};
-
-/**
- * Gets the data accessor
- *
- * @this {AccordionPicker}
- * @returns {String} the relative location of the accessor
- *
-*/
-SOTE.widget.AccordionPicker.prototype.getDataSourceUrl = function(){
- return this.dataSourceUrl;
-};
-
-/**
- * Sets the status of the component
- *
- * @this {AccordionPicker}
- * @param {String} s the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.AccordionPicker.prototype.setStatus = function(s){
- this.statusStr = s;
-};
-
-/**
- * Gets the status of the component
- *
- * @this {AccordionPicker}
- * @returns {String} the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.AccordionPicker.prototype.getStatus = function(){
- return this.statusStr;
-};
-
-
-// Additional Functions
-// removeOptions, addOptions
diff --git a/src/js/bank.js b/src/js/bank.js
deleted file mode 100644
index a28888996..000000000
--- a/src/js/bank.js
+++ /dev/null
@@ -1,842 +0,0 @@
-SOTE.namespace("SOTE.widget.Bank");
-
-SOTE.widget.Bank.prototype = new SOTE.widget.Component;
-
-/**
- * Instantiate the Bank
- *
- * @class A selection device classifying radio buttons/checkboxes into categories that are displayed in Accordion form.
- * Radio buttons allow single selection accross categories. Checkboxes allow multiple selections accross categories.
- * Radio selections cannot span multiple categories.
- * @constructor
- * @this {Bank}
- * @param {String} containerId is the container id of the div in which to render the object
- * @param {Object} [config] is a hash allowing configuration of this component
- * @config {Object[]} [items] a JS Array of JS Objects: items.category[i..n].key, items.category[i..n].value
- * , items.category[i..n].action, items.type[i..n] representing the available options
- * @config {String} [selected] the key of the initially selected option(s)
- * @augments SOTE.widget.Component
- *
-*/
-SOTE.widget.Bank = function(containerId, config){
- this.log = Logging.getLogger("Worldview.Widget.Bank");
- this.VALID_PROJECTIONS = ["geographic", "arctic", "antarctic"];
- this.hidden = {};
-
- //Get the ID of the container element
- this.container=document.getElementById(containerId);
- if (this.container==null){
- this.setStatus("Error: element '"+containerId+"' not found!",true);
- return;
- }
- this.id = containerId;
- //Store the container's ID
- this.containerId=containerId;
-
- //Define an object for holding configuration
- if (config===undefined){
- config={};
- }
-
- if(config.title === undefined){
- config.title = "My Bank";
- }
-
- if(config.categories === undefined){
- config.categories = ["Category 1","Category 2"];
- }
-
- if(config.callback === undefined){
- config.callback = null;
- }
-
- if(config.state === undefined || config.state === ""){
- config.state = "geographic";
- }
-
-
- this.state = config.state;
- //console.log("state: " + this.state);
- this.selected = config.selected;
- this.values = this.unserialize(this.selected[this.state]);
-
- this.dataSourceUrl = config.dataSourceUrl;
- //console.log("dataSourceUrl: " + this.dataSourceUrl);
- this.title = config.title;
- this.callback = config.callback;
- this.selector = config.selector;
- this.meta = new Object;
- this.buildMetaDone = false;
- /*this.meta["MODIS_Terra_CorrectedReflectance_TrueColor"] = {label:"Corrected Reflectance (True Color)",sublabel:"Terra / MODIS"};
- this.meta["fires48"] = {label:"Fires (Past 48 Hours)",sublabel:"MODIS Fire and Thermal Anomalies"};
- this.meta["AIRS_Dust_Score"] = {label:"Dust Score",sublabel:"Aqua / AIRS"};
- this.meta["OMI_Aerosol_Index"] = {label:"Aerosol Index",sublabel:"Aura / OMI"};*/
- this.categories = config.categories;
- this.initRenderComplete = false;
- this.dataSourceUrl = config.dataSourceUrl;
- this.statusStr = "";
- this.config = config.config;
- this.paletteWidget = config.paletteWidget;
- this.queryString = "";
- this.noFireVal = null;
- this.init();
- //this.updateComponent(this.id+"=baselayers.MODIS_Terra_CorrectedReflectance_TrueColor-overlays.fires48.AIRS_Dust_Score.OMI_Aerosol_Index")
-
-};
-
-SOTE.widget.Bank.prototype.buildMeta = function(cb,val){
- this.buildMetaDone = false;
- var data = this.config.ap_products[this.state];
- SOTE.widget.Bank.handleMetaSuccess(data, null, null, {
- self: this,
- callback: cb,
- val: val
- });
-};
-
-SOTE.widget.Bank.handleMetaSuccess = function(data,status,xhr,args){
- var self = args.self;
- for(var i in data){
- if(i != "palettes") {
- for(var j=0; j<data[i].length; j++){
-
- self.meta[data[i][j].value] = {label:data[i][j].label,sublabel:data[i][j].sublabel,type:data[i][j].type};
-
- }
- }
- }
-
- /* TODO: This breaks when switching to polar projections
- var key = data["Floods"][0].value;
- //console.log("Key = " + key);
- //console.log("Meta Label = " + self.meta[key].label);
- //console.log("Meta Sublabel = " + self.meta[key].sublabel);
- */
- $.each(self.meta, function(name, meta) {
- if ( name in self.config.layers) {
- var layer = self.config.layers[name];
- if ( "rendered" in layer ) {
- meta.units = layer.units;
- meta.min = ( layer.min === undefined )
- ? "&nbsp;&nbsp;&nbsp;&nbsp"
- : layer.min;
- meta.max = ( layer.max === undefined )
- ? "&nbsp;&nbsp;&nbsp;"
- : layer.max;
- meta.bins = layer.bins;
- meta.stops = layer.stops;
- meta.palette = self.config.palettes[layer.rendered];
- }
- }
- });
- if(args.callback){
- args.callback({self:self,val:args.val});
- }
- else{
- self.values = null;
- self.values = self.unserialize(self.selected[self.state]);
- self.render();
- self.fire();
- }
- self.buildMetaDone = true;
-};
-
-/**
- * Displays all options in HTML in an Accordion format (see JQuery UI Accordion) with the selected states being indicated
- * by radio button and checkbox selection. All callbacks should be set. The component UI should be rendered
- * with controllers to call the events.
- *
- *
- * @this {Bank}
- *
-*/
-SOTE.widget.Bank.prototype.init = function(){
-
- this.buildMeta();
-
- if(REGISTRY){
- REGISTRY.register(this.id,this);
- }
- else{
- alert("No REGISTRY found! Cannot register Bank!");
- }
-
-
-};
-
-/**
- * Renders the UI accordion from this.items
- *
- *
- * @this {Bank}
- *
-*/
-SOTE.widget.Bank.prototype.render = function(){
-
- this.container.innerHTML = "";
-
-/* var tabs = document.createElement("ul");
- tabs.innerHTML = "<li><a href='#bank' class='activetab'>Active</a></li><li><a class='addlayerstab' href='#selectorbox'>Add Layers</a></li>";
- this.container.appendChild(tabs);
- */
- var tabs_height = $(".ui-tabs-nav").outerHeight(true);
- $('#'+this.id).addClass('bank');
- $('#'+this.id).height($('#'+this.id).parent().outerHeight() - tabs_height); /*var container = document.createElement("div");
- container.setAttribute("id","bank");
- container.setAttribute("class","bank");*/
-
- //var titleContainer = document.createElement("div");
- //titleContainer.setAttribute("class","tabContainer");
- //var title = document.createElement("h2");
- //title.innerHTML = "Active"; //this.title;
- /*var ext = document.createElement("a");
- ext.setAttribute("id","callSelectorLink");
- ext.setAttribute("class","callSelectorLink");
- ext.setAttribute("title","Show Product Listing");
- */
- //titleContainer.appendChild(title);
- //titleContainer.appendChild(ext);
-
- //container.appendChild(titleContainer);
-
- //$('#'+this.id).delegate('.callSelectorLink','click',{selector:this.selector},this.callback);
-
- for(var i=0; i<this.categories.length; i++){
- var formattedCategoryName = this.categories[i].replace(/\s/g, "");
- var category = document.createElement("ul");
- category.setAttribute("id",formattedCategoryName.toLowerCase());
- category.setAttribute("class",this.id+"category category");
-
- var categoryContainer = document.createElement("div");
- categoryContainer.setAttribute("id",this.id + formattedCategoryName);
- categoryContainer.setAttribute("class","categoryContainer");
-
- var categoryTitle = document.createElement("h3");
- categoryTitle.setAttribute("class","head");
- categoryTitle.innerHTML = this.categories[i];
-
- categoryContainer.appendChild(categoryTitle);
-
-
- if(this.values !== null && this.values[formattedCategoryName.toLowerCase()]){
- for(var j=0; j<this.values[formattedCategoryName.toLowerCase()].length; j++){
- var myVal = this.values[formattedCategoryName.toLowerCase()][j].value;
- var item = document.createElement("li");
- item.setAttribute("id",formattedCategoryName.toLowerCase()+"-"+myVal);
- item.setAttribute("class",this.id+"item item");
- item.innerHTML = "<a><img class='close bank-item-img' id='close"+myVal.replace(/:/g,"colon")+"' title='Remove Layer' src='images/close-red-x.png' /></a>";
- if(this.meta !== null && this.meta[myVal]){
- if(myVal in this.hidden){
- item.innerHTML += "<a class='hdanchor'><img class='hide hideReg bank-item-img' title='Show Layer' id='hide"+myVal.replace(/:/g,"colon")+"' src='images/invisible.png' /></a>";
- }
- else {
- item.innerHTML += "<a class='hdanchor'><img class='hide hideReg bank-item-img' title='Hide Layer' id='hide"+myVal.replace(/:/g,"colon")+"' src='images/visible.png' /></a>";
- }
- item.innerHTML += "<h4>"+this.meta[myVal].label+"</h4>";
- item.innerHTML += "<p>"+this.meta[myVal].sublabel+"</p>";
- var m = this.meta[myVal];
-
- if(m && m.palette){
- var paletteString = "<div><span class='palette'><span class='p-min' style='margin-right:10px;'>"+m.min+"</span>" +
- "<canvas class='colorBar' id='canvas"+this.values[formattedCategoryName.toLowerCase()][j].value+"' width=100px height=14px'></canvas>" +
- "<span class='p-max' style='margin-left:10px;'>"+m.max+"</span>";
- if(m.units && m.units != ""){
- paletteString += "<span class='p-units' style='margin-left:3px;'>"+m.units+"</span></span></div>";
- }
- item.innerHTML += paletteString;
- }
-
- }
- else{
- item.innerHTML += "<h4>"+this.values[formattedCategoryName.toLowerCase()][j].value+"</h4>";
- }
- category.appendChild(item);
- }
- }
-
- categoryContainer.appendChild(category);
- this.container.appendChild(categoryContainer);
-
- }
- /*
- var selectorbox = document.createElement("div");
- selectorbox.setAttribute("id","selectorbox");
- this.container.appendChild(selectorbox);*/
-
- this.renderCanvases();
- /*var accordionToggler = document.createElement("a");
- accordionToggler.setAttribute("class","accordionToggler atcollapse");
- accordionToggler.setAttribute("title","Hide Products");
- this.isCollapsed = false;
- this.container.appendChild(accordionToggler);
- $('.accordionToggler').bind('click',{self:this},SOTE.widget.Bank.toggle);*/
- $("#"+this.id).undelegate(".close" ,'click');
- $("#"+this.id).undelegate(".hideReg" ,'click');
- $("#"+this.id).undelegate(".hideSingle" ,'click');
- $("#"+this.id).delegate(".close" ,'click',{self:this},SOTE.widget.Bank.removeValue);
- $("#"+this.id).delegate(".hideReg" ,'click',{self:this},SOTE.widget.Bank.toggleValue);
- $("#"+this.id).delegate(".hideSingle" ,'click',{self:this},SOTE.widget.Bank.toggleValue);
- $( "." + this.id + "category" ).sortable({items: "li:not(.head)", axis: "y", containment: "parent", tolerance: "pointer"});
- if($(window).width() > 720)
- {
- if(this.jsp){
- var api = this.jsp.data('jsp');
- if(api) api.destroy();
- }
- this.jsp = $( "." + this.id + "category" ).jScrollPane({autoReinitialise: false, verticalGutter:0});
- }
- $( "." + this.id + "category li" ).disableSelection();
- $( "." + this.id + "category" ).bind('sortstop',{self:this},SOTE.widget.Bank.handleSort);
-
- setTimeout(SOTE.widget.Bank.adjustCategoryHeights,1,{self:this});
-
- //this.hideAllRadioExceptTop();
-
- /*$('#'+this.id).tabs();
- //this.b = new SOTE.widget.Bank("products",{paletteWidget: window.palettes, dataSourceUrl:"ap_products.php",title:"My Layers",selected:{antarctic:"baselayers,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,antarctic_coastlines", arctic:"baselayers,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,arctic_coastlines",geographic:"baselayers,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,sedac_bound"},categories:["Base Layers","Overlays"],config:config});
- this.s = new SOTE.widget.Selector("selectorbox",{dataSourceUrl:"ap_products.php",categories:["Base Layers","Overlays"]}); */
-
- // Mark the component as ready in the registry if called via init()
- if ((this.initRenderComplete === false) && REGISTRY) {
- this.initRenderComplete = true;
- REGISTRY.markComponentReady(this.id);
- }
-
-};
-
-SOTE.widget.Bank.adjustCategoryHeights = function(args){
- var self = args.self;
- var heights = new Array;
- var container_height = $("#"+self.id).outerHeight(true);
- var labelHeight = 0;
- $('#'+self.id+' .head').each(function(){
- labelHeight += $(this).outerHeight(true);
- });
- container_height -= labelHeight;
- //console.log("This.id: " + container_height);
- for(var i=0; i<self.categories.length; i++){
- var formattedCategoryName = self.categories[i].replace(/\s/g, "");
- var actual_height = 0;
- var count = 0;
- $('#' + formattedCategoryName.toLowerCase() + ' li').each(function(){
- actual_height += $(this).outerHeight(true);
- count++;
- });
-
- heights.push({name:formattedCategoryName.toLowerCase(),height:actual_height,count:count});
- }
-
- if(heights[0].height + heights[1].height > container_height){
- if(heights[0].height > container_height/2) {
- heights[0].height = container_height/2;
- }
-
- heights[1].height = container_height - heights[0].height;
-
- }
-
- $("#" + heights[0].name).css("height",heights[0].height+"px");
- $("#" + heights[1].name).css("height",heights[1].height+"px");
-
- SOTE.widget.Bank.reinitializeScrollbars({self:self});
-};
-
-SOTE.widget.Bank.reinitializeScrollbars = function(o) {
- var pane = $("." + o.self.id + "category").each(function(){
- var api = $(this).data('jsp');
- if(api) api.reinitialise();
- });
-};
-
-SOTE.widget.Bank.prototype.renderCanvases = function(){
-
- var openPaletteSelector = function(name) {
- return function() {
- if ( !Worldview.Support.allowCustomPalettes() ) {
- Worldview.Support.showUnsupportedMessage();
- } else {
- self.paletteWidget.displaySelector(name);
- }
- };
- };
-
- var self = this;
-
- for(var i=0; i<this.categories.length; i++){
- var formattedCategoryName = this.categories[i].replace(/\s/g, "");
- if(this.values !== null && this.values[formattedCategoryName.toLowerCase()]){
- for(var j=0; j<this.values[formattedCategoryName.toLowerCase()].length; j++){
- var val = this.values[formattedCategoryName.toLowerCase()][j].value;
- var m = this.meta[this.values[formattedCategoryName.toLowerCase()][j].value];
- if(m && m.palette){
- var width = 100/m.palette.length;
- var canvas = document.getElementById("canvas"+val);
- if ( m.palette.stops.length > 1 ) {
- canvas.onclick = openPaletteSelector(val);
- canvas.style.cursor = "pointer";
- }
- var context = canvas.getContext('2d');
- var palette = this.paletteWidget.getPalette(this.values[formattedCategoryName.toLowerCase()][j].value);
-
- var spec = {
- selector: "#canvas" + val,
- bins: m.bins,
- stops: m.stops,
- palette: palette
- };
- Worldview.Palette.ColorBar(spec);
- }
- }
- }
- }
-};
-
-SOTE.widget.Bank.toggle = function(e,ui){
- var self = e.data.self;
- if(self.isCollapsed){
- $('.accordionToggler').removeClass('atexpand').addClass('atcollapse');
- $('.accordionToggler').attr("title","Hide Products");
- $('.bank').css('display','block');
- self.isCollapsed = false;
- }
- else{
- $('.accordionToggler').removeClass('atcollapse').addClass('atexpand');
- $('.accordionToggler').attr("title","Show Products");
- $('.bank').css('display','none');
- self.isCollapsed = true;
- }
-};
-
-SOTE.widget.Bank.handleSort = function(e,ui){
- var self = e.data.self;
- self.values = new Object;
- for(var i=0; i<self.categories.length; i++){
- var formatted = self.categories[i].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
- self.values[formatted] = new Array();
- jQuery('li[id|="'+formatted+'"]').each(function() {
- var item = jQuery( this );
- var id = item.attr("id");
- var vals = id.split("-");
- var val = vals.splice(0,1);
- val = vals.join("-");
- self.values[formatted].push({value:val});
- });
- }
- self.fire();
-
-};
-
-SOTE.widget.Bank.removeValue = function(e){
- var self = e.data.self;
- var val = e.target.id.replace(/colon/g,":");
- val = val.replace(/close/g,"");
- for(var i=0; i<self.categories.length; i++){
- var formatted = self.categories[i].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
- for(var j=0; j<self.values[formatted].length; j++){
- if(self.values[formatted][j].value == val){
- self.values[formatted].splice(j,1);
- }
- }
- }
- var formattedVal = "close"+val.replace(/:/g,"colon");
- //self.render();
- $("#"+self.id+" #"+formattedVal).parent().parent().remove();
- self.count--;
- self.fire();
-};
-
-SOTE.widget.Bank.toggleValue = function(e){
- var self = e.data.self;
- var val = e.target.id.replace(/colon/g,":");
- val = val.replace(/hide/g,"");
- for(var i=0; i<self.categories.length; i++){
- var formatted = self.categories[i].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
- if(self.values[formatted]){
- for(var j=0; j<self.values[formatted].length; j++){
- if(self.values[formatted][j].value == val){
- if(val in self.hidden){
- delete self.hidden[val];
- e.target.src = 'images/visible.png';
- $("#"+e.target.id).attr("title","Hide Layer");
- }
- else {
- self.hidden[val] = 1;
- e.target.src = 'images/invisible.png';
- $("#"+e.target.id).attr("title","Show Layer");
- }
-
-
- }
- }
- }
- }
- //var formattedVal = val.replace(/:/g,"colon");
- //self.render();
- //$("#"+self.id+" #"+formattedVal).parent().parent().remove();
- self.fire();
-};
-
-SOTE.widget.Bank.prototype.hideAllRadioExceptTop = function(){
- for(var i=0; i<this.categories.length - 1; i++){
- var formatted = this.categories[i].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
- for(var j=1; j<this.values[formatted].length; j++){
-
- this.hidden[this.values[formatted][j].value] = 1;
- $('#hide'+this.values[formatted][j].value).attr("src",'images/invisible.png');
-
- }
- }
-};
-
-SOTE.widget.Bank.radioToggleValue = function(e){
- var self = e.data.self;
- var val = e.target.id.replace(/colon/g,":");
- var cat = -1;
- var hidden = false;
- val = val.replace(/hide/g,"");
-
- for(var i=0; i<self.categories.length; i++){
- var formatted = self.categories[i].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
- if(self.values[formatted]){
- for(var j=0; j<self.values[formatted].length; j++){
- if(self.values[formatted][j].value == val){
- if(val in self.hidden){
- delete self.hidden[val];
- e.target.src = 'images/visible.png';
- for(var k=0; k<self.values[formatted].length; k++){
- if(self.values[formatted][k].value != val){
- self.hidden[self.values[formatted][k].value] = 1;
- $('#hide'+self.values[formatted][k].value).attr("src",'images/invisible.png');
- }
- }
- }
- else {
- self.hidden[val] = 1;
- e.target.src = 'images/invisible.png';
- if(j+1 < self.values[formatted].length){
- if(self.hidden[self.values[formatted][j+1].value]){
- delete self.hidden[self.values[formatted][j+1].value];
- $('#hide'+self.values[formatted][j+1].value).attr("src",'images/visible.png');
- }
- }
- else {
- if(self.hidden[self.values[formatted][0].value]){
- delete self.hidden[self.values[formatted][0].value];
- $('#hide'+self.values[formatted][0].value).attr("src",'images/visible.png');
-
- }
- }
- }
-
- }
- }
- }
- }
-
-
- //var formattedVal = val.replace(/:/g,"colon");
- //self.render();
- //$("#"+self.id+" #"+formattedVal).parent().parent().remove();
- self.fire();
-};
-
-
-
-/**
- * Fires an event to the registry when the state of the component is changed
- *
- * @this {Bank}
- *
-*/
-SOTE.widget.Bank.prototype.fire = function(){
- setTimeout(SOTE.widget.Bank.adjustCategoryHeights,1,{self:this});
- $("#"+this.id).trigger("fire");
-
- if(REGISTRY){
- REGISTRY.fire(this,this.noFireVal);
- this.noFireVal = null;
- }
- else{
- alert("No REGISTRY found! Cannot fire to REGISTRY from Bank!");
- }
-
-};
-
-/**
- * Sets the selected option(s) in the Bank from the passed in value(s), if valid
- * [containerId]=[options] (options is a dot delimited string with the first item containing
- * a single select item, and the remaining items containing the multi-select items).
- *
- * @this {Bank}
- * @param {String} value is a dot delimited string of the key(s) of the option(s) to be set as selected
- * @returns {boolean} true or false depending on if the new value(s) validates
- *
-*/
-SOTE.widget.Bank.prototype.setValue = function(valString, selector){
-
- this.values = this.unserialize(valString, selector);
- var valid = true;
- var self = this;
-
- this.render();
- this.fire();
-
-};
-
-SOTE.widget.Bank.prototype.currCount = function(){
- return this.count;
-};
-
-/**
- * Gets the currently selected option(s) [containerId]=[options]
- *
- * @this {Bank}
- * @returns {String} [container]=[options], options being a dot delimited string
- * representing the key(s) of the currently selected option(s)
- *
-*/
-SOTE.widget.Bank.prototype.getValue = function(){
-
- var value = this.serialize(this.values);
- return this.id + "=" + value;
-};
-
-SOTE.widget.Bank.prototype.value = function(){
-
- var value = this.serialize(this.values);
- return value;
-};
-
-SOTE.widget.Bank.prototype.serialize = function(values){
- var serialized = "";
- for(var i=0; i<this.categories.length; i++){
- if(i > 0){
- serialized += "~";
- }
- var formatted = this.categories[i].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
-
- serialized += formatted;
- if(values[formatted]){
- for(var j=0; j<values[formatted].length; j++){
- if(!(values[formatted][j].value in this.hidden)){
- serialized += "," + values[formatted][j].value;
- }else {
- serialized += "," + "!" + values[formatted][j].value;
- }
- }
- }
- }
- return serialized;
-};
-
-SOTE.widget.Bank.prototype.unserialize = function(string, selector){
- var unserialized = new Object;
- var hideIndicator = /^!/;
- var categories = string.split("~");
- var values = [];
- this.count = 0;
- for(var i=0; i<categories.length; i++){
- var items = categories[i].split(/[\.,]/);
- unserialized[items[0]] = new Array;
- for(var j=1; j<items.length; j++){
- if ( this.meta && !this.meta[items[j]] && !hideIndicator.test(items[j]) ) {
- this.log.warn("No such product: " + items[j]);
- } else {
- if(hideIndicator.test(items[j])){
- items[j] = items[j].replace(/!/g, "");
- this.hidden[items[j]] = 1;
- }
- else {
- if(!selector){
- delete this.hidden[items[j]];
- }
- }
-
- unserialized[items[0]].push({"value":items[j]});
- values.push(items[j]);
- this.count++;
- }
- }
-
- }
-
- for(var key in this.hidden){
- if( values.indexOf(key) < 0 ){
- delete this.hidden[key];
- }
- }
-
- return unserialized;
-};
-
-/**
- * Change the component based on dependencies (i.e. Available Options, Selected)
- *
- * @this {Bank}
- * @param {String} querystring contains all values of dependencies (from registry)
- * @returns {boolean} true or false depending on if the selected value still validats with criteria change
- *
-*/
-SOTE.widget.Bank.prototype.updateComponent = function(querystring){
- var qs = (querystring === undefined)? "":querystring;
- /*SOTE.util.getJSON(
- this.dataSourceUrl+"?"+querystring,
- {self:this,qs:querystring},
- SOTE.widget.Bank.handleUpdateSuccess,
- SOTE.widget.Bank.handleUpdateFailure
- );*/
- SOTE.widget.Bank.handleUpdateSuccess(this,qs);
-};
-
-/**
- * Static function to handle a successful retrieval from the data accessor
- *
- * @this {Bank}
- * @param {Object,String,Object,Object} data is the data passed back from the call, status is the response status, xhr is the applicable xmlhttprequest object, args are the custom arguments passed
- *
-*/
-SOTE.widget.Bank.handleUpdateSuccess = function(self,qs){
- /*var expanded = SOTE.util.extractFromQuery("hazard",args.qs);
- data.expanded = (expanded !== undefined && expanded !== "" && expanded !== null)? expanded:data.expanded;
- data.selected = (data.selected === undefined || data.selected === "")? SOTE.util.extractFromQuery(args.self.id,args.self.getValue()):data.selected;*/
- var projection = SOTE.util.extractFromQuery("switch", qs);
- self.noFireVal = (SOTE.util.extractFromQuery("norecurse",qs) === "")? null: SOTE.util.extractFromQuery("norecurse",qs);
- if (projection === "") {
- projection = self.VALID_PROJECTIONS[0];
- } else if ($.inArray(projection, self.VALID_PROJECTIONS) < 0) {
- self.log.warn("Invalid projection: " + projection + ", using: " +
- self.VALID_PROJECTIONS[0]);
- projection = self.VALID_PROJECTIONS[0];
- }
- if(projection == self.state){
- var vals = SOTE.util.extractFromQuery("selectorbox",qs)
- self.setValue(vals, "selector");
- }
- else {
- self.state = projection;
- self.buildMeta();
- }
-};
-
-/**
- * Static function to handle a failed retrieval from the data accessor
- *
- * @this {Bank}
- * @param {Object,String,String,Object} xhr is the applicable xmlhttprequest object, status is the response status, error is the thrown error, args are the custom arguments passed
- *
-*/
-SOTE.widget.Bank.handleUpdateFailure = function(xhr,status,error,args){
- alert("Failed to load data accessor: " + error);
-};
-
-
-/**
- * Sets the selected option(s) from the query string [containerId]=[options]
- *
- * @this {Bank}
- * @param {String} qs contains the querystring
- * @returns {boolean} true or false depending on whether the new option validates
- *
-*/
-SOTE.widget.Bank.prototype.loadFromQuery = function(qs){
- var newState = SOTE.util.extractFromQuery("switch",qs);
-
- if (newState === "" ) {
- newState = "geographic";
- }
- if(this.state != newState){
- this.state = newState;
- this.updateComponent(qs);
- }
- else {
- this.sleep(SOTE.util.extractFromQuery(this.id,qs));
- }
-};
-
-SOTE.widget.Bank.prototype.sleep = function(v){
- SOTE.widget.Bank.loadValue({self:this,val:v});
-};
-
-SOTE.widget.Bank.loadValue = function(args){
- if(args.self.buildMetaDone == true) {
- // If products are not specified, use the defaults
- if ( args.val.length === 0 ) {
- args.self.setValue(args.self.selected[args.self.state]);
- } else {
- args.self.setValue(args.val);
- }
- }
- else {
- args.self.sleep(args.val);
- }
-};
-
-/**
- * Validates that the selected option(s) is not null, only one radio button is selected cross category
- * and all options are within the scope of available options
- *
- * @this {Bank}
- * @returns {boolean} true or false depending on whether the selected option(s) meet the validation criteria
-*/
-SOTE.widget.Bank.prototype.validate = function(){
-
- var isValid = true;
- return isValid;
-
-};
-
-SOTE.widget.Bank.prototype.setHeight = function(height){
- $("#"+this.id).css("height",height+"px");
- SOTE.widget.Bank.adjustCategoryHeights({self:this});
-};
-
-/**
- * Sets the data accessor that provides state change instructions given dependencies
- *
- * @this {Bank}
- * @param {String} datasourceurl is the relative location of the data accessor
- *
-*/
-SOTE.widget.Bank.prototype.setDataSourceUrl = function(dataSourceUrl){
- this.dataSourceUrl = dataSourceUrl;
-};
-
-/**
- * Gets the data accessor
- *
- * @this {Bank}
- * @returns {String} the relative location of the accessor
- *
-*/
-SOTE.widget.Bank.prototype.getDataSourceUrl = function(){
- return this.dataSourceUrl;
-};
-
-/**
- * Sets the status of the component
- *
- * @this {Bank}
- * @param {String} s the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Bank.prototype.setStatus = function(s){
- this.statusStr = s;
-};
-
-/**
- * Gets the status of the component
- *
- * @this {Bank}
- * @returns {String} the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Bank.prototype.getStatus = function(){
- return this.statusStr;
-};
-
diff --git a/src/js/menuPicker.js b/src/js/menuPicker.js
deleted file mode 100644
index aae9fd3a8..000000000
--- a/src/js/menuPicker.js
+++ /dev/null
@@ -1,332 +0,0 @@
-SOTE.namespace("SOTE.widget.MenuPicker");
-
-SOTE.widget.MenuPicker.prototype = new SOTE.widget.Component;
-
-/**
- * A selection device with similar functionality to a drop-down selection list, but built with HTML
- * elements for maximum styling and flexibility.
- *
- * @module SOTE.widget
- * @class MenuPicker
- * @constructor
- * @this {menuPicker}
- * @param {String} containerId is the container id of the div in which to render the object
- * @param {Object} [config] is a hash allowing configuration of this component
- * @config {Object[]} [items] a JS Array of JS Objects: items[i..n].label, items[i..n].value pairs
- * representing the available options. Each object can also contain an optional disabled: true
- * @config {String} [selected] the key of the initially selected option
- * @augments SOTE.widget.Component
- *
-*/
-SOTE.widget.MenuPicker = function(containerId, config){
- //Get the ID of the container element
- this.container = document.getElementById(containerId);
-
- if (this.container == null){
- this.setStatus("Error: element '" + containerId + "' not found!");
- return;
- }
- this.id = containerId;
-
- //Define an object for holding configuration
- if (config === undefined)
- config = {};
- if (config.isCollapsible === undefined)
- config.isCollapsible = false;
- if (config.dataSourceUrl === undefined)
- config.dataSourceUrl = null;
-
- this.selectedValue = null;
- this.menuIsCollapsible = config.isCollapsible;
- this.dataSourceUrl = config.dataSourceUrl;
- this.initRenderComplete = false;
- this.statusStr = "";
- this.init();
-};
-
-/**
- * Displays all options in HTML with the selected option indicated with styles.
- * All callbacks should be set. The component UI should be rendered with controllers to call the events.
- *
- * @this {menuPicker}
- *
-*/
-SOTE.widget.MenuPicker.prototype.init = function(){
- this.updateComponent();
-
- if (REGISTRY)
- REGISTRY.register(this.id,this);
- else
- alert("No REGISTRY so could not register MenuPicker");
-};
-
-/*
- * Renders the UI menu
- */
-SOTE.widget.MenuPicker.prototype.render = function(){
- // Get rid of previously defined stuff
- this.container.innerHTML = "";
- $('#' + this.id).undelegate("click");
-
- var menuUL = document.createElement('ul');
- var ulClass = "menuPicker";
- if (this.menuIsCollapsible === true)
- ulClass += " collapsible";
- menuUL.setAttribute('class', ulClass);
-
- for (var i=0; i < this.menuItems.length; i++) {
- // Generate liID and save for use in validate()
- var liID = this.id + "_" + "item" + i;
- this.menuItems[i].liID = liID;
-
- var menuLI = document.createElement('li');
- menuLI.setAttribute('id',liID);
- menuLI.innerHTML = "<div>" + this.menuItems[i].label + "</div>";
-
- if ((this.selectedValue !== null) && (this.menuItems[i].value === this.selectedValue)) {
- this.setValue(this.menuItems[i].value);
- menuLI.setAttribute('class', "selected");
- }
-
- menuUL.appendChild(menuLI);
-
- if (this.menuItems[i].disabled !== true)
- $('#' + this.id).delegate("#" + liID, "click", {val:this.menuItems[i].value, self:this}, SOTE.widget.MenuPicker.bindClick);
- // Use when we change to JQuery 1.7
- //$('#' + this.id).on("click", "#" + liID, {val:this.menuItems[i].value, self:this}, SOTE.widget.MenuPicker.bindClick);
- else
- menuLI.setAttribute('class', "disabled");
- }
- // Mark the component as ready in the registry if called via init()
- if ((this.initRenderComplete === false) && REGISTRY) {
- this.initRenderComplete = true;
- REGISTRY.markComponentReady(this.id);
- }
-
- this.container.appendChild(menuUL);
-};
-
-/**
- * Handler for clicking on an li
- */
-SOTE.widget.MenuPicker.bindClick = function(event){
- event.data.self.setValue(event.data.val);
-};
-
-/**
- * Fires an event in the registry when the component value is changed
- *
- * @this {SOTE.widget.MenuPicker}
- */
-SOTE.widget.MenuPicker.prototype.fire = function(){
- if(REGISTRY){
- REGISTRY.fire(this);
- }
- else{
- alert("No REGISTRY so no event REGISTRY event to fire");
- }
-};
-
-/**
- * Sets the selected option in the menuPicker to the passed in value, if valid ([containerId]=[key])
- *
- * @this {menuPicker}
- * @param {String} value is the key of the option to be set as selected ([containerId]=[key])
- * @returns {boolean} true or false depending on if the value validates
- *
-*/
-SOTE.widget.MenuPicker.prototype.setValue = function(value){
- var oldSelectedValue = this.selectedValue;
- var oldSelectedId = this.selectedId;
- this.selectedValue = value;
- var validation = this.validate();
-
- if (validation) {
- $('#' + oldSelectedId).removeClass('selected');
- $('#' + this.selectedId).addClass('selected');
- }
- else {
- this.selectedValue = oldSelectedValue;
- }
- this.fire();
- return validation;
-};
-
-/**
- * Gets the currently selected option ([containerId]=[key])
- *
- * @this {menuPicker}
- * @returns {String} a string representing the key of the currently selected option ([containerId]=[key])
- *
-*/
-SOTE.widget.MenuPicker.prototype.getValue = function(){
- return this.id + "=" + this.selectedValue;
-};
-
-/**
- * Change the component based on dependencies (i.e. Available Options, Selected)
- *
- * @this {menuPicker}
- * @param {String} querystring contains all values of dependencies (from registry)
- * @returns {boolean} true or false depending on if the selected value still validates with modified criteria
- *
-*/
-SOTE.widget.MenuPicker.prototype.updateComponent = function(querystring){
- var qs = (querystring === undefined) ? "" : querystring;
- if (this.dataSourceUrl !== null)
- SOTE.util.getJSON(
- this.dataSourceUrl + "?" + qs,
- {self:this},
- SOTE.widget.MenuPicker.handleUpdateSuccess,
- SOTE.widget.MenuPicker.handleUpdateFailure
- );
-};
-
-/**
- * Static function to handle a successful retrieval from the data accessor
- *
- * @this {AccordionPicker}
- * @param {Object,String,Object,Object} data is the data passed back from the call, status is the response status, xhr is the applicable xmlhttprequest object, args are the custom arguments passed
- *
-*/
-SOTE.widget.MenuPicker.handleUpdateSuccess = function(data,status,xhr,args){
- var value = SOTE.util.extractFromQuery(args.self.id,args.self.getValue());
- args.self.menuItems = data.items;
- args.self.selectedValue = data.selected;
-
- // If the old selected LI no longer exists, set selected val to null
- if (!args.self.setValue(value))
- args.self.value = null;
- args.self.render();
-};
-
-/**
- * Static function to handle a failed retrieval from the data accessor
- *
- * @this {AccordionPicker}
- * @param {Object,String,String,Object} xhr is the applicable xmlhttprequest object, status is the response status, error is the thrown error, args are the custom arguments passed
- *
-*/
-SOTE.widget.MenuPicker.handleUpdateFailure = function(xhr,status,error,args){
- alert("Failed to load data accessor: " + error);
-};
-
-/**
- * Sets the selection option from the query string ([containerId]=[key])
- *
- * @this {menuPicker}
- * @param {String} qs contains the querystring ([containerId]=[key])
- *
-*/
-SOTE.widget.MenuPicker.prototype.loadFromQuery = function(qs){
- return this.setValue(SOTE.util.extractFromQuery(this.id,qs));
-};
-
-/**
- * Validates that the selected option is not null and is one of the available options
- *
- * @this {menuPicker}
- * @returns {boolean} true or false depending on whether the selected option is not null and
- * is one of the available options
-*/
-SOTE.widget.MenuPicker.prototype.validate = function(){
- var valid = false;
- var matcheditem = false;
-
- for (var i=0; i < this.menuItems.length; i++) {
- if ((this.menuItems[i].value === this.selectedValue) && (this.menuItems[i].disabled !== true)) {
- valid = true;
- matcheditem = true;
- this.selectedId = this.menuItems[i].liID;
- break;
- }
- else if (this.menuItems[i].value === this.selectedValue) {
- this.setStatus("List item with value = " + this.menuItems[i].value + " is disabled");
- matcheditem = true;
- break;
- }
- }
- if (matcheditem == false)
- this.setStatus("List item value = " + this.selectedValue + " is not valid");
-
- return valid;
-};
-
-/**
- * Sets the data accessor that provides state change instructions given dependencies
- *
- * @this {menuPicker}
- * @param {String} datasourceurl is the relative location of the data accessor
- *
-*/
-SOTE.widget.MenuPicker.prototype.setDataSourceUrl = function(datasourceurl){
- this.dataSourceUrl = datasourceurl;
-};
-
-/**
- * Gets the data accessor
- *
- * @this {menuPicker}
- * @returns {String} the relative location of the accessor
- *
-*/
-SOTE.widget.MenuPicker.prototype.getDataSourceUrl = function(){
- return this.dataSourceUrl;
-};
-
-/**
- * Sets the status of the component
- *
- * @this {menuPicker}
- * @param {String} s the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.MenuPicker.prototype.setStatus = function(s){
- this.statusStr = s;
-};
-
-/**
- * Gets the status of the component
- *
- * @this {menuPicker}
- * @returns {String} the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.MenuPicker.prototype.getStatus = function(){
- return this.statusStr;
-};
-
-/**
- * Add an item to the options list
- *
- * @this {menuPicker}
- * @param {Object} item is a key/value pair
- * @returns {boolean} true or false depending on if the item was successfully added
- *
-*/
-SOTE.widget.MenuPicker.prototype.addItem = function(item){
- // Content
-};
-
-/**
- * Remove an item from the options list
- *
- * @this {menuPicker}
- * @param {String} the key of the item to be removed
- * @returns {boolean} true or false depending on if the operation was successful
- *
-*/
-SOTE.widget.MenuPicker.prototype.removeItem = function(item){
- // Content
-};
-
-/**
- * Returns the total number of items currently in the options list
- *
- * @this {menuPicker}
- * @returns {Number} the number of items currently in the options list
- *
-*/
-SOTE.widget.MenuPicker.prototype.length = function(){
- // Content
-};
\ No newline at end of file
diff --git a/src/js/products.js b/src/js/products.js
deleted file mode 100644
index ded885518..000000000
--- a/src/js/products.js
+++ /dev/null
@@ -1,367 +0,0 @@
-SOTE.namespace("SOTE.widget.Products");
-
-SOTE.widget.Products.prototype = new SOTE.widget.Component;
-
-/**
- * Instantiate the Products
- *
- * @class A selection device classifying radio buttons/checkboxes into categories that are displayed in Accordion form.
- * Radio buttons allow single selection accross categories. Checkboxes allow multiple selections accross categories.
- * Radio selections cannot span multiple categories.
- * @constructor
- * @this {Products}
- * @param {String} containerId is the container id of the div in which to render the object
- * @param {Object} [config] is a hash allowing configuration of this component
- * @config {Object[]} [items] a JS Array of JS Objects: items.category[i..n].key, items.category[i..n].value
- * , items.category[i..n].action, items.type[i..n] representing the available options
- * @config {String} [selected] the key of the initially selected option(s)
- * @augments SOTE.widget.Component
- *
-*/
-SOTE.widget.Products = function(containerId, config){
- this.log = Logging.getLogger("Worldview.Widget.Products");
- //this.VALID_PROJECTIONS = ["geographic", "arctic", "antarctic"];
-
- //Get the ID of the container element
- this.container=document.getElementById(containerId);
- if (this.container==null){
- this.setStatus("Error: element '"+containerId+"' not found!",true);
- return;
- }
- this.id = containerId;
- //Store the container's ID
- this.containerId=containerId;
-
- //Define an object for holding configuration
- if (config===undefined){
- config={};
- }
-
- if(config.title === undefined){
- config.title = "My Products";
- }
-
- if(config.categories === undefined){
- config.categories = ["Category 1","Category 2"];
- }
-
- if(config.callback === undefined){
- config.callback = null;
- }
-
- if(config.state === undefined || config.state === ""){
- config.state = "geographic";
- }
-
-
- this.state = config.state;
- this.selected = config.selected;
- this.isCollapsed = false;
- this.dataSourceUrl = config.dataSourceUrl;
- this.categories = config.categories;
- this.config = config.config;
- this.paletteWidget = config.paletteWidget;
- this.events = Worldview.Events();
- this.initRenderComplete = false;
- this.init();
-
-};
-
-SOTE.widget.Products.HTML_TAB_ACTIVE_SELECTED =
- "<i class='productsIcon selected icon-layers'></i>" +
- "Active";
-
-SOTE.widget.Products.HTML_TAB_ACTIVE_UNSELECTED =
- "<i class='productsIcon selected icon-layers' title='Active'></i>";
-
-SOTE.widget.Products.HTML_TAB_ADD_SELECTED =
- "<i class='productsIcon selected icon-add'></i>" +
- "Add Layers";
-
-SOTE.widget.Products.HTML_TAB_ADD_UNSELECTED =
- "<i class='productsIcon selected icon-add' title='Add Layers'></i>";
-
-SOTE.widget.Products.HTML_TAB_DOWNLOAD_SELECTED =
- "<i class='productsIcon selected icon-download'></i>" +
- "Download";
-
-SOTE.widget.Products.HTML_TAB_DOWNLOAD_UNSELECTED =
- "<i class='productsIcon selected icon-download' title='Download'></i>";
-
-/**
- * Displays all options in HTML in an Accordion format (see JQuery UI Accordion) with the selected states being indicated
- * by radio button and checkbox selection. All callbacks should be set. The component UI should be rendered
- * with controllers to call the events.
- *
- *
- * @this {Products}
- *
-*/
-SOTE.widget.Products.prototype.init = function(){
-
- this.render();
- if(REGISTRY){
- REGISTRY.register(this.id,this);
- }
- else{
- alert("No REGISTRY found! Cannot register Products!");
- }
-
-
-};
-
-/**
- * Renders the UI accordion from this.items
- *
- *
- * @this {Products}
- *
-*/
-SOTE.widget.Products.prototype.render = function(){
-
- this.container.innerHTML = "";
- //var productContainer = document.createElement("div");
- //this.container.setAttribute("id",this.id+"prods");
- this.container.setAttribute("class","products");
-
- var tabs = document.createElement("ul");
- tabs.setAttribute("id",this.id+"tabs");
- tabs.innerHTML =
- "<li class='layerPicker first'>" +
- "<a href='#products' class='activetab tab'></a>" +
- "</li>" +
- "<li class='layerPicker second'>" +
- "<a class='addlayerstab tab' href='#selectorbox'></a>" +
- "</li>" +
- "<li class='layerPicker third'>" +
- "<a class='tab' href='#DataDownload'></a>" +
- "</li>";
- this.container.appendChild(tabs);
- //$('#'+this.id).addClass('products');
- var toggleButtonHolder = document.createElement("div");
- toggleButtonHolder.setAttribute("id",this.id+"toggleButtonHolder");
- toggleButtonHolder.setAttribute("class","toggleButtonHolder");
- var accordionToggler = document.createElement("a");
- accordionToggler.setAttribute("class","accordionToggler atcollapse arrow");
- accordionToggler.setAttribute("title","Hide Layer Selector");
- this.isCollapsed = false;
- toggleButtonHolder.appendChild(accordionToggler);
- this.container.appendChild(toggleButtonHolder);
-
- var container = document.createElement("div");
- container.setAttribute("id","products");
- this.container.appendChild(container);
-
- var selectorbox = document.createElement("div");
- selectorbox.setAttribute("id","selectorbox");
- this.container.appendChild(selectorbox);
-
- var downloadBox = document.createElement("div");
- downloadBox.setAttribute("id", "DataDownload");
- this.container.appendChild(downloadBox);
-
- //this.container.appendChild(productContainer);
- var self = this;
- $('#'+this.id).tabs({show: function(e, ui) {
- e.data = { self: self };
- SOTE.widget.Products.change(e, ui);
- }});
- /*
- this.b = new SOTE.widget.Bank("products", {
- paletteWidget: this.paletteWidget,
- dataSourceUrl: "ap_products.php",
- title: "My Layers",
- selected: {
- antarctic: "baselayers,!MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,antarctic_coastlines",
- arctic: "baselayers,!MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,arctic_coastlines",
- geographic: "baselayers,!MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,sedac_bound"
- },
- categories: ["Base Layers","Overlays"],
- config:this.config
- });*/
- this.b = Worldview.Widget.ActiveLayers(this.config);
- /*
- this.s = new SOTE.widget.Selector("selectorbox", {
- dataSourceUrl: "ap_products.php",
- categories: ["Base Layers","Overlays"],
- selected: {
- antarctic:"baselayers,!MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,antarctic_coastlines",
- arctic:"baselayers,!MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,arctic_coastlines",
- geographic:"baselayers,!MODIS_Aqua_CorrectedReflectance_TrueColor,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,sedac_bound"
- },
- config:this.config
- });
- */
-
- //$('#'+this.id+"prods").on("tabsshow",SOTE.widget.Products.change);
- $('.accordionToggler').bind('click',{self:this},SOTE.widget.Products.toggle);
-
- if($(window).width() < 720){
- SOTE.widget.Products.toggle({data: {self:this}});
- }
-
-
- //setTimeout(SOTE.forceResize();
-
- // Mark the component as ready in the registry if called via init()
- if ((this.initRenderComplete === false) && REGISTRY) {
- this.initRenderComplete = true;
- REGISTRY.markComponentReady(this.id);
- }
- var self = this;
- $(window).resize(function(){
- self.b.render();
- self.s.resize();
- self.adjustAlignment();
- });
-
- $("#products").bind("fire", {self:this}, SOTE.widget.Products.handleFire);
-
-};
-
-SOTE.widget.Products.handleFire = function(e){
- var self = e.data.self;
- if(self.isCollapsed){
- $('.accordionToggler').html("Layers ("+ self.b.currCount()+")");
- }
-};
-
-SOTE.widget.Products.prototype.adjustAlignment = function(){
- if($(window).width() < 720 && this.isCollapsed){
- var w = $('.products').outerWidth();
- $('.products').css("left", "-"+w+"px");
- }
-};
-
-SOTE.widget.Products.forceResize = function(self){
- var outerHeight = $("#"+self.id).outerHeight();
- var tabHeight = $("#"+self.id+"tabs").outerHeight();
- self.b.setHeight(outerHeight - tabHeight);
- self.s.setHeight(outerHeight - tabHeight);
-};
-
-SOTE.widget.Products.stopLink = function(e){
- //e.stopPropagation();
-};
-
-SOTE.widget.Products.change = function(e,ui){
- var self = e.data.self;
- if ( ui.index === 0 ) {
- $('.ui-tabs-nav')
- .addClass('firstselected')
- .removeClass('secondselected')
- .removeClass('thirdselected');
- }
- else if ( ui.index === 1 ) {
- $('.ui-tabs-nav')
- .removeClass('firstselected')
- .addClass('secondselected')
- .removeClass('thirdselected');
- } else if ( ui.index === 2 ) {
- $('.ui-tabs-nav')
- .removeClass('firstselected')
- .removeClass('secondselected')
- .addClass('thirdselected');
- } else {
- throw new Error("Invalid tab index: " + ui.index);
- }
-
- var tab1 = ( ui.index === 0 )
- ? SOTE.widget.Products.HTML_TAB_ACTIVE_SELECTED
- : SOTE.widget.Products.HTML_TAB_ACTIVE_UNSELECTED;
- var tab2 = ( ui.index === 1 )
- ? SOTE.widget.Products.HTML_TAB_ADD_SELECTED
- : SOTE.widget.Products.HTML_TAB_ADD_UNSELECTED;
- var tab3 = ( ui.index === 2 )
- ? SOTE.widget.Products.HTML_TAB_DOWNLOAD_SELECTED
- : SOTE.widget.Products.HTML_TAB_DOWNLOAD_UNSELECTED;
-
- if ( ui.index === 2 ) {
- self.events.trigger("dataDownloadSelect");
- } else {
- self.events.trigger("dataDownloadUnselect");
- }
-
- $('.ui-tabs-nav li.first a').html(tab1);
- $('.ui-tabs-nav li.second a').html(tab2);
- $('.ui-tabs-nav li.third a').html(tab3);
-
- return false;
-};
-
-SOTE.widget.Products.toggle = function(e,ui){
- var self = e.data.self;
- if(self.isCollapsed){
- $('.accordionToggler').removeClass('atexpand').addClass('atcollapse').removeClass('staticLayers dateHolder').addClass('arrow');
- $('.accordionToggler').attr("title","Hide Layer Selector");
- $('.accordionToggler').empty();
- //$('.products').css("left","0");
- $('.products').animate({left:'0'}, 300);
- self.isCollapsed = false;
- $('.accordionToggler').appendTo("#"+self.id+"toggleButtonHolder");
- }
- else{
- $('.accordionToggler').removeClass('atcollapse').addClass('dateHolder').removeClass('arrow').addClass('staticLayers');
- $('.accordionToggler').attr("title","Show Layer Selector");
- $('.accordionToggler').html("Layers ("+ self.b.currCount()+")");
-
- var w = $('.products').outerWidth();
- $('.products').animate({left:'-'+w+"px"}, 300);
- self.isCollapsed = true;
- $("#"+self.id).after($('.accordionToggler'));
- }
-};
-
-SOTE.widget.Products.prototype.selectTab = function(tabName) {
- var selectedTab = $("#" + this.id).tabs("option", "selected");
- if ( tabName === "download" ) {
- if ( selectedTab !== 2 ) {
- $("#" + this.id).tabs("select", 2);
- }
- } else {
- throw new Error("Invalid tab: " + tabName);
- }
-};
-
-/**
- * Fires an event to the registry when the state of the component is changed
- *
- * @this {Products}
- *
-*/
-SOTE.widget.Products.prototype.fire = function(){
-
- if(REGISTRY){
- REGISTRY.fire(this);
- }
- else{
- alert("No REGISTRY found! Cannot fire to REGISTRY from Products!");
- }
-
-};
-
-/**
- * Gets the currently selected option(s) [containerId]=[options]
- *
- * @this {Products}
- * @returns {String} [container]=[options], options being a dot delimited string
- * representing the key(s) of the currently selected option(s)
- *
-*/
-SOTE.widget.Products.prototype.getValue = function(){
- return this.id + "=" + this.b.value();
-};
-
-/**
- * Change the component based on dependencies (i.e. Available Options, Selected)
- *
- * @this {Bank}
- * @param {String} querystring contains all values of dependencies (from registry)
- * @returns {boolean} true or false depending on if the selected value still validats with criteria change
- *
-*/
-SOTE.widget.Products.prototype.updateComponent = function(querystring){
- var qs = (querystring === undefined)? "":querystring;
- this.fire();
-};
-
diff --git a/src/js/selector.js b/src/js/selector.js
deleted file mode 100644
index 8b5e14860..000000000
--- a/src/js/selector.js
+++ /dev/null
@@ -1,736 +0,0 @@
-SOTE.namespace("SOTE.widget.Selector");
-
-SOTE.widget.Selector.prototype = new SOTE.widget.Component;
-
-/**
- * Instantiate the Selector
- *
- * @class A selection device classifying radio buttons/checkboxes into categories that are displayed in Accordion form.
- * Radio buttons allow single selection accross categories. Checkboxes allow multiple selections accross categories.
- * Radio selections cannot span multiple categories.
- * @constructor
- * @this {Selector}
- * @param {String} containerId is the container id of the div in which to render the object
- * @param {Object} [config] is a hash allowing configuration of this component
- * @config {Object[]} [items] a JS Array of JS Objects: items.category[i..n].key, items.category[i..n].value
- * , items.category[i..n].action, items.type[i..n] representing the available options
- * @config {String} [selected] the key of the initially selected option(s)
- * @augments SOTE.widget.Component
- *
-*/
-SOTE.widget.Selector = function(containerId, config){
- //Get the ID of the container element
- this.container=document.getElementById(containerId);
- if (this.container==null){
- this.setStatus("Error: element '"+containerId+"' not found!",true);
- return;
- }
- this.id = containerId;
- //Store the container's ID
- this.containerId=containerId;
-
- //Define an object for holding configuration
- if (config===undefined){
- config={};
- }
-
- if(config.categories === undefined){
- config.categories = ["Category 1","Category 2"];
- }
-
- if(config.state === undefined){
- config.state = "geographic";
- }
-
- this.state = config.state;
-
- this.selected = config.selected;
- this.values = this.unserialize(this.selected[this.state]);
-
- this.meta = new Object;
- this.categories = config.categories;
- this.initRenderComplete = false;
- this.dataSourceUrl = config.dataSourceUrl;
- this.statusStr = "";
- this.config = config.config;
- this.init();
- //this.updateComponent(this.id+"=baselayers.MODIS_Terra_CorrectedReflectance_TrueColor-overlays.fires48.AIRS_Dust_Score.OMI_Aerosol_Index")
-
-};
-
-/**
- * Displays all options in HTML in an Accordion format (see JQuery UI Accordion) with the selected states being indicated
- * by radio button and checkbox selection. All callbacks should be set. The component UI should be rendered
- * with controllers to call the events.
- *
- *
- * @this {Selector}
- *
-*/
-SOTE.widget.Selector.prototype.init = function(){
-
- this.loadData();
-
- if(REGISTRY){
- REGISTRY.register(this.id,this);
- }
- else{
- alert("No REGISTRY found! Cannot register Selector!");
- }
-
-
-};
-
-SOTE.widget.Selector.prototype.loadData = function(){
- var data = this.config.ap_products[this.state];
- SOTE.widget.Selector.handleLoadSuccess(data, null, null, {
- self: this
- });
-};
-
-SOTE.widget.Selector.handleLoadSuccess = function(data,status,xhr,args){
- var self = args.self;
- self.data = data;
- self.render();
-
-};
-
-/**
- * Renders the UI accordion from this.items
- *
- *
- * @this {Selector}
- *
-*/
-SOTE.widget.Selector.prototype.render = function(){
-
- //this.container.innerHTML = "";
- $("#"+this.id).empty();
- var tabs_height = $(".ui-tabs-nav").outerHeight(true);
- $('#'+this.id).addClass('selector');
- $('#'+this.id).height($('#'+this.id).parent().outerHeight() - tabs_height);
-
-
- var catList = document.createElement("ul");
- catList.setAttribute("class","toplevel");
-
-//<div id="selectorbox"><h1>Choose Your Interest Area</h1><ul><li><a>Text 1</a></li></ul><a>Skip this step</a></div>
- var titleContainer = document.createElement("div");
- var title = document.createElement("h2");
- title.innerHTML = "Choose Your Interest Area";
- titleContainer.appendChild(title);
- this.container.appendChild(titleContainer);
- var count = 0;
-
- SOTE.widget.Selector.loadCategory({ data: {self:this,category:"All"}, back: false });
-
-
- // Mark the component as ready in the registry if called via init()
- if ((this.initRenderComplete === false) && REGISTRY) {
- this.initRenderComplete = true;
- REGISTRY.markComponentReady(this.id);
- }
-
-
-
-};
-
-SOTE.widget.Selector.prototype.resize = function (){
- var tabs_height = $(".ui-tabs-nav").outerHeight(true);
- $('#'+this.id).height($('#'+this.id).parent().outerHeight() - tabs_height);
- setTimeout(SOTE.widget.Selector.adjustCategoryHeights,1,{self:this});
-};
-
-SOTE.widget.Selector.callRender = function (e){
- e.data.self.openCat = null;
- e.data.self.render();
-};
-
-SOTE.widget.Selector.prototype.reloadCategory = function(){
- var e = new Object;
- e.data = new Object;
- e.data.self = this;
- e.data.category = this.openCat;
- SOTE.widget.Selector.loadCategory(e);
-};
-
-SOTE.widget.Selector.loadCategory = function(e){
-
- var self = e.data.self;
- var cat = e.data.category;
- self.openCat = cat;
- var back = false;
-
-
- var categories = new Object;
- //self.container.innerHTML = "";
- $("#"+self.id).empty();
-
- var form = document.createElement("div");
- form.setAttribute("class","facetedSearch");
- form.setAttribute("id",self.id+"facetedSearch");
-
- var select = document.createElement("select");
- select.setAttribute("id",self.id+"select");
- select.setAttribute("class","select");
- for (var c in self.data){
- if(c != 'palettes'){
- var opt = document.createElement("option");
- opt.setAttribute("value",c);
- opt.text = c;
- select.add(opt);
- }
- }
-
- form.appendChild(select);
-
-
- var search = document.createElement("input");
- search.setAttribute("type","text");
- search.setAttribute("name","search");
- search.setAttribute("id",self.id+"search");
- search.setAttribute("class","search");
- search.setAttribute("placeholder","ex. modis, terra, fire");
- search.setAttribute("autocomplete","off");
-
- form.appendChild(search);
-
- var content = document.createElement("div");
- content.setAttribute("id",self.id+"content");
-
- var categoryTitles = [];
-
- for(var i=0; i<self.categories.length; i++){
- var formattedCategoryName = self.categories[i].replace(/\s/g, "");
-
-
- var categoryTitle = document.createElement("h3");
- categoryTitle.setAttribute("class","head");
- categoryTitle.innerHTML = self.categories[i];
- categoryTitles.push(categoryTitle);
-
- categories[formattedCategoryName.toLowerCase()] = document.createElement("ul");
- categories[formattedCategoryName.toLowerCase()].setAttribute("id",self.id + formattedCategoryName.toLowerCase());
- categories[formattedCategoryName.toLowerCase()].setAttribute("class",self.id + "category category scroll-pane");
-
- }
-
-
- for(var i=0; i< self.data[cat].length; i++){
- var item = self.data[cat][i];
- var subItem = document.createElement("li");
- subItem.setAttribute("class","selectorItem item");
- var itemHead = document.createElement("h4");
- if ( self.config.parameters.markPalettes ) {
- if ( self.config.layers[item.value].rendered ) {
- itemHead.setAttribute("class", "mark");
- }
- } else if ( self.config.parameters.markDownloads ) {
- if ( self.config.layers[item.value].product ) {
- itemHead.setAttribute("class", "mark");
- }
- }
- var formatted = item.value.replace(/:/g,"colon");
- itemHead.innerHTML = item.label;
- var itemP = document.createElement("p");
- itemP.innerHTML = item.sublabel;
- var itemInput = document.createElement("input");
- if(item.type === "single"){
- itemInput.setAttribute("type","checkbox");
- itemInput.setAttribute("name",cat);
- }
- else {
- itemInput.setAttribute("type","checkbox");
- }
- itemInput.setAttribute("id",formatted);
- itemInput.setAttribute("value",item.value);
- subItem.appendChild(itemInput);
- subItem.appendChild(itemHead);
- subItem.appendChild(itemP);
-
- categories[item.category].appendChild(subItem);
- $("#"+self.id).undelegate("#" + formatted,'click');
- $("#"+self.id).delegate("#" + formatted,'click',{self:self},SOTE.widget.Selector.toggleValue);
- }
-
- for(var i=0; i<self.categories.length; i++){
- var formattedCategoryName = self.categories[i].replace(/\s/g, "");
- var catContainer = document.createElement("div");
- catContainer.setAttribute("id",self.id+formattedCategoryName);
- catContainer.setAttribute("class","categoryContainer");
- catContainer.appendChild(categoryTitles[i]);
- catContainer.appendChild(categories[formattedCategoryName.toLowerCase()]);
- content.appendChild(catContainer);
- }
-
- self.container.appendChild(form);
- self.container.appendChild(content);
- //self.renderCanvases(cat);
- if(back){
- var subBack = document.createElement("a");
- subBack.setAttribute("id","subback");
- subBack.setAttribute("class","flowbutton");
- subBack.setAttribute("href","javascript:void(0);");
- subBack.innerHTML = "<< <b>go back</b> and reselect my interest area";
- self.container.appendChild(subBack);
- $("#"+self.id).undelegate("#" + "subback",'click');
- $("#"+self.id).delegate("#" + "subback",'click',{self:self},SOTE.widget.Selector.callRender);
- }
-
- //$("#"+self.id+"search").undelegate('keypress');
- $("#"+self.id+"select").on('change',{self:self,select:true},SOTE.widget.Selector.selectCat);
- $('#'+self.id+"select").val("All");
-
- $("#"+self.id+"search").on('keyup',{self:self,select:false},SOTE.widget.Selector.search);
- $("#"+self.id+"search").focus();
-
- if($(window).width() > 720){
- if(self.jsp){
- var api = self.jsp.data('jsp');
- if(api) {api.destroy()};
- }
- self.jsp = $( ".category" ).jScrollPane({autoReinitialise: false, verticalGutter:0});
- }
- setTimeout(SOTE.widget.Selector.adjustCategoryHeights,1,{self:self});
-
- self.adjustSelected();
-
-
-};
-
-SOTE.widget.Selector.reinitializeScrollbars = function(o) {
- var pane = $(".category").each(function(){
- var api = $(this).data('jsp');
- if(api) api.reinitialise();
- });
-};
-
-SOTE.widget.Selector.selectCat = function(e){
- e.data.self.openCat = e.target.value;
- $("#"+e.data.self.id+"search").keyup();
-};
-
-SOTE.widget.Selector.search = function(e){
- var self = e.data.self;
- var cat = self.openCat;
- var val = e.target.value.toUpperCase();
- val = val.replace(/[\(\)\"\'!\$\%\&\?\+\*\\\@\=]/g,"");
- var valArr = val.split(/\s/);
- //var re = new RegExp(val);
- var content = document.getElementById(self.id+"content");
- content.innerHTML = "";
-
- var categories = new Object;
-
- var categoryTitles = [];
-
- for(var i=0; i<self.categories.length; i++){
- var formattedCategoryName = self.categories[i].replace(/\s/g, "");
-
-
- var categoryTitle = document.createElement("h3");
- categoryTitle.setAttribute("class","head");
- categoryTitle.innerHTML = self.categories[i];
- categoryTitles.push(categoryTitle);
-
- categories[formattedCategoryName.toLowerCase()] = document.createElement("ul");
- categories[formattedCategoryName.toLowerCase()].setAttribute("id",self.id + formattedCategoryName.toLowerCase());
- categories[formattedCategoryName.toLowerCase()].setAttribute("class",self.id + "category category scroll-pane");
-
- }
-
-
- for(var i=0; i< self.data[cat].length; i++){
- var item = self.data[cat][i];
-
- //var matched = false;
- var count = 0;
- for(var j=0; j<valArr.length; ++j){
- var myVal = new RegExp(valArr[j]);
- if(item.label.toUpperCase().match(myVal) || item.sublabel.toUpperCase().match(myVal) || item.tags && item.tags.toUpperCase().match(myVal)) {
- count++;
- }
- }
-
- if(count == valArr.length) { //item.label.toUpperCase().match(val) || item.sublabel.toUpperCase().match(val)){
-
- var subItem = document.createElement("li");
- subItem.setAttribute("class","selectorItem item");
- var itemHead = document.createElement("h4");
- var formatted = item.value.replace(/:/g,"colon");
- itemHead.innerHTML = item.label;
- var itemP = document.createElement("p");
- itemP.innerHTML = item.sublabel;
- var itemInput = document.createElement("input");
- if(item.type === "single"){
- itemInput.setAttribute("type","checkbox");
- itemInput.setAttribute("name",cat);
- }
- else {
- itemInput.setAttribute("type","checkbox");
- }
- itemInput.setAttribute("class","css-checkbox");
- itemInput.setAttribute("id",formatted);
- itemInput.setAttribute("value",item.value);
- subItem.appendChild(itemInput);
- subItem.appendChild(itemHead);
- subItem.appendChild(itemP);
-
- categories[item.category].appendChild(subItem);
- //ul.appendChild(subItem);
- $("#"+self.id).undelegate("#" + formatted,'click');
- $("#"+self.id).delegate("#" + formatted,'click',{self:self},SOTE.widget.Selector.toggleValue);
- }
- }
-
- for(var i=0; i<self.categories.length; i++){
- var formattedCategoryName = self.categories[i].replace(/\s/g, "");
- var catContainer = document.createElement("div");
- catContainer.setAttribute("id",self.id+formattedCategoryName);
- catContainer.setAttribute("class","categoryContainer");
- catContainer.appendChild(categoryTitles[i]);
- catContainer.appendChild(categories[formattedCategoryName.toLowerCase()]);
- content.appendChild(catContainer);
- }
-
- if($(window).width() > 720){
- if(self.jsp){
- var api = self.jsp.data('jsp');
- if(api) api.destroy();
- }
- self.jsp = $( ".category" ).jScrollPane({autoReinitialise: false, verticalGutter:0});
- }
- setTimeout(SOTE.widget.Selector.adjustCategoryHeights,1,{self:self});
-
- self.adjustSelected();
-
- //content.appendChild(ul);
-
-};
-
-SOTE.widget.Selector.prototype.renderCanvases = function(cat){
- for(var i=0; i< this.data[cat].length; i++){
- var item = this.data[cat][i];
- if(this.data.palettes[item.value]){
- var p = this.data.palettes[item.value];
- var width = 100/p.palette.length;
- var canvas = document.getElementById("canvas"+this.id+item.value);
- var context = canvas.getContext('2d');
- for(var k=0; k<p.palette.length; ++k){
- context.fillStyle = "rgba("+ p.palette[k] +")";
- context.fillRect (width*k,0,width,14);
- }
- }
- }
-
-};
-
-SOTE.widget.Selector.adjustCategoryHeights = function(args){
- var self = args.self;
- var heights = new Array;
- var facets_height = $("#"+self.id+"facetedSearch").outerHeight(true);
- var container_height = $("#"+self.id).outerHeight(true) - facets_height;
- $('#'+self.id+"content").height(container_height);
- var labelHeight = 0;
- $('#'+self.id+'content .head').each(function(){
- labelHeight += $(this).outerHeight(true);
- });
- container_height -= labelHeight;
- //console.log("This.id: " + container_height);
- for(var i=0; i<self.categories.length; i++){
- var formattedCategoryName = self.categories[i].replace(/\s/g, "");
- var actual_height = 0;
- var count = 0;
- $('#' + self.id + formattedCategoryName.toLowerCase() + ' li').each(function(){
- //console.log(document.getElementById(", " + $(this).outerHeight()));
- actual_height += $(this).outerHeight(true);
- count++;
- });
-
- heights.push({
- name: self.id + formattedCategoryName.toLowerCase(),
- height: actual_height,
- count: count
- });
- }
-
- if(heights[0].height + heights[1].height > container_height){
- if(heights[0].height > container_height/2) {
- heights[0].height = container_height/2;
- }
-
- heights[1].height = container_height - heights[0].height;
-
- }
-
- $("#" + heights[0].name).css("height",heights[0].height+"px");
- $("#" + heights[1].name).css("height",heights[1].height+"px");
-
- SOTE.widget.Selector.reinitializeScrollbars({self:self});
-
-};
-
-SOTE.widget.Selector.prototype.adjustSelected = function(){
- var inputs = document.getElementsByTagName("input");
- for(var i=0; i<inputs.length; i++){
- inputs[i].checked = "";
- }
- for(var j=0; j<this.categories.length; j++){
- var formatted = this.categories[j].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
- if(this.values[formatted]){
- for(var k=0; k < this.values[formatted].length; k++){
- var val = this.values[formatted][k].value.replace(/:/g,"colon");
- var el = document.getElementById(val);
- if(el)
- el.checked = "checked";
- }
- }
- }
-};
-
-SOTE.widget.Selector.toggleValue = function(e){
- var self = e.data.self;
- var targetEl = e.target;
- var category = $("#"+targetEl.id).parents('.category').attr("id");
- category = category.replace(self.id,"");
- var value = $("#"+targetEl.id).attr("value");
- value = value.replace(/colon/,":");
- var checked = $("#"+targetEl.id).attr("checked");
-
- if(!self.values[category]){
- self.values[category] = new Array();
- }
- if(checked !== undefined && checked == "checked"){
- self.removeItem(category,value);
- self.values[category].unshift({"value":value});
- }
- else{
- self.removeItem(category,value);
- }
-
- self.fire();
-};
-
-SOTE.widget.Selector.prototype.removeItem = function(cat,val){
- for(var i=0; i<this.values[cat].length; i++){
- if(this.values[cat][i].value == val){
- this.values[cat].splice(i,1);
- }
- }
-};
-
-/**
- * Fires an event to the registry when the state of the component is changed
- *
- * @this {Selector}
- *
-*/
-SOTE.widget.Selector.prototype.fire = function(){
- if(REGISTRY){
- REGISTRY.fire(this);
- }
- else{
- alert("No REGISTRY found! Cannot fire to REGISTRY from Selector!");
- }
-
-};
-
-/**
- * Sets the selected option(s) in the Selector from the passed in value(s), if valid
- * [containerId]=[options] (options is a dot delimited string with the first item containing
- * a single select item, and the remaining items containing the multi-select items).
- *
- * @this {Selector}
- * @param {String} value is a dot delimited string of the key(s) of the option(s) to be set as selected
- * @returns {boolean} true or false depending on if the new value(s) validates
- *
-*/
-SOTE.widget.Selector.prototype.setValue = function(valString){
-
- this.values = this.unserialize(valString);
- return this.validate();
-
-};
-
-/**
- * Gets the currently selected option(s) [containerId]=[options]
- *
- * @this {Selector}
- * @returns {String} [container]=[options], options being a dot delimited string
- * representing the key(s) of the currently selected option(s)
- *
-*/
-SOTE.widget.Selector.prototype.getValue = function(){
-
- var value = this.serialize(this.values);
- return this.id + "=" + value;
-};
-
-SOTE.widget.Selector.prototype.serialize = function(values){
- var serialized = "";
- for(var i=0; i<this.categories.length; i++){
- if(i > 0){
- serialized += "~";
- }
- var formatted = this.categories[i].replace(/\s/g, "");
- formatted = formatted.toLowerCase();
-
- serialized += formatted;
- if(values[formatted]){
- for(var j=0; j<values[formatted].length; j++){
- serialized += "," + values[formatted][j].value;
- }
- }
- }
- return serialized;
-};
-
-SOTE.widget.Selector.prototype.unserialize = function(string){
- var unserialized = new Object;
- var hideIndicator = /^!/;
- var categories = string.split("~");
- for(var i=0; i<categories.length; i++){
- var items = categories[i].split(/[\.,]/);
- unserialized[items[0]] = new Array;
- for(var j=1; j<items.length; j++){
- if(hideIndicator.test(items[j])){
- items[j] = items[j].replace(/!/g,"");
- }
- unserialized[items[0]].push({"value":items[j]});
- }
-
- }
- return unserialized;
-};
-
-/**
- * Change the component based on dependencies (i.e. Available Options, Selected)
- *
- * @this {Selector}
- * @param {String} querystring contains all values of dependencies (from registry)
- * @returns {boolean} true or false depending on if the selected value still validats with criteria change
- *
-*/
-SOTE.widget.Selector.prototype.updateComponent = function(querystring){
- var qs = (querystring === undefined)? "":querystring;
- /*SOTE.util.getJSON(
- this.dataSourceUrl+"?"+querystring,
- {self:this,qs:querystring},
- SOTE.widget.Selector.handleUpdateSuccess,
- SOTE.widget.Selector.handleUpdateFailure
- );*/
- SOTE.widget.Selector.handleUpdateSuccess(this,qs);
-};
-
-/**
- * Static function to handle a successful retrieval from the data accessor
- *
- * @this {Selector}
- * @param {Object,String,Object,Object} data is the data passed back from the call, status is the response status, xhr is the applicable xmlhttprequest object, args are the custom arguments passed
- *
-*/
-SOTE.widget.Selector.handleUpdateSuccess = function(self,qs){
- /*var expanded = SOTE.util.extractFromQuery("hazard",args.qs);
- data.expanded = (expanded !== undefined && expanded !== "" && expanded !== null)? expanded:data.expanded;
- data.selected = (data.selected === undefined || data.selected === "")? SOTE.util.extractFromQuery(args.self.id,args.self.getValue()):data.selected;*/
- if(SOTE.util.extractFromQuery("switch",qs) == self.state){
- var vals = SOTE.util.extractFromQuery("products",qs);
- self.values = self.unserialize(vals);
- if(self.openCat !== undefined && self.openCat !== null){
- self.adjustSelected();
- }
- }
- else {
- self.state = SOTE.util.extractFromQuery("switch",qs);
- self.loadData();
- }
-};
-
-/**
- * Static function to handle a failed retrieval from the data accessor
- *
- * @this {Selector}
- * @param {Object,String,String,Object} xhr is the applicable xmlhttprequest object, status is the response status, error is the thrown error, args are the custom arguments passed
- *
-*/
-SOTE.widget.Selector.handleUpdateFailure = function(xhr,status,error,args){
- alert("Failed to load data accessor: " + error);
-};
-
-
-/**
- * Sets the selected option(s) from the query string [containerId]=[options]
- *
- * @this {Selector}
- * @param {String} qs contains the querystring
- * @returns {boolean} true or false depending on whether the new option validates
- *
-*/
-SOTE.widget.Selector.prototype.loadFromQuery = function(qs){
- //return this.setValue(SOTE.util.extractFromQuery(this.id,qs));
-};
-
-/**
- * Validates that the selected option(s) is not null, only one radio button is selected cross category
- * and all options are within the scope of available options
- *
- * @this {Selector}
- * @returns {boolean} true or false depending on whether the selected option(s) meet the validation criteria
-*/
-SOTE.widget.Selector.prototype.validate = function(){
-
- var isValid = true;
- return isValid;
-
-};
-
-SOTE.widget.Selector.prototype.setHeight = function(height){
- $("#"+this.id).css("height",height+"px");
- SOTE.widget.Selector.adjustCategoryHeights({self:this});
-};
-
-/**
- * Sets the data accessor that provides state change instructions given dependencies
- *
- * @this {Selector}
- * @param {String} datasourceurl is the relative location of the data accessor
- *
-*/
-SOTE.widget.Selector.prototype.setDataSourceUrl = function(dataSourceUrl){
- this.dataSourceUrl = dataSourceUrl;
-};
-
-/**
- * Gets the data accessor
- *
- * @this {Selector}
- * @returns {String} the relative location of the accessor
- *
-*/
-SOTE.widget.Selector.prototype.getDataSourceUrl = function(){
- return this.dataSourceUrl;
-};
-
-/**
- * Sets the status of the component
- *
- * @this {Selector}
- * @param {String} s the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Selector.prototype.setStatus = function(s){
- this.statusStr = s;
-};
-
-/**
- * Gets the status of the component
- *
- * @this {Selector}
- * @returns {String} the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Selector.prototype.getStatus = function(){
- return this.statusStr;
-};
-
diff --git a/src/js/superview.js b/src/js/superview.js
deleted file mode 100644
index 78a9cf369..000000000
--- a/src/js/superview.js
+++ /dev/null
@@ -1,172 +0,0 @@
-SOTE.widget.Superview.prototype = new SOTE.widget.Component;
-
-/**
- * A series of dateSpans each with the same min/max bounds, range, and start date. Allows
- * visual selection of date and data product
- *
- * @module SOTE.widget
- * @class Superview
- * @constructor
- * @this {superview}
- * @param {String} containerId is the container id of the div in which to render the object
- * @param {Object} [config] is a hash allowing configuration of this component
- * @config {String} [minDate] an ISO8601 formatted date string containing the minimum bound for the dateSpan
- * @config {String} [maxDate] an ISO8601 formatted date string containing the maximum bound for the dateSpan
- * @config {String} [thumbSource] the address of a script producing thumbnails
- * @config {String} [extent] the extent of the current map (bbox=w,s,e,n)
- * @config {String} [startDate] an ISO8601 formatted date string containing the start date of the dateSpan
- * @config {String} [selectedDate] an ISO8601 formatted date string containing the initially selected date
- * @config {Number} [range] the total number of days displayed to the user
- * @config {boolean} [slideToSelect] whether the selection slider is visible or not
- * @config {boolean} [isExpanded] whether the dateSpan thumbnails should be visible or not
- * @config {Object[]} [content] content[i..n].product, content[i..n].anchorId pairs for each product to be included
- * @augments SOTE.widget.Component
- *
-*/
-SOTE.widget.Superview = function(containerId, config){
- // Content
-};
-
-/**
- * Displays a series of datespans with scrolling if dateSpans cross the maximum vertical viewport.
- * All callbacks should be set. The component UI should be rendered with controllers to call the events.
- *
- * @this {superview}
- * @requires SOTE.widget.DateSpan
-*/
-SOTE.widget.Superview.prototype.init = function(){
- // Content
-};
-
-/**
- * Sets the selected date to passed in date, and deselects any other datespan dates
- *
- * @this {superview}
- * @param {String} a date product pair specifying the date to be selected (i.e. [containerId]=[date].[product])
- * @returns {boolean} true or false depending on whether the passed in date validates
- *
-*/
-SOTE.widget.Superview.prototype.setValue = function(value){
- // Content
-};
-
-/**
- * Gets the currently selected date in ISO8601 format, and the product represented by the dateSpan
- *
- * @this {superview}
- * @returns {String} [containerId]=[selectedDate].[selectedProduct]
- *
-*/
-SOTE.widget.Superview.prototype.getValue = function(){
- // Content
-};
-
-/**
- * Modifies contained dateSpans based on dependencies specified in querystring argument
- *
- * @this {superview}
- * @param {String} querystring contains all values of dependencies (from registry)
- * @returns {boolean} true or false depending on whether the current selected date validate under the new criteria
- *
-*/
-SOTE.widget.Superview.prototype.updateComponent = function(querystring){
- // Content
-};
-
-/**
- * Sets the selected date from the querystring, requires both date and product
- *
- * @this {superview}
- * @param {String} qs contains [containerId]=[date].[product]
- * @returns {boolean} true or false depending on if the date specified in the qs validates
- *
-*/
-SOTE.widget.Superview.prototype.loadFromQuery = function(qs){
- // Content
-};
-
-/**
- * Validates that the selected date is between the mindate and maxdate, and the product is one of the available products
- *
- * @this {superview}
- * @returns {boolean} true or false based on whether or not validation conditions are passed
-*/
-SOTE.widget.Superview.prototype.validate = function(){
- // Content
-};
-
-/**
- * Sets the data accessor that provides state change instructions given dependencies
- *
- * @this {superview}
- * @param {String} datasourceurl is the relative location of the data accessor
- *
-*/
-SOTE.widget.Superview.prototype.setDataSourceUrl = function(datasourceurl){
- // Content
-};
-
-/**
- * Gets the data accessor
- *
- * @this {superview}
- * @returns {String} the relative location of the accessor
- *
-*/
-SOTE.widget.Superview.prototype.getDataSourceUrl = function(){
- // Content
-};
-
-/**
- * Sets the status of the component
- *
- * @this {superview}
- * @param {String} s the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Superview.prototype.setStatus = function(s){
- // Content
-};
-
-/**
- * Gets the status of the component
- *
- * @this {superview}
- * @returns {String} the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Superview.prototype.getStatus = function(){
- // Content
-};
-
-/**
- * Shows the specified dateSpan in the superview
- *
- * @this {superview}
- * @param {String} p is the product name representing the datespan
- *
-*/
-SOTE.widget.Superview.prototype.show = function(p){
- // Content
-};
-
-/**
- * Hides the specified dateSpan from the superview. Entire superview is hidden if all
- * contained datespans are hidden
- *
- * @this {superview}
- * @param {String} p is the product name representing the datespan
- *
-*/
-SOTE.widget.Superview.prototype.hide = function(p){
- // Content
-};
-
-// Additional Optional Functions:
-// getAvailableProducts, getAvailableDates, showAll, hideAll, setBounds, setStart, setExtent
-
-
-
-
-
-
diff --git a/src/js/switch.js b/src/js/switch.js
deleted file mode 100644
index 403fa16aa..000000000
--- a/src/js/switch.js
+++ /dev/null
@@ -1,288 +0,0 @@
-SOTE.namespace("SOTE.widget.Switch");
-
-SOTE.widget.Switch.prototype = new SOTE.widget.Component;
-
-/**
- * A selection device classifying radio buttons/checkboxes into categories that are displayed in Accordion form.
- * Radio buttons allow single selection accross categories. Checkboxes allow multiple selections accross categories.
- * Radio selections cannot span multiple categories.
- *
- * @module SOTE.widget
- * @class Switch
- * @constructor
- * @this {Switch}
- * @param {String} containerId is the container id of the div in which to render the object
- * @param {Object} [config] is a hash allowing configuration of this component
- * @config {Object[]} [items] a JS Array of JS Objects: items.category[i..n].key, items.category[i..n].value
- * , items.category[i..n].action, items.type[i..n] representing the available options
- * @config {String} [selected] the key of the initially selected option(s)
- * @augments SOTE.widget.Component
- *
-*/
-SOTE.widget.Switch = function(containerId, config){
- this.log = Logging.getLogger("Worldview.Widget.Switch");
- //Logging.debug("Worldview.Widget.Switch");
- this.VALID_PROJECTIONS = ["geographic", "arctic", "antarctic"];
-
- //Get the ID of the container element
- this.container=document.getElementById(containerId);
- if (this.container==null){
- this.setStatus("Error: element '"+containerId+"' not found!",true);
- return;
- }
- this.id = containerId;
- //Store the container's ID
- this.containerId=containerId;
-
- //Define an object for holding configuration
- if (config===undefined){
- config={};
- }
-
- this.value = config.selected;
- this.data = (config.values !== undefined)? config.values:null;
- this.initRenderComplete = false;
- this.dataSourceUrl = config.dataSourceUrl;
- this.statusStr = "";
- this.init();
- //this.updateComponent(this.id+"=baselayers.MODIS_Terra_CorrectedReflectance_TrueColor-overlays.fires48.AIRS_Dust_Score.OMI_Aerosol_Index")
-
-};
-
-/**
- * Displays all options in HTML in an Accordion format (see JQuery UI Accordion) with the selected states being indicated
- * by radio button and checkbox selection. All callbacks should be set. The component UI should be rendered
- * with controllers to call the events.
- *
- *
- * @this {Switch}
- *
-*/
-SOTE.widget.Switch.prototype.init = function(){
-
- this.render();
-
- if(REGISTRY){
- REGISTRY.register(this.id,this);
- REGISTRY.markComponentReady(this.id);
-
- }
- else{
- alert("No REGISTRY found! Cannot register Switch!");
- }
-
-
-};
-
-/**
- * Renders the UI accordion from this.items
- *
- *
- * @this {Switch}
- *
-*/
-SOTE.widget.Switch.prototype.render = function(){
-
- this.container.innerHTML = "";
- $('#'+this.id).addClass('switch');
- //<ul><li><div><a></a><a></a><a></a></div></li></ul>
- this.container.innerHTML = "<ul><li><div class='sw_current' title='Choose a projection'></div><div class='hidden'><a id='arctic' class='sw_arctic' title='Arctic'></a><a id='geographic' class='sw_geographic' title='Geographic'></a><a id='antarctic' class='sw_antarctic' title='Antarctic'></a></div></li></ul>";
- $('#arctic').bind('click',{self:this,val:'arctic'},SOTE.widget.Switch.setVal);
- $('#geographic').bind('click',{self:this,val:'geographic'},SOTE.widget.Switch.setVal);
- $('#antarctic').bind('click',{self:this,val:'antarctic'},SOTE.widget.Switch.setVal);
-
- // Mark the component as ready in the registry if called via init()
- if ((this.initRenderComplete === false) && REGISTRY) {
- this.initRenderComplete = true;
- }
-
-};
-
-SOTE.widget.Switch.setVal = function(o){
- var self = o.data.self;
- var val = o.data.val;
- self.value = val;
- $('div.sw_current').css("background-image","url(images/"+self.value+".png)").hover(function() {
- $(this).css("background-image","url(images/"+self.value+"on.png)");
- },
- function() {
- $(this).css("background-image","url(images/"+self.value+".png)");
- });
- self.fire();
-};
-
-/**
- * Fires an event to the registry when the state of the component is changed
- *
- * @this {Switch}
- *
-*/
-SOTE.widget.Switch.prototype.fire = function(){
-
- if(REGISTRY){
- REGISTRY.fire(this);
- }
- else{
- alert("No REGISTRY found! Cannot fire to REGISTRY from Switch!");
- }
-
-};
-
-/**
- * Sets the selected option(s) in the Switch from the passed in value(s), if valid
- * [containerId]=[options] (options is a dot delimited string with the first item containing
- * a single select item, and the remaining items containing the multi-select items).
- *
- * @this {Switch}
- * @param {String} value is a dot delimited string of the key(s) of the option(s) to be set as selected
- * @returns {boolean} true or false depending on if the new value(s) validates
- *
-*/
-SOTE.widget.Switch.prototype.setValue = function(valString){
-
- this.log.debug("Switch: setValue", valString);
-
- // Check to see if the projection is valid. If not, default to the first
- // projectiond defined.
- if ( valString === "" ) {
- this.value = this.VALID_PROJECTIONS[0];
- } else if ( $.inArray(valString, this.VALID_PROJECTIONS) < 0 ) {
- this.log.warn("Invalid projection: " + valString + ", using: " +
- this.VALID_PROJECTIONS[0]);
- this.value = this.VALID_PROJECTIONS[0];
- } else {
- this.value = valString;
- }
- $(".sw_current").css("background-image","url(images/"+this.value+".png)");
- this.validate();
- this.fire();
-
-};
-
-/**
- * Gets the currently selected option(s) [containerId]=[options]
- *
- * @this {Switch}
- * @returns {String} [container]=[options], options being a dot delimited string
- * representing the key(s) of the currently selected option(s)
- *
-*/
-SOTE.widget.Switch.prototype.getValue = function(){
-
- var returnVal = this.id + "=" + this.value;
- return returnVal;
-};
-
-
-
-/**
- * Change the component based on dependencies (i.e. Available Options, Selected)
- *
- * @this {Switch}
- * @param {String} querystring contains all values of dependencies (from registry)
- * @returns {boolean} true or false depending on if the selected value still validats with criteria change
- *
-*/
-SOTE.widget.Switch.prototype.updateComponent = function(querystring){
-
-};
-
-/**
- * Static function to handle a successful retrieval from the data accessor
- *
- * @this {Switch}
- * @param {Object,String,Object,Object} data is the data passed back from the call, status is the response status, xhr is the applicable xmlhttprequest object, args are the custom arguments passed
- *
-*/
-SOTE.widget.Switch.handleUpdateSuccess = function(self,qs){
-
-};
-
-/**
- * Static function to handle a failed retrieval from the data accessor
- *
- * @this {Switch}
- * @param {Object,String,String,Object} xhr is the applicable xmlhttprequest object, status is the response status, error is the thrown error, args are the custom arguments passed
- *
-*/
-SOTE.widget.Switch.handleUpdateFailure = function(xhr,status,error,args){
- alert("Failed to load data accessor: " + error);
-};
-
-
-/**
- * Sets the selected option(s) from the query string [containerId]=[options]
- *
- * @this {Switch}
- * @param {String} qs contains the querystring
- * @returns {boolean} true or false depending on whether the new option validates
- *
-*/
-SOTE.widget.Switch.prototype.loadFromQuery = function(qs){
- return this.setValue(SOTE.util.extractFromQuery(this.id,qs));
-};
-
-/**
- * Validates that the selected option(s) is not null, only one radio button is selected cross category
- * and all options are within the scope of available options
- *
- * @this {Switch}
- * @returns {boolean} true or false depending on whether the selected option(s) meet the validation criteria
-*/
-SOTE.widget.Switch.prototype.validate = function(){
-
- var isValid = true;
- return isValid;
-
-};
-
-/**
- * Sets the data accessor that provides state change instructions given dependencies
- *
- * @this {Switch}
- * @param {String} datasourceurl is the relative location of the data accessor
- *
-*/
-SOTE.widget.Switch.prototype.setDataSourceUrl = function(dataSourceUrl){
- this.dataSourceUrl = dataSourceUrl;
-};
-
-/**
- * Gets the data accessor
- *
- * @this {Switch}
- * @returns {String} the relative location of the accessor
- *
-*/
-SOTE.widget.Switch.prototype.getDataSourceUrl = function(){
- return this.dataSourceUrl;
-};
-
-/**
- * Sets the status of the component
- *
- * @this {Switch}
- * @param {String} s the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Switch.prototype.setStatus = function(s){
- this.statusStr = s;
-};
-
-/**
- * Gets the status of the component
- *
- * @this {Switch}
- * @returns {String} the current status of the component (user prompts, error messages)
- *
-*/
-SOTE.widget.Switch.prototype.getStatus = function(){
- return this.statusStr;
-};
-
-SOTE.widget.Switch.prototype.parse = function(queryString, object) {
- var projection = Worldview.extractFromQuery("switch", queryString);
- object.projection = projection;
- return object;
-}
-