var MAX = 1500; var MIN = 10; var range = 145; var BUF = 10; var minPrice = -1; var maxPrice = -1; var cf = (MAX - MIN)/(range - BUF); YAHOO.namespace('slider'); var Dom = YAHOO.util.Dom; // Slider has a range of 200 pixels // No ticks for this example var tickSize = 0; // We'll set a minimum distance the thumbs can be from one another var minThumbDistance = 5; // Initial values for the thumbs var initValues = [0,123]; // Conversion factor from 0-200 pixels to 100-1000 // Note 20 pixels are subtracted from the range to account for the // thumb values calculated from their center point (10 pixels from // the center of the left thumb + 10 pixels from the center of the // right thumb) // Set up a function to convert the min and max values into something useful var convert = function (val) { return Math.round(val * cf + MIN); }; // Slider set up is done when the DOM is ready var div = Dom.get("slider"), info = Dom.get("price"); // Create the DualSlider var slider = YAHOO.widget.Slider.getHorizDualSlider(div, "min_thumb", "max_thumb", range, tickSize, initValues); slider.minRange = minThumbDistance; // Custom function to update the text fields, the converted value // report and the slider's title attribute var updateUI = function () { //from.value = slider.minVal; //to.value = slider.maxVal; // Update the converted values and the slider's title. // Account for the thumb width offsetting the value range by // subtracting the thumb width from the max value. var min = convert(slider.minVal), max = convert(slider.maxVal - BUF); if (isNaN(min) == true) { min = 10; } if (isNaN(max) == true) { max = 60; } if (priceRange > 0) { info.innerHTML = "btw €" + min + " and €" + max; minPrice = min; maxPrice = max; } else { info.innerHTML = "no price range"; minPrice = maxPrice = -1; } }; // END var updateUI = function () var slideEnd = function () { //alert("slide end"); // from init.jsp hotelMap.downloadHotels(); } // Subscribe to the dual thumb slider's change and ready events to // report the state. slider.subscribe('ready', updateUI); slider.subscribe('change', updateUI); slider.subscribe('slideEnd', slideEnd); // Attach the slider to the YAHOO.example namespace for public probing YAHOO.example.slider = slider;