diff --git a/LICENSE.txt b/LICENSE.txt
index c6914d5..55ece0d 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2023 William Troup
+Copyright (c) 2024 William Troup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 9943d02..9c23a9b 100644
--- a/README.md
+++ b/README.md
@@ -2,15 +2,15 @@
Observe.js
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe)
-[![npm](https://img.shields.io/badge/npmjs-v0.5.1-blue)](https://www.npmjs.com/package/jobserve.js)
-[![nuget](https://img.shields.io/badge/nuget-v0.5.1-purple)](https://www.nuget.org/packages/jObserve.js/)
+[![npm](https://img.shields.io/badge/npmjs-v0.6.0-blue)](https://www.npmjs.com/package/jobserve.js)
+[![nuget](https://img.shields.io/badge/nuget-v0.6.0-purple)](https://www.nuget.org/packages/jObserve.js/)
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt)
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions)
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup)
>
A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.
->
v0.5.1
+>
v0.6.0
diff --git a/README_NUGET.md b/README_NUGET.md
index 8122dc4..5eceb85 100644
--- a/README_NUGET.md
+++ b/README_NUGET.md
@@ -1,8 +1,8 @@
-# Observe.js v0.5.1
+# Observe.js v0.6.0
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe)
-[![npm](https://img.shields.io/badge/npmjs-v0.5.1-blue)](https://www.npmjs.com/package/jobserve.js)
-[![nuget](https://img.shields.io/badge/nuget-v0.5.1-purple)](https://www.nuget.org/packages/jObserve.js/)
+[![npm](https://img.shields.io/badge/npmjs-v0.6.0-blue)](https://www.npmjs.com/package/jobserve.js)
+[![nuget](https://img.shields.io/badge/nuget-v0.6.0-purple)](https://www.nuget.org/packages/jObserve.js/)
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt)
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions)
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup)
diff --git a/dist/observe.js b/dist/observe.js
index 1c3c287..51dcb91 100644
--- a/dist/observe.js
+++ b/dist/observe.js
@@ -1,4 +1,4 @@
-/*! Observe.js v0.5.1 | (c) Bunoon | MIT License */
+/*! Observe.js v0.6.0 | (c) Bunoon 2024 | MIT License */
(function() {
function collectDOMObjects() {
var tagTypes = _configuration.domElementTypes;
@@ -149,7 +149,6 @@
}
}
function compareWatchObjectProperties(oldObject, newObject, watch) {
- var options = watch.options;
var propertyName;
for (propertyName in oldObject) {
if (oldObject.hasOwnProperty(propertyName)) {
@@ -159,11 +158,11 @@
propertyNewValue = newObject[propertyName];
}
if (isDefinedObject(propertyOldValue) && isDefinedObject(propertyNewValue)) {
- compareWatchObjectProperties(propertyOldValue, propertyNewValue, options);
+ compareWatchObjectProperties(propertyOldValue, propertyNewValue, watch.options);
} else {
if (!isDefinedArray(watch.options.propertyNames) || watch.options.propertyNames.indexOf(propertyName) > -1) {
if (JSON.stringify(propertyOldValue) !== JSON.stringify(propertyNewValue)) {
- fireCustomTrigger(options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue);
+ fireCustomTrigger(watch.options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue);
}
}
}
@@ -180,18 +179,23 @@
}
function cancelWatchObject(storageId) {
if (_watches.hasOwnProperty(storageId)) {
- fireCustomTrigger(_watches[storageId].options.onCancel, storageId);
- clearTimeout(_watches[storageId].timer);
- delete _watches[storageId];
+ var watchOptions = _watches[storageId].options;
+ if (watchOptions.allowCanceling || _watches_Cancel) {
+ fireCustomTrigger(watchOptions.onCancel, storageId);
+ clearTimeout(_watches[storageId].timer);
+ delete _watches[storageId];
+ }
}
}
function pauseWatchObject(storageId, milliseconds) {
var result = false;
if (_watches.hasOwnProperty(storageId)) {
var watchOptions = _watches[storageId].options;
- watchOptions.starts = new Date();
- watchOptions.starts.setMilliseconds(watchOptions.starts.getMilliseconds() + milliseconds);
- result = true;
+ if (watchOptions.allowPausing) {
+ watchOptions.starts = new Date();
+ watchOptions.starts.setMilliseconds(watchOptions.starts.getMilliseconds() + milliseconds);
+ result = true;
+ }
}
return result;
}
@@ -205,6 +209,8 @@
options.maximumChangesBeforeCanceling = getDefaultNumber(options.maximumChangesBeforeCanceling, 0);
options.pauseTimeoutOnChange = getDefaultNumber(options.pauseTimeoutOnChange, 0);
options.propertyNames = getDefaultArray(options.propertyNames, null);
+ options.allowCanceling = getDefaultBoolean(options.allowCanceling, true);
+ options.allowPausing = getDefaultBoolean(options.allowPausing, null);
options = getWatchOptionsCustomTriggers(options);
return options;
}
@@ -318,6 +324,7 @@
var _parameter_Window = null;
var _string = {empty:""};
var _watches = {};
+ var _watches_Cancel = false;
var _configuration = {};
var _attribute_Name_Watch_Options = "data-observe-watch-options";
this.watch = function(object, options) {
@@ -377,6 +384,15 @@
}
return result;
};
+ this.pauseWatches = function(milliseconds) {
+ var storageId;
+ for (storageId in _watches) {
+ if (_watches.hasOwnProperty(storageId)) {
+ pauseWatchObject(storageId, milliseconds);
+ }
+ }
+ return this;
+ };
this.resumeWatch = function(id) {
var result = false;
if (_watches.hasOwnProperty(id)) {
@@ -394,6 +410,15 @@
}
return result;
};
+ this.resumeWatches = function() {
+ var storageId;
+ for (storageId in _watches) {
+ if (_watches.hasOwnProperty(storageId)) {
+ _watches[storageId].options.starts = null;
+ }
+ }
+ return this;
+ };
this.searchDomForNewWatches = function() {
collectDOMObjects();
return this;
@@ -404,7 +429,7 @@
return this;
};
this.getVersion = function() {
- return "0.5.1";
+ return "0.6.0";
};
(function(documentObject, windowObject) {
_parameter_Document = documentObject;
@@ -414,6 +439,7 @@
collectDOMObjects();
});
_parameter_Window.addEventListener("unload", function() {
+ _watches_Cancel = true;
cancelWatchesForObjects();
});
if (!isDefined(_parameter_Window.$observe)) {
diff --git a/dist/observe.min.js b/dist/observe.min.js
index 44cd370..6d24f6c 100644
--- a/dist/observe.min.js
+++ b/dist/observe.min.js
@@ -1,12 +1,13 @@
-/*! Observe.js v0.5.1 | (c) Bunoon | MIT License */
-(function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=h.starts){if(d.hasOwnProperty(l)){var e=d[l],f=p(e.domElementId),
-m=null;f&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=B.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=f?n:JSON.stringify(n);if(v!==n){e.options.reset?f?m.outerHTML=e.cachedObject:e.originalObject=z(v).result:e.cachedObject=n;if(f)u(e.options.onChange,v,n);else if(f=z(v).result,m=z(n).result,w(f)||w(m))u(e.options.onChange,f,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n=e.options.maximumChangesBeforeCanceling&&x(l)}}A(h.expires)&&k>=h.expires&&x(l)}},h.timeout);d[g]=b}return g}function N(a,b,c){var g=c.options,h;for(h in a)if(a.hasOwnProperty(h)){var l=
-a[h],k=null;b.hasOwnProperty(h)&&(k=b[h]);t(l)&&t(k)?N(l,k,g):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(B.empty)}function r(a){return null!==a&&void 0!==a&&a!==B.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&&"string"===typeof a}function C(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function A(a){return t(a)&&
-a instanceof Date}function H(a,b){return r(a)&&"boolean"===typeof a?a:b}function D(a,b){return C(a)?a:b}function G(a,b){return r(a)&&"number"===typeof a?a:b}function z(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(g){try{c=eval("("+a+")"),C(c)&&(c=c())}catch(h){b=Q("Errors in object: "+g.message+", "+h.message),c=null}}return{parsed:b,result:c}}function Q(a){var b=!0;q.safeMode||(console.error(a),b=!1);return b}function P(){q.safeMode=H(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)?
-(b=b.split(B.space),0===b.length&&(b=c)):b=w(b)?b:c;a.domElementTypes=b}var y=null,E=null,B={empty:""},d={},q={};this.watch=function(a,b){return L(a,b)};this.cancelWatch=function(a){var b=!1;if(d.hasOwnProperty(a))x(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){x(c);b=!0;break}return b};this.cancelWatches=function(){O();return this};this.getWatch=function(a){var b=null;if(d.hasOwnProperty(a))b=d[a];else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&
-d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=F(a,b);else for(var g in d)if(d.hasOwnProperty(g)&&p(d[g].domElementId)&&d[g].domElementId===a){c=F(g,b);break}return c};this.resumeWatch=function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.searchDomForNewWatches=
-function(){I();return this};this.setConfiguration=function(a){q=t(a)?a:{};P();return this};this.getVersion=function(){return"0.5.1"};(function(a,b){y=a;E=b;P();y.addEventListener("DOMContentLoaded",function(){I()});E.addEventListener("unload",function(){O()});r(E.$observe)||(E.$observe=this)})(document,window)})();
\ No newline at end of file
+/*! Observe.js v0.6.0 | (c) Bunoon 2024 | MIT License */
+(function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=k.starts){if(d.hasOwnProperty(h)){var e=d[h],g=p(e.domElementId),
+m=null;g&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=C.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=g?n:JSON.stringify(n);if(v!==n){e.options.reset?g?m.outerHTML=e.cachedObject:e.originalObject=A(v).result:e.cachedObject=n;if(g)u(e.options.onChange,v,n);else if(g=A(v).result,m=A(n).result,w(g)||w(m))u(e.options.onChange,g,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n=e.options.maximumChangesBeforeCanceling&&x(h)}}B(k.expires)&&l>=k.expires&&x(h)}},k.timeout);d[f]=b}return f}function N(a,b,c){for(var f in a)if(a.hasOwnProperty(f)){var k=a[f],
+h=null;b.hasOwnProperty(f)&&(h=b[f]);t(k)&&t(h)?N(k,h,c.options):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(C.empty)}function r(a){return null!==a&&void 0!==a&&a!==C.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&&
+"string"===typeof a}function D(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function B(a){return t(a)&&a instanceof Date}function z(a,b){return r(a)&&"boolean"===typeof a?a:b}function F(a,b){return D(a)?a:b}function H(a,b){return r(a)&&"number"===typeof a?a:b}function A(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(f){try{c=eval("("+a+")"),D(c)&&(c=c())}catch(k){b=R("Errors in object: "+f.message+", "+k.message),c=null}}return{parsed:b,result:c}}function R(a){var b=
+!0;q.safeMode||(console.error(a),b=!1);return b}function Q(){q.safeMode=z(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)?(b=b.split(C.space),0===b.length&&(b=c)):b=w(b)?b:c;a.domElementTypes=b}var y=null,G=null,C={empty:""},d={},P=!1,q={};this.watch=function(a,b){return L(a,b)};this.cancelWatch=function(a){var b=!1;if(d.hasOwnProperty(a))x(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){x(c);b=!0;break}return b};this.cancelWatches=function(){O();
+return this};this.getWatch=function(a){var b=null;if(d.hasOwnProperty(a))b=d[a];else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=E(a,b);else for(var f in d)if(d.hasOwnProperty(f)&&p(d[f].domElementId)&&d[f].domElementId===a){c=E(f,b);break}return c};this.pauseWatches=function(a){for(var b in d)d.hasOwnProperty(b)&&E(b,a);return this};this.resumeWatch=
+function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.resumeWatches=function(){for(var a in d)d.hasOwnProperty(a)&&(d[a].options.starts=null);return this};this.searchDomForNewWatches=function(){I();return this};this.setConfiguration=function(a){q=t(a)?a:{};Q();return this};this.getVersion=function(){return"0.6.0"};(function(a,b){y=a;G=b;Q();
+y.addEventListener("DOMContentLoaded",function(){I()});G.addEventListener("unload",function(){P=!0;O()});r(G.$observe)||(G.$observe=this)})(document,window)})();
\ No newline at end of file
diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md
index 0762dc0..42aaec2 100644
--- a/docs/CHANGE_LOG.md
+++ b/docs/CHANGE_LOG.md
@@ -1,5 +1,24 @@
# Observe.js - Change Log:
+## Version 0.6.0:
+
+#### **Binding Options / Function Options:**
+- Added a new binding/option called "allowCanceling", which states the watch can be cancelled (defaults to true).
+- Added a new binding/option called "allowPausing", which states the watch can be paused (defaults to true).
+
+#### **Public Functions:**
+- Added new public function "pauseWatches()", which is used to pause all the watches for a specific number of milliseconds.
+- Added new public function "resumeWatches()", which is used to resume all the watches currently paused.
+
+#### **General Improvements:**
+- Minor internal refactoring to make things a little clearer.
+
+#### **Fixes:**
+- Fixed some errors in HTML files when calling the public functions.
+
+
+
+
## Version 0.5.1:
- Project description update.
- Minor documentation updates.
diff --git a/docs/PUBLIC_FUNCTIONS.md b/docs/PUBLIC_FUNCTIONS.md
index 9b0fc67..4ad7478 100644
--- a/docs/PUBLIC_FUNCTIONS.md
+++ b/docs/PUBLIC_FUNCTIONS.md
@@ -55,12 +55,26 @@ Pauses the watching of an object for changes for a specific number of millisecon
***Returns***: '*boolean*' - States if the object being watched has been paused.
+### **pauseWatches( *milliseconds* )**:
+Pauses all the watches for a specific number of milliseconds.
+
+***Parameter: milliseconds***: '*number*' - The milliseconds to pause the watches for.
+
+***Returns***: '*Object*' - The Observe.js class instance.
+
+
### **resumeWatch( *id* )**:
-Resumes the watching of an object for changes after it was paused.
+Resumes all the watches that are currently paused.
***Parameter: id***: '*string*' - The ID of the object being watched, or DOM element ID being watched.
-***Returns***: '*boolean*' - States if the watching of an object has been resumed
+***Returns***: '*boolean*' - States if the watching of an object has been resumed.
+
+
+### **resumeWatches()**:
+Resumes the watching of all objects for changes after they were paused.
+
+***Returns***: '*Object*' - The Observe.js class instance.
### **searchDomForNewWatches()**:
diff --git a/docs/binding/options/OPTIONS.md b/docs/binding/options/OPTIONS.md
index a5daa73..2b384cc 100644
--- a/docs/binding/options/OPTIONS.md
+++ b/docs/binding/options/OPTIONS.md
@@ -17,6 +17,8 @@ Below is a list of all the options supported in the "data-observe-watch-options"
| *number* | maximumChangesBeforeCanceling | States the total number of changes that are allowed before the watch is cancelled (defaults to 0, which is off) |
| *number* | pauseTimeoutOnChange | States the delay (in milliseconds) that should be used before checking for changes again after a change is detected (defaults to 0, which is off) |
| *string[]* | propertyNames | States the property names that should be watched for changes (defaults to all). |
+| *boolean* | allowCanceling | States if the watch can be cancelled (defaults to true). |
+| *boolean* | allowPausing | States if the watch can be paused (defaults to true). |
diff --git a/observe.js.nuspec b/observe.js.nuspec
index 772b0f9..c890b7d 100644
--- a/observe.js.nuspec
+++ b/observe.js.nuspec
@@ -2,7 +2,7 @@
jObserve.js
- 0.5.1
+ 0.6.0Observe.jsA lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.William Troup
diff --git a/package.json b/package.json
index ffee6bc..526a5a1 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "jobserve.js",
"title": "Observe.js",
"description": "A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.",
- "version": "0.5.1",
+ "version": "0.6.0",
"main": "dist/observe.js",
"author": {
"name": "Bunoon"
diff --git a/src/observe.js b/src/observe.js
index 6d1a3c3..105f35d 100644
--- a/src/observe.js
+++ b/src/observe.js
@@ -4,10 +4,10 @@
* A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.
*
* @file observe.js
- * @version v0.5.1
+ * @version v0.6.0
* @author Bunoon
* @license MIT License
- * @copyright Bunoon 2023
+ * @copyright Bunoon 2024
*/
@@ -23,6 +23,7 @@
// Variables: Watches
_watches = {},
+ _watches_Cancel = false,
// Variables: Configuration
_configuration = {},
@@ -236,8 +237,6 @@
}
function compareWatchObjectProperties( oldObject, newObject, watch ) {
- var options = watch.options;
-
for ( var propertyName in oldObject ) {
if ( oldObject.hasOwnProperty( propertyName ) ) {
var propertyOldValue = oldObject[ propertyName ],
@@ -248,12 +247,12 @@
}
if ( isDefinedObject( propertyOldValue ) && isDefinedObject( propertyNewValue ) ) {
- compareWatchObjectProperties( propertyOldValue, propertyNewValue, options );
+ compareWatchObjectProperties( propertyOldValue, propertyNewValue, watch.options );
} else {
if ( !isDefinedArray( watch.options.propertyNames ) || watch.options.propertyNames.indexOf( propertyName ) > -1 ) {
if ( JSON.stringify( propertyOldValue ) !== JSON.stringify( propertyNewValue ) ) {
- fireCustomTrigger( options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue );
+ fireCustomTrigger( watch.options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue );
}
}
}
@@ -271,10 +270,14 @@
function cancelWatchObject( storageId ) {
if ( _watches.hasOwnProperty( storageId ) ) {
- fireCustomTrigger( _watches[ storageId ].options.onCancel, storageId );
- clearTimeout( _watches[ storageId ].timer );
-
- delete _watches[ storageId ];
+ var watchOptions = _watches[ storageId ].options;
+
+ if ( watchOptions.allowCanceling || _watches_Cancel ) {
+ fireCustomTrigger( watchOptions.onCancel, storageId );
+ clearTimeout( _watches[ storageId ].timer );
+
+ delete _watches[ storageId ];
+ }
}
}
@@ -284,10 +287,12 @@
if ( _watches.hasOwnProperty( storageId ) ) {
var watchOptions = _watches[ storageId ].options;
- watchOptions.starts = new Date();
- watchOptions.starts.setMilliseconds( watchOptions.starts.getMilliseconds() + milliseconds );
-
- result = true;
+ if ( watchOptions.allowPausing ) {
+ watchOptions.starts = new Date();
+ watchOptions.starts.setMilliseconds( watchOptions.starts.getMilliseconds() + milliseconds );
+
+ result = true;
+ }
}
return result;
@@ -311,7 +316,9 @@
options.maximumChangesBeforeCanceling = getDefaultNumber( options.maximumChangesBeforeCanceling, 0 );
options.pauseTimeoutOnChange = getDefaultNumber( options.pauseTimeoutOnChange, 0 );
options.propertyNames = getDefaultArray( options.propertyNames, null );
-
+ options.allowCanceling = getDefaultBoolean( options.allowCanceling, true );
+ options.allowPausing = getDefaultBoolean( options.allowPausing, null );
+
options = getWatchOptionsCustomTriggers( options );
return options;
@@ -626,6 +633,27 @@
return result;
};
+ /**
+ * pauseWatches().
+ *
+ * Pauses all the watches for a specific number of milliseconds.
+ *
+ * @public
+ *
+ * @param {number} milliseconds The milliseconds to pause the watches for.
+ *
+ * @returns {Object} The Observe.js class instance.
+ */
+ this.pauseWatches = function( milliseconds ) {
+ for ( var storageId in _watches ) {
+ if ( _watches.hasOwnProperty( storageId ) ) {
+ pauseWatchObject( storageId, milliseconds );
+ }
+ }
+
+ return this;
+ };
+
/**
* resumeWatch().
*
@@ -657,6 +685,25 @@
return result;
};
+ /**
+ * resumeWatches().
+ *
+ * Resumes all the watches that are currently paused.
+ *
+ * @public
+ *
+ * @returns {Object} The Observe.js class instance.
+ */
+ this.resumeWatches = function() {
+ for ( var storageId in _watches ) {
+ if ( _watches.hasOwnProperty( storageId ) ) {
+ _watches[ storageId ].options.starts = null;
+ }
+ }
+
+ return this;
+ };
+
/**
* searchDomForNewWatches().
*
@@ -720,7 +767,7 @@
* @returns {string} The version number.
*/
this.getVersion = function() {
- return "0.5.1";
+ return "0.6.0";
};
@@ -741,6 +788,8 @@
} );
_parameter_Window.addEventListener( "unload", function() {
+ _watches_Cancel = true;
+
cancelWatchesForObjects();
} );
diff --git a/test/dist/observe.js.basic.html b/test/dist/observe.js.basic.html
index cc29493..7ae5658 100644
--- a/test/dist/observe.js.basic.html
+++ b/test/dist/observe.js.basic.html
@@ -43,11 +43,19 @@