aboutsummaryrefslogtreecommitdiff
path: root/docs/assets
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2013-06-19 19:13:38 -0700
committerMark Otto <[email protected]>2013-06-19 19:13:38 -0700
commitb0bece66f295df37b0cf3e61267de17640640da8 (patch)
treea5e75dfd80126c66e8186d1c1ef99cec09f10c06 /docs/assets
parent5fcdf1229d1845ce9e115b0e6390610b702a3335 (diff)
parent7090eb00619f4ebfc12de907b0c202b2b2b56efb (diff)
downloadbootstrap-b0bece66f295df37b0cf3e61267de17640640da8.tar.xz
bootstrap-b0bece66f295df37b0cf3e61267de17640640da8.zip
Merge branch 'offcanvas-example' of https://github.com/trumbitta/bootstrap into trumbitta-offcanvas-example
Diffstat (limited to 'docs/assets')
-rw-r--r--docs/assets/img/examples/bootstrap-example-offcanvas.pngbin0 -> 16337 bytes
-rw-r--r--docs/assets/js/examples/bootstrap-offcanvas.js100
2 files changed, 100 insertions, 0 deletions
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
--- /dev/null
+++ b/docs/assets/img/examples/bootstrap-example-offcanvas.png
Binary files 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