/*
Hugo Story by CaressOfSteel
A (modular, highly tweakable) responsive one-page theme for Hugo.
Ported from Story by HTML5UP.
This Hugo theme is licensed under the Creative Commons Attribution 3.0 License.
*/
(function($) {
var $window = $(window);
// Styles.
$(
''
).appendTo($('head'));
// Functions.
$.fn.demo_controls = function(styles, userOptions) {
var $this = $(this),
$styleProperty, $stylePropertyClasses,
$controls, $x, $y, $z,
options,
current, i, j, k, s, n, count;
// No elements?
if (this.length == 0)
return $this;
// Multiple elements?
if (this.length > 1) {
for (var i=0; i < this.length; i++)
$(this[i]).demo_controls(styles, userOptions);
return $this;
}
// Options.
options = $.extend({
target: null,
palette: true
}, userOptions);
// Controls.
if (styles) {
$controls = $(
'' +
'' +
'style' +
'' + (options.palette ? ', ' : ' ') +
'' +
(options.palette ?
'' +
'scheme' +
'' +
'default' +
'invert' +
', ' +
'' +
'' +
'color' +
'' +
'default' +
'color1' +
'color2' +
'color3' +
'color4' +
'color5' +
'color6' +
'color7' +
', ' +
''
: '') +
''
);
}
else {
$controls = $(
'' +
(options.palette ?
'' +
'scheme' +
'' +
'default' +
'invert' +
' and ' +
'' +
'' +
'color' +
'' +
'default' +
'color1' +
'color2' +
'color3' +
'color4' +
'color5' +
'color6' +
'color7' +
'' +
''
: '') +
''
);
}
// Target.
switch (options.target) {
case 'previous':
$this.prev().find('.demo-controls').replaceWith($controls);
break;
default:
$this.find('.demo-controls').replaceWith($controls);
break;
}
// Styles.
if (styles) {
$styleProperty = $controls.find('.property[data-name="style"]');
$stylePropertyClasses = $styleProperty.children('.classes');
for (i in styles) {
current = false;
count = Object.keys(styles[i]).length;
n = 1;
// Add to style property.
$x = $(', ' + i + '')
.appendTo($stylePropertyClasses);
if ($this.hasClass(i)) {
$x.addClass('active');
current = true;
}
// Step through properties.
for (j in styles[i]) {
$x = $(
'' +
(n == count ? 'and ' : '') +
'' + j + '' +
'' +
'' + (n < count ? ', ' : '') +
''
).appendTo($controls);
$y = $x.children('.classes');
if (current)
$x.addClass('active');
for (k in styles[i][j]) {
$z = $(', ' + styles[i][j][k].replace('*', '') + '')
.appendTo($y);
if (styles[i][j][k].substr(-1, 1) == '*')
$z.addClass('default');
if (current
&& $this.hasClass(k))
$z.addClass('active');
}
n++;
}
}
}
// Events.
$controls.on('click', 'a', function(event) {
event.preventDefault();
});
$controls.on('click', '.property.active', function(event) {
var $property = $(this);
var $classes = $property.find('.classes > *');
var $current = $classes.filter('.active');
var $next;
// Determine next.
if ($current.length == 0
|| $current.index() == $classes.length - 1)
$next = $classes.first();
else
$next = $current.next();
// Turn on animate all.
$this.addClass('demo-animate-all');
// Deactivate current.
$current.removeClass('active');
$this.removeClass($current.data('class'));
// Activate next.
$next.addClass('active');
$this.addClass($next.data('class'));
// Turn off animate all.
setTimeout(function() {
$this.removeClass('demo-animate-all');
}, 500);
});
$controls.on('click', '.property[data-name="style"]', function(event) {
var $property = $(this);
var $classes = $property.find('.classes > *');
var $current = $classes.filter('.active');
var $next;
// Determine next.
if ($current.length == 0
|| $current.index() == $classes.length - 1)
$next = $classes.first();
else
$next = $current.next();
// Turn on animate all.
$this.addClass('demo-animate-all');
// Deactivate current.
$current.removeClass('active');
$this.removeClass($current.data('class'));
$controls.find('.property[data-requires="' + $current.data('class') + '"]')
.removeClass('active');
$controls.find('.property[data-requires="' + $current.data('class') + '"] > .classes > .active').each(function() {
$(this).removeClass('active');
if ($(this).data('class') != '-')
$this.removeClass($(this).data('class'));
});
// Activate next.
$next.addClass('active');
$this.addClass($next.data('class'));
$controls.find('.property[data-requires="' + $next.data('class') + '"]')
.addClass('active');
$controls.find('.property[data-requires="' + $next.data('class') + '"] > .classes > .default').each(function() {
$(this).addClass('active');
if ($(this).data('class') != '-')
$this.addClass($(this).data('class'));
});
// Turn off animate all.
setTimeout(function() {
$this.removeClass('demo-animate-all');
}, 500);
});
};
// Elements.
// Wrappers.
$('.wrapper').demo_controls(null, {
palette: true
});
// Banner.
$('.banner').demo_controls({
style1: {
'size': {
'-': 'normal',
'fullscreen': 'fullscreen*'
},
'orientation': {
'orient-left': 'left*',
'orient-right': 'right'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
style2: {
'size': {
'-': 'normal',
'fullscreen': 'fullscreen*'
},
'orientation': {
'orient-left': 'left',
'orient-center': 'center*',
'orient-right': 'right'
},
'content alignment': {
'content-align-left': 'left',
'content-align-center': 'center*',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
style3: {
'size': {
'-': 'normal',
'fullscreen': 'fullscreen*'
},
'orientation': {
'orient-left': 'left',
'orient-right': 'right*'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
style4: {
'size': {
'-': 'normal',
'fullscreen': 'fullscreen*'
},
'phone type': {
'iphone': 'iphone*',
'android': 'android'
},
'orientation': {
'orient-left': 'left',
'orient-right': 'right*'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
style5: {
'size': {
'-': 'normal',
'fullscreen': 'fullscreen*'
},
'content alignment': {
'content-align-left': 'left',
'content-align-center': 'center*',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
}
});
// Spotlight.
$('.spotlight').demo_controls({
style1: {
'orientation': {
'orient-left': 'left',
'orient-right': 'right*'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left*',
'image-position-center': 'center',
'image-position-right': 'right'
}
},
style2: {
'orientation': {
'orient-left': 'left',
'orient-right': 'right*'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
style3: {
'phone type': {
'iphone': 'iphone*',
'android': 'android'
},
'orientation': {
'orient-left': 'left',
'orient-right': 'right*'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
style4: {
'size': {
'-size': 'normal',
'fullscreen': 'fullscreen*',
'halfscreen': 'halfscreen'
},
'orientation': {
'orient-left': 'left*',
'orient-center': 'center',
'orient-right': 'right'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
style5: {
'size': {
'-size': 'normal',
'fullscreen': 'fullscreen*',
'halfscreen': 'halfscreen'
},
'orientation': {
'orient-left': 'left*',
'orient-center': 'center',
'orient-right': 'right'
},
'content alignment': {
'content-align-left': 'left*',
'content-align-center': 'center',
'content-align-right': 'right'
},
'image position': {
'image-position-left': 'left',
'image-position-center': 'center*',
'image-position-right': 'right'
}
},
});
// Gallery.
$('.gallery').demo_controls({
style1: {
'size': {
'small': 'small',
'medium': 'medium*',
'big': 'big'
}
},
style2: {
'size': {
'small': 'small',
'medium': 'medium*',
'big': 'big'
}
},
}, {
target: 'previous',
palette: false
});
// Items.
$('.items').demo_controls({
style1: {
'size': {
'small': 'small',
'medium': 'medium*',
'big': 'big'
}
},
style2: {
'size': {
'small': 'small',
'medium': 'medium*',
'big': 'big'
}
},
style3: {
'size': {
'small': 'small',
'medium': 'medium*',
'big': 'big'
}
}
}, {
target: 'previous',
palette: false
});
})(jQuery);