├── .bowercc ├── .editorconfig ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── bower.json ├── css ├── barekit.css ├── barekit.css.map ├── barekit.scss ├── barekit.styl ├── sass │ ├── global │ │ ├── _functions.scss │ │ ├── _mixins.scss │ │ ├── _utility.scss │ │ └── _variables.scss │ ├── lib │ │ └── _normalize.scss │ └── module │ │ ├── _accordion.scss │ │ ├── _dropdown-nav.scss │ │ ├── _form.scss │ │ ├── _grid-extends.scss │ │ ├── _grid.scss │ │ ├── _modal.scss │ │ ├── _off-canvas.scss │ │ ├── _tabs.scss │ │ └── _toggle.scss └── stylus │ ├── global │ ├── _functions.styl │ ├── _mixins.styl │ ├── _utility.styl │ └── _variables.styl │ ├── lib │ └── _normalize.styl │ └── module │ ├── _accordion.styl │ ├── _dropdown-nav.styl │ ├── _form.styl │ ├── _grid-extends.styl │ ├── _grid.styl │ ├── _modal.styl │ ├── _off-canvas.styl │ ├── _tabs.styl │ └── _toggle.styl ├── example.html ├── gruntfile.js ├── gulpfile.js ├── js ├── barekit.js └── barekit.min.js ├── package.json ├── spec ├── index.html └── tests.js └── src ├── modules ├── accordion.js ├── core.js ├── dropdown-nav.js ├── modal.js ├── off-canvas.js ├── tabs.js └── toggle.js ├── prefix.js └── suffix.js /.bowercc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components" 3 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bower_components 2 | node_modules 3 | .sass-cache 4 | .DS_Store 5 | .idea -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## v0.7.0 3 | 4 | #### Bug Fixes 5 | 6 | * Added back in defaults to breakpoints to allow the overriding of them in a settings file ([906089e3](https://github.com/trevanhetzel/barekit/commit/906089e39a70d08081d36839bfdea385fe31c174)) 7 | * Added direct child selector to improve nesting in tabs ([71981377](https://github.com/trevanhetzel/barekit/commit/71981377c019288e92b41c0a5dd0785eabd199ef)) 8 | * Prevent default for non-absolute links in accordion ([b5417a2c](https://github.com/trevanhetzel/barekit/commit/b5417a2cfe0356324ea0180c54d0bcb402722e70)) 9 | * Added direct child trigger selector to trigger only true accordion "triggers" ([1b3a2dde](https://github.com/trevanhetzel/barekit/commit/1b3a2dde2fc2b7381838b9d35f6f8e7a80c4a8d3)) 10 | 11 | #### Features 12 | 13 | * Added Docco task ([eb883e59](https://github.com/trevanhetzel/barekit/commit/eb883e59a52bc7559a6f93ac038177690befd2a2)) 14 | 15 | #### Breaking Changes 16 | 17 | * A new default class of `df-` has been added to the grid. The `sm-` classes have been moved inside a media query, so using `sm-` as your default class will no longer kick in until the viewport has reached the value of the `$small` breakpoint. ([a2d2116b](https://github.com/trevanhetzel/barekit/commit/a2d2116b59fc1454b3feb9c050f818af29a5ed81)) 18 | 19 | 20 | ## v0.6.2 21 | 22 | #### Bug Fixes 23 | 24 | * Fix modal background issue ([0e3d60b1](https://github.com/trevanhetzel/barekit/commit/0e3d60b1085a237d2fc57ad4c06007a8d78e87e6)) 25 | * Change the default dropdown behavior to trigger on hover instead of click ([ed2e206a](https://github.com/trevanhetzel/barekit/commit/ed2e206aaca6c95816e799e67ab455ff5e71b7eb)) 26 | 27 | #### Features 28 | 29 | * Added QUnit (no tests have been written yet) ([c977f7d6](https://github.com/trevanhetzel/barekit/commit/c977f7d6116ae0e4b1ca0f7705200e492170b4ec)) 30 | 31 | #### Breaking Changes 32 | 33 | * JavaScript has been re-organized. Compiled JS is still in the `js` folder (along with a new unminified version), but source JS has moved to a `src` folder ([c977f7d6](https://github.com/trevanhetzel/barekit/commit/c977f7d6116ae0e4b1ca0f7705200e492170b4ec)) 34 | 35 | 36 | ## v0.6.1 37 | 38 | #### Bug Fixes 39 | 40 | * Fix to allow `.off-canvas-trigger-` child elements to trigger the off-canvas module. 41 | 42 | 43 | ## v0.6.0 44 | 45 | #### Bug Fixes 46 | 47 | * Tidied up checkboxes and radios to be formatted/positioned correctly by default ([d2aa4a34](https://github.com/trevanhetzel/barekit/commit/d2aa4a3472bd959b2d6fb211a05038dca2df31da)) 48 | * Fixed z-index issue with modals ([62fddc1f](https://github.com/trevanhetzel/barekit/commit/62fddc1f5c6d9318cb69b167e5c89166843e3665)) 49 | * Allow multiple modals on the same page ([607af9cd](https://github.com/trevanhetzel/barekit/commit/607af9cd49da3c1f3e1e774f12550c16d4f1ed24)) 50 | 51 | 52 | #### Features 53 | 54 | * Support for two off-canvas elements ([52a76560](https://github.com/trevanhetzel/barekit/commit/52a7656034e6d26328597ae77ac5831e3417e7cf)) 55 | * Added ability to input custom value to breakpoint mixin ([2372edc0](https://github.com/trevanhetzel/barekit/commit/2372edc07b9082bf7ef6c2a90f93e19ade26855f)) 56 | * Added `.editorconfig` file. ([26175e87](https://github.com/trevanhetzel/barekit/commit/26175e87d9ad1b2df8dbecdeb4e418fe27d4f73e)) 57 | * Toggle "triggers" now get an active class (`toggle-trigger-shown`) added when toggled. 58 | * Can now specify that a toggled element be hidden when clicking anywhere else on the page (new data attr: `closeOnClick`) ([56a12737](https://github.com/trevanhetzel/barekit/commit/56a127377bb08d2b83707b72e02ee2e63e446cb0)) 59 | 60 | 61 | #### Breaking Changes 62 | 63 | * **Grid class names have changed** ([6b3b0dba](https://github.com/trevanhetzel/barekit/commit/6b3b0dbafdeea83c5a6707d068273b5a6a799184)) 64 | 65 | Previously, BareKit was using some very generic selectors to select all elements that start with `sm`, `md` and `lg` and give them some box model properties (`float` and `padding`). This caused some trouble, so I decided to separate out those box model properties to their own new class: `has-gutter`. This way, you can still use classes like `sm-6` for widths, but aren't tied down to the padding and float if you don't want to be. 66 | 67 | So if you want to still use the "grid" (not just the width classes), a line that previously looked like this: 68 | 69 | ``` 70 |
1
71 | ``` 72 | 73 | will now need to look like this: 74 | 75 | ``` 76 |
1
77 | ``` 78 | 79 | * **Off-canvas class names have changed** ([52a76560](https://github.com/trevanhetzel/barekit/commit/52a7656034e6d26328597ae77ac5831e3417e7cf)) 80 | 81 | In order to support two off-canvas elements instead of one, the class names needed to set up off-canvas have changed. 82 | 83 | This: 84 | 85 | ``` 86 |
87 |
88 | I am content off-canvas. 89 |
90 | 91 |
92 | Trigger 93 |

I am the main content of the page that gets pushed over when the off-canvas is open. I also contain the off-canvas trigger.

94 |
95 |
96 | ``` 97 | 98 | Now needs to look like this: 99 | 100 | ``` 101 |
102 |
103 | I am content off-canvas. 104 |
105 | 106 |
107 | I am content off-canvas. 108 |
109 | 110 |
111 | Left trigger 112 | Right trigger 113 |

I am the main content of the page that gets pushed over when the off-canvas is open. I also contain the off-canvas trigger.

