// DOM.event.move 2.0.0 Stephen Band !function(e){"function"==typeof define&&define.amd?define([],e):"undefined"!=typeof module&&null!==module&&module.exports?module.exports=e:e()}(function(){var e=Object.assign||window.jQuery&&jQuery.extend,t=8,n=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e,t){return window.setTimeout(function(){e()},25)};!function(){if("function"==typeof window.CustomEvent)return!1;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}();var o={textarea:!0,input:!0,select:!0,button:!0},i={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},a={move:"touchmove",cancel:"touchend",end:"touchend"},c=/\s+/,u={bubbles:!0,cancelable:!0},r="function"==typeof Symbol?Symbol("events"):{};function d(e){return e[r]||(e[r]={})}function m(e,t,n,o,i){t=t.split(c);var a,u=d(e),r=t.length;function m(e){n(e,o)}for(;r--;)(u[a=t[r]]||(u[a]=[])).push([n,m]),e.addEventListener(a,m)}function v(e,t,n,o){t=t.split(c);var i,a,u,r=d(e),m=t.length;if(r)for(;m--;)if(a=r[i=t[m]])for(u=a.length;u--;)a[u][0]===n&&(e.removeEventListener(i,a[u][1]),a.splice(u,1))}function f(t,n,o){var i=new CustomEvent(n,u);o&&e(i,o),t.dispatchEvent(i)}function s(){}function l(e){e.preventDefault()}function p(e,t){var n,o;if(e.identifiedTouch)return e.identifiedTouch(t);for(n=-1,o=e.length;++n"),e.no_overlay||a.append("
");var r=a.find("img:first"),c=a.find("img:last");a.append("
");var l=a.find(".twentytwenty-handle");l.append(""),l.append(""),a.addClass("twentytwenty-container"),r.addClass("twentytwenty-before"),c.addClass("twentytwenty-after");var d=a.find(".twentytwenty-overlay");d.append("
"),d.append("
");var w=function(t){var e,n,o,s,d=(e=t,n=r.width(),o=r.height(),{w:n+"px",h:o+"px",cw:e*n+"px",ch:e*o+"px"});l.css("vertical"===i?"top":"left","vertical"===i?d.ch:d.cw),s=d,"vertical"===i?(r.css("clip","rect(0,"+s.w+","+s.ch+",0)"),c.css("clip","rect("+s.ch+","+s.w+","+s.h+",0)")):(r.css("clip","rect(0,"+s.cw+","+s.h+",0)"),c.css("clip","rect(0,"+s.w+","+s.h+","+s.cw+")")),a.css("height",s.h)},v=function(t,e){var n,a,o;return n="vertical"===i?(e-p)/h:(t-f)/y,a=0,o=1,Math.max(a,Math.min(o,n))};t(window).on("resize.twentytwenty",function(t){w(n)});var f=0,p=0,y=0,h=0,u=function(t){(t.distX>t.distY&&t.distX<-t.distY||t.distX-t.distY)&&"vertical"!==i?t.preventDefault():(t.distXt.distY&&t.distX>-t.distY)&&"vertical"===i&&t.preventDefault(),a.addClass("active"),f=a.offset().left,p=a.offset().top,y=r.width(),h=r.height()},_=function(t){a.hasClass("active")&&(n=v(t.pageX,t.pageY),w(n))},m=function(){a.removeClass("active")},g=e.move_with_handle_only?l:a;g.on("movestart",u),g.on("move",_),g.on("moveend",m),e.move_slider_on_hover&&(a.on("mouseenter",u),a.on("mousemove",_),a.on("mouseleave",m)),l.on("touchmove",function(t){t.preventDefault()}),a.find("img").on("mousedown",function(t){t.preventDefault()}),e.click_to_move&&a.on("click",function(t){f=a.offset().left,p=a.offset().top,y=r.width(),h=r.height(),n=v(t.pageX,t.pageY),w(n)}),t(window).trigger("resize.twentytwenty")})}}(jQuery); $(function(){ if(($('div.ab_dynamic_chart') || $('div.tag_dynamicChart')) && ($('div.ab_dynamic_chart').length > 0 || $('div.tag_dynamicChart').length > 0)) { var highcharts = "//code.highcharts.com/highcharts.js"; var highcharts_3d = "//code.highcharts.com/highcharts-3d.js"; var highcharts_more = "//code.highcharts.com/highcharts-more.js"; var exporting = "//code.highcharts.com/modules/exporting.js"; var export_data = "//code.highcharts.com/modules/export-data.js"; var map = "//code.highcharts.com/maps/modules/map.js"; var wmap = "//static.joins.com/joongang_15re/scripts/_res/JAddon/v1/world.js"; $.getScript(highcharts, function() { $.getScript(highcharts_3d, function() { $.getScript(highcharts_more, function() { $.getScript(exporting, function() { $.getScript(export_data, function() { $.getScript(map, function() { $.getScript(wmap, function() { Highcharts.setOptions({ lang: { thousandsSep: ","}, navigation: {buttonOptions: {enabled: false}} }); $('div.ab_dynamic_chart').articleDChartInit(); $('div.tag_dynamicChart').articleDChartInit(); }); }); }); }); }); }); }); } if($('div.tag_chatbox') && $('div.tag_chatbox').length > 0) { $('div.tag_chatbox').jaddonChatBox(); } if($('div.tag_jaddons_Beaf') && $('div.tag_jaddons_Beaf').length > 0) { $('div.tag_jaddons_Beaf').jaddonBeaf(); } if($('div.ab_quiz') && $('div.ab_quiz').length > 0) { $('div.ab_quiz').articleQuizInit(); } }); /* # ChatBox # # # # */ $.fn.jaddonChatBox = function () { return this.each(function (i, v) { var seq = $(v).addClass('ab_chat').removeClass('tag_chatbox').data('id'); if (!seq) { return; } $.ajax({dataType:'jsonp', contentType:'text/plain', cache:false, url:('https://jaddon.joins.net/ChatBox/Cont/json/'+seq)}).done(function(res) { $(v).html('').append(res.Data); $(v).find('span.jaddon_exp_box').css({'cursor':'pointer'}).on('click', function() { jaddonPhotoViewer($(this).find('img:first').attr('src')); }); }); }); }; function jaddonPhotoViewer(tsrc) { if(tsrc.length<=0) { return; } var adpv=$('#jaddonPhotoViewerLayer'); if(adpv.length<=0) { $('body').append(''); adpv=$('#jaddonPhotoViewerLayer'); } $('#jaddonPhotoViewerImage').remove(); var ti = new Image(); ti.onload = function () { $(adpv).append($(ti)); $('#jaddonPhotoViewerLayer').show(); var sp=($('#jaddonPhotoViewerLayer').height()-$('#jaddonPhotoViewerImage').height())/3; $('#jaddonPhotoViewerImage').css({'margin-top':sp+'px'}); } ti.style = 'display:block;margin:auto;max-width:90%;max-height:90%;'; ti.alt='확대보기'; ti.id='jaddonPhotoViewerImage'; ti.src = tsrc; } /* # # # # ChatBox # */ function cback(res) { if(res==undefined || !res.result || res.nid<=0) { return; } res = res.result; var key = 'Beaf_' + res.nid + "-" +generateUUID(); var cd = ('
' + res.beaftitle + '
Before
'); var imgA = new Image(); imgA.onload = function () { $('#' + key).append($(imgA)); $('#' + key).twentytwenty({ default_offset_pct: 0.5, orientation: 'horizontal' , before_label: res.beafdescb, after_label: res.beafdesca, no_overlay: false , move_slider_on_hover: false, move_with_handle_only: true , click_to_move: true }); }; var width = 400; if (res.beaftype == 'b') { width = 580; } $('[data-id="'+res.nid+'"]').css({'text-align': 'center'}).html('').append(cd); $('#' + key + ' img').width(width).css({'max-width': '100%'}); $('#' + key).width(width).css({'margin': 'auto auto auto auto', 'max-width': '100%'}); imgA.src = '' + res.beafsimga; } /* # Beaf # # # # */ $.fn.jaddonBeaf = function(){ return this.each(function (i, v) { var seq = $(v).addClass('ab_jaddons_Beaf').removeClass('tag_jaddons_Beaf').data('id'); if (!seq) { return; } // create script element var script = document.createElement('script'); // assing src with callback name script.src = 'https://static.joins.com/jaddons/svc/Beaf/json/' + seq + '.json?callback=cback'; document.body.appendChild(script); }); }; /* # # # # Beaf # */ function generateUUID() { var d = new Date().getTime(); return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); } /** Quiz */ $.fn.articleQuizInit = function () { var finish = function () { $('div.ab_quiz').find('.quiz_finish_btn').off().on('click', function (event) { var $quizDiv = $(this).closest('div.ab_quiz'); var quizCnt = $quizDiv.data('quizcnt'); $(this).closest('div.quiz_question_screen').hide(); var resultType = $quizDiv.find('.quiz_result_type').html(); var quizResult = $quizDiv.data('quizresult'); var correctCnt = quizResult.split(',').filter(function (val) {return val == 'Y';}).length; var correctPercent = (correctCnt / quizCnt) * 100; var gradeClass = 'quiz_grade'; var gradeText = 'Thank You!'; var resultText = ''; if (resultType == 'A') { if (correctPercent >= 80) { gradeClass += '_a'; gradeText = '와우 전문가~!'; } else if (correctPercent >= 40) { gradeClass += '_b'; gradeText = '나쁘지 않아요!'; } else { gradeClass += '_c'; gradeText = '힘을 내요!'; } resultText = '적중'; } else { resultText = '정답'; } var $resultTarget = $quizDiv.find('.quiz_result_screen'); $resultTarget.addClass(gradeClass); $resultTarget.find('.quiz_result').html(gradeText); $resultTarget.find('.quiz_score').html(''); $resultTarget.find('.quiz_score').append(''+quizCnt+'문제 중 '+correctCnt+'문제 '+resultText+'!'); try { jatracker('event', 'clickEvent', 'JAM Particle Quiz', quizKey($(this).closest('div.ab_quiz')), 'End'); // 퀴즈 완료 시 } catch (e) { console.log(e); } event.preventDefault(); }); }; var quizKey = function(div) { return div.data('nid'); }; //시작버튼 클릭 $('div.ab_quiz').find('.quiz_start_btn').off().on('click', function (event) { function pad(num) { num = num + ''; return num.length < 2 ? '0' + num : num; } var $quizDiv = $(this).closest('div.ab_quiz'); $(this).closest('div.quiz_start_screen').hide(); var $quizQuestion = $quizDiv.find('.quiz_question_screen'); var quizCnt = $quizQuestion.length; $(this).closest('div.ab_quiz').data('quizcnt', quizCnt); $.each($quizQuestion, function (i, item) { $(item).find('.quiz_counter').html('' + pad(i + 1) + ' / ' + pad(quizCnt)); if (i == (quizCnt - 1)) { var $lastBtn = $(item).find('.quiz_next_btn'); $lastBtn.html('결과보기'); $lastBtn.unbind("click"); $lastBtn.addClass('quiz_finish_btn'); finish(); } }); try { jatracker('event', 'clickEvent', 'JAM Particle Quiz', quizKey($(this).closest('div.ab_quiz')), 'Start'); // 퀴즈 시작 시 } catch (e) { console.log(e); } event.preventDefault(); }); function findTextNode (obj) { return obj.filter(function () {return this.nodeType === 3;}).text(); } $('ul.quiz_answer').find('a').off().on('click', function (event) { var result = $(this).closest('li').find('.result').html(); var $quizQuestionScreen = $(this).closest('div.quiz_question_screen'); if ($quizQuestionScreen.data('selected') === 'N') { $quizQuestionScreen.removeClass('quiz_correct_state'); $quizQuestionScreen.removeClass('quiz_incorrect_state'); $quizQuestionScreen.addClass(result == 'Y' ? 'quiz_correct_state' : 'quiz_incorrect_state'); $quizQuestionScreen.data('selected', 'Y'); if (0 == $quizQuestionScreen.index($quizQuestionScreen.closest('div.ab_quiz').find('div.quiz_question_screen'))) { $quizQuestionScreen.find('.quiz_previous_btn').hide(); } $(this).addClass(result == 'Y' ? 'correct' : 'incorrect'); if (result == 'N') { $.each($(this).closest('.quiz_answer').find('li'), function (i, item) { if ($(item).find('.result').html() == 'Y') { $(item).find('a').addClass('correct'); } }); } var explain = $.trim(findTextNode($quizQuestionScreen.find('.quiz_response').contents())).length; if (explain == 0) { var quizQuestion = findTextNode($quizQuestionScreen.find('.quiz_question').contents()); $quizQuestionScreen.find('.quiz_response').find('span').eq(1).after(quizQuestion); } var beforeResult = $(this).closest('div.ab_quiz').data('quizresult'); if (beforeResult.length > 0) { result = beforeResult + ','+result; } $(this).closest('div.ab_quiz').data('quizresult', result); } event.preventDefault(); }); $('div.ab_quiz').find('.quiz_previous_btn').off().on('click', function (event) { $(this).closest('div.quiz_question_screen').prev('div.quiz_question_screen').show(); event.preventDefault(); }); $('div.ab_quiz').find('.quiz_next_btn').off().on('click', function (event) { $(this).closest('div.quiz_question_screen').hide(); event.preventDefault(); }); //다시풀기 $('div.ab_quiz').find('.quiz_restart_btn').closest('.quiz_control').off().on('click', function (event) { var key = quizKey($(this).closest('div.ab_quiz')); var $resetQuizDiv = $('div.ab_quiz[data-nid="' + key + '"]'); $resetQuizDiv.find('.quiz_start_screen').show(); $resetQuizDiv.find('.quiz_question_screen').show(); $resetQuizDiv.find('.quiz_question_screen').removeClass('quiz_correct_state'); $resetQuizDiv.find('.quiz_question_screen').removeClass('quiz_incorrect_state'); $resetQuizDiv.find('.quiz_question_screen').data('selected', 'N'); $resetQuizDiv.find('.quiz_answer').find('a').removeClass('correct'); $resetQuizDiv.find('.quiz_answer').find('a').removeClass('incorrect'); $resetQuizDiv.find('.quiz_result_screen').removeClass('quiz_grade_a'); $resetQuizDiv.find('.quiz_result_screen').removeClass('quiz_grade_b'); $resetQuizDiv.find('.quiz_result_screen').removeClass('quiz_grade_c'); $resetQuizDiv.find('.quiz_result_screen').removeClass('quiz_grade'); $resetQuizDiv.data('quizresult', ''); $resetQuizDiv.data('quizcnt', 0); event.preventDefault(); }); $('div.ab_quiz').find('.quiz_share_btn').off().on('click', function (event) { event.preventDefault(); }); }; /** */ /* Highcharts */ $.fn.articleDChartInit = function(){ return this.each(function(i, e) { var $ele = $(e); var targetId = ""; var chartData = ""; var $figure = $ele.find("figure"); targetId = $figure.prop("id", ($figure.prop("id") +"-" + i)).prop("id"); chartData = $ele.data("datadchart"); if (typeof chartData === "string") { chartData = JSON.parse(decodeURIComponent(chartData)); } if (chartData.chart.map || chartData.chart.world) { //20210120 유가영 : zoom 정보 세팅 var zoomValue = chartData["chart"]["dataForLoading"]["zoomData"]; Highcharts.mapChart(targetId, chartData, function(chart){ var xMax = parseInt(zoomValue["curMaxZoomMap"]); var xMin = parseInt(zoomValue["curMinZoomMap"]); var yMax = parseInt(zoomValue["curMaxZoomMapY"]); var yMin = parseInt(zoomValue["curMinZoomMapY"]); if(!isNaN(xMax)){ chart.xAxis[0].setExtremes(xMin, xMax); chart.yAxis[0].setExtremes(yMin, yMax); } }); } else { Highcharts.chart(targetId, chartData); } }); } function generateUUID() { var d = new Date().getTime(); return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); }