Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove unused JavaScript #195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
//= require jquery
//= require jquery_ujs
//= require linkify
//= require jquery.easing
//= require jquery.blockUI
//= require jquery.elastic
//= require jquery.superlabels.min
//= require showdown
//= require script
//= require main
59 changes: 44 additions & 15 deletions app/assets/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
$(document).ready(function() {
$('textarea').elastic();
$('form.new_job_post_request, form.new_job, form.edit_job, #sign_in form').superLabels({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the jQuery version of Rails UJS, superlables is the only thing left from what I can tell that relies on jQuery.

labelLeft: 10,
labelTop: 10
});
});


document.addEventListener('DOMContentLoaded', function() {
// Job title preview
document.querySelectorAll('input.job_title, input.job_company').forEach(function(elm) {
elm.addEventListener('keyup', function(event) {
var name = document.querySelector('input.job_title').value + " at " + document.querySelector('input.job_company').value;
document.querySelector('#single-job.job.readable h1').textContent = name;
});
});

$('textarea#job_description, textarea#job_post_request_description').keyup(function(event) {
var text = $(this).val();
var converter = new Showdown.converter();
var html = converter.makeHtml(text);
$('#markdown-target').html(html);
// Markdown preview
document.querySelectorAll('textarea#job_description, textarea#job_post_request_description').forEach(function(elm) {
elm.addEventListener('keyup', function(event) {
var text = event.target.value;
var converter = new Showdown.converter();
var html = converter.makeHtml(text);
document.querySelector('#markdown-target').innerHTML = html;
});
});

$('input.job_title, input.job_company').keyup(function(event) {
var name = $('input.job_title').val() + " at " + $('input.job_company').val();
$('#single-job.job.readable h1').text(name);
// Tab logic
document.querySelectorAll('.tab-container').forEach(function(elm) {
if (!elm.classList.contains('active')) {
elm.style.display = 'none';
}
});
document.querySelectorAll('ul.tab-menu li').forEach(function(tabElm, tabIndex) {
tabElm.addEventListener('click', function(event) {
event.preventDefault();
document.querySelectorAll('ul.tab-menu li').forEach(function(tabElm2) {
if (tabElm === tabElm2) {
tabElm2.classList.add('active');
} else {
tabElm2.classList.remove('active');
}
});

$('.tab-container').not('.active').hide();
$("ul.tab-menu li").click(function (ev) {
ev.preventDefault();
$('ul.tab-menu li').removeClass('active');
$(this).addClass('active');
$('.tab-container').hide().eq($(this).index()).show();
document.querySelectorAll('.tab-container').forEach(function(containerElm, containerIndex) {
if (tabIndex === containerIndex) {
containerElm.classList.add('active');
containerElm.style.display = 'block';
} else {
containerElm.classList.remove('active');
containerElm.style.display = 'none';
}
});
});
});
});
2 changes: 0 additions & 2 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*
*= require_self
*= require jquery.qtip
*= require jquery-ui/jquery-ui
*= require main
*= require atoms
*= require header
Expand Down
26 changes: 13 additions & 13 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
= stylesheet_link_tag 'application'
= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
= favicon_link_tag "/favicon.png"
= javascript_include_tag 'application'
<!-- Google Analytics -->
:javascript
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3615572-3']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<!-- END Google Analytics -->
= yield(:head)

%body{class: "#{request[:controller].split('/').join(' ')} #{request[:action]}"}
Expand Down Expand Up @@ -65,17 +78,4 @@
%p.ff-sm
Made with ❤️ by the Indy Hackers board

= javascript_include_tag 'application'
<!-- Google Analytics -->
:javascript
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3615572-3']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<!-- END Google Analytics -->
= yield(:footer)
6 changes: 0 additions & 6 deletions vendor/assets/javascripts/jquery-ui.min.js

This file was deleted.

Loading