Commit 1a5992b5 authored by Phil Hughes's avatar Phil Hughes

Changed breakpoint size

Changed breakpoint class into singleton
parent 23b0eeca
...@@ -108,8 +108,7 @@ window.onload = -> ...@@ -108,8 +108,7 @@ window.onload = ->
setTimeout shiftWindow, 100 setTimeout shiftWindow, 100
$ -> $ ->
breakpoints = new Breakpoints() bootstrapBreakpoint = bp.getBreakpointSize()
bootstrapBreakpoint = breakpoints.getBreakpointSize()
$(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF") $(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF")
...@@ -261,12 +260,12 @@ $ -> ...@@ -261,12 +260,12 @@ $ ->
fitSidebarForSize = -> fitSidebarForSize = ->
oldBootstrapBreakpoint = bootstrapBreakpoint oldBootstrapBreakpoint = bootstrapBreakpoint
bootstrapBreakpoint = breakpoints.getBreakpointSize() bootstrapBreakpoint = bp.getBreakpointSize()
if bootstrapBreakpoint != oldBootstrapBreakpoint if bootstrapBreakpoint != oldBootstrapBreakpoint
$(document).trigger('breakpoint:change', [bootstrapBreakpoint]) $(document).trigger('breakpoint:change', [bootstrapBreakpoint])
checkInitialSidebarSize = -> checkInitialSidebarSize = ->
bootstrapBreakpoint = breakpoints.getBreakpointSize() bootstrapBreakpoint = bp.getBreakpointSize()
if bootstrapBreakpoint is "xs" or "sm" if bootstrapBreakpoint is "xs" or "sm"
$(document).trigger('breakpoint:change', [bootstrapBreakpoint]) $(document).trigger('breakpoint:change', [bootstrapBreakpoint])
......
class @Breakpoints class @Breakpoints
instance = null;
class BreakpointInstance
BREAKPOINTS = ["xs", "sm", "md", "lg"] BREAKPOINTS = ["xs", "sm", "md", "lg"]
constructor: -> constructor: ->
...@@ -8,17 +11,23 @@ class @Breakpoints ...@@ -8,17 +11,23 @@ class @Breakpoints
allDeviceSelector = BREAKPOINTS.map (breakpoint) -> allDeviceSelector = BREAKPOINTS.map (breakpoint) ->
".device-#{breakpoint}" ".device-#{breakpoint}"
if $(allDeviceSelector.join(",")).length return if $(allDeviceSelector.join(",")).length
return
# Create all the elements # Create all the elements
$.each BREAKPOINTS, (i, breakpoint) -> $.each BREAKPOINTS, (i, breakpoint) ->
$("body").append "<div class='device-#{breakpoint} visible-#{breakpoint}'></div>" $("body").append "<div class='device-#{breakpoint} visible-#{breakpoint}'></div>"
getBreakpointSize: -> getBreakpointSize: ->
@setup()
allDeviceSelector = BREAKPOINTS.map (breakpoint) -> allDeviceSelector = BREAKPOINTS.map (breakpoint) ->
".device-#{breakpoint}" ".device-#{breakpoint}"
$visibleDevice = $(allDeviceSelector.join(",")).filter(":visible") $visibleDevice = $(allDeviceSelector.join(",")).filter(":visible")
return $visibleDevice.attr("class").split("visible-")[1] return $visibleDevice.attr("class").split("visible-")[1]
@get: ->
return instance ?= new BreakpointInstance
@bp = Breakpoints.get()
mobileWidth = 991
collapsed = 'page-sidebar-collapsed' collapsed = 'page-sidebar-collapsed'
expanded = 'page-sidebar-expanded' expanded = 'page-sidebar-expanded'
...@@ -21,8 +20,7 @@ $(document).on("click", '.toggle-nav-collapse', (e) -> ...@@ -21,8 +20,7 @@ $(document).on("click", '.toggle-nav-collapse', (e) ->
) )
$ -> $ ->
breakpoints = new Breakpoints() size = bp.getBreakpointSize()
size = breakpoints.getBreakpointSize()
if size is "xs" or size is "sm" if size is "xs" or size is "sm"
if $('.page-with-sidebar').hasClass(expanded) if $('.page-with-sidebar').hasClass(expanded)
......
...@@ -144,7 +144,7 @@ header { ...@@ -144,7 +144,7 @@ header {
.header-collapsed { .header-collapsed {
margin-left: $sidebar_collapsed_width; margin-left: $sidebar_collapsed_width;
@media (min-width: $screen-sm-max) { @media (min-width: $screen-md-min) {
@include collapsed-header; @include collapsed-header;
} }
} }
...@@ -152,7 +152,7 @@ header { ...@@ -152,7 +152,7 @@ header {
.header-expanded { .header-expanded {
margin-left: $sidebar_collapsed_width; margin-left: $sidebar_collapsed_width;
@media (min-width: $screen-sm-max) { @media (min-width: $screen-md-min) {
margin-left: $sidebar_width; margin-left: $sidebar_width;
} }
} }
......
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
@mixin expanded-sidebar { @mixin expanded-sidebar {
padding-left: $sidebar_collapsed_width; padding-left: $sidebar_collapsed_width;
@media (min-width: $screen-sm-max) { @media (min-width: $screen-md-min) {
padding-left: $sidebar_width; padding-left: $sidebar_width;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment