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
BREAKPOINTS = ["xs", "sm", "md", "lg"] instance = null;
constructor: -> class BreakpointInstance
@setup() BREAKPOINTS = ["xs", "sm", "md", "lg"]
setup: -> constructor: ->
allDeviceSelector = BREAKPOINTS.map (breakpoint) -> @setup()
".device-#{breakpoint}"
if $(allDeviceSelector.join(",")).length setup: ->
return allDeviceSelector = BREAKPOINTS.map (breakpoint) ->
".device-#{breakpoint}"
# Create all the elements return if $(allDeviceSelector.join(",")).length
$.each BREAKPOINTS, (i, breakpoint) ->
$("body").append "<div class='device-#{breakpoint} visible-#{breakpoint}'></div>"
getBreakpointSize: -> # Create all the elements
allDeviceSelector = BREAKPOINTS.map (breakpoint) -> $.each BREAKPOINTS, (i, breakpoint) ->
".device-#{breakpoint}" $("body").append "<div class='device-#{breakpoint} visible-#{breakpoint}'></div>"
$visibleDevice = $(allDeviceSelector.join(",")).filter(":visible") getBreakpointSize: ->
@setup()
return $visibleDevice.attr("class").split("visible-")[1]
allDeviceSelector = BREAKPOINTS.map (breakpoint) ->
".device-#{breakpoint}"
$visibleDevice = $(allDeviceSelector.join(",")).filter(":visible")
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;
} }
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
@media (min-width: $screen-sm-min) { @media (min-width: $screen-sm-min) {
padding-right: $gutter_width; padding-right: $gutter_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