1/* Numeric UpDown */ 2Startshop.Controls.NumericUpDown = function ($oSettings) { 3 var $oDefaults = { 4 'Value': 1, 5 'Minimum': 1, 6 'Maximum': 1, 7 'Ratio': 1, 8 'Unlimited': false, 9 'Events': { 10 'OnValueChange': function () {} 11 }, 12 'ValueType': 'Integer' 13 }; 14 15 this.Settings = $.extend({}, $oDefaults, $oSettings || {}); 16}; 17 18Startshop.Controls.NumericUpDown.prototype.HandleValue = function ($nValue) { 19 if (this.Settings.ValueType == 'Float') { 20 return parseFloat(parseFloat($nValue).toFixed(2)); 21 } else { 22 return parseInt($nValue); 23 } 24}; 25 26Startshop.Controls.NumericUpDown.prototype.Increase = function () { 27 return this.SetValue(this.HandleValue(this.Settings.Value) + this.HandleValue(this.Settings.Ratio)); 28}; 29 30Startshop.Controls.NumericUpDown.prototype.Decrease = function () { 31 return this.SetValue(this.HandleValue(this.Settings.Value) - this.HandleValue(this.Settings.Ratio)); 32}; 33 34Startshop.Controls.NumericUpDown.prototype.GetValue = function () { 35 if (parseInt(this.Settings.Value * 100) % 100 == 0) { 36 return this.HandleValue(this.Settings.Value).toFixed(0); 37 } else { 38 if (parseInt(this.Settings.Value * 100) % 10 == 0) { 39 return this.HandleValue(this.Settings.Value).toFixed(1); 40 } else { 41 return this.HandleValue(this.Settings.Value).toFixed(2); 42 } 43 } 44}; 45 46Startshop.Controls.NumericUpDown.prototype.SetValue = function ($nValue) { 47 $nValue = this.HandleValue($nValue); 48 var $nNewValue = this.Settings.Value; 49 50 if (this.HandleValue(this.Settings.Minimum) >= this.HandleValue(this.Settings.Maximum) && this.Settings.Unlimited == false) { 51 $nNewValue = this.HandleValue(this.Settings.Maximum); 52 } else if (isNaN($nValue) || $nValue <= this.HandleValue(this.Settings.Minimum)) { 53 $nNewValue = this.HandleValue(this.Settings.Minimum); 54 } else if ($nValue >= this.HandleValue(this.Settings.Maximum) && this.Settings.Unlimited == false) { 55 $nNewValue = this.HandleValue(this.Settings.Maximum); 56 } else { 57 if ((Math.round($nValue * 100) % Math.round(this.Settings.Ratio * 100)) == 0) { 58 59 $nNewValue = $nValue; 60 } else { 61 $nNewValue = this.HandleValue($nValue - ($nValue % this.Settings.Ratio)); 62 } 63 } 64 65 this.Settings.Value = $nNewValue; 66 67 if (Startshop.Functions.isFunction(this.Settings.Events.OnValueChange)) 68 this.Settings.Events.OnValueChange(this); 69}; 70 71/* Slider */ 72Startshop.Controls.Slider = function ($oSettings) { 73 var $oThat = this; 74 var $oDefaults = { 75 "Container": ".slider", 76 "Element": ".slide", 77 "Count": 4, 78 "Animation": { 79 "Enabled": true, 80 "Speed": 400 81 }, 82 "Custom": null 83 }; 84 this.Settings = $.extend({}, $oDefaults, $oSettings || {}); 85 this.Events = new Startshop.Classes.Events(); 86 87 this.Current = 1; 88 89 $(window).resize(function () { 90 $oThat.Refresh(); 91 }); 92}; 93 94Startshop.Controls.Slider.prototype.__SlideTo = function ($iSlideNumber) { 95 var $oSettings = {}; 96 var $oThat = this; 97 98 $oSettings.Slider = this; 99 $oSettings.Container = this.GetContainer(); 100 $oSettings.Elements = this.GetElements(); 101 $oSettings.Element = {}; 102 $oSettings.Element.Current = {}; 103 $oSettings.Element.Current.Number = this.Current; 104 $oSettings.Element.Next = {}; 105 $oSettings.Element.Next.Number = $iSlideNumber; 106 $oSettings.Boundaries = {}; 107 $oSettings.Boundaries.Minimum = 1; 108 $oSettings.Boundaries.Maximum = this.GetMaximumElementNumber(); 109 $oSettings.Animation = {}; 110 $oSettings.Animation.Enabled = this.Settings.Animation.Enabled; 111 $oSettings.Animation.Speed = this.Settings.Animation.Speed; 112 $oSettings.Slided = true; 113 114 this.Events.Call("BeforeSlide", $oSettings); 115 116 if ($oSettings.Element.Next.Number > $oSettings.Boundaries.Maximum) 117 $oSettings.Element.Next.Number = $oSettings.Boundaries.Maximum; 118 119 if ($oSettings.Element.Next.Number < $oSettings.Boundaries.Minimum) 120 $oSettings.Element.Next.Number = $oSettings.Boundaries.Minimum; 121 122 $oSettings.Element.Next.Object = this.GetElement($oSettings.Element.Next.Number); 123 $oSettings.Element.Current.Object = this.GetElement($oSettings.Element.Current.Number); 124 125 if (Startshop.Functions.isFunction(this.Settings.Custom)) { 126 this.Settings.Custom($oSettings); 127 } else { 128 var $oSize = Startshop.Functions.GetElementSize($oSettings.Elements); 129 130 if ($oSettings.Animation.Enabled) { 131 $oSettings.Container.stop().animate({'scrollLeft': $oSize.Width * ($oSettings.Element.Next.Number - 1)}, $oSettings.Animation.Speed, function () { 132 $oThat.Events.Call("AfterSlide", $oSettings); 133 }); 134 } else { 135 $oSettings.Container.stop().scrollLeft($oSize.Width * ($oSettings.Element.Next.Number - 1)); 136 this.Events.Call("AfterSlide", $oSettings); 137 } 138 } 139 140 141 this.Current = $oSettings.Element.Next.Number; 142}; 143 144Startshop.Controls.Slider.prototype.SlideTo = function ($iSlideNumber) { 145 this.__SlideTo($iSlideNumber); 146}; 147 148Startshop.Controls.Slider.prototype.SlideNext = function () { 149 this.__SlideTo(this.GetCurrentElementNumber() + 1); 150}; 151 152Startshop.Controls.Slider.prototype.SlidePrev = function () { 153 this.__SlideTo(this.GetCurrentElementNumber() - 1); 154}; 155 156Startshop.Controls.Slider.prototype.GetCurrentElementNumber = function () { 157 return this.Current; 158}; 159 160Startshop.Controls.Slider.prototype.GetCurrentElement = function () { 161 return $(this.GetElement(this.GetCurrentElementNumber())); 162}; 163 164Startshop.Controls.Slider.prototype.GetContainer = function () { 165 return $(this.Settings.Container); 166}; 167 168Startshop.Controls.Slider.prototype.GetElements = function () { 169 return this.GetContainer().find(this.Settings.Element); 170}; 171 172Startshop.Controls.Slider.prototype.GetElement = function ($iSlideNumber) { 173 return this.GetElements().eq($iSlideNumber - 1); 174}; 175 176Startshop.Controls.Slider.prototype.GetMaximumElementNumber = function () { 177 var $iMaximumElementNumber = (this.GetElements().size() - this.Settings.Count + 1); 178 179 if ($iMaximumElementNumber < 1) 180 $iMaximumElementNumber = 1; 181 182 return $iMaximumElementNumber; 183}; 184 185Startshop.Controls.Slider.prototype.Refresh = function () { 186 var $oAnimationState = this.Settings.Animation.Enabled; 187 this.Settings.Animation.Enabled = false;
188 this.Events.Call("BeforeAdaptability", this); 189 this.SlideTo(this.GetCurrentElementNumber()); 190 this.Events.Call("AfterAdaptability", this); 191 this.Settings.Animation.Enabled = $oAnimationState; 192}; 193 194Startshop.Controls.Slider.prototype.Initialize = function () { 195 this.Refresh(); 196 this.SlideTo(1); 197}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.