Angular directive for Canon popovers.
- AngularJS v1.3 or higher
- Canon v1.1 or higher
- jQuery v1.9 or higher
This package is not currently published to either NPM or Bower. Once the API stabilizes, the built files will be published. Until then, you can install directly from the GitHub repository.
To install with Bower, add the following line to dependencies in your bower.json:
"rs-popover": "https://github.com/rackerlabs/rs-popover.git"
Once you have installed the package, you'll need to:
- Include
rs-popover.js
orrs-popover.min.js
in your application. - Add
rs.popover
to your main module's list of dependencies.
This directive defines a popover and can be used as either an element or an
attribute. All instances of this attribute must have a unique id
attribute.
<rs-popover id="myPopover">
This is popover content!
</rs-popover>
Type: String
, Required
Accepts any unique string used to identity this popover. This attribute is required and must be unique across all other elements on the page.
Type: Expression
, Default: ''
Accepts the name of a function to be called when the popover is opened. This function should return a promise. A loading pattern will be displayed until the promise returned by this method is resolved. This attribute is optional.
This directive defines a popover that contains a form and can be used as either
an element or an attribute. All instances of this attribute must have a unique
id
attribute.
<rs-popover-form id="myPopoverForm">
<div class="rs-control-group">
<label>Label</label>
<div class="rs-controls">
<input type="text">
</div>
</div>
</rs-popover-form>
Type: String
, Required
Accepts any unique string used to identity this popover. This attribute is required and must be unique across all other elements on the page.
Type: Expression
, Default: ''
Accepts the name of a function to be called when the popover is opened. This function should return a promise. A loading pattern will be displayed until the promise returned by this method is resolved. This attribute is optional.
Type: Expression
, Default: ''
Accepts the name of a function to be called when the popover's form is submitted. This function should return a promise. The save and cancel buttons will be disabled until the promise returned by this method is resolved. When the promise resolved, the popover will be closed. When the promise throws an error, the buttons will be enabled and an error message will be displayed. This attribute is optional.
This directive toggles a popover's visibility and can only be used as an attribute.
<button rs-popover-trigger="myPopover"
rs-popover-target="myTarget"
rs-popover-attach="top-left"
rs-popover-data="{ id: 'object-id' }">Toggle Me!</button>
Type: String
, Required
Accepts the ID of the popover it should toggle. If this attribute is used inside of a popover, it defaults to toggling the containing popover.
Type: String
Accepts the ID of the element at which the popover should point. If this attribute is not provided, the popover will point at the popover trigger.
Type: String
, Default: top-left
Specifies how the popover will be oriented in relation to the target.
attach="left-top"
- Position the target to the left of the popover.attach="top-left"
- Position the target to the top left of the popover.
Type: Object
, Default: {}
Accepts an object that will be passed to the on-open
and on-save
hooks
exposed by the popover.
In addition to the rs-popover-trigger
directive for toggling popover
visibility, this package also provides a service that can be used to control
popovers programmatically.
angular.module('my.module').controller('MyController', function (registry) {
$scope.toggle = function (e) {
registry.popover('somepopoverid').toggle(e.target, 'top-left');
};
$scope.show = function (e) {
registry.popover('somepopoverid').open(e.target, 'top-left');
};
$scope.hide = function () {
registry.popover('somepopoverid').close();
};
});
rs-popover is released under the MIT License.