1/* 2 3uSquare 1.6 - Universal Responsive Grid 4 5Copyright (c) 2012 Br0 (shindiristudio.com) 6 7Project site: http://codecanyon.net/ 8Project demo: http://shindiristudio.com/usquare/ 9 10*/ 11 12(function($) { 13 14 function uSquareItem(element, options) { 15 this.$item = $(element); 16 this.$parent = options.$parent; 17 this.parent_this = options.parent_this; 18 this.options = options; 19 //console.log(this.options.grayscale); 20 this.$trigger = this.$(options.trigger); 21 this.$close = this.$('.close'); 22 this.$info = this.$(options.moreInfo); 23 this.$trigger_text = this.$trigger.find('.usquare_square_text_wrapper'); 24 this.$image = this.$item.find('img.usquare_square:first'); 25 if (this.options.grayscale) this.$image2 = this.$item.find('img.usquare_square:last'); 26 27 this.$image_parent = this.$image.parent(); 28 this.linked_image=0; 29 this.image_parent_href2=''; 30 if (this.$image_parent.is('a')) 31 { 32 var opened_only = this.$image_parent.attr('data-only-open'); 33 this.image_parent_opened_only=0; 34 this.image_parent_href2=this.$image_parent.attr('href'); 35 if (typeof opened_only != 'undefined') 36 { 37 this.image_parent_opened_only=1; 38 this.image_parent_href=this.$image_parent.attr('data-href'); 39 this.image_parent_href2=this.$image_parent.attr('data-href'); 40 this.image_parent_rel=this.$image_parent.attr('data-rel'); 41 this.image_parent_target=this.$image_parent.attr('data-target'); 42 } 43 this.linked_image=1; 44 } 45 this.image_clicked=0; 46 this.widget_height=0;; 47 this.pushed=0; 48 this.$usquare_about = this.$info.find('.usquare_about'); 49 this.dont_open=this.$item.attr('data-dont-open'); 50 if (typeof this.dont_open == 'undefined') this.dont_open=0; 51 this.dont_move=this.$item.attr('data-dont-move'); 52 if (typeof this.dont_move == 'undefined') this.dont_move=0; 53 this.link_square=this.$item.attr('data-link-square'); 54 if (typeof this.link_square == 'undefined') this.link_square=0; 55 56 this.$image.click ($.proxy(this.image_click, this)); 57 //this.$image2.mouseenter (function(){alert('ok');}); 58 if (this.options.grayscale) { 59 //this.$image2.click ($.proxy(this.image_click, this)); 60 this.$image2.mouseenter ($.proxy(this.mouseenter, this)); 61 this.$image.mouseleave ($.proxy(this.mouseleave, this)); 62 } 63 this.$trigger.click($.proxy(this.show, this)); 64 this.$close.click($.proxy(this.close, this)); 65 //this.skip_image2_show=0; 66 //this.skip_image2_show2=0; 67 options.$overlay.click($.proxy(this.close, this)); 68 }; 69 uSquareItem.prototype = { 70 image_click: function(e) { 71 if (this.linked_image==1) { 72 this.image_clicked=1; 73 } 74 }, 75 mouseenter: function() { 76 if (this.options.grayscale) this.$image2.hide(); 77 }, 78 mouseleave: function() { 79 if (!this.$item.data('showed') && !this.$parent.data('in_trans') && this.options.grayscale) this.$image2.show(); //&& this.skip_image2_show2==0 80 //if (this.skip_image2_show2==1) this.skip_image2_show2=0; 81 }, 82 show: function(e) { 83 var skip_prevent=0; 84 if (this.linked_image==1 && this.image_clicked==1) { 85 if (this.image_parent_opened_only==0) if (this.$image_parent.attr('rel')=='') { 86 if (!this.$item.data('showed')) this.parent_this.overlayHide(); 87 this.$parent.data('in_trans', 0); 88 this.image_clicked=0; 89 return; 90 } 91 if (this.image_parent_opened_only==1) skip_prevent=1; 92 } 93 94 if (this.link_square==1 && (this.image_parent_opened_only==0 || (this.image_parent_opened_only==1 && this.$item.data('showed') ) ) ) { 95 if (!this.$item.data('showed')) this.parent_this.overlayHide(); 96 this.$parent.data('in_trans', 0); 97 this.image_clicked=0; 98 window.location=this.image_parent_href2; 99 return; 100 } 101 if (this.dont_open==1) { 102 if (!this.$item.data('showed')) this.parent_this.overlayHide(); 103 this.$parent.data('in_trans', 0); 104 this.image_clicked=0; 105 return; 106 } 107 108 if (skip_prevent==0) e.preventDefault(); 109 110 if (!this.$parent.data('in_trans')) 111 { 112 if (!this.$item.data('showed')) 113 { 114 if (this.options.grayscale) this.$image2.hide(); 115 this.$parent.data('in_trans', 1); 116 this.$item.data('showed', 1); 117 if (this.options.before_item_opening_callback) this.options.before_item_opening_callback(this.$item); 118 var item_position = this.$item.position(); 119 var trigger_text_position; 120 var this_backup=this; 121 var moving=0; 122 var going_to2=0; 123 if (item_position.top>0) // && this.$parent.width()>=640) 124 { 125 var parent_position=this.$parent.offset(); 126 var parent_top = parent_position.top; 127 var non_visible_area=$(window).scrollTop()-parent_top; 128 var going_to=item_position.top; 129 if (non_visible_area>0) 130 { 131 var non_visible_row=Math.floor(non_visible_area/this.$item.height())+1; 132 going_to=this.$item.height()*non_visible_row; 133 going_to=item_position.top-going_to; 134 } 135 if (going_to>0) moving=1; 136 going_to2=going_to; 137 138 if (this.dont_move==1) { 139 moving=0; 140 going_to=0; 141 going_to2=0; 142 } 143 144 if (moving) 145 { 146 this.$item.data('moved', going_to); 147 var top_string='-'+going_to+'px'; 148 var speed=this.options.opening_speed+(going_to/160)*100; 149 this.$item.animate({top: top_string}, speed, this.options.easing, function(){ 150 trigger_text_position = this_backup.$item.height() - this_backup.$trigger_text.height(); 151 this_backup.$trigger_text.data('top', trigger_text_position); 152 this_backup.$trigger_text.css('top', trigger_text_position); 153 this_backup.$trigger_text.css('bottom', 'auto'); 154 this_backup.$trigger_text.animate({'top': 0}, 'slow'); 155 }); 156 } 157 } 158 if (!moving) 159 { 160 trigger_text_position = this_backup.$item.height() - this_backup.$trigger_text.height(); 161 this_backup.$trigger_text.data('top', trigger_text_position); 162 this_backup.$trigger_text.css('top', trigger_text_position); 163 this_backup.$trigger_text.css('bottom', 'auto'); 164 this_backup.$trigger_text.animate({'top': 0}, 'slow'); 165 } 166 this.$item.addClass('usquare_block_selected'); 167 var height_backup=this.$info.css('height'); 168 var height_backup2=parseInt(height_backup); 169 this.$info.css('height', 0); 170 this.$info.show(); 171 172 if (this.options.push_content_below) { 173 var visina; 174 if (moving) visina=item_position.top-going_to2; 175 else visina=this_backup.$item.position().top; 176 var item_height=this_backup.$item.height()+height_backup2; 177 /* console.log('moving = '+moving); 178 console.log('going_to2 = '+going_to2); 179 console.log('visina = '+visina); 180 console.log('height_backup = '+height_backup2); 181 console.log('item_height = '+item_height); 182 console.log('widget_height = '+this_backup.widget_height);
183 console.log('new_weight = '+new_weight); 184 */ 185 //if (this_backup.widget_height==0) 186 this_backup.widget_height = this_backup.$parent.height(); 187 //alert(this_backup.$parent.height()); 188 189 var new_weight=visina+item_height; 190 if (this_backup.widget_height<new_weight) { 191 this_backup.pushed=1; 192 this_backup.$parent.height(this_backup.widget_height); 193 //alert(this_backup.widget_height); 194 this_backup.$parent.animate({'height': new_weight+'px'}, this.options.opening_speed, this.options.easing); 195 } 196 } 197 //this.$usquare_about.tinyscrollbar(); 198 if (typeof this_backup.open_counter == 'undefined') this_backup.open_counter=0; 199 this_backup.open_counter++; 200 if (this_backup.open_counter==1) this_backup.$usquare_about.tinyscrollbar(); 201 else this_backup.$usquare_about.tinyscrollbar_update(); 202 203 if (this.options.before_info_rolling_callback) this.options.before_info_rolling_callback(this.$item); 204 this.$info.animate({height:height_backup}, this.options.opening_speed, this.options.easing, function() 205 { 206 this_backup.$parent.data('in_trans', 0); 207 this_backup.$info.css('height', ''); 208 if (this_backup.options.after_info_rolling_callback) this_backup.options.after_info_rolling_callback(this_backup.$item); 209 210 if (this_backup.linked_image==1 && this_backup.image_parent_opened_only==1) { 211 this_backup.$image_parent.attr('href', this_backup.image_parent_href); 212 this_backup.$image_parent.attr('rel', this_backup.image_parent_rel); 213 this_backup.$image_parent.attr('target', this_backup.image_parent_target); 214 } 215 }); 216 } 217 } 218 }, 219/* close2: function(e) { 220 this.skip_image2_show=1; 221 this.skip_image2_show2=1; 222 this.close(e); 223 },*/ 224 close: function(e) { 225 e.preventDefault(); 226 this.image_clicked=0; 227 228 if (!this.$parent.data('in_trans')) 229 { 230 if (this.$item.data('showed')) 231 { 232 //if (this.skip_image2_show==0) { 233 if (this.options.grayscale) this.$image2.show(); 234 //} 235 //else this.skip_image2_show=0; 236 var this_backup=this; 237 if (this_backup.linked_image==1 && this_backup.image_parent_opened_only==1) { 238 this_backup.$image_parent.removeAttr('href'); 239 this_backup.$image_parent.removeAttr('rel'); 240 this_backup.$image_parent.removeAttr('target'); 241 } 242 if (this.pushed) { 243 var speed2; 244 if (this.$item.data('moved')) 245 { 246 var top_backup2=this.$item.data('moved'); 247 speed2=this.options.closing_speed+(top_backup2/160)*100; 248 } else 249 { 250 speed2='slow'; 251 } 252 this.$parent.animate({'height': this.widget_height+'px'}, speed2, this.options.easing, function(){ 253 this_backup.$parent.removeAttr('style'); 254 //this_backup.$parent.removeAttr('height'); 255 }); 256 } 257 this.$info.hide(); 258 var trigger_text_position_top = this_backup.$item.height() - this_backup.$trigger_text.height()-3; 259 this_backup.$item.removeClass('usquare_block_selected'); 260 if (this.$item.data('moved')) 261 { 262 var top_backup=this.$item.data('moved'); 263 var speed=this.options.closing_speed+(top_backup/160)*100; 264 this.$item.data('moved', 0); 265 this.$item.animate({'top': 0}, speed, this.options.easing, function() 266 { 267 this_backup.$trigger_text.animate({'top': trigger_text_position_top}, 'slow'); 268 }); 269 } 270 else 271 { 272 this_backup.$trigger_text.animate({'top': trigger_text_position_top}, 'slow'); 273 } 274 this.$item.data('showed', 0); 275 } 276 } 277 }, 278 $: function (selector) { 279 return this.$item.find(selector); 280 } 281 }; 282 283 function uSquare(element, options) { 284 var self = this; 285 this.options = $.extend({}, $.fn.uSquare.defaults, options); 286 this.$element = $(element); 287 this.$overlay = this.$('.usquare_module_shade'); 288 this.$items = this.$(this.options.block); 289 this.$triggers = this.$(this.options.trigger); 290 this.$closes = this.$('.close'); 291 292 this.$triggers.click($.proxy(this.overlayShow, this)); 293 this.$closes.click ($.proxy(this.overlayHide, this)); 294 this.$overlay.click($.proxy(this.overlayHide, this)); 295 296 $.each( this.$items, function(i, element) { 297 new uSquareItem(element, $.extend(self.options, {$overlay: self.$overlay, $parent: self.$element, parent_this: self }) ); 298 }); 299 }; 300 301 uSquare.prototype = { 302 $: function (selector) { 303 return this.$element.find(selector); 304 }, 305 overlayShow: function() { 306 this.$overlay.fadeIn('slow', function(){ 307 $(this).css({opacity : 0.5}); 308 }) 309 }, 310 overlayHide: function() { 311 if (!this.$element.data('in_trans')) 312 { 313 this.$overlay.fadeOut('slow'); 314 } 315 } 316 }; 317 318 $.fn.uSquare = function ( option ) { 319 return this.each(function () { 320 var $this = $(this), 321 data = $this.data('tooltip'), 322 options = typeof option == 'object' && option; 323 324 data || $this.data('tooltip', (data = new uSquare(this, options))); 325 (typeof option == 'string') && data[option](); 326 }); 327 }; 328 329 $.fn.uSquare.Constructor = uSquare; 330 $.fn.uSquare.defaults = { 331 block: '.usquare_block', 332 trigger: '.usquare_square', 333 moreInfo: '.usquare_block_extended', 334 opening_speed: 300, 335 closing_speed: 500, 336 easing: 'swing', 337 grayscale: 1, 338 before_item_opening_callback: null, 339 before_info_rolling_callback: null, 340 after_info_rolling_callback: null, 341 push_content_below: 0 342 }; 343 344})(jQuery);
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.