Skip to content

Commit

Permalink
Merge pull request #184 from vish250491/master
Browse files Browse the repository at this point in the history
carousal buildfire library modified for fullscreen carousal view
  • Loading branch information
DanielHindi committed Jan 29, 2016
2 parents 51d45a0 + 7105eda commit aca604d
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions scripts/buildfire/components/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,33 +298,36 @@ buildfire.components.carousel.editor.prototype = {
};

// This is the class that will be used in the mobile
buildfire.components.carousel.view = function (selector, items, layout) {
buildfire.components.carousel.view = function (selector, items, layout,speed) {
if (typeof($.fn) != "object" || !($.fn && $.fn.owlCarousel)) {
throw ("please add owlCarousel.js first to use carousel component");
}
this.selector = selector;
this.items = [];
this._initDimensions(layout);
this._loadItems(items, false);
this.init(selector);
this.init(selector,speed);
window.dispatchEvent(new CustomEvent('resize'));
};

// Carousel view methods
buildfire.components.carousel.view.prototype = {
// will be called to initialize the setting in the constructor
init: function (selector) {
init: function (selector,speed) {
this.selector = buildfire.components.carousel._getDomSelector(selector);
this._renderSlider();
this._loadImages();
if (this.items.length) {
this._applySlider();
if(typeof speed === 'undefined')
this._applySlider();
else
this._applySlider(speed);
} else {
this._hideSlider();
}
},
// this method allows you to append or replace slider images
loadItems: function (items, appendItems, layout) {
loadItems: function (items, appendItems, layout,speed) {
if (this.$slider) {
this._destroySlider();
this._removeAll();
Expand All @@ -334,7 +337,7 @@ buildfire.components.carousel.view.prototype = {
this._renderSlider();

this._loadItems(items, appendItems);
this._loadImages();
this._loadImages(speed);

if (!this.items.length) {
this._hideSlider();
Expand All @@ -346,7 +349,7 @@ buildfire.components.carousel.view.prototype = {
if (items instanceof Array && !items.length && !appendItems) {
return;
}
this._applySlider();
this._applySlider(speed);
},
// allows you to append a single item or an array of items
append: function(items){
Expand All @@ -361,11 +364,14 @@ buildfire.components.carousel.view.prototype = {
this.width = window.innerWidth;
layout = layout || "WideScreen";
if (layout == "WideScreen") {
this.height = Math.ceil(9 * this.width / 16);
this.height = Math.ceil(9 * this.width / 16);
} else if (layout == "Square") {
this.height = this.width;
} else if (layout == "Cinema") {
this.height = Math.ceil(1 * this.width / 2.39);
}else if(layout == "MobileScreen"){
this.height=(window.innerHeight/this.width)*this.width;
this.width=this.width;
}

this.cssWidth = this.width + "px";
Expand Down Expand Up @@ -402,7 +408,7 @@ buildfire.components.carousel.view.prototype = {
this.selector.style.display = "block";
},
// initialize the slider
_applySlider: function () {
_applySlider: function (speed) {
var me = this;
me.$slider = $(me.selector);
if (me.items.length > 1) {
Expand All @@ -419,12 +425,17 @@ buildfire.components.carousel.view.prototype = {
autoHeight: false
};

sliderOptions.autoplay = 3000;
sliderOptions.autoplaySpeed = 800;
sliderOptions.autoplay =(speed==0)? 0:3000;
sliderOptions.autoplaySpeed =speed?speed: 800;
sliderOptions.loop = true;
me.$slider.owlCarousel(sliderOptions);
}
$('.plugin-slide').show();


if(typeof speed === 'undefined')
$('.plugin-slide').show();
else
$('.my-slide').show();
},
// destroy the slider if it's already in the DOM
_destroySlider: function () {
Expand All @@ -447,18 +458,22 @@ buildfire.components.carousel.view.prototype = {
me.selector.className = "plugin-slider text-center";
},
// loop and append the images to the DOM
_loadImages: function () {
_loadImages: function (speed) {
var items = this.items;
var itemsLength = items.length;

for (var i = 0; i < itemsLength; i++) {
this._appendItem(items[i], i);
this._appendItem(items[i], i,speed);
}
},
// add new slider to the DOM
_appendItem: function (item, index) {
_appendItem: function (item, index,speed) {
var slider = document.createElement("div");
slider.className = "plugin-slide";

if(typeof speed === 'undefined')
slider.className = "plugin-slide";
else
slider.className = "my-slide";

if(0 != index) {
slider.style.display = "none";
Expand Down

0 comments on commit aca604d

Please sign in to comment.