[Bps-public-commit] rt-extension-inlinehelp branch master updated. fc3ad68af85dd85cface9d5b6239aac23d5ded5b

BPS Git Server git at git.bestpractical.com
Tue Oct 12 19:35:21 UTC 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-inlinehelp".

The branch, master has been updated
       via  fc3ad68af85dd85cface9d5b6239aac23d5ded5b (commit)
       via  94f6cab1ba869c1332a21116dbeed0bd44b00b98 (commit)
       via  0900e71a1f6c5ee3f1030392e7019046cc401c8e (commit)
      from  dc6985014107967ffe79724ff206fa8bcce7f30a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fc3ad68af85dd85cface9d5b6239aac23d5ded5b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Oct 13 03:15:16 2021 +0800

    Avoid errors caused by calling ->Id on undefined

diff --git a/html/Helpers/HelpTopic b/html/Helpers/HelpTopic
index e383878..04ccc79 100644
--- a/html/Helpers/HelpTopic
+++ b/html/Helpers/HelpTopic
@@ -57,9 +57,13 @@ my %result;
 if ($title) {
     my $lh = $session{'CurrentUser'}->LanguageHandle;
     my @locs = ( $lh->language_tag(), $lh->fallback_languages() );
-    my $help_class = GetInlineHelpClass( \@locs );
-    $result{content} = GetHelpArticleContent( $help_class->Id, $title ) || "<div class='text-danger'>No help was found for '$title'.</div>";
-    $result{title} = GetHelpArticleTitle( $help_class->id, $title ) || $title;
+    if ( my $help_class = GetInlineHelpClass( \@locs ) ) {
+        $result{content} = GetHelpArticleContent( $help_class->Id, $title );
+        $result{title} = GetHelpArticleTitle( $help_class->id, $title );
+    }
+
+    $result{content} ||= "<div class='text-danger'>No help was found for '$title'.</div>";
+    $result{title} ||= $title;
 }
 
 $m->out( JSON( \%result ) );
commit 94f6cab1ba869c1332a21116dbeed0bd44b00b98
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Oct 13 01:47:55 2021 +0800

    Convert tabs to whitespaces

diff --git a/static/js/inlinehelp.js b/static/js/inlinehelp.js
index 8d84df4..0f3a503 100644
--- a/static/js/inlinehelp.js
+++ b/static/js/inlinehelp.js
@@ -1,121 +1,121 @@
 // a list of entries to process for the page
 var pagePopupHelpItems = [
-	{ selector: "[data-help]", action: helpify }  // by default, anything with data-help attributes gets processed
+    { selector: "[data-help]", action: helpify }  // by default, anything with data-help attributes gets processed
 ];
 
 // add one or more items to the list of help entries to process for the page
 function addPopupHelpItems() {
-	const args = [].slice.call(arguments).reduce(function(acc,val) { return acc.concat(val) }, [] );
-	pagePopupHelpItems = pagePopupHelpItems || [];
-	pagePopupHelpItems = pagePopupHelpItems.concat(args);
+    const args = [].slice.call(arguments).reduce(function(acc,val) { return acc.concat(val) }, [] );
+    pagePopupHelpItems = pagePopupHelpItems || [];
+    pagePopupHelpItems = pagePopupHelpItems.concat(args);
 }
 
 function applySelectorQueryOrFunc( sel ) {
-	if ( sel ) {
-		if ( typeof(sel) === "string" ) {
-			return jQuery(sel);
-		} else if ( typeof(sel) === "function" ) {
-			return sel(jQuery);
-		}
-	}
+    if ( sel ) {
+        if ( typeof(sel) === "string" ) {
+            return jQuery(sel);
+        } else if ( typeof(sel) === "function" ) {
+            return sel(jQuery);
+        }
+    }
 }
 
 function getPopupHelpAction( entry={} ) {
-	entry.action = entry.action || "append"
-	if ( typeof(entry.action) === "string" ) {
-		const funcMap = {
-			"before": beforePopupHelp,
-			"after": afterPopupHelp,
-			"append": appendPopupHelp,
-			"prepend": prependPopupHelp,
-			"offset": offsetPopupHelp,
-			"replace": replacePopupHelp
-		}
-		if (funcMap.hasOwnProperty(entry.action)) {
-			return funcMap[entry.action];
-		} else {
-			console.error("Unknown action '" + entry.action + "' using 'after' instead");
-			return funcMap.after;
-		}
-	} else if ( typeof(entry.action) === "function" ) {
-		return entry.action;
-	}
+    entry.action = entry.action || "append"
+    if ( typeof(entry.action) === "string" ) {
+        const funcMap = {
+            "before": beforePopupHelp,
+            "after": afterPopupHelp,
+            "append": appendPopupHelp,
+            "prepend": prependPopupHelp,
+            "offset": offsetPopupHelp,
+            "replace": replacePopupHelp
+        }
+        if (funcMap.hasOwnProperty(entry.action)) {
+            return funcMap[entry.action];
+        } else {
+            console.error("Unknown action '" + entry.action + "' using 'after' instead");
+            return funcMap.after;
+        }
+    } else if ( typeof(entry.action) === "function" ) {
+        return entry.action;
+    }
 }
 
 function getPopupHelpActionArgs( entry={}, $els ) {
-	return entry.actionArgs ? [ $els, entry, entry.actionArgs ] : [ $els, entry ];
+    return entry.actionArgs ? [ $els, entry, entry.actionArgs ] : [ $els, entry ];
 }
 
 function beforePopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "before";
