(function() { var $, Silder, digitRound; $ = jQuery; this.settings = { round: false, value: 0, total: 10, step: 0, callback: function() {} }; Silder = (function() { function Silder(args) { var _ref; _ref = [args.elem, args.settings], this.elem = _ref[0], this.settings = _ref[1]; this.callback = this.settings.callback; this.step = this.settings.step; this.value = this.settings.value; this.total = this.settings.total; this.percent = 0; this.wrapper = {}; this.init(); } Silder.prototype.init = function() { var $btn, $target, $wrapper, templ, total, value; $target = $(this.elem); templ = $("
").attr({ "class": "silder-wrapper" }); $target.append(templ); this.wrapper = $target.children().filter(".silder-wrapper"); $btn = $(this.wrapper).children(".silder-btn"); $wrapper = $(this.wrapper); if (this.value !== 0) { value = this.value; total = this.total; setTimeout(function() { return $btn.css({ top: 0, left: $wrapper.width() * value / total - $btn.width() / 2 }); }, 30); } return this.setEvent(); }; Silder.prototype.getPercent = function() { return this.percent; }; Silder.prototype.setEvent = function() { var $btn, callback, digit, gridH, gridW, step, total, wrapper; wrapper = this.wrapper; callback = this.callback; $btn = $(this.wrapper).children(".silder-btn"); step = this.step; total = this.total; $btn = $(this.wrapper).children(".silder-btn"); gridW = $btn.width(); if (step !== 0) { digit = Math.pow(10, step.toString().length - 2); gridW = gridW / digit; } gridH = $btn.height(); $btn.draggable({ cursor: "col-resize", containment: 'parent', axis: "x", grid: [gridW, gridH], refreshPositions: true, drag: function(event, ui) { var ajax, percent, value; percent = (ui.position.left + $btn.width() / 2) / wrapper.width(); ajax = false; percent = digitRound(percent, step); value = digitRound(percent * total, step); return callback.apply(this, [percent, value, ajax]); }, stop: function(event, ui) { var ajax, percent, value; percent = (ui.position.left + $btn.width() / 2) / wrapper.width(); ajax = true; percent = digitRound(percent, step); value = digitRound(percent * total, step); return callback.apply(this, [percent, value, ajax]); } }); return this; }; return Silder; })(); digitRound = function(v, step) { var digit; if (step !== 0) { digit = Math.pow(10, step.toString().length - 2); v = Math.round(parseFloat(v) * digit) / digit; } return v; }; $.fn.extend({ silder: function(options) { this.settings = $.extend(settings, options); return this.each(function(idx, elem) { var silder; return silder = new Silder({ elem: elem, settings: settings }); }); } }); }).call(this); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNpbGRlci5jb2ZmZWUiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUFBQSxNQUFBLHFCQUFBOztBQUFBLEVBQUEsQ0FBQSxHQUFJLE1BQUosQ0FBQTs7QUFBQSxFQUVBLElBQUMsQ0FBQSxRQUFELEdBQ0U7QUFBQSxJQUFBLEtBQUEsRUFBTyxLQUFQO0FBQUEsSUFDQSxLQUFBLEVBQU8sQ0FEUDtBQUFBLElBRUEsS0FBQSxFQUFPLEVBRlA7QUFBQSxJQUdBLElBQUEsRUFBTSxDQUhOO0FBQUEsSUFJQSxRQUFBLEVBQVUsU0FBQSxHQUFBLENBSlY7R0FIRixDQUFBOztBQUFBLEVBV007QUFDUyxJQUFBLGdCQUFDLElBQUQsR0FBQTtBQUNYLFVBQUEsSUFBQTtBQUFBLE1BQUEsT0FBcUIsQ0FBQyxJQUFJLENBQUMsSUFBTixFQUFZLElBQUksQ0FBQyxRQUFqQixDQUFyQixFQUFDLElBQUMsQ0FBQSxjQUFGLEVBQVEsSUFBQyxDQUFBLGtCQUFULENBQUE7QUFBQSxNQUNBLElBQUMsQ0FBQSxRQUFELEdBQVksSUFBQyxDQUFBLFFBQVEsQ0FBQyxRQUR0QixDQUFBO0FBQUEsTUFHQSxJQUFDLENBQUEsSUFBRCxHQUFRLElBQUMsQ0FBQSxRQUFRLENBQUMsSUFIbEIsQ0FBQTtBQUFBLE1BSUEsSUFBQyxDQUFBLEtBQUQsR0FBUyxJQUFDLENBQUEsUUFBUSxDQUFDLEtBSm5CLENBQUE7QUFBQSxNQUtBLElBQUMsQ0FBQSxLQUFELEdBQVMsSUFBQyxDQUFBLFFBQVEsQ0FBQyxLQUxuQixDQUFBO0FBQUEsTUFNQSxJQUFDLENBQUEsT0FBRCxHQUFXLENBTlgsQ0FBQTtBQ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