diff --git a/app/app/urls.py b/app/app/urls.py index 485fc0f6e38..8e795c65e25 100644 --- a/app/app/urls.py +++ b/app/app/urls.py @@ -210,9 +210,9 @@ # Hackathons / special events path('hackathon//', dashboard.views.hackathon, name='hackathon'), path('hackathon///', dashboard.views.hackathon, name='hackathon'), - path('hackathon/onboard//', dashboard.views.hackathon_onboard, name='hackathon_onboard'), + path('hackathon//onboard', dashboard.views.hackathon_onboard, name='hackathon_onboard'), path('hackathon//projects/', dashboard.views.hackathon_projects, name='hackathon_projects'), - path('hackathon//projects/', dashboard.views.hackathon_projects, name='hackathon_projects2'), + path('hackathon//prizes/', dashboard.views.hackathon, name='hackathon_prizes'), path( 'hackathon/projects//', dashboard.views.hackathon_project, name='hackathon_project' ), diff --git a/app/assets/v2/css/dashboard-hackathon.css b/app/assets/v2/css/dashboard-hackathon.css new file mode 100644 index 00000000000..838a4218e4d --- /dev/null +++ b/app/assets/v2/css/dashboard-hackathon.css @@ -0,0 +1,351 @@ +body { + background: #FFFFFF; +} + +.invisible { + background: #FFFFFF !important; + visibility: hidden; + height: 0; +} + + +#left_sidebar .townsquare-org-filter { + cursor:pointer +} +#left_sidebar .townsquare-org-filter:active { + border-bottom: 4px solid #280076 !important; +} + +#onboard-dashboard { + background: #F2F6F9; + margin-bottom: 2em; +} + +#onboard-dashboard > div { + padding-top: 3.5rem; + padding-bottom: 2em; +} + +#onboard-dashboard .info i.circle, +.darkify { + font-weight: bolder; + color: #280076; +} + +#onboard-dashboard h2, +#onboard-dashboard h3 { + text-transform: capitalize; + letter-spacing: 0; +} + +#onboard-footer p a, +#onboard-dashboard .info p a { + color: #007BFF; + text-decoration: none; +} + +#onboard-dashboard .info #onboard-alert { + float: right; + padding: .3rem 1.7rem; +} + +#onboard-dashboard .info i { + font-size: 0.7rem; + margin-right: 1rem; +} + +#onboard-dashboard .tips .fa-circle { + font-size: 5.7px; + margin-right: 0.4rem; + top: -2px; + position: relative; +} + +#onboard-footer p { + margin: 0; + padding-left: 0.5rem; + padding-right: 0.5rem; +} + +#onboard-dashboard .tips .tips-info { + margin-top: 1rem; +} + +#onboard-dashboard .tips .tips-info p { + margin-bottom: 0.45rem; +} + +#onboard-dashboard .no-results { + background: #FFFFFF; +} + +.title-row { + display: flex; + float: right; + border-bottom: 2px solid #3E24FB; +} + +.bounty-info { + top: 4px; + text-align: right; +} + +#stats { + padding-left: 5px; + font-weight: 300; + color: #7A7A7A; +} + +.title { + text-transform: capitalize; + font-weight: 600; +} + +.bounty_row { + color: #000000; + text-decoration: none; + padding: 10px 3rem 10px 1rem; + display: flex; + flex-wrap: wrap; +} + +.bounty_row .avatar-container { + text-align: right; + margin-top: auto; + margin-bottom: auto; +} + +.bounty_row img { + margin-right: 20px; +} + +.bounty_row .title { + margin-bottom: 2px; +} + +.bounty_row:hover { + color: #000000; + text-decoration: none; + background-color: #F9F9F9; +} + +.bounty-detail { + margin-top: 10px; + margin-bottom: 10px; +} + +.bounty-summary { + display: inline-flex; +} + +.bounty-summary img { + position: absolute; + width: 20px; + margin: 0; + top: 2px; +} + +.bounty-summary .col-xs-1 { + margin-right: 2em; +} + +.bounty-summary .github-comment { + position: absolute; + text-align: center; + color: white; + width: 20px; + top: 0px; +} + +#onboard-dashboard .no-results img { + width: 15rem; +} + +.bounty-detail .info { + color: #666666; +} + +#onboard-dashboard .robot { + margin-top: auto; + margin-bottom: auto; +} + +#onboard-dashboard .robot img { + width: 12rem; +} + +.tags { + display: flex; + flex-wrap: wrap; +} + +.tags.fixed { + padding-bottom: 1rem; +} + +#onboard-footer { + text-align: center; + background: #F2F6F9; + padding-top: 2rem; + padding-bottom: 2rem; +} + +@media (min-width: 992px) { + + #onboard-dashboard .tips { + padding-left: 2rem; + border-left: 1.5px solid #dbdcdc; + } +} + +@media (max-width: 991.98px) { + .bounty_row { + padding-left: 1rem; + padding-right: 1rem; + } + + #onboard-dashboard .robot { + display: none; + } + + .bounty_row .avatar-container { + display: none !important; + } +} + +@media (max-width: 768px) { + + #onboard-dashboard .col-12 { + padding-left: 3em; + padding-right: 3em; + } + + .bounty-info { + top: 10px; + font-size: 10px; + text-align: left; + } + + #stats { + font-size: 10px; + } +} + +.hiring-alt { + font-size: 11px; + color: #4A90E2; + font-weight: 700; + letter-spacing: 1.7px; +} + +.hackathon-alt { + font-size: 11px; + color: #0d0764; + font-weight: 600; + letter-spacing: 1.7px; +} + +.hackathon-explorer { + background: rgb(242, 246, 249) !important; +} + +.hackathon-explorer .hackathon-alt { + display: none; +} + +.status-open { + color: #00A652; +} + +.status-reserved { + color: #d58512; +} + +.status-started { + color: #0D0764; +} + +.status-submitted { + color: #008EFF; +} + +.status-done { + color: #666666; +} + +.status-cancelled, +.status-expired { + color: #C70018; +} + +.separator-bull { + margin: 0 0.6em; +} + +.separator-bull:after { + content: '\2022' +} + +.btn-expand-token { + position: absolute; + line-height: 1.5rem; + border: 0; + background-color: transparent; + font-weight: 400; + color: #007bff; +} + +.btn-expand-token:focus { + color: #007bff; +} + +.expired-icon { + font-size: 15px; + padding-right: 0.5em; + vertical-align: text-bottom; +} + +.navigation { + height: 60px; + display: flex; + align-items: center; +} + +.navigation .nav-link, .navigation .nav-link:hover { + color: inherit; + border:0; +} + +.navigation .nav-link.active { + background-color: transparent !important; + font-weight: bold !important; + color: #4700FF !important; + border-bottom: 4px solid #4700FF !important; +} + +li.navigation > a.nav-link { + height: 100%; +} + + +.sponsor-top { + height: 60px; + display: flex; + background-color: #ffffff; + border-bottom: 1px solid #dee2e6; +} + +div.nav-tabs { + background-color:#ffffff; + border-left:0; +} + +.hackathon-explorer ul.nav-tabs { + border:0; +} + +.navigation a { + width:100% !important; + font-weight: 500 !important; + padding: 0 !important; +} diff --git a/app/assets/v2/css/dashboard.css b/app/assets/v2/css/dashboard.css index 052d9754a1d..a0504832e72 100644 --- a/app/assets/v2/css/dashboard.css +++ b/app/assets/v2/css/dashboard.css @@ -236,7 +236,6 @@ body { font-weight: 600; letter-spacing: 1.7px; } - .hackathon-explorer { background: rgb(242, 246, 249) !important; } @@ -303,24 +302,13 @@ body { align-items: center; } -.navigation .nav-link, .navigation .nav-link:hover { - color: inherit; - border:0; -} - -.navigation .nav-link.active{ - background-color: transparent !important; - border:0; -} - .navigation a { - width:100% !important; - font-weight: 500 !important; - padding: 0 !important; + font-weight: 500; + padding: 0; } .navigation a.active { - font-weight: bold !important; - color: #0b0d9d !important; - border-bottom: 4px solid #0b0d9d !important; + font-weight: bold; + color: #0b0d9d; + border-bottom: 4px solid #0b0d9d; } diff --git a/app/assets/v2/css/sidebar_search.css b/app/assets/v2/css/sidebar_search.css index 552ef18058d..86278af8f92 100644 --- a/app/assets/v2/css/sidebar_search.css +++ b/app/assets/v2/css/sidebar_search.css @@ -112,4 +112,9 @@ margin-right: 10px; padding: 20px 20px 10px; } -} \ No newline at end of file +} + +.left-ribbon { + border-left: 3px solid var(--gc-blue); + padding-left: 6px !important; +} diff --git a/app/assets/v2/css/top-nav.css b/app/assets/v2/css/top-nav.css index a0a5d2a5aa6..6a7b9061579 100644 --- a/app/assets/v2/css/top-nav.css +++ b/app/assets/v2/css/top-nav.css @@ -13,7 +13,7 @@ .top-nav a { - padding: 0.3rem 0.7rem; + padding: 0.3rem 0.62rem; } .top-nav .link { diff --git a/app/assets/v2/css/users.css b/app/assets/v2/css/users.css index 459f993088d..f5d90544c20 100644 --- a/app/assets/v2/css/users.css +++ b/app/assets/v2/css/users.css @@ -6,7 +6,7 @@ .grid-4 { display: grid; grid-template-columns: repeat(1, 1fr); - grid-gap: 5rem 3rem; + grid-gap: 5rem 2rem; } @media (min-width: 768px) { diff --git a/app/assets/v2/js/pages/dashboard-hackathon.js b/app/assets/v2/js/pages/dashboard-hackathon.js new file mode 100644 index 00000000000..626dac8b30b --- /dev/null +++ b/app/assets/v2/js/pages/dashboard-hackathon.js @@ -0,0 +1,1028 @@ +/* eslint-disable no-loop-func */ +(function($) { + + let hackathonProjects = [] + let projectsPage = 1; + let hackathonSponsors = document.hackathonSponsors; + let projectsNumPages = ''; + let projectsHasNext = false; + let numProjects = ''; + let hackathonId = document.hasOwnProperty('hackathon_id') ? document.hackathon_id : ''; + + var filters = [ + 'experience_level', + 'project_length', + 'bounty_type', + 'bounty_filter', + 'moderation_filter', + 'network', + 'idx_status', + 'project_type', + 'permission_type', + 'misc', + 'applicants' + ]; + var local_storage_keys = JSON.parse(JSON.stringify(filters)); + + local_storage_keys.push('keywords'); + local_storage_keys.push('org'); + + results_limit = 10; + + var localStorage; + + var explorer = { }; + + try { + localStorage = window.localStorage; + } catch (e) { + localStorage = {}; + } + + function scrollSlider(element, cardSize) { + const arrowLeft = $('#arrowLeft'); + const arrowRight = $('#arrowRight'); + + arrowLeft.on('click', function() { + element[0].scrollBy({left: -cardSize, behavior: 'smooth'}); + }); + arrowRight.on('click', function() { + element[0].scrollBy({left: cardSize, behavior: 'smooth'}); + }); + + element.on('scroll mouseenter', function() { + if (this.clientWidth === (this.scrollWidth - this.scrollLeft)) { + arrowRight.hide(); + } else { + arrowRight.show(); + } + + if (this.scrollLeft < 10) { + arrowLeft.hide(); + } else { + arrowLeft.show(); + } + }); + } + + scrollSlider($('#featured-card-container'), 288); + + function debounce(func, wait, immediate) { + var timeout; + + return function() { + var context = this; + var args = arguments; + var later = function() { + timeout = null; + if (!immediate) + func.apply(context, args); + }; + var callNow = immediate && !timeout; + + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) + func.apply(context, args); + }; + } + + const scrub = value => value.replace(/[!@#$%^&*(),.?":{}|<>]+/g, ''); + + /** + * Fetches all filters options from the URI + */ + var getActiveFilters = function() { + + if (window.location.search) { + resetFilters(); + } + let _filters = filters.slice(); + + _filters.push('keywords', 'order_by', 'org', 'tab'); + if (document.hackathon) { + resetFilters(true); + filters.push('org', 'tab'); + + } + _filters.forEach(filter => { + if (getParam(filter)) { + if (filter !== undefined && filter !== 'undefined') { + localStorage[filter] = getParam(filter).replace(/^,|,\s*$/g, ''); + } else { + delete localStorage[filter]; + } + } + }); + }; + + /** + * Build URI based on selected filter + */ + var buildURI = function(custom_filters) { + let uri = ''; + let _filters = []; + + if (custom_filters) { + _filters = custom_filters; + } else { + _filters = filters.slice(); + _filters.push('keywords', 'order_by', 'org'); + } + + _filters.forEach((filter) => { + + if (localStorage[filter] === undefined || localStorage[filter] === 'undefined') { + delete localStorage[filter]; + } else if (localStorage[filter] && localStorage[filter] !== 'any') { + uri += (filter + '=' + localStorage[filter] + '&'); + } + }); + + return uri.slice(0, -1); + }; + + /** + * Updates localStorage with selected filters + */ + var save_sidebar_latest = function() { + localStorage['order_by'] = $('#sort_option').val(); + + filters.forEach((filter) => { + localStorage[filter] = ''; + if (filter === 'applicants') { + localStorage[filter] = $('#applicants_box').val(); + } else { + $('input[name="' + filter + '"]:checked').each(function() { + localStorage[filter] += $(this).val() + ','; + }); + } + + localStorage[filter] = localStorage[filter].replace(/^,|,\s*$/g, ''); + }); + }; + + // saves search information default + const set_sidebar_defaults = () => { + const q = getParam('q'); + const org = getParam('org'); + const applicants = getParam('applicants'); + + if (q) { + const keywords = decodeURIComponent(q).replace(/^,|\s|,\s*$/g, ''); + + if (localStorage['keywords']) { + keywords.split(',').forEach(function(v, k) { + if (localStorage['keywords'].indexOf(v) === -1) { + localStorage['keywords'] += ',' + v; + } + }); + } else { + localStorage['keywords'] = keywords; + } + } + + if (org) { + if (localStorage['org']) { + org.split(',').forEach(function(value) { + if (localStorage['org'].indexOf(value) === -1) { + localStorage['org'] += ',' + value; + } + }); + } else { + localStorage['org'] = org; + } + } + + if (applicants) { + if (localStorage['applicants']) { + localStorage['applicants'] = applicants; + } + } + getActiveFilters(); + + if (localStorage['order_by']) { + $('#sort_option').val(localStorage['order_by']); + $('#sort_option').selectmenu().selectmenu('refresh'); + } + + filters.forEach((filter) => { + if (localStorage[filter]) { + if (filter === 'applicants') { + $('#applicants_box').val(localStorage[filter]).trigger('change.select2'); + } + + localStorage[filter].split(',').forEach(function(val) { + $('input[name="' + filter + '"][value="' + val + '"]').prop('checked', true); + }); + + if ($('input[name="' + filter + '"][value!=any]:checked').length > 0) + $('input[name="' + filter + '"][value=any]').prop('checked', false); + } + }); + }; + + var toggleAny = function(event) { + if (!event) + return; + var key = event.target.name; + var anyOption = $('input[name="' + key + '"][value=any]'); + + // Selects option 'any' when no filter is applied + if ($('input[name="' + key + '"]:checked').length === 0) { + anyOption.prop('checked', true); + return; + } + if (event.target.value === 'any') { + // Deselect other filters when 'any' is selected + $('input[name="' + key + '"][value!=any]').prop('checked', false); + } else { + // Deselect option 'any' when another filter is selected + anyOption.prop('checked', false); + } + }; + + var addTechStackKeywordFilters = function(value) { + if (localStorage['keywords']) { + const keywords = localStorage['keywords']; + const new_value = ',' + value; + + if (keywords === value || + keywords.indexOf(new_value) !== -1 || + keywords.indexOf(value + ',') !== -1) { + + return; + } + localStorage['keywords'] = keywords + new_value; + } else { + localStorage['keywords'] = value; + } + $('.filter-tags').append('' + scrub(value) + '' + + ''); + }; + + var addTechStackOrgFilters = function(value) { + if (localStorage['org']) { + const org = localStorage['org']; + const new_value = ',' + value; + + if (org === value || + org.indexOf(new_value) !== -1 || + org.indexOf(value + ',') !== -1) { + + return; + } + localStorage['org'] = org + new_value; + } else { + localStorage['org'] = value; + } + + $('.filter-tags').append('' + scrub(value) + '' + + ''); + }; + + var getFilters = function() { + var _filters = []; + + filters.forEach((filter) => { + $.each($('input[name="' + filter + '"]:checked'), function() { + if ($(this).attr('val-ui')) { + _filters.push('' + $(this).attr('val-ui') + '' + + ''); + } + }); + }); + + if (localStorage['keywords']) { + localStorage['keywords'].split(',').forEach(function(v, k) { + _filters.push('' + scrub(v) + '' + + ''); + }); + } + + if (localStorage['org']) { + localStorage['org'].split(',').forEach(function(v, k) { + _filters.push('' + scrub(v) + '' + + ''); + }); + } + + $('.filter-tags').html(_filters); + }; + + var removeFilter = function(key, value) { + if (key !== 'keywords' && key !== 'org') { + $('input[name="' + key + '"][value="' + value + '"]').prop('checked', false); + } else { + localStorage[key] = localStorage[key].replace(value, '').replace(',,', ','); + + // Removing the start and last comma to avoid empty element when splitting with comma + localStorage[key] = localStorage[key].replace(/^,|,\s*$/g, ''); + } + + reset_offset(); + refreshBounties(null, 0, false); + }; + + var get_search_URI = function(offset, order) { + var uri = '/api/v0.1/bounties/slim/?'; + var keywords = ''; + var org = ''; + + filters.forEach((filter) => { + var active_filters = []; + + $.each ($('input[name="' + filter + '"]:checked'), function() { + if ($(this).val()) { + active_filters.push($(this).val()); + } + }); + + var val = active_filters.toString(); + + if ((filter === 'bounty_filter') && val) { + var values = val.split(','); + + values.forEach(function(_value) { + var _key; + + if (_value === 'createdByMe') { + _key = 'bounty_owner_github_username'; + _value = document.contxt.github_handle; + } else if (_value === 'startedByMe') { + _key = 'interested_github_username'; + _value = document.contxt.github_handle; + } else if (_value === 'fulfilledByMe') { + _key = 'fulfiller_github_username'; + _value = document.contxt.github_handle; + } else if (_value === 'reservedForMe') { + _key = 'reserved_for_user_handle'; + _value = document.contxt.github_handle; + } + + if (_value !== 'any') { + if (!uri.endsWith('?')) + uri += '&'; + uri += _key + '=' + _value; + } + }); + + // TODO: Check if value myself is needed for coinbase + if (val === 'fulfilledByMe') { + filter = 'bounty_owner_address'; + val = 'myself'; + } + } + if (filter === 'applicants') { + val = $('#applicants_box').val(); + } + + if (val && val !== 'any' && + filter !== 'bounty_filter' && + filter !== 'bounty_owner_address') { + if (!uri.endsWith('?')) + uri += '&'; + uri += filter + '=' + val; + } + }); + + if (localStorage['keywords']) { + localStorage['keywords'].split(',').forEach(function(v, pos, arr) { + keywords += v; + if (arr.length > pos + 1) { + keywords += ','; + } + }); + } + + if (keywords) { + uri += '&keywords=' + keywords; + } + + if (localStorage['org']) { + localStorage['org'].split(',').forEach(function(v, pos, arr) { + org += v; + if (arr.length > pos + 1) { + org += ','; + } + }); + } + + if (org) { + uri += '&org=' + org; + } + let order_by; + + if (order) { + order_by = order; + } else { + order_by = localStorage['order_by']; + } + + if (document.hackathon) { + uri += `&event_tag=${document.hackathon}`; + } + + if (typeof order_by !== 'undefined' && order_by !== 'undefined') { + uri += '&order_by=' + order_by; + } + + uri += '&offset=' + offset; + uri += '&limit=' + results_limit; + + return uri; + }; + + var trigger_scroll = debounce(function() { + var scrollPos = $(document).scrollTop(); + var last_active_bounty = $('.bounty_row.result:last-child'); + + if (last_active_bounty.length == 0) { + return; + } + + var window_height = $(window).height(); + var have_painted_all_bounties = false;// TODO + var buffer = 500; + var get_more = !have_painted_all_bounties && ((last_active_bounty.offset().top) < (scrollPos + buffer + window_height)); + + if (get_more && !document.done_loading_results) { + + // move loading indicator + var loading_html = $('.loading_img').clone().wrap('

