Cube Portfolio

About

Cube Portfolio is a powerful jQuery plugin that provides beautiful animated filtering, custom captions and it's perfect for portfolios, galleries, team members, blog posts or any other ordered 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 asssets 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="//ajax.googleapis.com/ajax/libs/jquery/121022/jquery.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.7+. If you already have jQuery on your page, please don’t include it second time.


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

For more complex structures please check the templates folder.

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

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

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

Options

There are numerous options that can be added to configure Cube Portfolio behaviour. To set an option you must add it to the initialisation 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
defaultFilter strings that represent the filter name(e.g. *, .logo, .web-design, .design) * Default filter for plugin
filterDeeplinking true or false false Enable / disable the deeplinking feature when you click on filters
animationType fadeOut
quicksand
boxShadow
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 use the best browser features when available (CSS3 transition and transform, GPU acceleration) and fallback to simple animations (javascript animations) for legacy browsers.
gridAdjustment default
alignCenter
responsive
default 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)
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
moveRight
moveLeft
overlayBottomPush
overlayBottom
overlayBottomReveal
overlayBottomAlong
overlayRightAlong
minimal
fadeIn
zoom
pushTop Caption - the overlay that is shown when you put the mouse over an item.
NOTE: If you don't want to have captions just leave this option to an empty string ( caption: '')
displayType default
fadeIn
lazyLoading
fadeInToTop
sequentially
bottomToTop
default The plugin will display his content based on the following values.
- default (the content will be displayed as soon as possible)
- fadeIn (the content will be displayed with a fadeIn effect)
- 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. '')
singlePageCallback function empty function Use this callback to update singlePage content. The callback will trigger after the singlePage popup will open. (@param url = the href attribute of the item clicked, @param element = the item clicked)
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 empty function Use this callback to update singlePage content. The callback will trigger after the singlePage popup will open. (@param url = the href attribute of the item clicked, @param element = the item clicked)

Filters

Based on your filters Cube Portfolio use jQuery to decide witch items to hide, show or reposition. Then applies CSS3 transition and transform to smoothly animate these items to their new locations. The plugin use the best browser features when available (CSS3 transition and transform, GPU acceleration) and fallback to simple animations (javascript animations) for legacy browsers.

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 drowdown structure plese check exemples/lightbox-gallery/ folder.

1. Create the HTML markup:

<div id="filters-container">
<!-- '*' means shows all item elements -->
<button data-filter="*" class="cbp-filter-item cbp-filter-item-active">
    All
</button>
<button data-filter=".animation" class="cbp-filter-item">
    Animation
</button>
<button data-filter=".artwork" class="cbp-filter-item">
    Artwork
</button>
<button data-filter=".illustration" class="cbp-filter-item">
    Illustration
</button>
<button data-filter=".photography" class="cbp-filter-item">
    Photography
</button>
</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">
<ul>
    <li class="cbp-item animation illustration">
        <a title="custom title 1" href="#"><img src="path/to/img1" alt="custom alt 1" width="100%"/></a>
    </li>
    <li class="cbp-item artwork">
        <a title="custom title 2" href="#"><img src="path/to/img2" alt="custom alt 2" width="100%"/></a>
    </li>
    <li class="cbp-item animation artwork photography">
        <a title="custom title 3" href="#"><img src="path/to/img3" alt="custom alt 3" width="100%"/></a>
    </li>
</ul>
</div>

3. Initialize the javascript. Here is the part for initialising the plugin and then call the filter method.

<script type="text/javascript">
jQuery(document).ready(function() {
    var gridContainer = jQuery('#grid-container'),
        filtersContainer = $('#filters-container');

    // init cubeportfolio
    gridContainer.cubeportfolio({
        // cubeportfolio options
    });

    //activate filters for cubeportfolio
    filtersContainer.on('click', 'button', function (e) {

        // cache current button clicked
        var me = jQuery(this);

        // add class cbp-filter-item-active on the current button clicked and remove from other buttons
        me.addClass('cbp-filter-item-active').siblings().removeClass('cbp-filter-item-active');

        // call cubeportfolio filter function
        gridContainer.cubeportfolio('filter', me.data('filter'));

    });
});
</script>

4. Next steps are optional. Follow them only if you want to show counter for filters.

4.1 Update the above HTML markup with this one:

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

4.2 Update the above js initialization with this one:

<script type="text/javascript">
jQuery(document).ready(function() {
    var gridContainer = jQuery('#grid-container'),
        filtersContainer = $('#filters-container');

    // init cubeportfolio
    gridContainer.cubeportfolio({
        // cubeportfolio options
    });

    //activate filters for cubeportfolio
    filtersContainer.on('click', 'button', function (e) {

        // cache current button clicked
        var me = jQuery(this);

        // add class cbp-filter-item-active on the current button clicked and remove from other buttons
        me.addClass('cbp-filter-item-active').siblings().removeClass('cbp-filter-item-active');

        // call cubeportfolio filter function
        gridContainer.cubeportfolio('filter', me.data('filter'));
    });

    // activate counter on filters for cubeportfolio
    gridContainer.cubeportfolio('showCounter', filtersContainer.find('button'));
});
</script>

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.

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 webpage based on the url of 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 dependend to 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.

<div id="grid-container">
<ul>
    <li 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">
            <img src="path/to/img1" alt="custom alt 1" width="100%"/>
        </a>
    </li>
    <li class="cbp-item">
        <a class="cbp-lightbox" data-title="custom title 2" href="http://vimeo.com/74216460">
            <img src="path/to/img2" alt="custom alt 2" width="100%"/>
        </a>
    </li>
    </li>
    <li 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>
    </li>
    </li>
    </li>
    <li 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>
    </li>
    <li 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>
    </li>
