diff options
Diffstat (limited to 'fg21sim/webui')
-rw-r--r-- | fg21sim/webui/static/css/jquery.modal.css | 77 | ||||
-rw-r--r-- | fg21sim/webui/static/js/jquery.modal.js | 240 |
2 files changed, 317 insertions, 0 deletions
diff --git a/fg21sim/webui/static/css/jquery.modal.css b/fg21sim/webui/static/css/jquery.modal.css new file mode 100644 index 0000000..c4a20e8 --- /dev/null +++ b/fg21sim/webui/static/css/jquery.modal.css @@ -0,0 +1,77 @@ +/* + A simple jQuery modal (http://github.com/kylefox/jquery-modal) + Version 0.8.0 +*/ + +.blocker { + position: fixed; + top: 0; right: 0; bottom: 0; left: 0; + width: 100%; height: 100%; + overflow: auto; + z-index: 1; + padding: 20px; + box-sizing: border-box; + background-color: rgb(0,0,0); + background-color: rgba(0,0,0,0.75); + text-align: center; +} +.blocker:before{ + content: ""; + display: inline-block; + height: 100%; + vertical-align: middle; + margin-right: -0.05em; +} +.blocker.behind { + background-color: transparent; +} +.modal { + display: inline-block; + vertical-align: middle; + position: relative; + z-index: 2; + max-width: 500px; + box-sizing: border-box; + width: 90%; + background: #fff; + padding: 15px 30px; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + -o-border-radius: 8px; + -ms-border-radius: 8px; + border-radius: 8px; + -webkit-box-shadow: 0 0 10px #000; + -moz-box-shadow: 0 0 10px #000; + -o-box-shadow: 0 0 10px #000; + -ms-box-shadow: 0 0 10px #000; + box-shadow: 0 0 10px #000; + text-align: left; +} + +.modal a.close-modal { + position: absolute; + top: -12.5px; + right: -12.5px; + display: block; + width: 30px; + height: 30px; + text-indent: -9999px; + background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAACXBIWXMAAAsTAAALEwEAmpwYAAAABGdBTUEAANjr9RwUqgAAACBjSFJNAABtmAAAc44AAPJxAACDbAAAg7sAANTIAAAx7AAAGbyeiMU/AAAG7ElEQVR42mJkwA8YoZjBwcGB6fPnz4w/fvxg/PnzJ2N6ejoLFx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zQEeKGO4UJqOzFADQMZ/A1qCSzBfQXi71ALfyM17sEAIIAY8fQiWKAYFgIwzIbWTv4HjbdfUAf8RPLhH1icojfoAQKIEU8bG9kRyF0aRiz6YP0k5C4LsmUY9TtAADEyEA+IVfufGEUAAQYABejinPr4dLEAAAAASUVORK5CYII=") no-repeat 0 0; +} + +.modal-spinner { + display: none; + width: 64px; + height: 64px; + position: fixed; + top: 50%; + left: 50%; + margin-right: -32px; + margin-top: -32px; + background: url("data:image/gif;base64,R0lGODlhIAAgAPMAABEREf///0VFRYKCglRUVG5ubsvLy62trTQ0NCkpKU5OTuLi4vr6+gAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHRLYKhKP1oZmADdEAAAh+QQACgABACwAAAAAIAAgAAAE6hDISWlZpOrNp1lGNRSdRpDUolIGw5RUYhhHukqFu8DsrEyqnWThGvAmhVlteBvojpTDDBUEIFwMFBRAmBkSgOrBFZogCASwBDEY/CZSg7GSE0gSCjQBMVG023xWBhklAnoEdhQEfyNqMIcKjhRsjEdnezB+A4k8gTwJhFuiW4dokXiloUepBAp5qaKpp6+Ho7aWW54wl7obvEe0kRuoplCGepwSx2jJvqHEmGt6whJpGpfJCHmOoNHKaHx61WiSR92E4lbFoq+B6QDtuetcaBPnW6+O7wDHpIiK9SaVK5GgV543tzjgGcghAgAh+QQACg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NQaDSTtfhhx0CwVPI0UJe0+bm4g5VgcGoqOcnjmjqDSdnhgEoamcsZuXO1aWQy8KAwOAuTYYGwi7w5h+Kr0SJ8MFihpNbx+4Erq7BYBuzsdiH1jCAzoSfl0rVirNbRXlBBlLX+BP0XJLAPGzTkAuAOqb0WT5AH7OcdCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA==") #111 no-repeat center center; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + -o-border-radius: 8px; + -ms-border-radius: 8px; + border-radius: 8px; +} diff --git a/fg21sim/webui/static/js/jquery.modal.js b/fg21sim/webui/static/js/jquery.modal.js new file mode 100644 index 0000000..6663f53 --- /dev/null +++ b/fg21sim/webui/static/js/jquery.modal.js @@ -0,0 +1,240 @@ +/* + A simple jQuery modal (http://github.com/kylefox/jquery-modal) + Version 0.8.0 +*/ + +(function (factory) { + // Making your jQuery plugin work better with npm tools + // http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm + if(typeof module === "object" && typeof module.exports === "object") { + factory(require("jquery"), window, document); + } + else { + factory(jQuery, window, document); + } +}(function($, window, document, undefined) { + + var modals = [], + getCurrent = function() { + return modals.length ? modals[modals.length - 1] : null; + }, + selectCurrent = function() { + var i, + selected = false; + for (i=modals.length-1; i>=0; i--) { + if (modals[i].$blocker) { + modals[i].$blocker.toggleClass('current',!selected).toggleClass('behind',selected); + selected = true; + } + } + }; + + $.modal = function(el, options) { + var remove, target; + this.$body = $('body'); + this.options = $.extend({}, $.modal.defaults, options); + this.options.doFade = !isNaN(parseInt(this.options.fadeDuration, 10)); + this.$blocker = null; + if (this.options.closeExisting) + while ($.modal.isActive()) + $.modal.close(); // Close any open modals. + modals.push(this); + if (el.is('a')) { + target = el.attr('href'); + //Select element by id from href + if (/^#/.test(target)) { + this.$elm = $(target); + if (this.$elm.length !== 1) return null; + this.$body.append(this.$elm); + this.open(); + //AJAX + } else { + this.$elm = $('<div>'); + this.$body.append(this.$elm); + remove = function(event, modal) { modal.elm.remove(); }; + this.showSpinner(); + el.trigger($.modal.AJAX_SEND); + $.get(target).done(function(html) { + if (!$.modal.isActive()) return; + el.trigger($.modal.AJAX_SUCCESS); + var current = getCurrent(); + current.$elm.empty().append(html).on($.modal.CLOSE, remove); + current.hideSpinner(); + current.open(); + el.trigger($.modal.AJAX_COMPLETE); + }).fail(function() { + el.trigger($.modal.AJAX_FAIL); + var current = getCurrent(); + current.hideSpinner(); + modals.pop(); // remove expected modal from the list + el.trigger($.modal.AJAX_COMPLETE); + }); + } + } else { + this.$elm = el; + this.$body.append(this.$elm); + this.open(); + } + }; + + $.modal.prototype = { + constructor: $.modal, + + open: function() { + var m = this; + this.block(); + if(this.options.doFade) { + setTimeout(function() { + m.show(); + }, this.options.fadeDuration * this.options.fadeDelay); + } else { + this.show(); + } + $(document).off('keydown.modal').on('keydown.modal', function(event) { + var current = getCurrent(); + if (event.which == 27 && current.options.escapeClose) current.close(); + }); + if (this.options.clickClose) + this.$blocker.click(function(e) { + if (e.target==this) + $.modal.close(); + }); + }, + + close: function() { + modals.pop(); + this.unblock(); + this.hide(); + if (!$.modal.isActive()) + $(document).off('keydown.modal'); + }, + + block: function() { + this.$elm.trigger($.modal.BEFORE_BLOCK, [this._ctx()]); + this.$body.css('overflow','hidden'); + this.$blocker = $('<div class="jquery-modal blocker current"></div>').appendTo(this.$body); + selectCurrent(); + if(this.options.doFade) { + this.$blocker.css('opacity',0).animate({opacity: 1}, this.options.fadeDuration); + } + this.$elm.trigger($.modal.BLOCK, [this._ctx()]); + }, + + unblock: function(now) { + if (!now && this.options.doFade) + this.$blocker.fadeOut(this.options.fadeDuration, this.unblock.bind(this,true)); + else { + this.$blocker.children().appendTo(this.$body); + this.$blocker.remove(); + this.$blocker = null; + selectCurrent(); + if (!$.modal.isActive()) + this.$body.css('overflow',''); + } + }, + + show: function() { + this.$elm.trigger($.modal.BEFORE_OPEN, [this._ctx()]); + if (this.options.showClose) { + this.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal ' + this.options.closeClass + '">' + this.options.closeText + '</a>'); + this.$elm.append(this.closeButton); + } + this.$elm.addClass(this.options.modalClass).appendTo(this.$blocker); + if(this.options.doFade) { + this.$elm.css('opacity',0).show().animate({opacity: 1}, this.options.fadeDuration); + } else { + this.$elm.show(); + } + this.$elm.trigger($.modal.OPEN, [this._ctx()]); + }, + + hide: function() { + this.$elm.trigger($.modal.BEFORE_CLOSE, [this._ctx()]); + if (this.closeButton) this.closeButton.remove(); + var _this = this; + if(this.options.doFade) { + this.$elm.fadeOut(this.options.fadeDuration, function () { + _this.$elm.trigger($.modal.AFTER_CLOSE, [_this._ctx()]); + }); + } else { + this.$elm.hide(0, function () { + _this.$elm.trigger($.modal.AFTER_CLOSE, [_this._ctx()]); + }); + } + this.$elm.trigger($.modal.CLOSE, [this._ctx()]); + }, + + showSpinner: function() { + if (!this.options.showSpinner) return; + this.spinner = this.spinner || $('<div class="' + this.options.modalClass + '-spinner"></div>') + .append(this.options.spinnerHtml); + this.$body.append(this.spinner); + this.spinner.show(); + }, + + hideSpinner: function() { + if (this.spinner) this.spinner.remove(); + }, + + //Return context for custom events + _ctx: function() { + return { elm: this.$elm, $blocker: this.$blocker, options: this.options }; + } + }; + + $.modal.close = function(event) { + if (!$.modal.isActive()) return; + if (event) event.preventDefault(); + var current = getCurrent(); + current.close(); + return current.$elm; + }; + + // Returns if there currently is an active modal + $.modal.isActive = function () { + return modals.length > 0; + } + + $.modal.getCurrent = getCurrent; + + $.modal.defaults = { + closeExisting: true, + escapeClose: true, + clickClose: true, + closeText: 'Close', + closeClass: '', + modalClass: "modal", + spinnerHtml: null, + showSpinner: true, + showClose: true, + fadeDuration: null, // Number of milliseconds the fade animation takes. + fadeDelay: 1.0 // Point during the overlay's fade-in that the modal begins to fade in (.5 = 50%, 1.5 = 150%, etc.) + }; + + // Event constants + $.modal.BEFORE_BLOCK = 'modal:before-block'; + $.modal.BLOCK = 'modal:block'; + $.modal.BEFORE_OPEN = 'modal:before-open'; + $.modal.OPEN = 'modal:open'; + $.modal.BEFORE_CLOSE = 'modal:before-close'; + $.modal.CLOSE = 'modal:close'; + $.modal.AFTER_CLOSE = 'modal:after-close'; + $.modal.AJAX_SEND = 'modal:ajax:send'; + $.modal.AJAX_SUCCESS = 'modal:ajax:success'; + $.modal.AJAX_FAIL = 'modal:ajax:fail'; + $.modal.AJAX_COMPLETE = 'modal:ajax:complete'; + + $.fn.modal = function(options){ + if (this.length === 1) { + new $.modal(this, options); + } + return this; + }; + + // Automatically bind links with rel="modal:close" to, well, close the modal. + $(document).on('click.modal', 'a[rel~="modal:close"]', $.modal.close); + $(document).on('click.modal', 'a[rel~="modal:open"]', function(event) { + event.preventDefault(); + $(this).modal(); + }); +})); |