Gregory's Blog

Gregory's Blog default user name and password after fresh installation

In order to log into the administrative section of the blog after installation, use 'admin' as the user name, and 'admin' as the password. Be sure to change the password after logging in for the first time. In this version, the administrative section is nearly identical to the original BlogCfc administration interface with a lot more settings included. I will likely change this in the next version.

This entry was posted on June 1, 2019 at 7:41 PM and has received 227 views.

There are currently 0 comments.

Social Media Sharing with Gregory's Blog

This post is intended to allow the owner of the blog to incorporate social media using Gregory's 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 Gregory's 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<InvalidTag 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 115 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 78 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 85 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 81 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 78 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 87 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 100 views.

There are currently 0 comments. Download attachment.

Kendo template with void to consume a function in an anchor link

I have a Kendo template that is used to display real time statuses for contracts, and programmed an a href tag that was intended to consume a javascript function rather than opening up a link. On my first attempt, I was having problems as I could not program a pound symbol into the Kendo template (like ColdFusion, a pound symbol indicates a variable within a Kendo template), so I escaped it using two pounds, and found myself struggling to figure out why my window was suddenly being refreshed. I spent around ten minutes stepping through my code only to find out that the a href tag refreshing the entire page, even though it was blank as the double pound sign was escaped. On further introspection, this is understandable as I just had inadvertently programmed a typical link. To fix this issue, I used a simple javascript:void(0); within the link, and the javascript function is called without the default a href tag opening up the link. Essentially, the void(0) code prevents the default behavior of the link, and it acts like a a href="#". I would not typically use void in other code, but using it within a Kendo MVVM template is an appropriate place. Here is the code:

