Skip to content

Commit

Permalink
Merge pull request #10 from williamtroup/0.8.0
Browse files Browse the repository at this point in the history
0.8.0
  • Loading branch information
William Troup authored Mar 14, 2024
2 parents 53eb28e + ee998de commit 1849eae
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 87 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.7.1-blue)](https://www.npmjs.com/package/jobserve.js)
[![nuget](https://img.shields.io/badge/nuget-v0.7.1-purple)](https://www.nuget.org/packages/jObserve.js/)
[![npm](https://img.shields.io/badge/npmjs-v0.8.0-blue)](https://www.npmjs.com/package/jobserve.js)
[![nuget](https://img.shields.io/badge/nuget-v0.8.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://www.william-troup.com/)
</h1>

> <p align="center">A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.</p>
> <p align="center">v0.7.1</p>
> <p align="center">v0.8.0</p>
<br />
<br>
Expand Down
6 changes: 3 additions & 3 deletions README_NUGET.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Observe.js v0.7.1
# Observe.js v0.8.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.7.1-blue)](https://www.npmjs.com/package/jobserve.js)
[![nuget](https://img.shields.io/badge/nuget-v0.7.1-purple)](https://www.nuget.org/packages/jObserve.js/)
[![npm](https://img.shields.io/badge/npmjs-v0.8.0-blue)](https://www.npmjs.com/package/jobserve.js)
[![nuget](https://img.shields.io/badge/nuget-v0.8.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://www.william-troup.com/)
Expand Down
41 changes: 26 additions & 15 deletions dist/observe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Observe.js v0.7.1 | (c) Bunoon 2024 | MIT License */
/*! Observe.js v0.8.0 | (c) Bunoon 2024 | MIT License */
(function() {
function collectDOMObjects() {
var tagTypes = _configuration.domElementTypes;
Expand Down Expand Up @@ -27,19 +27,17 @@
if (!isDefinedString(element.id)) {
element.id = newGuid();
}
element.removeAttribute(_attribute_Name_Watch_Options);
if (bindingOptions.removeAttribute) {
element.removeAttribute(_attribute_Name_Watch_Options);
}
createWatch(element, bindingOptions, element.id);
} else {
if (!_configuration.safeMode) {
console.error("The attribute '" + _attribute_Name_Watch_Options + "' is not a valid object.");
result = false;
}
}
} else {
if (!_configuration.safeMode) {
console.error("The attribute '" + _attribute_Name_Watch_Options + "' has not been set correctly.");
logError(_configuration.attributeNotValidErrorText.replace("{{attribute_name}}", _attribute_Name_Watch_Options));
result = false;
}
} else {
logError(_configuration.attributeNotSetErrorText.replace("{{attribute_name}}", _attribute_Name_Watch_Options));
result = false;
}
}
return result;
Expand Down Expand Up @@ -206,7 +204,7 @@
return result;
}
function getWatchOptions(newOptions) {
var options = !isDefinedObject(newOptions) ? {} : newOptions;
var options = getDefaultObject(newOptions, {});
options.timeout = getDefaultNumber(options.timeout, 250);
options.starts = getDefaultDate(options.starts, null);
options.expires = getDefaultDate(options.expires, null);
Expand All @@ -217,6 +215,7 @@
options.propertyNames = getDefaultArray(options.propertyNames, null);
options.allowCanceling = getDefaultBoolean(options.allowCanceling, true);
options.allowPausing = getDefaultBoolean(options.allowPausing, true);
options.removeAttribute = getDefaultBoolean(options.removeAttribute, true);
options = getWatchOptionsCustomTriggers(options);
return options;
}
Expand Down Expand Up @@ -278,12 +277,18 @@
function getDefaultNumber(value, defaultValue) {
return isDefinedNumber(value) ? value : defaultValue;
}
function getDefaultString(value, defaultValue) {
return isDefinedString(value) ? value : defaultValue;
}
function getDefaultDate(value, defaultValue) {
return isDefinedDate(value) ? value : defaultValue;
}
function getDefaultArray(value, defaultValue) {
return isDefinedArray(value) ? value : defaultValue;
}
function getDefaultObject(value, defaultValue) {
return isDefinedObject(value) ? value : defaultValue;
}
function getDefaultStringOrArray(value, defaultValue) {
if (isDefinedString(value)) {
value = value.split(_string.space);
Expand All @@ -309,7 +314,7 @@
result = result();
}
} catch (e2) {
parsed = logError("Errors in object: " + e1.message + ", " + e2.message);
parsed = logError(_configuration.objectErrorText.replace("{{error_1}}", e1.message).replace("{{error_2}}", e2.message));
result = null;
}
}
Expand All @@ -326,6 +331,12 @@
function buildDefaultConfiguration() {
_configuration.safeMode = getDefaultBoolean(_configuration.safeMode, true);
_configuration.domElementTypes = getDefaultStringOrArray(_configuration.domElementTypes, ["*"]);
buildDefaultConfigurationStrings();
}
function buildDefaultConfigurationStrings() {
_configuration.objectErrorText = getDefaultString(_configuration.objectErrorText, "Errors in object: {{error_1}}, {{error_2}}");
_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.");
}
var _parameter_Document = null;
var _parameter_Window = null;
Expand Down Expand Up @@ -432,13 +443,13 @@
collectDOMObjects();
return this;
};
this.setConfiguration = function(newOptions) {
_configuration = !isDefinedObject(newOptions) ? {} : newOptions;
this.setConfiguration = function(newConfiguration) {
_configuration = getDefaultObject(newConfiguration, {});
buildDefaultConfiguration();
return this;
};
this.getVersion = function() {
return "0.7.1";
return "0.8.0";
};
(function(documentObject, windowObject, mathObject, jsonObject) {
_parameter_Document = documentObject;
Expand Down
27 changes: 14 additions & 13 deletions dist/observe.min.js

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

Loading

0 comments on commit 1849eae

Please sign in to comment.