').parent().html(); + + $('.loading_img').remove(); + $('#bounties').append(loading_html); + $('.loading_img').css('display', 'block'); + + document.offset = parseInt(document.offset) + parseInt(results_limit); + refreshBounties(null, document.offset, true); + } + }, 200); + + $(window).scroll(trigger_scroll); + $('body').bind('touchmove', trigger_scroll); + + + var addPopover = () => { + // $('[data-toggle="popover"]').popover(); + console.log('pops enabled'); + $('.bounty_row').popover({ + html: true, + trigger: 'hover', + placement: 'auto', + template: `

` + }); + }; + + var reset_offset = function() { + document.done_loading_results = false; + document.offset = 0; + }; + + let organizations = []; + + var refreshBounties = function(event, offset, append) { + + // Allow search for freeform text + var searchInput = $('#keywords')[0]; + var orgInput = $('#org')[0]; + + $('#results-count span.num').html(''); + if (searchInput && searchInput.value.length > 0) { + addTechStackKeywordFilters(searchInput.value.trim()); + searchInput.value = ''; + searchInput.blur(); + $('.close-icon').hide(); + } + + if (!document.hackathon) { + if (orgInput.value.length > 0) { + addTechStackOrgFilters(orgInput.value.trim()); + orgInput.value = ''; + orgInput.blur(); + $('.close-icon').hide(); + } + + save_sidebar_latest(); + toggleAny(event); + getFilters(); + window.history.pushState('', '', window.location.pathname + '?' + buildURI()); + } else { + toggleAny(event); + + const org = $("input[name='org']:checked").val(); + console.log("we're here") + localStorage['org'] = org === 'any' ? '' : org; + localStorage['order_by'] = $('#sort_option').val(); + window.history.pushState('', '', window.location.pathname + '?' + buildURI([ 'org', 'tab' ])); + } + + if (!append) { + $('.nonefound').css('display', 'none'); + $('.loading').css('display', 'block'); + $('.bounty_row').remove(); + } + + const uri = get_search_URI(offset); + const uriFeatured = get_search_URI(offset, '-featuring_date'); + let bountiesURI; + let featuredBountiesURI; + + if (!uri.endsWith('?')) { + bountiesURI = uri; + featuredBountiesURI = uriFeatured + '&'; + } + // bountiesURI += ''; + featuredBountiesURI += 'is_featured=True'; + + // Abort pending request if any subsequent request + if (explorer.bounties_request && explorer.bounties_request.readyState !== 4) { + explorer.bounties_request.abort(); + } + + explorer.bounties_request = $.get(bountiesURI, function(results, x) { + results = sanitizeAPIResults(results); + + if (results.length === 0 && !append) { + if (localStorage['referrer'] === 'onboard' && !document.hackathon) { + $('.no-results').removeClass('hidden'); + $('#dashboard-content').addClass('hidden'); + } else { + $('.nonefound').css('display', 'block'); + } + } + + document.last_bounty_rendered = 0; + + var html = renderBountyRowsFromResults(results, true); + + if (html) { + $('#bounties').append(html); + } + + document.done_loading_results = results.length < results_limit; + + $('div.bounty_row.result').each(function() { + var href = $(this).attr('href'); + + if (typeof $(this).changeElementType !== 'undefined') { + $(this).changeElementType('a'); // hack so that users can right click on the element + } + + $(this).attr('href', href); + + }); + + if (localStorage['referrer'] === 'onboard') { + $('.bounty_row').each(function(index) { + if (index > 2) + $(this).addClass('hidden'); + }); + } + + $('#results-count span.num').html(offset + results.length); + if (results.length == results_limit) { + $('#results-count span.plus').html('+'); + } else { + $('#results-count span.plus').html(''); + } + }).fail(function() { + if (explorer.bounties_request.readyState !== 0) + _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); + }).always(function() { + $('.loading').css('display', 'none'); + addPopover(); + }); + + explorer.bounties_request = $.get(featuredBountiesURI, function(results, x) { + results = sanitizeAPIResults(results); + + if (results.length === 0 && !append) { + $('.featured-bounties').hide(); + if (localStorage['referrer'] === 'onboard') { + $('.no-results').removeClass('hidden'); + $('#dashboard-content').addClass('hidden'); + } else { + $('.nonefound').css('display', 'none'); + } + } + + var html = renderFeaturedBountiesFromResults(results, true); + + if (html) { + $('.featured-bounties').show(); + $('#featured-card-container').html(html); + } + }).fail(function() { + if (explorer.bounties_request.readyState !== 0) + _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); + }).always(function() { + $('.loading').css('display', 'none'); + addPopover(); + }); + }; + + + /** + * removed all filters from the sidebar search + * resetKeyword : boolean + */ + var resetFilters = function(resetKeyword) { + filters.forEach((filter) => { + var tag = ($('input[name="' + filter + '"][value]')); + + for (var j = 0; j < tag.length; j++) { + if (tag[j].value == 'any') + $('input[name="' + filter + '"][value="any"]').prop('checked', true); + else + $('input[name="' + filter + '"][value="' + tag[j].value + '"]').prop('checked', false); + } + + if (resetKeyword && filter === 'applicants' && !document.hackathon) { + $('#applicants_box').val('ALL').trigger('change.select2'); + } else if (resetKeyword && filter === 'applicants' && document.hackathon) { + localStorage.setItem(filter, ''); + } + + // Defaults to mainnet on clear filters to make it less confusing + $('input[name="network"][value="mainnet"]').prop('checked', true); + }); + + if (resetKeyword && localStorage['keywords']) { + localStorage['keywords'].split(',').forEach(function(v, k) { + removeFilter('keywords', v); + }); + } + + if (resetKeyword && localStorage['org'] && !document.hackathon) { + localStorage['org'].split(',').forEach(function(v, k) { + removeFilter('org', v); + }); + } + }; + + var initDOM = () => { + $('.js-select2').each(function() { + $(this).select2({ + minimumResultsForSearch: Infinity + }); + }); + + $('#expand').on('click', () => { + $('#expand').hide(); + $('#minimize').show(); + $('#sidebar_container form').css({ + 'height': 'auto', + 'display': 'inherit' + }); + }); + + $('#minimize').on('click', () => { + $('#minimize').hide(); + $('#expand').show(); + $('#sidebar_container form').css({ + 'height': 0, + 'display': 'none' + }); + }); + + // Sort select menu + $('#sort_option').selectmenu({ + select: function(event, ui) { + reset_offset(); + refreshBounties(null, 0, false); + event.preventDefault(); + } + }); + + // TODO: DRY + function split(val) { + return val.split(/,\s*/); + } + + function extractLast(term) { + return split(term).pop(); + } + + // Handle search input clear + $('.close-icon') + .on('click', function(e) { + e.preventDefault(); + $('#keywords').val(''); + $(this).hide(); + }); + + $('#keywords') + .on('input', function() { + if ($(this).val()) { + $('.close-icon').show(); + } else { + $('.close-icon').hide(); + } + }) + // don't navigate away from the field on tab when selecting an item + .on('keydown', function(event) { + if (event.keyCode === $.ui.keyCode.TAB && $(this).autocomplete('instance').menu.active) { + event.preventDefault(); + } + }) + .autocomplete({ + minLength: 0, + source: function(request, response) { + // delegate back to autocomplete, but extract the last term + response($.ui.autocomplete.filter(document.keywords, extractLast(request.term))); + }, + focus: function() { + // prevent value inserted on focus + return false; + }, + select: function(event, ui) { + var terms = split(this.value); + + $('.close-icon').hide(); + + // remove the current input + terms.pop(); + + // add the selected item + terms.push(ui.item.value); + + // add placeholder to get the comma-and-space at the end + terms.push(''); + + this.value = ''; + + addTechStackKeywordFilters(ui.item.value); + + return false; + } + }); + + // sidebar clear + $('.dashboard #clear').on('click', function(e) { + e.preventDefault(); + resetFilters(true); + reset_offset(); + refreshBounties(null, 0, false); + }); + + // search bar + $('#sidebar_container').delegate('#new_search', 'click', function(e) { + reset_offset(); + refreshBounties(null, 0, false); + e.preventDefault(); + }); + + $('.search-area input[type=text]').keypress(function(e) { + if (e.which == 13) { + reset_offset(); + refreshBounties(null, 0, false); + e.preventDefault(); + } + }); + + $(` + .sidebar_search input[type=radio], .sidebar_search input[type=checkbox], + .sidebar_search .js-select2, #org + `).on('change', function(e) { + reset_offset(); + refreshBounties(null, 0, false); + e.preventDefault(); + }); + + if (localStorage['referrer'] === 'onboard' && !document.hackathon) { + $('#sidebar_container').addClass('invisible'); + $('#dashboard-title').addClass('hidden'); + $('#onboard-dashboard').removeClass('hidden'); + $('#onboard-footer').removeClass('hidden'); + resetFilters(true); + $('input[name=idx_status][value=open]').prop('checked', true); + $('.search-area input[type=text]').text(getURLParams('q')); + + $('#onboard-alert').on('click', function(e) { + + if (!$('.no-results').hasClass('hidden')) + $('.nonefound').css('display', 'block'); + + $('.bounty_row').each(function(index) { + $(this).removeClass('hidden'); + }); + + $('#onboard-dashboard').addClass('hidden'); + $('#onboard-footer').addClass('hidden'); + $('#sidebar_container').removeClass('invisible'); + $('#dashboard-title').removeClass('hidden'); + $('#dashboard-content').removeClass('hidden'); + + localStorage['referrer'] = ''; + e.preventDefault(); + }); + } else { + $('#dashboard-content').removeClass('hidden'); + $('#onboard-dashboard').addClass('hidden'); + $('#onboard-footer').addClass('hidden'); + $('#sidebar_container').removeClass('invisible'); + $('#dashboard-title').removeClass('hidden'); + } + addPopover(); + }; + + + $(function() { + Vue = Vue.extend({ + delimiters: [ '[[', ']]' ] + }); + Vue.component('sponsor-tribes-widget', { + delimiters: [ '[[', ']]' ], + mounted() { + let vm = this; + let tribesData = {}; + + vm.hackathonSponsrs.map((n) => { + tribesData[n.org_name] = n; + }) + vm.tribesData = tribesData; + }, + methods: { + followTribe: (tribe) => { + let vm = this; + let sponsorLocal = vm.tribesData[tribe]; + + + let apiFollowUrl = `/api/v0.1/projects_fetch/?${sponsorLocal.org_name.toString()}`; + + var followTribeRequest = fetchData (apiFollowUrl, 'GET'); + } + }, + data: () => ({ + tribesData: {}, + hackathonSponsrs: document.hackathonSponsors + }) + }); + Vue.component('project-directory', { + delimiters: [ '[[', ']]' ], + methods: { + fetchProjects: function(newPage) { + let vm = this; + + vm.isLoading = true; + vm.noResults = false; + + if (newPage) { + vm.projectsPage = newPage; + } + vm.params.page = vm.projectsPage; + vm.params.hackathon = hackathonId; + if (vm.searchTerm) { + vm.params.search = vm.searchTerm; + } else { + delete vm.params['search']; + } + + let searchParams = new URLSearchParams(vm.params); + + let apiUrlProjects = `/api/v0.1/projects_fetch/?${searchParams.toString()}`; + + var getProjects = fetchData (apiUrlProjects, 'GET'); + + $.when(getProjects).then(function(response) { + vm.hackathonProjects = []; + response.data.forEach(function(item) { + vm.hackathonProjects.push(item); + }); + + vm.projectsNumPages = response.num_pages; + vm.projectsHasNext = response.has_next; + vm.numProjects = response.count; + if (vm.projectsHasNext) { + vm.projectsPage = ++vm.projectsPage; + + } else { + vm.projectsPage = 1; + } + + if (vm.hackathonProjects.length) { + vm.noResults = false; + } else { + vm.noResults = true; + } + vm.isLoading = false; + }); + }, + searchProjects: function() { + let vm = this; + + vm.hackathonProjects = []; + + vm.fetchProjects(1); + + } + }, + data: () => ({ + hackathonSponsors, + hackathonProjects, + projectsPage, + hackathonId, + projectsNumPages, + projectsHasNext, + numProjects, + media_url, + searchTerm: null, + bottom: false, + params: {}, + isFunder: false, + showModal: false, + showFilters: true, + skills: document.keywords || [], + selectedSkills: [], + noResults: false, + isLoading: true, + hideFilterButton: false + }), + mounted() { + this.fetchProjects(); + this.$watch('params', function(newVal, oldVal) { + this.searchProjects(); + }, { + deep: true + }); + }, + created() { + // this.extractURLFilters(); + }, + beforeMount() { + window.addEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }, false); + }, + beforeDestroy() { + window.removeEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }); + } + }); + var app = new Vue({ + delimiters: [ '[[', ']]' ], + el: '#dashboard-vue-app', + updated: () => { + addPopover(); + }, + mounted: () => { + setTimeout(() => { + set_sidebar_defaults(); + reset_offset(); + refreshBounties(null, 0, false); + initDOM(); + addPopover(); + }, 0); + }, + methods: { + tabChange: (input) => { + let vm = this; + + console.log(vm.activePanel); + console.log(vm.hackathonObj); + addPopover(); + + switch (input) { + default: + case 0: + newPathName = 'prizes'; + break; + case 1: + newPathName = 'townsquare'; + break; + case 2: + newPathName = 'projects'; + break; + case 3: + newPathName = 'chat'; + break; + case 4: + newPathName = 'participants'; + break; + } + let newUrl = `/hackathon/${vm.hackathonObj['slug']}/${newPathName}/${window.location.search}`; + + history.pushState({}, `${vm.hackathonObj['slug']} - ${newPathName}`, newUrl); + } + }, + data: () => ({ + is_registered: document.is_registered, + activePanel: document.activePanel, + hackathonObj: document.hackathonObj, + hackathonSponsors: document.hackathonSponsors, + hackathonProjects: [], + chatURL: document.chatURL, + timeuntil: document.timeuntil + }) + }); + }); + +})(jQuery); + diff --git a/app/assets/v2/js/pages/dashboard.js b/app/assets/v2/js/pages/dashboard.js index ab34c6ff6ae..83aa662755f 100644 --- a/app/assets/v2/js/pages/dashboard.js +++ b/app/assets/v2/js/pages/dashboard.js @@ -1,1009 +1,820 @@ /* eslint-disable no-loop-func */ -(function($) { - - let hackathonProjects = [] - let projectsPage = 1; - let hackathonSponsors = document.hackathonSponsors; - let projectsNumPages = ''; - let projectsHasNext = false; - let numProjects = ''; - let hackathonId = document.hasOwnProperty('hackathon_id') ? document.hackathon_id : ''; - - var filters = [ - 'experience_level', - 'project_length', - 'bounty_type', - 'bounty_filter', - 'moderation_filter', - 'network', - 'idx_status', - 'project_type', - 'permission_type', - 'misc', - 'applicants' - ]; - var local_storage_keys = JSON.parse(JSON.stringify(filters)); - - local_storage_keys.push('keywords'); - local_storage_keys.push('org'); - - results_limit = 10; - if (document.hackathon) { - let hackathon_orgs = []; - - $('[name=org]').each(function() { - hackathon_orgs.push($(this).val()); - }); - - const org = getURLParams('org'); +var filters = [ + 'experience_level', + 'project_length', + 'bounty_type', + 'bounty_filter', + 'moderation_filter', + 'network', + 'idx_status', + 'project_type', + 'permission_type', + 'misc', + 'applicants' +]; +var local_storage_keys = JSON.parse(JSON.stringify(filters)); + +local_storage_keys.push('keywords'); +local_storage_keys.push('org'); + +results_limit = 10; + +if (document.hackathon) { + let hackathon_orgs = []; + + $('[name=org]').each(function() { + hackathon_orgs.push($(this).val()); + }); - hackathon_orgs.includes(org) ? - $(`#${org}`).prop('checked', true) : - $(`#${hackathon_orgs[0]}`).prop('checked', true); + const org = getURLParams('org'); - } + hackathon_orgs.includes(org) ? + $(`#${org}`).prop('checked', true) : + $(`#${hackathon_orgs[0]}`).prop('checked', true); - var localStorage; +} - var explorer = { }; +var localStorage; - try { - localStorage = window.localStorage; - } catch (e) { - localStorage = {}; - } +var explorer = { }; - function scrollSlider(element, cardSize) { - const arrowLeft = $('#arrowLeft'); - const arrowRight = $('#arrowRight'); +try { + localStorage = window.localStorage; +} catch (e) { + localStorage = {}; +} - arrowLeft.on('click', function() { - element[0].scrollBy({left: -cardSize, behavior: 'smooth'}); - }); - arrowRight.on('click', function() { - element[0].scrollBy({left: cardSize, behavior: 'smooth'}); - }); +function scrollSlider(element, cardSize) { + const arrowLeft = $('#arrowLeft'); + const arrowRight = $('#arrowRight'); - element.on('scroll mouseenter', function() { - if (this.clientWidth === (this.scrollWidth - this.scrollLeft)) { - arrowRight.hide(); - } else { - arrowRight.show(); - } + arrowLeft.on('click', function() { + element[0].scrollBy({left: -cardSize, behavior: 'smooth'}); + }); + arrowRight.on('click', function() { + element[0].scrollBy({left: cardSize, behavior: 'smooth'}); + }); - if (this.scrollLeft < 10) { - arrowLeft.hide(); - } else { - arrowLeft.show(); - } - }); - } + element.on('scroll mouseenter', function() { + if (this.clientWidth === (this.scrollWidth - this.scrollLeft)) { + arrowRight.hide(); + } else { + arrowRight.show(); + } - scrollSlider($('#featured-card-container'), 288); + if (this.scrollLeft < 10) { + arrowLeft.hide(); + } else { + arrowLeft.show(); + } + }); +} - function debounce(func, wait, immediate) { - var timeout; +scrollSlider($('#featured-card-container'), 288); - return function() { - var context = this; - var args = arguments; - var later = function() { - timeout = null; - if (!immediate) - func.apply(context, args); - }; - var callNow = immediate && !timeout; +function debounce(func, wait, immediate) { + var timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) + return function() { + var context = this; + var args = arguments; + var later = function() { + timeout = null; + if (!immediate) func.apply(context, args); }; - } + var callNow = immediate && !timeout; + + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) + func.apply(context, args); + }; +} - const scrub = value => value.replace(/[!@#$%^&*(),.?":{}|<>]+/g, ''); +const scrub = value => value.replace(/[!@#$%^&*(),.?":{}|<>]+/g, ''); - /** +/** * Fetches all filters options from the URI */ - var getActiveFilters = function() { +var getActiveFilters = function() { - if (window.location.search) { - resetFilters(); - } - let _filters = filters.slice(); - - _filters.push('keywords', 'order_by', 'org', 'tab'); - if (document.hackathon) { - resetFilters(true); - filters.push('org', 'tab'); + if (window.location.search) { + resetFilters(); + } + let _filters = filters.slice(); + _filters.push('keywords', 'order_by', 'org'); + if (document.hackathon) { + resetFilters(true); + filters.push('org'); + } + _filters.forEach(filter => { + if (getParam(filter)) { + localStorage[filter] = getParam(filter).replace(/^,|,\s*$/g, ''); } - _filters.forEach(filter => { - if (getParam(filter)) { - localStorage[filter] = getParam(filter).replace(/^,|,\s*$/g, ''); - } - }); - }; + }); +}; - /** +/** * Build URI based on selected filter */ - var buildURI = function(custom_filters) { - let uri = ''; - let _filters = []; - - if (custom_filters) { - _filters = custom_filters; - } else { - _filters = filters.slice(); - _filters.push('keywords', 'order_by', 'org'); - } +var buildURI = function(custom_filters) { + let uri = ''; + let _filters = []; + + if (custom_filters) { + _filters = custom_filters; + } else { + _filters = filters.slice(); + _filters.push('keywords', 'order_by', 'org'); + } - _filters.forEach((filter) => { - if (localStorage[filter] && + _filters.forEach((filter) => { + if (localStorage[filter] && localStorage[filter] != 'any') { - uri += (filter + '=' + localStorage[filter] + '&'); - } - }); + uri += (filter + '=' + localStorage[filter] + '&'); + } + }); - return uri.slice(0, -1); - }; + return uri.slice(0, -1); +}; - /** +/** * Updates localStorage with selected filters */ - var save_sidebar_latest = function() { - localStorage['order_by'] = $('#sort_option').val(); +var save_sidebar_latest = function() { + localStorage['order_by'] = $('#sort_option').val(); - filters.forEach((filter) => { - localStorage[filter] = ''; - if (filter === 'applicants') { - localStorage[filter] = $('#applicants_box').val(); - } else { - $('input[name="' + filter + '"]:checked').each(function() { - localStorage[filter] += $(this).val() + ','; - }); - } + filters.forEach((filter) => { + localStorage[filter] = ''; + if (filter === 'applicants') { + localStorage[filter] = $('#applicants_box').val(); + } else { + $('input[name="' + filter + '"]:checked').each(function() { + localStorage[filter] += $(this).val() + ','; + }); + } - localStorage[filter] = localStorage[filter].replace(/^,|,\s*$/g, ''); - }); - }; + localStorage[filter] = localStorage[filter].replace(/^,|,\s*$/g, ''); + }); +}; - // saves search information default - const set_sidebar_defaults = () => { - const q = getParam('q'); - const org = getParam('org'); - const applicants = getParam('applicants'); - - if (q) { - const keywords = decodeURIComponent(q).replace(/^,|\s|,\s*$/g, ''); - - if (localStorage['keywords']) { - keywords.split(',').forEach(function(v, k) { - if (localStorage['keywords'].indexOf(v) === -1) { - localStorage['keywords'] += ',' + v; - } - }); - } else { - localStorage['keywords'] = keywords; - } - } +// saves search information default +const set_sidebar_defaults = () => { + const q = getParam('q'); + const org = getParam('org'); + const applicants = getParam('applicants'); - if (org) { - if (localStorage['org']) { - org.split(',').forEach(function(value) { - if (localStorage['org'].indexOf(value) === -1) { - localStorage['org'] += ',' + value; - } - }); - } else { - localStorage['org'] = org; - } - } + if (q) { + const keywords = decodeURIComponent(q).replace(/^,|\s|,\s*$/g, ''); - if (applicants) { - if (localStorage['applicants']) { - localStorage['applicants'] = applicants; - } + if (localStorage['keywords']) { + keywords.split(',').forEach(function(v, k) { + if (localStorage['keywords'].indexOf(v) === -1) { + localStorage['keywords'] += ',' + v; + } + }); + } else { + localStorage['keywords'] = keywords; } - getActiveFilters(); + } - if (localStorage['order_by']) { - $('#sort_option').val(localStorage['order_by']); - $('#sort_option').selectmenu().selectmenu('refresh'); + if (org) { + if (localStorage['org']) { + org.split(',').forEach(function(value) { + if (localStorage['org'].indexOf(value) === -1) { + localStorage['org'] += ',' + value; + } + }); + } else { + localStorage['org'] = org; } + } - filters.forEach((filter) => { - if (localStorage[filter]) { - if (filter === 'applicants') { - $('#applicants_box').val(localStorage[filter]).trigger('change.select2'); - } + if (applicants) { + if (localStorage['applicants']) { + localStorage['applicants'] = applicants; + } + } + getActiveFilters(); - localStorage[filter].split(',').forEach(function(val) { - $('input[name="' + filter + '"][value="' + val + '"]').prop('checked', true); - }); + if (localStorage['order_by']) { + $('#sort_option').val(localStorage['order_by']); + $('#sort_option').selectmenu().selectmenu('refresh'); + } - if ($('input[name="' + filter + '"][value!=any]:checked').length > 0) - $('input[name="' + filter + '"][value=any]').prop('checked', false); + filters.forEach((filter) => { + if (localStorage[filter]) { + if (filter === 'applicants') { + $('#applicants_box').val(localStorage[filter]).trigger('change.select2'); } - }); - }; - var toggleAny = function(event) { - if (!event) - return; - var key = event.target.name; - var anyOption = $('input[name="' + key + '"][value=any]'); + localStorage[filter].split(',').forEach(function(val) { + $('input[name="' + filter + '"][value="' + val + '"]').prop('checked', true); + }); - // Selects option 'any' when no filter is applied - if ($('input[name="' + key + '"]:checked').length === 0) { - anyOption.prop('checked', true); - return; + if ($('input[name="' + filter + '"][value!=any]:checked').length > 0) + $('input[name="' + filter + '"][value=any]').prop('checked', false); } - if (event.target.value === 'any') { + }); +}; + +var toggleAny = function(event) { + if (!event) + return; + var key = event.target.name; + var anyOption = $('input[name="' + key + '"][value=any]'); + + // Selects option 'any' when no filter is applied + if ($('input[name="' + key + '"]:checked').length === 0) { + anyOption.prop('checked', true); + return; + } + if (event.target.value === 'any') { // Deselect other filters when 'any' is selected - $('input[name="' + key + '"][value!=any]').prop('checked', false); - } else { + $('input[name="' + key + '"][value!=any]').prop('checked', false); + } else { // Deselect option 'any' when another filter is selected - anyOption.prop('checked', false); - } - }; + anyOption.prop('checked', false); + } +}; - var addTechStackKeywordFilters = function(value) { - if (localStorage['keywords']) { - const keywords = localStorage['keywords']; - const new_value = ',' + value; +var addTechStackKeywordFilters = function(value) { + if (localStorage['keywords']) { + const keywords = localStorage['keywords']; + const new_value = ',' + value; - if (keywords === value || + if (keywords === value || keywords.indexOf(new_value) !== -1 || keywords.indexOf(value + ',') !== -1) { - return; - } - localStorage['keywords'] = keywords + new_value; - } else { - localStorage['keywords'] = value; + return; } - $('.filter-tags').append('' + scrub(value) + '' + + localStorage['keywords'] = keywords + new_value; + } else { + localStorage['keywords'] = value; + } + $('.filter-tags').append('' + scrub(value) + '' + ''); - }; +}; - var addTechStackOrgFilters = function(value) { - if (localStorage['org']) { - const org = localStorage['org']; - const new_value = ',' + value; +var addTechStackOrgFilters = function(value) { + if (localStorage['org']) { + const org = localStorage['org']; + const new_value = ',' + value; - if (org === value || + if (org === value || org.indexOf(new_value) !== -1 || org.indexOf(value + ',') !== -1) { - return; - } - localStorage['org'] = org + new_value; - } else { - localStorage['org'] = value; + return; } + localStorage['org'] = org + new_value; + } else { + localStorage['org'] = value; + } - $('.filter-tags').append('' + scrub(value) + '' + + $('.filter-tags').append('' + scrub(value) + '' + ''); - }; +}; - var getFilters = function() { - var _filters = []; +var getFilters = function() { + var _filters = []; - filters.forEach((filter) => { - $.each($('input[name="' + filter + '"]:checked'), function() { - if ($(this).attr('val-ui')) { - _filters.push('' + $(this).attr('val-ui') + '' + + filters.forEach((filter) => { + $.each($('input[name="' + filter + '"]:checked'), function() { + if ($(this).attr('val-ui')) { + _filters.push('' + $(this).attr('val-ui') + '' + ''); - } - }); + } }); + }); - if (localStorage['keywords']) { - localStorage['keywords'].split(',').forEach(function(v, k) { - _filters.push('' + scrub(v) + '' + + if (localStorage['keywords']) { + localStorage['keywords'].split(',').forEach(function(v, k) { + _filters.push('' + scrub(v) + '' + ''); - }); - } + }); + } - if (localStorage['org']) { - localStorage['org'].split(',').forEach(function(v, k) { - _filters.push('' + scrub(v) + '' + + if (localStorage['org']) { + localStorage['org'].split(',').forEach(function(v, k) { + _filters.push('' + scrub(v) + '' + ''); - }); - } + }); + } - $('.filter-tags').html(_filters); - }; + $('.filter-tags').html(_filters); +}; - var removeFilter = function(key, value) { - if (key !== 'keywords' && key !== 'org') { - $('input[name="' + key + '"][value="' + value + '"]').prop('checked', false); - } else { - localStorage[key] = localStorage[key].replace(value, '').replace(',,', ','); +var removeFilter = function(key, value) { + if (key !== 'keywords' && key !== 'org') { + $('input[name="' + key + '"][value="' + value + '"]').prop('checked', false); + } else { + localStorage[key] = localStorage[key].replace(value, '').replace(',,', ','); - // Removing the start and last comma to avoid empty element when splitting with comma - localStorage[key] = localStorage[key].replace(/^,|,\s*$/g, ''); - } + // Removing the start and last comma to avoid empty element when splitting with comma + localStorage[key] = localStorage[key].replace(/^,|,\s*$/g, ''); + } - reset_offset(); - refreshBounties(null, 0, false); - }; + reset_offset(); + refreshBounties(null, 0, false); +}; - var get_search_URI = function(offset, order) { - var uri = '/api/v0.1/bounties/slim/?'; - var keywords = ''; - var org = ''; +var get_search_URI = function(offset, order) { + var uri = '/api/v0.1/bounties/slim/?'; + var keywords = ''; + var org = ''; - filters.forEach((filter) => { - var active_filters = []; + filters.forEach((filter) => { + var active_filters = []; - $.each ($('input[name="' + filter + '"]:checked'), function() { - if ($(this).val()) { - active_filters.push($(this).val()); + $.each ($('input[name="' + filter + '"]:checked'), function() { + if ($(this).val()) { + active_filters.push($(this).val()); + } + }); + + var val = active_filters.toString(); + + if ((filter === 'bounty_filter') && val) { + var values = val.split(','); + + values.forEach(function(_value) { + var _key; + + if (_value === 'createdByMe') { + _key = 'bounty_owner_github_username'; + _value = document.contxt.github_handle; + } else if (_value === 'startedByMe') { + _key = 'interested_github_username'; + _value = document.contxt.github_handle; + } else if (_value === 'fulfilledByMe') { + _key = 'fulfiller_github_username'; + _value = document.contxt.github_handle; + } else if (_value === 'reservedForMe') { + _key = 'reserved_for_user_handle'; + _value = document.contxt.github_handle; } - }); - var val = active_filters.toString(); - - if ((filter === 'bounty_filter') && val) { - var values = val.split(','); - - values.forEach(function(_value) { - var _key; - - if (_value === 'createdByMe') { - _key = 'bounty_owner_github_username'; - _value = document.contxt.github_handle; - } else if (_value === 'startedByMe') { - _key = 'interested_github_username'; - _value = document.contxt.github_handle; - } else if (_value === 'fulfilledByMe') { - _key = 'fulfiller_github_username'; - _value = document.contxt.github_handle; - } else if (_value === 'reservedForMe') { - _key = 'reserved_for_user_handle'; - _value = document.contxt.github_handle; - } - - if (_value !== 'any') { - if (!uri.endsWith('?')) - uri += '&'; - uri += _key + '=' + _value; - } - }); - - // TODO: Check if value myself is needed for coinbase - if (val === 'fulfilledByMe') { - filter = 'bounty_owner_address'; - val = 'myself'; + if (_value !== 'any') { + if (!uri.endsWith('?')) + uri += '&'; + uri += _key + '=' + _value; } + }); + + // TODO: Check if value myself is needed for coinbase + if (val === 'fulfilledByMe') { + filter = 'bounty_owner_address'; + val = 'myself'; } - if (filter === 'applicants') { - val = $('#applicants_box').val(); - } + } + if (filter === 'applicants') { + val = $('#applicants_box').val(); + } - if (val && val !== 'any' && + if (val && val !== 'any' && filter !== 'bounty_filter' && filter !== 'bounty_owner_address') { - if (!uri.endsWith('?')) - uri += '&'; - uri += filter + '=' + val; + if (!uri.endsWith('?')) + uri += '&'; + uri += filter + '=' + val; + } + }); + + if (localStorage['keywords']) { + localStorage['keywords'].split(',').forEach(function(v, pos, arr) { + keywords += v; + if (arr.length > pos + 1) { + keywords += ','; } }); + } - if (localStorage['keywords']) { - localStorage['keywords'].split(',').forEach(function(v, pos, arr) { - keywords += v; - if (arr.length > pos + 1) { - keywords += ','; - } - }); - } + if (keywords) { + uri += '&keywords=' + keywords; + } - if (keywords) { - uri += '&keywords=' + keywords; - } + if (localStorage['org']) { + localStorage['org'].split(',').forEach(function(v, pos, arr) { + org += v; + if (arr.length > pos + 1) { + org += ','; + } + }); + } - if (localStorage['org']) { - localStorage['org'].split(',').forEach(function(v, pos, arr) { - org += v; - if (arr.length > pos + 1) { - org += ','; - } - }); - } + if (org) { + uri += '&org=' + org; + } + let order_by; - if (org) { - uri += '&org=' + org; - } - let order_by; + if (order) { + order_by = order; + } else { + order_by = localStorage['order_by']; + } - if (order) { - order_by = order; - } else { - order_by = localStorage['order_by']; - } + if (document.hackathon) { + uri += `&event_tag=${document.hackathon}`; + } - if (document.hackathon) { - uri += `&event_tag=${document.hackathon}`; - } + if (typeof order_by !== 'undefined') { + uri += '&order_by=' + order_by; + } - if (typeof order_by !== 'undefined') { - uri += '&order_by=' + order_by; - } + uri += '&offset=' + offset; + uri += '&limit=' + results_limit; - uri += '&offset=' + offset; - uri += '&limit=' + results_limit; + return uri; +}; - return uri; - }; +var trigger_scroll = debounce(function() { + var scrollPos = $(document).scrollTop(); + var last_active_bounty = $('.bounty_row.result:last-child'); + + if (last_active_bounty.length == 0) { + return; + } - var trigger_scroll = debounce(function() { - var scrollPos = $(document).scrollTop(); - var last_active_bounty = $('.bounty_row.result:last-child'); + var window_height = $(window).height(); + var have_painted_all_bounties = false;// TODO + var buffer = 500; + var get_more = !have_painted_all_bounties && ((last_active_bounty.offset().top) < (scrollPos + buffer + window_height)); - if (last_active_bounty.length == 0) { - return; - } + if (get_more && !document.done_loading_results) { - var window_height = $(window).height(); - var have_painted_all_bounties = false;// TODO - var buffer = 500; - var get_more = !have_painted_all_bounties && ((last_active_bounty.offset().top) < (scrollPos + buffer + window_height)); + // move loading indicator + var loading_html = $('.loading_img').clone().wrap('

