hSdrop.js 1.4 KB

1234567891011121314151617181920
  1. ;(function(){function hSdrop(options){var self=this;self=$.extend(self,{els:'',},options);$(self.els).click(function(e){self.init(this);})}
  2. hSdrop.prototype={init:function(el){var kl=''
  3. kl+='<div class="select-moob">'
  4. kl+='<div class="select-moob-cover"></div>'
  5. kl+='<div class="select-moob-container">'
  6. kl+=' <div class="x12 select-moob-title">'
  7. kl+=' <div class="cancel">取消</div>'
  8. kl+=' <div class="determine">确定</div>'
  9. kl+=' </div>'
  10. kl+=' <div class="x12 select-moob-content">'
  11. kl+=' <div class="swiper-container sw-select">'
  12. kl+=' <div class="swiper-wrapper">'
  13. var dob=$(el).next().children();for(var i=0;i<dob.length;i++){kl+=' <div class="swiper-slide" vid="'+$(dob[i]).attr('vid')+'">'+$(dob[i]).html()+'</div>'}
  14. kl+=' </div>'
  15. kl+=' </div>'
  16. kl+=' </div>'
  17. kl+='</div>'
  18. kl+='</div>'
  19. $('body').append(kl);var swipersff=new Swiper('.sw-select',{direction:'vertical',autoHeight:true,slidesPerView:3,centeredSlides:true,observer:true,observeParents:true,observeSlideChildren:true,});$('.sw-select .swiper-wrapper>div').click(function(e){swipersff.slideTo($(this).index(),500,false);});$('.select-moob .cancel,.select-moob-cover').click(function(e){$('.select-moob').remove();});$('.select-moob .determine').click(function(e){$(el).children('input').val($('.sw-select .swiper-slide-active').html());$(el).children('input').attr('value',$('.sw-select .swiper-slide-active').attr('vid'));$('.select-moob').remove();})},}
  20. window.hSdrop=hSdrop;}());