Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comit 11 #9

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<div class="listitems">
<div class="item">
<div class="foritem">
<div class="int"><input class="additional" type="text" placeholder="Нова назва"></div>
<div class="name">Помідори</div>
<div class="counts">
<div class="ovalmin" data-tooltip="Віднімає кількість">-</div>
Expand Down
17 changes: 17 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ input:focus::placeholder {
display: inline-block;
}

.int {
width: 34%;
font-weight: normal;
font-style: normal;
font-family: Arial;
opacity: 0.7;
color: black;
display: none;
}

input.additional {
width: 50%;
height: 100%;
border: 1px solid rgba(0, 0, 0, 0.6);
border-radius: 4px;
}

.counts {
width: 80px;
margin-left: -1px;
Expand Down
69 changes: 51 additions & 18 deletions scriptbuylist.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,24 @@ function addItem(title, Itemrow, Itemrowbought, Itemrownobought, c) {
var row = $(Itemrow);
var row2 = $(Itemrowbought);
var row3 = $(Itemrownobought);
var forChange = true;
//write names
row.find('.name').text(title);
row.find('.num').text(String(c));
row2.find('.title').text(title);
row2.find('.oval').text(String(c));
row3.find('.title').text(title);
row3.find('.oval').text(String(c));


//remove elements
row.find('.butdelete').click(function () {
row.remove();
row2.remove();
row3.remove();
});

//function button bought
row.find('.butbought').click(function () {
$(row2).fadeOut(500);
$(row3).delay(500).fadeIn(500);
Expand All @@ -65,8 +70,10 @@ function addItem(title, Itemrow, Itemrowbought, Itemrownobought, c) {
$(row.find('.butdelete')).fadeOut(500);
$(row.find('.num')).fadeIn(500);
$(row.find('.butboughtno')).delay(500).fadeIn(500);
forChange = false;
});

//function button not bought
row.find('.butboughtno').click(function () {
$(row3).fadeOut(500);
$(row2).delay(500).fadeIn(500);
Expand All @@ -78,8 +85,10 @@ function addItem(title, Itemrow, Itemrowbought, Itemrownobought, c) {
$(row.find('.num')).fadeIn(500);
$(row.find('.butbought')).delay(500).fadeIn(500);
$(row.find('.butdelete')).delay(500).fadeIn(500);
forChange = true;
});

//function button oval plus
row.find('.ovalpl').click(function () {
c++;
row.find('.num').fadeOut(250, function () {
Expand All @@ -88,26 +97,33 @@ function addItem(title, Itemrow, Itemrowbought, Itemrownobought, c) {
});
row2.find('.oval').text(String(c));
row3.find('.oval').text(String(c));
if (c > 9) {
row2.find('.oval').css('padding-left', '3px');
}
else {
row2.find('.oval').css('padding-left', '6px');
}
if (c != 1) {
if (c > 1) {
row.find('.ovalmin').css('background-color', 'rgb(196, 10, 10)');
row.find('.ovalmin').css('box-shadow', '0 1px 0 0 rgb(173, 9, 9)');
row.find('.ovalmin').css('box-shadow', '0 1px 0 0 rgb(140, 0, 0)');
row.find('.ovalmin').mouseenter(function () {
$(this).css('background-color', 'rgb(163, 0, 0)');
$(this).css('background-color', 'rgb(173, 9, 9)');
});
row.find('.ovalmin').mouseleave(function () {
$(this).css('background-color', 'rgb(196, 10, 10)');
});
row.find('.ovalmin').mousedown(function () {
$(this).css('background-color', 'rgb(140, 0, 0)');
});
row.find('.ovalmin').mouseup(function () {
$(this).css('background-color', 'rgb(173, 9, 9)');
});
}
if (c > 9) {
row2.find('.oval').css('padding-left', '3px');
}
else {
row2.find('.oval').css('padding-left', '6px');
}
});

//function button oval minus
row.find('.ovalmin').click(function () {
if (c !== 1 && c !== 2) {
if (c > 1) {
c--;
row.find('.num').fadeOut(250, function () {
row.find('.num').text(String(c));
Expand All @@ -116,14 +132,7 @@ function addItem(title, Itemrow, Itemrowbought, Itemrownobought, c) {
row2.find('.oval').text(String(c));
row3.find('.oval').text(String(c));
}
else if (c === 2){
c--;
row.find('.num').fadeOut(250, function () {
row.find('.num').text(String(c));
row.find('.num').fadeIn(250);
});
row2.find('.oval').text(String(c));
row3.find('.oval').text(String(c));
if (c == 1) {
row.find('.ovalmin').css('background-color', 'rgb(239, 158, 158)');
row.find('.ovalmin').css('box-shadow', 'none');
row.find('.ovalmin').mouseenter(function () {
Expand All @@ -132,6 +141,9 @@ function addItem(title, Itemrow, Itemrowbought, Itemrownobought, c) {
row.find('.ovalmin').mouseleave(function () {
$(this).css('background-color', 'rgb(239, 158, 158)');
});
row.find('.ovalmin').mousedown(function () {
$(this).css('background-color', 'rgb(239, 158, 158)');
});
}
if (c > 9) {
row2.find('.oval').css('padding-left', '3px');
Expand All @@ -141,6 +153,27 @@ function addItem(title, Itemrow, Itemrowbought, Itemrownobought, c) {
}
});

//function click name of item
row.find('.name').click(function () {
if (forChange) {
$(this).css('display', 'none');
row.find('.int').css('display', 'inline-block');
row.find('input.additional').focus();
row.find('input.additional').val(title);
$(document).mousedown(function (e) {
var cont = $('.int');
if (cont.has(e.target).length === 0){
title = row.find('input.additional').val();
row.find('.int').css('display', 'none');
row.find('.name').text(title);
row2.find('.title').text(title);
row3.find('.title').text(title);
row.find('.name').css('display', 'inline-block');
}
});
}
});

$(row3).hide();
list.append(row);
listnobought.append(row2);
Expand Down