aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeylor Ohmaly2014-02-25 21:21:22 -0300
committerNeylor Ohmaly2014-02-25 21:21:22 -0300
commit96838f8b18885aadf9497e73be20ecc5bef8ca18 (patch)
treecdf9874967fc0762117b9ead77c2b5ed990ad8f4
parentf62db567d999f50a09947a0d6478a205f60ba03c (diff)
downloadnsPopover-96838f8b18885aadf9497e73be20ecc5bef8ca18.tar.bz2
Added a new configuration option to allow the specification of the delay used to close the popover.0.5.6
-rw-r--r--bower.json2
-rw-r--r--example/index.html3
-rw-r--r--example/nsPopover.js33
-rw-r--r--package.json2
-rw-r--r--src/nsPopover.js33
5 files changed, 18 insertions, 55 deletions
diff --git a/bower.json b/bower.json
index 14a80ae..64be25e 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "nsPopover",
- "version": "0.5.5",
+ "version": "0.5.6",
"homepage": "https://github.com/nohros/nsPopover",
"description": "Popover for angularjs library",
"authors": [
diff --git a/example/index.html b/example/index.html
index 7afb219..dcf33fd 100644
--- a/example/index.html
+++ b/example/index.html
@@ -41,7 +41,8 @@
<button ns-popover
ns-popover-template="menu"
ns-popover-trigger="click"
- ns-popover-theme="ns-popover-list-theme">
+ ns-popover-theme="ns-popover-list-theme"
+ ns-popover-timeout="5">
Click me
</button>
diff --git a/example/nsPopover.js b/example/nsPopover.js
index 1e8aad1..cfdb904 100644
--- a/example/nsPopover.js
+++ b/example/nsPopover.js
@@ -6,26 +6,6 @@
var isDef = angular.isDefined;
var forEach = angular.forEach;
- /**
- * Extends the destination objec 'dst' by copying all of the properties from the 'src' object(s)
- * to 'dst'. Multiple src objects could be specified. 'undefined' values are not copied.
- *
- * @param {Object} dst The destination object.
- * @param {Object} src The spurce object.
- * @returns {Object} Reference to 'dst'.
- */
- var extend_ = function extend(dst, src) {
- forEach(arguments, function(obj) {
- if (obj !== src) {
- forEach(obj, function(value, key) {
- if (isDef(value)) {
- dst[key] = value;
- }
- });
- }
- });
- };
-
module.directive('nsPopover', function($timeout, $templateCache, $q, $http, $compile, $document) {
return {
restrict: 'A',
@@ -36,7 +16,8 @@
plain: attrs.nsPopoverPlain,
trigger: attrs.nsPopoverTrigger || 'click',
container: attrs.nsPopoverContainer,
- placement: attrs.nsPopoverPlacement || 'bottom|left'
+ placement: attrs.nsPopoverPlacement || 'bottom|left',
+ timeout: attrs.nsPopoverTimeout || 1.5
};
var hider_ = {
@@ -46,7 +27,7 @@
* Set the display property of the popover to 'none' after |delay| milliseconds.
*
* @param popover {Object} The popover to set the display property.
- * @param delay {Number} The time (in milliseconds) to wait before set the display property.
+ * @param delay {Number} The time (in seconds) to wait before set the display property.
* @returns {Object|promise} A promise returned from the $timeout service that can be used
* to cancel the hiding operation.
*/
@@ -55,12 +36,12 @@
// delay the hiding operation for 1.5s by default.
if (!isDef(delay)) {
- delay = 1500;
+ delay = 1.5;
}
hider_.id_ = $timeout(function() {
popover.css('display', 'none');
- }, delay);
+ }, delay*1000);
},
cancel: function() {
@@ -160,12 +141,12 @@
});
elm.on('mouseout', function() {
- hider_.hide($popover);
+ hider_.hide($popover, options.timeout);
});
$popover
.on('mouseout', function(e) {
- hider_.hide($popover);
+ hider_.hide($popover, options.timeout);
})
.on('mouseover', function() {
hider_.cancel();
diff --git a/package.json b/package.json
index ab814bf..5408937 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"author": "Neylor Ohmaly",
"name": "nsPopover",
- "version": "0.5.5",
+ "version": "0.5.6",
"homepage": "http://nohros.com/nsPopover",
"licenses": {
"type": "MIT",
diff --git a/src/nsPopover.js b/src/nsPopover.js
index 1e8aad1..cfdb904 100644
--- a/src/nsPopover.js
+++ b/src/nsPopover.js
@@ -6,26 +6,6 @@
var isDef = angular.isDefined;
var forEach = angular.forEach;
- /**
- * Extends the destination objec 'dst' by copying all of the properties from the 'src' object(s)
- * to 'dst'. Multiple src objects could be specified. 'undefined' values are not copied.
- *
- * @param {Object} dst The destination object.
- * @param {Object} src The spurce object.
- * @returns {Object} Reference to 'dst'.
- */
- var extend_ = function extend(dst, src) {
- forEach(arguments, function(obj) {
- if (obj !== src) {
- forEach(obj, function(value, key) {
- if (isDef(value)) {
- dst[key] = value;
- }
- });
- }
- });
- };
-
module.directive('nsPopover', function($timeout, $templateCache, $q, $http, $compile, $document) {
return {
restrict: 'A',
@@ -36,7 +16,8 @@
plain: attrs.nsPopoverPlain,
trigger: attrs.nsPopoverTrigger || 'click',
container: attrs.nsPopoverContainer,
- placement: attrs.nsPopoverPlacement || 'bottom|left'
+ placement: attrs.nsPopoverPlacement || 'bottom|left',
+ timeout: attrs.nsPopoverTimeout || 1.5
};
var hider_ = {
@@ -46,7 +27,7 @@
* Set the display property of the popover to 'none' after |delay| milliseconds.
*
* @param popover {Object} The popover to set the display property.
- * @param delay {Number} The time (in milliseconds) to wait before set the display property.
+ * @param delay {Number} The time (in seconds) to wait before set the display property.
* @returns {Object|promise} A promise returned from the $timeout service that can be used
* to cancel the hiding operation.
*/
@@ -55,12 +36,12 @@
// delay the hiding operation for 1.5s by default.
if (!isDef(delay)) {
- delay = 1500;
+ delay = 1.5;
}
hider_.id_ = $timeout(function() {
popover.css('display', 'none');
- }, delay);
+ }, delay*1000);
},
cancel: function() {
@@ -160,12 +141,12 @@
});
elm.on('mouseout', function() {
- hider_.hide($popover);
+ hider_.hide($popover, options.timeout);
});
$popover
.on('mouseout', function(e) {
- hider_.hide($popover);
+ hider_.hide($popover, options.timeout);
})
.on('mouseover', function() {
hider_.cancel();