diff --git a/README.md b/README.md index 6b79d140..ae8c8cec 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Native Javascript for Bootstrap -This is a set of scripts developed with native Javascript for Bootstrap 3 series, and featuring superior performance compared to the original jQuery Plugins. Thanks to [Ingwie Phoenix](https://github.com/IngwiePhoenix) for contributing with npm/RequireJS/CommonJS compatibility. A huge advantage is the size, this library is only ***20Kb*** minified and ***6.5Kb*** gZipped. +This is a library developed with native Javascript for Bootstrap 3 series, and featuring superior performance compared to the original jQuery Plugins. Thanks to [Ingwie Phoenix](https://github.com/IngwiePhoenix) for contributing with npm/RequireJS/CommonJS compatibility. A huge advantage is the size, this library is only ***20Kb*** minified and ***6.5Kb*** gZipped. See demo for scripting examples and instructions. # CDN -New releases will be available automatically on jsdelivr CDN repositories and CDNjs repositories. You may also find more CDN repositories on Google as well. +New releases will be available automatically on jsdelivr CDN repositories and CDN repositories on CDNjs repositories. You may also find more Google as well. # Bower and NPM You can install this package by using either Bower or NPM. @@ -50,7 +50,7 @@ As mentioned above, the object properties of the exported object, when using `re So when using `bootstrap.native` inside of a NodeJS app, make sure you create a proper Browser-like environment first to avoid unexpected behaviour. # Browser Support -The scripts are developed with clean code mainly for modern browsers that nativelly support HTML5. When using polyfills, IE8-IE9 will thank you. +The components are developed with clean code mainly for modern browsers that nativelly support HTML5. When using polyfills, IE8-IE9 will thank you. # Custom Builds You can make a custom build of bootstrap-native, including only the modules you need, by using the `build.js` script. @@ -78,4 +78,4 @@ Writes to stdout - Full contributors list [here](https://github.com/thednp/bootstrap.native/graphs/contributors). Thanks so much! # License -The scripts are released under the [MIT license](https://github.com/thednp/bootstrap.native/blob/master/LICENSE). +The library is released under the [MIT license](https://github.com/thednp/bootstrap.native/blob/master/LICENSE). diff --git a/assets/js/scripts.js b/assets/js/scripts.js index 1c7432de..aa112053 100644 --- a/assets/js/scripts.js +++ b/assets/js/scripts.js @@ -53,7 +53,7 @@ btnModalNotTrigger.addEventListener('click', function(e) { // NEW added events to Modal modalFrame.addEventListener('show.bs.modal', function(e) { - var related = null; console.log(e) + var related = null; related = ', relatedTarget: '+ (e.relatedTarget ? e.relatedTarget.tagName + '.'+e.relatedTarget.className.replace(/\s/g,'.') : 'null'); console.log( 'The "show.bs.modal" event fired for #' + e.target.id + related ); }, false); diff --git a/bower.json b/bower.json index b382a26c..b93f023a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap.native", - "version": "2.0.0", + "version": "2.0.1", "homepage": "http://thednp.github.io/bootstrap.native/", "authors": [ "dnp_theme" diff --git a/dist/bootstrap-native.js b/dist/bootstrap-native.js index 4b0b1121..9b4af972 100644 --- a/dist/bootstrap-native.js +++ b/dist/bootstrap-native.js @@ -1,4 +1,4 @@ -// Native Javascript for Bootstrap 3 v2.0.0 | © dnp_theme | MIT-License +// Native Javascript for Bootstrap 3 v2.0.1 | © dnp_theme | MIT-License (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD support: @@ -65,6 +65,7 @@ dataDismissible = 'data-dismissible', dataTrigger = 'data-trigger', dataAnimation = 'data-animation', + dataContainer = 'data-container', dataPlacement = 'data-placement', dataDelay = 'data-delay', dataOffsetTop = 'data-offset-top', @@ -78,6 +79,7 @@ // box model offsetTop = 'offsetTop', offsetBottom = 'offsetBottom', + offsetLeft = 'offsetLeft', scrollTop = 'scrollTop', scrollLeft = 'scrollLeft', clientWidth = 'clientWidth', clientHeight = 'clientHeight', offsetWidth = 'offsetWidth', offsetHeight = 'offsetHeight', @@ -237,8 +239,9 @@ x : global.pageXOffset || doc[scrollLeft] } }, - styleTip = function(link,element,position) { // both popovers and tooltips - var rect = link[getBoundingClientRect](), scroll = getScroll(), + styleTip = function(link,element,position,container) { // both popovers and tooltips + var rect = link[getBoundingClientRect](), + scroll = container === body ? getScroll() : { x: container[offsetLeft] + container[scrollLeft], y: container[offsetTop] + container[scrollTop] }, linkDimensions = { w: rect[right] - rect[left], h: rect[bottom] - rect[top] }, elementDimensions = { w : element[offsetWidth], h: element[offsetHeight] }; @@ -1211,6 +1214,7 @@ placementData = element[getAttribute](dataPlacement), dismissibleData = element[getAttribute](dataDismissible), delayData = element[getAttribute](dataDelay), + containerData = element[getAttribute](dataContainer), // internal strings component = 'popover', @@ -1235,7 +1239,7 @@ this[delay] = parseInt(options[delay] || delayData) || 100; this[dismissible] = options[dismissible] || dismissibleData === 'true' ? true : false; this[duration] = (isIE && isIE < 10) ? 0 : parseInt(options[duration] || durationData) || 150; - this[container] = queryElement(options[container]) || body; // JavaScript only + this[container] = queryElement(options[container]) || queryElement(containerData) || body; // bind, content var self = this, @@ -1299,10 +1303,10 @@ !hasClass(popover,'in') && ( addClass(popover,'in') ); }, updatePopover = function() { - styleTip(element,popover,placementSetting); + styleTip(element,popover,placementSetting,self[container]); if (!isElementInViewport(popover) ) { placementSetting = updatePlacement(placementSetting); - styleTip(element,popover,placementSetting); + styleTip(element,popover,placementSetting,self[container]); } }; @@ -1586,6 +1590,7 @@ placementData = element[getAttribute](dataPlacement); durationData = element[getAttribute](dataDuration); delayData = element[getAttribute](dataDelay), + containerData = element[getAttribute](dataContainer), // strings component = 'tooltip', @@ -1600,7 +1605,7 @@ this[placement] = options[placement] ? options[placement] : placementData || top; this[delay] = parseInt(options[delay] || delayData) || 100; this[duration] = (isIE && isIE < 10) ? 0 : parseInt(options[duration] || durationData) || 150; - this[container] = queryElement(options[container]) || body; // JavaScript only + this[container] = queryElement(options[container]) || queryElement(containerData) || body; // bind, event targets, title and constants var self = this, timer = 0, placementSetting = this[placement], tooltip = null, @@ -1629,10 +1634,10 @@ tooltip[setAttribute](classString, component + ' ' + placementSetting + ' ' + self[animation]); }, updateTooltip = function () { - styleTip(element,tooltip,placementSetting); + styleTip(element,tooltip,placementSetting,self[container]); if (!isElementInViewport(tooltip) ) { placementSetting = updatePlacement(placementSetting); - styleTip(element,tooltip,placementSetting); + styleTip(element,tooltip,placementSetting,self[container]); } }, showTooltip = function () { diff --git a/dist/bootstrap-native.min.js b/dist/bootstrap-native.min.js index ab39b6d9..98df7c9b 100644 --- a/dist/bootstrap-native.min.js +++ b/dist/bootstrap-native.min.js @@ -1,2 +1,2 @@ -// Native Javascript for Bootstrap 3 v2.0.0 | © dnp_theme | MIT-License -!function(t,e){if("function"==typeof define&&define.amd)define([],e);else if("object"==typeof module&&module.exports)module.exports=e();else{var n=e();t.Affix=n.Affix,t.Alert=n.Alert,t.Button=n.Button,t.Carousel=n.Carousel,t.Collapse=n.Collapse,t.Dropdown=n.Dropdown,t.Modal=n.Modal,t.Popover=n.Popover,t.ScrollSpy=n.ScrollSpy,t.Tab=n.Tab,t.Tooltip=n.Tooltip}}(this,function(){var t="undefined"!=typeof t?t:this||window,e=document.documentElement,n=document.body,i=null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)&&parseFloat(RegExp.$1),o="data-toggle",a="data-dismiss",l="data-spy",r="data-ride",s="Affix",c="Alert",u="Button",d="Carousel",f="Collapse",h="Dropdown",p="Modal",m="Popover",v="ScrollSpy",g="Tab",y="Tooltip",T="data-backdrop",x="data-keyboard",b="data-duration",w="data-target",I="data-interval",C="data-height",E="data-pause",L="data-original-title",A="data-original-text",S="data-dismissible",k="data-trigger",M="data-animation",B="data-placement",D="data-delay",H="data-offset-top",N="data-offset-bottom",P="backdrop",O="keyboard",W="delay",$="duration",R="content",j="target",z="interval",q="pause",F="animation",U="placement",X="container",Y="offsetTop",G="offsetBottom",J="scrollTop",K="scrollLeft",Q="clientWidth",V="clientHeight",Z="offsetWidth",_="offsetHeight",tt="innerWidth",et="innerHeight",nt="scrollHeight",it="height",ot="aria-expanded",at="aria-hidden",lt="click",rt="hover",st="keydown",ct="resize",ut="scroll",dt="show",ft="shown",ht="hide",pt="hidden",mt="close",vt="closed",gt="slid",yt="slide",Tt="change",xt="getAttribute",bt="setAttribute",wt="hasAttribute",It="getElementsByTagName",Ct="getBoundingClientRect",Et="collapsing",Lt="parentNode",At="length",St="active",kt="disabled",Mt="loading",Bt="left",Dt="right",Ht="top",Nt="bottom",Pt="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],Ot=/\b(top|bottom|left|top)+/,Wt=function(t,e){t.classList.add(e)},$t=function(t,e){t.classList.remove(e)},Rt=function(t,e){return t.classList.contains(e)},jt=function(t,e){var n=8===i?"querySelectorAll":"getElementsByClassName";return t[n](8===i?"."+e.replace(/\s(?=[a-z])/g,"."):e)},zt=function(t,e){var n=e?e:document;return"object"==typeof t?t:/^#/.test(t)?document.getElementById(t.replace("#","")):n.querySelector(t)},qt=function(t,e){for(var n=e.charAt(0);t&&t!==document;t=t[Lt]){if(("."===n||"#"!==n)&&null!==zt(e,t[Lt]))return t;if("#"===n&&t.id===e.substr(1))return t}return!1},Ft=function(t,e,n){t.addEventListener(e,n,!1)},Ut=function(t,e,n){t.removeEventListener(e,n,!1)},Xt=function(t,e,n){var i=new CustomEvent(t+".bs."+e);i.relatedTarget=n,this.dispatchEvent(i)},Yt=document[It]("*"),Gt=function(t,e,n,i){for(var o=i&&i[At]?i:Yt,a=0;a-1||l===r)&&new e(o[a])}},Jt=function(e){var n=e&&(e.currentStyle||t.getComputedStyle(e)),i=/px/.test(n.borderTopWidth)?Math.round(n.borderTopWidth.replace("px","")):0,o=/px/.test(n.borderBottomWidth)?Math.round(n.borderBottomWidth.replace("px","")):0,a=/px/.test(n.marginTop)?Math.round(n.marginTop.replace("px","")):0,l=/px/.test(n.marginBottom)?Math.round(n.marginBottom.replace("px","")):0;return e[V]+parseInt(i)+parseInt(o)+parseInt(a)+parseInt(l)},Kt=function(t){for(var e=0,n=0,i=t.children[At];n=0&&i[Bt]>=0&&i[Nt]<=(t[et]||e[V])&&i[Dt]<=(t[tt]||e[Q])},Vt=function(){return{y:t.pageYOffset||e[J],x:t.pageXOffset||e[K]}},Zt=function(t,e,n){var i=t[Ct](),o=Vt(),a={w:i[Dt]-i[Bt],h:i[Nt]-i[Ht]},l={w:e[Z],h:e[_]};n===Ht?(e.style[Ht]=i[Ht]+o.y-l.h+"px",e.style[Bt]=i[Bt]+o.x-l.w/2+a.w/2+"px"):n===Nt?(e.style[Ht]=i[Ht]+o.y+a.h+"px",e.style[Bt]=i[Bt]+o.x-l.w/2+a.w/2+"px"):n===Bt?(e.style[Ht]=i[Ht]+o.y-l.h/2+a.h/2+"px",e.style[Bt]=i[Bt]+o.x-l.w+"px"):n===Dt&&(e.style[Ht]=i[Ht]+o.y-l.h/2+a.h/2+"px",e.style[Bt]=i[Bt]+o.x+a.w+"px"),e.className.indexOf(n)===-1&&(e.className=e.className.replace(Ot,n))},_t=function(t){return t===Ht?Nt:t===Nt?Ht:t===Bt?Dt:t===Dt?Bt:t},te=function(o,a){o=zt(o),a=a||{};var l=o[xt](w),r=o[xt](H),c=o[xt](N),u="affix",d="affixed",f="function",h="update",p="affix-top",m="affixed-top",v="affix-bottom",g="affixed-bottom";if(this[j]=a[j]?zt(a[j]):zt(l)||null,this[Y]=a[Y]?a[Y]:parseInt(r)||0,this[G]=a[G]?a[G]:parseInt(c)||0,this[j]||this[Y]||this[G]){var y,T,x,b,I,C,E=this,L=i&&i<10?500:50,A=!1,S=!1,k=function(){return Math.max(n[nt],n[_],e[V],e[nt],e[_])},M=function(){return null!==E[j]?E[j][Ct]()[Ht]+b:E[Y]?parseInt(typeof E[Y]===f?E[Y]():E[Y]||0):void 0},B=function(){if(E[G])return x-o[_]-parseInt(typeof E[G]===f?E[G]():E[G]||0)},D=function(){x=k(),b=parseInt(Vt().y,0),y=M(),T=B(),I=parseInt(y)-b<0&&b>parseInt(y),C=parseInt(T)-b<0&&b>parseInt(T)},P=function(){A||Rt(o,u)||(Xt.call(o,u,u),Xt.call(o,p,u),Wt(o,u),A=!0,Xt.call(o,d,u),Xt.call(o,m,u))},O=function(){A&&Rt(o,u)&&($t(o,u),A=!1)},W=function(){S||Rt(o,v)||(Xt.call(o,u,u),Xt.call(o,v,u),Wt(o,v),S=!0,Xt.call(o,d,u),Xt.call(o,g,u))},$=function(){S&&Rt(o,v)&&($t(o,v),S=!1)},R=function(){C?(I&&O(),W()):($(),I?P():O())};this[h]=function(){D(),R()},s in o||(Ft(t,ut,this[h]),Ft(t,ct,function(){setTimeout(function(){E[h]()},L)}),o[s]=this),this[h]()}};Gt(s,te,l);var ee=function(t){t=zt(t);var e=this,n="alert",o=qt(t,"."+n),l=i&&i<10?0:300,r=function(i){var l=i[j];l=l[wt](a)?l:l[Lt],l&&l[wt](a)&&(o=qt(l,"."+n),t=zt("["+a+'="'+n+'"]',o),(t===l||t===l[Lt])&&o&&e.close())};this.close=function(){o&&t&&Rt(o,"in")&&(Xt.call(o,mt,n),$t(o,"in"),setTimeout(function(){o&&(Xt.call(o,vt,n),Ut(t,lt,r),o[Lt].removeChild(o))},l))},c in t||(Ft(t,lt,r),t[c]=this)};Gt(c,ee,a);var ne=function(t,e){t=zt(t),e=e||null;var n=!1,i="button",o="checked",a="reset",l="LABEL",r="INPUT",s=function(){e&&e!==a&&(e===Mt&&(Wt(t,kt),t[bt](kt,kt)),t[bt](A,t.innerHTML.replace(/^\s+|\s+$/g,"")),t.innerHTML=t[xt]("data-"+e+"-text"))},c=function(){t[xt](A)&&((Rt(t,kt)||t[xt](kt)===kt)&&($t(t,kt),t.removeAttribute(kt)),t.innerHTML=t[xt](A))},d=function(e){var a=e[j][Lt],s=e[j].tagName===l?e[j]:a.tagName===l?a:null;if(s){var c=this,u=jt(c,"btn"),d=s[It](r)[0];if(d){if("checkbox"===d.type&&(d[o]?($t(s,St),d[xt](o),d.removeAttribute(o),d[o]=!1):(Wt(s,St),d[xt](o),d[bt](o,o),d[o]=!0),n||(n=!0,Xt.call(d,Tt,i),Xt.call(t,Tt,i))),"radio"===d.type&&!n&&!d[o]){Wt(s,St),d[bt](o,o),d[o]=!0,Xt.call(d,Tt,i),Xt.call(t,Tt,i),n=!0;for(var f=0,h=u[At];fp||n===y-1&&0===p)&&(T=h[u]=Dt),h.slideTo(p)}},D=function(t){if(t.preventDefault(),!v){var e=t.currentTarget||t.srcElement;e===L?(p++,T=h[u]=Bt,p===y-1?p=y-1:p===y&&(p=0)):e===C&&(p--,T=h[u]=Dt,0===p?p=0:p<0&&(p=y-1)),h.slideTo(p)}},H=function(t){if(!v){switch(t.which){case 39:p++,T=h[u]=Bt,p==y-1?p=y-1:p==y&&(p=0);break;case 37:p--,T=h[u]=Dt,0==p?p=0:p<0&&(p=y-1);break;default:return}h.slideTo(p)}},N=function(t){for(var e=0,n=S[At];e-1)&&(n.persist||l))return;s=null,v()}(/\#$/.test(r.href)||/\#$/.test(r[Lt].href))&&e.preventDefault()}},m=function(){Xt.call(a,dt,l,s),Wt(a,r),c[bt](ot,!0),Xt.call(a,ft,l,s),Ft(document,st,f),i=!0},v=function(){Xt.call(a,ht,l,s),$t(a,r),c[bt](ot,!1),Xt.call(a,pt,l,s),Ut(document,st,f),i=!1},g=0,y=d[At]||0;ge[V],m=A()},k=function(){r.style[u]=!f&&h?m+"px":"",r.style[d]=f&&!h?m+"px":""},M=function(){r.style[u]="",r.style[d]=""},B=function(){var t=document.createElement("div");v=zt("."+modalBackdropString),null===v&&(t[bt]("class",modalBackdropString+" fade"),v=t,n.appendChild(v))},D=function(){v=zt("."+modalBackdropString),v&&null!==v&&"object"==typeof v&&(n.removeChild(v),v=null)},H=function(){Rt(r,"in")?Ut(document,st,q):Ft(document,st,q)},N=function(){Rt(r,"in")?Ut(t,ct,this.update):Ft(t,ct,this.update)},W=function(){Rt(r,"in")?Ut(r,lt,F):Ft(r,lt,F)},z=function(t){var e=t[j];e=e[wt](w)||e[wt]("href")?e:e[Lt],t.defaultPrevented||y||e!==o||Rt(r,"in")||(r.modalTrigger=o,I=o,g.show(),t.preventDefault(),setTimeout(function(){t.defaultPrevented=!1},50))},q=function(t){var e=t.which||t.keyCode;g[O]&&27==e&&y&&g.hide()},F=function(t){var e=t[j];!t.defaultPrevented&&y&&(e[Lt][xt](a)===s||e[xt](a)===s||e===r&&g[P]!==c)&&(g.hide(),I=null,t.preventDefault(),setTimeout(function(){t.defaultPrevented=!1},50))};this.toggle=function(){y&&Rt(r,"in")?this.hide():this.show()},this.show=function(){Xt.call(r,dt,s,I);var t=jt(document,s+" in")[0];t&&t!==r&&t.modalTrigger[p].hide(),this[P]&&B(),v&&!Rt(v,"in")&&setTimeout(function(){Wt(v,"in")},0),setTimeout(function(){r.style.display="block",S(),E(),k(),N(),W(),H(),Wt(n,s+"-open"),Wt(r,"in"),r[bt](at,!1)},this[$]/2),setTimeout(function(){y=!0,Xt.call(r,ft,s,I)},this[$])},this.hide=function(){Xt.call(r,ht,s),v=zt("."+modalBackdropString),null!==v&&$t(v,"in"),$t(r,"in"),r[bt](at,!0),setTimeout(function(){$t(n,s+"-open"),N(),W(),H(),M(),L(),r.style.display=""},this[$]/2),setTimeout(function(){jt(document,s+" in")[0]||D(),y=!1,Xt.call(r,pt,s)},this[$])},this.setContent=function(t){zt("."+s+"-content",r).innerHTML=t},this.update=function(){y&&(S(),E(),k())},p in o||(this[R]&&this.setContent(this[R]),Ft(o,lt,z),o[p]=this)};Gt(p,le,o);var re=function(e,o){e=zt(e);var a=e[xt](k),l=e[xt](M),r=e[xt](b),s=e[xt](B),c=e[xt](S),u=e[xt](D),d="popover",f="template",h="trigger",p="class",v="div",g="fade",y="data-title",T="data-content",x="dismissible",w='';o=o||{},this[f]=o[f]?o[f]:null,this[h]=o[h]?o[h]:a||rt,this[F]=o[F]&&o[F]!==g?o[F]:l||g,this[U]=o[U]?o[U]:s||Ht,this[W]=parseInt(o[W]||u)||100,this[x]=!(!o[x]&&"true"!==c),this[$]=i&&i<10?0:parseInt(o[$]||r)||150,this[X]=zt(o[X])||n;var I=this,C=e[xt](y)||null,E=e[xt](T)||null;if(E||this[f]){var L=null,A=0,H=this[U],N=function(t){null!==L&&t[j]===zt(".close",L)&&I.hide()},P=function(){I[X].removeChild(L),A=null,L=null},O=function(){if(C=e[xt](y),E=e[xt](T),L=document.createElement(v),null!==E&&null===I[f]){if(L[bt]("role","tooltip"),null!==C){var t=document.createElement("h3");t[bt](p,d+"-title"),t.innerHTML=I[x]?C+w:C,L.appendChild(t)}var n=document.createElement(v),i=document.createElement(v);n[bt](p,"arrow"),i[bt](p,d+"-content"),L.appendChild(n),L.appendChild(i),i.innerHTML=I[x]&&null===C?E+w:E}else{var o=document.createElement(v);o.innerHTML=I[f],L.innerHTML=o.firstChild.innerHTML}I[X].appendChild(L),L.style.display="block",L[bt](p,d+" "+H+" "+I[F])},R=function(){!Rt(L,"in")&&Wt(L,"in")},z=function(){Zt(e,L,H),Qt(L)||(H=_t(H),Zt(e,L,H))};this.toggle=function(){null===L?I.show():I.hide()},this.show=function(){clearTimeout(A),A=setTimeout(function(){null===L&&(H=I[U],O(),z(),R(),Xt.call(e,dt,d),setTimeout(function(){Xt.call(e,ft,d)},I[$]))},20)},this.hide=function(){clearTimeout(A),A=setTimeout(function(){L&&null!==L&&Rt(L,"in")&&(Xt.call(e,ht,d),$t(L,"in"),setTimeout(function(){P(),Xt.call(e,pt,d)},I[$]))},I[W])},m in e||(I[h]===rt?(Ft(e,Pt[0],I.show),I[x]||Ft(e,Pt[1],I.hide)):/^(click|focus)$/.test(I[h])&&(Ft(e,I[h],I.toggle),I[x]||Ft(e,"blur",I.hide)),I[x]&&Ft(document,lt,N),i&&i<9||Ft(t,ct,I.hide),e[m]=I)}};Gt(m,re,o);var se=function(e,n){e=zt(e);var o=zt(e[xt](w));if(n=n||{},n[j]||o){for(var a,l=n[j]&&zt(n[j])||o,r=l&&l[It]("A"),s=[],c=[],u=e[_]-1?i[Lt][Y]:0,l=d&&i[Ct](),r=Rt(n,St)||!1,u=d?l[Ht]+a:i[Y]+o,f=d?l[Nt]+a:u+i[_],h=a>=u&&f>a;if(!r&&h)"LI"!==n.tagName||Rt(n,St)||(Wt(n,St),r=!0,Xt.call(e,"activate","scrollspy",s[t]));else if(h){if(!h&&!r||r&&h)return}else"LI"===n.tagName&&Rt(n,St)&&($t(n,St),r=!1)},y=function(){a=d?Vt().y:e[J];for(var t=0,n=s[At];t1&&(t=e[e[At]-1]):t=e[0],t[It]("A")[0]},p=function(){return zt(h()[xt]("href"))},m=function(t){t.preventDefault(),s=t[j],u.show()};this.show=function(){var e=zt(s[xt]("href")),n=h(),i=p();n[r]&&s[r]||Rt(s[Lt],St)||(n[r]=s[r]=!0,$t(n[Lt],St),Wt(s[Lt],St),f&&(Rt(t[Lt][Lt],"dropdown-menu")?Rt(f,St)||Wt(f,St):Rt(f,St)&&$t(f,St)),c&&(c.style[l]=Kt(i)+"px"),Xt.call(n,ht,a,s),setTimeout(function(){$t(i,"in")},10),setTimeout(function(){c&&Wt(c,Et),$t(i,St),Wt(e,St),setTimeout(function(){Wt(e,"in")},10),Xt.call(s,dt,a,n),Xt.call(n,pt,a,s),c&&(c.style[l]=Kt(e)+"px")},.7*u[$]),setTimeout(function(){Xt.call(s,ft,a,n),c&&($t(c,Et),c.style[l]=""),n[r]=s[r]=!1},1.5*u[$]))},g in t||(this[l]&&(c=p()[Lt]),Ft(t,lt,m),t[g]=this)};Gt(g,ce,o);var ue=function(t,e){t=zt(t);var o=t[xt](M);placementData=t[xt](B),durationData=t[xt](b),delayData=t[xt](D),component="tooltip",classString="class",title="title",fade="fade",div="div",e=e||{},this[F]=e[F]&&e[F]!==fade?e[F]:o||fade,this[U]=e[U]?e[U]:placementData||Ht,this[W]=parseInt(e[W]||delayData)||100,this[$]=i&&i<10?0:parseInt(e[$]||durationData)||150,this[X]=zt(e[X])||n;var a=this,l=0,r=this[U],s=null,c=t[xt](title)||t[xt](L);if(c){var u=function(){a[X].removeChild(s),s=null,l=null},d=function(){c=t[xt](title)||t[xt](L),s=document.createElement(div),s[bt]("role",component);var e=document.createElement(div),n=document.createElement(div);e[bt](classString,component+"-arrow"),n[bt](classString,component+"-inner"),s.appendChild(e),s.appendChild(n),n.innerHTML=c,a[X].appendChild(s),s[bt](classString,component+" "+r+" "+a[F])},f=function(){Zt(t,s,r),Qt(s)||(r=_t(r),Zt(t,s,r))},h=function(){!Rt(s,"in")&&Wt(s,"in")};this.show=function(){clearTimeout(l),l=setTimeout(function(){null===s&&(r=a[U],d(),f(),h(),Xt.call(t,dt,component),setTimeout(function(){Xt.call(t,ft,component)},a[$]))},20)},this.hide=function(){clearTimeout(l),l=setTimeout(function(){s&&null!==s&&Rt(s,"in")&&(Xt.call(t,ht,component),$t(s,"in"),setTimeout(function(){u(),Xt.call(t,pt,component)},a[$]))},a[W])},this.toggle=function(){s?a.hide():a.show()},y in t||(t[bt](L,c),t.removeAttribute(title),Ft(t,Pt[0],this.show),Ft(t,Pt[1],this.hide),t[y]=this)}};return Gt(y,ue,o),{Affix:te,Alert:ee,Button:ne,Carousel:ie,Collapse:oe,Dropdown:ae,Modal:le,Popover:re,ScrollSpy:se,Tab:ce,Tooltip:ue}}); +// Native Javascript for Bootstrap 3 v2.0.1 | © dnp_theme | MIT-License +!function(t,e){if("function"==typeof define&&define.amd)define([],e);else if("object"==typeof module&&module.exports)module.exports=e();else{var n=e();t.Affix=n.Affix,t.Alert=n.Alert,t.Button=n.Button,t.Carousel=n.Carousel,t.Collapse=n.Collapse,t.Dropdown=n.Dropdown,t.Modal=n.Modal,t.Popover=n.Popover,t.ScrollSpy=n.ScrollSpy,t.Tab=n.Tab,t.Tooltip=n.Tooltip}}(this,function(){var t="undefined"!=typeof t?t:this||window,e=document.documentElement,n=document.body,i=null!=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)&&parseFloat(RegExp.$1),o="data-toggle",a="data-dismiss",l="data-spy",r="data-ride",s="Affix",c="Alert",u="Button",d="Carousel",f="Collapse",h="Dropdown",p="Modal",m="Popover",v="ScrollSpy",g="Tab",y="Tooltip",T="data-backdrop",x="data-keyboard",b="data-duration",w="data-target",I="data-interval",C="data-height",L="data-pause",E="data-original-title",A="data-original-text",S="data-dismissible",k="data-trigger",M="data-animation",D="data-container",B="data-placement",H="data-delay",N="data-offset-top",P="data-offset-bottom",O="backdrop",W="keyboard",$="delay",R="duration",j="content",z="target",q="interval",F="pause",U="animation",X="placement",Y="container",G="offsetTop",J="offsetBottom",K="offsetLeft",Q="scrollTop",V="scrollLeft",Z="clientWidth",_="clientHeight",tt="offsetWidth",et="offsetHeight",nt="innerWidth",it="innerHeight",ot="scrollHeight",at="height",lt="aria-expanded",rt="aria-hidden",st="click",ct="hover",ut="keydown",dt="resize",ft="scroll",ht="show",pt="shown",mt="hide",vt="hidden",gt="close",yt="closed",Tt="slid",xt="slide",bt="change",wt="getAttribute",It="setAttribute",Ct="hasAttribute",Lt="getElementsByTagName",Et="getBoundingClientRect",At="collapsing",St="parentNode",kt="length",Mt="active",Dt="disabled",Bt="loading",Ht="left",Nt="right",Pt="top",Ot="bottom",Wt="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],$t=/\b(top|bottom|left|top)+/,Rt=function(t,e){t.classList.add(e)},jt=function(t,e){t.classList.remove(e)},zt=function(t,e){return t.classList.contains(e)},qt=function(t,e){var n=8===i?"querySelectorAll":"getElementsByClassName";return t[n](8===i?"."+e.replace(/\s(?=[a-z])/g,"."):e)},Ft=function(t,e){var n=e?e:document;return"object"==typeof t?t:/^#/.test(t)?document.getElementById(t.replace("#","")):n.querySelector(t)},Ut=function(t,e){for(var n=e.charAt(0);t&&t!==document;t=t[St]){if(("."===n||"#"!==n)&&null!==Ft(e,t[St]))return t;if("#"===n&&t.id===e.substr(1))return t}return!1},Xt=function(t,e,n){t.addEventListener(e,n,!1)},Yt=function(t,e,n){t.removeEventListener(e,n,!1)},Gt=function(t,e,n){var i=new CustomEvent(t+".bs."+e);i.relatedTarget=n,this.dispatchEvent(i)},Jt=document[Lt]("*"),Kt=function(t,e,n,i){for(var o=i&&i[kt]?i:Jt,a=0;a-1||l===r)&&new e(o[a])}},Qt=function(e){var n=e&&(e.currentStyle||t.getComputedStyle(e)),i=/px/.test(n.borderTopWidth)?Math.round(n.borderTopWidth.replace("px","")):0,o=/px/.test(n.borderBottomWidth)?Math.round(n.borderBottomWidth.replace("px","")):0,a=/px/.test(n.marginTop)?Math.round(n.marginTop.replace("px","")):0,l=/px/.test(n.marginBottom)?Math.round(n.marginBottom.replace("px","")):0;return e[_]+parseInt(i)+parseInt(o)+parseInt(a)+parseInt(l)},Vt=function(t){for(var e=0,n=0,i=t.children[kt];n=0&&i[Ht]>=0&&i[Ot]<=(t[it]||e[_])&&i[Nt]<=(t[nt]||e[Z])},_t=function(){return{y:t.pageYOffset||e[Q],x:t.pageXOffset||e[V]}},te=function(t,e,i,o){var a=t[Et](),l=o===n?_t():{x:o[K]+o[V],y:o[G]+o[Q]},r={w:a[Nt]-a[Ht],h:a[Ot]-a[Pt]},s={w:e[tt],h:e[et]};i===Pt?(e.style[Pt]=a[Pt]+l.y-s.h+"px",e.style[Ht]=a[Ht]+l.x-s.w/2+r.w/2+"px"):i===Ot?(e.style[Pt]=a[Pt]+l.y+r.h+"px",e.style[Ht]=a[Ht]+l.x-s.w/2+r.w/2+"px"):i===Ht?(e.style[Pt]=a[Pt]+l.y-s.h/2+r.h/2+"px",e.style[Ht]=a[Ht]+l.x-s.w+"px"):i===Nt&&(e.style[Pt]=a[Pt]+l.y-s.h/2+r.h/2+"px",e.style[Ht]=a[Ht]+l.x+r.w+"px"),e.className.indexOf(i)===-1&&(e.className=e.className.replace($t,i))},ee=function(t){return t===Pt?Ot:t===Ot?Pt:t===Ht?Nt:t===Nt?Ht:t},ne=function(o,a){o=Ft(o),a=a||{};var l=o[wt](w),r=o[wt](N),c=o[wt](P),u="affix",d="affixed",f="function",h="update",p="affix-top",m="affixed-top",v="affix-bottom",g="affixed-bottom";if(this[z]=a[z]?Ft(a[z]):Ft(l)||null,this[G]=a[G]?a[G]:parseInt(r)||0,this[J]=a[J]?a[J]:parseInt(c)||0,this[z]||this[G]||this[J]){var y,T,x,b,I,C,L=this,E=i&&i<10?500:50,A=!1,S=!1,k=function(){return Math.max(n[ot],n[et],e[_],e[ot],e[et])},M=function(){return null!==L[z]?L[z][Et]()[Pt]+b:L[G]?parseInt(typeof L[G]===f?L[G]():L[G]||0):void 0},D=function(){if(L[J])return x-o[et]-parseInt(typeof L[J]===f?L[J]():L[J]||0)},B=function(){x=k(),b=parseInt(_t().y,0),y=M(),T=D(),I=parseInt(y)-b<0&&b>parseInt(y),C=parseInt(T)-b<0&&b>parseInt(T)},H=function(){A||zt(o,u)||(Gt.call(o,u,u),Gt.call(o,p,u),Rt(o,u),A=!0,Gt.call(o,d,u),Gt.call(o,m,u))},O=function(){A&&zt(o,u)&&(jt(o,u),A=!1)},W=function(){S||zt(o,v)||(Gt.call(o,u,u),Gt.call(o,v,u),Rt(o,v),S=!0,Gt.call(o,d,u),Gt.call(o,g,u))},$=function(){S&&zt(o,v)&&(jt(o,v),S=!1)},R=function(){C?(I&&O(),W()):($(),I?H():O())};this[h]=function(){B(),R()},s in o||(Xt(t,ft,this[h]),Xt(t,dt,function(){setTimeout(function(){L[h]()},E)}),o[s]=this),this[h]()}};Kt(s,ne,l);var ie=function(t){t=Ft(t);var e=this,n="alert",o=Ut(t,"."+n),l=i&&i<10?0:300,r=function(i){var l=i[z];l=l[Ct](a)?l:l[St],l&&l[Ct](a)&&(o=Ut(l,"."+n),t=Ft("["+a+'="'+n+'"]',o),(t===l||t===l[St])&&o&&e.close())};this.close=function(){o&&t&&zt(o,"in")&&(Gt.call(o,gt,n),jt(o,"in"),setTimeout(function(){o&&(Gt.call(o,yt,n),Yt(t,st,r),o[St].removeChild(o))},l))},c in t||(Xt(t,st,r),t[c]=this)};Kt(c,ie,a);var oe=function(t,e){t=Ft(t),e=e||null;var n=!1,i="button",o="checked",a="reset",l="LABEL",r="INPUT",s=function(){e&&e!==a&&(e===Bt&&(Rt(t,Dt),t[It](Dt,Dt)),t[It](A,t.innerHTML.replace(/^\s+|\s+$/g,"")),t.innerHTML=t[wt]("data-"+e+"-text"))},c=function(){t[wt](A)&&((zt(t,Dt)||t[wt](Dt)===Dt)&&(jt(t,Dt),t.removeAttribute(Dt)),t.innerHTML=t[wt](A))},d=function(e){var a=e[z][St],s=e[z].tagName===l?e[z]:a.tagName===l?a:null;if(s){var c=this,u=qt(c,"btn"),d=s[Lt](r)[0];if(d){if("checkbox"===d.type&&(d[o]?(jt(s,Mt),d[wt](o),d.removeAttribute(o),d[o]=!1):(Rt(s,Mt),d[wt](o),d[It](o,o),d[o]=!0),n||(n=!0,Gt.call(d,bt,i),Gt.call(t,bt,i))),"radio"===d.type&&!n&&!d[o]){Rt(s,Mt),d[It](o,o),d[o]=!0,Gt.call(d,bt,i),Gt.call(t,bt,i),n=!0;for(var f=0,h=u[kt];fp||n===y-1&&0===p)&&(T=h[u]=Nt),h.slideTo(p)}},B=function(t){if(t.preventDefault(),!v){var e=t.currentTarget||t.srcElement;e===E?(p++,T=h[u]=Ht,p===y-1?p=y-1:p===y&&(p=0)):e===C&&(p--,T=h[u]=Nt,0===p?p=0:p<0&&(p=y-1)),h.slideTo(p)}},H=function(t){if(!v){switch(t.which){case 39:p++,T=h[u]=Ht,p==y-1?p=y-1:p==y&&(p=0);break;case 37:p--,T=h[u]=Nt,0==p?p=0:p<0&&(p=y-1);break;default:return}h.slideTo(p)}},N=function(t){for(var e=0,n=S[kt];e-1)&&(n.persist||l))return;s=null,v()}(/\#$/.test(r.href)||/\#$/.test(r[St].href))&&e.preventDefault()}},m=function(){Gt.call(a,ht,l,s),Rt(a,r),c[It](lt,!0),Gt.call(a,pt,l,s),Xt(document,ut,f),i=!0},v=function(){Gt.call(a,mt,l,s),jt(a,r),c[It](lt,!1),Gt.call(a,vt,l,s),Yt(document,ut,f),i=!1},g=0,y=d[kt]||0;ge[_],m=A()},k=function(){r.style[u]=!f&&h?m+"px":"",r.style[d]=f&&!h?m+"px":""},M=function(){r.style[u]="",r.style[d]=""},D=function(){var t=document.createElement("div");v=Ft("."+modalBackdropString),null===v&&(t[It]("class",modalBackdropString+" fade"),v=t,n.appendChild(v))},B=function(){v=Ft("."+modalBackdropString),v&&null!==v&&"object"==typeof v&&(n.removeChild(v),v=null)},H=function(){zt(r,"in")?Yt(document,ut,q):Xt(document,ut,q)},N=function(){zt(r,"in")?Yt(t,dt,this.update):Xt(t,dt,this.update)},P=function(){zt(r,"in")?Yt(r,st,F):Xt(r,st,F)},$=function(t){var e=t[z];e=e[Ct](w)||e[Ct]("href")?e:e[St],t.defaultPrevented||y||e!==o||zt(r,"in")||(r.modalTrigger=o,I=o,g.show(),t.preventDefault(),setTimeout(function(){t.defaultPrevented=!1},50))},q=function(t){var e=t.which||t.keyCode;g[W]&&27==e&&y&&g.hide()},F=function(t){var e=t[z];!t.defaultPrevented&&y&&(e[St][wt](a)===s||e[wt](a)===s||e===r&&g[O]!==c)&&(g.hide(),I=null,t.preventDefault(),setTimeout(function(){t.defaultPrevented=!1},50))};this.toggle=function(){y&&zt(r,"in")?this.hide():this.show()},this.show=function(){Gt.call(r,ht,s,I);var t=qt(document,s+" in")[0];t&&t!==r&&t.modalTrigger[p].hide(),this[O]&&D(),v&&!zt(v,"in")&&setTimeout(function(){Rt(v,"in")},0),setTimeout(function(){r.style.display="block",S(),L(),k(),N(),P(),H(),Rt(n,s+"-open"),Rt(r,"in"),r[It](rt,!1)},this[R]/2),setTimeout(function(){y=!0,Gt.call(r,pt,s,I)},this[R])},this.hide=function(){Gt.call(r,mt,s),v=Ft("."+modalBackdropString),null!==v&&jt(v,"in"),jt(r,"in"),r[It](rt,!0),setTimeout(function(){jt(n,s+"-open"),N(),P(),H(),M(),E(),r.style.display=""},this[R]/2),setTimeout(function(){qt(document,s+" in")[0]||B(),y=!1,Gt.call(r,vt,s)},this[R])},this.setContent=function(t){Ft("."+s+"-content",r).innerHTML=t},this.update=function(){y&&(S(),L(),k())},p in o||(this[j]&&this.setContent(this[j]),Xt(o,st,$),o[p]=this)};Kt(p,se,o);var ce=function(e,o){e=Ft(e);var a=e[wt](k),l=e[wt](M),r=e[wt](b),s=e[wt](B),c=e[wt](S),u=e[wt](H),d=e[wt](D),f="popover",h="template",p="trigger",v="class",g="div",y="fade",T="data-title",x="data-content",w="dismissible",I='';o=o||{},this[h]=o[h]?o[h]:null,this[p]=o[p]?o[p]:a||ct,this[U]=o[U]&&o[U]!==y?o[U]:l||y,this[X]=o[X]?o[X]:s||Pt,this[$]=parseInt(o[$]||u)||100,this[w]=!(!o[w]&&"true"!==c),this[R]=i&&i<10?0:parseInt(o[R]||r)||150,this[Y]=Ft(o[Y])||Ft(d)||n;var C=this,L=e[wt](T)||null,E=e[wt](x)||null;if(E||this[h]){var A=null,N=0,P=this[X],O=function(t){null!==A&&t[z]===Ft(".close",A)&&C.hide()},W=function(){C[Y].removeChild(A),N=null,A=null},j=function(){if(L=e[wt](T),E=e[wt](x),A=document.createElement(g),null!==E&&null===C[h]){if(A[It]("role","tooltip"),null!==L){var t=document.createElement("h3");t[It](v,f+"-title"),t.innerHTML=C[w]?L+I:L,A.appendChild(t)}var n=document.createElement(g),i=document.createElement(g);n[It](v,"arrow"),i[It](v,f+"-content"),A.appendChild(n),A.appendChild(i),i.innerHTML=C[w]&&null===L?E+I:E}else{var o=document.createElement(g);o.innerHTML=C[h],A.innerHTML=o.firstChild.innerHTML}C[Y].appendChild(A),A.style.display="block",A[It](v,f+" "+P+" "+C[U])},q=function(){!zt(A,"in")&&Rt(A,"in")},F=function(){te(e,A,P,C[Y]),Zt(A)||(P=ee(P),te(e,A,P,C[Y]))};this.toggle=function(){null===A?C.show():C.hide()},this.show=function(){clearTimeout(N),N=setTimeout(function(){null===A&&(P=C[X],j(),F(),q(),Gt.call(e,ht,f),setTimeout(function(){Gt.call(e,pt,f)},C[R]))},20)},this.hide=function(){clearTimeout(N),N=setTimeout(function(){A&&null!==A&&zt(A,"in")&&(Gt.call(e,mt,f),jt(A,"in"),setTimeout(function(){W(),Gt.call(e,vt,f)},C[R]))},C[$])},m in e||(C[p]===ct?(Xt(e,Wt[0],C.show),C[w]||Xt(e,Wt[1],C.hide)):/^(click|focus)$/.test(C[p])&&(Xt(e,C[p],C.toggle),C[w]||Xt(e,"blur",C.hide)),C[w]&&Xt(document,st,O),i&&i<9||Xt(t,dt,C.hide),e[m]=C)}};Kt(m,ce,o);var ue=function(e,n){e=Ft(e);var o=Ft(e[wt](w));if(n=n||{},n[z]||o){for(var a,l=n[z]&&Ft(n[z])||o,r=l&&l[Lt]("A"),s=[],c=[],u=e[et]-1?i[St][G]:0,l=d&&i[Et](),r=zt(n,Mt)||!1,u=d?l[Pt]+a:i[G]+o,f=d?l[Ot]+a:u+i[et],h=a>=u&&f>a;if(!r&&h)"LI"!==n.tagName||zt(n,Mt)||(Rt(n,Mt),r=!0,Gt.call(e,"activate","scrollspy",s[t]));else if(h){if(!h&&!r||r&&h)return}else"LI"===n.tagName&&zt(n,Mt)&&(jt(n,Mt),r=!1)},y=function(){a=d?_t().y:e[Q];for(var t=0,n=s[kt];t1&&(t=e[e[kt]-1]):t=e[0],t[Lt]("A")[0]},p=function(){return Ft(h()[wt]("href"))},m=function(t){t.preventDefault(),s=t[z],u.show()};this.show=function(){var e=Ft(s[wt]("href")),n=h(),i=p();n[r]&&s[r]||zt(s[St],Mt)||(n[r]=s[r]=!0,jt(n[St],Mt),Rt(s[St],Mt),f&&(zt(t[St][St],"dropdown-menu")?zt(f,Mt)||Rt(f,Mt):zt(f,Mt)&&jt(f,Mt)),c&&(c.style[l]=Vt(i)+"px"),Gt.call(n,mt,a,s),setTimeout(function(){jt(i,"in")},10),setTimeout(function(){c&&Rt(c,At),jt(i,Mt),Rt(e,Mt),setTimeout(function(){Rt(e,"in")},10),Gt.call(s,ht,a,n),Gt.call(n,vt,a,s),c&&(c.style[l]=Vt(e)+"px")},.7*u[R]),setTimeout(function(){Gt.call(s,pt,a,n),c&&(jt(c,At),c.style[l]=""),n[r]=s[r]=!1},1.5*u[R]))},g in t||(this[l]&&(c=p()[St]),Xt(t,st,m),t[g]=this)};Kt(g,de,o);var fe=function(t,e){t=Ft(t);var o=t[wt](M);placementData=t[wt](B),durationData=t[wt](b),delayData=t[wt](H),containerData=t[wt](D),component="tooltip",classString="class",title="title",fade="fade",div="div",e=e||{},this[U]=e[U]&&e[U]!==fade?e[U]:o||fade,this[X]=e[X]?e[X]:placementData||Pt,this[$]=parseInt(e[$]||delayData)||100,this[R]=i&&i<10?0:parseInt(e[R]||durationData)||150,this[Y]=Ft(e[Y])||Ft(containerData)||n;var a=this,l=0,r=this[X],s=null,c=t[wt](title)||t[wt](E);if(c){var u=function(){a[Y].removeChild(s),s=null,l=null},d=function(){c=t[wt](title)||t[wt](E),s=document.createElement(div),s[It]("role",component);var e=document.createElement(div),n=document.createElement(div);e[It](classString,component+"-arrow"),n[It](classString,component+"-inner"),s.appendChild(e),s.appendChild(n),n.innerHTML=c,a[Y].appendChild(s),s[It](classString,component+" "+r+" "+a[U])},f=function(){te(t,s,r,a[Y]),Zt(s)||(r=ee(r),te(t,s,r,a[Y]))},h=function(){!zt(s,"in")&&Rt(s,"in")};this.show=function(){clearTimeout(l),l=setTimeout(function(){null===s&&(r=a[X],d(),f(),h(),Gt.call(t,ht,component),setTimeout(function(){Gt.call(t,pt,component)},a[R]))},20)},this.hide=function(){clearTimeout(l),l=setTimeout(function(){s&&null!==s&&zt(s,"in")&&(Gt.call(t,mt,component),jt(s,"in"),setTimeout(function(){u(),Gt.call(t,vt,component)},a[R]))},a[$])},this.toggle=function(){s?a.hide():a.show()},y in t||(t[It](E,c),t.removeAttribute(title),Xt(t,Wt[0],this.show),Xt(t,Wt[1],this.hide),t[y]=this)}};return Kt(y,fe,o),{Affix:ne,Alert:ie,Button:oe,Carousel:ae,Collapse:le,Dropdown:re,Modal:se,Popover:ce,ScrollSpy:ue,Tab:de,Tooltip:fe}}); diff --git a/index.html b/index.html index 0edcc79d..c11980d9 100644 --- a/index.html +++ b/index.html @@ -393,6 +393,7 @@

Usage

Via DATA API

You can initialize Modal without writing any code as long as you have a modal and a trigger with data-target or a link with href referencing that modal. The component will initialize for all elements with data-toggle="modal" found in the DOM.

+
<!-- provide a trigger button -->
 <button id="myModalTrigger" type="button" data-toggle="modal" data-target="#myModal">Launch modal</button>
 
@@ -549,9 +550,9 @@ 
                       

Text in a modal

Duis mollis, est non commodo luctus, nisi erat porttitor ligula.

Popover in a modal

-

This button should trigger a popover on click.

+

This button should trigger a popover on click.

Tooltips in a modal

-

This link and that link should have tooltips on hover.

+

This link and that link should have tooltips on hover.

Open modal from modal

Click here to open another modal.


@@ -1547,8 +1548,8 @@

Options

container selector
or object - <body> - The container where your tooltips get appended to. This option is only for JavaScript initialization and is not fully implemented as the original. + <document.body> + The container where your popovers get appended to. You can set the option via the data-container="#elementID" attribute or via JavaScript. @@ -1778,8 +1779,8 @@

Options

container selector
or object - <body> - The container where your popovers get appended to. This option is only for JavaScript initialization and is not fully implemented as the original. + <document.body> + The container where your popovers get appended to. You can set the option via the data-container="#elementID" attribute or via JavaScript. diff --git a/lib/popover-native.js b/lib/popover-native.js index 5bb31b4e..afcdc43a 100644 --- a/lib/popover-native.js +++ b/lib/popover-native.js @@ -16,6 +16,7 @@ var Popover = function( element, options ) { placementData = element[getAttribute](dataPlacement), dismissibleData = element[getAttribute](dataDismissible), delayData = element[getAttribute](dataDelay), + containerData = element[getAttribute](dataContainer), // internal strings component = 'popover', @@ -40,7 +41,7 @@ var Popover = function( element, options ) { this[delay] = parseInt(options[delay] || delayData) || 100; this[dismissible] = options[dismissible] || dismissibleData === 'true' ? true : false; this[duration] = (isIE && isIE < 10) ? 0 : parseInt(options[duration] || durationData) || 150; - this[container] = queryElement(options[container]) || body; // JavaScript only + this[container] = queryElement(options[container]) || queryElement(containerData) || body; // bind, content var self = this, @@ -104,10 +105,10 @@ var Popover = function( element, options ) { !hasClass(popover,'in') && ( addClass(popover,'in') ); }, updatePopover = function() { - styleTip(element,popover,placementSetting); + styleTip(element,popover,placementSetting,self[container]); if (!isElementInViewport(popover) ) { placementSetting = updatePlacement(placementSetting); - styleTip(element,popover,placementSetting); + styleTip(element,popover,placementSetting,self[container]); } }; diff --git a/lib/tooltip-native.js b/lib/tooltip-native.js index b102db27..f5de1a8b 100644 --- a/lib/tooltip-native.js +++ b/lib/tooltip-native.js @@ -14,6 +14,7 @@ var Tooltip = function( element,options ) { placementData = element[getAttribute](dataPlacement); durationData = element[getAttribute](dataDuration); delayData = element[getAttribute](dataDelay), + containerData = element[getAttribute](dataContainer), // strings component = 'tooltip', @@ -28,7 +29,7 @@ var Tooltip = function( element,options ) { this[placement] = options[placement] ? options[placement] : placementData || top; this[delay] = parseInt(options[delay] || delayData) || 100; this[duration] = (isIE && isIE < 10) ? 0 : parseInt(options[duration] || durationData) || 150; - this[container] = queryElement(options[container]) || body; // JavaScript only + this[container] = queryElement(options[container]) || queryElement(containerData) || body; // bind, event targets, title and constants var self = this, timer = 0, placementSetting = this[placement], tooltip = null, @@ -57,10 +58,10 @@ var Tooltip = function( element,options ) { tooltip[setAttribute](classString, component + ' ' + placementSetting + ' ' + self[animation]); }, updateTooltip = function () { - styleTip(element,tooltip,placementSetting); + styleTip(element,tooltip,placementSetting,self[container]); if (!isElementInViewport(tooltip) ) { placementSetting = updatePlacement(placementSetting); - styleTip(element,tooltip,placementSetting); + styleTip(element,tooltip,placementSetting,self[container]); } }, showTooltip = function () { diff --git a/lib/utils.js b/lib/utils.js index e5f17e1a..909d23e4 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -41,6 +41,7 @@ var global = typeof global !== 'undefined' ? global : this||window, dataDismissible = 'data-dismissible', dataTrigger = 'data-trigger', dataAnimation = 'data-animation', + dataContainer = 'data-container', dataPlacement = 'data-placement', dataDelay = 'data-delay', dataOffsetTop = 'data-offset-top', @@ -54,6 +55,7 @@ var global = typeof global !== 'undefined' ? global : this||window, // box model offsetTop = 'offsetTop', offsetBottom = 'offsetBottom', + offsetLeft = 'offsetLeft', scrollTop = 'scrollTop', scrollLeft = 'scrollLeft', clientWidth = 'clientWidth', clientHeight = 'clientHeight', offsetWidth = 'offsetWidth', offsetHeight = 'offsetHeight', @@ -213,8 +215,9 @@ var global = typeof global !== 'undefined' ? global : this||window, x : global.pageXOffset || doc[scrollLeft] } }, - styleTip = function(link,element,position) { // both popovers and tooltips - var rect = link[getBoundingClientRect](), scroll = getScroll(), + styleTip = function(link,element,position,container) { // both popovers and tooltips + var rect = link[getBoundingClientRect](), + scroll = container === body ? getScroll() : { x: container[offsetLeft] + container[scrollLeft], y: container[offsetTop] + container[scrollTop] }, linkDimensions = { w: rect[right] - rect[left], h: rect[bottom] - rect[top] }, elementDimensions = { w : element[offsetWidth], h: element[offsetHeight] }; diff --git a/package.json b/package.json index 9b74ecf1..428dfc5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap.native", - "version": "2.0.0", + "version": "2.0.1", "description": "Native Javascript for Bootstrap 3, the sweetest Javascript library without jQuery.", "main": "dist/bootstrap-native.js", "scripts": {