-	return helpify( $els, item, options );
+    item.action = options.action = "before";
+    return helpify( $els, item, options );
 }
 
 function afterPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "after";
-	return helpify( $els, item, options );
+    item.action = options.action = "after";
+    return helpify( $els, item, options );
 }
 
 function appendPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "append";
-	return helpify( $els, item, options );
+    item.action = options.action = "append";
+    return helpify( $els, item, options );
 }
 
 function prependPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "prepend";
-	return helpify( $els, item, options );
+    item.action = options.action = "prepend";
+    return helpify( $els, item, options );
 }
 
 function offsetPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "offset";
-	return helpify( $els, item, options );
+    item.action = options.action = "offset";
+    return helpify( $els, item, options );
 }
 
 function replacePopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "replace";
-	return helpify( $els, item, options );
+    item.action = options.action = "replace";
+    return helpify( $els, item, options );
 }
 
 function helpify($els, item={}, options={}) {
-	$els.each(function(index) {
-		const $el = jQuery($els.get(index));
-		const action = $el.data("action") || item.action || options.action;
-		const title = $el.data("title") || item.title || $el.data("help");
-		const content = $el.data("content") || item.content;
-		switch(action) {
-			case "before":
-				$el.before( buildPopupHelpHtml( title, content ) );
-				break;
-			case "prepend":
-				$el.prepend( buildPopupHelpHtml( title, content ) );
-				break;
-			case "offset":
-				$el.append( buildPopupHelpHtml( title, content ) ).offset( options );
-				break;
-			case "replace":
-				$el.replaceWith( buildPopupHelpHtml( title, content ) );
-				break;
-			case "append":
-				$el.append( buildPopupHelpHtml( title, content ) );
-				break;
-			case "after":  // intentionally fallthrough, as 'after' is the default
-			default:
-				$el.parent().append( buildPopupHelpHtml( title, content ) );
-		}
-	})
+    $els.each(function(index) {
+        const $el = jQuery($els.get(index));
+        const action = $el.data("action") || item.action || options.action;
+        const title = $el.data("title") || item.title || $el.data("help");
+        const content = $el.data("content") || item.content;
+        switch(action) {
+            case "before":
+                $el.before( buildPopupHelpHtml( title, content ) );
+                break;
+            case "prepend":
+                $el.prepend( buildPopupHelpHtml( title, content ) );
+                break;
+            case "offset":
+                $el.append( buildPopupHelpHtml( title, content ) ).offset( options );
+                break;
+            case "replace":
+                $el.replaceWith( buildPopupHelpHtml( title, content ) );
+                break;
+            case "append":
+                $el.append( buildPopupHelpHtml( title, content ) );
+                break;
+            case "after":  // intentionally fallthrough, as 'after' is the default
+            default:
+                $el.parent().append( buildPopupHelpHtml( title, content ) );
+        }
+    })
 }
 
 function buildPopupHelpHtml(title, content) {
-	const contentAttr = content ? ' data-content="' + content + '" ' : '';
-	return '<a class="popup-help" tabindex="0" role="button" data-toggle="popover" title="' + title + '" data-trigger="hover" ' + contentAttr + '><span class="far fa-question-circle fa-lg"></span></a>';
+    const contentAttr = content ? ' data-content="' + content + '" ' : '';
+    return '<a class="popup-help" tabindex="0" role="button" data-toggle="popover" title="' + title + '" data-trigger="hover" ' + contentAttr + '><span class="far fa-question-circle fa-lg"></span></a>';
 }
 
 function applyPopupHelpAction( entry, $els ) {
-	if ( entry ) {
-		const fn = getPopupHelpAction( entry );
-		const args = getPopupHelpActionArgs( entry, $els );
-		fn.apply(this, args);
-	}
+    if ( entry ) {
+        const fn = getPopupHelpAction( entry );
+        const args = getPopupHelpActionArgs( entry, $els );
+        fn.apply(this, args);
+    }
 }
 
 // Dynamically load the help topic corresponding to a DOM element using AJAX
