diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js deleted file mode 100644 index aede9d8..0000000 --- a/app/assets/javascripts/admin.js +++ /dev/null @@ -1,18 +0,0 @@ -$(function(){ - - $("form").on('click', "[data-id=input_option_adder]", function(){ - var $newLi = $(this).siblings('li').clone(); - $newLi.attr('style', ''); - $("[data-id=input_option_list]").append($newLi); - $newLi.find('input').focus(); - }); - - $("#question_input_type").on('change', function(){ - var qid = $(this).attr('data-qid') === undefined ? '' : "/" + $(this).attr('data-qid'); - // /admin/question(/:question_id)/options/:input_type - $("[data-id=input-options-wrapper]").load("/admin/question" + qid + "/options/" + $(this).val(), function(){ - $(".code-input textarea").linedtextarea(); - }); - }); - -}); diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8dbf4d2..d947126 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,6 +14,3 @@ //= require jquery_ujs //= require turbolinks //= require modernizr-lite/modernizr - -//= require main/ajax-links -//= require main/textarea-limit diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js deleted file mode 100644 index 24e7047..0000000 --- a/app/assets/javascripts/cable.js +++ /dev/null @@ -1,13 +0,0 @@ -// Action Cable provides the framework to deal with WebSockets in Rails. -// You can generate new channels where WebSocket features live using the rails generate channel command. -// -//= require action_cable -//= require_self -//= require_tree ./channels - -// (function() { -// this.App || (this.App = {}); -// -// App.cable = ActionCable.createConsumer(); -// -// }).call(this); diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/assets/javascripts/ie9.js b/app/assets/javascripts/ie9.js deleted file mode 100644 index a351371..0000000 --- a/app/assets/javascripts/ie9.js +++ /dev/null @@ -1 +0,0 @@ -//= require html5shiv/dist/html5shiv.min diff --git a/app/assets/javascripts/main/ajax-links.js b/app/assets/javascripts/main/ajax-links.js deleted file mode 100644 index 4a700c2..0000000 --- a/app/assets/javascripts/main/ajax-links.js +++ /dev/null @@ -1,27 +0,0 @@ -function handleAjaxResponse($el, callback) { - var $header = $('header'); - $el.on("ajax:success", function(e, data){ - $header.after('
' + data.message + '
'); - callback(data); - }).on("ajax:error", function(e, xhr) { - if (xhr.status === 400){ - $header.after('
' + xhr.responseJSON.join('
') + '
'); - } else { - $header.after('
Oops! There was an error processing your request. Please try again.
'); - } - }); -} - -function updateVotes(data){ - $("[data-id=up-votes]").html(data.upCount); - $("[data-id=down-votes]").html(data.downCount); - $("[data-id=my-vote]").html(data.myVote); -} - -$(document).ready(function() { - $('[data-id=ajax-action]').each(function(){ handleAjaxResponse($(this)); }); -}); - -$(document).ready(function() { - $('[data-id=vote-count]').each(function(){ handleAjaxResponse($(this), updateVotes); }); -}); diff --git a/app/assets/javascripts/main/textarea-limit.js b/app/assets/javascripts/main/textarea-limit.js deleted file mode 100644 index b325c60..0000000 --- a/app/assets/javascripts/main/textarea-limit.js +++ /dev/null @@ -1,25 +0,0 @@ -$.fn.extend({ - characterLimiter: function(limit, label) { - this.on("keyup focus show", function() { - setCount(this, label); - }); - - // TODO: append label container after $this, instead of hard HTML - function setCount(src, label) { - if(src !== undefined) { - var chars = src.value.length; - if (chars >= limit) { - src.value = src.value.substr(0, limit); - chars = limit; - } - label.html(limit - chars); - } - } - - setCount(this[0], label); - } -}); - -$(document).ready(function() { - $('textarea').characterLimiter(1000, $(".chars span")); -}); diff --git a/app/assets/javascripts/summary-edit.js b/app/assets/javascripts/summary-edit.js deleted file mode 100644 index 22ea2c2..0000000 --- a/app/assets/javascripts/summary-edit.js +++ /dev/null @@ -1,95 +0,0 @@ -/* global updateResults */ -// TODO: remove global ^ once live-coder is properly name spaced -/** - * Summary Page Answer Editor - */ -function disableForm($form){ - $form.find('fieldset').prop('disabled', true); - $form.find('textarea').prop('disabled', true); - $form.find('.button-save, .button-cancel').hide(); - $form.find('.button-edit').show(); - $form.find('.editable').removeClass('editable'); - $('.button-edit, .submit-button').removeClass('disabled-button'); -} - -function restoreValues($form){ - $form.find('[type=radio][data-last], [type=checkbox][data-last]').each(function(){ - $(this).prop('checked', $(this).attr('data-last')); - }); - - $form.find('textarea[data-last]').each(function(){ - $(this).val($(this).attr('data-last')); - }); -} - -function updateLocalValues($form){ - $form.find('[type=radio][data-last], [type=checkbox][data-last]').each(function(){ - $(this).attr('data-last', $(this).prop('checked') ? 'checked' : ''); - }); - - $form.find('textarea[data-last]').each(function(){ - $(this).attr('data-last', $(this).val()); - }); -} - -function updateProgress(data) { - $(".progress-bar").attr('aria-valuenow', data.progress) - .attr('style','width: '+ data.progress +'%;') - .find('span').text(data.progress + '%'); - if(data.can_submit === true){ - $('#summary-submit').find('.error').remove(); - $('#summary-submit').find('.submit-button').prop('disabled', false); - } -} - -function prepareAjax($form) { - $form.on("ajax:success", function(e, data){ - $form.prepend('
' + data.message + '
'); - disableForm($form); - updateLocalValues($form); - updateProgress(data); - }).on("ajax:error", function(e, xhr) { - if (xhr.status === 400){ - $form.prepend('
' + xhr.responseJSON.join('
') + '
'); - } else { - $form.prepend('
Oops! There was an error processing your request. Please try again.
'); - } - }); -} - -function editClickHandler(e) { - e.preventDefault(); - $('.button-edit, .submit-button').addClass('disabled-button'); - var $form = $(e.delegateTarget).closest('form'); - $(e.delegateTarget).addClass('editable'); - $form.find('fieldset').prop('disabled', false); - $form.find('textarea').prop('disabled', false); - $form.find('textarea').focus(); - $form.find('.button-edit').hide().delay(); - $form.find('.button-save, .button-cancel').show().delay(); -} - -function cancelClickHandler(e) { - e.preventDefault(); - var $form = $(e.delegateTarget).closest('form'); - $form.find('.error, .success').remove(); - disableForm($form); - restoreValues($form); - updateResults($form.find("[data-id=live-coder-answer]")); -} - -function saveClickHandler(e) { - e.preventDefault(); - var $form = $(e.delegateTarget).closest('form'); - $form.find('.error, .success').remove(); - $form.submit(); -} - -$('.summary_tpl fieldset').prop('disabled', true); -$('.summary_tpl textarea').prop('disabled', true); -$('.summary_tpl form').each(function(){ prepareAjax($(this)); }); -$('.summary_tpl .answer-sec') - .find('.button-cancel, .button-save').hide().end() - .on('click', '.button-edit', editClickHandler) - .on('click', '.button-cancel', cancelClickHandler) - .on('click', '.button-save', saveClickHandler);