2013-04-04 13:48:42 +11:00
|
|
|
*/(function(t,i){"use strict";var n,e,o,r,s,a,h,p,d;h="notify",r="__notify",o={top:"bottom",bottom:"top",left:"right",right:"left"},d={core:{html:'<div class="'+r+'Wrapper"></div>',css:"."+r+"Wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+r+"Container {\n display: none;\n z-index: 1;\n position: absolute;\n cursor: pointer;\n}\n\n."+r+"Text {\n position: relative;\n}"},user:{"default":{html:'<div>\n <div class="'+r+'Default" data-notify="text"></div>\n</div>',css:"."+r+"Default {\n background: #fff;\n font-size: 11px;\n box-shadow: 0 0 6px #000;\n -moz-box-shadow: 0 0 6px #000;\n -webkit-box-shadow: 0 0 6px #000;\n padding: 4px 10px 4px 8px;\n border-radius: 6px;\n border-style: solid;\n border-width: 2px;\n -moz-border-radius: 6px;\n -webkit-border-radius: 6px;\n white-space: nowrap;\n}"},bootstrap:{html:"<span>test</span>",css:"body {\n test: 42\n}"}}},p={autoHidePrompt:!1,autoHideDelay:1e4,arrowShow:!0,arrowSize:5,arrowPosition:"top",style:"default",color:"red",colors:{red:"#ee0101",green:"#33be40",black:"#393939",blue:"#00f"},showAnimation:"fadeIn",showDuration:200,hideAnimation:"fadeOut",hideDuration:600,gap:2},s=function(t){return $(i.createElement(t))},n=function(t){return $.extend(this,t)},n.prototype=p,a=function(t){var i,n;return t.is("[type=radio]")&&(n=t.parents("form:first").find("[type=radio]").filter(function(i,n){return $(n).attr("name")===t.attr("name")}),t=n.first()),i=t.prev(),i.is("span.styled,span.OBS_checkbox")&&(t=i),t},e=function(){function t(t,i,e){"string"===$.type(e)&&(e={color:e}),this.options=new n($.isPlainObject(e)?e:{}),this.elementType=t.attr("type"),this.originalElement=t,this.elem=a(t),this.elem.data(h,this),this.loadCSS(),this.loadHTML(),this.wrapper=$(d.core.html),this.wrapper.append(this.container),this.elem.before(this.wrapper),this.container.css(this.calculateCSS()),this.run(i)}return t.prototype.loadCSS=function(t){var i,n;return n=this.options.style,t=this.getStyle(n),i=t.cssElem,i?i.html(t.css):(i=s("style").attr("id",""+n+"-styles").html(t.css),$("head").append(i),t.cssElem=i)},t.prototype.loadHTML=function(t){if(t=this.getStyle(name),this.container=$(t.html),this.container.addClass(""+r+"Container"),this.text=this.container.find("[data-notify=text]"),0===this.text.length)throw"style: "+name+" HTML is missing the: data-notify='text' attribute";return this.text.addClass(""+r+"Text")},t.prototype.buildArrow=function(){var t,n,e,a,h;e=this.options.arrowPosition,h=this.options.arrowSize,t=o[e],this.arrow=s("div"),this.arrow.addClass(r+"Arrow").css({"margin-top":2+(5===i.documentMode?-4*h:0),position:"relative","z-index":"2","margin-left":10,width:0,height:0}).css("border-"+t,h+"px solid "+this.getColor());for(n in o)n!==e&&n!==t&&this.arrow.css("border-"+n,h+"px solid transparent");return a=this.options.arrowShow&&"radio"!==this.elementType,a?this.arrow.show():this.arrow.hide()},t.prototype.showMain=function(t){var i;return i=this.container.parent().parents(":hidden").length>0,i&&t&&this.container.show(),i&&!t&&this.container.hide(),!i&&t&&this.container[this.options.showAnimation](this.options.showDuration),i||t?undefined:this.container[this.options.hideAnimation](this.options.hideDuration)},t.prototype.calculateCSS=function(){var t,i,n,e;return t=this.elem.position(),e=this.container.parent().position(),i=this.elem.outerHeight(),n=t.left-e.left,navigator.userAgent.match(/MSIE/)||(i+=t.top-e.top),{top:i+this.options.gap,left:n}},t.prototype.getColor=function(){return this.options.colors[this.options.color]||this.options.color},t.prototype.getStyle=function(t){var i;if(t||(t=this.options.style),i=d.user[t],!i)throw"Missing style: "+t;return i},t.prototype.run=function(t,i){var n;return $.isPlainObject(i)?$.extend(this.options,i):"string"===$.type(i)&&(this.options.color=i),this.container&&!t?(this.showMain(!1),undefined):this.container||t?("string"===$.type(t)?this.text.html(t.replace("\n","<br/>")):this.text.empty().append(t),this.text.css({color:this.getColor(),"border-color":this.getColor()}),thi
|