Sha256: b8b0ccf00f8fc9db2d813214c648034ed627d41657da692eba3ec7c75ef978bd
Contents?: true
Size: 1.34 KB
Versions: 12
Compression:
Stored size: 1.34 KB
Contents
class window.ViewLayout constructor: -> @wrap = $('#main') @initElements() @css_classes = @control.find('.btn').map(-> $(this).data('css')).get().join(' ') @initHandlers() @restoreMainCss(true) $(document).on 'pjax:end', => @initElements() @restoreMainCss() initElements: -> @control = $('#view_layout') @sidebar_on = $('#toggle_sidebar_on') @sidebar_off = $('#toggle_sidebar_off') initHandlers: -> self = this $(document).on 'click', '#toggle_sidebar_off', => @wrap.addClass('hide_sidebar') @storeMainCss() $(document).on 'click', '#toggle_sidebar_on', => @wrap.removeClass('hide_sidebar') @storeMainCss() $(document).on 'click', '#view_layout .btn', -> $el = $(this) $el.toggleClass('active').siblings().removeClass('active') self.wrap.removeClass(self.css_classes).toggleClass($el.data('css'), $el.hasClass('active')) self.storeMainCss() storeMainCss: -> storeData('view_layout', @wrap.prop('className')) restoreMainCss: (wrap=false) => css = fetchData('view_layout') if css @wrap.prop('className', css) if wrap @control.find("[data-css='#{css_class}']").addClass('active') for css_class in css.split(' ') $ -> if $('#list')[0] && !$('#list').hasClass('skip_view_layout') window.view_layout = new ViewLayout()
Version data entries
12 entries across 12 versions & 1 rubygems