commit 0900e71a1f6c5ee3f1030392e7019046cc401c8e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Oct 13 01:43:57 2021 +0800

    Add semicolons to make statement ends more clear instead of depending on ASI

diff --git a/static/js/inlinehelp.js b/static/js/inlinehelp.js
index e76b721..8d84df4 100644
--- a/static/js/inlinehelp.js
+++ b/static/js/inlinehelp.js
@@ -1,21 +1,21 @@
 // a list of entries to process for the page
 var pagePopupHelpItems = [
 	{ selector: "[data-help]", action: helpify }  // by default, anything with data-help attributes gets processed
-]
+];
 
 // add one or more items to the list of help entries to process for the page
 function addPopupHelpItems() {
-	const args = [].slice.call(arguments).reduce(function(acc,val) { return acc.concat(val) }, [] )
-	pagePopupHelpItems = pagePopupHelpItems || []
-	pagePopupHelpItems = pagePopupHelpItems.concat(args)
+	const args = [].slice.call(arguments).reduce(function(acc,val) { return acc.concat(val) }, [] );
+	pagePopupHelpItems = pagePopupHelpItems || [];
+	pagePopupHelpItems = pagePopupHelpItems.concat(args);
 }
 
 function applySelectorQueryOrFunc( sel ) {
 	if ( sel ) {
 		if ( typeof(sel) === "string" ) {
-			return jQuery(sel)
+			return jQuery(sel);
 		} else if ( typeof(sel) === "function" ) {
-			return sel(jQuery)
+			return sel(jQuery);
 		}
 	}
 }
@@ -32,89 +32,89 @@ function getPopupHelpAction( entry={} ) {
 			"replace": replacePopupHelp
 		}
 		if (funcMap.hasOwnProperty(entry.action)) {
-			return funcMap[entry.action]
+			return funcMap[entry.action];
 		} else {
-			console.error("Unknown action '" + entry.action + "' using 'after' instead")
-			return funcMap.after
+			console.error("Unknown action '" + entry.action + "' using 'after' instead");
+			return funcMap.after;
 		}
 	} else if ( typeof(entry.action) === "function" ) {
-		return entry.action
+		return entry.action;
 	}
 }
 
 function getPopupHelpActionArgs( entry={}, $els ) {
-	return entry.actionArgs ? [ $els, entry, entry.actionArgs ] : [ $els, entry ]
+	return entry.actionArgs ? [ $els, entry, entry.actionArgs ] : [ $els, entry ];
 }
 
 function beforePopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "before"
