mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Enable control over body scroll with BodyScroll service
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Darkswarm.controller "CartDropdownCtrl", ($scope, Cart) ->
|
||||
Darkswarm.controller "CartDropdownCtrl", ($scope, Cart, BodyScroll) ->
|
||||
$scope.Cart = Cart
|
||||
$scope.showCartSidebar = false
|
||||
|
||||
$scope.toggleCartSidebar = ->
|
||||
$scope.showCartSidebar = !$scope.showCartSidebar
|
||||
BodyScroll.toggle()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Darkswarm.directive "bodyScroll", ($rootScope, BodyScroll) ->
|
||||
restrict: 'A'
|
||||
scope: true
|
||||
link: (scope, elem, attrs) ->
|
||||
$rootScope.$on "toggleBodyScroll", ->
|
||||
if BodyScroll.disabled
|
||||
elem.addClass "disable-scroll"
|
||||
else
|
||||
elem.removeClass "disable-scroll"
|
||||
@@ -0,0 +1,7 @@
|
||||
angular.module("Darkswarm").factory "BodyScroll", ($rootScope) ->
|
||||
new class BodyScroll
|
||||
disabled: false
|
||||
|
||||
toggle: ->
|
||||
@disabled = !@disabled
|
||||
$rootScope.$broadcast "toggleBodyScroll"
|
||||
@@ -163,3 +163,7 @@ a.button.large {
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.disable-scroll {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
= stylesheet_link_tag "darkswarm/all"
|
||||
= csrf_meta_tags
|
||||
|
||||
%body{class: body_classes, ng: {app: "Darkswarm"}}
|
||||
%body{class: body_classes, "body-scroll" => true , ng: {app: "Darkswarm"}}
|
||||
/ [if lte IE 8]
|
||||
= render partial: "shared/ie_warning"
|
||||
= javascript_include_tag "iehack"
|
||||
|
||||
Reference in New Issue
Block a user