ember-cli-bootstrap-sass
Version:
Include bootstrap-sass and bootstrap-for-ember into an ember-cli app
1 lines • 8.46 kB
JavaScript
!function(){var a,b,c;a='<div class="arrow"></div>{{#if title}}<h3 class="popover-title">{{title}}</h3>{{/if}}<div class="popover-content">{{#if template}} {{partial partialTemplateName}}{{else}} {{#if content}} {{#if html}} {{{content}}} {{else}} {{content}} {{/if}} {{else}} {{yield}} {{/if}}{{/if}} </div>',Ember.TEMPLATES["components/bs-popover"]=Ember.Handlebars.compile(a),c='<div class="tooltip-arrow"></div><div class="tooltip-inner">{{#if html}} {{{content}}}{{else}} {{content}}{{/if}}</div>',Ember.TEMPLATES["components/bs-tooltip"]=Ember.Handlebars.compile(c),Bootstrap.BsPopoverComponent=Ember.Component.extend({layoutName:"components/bs-popover",classNames:"popover",classNameBindings:["fade","in","top","left","right","bottom"],top:function(){return"top"===this.get("realPlacement")}.property("realPlacement"),left:function(){return"left"===this.get("realPlacement")}.property("realPlacement"),right:function(){return"right"===this.get("realPlacement")}.property("realPlacement"),bottom:function(){return"bottom"===this.get("realPlacement")}.property("realPlacement"),titleBinding:"data.title",content:Ember.computed.alias("data.content"),html:!1,delay:0,animation:!0,fade:function(){return this.get("animation")}.property("animation"),"in":function(){return this.get("isVisible")}.property("isVisible"),placement:function(){return this.get("data.placement")||"top"}.property("data.placement"),$element:null,$tip:null,inserted:!1,styleUpdater:function(){var a,b,c,d,e;if(this.$tip&&this.get("isVisible"))return this.$tip.css({top:0,left:0,display:"block"}).addClass(this.get("realPlacement")),d=this.get("realPlacement"),e=this.getPosition(),b=this.$tip[0].offsetWidth,a=this.$tip[0].offsetHeight,c=this.getCalculatedOffset(d,e,b,a),this.$tip.css("top",c.top),this.$tip.css("left",c.left),this.firstTime?(this.firstTime=!1,this.styleUpdater(),this.firstTime=!0):void 0}.observes("content","realPlacement","inserted","isVisible"),init:function(){var a,b;return this._super(),this.set("html",this.get("data.html")||!1),this.set("template",void 0!==this.get("data.template")),this.get("template")?(a="components/bs-popover/_partial-content-"+this.get("tip_id"),b=this.get("data.template"),Ember.TEMPLATES[a]="function"==typeof b?b:Ember.Handlebars.compile(b),this.set("partialTemplateName",a)):void 0},didInsertElement:function(){var a,b=this;return this.$tip=this.$(),a=Bootstrap.TooltipBoxManager.attribute,a="["+a+"='"+this.get("tip_id")+"']",this.$element=$(a),this.set("inserted",!0),"hover"===this.get("data.trigger")&&this.get("data.sticky")&&this.$().on("mouseenter",function(){return clearTimeout(Bootstrap.TooltipBoxManager.timeout)}),this.$().on("mouseleave",function(){return Bootstrap.TooltipBoxManager.removeTip(b.get("tip_id"))}),this.$().find("img").load(function(){return b.afterRender()})},afterRender:function(){return this.notifyPropertyChange("content")},realPlacement:function(){var a,b,c,d,e,f,g,h,i,j,k,l;return this.$tip?(k=this.get("placement")||"",e=/\s?auto?\s?/i,d=e.test(k),d&&(k=k.replace(e,"")||"top"),l=this.getPosition(),c=this.$tip[0].offsetWidth,b=this.$tip[0].offsetHeight,d&&(a=this.$element.parent(),g=k,f=document.documentElement.scrollTop||document.body.scrollTop,j=window.innerWidth,h=window.innerHeight,i=0,k="bottom"===k&&l.top+l.height+b-f>h?"top":"top"===k&&l.top-f-b<0?"bottom":"right"===k&&l.right+c>j?"left":"left"===k&&l.left-c<i?"right":k),k):null}.property("placement","inserted"),hasContent:function(){return this.get("title")},getPosition:function(){var a;return a=this.$element[0],$.extend({},"function"==typeof a.getBoundingClientRect?a.getBoundingClientRect():{width:a.offsetWidth,height:a.offsetHeight},this.$element.offset())},getCalculatedOffset:function(a,b,c,d){return"bottom"===a?{top:b.top+b.height,left:b.left+b.width/2-c/2}:"top"===a?{top:b.top-d,left:b.left+b.width/2-c/2}:"left"===a?{top:b.top+b.height/2-d/2,left:b.left-c}:{top:b.top+b.height/2-d/2,left:b.left+b.width}},actions:{close:function(){return Bootstrap.TooltipBoxManager.removeTip(this.get("tip_id"))}}}),Ember.Handlebars.helper("bs-popover",Bootstrap.BsPopoverComponent),Bootstrap.BsTooltipComponent=Bootstrap.BsPopoverComponent.extend({classNames:"tooltip",layoutName:"components/bs-tooltip",init:function(){return this._super(),this.classNames.removeObject("popover"),this.set("content",this.get("content")||this.get("title"))}}),Ember.Handlebars.helper("bs-tooltip",Bootstrap.BsTooltipComponent),Bootstrap.TooltipBoxController=Ember.Controller.extend({popoversBinding:"Bootstrap.TooltipBoxManager.popovers",tooltipsBinding:"Bootstrap.TooltipBoxManager.tooltips"}),b="{{#each pop in popovers}} {{bs-popover tip_id=pop.tip_id data=pop.data }}{{/each}}{{#each pop in tooltips}} {{bs-tooltip tip_id=pop.tip_id data=pop.data }}{{/each}}",Ember.TEMPLATES["bs-tooltip-box"]=Ember.Handlebars.compile(b),Bootstrap.TooltipBoxManager=Ember.Object.create({uuid:0,attribute:"bootstrap-tip-id",willSetup:!1,registeredTips:{},registerTip:function(a,b,c){var d,e;return d=++this.uuid,e=this,this.registeredTips[d]={id:d,data:b,eventName:b.trigger||("popover"===a?"click":"hover"),bound:!1,type:a,sticky:b.sticky,show:function(){e.showTip(d)},hide:function(){e.hideTip(d,!0)},toggle:function(){e.toggleTip(d)}},this.willSetup||(this.willSetup=!0,Ember.run.scheduleOnce("afterRender",this,function(){e.setupBindings()})),c.data.view.on("willClearRender",function(){Bootstrap.TooltipBoxManager.removeTip(d),$("["+e.attribute+"='"+d+"']").unbind(),delete Bootstrap.TooltipBoxManager.registeredTips[d]}),d},setupBindings:function(){var a,b,c;for(b in this.registeredTips)if(c=this.registeredTips[b],c.bound===!1)switch(c.bound=!0,a=$("["+this.attribute+"='"+b+"']"),c.eventName){case"click":a.on("click",$.proxy(c.toggle,c));break;case"hover":a.on("mouseenter",$.proxy(c.show,c)),a.on("mouseleave",$.proxy(c.hide,c));break;case"focus":a.on("focusin",$.proxy(c.show,c)),a.on("focusout",$.proxy(c.hide,c));break;case"manual":c.data.addObserver("show",c,function(a,b){var c;c=a.get(b),c?this.show():this.hide()}),c.data.show&&this.show()}this.willSetup=!1},popovers:[],tooltips:[],showing:{},timeout:null,showTip:function(a){var b,c,d;b=this.registeredTips[a].data,d=this.registeredTips[a].type,this.showing[a]||(this.showing[a]=!0,c=Ember.Object.create({data:b,tip_id:a}),"tooltip"===d?this.tooltips.pushObject(c):this.popovers.pushObject(c))},hideTip:function(a,b){var c;this.showing[a]&&(c=this.registeredTips[a].data,b&&c.sticky?this.timedRemove(a):this.removeTip(a))},toggleTip:function(a){this.showing[a]?this.hideTip(a):this.showTip(a)},timedRemove:function(a){var b;b=this,this.timeout=setTimeout(function(){b.removeTip(a)},100)},removeTip:function(a){var b;b=this.popovers.findProperty("tip_id",a)||this.tooltips.findProperty("tip_id"),this.popovers.removeObject(b),this.tooltips.removeObject(b),delete this.showing[a]},addFromView:function(a,b,c){var d,e;return a.attributeBindings.contains(Bootstrap.TooltipBoxManager.attribute)?(e={data:{view:a}},d=Bootstrap.TooltipBoxManager.registerTip(b,c,e),a.set(Bootstrap.TooltipBoxManager.attribute,d),void 0):(console.warn('TooltipBoxManager.addFromView: You need to add "TooltipBoxManager.attribute" to the attributeBindings!'),void 0)},helper:function(a,b,c){var d,e,f,g,h,i,j;if("string"==typeof a&&""!==a&&(h=a.split("."),e=h[0],g=c.data.keywords[e],g?(h.removeAt(0),h.insertAt(0,"this"),h=h.join("."),b=g.get(h)):b=this.get(a)),a instanceof Object){b=Ember.Object.create({});for(f in a.hash)j=a.hash[f],i=c.hashTypes[f],"STRING"===i?b.set(f,j):"ID"===i&&(h=j.split("."),e=h[0],g=c.data.keywords[e],g?h.removeAt(0):g=this,b._bindings||(b._bindings=g),h.insertAt(0,"_bindings"),h=h.join("."),b[f]="",d=Ember.Binding.from(h).to(f),d.connect(b))}return b}}),Ember.Handlebars.registerHelper("bs-bind-popover",function(a){var b,c,d;return d=arguments[arguments.length-1],c=this,c=Bootstrap.TooltipBoxManager.helper.call(this,a,c,d),b=Bootstrap.TooltipBoxManager.registerTip("popover",c,d),new Ember.Handlebars.SafeString(Bootstrap.TooltipBoxManager.attribute+"='"+b+"'")}),Ember.Handlebars.registerHelper("bs-bind-tooltip",function(a){var b,c,d;return d=arguments[arguments.length-1],c=this,c=Bootstrap.TooltipBoxManager.helper.call(this,a,c,d),b=Bootstrap.TooltipBoxManager.registerTip("tooltip",c,d),new Ember.Handlebars.SafeString(Bootstrap.TooltipBoxManager.attribute+"='"+b+"'")})}.call(this);