-	return helpify( $els, item, options )
+	item.action = options.action = "before";
+	return helpify( $els, item, options );
 }
 
 function afterPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "after"
-	return helpify( $els, item, options )
+	item.action = options.action = "after";
+	return helpify( $els, item, options );
 }
 
 function appendPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "append"
-	return helpify( $els, item, options )
+	item.action = options.action = "append";
+	return helpify( $els, item, options );
 }
 
 function prependPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "prepend"
-	return helpify( $els, item, options )
+	item.action = options.action = "prepend";
+	return helpify( $els, item, options );
 }
 
 function offsetPopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "offset"
-	return helpify( $els, item, options )
+	item.action = options.action = "offset";
+	return helpify( $els, item, options );
 }
 
 function replacePopupHelp( $els, item={}, options={} ) {
-	item.action = options.action = "replace"
-	return helpify( $els, item, options )
+	item.action = options.action = "replace";
+	return helpify( $els, item, options );
 }
 
 function helpify($els, item={}, options={}) {
 	$els.each(function(index) {
-		const $el = jQuery($els.get(index))
-		const action = $el.data("action") || item.action || options.action
-		const title = $el.data("title") || item.title || $el.data("help")
-		const content = $el.data("content") || item.content
+		const $el = jQuery($els.get(index));
+		const action = $el.data("action") || item.action || options.action;
+		const title = $el.data("title") || item.title || $el.data("help");
+		const content = $el.data("content") || item.content;
 		switch(action) {
 			case "before":
-				$el.before( buildPopupHelpHtml( title, content ) )
-				break
+				$el.before( buildPopupHelpHtml( title, content ) );
+				break;
 			case "prepend":
-				$el.prepend( buildPopupHelpHtml( title, content ) )
-				break
+				$el.prepend( buildPopupHelpHtml( title, content ) );
+				break;
 			case "offset":
-				$el.append( buildPopupHelpHtml( title, content ) ).offset( options )
-				break
+				$el.append( buildPopupHelpHtml( title, content ) ).offset( options );
+				break;
 			case "replace":
-				$el.replaceWith( buildPopupHelpHtml( title, content ) )
-				break
+				$el.replaceWith( buildPopupHelpHtml( title, content ) );
+				break;
 			case "append":
-				$el.append( buildPopupHelpHtml( title, content ) )
-				break
+				$el.append( buildPopupHelpHtml( title, content ) );
+				break;
 			case "after":  // intentionally fallthrough, as 'after' is the default
 			default:
-				$el.parent().append( buildPopupHelpHtml( title, content ) )
+				$el.parent().append( buildPopupHelpHtml( title, content ) );
 		}
 	})
 }
 
 function buildPopupHelpHtml(title, content) {
-	const contentAttr = content ? ' data-content="' + content + '" ' : ''
-	return '<a class="popup-help" tabindex="0" role="button" data-toggle="popover" title="' + title + '" data-trigger="hover" ' + contentAttr + '><span class="far fa-question-circle fa-lg"></span></a>'
+	const contentAttr = content ? ' data-content="' + content + '" ' : '';
+	return '<a class="popup-help" tabindex="0" role="button" data-toggle="popover" title="' + title + '" data-trigger="hover" ' + contentAttr + '><span class="far fa-question-circle fa-lg"></span></a>';
 }
 
 function applyPopupHelpAction( entry, $els ) {
 	if ( entry ) {
-		const fn = getPopupHelpAction( entry )
-		const args = getPopupHelpActionArgs( entry, $els )
-		fn.apply(this, args)
+		const fn = getPopupHelpAction( entry );
+		const args = getPopupHelpActionArgs( entry, $els );
+		fn.apply(this, args);
 	}
 }
 
