Cube Portfolio

About

Cube Portfolio is a jQuery grid plugin that provides powerful portfolio system, beautiful animated filtering, searching, custom captions and it’s perfect for portfolio projects, horizontal slider, images gallery, team members, blog posts or any other ordered grid content.

It plays nice with your existing HTML and CSS, making it a great choice for dynamic and responsive layouts.

How to install

1. Upload cubeportfolio folder to your server. This folder contains all of the assets of the plugin.

2. Include the following files in your <head> section of the page. Please ensure that all of them have the correct path:

<!-- load cubeportfolio css file -->
<link rel="stylesheet" href="cubeportfolio/css/cubeportfolio.min.css">

<!-- load latest jquery from google resources-->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

<!-- load cubeportfolio jQuery plugin -->
<script type="text/javascript" src="cubeportfolio/js/jquery.cubeportfolio.min.js"></script>

Be aware that Cube Portfolio plugin requires jQuery 1.8+. If you already have jQuery on your page, don’t include it second time.


3. Insert the HTML structure below to the <body> section to build the markup (don't forget to update images path!).

For more complex structures please check the templates folder.

<div id="grid-container">
    <div class="cbp-item">
        <a href="#" title="custom title 1">
            <img src="path/to/img1" alt="custom alt 1" width="100%">
        </a>
    </div>
    <div class="cbp-item">
        <a href="#" title="custom title 2">
            <img src="path/to/img2" alt="custom alt 2" width="100%">
        </a>
    </div>
    <div class="cbp-item">
        <a href="#" title="custom title 3">
            <img src="path/to/img3" alt="custom alt 3" width="100%">
        </a>
    </div>
</div>

4. Initialize the Cube Portfolio plugin. Usually just before the closing body tag: For more info about options go to Options section.

<script type="text/javascript">
jQuery(document).ready( function() {
     jQuery('#grid-container').cubeportfolio({
        // options
     });
});
</script>

As an alternative initialization, the options can be placed as a JSON object in the HTML data attributes for grid container:

<div id="grid-container" data-cbp-options='{"rewindNav": false}'>
    <div class="cbp-item">
        <a href="#" title="custom title 1">
            <img src="path/to/img1" alt="custom alt 1" width="100%">
        </a>
    </div>
</div>

Options

There are numerous options that can be added to configure Cube Portfolio behavior. To set an option, you must add it to the initialization block of code.

<script type="text/javascript">
jQuery('#grid-container').cubeportfolio({
    // place here the options. Don't forget to separate them by comma
});
</script>

Full list of options

Name Values Default Description
filters string that represent the elements in the document (DOM selector) '' Define the wrapper for filters
loadMore - - This options is deprecated. Please use plugins.loadMore.element option instead
loadMoreAction - - This options is deprecated. Please use plugins.loadMore.action option instead
search string that represent the elements in the document (DOM selector) '' Define the search input element
layoutMode 'grid', 'mosaic' or 'slider' 'grid' Layout Mode for this plugin
sortByDimension true or false false Filter the items by dimension (bigger to smallest) if there are gaps in grid. Option available only for `layoutMode: 'mosaic'`
drag true or false true Mouse and touch drag support. Option available only for `layoutMode: 'slider'`
auto true or false false Autoplay the slider. Option available only for `layoutMode: 'slider'`
autoTimeout only integers (ex: 1000, 2000, 5000) 5000 Autoplay interval timeout. Time is set in milliseconds. 1000 milliseconds equals 1 second. Option available only for `layoutMode: 'slider'`
autoPauseOnHover true or false true Stops autoplay when user hover the slider. Option available only for `layoutMode: 'slider'`
showNavigation true or false true Show `next` and `prev` buttons for slider. Option available only for `layoutMode: 'slider'`
showPagination true or false true Show pagination for slider. Option available only for `layoutMode: 'slider'`
rewindNav true or false true Enable slide to first item (last item). Option available only for `layoutMode: 'slider'`
scrollByPage true or false true Scroll by page and not by item. This option affect next/prev buttons and drag support. Option available only for `layoutMode: 'slider'`
defaultFilter strings that represent the filter name(e.g. '*', '.logo', '.web-design', '.design') '*' Default filter for plugin. Option available only for `layoutMode: 'grid'`
filterDeeplinking true or false false Enable / disable the deeplinking feature when you click on filters. Option available only for `layoutMode: 'grid'`
animationType 'fadeOut'
'quicksand'
'bounceLeft'
'bounceTop'
'bounceBottom'
'moveLeft'
'slideLeft'
'fadeOutTop'
'sequentially'
'skew'
'slideDelay'
'3d' Flip
'rotateSides'
'flipOutDelay'
'flipOut'
'unfold'
'foldLeft'
'scaleDown'
'scaleSides'
'frontRow'
'flipBottom'
'rotateRoom'
'fadeOut' Defines which animation to use for items that will be shown or hidden after a filter has been activated. The plugin uses the best browser features available (CSS3 transitions and transform, GPU acceleration) Option available only for `layoutMode: 'grid'`
gridAdjustment 'default'
'alignCenter'
'responsive'
'responsive' Adjust the layout grid.
- default (no adjustment applied)
- alignCenter (align the grid on center of the page)
- responsive (use a fluid grid to resize the grid)
mediaQueries - array of objects of format: [{width: a, cols: d}, {width: b, cols: e}]
- you can define as many objects as you want
- if this option is `false` Cube Portfolio will adjust the items width automatically (default option for backward compatibility)
false Define `media queries` for columns layout.
Format: [{width: a, cols: d}, {width: b, cols: e}, {width: c, cols: f}], where a, b, c are the grid width and d, e, f are the columns displayed. e.g. [{width: 1440, cols: 5}, {width: 1024, cols: 4}, {width: 768, cols: 3}, {width: 480, cols: 2}, {width: 320, cols: 1}] means:
if (gridWidth >= 1440) => show 5 columns,
if (gridWidth >= 1024 && gridWidth < 1440) => show 4 columns,
if (gridWidth >= 768 && gridWidth < 1024) => show 3 columns,
if (gridWidth >= 480 && gridWidth < 768) => show 2 columns,
if (gridWidth >= 320 && gridWidth < 480) => show 1 columns,
if (gridWidth < 320) => show 1 columns
Keep in mind that a > b > c
This option is available only when `gridAdjustment: 'responsive'`
gapHorizontal only integers (e.g. 1, 5, 10) 10 Horizontal gap between items
gapVertical only integers (e.g. 1, 5, 10) 10 Vertical gap between items
caption 'pushTop'
'pushDown'
'revealBottom'
'revealTop'
'revealLeft'
'moveRight'
'overlayBottom'
'overlayBottomPush'
'overlayBottomReveal'
'overlayBottomAlong'
'overlayRightAlong'
'minimal'
'fadeIn'
'zoom'
'opacity'
'pushTop' Caption - the overlay that is shown when you put the mouse over an item.
NOTE: If you don't want to have captions set this option to an empty string (e.g. caption: '')
displayType 'default'
'bottomToTop'
'fadeIn'
'fadeInToTop'
'sequentially'
'fadeIn' The plugin will display his content based on the following values.
- default (the content will be displayed without any animation)
- fadeIn (e.g. lazyLoading) (the plugin will fully preload the images before displaying the items with a fadeIn effect)
- fadeInToTop - fadeInToTop (the plugin will fully preload the images before displaying the items with a fadeIn effect from bottom to top)
- sequentially (the plugin will fully preload the images before displaying the items with a sequentially effect)
- bottomToTop (the plugin will fully preload the images before displaying the items with an animation from bottom to top)
displayTypeSpeed only integers, values in ms (e.g. 200, 300, 500) 400 Defines the speed of displaying the items (when displayType: 'default' this option will have no effect)
lightboxDelegate strings that represent the elements in the document (DOM selector) '.cbp-lightbox' Define any clickable elements you wish to use to trigger lightbox popup on click.
lightboxGallery true or false true Enable / disable gallery mode for lightbox popup
lightboxTitleSrc HTML atributte 'data-title' Attribute of the delegate item that contains caption for lightbox
lightboxShowCounter - - This options is deprecated. Please use lightboxCounter option instead
lightboxCounter HTML markup code '<div class="cbp-popup-lightbox-counter">{{current}} of {{total}}</div>' Markup of the lightbox counter. To hide the counter for lightbox put this option to an empty string (e.g. '')
singlePageDelegate strings that represent the elements in the document (DOM selector) '.cbp-singlePage' Define any clickable elements you wish to use to trigger singlePage popup on click.
singlePageDeeplinking true or false true Enable / disable the deeplinking feature for singlePage popup
singlePageStickyNavigation true or false true Enable / disable the sticky navigation for singlePage popup
singlePageShowCounter - - This options is deprecated. Please use singlePageCounter option instead
singlePageCounter HTML markup code '<div class="cbp-popup-singlePage-counter">{{current}} of {{total}}</div>' Markup of the singlePage counter. To hide the counter for singlePage put this option to an empty string (e.g. '')
singlePageAnimation 'left'
'fade'
'right'
'left' Defines which animation to use when singlePage appear
singlePageCallback function(url, element) {
// to update singlePage content use the following method: this.updateSinglePage(yourContent)
}
null Use this callback to update singlePage content. The callback will trigger after the singlePage popup is open. (@param url = the href attribute of the item clicked, @param element = the item clicked)
singlePageInlineDeeplinking true or false false Enable / disable the deeplinking feature for singlePageInline
singlePageInlineDelegate strings that represent the elements in the document (DOM selector) '.cbp-singlePageInline' Define any clickable elements you wish to use to trigger singlePageInline popup on click.
singlePageInlinePosition 'above'
'below'
'top'
'bottom'
'top' Define the position of singlePage Inline block
singlePageInlineInFocus true or false true Push the open panel in focus and at close go back to the former stage
singlePageInlineCallback function(url, element) {
// to update singlePage Inline content use the following method: this.updateSinglePageInline(yourContent)
}
null Use this callback to update singlePage content. The callback will trigger after the singlePage popup is open. (@param url = the href attribute of the item clicked, @param element = the item clicked)
plugins.loadMore.element string that represent the elements in the document (DOM selector) '' Define the wrapper for loadMore
plugins.loadMore.action 'click' or 'auto' 'click' How the loadMore functionality should behave. Load on click on the button or automatically when you scroll the page
plugins.loadMore.loadItems only integers (e.g. 2, 3, 10) 3 How many items to load when you click on the loadMore button

Filters

Based on your filters Cube Portfolio use jQuery to decide which items to hide, show or re-position. Then applies CSS3 transition and transform to smoothly animate these items to their new locations. The plugin use the best browser features available (CSS3 transition and transform, GPU acceleration).

Filtering happens when public API method filter is triggered. This method (filter) can be trigger from anywhere, so you can use any kind of HTML structure for filters: buttons, links, dropdowns, etc.

The following example use some simple buttons to filter the plugin. For dropdown structure please check templates/03-lightbox-gallery/ folder.

1. Create the HTML markup:

<div id="filters-container">
    <!-- '*' means shows all item elements -->
    <div data-filter="*" class="cbp-filter-item cbp-filter-item-active">All</div>
    <div data-filter=".animation" class="cbp-filter-item">Animation</div>
    <div data-filter=".artwork" class="cbp-filter-item">Artwork</div>
    <div data-filter=".illustration" class="cbp-filter-item">Illustration</div>
    <div data-filter=".photography" class="cbp-filter-item">Photography</div>
</div>

Every filter categories should be entered as the "data-filter" attribute.

2. Add filter categories to desired target item into its class attribute:

<div id="grid-container">
    <div class="cbp-item animation illustration">
        <a title="custom title 1" href="#"><img src="path/to/img1" alt="custom alt 1" width="100%"></a>
    </div>
    <div class="cbp-item artwork">
        <a title="custom title 2" href="#"><img src="path/to/img2" alt="custom alt 2" width="100%"></a>
    </div>
    <div class="cbp-item animation artwork photography">
        <a title="custom title 3" href="#"><img src="path/to/img3" alt="custom alt 3" width="100%"></a>
    </div>
</div>

3. When you initialize the plugin you must specify the selector to filters container

<script type="text/javascript">
jQuery('#grid-container').cubeportfolio({
    filters: '#filters-container', // you can even add multiple filters here (e.g. `filters: '#filters-container1, #filters-container2, #filters-container3'`)
});
</script>

4. If you want to show counter for filters you must update your filters html by adding .cbp-filter-counter inside every .cbp-filter-item element.

<div id="filters-container">
    <div data-filter="*" class="cbp-filter-item cbp-filter-item-active">
        All <div class="cbp-filter-counter"></div>
    </div>
    <div data-filter=".animation" class="cbp-filter-item">
        Animation <div class="cbp-filter-counter"></div>
    </div>
    <div data-filter=".artwork" class="cbp-filter-item">
        Artwork <div class="cbp-filter-counter"></div>
    </div>
    <div data-filter=".illustration" class="cbp-filter-item">
        Illustration <div class="cbp-filter-counter"></div>
    </div>
    <div data-filter=".photography" class="cbp-filter-item">
        Photography <div class="cbp-filter-counter"></div>
    </div>
</div>

You can enable a default filter right from the URL. When you visit the page that has Cube Portfolio implemented on it and want to enable the filter Print you can append to url the string #cbpf=.print and the `Print` filter will be active.

Search

You can add search functionality in the current grid layout so you can find items quickly (please check Blog Posts template for a working version). First, add this snippet in your HTML:

<div class="cbp-search">
    <!-- data-search attribute is used to target the searching with a jQuery selector. For full search set data-search="*" -->
    <input id="js-search-blog-posts" type="text" placeholder="Search by title" data-search=".cbp-l-grid-blog-title" class="cbp-search-input">
    <div class="cbp-search-icon"></div>
</div>

To connect the plugin with the HTML snippet you must set the option search: '#js-search-blog-posts' when initialize the plugin.

Sort

Cube Portfolio can change the order of item elements based on their text content.

1. Define the data used for sorting in your HTML

<div id="js-sort" class="cbp-l-sort">
    <div class="cbp-l-dropdown">
        <div class="cbp-l-dropdown-wrap">
            <div class="cbp-l-dropdown-header">Original sorting</div>
            <div class="cbp-l-dropdown-list">
                <div class="cbp-l-dropdown-item cbp-sort-item cbp-l-dropdown-item--active" data-sort="">Original sorting</div>
                <div class="cbp-l-dropdown-item cbp-sort-item" data-sort=".cbp-l-grid-projects-title">Title</div>
                <div class="cbp-l-dropdown-item cbp-sort-item" data-sort=".cbp-l-grid-projects-desc">Description</div>
            </div>
        </div>
    </div>
    <div class="cbp-l-direction cbp-l-direction--second">
        <div class="cbp-l-direction-item cbp-sort-item" data-sortBy="string:asc"></div>
        <div class="cbp-l-direction-item cbp-sort-item" data-sortBy="string:desc"></div>
    </div>
</div>

The data-sort attribute is a selector used to retrieve the data from the grid. For the above example, Cube Portfolio gets for every item the text content of .cbp-l-grid-projects-title selector. That text will be used as a sorting data.

The data-sortBy attribute is used to define how the sorting data is processed.


2. Connect the sorting wrapper (#js-sort for the above example) to cube portfolio initialization options:

<script type="text/javascript">
jQuery('#grid-container').cubeportfolio({
    plugins: {
        sort: {
            element: '#js-sort',
        },
    },
});
</script>

Lazy Load

Because Cube Portfolio must know the dimensions of his items before creating the grid you have three approaches on how to load the images:

1. Load all images before displaying the grid.

Images HTML markup:
<img src="path/to/your/img">

2. Display the grid as soon as possible. This means that the content will be visible and in time the images will catch up.

Images HTML markup:
<!--  width & height attributes are the original dimensions of the image -->
<img src="path/to/your/img" width="200" height="200">

3. Display the grid as soon as possible with a preload effect for images. This option will load only the images that are visible in the current viewport. As you scroll the page the rest of the images are loaded. I recommend this approach if you use a lot of images.

Images HTML markup:
<!--
Width & height attributes are the original dimensions of the image.
The src attribute is mandatory to have a valid markup HTML. In the below snippet, the image source is set to a 1px gif white color.
The data-cbp-src is used to set the src attribute once the image is loaded.
-->
<img src="data:image/gif;base64,R0lGODlhAQABAPAAAP///////yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" data-cbp-src="path/to/your/img" width="200" height="200">

Lightbox

When an anchor tag (link) is pressed you can choose either to display a cubeportoflio lightbox, open a singlePage popup, or to open a new web page based on the URL of the anchor tag. The lightbox can display images or videos loaded from YouTube, Vimeo, Ted.com or self-hosted videos (use delimiter '|' in href attribute to add the path to other formats for self-hosted videos).

Cube Portfolio use a custom lightbox system that is dependent to the plugin. You can use another lightbox system, but you will not have all of the features included in the Cube Portfolio lightbox. (Please see options section)

To enable lightbox, you must add cbp-lightbox class (or another class that you set in lightboxDelegate options) on the anchor elements that will open the lightbox on click.

Based on the href attribute of the anchor tag the lightbox will open an image or a video.

You can also add sounds from SoundCloud by going on their site, select the share option and click on Embed tab. In there you will find in the input an iframe element, copy the src of the iframe and include it in the .cbp-lightbox href (check the code below of a working example).

Also, Cubeportfolio has support for self-hosted .mp3 audio files. You must add the path your .mp3 file to the href attribute of the lightbox.

For youtube and vimeo videos you can also append custom params to the video link (e.g. &rel=0&autoplay=0&loop=1
Please check youtube and vimeo embedding pages for more info)

<div id="grid-container">
    <div class="cbp-item">
        <!-- data-title attribute will be use to populate lightbox caption -->
        <a class="cbp-lightbox" data-title="custom title 1" href="http://www.youtube.com/watch?v=bpOSxM0rNPM&rel=0&autoplay=0">
            <img src="path/to/img1" alt="custom alt 1" width="100%">
        </a>
    </div>
    <div class="cbp-item">
        <a class="cbp-lightbox" data-title="custom title 2" href="http://vimeo.com/74216460?autoplay=0&loop=1">
            <img src="path/to/img2" alt="custom alt 2" width="100%">
        </a>
    </div>
    <div class="cbp-item">
        <a class="cbp-lightbox" data-title="custom title 3" href="http://www.ted.com/talks/david_epstein_are_athletes_really_getting_faster_better_stronger">
            <img src="path/to/img2" alt="custom alt 3" width="100%">
        </a>
    </div>
    <div class="cbp-item">
        <a class="cbp-lightbox" data-title="custom title 3" href="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/26519543&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true">
            <img src="path/to/img2" alt="custom alt 3" width="100%">
        </a>
    </div>
    <div class="cbp-item">
        <a class="cbp-lightbox" data-title="custom title 4" href="path/to/videos/big_buck_bunny.mp4|path/to/videos/big_buck_bunny.ogg|path/to/videos/big_buck_bunny.webm">
            <img src="path/to/img2" alt="custom alt 4" width="100%">
        </a>
    </div>
    <div class="cbp-item">
        <a class="cbp-lightbox" data-title="custom title 5" href="path/to/big/img">
            <img src="path/to/img3" alt="custom alt 5" width="100%">
        </a>
    </div>
</div>

Use Cube Portfolio lightbox outside of the plugin

To use the lightbox feature add class cbp-lightbox on your link elements.

<a class="cbp-lightbox" data-title="custom title 3" href="path/to/img3">
    external link
</a>

To create a gallery add also the data-cbp-lightbox attribute on those links. The value for data-cbp-lightbox attribute can be whatever you want but must be the same for one gallery.

<a class="cbp-lightbox" data-title="custom title 1" href="path/to/img1" data-cbp-lightbox="myCustomLightbox">
    external link 1
</a>
<a class="cbp-lightbox" data-title="custom title 2" href="path/to/img2" data-cbp-lightbox="myCustomLightbox">
    external link 2
</a>
<a class="cbp-lightbox" data-title="custom title 3" href="path/to/img3" data-cbp-lightbox="myCustomLightbox">
    external link 3
</a>

Single Page

You can open a custom HTML content by using the singlePage feature. Single Page uses a similar approach to lightbox system and you can use any kind of HTML markup as a content.

You have the option to deep link a singlePage based on the href attribute of anchor tag that opened the singlePage. This means that URL automatically change when you switch to another singlePage and you can easily link to the desired singlePage when Cube Portfolio starts. To do that, you have to enable singlePageDeeplinking in options.

To enable singlePage, you must add a cbp-singlePage class (or another class that you set in singlePageDelegate options) on the anchor elements that will open the singlePage on click.

The content that will be add to singlePage with the callback: singlePageCallback

To update content you must use updateSinglePage method and pass your HTML content as a parameter.

<div id="grid-container">
    <div class="cbp-item">
        <a href="myCustomLink1" class="cbp-singlePage">
            open singlePage 1
        </a>
    </div>
    <div class="cbp-item">
        <a href="myCustomLink2" class="cbp-singlePage">
            open singlePage 2
        </a>
    </div>
    <div class="cbp-item">
        <a href="myCustomLink3" class="cbp-singlePage">
            open singlePage 3
        </a>
    </div>
</div>
<script type="text/javascript">
jQuery('#grid-container').cubeportfolio({
    /**
     *  This callback function will be trigger after the singlePage popup will be opened. (@param item = the current item clicked)
     */
    singlePageCallback: function (item) {
        // add content to singlePage
        this.updateSinglePage('<div>My content to append to singlePage container</div>');

    }
});
</script>

Use Cube Portfolio singlePage outside of the plugin

To use singlePage feature add class cbp-singlePage on your link elements.

<a class="cbp-singlePage" href="myCustomLink">
    external singlePage link
</a>

To create a gallery add also the data-cbp-singlePage attribute on those links. The value for data-cbp-singlePage attribute can be whatever you want but must be the same for one gallery.

<a class="cbp-singlePage" href="myCustomLink1" data-cbp-singlePage="myCustomSinglePage">
    external singlePage link 1
</a>
<a class="cbp-singlePage" href="myCustomLink2" data-cbp-singlePage="myCustomSinglePage">
    external singlePage link 2
</a>
<a class="cbp-singlePage" href="myCustomLink3" data-cbp-singlePage="myCustomSinglePage">
    external singlePage link 3
</a>

NoteIf you run the plugin locally you must know that Chrome, Opera and Internet Explorer deny local AJAX (XMLHttpRequest) requests locally. You must use a web server to test singlePage feature. If you are using a web server and still have this issues please send me a link to your live website.

Single Page Inline

You can open a custom HTML content by using the singlePageInline feature. Single Page Inline use a similar approach to singlePage, but his content is added directly to the content of the plugin.

To enable singlePageInline, you must add a cbp-singlePageInline class (or another class that you set in singlePageInlineDelegate options) on the anchor elements that will open the singlePageInline on click.

The content that will be add to singlePageInline with the callback: singlePageInlineCallback

To update content you must use updateSinglePageInline method and pass your HTML content as a parameter.

<div id="grid-container">
    <div class="cbp-item">
        <a href="myCustomLink1" class="cbp-singlePageInline">
            open singlePageInline 1
        </a>
    </div>
    <div class="cbp-item">
        <a href="myCustomLink2" class="cbp-singlePageInline">
            open singlePageInline 2
        </a>
    </div>
    <div class="cbp-item">
        <a href="myCustomLink3" class="cbp-singlePageInline">
            open singlePageInline 3
        </a>
    </div>
</div>
<script type="text/javascript">
jQuery('#grid-container').cubeportfolio({
    /**
     *  This callback function will be trigger after the singlePageInline popup will be opened. (@param item = the current item clicked)
     */
    singlePageInlineCallback: function (item) {
        // add content to singlePageInline
        this.updateSinglePageInline('<div>My content to append to singlePageInline container</div>');

    }
});
</script>

NoteIf you run the plugin locally you must know that Chrome, Opera and Internet Explorer deny local AJAX (XMLHttpRequest) requests locally. You must use a web server to test singlePageInline feature. If you are using a web server and still have this issues please send me a link to your live website.

Captions

Cube Portfolio has predefined captions, but it is very simple to add your own HMTL formatted containers inside the entries with your own CSS. You can create captions from almost any static HTML elements.

There are 11 predefined examples for captions in Cube Portfolio:

To activate a particulary caption set that caption in caption options

<script type="text/javascript">
jQuery('#grid-container').cubeportfolio({
    caption: 'pushTop'
});
</script>

In your HTML markup you must add cbp-caption class to container that wrap your caption. Also, the default state of caption must be wrap in a cbp-caption-defaultWrap container and the active state of caption must be wrap in another cbp-caption-activeWrap container.

<div id="grid-container">
    <div class="cbp-item">
        <div class="cbp-caption">
            <div class="cbp-caption-defaultWrap">
                <img src="path/to/img" alt="" width="100%">
            </div>
            <div class="cbp-caption-activeWrap">
                <h1>Caption that is active on hover</h1>
            </div>
        </div>
    </div>
</div>

Templates

Cube Portfolio comes with 16 starter templates: Juicy Project, Lightbox Gallery, Meet the Team, Full Width, Masonry, Blog Posts, Slider, Awesome Work, Clients, Tabs, Agency, Testimonials. You will find them in the templates folder.

Every component (filters, grid container, and load more) have different skins that are completely independent of the others), so the skins can be combined. To enable a skin add the correspondent class to desire component container. To change the numbers of columns please refer to the Options area for mediaQueries feature.

If you want to control the height of you item you can define the height for every .cbp-item in your CSS:

.cbp-item {
    height: 300px; /* your desire value */
}

API

Cube Portfolio has several public API methods to use for external control. For every callbackFunction this keyword refers to Cube Portfolio instance.

1. Initialize the plugin

// default init
jQuery("#grid-container").cubeportfolio(options);
                    // or
jQuery("#grid-container").cubeportfolio('init', options);

// with callback function
jQuery("#grid-container").cubeportfolio(options, callbackFunction);
                    // or
jQuery("#grid-container").cubeportfolio('init', options, callbackFunction);

2. Destroy the plugin (removes all events, data and markup from page)

jQuery("#grid-container").cubeportfolio('destroy');

// with callback function
jQuery("#grid-container").cubeportfolio('destroy', callbackFunction);

3. Filter the items

// filterDataSelector can be (only if you set .cbp-filter-item on filter selectors): jQuery('.cbp-filter-item').data('filter')
jQuery("#grid-container").cubeportfolio('filter', filterDataSelector);

// with callback function
jQuery("#grid-container").cubeportfolio('filter', filterDataSelector, callbackFunction);

4. Activate counter on filters

// filterSelector can be (only if you set .cbp-filter-item on filter selectors): jQuery('.cbp-filter-item')
jQuery("#grid-container").cubeportfolio('showCounter', filterSelector);

// with callback function
jQuery("#grid-container").cubeportfolio('showCounter', filterSelector, callbackFunction);

5. Append new items to plugin

Append the htmlContent to the grid, filter the new content, then will rearange all item elements to a properly layout.

// htmlContent - your HTML content
jQuery("#grid-container").cubeportfolio('append', htmlContent);

// with callback function
jQuery("#grid-container").cubeportfolio('append', htmlContent, callbackFunction);

A typical htmlContent can look like this:

var htmlContent = '<div class="logo cbp-item">my awesome content to append to plugin</div> <div class="logo cbp-item">my second awesome content to append to plugin</div>';

Note: Don't forget to add class .cbp-item to your div element


6. Prepend new items to plugin

Prepend method works similar with the above append method, the only difference is that the htmlContent is inserted and the start of the grid.

// htmlContent - your HTML content
jQuery("#grid-container").cubeportfolio('prepend', htmlContent);

// with callback function
jQuery("#grid-container").cubeportfolio('prepend', htmlContent, callbackFunction);

7. Remove items from the CubePortfolio instance and DOM

// items - jQuery DOM Object of the items you want to remove
jQuery("#grid-container").cubeportfolio('remove', items);

// with callback function
jQuery("#grid-container").cubeportfolio('remove', items, callbackFunction);

To remove the first item in the grid you can use it like this:

var grid = jQuery("#grid-container");
grid.cubeportfolio('remove', grid.find('.cbp-item').first());

8. Relayout all elements in the current grid. Useful when all/some items need to be laid out again, or grid width is changed.

jQuery("#grid-container").cubeportfolio('layout');

// with callback function
jQuery("#grid-container").cubeportfolio('layout', callbackFunction);

Event Emitter

Cube Portfolio emit some events when certain events happens. You can subscribe to them by using jQuery event syntax:

jQuery("#grid-container").on('updateSinglePageComplete.cbp', function() {
    // your functionality
});
and unsubscrbe to them by ussing .off method
jQuery("#grid-container").off('updateSinglePageComplete.cbp');

The events supported are:

Load More Items

You can use load more feature using public API method append.

// ... after cubeportfolio initialization
// basic load more items using public method `append`
jQuery("#grid-container").cubeportfolio('append', '<div class="logo cbp-item">my awesome content to append to plugin</div> <div class="logo cbp-item">my second awesome content to append to plugin</div>');

For more advanced examples please go to templates/juicy-projects/index.html path and check the HTML and JS markup.

Support

If you have any questions that are beyond the scope of this documentation file, please feel free to email via my user page contact form here.

Change Log

v4.4.0 - 1 August, 2018

v4.3.4 - 16 July, 2018

v4.3.3 - 5 June, 2018

v4.3.2 - 7 April, 2018

v4.3.1 – 15 January, 2018

v4.3.0 - 9 August, 2017

v4.2.0 - 2 June, 2017

v4.1.1 - 20 March, 2017

v4.1.0 - 9 February, 2017

v4.0.0 - 4 January, 2017

v3.9.0 - 9 December, 2016

v3.8.1 - 25 November, 2016

v3.8.0 - 19 September, 2016

v3.7.1 - 28 June, 2016

v3.7.0 - 6 June, 2016

v3.6.2 - 27 April, 2016

v3.6.1 - 26 April, 2016

v3.6.0 - 18 March, 2016

v3.5.2 - 11 February, 2016

v3.5.1 - 30 January, 2016

v3.5.0 - 30 January, 2016

v3.4.3 - 6 January, 2016

v3.4.2 - 12 December, 2015

v3.4.0 - 15 November, 2015

v3.2.1 - 14 October, 2015

v3.2.0 - 12 September, 2015

v3.1.1 - 7 September, 2015

v3.1.0 - 2 September, 2015

v3.0.4 - 30 August, 2015

v3.0.3 - 19 August, 2015

v3.0.2 - 14 August, 2015

v3.0.1 - 4 August, 2015

v3.0.0 - 1 August, 2015

v2.3.4 - 20 July, 2015

v2.3.3 - 16 June, 2015

v2.3.2 - 26 May, 2015

v2.3.1 - 7 May, 2015

v2.3.0 - 4 May, 2015

v2.2.0 - 19 April, 2015

v2.1.1 - 7 April, 2015

v2.1.0 – 27 March, 2015

v2.0.1 – 21 January, 2015

v2.0.0 – 17 January, 2015

v1.6.0 – 7 November, 2014

v1.5.1 – 29 September, 2014

v1.5.0 – 8 September, 2014

v1.4.1 – 23 June, 2014

v1.4.0 – 10 May, 2014

v1.3.0 – 24 March, 2014

v1.2.0 – 23 January, 2014

v1.1.0 – 18 December, 2013

v1.0.0 – 10 December, 2013



Created by Mihai Buricea