Skip to content

Commit

Permalink
Added "use strict" support internally and updated all public function…
Browse files Browse the repository at this point in the history
…s to use the new scope.
  • Loading branch information
williamtroup committed Mar 19, 2024
1 parent 7d48ef6 commit ed17fb5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 50 deletions.
38 changes: 19 additions & 19 deletions dist/observe.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Observe.js v0.8.1 | (c) Bunoon 2024 | MIT License */
(function() {
var _parameter_Document = null, _parameter_Window = null, _parameter_Math = null, _parameter_Json = null, _string = {empty:""}, _watches = {}, _watches_Cancel = false, _configuration = {}, _attribute_Name_Watch_Options = "data-observe-watch-options";
var _parameter_Document = null, _parameter_Window = null, _parameter_Math = null, _parameter_Json = null, _public = {}, _string = {empty:""}, _watches = {}, _watches_Cancel = false, _configuration = {}, _attribute_Name_Watch_Options = "data-observe-watch-options";
function collectDOMObjects() {
var tagTypes = _configuration.domElementTypes, tagTypesLength = tagTypes.length;
for (var tagTypeIndex = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++) {
Expand Down Expand Up @@ -311,10 +311,10 @@
}
return result;
}
this.watch = function(object, options) {
_public.watch = function(object, options) {
return createWatch(object, options);
};
this.cancelWatch = function(id) {
_public.cancelWatch = function(id) {
var result = false;
if (isDefinedString(id)) {
if (_watches.hasOwnProperty(id)) {
Expand All @@ -332,11 +332,11 @@
}
return result;
};
this.cancelWatches = function() {
_public.cancelWatches = function() {
cancelWatchesForObjects();
return this;
return _public;
};
this.getWatch = function(id) {
_public.getWatch = function(id) {
var result = null;
if (isDefinedString(id)) {
if (_watches.hasOwnProperty(id)) {
Expand All @@ -352,10 +352,10 @@
}
return result;
};
this.getWatches = function() {
_public.getWatches = function() {
return _watches;
};
this.pauseWatch = function(id, milliseconds) {
_public.pauseWatch = function(id, milliseconds) {
var result = false;
if (isDefinedString(id) && isDefinedNumber(milliseconds)) {
if (_watches.hasOwnProperty(id)) {
Expand All @@ -371,17 +371,17 @@
}
return result;
};
this.pauseWatches = function(milliseconds) {
_public.pauseWatches = function(milliseconds) {
if (isDefinedNumber(milliseconds)) {
for (var storageId in _watches) {
if (_watches.hasOwnProperty(storageId)) {
pauseWatchObject(storageId, milliseconds);
}
}
}
return this;
return _public;
};
this.resumeWatch = function(id) {
_public.resumeWatch = function(id) {
var result = false;
if (isDefinedString(id)) {
if (_watches.hasOwnProperty(id)) {
Expand All @@ -399,19 +399,19 @@
}
return result;
};
this.resumeWatches = function() {
_public.resumeWatches = function() {
for (var storageId in _watches) {
if (_watches.hasOwnProperty(storageId)) {
_watches[storageId].options.starts = null;
}
}
return this;
return _public;
};
this.searchDomForNewWatches = function() {
_public.searchDomForNewWatches = function() {
collectDOMObjects();
return this;
return _public;
};
this.setConfiguration = function(newConfiguration) {
_public.setConfiguration = function(newConfiguration) {
if (isDefinedObject(newConfiguration)) {
var configurationHasChanged = false;
for (var propertyName in newConfiguration) {
Expand All @@ -424,7 +424,7 @@
buildDefaultConfiguration(_configuration);
}
}
return this;
return _public;
};
function buildDefaultConfiguration(newConfiguration) {
_configuration = !isDefinedObject(newConfiguration) ? {} : newConfiguration;
Expand All @@ -437,7 +437,7 @@
_configuration.attributeNotValidErrorText = getDefaultString(_configuration.attributeNotValidErrorText, "The attribute '{{attribute_name}}' is not a valid object.");
_configuration.attributeNotSetErrorText = getDefaultString(_configuration.attributeNotSetErrorText, "The attribute '{{attribute_name}}' has not been set correctly.");
}
this.getVersion = function() {
_public.getVersion = function() {
return "0.8.1";
};
(function(documentObject, windowObject, mathObject, jsonObject) {
Expand All @@ -454,7 +454,7 @@
cancelWatchesForObjects();
});
if (!isDefined(_parameter_Window.$observe)) {
_parameter_Window.$observe = this;
_parameter_Window.$observe = _public;
}
})(document, window, Math, JSON);
})();
26 changes: 13 additions & 13 deletions dist/observe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/CHANGE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- The "unload" window event has been replaced with "pagehide" (due to "unload" being deprecated).
- The public function "setConfiguration()" will now only update the configuration if something in the configuration has been changed.
- All public functions now only accept the right variable types for data (to prevent issues from occurring).
- Added "use strict" support internally and updated all public functions to use the new scope.

<br>

Expand Down
Loading

0 comments on commit ed17fb5

Please sign in to comment.