Gregory's Blog

Social Media Sharing with Galaxie Blog

This post is intended to allow the owner of the blog to incorporate social media using Galaxie Blog. I am using 'addThis' as my library, and there is a 'Add This Social Integration' form in the settings section of the administrative interface. Social media sharing is set up by default in Galaxie Blog, but you need to create your own addThis personal account and register an ID with. This does not require any code changes, you can do this yourself and put in the key that you have created using a web interface. This is easy to do if you follow along.

To set up your own social media share buttons for your own site using your own account, go to the addThis.com website, and set up a new account. Once you're set up, you should see a 'tools' option on their website. Click on 'add a new tool', you should see a new 'select a new tool' interface.

Click on the 'share buttons' icon- it should be the first icon in the list. Once you have selected the inline tool, click on the blue button labeled 'continue' at the bottom of the page.

You should see a new 'sharing services' interface. Select choose 'inline' for the tool type, click continue, and then in the 'sharing services' interface, click on the 'selected by you' radio button. Choose 'facebook', 'twitter', 'pinterest' 'linkedIn' and 'tumblr'. You can sort these options by dragging and dropping the icons underneath 'Selected Sharing Services'. Sort the icons in your own desired order.

I have tested all of these services and they should work. Choose any other services that you want here, but I have not tested anything other than these services. If you want to add more services, they may or may not work, you may have to add more code on your own, your mileage may vary.

Once your services are selected, click on the design icon, and design the addThis buttons to your liking. I chose to round the corners quite a bit, but kept all of the other settings that were shown as default. Once you're satisfied with the look and feel of the buttons, click on the 'activate tool' button. You should now see a 'get the code' button. Click on it, the code should be similar to the following code below.

view plain about
1<!-- Go to www.addthis.com/dashboard to customize your tools -->
2<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5cad55abc3dea5c2"></script>

/>

Copy the string between 'pubid=' and the closing tag '">'. The default string that I use is 'ra-5cad55abc3dea5c2'. Enter this string in the 'Add This Social Integration' section in the settings interface in the administrative section of the site (typically found in using the '/blogCfc/client/admin/' URL), click on the 'save settings' button, and you should be good to go.

This entry was posted on May 27, 2019 at 1:53 AM and has received 183 views.

There are currently 0 comments. Download attachment.

ColdFusion arrays can't use zero as an index.

I should have known better, but I had forgot that you can't use a zero as an index when constructing a ColdFusion array. On this blog, I have 14 different themes, and 39 settings for each theme, and created an array stored in the application scope to store the values in. I wanted to use a zero as an index to identify the name of the theme, and then use 1 through 39 as the theme setting. However, when I tried this approach I received the following error: "A scalar value of type java.lang.String cannot be assigned to a 2-dimensional ColdFusion array." The problem was solved when I used 1 instead of 0 as the first index. I have always thought that this was odd as assigning a zero index should work. Most other languages default to a zero on the first array item, and still mistakenly assumed that this would work here.

Here was my original code that caused this error:

view plain about
1<!--- Theme --->
2<cfset application.arrThemeSettingsFromIniStore[1][0] = "black"><!--- black --->
3<!--- Theme variables --->
4<cfset application.arrThemeSettingsFromIniStore[1][1] = trim(getSettingsByTheme('black').useCustomTheme)><!--- useCustomTheme --->
5more custom theme settings...

The code should not use a zero based index like so:

view plain about
1<!--- Theme --->
2<cfset application.arrThemeSettingsFromIniStore[1][1] = "black"><!--- black --->
3<!--- Theme variables --->
4<cfset application.arrThemeSettingsFromIniStore[1][2] = trim(getSettingsByTheme('black').useCustomTheme)><!--- useCustomTheme --->
5more custom theme settings...

This entry was posted on May 25, 2019 at 12:31 AM and has received 109 views.

There are currently 0 comments.

Data types may be different between ColdFusion and jQuery.

