Вход Регистрация
Файл: 100loto.best/fortune/assets/js/superwheel.js
Строк: 1068
<?php
;(function(factory) {
    
'use strict';
    if (
typeof define === 'function' && define.amd) {
        
define(['jquery'], factory);
    } else if (
typeof exports !== 'undefined') {
        
module.exports factory(require('jquery'));
    } else {
        
factory(jQuery);
    }
}(function($) {
    
'use strict';
    var 
SuperWheel window.SuperWheel || {};
    
SuperWheel = (function() {
        var 
instanceUid 0;
        function 
SuperWheel(elementsettings) {
            var 
self this,
                
dataSettings;
            
self.defaults = {
                
slices: [{name:'Win',message:'You win',value:'win'},{name:'Lose',message:'You lose',value:'lose'}],
                
slice: {
                    
background "#333",
                    
selected : {
                        
background"#ddd",
                        
color:      "#333"
                    
}
                },
                
text: {
                    
type'text',
                    
color'#fefefe',
                    
size 16,
                    
offset 10,
                    
letterSpacing 0,
                    
orientation'v',
                    
arcfalse
                
},
                
line: {
                    
width 6,
                    
color "#d6d6d6",
                },
                
outer: {
                    
width 12,
                    
color "#d6d6d6",
                },
                
inner: {
                    
width 12,
                    
color "#d6d6d6",
                },
                
center: {
                    
width      30,
                    
background '#FFFFFF00',
                    
rotate     true,
                    class      : 
"",
                    
image      :{
                            
url   "",
                            
width 45,
                    },
                    
html      : {
                        
template '',
                        
width    45,
                    }
                },
                
marker:{
                    
animate true,
                    
background'#e74c3c'
                
},
                
width500,
                
easing'superWheel',
                
duration8000,
                
selector'value',
                
type'rotate',
                
rotates8,
                
frame6,
            };
            
dataSettings = $(element).data('superWheel') || {};
            
self.= $.extend({}, self.defaultssettingsdataSettings);
            
            if(
typeof self.o.text   !== 'object'self.o.text   self.defaults.text;
                else 
self.o.text = $.extend({}, self.defaults.textself.o.text);
                
            if(
typeof self.o.slice  !== 'object'self.o.slice  self.defaults.slice;
                else 
self.o.slice = $.extend({}, self.defaults.sliceself.o.slice);
                
            if(
typeof self.o.slice.selected !== 'object'self.o.slice.selected self.defaults.slice.selected;
                else 
self.o.slice.selected = $.extend({}, self.defaults.slice.selectedself.o.slice.selected);
                
            if(
typeof self.o.line  !== 'object'self.o.line  self.defaults.line;
                else 
self.o.line = $.extend({}, self.defaults.lineself.o.line);
                
            if(
typeof self.o.outer  !== 'object'self.o.outer  self.defaults.outer;
                else 
self.o.outer = $.extend({}, self.defaults.outerself.o.outer);
                
            if(
typeof self.o.inner  !== 'object'self.o.inner  self.defaults.inner;
                else 
self.o.inner = $.extend({}, self.defaults.innerself.o.inner);
                
            if(
typeof self.o.center !== 'object'self.o.center self.defaults.center;
                else 
self.o.center = $.extend({}, self.defaults.centerself.o.center);
                
            if(
typeof self.o.center.image !== 'object'self.o.center.image self.defaults.center.image;
            
            if(
typeof self.o.center.html !== 'object'self.o.center.html self.defaults.center.html;
            
            if( (
typeof self.o.center.html.template === 'undefined' || self.o.center.html.template )  && typeof self.o.center.html.tmpl !== 'undefined')
                
self.o.center.html.template self.o.center.html.tmpl;
            
            if( (
typeof self.o.center.image.url === 'undefined' || self.o.center.image.url )  && typeof self.o.center.image.src !== 'undefined')
                
self.o.center.image.url self.defaults.center.image.src;
            
            if(
typeof self.o.marker !== 'object'self.o.marker self.defaults.marker;
                else 
self.o.marker = $.extend({}, self.defaults.markerself.o.marker);
                
            $.
each(self.o.slices, function(islice) {
                var 
validatedSlice slice;
                if(
typeof validatedSlice.color === 'undefined'){
                    
validatedSlice.color self.o.text.color;
                }
                if(
typeof validatedSlice.background === 'undefined' ){
                    if(!
self.o.slice.background){
                        
validatedSlice.background self.randomColor((360/self.o.slices.length) * i);
                    }else{
                        
validatedSlice.background self.o.slice.background;
                    }
                }
                
self.o.slices[i] = validatedSlice;
            });
            
            if( (
typeof self.o.center.image.url === 'undefined' || self.o.center.image.url )  && typeof self.o.center.image.src !== 'undefined')
                
self.o.center.image.url self.defaults.center.image.src;
            
            if( 
typeof self.o.center.image.width !== 'undefined')
                
self.o.center.image.width Math.abs(self.o.center.image.width);
            
            
self.o.width Math.abs(self.o.width);
            
self.o.center.width Math.abs(self.o.center.width);
            
self.o.outer.width Math.abs(self.o.outer.width/2);
            
self.o.inner.width Math.abs(self.o.inner.width/2);
            
self.o.line.width Math.abs(self.o.line.width/2);
            
self.initials = {
                
spinnerfalse,
                
now0,
                
spinningfalse,
                
slice: {
                    
idnull,
                    
resultsnull,
                },
                
currentSliceData: {
                    
idnull,
                    
resultsnull,
                },
                
winnerfalse,
                
spinCount0,
                
counter0,
                
currentSlice0,
                
currentStep0,
                
lastStep0,
                
slicePercent0,
                
circlePercent0,
                
rotatesparseInt(self.o.rotates,10),
                
$element: $(element),
                
slices self.o.slices,
                
width 400,
                
cache: $(element).data('superWheelData') ? $(element).data('superWheelData').cache : []
            };
            $.
extend(selfself.initials);
            
self.half 200 2;
            $.
extend($.easing, {superWheel: function(xtbcd) {return -* ((1) * 1) + b}});
            $.
extend($.easing, {easeOutQuad: function(xtbcd) {return -* (/= d) * (2) + b;}});
            
self.instanceUid = $(element).data('superWheelData') ? $(element).data('superWheelData').instanceUid instanceUid++;
            $(
element).data('superWheelData',self);
            
self.init();
        }
        return 
SuperWheel;
    }());
    
/*#######################################################
    /////////////////////////////////////////////////////////
    ////////////////////   Initialize   /////////////////////
    /////////////////////////////////////////////////////////
    #######################################################*/
    
SuperWheel.prototype.init = function() {
        var 
self this;
        
self.$element.addClass('superWheel _' self.instanceUid).html('');
        
self.$element.html('');
        var 
arcSize 360 self.totalSlices(),
            
pStart 0,
            
pEnd 0,
            
wrapper = $('<div/>').addClass('sWheel-wrapper').appendTo(self.$element),
            
inner = $('<div/>').addClass('sWheel-inner').appendTo(wrapper),
            
spinner = $('<div/>').addClass('sWheel').prependTo(inner),
            
Layerbg = $('<div/>').addClass('sWheel-bg-layer').appendTo(spinner),
            
Layersvg = $(self.SVG('svg', {
                
'version''1.1',
                
'xmlns''http://www.w3.org/2000/svg',
                
'xmlns:xlink''http://www.w3.org/1999/xlink',
                
'x''0px',
                
'y''0px',
                
'viewBox''0 0 200 200',
                
'xml:space''preserve',
                
'style''enable-background:new 0 0 200 200;',
            })),
            
mask = $('<defs><clipPath id="cut-off-line"></circle></clipPath></defs>'),
            
maskArc self.annularSector({
                
centerXself.half,
                
centerYself.half,
                
startDegrees0,
                
endDegrees359.990000,
                
innerRadiusparseInt(self.o.center.width10 ),
                
outerRadiusself.half - ( parseInt(self.o.outer.width10) > 1  )
            });
        
mask.find('clipPath')
        .
append(self.SVG('path',{
                
'stroke-width'0,
                
'fill''#ccc',
                
'd'maskArc
            
}))
        .
closest('defs').appendTo(Layersvg);
        if ( ( 
self.o.text.orientation === 'v' || self.o.text.orientation === 'vertical') ||
                ( (
self.o.text.type === 'icon' || self.o.text.type === 'image') && ( self.o.text.orientation === 'h' || self.o.text.orientation === 'horizontal' ) ) ){
            var 
Layertext = $('<div/>'),
                
textHtml = $('<div/>');
            
Layertext.addClass('sWheel-txt-wrap');
            
Layertext.appendTo(spinner);
            
textHtml.addClass('sWheel-txt');
            
textHtml.css({
                
'-webkit-transform''rotate(' + ((-(360 self.totalSlices()) / 2) + self.getDegree()) + 'deg)',
                
'-moz-transform''rotate(' + ((-(360 self.totalSlices()) / 2) + self.getDegree()) + 'deg)',
                
'-ms-transform''rotate(' + ((-(360 self.totalSlices()) / 2) + self.getDegree()) + 'deg)',
                
'-o-transform''rotate(' + ((-(360 self.totalSlices()) / 2) + self.getDegree()) + 'deg)',
                
'transform''rotate(' + ((-(360 self.totalSlices()) / 2) + self.getDegree()) + 'deg)'
            
});
            
textHtml.appendTo(Layertext);
        } else {
            var 
textsGroup = $('<g class="sWheel-txt"/>'),
                
LayerDefs = $('<defs/>');
        }
        var 
Layercenter = $('<div/>');
        
Layercenter.addClass('sWheel-center');
        
Layercenter.addClass(self.o.center.class);
        
Layercenter.appendTo(self.o.center.rotate === true || self.o.center.rotate === || self.o.center.rotate === "true" spinner inner);
        if (
typeof self.o.center.image.url === 'string' && $.trim(self.o.center.image.url) !== '') {
            var 
centerImage = $('<img />');
            if (!
parseInt(self.o.center.image.width,10)) self.o.center.image.width parseInt(self.o.center.width,10);
            
centerImage.css('width'parseInt(self.o.center.image.width,10) + '%');
            
centerImage.attr('src'self.o.center.image.url);
            
centerImage.appendTo(Layercenter);
            
Layercenter.append('<div class="sw-center-empty" style="width:' parseInt(self.o.center.image.width,10) + '%; height:' parseInt(self.o.center.image.width,10) + '%" />');
        }
        if (
typeof self.o.center.html.template === 'string' && $.trim(self.o.center.html.template) !== '') {
            var 
centerHtml = $('<div class="sw-center-html">' self.o.center.html.template '</div>');
            if (!
parseInt(self.o.center.html.width,10)) self.o.center.html.width parseInt(self.o.center.width,10);
            
centerHtml.css({
                
'width'parseInt(self.o.center.html.width,10) + '%',
                
'height'parseInt(self.o.center.html.width,10) + '%'
            
});
            
centerHtml.appendTo(Layercenter);
        }
        if ($.
trim(self.o.type) !== 'color') {
            var 
Layermarker = $('<div/>').addClass('sWheel-marker').appendTo(wrapper);
            
Layermarker.append('<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 80 115" style="enable-background:new 0 0 80 115;" xml:space="preserve">' '<g>' '<path fill="' self.o.marker.background '" d="M40,0C17.9,0,0,17.7,0,39.4S40,115,40,115s40-53.9,40-75.6S62.1,0,40,0z M40,52.5c-7,0-12.6-5.6-12.6-12.4 S33,27.7,40,27.7s12.6,5.6,12.6,12.4C52.6,46.9,47,52.5,40,52.5z"/>' '<path fill="rgba(0, 0, 0, 0.3)" d="M40,19.2c-11.7,0-21.2,9.3-21.2,20.8S28.3,60.8,40,60.8S61.2,51.5,61.2,40S51.7,19.2,40,19.2z M40,52.5 c-7,0-12.6-5.6-12.6-12.4S33,27.7,40,27.7s12.6,5.6,12.6,12.4C52.6,46.9,47,52.5,40,52.5z"/>' '</g>' '</svg>');
        }
        var 
slicesGroup = $('<g/>'),
            
linesGroup = $('<g/>'),
            
corner 360/self.totalSlices(),
            
lineLength self.half,
            
cx self.half,
            
cy self.half,
            
cr 0;
        $.
each(self.slices, function(islice) {
            
/*#######################################################
            /////////////////////////////////////////////////////////
            //////////////////   Slice Drawer   /////////////////////
            /////////////////////////////////////////////////////////
            #######################################################*/
            
var rotate = (360 self.totalSlices()) * i;
            
pEnd += arcSize;
            var 
arc self.annularSector({
                
centerXself.half,
                
centerYself.half,
                
startDegreespStart,
                
endDegreespEnd,
                
innerRadiusparseInt(self.o.center.width10 ),
                
outerRadiusself.half - ( parseInt(self.o.outer.width10) > 1  )
            });
            
slicesGroup.append(self.SVG('path',{
                
'stroke-width'0,
                
'fill'slice.background,
                
'data-fill'slice.background,
                
'd'arc
            
}));
            var 
p1 self.findPoint(cxcycr lineLengthcorner i),
                
p2 self.findPoint(cxcycrcorner i);
            
linesGroup.append(self.SVG('line', {
                
'x1'p1.x,
                
'y1'p1.y,
                
'x2'p2.x,
                
'y2'p2.y,
                
'stroke'self.o.line.color,
                
'stroke-width'self.o.line.width,
                
'fill''none',
                
'clip-path''url(#cut-off-line)',
            }));
            
/*#######################################################
            /////////////////////////////////////////////////////////
            //////////////////   Slice Content   ////////////////////
            /////////////////////////////////////////////////////////
            #######################################################*/
            
if ( ( self.o.text.orientation === 'v' || self.o.text.orientation === 'vertical') ||
                ( (
self.o.text.type === 'icon' || self.o.text.type === 'image') && ( self.o.text.orientation === 'h' || self.o.text.orientation === 'horizontal' ) ) ){
                var 
LayerTitle = $('<div/>');
                if (
self.toNumber(self.o.text.letterSpacing) > 0textHtml.css('letter-spacing'self.toNumber(self.o.text.letterSpacing));
                
LayerTitle.css({
                    
paddingRightparseInt(self.o.text.offset,10) + '%',
                    
'-webkit-transform''rotate(' rotate 'deg) translate(0px, -50%)',
                    
'-moz-transform''rotate(' rotate 'deg) translate(0px, -50%)',
                    
'-ms-transform''rotate(' rotate 'deg) translate(0px, -50%)',
                    
'-o-transform''rotate(' rotate 'deg) translate(0px, -50%)',
                    
'transform''rotate(' rotate 'deg) translate(0px, -50%)',
                    
'color'slice.color
                
});
                if(
self.o.text.type === 'icon'){
                    
LayerTitle.html('<i class="'+slice.text+'" aria-hidden="true"></i>')
                    if( 
self.o.text.orientation === 'h' || self.o.text.orientation === 'horizontal' ){
                        
LayerTitle.find('>i').css({
                            
'-webkit-transform''rotate(90deg)',
                            
'-moz-transform''rotate(90deg)',
                            
'-ms-transform''rotate(90deg)',
                            
'-o-transform''rotate(90deg)',
                            
'transform''rotate(90deg)'
                        
});
                    }
                }else if(
self.o.text.type === 'image'){
                    
LayerTitle.html('<img src="'+slice.text+'"/>')
                    if( 
self.o.text.orientation === 'h' || self.o.text.orientation === 'horizontal' ){
                        
LayerTitle.find('>img').css({
                            
'-webkit-transform''rotate(90deg)',
                            
'-moz-transform''rotate(90deg)',
                            
'-ms-transform''rotate(90deg)',
                            
'-o-transform''rotate(90deg)',
                            
'transform''rotate(90deg)'
                        
});
                    }
                }else{
                    
LayerTitle.html(slice.text);
                }
                
LayerTitle.attr('data-color',slice.color);
                
LayerTitle.addClass('sWheel-title').appendTo(textHtml);
            } else {
                var 
LayerText = $('<text stroke-width="0" data-color="' slice.color '" fill="' slice.color '" dy="' + (self.toNumber(self.o.text.offset)) + '%">' '<textPath xlink:href="#sw-text-' '" startOffset="50%" style="text-anchor: middle;">' slice.text '</textPath>' '</text>');
                
LayerText.addClass('sWheel-title');
                
textsGroup.css('font-size'parseInt(self.o.text.size 2,10));
                if (
parseInt(self.o.text.letterSpacing,10) > 0textsGroup.css('letter-spacing'parseInt(self.o.text.letterSpacing 2,10));
                
textsGroup.append(LayerText);
                var 
firstArcSection = /(^.+?)L/;
                var 
newD firstArcSection.exec(arc)[1];
                if (
self.o.text.arc !== true && self.o.text.arc !== 'true' && self.o.text.arc !== ) {
                    var 
secArcSection = /(^.+?)A/;
                    var 
Commas = /(^.+?),/;
                    var 
newc secArcSection.exec(newD);
                    var 
replaceVal newD.replace(newc[0], "");
                    var 
getFirstANumber Commas.exec(replaceVal);
                    var 
nval replaceVal.replace(getFirstANumber[1], 0);
                    
newD newD.replace(replaceValnval);
                }
                
LayerDefs.append(self.SVG('path', {
                    
'stroke-width'0,
                    
'fill''none',
                    
'id''sw-text-' i,
                    
'd'newD
                
}));
            }
            var 
LayerTitleInner = $('<div/>');
            
LayerTitleInner.html(slice);
            
LayerTitleInner.appendTo(LayerTitle);
            
pStart += arcSize
        });
        
slicesGroup.addClass('sw-slicesGroup').appendTo(Layersvg);
        
linesGroup.appendTo(Layersvg);
        if (
self.o.text.orientation  !== 'v' && self.o.text.orientation !== 'vertical' && self.o.text.type === 'text' ){
            
LayerDefs.appendTo(Layersvg);
            
textsGroup.appendTo(Layersvg);
        }
        var 
outerLine self.SVG('circle', {
            
'class''outerLine',
            
'cx'self.half,
            
'cy'self.half,
            
'r'self.half - (parseInt(self.o.outer.width,10) / 2),
            
'stroke'self.o.outer.color,
            
'stroke-width'parseInt(self.o.outer.width,10),
            
'fill-opacity'0,
            
'fill''none'
        
});
        $(
outerLine).appendTo(Layersvg);
        var 
innerLine self.SVG('circle', {
            
'class''innerLine',
            
'cx'self.half,
            
'cy'self.half,
            
'r'parseInt(self.o.center.width10 ) + (parseInt(self.o.inner.width,10) ? parseInt(self.o.inner.width,10) / 0),
            
'stroke'self.o.inner.color,
            
'stroke-width'parseInt(self.o.inner.width,10),
            
'fill-opacity'self.o.center.background 0,
            
'fill'self.o.center.background self.o.center.background 'none'
        
});
        $(
innerLine).appendTo(Layersvg);
        
Layersvg.appendTo(Layerbg);
        
Layerbg.html(Layerbg.html());
        
self.$element.css('font-size'parseInt(self.o.text.size,10));
        
self.$element.width(parseInt(self.o.width,10));
        
self.$element.height(self.$element.width());
        
self.$element.find('.sWheel-wrapper').width(self.$element.width());
        
self.$element.find('.sWheel-wrapper').height(self.$element.width());
        
self.FontScale();
        $(
window).on('resize.' self.instanceUid, function() {
            
self.$element.height(self.$element.width());
            
self.$element.find('.sWheel-wrapper').width(self.$element.width());
            
self.$element.find('.sWheel-wrapper').height(self.$element.width());
            
self.FontScale();
        });
    };
    
/*#######################################################
    /////////////////////////////////////////////////////////
    ///////////////////   SVG OBJECTS   /////////////////////
    /////////////////////////////////////////////////////////
    #######################################################*/
    
SuperWheel.prototype.SVG = function(et) {
        var 
document.createElementNS("http://www.w3.org/2000/svg"e);
        for (var 
n in tr.setAttribute(nt[n]);
        return 
r
    
};
    
SuperWheel.prototype.annularSector = function(options) {
        var 
self this;
        var 
opts self.oWithDefaults(options);
        var 
= [ // points
            
opts.cx opts.r2 Math.cos(opts.startRadians), opts.cy opts.r2*Math.sin(opts.startRadians) ],
            [ 
opts.cx opts.r2 Math.cos(opts.closeRadians), opts.cy opts.r2*Math.sin(opts.closeRadians) ],
            [ 
opts.cx opts.r1 Math.cos(opts.closeRadians), opts.cy opts.r1*Math.sin(opts.closeRadians) ],
            [ 
opts.cx opts.r1 Math.cos(opts.startRadians), opts.cy opts.r1*Math.sin(opts.startRadians) ]
        ];
        var 
angleDiff opts.closeRadians opts.startRadians;
        var 
largeArc = ( angleDiff % ( Math.PI ) ) > Math.PI 0;
        var 
cmds = [];
        
cmds.push"M" p[0].join() );
        
cmds.push"A" + [ opts.r2opts.r20largeArc1p[1] ].join() );
        
cmds.push"L" p[2].join() );
        
cmds.push"A" + [ opts.r1opts.r10largeArc0p[3] ].join() );
        
cmds.push"z" );
        return 
cmds.join(' ');
    }    
    
SuperWheel.prototype.oWithDefaults = function(o) {
        var 
o2 = {
            
cx           o.centerX || 0,
            
cy           o.centerY || 0,
            
startRadians : (o.startDegrees || 0) * Math.PI/180,
            
closeRadians : (o.endDegrees   || 0) * Math.PI/180,
        };
        var 
o.thickness!==undefined o.thickness 100;
        if (
o.innerRadius!==undefined)      o2.r1 o.innerRadius;
        else if (
o.outerRadius!==undefinedo2.r1 o.outerRadius t;
        else                                
o2.r1 200           t;
        if (
o.outerRadius!==undefined)      o2.r2 o.outerRadius;
        else                                
o2.r2 o2.r1         t;
        if (
o2.r1<0o2.r1 0;
        if (
o2.r2<0o2.r2 0;
        return 
o2;
    }
    
SuperWheel.prototype.findPoint = function(cxcyradcornerGrad) {
          var 
cornerRad cornerGrad   Math.PI 180;
          var 
nx        Math.cos(cornerRad) * rad cx;
          var 
ny        Math.sin(cornerRad) * rad cy;
          return { 
xnxyny };
    }
    
/*#######################################################
    /////////////////////////////////////////////////////////
    ////////////////////   Wheel Core   /////////////////////
    /////////////////////////////////////////////////////////
    #######################################################*/
    
SuperWheel.prototype.start = function(key,val) {
        var 
self this;
        if (
self.spinning) return;
        if(
typeof val === 'undefined'){
            
val key;
            
key self.o.selector;
        }
        
self.o.selector key;
        if (
typeof val !== 'undefined') {
            
self.winner self.findWinner(val,false);
            if(
self.winner !== false){
                
self.slice.id self.winner;
            }else{
                return;
            }
        } else {
            return;
        }
        
self.spinning true;
        if (
typeof self.slices[self.slice.id] === 'undefined') return;
        
self.slice.results self.slices[self.slice.id];
        
self.slice.length self.slice.id;
        if(
typeof self.cache['onStart'] !== 'undefined'){
            $.
each(self.cache['onStart'], function(icallback) {
                    if(
typeof callback === 'function')
                        
callback.call(self.$wheelself.slice.resultsself.spinCountself.now);
            });
        }
        var 
selectedSlicePos self.calcSliceSize(self.slice.id);
        var 
randomize self.randomInt(selectedSlicePos.startselectedSlicePos.end);
        var 
_deg = (360 parseInt(self.rotates,10)) + randomize;
        var 
temp self.numberToArray(self.totalSlices()).reverse();
        var 
MarkerAnimator false;
        if (
parseInt(self.o.frame,10) !== 0) {
            var 
oldinterval = $.fx.interval;
            $.
fx.interval parseInt(self.o.frame,10);
        }
        
self.spinner = $({
            
degself.now
        
}).animate({
            
deg_deg
        
}, {
            
durationparseInt(self.o.duration,10),
            
easing: $.trim(self.o.easing),
            
step: function(nowfx) {
                if (
parseInt(self.o.frame,10) !== 0) $.fx.interval parseInt(self.o.frame,10);
                
self.now now 360;
                if ($.
trim(self.o.type) !== 'color') {
                    
self.$element.find('.sWheel').css({
                        
'-webkit-transform''rotate(' self.now 'deg)',
                           
'-moz-transform''rotate(' self.now 'deg)',
                            
'-ms-transform''rotate(' self.now 'deg)',
                             
'-o-transform''rotate(' self.now 'deg)',
                                
'transform''rotate(' self.now 'deg)'
                    
});
                }
                
self.currentStep Math.floor(now / (360 self.totalSlices()));
                
self.currentSlice temp[self.currentStep self.totalSlices()];
                var 
ewCircleSize 400 4,
                    
ewTotalArcs self.totalSlices(),
                    
ewArcSizeDeg 360 ewTotalArcs,
                    
ewArcSize ewCircleSize ewTotalArcs,
                    
point ewCircleSize 360,
                    
ewCirclePos = (point self.now),
                    
ewCirclePosPercent = (ewCirclePos ewCircleSize) * 100,
                    
ewArcPos = (((self.currentSlice 1) * ewArcSize) - (ewCircleSize - (point self.now))),
                    
ewArcPosPercent = (ewArcPos ewArcSize) * 100,
                    
cpercent ewCirclePosPercent,
                    
apercent ewArcPosPercent;
                
self.slicePercent ewArcPosPercent;
                
self.circlePercent ewCirclePosPercent;
                if(
typeof self.cache['onProgress'] !== 'undefined'){
                    $.
each(self.cache['onProgress'], function(icallback) {
                            if(
typeof callback === 'function')
                                
callback.call(self.$elementself.slicePercentself.circlePercent);
                    });
                }
                if (
self.lastStep !== self.currentStep) {
                    
self.lastStep self.currentStep;
                    if ((
self.o.marker.animate === true || self.o.marker.animate === || self.o.marker.animate === 'true' ) && $.inArray($.trim(self.o.easing), ['easeInElastic''easeInBack''easeInBounce''easeOutElastic''easeOutBack''easeOutBounce''easeInOutElastic''easeInOutBack''easeInOutBounce']) === -1) {
                        var 
Mduration parseFloat(self.o.duration) /  ( ( ( self.totalSlices()  ) * self.o.rotates + (self.totalSlices() - self.winner)) - self.currentStep ) / self.o.rotates;
                        var 
BDeg = (self.totalSlices() * self.o.rotates self.currentStep);
                        if (
MarkerAnimatorMarkerAnimator.stop();
                        var 
markerNow 0;
                        
MarkerAnimator = $({
                            
deg: (BDeg 40 ? -40 : -BDeg > -10 : -BDeg
                        }).
animate({
                            
deg: -50
                        
}, {
                            
easing"linear",
                            
duration: (Mduration 4),
                            
step: function(now) {
                                
markerNow now;
                                $(
".sWheel-marker").css({
                                    
'-webkit-transform''rotate(' now 'deg)',
                                    
'-moz-transform''rotate(' now 'deg)',
                                    
'-ms-transform''rotate(' now 'deg)',
                                    
'-o-transform''rotate(' now 'deg)',
                                    
'transform''rotate(' now 'deg)'
                                
});
                            },
                            
complete: function(animationprogressremainingMs) {
                                
MarkerAnimator = $({
                                    
degmarkerNow
                                
}).animate({
                                    
deg0
                                
}, {
                                    
easing"linear",
                                    
duration100,
                                    
step: function(now) {
                                        $(
".sWheel-marker").css({
                                            
'-webkit-transform''rotate(' now 'deg)',
                                            
'-moz-transform''rotate(' now 'deg)',
                                            
'-ms-transform''rotate(' now 'deg)',
                                            
'-o-transform''rotate(' now 'deg)',
                                            
'transform''rotate(' now 'deg)'
                                        
});
                                    }
                                });
                            },
                        });
                    }
                    if ($.
trim(self.o.type) === 'color') {
                        
self.$element.find('svg>g.sw-slicesGroup>path').each(function(i) {
                            $(
this).attr('class','').attr('fill', $(this).attr('data-fill'));
                        });
                        
self.$element.find('.sWheel-txt>.sWheel-title').each(function(i) {
                            $(
this).attr('class','sWheel-title');
                            if (
self.o.text.orientation === 'v' || self.o.text.orientation === 'vertical') $(this).css('color', $(this).attr('data-color'));
                            else $(
this).attr('fill', $(this).attr('data-color'));
                        });
                        
self.$element.find('svg>g.sw-slicesGroup>path').eq(self.currentSlice).addClass('sw-ccurrent').attr('fill'self.o.slice.selected.background);
                        if (
self.o.text.orientation === 'v' || self.o.text.orientation === 'vertical')
                            
self.$element.find('.sWheel-txt>.sWheel-title').eq(self.currentSlice).addClass('sw-ccurrent').css('color'self.o.slice.selected.color);
                        else 
self.$element.find('.sWheel-txt>.sWheel-title').eq(self.currentSlice).addClass('sw-ccurrent').attr('fill'self.o.slice.selected.color);
                    } else {
                        
self.$element.find('svg>g.sw-slicesGroup>path').removeClass('sw-current');
                        
self.$element.find('svg>g.sw-slicesGroup>path').eq(self.currentSlice).addClass('sw-current');
                        
self.$element.find('.sWheel-txt>.sWheel-title').eq(self.currentSlice).addClass('sw-current');
                    }
                    
self.currentSliceData = {};
                    
self.currentSliceData.id self.currentSlice;
                    
self.currentSliceData.results self.slices[self.currentSliceData.id];
                    
self.currentSliceData.results.length self.currentSliceData.id;
                    if(
typeof self.cache['onStep'] !== 'undefined'){
                        $.
each(self.cache['onStep'], function(icallback) {
                                if(
typeof callback === 'function')
                                    
callback.call(self.$elementself.currentSliceData.resultsself.slicePercentself.circlePercent);
                        });
                    }
                }
                if (
parseInt(self.o.frame,10) !== 0) $.fx.interval oldinterval;
            },
            
fail: function(animationprogressremainingMs) {
                
self.spinning false;
                if(
typeof self.cache['onFail'] !== 'undefined'){
                    $.
each(self.cache['onFail'], function(icallback) {
                            if(
typeof callback === 'function')
                                
callback.call(self.$elementself.slice.resultsself.spinCountself.now);
                    });
                }
            },
            
complete: function(animationprogressremainingMs) {
                
self.spinning false;
                if(
typeof self.cache['onComplete'] !== 'undefined'){
                    $.
each(self.cache['onComplete'], function(icallback) {
                            if(
typeof callback === 'function')
                                
callback.call(self.$elementself.slice.resultsself.spinCountself.now);
                    });
                }
            },
        });
        
self.counter++;
        
self.spinCount++;
    }
    
/*#######################################################
    /////////////////////////////////////////////////////////
    ///////////////////   Core Helpers   ////////////////////
    /////////////////////////////////////////////////////////
    #######################################################*/
    
SuperWheel.prototype.totalSlices = function() {
        var 
self this;
        return 
self.slices.length;
    };
    
SuperWheel.prototype.calcSliceSize = function(slice) {
        var 
self this;
        var 
start self.degStart((slice)) - (parseInt(self.o.line.width,10) + 2);
        var 
end self.degEnd(slice) + (parseInt(self.o.line.width,10) + 2);
        var 
results = [];
        
results.start start;
        
results.end end;
        return 
results;
    };
    
SuperWheel.prototype.findWinner = function(value,type) {
        var 
self this;
        var 
filter = [];
        $.
each(self.slices, function(islice) {
            if(
typeof slice[self.o.selector] === 'object' || typeof slice[self.o.selector] === 'array' || typeof slice[self.o.selector] === 'undefined')
                return 
undefined;
            if( 
slice[self.o.selector] === value){
                
filter.push(i);
            }
        });
        var 
keys Object.keys(filter);
        var 
selectedKey =  filter[keyskeys.length Math.random() << 0]];
        return 
selectedKey;
    };
    
SuperWheel.prototype.getDegree = function(id) {
        var 
self this;
        return (
360 self.totalSlices());
    }
    
SuperWheel.prototype.degStart = function(id) {
        var 
self this;
        return 
360 - (self.getDegree() * id);
    };
    
SuperWheel.prototype.degEnd = function(id) {
        var 
self this;
        return 
360 - ((self.getDegree() * id) + self.getDegree());
    };
    
/*#######################################################
    /////////////////////////////////////////////////////////
    /////////////////////   Helpers   ///////////////////////
    /////////////////////////////////////////////////////////
    #######################################################*/
    
SuperWheel.prototype.toNumber = function(e) {
        return 
NaN === Number(e) ? Number(e)
    };
    
SuperWheel.prototype.numberToArray = function(N) {
        var 
args = [];
        var 
i;
        for (
0Ni++) {
            
args[i] = i;
        }
        return 
args;
    };
    
SuperWheel.prototype.brightness = function(c) {
        var 
rgbbrightness;
        if (
c.match(/^rgb/)) {
            
c.match(/rgba?(([^)]+))/)[1];
            
c.split(/ *, */).map(Number);
            
c[0];
            
c[1];
            
c[2];
        } else if (
'#' == c[0] && == c.length) {
            
parseInt(c.slice(13), 16);
            
parseInt(c.slice(35), 16);
            
parseInt(c.slice(57), 16);
        } else if (
'#' == c[0] && == c.length) {
            
parseInt(c[1] + c[1], 16);
            
parseInt(c[2] + c[2], 16);
            
parseInt(c[3] + c[3], 16);
        }
        
brightness = (299 587 114) / 1000;
        if (
brightness 125) {
            return 
'#fff';
        } else {
            return 
'#333';
        }
    }
    
SuperWheel.prototype.randomInt = function(minmax) {
        return 
Math.floor(Math.random() * (max min 1) + min);
    };
    
SuperWheel.prototype.randomColor = function(h){
        var 
PHI 0.618033988749895
        var 
svhue;
        if(
h===undefined){
            
hue = (Math.floor(Math.random()*(360 1)+0))/360;
            
= ( hue + ( hue PHI )) % 360
        } 
        else 
h/=360;                                           
        
Math.floor(Math.random() * (100 20 1) + 20);
        
= (v-10)/100;
        
v/100;
        var 
rgbifpqt;
        
Math.floor(6);
        
i;
        
* (s);
        
* (s);
        
* (- (f) * s);
        switch (
6) {
            case 
0vtp; break;
            case 
1qvp; break;
            case 
2pvt; break;
            case 
3pqv; break;
            case 
4tpv; break;
            case 
5vpq; break;
        }
            
Math.round(255);
            
Math.round(255);
            
Math.round(255);
        var 
finalColor "#" + ((<< 24) + (<< 16) + (<< 8) + b).toString(16).slice(1);
        return 
finalColor;
    }
    
SuperWheel.prototype.FontScale = function(slice) {
        var 
self this;
        var 
Fscale * (self.$element.width() - parseInt(self.o.width,10)) / parseInt(self.o.width,10);
        if (
Fscale 4) {
            
Fscale 4;
        } else if (
Fscale 0.1) {
            
Fscale 0.1;
        }
        
self.$element.find(".sWheel-wrapper").css('font-size'Fscale 100 '%');
    };
    
SuperWheel.prototype.guid = function(r) {
        var 
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
            
"";
        
|| (8);
        for (var 
0ro++) += t.charAt(Math.floor(Math.random() * t.length));
        return 
a
    
};
    
/*#######################################################
    /////////////////////////////////////////////////////////
    ///////////////////    Callback's   /////////////////////
    /////////////////////////////////////////////////////////
    #######################################################*/
    
SuperWheel.prototype.onStart = function(callback) {
        var 
self this;
        if(
typeof self.cache['onStart'] === 'undefined')
            
self.cache['onStart'] = [];
        
self.cache['onStart'][self.cache['onStart'].length] = callback;
    };
    
SuperWheel.prototype.onStep = function(callback) {
        var 
self this;
        if(
typeof self.cache['onStep'] === 'undefined')
            
self.cache['onStep'] = [];
        
self.cache['onStep'][self.cache['onStep'].length] = callback;
    };
    
SuperWheel.prototype.onProgress = function(callback) {
        var 
self this;
        if(
typeof self.cache['onProgress'] === 'undefined')
            
self.cache['onProgress'] = [];
        
self.cache['onProgress'][self.cache['onProgress'].length] = callback;
    };
    
SuperWheel.prototype.onFail = function(callback) {
        var 
self this;
        if(
typeof self.cache['onFail'] === 'undefined')
            
self.cache['onFail'] = [];
        
self.cache['onFail'][self.cache['onFail'].length] = callback;
    };
    
SuperWheel.prototype.onComplete = function(callback) {
        var 
self this;
        if(
typeof self.cache['onComplete'] === 'undefined')
            
self.cache['onComplete'] = [];
        
self.cache['onComplete'][self.cache['onComplete'].length] = callback;
    };
    
SuperWheel.prototype.onFail = function(callback) {
        var 
self this;
        if(
typeof self.cache['onFail'] === 'undefined')
            
self.cache['onFail'] = [];
        
self.cache['onFail'][self.cache['onFail'].length] = callback;
    };
    
/*#######################################################
    /////////////////////////////////////////////////////////
    //////////////////   jQuery Plugin   ////////////////////
    /////////////////////////////////////////////////////////
    #######################################################*/
    
$.fn.superWheel = function() {
        var 
self this,
            
opt arguments[0],
            
args = Array.prototype.slice.call(arguments1),
            
arg2 = Array.prototype.slice.call(arguments2),
            
self.length,
            
i,
            
apply,
            
allowed = ['destroy''start''finish''option''onStart''onStep''onProgress''onComplete''onFail'];
        for ( 
0li++  ) {
            if (
typeof opt == 'object' || typeof opt == 'undefined') {
                
self[i].superWheel = new SuperWheel(self[i], opt);
            } else if ($.
inArray($.trim(opt), allowed) !== -1) {
                if ($.
trim(opt) === 'option') {
                    
apply self[i].superWheel[opt].apply(self[i].superWheelargsarg2);
                } else {
                    
apply self[i].superWheel[opt].apply(self[i].superWheelargs);
                }
            }
            if (
typeof apply != 'undefined') return apply;
        }
        return 
self;
    };
}));
?>
Онлайн: 0
Реклама