From 323af1f0d01e548132b741eb6b5723d3547853f2 Mon Sep 17 00:00:00 2001 From: Zuriel Yahav Date: Wed, 4 Jan 2017 23:44:08 +0200 Subject: [PATCH 01/14] html + main --- ex9/js/main.js | 95 ++++++++++++++++++++++++++++++++++++++++++++++ ex9/phonebook.html | 79 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 ex9/js/main.js create mode 100644 ex9/phonebook.html diff --git a/ex9/js/main.js b/ex9/js/main.js new file mode 100644 index 0000000..b4e7ab4 --- /dev/null +++ b/ex9/js/main.js @@ -0,0 +1,95 @@ +require(['ajaxGet'], function(ajaxGet) { + $(function() { + var on; + setEvents(); + on = { + loadList: function() { + ajaxGet('json/data.json', function(phoneBookData) { + $('li').remove(); + $("#phoneBookTemplate").tmpl( phoneBookData ) + .appendTo( "#phoneBook" ); + }); + }, + searchInput: function() { + console.log('searchInput'); + if($('#textSearch').val() === '') { + $( "#btnFilter" ).prop( "disabled", true ); + } else { + $( "#btnFilter" ).prop( "disabled", false ); + } + }, + searchChange: function() { + console.log('searchChange'); + if($('#textSearch').val() === '') { + $( "#btnFilter" ).prop( "disabled", true ); + } else { + $( "#btnFilter" ).prop( "disabled", false ); + } + }, + filter: function() { + console.log('filter click'); + }, + searchOn: function() { + console.log('searchOn'); + // Search off + $( "#btnFilter" ).prop( "disabled", true ); + $('#textSearch').show(); + $('#btnFilter').show(); + $('#btnSearchOff').show(); + $('#btnSearchOn').hide(); + }, + searchOff: function() { + console.log('searchOff'); + // Search off + $('#textSearch').hide(); + $('#btnFilter').hide(); + $('#btnSearchOff').hide(); + $('#btnSearchOn').show(); + }, + asc: function() { + console.log('asc'); + $('#btnASC').hide(); + $('#btnDESC').show(); + }, + desc: function() { + console.log('desc'); + $('#btnASC').show(); + $('#btnDESC').hide(); + } + }; + + function setEvents() { + $('#btnReloadList').click(function() { + on.loadList(); + }); + + $('#btnSearchOn').click(function() { + on.searchOn(); + }); + + $('#btnSearchOff').click(function() { + on.searchOff(); + }); + + $('#textSearch').change(function() { + on.searchChange(); + }); + + $('#textSearch').on('input', function() { + on.searchInput(); + }); + + $('#btnFilter').click(function() { + on.filter(); + }); + + $('#btnASC').click(function() { + on.asc(); + }); + + $('#btnDESC').click(function() { + on.desc(); + }); + } + }); +}); diff --git a/ex9/phonebook.html b/ex9/phonebook.html new file mode 100644 index 0000000..dc49e0c --- /dev/null +++ b/ex9/phonebook.html @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + +
    +
  1. + + *ohad kravchick + + + 347-346-2425 + + +
  2. +
  3. + + *ohad kravchick + + + 347-346-2425 + + +
  4. +
  5. + + *ohad kravchick + + + 347-346-2425 + + +
  6. +
  7. + + *zuriel yahav + + + 0450-9001564 + + +
  8. +
+ + From c5c05b4b00f31d0167617df4ae238d314074b815 Mon Sep 17 00:00:00 2001 From: Zuriel Yahav Date: Fri, 6 Jan 2017 22:17:47 +0200 Subject: [PATCH 02/14] html container and split files --- ex9/js/main.js | 99 +++++----------------------------------------- ex9/js/order.js | 27 +++++++++++++ ex9/js/search.js | 69 ++++++++++++++++++++++++++++++++ ex9/phonebook.html | 25 ++++++++---- 4 files changed, 122 insertions(+), 98 deletions(-) create mode 100644 ex9/js/order.js create mode 100644 ex9/js/search.js diff --git a/ex9/js/main.js b/ex9/js/main.js index b4e7ab4..b70f6d2 100644 --- a/ex9/js/main.js +++ b/ex9/js/main.js @@ -1,95 +1,14 @@ -require(['ajaxGet'], function(ajaxGet) { +requirejs(['search', 'order', 'ajaxGet'], function(search, order, ajaxGet) { $(function() { - var on; - setEvents(); - on = { - loadList: function() { - ajaxGet('json/data.json', function(phoneBookData) { - $('li').remove(); - $("#phoneBookTemplate").tmpl( phoneBookData ) - .appendTo( "#phoneBook" ); - }); - }, - searchInput: function() { - console.log('searchInput'); - if($('#textSearch').val() === '') { - $( "#btnFilter" ).prop( "disabled", true ); - } else { - $( "#btnFilter" ).prop( "disabled", false ); - } - }, - searchChange: function() { - console.log('searchChange'); - if($('#textSearch').val() === '') { - $( "#btnFilter" ).prop( "disabled", true ); - } else { - $( "#btnFilter" ).prop( "disabled", false ); - } - }, - filter: function() { - console.log('filter click'); - }, - searchOn: function() { - console.log('searchOn'); - // Search off - $( "#btnFilter" ).prop( "disabled", true ); - $('#textSearch').show(); - $('#btnFilter').show(); - $('#btnSearchOff').show(); - $('#btnSearchOn').hide(); - }, - searchOff: function() { - console.log('searchOff'); - // Search off - $('#textSearch').hide(); - $('#btnFilter').hide(); - $('#btnSearchOff').hide(); - $('#btnSearchOn').show(); - }, - asc: function() { - console.log('asc'); - $('#btnASC').hide(); - $('#btnDESC').show(); - }, - desc: function() { - console.log('desc'); - $('#btnASC').show(); - $('#btnDESC').hide(); - } - }; - - function setEvents() { - $('#btnReloadList').click(function() { - on.loadList(); - }); - - $('#btnSearchOn').click(function() { - on.searchOn(); - }); - - $('#btnSearchOff').click(function() { - on.searchOff(); - }); - - $('#textSearch').change(function() { - on.searchChange(); + $('#btnReloadList').click(function() { + ajaxGet('json/data.json', function(phoneBookData) { + $('li').remove(); + $("#phoneBookTemplate").tmpl( phoneBookData ) + .appendTo( "#phoneBook" ); }); + }); - $('#textSearch').on('input', function() { - on.searchInput(); - }); - - $('#btnFilter').click(function() { - on.filter(); - }); - - $('#btnASC').click(function() { - on.asc(); - }); - - $('#btnDESC').click(function() { - on.desc(); - }); - } + search(); + order(); }); }); diff --git a/ex9/js/order.js b/ex9/js/order.js new file mode 100644 index 0000000..ed4ae5a --- /dev/null +++ b/ex9/js/order.js @@ -0,0 +1,27 @@ +define(function() { + return function() { + setEvents(); + } + + function setEvents() { + $('#btnASC').click(function() { + asc(); + }); + + $('#btnDESC').click(function() { + desc(); + }); + } + + function asc() { + console.log('asc'); + $('#btnASC').hide(); + $('#btnDESC').show(); + } + + function desc() { + console.log('desc'); + $('#btnASC').show(); + $('#btnDESC').hide(); + } +}); diff --git a/ex9/js/search.js b/ex9/js/search.js new file mode 100644 index 0000000..f2e001c --- /dev/null +++ b/ex9/js/search.js @@ -0,0 +1,69 @@ +define(function() { + return function() { + setEvents(); + } + + function setEvents() { + $('#btnMax').click(function() { + showSearch(); + }); + + $('#btnMin').click(function() { + hideSearch(); + }); + + $( '#filter' ).focus(function() { + if ($( '#filter' ).val() === 'Type your filter') { + $( '#filter' ).val( '' ); + } + }); + + $('#filter').change(function() { + onFilterChange(); + }); + + $('#filter').on('input', function() { + onFilterInput(); + }); + + $('#btnFilter').click(function() { + filterList(); + }); + } + + function onFilterInput() { + console.log('searchInput'); + if($('#filter').val() === '') { + $( '#btnFilter' ).prop( "disabled", true ); + } else { + $( '#btnFilter' ).prop( "disabled", false ); + } + } + + function onFilterChange() { + console.log('searchChange'); + if($('#filter').val() === '') { + $( '#btnFilter' ).prop( "disabled", true ); + } else { + $( "#btnFilter" ).prop( "disabled", false ); + } + } + + function filterList() { + console.log('filter list click'); + } + + function showSearch() { + console.log('searchOn'); + $( '#btnFilter' ).prop( "disabled", true ); + $('#filter').val('Type your filter'); + $('.searchMin').hide(); + $('.searchMax').show(); + } + + function hideSearch() { + console.log('searchOff'); + $('.searchMin').show(); + $('.searchMax').hide(); + } +}); diff --git a/ex9/phonebook.html b/ex9/phonebook.html index dc49e0c..ba3cad0 100644 --- a/ex9/phonebook.html +++ b/ex9/phonebook.html @@ -7,15 +7,24 @@ - - - - - - - - +
+ +
+
+ + +
+ -
- -
+
+
+ +
-
- - -
-