Skip to content

Commit

Permalink
new component sidebar and tile image slider plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
olton committed Oct 26, 2012
1 parent 28f783c commit bbbaae3
Show file tree
Hide file tree
Showing 16 changed files with 977 additions and 47 deletions.
176 changes: 162 additions & 14 deletions css/modern.css
Original file line number Diff line number Diff line change
Expand Up @@ -839,19 +839,6 @@ table {
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/K88pR3goAWT7BTt32Z01mz8E0i7KZn-EPnyo3HZu7kw.woff) format('woff');
}
/*
@baseFontUI: 'Segoe UI', 'Open Sans', Verdana, Arial, Helvetica, sans-serif;
@baseFontText: 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;
.font-ui {font-family: @baseFontUI;}
.font-text {font-family: @baseFontText;}
.light-text {font-weight: 200;}
.semilight-text {font-weight: 300;}
.regular-text {font-weight: 400;}
.semibold-text {font-weight: 600;}
.bold-text {font-weight: 700;}
*/
.text-rest-state {
color: #000000;
}
Expand Down Expand Up @@ -1484,6 +1471,22 @@ ol.unstyled,
.page.fixed-header .page-region {
padding-top: 140px;
}
.page.with-sidebar .page-region {
margin-left: 220px;
width: auto;
*zoom: 1;
}
.page.with-sidebar .page-region .page-region-content {
padding-left: 20px;
}
.page.with-sidebar .page-region:before,
.page.with-sidebar .page-region:after {
display: table;
content: "";
}
.page.with-sidebar .page-region:after {
clear: both;
}
.app-bar {
position: absolute;
bottom: 0;
Expand Down Expand Up @@ -2097,7 +2100,7 @@ button.big [class*=icon-],
margin-left: 0px;
box-sizing: border-box;
border: 1px transparent solid;
z-index: 1001;
z-index: 2;
}
.button-set a,
.button-set button {
Expand Down Expand Up @@ -2372,6 +2375,9 @@ table.bordered tbody tr:last-child td {
}
.grid {
margin: 0 0 20px;
display: block;
height: auto;
width: 100%;
*zoom: 1;
}
.grid.no-margin {
Expand Down Expand Up @@ -2842,6 +2848,148 @@ table.bordered tbody tr:last-child td {
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
/*
* Metro UI CSS v 0.1.4
* Copyright 2012 Sergey Pimenov
* Licensed under the MIT Lilcense
*
* Sidebar.less
*/
.page-sidebar {
display: block;
width: 213px;
float: left;
min-height: 100% !important;
height: auto;
background-color: #EBEBEB;
padding-top: 10px;
padding-bottom: 10px;
margin-top: 10px;
margin-left: 7px;
}
.page-sidebar a {
font-family: 'Segoe UI', 'Open Sans', Verdana, Arial, Helvetica, sans-serif;
font-weight: 400;
font-size: 11pt;
letter-spacing: 0.01em;
line-height: 14pt;
color: #000000;
display: block;
width: 100%;
padding: 5px 20px 5px 10px;
white-space: nowrap;
font-size: 14px;
cursor: pointer;
}
.page-sidebar a:hover {
color: rgba(0, 0, 0, 0.8);
}
.page-sidebar a:active {
color: rgba(0, 0, 0, 0.4);
}
.page-sidebar a:hover {
background-color: #2d89ef !important;
color: #ffffff !important;
}
.page-sidebar li {
display: list-item;
line-height: 20px;
position: relative;
}
.page-sidebar > ul > li > a {
font-size: 1.1em;
}
.page-sidebar > ul > li a.lead,
.page-sidebar > ul > li.lead a,
.page-sidebar > ul > li.lead {
font-weight: bold;
}
.page-sidebar > ul > li.sticker:before {
content: ".";
position: absolute;
width: 7px;
height: 28px;
left: -7px;
text-indent: -9999px;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
background-color: #ebebeb;
}
.page-sidebar > ul > li.sticker.sticker-color-blue:before {
background-color: #2d89ef;
}
.page-sidebar > ul > li.sticker.sticker-color-blueLight:before {
background-color: #44a3aa;
}
.page-sidebar > ul > li.sticker.sticker-color-blueDark:before {
background-color: #0a5ac2;
}
.page-sidebar > ul > li.sticker.sticker-color-green:before {
background-color: #00a300 !important;
}
.page-sidebar > ul > li.sticker.sticker-color-greenLight:before {
background-color: #99b433 !important;
}
.page-sidebar > ul > li.sticker.sticker-color-greenDark:before {
background-color: #005200 !important;
}
.page-sidebar > ul > li.sticker.sticker-color-red:before {
background-color: #b91d47 !important;
}
.page-sidebar > ul > li.sticker.sticker-color-yellow:before {
background-color: #ffc40d !important;
}
.page-sidebar > ul > li.sticker.sticker-color-orange:before {
background-color: #e3a21a !important;
}
.page-sidebar > ul > li.sticker.sticker-color-orangeDark:before {
background-color: #da532c !important;
}
.page-sidebar > ul > li.sticker.sticker-color-pink:before {
background-color: #c3325f !important;
}
.page-sidebar > ul > li.sticker.sticker-color-pinkDark:before {
background-color: #9f00a7 !important;
}
.page-sidebar > ul > li.sticker.sticker-color-purple:before {
background-color: #603cba !important;
}
.page-sidebar > ul > li.sticker.sticker-color-darken:before {
background-color: #1d1d1d !important;
}
.page-sidebar > ul > li.sticker.sticker-color-white:before {
background-color: #ffffff !important;
}
.page-sidebar > ul > li.sticker.sticker-color-grayDark:before {
background-color: #525252 !important;
}
.page-sidebar .divider {
height: 1px;
margin: 9px 1px;
overflow: hidden;
background-color: #e5e5e5;
}
.page-sidebar ul {
margin-left: 0;
list-style: none;
background-color: #EBEBEB;
}
.page-sidebar ul.sub-menu {
padding-top: 5px;
padding-bottom: 5px;
}
.page-sidebar ul.sub-menu a {
padding: 5px 20px 5px 25px;
}
.page-sidebar ul.sub-menu.light {
background-color: #f9f9f9 !important;
}
.page-sidebar .sidebar-dropdown-menu {
display: none;
}
.page-sidebar .sidebar-dropdown-menu.open {
display: block;
}
/*
* Metro UI CSS v 0.1.4
* Copyright 2012 Sergey Pimenov
Expand Down
140 changes: 140 additions & 0 deletions javascript/tile-image-slider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
(function($) {

$.tileImageSlider = function(element, options) {

// настройки по умолчанию
var defaults = {
// период смены картинок
period: 2000,
// продолжительность анимации
duration: 1000,
// направление анимации (up, down, left, right)
direction: 'left'

}
// объект плагина
var plugin = this;
// настройки конкретного объекта
plugin.settings = {}

var $element = $(element), // reference to the jQuery version of DOM element
element = element; // reference to the actual DOM element


var images, // все картинки
imagesWidth = [],
imagesHeight = [],
imagesLeft = [], // куда сдвигать по горизонтали
imagesTop = [], // куда сдвигать по вертикали
currentImageIndex; // индекс текущей картинки

// инициализируем
plugin.init = function() {

var tileWidth,
tileHeight;

plugin.settings = $.extend({}, defaults, options);

// все картинки
images = $element.children(".tile-content").children('img');
currentImageIndex = images.length - 1;
// дублируем верхнюю картинку в самый низ, для непрерывности слайдинга
$(images[currentImageIndex]).clone().appendTo($element.children(".tile-content"));

// добавляем необходимые стили картинкам, но лучше добавить готовым стилем
images.css({
'position': 'absolute'
});

// размеры текущей плитки
tileWidth = $element.innerWidth();
tileHeight = $element.innerHeight();

// сразу определяем все необходимые параметры изображений и сохраняем в соответствующие массивы
images.each(function(index, image){

var $image = $(image);

imagesWidth[index] = $image.width();
imagesHeight[index] = $image.height();

if (plugin.settings.direction === 'left') {
imagesLeft[index] = - imagesWidth[index];
} else if (plugin.settings.direction === 'right') {
imagesLeft[index] = tileWidth;
} else {
imagesLeft[index] = 0;
}

if (plugin.settings.direction === 'up') {
imagesTop[index] = - imagesHeight[index];
} else if (plugin.settings.direction === 'down') {
imagesTop[index] = tileHeight;
} else {
imagesTop[index] = 0;
}
});



// запускаем интервал для смены картинок
setInterval(function(){
slideImage();
}, plugin.settings.period);
}

// сдвигаем текущую картинку
var slideImage = function() {

var imageToSlide, // картинка которую надо сдвинуть
cssDestination;

cssDestination = {
'top': imagesTop[currentImageIndex],
'left': imagesLeft[currentImageIndex]
};

imageToSlide = $(images[currentImageIndex]);
imageToSlide.animate(cssDestination, plugin.settings.duration, function(){
if (currentImageIndex === images.length - 1) {
resetImages();
}
});

// индексы меняются в обратном порядке, так как последняя (в коде) картинка находится сверху
currentImageIndex--;
if (currentImageIndex < 0) {
currentImageIndex = images.length - 1;
}
}

// возвращаем все картинки на место
var resetImages = function () {
images.each(function(index, image){
$(image).css({
'left': 0,
'top': 0
})
})
}


plugin.init();

}

$.fn.tileImageSlider = function(options) {
return this.each(function() {
if (undefined == $(this).data('tileImageSlider')) {
var plugin = new $.tileImageSlider(this, options);
$(this).data('tileImageSlider', plugin);
}
});
}

})(jQuery);

$(window).load(function(){
$('[data-role=image-slider], .image-slider').tileImageSlider();
})
2 changes: 1 addition & 1 deletion less/buttons.less
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ button, .button, .tool-button {
margin-left: 0px;
box-sizing: border-box;
border: 1px transparent solid;
z-index: 1001;
z-index: 2;
}
}

Expand Down
4 changes: 4 additions & 0 deletions less/grid.less
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@

.grid {
margin: 0 0 20px;
display: block;
height: auto;
width: 100%;

&.no-margin {
margin: 0;
Expand All @@ -96,6 +99,7 @@
.row {
width: 100%;
.clearfix();

[class*="span"] {
float: left;
}
Expand Down
Loading

0 comments on commit bbbaae3

Please sign in to comment.