From 01d0cf22abb5345548b01e2e48310057d234b234 Mon Sep 17 00:00:00 2001 From: William Ghelfi Date: Mon, 6 May 2013 15:58:04 +0200 Subject: add offcanvas layout example based on bradfrost/this-is-responsive --- docs/_includes/footer.html | 4 + .../img/examples/bootstrap-example-offcanvas.png | Bin 0 -> 16337 bytes docs/assets/js/examples/bootstrap-offcanvas.js | 100 +++++++++++ docs/docs.html | 7 + docs/examples/offcanvas.html | 195 +++++++++++++++++++++ 5 files changed, 306 insertions(+) create mode 100644 docs/assets/img/examples/bootstrap-example-offcanvas.png create mode 100644 docs/assets/js/examples/bootstrap-offcanvas.js create mode 100644 docs/examples/offcanvas.html diff --git a/docs/_includes/footer.html b/docs/_includes/footer.html index 048f31359..81cd6f947 100644 --- a/docs/_includes/footer.html +++ b/docs/_includes/footer.html @@ -16,6 +16,10 @@ + + + diff --git a/docs/assets/img/examples/bootstrap-example-offcanvas.png b/docs/assets/img/examples/bootstrap-example-offcanvas.png new file mode 100644 index 000000000..7e213f2af Binary files /dev/null and b/docs/assets/img/examples/bootstrap-example-offcanvas.png differ diff --git a/docs/assets/js/examples/bootstrap-offcanvas.js b/docs/assets/js/examples/bootstrap-offcanvas.js new file mode 100644 index 000000000..075227904 --- /dev/null +++ b/docs/assets/js/examples/bootstrap-offcanvas.js @@ -0,0 +1,100 @@ +/* ============================================================ + * bootstrap-offcanvas.js v3.0.0 + * http://twitter.github.com/bootstrap/javascript.html#offcanvas + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + +/* ============================================================ + * This shouldn't be a plugin, because it's too simple. + * BTW, having it as a plugin, makes for a simpler dev cycle. + * ============================================================ */ + +!function ($) { + + "use strict"; // jshint ;_; + + + /* OFFCANVAS CLASS DEFINITION + * ========================= */ + + var toggle = '[data-toggle=offcanvas]' + , Offcanvas = function (element) { + var $el = $(element).on('click.offcanvas.data-api', this.toggle) + } + + Offcanvas.prototype = { + + constructor: Offcanvas + + , toggle: function (e) { + var $this = $(this) + , $parent + + $parent = $this.parents('.row-offcanvas') + + $parent.toggleClass('active') + $this.toggleClass('active') + + return false + } + + , keydown: function (e) { + $(this).toggle + // TODO + // This should be enough to provide the basic functionality. + // In the future I'd like to have the following behaviour: + // + // * on active via keyboard, give focus to the sidebar + // * while in sidebar: ESC gives back focus to the toggler anchor/button + } + + } + + + /* OFFCANVAS PLUGIN DEFINITION + * ========================== */ + + var old = $.fn.offcanvas + + $.fn.offcanvas = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('offcanvas') + if (!data) $this.data('offcanvas', (data = new Offcanvas(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.offcanvas.Constructor = Offcanvas + + + /* OFFCANVAS NO CONFLICT + * ==================== */ + + $.fn.offcanvas.noConflict = function () { + $.fn.offcanvas = old + return this + } + + + /* APPLY TO OFFCANVAS ELEMENTS + * =================================== */ + + $(document) + .on('click.offcanvas.data-api touchstart.offcanvas.data-api' , toggle, Offcanvas.prototype.toggle) + .on('keydown.offcanvas.data-api touchstart.offcanvas.data-api', toggle, Offcanvas.prototype.keydown) + +}(window.jQuery); \ No newline at end of file diff --git a/docs/docs.html b/docs/docs.html index 346725215..f02f75fb5 100644 --- a/docs/docs.html +++ b/docs/docs.html @@ -208,6 +208,13 @@ title: Bootstrap Documentation

Fixed top navbar

Basic template for showcasing the fixed navbar variation.

+
+ + + +

Offcanvas layout

+

An offcanvas layout based on This Is Responsive by Brad Frost.

+
diff --git a/docs/examples/offcanvas.html b/docs/examples/offcanvas.html new file mode 100644 index 000000000..cfc182ae4 --- /dev/null +++ b/docs/examples/offcanvas.html @@ -0,0 +1,195 @@ +--- +layout: example +title: Static navbar template +--- + + + + + + +
+ +
+
+

+
+

Hello, world!

+

This is an example to show the potential of an offcanvas layout pattern in Bootstrap. Try some responsive-range viewport sizes to see it in action.

+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+ +
+ +
+ +
+

© Company 2012

+
+ +
\ No newline at end of file -- cgit v1.2.3 From 9013ff002adcf2f7a3bfe2d60329649fc159204a Mon Sep 17 00:00:00 2001 From: William Ghelfi Date: Mon, 6 May 2013 15:58:04 +0200 Subject: add offcanvas layout example based on bradfrost/this-is-responsive --- docs/_includes/footer.html | 4 + .../img/examples/bootstrap-example-offcanvas.png | Bin 0 -> 16337 bytes docs/assets/js/examples/bootstrap-offcanvas.js | 100 +++++++++++ docs/docs.html | 7 + docs/examples/offcanvas.html | 195 +++++++++++++++++++++ 5 files changed, 306 insertions(+) create mode 100644 docs/assets/img/examples/bootstrap-example-offcanvas.png create mode 100644 docs/assets/js/examples/bootstrap-offcanvas.js create mode 100644 docs/examples/offcanvas.html diff --git a/docs/_includes/footer.html b/docs/_includes/footer.html index 048f31359..81cd6f947 100644 --- a/docs/_includes/footer.html +++ b/docs/_includes/footer.html @@ -16,6 +16,10 @@ + + + diff --git a/docs/assets/img/examples/bootstrap-example-offcanvas.png b/docs/assets/img/examples/bootstrap-example-offcanvas.png new file mode 100644 index 000000000..7e213f2af Binary files /dev/null and b/docs/assets/img/examples/bootstrap-example-offcanvas.png differ diff --git a/docs/assets/js/examples/bootstrap-offcanvas.js b/docs/assets/js/examples/bootstrap-offcanvas.js new file mode 100644 index 000000000..075227904 --- /dev/null +++ b/docs/assets/js/examples/bootstrap-offcanvas.js @@ -0,0 +1,100 @@ +/* ============================================================ + * bootstrap-offcanvas.js v3.0.0 + * http://twitter.github.com/bootstrap/javascript.html#offcanvas + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + +/* ============================================================ + * This shouldn't be a plugin, because it's too simple. + * BTW, having it as a plugin, makes for a simpler dev cycle. + * ============================================================ */ + +!function ($) { + + "use strict"; // jshint ;_; + + + /* OFFCANVAS CLASS DEFINITION + * ========================= */ + + var toggle = '[data-toggle=offcanvas]' + , Offcanvas = function (element) { + var $el = $(element).on('click.offcanvas.data-api', this.toggle) + } + + Offcanvas.prototype = { + + constructor: Offcanvas + + , toggle: function (e) { + var $this = $(this) + , $parent + + $parent = $this.parents('.row-offcanvas') + + $parent.toggleClass('active') + $this.toggleClass('active') + + return false + } + + , keydown: function (e) { + $(this).toggle + // TODO + // This should be enough to provide the basic functionality. + // In the future I'd like to have the following behaviour: + // + // * on active via keyboard, give focus to the sidebar + // * while in sidebar: ESC gives back focus to the toggler anchor/button + } + + } + + + /* OFFCANVAS PLUGIN DEFINITION + * ========================== */ + + var old = $.fn.offcanvas + + $.fn.offcanvas = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('offcanvas') + if (!data) $this.data('offcanvas', (data = new Offcanvas(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.offcanvas.Constructor = Offcanvas + + + /* OFFCANVAS NO CONFLICT + * ==================== */ + + $.fn.offcanvas.noConflict = function () { + $.fn.offcanvas = old + return this + } + + + /* APPLY TO OFFCANVAS ELEMENTS + * =================================== */ + + $(document) + .on('click.offcanvas.data-api touchstart.offcanvas.data-api' , toggle, Offcanvas.prototype.toggle) + .on('keydown.offcanvas.data-api touchstart.offcanvas.data-api', toggle, Offcanvas.prototype.keydown) + +}(window.jQuery); \ No newline at end of file diff --git a/docs/docs.html b/docs/docs.html index f3370dfbd..3e4fdeb22 100644 --- a/docs/docs.html +++ b/docs/docs.html @@ -208,6 +208,13 @@ title: Bootstrap Documentation

Fixed top navbar

Basic template for showcasing the fixed navbar variation.

+
+ + + +

Offcanvas layout

+

An offcanvas layout based on This Is Responsive by Brad Frost.

+
diff --git a/docs/examples/offcanvas.html b/docs/examples/offcanvas.html new file mode 100644 index 000000000..cfc182ae4 --- /dev/null +++ b/docs/examples/offcanvas.html @@ -0,0 +1,195 @@ +--- +layout: example +title: Static navbar template +--- + + + + + + +
+ +
+
+

+
+

Hello, world!

+

This is an example to show the potential of an offcanvas layout pattern in Bootstrap. Try some responsive-range viewport sizes to see it in action.

+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+

Heading

+

Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.

+

View details »

+
+
+
+ +
+ +
+ +
+

© Company 2012

+
+ +
\ No newline at end of file -- cgit v1.2.3