Skip to content

Commit

Permalink
Merge pull request #3 from virginiacommonwealthuniversity/release/1.3.1
Browse files Browse the repository at this point in the history
Release 1.3.1
  • Loading branch information
joeleisner authored Oct 13, 2016
2 parents e216cfa + 08cdb3f commit b16d031
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 26 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog
T4Utils 2 utilizes [GitHub's releases feature](https://github.com/blog/1547-release-your-software) for its changelogs, but this document serves as static duplicate of that content.

## [v1.3.1_2016.10.13 - Global Context Variables](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.3.1_2016.10.13)
Issues related to the `var context = content || null;` problem within page-layouts have been solved. Here's how:
* In page-layouts, the original way of calculating context errors out. The following logic works and will be utilized: `var context = typeof content == 'undefined' ? null : content;`
* All new `context`, `contextIsPage` and `contextIsContent` member variables have been added to the base `T4Utils` object
* This ensures that the context is defined globally at the start of the library
* The modules `brokerUtils`, `elementInfo` and `ordinalIndicators` now utilize these member variables in their logic

## [v1.3.0_2016.10.12 - Ordinal Indicators Failsafe](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.3.0_2016.10.12)
A new failsafe has been added to `ordinalIndicators` to allow for the entire library to be used within page layouts. Here's what's changed:
* All code within pageInfo/groupInfo has been wrapped in a conditional checking to see if the global variable `content` is undefined
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "t4-utils-2",
"version": "1.3.0",
"version": "1.3.1",
"description": "A Javascript Library of Utility Classes and Extensions for TerminalFour Programmable Layouts",
"main": "dist/8.4/T4Utils.min.js",
"author": "Joel Eisner <[email protected]>",
Expand Down
11 changes: 6 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ A Javascript library of utility classes and extensions for TerminalFour Programm

## Latest Version

## [v1.3.0_2016.10.12 - Ordinal Indicators Failsafe](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.3.0_2016.10.12)
A new failsafe has been added to `ordinalIndicators` to allow for the entire library to be used within page layouts. Here's what's changed:
* All code within pageInfo/groupInfo has been wrapped in a conditional checking to see if the global variable `content` is undefined
* If `content` is defined, the self-executing functions will run as expected
* If `content` is undefined, the self-executing functions will return objects with null key/value pairs
## [v1.3.1_2016.10.13 - Global Context Variables](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.3.1_2016.10.13)
Issues related to the `var context = content || null;` problem within page-layouts have been solved. Here's how:
* In page-layouts, the original way of calculating context errors out. The following logic works and will be utilized: `var context = typeof content == 'undefined' ? null : content;`
* All new `context`, `contextIsPage` and `contextIsContent` member variables have been added to the base `T4Utils` object
* This ensures that the context is defined globally at the start of the library
* The modules `brokerUtils`, `elementInfo` and `ordinalIndicators` now utilize these member variables in their logic

Check out the [changelog](changelog.md) for previous release information.

Expand Down
34 changes: 33 additions & 1 deletion src/modules/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* T4Utils
* @module
* @author Ben Margevicius <[email protected]>, Joel Eisner <[email protected]>
* @version 1.0.0
* @version 1.1.0
*/
var T4Utils = (function (utils) {

Expand Down Expand Up @@ -77,6 +77,38 @@ var T4Utils = (function (utils) {
}
};

/**
* Sets the context of where the library is being executed from (i.e. null if from within a page-layout, content if from within a content-type)
* @member context
* @return {?Object} context - Either null if the context is from within a page-layout, and the content variable if from withing a content-type
* T4Utils.context
*/
utils.context = (function () {
return typeof content == 'undefined' ? null : content;
})();

/**
* Boolean of whether the context of where the library is being executed from is within a page-layout
* @member contextIsPage
* @return {boolean} context - True if the library is executed within a page-layout, false if not
* @example
* T4Utils.contextIsPage
*/
utils.contextIsPage = (function () {
return typeof content == 'undefined' ? true : false;
})();

/**
* Boolean of whether the context of where the library is being executed from is within a content-type
* @member contextIsContent
* @return {boolean} context - True if the library is executed within a content-type, false if not
* @example
* T4Utils.contextIsContent
*/
utils.contextIsContent = (function () {
return typeof content == 'undefined' ? false : true;
})();

/**
* Writes a paragraph formatted HTML message to the browser
* @member write
Expand Down
7 changes: 3 additions & 4 deletions src/modules/brokerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* brokerUtils - The Broker Utilities Module
* @namespace brokerUtils
* @extends T4Utils
* @author Ben Margevicius <[email protected]>
* @version 1.0.0
* @author Ben Margevicius <[email protected]>, Joel Eisner <[email protected]>
* @version 1.1.0
* @example
* T4Utils.brokerUtils
*/
Expand All @@ -18,6 +18,5 @@ T4Utils.brokerUtils = T4Utils.brokerUtils || {};
* T4Utils.brokerUtils.processT4tag(string);
*/
T4Utils.brokerUtils.processT4Tag = function (t4Tag) {
var context = content || null;
return com.terminalfour.publish.utils.BrokerUtils.processT4Tags(dbStatement, publishCache, section, context, language, isPreview, t4Tag);
return com.terminalfour.publish.utils.BrokerUtils.processT4Tags(dbStatement, publishCache, section, T4Utils.context, language, isPreview, t4Tag);
};
22 changes: 9 additions & 13 deletions src/modules/elementInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* elementInfo - The Element Info Module
* @namespace elementInfo
* @extends T4Utils
* @author Ben Margevicius <[email protected]>
* @version 1.0.0
* @author Ben Margevicius <[email protected]>, Joel Eisner <[email protected]>
* @version 1.1.0
* @example
* T4Utils.elementInfo
*/
Expand All @@ -17,8 +17,7 @@ T4Utils.elementInfo = T4Utils.elementInfo || {};
* T4Utils.elementInfo.getElements();
*/
T4Utils.elementInfo.getElements = function () {
var context = content || null;
return context !== null ? context.getElements() : null ;
return T4Utils.contextIsContent ? content.getElements() : null ;
};

/**
Expand All @@ -30,9 +29,8 @@ T4Utils.elementInfo.getElements = function () {
* T4Utils.elementInfo.getElementValue(string);
*/
T4Utils.elementInfo.getElementValue = function (element) {
var context = content || null;
if (context !== null) {
var el = context.get(element);
if (T4Utils.contextIsContent) {
var el = content.get(element);
if (typeof el.publish === "function") {
return el.publish();
}
Expand All @@ -49,9 +47,8 @@ T4Utils.elementInfo.getElementValue = function (element) {
* T4Utils.elementInfo.getElementName(string);
*/
T4Utils.elementInfo.getElementName = function (element) {
var context = content || null;
if (context !== null) {
var el = context.get(element);
if (T4Utils.contextIsContent) {
var el = content.get(element);
if (typeof el.getName === "function") {
return c.get(element).getName();
}
Expand All @@ -68,9 +65,8 @@ T4Utils.elementInfo.getElementName = function (element) {
* T4Utils.elementInfo.getElementID(string);
*/
T4Utils.elementInfo.getElementID = function (element) {
var context = content || null;
if (context !== null) {
var el = context.get(element);
if (T4Utils.contextIsContent) {
var el = content.get(element);
if (typeof el.getID === "function") {
return c.getID();
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/ordinalIndicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ T4Utils.ordinalIndicators.pageInfo = (function() {
return array;
}
// If content is defined...
if (typeof content !== 'undefined') {
if (T4Utils.contextIsContent) {
// Grab all pieces of content on the page
var cL = com.terminalfour.sitemanager.cache.utils.CSHelper.extractCachedContent( /* Extract all cached content from the page where... */
com.terminalfour.sitemanager.cache.utils.CSHelper.removeSpecialContent( /* ... deleted content is ignored... */
Expand Down Expand Up @@ -152,7 +152,7 @@ T4Utils.ordinalIndicators.pageLast = T4Utils.ordinalIndicators.pageInfo.last;
*/
T4Utils.ordinalIndicators.groupInfo = (function() {
// If content is defined...
if (typeof content !== 'undefined') {
if (T4Utils.contextIsContent) {
var ctid = content.getContentTypeID(),
sid = section.getID(),
oCH = new ContentHierarchy(),
Expand Down

0 comments on commit b16d031

Please sign in to comment.