diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000..13566b81b0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/clean-code-s1e1.iml b/.idea/clean-code-s1e1.iml new file mode 100644 index 0000000000..24643cc374 --- /dev/null +++ b/.idea/clean-code-s1e1.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000..84337bf755 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000..35eb1ddfbb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app.js b/app.js index ab737a6002..5ae2dbcc76 100644 --- a/app.js +++ b/app.js @@ -1,3 +1,4 @@ + //Document is the DOM can be accessed in the console with document.window. // Tree is from the top, html, body, p etc. @@ -9,8 +10,8 @@ // Event handling, user interaction is what starts the code execution. var taskInput=document.getElementById("new-task");//Add a new task. -var addButton=document.getElementsByTagName("button")[0];//first button -var incompleteTaskHolder=document.getElementById("incompleteTasks");//ul of #incompleteTasks +var addButton=document.getElementsByClassName("task-btn")[0];//first button +var incompleteTaskHolder=document.getElementById("incomplete-tasks");//ul of #incomplete-tasks var completedTasksHolder=document.getElementById("completed-tasks");//completed-tasks @@ -18,6 +19,7 @@ var completedTasksHolder=document.getElementById("completed-tasks");//completed- var createNewTaskElement=function(taskString){ var listItem=document.createElement("li"); + listItem.className = "task-list-item"; //input (checkbox) var checkBox=document.createElement("input");//checkbx @@ -25,26 +27,28 @@ var createNewTaskElement=function(taskString){ var label=document.createElement("label");//label //input (text) var editInput=document.createElement("input");//text - //button.edit - var editButton=document.createElement("button");//edit button + //button.edit-task + var editButton=document.createElement("button");//edit-task button - //button.delete - var deleteButton=document.createElement("button");//delete button - var deleteButtonImg=document.createElement("img");//delete button image + //button.delete-task + var deleteButton=document.createElement("button");//delete-task button + var deleteButtonImg=document.createElement("img");//delete-task button image label.innerText=taskString; - label.className='task'; + label.className='task task-label'; //Each elements, needs appending checkBox.type="checkbox"; + checkBox.className = "task-checkbox"; editInput.type="text"; - editInput.className="task"; + editInput.className="task task-text"; editButton.innerText="Edit"; //innerText encodes special characters, HTML does not. - editButton.className="edit"; + editButton.className="task-btn edit-task"; - deleteButton.className="delete"; + deleteButton.className="task-btn delete-task"; deleteButtonImg.src='./remove.svg'; + deleteButtonImg.className = "delete-task-img"; deleteButton.appendChild(deleteButtonImg); @@ -82,14 +86,14 @@ var editTask=function(){ var listItem=this.parentNode; - var editInput=listItem.querySelector('input[type=text]'); - var label=listItem.querySelector("label"); - var editBtn=listItem.querySelector(".edit"); - var containsClass=listItem.classList.contains("editMode"); - //If class of the parent is .editmode + var editInput=listItem.querySelector('.task-text'); + var label=listItem.querySelector(".task-label"); + var editBtn=listItem.querySelector(".edit-task"); + var containsClass=listItem.classList.contains("edit-mode"); + //If class of the parent is .edit-mode if(containsClass){ - //switch to .editmode + //switch to .edit-mode //label becomes the inputs value. label.innerText=editInput.value; editBtn.innerText="Edit"; @@ -98,8 +102,8 @@ var editTask=function(){ editBtn.innerText="Save"; } - //toggle .editmode on the parent. - listItem.classList.toggle("editMode"); + //toggle .edit-mode on the parent. + listItem.classList.toggle("edit-mode"); }; @@ -131,7 +135,7 @@ var taskIncomplete=function(){ console.log("Incomplete Task..."); //Mark task as incomplete. //When the checkbox is unchecked - //Append the task list item to the #incompleteTasks. + //Append the task list item to the #incomplete-tasks. var listItem=this.parentNode; incompleteTaskHolder.appendChild(listItem); bindTaskEvents(listItem,taskCompleted); @@ -155,14 +159,14 @@ addButton.addEventListener("click",ajaxRequest); var bindTaskEvents=function(taskListItem,checkBoxEventHandler){ console.log("bind list item events"); //select ListItems children - var checkBox=taskListItem.querySelector("input[type=checkbox]"); - var editButton=taskListItem.querySelector("button.edit"); - var deleteButton=taskListItem.querySelector("button.delete"); + var checkBox=taskListItem.querySelector(".task-checkbox"); + var editButton=taskListItem.querySelector(".task-btn.edit-task"); + var deleteButton=taskListItem.querySelector(".task-btn.delete-task"); - //Bind editTask to edit button. + //Bind editTask to edit-task button. editButton.onclick=editTask; - //Bind deleteTask to delete button. + //Bind deleteTask to delete-task button. deleteButton.onclick=deleteTask; //Bind taskCompleted to checkBoxEventHandler. checkBox.onchange=checkBoxEventHandler; @@ -190,6 +194,4 @@ for (var i=0; i -Todo App - - - - -
Want more details?
-

-

Todo

-

Completed

