Base Legislation Annotations
This commit is contained in:
@@ -49,8 +49,9 @@
|
||||
//= require markdown-it
|
||||
//= require markdown_editor
|
||||
//= require cocoon
|
||||
//= require allegations
|
||||
//= require legislation
|
||||
//= require legislation_allegations
|
||||
//= require legislation_annotatable
|
||||
//= require custom
|
||||
|
||||
var initialize_modules = function() {
|
||||
@@ -74,8 +75,9 @@ var initialize_modules = function() {
|
||||
App.Banners.initialize();
|
||||
App.SocialShare.initialize();
|
||||
App.MarkdownEditor.initialize();
|
||||
App.Allegations.initialize();
|
||||
App.LegislationAllegations.initialize();
|
||||
App.Legislation.initialize();
|
||||
App.LegislationAnnotatable.initialize();
|
||||
};
|
||||
|
||||
$(function(){
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.Allegations =
|
||||
App.LegislationAllegations =
|
||||
|
||||
toggle_comments: ->
|
||||
$('.draft-allegation').toggleClass('comments-on');
|
||||
@@ -8,10 +8,10 @@ App.Allegations =
|
||||
click: (e) ->
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
App.Allegations.toggle_comments()
|
||||
App.LegislationAllegations.toggle_comments()
|
||||
|
||||
$('.js-toggle-allegations').on
|
||||
click: (e) ->
|
||||
# Toggle comments when the section title is visible
|
||||
if $(this).find('.draft-panel .panel-title:visible').length == 0
|
||||
App.Allegations.toggle_comments()
|
||||
App.LegislationAllegations.toggle_comments()
|
||||
38
app/assets/javascripts/legislation_annotatable.js.coffee
Normal file
38
app/assets/javascripts/legislation_annotatable.js.coffee
Normal file
@@ -0,0 +1,38 @@
|
||||
_t = (key) -> new Gettext().gettext(key)
|
||||
|
||||
App.LegislationAnnotatable =
|
||||
initialize: ->
|
||||
current_user_id = $('html').data('current-user-id')
|
||||
if current_user_id == ""
|
||||
annotator.ui.editor.Editor.template = [
|
||||
'<div class="annotator-outer annotator-editor annotator-hide">',
|
||||
' <form class="annotator-widget">',
|
||||
' ' + _t('Unregistered'),
|
||||
' <div class="annotator-controls">',
|
||||
' <a href="#cancel" class="annotator-cancel">' + _t('Cancel') + '</a>',
|
||||
' </div>',
|
||||
' </form>',
|
||||
'</div>'
|
||||
].join('\n')
|
||||
|
||||
$(".legislation-annotatable").each ->
|
||||
$this = $(this)
|
||||
ann_type = "legislation_draft_version"
|
||||
ann_id = $this.data("legislation-draft-version-id")
|
||||
base_url = $this.data("legislation-annotatable-base-url")
|
||||
|
||||
app = new annotator.App()
|
||||
.include ->
|
||||
beforeAnnotationCreated: (ann) ->
|
||||
ann["legislation_draft_version_id"] = ann_id
|
||||
ann.permissions = ann.permissions || {}
|
||||
ann.permissions.admin = []
|
||||
.include(annotator.ui.main, { element: this })
|
||||
.include(annotator.storage.http, { prefix: base_url, urls: { search: "/annotations/search" } })
|
||||
|
||||
app.start().then ->
|
||||
app.ident.identity = current_user_id
|
||||
|
||||
options = {}
|
||||
options["legislation_draft_version_id"] = ann_id
|
||||
app.annotations.load(options)
|
||||
Reference in New Issue
Block a user