$( function(){ //日付カレンダー $(document).on('focus','.datepicker',function(){ if ( ! $(this).hasClass("hasDatepicker") ) { $(this).datepicker({ changeYear: 'true', changeMonth: 'true', showOn:'focus' }); } }); if ( $('.datepicker').length > 0 ) { $('.datepicker').eq(0).datepicker({ changeYear: 'true', changeMonth: 'true', showOn:'focus' }); } $(document).on('focus','.datepicker2', function(){ $(this).ympicker({ closeText: '閉じる', prevText: '<前', nextText: '次>', currentText: '今日', monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'], monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'], dateFormat: 'yy/mm', yearSuffix: '年' }); }); //画像切り替え $('.catalog_thumb a').click( function(){ $(this).closest('.catalog_item_table').find('.sitem_image img').css( 'backgroundImage', 'url('+$(this).attr('href')+')' ); $(this).closest('.catalog_item_table').find('.sitem_image a').attr( 'href', $(this).attr('href') ); return false; } ); //ショッピングカートアイコンの表示 $(document).scroll( function(){ if ( $('#shopping_cart_area').length > 0 ) { if ( $('#shopping_cart_area').offset().top < $(window).scrollTop() ) { $('#shopping_cart_area2').css('display','table').show(); $('#shopping_cart_area').animate( { opacity:0 }, 0 ); } else { $('#shopping_cart_area2').hide(); $('#shopping_cart_area').animate( { opacity:1 }, 0 ); } } } ); //一覧からカートに入れる $('.set_cart').click( function(){ setCart( $(this).attr('rel'), 1, '', '', '' ); return false; } ); //詳細からカートに入れる $('.shopping_cart_btn').click( function(){ setCart( $(this).closest('form').find('input[name="sitem_id"]').val(), $(this).closest('form').find('select[name="amount"]').val(), $(this).closest('form').find('input[name="date"]').val(), ( $(this).closest('form').find('select[name="date2"]').length > 0 ? $(this).closest('form').find('select[name="date2"]').val() : '' ), 'detail' ); return false; } ); } ); function setCart( id, amount, dt, md, page ) { $.post( 'shopping.html', { mode: 'incart', id:id, amount:amount, dt:dt, md:md }, function( data ){ var tmp = data.split(""); if ( tmp[0] == 'OK' ) { $('#shopping_cart_area .cartbox,#shopping_cart_area2 .cartbox').animate( { backgroundColor:'rgba(255,0,0,.3)' }, 500, function(){ $('div.shopping_cart_amount').html(tmp[1]); $(this).animate( { backgroundColor:'rgba(255,255,255,0)' }, 300, function(){ if ( page == 'detail' ) window.location.href = 'cart.html'; } ); } ); } else { alert( data ); } } ); }