-
- + + Todo App + + + + +
+ Eisenhower Matrix + Want more details? +
+
+
+

Add Item

+
+ + +
+
+
+

Todo

+
    +
  • + + + + + +
  • +
  • + + + + + +
  • +
+
+
+

Completed

+
    +
  • + + + + + +
  • +
+
+
+ \ No newline at end of file diff --git a/style.css b/style.css index ab36227705..07cccc34ed 100644 --- a/style.css +++ b/style.css @@ -1,148 +1,150 @@ /* Basic Style */ -body { - background-color: #f8f8f8; - color: #333; - font-family: Lato, sans-serif; +.page { + background-color: #f8f8f8; + color: #333; + font-family: Lato, sans-serif; } -.aaa { - width: 500px; - margin: 0 auto; - display: block; - text-align: right; +.header { + width: 500px; + margin: 0 auto; + display: block; + text-align: right; } -.aaa img { - width: 100%; +.header-img {width: 100%; } -.aaa .more_inf { - font-family: fantasy, cursive; +.more-info { + font-family: fantasy, cursive; } -@media (max-width:768px) { -.aaa { text-align: center; +@media (max-width: 768px) { + .header { + text-align: center; + } } -} -.centered-main-page-element { - display: block; - width: 500px; - margin: 0 auto 0; + +.main { + display: block; + width: 500px; + margin: 0 auto 0; } .task { - width: 56%; - display: inline-block; - flex-grow: 1 + width: 56%; + display: inline-block; + flex-grow: 1; } .task-row-wrapper { - display: flex; + display: flex; } ul { - margin:0; - padding: 0px; + margin: 0; + padding: 0; } -li, h3 { - list-style:none; +li, +.task-list-header { + list-style: none; } -input,button{ - outline:none; +input, +button { + outline: none; } button { - background: none; - border: 0px; - color: #888; - font-size: 15px; - width: 60px; - font-family: Lato, sans-serif; - cursor: pointer; + background: none; + border: 0; + color: #888; + font-size: 15px; + width: 60px; + font-family: Lato, sans-serif; + cursor: pointer; } button:hover { - color: #3a3A3a; + color: #3a3A3a; } /* Heading */ -h3, -label[for='new-task'] { - color: #333; - font-weight: 700; - font-size: 15px; - border-bottom: 2px solid #333; - padding: 30px 0 10px; - margin: 0; - text-transform: uppercase; +.task-list-header, +.add-tasks-header { + color: #333; + font-weight: 700; + font-size: 15px; + border-bottom: 2px solid #333; + padding: 30px 0 10px; + margin: 0; + text-transform: uppercase; } input[type="text"] { - margin: 0; - font-size: 18px; - line-height: 18px; - height: 21px; - padding: 0 9px; - border: 1px solid #dDd; - background: #FFF; - border-radius: 6px; - font-family: Lato, sans-serif; - color: #888; + margin: 0; + font-size: 18px; + line-height: 18px; + height: 21px; + padding: 0 9px; + border: 1px solid #dDd; + background: #FFF; + border-radius: 6px; + font-family: Lato, sans-serif; + color: #888; } input[type="text"]:focus { - color: #333; + color: #333; } /* New Task */ -label[for='new-task'] { - display: block; - margin: 0 0 20px; +.add-tasks-header { + display: block; + margin: 0 0 20px; } -input#new-task { - width: 318px; +#new-task { + width: 318px; } /* Task list */ -li { - overflow: hidden; - padding: 20px 0; - border-bottom: 1px solid #eee; - - display: flex; - justify-content: space-between; - align-items: center; +.task-list-item { + overflow: hidden; + padding: 20px 0; + border-bottom: 1px solid #eee; + display: flex; + justify-content: space-between; + align-items: center; } -li > * { - vertical-align: middle; +.task-list-item > * { + vertical-align: middle; } -li > input[type="checkbox"] { - margin: 0 10px; +.task-checkbox { + margin: 0 10px; } -li > label { - padding-left: 10px; - box-sizing: border-box; - font-size: 18px; - width: 226px; +.task-label { + padding-left: 10px; + box-sizing: border-box; + font-size: 18px; + width: 226px; } -li > input[type="text"] { - width: 226px +.task-text { + width: 226px; } -button.delete img { - height: 2em; - transform: rotateZ(45deg); - transition: transform 200ms ease-in; +.delete-task-img { + height: 2em; + transform: rotateZ(45deg); + transition: transform 200ms ease-in; } -button.delete img:hover { - transform: rotateZ(0); +.delete-task-img:hover { + transform: rotateZ(0); } /* Completed */ -ul#completed-tasks label { - text-decoration: line-through - color: #888; +#completed-tasks .task-label { + text-decoration: line-through; + color: #888; } /* Edit Task */ -ul li input[type=text] { - display:none +.task-list-item input[type=text] { + display: none; } -ul li.editMode input[type=text] { - display:inline-block; - width:224px +.task-list-item.edit-mode input[type=text] { + display: inline-block; + width: 224px; } -ul li.editMode label { - display:none; +.task-list-item.edit-mode .task-label { + display: none; } \ No newline at end of file