removed mods directory from the ATutor codebase
[atutor.git] / mods / atutor_opencaps / opencaps / js / jquery / ui.slider.js
diff --git a/mods/atutor_opencaps/opencaps/js/jquery/ui.slider.js b/mods/atutor_opencaps/opencaps/js/jquery/ui.slider.js
deleted file mode 100755 (executable)
index 9b8f221..0000000
+++ /dev/null
@@ -1,558 +0,0 @@
-/*\r
- * jQuery UI Slider 1.7.2\r
- *\r
- * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)\r
- * Dual licensed under the MIT (MIT-LICENSE.txt)\r
- * and GPL (GPL-LICENSE.txt) licenses.\r
- *\r
- * http://docs.jquery.com/UI/Slider\r
- *\r
- * Depends:\r
- *     ui.core.js\r
- */\r
-\r
-(function($) {\r
-\r
-$.widget("ui.slider", $.extend({}, $.ui.mouse, {\r
-\r
-       _init: function() {\r
-\r
-               var self = this, o = this.options;\r
-               this._keySliding = false;\r
-               this._handleIndex = null;\r
-               this._detectOrientation();\r
-               this._mouseInit();\r
-\r
-               this.element\r
-                       .addClass("ui-slider"\r
-                               + " ui-slider-" + this.orientation\r
-                               + " ui-widget"\r
-                               + " ui-widget-content"\r
-                               + " ui-corner-all");\r
-\r
-               this.range = $([]);\r
-\r
-               if (o.range) {\r
-\r
-                       if (o.range === true) {\r
-                               this.range = $('<div></div>');\r
-                               if (!o.values) o.values = [this._valueMin(), this._valueMin()];\r
-                               if (o.values.length && o.values.length != 2) {\r
-                                       o.values = [o.values[0], o.values[0]];\r
-                               }\r
-                       } else {\r
-                               this.range = $('<div></div>');\r
-                       }\r
-\r
-                       this.range\r
-                               .appendTo(this.element)\r
-                               .addClass("ui-slider-range");\r
-\r
-                       if (o.range == "min" || o.range == "max") {\r
-                               this.range.addClass("ui-slider-range-" + o.range);\r
-                       }\r
-\r
-                       // note: this isn't the most fittingly semantic framework class for this element,\r
-                       // but worked best visually with a variety of themes\r
-                       this.range.addClass("ui-widget-header");\r
-\r
-               }\r
-\r
-               if ($(".ui-slider-handle", this.element).length == 0)\r
-                       $('<a href="#"></a>')\r
-                               .appendTo(this.element)\r
-                               .addClass("ui-slider-handle");\r
-\r
-               if (o.values && o.values.length) {\r
-                       while ($(".ui-slider-handle", this.element).length < o.values.length)\r
-                               $('<a href="#"></a>')\r
-                                       .appendTo(this.element)\r
-                                       .addClass("ui-slider-handle");\r
-               }\r
-\r
-               this.handles = $(".ui-slider-handle", this.element)\r
-                       .addClass("ui-state-default"\r
-                               + " ui-corner-all");\r
-\r
-               this.handle = this.handles.eq(0);\r
-\r
-               this.handles.add(this.range).filter("a")\r
-                       .click(function(event) {\r
-                               event.preventDefault();\r
-                       })\r
-                       .hover(function() {\r
-                               if (!o.disabled) {\r
-                                       $(this).addClass('ui-state-hover');\r
-                               }\r
-                       }, function() {\r
-                               $(this).removeClass('ui-state-hover');\r
-                       })\r
-                       .focus(function() {\r
-                               if (!o.disabled) {\r
-                                       $(".ui-slider .ui-state-focus").removeClass('ui-state-focus'); $(this).addClass('ui-state-focus');\r
-                               } else {\r
-                                       $(this).blur();\r
-                               }\r
-                       })\r
-                       .blur(function() {\r
-                               $(this).removeClass('ui-state-focus');\r
-                       });\r
-\r
-               this.handles.each(function(i) {\r
-                       $(this).data("index.ui-slider-handle", i);\r
-               });\r
-\r
-               this.handles.keydown(function(event) {\r
-\r
-                       var ret = true;\r
-\r
-                       var index = $(this).data("index.ui-slider-handle");\r
-\r
-                       if (self.options.disabled)\r
-                               return;\r
-\r
-                       switch (event.keyCode) {\r
-                               case $.ui.keyCode.HOME:\r
-                               case $.ui.keyCode.END:\r
-                               case $.ui.keyCode.UP:\r
-                               case $.ui.keyCode.RIGHT:\r
-                               case $.ui.keyCode.DOWN:\r
-                               case $.ui.keyCode.LEFT:\r
-                                       ret = false;\r
-                                       if (!self._keySliding) {\r
-                                               self._keySliding = true;\r
-                                               $(this).addClass("ui-state-active");\r
-                                               self._start(event, index);\r
-                                       }\r
-                                       break;\r
-                       }\r
-\r
-                       var curVal, newVal, step = self._step();\r
-                       if (self.options.values && self.options.values.length) {\r
-                               curVal = newVal = self.values(index);\r
-                       } else {\r
-                               curVal = newVal = self.value();\r
-                       }\r
-\r
-                       switch (event.keyCode) {\r
-                               case $.ui.keyCode.HOME:\r
-                                       newVal = self._valueMin();\r
-                                       break;\r
-                               case $.ui.keyCode.END:\r
-                                       newVal = self._valueMax();\r
-                                       break;\r
-                               case $.ui.keyCode.UP:\r
-                               case $.ui.keyCode.RIGHT:\r
-                                       if(curVal == self._valueMax()) return;\r
-                                       newVal = curVal + step;\r
-                                       break;\r
-                               case $.ui.keyCode.DOWN:\r
-                               case $.ui.keyCode.LEFT:\r
-                                       if(curVal == self._valueMin()) return;\r
-                                       newVal = curVal - step;\r
-                                       break;\r
-                       }\r
-\r
-                       self._slide(event, index, newVal);\r
-\r
-                       return ret;\r
-\r
-               }).keyup(function(event) {\r
-\r
-                       var index = $(this).data("index.ui-slider-handle");\r
-\r
-                       if (self._keySliding) {\r
-                               self._stop(event, index);\r
-                               self._change(event, index);\r
-                               self._keySliding = false;\r
-                               $(this).removeClass("ui-state-active");\r
-                       }\r
-\r
-               });\r
-\r
-               this._refreshValue();\r
-\r
-       },\r
-\r
-       destroy: function() {\r
-\r
-               this.handles.remove();\r
-               this.range.remove();\r
-\r
-               this.element\r
-                       .removeClass("ui-slider"\r
-                               + " ui-slider-horizontal"\r
-                               + " ui-slider-vertical"\r
-                               + " ui-slider-disabled"\r
-                               + " ui-widget"\r
-                               + " ui-widget-content"\r
-                               + " ui-corner-all")\r
-                       .removeData("slider")\r
-                       .unbind(".slider");\r
-\r
-               this._mouseDestroy();\r
-\r
-       },\r
-\r
-       _mouseCapture: function(event) {\r
-\r
-               var o = this.options;\r
-\r
-               if (o.disabled)\r
-                       return false;\r
-\r
-               this.elementSize = {\r
-                       width: this.element.outerWidth(),\r
-                       height: this.element.outerHeight()\r
-               };\r
-               this.elementOffset = this.element.offset();\r
-\r
-               var position = { x: event.pageX, y: event.pageY };\r
-               var normValue = this._normValueFromMouse(position);\r
-\r
-               var distance = this._valueMax() - this._valueMin() + 1, closestHandle;\r
-               var self = this, index;\r
-               this.handles.each(function(i) {\r
-                       var thisDistance = Math.abs(normValue - self.values(i));\r
-                       if (distance > thisDistance) {\r
-                               distance = thisDistance;\r
-                               closestHandle = $(this);\r
-                               index = i;\r
-                       }\r
-               });\r
-\r
-               // workaround for bug #3736 (if both handles of a range are at 0,\r
-               // the first is always used as the one with least distance,\r
-               // and moving it is obviously prevented by preventing negative ranges)\r
-               if(o.range == true && this.values(1) == o.min) {\r
-                       closestHandle = $(this.handles[++index]);\r
-               }\r
-\r
-               this._start(event, index);\r
-\r
-               self._handleIndex = index;\r
-\r
-               closestHandle\r
-                       .addClass("ui-state-active")\r
-                       .focus();\r
-               \r
-               var offset = closestHandle.offset();\r
-               var mouseOverHandle = !$(event.target).parents().andSelf().is('.ui-slider-handle');\r
-               this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {\r
-                       left: event.pageX - offset.left - (closestHandle.width() / 2),\r
-                       top: event.pageY - offset.top\r
-                               - (closestHandle.height() / 2)\r
-                               - (parseInt(closestHandle.css('borderTopWidth'),10) || 0)\r
-                               - (parseInt(closestHandle.css('borderBottomWidth'),10) || 0)\r
-                               + (parseInt(closestHandle.css('marginTop'),10) || 0)\r
-               };\r
-\r
-               normValue = this._normValueFromMouse(position);\r
-               this._slide(event, index, normValue);\r
-               return true;\r
-\r
-       },\r
-\r
-       _mouseStart: function(event) {\r
-               return true;\r
-       },\r
-\r
-       _mouseDrag: function(event) {\r
-\r
-               var position = { x: event.pageX, y: event.pageY };\r
-               var normValue = this._normValueFromMouse(position);\r
-               \r
-               this._slide(event, this._handleIndex, normValue);\r
-\r
-               return false;\r
-\r
-       },\r
-\r
-       _mouseStop: function(event) {\r
-\r
-               this.handles.removeClass("ui-state-active");\r
-               this._stop(event, this._handleIndex);\r
-               this._change(event, this._handleIndex);\r
-               this._handleIndex = null;\r
-               this._clickOffset = null;\r
-\r
-               return false;\r
-\r
-       },\r
-       \r
-       _detectOrientation: function() {\r
-               this.orientation = this.options.orientation == 'vertical' ? 'vertical' : 'horizontal';\r
-       },\r
-\r
-       _normValueFromMouse: function(position) {\r
-\r
-               var pixelTotal, pixelMouse;\r
-               if ('horizontal' == this.orientation) {\r
-                       pixelTotal = this.elementSize.width;\r
-                       pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0);\r
-               } else {\r
-                       pixelTotal = this.elementSize.height;\r
-                       pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0);\r
-               }\r
-\r
-               var percentMouse = (pixelMouse / pixelTotal);\r
-               if (percentMouse > 1) percentMouse = 1;\r
-               if (percentMouse < 0) percentMouse = 0;\r
-               if ('vertical' == this.orientation)\r
-                       percentMouse = 1 - percentMouse;\r
-\r
-               var valueTotal = this._valueMax() - this._valueMin(),\r
-                       valueMouse = percentMouse * valueTotal,\r
-                       valueMouseModStep = valueMouse % this.options.step,\r
-                       normValue = this._valueMin() + valueMouse - valueMouseModStep;\r
-\r
-               if (valueMouseModStep > (this.options.step / 2))\r
-                       normValue += this.options.step;\r
-\r
-               // Since JavaScript has problems with large floats, round\r
-               // the final value to 5 digits after the decimal point (see #4124)\r
-               return parseFloat(normValue.toFixed(5));\r
-\r
-       },\r
-\r
-       _start: function(event, index) {\r
-               var uiHash = {\r
-                       handle: this.handles[index],\r
-                       value: this.value()\r
-               };\r
-               if (this.options.values && this.options.values.length) {\r
-                       uiHash.value = this.values(index);\r
-                       uiHash.values = this.values();\r
-               }\r
-               this._trigger("start", event, uiHash);\r
-       },\r
-\r
-       _slide: function(event, index, newVal) {\r
-\r
-               var handle = this.handles[index];\r
-\r
-               if (this.options.values && this.options.values.length) {\r
-\r
-                       var otherVal = this.values(index ? 0 : 1);\r
-\r
-                       if ((this.options.values.length == 2 && this.options.range === true) && \r
-                               ((index == 0 && newVal > otherVal) || (index == 1 && newVal < otherVal))){\r
-                               newVal = otherVal;\r
-                       }\r
-\r
-                       if (newVal != this.values(index)) {\r
-                               var newValues = this.values();\r
-                               newValues[index] = newVal;\r
-                               // A slide can be canceled by returning false from the slide callback\r
-                               var allowed = this._trigger("slide", event, {\r
-                                       handle: this.handles[index],\r
-                                       value: newVal,\r
-                                       values: newValues\r
-                               });\r
-                               var otherVal = this.values(index ? 0 : 1);\r
-                               if (allowed !== false) {\r
-                                       this.values(index, newVal, ( event.type == 'mousedown' && this.options.animate ), true);\r
-                               }\r
-                       }\r
-\r
-               } else {\r
-\r
-                       if (newVal != this.value()) {\r
-                               // A slide can be canceled by returning false from the slide callback\r
-                               var allowed = this._trigger("slide", event, {\r
-                                       handle: this.handles[index],\r
-                                       value: newVal\r
-                               });\r
-                               if (allowed !== false) {\r
-                                       this._setData('value', newVal, ( event.type == 'mousedown' && this.options.animate ));\r
-                               }\r
-                                       \r
-                       }\r
-\r
-               }\r
-\r
-       },\r
-\r
-       _stop: function(event, index) {\r
-               var uiHash = {\r
-                       handle: this.handles[index],\r
-                       value: this.value()\r
-               };\r
-               if (this.options.values && this.options.values.length) {\r
-                       uiHash.value = this.values(index);\r
-                       uiHash.values = this.values();\r
-               }\r
-               this._trigger("stop", event, uiHash);\r
-       },\r
-\r
-       _change: function(event, index) {\r
-               var uiHash = {\r
-                       handle: this.handles[index],\r
-                       value: this.value()\r
-               };\r
-               if (this.options.values && this.options.values.length) {\r
-                       uiHash.value = this.values(index);\r
-                       uiHash.values = this.values();\r
-               }\r
-               this._trigger("change", event, uiHash);\r
-       },\r
-\r
-       value: function(newValue) {\r
-\r
-               if (arguments.length) {\r
-                       this._setData("value", newValue);\r
-                       this._change(null, 0);\r
-               }\r
-\r
-               return this._value();\r
-\r
-       },\r
-\r
-       values: function(index, newValue, animated, noPropagation) {\r
-\r
-               if (arguments.length > 1) {\r
-                       this.options.values[index] = newValue;\r
-                       this._refreshValue(animated);\r
-                       if(!noPropagation) this._change(null, index);\r
-               }\r
-\r
-               if (arguments.length) {\r
-                       if (this.options.values && this.options.values.length) {\r
-                               return this._values(index);\r
-                       } else {\r
-                               return this.value();\r
-                       }\r
-               } else {\r
-                       return this._values();\r
-               }\r
-\r
-       },\r
-\r
-       _setData: function(key, value, animated) {\r
-\r
-               $.widget.prototype._setData.apply(this, arguments);\r
-\r
-               switch (key) {\r
-                       case 'disabled':\r
-                               if (value) {\r
-                                       this.handles.filter(".ui-state-focus").blur();\r
-                                       this.handles.removeClass("ui-state-hover");\r
-                                       this.handles.attr("disabled", "disabled");\r
-                               } else {\r
-                                       this.handles.removeAttr("disabled");\r
-                               }\r
-                       case 'orientation':\r
-\r
-                               this._detectOrientation();\r
-                               \r
-                               this.element\r
-                                       .removeClass("ui-slider-horizontal ui-slider-vertical")\r
-                                       .addClass("ui-slider-" + this.orientation);\r
-                               this._refreshValue(animated);\r
-                               break;\r
-                       case 'value':\r
-                               this._refreshValue(animated);\r
-                               break;\r
-               }\r
-\r
-       },\r
-\r
-       _step: function() {\r
-               var step = this.options.step;\r
-               return step;\r
-       },\r
-\r
-       _value: function() {\r
-\r
-               var val = this.options.value;\r
-               if (val < this._valueMin()) val = this._valueMin();\r
-               if (val > this._valueMax()) val = this._valueMax();\r
-\r
-               return val;\r
-\r
-       },\r
-\r
-       _values: function(index) {\r
-\r
-               if (arguments.length) {\r
-                       var val = this.options.values[index];\r
-                       if (val < this._valueMin()) val = this._valueMin();\r
-                       if (val > this._valueMax()) val = this._valueMax();\r
-\r
-                       return val;\r
-               } else {\r
-                       return this.options.values;\r
-               }\r
-\r
-       },\r
-\r
-       _valueMin: function() {\r
-               var valueMin = this.options.min;\r
-               return valueMin;\r
-       },\r
-\r
-       _valueMax: function() {\r
-               var valueMax = this.options.max;\r
-               return valueMax;\r
-       },\r
-\r
-       _refreshValue: function(animate) {\r
-\r
-               var oRange = this.options.range, o = this.options, self = this;\r
-\r
-               if (this.options.values && this.options.values.length) {\r
-                       var vp0, vp1;\r
-                       this.handles.each(function(i, j) {\r
-                               var valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100;\r
-                               var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';\r
-                               $(this).stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);\r
-                               if (self.options.range === true) {\r
-                                       if (self.orientation == 'horizontal') {\r
-                                               (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ left: valPercent + '%' }, o.animate);\r
-                                               (i == 1) && self.range[animate ? 'animate' : 'css']({ width: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate });\r
-                                       } else {\r
-                                               (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ bottom: (valPercent) + '%' }, o.animate);\r
-                                               (i == 1) && self.range[animate ? 'animate' : 'css']({ height: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate });\r
-                                       }\r
-                               }\r
-                               lastValPercent = valPercent;\r
-                       });\r
-               } else {\r
-                       var value = this.value(),\r
-                               valueMin = this._valueMin(),\r
-                               valueMax = this._valueMax(),\r
-                               valPercent = valueMax != valueMin\r
-                                       ? (value - valueMin) / (valueMax - valueMin) * 100\r
-                                       : 0;\r
-                       var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%';\r
-                       this.handle.stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate);\r
-\r
-                       (oRange == "min") && (this.orientation == "horizontal") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ width: valPercent + '%' }, o.animate);\r
-                       (oRange == "max") && (this.orientation == "horizontal") && this.range[animate ? 'animate' : 'css']({ width: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });\r
-                       (oRange == "min") && (this.orientation == "vertical") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ height: valPercent + '%' }, o.animate);\r
-                       (oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });\r
-               }\r
-\r
-       }\r
-       \r
-}));\r
-\r
-$.extend($.ui.slider, {\r
-       getter: "value values",\r
-       version: "1.7.2",\r
-       eventPrefix: "slide",\r
-       defaults: {\r
-               animate: false,\r
-               delay: 0,\r
-               distance: 0,\r
-               max: 100,\r
-               min: 0,\r
-               orientation: 'horizontal',\r
-               range: false,\r
-               step: 1,\r
-               value: 0,\r
-               values: null\r
-       }\r
-});\r
-\r
-})(jQuery);\r