GithubHelp home page GithubHelp logo

nspopover's Introduction

nsPopover

nsPopover is a simple component for angularjs applications that adds small overlays of content, like those on the iPad, to any element for housing secondary information.. It has only angularjs as dependency.

Getting Involved

We use the Collective Code Construction Contract (http://rfc.zeromq.org/spec:22). collaboration model.

Install

You can download all necessary nsPopover files manually or install it with bower:

bower install nsPopover
npm install
grunt compile

Usage

You need only to include the nsPopover.js (as minimal setup) to your project and then you can start using the nsPopover directives.

Directive

angular
  .module('nsPopoverExample', [
   'nsPopover'
  ])

  .controller('MainCtrl', function($scope) {
    $scope.items = [{
      name: "Action"
    }, {
      name: "Another action"
    }, {
      name: "Something else here"
    }];
  });
<script type="text/ng-template" id="popover">
  <ul>
    <li ng-repeat="item in items"><a>{{item.name}}</a></li>
  </ul>
</script>

<button ns-popover
  ns-popover-template="popover"
  ns-popover-trigger="click"
  ns-popover-placement="bottom">
    Popover
</button>

Attributes

nsPopover defines a simple set of attributes that can be used to customize the popover behavior.

ns-popover {Boolean}

The popover will show by default but ff you set ns-popover attribute equal to a scope variable whose value is false, the popover will not be displayed. IE:

// In controller:
$scope.displayPopover = false;

// In HTML:
<div ns-popover="displayPopover"></div>

ns-popover-template {String}

The id of the template that contains the popover content. The content will be loaded through the angular $http service and cached (content will not be loaded if it is already in $templateCache). It can be loaded through path to external html template or <script> tag with text\ng-template.

<script type="text/ng-template" id="templateId">
  <h1>Template heading</h1>
  <p>Some content</p>
</script>

Also it is possible to use simple strings as template together with ns-popover-plain option.

ns-popover-plain {Boolean}

A flag that indicates if the ns-popover-template is a plain string or not, default: false.

ns-popover-trigger {String}

The ns-popover-trigger specify how the popover is triggered. This can be any event that the associated DOM element can trigger, default: click.

ns-popover-timeout {Number}

The ns-popover-timeout specify the time to wait before closing the popover and after the mouseout event is triggered by the popover, default 1.5 seconds, use -1 to disable to timeout.

ns-popover-placement {String}

Specifies how to position the popover relative to the triggering element. The placement attribute has the given syntax: [position]|[alignment]. The [position] parameter specifies the position (top/right/bottom/left) of the popover, and the alignment defines the alignment of the popover (left/center/right). The list below shows the possible combinations of [position] and [alignment].

Position Alignment Description
top center The popover will be positioned above the triggering element and its horizontal center will be aligned with the horizontal center of the triggering element.
top left The popover will be positioned above the triggering element and its left side will be aligned with the left side of the triggering element.
top right The popover will be positioned above the triggering element and its right side will be aligned with the right side of the triggering element.
bottom center The popover will be positioned on the below the triggering element and its horizontal center will be aligned with the horizontal center of the triggering element.
bottom left The popover will be positioned below the triggering element and its left side will be aligned with the left side of the triggering element.
bottom right The popover will be positioned below the triggering element and its right side will be aligned with the right side of the triggering element.
left center The popover will be positioned on the left side of the triggering element and its vertical center will be aligned with vertical center of the triggering element.
left top The popover will be positioned on the left side of the triggering element and its top will be aligned with the top of the triggering element.
left bottom The popover will be positioned on the left side of the triggering element and its bottom will be aligned with the bottom of the triggering element.
right center The popover will be positioned on the right side of the triggering element and its vertical center will be aligned with vertical center of the triggering element.
right top The popover will be positioned on the right side of the triggering element and its top will be aligned with the top of the triggering element.
right bottom The popover will be positioned on the right side of the triggering element and its bottom will be aligned with the bottom of the triggering element.

ns-popover-hide-on-inside-click {Boolean}

The ns-popover-hide-on-inside-click attribute specifies whether or not to close the popover when clicking on it (or an element inside of it). Setting this to false allows for element-targeted closing of the popover (i.e. a close button inside the popover). Defaults to false.

ns-popover-mouse-relative {{String}}

Locks the position relative to the mouse. The following are possible values:

  • x - Constraints the x axis to follow the mouse.
  • y - Constraints the y axis to follow the mouse.
  • xy - Constraints both the x and y axis to follow the mouse.

ns-popover-group {String}

The ns-popover-group specifies the group of popovers which should be closed when this instance is shown. This allows the construction of popovers that acts like a modal dialog.

Programmatic Hiding of the Popover

Register the hidePopover() function against a ng-click directive to hide the popover when a specific element is clicked (e.g. a close button):

<button ng-click="hidePopover()">Close</button>

This button lives within the popover template.

Themes

You can customize the nsPopover through themes. You can use the nsPopover to create your own theme, like so.

.ns-popover-custom-theme {
  ul, .list {
  }

  li, .list-item {
    list-style-type: none;

    a {
      &:hover {
      }
    }
  }
}

and them specify this theme on the HTML

  <button ns-popover
    ns-popover-template="popover"
    ns-popover-theme="ns-popover-custom-theme">
      Popover
  </button>

License

MIT Licensed

Copyright (c) 2013, nohros.com [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nspopover's People

Contributors

andyxlee avatar blackening avatar busterbeans avatar dozed avatar gabehayes avatar gaffney avatar itamark avatar jason-whitehead avatar joluma avatar justinobney avatar kenadia avatar khoden avatar longzheng avatar nohros avatar noordawod avatar pads avatar prabhu-das avatar ridespirals avatar sketchynix avatar teddywing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nspopover's Issues

Bower cant find package

using

 bower install nspopover --save

fails with error message Package nspopover not found

Set offset position from the triggering element?

I added a notch to the popover, but it overlaps the triggering button. Changing the top position fixes the issue, but how would I do it through the code? There should be an option to add some offset value to the calculated top.

Add event for hiding the popover

Currently there are 2 options (not documented):

  1. ns-popover-angular-event
  2. ns-popover-scope-event

Both of them are used to display the popover, it would be great to have options to hide the popover.

delay compilation

Can we delay the popover construction until the user triggered it?
Otherwise, we will end up with a ton of hidden div.

Issue in fixed div

If there is a div with position: fixed with a ns-popover-template, when you scrolls the body, the popover won't be fixed.

Popover is not responsive

First of all its a great library to use. However I'm facing a problem. My application is supported in any resolutions. But popover doesn't look good when I use it in mobile devices. It don't stick to that element properly. Am I doing something wrong or popover is not responsive?

Popover sometimes getting positioned at the top-left corner of the page

Hi
I have a infinite horizontal scroll on my webpage and there are cards lying adjacent to each other..On every card nsPopover are bound on hover. But a times the popover gets positioned at the top left corner of the page, and on hovering again(1-2 times) the popover gets positioned correctly. Why is it happening like this? Please help me to sort out this bug.

IE8 support

The popover shift to left in Internet Explorer 8. I detected emulating IE8 with IE11.

No default absolute position defined before popover shown

So I am using Angular Material design for angular (which uses Flexbox for layout).

I was noticing that on the first click to show my popover, the popover was always slightly off position. Subsequent clicks correctly positioned the popover.

I found out that since no default absolute position is set on the popover and due to me using Flexbox, that when the popover's display was changed to block in the source code (which occurs BEFORE it's absolute position is determined), the UI layout displayed a browser scrollbar which then shifted the location of my element showing the popover and incorrect location values were calculated for the popup.

The simple fix I added was to just set an initial position on the popup when it's display is initially set to none:
nsPopover.js

          $popover
              .css('position', 'absolute')
              .css('top', '0px')
              .css('left', '0px')
              .css('display', 'none');

Thus, when the browser sets the popover's display to 'block' my page isn't "shifted" and the correct location of my element is calculated.

I'm posting this in case others experience a similar problem or are having issues using a layout framework (like Flexbox) and the initial positioning of the popover is slightly off.

I don't think setting this initial position would cause any other issues but I think ultimately, adding the following capabilities would be even better and may make my issue obsolete:
#1
#15

ns-popover-hide-on-inside-click

Readme say ns-popover-hide-on-click {Boolean} is defaulted to true.

The attribute really is ns-popover-hide-on-inside-click defaulted to false.

localRect

error on line 231nsPopover.js.
should be rect and not localRect

Delay for popup

This directive very much needs something similar to Bootstrap's "tooltip-popup-delay".

See Angular Bootstrap's tooltip.js / docs

Dynamically positioning the popover

Hi
I want to dynamically position the popover to the other side if the popover is just at the boundary of the page and hence is getting hidden. Is there a way I can handle this issue? Please help. Thanks.

Support for Version Angular 1.3.*

Hi,

I'm using the module but when I run the command line "bower install", I get notifications about version:
Unable to find a suitable version for angular, please choose one:
angular#~1.2.9 which resolved to 1.2.28 and is required by nsPopover#0.6.7
I wonder if you can upgrade to the latest version of the angular or if there is a problem to update?

Make this package availabe on npm

Thank for your work :)

