From e4d5bdf52a921932551c051df63ea8087d2037da Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Tue, 9 Dec 2014 18:54:24 +0200 Subject: [PATCH] Add solutions --- MANIFEST | 3 + js/01-zepto-jquery.js | 1 + js/10-bootstrap-modal.js | 324 ++++++++++++++++++++++++++++++ lib/Plack/App/Gruntmaster.pm | 4 + lib/Plack/App/Gruntmaster/HTML.pm | 9 + tmpl/pb_entry.en | 15 +- tmpl/sol.en | 1 + 7 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 js/01-zepto-jquery.js create mode 100644 js/10-bootstrap-modal.js create mode 100644 tmpl/sol.en diff --git a/MANIFEST b/MANIFEST index 8c81dff..14d91b8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,7 +11,9 @@ css/themes/cosmo.css css/themes/cyborg.css css/themes/slate.css js/00-zepto.js +js/01-zepto-jquery.js js/10-bootstrap-dropdown.js +js/10-bootstrap-modal.js js/90-custom.js js/90-form.js lib/Plack/App/Gruntmaster.pm @@ -31,6 +33,7 @@ tmpl/log_entry.en tmpl/pb.en tmpl/pb_entry.en tmpl/skel.en +tmpl/sol.en tmpl/st.en tmpl/us.en tmpl/us_entry.en diff --git a/js/01-zepto-jquery.js b/js/01-zepto-jquery.js new file mode 100644 index 0000000..1fe7da3 --- /dev/null +++ b/js/01-zepto-jquery.js @@ -0,0 +1 @@ +jQuery = Zepto; diff --git a/js/10-bootstrap-modal.js b/js/10-bootstrap-modal.js new file mode 100644 index 0000000..93891aa --- /dev/null +++ b/js/10-bootstrap-modal.js @@ -0,0 +1,324 @@ +/* ======================================================================== + * Bootstrap: modal.js v3.3.1 + * http://getbootstrap.com/javascript/#modals + * ======================================================================== + * Copyright 2011-2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ + + ++function ($) { + 'use strict'; + + // MODAL CLASS DEFINITION + // ====================== + + var Modal = function (element, options) { + this.options = options + this.$body = $(document.body) + this.$element = $(element) + this.$backdrop = + this.isShown = null + this.scrollbarWidth = 0 + + if (this.options.remote) { + this.$element + .find('.modal-content') + .load(this.options.remote, $.proxy(function () { + this.$element.trigger('loaded.bs.modal') + }, this)) + } + } + + Modal.VERSION = '3.3.1' + + Modal.TRANSITION_DURATION = 300 + Modal.BACKDROP_TRANSITION_DURATION = 150 + + Modal.DEFAULTS = { + backdrop: true, + keyboard: true, + show: true + } + + Modal.prototype.toggle = function (_relatedTarget) { + return this.isShown ? this.hide() : this.show(_relatedTarget) + } + + Modal.prototype.show = function (_relatedTarget) { + var that = this + var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) + + this.$element.trigger(e) + + if (this.isShown || e.isDefaultPrevented()) return + + this.isShown = true + + this.checkScrollbar() + this.setScrollbar() + this.$body.addClass('modal-open') + + this.escape() + this.resize() + + this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) + + this.backdrop(function () { + var transition = $.support.transition && that.$element.hasClass('fade') + + if (!that.$element.parent().length) { + that.$element.appendTo(that.$body) // don't move modals dom position + } + + that.$element + .show() + .scrollTop(0) + + if (that.options.backdrop) that.adjustBackdrop() + that.adjustDialog() + + if (transition) { + that.$element[0].offsetWidth // force reflow + } + + that.$element + .addClass('in') + .attr('aria-hidden', false) + + that.enforceFocus() + + var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) + + transition ? + that.$element.find('.modal-dialog') // wait for modal to slide in + .one('bsTransitionEnd', function () { + that.$element.trigger('focus').trigger(e) + }) + .emulateTransitionEnd(Modal.TRANSITION_DURATION) : + that.$element.trigger('focus').trigger(e) + }) + } + + Modal.prototype.hide = function (e) { + if (e) e.preventDefault() + + e = $.Event('hide.bs.modal') + + this.$element.trigger(e) + + if (!this.isShown || e.isDefaultPrevented()) return + + this.isShown = false + + this.escape() + this.resize() + + $(document).off('focusin.bs.modal') + + this.$element + .removeClass('in') + .attr('aria-hidden', true) + .off('click.dismiss.bs.modal') + + $.support.transition && this.$element.hasClass('fade') ? + this.$element + .one('bsTransitionEnd', $.proxy(this.hideModal, this)) + .emulateTransitionEnd(Modal.TRANSITION_DURATION) : + this.hideModal() + } + + Modal.prototype.enforceFocus = function () { + $(document) + .off('focusin.bs.modal') // guard against infinite focus loop + .on('focusin.bs.modal', $.proxy(function (e) { + if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { + this.$element.trigger('focus') + } + }, this)) + } + + Modal.prototype.escape = function () { + if (this.isShown && this.options.keyboard) { + this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { + e.which == 27 && this.hide() + }, this)) + } else if (!this.isShown) { + this.$element.off('keydown.dismiss.bs.modal') + } + } + + Modal.prototype.resize = function () { + if (this.isShown) { + $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) + } else { + $(window).off('resize.bs.modal') + } + } + + Modal.prototype.hideModal = function () { + var that = this + this.$element.hide() + this.backdrop(function () { + that.$body.removeClass('modal-open') + that.resetAdjustments() + that.resetScrollbar() + that.$element.trigger('hidden.bs.modal') + }) + } + + Modal.prototype.removeBackdrop = function () { + this.$backdrop && this.$backdrop.remove() + this.$backdrop = null + } + + Modal.prototype.backdrop = function (callback) { + var that = this + var animate = this.$element.hasClass('fade') ? 'fade' : '' + + if (this.isShown && this.options.backdrop) { + var doAnimate = $.support.transition && animate + + this.$backdrop = $(' + + diff --git a/tmpl/sol.en b/tmpl/sol.en new file mode 100644 index 0000000..452d076 --- /dev/null +++ b/tmpl/sol.en @@ -0,0 +1 @@ +
-- 2.30.2