I developed code that gets and sets theme settings from a .ini file. I am using getProfileString and setProfile string to set the various theme properties in a ColdFusion component on the server side. Depending upon the approach that I use, the datatypes that are being returned to the client are different. For example, if I invoke the function from a .cfm page, the values that I am getting are stored in strings, and are being returned as either a 'yes' or 'no'. However, if I invoke the same function from ajax, the value is being returned as a boolean value, i.e. true or false. The component and the method are the same, but the evaluation of the return value is different between ColdFusion and jQuery. Be aware that if you don't declare and set the datatype of the structure elements independently; the datatypes can be interpreted differently depending upon where they are being evaluated.

This entry was posted on May 18, 2019 at 5:13 PM and has received 115 views.

There are currently 0 comments.

JSON Parse Error in jQuery when using a Coldfusion function inside a .cfm page.

Late at night, I put a function inside a .cfm template and tried to consume it from Ajax, but I received a json parse error that was displayed in Chrome's console when trying to invoke a function within a .cfm page. I had forgot that ajax functions should not be consuming a .cfm page, and placed the exact same function within a component with a .cfc extension, and the issue went away. When a function is within a component with the access remote argument, ColdFusion will autogenerate a web services stub, but it does not do this within a .cfm page. If you receive a json parse error using logic that is known to create a valid json object within a .cfm page, try putting the same code in a .cfc component and consume it there. It may solve this parse error for you as well. The code below has a 'proxyControllerUrl' variable that was initially using a template with a .cfm extension, and it failed. However, when I put the same function within a .cfc extension, it worked.

view plain about
1function getAllThemeSettingsFromIniStore(themeId){
2
3    // Get all of the theme properties stored in the ini configuration file.
4    $.ajax({
5        type: "get",
6        url: "<cfoutput>#application.proxyControllerUrl#?</cfoutput>method=getAllThemeSettingsFromIniStore",//Works with a .cfc component, fails when the method is inside a .cfm template.
7        data: { // method and the arguments
8            themeId: themeId
9        },
10        dataType: "json",
11        cache: false,
12        success: function (data){
13            // Pass the data to the getAllThemeSettingsResult function.
14            getAllThemeSettingsResult(data);
15        },
16        error: function(xhr, textStatus, error){
17            console.log(xhr.statusText);//Parse error shows up here when inside a .cfm template.
18            console.log(textStatus);
19            console.log(error);
20        }
21    });
22}//... function

This entry was posted on May 18, 2019 at 2:26 AM and has received 117 views.

There are currently 0 comments.

Set active kendo tab

There are two standard ways to activate a Kendo tab: 1) via Javascript, or 2) appending the k-state-active class to the HTML list. Both approaches are useful. However, I have had troubles using a javascript function to set the active tab when I had a button open up a new Kendo window, and then set the active tab based upon the URL variable that I sent along when opening up the Kendo window. For some odd reason, when I used the javascript method it would not process the scripts in the second tab. I could not figure out how, or even why, this method failed, but appending the k-state-active class to set the to tab worked just fine. I will share both options below.

Option 1, use javascript and the select(tabIndex) method:

view plain about
1// Set the active tab if it was passed into the URL.
2var tabName = <cfoutput>'#URL.tabName#'</cfoutput>
3// Set the active tab if the tab argument is not a null string
4if (tabName !=''){
5    // Set the tab
6    setContractDetailTab(tabName);
7}
8    
9// function to select the appropriate detail tab.
10function setContractDetailTab(tabName){
11        
12    if (tabName == 'contractDetail'){
13        // Get the index. We are starting at 0, so the first tab will have a zero index.
14            var tabIndex = 0;
15        } else if (tabName == 'routing'){
16            var tabIndex = 1;
17        } else if (tabName == 'attachment'){
18            var tabIndex = 2;
19        }
20        
21        // Don't perform any actions until the dom is loaded.
22        $(document).ready(function() {
23            // Get a reference to the tab.
24            var detailTabSrip = $("#detailTabSrip").kendoTabStrip().data("kendoTabStrip");
25            // Select the tab. Make sure to use a timeout otherwise an error will occur and the kendo dropdowns will not be instantiated.
26            setTimeout(function() {
27                detailTabSrip.select(tabIndex);
28            }, 500);
29            
30        });    //document.ready
31    }
32}