@@ -123,31 +123,31 @@ function applyPopupHelpAction( entry, $els ) {
 // making it directly compatible with the 'content' property of the popper.js
 // popover() method, which is its primary purpose
 const popupHelpAjax = function() {
-    const isDefined = function(x) { return typeof x !== "undefined" }
-    const buildUrl = function(title) { return RT.Config.WebHomePath + "/Helpers/HelpTopic?title=" + encodeURIComponent(title) }
+    const isDefined = function(x) { return typeof x !== "undefined" };
+    const buildUrl = function(title) { return RT.Config.WebHomePath + "/Helpers/HelpTopic?title=" + encodeURIComponent(title) };
     const boolVal = function(str) {
         try {
-            return !!JSON.parse(str)
+            return !!JSON.parse(str);
         }
         catch {
-            return false
+            return false;
         }
     }
 
-    const $el = jQuery(this)
-    const title = $el.data("help") || $el.data("title") || $el.data("originalTitle")
-    var content = $el.data("content")
+    const $el = jQuery(this);
+    const title = $el.data("help") || $el.data("title") || $el.data("originalTitle");
+    var content = $el.data("content");
     if (content) {
-        return content
+        return content;
     } else {
-        const isAsync = isDefined($el.data("async")) ? boolVal($el.data("async")) : true
+        const isAsync = isDefined($el.data("async")) ? boolVal($el.data("async")) : true;
         if (isAsync) {
-            const tmpId = "tmp-id-" + jQuery.now()
+            const tmpId = "tmp-id-" + jQuery.now();
             jQuery.ajax({
                 url: buildUrl(title),
                 dataType: "json",
                 success: function(response, statusText, xhr) {
-                    jQuery("#" + tmpId).html(response.content)
+                    jQuery("#" + tmpId).html(response.content);
                     $el.data('content', response.content);
                     $el.attr('data-original-title', response.title);
                     if ( response.content && title != response.title ) {
@@ -155,31 +155,31 @@ const popupHelpAjax = function() {
                     }
                 },
                 error: function(e) {
-                    jQuery("#" + tmpId).html("<div class='text-danger'>Error loading help for '" + title + "': " + e)
+                    jQuery("#" + tmpId).html("<div class='text-danger'>Error loading help for '" + title + "': " + e);
                 }
             })
-            return "<div id='" + tmpId + "'>Loading...</div>"
+            return "<div id='" + tmpId + "'>Loading...</div>";
         } else {
-            return "<div class='text-danger'>No help content available for '" + title + "'.</div>"
+            return "<div class='text-danger'>No help content available for '" + title + "'.</div>";
         }
     }
 }
 
 // render all the help icons and popover-ify them
 function renderPopupHelpItems( list ) {
-    list = list || pagePopupHelpItems
+    list = list || pagePopupHelpItems;
     if (list && Array.isArray(list) && list.length) {
         list.forEach(function(entry) {
             // console.log("processing entry:", entry)
-            const $els = applySelectorQueryOrFunc(entry.selector)
+            const $els = applySelectorQueryOrFunc(entry.selector);
             if ( $els ) {
-                applyPopupHelpAction( entry, $els )
+                applyPopupHelpAction( entry, $els );
             }
-        })
+        });
         jQuery('[data-toggle="popover"]').popover({
             trigger: 'hover',
             html: true,
             content: popupHelpAjax
-        })
+        });
     }
 }
-----------------------------------------------------------------------

Summary of changes:
 html/Helpers/HelpTopic  |  10 ++-
 static/js/inlinehelp.js | 192 ++++++++++++++++++++++++------------------------
 2 files changed, 103 insertions(+), 99 deletions(-)


hooks/post-receive
-- 
rt-extension-inlinehelp


More information about the Bps-public-commit mailing list