1(function($){ 2 3'use strict'; 4 5//////////////////////////////////////////////////////////////////////////////// 6 7 function BookShelf(instance,options){ 8 this.element=instance 9 this.options=options; 10 this.id=$(this.element).attr('id'); 11 this.init(); 12 this.addWrap(); 13 14 15 16 } 17 18//////////////////////////////////////////////////////////////////////////////// 19 20 BookShelf.prototype.addWrap = function () { 21 22 //reset wrap 23 $(".bs-shelf-background",this.element).remove(); 24 $(".bs-shelf",this.element).contents().unwrap(); 25 $(".bs-shelf-images",this.element).contents().unwrap(); 26 27 28 //index calculate 29 /* 30 var index=0; 31 $(".bs-shelf-image",this.element).each(function() { 32 ++index; 33 34 if($(this).prev().length > 0) { 35 if($(this).offset().top != $(this).prev().offset().top) { 36 index--; 37 return false; 38 }} 39 }); 40 /*/ 41 42 43 /////index calculate ( new method ) 44 var _current_width=$(this.element).width(); 45 var _x_space=parseInt( $('#'+this.id+'.bs-container .bs-shelf-image').css('margin-right') ) 46 var _left_margin=parseInt( $('#'+this.id+'.bs-container .bs-shelf-image:first-child').css('margin-left') ) 47 var _right_margin=parseInt( $('#'+this.id+'.bs-container .bs-shelf-image:last-child').css('margin-right') ) 48 var _rectangle=parseInt( $('#'+this.id+'.bs-container .bs-shelf-image').css('width') ) 49 var free_area=( (_current_width - _left_margin - _right_margin ) / ( _rectangle+_x_space ) ) 50 var index=Math.floor( free_area ); 51 if( index < 1 ){ index= 1 } 52 53 54 //add Wrap 55 var images = $(".bs-shelf-image",this.element); 56 for(var i = 0; i < images.length; i+=index) { 57 images.slice(i, i+index).wrapAll("<div class='bs-shelf'><div class='bs-shelf-images'></div></div>"); 58 } 59 60 //add background 61 $('.bs-shelf',this.element).prepend("<div class='bs-shelf-background'><div class='bs-rectangle'></div></div>"); 62 63 //add mask 64 $('.bs-textbox',this.element).wrap("<div class='bs-mask'></div>"); 65 66 //if alwayes title 67 var _this=this; 68 if ( this.options.always_title=="true"){ 69 setTimeout( function(){ 70 $('.bs-shelf-image',_this.element).each(function(index, element) { 71 _this.over($(this),1) 72 });
73 },1000) 74 } 75 76 77 78 79 80} 81 82/////////////////////mouse over//////////////////////////////////////////////////////////// 83 84 BookShelf.prototype.over = function (item_,anim_) { 85 86 87 var item=item_; //class 'bs-shelf-image' 88 var textbox=$('.bs-textbox',item); 89 var textbox_height=textbox.innerHeight(); 90 var img=$('img',item); 91 var img_width=img.width(); 92 var img_height=img.height(); 93 var img_top=img.position().top; 94 textbox.css('width',img_width+'px') 95 textbox.css('bottom',-textbox_height+'px'); 96 97 //animation blockade 98 if( textbox.children().length ){ 99 100 if( !anim_ ){ 101 textbox.animate({ bottom:0+"px"},200) 102 }else{ 103 textbox.css('bottom','0'); 104 } 105 106 } 107 108 109 110 111 112 } 113 114 115/////////////////////mouse out//////////////////////////////////////////////////////////// 116 117 BookShelf.prototype.out = function (item_) { 118 119 var item=item_ /// class 'bs-shelf-image' 120 var textbox=$('.bs-textbox',item); 121 var img=$(this); 122 textbox.animate( 123 { 124 125 bottom:-textbox.innerHeight()+"px" 126 127 }, 128 200 129 ) 130 131 132 } 133 134 135/////////////////////////////////////////////////////////////////////////////// 136 137 BookShelf.prototype.init = function () { 138 var _this=this; 139 $(window).bind('orientationchange resize', function(event){ 140 _this.addWrap() 141 }); 142 143 144 145 if ( this.options.always_title!="true"){ 146 //mouse over 147 $(".bs-shelf-image",this.element).bind('mouseenter touchstart',function(){ 148 _this.over(this) 149 }) 150 151 ///mouse out 152 $(".bs-shelf-image",this.element).bind('mouseleave',function(){ 153 _this.out(this) 154 }) 155 } 156 157 158 159 160 161 162 163 }; 164 165 166///////////////////////////////////////////////////////////////////////////////// 167 168 169 $.fn.bookshelf = function( options ) { 170 171 var settings = $.extend({ 172 param : 'param', 173 always_title : 'false' 174 }, options); 175 176 return this.each( function() { 177 new BookShelf(this,settings); 178 }); 179 180 } 181 182/////////////////////////////////////////////////////////////////////////////////// 183 184 185 186})(jQuery) 187 188 189 190
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.