diff options
author | Phil Hughes <me@iamphill.com> | 2016-03-11 18:11:11 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-03-14 14:39:56 +0300 |
commit | f0f6723fe02bfb1a79c1cbefed156a420dddc352 (patch) | |
tree | 493a93b8c22abe55e45791bc6ff2c2e3e6b79c42 /app/assets/javascripts/breakpoints.coffee | |
parent | ce9bbce78a258b43181766bcbebad7add90968ff (diff) |
Created bootstrap breakpoint class
This class checks the current bootstrap breakpoint
Diffstat (limited to 'app/assets/javascripts/breakpoints.coffee')
-rw-r--r-- | app/assets/javascripts/breakpoints.coffee | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/assets/javascripts/breakpoints.coffee b/app/assets/javascripts/breakpoints.coffee new file mode 100644 index 00000000000..fd2ee8efa2c --- /dev/null +++ b/app/assets/javascripts/breakpoints.coffee @@ -0,0 +1,24 @@ +class @Breakpoints + BREAKPOINTS = ["xs", "sm", "md", "lg"] + + constructor: -> + @setup() + + setup: -> + allDeviceSelector = BREAKPOINTS.map (breakpoint) -> + ".device-#{breakpoint}" + + if $(allDeviceSelector.join(",")).length + return + + # Create all the elements + $.each BREAKPOINTS, (i, breakpoint) -> + $("body").append "<div class='device-#{breakpoint} visible-#{breakpoint}'></div>" + + getBreakpointSize: -> + allDeviceSelector = BREAKPOINTS.map (breakpoint) -> + ".device-#{breakpoint}" + + $visibleDevice = $(allDeviceSelector.join(",")).filter(":visible") + + return $visibleDevice.attr("class").split("visible-")[1] |