diff options
Diffstat (limited to 'example')
| -rw-r--r-- | example/index.css | 6 | ||||
| -rw-r--r-- | example/index.html | 1 | ||||
| -rw-r--r-- | example/nsPopover.js | 23 | 
3 files changed, 23 insertions, 7 deletions
| diff --git a/example/index.css b/example/index.css index d641f03..58add65 100644 --- a/example/index.css +++ b/example/index.css @@ -37,11 +37,11 @@ body > section {  article {
    position: relative;
    margin: 0 auto;
 -  float: left;
  }
 -article:after {
 -  clear: both;
 +article + h1 {
 +  clear: left;
 +  display: block;
  }
  h1 {
 diff --git a/example/index.html b/example/index.html index 28ff4fe..034f630 100644 --- a/example/index.html +++ b/example/index.html @@ -77,6 +77,5 @@      </a>
    </article>
  </section>
 -
  </body>
  </html>
\ No newline at end of file diff --git a/example/nsPopover.js b/example/nsPopover.js index 505fbba..b3c9ab5 100644 --- a/example/nsPopover.js +++ b/example/nsPopover.js @@ -5,6 +5,8 @@    var $el = angular.element;
    var isDef = angular.isDefined;
    var forEach = angular.forEach;
 +  var $popovers = [];
 +  var globalId = 0;
    module.directive('nsPopover', function($timeout, $templateCache, $q, $http, $compile, $document) {
      return {
 @@ -54,11 +56,15 @@            $container = $document.find('body');
          }
 -        var $popover = $el('<div></div>');
          var $triangle;
          var placement_;
          var align_;
 +        globalId += 1;
 +
 +        var $popover = $el('<div id="nspopover-' + globalId +'"></div>');
 +        $popovers.push($popover);
 +
          var match = options.placement
            .match(/^(top|bottom|left|right)$|((top|bottom)\|(center|left|right)+)|((left|right)\|(center|top|bottom)+)/);
 @@ -222,8 +228,19 @@            var x = (isDef(w.pageXOffset)) ? w.pageXOffset : doc.scrollLeft;
            var y = (isDef(w.pageYOffset)) ? w.pageYOffset : doc.scrollTop;
            var rect = elm.getBoundingClientRect();
 -          rect.top += y;
 -          rect.left += x;
 +
 +          // ClientRect class is immutable, so we need to return a modified copy
 +          // of it when the window has been scrolled.
 +          if (x || y) {
 +            return {
 +              bottom:rect.bottom+y,
 +              left:rect.left + x,
 +              right:rect.right + x,
 +              top:rect.top + y,
 +              height:rect.height,
 +              width:rect.width
 +            };
 +          }
            return rect;
          }
 | 
