renames & refactors annotations.js into annotable.js
This commit is contained in:
20
app/assets/javascripts/annotable.js.coffee
Normal file
20
app/assets/javascripts/annotable.js.coffee
Normal file
@@ -0,0 +1,20 @@
|
||||
App.Annotable =
|
||||
initialize: ->
|
||||
$("[data-annotable-type]").each ->
|
||||
$this = $(this)
|
||||
ann_type = $this.data("annotable-type")
|
||||
ann_id = $this.data("annotable-id")
|
||||
ann_user_id = $this.data("annotable-user-id")
|
||||
|
||||
app = new annotator.App()
|
||||
.include(annotator.ui.main, { element: this })
|
||||
.include(annotator.storage.http, { prefix: "", urls: { search: "/annotations/search" } })
|
||||
.include ->
|
||||
beforeannotationCreated: (ann) ->
|
||||
ann[ann_type + "_id"] = ann_id
|
||||
ann.user_id = ann_user_id
|
||||
|
||||
app.start().then ->
|
||||
options = {}
|
||||
options[ann_type + "_id"] = ann_id
|
||||
app.annotations.load(options)
|
||||
@@ -1,20 +0,0 @@
|
||||
legislationSelector = ".annotate"
|
||||
|
||||
annotationsMetadata = ->
|
||||
return {
|
||||
beforeAnnotationCreated: (ann) ->
|
||||
ann.legislation_id = $(legislationSelector).data("id");
|
||||
ann.user_id = $(legislationSelector).data("user-id");
|
||||
};
|
||||
|
||||
App.annotations =
|
||||
initialize: ->
|
||||
app = new annotator.App()
|
||||
.include(annotator.ui.main, { element: $(legislationSelector)[0] })
|
||||
.include(annotator.storage.http, { prefix: "", urls: { search: "/annotations/search" } })
|
||||
.include(annotationsMetadata)
|
||||
|
||||
app.start()
|
||||
.then( ->
|
||||
app.annotations.load( { legislation_id: $(legislationSelector).data("id") } )
|
||||
)
|
||||
@@ -29,11 +29,11 @@
|
||||
//= require moderator_debates
|
||||
//= require moderator_proposals
|
||||
//= require prevent_double_submission
|
||||
//= require annotator.min
|
||||
//= require annotator
|
||||
//= require tags
|
||||
//= require users
|
||||
//= require votes
|
||||
//= require annotations
|
||||
//= require annotable
|
||||
|
||||
|
||||
var initialize_modules = function() {
|
||||
@@ -46,7 +46,7 @@ var initialize_modules = function() {
|
||||
App.CheckAllNone.initialize();
|
||||
App.PreventDoubleSubmission.initialize();
|
||||
App.IeAlert.initialize();
|
||||
App.annotations.initialize();
|
||||
App.Annotable.initialize();
|
||||
};
|
||||
|
||||
$(function(){
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<% if current_user %>
|
||||
<section class="annotate" data-id=<%= @legislation.id %> data-user-id=<%= current_user.id %>>
|
||||
<% else %>
|
||||
<section>
|
||||
<% end %>
|
||||
<section data-annotable-type="legislation"
|
||||
data-annotable-id="<%= @legislation.id %>"
|
||||
data-annotable-user-id="<%= current_user.try(:id) %>">
|
||||
|
||||
<div><%= @legislation.title %></div>
|
||||
<div id="test"><%= @legislation.body %></div>
|
||||
|
||||
16009
vendor/assets/javascripts/annotator.js
vendored
Normal file
16009
vendor/assets/javascripts/annotator.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user