1/** 2 * @module jquery-circle-progress 3 * @author Rostyslav Bryzgunov <[email protected]> 4 * @see http://kottenator.github.io/jquery-circle-progress/ 5 * @licence MIT 6 * @version 1.2.2 7 */ 8!function(i){if("function"==typeof define&&define.amd)define(["jquery"],i);else if("object"==typeof module&&module.exports){var t=require("jquery");i(t),module.exports=t}else i(jQuery)}(function(i){function t(i){this.init(i)}t.prototype={value:0,size:100,startAngle:-Math.PI,thickness:"auto",fill:{gradient:["#3aeabb","#fdd250"]},emptyFill:"rgba(0, 0, 0, .1)",animation:{duration:1200,easing:"circleProgressEasing"},animationStartValue:0,reverse:!1,lineCap:"butt",insertMode:"prepend",constructor:t,el:null,canvas:null,ctx:null,radius:0,arcFill:null,lastFrameValue:0,init:function(t){i.extend(this,t),this.radius=this.size/2,this.initWidget(),this.initFill(),this.draw(),this.el.trigger("circle-inited")},initWidget:function(){this.canvas||(this.canvas=i("<canvas>")["prepend"==this.insertMode?"prependTo":"appendTo"](this.el)[0]);var t=this.canvas;if(t.width=this.size,t.height=this.size,this.ctx=t.getContext("2d"),window.devicePixelRatio>1){var e=window.devicePixelRatio;t.style.width=t.style.height=this.size+"px",t.width=t.height=this.size*e,this.ctx.scale(e,e)}},initFill:function(){function t(){var t=i("<canvas>")[0];t.width=e.size,t.height=e.size,t.getContext("2d").drawImage(g,0,0,r,r),e.arcFill=e.ctx.createPattern(t,"no-repeat"),e.drawFrame(e.lastFrameValue)}var e=this,a=this.fill,n=this.ctx,r=this.size;if(!a)throw Error("The fill is not specified!");if("string"==typeof a&&(a={color:a}),a.color&&(this.arcFill=a.color),a.gradient){var s=a.gradient;if(1==s.length)this.arcFill=s[0];else if(s.length>1){for(var l=a.gradientAngle||0,o=a.gradientDirection||[r/2*(1-Math.cos(l)),r/2*(1+Math.sin(l)),r/2*(1+Math.cos(l)),r/2*(1-Math.sin(l))],h=n.createLinearGradient.apply(n,o),c=0;c<s.length;c++){var d=s[c],u=c/(s.length-1);i.isArray(d)&&(u=d[1],d=d[0]),h.addColorStop(u,d)}this.arcFill=h}}if(a.image){var g;a.image instanceof Image?g=a.image:(g=new Image,g.src=a.image),g.complete?t():g.onload=t}},draw:function(){this.animation?this.drawAnimated(this.value):this.drawFrame(this.value)},drawFrame:function(i){this.lastFrameValue=i,this.ctx.clearRect(0,0,this.size,this.size),this.drawEmptyArc(i),this.drawArc(i)},drawArc:function(i){if(0!==i){var t=this.ctx,e=this.radius,a=this.getThickness(),n=this.startAngle;t.save(),t.beginPath(),this.reverse?t.arc(e,e,e-a/2,n-2*Math.PI*i,n):t.arc(e,e,e-a/2,n,n+2*Math.PI*i),t.lineWidth=a,t.lineCap=this.lineCap,t.strokeStyle=this.arcFill,t.stroke(),t.restore()}},drawEmptyArc:function(i){var t=this.ctx,e=this.radius,a=this.getThickness(),n=this.startAngle;i<1&&(t.save(),t.beginPath(),i<=0?t.arc(e,e,e-a/2,0,2*Math.PI):this.reverse?t.arc(e,e,e-a/2,n,n-2*Math.PI*i):t.arc(e,e,e-a/2,n+2*Math.PI*i,n),t.lineWidth=a,t.strokeStyle=this.emptyFill,t.stroke(),t.restore())},drawAnimated:function(t){var e=this,a=this.el,n=i(this.canvas);n.stop(!0,!1),a.trigger("circle-animation-start"),n.css({animationProgress:0}).animate({animationProgress:1},i.extend({},this.animation,{step:function(i){var n=e.animationStartValue*(1-i)+t*i;e.drawFrame(n),a.trigger("circle-animation-progress",[i,n])}})).promise().always(function(){a.trigger("circle-animation-end")})},getThickness:function(){return i.isNumeric(this.thickness)?this.thickness:this.size/14},getValue:function(){return this.value},setValue:function(i){this.animation&&(this.animationStartValue=this.lastFrameValue),this.value=i,this.draw()}},i.circleProgress={defaults:t.prototype},i.easing.circleProgressEasing=function(i){return i<.5?(i=2*i,.5*i*i*i):(i=2-2*i,1-.5*i*i*i)},i.fn.circleProgress=function(e,a){var n="circle-progress",r=this.data(n);if("widget"==e){if(!r)throw Error('Calling "widget" method on not initialized instance is forbidden');return r.canvas}if("value"==e){if(!r)throw Error('Calling "value" method on not initialized instance is forbidden');if("undefined"==typeof a)return r.getValue();var s=arguments[1];return this.each(function(){i(this).data(n).setValue(s)})}return this.each(function(){var a=i(this),r=a.data(n),s=i.isPlainObject(e)?e:{};if(r)r.init(s);else{var l=i.extend({},a.data());"string"==typeof l.fill&&(l.fill=JSON.parse(l.fill)),"string"==typeof l.animation&&(l.animation=JSON.parse(l.animation)),s=i.extend(l,s),s.el=a,r=new t(s),a.data(n,r)}})}}); 9 10 11/** 12 * JS trida pro Menu 13 * @author Martin Stránský SG <[email protected]> 14 */ 15var Surveys = { 16 17 $progressLinear : $(".progress-linear"), 18 $progressCircle : $(".progress-bar-circle"), 19 isNoviBuilder : false, 20 idVote : 0, 21 22 23 /** 24 * Inicializace class 25 * @param {string} path - cesta k presenteru 26 */ 27 init: function(path) { 28 this.presenter = window.location.origin + path +'/module-surveys/'; 29 }, 30 31 32 /** 33 * Load ankety cary 34 */ 35 LoadProgressLinear : function() { 36 Surveys.$progressLinear.each(function() { 37 let bar = $(this); 38 let initProgress = function() { 39 var 40 bar = $(this), 41 end = parseInt($(this).find('.progress-value').text(), 10); 42 43 if ( !bar.hasClass( "animated-first" ) && Surveys.isScrolledIntoView( bar ) ) { 44 bar.find('.progress-bar-linear').css({width: end + '%'}); 45 bar.find('.progress-value').countTo({ 46 refreshInterval: 40, 47 from: 0, 48 to: end, 49 speed: 1000 50 }); 51 bar.addClass('animated-first'); 52 } 53 }; 54 $.proxy( initProgress, bar )(); 55 $(window).on( "scroll", $.proxy( initProgress, bar ) ); 56 57 }); 58 }, 59 60 61 /** 62 * Load ankety kola 63 */ 64 LoadProgressCircle : function() { 65 Surveys.$progressCircle.each(function() { 66 let circle = $(this); 67 circle.circleProgress({ 68 value: circle.attr('data-value'), 69 size: circle.attr('data-size') ? circle.attr('data-size') : 175, 70 fill: { 71 gradient: circle.attr('data-gradient').split(","), 72 gradientAngle: Math.PI / 4 73 }, 74 startAngle: -Math.PI / 4 * 2, 75 emptyFill: circle.attr('data-empty-fill') ? circle.attr('data-empty-fill') : "rgb(245,245,245)" 76 }).on('circle-animation-progress', function (event, progress, stepValue) { 77 if (stepValue < .1) { 78 $(this).find('span').text( String(stepValue.toFixed(1)).replace('0.', '').replace('1.', '1') ); 79 } else { 80 $(this).find('span').text( String(stepValue.toFixed(2)).replace('0.', '').replace('1.', '1') ); 81 } 82 }); 83 84 if ( Surveys.isScrolledIntoView( circle ) ) circle.addClass('animated-first'); 85 86 $(window).on( 'scroll', $.proxy( function() { 87 var circle = $(this); 88 if ( !circle.hasClass( "animated-first" ) && Surveys.isScrolledIntoView( circle ) ) { 89 circle.circleProgress( 'redraw' ); 90 circle.addClass( 'animated-first' ); 91 } 92 }, circle ) ); 93 }); 94 }, 95 96 /**
97 * @desc Check the element whas been scrolled into the view 98 * @param {object} elem - jQuery object 99 * @return {boolean} 100 */ 101 isScrolledIntoView : function(elem) { 102 if (!Surveys.isNoviBuilder) { 103 return elem.offset().top + elem.outerHeight() >= $(window).scrollTop() && elem.offset().top <= $(window).scrollTop() + $(window).height(); 104 } 105 else { 106 return true; 107 } 108 }, 109 110 111 /** 112 * Prida hlas 113 * @param {int} id_vote 114 */ 115 addVote : function(id_vote) { 116 var form_data = new FormData(); 117 form_data.append('id_vote', id_vote); 118 $.ajax({ 119 type: "POST", 120 url: Surveys.presenter + 'add-vote', 121 data: form_data, 122 contentType: false, 123 processData: false, 124 dataType: "json", 125 success: function (data) { 126 if (data.state == 'vote_add') { 127 $.fancybox.close(); 128 flashMessage(data.message, "success"); 129 } else if (data.state == 'login') { 130 Surveys.idVote = id_vote; 131 $.ajax({ 132 type: "GET", 133 url: Surveys.presenter + 'login-modal/', 134 dataType: "json", 135 success: function(data) { 136 $(".modal").find(".modal-header label").html("Pro hlasovánà zadejte Váš e-mail"); 137 $(".modal").find(".modal-body").html(data.html); 138 $(".modal-dialog").css('width','300px'); 139 $.fancybox($(".modal").html()); 140 $(".modal").find(".modal-body").html(''); 141 } 142 }); 143 144 } else { 145 flashMessage(data.message, "warning"); 146 } 147 } 148 }); 149 }, 150 151 152 /** 153 * Prida hlas uzivatele 154 * @param $form 155 */ 156 addVoteWithUser : function($form) { 157 var form_data = new FormData(document.querySelector('form.SurveyForm')); 158 form_data.append('id_vote', Surveys.idVote); 159 $.ajax({ 160 type: "POST", 161 url: Surveys.presenter + 'add-vote-with-user', 162 data: form_data, 163 contentType: false, 164 processData: false, 165 dataType: "json", 166 success: function (data) { 167 $.fancybox.close(); 168 if (data.state == 'add_vote') { 169 flashMessage(data.message, "success"); 170 } else if (data.state == 'vote_exist') { 171 flashMessage(data.message, "warning"); 172 } else { 173 flashMessage(data.message, "warning"); 174 } 175 } 176 }); 177 }, 178 179 180 /** 181 * Nacte anketu do grafu 182 * @param {int} id_survey 183 */ 184 loadModal : function(id_survey) { 185 $.ajax({ 186 type: "GET", 187 url: Surveys.presenter + 'load-modal/'+id_survey, 188 dataType: "json", 189 success: function(data) { 190 $(".modal").find(".modal-header label").html("Anketa"); 191 $(".modal").find(".modal-body").html(data.html); 192 $(".modal-dialog").css('width','600px'); 193 $.fancybox($(".modal").html()); 194 $(".modal").find(".modal-body").html(''); 195 Surveys.LoadProgressLinear(); 196 setTimeout(function () { 197 Surveys.LoadProgressCircle(); 198 }, 1000); 199 } 200 }); 201 } 202 203}; 204 205 206/** 207 * Volani funkci 208 * @returns {undefined} 209 */ 210$(function(){ 211 212 /** 213 * Init jClass 214 */ 215 Surveys.init($('body').attr('data-path')); 216 217 218 if (Surveys.$progressLinear.length) { 219 Surveys.LoadProgressLinear(); 220 } 221 if (Surveys.$progressCircle.length) { 222 Surveys.LoadProgressCircle(); 223 } 224 225 $('body').on('click', '.is_voteable .progress-item', function(event) { 226 event.preventDefault(); 227 Surveys.addVote($(this).attr('data-id')); 228 }); 229 230 // z modalu 231 $("body").on("click", ".SurveyForm input[type=submit]", function(event) { 232 event.preventDefault(); 233 Surveys.addVoteWithUser($(this).closest('form')); 234 }); 235 236 $("body").on("click", ".SurveyLoadModal", function() { 237 Surveys.loadModal($(this).attr('data-id')); 238 }); 239});
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.