diff options
author | Thomas Park <thomas@thomaspark.me> | 2012-03-19 21:53:08 -0400 |
---|---|---|
committer | Thomas Park <thomas@thomaspark.me> | 2012-03-19 21:53:08 -0400 |
commit | 9a54e79cd3047f8bfc50646261961399d0f5b549 (patch) | |
tree | e643b8766d12a0fc0dbb9cf8054f4342731a44fb | |
parent | 6f4c8594f85881d67deaeb81d5b7c110bbd13dff (diff) |
index: modal for custom work
-rw-r--r-- | css/bootswatch.css | 12 | ||||
-rw-r--r-- | index.html | 29 | ||||
-rw-r--r-- | js/bootstrap-modal.js | 210 | ||||
-rwxr-xr-x | js/bootstrap-transition.js | 51 |
4 files changed, 300 insertions, 2 deletions
diff --git a/css/bootswatch.css b/css/bootswatch.css index c7e8e33e..b2204dca 100644 --- a/css/bootswatch.css +++ b/css/bootswatch.css @@ -112,6 +112,18 @@ body { margin-top: 10px; } +.modal .label { + vertical-align: text-top; +} + +.modal p { + margin-bottom: 1em; +} + +.modal p:last-child { + margin-top: 2em; +} + /* Landscape phones and down */ @media (max-width: 480px) { @@ -54,6 +54,7 @@ </div> </div> + <div class="container"> <!-- Main hero unit for a primary marketing message or call to action --> @@ -490,10 +491,10 @@ <img src="img/refs/blank.png" alt="" style="background-image: url('img/refs/stripes.png');"> <div class="caption"> <h3>Still searching?</h3> - <p>Inquire about custom-built swatches.</p> + <p>Get a swatch that's customized to your needs.</p> <div class="btn-toolbar"> <div class="btn-group"> - <a class="btn btn-large btn-danger" target="_blank" href="mailto:thomas@thomaspark.me"><i class="icon-envelope icon-white"></i> thomas@thomaspark.me</a> + <a class="btn btn-large btn-warning" data-toggle="modal" target="_blank" href="#modal-custom"><i class="icon-info-sign icon-white"></i> More Info</a> </div> </div> </div> @@ -506,6 +507,27 @@ </div> <!-- end row--> + <div class="modal hide fade" id="modal-custom"> + <div class="modal-header"> + <a class="close" data-dismiss="modal">×</a> + <h3>Custom-Built Swatches</h3> + </div> + <div class="modal-body"> + <h4>Quick Swatch</h4> + <p>Get a build of Bootstrap with <a target="_blank" href="https://github.com/twitter/bootstrap/blob/master/less/variables.less">variables.less</a> reskinned for you.</p> + <h4>Full Swatch</h4> + <p>Get a full theme that goes far beyond variables.less, based on your existing design.</p> + <h4>Custom Swatch</h4> + <p>Get a full theme designed and developed from the ground up.</p> + <h4>Other Services</h4> + <p>Get help with Bootstrap-ready markup, custom utility classes, and more!</p> + <p>Send inquiries to <a href="mailto:thomas@thomaspark.me">thomas@thomaspark.me</a>.</p> + </div> + <div class="modal-footer"> + <a href="#" class="btn" data-dismiss="modal">Close</a> + </div> + </div> + <div class="row" style="padding-top: 30px;"> <div class="span12"> @@ -636,6 +658,7 @@ </div> <!-- /container --> + <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> @@ -643,6 +666,8 @@ <script src="js/bootstrap-dropdown.js"></script> <script src="js/bootstrap-tooltip.js"></script> <script src="js/bootstrap-collapse.js"></script> + <script src="js/bootstrap-modal.js"></script> + <script src="js/bootstrap-transition.js"></script> <script src="js/bootswatch.js"></script> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js new file mode 100644 index 00000000..e9297062 --- /dev/null +++ b/js/bootstrap-modal.js @@ -0,0 +1,210 @@ +/* ========================================================= + * bootstrap-modal.js v2.0.2 + * http://twitter.github.com/bootstrap/javascript.html#modals + * ========================================================= + * 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. + * ========================================================= */ + + +!function( $ ){ + + "use strict" + + /* MODAL CLASS DEFINITION + * ====================== */ + + var Modal = function ( content, options ) { + this.options = options + this.$element = $(content) + .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) + } + + Modal.prototype = { + + constructor: Modal + + , toggle: function () { + return this[!this.isShown ? 'show' : 'hide']() + } + + , show: function () { + var that = this + + if (this.isShown) return + + $('body').addClass('modal-open') + + this.isShown = true + this.$element.trigger('show') + + escape.call(this) + backdrop.call(this, function () { + var transition = $.support.transition && that.$element.hasClass('fade') + + !that.$element.parent().length && that.$element.appendTo(document.body) //don't move modals dom position + + that.$element + .show() + + if (transition) { + that.$element[0].offsetWidth // force reflow + } + + that.$element.addClass('in') + + transition ? + that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : + that.$element.trigger('shown') + + }) + } + + , hide: function ( e ) { + e && e.preventDefault() + + if (!this.isShown) return + + var that = this + this.isShown = false + + $('body').removeClass('modal-open') + + escape.call(this) + + this.$element + .trigger('hide') + .removeClass('in') + + $.support.transition && this.$element.hasClass('fade') ? + hideWithTransition.call(this) : + hideModal.call(this) + } + + } + + + /* MODAL PRIVATE METHODS + * ===================== */ + + function hideWithTransition() { + var that = this + , timeout = setTimeout(function () { + that.$element.off($.support.transition.end) + hideModal.call(that) + }, 500) + + this.$element.one($.support.transition.end, function () { + clearTimeout(timeout) + hideModal.call(that) + }) + } + + function hideModal( that ) { + this.$element + .hide() + .trigger('hidden') + + backdrop.call(this) + } + + function backdrop( callback ) { + var that = this + , animate = this.$element.hasClass('fade') ? 'fade' : '' + + if (this.isShown && this.options.backdrop) { + var doAnimate = $.support.transition && animate + + this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') + .appendTo(document.body) + + if (this.options.backdrop != 'static') { + this.$backdrop.click($.proxy(this.hide, this)) + } + + if (doAnimate) this.$backdrop[0].offsetWidth // force reflow + + this.$backdrop.addClass('in') + + doAnimate ? + this.$backdrop.one($.support.transition.end, callback) : + callback() + + } else if (!this.isShown && this.$backdrop) { + this.$backdrop.removeClass('in') + + $.support.transition && this.$element.hasClass('fade')? + this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) : + removeBackdrop.call(this) + + } else if (callback) { + callback() + } + } + + function removeBackdrop() { + this.$backdrop.remove() + this.$backdrop = null + } + + function escape() { + var that = this + if (this.isShown && this.options.keyboard) { + $(document).on('keyup.dismiss.modal', function ( e ) { + e.which == 27 && that.hide() + }) + } else if (!this.isShown) { + $(document).off('keyup.dismiss.modal') + } + } + + + /* MODAL PLUGIN DEFINITION + * ======================= */ + + $.fn.modal = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('modal') + , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option) + if (!data) $this.data('modal', (data = new Modal(this, options))) + if (typeof option == 'string') data[option]() + else if (options.show) data.show() + }) + } + + $.fn.modal.defaults = { + backdrop: true + , keyboard: true + , show: true + } + + $.fn.modal.Constructor = Modal + + + /* MODAL DATA-API + * ============== */ + + $(function () { + $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { + var $this = $(this), href + , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data()) + + e.preventDefault() + $target.modal(option) + }) + }) + +}( window.jQuery );
\ No newline at end of file diff --git a/js/bootstrap-transition.js b/js/bootstrap-transition.js new file mode 100755 index 00000000..f5226f96 --- /dev/null +++ b/js/bootstrap-transition.js @@ -0,0 +1,51 @@ +/* =================================================== + * bootstrap-transition.js v2.0.2 + * http://twitter.github.com/bootstrap/javascript.html#transitions + * =================================================== + * 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. + * ========================================================== */ + +!function( $ ) { + + $(function () { + + "use strict" + + /* CSS TRANSITION SUPPORT (https://gist.github.com/373874) + * ======================================================= */ + + $.support.transition = (function () { + var thisBody = document.body || document.documentElement + , thisStyle = thisBody.style + , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined + + return support && { + end: (function () { + var transitionEnd = "TransitionEnd" + if ( $.browser.webkit ) { + transitionEnd = "webkitTransitionEnd" + } else if ( $.browser.mozilla ) { + transitionEnd = "transitionend" + } else if ( $.browser.opera ) { + transitionEnd = "oTransitionEnd" + } + return transitionEnd + }()) + } + })() + + }) + +}( window.jQuery );
\ No newline at end of file |