1 /** 2 * @class Select 3 * @extends Form 4 */ 5 wso2vis.f.form.Select = function() { //canvas, selectID, onChangeFuncStr, dataField, key, value, defaultText) { 6 wso2vis.f.BasicFilter.call(this); 7 this.defaultText("default"); 8 this.filterArray([]); 9 /* @private */ 10 this.dirty = true; 11 }; 12 13 wso2vis.extend(wso2vis.f.form.Select, wso2vis.f.BasicFilter); 14 15 wso2vis.f.form.Select.prototype 16 .property("canvas") 17 .property("dataField") 18 .property("dataLabel") 19 .property("dataValue") 20 .property("defaultText"); 21 22 wso2vis.f.form.Select.prototype.invalidate = function() { 23 this.dirty = true; 24 } 25 26 /*wso2vis.f.form.Select.prototype.filterData = function(data) { 27 if (this.dirty) { 28 this.dirty = false; 29 30 31 32 } 33 this.superclass.filterData(data); 34 };*/ 35 36 wso2vis.f.form.Select.prototype.create = function() { 37 var newElementHTML = '<select id="wso2visSelect_'+this.getID()+'" onchange="wso2vis.fn.selectFormChanged('+this.getID()+');">'; 38 if ((this.filterArray() !== undefined) && (this.filterArray() !== null) && (this.filterArray().length > 0)) { 39 newElementHTML += '<option value="' + this.defaultText() + '">' + this.defaultText() + '</option>'; 40 newElementHTML += '<option value="' + this.filterArray()[0] + '" selected>' + this.filterArray()[0] + '</option>'; 41 } 42 else { 43 newElementHTML += '<option value="' + this.defaultText() + '" selected>' + this.defaultText() + '</option>'; 44 } 45 if (this.remainingArray !== null && this.remainingArray.length > 0) { 46 for (var x = 0; x < this.remainingArray.length; x++) { 47 newElementHTML += '<option value="' + this.remainingArray[x] + '">' + this.remainingArray[x] + '</option>' 48 } 49 } 50 newElementHTML += '</select>'; 51 return newElementHTML; 52 }; 53 54 wso2vis.f.form.Select.prototype.load = function() { var canvas = document.getElementById(this.canvas()); canvas.innerHTML = this.create(); }; 55 wso2vis.f.form.Select.prototype.unload = function() { var canvas = document.getElementById(this.canvas()); canvas.innerHTML = ""; }; 56 57 wso2vis.f.form.Select.prototype.onChange = function(text) { 58 }; 59 60 wso2vis.fn.selectFormChanged = function(id) { 61 var filter = wso2vis.fn.getFilterFromID(id); 62 var elem = document.getElementById("wso2visSelect_"+id); 63 filter.filterArray([]); 64 if (elem[elem.selectedIndex].text != filter.defaultText()) 65 filter.filterArray().push(elem[elem.selectedIndex].text); 66 filter.onChange(elem[elem.selectedIndex].text); 67 }; 68