if(document.getElementById('page-pass')) { $('#page-pass .split-top button').click(function(){ $('._login,._register').slideToggle(); }); ajaxForm('login'); ajaxForm('register'); } if(document.getElementById('member-address')) { $('.member-address form').each(function(){ var $item=$(this); $('.btn-edit',$item).on('click',function(){ $('.layer-padding',$item).show(); $('input',$item).attr('disabled',false).eq(0).focus(); }); $('.btn-cancel',$item).on('click',function(){ $('.layer-padding',$item).hide(); $('input',$item).attr('disabled','disabled'); }); var s=$('.state',$item); $.getJSON('/action/getState?iid='+$item.attr('country')+'&state='+$('input[name="state"]',$item).val(),function(data){ if(data.status==SUCCESS) s.empty().append(data.data); }); }); } if(document.getElementById('page-address-add')) { ajaxForm('addAddress'); function getState() { $.getJSON('/action/getState?iid='+$('select[name="country_id"]').val(),function(data){ notice.clear(); if(data.status==SUCCESS) $('#state-input').empty().append(data.data); else $('#state-input').empty().append(''); }); } $('select[name="country_id"]').change(function(){getState();}); getState(); } if(document.getElementById('page-profile')) { ajaxForm('profile'); } $(function(){ $('.btn-del').each(function(){ $(this).click(function(e){ e.preventDefault(); sure(e,$(this).attr('r')||'Are you sure to delete this item?',$(this).attr('href')||$(this).attr('data-href'),function(){ $(this).parents($(this).attr('del-item') || 'tr').fadeOut(function(){$(this).remove();}); },true); }); }); $('.ajax-toggle').on('click',function(){ var $a=$(this); $.getJSON($a.attr('url'),{iid:$a.attr('data-iid'),name:$a.attr('data-name')},function(data){ notice.result(data); if(SUCCESS==data.status){ $('.fa',$a).toggleClass('fa-toggle-on').toggleClass('fa-toggle-off').attr('title',data.info); } }); }); $('.ajax-select').change(function(){ var $a=$(this); $.post($a.attr('url'),{iid:$a.attr('iid'),name:$a.attr('name'),value:$a.val(),txt:$a.find('option:selected').text()},function(data){ notice.result(data); }); }); });