1/* ========================================================= 2 * vc_grid.js v1.0 3 * ========================================================= 4 * Copyright 2014 Wpbakery 5 * 6 * Vc Grid 7 * ========================================================= */ 8var VcGrid, vcGridSettings = { 9 addItemsAnimation: 'zoomIn', 10 mobileWindowWidth: 768, 11 itemAnimationSpeed: 1000, 12 itemAnimationDelay: [], 13 clearAnimationDelays: function () { 14 _.each( this.itemAnimationDelay, function ( id ) { 15 window.clearTimeout( id ); 16 } ); 17 this.itemAnimationDelay = []; 18 } 19}; 20(function ( $ ) { 21 'use strict'; 22 VcGrid = function ( el ) { 23 this.$el = $( el ); 24 this.settings = {}; 25 this.$filter = false; 26 this.gridBuilder = false; 27 this.init(); 28 }; 29 /** 30 * Initialize 31 */ 32 VcGrid.prototype.init = function () { 33 _.bindAll( 34 this, 35 'filterItems', 36 'filterItemsDropdown' 37 ); 38 this.setSettings(); 39 this.initStyle(); 40 // this.initFilter(); 41 this.initHover(); 42 this.initZoneLink(); 43 }; 44 VcGrid.prototype.setSettings = function () { 45 this.settings = $.extend( { 46 visible_pages: 5 47 }, this.$el.data( 'vcGridSettings' ) || {} ); // Setttings with grid settings for layout. 48 }; 49 /** 50 * Init style object to interact with content of grid. 51 */ 52 VcGrid.prototype.initStyle = function () { 53 var styleObject = this.settings.style ? $.camelCase( 'vc-grid-style-' + this.settings.style ) : false; 54 if ( styleObject && ! _.isUndefined( window[ styleObject ] ) && window[ styleObject ].prototype.render ) { 55 this.gridBuilder = new window[ styleObject ]( this ); 56 this.gridBuilder.render(); 57 } 58 }; 59 /** 60 * Build filters with a stack of the style grid object. 61 */ 62 VcGrid.prototype.initFilter = function () { 63 this.$filter = this.$el.find( '[data-vc-grid-filter]' ); 64 this.$filterDropdown = this.$el.find( '[data-vc-grid-filter-select]' ); 65 this.$filter.length && this.$filter 66 .find( '.vc_grid-filter-item' ) 67 .unbind( 'click' ) 68 .click( this.filterItems ); 69 this.$filterDropdown.length && this.$filterDropdown 70 .unbind( 'change' ) 71 .change( this.filterItemsDropdown ); 72 }; 73 /** 74 * Set hover css class for animation. 75 * 76 */ 77 VcGrid.prototype.initHover = function () { 78 this.$el 79 .on( 'mouseover', '.vc_grid-item-mini', function () { 80 var $this = $( this ); 81 $this.addClass( 'vc_is-hover' ); 82 /* 83 $this.find('[data-vc-animation]').each(function(){ 84 var animation = $(this).data('vcAnimation'), 85 animationObject = 'VcGridAnimation' + animation; 86 window[animationObject] && window[animationObject](this, 'in'); 87 }); 88 */ 89 } ).on( 'mouseleave', '.vc_grid-item-mini', function () { 90 var $this = $( this ); 91 $this.removeClass( 'vc_is-hover' ); 92 /* 93 $this.find('[data-vc-animation]').each(function(){ 94 var animation = $(this).data('vcAnimation'), 95 animationObject = 'VcGridAnimation' + animation; 96 window[animationObject] && window[animationObject](this, 'out'); 97 }); 98 */ 99 } ); 100 }; 101 VcGrid.prototype.initZoneLink = function () { 102 if ( window.vc_iframe ) { 103 this.$el.on( 'click.zonePostLink', '[data-vc-link]', function () { 104 var $this = $( this ), 105 href = $( this ).data( 'vcLink' ); 106 window.open( href ); 107 } ); 108 this.$el.on( 'click', '.vc_gitem-link', function ( e ) { 109 var $this = $( this ); 110 e.preventDefault(); 111 ! $this.hasClass( 'vc-gitem-link-ajax' ) && window.open( $this.attr( 'href' ) ); 112 } ); 113 } else { 114 this.$el.on( 'click.zonePostLink', '[data-vc-link]', function () { 115 var $this = $( this ), 116 href = $( this ).data( 'vcLink' ); 117 if ( '_blank' === $this.data( 'vcTarget' ) ) { 118 window.open( href ); 119 } else { 120 window.location.href = href; 121 } 122 } ); 123 } 124 }; 125 VcGrid.prototype.initHover_old = function () { 126 this.$el 127 .on( 'mouseover', '.vc_grid-item', function () { 128 var $this = $( this ); 129 if ( $this.hasClass( 'vc_is-hover' ) ) { 130 return; 131 } 132 vcGridSettings.clearAnimationDelays(); 133 $this.addClass( 'vc_is-hover vc_is-animated' ); 134 $this.find( '.vc_grid-item-row-animate' ).each( function () { 135 var $animate = $( this ), 136 animationIn = $animate.data( 'animationIn' ), 137 animationOut = $animate.data( 'animationOut' ); 138 $animate.removeClass( animationOut ).addClass( animationIn ); 139 vcGridSettings.itemAnimationDelay.push( _.delay( function () { 140 $animate.removeClass( animationIn ); 141 $this.removeClass( 'vc_is-animated' ); 142 }, vcGridSettings.itemAnimationSpeed ) ); 143 } ); 144 } ).on( 'mouseleave', '.vc_grid-item', function () { 145 var $this = $( this ); 146 vcGridSettings.clearAnimationDelays(); 147 $this.addClass( 'vc_is-animated' ).removeClass( 'vc_is-hover' ); 148 $this.find( '.vc_grid-item-row-animate' ).each( function () { 149 var $animate = $this.find( '.vc_grid-item-row-animate' ), 150 animationOut = $animate.data( 'animationOut' ), 151 animationIn = $animate.data( 'animationIn' ); 152 $animate.addClass( animationOut ); 153 vcGridSettings.itemAnimationDelay.push( _.delay( function () { 154 $animate.removeClass( animationOut + ' ' + animationIn ); 155 $this.removeClass( 'vc_is-animated' ); 156 }, vcGridSettings.itemAnimationSpeed - 1 ) ); 157 } ); 158 } ); 159 }; 160 /** 161 * Filter items in the grid. Called as a result of manipulations with filter UI components. 162 * @param e 163 * @return {Boolean} 164 */ 165 VcGrid.prototype.filterItems = function ( e ) { 166 var filter_method = this.style ? $.camelCase( 'filter-' + this.style ) : 'filterAll', 167 $control = $( e.currentTarget ).find( '[data-vc-grid-filter-value]' ), 168 filter = $control.data( 'vcGridFilterValue' ); 169 e && e.preventDefault(); 170 if ( $control.hasClass( 'vc_active' ) ) { 171 return false;
172 } 173 this.$filter.find( '.vc_active' ).removeClass( 'vc_active' ); 174 this.$filterDropdown.find( '.vc_active' ).removeClass( 'vc_active' ); 175 this.$filterDropdown.find( '[value="' + filter + '"]' ).addClass( 'vc_active' ).attr( 'selected', 'selected' ); 176 $control.parent().addClass( 'vc_active' ); 177 this.gridBuilder.filter( filter ); 178 }; 179 /** 180 * Filter items in the grid. Called as a result of manipulations with filter UI components. 181 * @param e 182 * @return {Boolean} 183 */ 184 VcGrid.prototype.filterItemsDropdown = function ( e ) { 185 var $control = this.$filterDropdown.find( ':selected' ), 186 filter = $control.val(); 187 if ( $control.hasClass( 'vc_active' ) ) { 188 return false; 189 } 190 this.$filterDropdown.find( '.vc_active' ).removeClass( 'vc_active' ); 191 this.$filter.find( '.vc_active' ).removeClass( 'vc_active' ); 192 this.$filter.find( '[data-vc-grid-filter-value="' + filter + '"]' ).parent().addClass( 'vc_active' ); 193 194 $control.addClass( 'vc_active' ); 195 this.gridBuilder.filter( filter ); 196 }; 197 /** 198 * Ajax request to load into Grid. 199 * 200 * @param data 201 * @param callback 202 */ 203 VcGrid.prototype.ajax = function ( data, callback ) { 204 var requestData; 205 if ( _.isUndefined( data ) ) { 206 data = {}; 207 } 208 requestData = _.extend( { 209 action: 'vc_get_vc_grid_data', 210 vc_action: 'vc_get_vc_grid_data', 211 tag: this.settings.tag, 212 data: this.settings, 213 vc_post_id: this.$el.data( 'vcPostId' ) 214 }, data ); 215 216 $.ajax( { 217 type: 'POST', 218 dataType: 'html', 219 url: this.$el.data( 'vcRequest' ), 220 data: requestData 221 } ).done( callback ); 222 }; 223 // PLUGIN DEFINITION 224 // ===================== 225 function Plugin( option ) { 226 return this.each( function () { 227 var $this = $( this ); 228 var data = $this.data( 'vcGrid' ); 229 if ( ! data ) { 230 $this.data( 'vcGrid', (data = new VcGrid( this )) ); 231 } 232 if ( typeof option == 'string' ) { 233 data[ option ](); 234 } 235 } ); 236 } 237 238 $.fn.vcGrid = Plugin; 239 $.fn.vcGrid.Constructor = VcGrid; 240 $( document ).ready( function () { 241 $( '[data-vc-grid-settings]' ).vcGrid(); 242 } ); 243})( window.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.