Option 2) use the k-state-active Kendo class to select the active tab:

view plain about
1<div id="detailTabSrip" style="height:925px">
2 <!--- Tab names. --->
3 <ul>
4 <li id="contractDetail" <cfif not isDefined("URL.tabName") or URL.tabName eq "">class="k-state-active"</cfif>>
5     <p>Contract Detail</p>
6 </li>
7 <li id="routing" <cfif isDefined("URL.tabName") and URL.tabName eq 'routing'>class="k-state-active"</cfif>>
8     <p>Routing</p>
9 </li>
10 <li id="attachment" <cfif isDefined("URL.tabName") and URL.tabName eq 'attachment'>class="k-state-active"</cfif>
11 <p>Attachment</p>
12 </li>
13 </ul>

This entry was posted on May 9, 2019 at 2:55 PM and has received 106 views.

There are currently 0 comments.

How to get both background and non-background images using the imagesLoaded library.

I use the imagesLoaded javascript library to determine when and what images are loaded and to provide a status on a pre-loader status screen. The imagesLoaded library has the ability to gather information on background images, and non-background images using the 'background: true/false' argument. If you need to get both background and non-background images, just run it twice switching the background arguments. I highly recommend using this library when you want to provide a 'please wait' dialog and show the load progress of a graphically intense site.

view plain about
1// Get the parallax images (non-background images).
2$('.images').imagesLoaded({
3    background: false
4}).progress( function( instance, image ) {
5    loadProgress();
6});
7
8// Get the background images in the scenes.
9$('.bcg').imagesLoaded({
10    background: true
11}).progress( function( instance, image ) {
12    loadProgress();
13});

This entry was posted on May 8, 2019 at 11:35 PM and has received 127 views.

There are currently 0 comments.

Kendo tooltips with multiple classes and styles.

I had thought that I figured out how to use the Kendo tooltip widget as illustrated in another post, however, I quickly found out that by over-riding the k-tooltip Kendo base class that I could only have one tooltip style for the whole page. Unlike most other Kendo widgets, you can't specify a unique css rule with #divName .k-tooltip { rules... }. As soon as I put in the element name in front of .k-tooltip, everything broke. I thought that I must have made a silly mistake, and tried everything, including the element name after the .k-tooltip class, trying to put in the parent element name, trying to create new custom classes, and appending the class to .k-tooltip, etc, but nothing worked. Time to search the web with google.

Apparently, Telerik's tooltip design prevents this type of chaining. You can't manually add a class to the tooltip. Instead, we have to use jQuery's addClass to add a class in a function. This particular approach has some issues when the first tooltip is raised (the cutout does not immediately point to the element, and the correct background color may not immediately appear), but otherwise, it works for the most part. I am finally able to have multiple Kendo tooltip styles. Here is my approach. There are a few ColdFusion tags in the example, but the code and comments should be illustrative. A working example of this code is found on my home site at gregoryalexander.com/

HTML

view plain about
1<!--- Tooltip on the left side of the page. --->
2<div id="aboutThisImage">
3    <span id="leftTooltip" title="Jenny Lake, Grand Teton National Park." data-desc="This is a majestic trail. But pay attention.... you may come face to face with a Grizzly bear..." class="leftTooltip">
4        <img src="/images/symbol/aboutGreen.gif" align="center" />
5    </span>
6</div><!---<div id="aboutThisImage">--->
7
8<!--- Tooltip on the right side of the page. --->
9<div id="imageLocation">
10    <!--- Don't show the tooltip on mobile devices. --->
11    <cfif not session.isMobile><span title="Click to view an interactive map." data-desc="Click on this button to view an interactive map of the Jenny Lake trail." class="rightTooltip"></cfif>
12        <img src="/images/symbol/mapMarkerButton.gif" align="left" onClick="openMapWindow(0)"/>
13    <cfif not session.isMobile></span></cfif>
14</div><!---<div id="imageLocation">--->

CSS:

