1/*! roundSlider v1.0 | (c) 2015, Soundar | MIT license | http://roundsliderui.com/licence.html */ 2(function ($, window, undefined) { 3 "use strict"; 4 5 function $proxy(n, t) { 6 return typeof $.proxy == "function" ? $.proxy(n, t) : function (i) { 7 n.call(t, i) 8 } 9 } 10 11 function $data(n, t, i) { 12 return typeof $.data == "function" ? $.data(n, t, i) : i ? void 0 : $(n).hasClass("rs-control") 13 } 14 15 function $isPlainObject(n) { 16 if (typeof $.isPlainObject == "function") return $.isPlainObject(n); 17 var t = JSON.stringify(n); 18 return typeof n == "object" && n.length === undefined && t.length > 2 && t.substr(0, 1) === "{" && t.substr(t.length - 1) === "}" 19 } 20 21 function isNumber(n) { 22 return n = parseFloat(n), typeof n == "number" && !isNaN(n) 23 } 24 25 function createElement(n) { 26 var t = n.split("."); 27 return $(document.createElement(t[0])).addClass(t[1] || "") 28 } 29 30 function getdistance(n, t) { 31 return Math.sqrt((n.x - t.x) * (n.x - t.x) + (n.y - t.y) * (n.y - t.y)) 32 } 33 34 function setTransform(n, t) { 35 return n.css("-webkit-transform", "rotate(" + t + "deg)"), n.css("-moz-transform", "rotate(" + t + "deg)"), n.css("-ms-transform", "rotate(" + t + "deg)"), n.css("-o-transform", "rotate(" + t + "deg)"), n.css("transform", "rotate(" + t + "deg)"), n 36 } 37 38 function RoundSlider(n, t) { 39 n.id && (window[n.id] = this); 40 this.control = $(n); 41 this.options = $.extend({}, this.defaults, t); 42 this._raise("beforeCreate") !== !1 ? (this._init(), this._raise("create")) : this._removeData() 43 } 44 45 function CreateRoundSlider(n, t) { 46 for (var i, r, u = 0; u < this.length; u++) 47 if (i = this[u], r = $data(i, pluginName), r) { 48 if ($isPlainObject(n)) typeof r.option == "function" ? r.option(n) : i.id && window[i.id] && typeof window[i.id].option == "function" && window[i.id].option(n); 49 else if (typeof n == "string" && typeof r[n] == "function") { 50 if ((n == "option" || n.startsWith("get")) && t[2] === undefined) return r[n](t[1]); 51 r[n](t[1], t[2]) 52 } 53 } else $data(i, pluginName, new RoundSlider(i, n)); 54 return this 55 } 56 var pluginName = "roundSlider"; 57 $.fn[pluginName] = function (n) { 58 return CreateRoundSlider.call(this, n, arguments) 59 }; 60 RoundSlider.prototype = { 61 pluginName: pluginName, 62 version: "1.0", 63 options: {}, 64 defaults: { 65 min: 0, 66 max: 100, 67 step: 1, 68 value: null, 69 radius: 85, 70 width: 18, 71 handleSize: "+0", 72 startAngle: 0, 73 endAngle: "+360", 74 animation: !0, 75 showTooltip: !0, 76 editableTooltip: !0, 77 readOnly: !1, 78 disabled: !1, 79 keyboardAction: !0, 80 mouseScrollAction: !1, 81 sliderType: "default", 82 circleShape: "full", 83 handleShape: "round", 84 beforeCreate: null, 85 create: null, 86 start: null, 87 drag: null, 88 change: null, 89 stop: null, 90 tooltipFormat: null 91 }, 92 _props: function () { 93 return { 94 numberType: ["min", "max", "step", "radius", "width", "startAngle"], 95 booleanType: ["animation", "showTooltip", "editableTooltip", "readOnly", "disabled", "keyboardAction", "mouseScrollAction"], 96 stringType: ["sliderType", "circleShape", "handleShape"] 97 } 98 }, 99 control: null, 100 _init: function () { 101 this._initialize(); 102 this._update(); 103 this._render() 104 }, 105 _initialize: function () { 106 (this._isBrowserSupport = this._isBrowserSupported(), this._isBrowserSupport) && (this._originalObj = this.control.clone(), this._isReadOnly = !1, this._checkDataType(), this._refreshCircleShape()) 107 }, 108 _render: function () { 109 if (this.container = createElement("div.rs-container"), this.innerContainer = createElement("div.rs-inner-container"), this.block = createElement("div.rs-block rs-outer rs-border"), this.container.append(this.innerContainer.append(this.block)), this.control.addClass("rs-control").empty().append(this.container), this._setRadius(), this._isBrowserSupport) this._createLayers(), this._setProperties(), this._setValue(), this._bindControlEvents("_bind"), this._checkIE(); 110 else { 111 var n = createElement("div.rs-msg"); 112 n.html(typeof this._throwError == "function" ? this._throwError() : this._throwError); 113 this.control.empty().addClass("rs-error").append(n) 114 } 115 }, 116 _update: function () {
117 this._validateSliderType(); 118 this._updateStartEnd(); 119 this._validateStartEnd(); 120 this._handle1 = this._handle2 = this._handleDefaults(); 121 this._analyzeModelValue(); 122 this._validateModelValue() 123 }, 124 _createLayers: function () { 125 var i = this.options.width, 126 t = this._start, 127 n; 128 n = createElement("div.rs-path rs-transition"); 129 this._rangeSlider || this._showRange ? (this.block1 = n.clone().addClass("rs-range-color").rsRotate(t), this.block2 = n.clone().addClass("rs-range-color").css("opacity", "0").rsRotate(t), this.block3 = n.clone().addClass("rs-path-color").rsRotate(t), this.block4 = n.addClass("rs-path-color").css({ 130 opacity: "1", 131 "z-index": "1" 132 }).rsRotate(t - 180), this.block.append(this.block1, this.block2, this.block3, this.block4).addClass("rs-split")) : this.block.append(n.addClass("rs-path-color")); 133 this.lastBlock = createElement("span.rs-block").css({ 134 padding: i 135 }); 136 this.innerBlock = createElement("div.rs-inner rs-bg-color rs-border"); 137 this.lastBlock.append(this.innerBlock); 138 this.block.append(this.lastBlock); 139 this._appendHandle(); 140 this._appendOverlay(); 141 this._appendHiddenField() 142 }, 143 _setProperties: function () { 144 this._prechange = this._predrag = this.options.value; 145 this._setHandleShape(); 146 this._addAnimation(); 147 this._appendTooltip(); 148 this.options.showTooltip || this._removeTooltip(); 149 this.options.disabled ? this.disable() : this.options.readOnly && this._readOnly(!0); 150 this.options.mouseScrollAction && this._bindScrollEvents("_bind") 151 }, 152 _setValue: function () { 153 if (this._rangeSlider) this._setHandleValue(1), this._setHandleValue(2); 154 else { 155 this._showRange && this._setHandleValue(1); 156 var n = this.options.sliderType == "default" ? this._active || 1 : parseFloat(this.bar.children().attr("index")); 157 this._setHandleValue(n) 158 } 159 }, 160 _appendTooltip: function () { 161 this.container.children(".rs-tooltip").length === 0 && (this.tooltip = createElement("span.rs-tooltip rs-tooltip-text"), this.container.append(this.tooltip), this._tooltipEditable(), this._updateTooltip()) 162 }, 163 _removeTooltip: function () { 164 this.container.children(".rs-tooltip").length != 0 && this.tooltip && this.tooltip.remove() 165 }, 166 _tooltipEditable: function () { 167 if (this.tooltip && this.options.showTooltip) { 168 var n; 169 this.options.editableTooltip ? (this.tooltip.addClass("edit"), n = "_bind") : (this.tooltip.removeClass("edit"), n = "_unbind"); 170 this[n](this.tooltip, "click", this._editTooltip) 171 } 172 }, 173 _editTooltip: function () { 174 this.tooltip.hasClass("edit") && !this._isReadOnly && (this.input = createElement("input.rs-input rs-tooltip-text").css({ 175 height: this.tooltip.outerHeight(), 176 width: this.tooltip.outerWidth() 177 }), this.tooltip.html(this.input).removeClass("edit").addClass("hover"), this.input.val(this._getTooltipValue(!0)).focus(), this._bind(this.input, "blur", this._focusOut), this._bind(this.input, "change", this._focusOut)) 178 }, 179 _focusOut: function (n) { 180 n.type == "change" ? (this.options.value = this.input.val().replace("-", ","), this._analyzeModelValue(), this._validateModelValue(), this._setValue(), this.input.val(this._getTooltipValue(!0))) : this.tooltip.addClass("edit").removeClass("hover"); 181 this._raiseEvent("change") 182 }, 183 _setHandleShape: function () { 184 var n = this.options.handleShape; 185 this._handles().removeClass("rs-handle-dot rs-handle-square"); 186 n == "dot" ? this._handles().addClass("rs-handle-dot") : n == "square" ? this._handles().addClass("rs-handle-square") : this.options.handleShape = this.defaults.handleShape 187 }, 188 _setHandleValue: function (n) { 189 this._active = n; 190 var t = this["_handle" + n]; 191 this.options.sliderType != "min-range" && (this.bar = this._activeHandleBar()); 192 this._changeSliderValue(t.value, t.angle) 193 }, 194 _setAnimation: function () { 195 this.options.animation ? this._addAnimation() : this._removeAnimation() 196 }, 197 _addAnimation: function () { 198 this.options.animation && this.control.addClass("rs-animation") 199 }, 200 _removeAnimation: function () { 201 this.control.removeClass("rs-animation") 202 }, 203 _setRadius: function () { 204 var t = this.options.radius, 205 i = t * 2, 206 n = this.options.circleShape, 207 r = i, 208 u = i, 209 f, e; 210 if (this.container.removeClass().addClass("rs-container"), n.indexOf("half") === 0) { 211 switch (n) { 212 case "half-top": 213 case "half-bottom": 214 r = t; 215 u = i; 216 break; 217 case "half-left": 218 case "half-right": 219 r = i; 220 u = t 221 } 222 this.container.addClass(n.replace("half-", "") + " half") 223 } else n.indexOf("quarter") === 0 ? (r = u = t, f = n.split("-"), this.container.addClass(f[0] + " " + f[1] + " " + f[2])) : this.container.addClass("full " + n); 224 e = { 225 height: r, 226 width: u 227 }; 228 this.control.css(e); 229 this.container.css(e) 230 }, 231 _border: function () { 232 return parseFloat(this.block.css("border-top-width")) * 2 233 }, 234 _appendHandle: function () { 235 (this._rangeSlider || !this._showRange) && this._createHandle(1); 236 (this._rangeSlider || this._showRange) && this._createHandle(2); 237 this._startLine = this._addSeperator(this._start, "rs-start"); 238 this._endLine = this._addSeperator(this._start + this._end, "rs-end") 239 }, 240 _addSeperator: function (n, t) { 241 var r = createElement("span.rs-seperator").css({ 242 width: this.options.width, 243 "margin-left": this._border() / 2 244 }), 245 i = createElement("span.rs-bar rs-transition " + t).append(r).rsRotate(n); 246 return this.container.append(i), i 247 }, 248 _updateSeperator: function () { 249 this._startLine.rsRotate(this._start); 250 this._endLine.rsRotate(this._start + this._end) 251 }, 252 _createHandle: function (n) { 253 var t = createElement("div.rs-handle rs-move"), 254 i; 255 t.attr({ 256 index: n, 257 tabIndex: "0" 258 }); 259 var r = this.control[0].id, 260 r = r ? r + "_" : "", 261 u = r + "handle" + (this.options.sliderType == "range" ? "_" + (n == 1 ? "start" : "end") : ""); 262 return t.attr({ 263 role: "slider", 264 "aria-label": u 265 }), i = createElement("div.rs-bar rs-transition").css("z-index", "4").append(t).rsRotate(this._start), i.addClass(this.options.sliderType == "range" && n == 2 ? "rs-second" : "rs-first"), this.container.append(i), this._refreshHandle(), this.bar = i, this._active = n, n != 1 && n != 2 && (this["_handle" + n] = this._handleDefaults()), this._bind(t, "focus", this._handleFocus), this._bind(t, "blur", this._handleBlur), t 266 }, 267 _refreshHandle: function () { 268 var hSize = this.options.handleSize, 269 h, w, isSquare = !0, 270 s, diff; 271 if (typeof hSize == "string" && isNumber(hSize)) 272 if (hSize.charAt(0) === "+" || hSize.charAt(0) === "-") try { 273 hSize = eval(this.options.width + hSize.charAt(0) + Math.abs(parseFloat(hSize))) 274 } catch (e) { 275 console.warn(e) 276 } else hSize.indexOf(",") && (s = hSize.split(","), isNumber(s[0]) && isNumber(s[1]) && (w = parseFloat(s[0]), h = parseFloat(s[1]), isSquare = !1)); 277 isSquare && (h = w = isNumber(hSize) ? parseFloat(hSize) : this.options.width); 278 diff = (this.options.width + this._border() - w) / 2; 279 this._handles().css({ 280 height: h, 281 width: w, 282 margin: -h / 2 + "px 0 0 " + diff + "px" 283 }) 284 }, 285 _handleDefaults: function () { 286 return { 287 angle: this._valueToAngle(this.options.min), 288 value: this.options.min 289 } 290 }, 291 _handles: function () { 292 return this.container.children("div.rs-bar").find(".rs-handle") 293 }, 294 _activeHandleBar: function () { 295 return $(this.container.children("div.rs-bar")[this._active - 1]) 296 }, 297 _handleArgs: function () { 298 var n = this["_handle" + this._active]; 299 return { 300 element: this._activeHandleBar().children(), 301 index: this._active, 302 value: n ? n.value : null, 303 angle: n ? n.angle : null 304 } 305 }, 306 _raiseEvent: function (n) { 307 return this._updateTooltip(), n == "change" && this._updateHidden(), this["_pre" + n] !== this.options.value ? (this["_pre" + n] = this.options.value, this._raise(n, { 308 value: this.options.value, 309 handle: this._handleArgs() 310 })) : void 0 311 }, 312 _elementDown: function (n) { 313 var u, t, r, h, i;
314 if (!this._isReadOnly) 315 if (u = $(n.target), u.hasClass("rs-handle")) this._handleDown(n); 316 else { 317 var f = this._getXY(n), 318 e = this._getCenterPoint(), 319 o = getdistance(f, e), 320 s = this.block.outerWidth() / 2, 321 c = s - (this.options.width + this._border()); 322 o >= c && o <= s && (n.preventDefault(), t = this.control.find(".rs-handle.rs-focus"), this.control.attr("tabindex", "0").focus().removeAttr("tabindex"), r = this._getAngleValue(f, e), h = r.angle, i = r.value, this._rangeSlider && (t = this.control.find(".rs-handle.rs-focus"), this._active = t.length == 1 ? parseFloat(t.attr("index")) : this._handle2.value - i < i - this._handle1.value ? 2 : 1, this.bar = this._activeHandleBar()), this._changeSliderValue(i, h), this._raiseEvent("change")) 323 } 324 }, 325 _handleDown: function (n) { 326 n.preventDefault(); 327 var t = $(n.target); 328 t.focus(); 329 this._removeAnimation(); 330 this._bindMouseEvents("_bind"); 331 this.bar = t.parent(); 332 this._active = parseFloat(t.attr("index")); 333 this._handles().removeClass("rs-move"); 334 this._raise("start", { 335 handle: this._handleArgs() 336 }) 337 }, 338 _handleMove: function (n) { 339 n.preventDefault(); 340 var u = this._getXY(n), 341 f = this._getCenterPoint(), 342 t = this._getAngleValue(u, f), 343 i, r; 344 i = t.angle; 345 r = t.value; 346 this._changeSliderValue(r, i); 347 this._raiseEvent("drag") 348 }, 349 _handleUp: function () { 350 this._handles().addClass("rs-move"); 351 this._bindMouseEvents("_unbind"); 352 this._addAnimation(); 353 this._raiseEvent("change"); 354 this._raise("stop", { 355 handle: this._handleArgs() 356 }) 357 }, 358 _handleFocus: function (n) { 359 if (!this._isReadOnly) { 360 var t = $(n.target); 361 this._handles().removeClass("rs-focus"); 362 t.addClass("rs-focus"); 363 this.bar = t.parent(); 364 this._active = parseFloat(t.attr("index")); 365 this.options.keyboardAction && (this._bindKeyboardEvents("_unbind"), this._bindKeyboardEvents("_bind")); 366 this.control.find("div.rs-bar").css("z-index", "4"); 367 this.bar.css("z-index", "5") 368 } 369 }, 370 _handleBlur: function () { 371 this._handles().removeClass("rs-focus"); 372 this.options.keyboardAction && this._bindKeyboardEvents("_unbind") 373 }, 374 _handleKeyDown: function (n) { 375 var t, r, i, u; 376 this._isReadOnly || (t = n.keyCode, t == 27 && this._handles().blur(), t >= 35 && t <= 40) && (t >= 37 && t <= 40 && this._removeAnimation(), r = this["_handle" + this._active], n.preventDefault(), t == 38 || t == 37 ? i = this._round(this._limitValue(r.value + this.options.step)) : t == 39 || t == 40 ? i = this._round(this._limitValue(r.value - this._getMinusStep(r.value))) : t == 36 ? i = this._getKeyValue("Home") : t == 35 && (i = this._getKeyValue("End")), u = this._valueToAngle(i), this._changeSliderValue(i, u), this._raiseEvent("change")) 377 }, 378 _handleKeyUp: function () { 379 this._addAnimation() 380 }, 381 _getMinusStep: function (n) { 382 if (n == this.options.max) { 383 var t = (this.options.max - this.options.min) % this.options.step; 384 return t == 0 ? this.options.step : t 385 } 386 return this.options.step 387 }, 388 _getKeyValue: function (n) { 389 return this._rangeSlider ? n == "Home" ? this._active == 1 ? this.options.min : this._handle1.value : this._active == 1 ? this._handle2.value : this.options.max : n == "Home" ? this.options.min : this.options.max 390 }, 391 _elementScroll: function (n) { 392 if (!this._isReadOnly) { 393 n.preventDefault(); 394 var i = n.originalEvent || n, 395 r, t, f, u; 396 (u = i.wheelDelta ? i.wheelDelta / 60 : i.detail ? -i.detail / 2 : 0, u != 0) && (this._updateActiveHandle(n), r = this["_handle" + this._active], t = r.value + (u > 0 ? this.options.step : -this._getMinusStep(r.value)), t = this._limitValue(t), f = this._valueToAngle(t), this._removeAnimation(), this._changeSliderValue(t, f), this._raiseEvent("change"), this._addAnimation()) 397 } 398 }, 399 _updateActiveHandle: function (n) { 400 var t = $(n.target); 401 t.hasClass("rs-handle") && t.parent().parent()[0] == this.control[0] && (this.bar = t.parent(), this._active = parseFloat(t.attr("index"))); 402 this.bar.find(".rs-handle").hasClass("rs-focus") || this.bar.find(".rs-handle").focus() 403 }, 404 _bindControlEvents: function (n) { 405 this[n](this.control, "mousedown", this._elementDown); 406 this[n](this.control, "touchstart", this._elementDown) 407 }, 408 _bindScrollEvents: function (n) { 409 this[n](this.control, "mousewheel", this._elementScroll); 410 this[n](this.control, "DOMMouseScroll", this._elementScroll) 411 }, 412 _bindMouseEvents: function (n) { 413 this[n]($(document), "mousemove", this._handleMove); 414 this[n]($(document), "mouseup", this._handleUp); 415 this[n]($(document), "mouseleave", this._handleUp); 416 this[n]($(document), "touchmove", this._handleMove); 417 this[n]($(document), "touchend", this._handleUp); 418 this[n]($(document), "touchcancel", this._handleUp) 419 }, 420 _bindKeyboardEvents: function (n) { 421 this[n]($(document), "keydown", this._handleKeyDown); 422 this[n]($(document), "keyup", this._handleKeyUp) 423 }, 424 _changeSliderValue: function (n, t) { 425 var r = this._oriAngle(t), 426 i = this._limitAngle(t); 427 if (this._rangeSlider || this._showRange) { 428 if (this._active == 1 && r <= this._oriAngle(this._handle2.angle) || this._active == 2 && r >= this._oriAngle(this._handle1.angle)) { 429 this["_handle" + this._active] = { 430 angle: t, 431 value: n 432 }; 433 this.options.value = this._rangeSlider ? this._handle1.value + "," + this._handle2.value : n; 434 this.bar.rsRotate(i); 435 this._updateARIA(n); 436 var e = this._oriAngle(this._handle2.angle) - this._oriAngle(this._handle1.angle), 437 u = "1", 438 f = "0"; 439 e <= 180 && (u = "0", f = "1"); 440 this.block2.css("opacity", u); 441 this.block3.css("opacity", f); 442 (this._active == 1 ? this.block4 : this.block2).rsRotate(i - 180); 443 (this._active == 1 ? this.block1 : this.block3).rsRotate(i) 444 } 445 } else this["_handle" + this._active] = { 446 angle: t, 447 value: n 448 }, this.options.value = n, this.bar.rsRotate(i), this._updateARIA(n) 449 }, 450 _updateARIA: function (n) { 451 var i = this.options.min, 452 r = this.options.max, 453 t; 454 this.bar.children().attr({ 455 "aria-valuenow": n 456 }); 457 this.options.sliderType == "range" ? (t = this._handles(), t.eq(0).attr({ 458 "aria-valuemin": i 459 }), t.eq(1).attr({ 460 "aria-valuemax": r 461 }), this._active == 1 ? t.eq(1).attr({ 462 "aria-valuemin": n 463 }) : t.eq(0).attr({ 464 "aria-valuemax": n 465 })) : this.bar.children().attr({ 466 "aria-valuemin": i, 467 "aria-valuemax": r 468 }) 469 },
470 _getXY: function (n) { 471 return n.type.indexOf("mouse") == -1 && (n = (n.originalEvent || n).changedTouches[0]), { 472 x: n.pageX, 473 y: n.pageY 474 } 475 }, 476 _getCenterPoint: function () { 477 var n = this.block.offset(); 478 return { 479 x: n.left + this.block.outerWidth() / 2, 480 y: n.top + this.block.outerHeight() / 2 481 } 482 }, 483 _getAngleValue: function (n, t) { 484 var r = Math.atan2(n.y - t.y, t.x - n.x), 485 i = -r / (Math.PI / 180); 486 return i < this._start && (i += 360), i = this._checkAngle(i), this._processStepByAngle(i) 487 }, 488 _checkAngle: function (n) { 489 var i = this._oriAngle(n), 490 t; 491 return i > this._end && (t = this._oriAngle(this["_handle" + this._active].angle), n = this._start + (t <= this._end - t ? 0 : this._end)), n 492 }, 493 _processStepByAngle: function (n) { 494 var t = this._angleToValue(n); 495 return this._processStepByValue(t) 496 }, 497 _processStepByValue: function (n) { 498 var r = this.options.step, 499 e, t, u, f, i, o; 500 return e = (n - this.options.min) % r, t = n - e, u = this._limitValue(t + r), f = this._limitValue(t - r), i = n >= t ? n - t < u - n ? t : u : t - n > n - f ? t : f, i = this._round(i), o = this._valueToAngle(i), { 501 value: i, 502 angle: o 503 } 504 }, 505 _round: function (n) { 506 var t = this.options.step.toString().split("."); 507 return t[1] ? parseFloat(n.toFixed(t[1].length)) : Math.round(n) 508 }, 509 _oriAngle: function (n) { 510 var t = n - this._start; 511 return t < 0 && (t += 360), t 512 }, 513 _limitAngle: function (n) { 514 return n > 360 + this._start && (n -= 360), n < this._start && (n += 360), n 515 }, 516 _limitValue: function (n) { 517 return n < this.options.min && (n = this.options.min), n > this.options.max && (n = this.options.max), n 518 }, 519 _angleToValue: function (n) { 520 var t = this.options; 521 return this._oriAngle(n) / this._end * (t.max - t.min) + t.min 522 }, 523 _valueToAngle: function (n) { 524 var t = this.options; 525 return (n - t.min) / (t.max - t.min) * this._end + this._start 526 }, 527 _appendHiddenField: function () { 528 this._hiddenField = createElement("input").attr({ 529 type: "hidden", 530 name: this.control[0].id || "", 531 value: this.options.value 532 }); 533 this.control.append(this._hiddenField) 534 }, 535 _updateHidden: function () { 536 this._hiddenField.val(this.options.value) 537 }, 538 _updateTooltip: function () { 539 this.tooltip && !this.tooltip.hasClass("hover") && this.tooltip.html(this._getTooltipValue()); 540 this._updateTooltipPos() 541 }, 542 _updateTooltipPos: function () { 543 this.tooltip && this.tooltip.css(this._getTooltipPos()) 544 }, 545 _getTooltipPos: function () { 546 var n = this.options.circleShape, 547 t; 548 if (n == "full" || n == "pie" || n.indexOf("custom") === 0) return { 549 "margin-top": -this.tooltip.outerHeight() / 2, 550 "margin-left": -this.tooltip.outerWidth() / 2 551 }; 552 if (n.indexOf("half") != -1) { 553 switch (n) { 554 case "half-top": 555 case "half-bottom": 556 t = { 557 "margin-left": -this.tooltip.outerWidth() / 2 558 }; 559 break; 560 case "half-left": 561 case "half-right": 562 t = { 563 "margin-top": -this.tooltip.outerHeight() / 2 564 } 565 } 566 return t 567 } 568 return {} 569 }, 570 _getTooltipValue: function (n) { 571 if (this._rangeSlider) { 572 var t = this.options.value.split(","); 573 return n ? t[0] + " - " + t[1] : this._tooltipValue(t[0]) + " - " + this._tooltipValue(t[1]) 574 } 575 return n ? this.options.value : this._tooltipValue(this.options.value) 576 }, 577 _tooltipValue: function (n) { 578 var t = this._raise("tooltipFormat", { 579 value: n, 580 handle: this._handleArgs() 581 }); 582 return t != null && typeof t != "boolean" ? t : n 583 }, 584 _validateStartAngle: function () { 585 var n = this.options.startAngle; 586 return n = (isNumber(n) ? parseFloat(n) : 0) % 360, n < 0 && (n += 360), this.options.startAngle = n, n 587 }, 588 _validateEndAngle: function () { 589 var end = this.options.endAngle; 590 if (typeof end == "string" && isNumber(end) && (end.charAt(0) === "+" || end.charAt(0) === "-")) try { 591 end = eval(this.options.startAngle + end.charAt(0) + Math.abs(parseFloat(end))) 592 } catch (e) { 593 console.warn(e) 594 } 595 return end = (isNumber(end) ? parseFloat(end) : 360) % 360, end <= this.options.startAngle && (end += 360), end 596 }, 597 _refreshCircleShape: function () { 598 var n = this.options.circleShape, 599 i = ["half-top", "half-bottom", "half-left", "half-right", "quarter-top-left", "quarter-top-right", "quarter-bottom-right", "quarter-bottom-left", "pie", "custom-half", "custom-quarter"], 600 t; 601 i.indexOf(n) == -1 && (t = ["h1", "h2", "h3", "h4", "q1", "q2", "q3", "q4", "3/4", "ch", "cq"].indexOf(n), n = t != -1 ? i[t] : n == "half" ? "half-top" : n == "quarter" ? "quarter-top-left" : "full"); 602 this.options.circleShape = n 603 }, 604 _appendOverlay: function () { 605 var n = this.options.circleShape; 606 n == "pie" ? this._checkOverlay(".rs-overlay", 270) : (n == "custom-half" || n == "custom-quarter") && (this._checkOverlay(".rs-overlay1", 180), n == "custom-quarter" && this._checkOverlay(".rs-overlay2", this._end)) 607 }, 608 _checkOverlay: function (n, t) { 609 var i = this.container.children(n); 610 i.length == 0 && (i = createElement("div" + n + " rs-transition rs-bg-color"), this.container.append(i)); 611 i.rsRotate(this._start + t) 612 }, 613 _checkDataType: function () { 614 var i = this.options, 615 r, n, t, u = this._props(); 616 for (r in u.numberType) n = u.numberType[r], t = i[n], i[n] = isNumber(t) ? parseFloat(t) : this.defaults[n]; 617 for (r in u.booleanType) n = u.booleanType[r], t = i[n], i[n] = t == "false" ? !1 : !!t; 618 for (r in u.stringType) n = u.stringType[r], t = i[n], i[n] = ("" + t).toLowerCase() 619 }, 620 _validateSliderType: function () { 621 var n = this.options.sliderType.toLowerCase(); 622 this._rangeSlider = this._showRange = !1; 623 n == "range" ? this._rangeSlider = this._showRange = !0 : n.indexOf("min") != -1 ? (this._showRange = !0, n = "min-range") : n = "default"; 624 this.options.sliderType = n 625 }, 626 _updateStartEnd: function () { 627 var n = this.options.circleShape; 628 n != "full" && (n.indexOf("quarter") != -1 ? this.options.endAngle = "+90" : n.indexOf("half") != -1 ? this.options.endAngle = "+180" : n == "pie" && (this.options.endAngle = "+270"), n == "quarter-top-left" || n == "half-top" ? this.options.startAngle = 0 : n == "quarter-top-right" || n == "half-right" ? this.options.startAngle = 90 : n == "quarter-bottom-right" || n == "half-bottom" ? this.options.startAngle = 180 : (n == "quarter-bottom-left" || n == "half-left") && (this.options.startAngle = 270)) 629 }, 630 _validateStartEnd: function () {
631 this._start = this._validateStartAngle(); 632 this._end = this._validateEndAngle(); 633 var n = this._start < this._end ? 0 : 360; 634 this._end += n - this._start 635 }, 636 _analyzeModelValue: function () { 637 var n = this.options.value, 638 t = this.options.min, 639 f = this.options.max, 640 u, r, i = typeof n == "string" ? n.split(",") : [n]; 641 this._rangeSlider ? r = typeof n == "string" ? i.length >= 2 ? (isNumber(i[0]) ? i[0] : t) + "," + (isNumber(i[1]) ? i[1] : f) : isNumber(i[0]) ? t + "," + i[0] : t + "," + t : isNumber(n) ? t + "," + n : t + "," + t : typeof n == "string" ? (u = i.pop(), r = isNumber(u) ? parseFloat(u) : t) : r = isNumber(n) ? parseFloat(n) : t; 642 this.options.value = r 643 }, 644 _validateModelValue: function () { 645 var r = this.options.value, 646 i; 647 if (this._rangeSlider) { 648 var u = r.split(","), 649 n = parseFloat(u[0]), 650 t = parseFloat(u[1]); 651 n = this._limitValue(n); 652 t = this._limitValue(t); 653 n > t && (t = n); 654 this._handle1 = this._processStepByValue(n); 655 this._handle2 = this._processStepByValue(t); 656 this.options.value = this._handle1.value + "," + this._handle2.value 657 } else i = this._showRange ? 2 : this._active || 1, this["_handle" + i] = this._processStepByValue(this._limitValue(r)), this._showRange && (this._handle1 = this._handleDefaults()), this.options.value = this["_handle" + i].value 658 }, 659 _isBrowserSupported: function () { 660 for (var t = ["borderRadius", "WebkitBorderRadius", "MozBorderRadius", "OBorderRadius", "msBorderRadius", "KhtmlBorderRadius"], n = 0; n < t.length; n++) 661 if (document.body.style[t[n]] !== undefined) return !0 662 }, 663 _throwError: function () { 664 return "This browser doesn't support the border-radious property." 665 }, 666 _checkIE: function () { 667 var n = window.navigator.userAgent; 668 (n.indexOf("MSIE ") >= 0 || n.indexOf("Trident/") >= 0) && this.control.css({ 669 "-ms-touch-action": "none", 670 "touch-action": "none" 671 }) 672 }, 673 _raise: function (n, t) { 674 var i = this.options[n], 675 r = !0; 676 return t = t || {}, i && (t.type = n, typeof i == "string" && (i = window[i]), $.isFunction(i) && (r = i.call(this, t), r = r === !1 ? !1 : r)), this.control.trigger($.Event ? $.Event(n, t) : n), r 677 }, 678 _bind: function (n, t, i) { 679 $(n).bind(t, $proxy(i, this)) 680 }, 681 _unbind: function (n, t, i) { 682 $.proxy ? $(n).unbind(t, $.proxy(i, this)) : $(n).unbind(t) 683 }, 684 _getInstance: function () { 685 return $data(this.control[0], pluginName) 686 }, 687 _removeData: function () { 688 var n = this.control[0]; 689 $.removeData && $.removeData(n, pluginName); 690 n.id && delete window[n.id] 691 }, 692 _destroyControl: function () { 693 this.control.empty().removeClass("rs-control").height("").width(""); 694 this._removeAnimation(); 695 this._bindControlEvents("_unbind") 696 }, 697 _updateWidth: function () { 698 this.lastBlock.css("padding", this.options.width); 699 this._refreshHandle() 700 }, 701 _readOnly: function (n) { 702 this._isReadOnly = n; 703 this.container.removeClass("rs-readonly"); 704 n && this.container.addClass("rs-readonly") 705 }, 706 _get: function (n) { 707 return this.options[n] 708 }, 709 _set: function (n, t) { 710 var i = this._props(); 711 if ($.inArray(n, i.numberType) != -1) { 712 if (!isNumber(t)) return; 713 t = parseFloat(t) 714 } else $.inArray(n, i.booleanType) != -1 ? t = t == "false" ? !1 : !!t : $.inArray(n, i.stringType) != -1 && (t = t.toLowerCase()); 715 if (this.options[n] != t) { 716 this.options[n] = t; 717 switch (n) { 718 case "startAngle": 719 case "endAngle":
720 this._validateStartEnd(); 721 this._updateSeperator(); 722 this._appendOverlay(); 723 case "min": 724 case "max": 725 case "step": 726 case "value": 727 this._analyzeModelValue(); 728 this._validateModelValue(); 729 this._setValue(); 730 this._updateHidden(); 731 this._updateTooltip(); 732 break; 733 case "radius": 734 this._setRadius(); 735 this._updateTooltipPos(); 736 break; 737 case "width": 738 this._removeAnimation(); 739 this._updateWidth(); 740 this._updateTooltipPos(); 741 this._addAnimation(); 742 this.container.children().find(".rs-seperator").css({ 743 width: this.options.width, 744 "margin-left": this._border() / 2 745 }); 746 break; 747 case "handleSize": 748 this._refreshHandle(); 749 break; 750 case "handleShape": 751 this._setHandleShape(); 752 break; 753 case "animation": 754 this._setAnimation(); 755 break; 756 case "showTooltip": 757 this.options.showTooltip ? this._appendTooltip() : this._removeTooltip(); 758 break; 759 case "editableTooltip": 760 this._tooltipEditable(); 761 this._updateTooltipPos(); 762 break; 763 case "disabled": 764 this.options.disabled ? this.disable() : this.enable(); 765 break; 766 case "readOnly": 767 this.options.readOnly ? this._readOnly(!0) : !this.options.disabled && this._readOnly(!1); 768 break; 769 case "mouseScrollAction": 770 this._bindScrollEvents(this.options.mouseScrollAction ? "_bind" : "_unbind"); 771 break; 772 case "circleShape": 773 this._refreshCircleShape(); 774 this.options.circleShape == "full" && (this.options.startAngle = 0, this.options.endAngle = "+360"); 775 case "sliderType": 776 this._destroyControl(); 777 this._init() 778 } 779 return this 780 } 781 }, 782 option: function (n, t) { 783 if (this._getInstance() && this._isBrowserSupport) { 784 if ($isPlainObject(n)) { 785 (n.min !== undefined || n.max !== undefined) && (n.min !== undefined && (this.options.min = n.min, delete n.min), n.max !== undefined && (this.options.max = n.max, delete n.max), n.value == undefined && this._set("value", this.options.value)); 786 for (var i in n) this._set(i, n[i]) 787 } else if (n && typeof n == "string") { 788 if (t === undefined) return this._get(n); 789 this._set(n, t) 790 } 791 return this 792 } 793 }, 794 getValue: function (n) { 795 if (this.options.sliderType == "range" && n && isNumber(n)) { 796 var t = parseFloat(n); 797 if (t == 1 || t == 2) return this["_handle" + t].value 798 } 799 return this._get("value") 800 }, 801 setValue: function (n, t) { 802 if (n && isNumber(n)) { 803 if (t && isNumber(t)) 804 if (this.options.sliderType == "range") { 805 var i = parseFloat(t), 806 r = parseFloat(n); 807 i == 1 ? n = r + "," + this._handle2.value : i == 2 && (n = this._handle1.value + "," + r) 808 } else this.options.sliderType == "default" && (this._active = t); 809 this._set("value", n) 810 } 811 }, 812 disable: function () { 813 this.options.disabled = !0; 814 this.container.addClass("rs-disabled"); 815 this._readOnly(!0) 816 }, 817 enable: function () { 818 this.options.disabled = !1; 819 this.container.removeClass("rs-disabled"); 820 this.options.readOnly || this._readOnly(!1) 821 }, 822 destroy: function () { 823 this._getInstance() && (this._destroyControl(), this._removeData(), this._originalObj.insertAfter(this.control), this.control.remove()) 824 } 825 }; 826 $.fn.rsRotate = function (n) { 827 return setTransform(this, n) 828 }; 829 typeof $.fn.outerHeight == "undefined" && ($.fn.outerHeight = function () { 830 return this[0].offsetHeight 831 }, $.fn.outerWidth = function () { 832 return this[0].offsetWidth 833 });
834 typeof $.fn.hasClass == "undefined" && ($.fn.hasClass = function (n) { 835 return this[0].className.split(" ").indexOf(n) !== -1 836 }); 837 typeof $.fn.offset == "undefined" && ($.fn.offset = function () { 838 return { 839 left: this[0].offsetLeft, 840 top: this[0].offsetTop 841 } 842 }); 843 $.fn[pluginName].prototype = RoundSlider.prototype 844})(jQuery, window)
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.