Логика выставления отступов при перегруппировке пар

parent 337f8add
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
cursor: pointer; cursor: pointer;
} }
.b-list_folders-item b .b-list_folders-item b
{ {
position: absolute; position: absolute;
...@@ -46,7 +47,6 @@ ...@@ -46,7 +47,6 @@
{ {
font-weight: bold; font-weight: bold;
color: #333 !important; color: #333 !important;
/*opacity: 1 !important;*/
} }
.b-list_folders-item.active b .b-list_folders-item.active b
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
.b-list_folders-item.viewed .b-list_folders-item.viewed
{ {
color: #9FA0A0; color: #9FA0A0;
/*opacity: 0.45;*/
} }
.b-preview .b-preview
...@@ -113,21 +112,34 @@ ...@@ -113,21 +112,34 @@
padding: 0; padding: 0;
} }
.b-foto-double.pair.last-pair
{
margin-right: 50px;
}
.b-foto-double:last-child
{
margin-right: 50px;
}
.b-foto-double.last-pair
{
margin-right: 0;
}
.b-foto { .b-foto {
padding: 4px; padding: 4px;
} }
.b-foto_inner { .b-foto_inner {
position: relative; position: relative;
border: 1px solid #8D9094; /*border: 1px solid #8D9094;*/
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
cursor: pointer; cursor: pointer;
} }
.b-foto_inner.selected { .b-foto_inner.selected {
border-width: 4px; /*border-width: 4px;*/
} }
.b-folder-content.has-selected .b-foto_inner.paired { .b-folder-content.has-selected .b-foto_inner.paired {
...@@ -139,11 +151,26 @@ ...@@ -139,11 +151,26 @@
width: 100%; width: 100%;
} }
.b-foto_border
{
position: absolute;
top: 0;
height: 100%;
width: 100%;
border: 1px solid #8D9094;
border-radius: 4px;
}
.b-foto_inner.selected .b-foto_border
{
border-width: 4px;
}
.b-foto_number { .b-foto_number {
display: none; display: none;
position: absolute; position: absolute;
top: 2px; top: 6px;
left: 2px; left: 6px;
height: 20px; height: 20px;
width: 20px; width: 20px;
color: #FFF; color: #FFF;
......
...@@ -72,6 +72,7 @@ $(document).ready(function(){ ...@@ -72,6 +72,7 @@ $(document).ready(function(){
' <div class="b-foto" data-id="<%= item %>" data-ind="<%= ind+1 %>">' + ' <div class="b-foto" data-id="<%= item %>" data-ind="<%= ind+1 %>">' +
' <div class="b-foto_inner" data-foto="<%= item %>" data-num="">' + ' <div class="b-foto_inner" data-foto="<%= item %>" data-num="">' +
' <img class="b-foto_img" src="<%= folder %>/<%= item %>" >' + ' <img class="b-foto_img" src="<%= folder %>/<%= item %>" >' +
' <div class="b-foto_border"></div>' +
' <div class="b-foto_number"></div>' + ' <div class="b-foto_number"></div>' +
' </div>' + ' </div>' +
' </div>' + ' </div>' +
...@@ -90,6 +91,7 @@ $(document).ready(function(){ ...@@ -90,6 +91,7 @@ $(document).ready(function(){
' <div class="b-foto" data-id="<%= item %>" data-ind="<%= ind+1 %>">' + ' <div class="b-foto" data-id="<%= item %>" data-ind="<%= ind+1 %>">' +
' <div class="b-foto_inner" data-foto="<%= item %>" data-num="">' + ' <div class="b-foto_inner" data-foto="<%= item %>" data-num="">' +
' <img class="b-foto_img" src="<%= folder %>/<%= item %>" >' + ' <img class="b-foto_img" src="<%= folder %>/<%= item %>" >' +
' <div class="b-foto_border"></div>' +
' <div class="b-foto_number"></div>' + ' <div class="b-foto_number"></div>' +
' </div>' + ' </div>' +
' </div>' + ' </div>' +
...@@ -171,7 +173,7 @@ $(document).ready(function(){ ...@@ -171,7 +173,7 @@ $(document).ready(function(){
function CreatePair($currentFolderWrap, $pairedFoto, $this) function CreatePair($currentFolderWrap, $pairedFoto, $this)
{ {
console.log('AAA CreatePair ', $currentFolderWrap); //console.log('AAA CreatePair ', $currentFolderWrap);
$pairedFoto.addClass('paired'); $pairedFoto.addClass('paired');
$this.addClass('paired'); $this.addClass('paired');
...@@ -197,15 +199,14 @@ $(document).ready(function(){ ...@@ -197,15 +199,14 @@ $(document).ready(function(){
$divDoublePair2.prependTo($currentFolderWrap); $divDoublePair2.prependTo($currentFolderWrap);
$divDoublePair1.prependTo($currentFolderWrap); $divDoublePair1.prependTo($currentFolderWrap);
RegroupRemainingFotos($currentFolderWrap); RegroupRemainingFotos($currentFolderWrap);
return false; return false;
} }
var var
$divDoublePair = $('<div class="b-foto-double col pair">'), $divDoublePair = $('<div class="b-foto-double col pair">'),
$doublePaired = $('.b-foto-double.pair', $currentFolderWrap),
$fotoPair = $pairedFoto.parent('.b-foto'), $fotoPair = $pairedFoto.parent('.b-foto'),
$fotoThis = $this.parent('.b-foto'), $fotoThis = $this.parent('.b-foto'),
foto1 = $fotoPair.remove(), foto1 = $fotoPair.remove(),
...@@ -214,8 +215,6 @@ $(document).ready(function(){ ...@@ -214,8 +215,6 @@ $(document).ready(function(){
foto1.appendTo($divDoublePair); foto1.appendTo($divDoublePair);
foto2.appendTo($divDoublePair); foto2.appendTo($divDoublePair);
var $doublePaired = $('.b-foto-double.pair', $currentFolderWrap);
if ($doublePaired.length > 0) { if ($doublePaired.length > 0) {
$divDoublePair.insertAfter($doublePaired.last()); $divDoublePair.insertAfter($doublePaired.last());
} else { } else {
...@@ -236,10 +235,10 @@ $(document).ready(function(){ ...@@ -236,10 +235,10 @@ $(document).ready(function(){
} }
if (countFotosInFolder == 3) { if (countFotosInFolder == 3) {
SetLastPairClasses($currentFolderWrap);
return false; return false;
} }
RegroupRemainingFotos($currentFolderWrap); RegroupRemainingFotos($currentFolderWrap);
} }
...@@ -249,20 +248,16 @@ $(document).ready(function(){ ...@@ -249,20 +248,16 @@ $(document).ready(function(){
var var
$remainingFotos = $('.b-foto-double:not(.pair) .b-foto', $currentFolderWrap); $remainingFotos = $('.b-foto-double:not(.pair) .b-foto', $currentFolderWrap);
console.log('AAA $remainingFotos ', $remainingFotos.length);
$remainingFotos.remove(); $remainingFotos.remove();
$('.b-foto-double:not(.pair)', $currentFolderWrap).remove(); $('.b-foto-double:not(.pair)', $currentFolderWrap).remove();
if ($remainingFotos.length>0) { if ($remainingFotos.length>0) {
var var
$divDoublePair = $('<div class="b-foto-double col">'); $divDoublePair = $('<div class="b-foto-double col">');
$remainingFotos.each(function(ind){ $remainingFotos.each(function(ind){
//console.log('AAA $remainingFotos ', ind);
$(this).appendTo($divDoublePair); $(this).appendTo($divDoublePair);
if (((ind % 2) != 0) && (ind<$remainingFotos.length-1)) { if (((ind % 2) != 0) && (ind<$remainingFotos.length-1)) {
$divDoublePair.appendTo($currentFolderWrap); $divDoublePair.appendTo($currentFolderWrap);
$divDoublePair = $('<div class="b-foto-double col">'); $divDoublePair = $('<div class="b-foto-double col">');
...@@ -270,6 +265,22 @@ $(document).ready(function(){ ...@@ -270,6 +265,22 @@ $(document).ready(function(){
}); });
$divDoublePair.appendTo($currentFolderWrap); $divDoublePair.appendTo($currentFolderWrap);
} }
SetLastPairClasses($currentFolderWrap);
}
function SetLastPairClasses($currentFolderWrap)
{
var
$pairs = $('.b-foto-double.pair', $currentFolderWrap),
$doubles = $('.b-foto-double', $currentFolderWrap);
if ($pairs.length>0) {
$pairs.removeClass('last-pair');
$pairs.last().addClass('last-pair');
$doubles.last().addClass('last-pair');
} else {
$doubles.last().removeClass('last-pair');
}
} }
function ShowFoldersNew() function ShowFoldersNew()
...@@ -364,8 +375,8 @@ $(document).ready(function(){ ...@@ -364,8 +375,8 @@ $(document).ready(function(){
} }
$('.b-foto_number', $this).text(num); $('.b-foto_number', $this).text(num);
$('.b-foto_border', $this).css('border-color', colorsActive[num]);
$this.attr('data-num', num); $this.attr('data-num', num);
$this.css('border-color', colorsActive[num]);
$this.addClass('selected'); $this.addClass('selected');
// Если осталось одно неразмеченное фото, то выбираем и его автоматически: // Если осталось одно неразмеченное фото, то выбираем и его автоматически:
...@@ -400,10 +411,10 @@ $(document).ready(function(){ ...@@ -400,10 +411,10 @@ $(document).ready(function(){
} }
$('.b-foto_number', $pairedFotos).text(''); $('.b-foto_number', $pairedFotos).text('');
$('.b-foto_border', $pairedFotos).css('border-color', '#8D9094');
$pairedFotos.attr('data-num', '') $pairedFotos.attr('data-num', '')
.removeClass('paired') .removeClass('paired')
.removeClass('selected') .removeClass('selected');
.css('border-color', '#8D9094');
hasSelectedFoto[folderName] = false; hasSelectedFoto[folderName] = false;
$currentFolderWrap.removeClass('has-selected'); $currentFolderWrap.removeClass('has-selected');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment