{"version":3,"file":"anim_progress_bar_fresh.min.js","sources":["../src/anim_progress_bar_fresh.js"],"sourcesContent":["/* jshint ignore:start */\r\ndefine(['jquery', 'core/log'], function ($, log) {\r\n\r\n    \"use strict\"; // jshint ;_;\r\n\r\n    log.debug('Bar Progress: initialising');\r\n\r\n    return {\r\n\r\n        waveroot: null,\r\n\r\n        playcanvas: null,\r\n        context: null,\r\n        startx: null,\r\n        starty: null,\r\n        barwidth: null,\r\n        barheight: null,\r\n        enabled: false,\r\n        drawparams: {\r\n            barColor: \"#6DDC6F\",\r\n            textColor: '#fff',\r\n            font: '12px Arial',\r\n            textAlign: \"center\"\r\n        },\r\n\r\n        //for making multiple instances\r\n        clone: function () {\r\n            return $.extend(true, {}, this);\r\n        },\r\n\r\n        //pass in config, the jquery video/audio object, and a function to be called when conversion has finshed\r\n        init: function (playcanvas) {\r\n            //stash the key actors for calling from draw\r\n            this.playcanvas = playcanvas.get(0);\r\n            this.startx = 0;\r\n            this.starty = 0;\r\n            this.barwidth = this.playcanvas.width;\r\n            this.barheight = this.playcanvas.height;\r\n            this.context = this.playcanvas.getContext('2d');\r\n        },\r\n        test: function (analyser) {\r\n            var testAnalyser = analyser;\r\n            var bufferLength = testAnalyser.core.fftSize;\r\n            var dataArray = new Uint8Array(bufferLength);\r\n            console.log(testAnalyser);\r\n        },\r\n\r\n        readyBars: function () {\r\n\r\n            var $waveRoot = $('.poodll_fresh_wave');\r\n            var $waveProgress = $('<div class=\"poodll_fresh_progress_bar\"><span></span></div>');\r\n            var stickCount = $waveRoot.width() / 4;\r\n            stickCount.toFixed();\r\n            $waveRoot.empty();\r\n\r\n            for (var i = 0; i < stickCount; i++) {\r\n                var pointHeight = 8;\r\n                var point = $(\r\n                    '<div class=\"poodll_fresh_point\">' +\r\n                    '<div class=\"poodll_fresh_stick\" style=\"height: ' + pointHeight + 'px\"></div>' +\r\n                    '</div>'\r\n                )\r\n                $waveRoot.append(point);\r\n            }\r\n            $waveRoot.append($waveProgress);\r\n\r\n        },\r\n\r\n        playBars: function (currentTime, duration) {\r\n            var that = this;\r\n            var $waveRoot = $('.poodll_fresh_wave');\r\n            var $waveProgress = $('.poodll_fresh_progress_bar');\r\n            var stickCount = $waveRoot.width() / 4;\r\n\r\n            $waveRoot\r\n                .attr('data-ct', currentTime)\r\n                .attr('data-duration', duration);\r\n            stickCount.toFixed();\r\n\r\n            var pointsCollection = $('.poodll_fresh_point');\r\n            $.each(pointsCollection,function(thepoint){\r\n                if (pointsCollection[thepoint].children[0]) {\r\n                    pointsCollection[thepoint].children[0].style.height = '4px';\r\n                }\r\n            });\r\n\r\n            var draw = function () {\r\n                var waveData = [];\r\n                $.each(pointsCollection,function(thepoint){\r\n                    var sampleData = Math.floor(Math.random() * 50 + 4);\r\n                    waveData.push(sampleData);\r\n                    var pointHeight = waveData[i] || 4;\r\n\r\n                    // if (i < that.fetchCurrent() * stickCount ) {\r\n                    pointsCollection[thepoint].children[0].style.height = pointHeight + 'px';\r\n                });\r\n\r\n\r\n                $waveProgress.css('left', that.fetchCurrent() * 100 + '%');\r\n                var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||\r\n                    window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;\r\n\r\n                if (that.fetchCurrent() < 1) {\r\n                    console.log(that.fetchCurrent());\r\n                    requestAnimationFrame(draw);\r\n                }\r\n            }//end of draw\r\n            draw();\r\n        },\r\n\r\n        pauseBars: function () {\r\n\r\n        },\r\n\r\n        setDrawParam: function (paramkey, paramvalue) {\r\n            this.drawparams[paramkey] = paramvalue;\r\n        },\r\n\r\n        clear: function () {\r\n            this.context.clearRect(this.startx, this.starty, this.barwidth, this.barheight);\r\n        },\r\n        //this function to be overridden by calling class\r\n        //0= 0% 1=100%\r\n        fetchCurrent: function () {\r\n            return 0;\r\n        },\r\n\r\n        //stop and clear\r\n        stop: function () {\r\n            this.enabled = false;\r\n            this.clear();\r\n        },\r\n        //stop without clearing\r\n        stopthere: function () {\r\n            this.enabled = false;\r\n        },\r\n\r\n        start: function () {\r\n            this.clear();\r\n            this.enabled = true;\r\n            var that = this;\r\n            //set draw params, later could make this configurable\r\n            this.context.textAlign = this.drawparams.textAlign;\r\n            this.context.font = this.drawparams.font;\r\n            var textcolor = this.drawparams.textColor;\r\n\r\n\r\n            var draw = function () {\r\n\r\n                if (!that.enabled) {\r\n                    return;\r\n                }\r\n                that.clear();\r\n                that.context.fillStyle = that.drawparams.barColor;\r\n                that.context.fillRect(that.startx, that.starty, that.fetchCurrent() * that.barwidth, that.barheight);\r\n\r\n                //draw text\r\n                //this distorts unless we set the height and width of the canvas as canvas attributes, and NOT with CSS\r\n                //that didn't really fit with this, so we use text in the page (ie not canvas)\r\n                /*\r\n                that.context.fillStyle = textcolor;\r\n                that.context.fillText(parseInt(that.fetchCurrent() * 100) +'%',that.barwidth/2, that.barheight/2);\r\n                */\r\n                var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||\r\n                    window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;\r\n                requestAnimationFrame(draw);\r\n\r\n            }//end of draw\r\n            draw();\r\n        }//end of enable\r\n    };//end of returned object\r\n});//total end\r\n"],"names":["define","$","log","debug","waveroot","playcanvas","context","startx","starty","barwidth","barheight","enabled","drawparams","barColor","textColor","font","textAlign","clone","extend","this","init","get","width","height","getContext","test","analyser","testAnalyser","bufferLength","core","fftSize","Uint8Array","console","readyBars","$waveRoot","$waveProgress","stickCount","toFixed","empty","i","point","append","playBars","currentTime","duration","that","attr","pointsCollection","each","thepoint","children","style","draw","waveData","sampleData","Math","floor","random","push","pointHeight","css","fetchCurrent","requestAnimationFrame","window","mozRequestAnimationFrame","webkitRequestAnimationFrame","msRequestAnimationFrame","pauseBars","setDrawParam","paramkey","paramvalue","clear","clearRect","stop","stopthere","start","fillStyle","fillRect"],"mappings":"AACAA,+CAAO,CAAC,SAAU,aAAa,SAAUC,EAAGC,YAIxCA,IAAIC,MAAM,8BAEH,CAEHC,SAAU,KAEVC,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