114 |
115 |
116 | ``` 117 | 118 | `right-align` and `left-align` classes have been removed from the `.off-canvas-contain` element and `-right`/`-left` have been appended to the `.off-canvas` and `.off-canvas-trigger` elements. 119 | 120 | 121 | ## v0.5.0 122 | 123 | Initial release -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Trevan Hetzel 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BareKit 2 | ========== 3 | 4 | ### [Visit website for full usage docs](http://trevanhetzel.github.io/barekit) 5 | 6 | BareKit is a front-end project starter meant to be a starting point and structural guide rather than a full framework. It's bare enough to not interfere with your custom styles or scripts, but yet has enough functioning modules to jumpstart a project in no time. 7 | 8 | _The project creator and lead for BareKit is [Trevan Hetzel](http://appendto.com/team/trevan-hetzel/) ([trevanhetzel](https://github.com/trevanhetzel)) . Use [Github issues](http://github.com/trevanhetzel/barekit) and pull requests or reach out to Trevan directly for support and contributions to BareKit._ 9 | 10 | # Getting Started 11 | 12 | The best way to get BareKit up and running on a project is to install via [Bower](http://bower.io/). You shouldn't ever touch the source anyway, so with Bower it's easy to get the latest updates. 13 | 14 | First, make sure you have Bower installed. Then you can add this line to a `bower.json` file `"barekit": "~0.7.0"` or simply do a `bower install barekit`. 15 | 16 | 17 | ### JavaScript 18 | 19 | Getting up and running with the BareKit JavaScript modules is very simple. You first need to reference the latest jQuery file (also installable via Bower), and then reference the `barekit.min.js` file at the bottom of your HTML page (before the closing body tag). 20 | 21 | If you installed jQuery and BareKit using Bower, the paths would look something like this: 22 | 23 | ``` 24 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | 3 | 'use strict'; 4 | 5 | grunt.initConfig({ 6 | pkg: grunt.file.readJSON('package.json'), 7 | 8 | /** 9 | * Sass 10 | */ 11 | sass: { 12 | dist: { 13 | options: { 14 | style: 'compressed' 15 | }, 16 | files: [{ 17 | expand: true, 18 | cwd: 'css', 19 | src: ['*.scss'], 20 | dest: 'css', 21 | ext: '.css' 22 | }] 23 | } 24 | }, 25 | 26 | /** 27 | * Autoprefixer 28 | */ 29 | autoprefixer: { 30 | options: { 31 | browsers: ['last 2 version', 'ie 8', 'ie 9'] 32 | }, 33 | multiple_files: { 34 | expand: true, 35 | flatten: true, 36 | src: 'css/*.css', 37 | dest: 'css/' 38 | } 39 | }, 40 | 41 | concat: { 42 | dist: { 43 | src: [ 44 | 'src/prefix.js', 45 | 'src/modules/core.js', 46 | 'src/modules/accordion.js', 47 | 'src/modules/dropdown-nav.js', 48 | 'src/modules/modal.js', 49 | 'src/modules/off-canvas.js', 50 | 'src/modules/tabs.js', 51 | 'src/modules/toggle.js', 52 | 'src/suffix.js' 53 | ], 54 | dest: 'js/barekit.js', 55 | } 56 | }, 57 | 58 | /** 59 | * Uglify 60 | */ 61 | uglify: { 62 | modules: { 63 | files: { 64 | 'js/barekit.min.js': [ 65 | 'js/barekit.js' 66 | ] 67 | } 68 | } 69 | }, 70 | 71 | 72 | /** 73 | * Watch 74 | */ 75 | watch: { 76 | css: { 77 | files: [ 78 | 'css/sass/barekit.scss', 79 | 'css/sass/global/*.scss', 80 | 'css/sass/layout/*.scss', 81 | 'css/sass/module/*.scss' 82 | ], 83 | tasks: ['sass:dist', 'autoprefixer'], 84 | options: { nospawn: true } 85 | }, 86 | uglify: { 87 | files: ['js/modules/*.js'], 88 | tasks: ['js'] 89 | } 90 | }, 91 | qunit: { 92 | all: ['spec/**/*.html'] 93 | }, 94 | 95 | 96 | docco: { 97 | src: ['js/barekit.js'], 98 | options: { 99 | output: 'docs/' 100 | } 101 | } 102 | }); 103 | 104 | // Load NPM Tasks 105 | grunt.loadNpmTasks('grunt-contrib-concat'); 106 | grunt.loadNpmTasks('grunt-contrib-sass'); 107 | grunt.loadNpmTasks('grunt-contrib-watch'); 108 | grunt.loadNpmTasks('grunt-autoprefixer'); 109 | grunt.loadNpmTasks('grunt-contrib-uglify'); 110 | grunt.loadNpmTasks('grunt-contrib-qunit'); 111 | grunt.loadNpmTasks('grunt-docco'); 112 | 113 | grunt.registerTask('js', [ 'concat', 'uglify' ]); 114 | grunt.registerTask('test', [ 'js', 'qunit' ]); 115 | 116 | // Register Tasks 117 | grunt.registerTask('default', [ 'sass', 'autoprefixer', 'js' ]); 118 | 119 | }; -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | stylus = require('gulp-stylus'), 3 | prefix = require('gulp-autoprefixer'), 4 | uglify = require('gulp-uglify'), 5 | concat = require('gulp-concat'); 6 | 7 | var paths = { 8 | styles: 'css/**/*.styl', 9 | scripts: [ 10 | 'js/modules/core.js', 11 | 'js/modules/accordion.js', 12 | 'js/modules/dropdown-nav.js', 13 | 'js/modules/modal.js', 14 | 'js/modules/off-canvas.js', 15 | 'js/modules/tabs.js', 16 | 'js/modules/toggle.js' 17 | ] 18 | }; 19 | 20 | gulp.task('styles', function () { 21 | gulp.src('css/barekit.styl') 22 | .pipe(stylus()) 23 | .pipe(prefix('last 2 version', 'ie 8', 'ie 9')) 24 | .pipe(gulp.dest('./css')) 25 | }); 26 | 27 | gulp.task('scripts', function () { 28 | gulp.src(paths.scripts) 29 | .pipe(concat('barekit.min.js')) 30 | .pipe(uglify()) 31 | .pipe(gulp.dest('./js')); 32 | }); 33 | 34 | gulp.task('watch', function () { 35 | gulp.watch(paths.styles, ['styles']); 36 | gulp.watch(paths.scripts, ['scripts']); 37 | gulp.watch(paths.html, ['html']); 38 | }); 39 | 40 | // The default task (called when you run `gulp` from cli) 41 | gulp.task('default', [ 42 | 'styles', 43 | 'scripts', 44 | 'watch' 45 | ]); -------------------------------------------------------------------------------- /js/barekit.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Barekit 0.7.0 3 | * 4 | * Copyright 2014 Trevan Hetzel. (http://trevan.coo) 5 | * Licensed under the MIT license. 6 | * 7 | * http://trevanhetzel.github.io/barekit/ 8 | */ 9 | ;(function($) { 10 | var Bk; 11 | 12 | window.Barekit = Bk = { 13 | autoInitialize: true 14 | }; 15 | 16 | var Accordion = function () { 17 | this.init.apply(this, arguments); 18 | }; 19 | 20 | Accordion.defaults = { 21 | className: 'accordion', 22 | multiExpand: false, 23 | panelSelector: 'dd', 24 | triggerSelector: 'dt', 25 | activeTrigger: 'accordion-trigger--open', 26 | activePanel: 'accordion-panel--open' 27 | }; 28 | 29 | Accordion.prototype.init = function (el, options) { 30 | // Store a reference to the jQuery element 31 | this.$el = $(el); 32 | 33 | // Set the options 34 | this.options = $.extend({}, Accordion.defaults, options, this.$el.data('options')); 35 | 36 | // Add the class 37 | this.$el.addClass(this.options.className); 38 | 39 | this.$el.on('click.bk.accordion', $.proxy(this.onClick, this)); 40 | }; 41 | 42 | Accordion.prototype.onClick = function (e) { 43 | var $target = $(e.target); 44 | 45 | //prevent default behaviour on non-absolute links 46 | if ($target.is('a')) { 47 | var href = $target.attr("href"); 48 | if ($target.attr("href") == "#") { 49 | e.preventDefault(); 50 | } 51 | } 52 | 53 | //find the dt parent node 54 | while($target.length && !$target.is('dt')) { 55 | $target = $target.parent(); 56 | } 57 | 58 | if ($target.length) { 59 | var $content = $target.next('dd'); 60 | this.processOptions($target, $content); 61 | } 62 | }; 63 | 64 | Accordion.prototype.processOptions = function ($target, $content) { 65 | var $panel = this.$el.find(this.options.panelSelector), 66 | $trigger = this.$el.find(this.options.triggerSelector), 67 | activeTrigger = this.options.activeTrigger, 68 | activePanel = this.options.activePanel; 69 | 70 | if (this.options.multiExpand === true) { 71 | // Trigger active class 72 | $target.toggleClass(activeTrigger); 73 | // Panel active class 74 | $content.toggleClass(activePanel); 75 | } else { 76 | // Remove all trigger active classes 77 | $trigger.removeClass(activeTrigger); 78 | // Trigger active class 79 | $target.addClass(activeTrigger); 80 | 81 | // Remove all panel active classes 82 | if (!$content.hasClass(activePanel)) { 83 | $panel.removeClass(activePanel); 84 | } 85 | // Panel active class 86 | $content.toggleClass(activePanel); 87 | } 88 | }; 89 | 90 | Accordion.prototype.destroy = function () { 91 | this.$el.off('.accordion'); 92 | }; 93 | 94 | Bk.Accordion = Accordion; 95 | 96 | // Expose as a jQuery Plugin 97 | $.fn.bkAccordion = function (options) { 98 | return this.each(function () { 99 | var $el = $(this); 100 | // Check if it is already set up 101 | if (!$el.data('bkAccordion')) { 102 | $el.data('bkAccordion', new Accordion(this, options)); 103 | } 104 | }); 105 | }; 106 | 107 | // Allow defaults to be accessed via a common jQuery pattern 108 | $.fn.bkAccordion.defaults = Accordion.defaults; 109 | 110 | // Auto-initialize if set 111 | jQuery(function ($) { 112 | if (Bk.autoInitialize) { 113 | $('.' + Accordion.defaults.className).bkAccordion(); 114 | } 115 | }); 116 | var Dropdown = function () { 117 | this.init.apply(this, arguments); 118 | }; 119 | 120 | Dropdown.defaults = { 121 | className: 'dropdown-nav', 122 | click: false, 123 | clickClass: 'click-setting', 124 | activeTrigger: 'dropdown-trigger--open', 125 | activeClass: 'dropdown--open' 126 | }; 127 | 128 | Dropdown.prototype.init = function (el, options) { 129 | // Store a reference to the jQuery element 130 | this.$el = $(el); 131 | 132 | var $trigger = this.$el.find('li:has(ul)'); 133 | 134 | // Set the options 135 | this.options = $.extend({}, Dropdown.defaults, options, this.$el.data('options')); 136 | 137 | // Add the class 138 | this.$el.addClass(this.options.className); 139 | 140 | if (this.options.click == true) { 141 | // Cancel out the CSS hover functionality 142 | $trigger.addClass(this.options.clickClass); 143 | $trigger.on('click.bk.dropdown', $.proxy(this.remove, this)); 144 | 145 | //mouse click listener to close the dropdown if clicked outside 146 | self = this; 147 | $(document).on('click', function(e){ 148 | $('.' + self.options.activeTrigger).each(function(){ 149 | self.hide($(this), e); 150 | }); 151 | }); 152 | 153 | //keyboard listener to close the dropdown if esc is pressed 154 | $(document).keyup(function(e) { 155 | if(e.keyCode === 27){ 156 | $('.' + self.options.activeTrigger).each(function(){ 157 | self.hide($(this), 'undefined'); 158 | }); 159 | } 160 | }); 161 | } 162 | }; 163 | 164 | Dropdown.prototype.hide = function($el, e) { 165 | if( e === 'undefined' || ($(e.target).parents('ul.' + this.options.className)[0] !== $el.parents('ul.' + this.options.className)[0])){ 166 | $el.removeClass(this.options.activeTrigger); 167 | $el.children('ul').removeClass(this.options.activeClass); 168 | } 169 | }; 170 | 171 | Dropdown.prototype.remove = function (e) { 172 | var $this = $(e.currentTarget), 173 | $menu = $this.children('ul'), 174 | $target = $(e.target); 175 | 176 | if(!$target.is('a')){ 177 | e.preventDefault(); 178 | } 179 | 180 | $this.removeClass(this.options.className); 181 | 182 | this.doDropdown($this, $menu); 183 | }; 184 | 185 | Dropdown.prototype.doDropdown = function ($this, $menu) { 186 | $this.toggleClass(this.options.activeTrigger); 187 | $menu.toggleClass(this.options.activeClass); 188 | }; 189 | 190 | Dropdown.prototype.destroy = function () { 191 | this.$el.off('.dropdown'); 192 | }; 193 | 194 | Bk.Dropdown = Dropdown; 195 | 196 | // Expose as a jQuery Plugin 197 | $.fn.bkDropdown = function (options) { 198 | return this.each(function () { 199 | var $el = $(this); 200 | // Check if it is already set up 201 | if (!$el.data('bkDropdown')) { 202 | $el.data('bkDropdown', new Dropdown(this, options)); 203 | } 204 | }); 205 | }; 206 | 207 | // Allow defaults to be accessed via a common jQuery pattern 208 | $.fn.bkDropdown.defaults = Dropdown.defaults; 209 | 210 | // Auto-initialize if set 211 | jQuery(function ($) { 212 | if (Bk.autoInitialize) { 213 | $('.' + Dropdown.defaults.className).bkDropdown(); 214 | } 215 | }); 216 | 217 | var Modal = function () { 218 | this.init.apply(this, arguments); 219 | }; 220 | 221 | Modal.defaults = { 222 | className: 'modal-trigger', 223 | modal: '.modal', 224 | close: '.modal-close', 225 | bg: 'modal-bg', 226 | openClass: 'modal-open' 227 | }; 228 | 229 | Modal.prototype.init = function (el, options) { 230 | var self = this; 231 | 232 | // Store a reference to the jQuery element 233 | this.$el = $(el); 234 | 235 | // Set the options 236 | this.options = $.extend({}, Modal.defaults, options, this.$el.data('options')); 237 | 238 | // Add the class 239 | this.$el.addClass(this.options.className); 240 | 241 | $(document) 242 | .on('click.bk.modal', function (e) { 243 | self.closeModal(); 244 | }) 245 | .on('click.bk.modal', '.' + this.options.className, function (e) { 246 | e.stopPropagation(); 247 | e.preventDefault(); 248 | 249 | if ($(e.currentTarget).data("options").modalId === self.options.modalId) { 250 | self.onClick(); 251 | } 252 | }) 253 | .on('click.bk.modal', this.options.modal, function (e) { 254 | e.stopPropagation(); 255 | e.preventDefault(); 256 | }) 257 | .on('keyup.bk.modal', function (e) { 258 | if (e.keyCode === 27) { 259 | self.closeModal(); 260 | } 261 | }); 262 | 263 | $(this.options.close).on('click.bk.modal', function () { 264 | self.closeModal(); 265 | }); 266 | }; 267 | 268 | Modal.prototype.onClick = function (e) { 269 | 270 | var $dest = $('#' + this.options.modalId); 271 | 272 | this.openModal($dest); 273 | }; 274 | 275 | Modal.prototype.openModal = function($dest) { 276 | // Add class to body for overlay 277 | $('body').addClass(this.options.bg); 278 | // Add open class to modal 279 | $dest.addClass(this.options.openClass); 280 | }; 281 | 282 | Modal.prototype.closeModal = function () { 283 | // Remove class from body to remove overlay 284 | $('body').removeClass(this.options.bg); 285 | // Remove open class from modal 286 | $(this.options.modal).removeClass(this.options.openClass); 287 | }; 288 | 289 | Modal.prototype.destroy = function () { 290 | $(document).off('.modal'); 291 | $(this.options.close).off('.modal'); 292 | }; 293 | 294 | Bk.Modal = Modal; 295 | 296 | // Expose as a jQuery Plugin 297 | $.fn.bkModal = function (options) { 298 | return this.each(function () { 299 | var $el = $(this); 300 | // Check if it is already set up 301 | if (!$el.data('bkModal')) { 302 | $el.data('bkModal', new Modal(this, options)); 303 | } 304 | }); 305 | }; 306 | 307 | // Allow defaults to be accessed via a common jQuery pattern 308 | $.fn.bkModal.defaults = Modal.defaults; 309 | 310 | // Auto-initialize if set 311 | jQuery(function ($) { 312 | if (Bk.autoInitialize) { 313 | $('.' + Modal.defaults.className).bkModal(); 314 | } 315 | }); 316 | 317 | var OffCanvas = function () { 318 | this.init.apply(this, arguments); 319 | }; 320 | 321 | OffCanvas.defaults = { 322 | className: 'off-canvas-contain', 323 | trigger: '[class^="off-canvas-trigger"]', 324 | leftOpenClass: 'off-canvas--open-left', 325 | rightOpenClass: 'off-canvas--open-right' 326 | }; 327 | 328 | OffCanvas.prototype.init = function (el, options) { 329 | var self = this; 330 | 331 | // Store a reference to the jQuery element 332 | this.$el = $(el); 333 | 334 | // Set the options 335 | var options = this.options = $.extend({}, OffCanvas.defaults, options, this.$el.data('options')); 336 | 337 | // Add the class 338 | this.$el.addClass(options.className); 339 | 340 | $(document) 341 | .on('click.bk.offcanvas', function () { 342 | self.closeOffCanvas(); 343 | }) 344 | .on('click.bk.offcanvas', options.trigger, function (e) { 345 | var $this = $(this), 346 | $offCanvas = $this.parents('.off-canvas-contain'); 347 | 348 | e.stopPropagation(); 349 | e.preventDefault(); 350 | 351 | if ($offCanvas.hasClass(options.leftOpenClass) || $offCanvas.hasClass(options.rightOpenClass)) { 352 | self.closeOffCanvas(options); 353 | } else { 354 | self.openOffCanvas(options, $this, $offCanvas); 355 | } 356 | }) 357 | .on('click.bk.offcanvas', '.off-canvas-left', function (e) { 358 | e.stopPropagation(); 359 | }) 360 | .on('click.bk.offcanvas', '.off-canvas-right', function (e) { 361 | e.stopPropagation(); 362 | }); 363 | }; 364 | 365 | OffCanvas.prototype.closeOffCanvas = function () { 366 | this.$el.removeClass('off-canvas--open-right').removeClass('off-canvas--open-left'); 367 | }; 368 | 369 | OffCanvas.prototype.openOffCanvas = function (options, $this, $offCanvas) { 370 | if ($this.hasClass('off-canvas-trigger-left')) { 371 | $offCanvas.addClass(options.leftOpenClass); 372 | } else if ($this.hasClass('off-canvas-trigger-right')) { 373 | $offCanvas.addClass(options.rightOpenClass); 374 | } 375 | }; 376 | 377 | OffCanvas.prototype.destroy = function () { 378 | $(document).off(".offcanvas"); 379 | }; 380 | 381 | Bk.OffCanvas = OffCanvas; 382 | 383 | // Expose as a jQuery Plugin 384 | $.fn.bkOffCanvas = function (options) { 385 | return this.each(function () { 386 | var $el = $(this); 387 | // Check if it is already set up 388 | if (!$el.data('bkOffCanvas')) { 389 | $el.data('bkOffCanvas', new OffCanvas(this, options)); 390 | } 391 | }); 392 | }; 393 | 394 | // Allow defaults to be accessed via a common jQuery pattern 395 | $.fn.bkOffCanvas.defaults = OffCanvas.defaults; 396 | 397 | // Auto-initialize if set 398 | jQuery(function ($) { 399 | if (Bk.autoInitialize) { 400 | $('.' + OffCanvas.defaults.className).bkOffCanvas(); 401 | } 402 | }); 403 | 404 | var Tabs = function () { 405 | this.init.apply(this, arguments); 406 | }; 407 | 408 | Tabs.defaults = { 409 | className: 'tabs', 410 | panelClass: 'tabs-panels', 411 | activeTrigger: 'tab-trigger--open', 412 | activePanel: 'tab-panel--open' 413 | }; 414 | 415 | Tabs.prototype.init = function (el, options) { 416 | var self = this; 417 | 418 | // Store a reference to the jQuery element 419 | this.$el = $(el); 420 | 421 | // Set the options 422 | this.options = $.extend({}, Tabs.defaults, options, this.$el.data('options')); 423 | 424 | // Add the class 425 | this.$el.addClass(this.options.className); 426 | 427 | this.$trigger = this.$el.find('li a'); 428 | 429 | this.$trigger.on('click.bk.tabs', function (e) { 430 | var $this = $(this); 431 | 432 | e.preventDefault(); 433 | 434 | self.doTabs($this); 435 | }); 436 | }; 437 | 438 | Tabs.prototype.doTabs = function ($this) { 439 | var $panelGroup = $this.parent().parent().next('.' + this.options.panelClass), 440 | $panel = $panelGroup.children('li'), 441 | triggerPos = $this.parent().index(), 442 | $matchingPanel = $panel.eq(triggerPos); 443 | 444 | // Remove all trigger active classes 445 | this.$trigger.parent().removeClass(this.options.activeTrigger); 446 | 447 | // Trigger active class 448 | $this.parent().addClass(this.options.activeTrigger); 449 | 450 | // Remove all panel active classes 451 | $panel.removeClass(this.options.activePanel); 452 | 453 | // Panel active class 454 | $matchingPanel.addClass(this.options.activePanel); 455 | }; 456 | 457 | Tabs.prototype.destroy = function () { 458 | this.$trigger.off(".tabs"); 459 | }; 460 | 461 | Bk.Tabs = Tabs; 462 | 463 | // Expose as a jQuery Plugin 464 | $.fn.bkTabs = function (options) { 465 | return this.each(function () { 466 | var $el = $(this); 467 | // Check if it is already set up 468 | if (!$el.data('bkTabs')) { 469 | $el.data('bkTabs', new Tabs(this, options)); 470 | } 471 | }); 472 | }; 473 | 474 | // Allow defaults to be accessed via a common jQuery pattern 475 | $.fn.bkTabs.defaults = Tabs.defaults; 476 | 477 | // Auto-initialize if set 478 | jQuery(function ($) { 479 | if (Bk.autoInitialize) { 480 | $('.' + Tabs.defaults.className).bkTabs(); 481 | } 482 | }); 483 | var Toggle = function () { 484 | this.init.apply(this, arguments); 485 | }; 486 | 487 | Toggle.defaults = { 488 | className: 'toggle-trigger', 489 | toggle: '', 490 | activeTriggerClass: 'toggle-trigger-shown', 491 | activeClass: 'toggle-shown', 492 | closeOnClick: false 493 | }; 494 | 495 | Toggle.prototype.init = function (el, options) { 496 | var self = this; 497 | 498 | // Store a reference to the jQuery element 499 | this.$el = $(el); 500 | 501 | this.options = $.extend({}, Toggle.defaults, options, this.$el.data('options')); 502 | 503 | // Add the class 504 | this.$el.addClass(this.options.className); 505 | 506 | if (this.options.closeOnClick == true) { 507 | $(document).on('click', function (e) { 508 | $('#' + self.options.toggle).removeClass(self.options.activeClass); 509 | }); 510 | 511 | $('#' + this.options.toggle).on('click', function (e) { 512 | e.stopPropagation(); 513 | }); 514 | } 515 | 516 | this.$el.on('click.bk.toggle', function (e) { 517 | var $this = $(this); 518 | 519 | e.preventDefault(); 520 | e.stopPropagation(); 521 | 522 | self.doToggle(); 523 | }); 524 | }; 525 | 526 | Toggle.prototype.doToggle = function () { 527 | var self = this, 528 | $target = $('#' + this.options.toggle); 529 | 530 | // Toggle class on trigger element 531 | self.$el.toggleClass(this.options.activeTriggerClass); 532 | 533 | // Toggle class on element desired to be shown/hidden 534 | $target.toggleClass(this.options.activeClass); 535 | }; 536 | 537 | Toggle.prototype.unToggle = function () { 538 | var self = this, 539 | $target = $('#' + this.options.toggle); 540 | 541 | $target.removeClass(this.options.activeClass); 542 | }; 543 | 544 | Toggle.prototype.destroy = function () { 545 | this.$el.off(".toggle"); 546 | }; 547 | 548 | Bk.Toggle = Toggle; 549 | 550 | // Expose as a jQuery Plugin 551 | $.fn.bkToggle = function (options) { 552 | return this.each(function () { 553 | var $el = $(this); 554 | // Check if it is already set up 555 | if (!$el.data('bkToggle')) { 556 | $el.data('bkToggle', new Toggle(this, options)); 557 | } 558 | }); 559 | }; 560 | 561 | // Allow defaults to be accessed via a common jQuery pattern 562 | $.fn.bkToggle.defaults = Toggle.defaults; 563 | 564 | // Auto-initialize if set 565 | jQuery(function ($) { 566 | if (Bk.autoInitialize) { 567 | $('.' + Toggle.defaults.className).bkToggle(); 568 | } 569 | }); 570 | }(jQuery)); -------------------------------------------------------------------------------- /js/barekit.min.js: -------------------------------------------------------------------------------- 1 | !function(a){var b;window.Barekit=b={autoInitialize:!0};var c=function(){this.init.apply(this,arguments)};c.defaults={className:"accordion",multiExpand:!1,panelSelector:"dd",triggerSelector:"dt",activeTrigger:"accordion-trigger--open",activePanel:"accordion-panel--open"},c.prototype.init=function(b,d){this.$el=a(b),this.options=a.extend({},c.defaults,d,this.$el.data("options")),this.$el.addClass(this.options.className),this.$el.on("click.bk.accordion",a.proxy(this.onClick,this))},c.prototype.onClick=function(b){var c=a(b.target);if(c.is("a")){{c.attr("href")}"#"==c.attr("href")&&b.preventDefault()}for(;c.length&&!c.is("dt");)c=c.parent();if(c.length){var d=c.next("dd");this.processOptions(c,d)}},c.prototype.processOptions=function(a,b){var c=this.$el.find(this.options.panelSelector),d=this.$el.find(this.options.triggerSelector),e=this.options.activeTrigger,f=this.options.activePanel;this.options.multiExpand===!0?(a.toggleClass(e),b.toggleClass(f)):(d.removeClass(e),a.addClass(e),b.hasClass(f)||c.removeClass(f),b.toggleClass(f))},c.prototype.destroy=function(){this.$el.off(".accordion")},b.Accordion=c,a.fn.bkAccordion=function(b){return this.each(function(){var d=a(this);d.data("bkAccordion")||d.data("bkAccordion",new c(this,b))})},a.fn.bkAccordion.defaults=c.defaults,jQuery(function(a){b.autoInitialize&&a("."+c.defaults.className).bkAccordion()});var d=function(){this.init.apply(this,arguments)};d.defaults={className:"dropdown-nav",click:!1,clickClass:"click-setting",activeTrigger:"dropdown-trigger--open",activeClass:"dropdown--open"},d.prototype.init=function(b,c){this.$el=a(b);var e=this.$el.find("li:has(ul)");this.options=a.extend({},d.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),1==this.options.click&&(e.addClass(this.options.clickClass),e.on("click.bk.dropdown",a.proxy(this.remove,this)),self=this,a(document).on("click",function(b){a("."+self.options.activeTrigger).each(function(){self.hide(a(this),b)})}),a(document).keyup(function(b){27===b.keyCode&&a("."+self.options.activeTrigger).each(function(){self.hide(a(this),"undefined")})}))},d.prototype.hide=function(b,c){("undefined"===c||a(c.target).parents("ul."+this.options.className)[0]!==b.parents("ul."+this.options.className)[0])&&(b.removeClass(this.options.activeTrigger),b.children("ul").removeClass(this.options.activeClass))},d.prototype.remove=function(b){var c=a(b.currentTarget),d=c.children("ul"),e=a(b.target);e.is("a")||b.preventDefault(),c.removeClass(this.options.className),this.doDropdown(c,d)},d.prototype.doDropdown=function(a,b){a.toggleClass(this.options.activeTrigger),b.toggleClass(this.options.activeClass)},d.prototype.destroy=function(){this.$el.off(".dropdown")},b.Dropdown=d,a.fn.bkDropdown=function(b){return this.each(function(){var c=a(this);c.data("bkDropdown")||c.data("bkDropdown",new d(this,b))})},a.fn.bkDropdown.defaults=d.defaults,jQuery(function(a){b.autoInitialize&&a("."+d.defaults.className).bkDropdown()});var e=function(){this.init.apply(this,arguments)};e.defaults={className:"modal-trigger",modal:".modal",close:".modal-close",bg:"modal-bg",openClass:"modal-open"},e.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},e.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),a(document).on("click.bk.modal",function(){d.closeModal()}).on("click.bk.modal","."+this.options.className,function(b){b.stopPropagation(),b.preventDefault(),a(b.currentTarget).data("options").modalId===d.options.modalId&&d.onClick()}).on("click.bk.modal",this.options.modal,function(a){a.stopPropagation(),a.preventDefault()}).on("keyup.bk.modal",function(a){27===a.keyCode&&d.closeModal()}),a(this.options.close).on("click.bk.modal",function(){d.closeModal()})},e.prototype.onClick=function(){var b=a("#"+this.options.modalId);this.openModal(b)},e.prototype.openModal=function(b){a("body").addClass(this.options.bg),b.addClass(this.options.openClass)},e.prototype.closeModal=function(){a("body").removeClass(this.options.bg),a(this.options.modal).removeClass(this.options.openClass)},e.prototype.destroy=function(){a(document).off(".modal"),a(this.options.close).off(".modal")},b.Modal=e,a.fn.bkModal=function(b){return this.each(function(){var c=a(this);c.data("bkModal")||c.data("bkModal",new e(this,b))})},a.fn.bkModal.defaults=e.defaults,jQuery(function(a){b.autoInitialize&&a("."+e.defaults.className).bkModal()});var f=function(){this.init.apply(this,arguments)};f.defaults={className:"off-canvas-contain",trigger:'[class^="off-canvas-trigger"]',leftOpenClass:"off-canvas--open-left",rightOpenClass:"off-canvas--open-right"},f.prototype.init=function(b,c){var d=this;this.$el=a(b);var c=this.options=a.extend({},f.defaults,c,this.$el.data("options"));this.$el.addClass(c.className),a(document).on("click.bk.offcanvas",function(){d.closeOffCanvas()}).on("click.bk.offcanvas",c.trigger,function(b){var e=a(this),f=e.parents(".off-canvas-contain");b.stopPropagation(),b.preventDefault(),f.hasClass(c.leftOpenClass)||f.hasClass(c.rightOpenClass)?d.closeOffCanvas(c):d.openOffCanvas(c,e,f)}).on("click.bk.offcanvas",".off-canvas-left",function(a){a.stopPropagation()}).on("click.bk.offcanvas",".off-canvas-right",function(a){a.stopPropagation()})},f.prototype.closeOffCanvas=function(){this.$el.removeClass("off-canvas--open-right").removeClass("off-canvas--open-left")},f.prototype.openOffCanvas=function(a,b,c){b.hasClass("off-canvas-trigger-left")?c.addClass(a.leftOpenClass):b.hasClass("off-canvas-trigger-right")&&c.addClass(a.rightOpenClass)},f.prototype.destroy=function(){a(document).off(".offcanvas")},b.OffCanvas=f,a.fn.bkOffCanvas=function(b){return this.each(function(){var c=a(this);c.data("bkOffCanvas")||c.data("bkOffCanvas",new f(this,b))})},a.fn.bkOffCanvas.defaults=f.defaults,jQuery(function(a){b.autoInitialize&&a("."+f.defaults.className).bkOffCanvas()});var g=function(){this.init.apply(this,arguments)};g.defaults={className:"tabs",panelClass:"tabs-panels",activeTrigger:"tab-trigger--open",activePanel:"tab-panel--open"},g.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},g.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),this.$trigger=this.$el.find("li a"),this.$trigger.on("click.bk.tabs",function(b){var c=a(this);b.preventDefault(),d.doTabs(c)})},g.prototype.doTabs=function(a){var b=a.parent().parent().next("."+this.options.panelClass),c=b.children("li"),d=a.parent().index(),e=c.eq(d);this.$trigger.parent().removeClass(this.options.activeTrigger),a.parent().addClass(this.options.activeTrigger),c.removeClass(this.options.activePanel),e.addClass(this.options.activePanel)},g.prototype.destroy=function(){this.$trigger.off(".tabs")},b.Tabs=g,a.fn.bkTabs=function(b){return this.each(function(){var c=a(this);c.data("bkTabs")||c.data("bkTabs",new g(this,b))})},a.fn.bkTabs.defaults=g.defaults,jQuery(function(a){b.autoInitialize&&a("."+g.defaults.className).bkTabs()});var h=function(){this.init.apply(this,arguments)};h.defaults={className:"toggle-trigger",toggle:"",activeTriggerClass:"toggle-trigger-shown",activeClass:"toggle-shown",closeOnClick:!1},h.prototype.init=function(b,c){var d=this;this.$el=a(b),this.options=a.extend({},h.defaults,c,this.$el.data("options")),this.$el.addClass(this.options.className),1==this.options.closeOnClick&&(a(document).on("click",function(){a("#"+d.options.toggle).removeClass(d.options.activeClass)}),a("#"+this.options.toggle).on("click",function(a){a.stopPropagation()})),this.$el.on("click.bk.toggle",function(b){a(this);b.preventDefault(),b.stopPropagation(),d.doToggle()})},h.prototype.doToggle=function(){var b=this,c=a("#"+this.options.toggle);b.$el.toggleClass(this.options.activeTriggerClass),c.toggleClass(this.options.activeClass)},h.prototype.unToggle=function(){var b=a("#"+this.options.toggle);b.removeClass(this.options.activeClass)},h.prototype.destroy=function(){this.$el.off(".toggle")},b.Toggle=h,a.fn.bkToggle=function(b){return this.each(function(){var c=a(this);c.data("bkToggle")||c.data("bkToggle",new h(this,b))})},a.fn.bkToggle.defaults=h.defaults,jQuery(function(a){b.autoInitialize&&a("."+h.defaults.className).bkToggle()})}(jQuery); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "barekit", 3 | "title": "BareKit", 4 | "version": "0.7.0", 5 | "description": "A bare minimum responsive framework", 6 | "keywords": [ 7 | "responsive", 8 | "framework" 9 | ], 10 | "homepage": "https://trevanhetzel.github.io/barekit", 11 | "bugs": "https://github.com/trevanhetzel/barekit/issues", 12 | "repository": { 13 | "type": "git", 14 | "url": "git://github.com/trevanhetzel/barekit.git" 15 | }, 16 | "dependencies": {}, 17 | "devDependencies": { 18 | "grunt": "~0.4.1", 19 | "grunt-autoprefixer": "~0.7.3", 20 | "grunt-contrib-sass": "~0.7.3", 21 | "grunt-contrib-uglify": "~0.5.0", 22 | "grunt-contrib-watch": "~0.5.1", 23 | "gulp": "^3.8.2", 24 | "gulp-autoprefixer": "0.0.7", 25 | "gulp-concat": "^2.2.0", 26 | "gulp-stylus": "^1.0.2", 27 | "gulp-uglify": "^0.3.1", 28 | "grunt-contrib-concat": "^0.5.0", 29 | "grunt-contrib-qunit": "^0.5.2", 30 | "grunt-docco": "^0.3.3" 31 | }, 32 | "licenses": [ 33 | { 34 | "type": "MIT", 35 | "url": "https://github.com/trevanhetzel/barekit/blob/master/LICENSE" 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /spec/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | QUnit Example 6 | 7 | 8 | 9 |
10 |
11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spec/tests.js: -------------------------------------------------------------------------------- 1 | module('Barekit'); 2 | 3 | test('core', function() { 4 | ok(window.Barekit); 5 | }); 6 | 7 | module('Accordion'); 8 | 9 | test('should be a jquery plugin', function() { 10 | ok($.fn.bkAccordion); 11 | }); -------------------------------------------------------------------------------- /src/modules/accordion.js: -------------------------------------------------------------------------------- 1 | var Accordion = function () { 2 | this.init.apply(this, arguments); 3 | }; 4 | 5 | Accordion.defaults = { 6 | className: 'accordion', 7 | multiExpand: false, 8 | panelSelector: 'dd', 9 | triggerSelector: 'dt', 10 | activeTrigger: 'accordion-trigger--open', 11 | activePanel: 'accordion-panel--open' 12 | }; 13 | 14 | Accordion.prototype.init = function (el, options) { 15 | // Store a reference to the jQuery element 16 | this.$el = $(el); 17 | 18 | // Set the options 19 | this.options = $.extend({}, Accordion.defaults, options, this.$el.data('options')); 20 | 21 | // Add the class 22 | this.$el.addClass(this.options.className); 23 | 24 | this.$el.on('click.bk.accordion', $.proxy(this.onClick, this)); 25 | }; 26 | 27 | Accordion.prototype.onClick = function (e) { 28 | var $target = $(e.target); 29 | 30 | //prevent default behaviour on non-absolute links 31 | if ($target.is('a')) { 32 | var href = $target.attr("href"); 33 | if ($target.attr("href") == "#") { 34 | e.preventDefault(); 35 | } 36 | } 37 | 38 | //find the dt parent node 39 | while($target.length && !$target.is('dt')) { 40 | $target = $target.parent(); 41 | } 42 | 43 | if ($target.length) { 44 | var $content = $target.next('dd'); 45 | this.processOptions($target, $content); 46 | } 47 | }; 48 | 49 | Accordion.prototype.processOptions = function ($target, $content) { 50 | var $panel = this.$el.find(this.options.panelSelector), 51 | $trigger = this.$el.find(this.options.triggerSelector), 52 | activeTrigger = this.options.activeTrigger, 53 | activePanel = this.options.activePanel; 54 | 55 | if (this.options.multiExpand === true) { 56 | // Trigger active class 57 | $target.toggleClass(activeTrigger); 58 | // Panel active class 59 | $content.toggleClass(activePanel); 60 | } else { 61 | // Remove all trigger active classes 62 | $trigger.removeClass(activeTrigger); 63 | // Trigger active class 64 | $target.addClass(activeTrigger); 65 | 66 | // Remove all panel active classes 67 | if (!$content.hasClass(activePanel)) { 68 | $panel.removeClass(activePanel); 69 | } 70 | // Panel active class 71 | $content.toggleClass(activePanel); 72 | } 73 | }; 74 | 75 | Accordion.prototype.destroy = function () { 76 | this.$el.off('.accordion'); 77 | }; 78 | 79 | Bk.Accordion = Accordion; 80 | 81 | // Expose as a jQuery Plugin 82 | $.fn.bkAccordion = function (options) { 83 | return this.each(function () { 84 | var $el = $(this); 85 | // Check if it is already set up 86 | if (!$el.data('bkAccordion')) { 87 | $el.data('bkAccordion', new Accordion(this, options)); 88 | } 89 | }); 90 | }; 91 | 92 | // Allow defaults to be accessed via a common jQuery pattern 93 | $.fn.bkAccordion.defaults = Accordion.defaults; 94 | 95 | // Auto-initialize if set 96 | jQuery(function ($) { 97 | if (Bk.autoInitialize) { 98 | $('.' + Accordion.defaults.className).bkAccordion(); 99 | } 100 | }); -------------------------------------------------------------------------------- /src/modules/core.js: -------------------------------------------------------------------------------- 1 | var Bk; 2 | 3 | window.Barekit = Bk = { 4 | autoInitialize: true 5 | }; 6 | -------------------------------------------------------------------------------- /src/modules/dropdown-nav.js: -------------------------------------------------------------------------------- 1 | var Dropdown = function () { 2 | this.init.apply(this, arguments); 3 | }; 4 | 5 | Dropdown.defaults = { 6 | className: 'dropdown-nav', 7 | click: false, 8 | clickClass: 'click-setting', 9 | activeTrigger: 'dropdown-trigger--open', 10 | activeClass: 'dropdown--open' 11 | }; 12 | 13 | Dropdown.prototype.init = function (el, options) { 14 | // Store a reference to the jQuery element 15 | this.$el = $(el); 16 | 17 | var $trigger = this.$el.find('li:has(ul)'); 18 | 19 | // Set the options 20 | this.options = $.extend({}, Dropdown.defaults, options, this.$el.data('options')); 21 | 22 | // Add the class 23 | this.$el.addClass(this.options.className); 24 | 25 | if (this.options.click == true) { 26 | // Cancel out the CSS hover functionality 27 | $trigger.addClass(this.options.clickClass); 28 | $trigger.on('click.bk.dropdown', $.proxy(this.remove, this)); 29 | 30 | //mouse click listener to close the dropdown if clicked outside 31 | self = this; 32 | $(document).on('click', function(e){ 33 | $('.' + self.options.activeTrigger).each(function(){ 34 | self.hide($(this), e); 35 | }); 36 | }); 37 | 38 | //keyboard listener to close the dropdown if esc is pressed 39 | $(document).keyup(function(e) { 40 | if(e.keyCode === 27){ 41 | $('.' + self.options.activeTrigger).each(function(){ 42 | self.hide($(this), 'undefined'); 43 | }); 44 | } 45 | }); 46 | } 47 | }; 48 | 49 | Dropdown.prototype.hide = function($el, e) { 50 | if( e === 'undefined' || ($(e.target).parents('ul.' + this.options.className)[0] !== $el.parents('ul.' + this.options.className)[0])){ 51 | $el.removeClass(this.options.activeTrigger); 52 | $el.children('ul').removeClass(this.options.activeClass); 53 | } 54 | }; 55 | 56 | Dropdown.prototype.remove = function (e) { 57 | var $this = $(e.currentTarget), 58 | $menu = $this.children('ul'), 59 | $target = $(e.target); 60 | 61 | if(!$target.is('a')){ 62 | e.preventDefault(); 63 | } 64 | 65 | $this.removeClass(this.options.className); 66 | 67 | this.doDropdown($this, $menu); 68 | }; 69 | 70 | Dropdown.prototype.doDropdown = function ($this, $menu) { 71 | $this.toggleClass(this.options.activeTrigger); 72 | $menu.toggleClass(this.options.activeClass); 73 | }; 74 | 75 | Dropdown.prototype.destroy = function () { 76 | this.$el.off('.dropdown'); 77 | }; 78 | 79 | Bk.Dropdown = Dropdown; 80 | 81 | // Expose as a jQuery Plugin 82 | $.fn.bkDropdown = function (options) { 83 | return this.each(function () { 84 | var $el = $(this); 85 | // Check if it is already set up 86 | if (!$el.data('bkDropdown')) { 87 | $el.data('bkDropdown', new Dropdown(this, options)); 88 | } 89 | }); 90 | }; 91 | 92 | // Allow defaults to be accessed via a common jQuery pattern 93 | $.fn.bkDropdown.defaults = Dropdown.defaults; 94 | 95 | // Auto-initialize if set 96 | jQuery(function ($) { 97 | if (Bk.autoInitialize) { 98 | $('.' + Dropdown.defaults.className).bkDropdown(); 99 | } 100 | }); 101 | -------------------------------------------------------------------------------- /src/modules/modal.js: -------------------------------------------------------------------------------- 1 | var Modal = function () { 2 | this.init.apply(this, arguments); 3 | }; 4 | 5 | Modal.defaults = { 6 | className: 'modal-trigger', 7 | modal: '.modal', 8 | close: '.modal-close', 9 | bg: 'modal-bg', 10 | openClass: 'modal-open' 11 | }; 12 | 13 | Modal.prototype.init = function (el, options) { 14 | var self = this; 15 | 16 | // Store a reference to the jQuery element 17 | this.$el = $(el); 18 | 19 | // Set the options 20 | this.options = $.extend({}, Modal.defaults, options, this.$el.data('options')); 21 | 22 | // Add the class 23 | this.$el.addClass(this.options.className); 24 | 25 | $(document) 26 | .on('click.bk.modal', function (e) { 27 | self.closeModal(); 28 | }) 29 | .on('click.bk.modal', '.' + this.options.className, function (e) { 30 | e.stopPropagation(); 31 | e.preventDefault(); 32 | 33 | if ($(e.currentTarget).data("options").modalId === self.options.modalId) { 34 | self.onClick(); 35 | } 36 | }) 37 | .on('click.bk.modal', this.options.modal, function (e) { 38 | e.stopPropagation(); 39 | e.preventDefault(); 40 | }) 41 | .on('keyup.bk.modal', function (e) { 42 | if (e.keyCode === 27) { 43 | self.closeModal(); 44 | } 45 | }); 46 | 47 | $(this.options.close).on('click.bk.modal', function () { 48 | self.closeModal(); 49 | }); 50 | }; 51 | 52 | Modal.prototype.onClick = function (e) { 53 | 54 | var $dest = $('#' + this.options.modalId); 55 | 56 | this.openModal($dest); 57 | }; 58 | 59 | Modal.prototype.openModal = function($dest) { 60 | // Add class to body for overlay 61 | $('body').addClass(this.options.bg); 62 | // Add open class to modal 63 | $dest.addClass(this.options.openClass); 64 | }; 65 | 66 | Modal.prototype.closeModal = function () { 67 | // Remove class from body to remove overlay 68 | $('body').removeClass(this.options.bg); 69 | // Remove open class from modal 70 | $(this.options.modal).removeClass(this.options.openClass); 71 | }; 72 | 73 | Modal.prototype.destroy = function () { 74 | $(document).off('.modal'); 75 | $(this.options.close).off('.modal'); 76 | }; 77 | 78 | Bk.Modal = Modal; 79 | 80 | // Expose as a jQuery Plugin 81 | $.fn.bkModal = function (options) { 82 | return this.each(function () { 83 | var $el = $(this); 84 | // Check if it is already set up 85 | if (!$el.data('bkModal')) { 86 | $el.data('bkModal', new Modal(this, options)); 87 | } 88 | }); 89 | }; 90 | 91 | // Allow defaults to be accessed via a common jQuery pattern 92 | $.fn.bkModal.defaults = Modal.defaults; 93 | 94 | // Auto-initialize if set 95 | jQuery(function ($) { 96 | if (Bk.autoInitialize) { 97 | $('.' + Modal.defaults.className).bkModal(); 98 | } 99 | }); 100 | -------------------------------------------------------------------------------- /src/modules/off-canvas.js: -------------------------------------------------------------------------------- 1 | var OffCanvas = function () { 2 | this.init.apply(this, arguments); 3 | }; 4 | 5 | OffCanvas.defaults = { 6 | className: 'off-canvas-contain', 7 | trigger: '[class^="off-canvas-trigger"]', 8 | leftOpenClass: 'off-canvas--open-left', 9 | rightOpenClass: 'off-canvas--open-right' 10 | }; 11 | 12 | OffCanvas.prototype.init = function (el, options) { 13 | var self = this; 14 | 15 | // Store a reference to the jQuery element 16 | this.$el = $(el); 17 | 18 | // Set the options 19 | var options = this.options = $.extend({}, OffCanvas.defaults, options, this.$el.data('options')); 20 | 21 | // Add the class 22 | this.$el.addClass(options.className); 23 | 24 | $(document) 25 | .on('click.bk.offcanvas', function () { 26 | self.closeOffCanvas(); 27 | }) 28 | .on('click.bk.offcanvas', options.trigger, function (e) { 29 | var $this = $(this), 30 | $offCanvas = $this.parents('.off-canvas-contain'); 31 | 32 | e.stopPropagation(); 33 | e.preventDefault(); 34 | 35 | if ($offCanvas.hasClass(options.leftOpenClass) || $offCanvas.hasClass(options.rightOpenClass)) { 36 | self.closeOffCanvas(options); 37 | } else { 38 | self.openOffCanvas(options, $this, $offCanvas); 39 | } 40 | }) 41 | .on('click.bk.offcanvas', '.off-canvas-left', function (e) { 42 | e.stopPropagation(); 43 | }) 44 | .on('click.bk.offcanvas', '.off-canvas-right', function (e) { 45 | e.stopPropagation(); 46 | }); 47 | }; 48 | 49 | OffCanvas.prototype.closeOffCanvas = function () { 50 | this.$el.removeClass('off-canvas--open-right').removeClass('off-canvas--open-left'); 51 | }; 52 | 53 | OffCanvas.prototype.openOffCanvas = function (options, $this, $offCanvas) { 54 | if ($this.hasClass('off-canvas-trigger-left')) { 55 | $offCanvas.addClass(options.leftOpenClass); 56 | } else if ($this.hasClass('off-canvas-trigger-right')) { 57 | $offCanvas.addClass(options.rightOpenClass); 58 | } 59 | }; 60 | 61 | OffCanvas.prototype.destroy = function () { 62 | $(document).off(".offcanvas"); 63 | }; 64 | 65 | Bk.OffCanvas = OffCanvas; 66 | 67 | // Expose as a jQuery Plugin 68 | $.fn.bkOffCanvas = function (options) { 69 | return this.each(function () { 70 | var $el = $(this); 71 | // Check if it is already set up 72 | if (!$el.data('bkOffCanvas')) { 73 | $el.data('bkOffCanvas', new OffCanvas(this, options)); 74 | } 75 | }); 76 | }; 77 | 78 | // Allow defaults to be accessed via a common jQuery pattern 79 | $.fn.bkOffCanvas.defaults = OffCanvas.defaults; 80 | 81 | // Auto-initialize if set 82 | jQuery(function ($) { 83 | if (Bk.autoInitialize) { 84 | $('.' + OffCanvas.defaults.className).bkOffCanvas(); 85 | } 86 | }); 87 | -------------------------------------------------------------------------------- /src/modules/tabs.js: -------------------------------------------------------------------------------- 1 | var Tabs = function () { 2 | this.init.apply(this, arguments); 3 | }; 4 | 5 | Tabs.defaults = { 6 | className: 'tabs', 7 | panelClass: 'tabs-panels', 8 | activeTrigger: 'tab-trigger--open', 9 | activePanel: 'tab-panel--open' 10 | }; 11 | 12 | Tabs.prototype.init = function (el, options) { 13 | var self = this; 14 | 15 | // Store a reference to the jQuery element 16 | this.$el = $(el); 17 | 18 | // Set the options 19 | this.options = $.extend({}, Tabs.defaults, options, this.$el.data('options')); 20 | 21 | // Add the class 22 | this.$el.addClass(this.options.className); 23 | 24 | this.$trigger = this.$el.find('li a'); 25 | 26 | this.$trigger.on('click.bk.tabs', function (e) { 27 | var $this = $(this); 28 | 29 | e.preventDefault(); 30 | 31 | self.doTabs($this); 32 | }); 33 | }; 34 | 35 | Tabs.prototype.doTabs = function ($this) { 36 | var $panelGroup = $this.parent().parent().next('.' + this.options.panelClass), 37 | $panel = $panelGroup.children('li'), 38 | triggerPos = $this.parent().index(), 39 | $matchingPanel = $panel.eq(triggerPos); 40 | 41 | // Remove all trigger active classes 42 | this.$trigger.parent().removeClass(this.options.activeTrigger); 43 | 44 | // Trigger active class 45 | $this.parent().addClass(this.options.activeTrigger); 46 | 47 | // Remove all panel active classes 48 | $panel.removeClass(this.options.activePanel); 49 | 50 | // Panel active class 51 | $matchingPanel.addClass(this.options.activePanel); 52 | }; 53 | 54 | Tabs.prototype.destroy = function () { 55 | this.$trigger.off(".tabs"); 56 | }; 57 | 58 | Bk.Tabs = Tabs; 59 | 60 | // Expose as a jQuery Plugin 61 | $.fn.bkTabs = function (options) { 62 | return this.each(function () { 63 | var $el = $(this); 64 | // Check if it is already set up 65 | if (!$el.data('bkTabs')) { 66 | $el.data('bkTabs', new Tabs(this, options)); 67 | } 68 | }); 69 | }; 70 | 71 | // Allow defaults to be accessed via a common jQuery pattern 72 | $.fn.bkTabs.defaults = Tabs.defaults; 73 | 74 | // Auto-initialize if set 75 | jQuery(function ($) { 76 | if (Bk.autoInitialize) { 77 | $('.' + Tabs.defaults.className).bkTabs(); 78 | } 79 | }); -------------------------------------------------------------------------------- /src/modules/toggle.js: -------------------------------------------------------------------------------- 1 | var Toggle = function () { 2 | this.init.apply(this, arguments); 3 | }; 4 | 5 | Toggle.defaults = { 6 | className: 'toggle-trigger', 7 | toggle: '', 8 | activeTriggerClass: 'toggle-trigger-shown', 9 | activeClass: 'toggle-shown', 10 | closeOnClick: false 11 | }; 12 | 13 | Toggle.prototype.init = function (el, options) { 14 | var self = this; 15 | 16 | // Store a reference to the jQuery element 17 | this.$el = $(el); 18 | 19 | this.options = $.extend({}, Toggle.defaults, options, this.$el.data('options')); 20 | 21 | // Add the class 22 | this.$el.addClass(this.options.className); 23 | 24 | if (this.options.closeOnClick == true) { 25 | $(document).on('click', function (e) { 26 | $('#' + self.options.toggle).removeClass(self.options.activeClass); 27 | }); 28 | 29 | $('#' + this.options.toggle).on('click', function (e) { 30 | e.stopPropagation(); 31 | }); 32 | } 33 | 34 | this.$el.on('click.bk.toggle', function (e) { 35 | var $this = $(this); 36 | 37 | e.preventDefault(); 38 | e.stopPropagation(); 39 | 40 | self.doToggle(); 41 | }); 42 | }; 43 | 44 | Toggle.prototype.doToggle = function () { 45 | var self = this, 46 | $target = $('#' + this.options.toggle); 47 | 48 | // Toggle class on trigger element 49 | self.$el.toggleClass(this.options.activeTriggerClass); 50 | 51 | // Toggle class on element desired to be shown/hidden 52 | $target.toggleClass(this.options.activeClass); 53 | }; 54 | 55 | Toggle.prototype.unToggle = function () { 56 | var self = this, 57 | $target = $('#' + this.options.toggle); 58 | 59 | $target.removeClass(this.options.activeClass); 60 | }; 61 | 62 | Toggle.prototype.destroy = function () { 63 | this.$el.off(".toggle"); 64 | }; 65 | 66 | Bk.Toggle = Toggle; 67 | 68 | // Expose as a jQuery Plugin 69 | $.fn.bkToggle = function (options) { 70 | return this.each(function () { 71 | var $el = $(this); 72 | // Check if it is already set up 73 | if (!$el.data('bkToggle')) { 74 | $el.data('bkToggle', new Toggle(this, options)); 75 | } 76 | }); 77 | }; 78 | 79 | // Allow defaults to be accessed via a common jQuery pattern 80 | $.fn.bkToggle.defaults = Toggle.defaults; 81 | 82 | // Auto-initialize if set 83 | jQuery(function ($) { 84 | if (Bk.autoInitialize) { 85 | $('.' + Toggle.defaults.className).bkToggle(); 86 | } 87 | }); -------------------------------------------------------------------------------- /src/prefix.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Barekit 0.7.0 3 | * 4 | * Copyright 2014 Trevan Hetzel. (http://trevan.coo) 5 | * Licensed under the MIT license. 6 | * 7 | * http://trevanhetzel.github.io/barekit/ 8 | */ 9 | ;(function($) { -------------------------------------------------------------------------------- /src/suffix.js: -------------------------------------------------------------------------------- 1 | }(jQuery)); --------------------------------------------------------------------------------