</ul>
</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">
my outside 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" >
my outside link 1
</a>
<a class="cbp-lightbox" data-title="custom title 2" href="path/to/img2" data-cbp-lightbox="myCustomLightbox" >
my outside link 2
</a>
<a class="cbp-lightbox" data-title="custom title 3" href="path/to/img3" data-cbp-lightbox="myCustomLightbox" >
my outside link 3
</a>

Single Page

You can open a custom HTML content by using singlePage feature. Single Page use 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 start. To do that, you have to enable singlePageDeeplinking in options.

To enable singlePage you must add 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">
<ul>
    <li class="cbp-item">
        <a href="myCustomLink1" class="cbp-singlePage">
            open singlePage 1
        </a>
    </li>
    <li class="cbp-item">
        <a href="myCustomLink2" class="cbp-singlePage">
            open singlePage 2
        </a>
    </li>
    <li class="cbp-item">
        <a href="myCustomLink3" class="cbp-singlePage">
            open singlePage 3
        </a>
    </li>
</ul>
</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">
my outside 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" >
my outside singlePage link 1
</a>
<a class="cbp-singlePage" href="myCustomLink2" data-cbp-singlePage="myCustomSinglePage" >
my outside singlePage link 2
</a>
<a class="cbp-singlePage" href="myCustomLink3" data-cbp-singlePage="myCustomSinglePage" >
my outside singlePage link 3
</a>

Single Page Inline

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

To enable singlePageInline you must add 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">
<ul>
    <li class="cbp-item">
        <a href="myCustomLink1" class="cbp-singlePageInline">
            open singlePageInline 1
        </a>
    </li>
    <li class="cbp-item">
        <a href="myCustomLink2" class="cbp-singlePageInline">
            open singlePageInline 2
        </a>
    </li>
    <li class="cbp-item">
        <a href="myCustomLink3" class="cbp-singlePageInline">
            open singlePageInline 3
        </a>
    </li>
</ul>
</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>

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">
<ul>
    <li 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>
    </li>
</ul>
</div>

Templates

Cube Portfolio comes with 6 starter templates: Juicy Project, Lightbox Gallery, Meet the Team, Full Screen Layout, Masonry Layout and Blog Posts. You will find them in templates folder.

Every component (filters, grid container and load more) have different skins that are completelly independent from the others), so the skins can be combined. To enable a skin add the correspondent class to desire component container.

#1. Juicy Projects:

If you want to change the number of columns or dimension of items just go to cubeportfolio/css/cubeportfolio.css file
at .cbp-l-grid-projects .cbp-item selector and change his width and height properties

/* set width and height for items */
.cbp-l-grid-projects .cbp-item {
/* @editable properties */
width: 270px;
height: 250px;
}

#2. Lightbox Gallery:

If you want to change the number of columns or dimension of items just go to cubeportfolio/css/cubeportfolio.css file
at .cbp-l-grid-gallery .cbp-item selector and change his width and height properties

/* set width and height for items */
.cbp-l-grid-gallery .cbp-item {
/* @editable properties */
width: 320px;
height: 236px;
}

#3. Meet the Team:

If you want to change the number of columns or dimension of items just go to cubeportfolio/css/cubeportfolio.css file
at .cbp-l-grid-team .cbp-item selector and change his width and height properties

/* set width and height for items */
.cbp-l-grid-team .cbp-item {
/* @editable properties */
width: 380px;
height: 130px;
}

#4. Full Screen Layout:

If you want to change the number of columns or dimension of items just go to cubeportfolio/css/cubeportfolio.css file
at .cbp-l-grid-fullScreen .cbp-item selector and change his width and height properties

/* set width and height for items */
.cbp-l-grid-fullScreen .cbp-item {
/* @editable properties */
width: 350px;
height: 263px;
}

#5. Masonry Layout:

If you want to change the number of columns or dimension of items just go to cubeportfolio/css/cubeportfolio.css file
at .cbp-l-grid-masonry .cbp-item selector and change his width and height properties

/* set width and height for items */
.cbp-l-grid-masonry .cbp-item {
/* @editable properties */
width: 277px;
}

.cbp-l-grid-masonry .cbp-l-grid-masonry-height1 {
/* @editable properties */
height: 267px;
}

.cbp-l-grid-masonry .cbp-l-grid-masonry-height2 {
/* @editable properties */
height: 415px;
}

#6. Blog Posts:

If you want to change the number of columns or dimension of items just go to cubeportfolio/css/cubeportfolio.css file
at .cbp-l-grid-blog .cbp-item selector and change his width and height properties

/* set width and height for items */
.cbp-l-grid-blog .cbp-item {
/* @editable properties */
width: 313px;
height: 330px;
}

API

FilterSlider has 5 methods to use for external control: init, destroy, filter, showCounter and appendItems 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 new items will append the content to the gird, filter the new content, then will rearange all item elements to a properly layout.

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

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

A typical htmlContent can look like this:

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

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

Load More Items

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

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

For a more advanced examples please go to templates/juicy-projects/index.aspx 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

v1.5.1 – 29 September, 2014

v1.5 – 8 September, 2014

v1.4.1 – 23 June, 2014

v1.4 – 10 May, 2014

v1.3 – 24 March, 2014

v1.2 – 23 January, 2014

v1.1 – 18 December, 2013

v1.0 – 10 December, 2013



Created by Mihai Buricea