view plain about
1/* Custom classes for the tooltips. These classes will be used to override the base k-tooltip class. */
2.leftTooltipStyle {
3    background: #046FA1 !important; /* Blue matching the left part of the logo */
4    width: var(--toolTipWidth);
5    height: var(--toolTipHeight);
6    font-size: var(--toolTipFontSize);
7    border-radius: 10px;
8    /* Subtle drop shadow on the main layer */
9    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
10}
11        
12/* Custom classes for the tooltips. These classes will be used to override the base k-tooltip class. */
13.rightTooltipStyle {
14    background: #698A50 !important; /* Green matching the right part of the logo */
15    width: var(--toolTipWidth);
16    height: var(--toolTipHeight);
17    font-size: var(--toolTipFontSize);
18    border-radius: 10px;
19    /* Subtle drop shadow on the main layer */
20    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
21}
22        
23.tooltipTemplateWrapper h3 {
24    font-size: <cfif session.isMobile>12px<cfelse>1em</cfif>;
25    font-weight: bold;
26    padding: 0px 10px 5px;
27    border-bottom: 1px solid #e2e2e2;
28    text-align: left;
29}
30
31.tooltipTemplateWrapper p {
32    font-size: <cfif session.isMobile>12px<cfelse>1em</cfif>;
33    padding-top: 0px;
34    padding-right: 10px;
35    padding-bottom: 10px;
36    padding-left: 10px;
37    text-align: left;
38}

And finally, the javascript:

view plain about
1var leftTooltipIntro = $("#intro").kendoTooltip({
2    // A class can also be used to trigger the popup.
3    filter: ".leftTooltip",
4    position: "right",
5    // Note: we need to use a template as we have created a popup matching the blue notification popups on the right side of the page.
6    content: kendo.template($("#aboutTemplate").html()),
7    show: function(e) {
8        // We also need to override the k-tooltip style with our own class. Otherwise, all of the other tooltips will have the same style. We are differentiating the look of both the right and left tooltip.
9        this.popup.element.addClass("leftTooltipStyle");
10    },
11    // Add animation effects.
12    animation: {
13        open: {
14            effects: "zoom",
15            duration: 150
16        }
17    }
18}).data("kendoTooltip");
19                
20var rightTooltipIntro = $("#intro").kendoTooltip({
21    // A class can also be used to trigger the popup. We can have as many classes as we want separated by comma's.
22    filter: ".rightTooltip",
23    position: "left",
24    // Note: we need to use a template as we have created a popup matching the blue notification popups on the right side of the page.
25    content: kendo.template($("#locationTemplate").html()),
26    show: function(e) {
27        // We also need to override the k-tooltip style with our own class. Otherwise, all of the other tooltips will have the same style. We are differentiating the look of both the right and left tooltip.
28        this.popup.element.addClass("rightTooltipStyle");
29    },
30    // Add animation effects.
31    animation: {
32        open: {
33            effects: "zoom",
34            duration: 150
35        }
36    }
37}).data("kendoTooltip");

This entry was posted on May 8, 2019 at 9:10 PM and has received 137 views.

There are currently 0 comments. Download attachment.




Footer Logo

Your input and contributions are welcomed!

If you have an idea, BlogCfc based code, or a theme that you have built using this site that you want to share, please contribute by making a post here or share it by contacting us! This community can only thrive if we continue to work together.

Images and Photography:

Gregory Alexander either owns the copyright, or has the rights to use, all images and photographs on the site. If an image is not part of the "Galaxie Blog" open sourced distribution package, and instead is part of a personal blog post or a comment, please contact us and the author of the post or comment to obtain permission if you would like to use a personal image or photograph found on this site.

Credits:

Portions of Galaxie Blog are powered on the server side by BlogCfc, an open source blog developed by Raymond Camden. Revitalizing BlogCfc was a part of my orginal inspiration that prompted me to design this site. Some of the major open source contributers to BlogCfc include:

  1. Peter Farrell: the author of 'Lyla Captcha' that is used on this blog.
  2. Pete Freitag: the author of the 'ColdFish' code formatter that is also used on this blog.

Version:

Galaxie Blog Version 1.35 September 6 2019