clu3 / bootstro.js

Tiny JS library using bootstrap's popovers to help guide your users around your website
http://clu3.github.io/bootstro.js/
MIT License
1.33k stars 235 forks source link

popover defined width and small screens (mobile) #40

Open eitamar opened 10 years ago

eitamar commented 10 years ago

i made this change to the code for a website im working on

on line 187 (inside get_popup function)

 if ($el.attr('data-bootstro-width'))
 {
     p.width = $el.attr('data-bootstro-width'); 
     var width_without_px = p.width.substr(0 , p.width.indexOf('px'));
     if(width_without_px > $(window).width()){//if bigger then screen
        p.width = ($(window).width()-10)+'px';
        $el.attr('data-bootstro-width' ,p.width );
        p.placement = 'bottom';
      }
style = style + 'width:' + $el.attr('data-bootstro-width') + ';'

}

so what it does is if popover width defined check the width and window width, if popover is bigger then screen make it smaller then screen and make placement bottom.

hope youj find it usefull

itamar