diff --git a/app/assets/javascripts/legislation_allegations.js.coffee b/app/assets/javascripts/legislation_allegations.js.coffee index b65da2681..e5c8ea62f 100644 --- a/app/assets/javascripts/legislation_allegations.js.coffee +++ b/app/assets/javascripts/legislation_allegations.js.coffee @@ -1,21 +1,25 @@ App.LegislationAllegations = toggle_comments: -> - $('.draft-allegation').toggleClass('comments-on'); - $('#comments-box').html('').hide() + if !App.LegislationAnnotatable.isMobile() + $('.draft-allegation').toggleClass('comments-on') + $('#comments-box').html('').hide() show_comments: -> - $('.draft-allegation').addClass('comments-on'); + if !App.LegislationAnnotatable.isMobile() + $('.draft-allegation').addClass('comments-on') initialize: -> $('.js-toggle-allegations .draft-panel').on click: (e) -> - e.preventDefault(); - e.stopPropagation(); - App.LegislationAllegations.toggle_comments() + e.preventDefault() + e.stopPropagation() + if !App.LegislationAnnotatable.isMobile() + 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.LegislationAllegations.toggle_comments() + if !App.LegislationAnnotatable.isMobile() + if $(this).find('.draft-panel .panel-title:visible').length == 0 + App.LegislationAllegations.toggle_comments() diff --git a/app/assets/javascripts/legislation_annotatable.js.coffee b/app/assets/javascripts/legislation_annotatable.js.coffee index 00ff6c9f2..76fc97ed6 100644 --- a/app/assets/javascripts/legislation_annotatable.js.coffee +++ b/app/assets/javascripts/legislation_annotatable.js.coffee @@ -38,6 +38,9 @@ App.LegislationAnnotatable = renderAnnotationComments: (event) -> $('#comments-box').css({top: event.offset - $('.calc-comments').offset().top}) + if App.LegislationAnnotatable.isMobile() + return + $.ajax method: "GET" url: event.annotation_url + "/annotations/" + event.annotation_id + "/comments" @@ -47,6 +50,10 @@ App.LegislationAnnotatable = event.preventDefault() event.stopPropagation() + if App.LegislationAnnotatable.isMobile() + annotation_url = $(event.target).closest(".legislation-annotatable").data("legislation-annotatable-base-url") + window.location.href = annotation_url + "/annotations/" + $(this).data('annotation-id') + return $('[data-annotation-id]').removeClass('current-annotation') $(this).addClass('current-annotation') @@ -59,6 +66,9 @@ App.LegislationAnnotatable = annotation_url: $(event.target).closest(".legislation-annotatable").data("legislation-annotatable-base-url") offset: $(event.target).offset()["top"] + isMobile: () -> + return window.innerWidth <= 652 + viewerExtension: (viewer) -> viewer._onHighlightMouseover = (event) -> return