Could you provide this module on npm ?

You just have to login throught npm ( npm login )
and do npm publish

Before you may have to change the name in package.json because it doesn't support camelCase

Avoid hiding of nsPopover on clicking it

Is there any way to avoid hiding of nsPopover on clicking it, as my custom nsPopover has some click events bound to it, and I want to keep the nsPopover timeout to be 0.1 sec.
PS: I want to hide the nsPopover 'only' when the mouse moves out of the target 'and' the nsPopover.

Can't load the nsPopover module

I can't load the module:

here is my definition

var MyApp = angular.module('MyApp', [
'angulartics.google.tagmanager','ngTouch', 'nsPopover',
'ngRoute', 'ngCookies', 'ngSanitize', 'ui.bootstrap', 'ngAnimate','angular-carousel'
]);

Error: [$injector:modulerr] Failed to instantiate module nsPopover due to:
Error: [$injector:nomod] Module 'nsPopover' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.28/$injector/nomod?p0=nsPopover
at http://0.0.0.0:9000/bower_components/angular/angular.js:78:12
at http://0.0.0.0:9000/bower_components/angular/angular.js:1677:17
at ensure (http://0.0.0.0:9000/bower_components/angular/angular.js:1601:38)
at module (http://0.0.0.0:9000/bower_components/angular/angular.js:1675:14)
at http://0.0.0.0:9000/bower_components/angular/angular.js:3877:22
at forEach (http://0.0.0.0:9000/bower_components/angular/angular.js:325:18)
at loadModules (http://0.0.0.0:9000/bower_components/angular/angular.js:3871:5)
at http://0.0.0.0:9000/bower_components/angular/angular.js:3878:40
at forEach (http://0.0.0.0:9000/bower_components/angular/angular.js:325:18)
at loadModules (http://0.0.0.0:9000/bower_components/angular/angular.js:3871:5)

Conflict with ns-popover-modal and ns-popover-hide-on-outside-click

Hi,

I have 3 buttons on a page. When the user clicks a button, I want to show the popover associated with that button. I also need to keep the popover open even if the user clicks outside of it - unless clicking on another button that triggers a popover.

I think I am supposed to use both ns-popover-hide-on-outside-click='false' along with ns-popover-modal="true". Unfortunately, what occurs is multiple popovers rendering on the screen, with each button click.

Is this a conflict?

Is there a way to trigger all popovers to close before showing the chosen one, when clicking a triggering button? hidePopover is only usable within the popover template.

Thanks for any help!

nsPopover with ng-keyup

Hello,

I'm trying to using the directive nspopover inside an input, it works fine, but when I add an ng-keyup event for example into the input, the event inside the ng-keyup is ignored, is that normal? How could I use angualrjs directives with nspopover ?

Regards,

Close popover when clicking outside of it

it would be helpful to have the popover closes when a user clicks outside of it and not on it. If the template contains some html with a directive or a button, then the hide on click must be set to false so now the only way to close it is to wait for the timeout.

Incorrect README.

This needs to be changed from

<script type="text\ng-template" id="templateId"> to <script type="text/ng-template" id="templateId">

Incomplete Documentation

The control that you have created is quite good but the documentation is not providing enough information to add a nsPopover having theme "ns-popover-tooltip-custom".. What I found in your code was the following snippet you should add inside your template first to make the popover visible otherwise it won't show up.

<div class="triangle"></div><div class="ns-popover-tooltip-custom">

I suppose you should add this in your documentation. Thanks!

How to call a function when showing the popover?

Looking through the attributes, I don't see any easy way to attach an event that gets called when the popover is displayed. Could you add this please?

In the meantime, I've found that I can use $watch for the css display changing to block, but to make this work, I had to modify the nsPopover.js to call $rootScope.$apply(); after setting the popover css. I'd rather not have to use this hack.

Thanks!

TypeError: triangle.css is not a function

TypeError: triangle.css is not a function
    at move (nsPopover.js:329)
    at nsPopover.js:114
    at angular.js:16299
    at completeOutstandingRequest (angular.js:4924)
    at angular.js:5312

angular 1.4

5.0.4 tag breaks an installation of the the latest version of nsPopover

When the user uses command bower install nsPopover (pretty common and usual case) or uses in bower.json declaration with the "latest" value

"dependencies": {
    "nsPopover": "latest"
}

he always got an old (0.5.4) version of nsPopover because of typo in tag name.

Repository has tag name 5.0.4 (must be 0.5.4) which interpreted by bower as the latest (highest) version of nsPopover accordingly to SemVer specification.

http://errors.angularjs.org/1.2.25/jqLite/nosel

Line 94 of nsPopover.js has a line
var $container = $el(options.container);

which leads to an unknown selector issue. this can be resolved by changing it to:

var $container = $document[0].querySelector(options.container);

Programatically open nspopover

hello folks!

Can anyone of you let me know or share me the snippet of how we could programatically open nsPopover?

Thanks

No popover in mozilla

I am getting this error in popover in Firefox.

Line number is 239.
TypeError: setting a property that has only a getter

Callback when hided

Hi there, it would be great if i could register a callbackfunction to be executed when the popover hides.

The purpose is: Users can modify content, that I need to post to an api at some point. The best moment is when the popover is hided.
What do you think?

Update README.md please

Hi, would be great if the readme.md will updated because for example: I have been using nsPopover 2 months ago and enter continuously to github. And I thought that you doesn't include any new feature because the doc was old, but right now I check the code and I see new features.

P.D: great work guys

The ns-popover-container feature does not work properly

Hi! The ns-popover-container feature does not work properly, in

var $container = $document[0].querySelector(options.container);

you get bare DOM element, not jQuery object, therefor either the

$container.append($popover);

fails (for elements having length property, e.g. form) or container (for elements not having length property) gets replaced by body:

if (!$container.length) {
    $container = $document.find('body');
}

$container should be filled e.g. by:

var $container = $document.find(options.container);

Cheers, Tomas

Positioning after y-scrolling

When you scroll the element (let's call it elem) at which the popover is attached vertically, then the y-position of the popover is not correctly calculated anymore.
To me, it looks like the y-coord of elem has a different fix-point than the y-coord of the popover. I tried to illustrate it (see below).
On the left you see the browser canvas, a div, the (child) elem, and the attached popover. On the right, the div is scrolled up. I guess the fix point of the elem is the "browser canvas", the fix point of the popover is the parent div.
When (a) gets smaller due to scrolling, (b) gets also smaller. That leads to a wrong y-position for the popover.

illustration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.