diff options
| author | Zog | 2017-12-27 15:19:54 +0100 |
|---|---|---|
| committer | Zog | 2017-12-28 09:38:15 +0100 |
| commit | 77485057dc0169798a3fdee6f6b646a1b92bfb8c (patch) | |
| tree | 9ddc301ee4eaf09982843c022353c5e631e961a9 | |
| parent | fee41e6002c1a3c6273225befb7be2f06b6b63f9 (diff) | |
| download | chouette-core-77485057dc0169798a3fdee6f6b646a1b92bfb8c.tar.bz2 | |
Refs #5426; Refactor sticky actions
| -rw-r--r-- | app/assets/javascripts/main_menu.coffee | 41 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/index.html.slim | 2 |
2 files changed, 27 insertions, 16 deletions
diff --git a/app/assets/javascripts/main_menu.coffee b/app/assets/javascripts/main_menu.coffee index 1c39be736..947d8eac1 100644 --- a/app/assets/javascripts/main_menu.coffee +++ b/app/assets/javascripts/main_menu.coffee @@ -1,9 +1,9 @@ $ -> - link = [] + stickyActions = [] ptitleCont = "" $(document).on 'page:before-change', -> - link = [] + stickyActions = [] ptitleCont = "" @@ -24,33 +24,44 @@ $ -> limit = 51 if $(window).scrollTop() >= limit - data = "" - if ($('.page-action .small').length > 0) - data = $('.page-action .small')[0].innerHTML + if stickyActions.length == 0 + if ($('.page-action .small').length > 0) + stickyActions.push + content: [ + $('.page-action .small'), + $('.page-action .small').first().next() + ] + originalParent: $('.page-action .small').parent() + + for action in $(".sticky-action") + stickyActions.push + class: "small", + content: [$(action)] + originalParent: $(action).parent() if ($(".page-title").length > 0) ptitleCont = $(".page-title").html() - stickyContent = '<div class="sticky-content">' - stickyContent += '<div class="sticky-ptitle">' + ptitleCont + '</div>' - stickyContent += '<div class="sticky-paction"><div class="small">' + data + '</div></div>' - stickyContent += '</div>' + stickyContent = $('<div class="sticky-content"></div>') + stickyContent.append $('<div class="sticky-ptitle">' + ptitleCont + '</div>') + sticyActionsNode = $('<div class="sticky-paction"></div></div>') + stickyContent.append sticyActionsNode $('#main_nav').addClass 'sticky' if $('#menu_top').find('.sticky-content').length == 0 if ptitleCont.length > 0 $('#menu_top').children('.menu-content').after(stickyContent) - if link.length == 0 - link = $('.page-action .small').next() - - $('.sticky-paction .small').after(link) + for item in stickyActions + for child in item.content + child.appendTo $('.sticky-paction') else $('#main_nav').removeClass 'sticky' if $('#menu_top').find('.sticky-content').length > 0 - if !$('.page-action').find('.formSubmitr').length - $('.page-action .small').after(link) + for item in stickyActions + for child in item.content + child.appendTo item.originalParent $('.sticky-content').remove() sticker(); diff --git a/app/views/vehicle_journeys/index.html.slim b/app/views/vehicle_journeys/index.html.slim index 595646808..ebcac8197 100644 --- a/app/views/vehicle_journeys/index.html.slim +++ b/app/views/vehicle_journeys/index.html.slim @@ -4,7 +4,7 @@ - content_for :page_header_content do .row.mb-sm .col-lg-12.text-right - = link_to(t('routes.actions.opposite_route_timetable'), [@referential, @route.line, @route.opposite_route, :vehicle_journeys], class: 'btn btn-primary') + = link_to(t('routes.actions.opposite_route_timetable'), [@referential, @route.line, @route.opposite_route, :vehicle_journeys], class: 'btn btn-primary sticky-action') .page_content |