view plain about
1<InvalidTag type="text/x-kendo-template" id="myApprovalTemplate">
2    /* Note: dynamic vars can be displayed like so: #: myApprovalDs.total() # */
3     /* Alternate row colors. */
4    # if(window.altRow) { #
5        <tr class='k-alt'>
6    # } else { #
7        <tr class='k-content'>
8         # } #
9 # if(ApprovalId >
0){ #
10     <td class="border">
11     <input type="checkbox" name="approved#: ApprovalId #" id="approved#: ApprovalId #" value="1" /></td>
12     <td class="border">#: ApproverTitle #</td>
13     <td class="border"><a href="javascript:void(0);" onClick="openContractDetailWindow(#: ContractId #, #: ApprovalId #, '')">#: Contract #</a></td>
14     <td class="border">#: Contractor #</td>
15     <td class="border">pdf</td>
16     <td class="border"></td>
17 #} else {#
18     <td colspan="6"<!--- class="k-loading-image k-loading-color" --->>
19     <br/>There are no contracts eligible for you to approve
20     </td>
21 #}#
22     </tr>
23 <!--- Toggle the window variable. --->
24 # window.altRow = !window.altRow; #
25 </script>

This entry was posted on April 24, 2019 at 7:51 PM and has received 91 views.

There are currently 0 comments.

Reopen an existing Kendo window.

I have been coding thousands of Kendo windows throughout the last several years, and ran into a problem that I have never seen before, and could not find a solution (or even a hit) on google. While coding a window that will hold a Kendo map, I ran into the following error when I opened the window, closed it, and then tried to open it again: Cannot call method 'destroy' of kendoWindow before it is initialized. This error is just not found.

Type in "Cannot call method 'destroy' of kendoWindow before it is initialized" into google, you won't find a single result. You'll find many other topics, but not one that matches this particular error message. Here is a solution on how I overcame this error, and why I think that it may have happened in the first place.

My personal website uses a Greensock animation carriage. It is my guess that the errors are due to having a lot of subtle animations there, and it is resource intensive as it has extensive scroll and touch listeners. Along with the Kendo map widget, the site is very resource intensive on the client end. This is probably freezing the destroy methods that are used to typically close a Kendo window. Whatever the actual reason, when I try to destroy the window that contains the map, as I usually do, I run into multiple errors and the window will not open again.

My approach was to build a function that would check if the window was previously opened, and then closed, to simply re-open it and then refresh the content (it has dynamic content).

If the window was not already created (by someone opening it), then I would create the window, as usual, but I eliminated Kendo's destroy method when the window is closed. I don't want to destroy it- in fact- I can't. It causes errors.

If the window was opened, and closed (making the window hidden since it does not have the destroy method), I would re-open the existing window. Here is the code:

view plain about
1function openMapWindow() {
2            
3    $( document ).ready(function() {
4                
5    /* This is a totally weird approach to open a kendo window. I have coded kendo windows for several years, and have probably coded several hundred windows, but using a Kendo window in this greensock platform, especially with Kendo maps, just does not work. Here, I am testing to see if the window is:
6    1) defined (the first mapWindow line of code will error out if the window has not already been opened)
7    2) and if the window is defined, is it hidden (it will be- I am not destroying the window like I always do in other code as I have problems with that here.)
8    If both conditions ARE true, then I merely reopen the existing window that was hidden when the user clicked on the 'x' at the top of the window.
9    If both conditions are NOT true, then I create the window as usual (but I don't destroy it as usual as I had problems there too).
10    Essentially what I am doing is:
11        - Creating the window if the window was not first opened and then closed.
12        - Or reopening the window if it was opened and then closed.
13    */

14    // This must be put into a try block as the 'var mapWindow =         $("#mapWindow").data("kendoWindow");' will cause errors if the window has not already bee already opened.
15    try {
16        // Get a reference to the opened window.
17        var mapWindow = $("#mapWindow").data("kendoWindow");
18        // Determine if the window was closed...
19        var mapWindowIsHidden = mapWindow.element.is(":hidden"); //returns true or false
20        // If the window was closed (and now hidden), re-open the existing window.
21        if (mapWindowIsHidden){
22            // Change the title
23            mapWindow.title(getMapDataByScene(sceneIndex));
24            // Open it.
25            mapWindow.open();
26            // And refresh the window.
27            mapWindow.bind("refresh", window_refresh);
28                    }
29        // Otherwise create the window (for the first time)...
30        } catch(e) {
31                    
32            // Initialize the window.
33            var mapWindow = $('#mapWindow').kendoWindow({
34            title: getMapDataByScene(sceneIndex),
35            actions: ["Refresh", <cfif not session.isMobile>"Minimize", </cfif>"Close"],
36            modal: false,
37            resizable: true,
38            draggable: true,
39            pinned: true, // Note: we must pin this window, or it will open at the top of the page at all times when we use this approach.
40            position: { top: 100 },
41            width: getGrizzlyWindowWidth(),
42            height: getGrizzlyWindowHeight(),
43            iframe: false, // Don't use iframes unless it is content derived outside of your own site.
44            content: "/includes/layers/map.cfm?sceneIndex=" + sceneIndex,// Make sure to create an absolute path here. I had problems with a cached page.
45        <cfif session.isMobile>
46            animation: {
47                close: {
48                effects: "slideIn:right",
49                reverse: true,
50                duration: 500
51            }
52        }
53    </cfif>
54    }).data('kendoWindow').center();// Center the window.
55                                
56    }//..try
57});
58            
59}//..function openMapWindow() {

Additionally, if you don't need a dynamic window where the content changes, you can simply use the following simple approach:

view plain about
1// Dynamic window for the approval routing picker.
2    // This window also has an id variable.
3    // Original inspiration provided by Ona Bai (http://dojo.telerik.com/@OnaBai/ekIba/2).
4    // To use, first create a div at the top of the page like so: <div id="dynamicDetailWindow"></div>
5    function dynamicRoutingPickerWindow(id, id2, name, width, height) {
6        var thisWin = $("#" + name).data("kendoWindow");
7        if (thisWin) {
8            thisWin.open();
9        } else {
10            thisWin = $("<div id='" + name + "'></div>").kendoWindow({
11            actions: ["Minimize", "Maximize", "Refresh", "Close"],
12            title: "Contract Details",
13            content: "includes/routingPicker.cfm?contractId=" + id,
14            width: width,
15            height: height,
16            modal: false,
17            resizable: true,
18            draggable: true,
19            // Open the window near the top of the page.
20            position:{
21                top:"15%",
22            },
23            appendTo: "#dynamicRoutingPickerWindow",
24            visible: true
25            }).data("kendoWindow").center();
26        }
27 }

This entry was posted on April 19, 2019 at 12:15 AM and has received 92 views.

There are currently 0 comments.




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 "Gregory's 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 Gregory's 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:

Gregory's Blog Version 1.15 July 25th, 2019.