/* ========================================================= * vc_grid_style_pagination.js v1.0 * ========================================================= * Copyright 2014 Wpbakery * * Basic Grid Style pagination * ========================================================= */ var vcGridStylePagination = null; (function ( $ ) { /** * "Paginator" grid style. * ============================== * * @param grid * @constructor */ vcGridStylePagination = function ( grid ) { this.grid = grid; this.settings = grid.settings; this.$el = false; this.$content = false; this.filterValue = null; this.isLoading = false; this.htmlCache = false; this.$loader = $( '
' ); this.$firstSlideItems; //todo check this? Expression statement is not assignment or call (at line 27) this.init(); }; /** * Initialize */ vcGridStylePagination.prototype.init = function () { _.bindAll( this, 'addItems', 'initCarousel' ); }; vcGridStylePagination.prototype.setIsLoading = function () { this.$loader.show(); this.isLoading = true; }; vcGridStylePagination.prototype.unsetIsLoading = function () { this.isLoading = false; this.$loader.hide(); }; /** * Build required content and data. */ vcGridStylePagination.prototype.render = function () { this.$el = this.grid.$el; this.$content = this.$el; this.$content.append( this.$loader ); this.setIsLoading(); this.grid.ajax( {}, this.addItems ); }; /** * Filter function called by grid object ot filter content. * * @param filter - string parameter with filter settings. */ vcGridStylePagination.prototype.filter = function ( filter ) { filter = _.isUndefined( filter ) || filter === '*' ? '' : filter; if ( this.filterValue == filter ) { return false; // already filtred } var $html; if ( this.$content.data( 'owl.vccarousel' ) ) { this.$content.off( 'initialized.owl.vccarousel' ); this.$content.off( 'changed.owl.vccarousel' ); this.$content.data( 'vcPagination' ) && this.$content.data( 'vcPagination' ).twbsPagination( 'destroy' ); this.$content.data( 'owl.vccarousel' ).destroy(); } this.$content.html( '' ); $html = $( '.vc_grid-item', this.htmlCache ); if ( filter !== '' ) { $html = $html.filter( filter ); } this.filterValue = filter; this.buildSlides( $html.addClass( 'vc_visible-item' ) ); // ( vcGridSettings.addItemsAnimation != 'none' ? vcGridSettings.addItemsAnimation + ' animated' : '') ) ); }; /** * Create slides from list of elements for grid. * * @param $html */ vcGridStylePagination.prototype.buildSlides = function ( $html ) { var i, j, tempArray, chunk = parseInt( this.settings.items_per_page ); //this.settings.total_items = $html.length; for ( i = 0, j = $html.length; i < j; i += chunk ) { tempArray = $html.slice( i, i + chunk ); $( '