-
Notifications
You must be signed in to change notification settings - Fork 0
/
umbra.min.js
2 lines (2 loc) · 7.11 KB
/
umbra.min.js
1
2
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Umbra=e()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module){(function(global){function clickElement(elt){elt=$(elt);var ev=$.Event("click");elt.trigger(ev),elt.is("a")&&!ev.isDefaultPrevented()&&(window.location=elt.attr("href"))}function activate(){$(document).ready(activateRootButtons),$(document).ready(activateClickouts)}function activateRootButtons(){$(".button_root").on("click",function(e){e.stopPropagation(),window.location.hash==$(this).attr("href")&&(e.preventDefault(),window.location="#")});var bindings={};$(".button_root").each(function(){var k=$(this).data("key");k&&(k in KEYS&&(k=KEYS[k]),bindings[k]=$(this))}),activateKeys(bindings)}function activateKeys(bindings){bindings=bindings||{},$(window).on("keydown",function(e){if($(".overlay").is(":target")){if(e.which==KEYS.ESC){var target=$(e.target),target2=target.find(":target");target2.length&&(target=target2),window.setTimeout(function(){clickElement(target.find(".button_close"))},10)}}else bindings[e.which]&&clickElement($(bindings[e.which]))})}function activateClickouts(){$("body").on("click.clickout",".overlay",function(e){e.target==this&&clickElement($(e.target).find(".button_close"))})}var KEYS=require("./keys.js"),$="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null;module.exports={activate:activate,activateRootButtons:activateRootButtons,activateKeys:activateKeys,activateClickouts:activateClickouts}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./keys.js":3}],2:[function(require,module){(function(global){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null,fieldName=function(field){return $(field).attr("name")||$(field).attr("id")},ActiveForm=function(f){this.formElement=$(f),this.validators=[],this.field_processors={},this.actions=[],this.processField=this.processField.bind(this),this.bindHandlers()};ActiveForm.defaultProcessor=function(x){return[!1,$(x).val()]},ActiveForm.numericProcessor=function(f){var ans=Math.round(parseFloat($(f).val()));return isNaN(ans)?[!0,"Not a number: "+$(f).val()]:[!1,ans]},ActiveForm.prototype={processField:function(f){var processor=this.field_processors[fieldName(f)];return processor||(processor=$(f).is(".numeric")?ActiveForm.numericProcessor:ActiveForm.defaultProcessor),processor($(f).get(0))},processData:function(){for(var ans={errors:""},fields=this.formElement.find("input"),i=0;i<fields.length;i++){var value=this.processField(fields[i]);value[0]?(ans.errors||(ans.errors=[]),ans.errors.push(value[1])):ans[fieldName(fields[i])]=value[1]}for(var i=0;i<this.validators.length;i++)this.validators[i](ans);return ans},validate:function(){var data=this.processData();return data.errors?this.formElement.find('[type="submit"]').addClass("disabled"):this.formElement.find('[type="submit"]').removeClass("disabled"),data},bindHandlers:function(){var af=this;this.formElement.on("change",function(){af.processData().errors?af.formElement.find('[type="submit"]').addClass("disabled"):af.formElement.find('[type="submit"]').removeClass("disabled")}),this.formElement.on("input",function(e){var f=e.target;af.processField(f)[0]?$(f).addClass("invalid").removeClass("valid"):$(f).addClass("valid").removeClass("invalid")}),this.formElement.on("submit",function(e){var data=af.processData();if(data.errors)e.preventDefault();else for(var i=0;i<af.actions.length;i++)af.actions[i](e,data)})}},module.exports=ActiveForm}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(require,module){for(var keys={SHIFT:16,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,"<":188,">":190,QUESTION:191,TILDE:192,APOSTROPHE:222},i=0;10>i;i++)keys[i]=48+i;for(var i=65;91>i;i++)keys[String.fromCharCode(i)]=i;for(var i=1;13>i;i++)keys["F"+i]=111+i;module.exports=keys},{}],4:[function(require,module){(function(global){var $="undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null,global_registry={},MessageBox=function(id,debug){return this instanceof MessageBox?(this.id=id,this.debug=debug,void this.getPanel().on("click",this.clickHandler.bind(this))):MessageBox.get(id,debug)},ProgressBar=function(parent_box,text){this.parent_box=parent_box,this.msgdiv=parent_box.post(text,"progress",864e5),this.msgdiv.append($('<div class="progressbar"><div class="progressbar_fill"></div></div>'))};ProgressBar.prototype={set:function(amount){var percent=100*amount+"%";this.msgdiv.find(".progressbar_fill").css({width:percent}),amount>=1&&window.setTimeout(this.parent_box.hide.bind(this.parent_box,this.msgdiv),100)}},MessageBox.prototype={del:function(msg){msg&&msg.is&&msg.is(".message")&&!msg.is(".pinned")&&msg.remove()},hide:function(msg){msg&&msg.is&&msg.is(".message")&&!msg.is(".pinned")&&(msg.removeClass("active"),window.setTimeout(this.del.bind(this,msg),150))},post:function(text,cls,expiry){var msg=$('<div class="message active">').text(text).addClass(cls);return msg.hasClass("debug")&&!this.debug?$():(this.getPanel().append(msg),window.setTimeout(this.hide.bind(this,msg),expiry||5e3),msg)},makeProgress:function(text){return new ProgressBar(this,text)},getPanel:function(){var panel=$("#"+this.id+" .box");return panel.length||(panel=$('<div class="box">').appendTo("#"+this.id)),panel},clickHandler:function(e){var t=$(e.target);t.is(".message")&&(t.hasClass("pinned")?(t.removeClass("pinned active"),this.hide(t)):t.hasClass("active")&&t.addClass("pinned"))}},MessageBox.get=function(id,debug){return id=String(id)||"messages",$("#"+id).length||$('<div id="#'+id+'" class="messages">').appendTo("body"),global_registry[id]||(global_registry[id]=new MessageBox(id,debug)),global_registry[id]},MessageBox.post=function(message,cls,expiry,id){return MessageBox.get(id).post(message,cls,expiry)},module.exports=MessageBox}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(require,module){(function(global){var buttons=("undefined"!=typeof window?window.$:"undefined"!=typeof global?global.$:null,require("./buttons.js"));document&&buttons.activate();var mb=require("./messagebox.js");module.exports={KEYS:require("./keys.js"),alert:mb.post,button_system:buttons,Form:require("./forms.js"),MessageBox:mb}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./buttons.js":1,"./forms.js":2,"./keys.js":3,"./messagebox.js":4}]},{},[5])(5)});
//# sourceMappingURL=umbra.min.js.map