/* food list ajax È£Ãâ food_list_js.init({ 'box' : $(".food_list"), 'url' : 'AJAX URL', 'getdata' : { 'page': '', 'toPage': '', 'searchkey':'', 'searchval' : '', 'per':20, 'category':'', 'cid':'' }, 'searchkey' : '°Ë»öÁ¾·ù', 'searchval' : '°Ë»ö¾î', 'category' : '1Â÷Ä«Å×°í¸®', 'cid' : '2Â÷Ä«Å×°í¸®', 'success' : function(d) { alert('AJAX¿Ï·á'); } 'finish_event' : function() { alert('AJAX callback ÇÔ¼ö ½ÇÇà¿Ï·á'); } }); */ var food_list_js = { 'v' : { 'CURRENT_PAGE' : 0, 'total_count' : 0, 'list_box' : $(".food_list"), 'epicure_box' : $(".epicure_list"), 'ajax_url' : '/System/proc/food/inc/food_list_ajax.inc.php', 'ajax_get_data' : { 'page': 0, 'toPage': 0, 'per':20, 'searchkey':'', 'searchval' : '', 'category':'', 'cid':''} }, 'init' : function(s){ var t = this; var now_hash = document.location.hash; if(s.box) t.v.list_box = s.box; if(s.url) t.v.ajax_url = s.url; if(s.getdata) t.v.ajax_get_data = s.getdata; if(s.success) t.callback_func = s.success; if(s.searchkey) t.v.ajax_get_data.searchkey = s.searchkey; if(s.searchval) t.v.ajax_get_data.searchval = s.searchval; if(s.category) t.v.ajax_get_data.category = s.category; if(s.cid) t.v.ajax_get_data.cid = s.cid; if(s.finish_event) t.finish_event = s.finish_event; if(!now_hash || now_hash == '#foodback') now_hash = "fromNo_0"; var hash_arr = now_hash.split("_"); //console.log(now_hash, hash_arr); t.v.ajax_get_data.toPage = parseInt(hash_arr[1]); //alert(t.v.ajax_get_data.toPage ); for(var i=0; i<=t.v.ajax_get_data.toPage; i++){ t.food_list(); } $(".btn_more").click(function(e){ //t.hash_change(); t.food_list(); e.preventDefault(); }); // ´õº¸±â }, 'set_getdata' : function(json_data) { this.v.ajax_get_data = json_data; }, 'callback_func' : function(page_box_id, obj) { var t = this; obj = JSON.parse(obj); if(document.location.hash){ var HashLocationName = document.location.hash; HashLocationName = HashLocationName.replace("#",""); } //console.log("123123123", page_box_id); //¸®½ºÆ® Áý¾î³Ö±â $('#'+page_box_id).html(obj.list_html); t.v.epicure_box.html(obj.epicure_list_html); // ¹Ì½ÄÆò°¡´Ü //½Ã°£³ëÃâ $("#fromNo_"+t.v.ajax_get_data.page+" .time_kor").each(function() { var time_kor = food_list_js.time_to_kor($(this).data("datetime")); $(this).html(time_kor); }); //¸®½ºÆ® À̹ÌÁö ·¹ÀÌÁö·Îµå $(".news_area img").lazyload({ effect : "fadeIn", threshold : 100 }); t.v.total_count = obj.total_count; if(t.v.ajax_get_data.searchval) $("#artcle_cnt").html('('+t.v.total_count+')'); if(!t.v.ajax_get_data.searchval && t.v.total_count == 0) $(".list_empty").show(); //¸®½ºÆ®¾øÀ»¶§ if(t.v.ajax_get_data.searchval && t.v.total_count == 0) $(".search_empty").show(); //°Ë»ö°á°ú¾øÀ»¶§ if(t.v.CURRENT_PAGE * t.v.ajax_get_data.per >= t.v.total_count ){ $(".btn_more").hide(); }else{ $(".btn_more").show(); } t.finish_event(); }, 'change_category' : function (cid) { var t = this; //$(".game_type_menu li").removeClass("on"); //$(".game_type_menu li").eq(cid).addClass("on"); var getdata = { 'page': 0, 'toPage': 0, 'searchval' : '{$searchval}', 'per':20, 'cid': cid }; food_list_js.reset_list(); food_list_js.set_getdata(getdata); food_list_js.food_list(); }, 'finish_event' : function(){ //¸¶Áö¸·¿¡ ½ÇÇàµÇ´Â ÇÔ¼ö }, 'food_list' : function (){ var t = this; t.v.ajax_get_data.page = t.v.CURRENT_PAGE; // ½ÃÀÛ ÆäÀÌÁö console.log(t.v); var page_box_id = 'fromNo_'+t.v.ajax_get_data.page; if($("#"+page_box_id).length < 1) { t.v.list_box.append('
'); t.v.CURRENT_PAGE++; // ´ÙÀ½ º¸¿©Áú ÆäÀÌÁö $.ajax({ url: t.v.ajax_url, type:'get', dataType:'html', data : t.v.ajax_get_data, success:function(obj){ //alert(22); //console.log(obj); t.callback_func(page_box_id, obj); } }); } }, 'reset_list' : function(){ //¸®½ºÆ® ÃʱâÈ­ var t = this; $(".btn_more").hide(); t.v.list_box.html(''); t.v.CURRENT_PAGE = 0; }, 'hash_change' : function (){ document.location.hash="#fromNo_"+food_list_js.v.CURRENT_PAGE ; }, 'time_to_kor' : function(time){ //½Ã°£º¯°æ var now_time = new Date().getTime() - time * 1000; var sign_timedata = new Date(time * 1000); var time_kor = ''; if( now_time > 3600 * 24 * 1000 ) { var month = (sign_timedata.getMonth() + 1); var date = sign_timedata.getDate(); if(month < 10) month = '0' + month; if(date < 10) date = '0' + date; time_kor = sign_timedata.getFullYear() + '.' + month + '.' + date; } else if( now_time > 3600 * 1000 ) { time_kor = Math.floor(now_time / 3600000) + '½Ã°£Àü'; } else { time_kor = Math.floor(now_time / 60000) + 'ºÐÀü'; } return time_kor; } }; //$(function() { // Çػ󵵺° À̺¥Æ® º¯°æ (food_common.js) $(window).on("load", function(){ window_size_change.init(); window_size_change.init_start(); }); //}); //Çػ󵵿¡ µû¸¥ ÅÂ±× ´õº¸±â ¹öÆ° Á¦¾î var window_size_change = { 'browser_mode' : 'm', 'window_size' : { 'xs' : 640, 's' : 1023 }, 'init_start' : function() { var t = this; var win_w = parseInt($(window).width()); if(win_w <= t.window_size.s && t.browser_mode != 's'){ t.browser_mode = 's'; t.s_down_event(); } else{ browser_mode = 'm'; t.s_up_event(); } if(win_w <= t.window_size.xs && t.browser_mode != 'xs'){ t.browser_mode = 'xs'; t.xs_down_event(); } else{ t.browser_mode = 's'; t.xs_up_event(); } }, 'init' : function() { var t = this; //$(window).on("load", function(){ t.init_start(); //}); $(window).bind('resize', function(){ t.init_start(); }); }, 'xs_down_event' : function () { $("#foot .cpr").html('© HumanWorks Corporation. All Rights Reserved.'); }, 'xs_up_event' : function () { $("#foot .cpr").html('Copyright © HumanWorks Corp. All Rights Reserved.'); }, 's_down_event' : function () { $('#btn_tag_more').unbind('click').bind('click', function(){ $(this).attr("href", "/tag/"); }); //°Ë»öÆäÀÌÁö ¿¬°üÅÂ±× ´õº¸±â Á¢±â $('#btn_tag_toggle').unbind('click').bind('click', function(){ var btn_text = $(this).text(); $('#main_tag_related_wrap .tag_area').toggleClass('h_auto'); if(btn_text == '´õº¸±â'){ $(this).text('Á¢±â'); }else{ $(this).text('´õº¸±â'); } }); $('#side_banner_area').removeClass('move_wrap'); $('#main_tag_related_wrap').appendTo('#head_wrap'); //À©µµ¿ì ½ºÅ©·Ñ ¹ß»ý ½Ã ³ÏÀÌ ´Ù½Ã üũÇÊ¿ä $('#sub_tag_area_wrap').appendTo('.news_area'); }, 's_up_event' : function() { var t = this; //¸ÞÀÎ ÆäÀÌÁö ÅÂ±× ´õº¸±â Ŭ¸¯ ½Ã $('.tags_btn_more').unbind('click').bind('click', function(){ $('#main_tag_related_wrap .tag_area').toggleClass('h_auto'); }); //À¥ ÇØ»óµµÀÏ ½Ã ÅÂ±× ¿ìÃø ¹è³Ê ¹ØÀ¸·Î À§Ä¡ $('#sub_tag_area_wrap').appendTo('.banner_box'); $('#main_tag_related_wrap').appendTo('.banner_box'); // ½ºÅ©·Ñ ½Ã top&down Á¦¾î if($('.banner_box').length > 0) { var fix_side_top = $('.banner_box').offset(); $(window).bind('scroll', function() { var win_w = parseInt($(window).width()); if(win_w > t.window_size.s){ if ($(window).scrollTop() > ( fix_side_top.top + $('.tag_area_wrap').height() + $('.fb_dailyfood').height() + 20 ) ) { $('#side_banner_area').addClass('move_wrap'); } else { $('#side_banner_area').removeClass('move_wrap'); } } }); } } } function click_article(p, oid, this_table_date, clickzone){ var url = '/outlink/?fid=food&oid='+oid+'&url='+encodeURIComponent('/'+p+this_table_date+oid); window.open(url); }