Interactive interface for browsing global, full-resolution satellite imagery
Palettes can be marked in the selection list with markPalettes=true in the query string
Mike McGanne920f7329a37
diff --git a/src/css/selector.css b/src/css/selector.cssindex 3d8cdf496..9f625d871 100644--- a/src/css/selector.css+++ b/src/css/selector.css@@ -4,7 +4,7 @@ div.selector { display:inline-block; float:left; width: 100%; height:100%; font.selector h1,h2,h3,h4 {margin:0px; padding:0px;}-.selector h2 { display:inline-block; float: right; color:#ffffff; border:none; padding:9px 30px 9px 30px;+.selector h2 { display:inline-block; float: right; color:#ffffff; border:none; padding:9px 30px 9px 30px;background: -moz-linear-gradient(top, rgba(255,255,255,0.7) 0%, rgba(160,121,11,0.7) 23%, rgba(156,115,0,0.7) 24%, rgba(144,106,0,0.7) 99%, rgba(144,106,0,0.7) 100%); /* FF3.6+ */background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.7)), color-stop(23%,rgba(160,121,11,0.7)), color-stop(24%,rgba(156,115,0,0.7)), color-stop(99%,rgba(144,106,0,0.7)), color-stop(100%,rgba(144,106,0,0.7))); /* Chrome,Safari4+ */background: -webkit-linear-gradient(top, rgba(255,255,255,0.7) 0%,rgba(160,121,11,0.7) 23%,rgba(156,115,0,0.7) 24%,rgba(144,106,0,0.7) 99%,rgba(144,106,0,0.7) 100%); /* Chrome10+,Safari5.1+ */@@ -44,4 +44,8 @@ color:#000; background: rgba(238,238,238,0.85);}div.facetedSearch {display:block; background:#fff; width:96%; margin: .5em auto; border-radius: 5px; }#selectorboxcontent { height:100%;}+.selector li.item h4.palette {+ font-weight: bold;+ color: red;+}diff --git a/src/js/selector.js b/src/js/selector.jsindex 3bc4ed72e..67cb09e5f 100644--- a/src/js/selector.js+++ b/src/js/selector.js@@ -1,22 +1,22 @@-SOTE.namespace("SOTE.widget.Selector");+SOTE.namespace("SOTE.widget.Selector");SOTE.widget.Selector.prototype = new SOTE.widget.Component;/**- * Instantiate the Selector+ * 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 {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+ * @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@@ -27,15 +27,15 @@ SOTE.widget.Selector = function(containerId, config){}this.id = containerId;//Store the container's ID- this.containerId=containerId;+ this.containerId=containerId;- //Define an object for holding configuration+ //Define an object for holding configurationif (config===undefined){config={};}-+if(config.categories === undefined){- config.categories = ["Category 1","Category 2"];+ config.categories = ["Category 1","Category 2"];}if(config.state === undefined){@@ -46,7 +46,7 @@ SOTE.widget.Selector = function(containerId, config){this.selected = config.selected;this.values = this.unserialize(this.selected[this.state]);-+this.meta = new Object;this.categories = config.categories;this.initRenderComplete = false;@@ -60,25 +60,25 @@ SOTE.widget.Selector = function(containerId, config){/*** 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+ * 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(){@@ -98,19 +98,19 @@ SOTE.widget.Selector.handleLoadSuccess = function(data,status,xhr,args){/*** 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");@@ -123,21 +123,21 @@ SOTE.widget.Selector.prototype.render = function(){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()+++ // 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);+ $('#'+this.id).height($('#'+this.id).parent().outerHeight() - tabs_height);setTimeout(SOTE.widget.Selector.adjustCategoryHeights,1,{self:this});};@@ -155,21 +155,21 @@ SOTE.widget.Selector.prototype.reloadCategory = function(){};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");@@ -181,10 +181,10 @@ SOTE.widget.Selector.loadCategory = function(e){select.add(opt);}}-+form.appendChild(select);--++var search = document.createElement("input");search.setAttribute("type","text");search.setAttribute("name","search");@@ -192,35 +192,40 @@ SOTE.widget.Selector.loadCategory = function(e){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", "palette");+ }+ }var formatted = item.value.replace(/:/g,"colon");itemHead.innerHTML = item.label;var itemP = document.createElement("p");@@ -238,12 +243,12 @@ SOTE.widget.Selector.loadCategory = function(e){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");@@ -253,10 +258,10 @@ SOTE.widget.Selector.loadCategory = function(e){catContainer.appendChild(categories[formattedCategoryName.toLowerCase()]);content.appendChild(catContainer);}-+self.container.appendChild(form);self.container.appendChild(content);- //self.renderCanvases(cat);+ //self.renderCanvases(cat);if(back){var subBack = document.createElement("a");subBack.setAttribute("id","subback");@@ -267,33 +272,33 @@ SOTE.widget.Selector.loadCategory = function(e){$("#"+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){@@ -314,37 +319,37 @@ SOTE.widget.Selector.search = function(e){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++;+ 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");@@ -366,14 +371,14 @@ SOTE.widget.Selector.search = function(e){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");@@ -383,12 +388,12 @@ SOTE.widget.Selector.search = function(e){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});@@ -396,7 +401,7 @@ SOTE.widget.Selector.search = function(e){self.adjustSelected();//content.appendChild(ul);-+};SOTE.widget.Selector.prototype.renderCanvases = function(cat){@@ -444,27 +449,27 @@ SOTE.widget.Selector.adjustCategoryHeights = function(args){count: count});}-+if(heights[0].height + heights[1].height > container_height){- if(heights[0].height > container_height/2) {+ 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 = "";+ inputs[i].checked = "";}for(var j=0; j<this.categories.length; j++){var formatted = this.categories[j].replace(/\s/g, "");@@ -493,13 +498,13 @@ SOTE.widget.Selector.toggleValue = function(e){self.values[category] = new Array();}if(checked !== undefined && checked == "checked"){- self.removeItem(category,value);- self.values[category].unshift({"value":value});+ self.removeItem(category,value);+ self.values[category].unshift({"value":value});}else{self.removeItem(category,value);}-+self.fire();};@@ -528,7 +533,7 @@ SOTE.widget.Selector.prototype.fire = function(){};/**- * Sets the selected option(s) in the Selector from the passed in value(s), if valid+ * 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).*@@ -541,19 +546,19 @@ 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+ * @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;};@@ -590,18 +595,18 @@ SOTE.widget.Selector.prototype.unserialize = function(string){}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;@@ -616,16 +621,16 @@ SOTE.widget.Selector.prototype.updateComponent = function(querystring){/*** 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){+ 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){@@ -637,13 +642,13 @@ SOTE.widget.Selector.handleUpdateSuccess = function(self,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);@@ -652,7 +657,7 @@ SOTE.widget.Selector.handleUpdateFailure = function(xhr,status,error,args){/*** 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@@ -665,7 +670,7 @@ SOTE.widget.Selector.prototype.loadFromQuery = function(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*/@@ -685,7 +690,7 @@ SOTE.widget.Selector.prototype.setHeight = function(height){* Sets the data accessor that provides state change instructions given dependencies** @this {Selector}- * @param {String} datasourceurl is the relative location of the data accessor+ * @param {String} datasourceurl is the relative location of the data accessor**/SOTE.widget.Selector.prototype.setDataSourceUrl = function(dataSourceUrl){@@ -694,7 +699,7 @@ SOTE.widget.Selector.prototype.setDataSourceUrl = function(dataSourceUrl){/*** Gets the data accessor- *+ ** @this {Selector}* @returns {String} the relative location of the accessor*