Skip to content

Commit

Permalink
Remove all inline JavaScript
Browse files Browse the repository at this point in the history
(and convert to CoffeeScript).

Closes #37
  • Loading branch information
mgurley committed Sep 5, 2014
1 parent 35e549e commit 3888836
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 187 deletions.
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PATH
remote: .
specs:
abstractor (2.1.2)
coffee-rails (~> 4.0.1, >= 4.0.1)
haml (~> 4.0.5, >= 4.0.5)
jquery-rails (~> 3.1, >= 3.1.0)
jquery-ui-rails (~> 4.2, >= 4.2.0)
Expand Down Expand Up @@ -61,6 +62,13 @@ GEM
xpath (~> 2.0)
childprocess (0.5.3)
ffi (~> 1.0, >= 1.0.11)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.8.0)
cucumber (1.3.16)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
Expand All @@ -76,6 +84,7 @@ GEM
database_cleaner (1.3.0)
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.2.1)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.4.1)
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ from narrative text via natural language processing. The gem includes
a user interface to present the abstracted data points for
confirmation/revision by a curator.

Reader's note: this README uses [YARD][] markup to provide links to
Abstractor's API documentation. If you aren't already, consider reading it
on [rubydoc.info][] so that the links will be followable.

[YARD]: http://yardoc.org/
[rubydoc.info]: http://rubydoc.info/github/NUBIC/abstractor/master/file/README.md

Expand Down
1 change: 1 addition & 0 deletions abstractor.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.add_dependency 'paper_trail', '~> 3.0.0', '>= 3.0.0'
s.add_dependency 'stanford-core-nlp', '~> 0.5.1', '>= 0.5.1'
s.add_dependency 'rubyzip', '~> 1.1.0', '>= 1.1.0'
s.add_dependency 'coffee-rails', '~> 4.0.1', '>= 4.0.1'

s.add_development_dependency 'sqlite3', '~> 1.3.9', '>= 1.3.9'
s.add_development_dependency 'rspec-rails', '~> 3.0.0', '>= 3.0.0'
Expand Down
108 changes: 0 additions & 108 deletions app/assets/javascripts/abstractor/abstractor.js

This file was deleted.

114 changes: 114 additions & 0 deletions app/assets/javascripts/abstractor/abstractor.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Abstractor = {}
Abstractor.AbstractionUI = ->
$(document).on "click", ".abstractor_abstraction_value a.edit_link", (e) ->
e.preventDefault()
parent_div = $(this).closest(".abstractor_abstraction")
parent_div.load $(this).attr("href"), ->
parent_div.find(".combobox").combobox watermark: "a value"
parent_div.find("input[type=\"submit\"], button, a.button").button()
$(".abstractor_datepicker").datepicker
altFormat: "yy-mm-dd"
dateFormat: "yy-mm-dd"
changeMonth: true
changeYear: true

return

parent_div.addClass "highlighted"
return


#parent_div.siblings('.abstractor_abstraction').block({ message: null, overlayCSS: { opacity: .2 }});
$(document).on "ajax:success", "form.edit_abstractor_abstraction", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_abstraction")
parent_div.html xhr.responseText

#parent_div.siblings('.abstractor_abstraction').unblock();
parent_div.removeClass "highlighted"
return

$(document).on "click", ".edit_abstractor_abstraction input[type='radio']", ->
$(this).siblings("input[type='checkbox']").prop "checked", false
return

$(document).on "click", ".edit_abstractor_abstraction input[type='checkbox']", ->
$(this).siblings("input[type='checkbox']").prop "checked", false
$(this).siblings("input[type='text']").prop "value", ""
autocompleters = $(this).siblings("select.combobox")
autocompleters.combobox "setValue", ""
autocompleters.change()
$.each $(this).siblings("input[type='radio']"), ->
if $(this).prop("value") is ""
$(this).prop "checked", true
else
$(this).prop "checked", false
return

return

$(document).on "change", ".edit_abstractor_abstraction select.combobox", ->
$(this).siblings("input[type='checkbox']").prop "checked", false if $(this).find("option:selected").prop("value").length
return

$(document).on "change", ".edit_abstractor_abstraction input[type='text']", ->
$(this).siblings("input[type='checkbox']").prop "checked", false
return

$(document).on "click", ".abstractor_abstraction_source_tooltip_img", (evt) ->
target = $(this).attr("rel")
html = $(target).html()
title = $(this).attr("title")
evt.preventDefault()
$("#abstractor_abstraction_dialog_tooltip").dialog
maxHeight: 400
autoOpen: false
width: 600
zIndex: 40000
dialogClass: "ui-dialog_abstractor"
$("#abstractor_abstraction_dialog_tooltip").html html
$("#abstractor_abstraction_dialog_tooltip").dialog "option", "title", title
$("#abstractor_abstraction_dialog_tooltip").dialog "option", "width", ($(window).width() * 0.80)
$("#abstractor_abstraction_dialog_tooltip").dialog "open"
return

$(document).on "change", "select.indirect_source_list", ->
source_type = $(this).attr("rel")
value = $(this).find("option:selected").prop("value")
$(this).siblings(".indirect_source_text").addClass "hidden"
$(this).siblings("." + source_type + "_" + value).removeClass "hidden"
return

return

Abstractor.AbstractionSuggestionUI = ->
$(document).on "change", ".abstractor_suggestion_status_selection", ->
$(this).closest("form").submit()
return

$(document).on "ajax:success", "form.edit_abstractor_suggestion", (e, data, status, xhr) ->
$(this).closest(".abstractor_abstraction").html xhr.responseText
return

return

Abstractor.AbstractionGroupUI = ->
$(document).on "ajax:success", ".abstractor_abstraction_group .delete_link", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_abstraction_group")
parent_div.html xhr.responseText
return

$(document).on "ajax:success", ".abstractor_subject_groups_container .add_link", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_subject_groups_container")
parent_div.find(".abstractor_subject_groups").append xhr.responseText
return

$(document).on "ajax:success", ".abstractor_abstraction_group .update_link", (e, data, status, xhr) ->
parent_div = $(this).closest(".abstractor_abstraction_group")
parent_div.html xhr.responseText
return

return

new Abstractor.AbstractionUI()
new Abstractor.AbstractionSuggestionUI()
new Abstractor.AbstractionGroupUI()
69 changes: 0 additions & 69 deletions app/assets/javascripts/abstractor/nested_attributes.js

This file was deleted.

7 changes: 1 addition & 6 deletions app/views/abstractor/abstractor_abstractions/_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,4 @@
- ungrouped_subject.abstractor_abstractions.not_deleted.where(:about_id => about.id).each do |abstractor_abstraction|
%div{ class: "abstractor_abstraction #{Abstractor::Utility.dehumanize(abstractor_abstraction.abstractor_subject.abstractor_abstraction_schema.predicate)}" }
= render :partial => 'abstractor/abstractor_abstractions/fields', :locals => {:abstractor_abstraction => abstractor_abstraction}
:javascript
$(function () {
new Abstractor.AbstractionUI();
new Abstractor.AbstractionSuggestionUI();
new Abstractor.AbstractionGroupUI();
});
#abstractor_abstraction_dialog_tooltip

0 comments on commit 3888836

Please sign in to comment.