').parent().html(); - if (get_more && !document.done_loading_results) { + $('.loading_img').remove(); + $('#bounties').append(loading_html); + $('.loading_img').css('display', 'block'); - // move loading indicator - var loading_html = $('.loading_img').clone().wrap('

').parent().html(); + document.offset = parseInt(document.offset) + parseInt(results_limit); + refreshBounties(null, document.offset, true); + } +}, 200); - $('.loading_img').remove(); - $('#bounties').append(loading_html); - $('.loading_img').css('display', 'block'); +$(window).scroll(trigger_scroll); +$('body').bind('touchmove', trigger_scroll); - document.offset = parseInt(document.offset) + parseInt(results_limit); - refreshBounties(null, document.offset, true); - } - }, 200); - - $(window).scroll(trigger_scroll); - $('body').bind('touchmove', trigger_scroll); - - - var addPopover = () => { - // $('[data-toggle="popover"]').popover(); - console.log('pops enabled'); - $('.bounty_row').popover({ - html: true, - trigger: 'hover', - placement: 'auto', - template: `

` - }); - }; +var reset_offset = function() { + document.done_loading_results = false; + document.offset = 0; +}; - var reset_offset = function() { - document.done_loading_results = false; - document.offset = 0; - }; +let organizations = []; - let organizations = []; +var refreshBounties = function(event, offset, append) { - var refreshBounties = function(event, offset, append) { + // Allow search for freeform text + var searchInput = $('#keywords')[0]; + var orgInput = $('#org')[0]; - // Allow search for freeform text - var searchInput = $('#keywords')[0]; - var orgInput = $('#org')[0]; + $('#results-count span.num').html(''); + if (searchInput && searchInput.value.length > 0) { + addTechStackKeywordFilters(searchInput.value.trim()); + searchInput.value = ''; + searchInput.blur(); + $('.close-icon').hide(); + } - $('#results-count span.num').html(''); - if (searchInput && searchInput.value.length > 0) { - addTechStackKeywordFilters(searchInput.value.trim()); - searchInput.value = ''; - searchInput.blur(); + if (!document.hackathon) { + if (orgInput.value.length > 0) { + addTechStackOrgFilters(orgInput.value.trim()); + orgInput.value = ''; + orgInput.blur(); $('.close-icon').hide(); } - if (!document.hackathon) { - if (orgInput.value.length > 0) { - addTechStackOrgFilters(orgInput.value.trim()); - orgInput.value = ''; - orgInput.blur(); - $('.close-icon').hide(); - } + save_sidebar_latest(); + toggleAny(event); + getFilters(); + window.history.pushState('', '', window.location.pathname + '?' + buildURI()); + } else { + toggleAny(event); - save_sidebar_latest(); - toggleAny(event); - getFilters(); - window.history.pushState('', '', window.location.pathname + '?' + buildURI()); - } else { - toggleAny(event); + const org = $("input[name='org']:checked").val(); - const org = $("input[name='org']:checked").val(); - console.log("we're here") - localStorage['org'] = org === 'any' ? '' : org; - localStorage['order_by'] = $('#sort_option').val(); - window.history.pushState('', '', window.location.pathname + '?' + buildURI([ 'org', 'tab' ])); - } + localStorage['org'] = org === 'any' ? '' : org; + localStorage['order_by'] = $('#sort_option').val(); + window.history.pushState('', '', window.location.pathname + '?' + buildURI(['org'])); + } - if (!append) { - $('.nonefound').css('display', 'none'); - $('.loading').css('display', 'block'); - $('.bounty_row').remove(); - } + if (!append) { + $('.nonefound').css('display', 'none'); + $('.loading').css('display', 'block'); + $('.bounty_row').remove(); + } - const uri = get_search_URI(offset); - const uriFeatured = get_search_URI(offset, '-featuring_date'); - let bountiesURI; - let featuredBountiesURI; + const uri = get_search_URI(offset); + const uriFeatured = get_search_URI(offset, '-featuring_date'); + let bountiesURI; + let featuredBountiesURI; - if (!uri.endsWith('?')) { - bountiesURI = uri; - featuredBountiesURI = uriFeatured + '&'; - } - // bountiesURI += ''; - featuredBountiesURI += 'is_featured=True'; + if (!uri.endsWith('?')) { + bountiesURI = uri; + featuredBountiesURI = uriFeatured + '&'; + } + // bountiesURI += ''; + featuredBountiesURI += 'is_featured=True'; - // Abort pending request if any subsequent request - if (explorer.bounties_request && explorer.bounties_request.readyState !== 4) { - explorer.bounties_request.abort(); - } + // Abort pending request if any subsequent request + if (explorer.bounties_request && explorer.bounties_request.readyState !== 4) { + explorer.bounties_request.abort(); + } - explorer.bounties_request = $.get(bountiesURI, function(results, x) { - results = sanitizeAPIResults(results); + explorer.bounties_request = $.get(bountiesURI, function(results, x) { + results = sanitizeAPIResults(results); - if (results.length === 0 && !append) { - if (localStorage['referrer'] === 'onboard' && !document.hackathon) { - $('.no-results').removeClass('hidden'); - $('#dashboard-content').addClass('hidden'); - } else { - $('.nonefound').css('display', 'block'); - } + if (results.length === 0 && !append) { + if (localStorage['referrer'] === 'onboard' && !document.hackathon) { + $('.no-results').removeClass('hidden'); + $('#dashboard-content').addClass('hidden'); + } else { + $('.nonefound').css('display', 'block'); } + } - document.last_bounty_rendered = 0; + document.last_bounty_rendered = 0; - var html = renderBountyRowsFromResults(results, true); + var html = renderBountyRowsFromResults(results, true); - if (html) { - $('#bounties').append(html); - } + if (html) { + $('#bounties').append(html); + } - document.done_loading_results = results.length < results_limit; + document.done_loading_results = results.length < results_limit; - $('div.bounty_row.result').each(function() { - var href = $(this).attr('href'); + $('div.bounty_row.result').each(function() { + var href = $(this).attr('href'); - if (typeof $(this).changeElementType !== 'undefined') { - $(this).changeElementType('a'); // hack so that users can right click on the element - } + if (typeof $(this).changeElementType !== 'undefined') { + $(this).changeElementType('a'); // hack so that users can right click on the element + } - $(this).attr('href', href); + $(this).attr('href', href); + }); + if (localStorage['referrer'] === 'onboard') { + $('.bounty_row').each(function(index) { + if (index > 2) + $(this).addClass('hidden'); }); + } - if (localStorage['referrer'] === 'onboard') { - $('.bounty_row').each(function(index) { - if (index > 2) - $(this).addClass('hidden'); - }); - } - - $('#results-count span.num').html(offset + results.length); - if (results.length == results_limit) { - $('#results-count span.plus').html('+'); - } else { - $('#results-count span.plus').html(''); - } - }).fail(function() { - if (explorer.bounties_request.readyState !== 0) - _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); - }).always(function() { - $('.loading').css('display', 'none'); - addPopover(); - }); + $('#results-count span.num').html(offset + results.length); + if (results.length == results_limit) { + $('#results-count span.plus').html('+'); + } else { + $('#results-count span.plus').html(''); + } + }).fail(function() { + if (explorer.bounties_request.readyState !== 0) + _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); + }).always(function() { + $('.loading').css('display', 'none'); + }); - explorer.bounties_request = $.get(featuredBountiesURI, function(results, x) { - results = sanitizeAPIResults(results); + explorer.bounties_request = $.get(featuredBountiesURI, function(results, x) { + results = sanitizeAPIResults(results); - if (results.length === 0 && !append) { - $('.featured-bounties').hide(); - if (localStorage['referrer'] === 'onboard') { - $('.no-results').removeClass('hidden'); - $('#dashboard-content').addClass('hidden'); - } else { - $('.nonefound').css('display', 'none'); - } + if (results.length === 0 && !append) { + $('.featured-bounties').hide(); + if (localStorage['referrer'] === 'onboard') { + $('.no-results').removeClass('hidden'); + $('#dashboard-content').addClass('hidden'); + } else { + $('.nonefound').css('display', 'none'); } + } - var html = renderFeaturedBountiesFromResults(results, true); + var html = renderFeaturedBountiesFromResults(results, true); - if (html) { - $('.featured-bounties').show(); - $('#featured-card-container').html(html); - } - }).fail(function() { - if (explorer.bounties_request.readyState !== 0) - _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); - }).always(function() { - $('.loading').css('display', 'none'); - addPopover(); - }); - }; + if (html) { + $('.featured-bounties').show(); + $('#featured-card-container').html(html); + } + }).fail(function() { + if (explorer.bounties_request.readyState !== 0) + _alert({ message: gettext('got an error. please try again, or contact support@gitcoin.co') }, 'error'); + }).always(function() { + $('.loading').css('display', 'none'); + }); +}; +window.addEventListener('load', function() { + set_sidebar_defaults(); + reset_offset(); + refreshBounties(null, 0, false); +}); - /** +/** * removed all filters from the sidebar search * resetKeyword : boolean */ - var resetFilters = function(resetKeyword) { - filters.forEach((filter) => { - var tag = ($('input[name="' + filter + '"][value]')); - - for (var j = 0; j < tag.length; j++) { - if (tag[j].value == 'any') - $('input[name="' + filter + '"][value="any"]').prop('checked', true); - else - $('input[name="' + filter + '"][value="' + tag[j].value + '"]').prop('checked', false); - } - - if (resetKeyword && filter === 'applicants' && !document.hackathon) { - $('#applicants_box').val('ALL').trigger('change.select2'); - } else if (resetKeyword && filter === 'applicants' && document.hackathon) { - localStorage.setItem(filter, ''); - } - - // Defaults to mainnet on clear filters to make it less confusing - $('input[name="network"][value="mainnet"]').prop('checked', true); - }); +var resetFilters = function(resetKeyword) { + filters.forEach((filter) => { + var tag = ($('input[name="' + filter + '"][value]')); - if (resetKeyword && localStorage['keywords']) { - localStorage['keywords'].split(',').forEach(function(v, k) { - removeFilter('keywords', v); - }); + for (var j = 0; j < tag.length; j++) { + if (tag[j].value == 'any') + $('input[name="' + filter + '"][value="any"]').prop('checked', true); + else + $('input[name="' + filter + '"][value="' + tag[j].value + '"]').prop('checked', false); } - if (resetKeyword && localStorage['org'] && !document.hackathon) { - localStorage['org'].split(',').forEach(function(v, k) { - removeFilter('org', v); - }); + if (resetKeyword && filter === 'applicants' && !document.hackathon) { + $('#applicants_box').val('ALL').trigger('change.select2'); + } else if (resetKeyword && filter === 'applicants' && document.hackathon) { + localStorage.setItem(filter, ''); } - }; - var initDOM = () => { - $('.js-select2').each(function() { - $(this).select2({ - minimumResultsForSearch: Infinity - }); - }); + // Defaults to mainnet on clear filters to make it less confusing + $('input[name="network"][value="mainnet"]').prop('checked', true); + }); - $('#expand').on('click', () => { - $('#expand').hide(); - $('#minimize').show(); - $('#sidebar_container form').css({ - 'height': 'auto', - 'display': 'inherit' - }); + if (resetKeyword && localStorage['keywords']) { + localStorage['keywords'].split(',').forEach(function(v, k) { + removeFilter('keywords', v); }); + } - $('#minimize').on('click', () => { - $('#minimize').hide(); - $('#expand').show(); - $('#sidebar_container form').css({ - 'height': 0, - 'display': 'none' - }); + if (resetKeyword && localStorage['org'] && !document.hackathon) { + localStorage['org'].split(',').forEach(function(v, k) { + removeFilter('org', v); }); + } +}; - // Sort select menu - $('#sort_option').selectmenu({ - select: function(event, ui) { - reset_offset(); - refreshBounties(null, 0, false); - event.preventDefault(); - } - }); +(function() { + if (localStorage['referrer'] === 'onboard' && !document.hackathon) { + $('#sidebar_container').addClass('invisible'); + $('#dashboard-title').addClass('hidden'); + $('#onboard-dashboard').removeClass('hidden'); + $('#onboard-footer').removeClass('hidden'); + resetFilters(true); + $('input[name=idx_status][value=open]').prop('checked', true); + $('.search-area input[type=text]').text(getURLParams('q')); - // TODO: DRY - function split(val) { - return val.split(/,\s*/); - } + $('#onboard-alert').on('click', function(e) { - function extractLast(term) { - return split(term).pop(); - } + if (!$('.no-results').hasClass('hidden')) + $('.nonefound').css('display', 'block'); - // Handle search input clear - $('.close-icon') - .on('click', function(e) { - e.preventDefault(); - $('#keywords').val(''); - $(this).hide(); + $('.bounty_row').each(function(index) { + $(this).removeClass('hidden'); }); - $('#keywords') - .on('input', function() { - if ($(this).val()) { - $('.close-icon').show(); - } else { - $('.close-icon').hide(); - } - }) - // don't navigate away from the field on tab when selecting an item - .on('keydown', function(event) { - if (event.keyCode === $.ui.keyCode.TAB && $(this).autocomplete('instance').menu.active) { - event.preventDefault(); - } - }) - .autocomplete({ - minLength: 0, - source: function(request, response) { - // delegate back to autocomplete, but extract the last term - response($.ui.autocomplete.filter(document.keywords, extractLast(request.term))); - }, - focus: function() { - // prevent value inserted on focus - return false; - }, - select: function(event, ui) { - var terms = split(this.value); - - $('.close-icon').hide(); - - // remove the current input - terms.pop(); - - // add the selected item - terms.push(ui.item.value); - - // add placeholder to get the comma-and-space at the end - terms.push(''); - - this.value = ''; + $('#onboard-dashboard').addClass('hidden'); + $('#onboard-footer').addClass('hidden'); + $('#sidebar_container').removeClass('invisible'); + $('#dashboard-title').removeClass('hidden'); + $('#dashboard-content').removeClass('hidden'); - addTechStackKeywordFilters(ui.item.value); + localStorage['referrer'] = ''; + e.preventDefault(); + }); + } else { + $('#dashboard-content').removeClass('hidden'); + $('#onboard-dashboard').addClass('hidden'); + $('#onboard-footer').addClass('hidden'); + $('#sidebar_container').removeClass('invisible'); + $('#dashboard-title').removeClass('hidden'); + } +})(); - return false; - } - }); +$(document).ready(function() { - // sidebar clear - $('.dashboard #clear').on('click', function(e) { - e.preventDefault(); - resetFilters(true); - reset_offset(); - refreshBounties(null, 0, false); + $('.js-select2').each(function() { + $(this).select2({ + minimumResultsForSearch: Infinity }); + }); - // search bar - $('#sidebar_container').delegate('#new_search', 'click', function(e) { - reset_offset(); - refreshBounties(null, 0, false); - e.preventDefault(); + $('#expand').on('click', () => { + $('#expand').hide(); + $('#minimize').show(); + $('#sidebar_container form').css({ + 'height': 'auto', + 'display': 'inherit' }); + }); - $('.search-area input[type=text]').keypress(function(e) { - if (e.which == 13) { - reset_offset(); - refreshBounties(null, 0, false); - e.preventDefault(); - } + $('#minimize').on('click', () => { + $('#minimize').hide(); + $('#expand').show(); + $('#sidebar_container form').css({ + 'height': 0, + 'display': 'none' }); + }); - $(` - .sidebar_search input[type=radio], .sidebar_search input[type=checkbox], - .sidebar_search .js-select2, #org - `).on('change', function(e) { + // Sort select menu + $('#sort_option').selectmenu({ + select: function(event, ui) { reset_offset(); refreshBounties(null, 0, false); + event.preventDefault(); + } + }); + + // TODO: DRY + function split(val) { + return val.split(/,\s*/); + } + + function extractLast(term) { + return split(term).pop(); + } + + // Handle search input clear + $('.close-icon') + .on('click', function(e) { e.preventDefault(); + $('#keywords').val(''); + $(this).hide(); }); - if (localStorage['referrer'] === 'onboard' && !document.hackathon) { - $('#sidebar_container').addClass('invisible'); - $('#dashboard-title').addClass('hidden'); - $('#onboard-dashboard').removeClass('hidden'); - $('#onboard-footer').removeClass('hidden'); - resetFilters(true); - $('input[name=idx_status][value=open]').prop('checked', true); - $('.search-area input[type=text]').text(getURLParams('q')); - - $('#onboard-alert').on('click', function(e) { + $('#keywords') + .on('input', function() { + if ($(this).val()) { + $('.close-icon').show(); + } else { + $('.close-icon').hide(); + } + }) + // don't navigate away from the field on tab when selecting an item + .on('keydown', function(event) { + if (event.keyCode === $.ui.keyCode.TAB && $(this).autocomplete('instance').menu.active) { + event.preventDefault(); + } + }) + .autocomplete({ + minLength: 0, + source: function(request, response) { + // delegate back to autocomplete, but extract the last term + response($.ui.autocomplete.filter(document.keywords, extractLast(request.term))); + }, + focus: function() { + // prevent value inserted on focus + return false; + }, + select: function(event, ui) { + var terms = split(this.value); - if (!$('.no-results').hasClass('hidden')) - $('.nonefound').css('display', 'block'); + $('.close-icon').hide(); - $('.bounty_row').each(function(index) { - $(this).removeClass('hidden'); - }); + // remove the current input + terms.pop(); - $('#onboard-dashboard').addClass('hidden'); - $('#onboard-footer').addClass('hidden'); - $('#sidebar_container').removeClass('invisible'); - $('#dashboard-title').removeClass('hidden'); - $('#dashboard-content').removeClass('hidden'); + // add the selected item + terms.push(ui.item.value); - localStorage['referrer'] = ''; - e.preventDefault(); - }); - } else { - $('#dashboard-content').removeClass('hidden'); - $('#onboard-dashboard').addClass('hidden'); - $('#onboard-footer').addClass('hidden'); - $('#sidebar_container').removeClass('invisible'); - $('#dashboard-title').removeClass('hidden'); - } - addPopover(); - }; + // add placeholder to get the comma-and-space at the end + terms.push(''); + this.value = ''; - $(function() { - Vue = Vue.extend({ - delimiters: [ '[[', ']]' ] - }); - Vue.component('project-directory', { - delimiters: [ '[[', ']]' ], - methods: { - fetchProjects: function(newPage) { - let vm = this; - - vm.isLoading = true; - vm.noResults = false; - - if (newPage) { - vm.projectsPage = newPage; - } - vm.params.page = vm.projectsPage; - vm.params.hackathon = hackathonId; - if (vm.searchTerm) { - vm.params.search = vm.searchTerm; - } else { - delete vm.params['search']; - } - - let searchParams = new URLSearchParams(vm.params); - - let apiUrlProjects = `/api/v0.1/projects_fetch/?${searchParams.toString()}`; - - var getProjects = fetchData (apiUrlProjects, 'GET'); - - $.when(getProjects).then(function(response) { - vm.hackathonProjects = []; - response.data.forEach(function(item) { - vm.hackathonProjects.push(item); - }); - - vm.projectsNumPages = response.num_pages; - vm.projectsHasNext = response.has_next; - vm.numProjects = response.count; - if (vm.projectsHasNext) { - vm.projectsPage = ++vm.projectsPage; - - } else { - vm.projectsPage = 1; - } - - if (vm.hackathonProjects.length) { - vm.noResults = false; - } else { - vm.noResults = true; - } - vm.isLoading = false; - }); - }, - searchProjects: function() { - let vm = this; - - vm.hackathonProjects = []; - - vm.fetchProjects(1); + addTechStackKeywordFilters(ui.item.value); - } - }, - data: () => ({ - hackathonSponsors, - hackathonProjects, - projectsPage, - hackathonId, - projectsNumPages, - projectsHasNext, - numProjects, - media_url, - searchTerm: null, - bottom: false, - params: {}, - isFunder: false, - showModal: false, - showFilters: true, - skills: document.keywords || [], - selectedSkills: [], - noResults: false, - isLoading: true, - hideFilterButton: false - }), - mounted() { - this.fetchProjects(); - this.$watch('params', function(newVal, oldVal) { - this.searchProjects(); - }, { - deep: true - }); - }, - created() { - // this.extractURLFilters(); - }, - beforeMount() { - window.addEventListener('scroll', () => { - this.bottom = this.bottomVisible(); - }, false); - }, - beforeDestroy() { - window.removeEventListener('scroll', () => { - this.bottom = this.bottomVisible(); - }); + return false; } }); - var app = new Vue({ - delimiters: [ '[[', ']]' ], - el: '#dashboard-vue-app', - updated: () => { - addPopover(); - }, - mounted: () => { - setTimeout(() => { - set_sidebar_defaults(); - reset_offset(); - refreshBounties(null, 0, false); - initDOM(); - addPopover(); - }, 0); - }, - methods: { - tabChange: (input) => { - let vm = this; - - console.log(vm.activePanel); - console.log(vm.hackathonObj); - addPopover(); - - switch (input) { - default: - case 0: - newPathName = 'townsquare'; - break; - case 1: - newPathName = 'chat'; - break; - case 2: - newPathName = 'prizes'; - break; - case 3: - newPathName = 'projects'; - break; - case 4: - newPathName = 'participants'; - break; - } - let newUrl = `/hackathon/${vm.hackathonObj['slug']}/${newPathName}/${window.location.search}`; - - history.pushState({}, `${vm.hackathonObj['slug']} - ${newPathName}`, newUrl); - } - }, - data: () => ({ - is_registered: document.is_registered, - activePanel: document.activePanel, - hackathonObj: document.hackathonObj, - hackathonSponsors: document.hackathonSponsors, - chatURL: document.chatURL, - timeuntil: document.timeuntil - }) - }); + + // sidebar clear + $('.dashboard #clear').on('click', function(e) { + e.preventDefault(); + resetFilters(true); + reset_offset(); + refreshBounties(null, 0, false); }); -})(jQuery); + // search bar + $('#sidebar_container').delegate('#new_search', 'click', function(e) { + reset_offset(); + refreshBounties(null, 0, false); + e.preventDefault(); + }); + $('.search-area input[type=text]').keypress(function(e) { + if (e.which == 13) { + reset_offset(); + refreshBounties(null, 0, false); + e.preventDefault(); + } + }); + + $(` + .sidebar_search input[type=radio], .sidebar_search input[type=checkbox], + .sidebar_search .js-select2, #org + `).change(function(e) { + reset_offset(); + refreshBounties(null, 0, false); + e.preventDefault(); + }); +}); diff --git a/app/assets/v2/js/status.js b/app/assets/v2/js/status.js index f6a769215c5..b10e85d603a 100644 --- a/app/assets/v2/js/status.js +++ b/app/assets/v2/js/status.js @@ -410,18 +410,20 @@ $(document).ready(function() { injectGiphy('latest'); }); window.addEventListener('DOMContentLoaded', function() { - var button = document.querySelector('#emoji-button'); - var picker = new EmojiButton({ - position: 'left-end' - }); - - if (button && picker) { - picker.on('emoji', function(emoji) { - document.querySelector('textarea').value += emoji; + $(() => { + var button = document.querySelector('#emoji-button'); + var picker = new EmojiButton({ + position: 'left-end' }); - button.addEventListener('click', function() { - picker.pickerVisible ? picker.hidePicker() : picker.showPicker(button); - }); - } + if (button && picker) { + picker.on('emoji', function(emoji) { + document.querySelector('textarea').value += emoji; + }); + + button.addEventListener('click', function() { + picker.pickerVisible ? picker.hidePicker() : picker.showPicker(button); + }); + } + }); }); diff --git a/app/assets/v2/js/users.js b/app/assets/v2/js/users.js index 9009e79928d..5730834934e 100644 --- a/app/assets/v2/js/users.js +++ b/app/assets/v2/js/users.js @@ -3,6 +3,7 @@ let usersPage = 1; let usersNumPages = ''; let usersHasNext = false; let numUsers = ''; +let hackathonId = document.hasOwnProperty('hackathon_id') ? document.hackathon_id : ''; // let funderBounties = []; Vue.mixin({ @@ -17,7 +18,7 @@ Vue.mixin({ vm.usersPage = newPage; } vm.params.page = vm.usersPage; - + vm.params.hackathon = hackathonId; if (vm.searchTerm) { vm.params.search = vm.searchTerm; } else { @@ -28,7 +29,7 @@ Vue.mixin({ vm.params.persona = 'tribe'; } - if (vm.params.persona == 'tribe') { + if (vm.params.persona === 'tribe') { // remove filters which do not apply for tribes directory delete vm.params['rating']; delete vm.params['organisation']; @@ -56,7 +57,7 @@ Vue.mixin({ vm.numUsers = response.count; vm.showBanner = response.show_banner; vm.persona = response.persona; - + vm.rating = response.rating; if (vm.usersHasNext) { vm.usersPage = ++vm.usersPage; @@ -247,8 +248,68 @@ Vue.mixin({ } } }); +Vue = Vue.extend({ + delimiters: [ '[[', ']]' ] +}); +Vue.component('user-directory', { + delimiters: [ '[[', ']]' ], + data: () => ({ + users, + usersPage, + hackathonId, + usersNumPages, + usersHasNext, + numUsers, + media_url, + searchTerm: null, + bottom: false, + params: {}, + funderBounties: [], + currentBounty: undefined, + contributorInvite: undefined, + isFunder: false, + bountySelected: null, + userSelected: [], + showModal: false, + showFilters: !document.getElementById('explore_tribes'), + skills: document.keywords, + selectedSkills: [], + noResults: false, + isLoading: true, + gitcoinIssueUrl: '', + issueDetails: undefined, + errorIssueDetails: undefined, + showBanner: undefined, + persona: undefined, + hideFilterButton: !!document.getElementById('explore_tribes') + }), + mounted() { + this.fetchUsers(); + this.$watch('params', function(newVal, oldVal) { + this.searchUsers(); + }, { + deep: true + }); + }, + created() { + this.fetchBounties(); + this.inviteOnMount(); + this.extractURLFilters(); + }, + beforeMount() { + window.addEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }, false); + }, + beforeDestroy() { + window.removeEventListener('scroll', () => { + this.bottom = this.bottomVisible(); + }); + } +}); if (document.getElementById('gc-users-directory')) { + var app = new Vue({ delimiters: [ '[[', ']]' ], el: '#gc-users-directory', diff --git a/app/dashboard/templates/dashboard/hackathon/hackathons.html b/app/dashboard/templates/dashboard/hackathon/hackathons.html index a78fc33f2fe..ba4c9de6c5d 100644 --- a/app/dashboard/templates/dashboard/hackathon/hackathons.html +++ b/app/dashboard/templates/dashboard/hackathon/hackathons.html @@ -90,7 +90,7 @@
{{ hackath Join {% endif %} {% if hackathon.start_date|timesince >= "1 min" %} - Prizes + Prizes {% endif %} {% if hackathon.show_results %} Projects diff --git a/app/dashboard/templates/dashboard/index-vue.html b/app/dashboard/templates/dashboard/index-vue.html index c7190c038c0..8005d9e5534 100644 --- a/app/dashboard/templates/dashboard/index-vue.html +++ b/app/dashboard/templates/dashboard/index-vue.html @@ -27,7 +27,7 @@ {% include 'shared/cards.html' %} {% endif %} - + @@ -103,10 +103,6 @@ height: 100%; } - #sponsor_sidebar .media-body { - background-color:#ffffff; - } - .card-project-logo { background-color: rgba(255, 255, 255, 0.30); object-fit: contain; @@ -168,10 +164,10 @@ border-radius: 4px; } .hack-logo-wrapper { - position:absolute; - max-width: 185px; - top: -165px; - left: 5%; + position: absolute; + max-width: 240px; + top: -200px; + left: -32%; } .townsquare_header { width: 100%; @@ -179,10 +175,10 @@ overflow: hidden; } .hackathon-logo { - height: 185px; - max-height: 185px; - width: 185px; - max-width: 185px; + height: 240px; + max-height: 240px; + width: 240px; + max-width: 240px; background-color: #090E60; border-radius: 10px; color: white; @@ -192,24 +188,13 @@ align-items: center; } .hackathon-logo img { - height: 115px; + height: 185px; } .register { width: 100%; } - .feed_container_child { - width: 100%; - height:800px; - overflow-y: scroll; - scrollbar-width: none; /* Firefox */ - -ms-overflow-style: none; - } - .feed_container_child::-webkit-scrollbar { /* WebKit */ - width: 0; - height: 0; - } .card-bg { background-color: #0C1A27; @@ -274,7 +259,6 @@ .looking-team { background-color: rgba(62, 0, 255, 0.05); border-radius: 8px; - height: 84.58px; padding: 11px 15px; } .info-card-title { @@ -291,6 +275,15 @@ line-height: 18px; color: #666666; } + + @media(max-width: 767.98px) { + .navbar-brand img { + height:20px; + } + li.navigation > a.nav-link { + font-size:14px; + } + } @@ -307,13 +300,11 @@ {% endif %} -
- -
+