Shaun Mccran

My digital playground
 
08
J
U
L
2010

CSS 3 Rounded Corners Example

My curiosity into CSS 3 was piqued at Scotch on the Rocks 2010 this year. There was a very good presentation from Chris Mills from Opera http://twitter.com/chrisdavidmills where he touched on some of the new CSS 3 and HTML 5 functionality that some of the modern browsers are taking advantage of. I particularly liked some of the really simple, but visual CSS 3 changes, in this case rounded corners.

This article is a quick example of how to add rounded corner styling to your designs.

Here is a demo of CSS 3 rounded corners in action.

[More]

 
29
A
P
R
2010

Using Feed burner RSS feeds with your Blog and auto tweeting to your Twitter Account

Feed burner is a Google product that allows you to consume and distribute your RSS feeds in a much more in depth way than simply displaying the information in a raw XML format. It allows you to analyse the usage of a feed, add social links into feed articles and push the content onto other web platforms, like Twitter and Facebook.

In this article I will display what I like to call the 'Distributed social circular'. This means that when you create a new Blog article feed burner will automatically consume it, update your RSS feed subscribers, and post a custom formatted Tweet to your Twitter account, hopefully driving more visitors to the original article.

[More]

 
16
A
P
R
2010

Adding fck Rich Text Editor to your Coldfusion forms & customising the Toolbar set

Whilst writing a Content Management System (CMS) recently I thought I'd take the time to go over some Coldfusion 8 functionality that passed me by when it was released.

In Coldfusion 8 the fck editor was included as part of the server installation. This article deals with integrating it into your forms, and how to build a custom tool bar set to manage the options displayed with it.

[More]

 
11
M
A
R
2010

JavaScript Library conflicts when using more than one at the same time

Whilst building a new piece of functionality I have been trying to combine a JQuery carousel plug-in and the lightview prototype plug-in. This threw up an unexpected issue. Both libraries map the dollar ($) as their shortcut indicator. JQuery uses "$" as a shortcut as a replacement for "jQuery" and Prototype uses "$" as well.

It turns out that there is a JQuery command for exactly this issue. Wherever you include the JQuery library reference add another script code. The noConflict function maps which character you tell it as the short name for "JQuery".

view plain print about
1<s/cript src="http://www.google.com/jsapi" type="text/javascript"></script>
2<s/cript type="text/javascript" charset="utf-8">
3    google.load("jquery", "1.3");
4</script>
5
6<s/cript>
7    jQuery.noConflict();
8    var J = jQuery;
9</script>

Just remember to change your references to JQuery from "$" to "J", or whatever you assign it to.

view plain print about
1J(document).ready(function(){
2code
3});

Now both the Libraries can load into different namespaces.

 
28
F
E
B
2010

My Software Development platform specifications - whats yours?

I've been experiencing issues with my development setup, so I thought I'd write a blog entry to wrap up my findings, and try and gauge what the community is running. In this article I will detail what I use in my development environment, and how it is set up.

I've recently had errors occurring in my Eclipse IDE. There have been some very frustrating SVN client version incompatibilities, so I thought I would re install it. It turns out this was a common error (menu options in subclipse were not available) based on an incompatibility between the subclipse plug-in and the Aptana studio.

A detailed fix is in this blog entry: https://radrails.tenderapp.com/discussions/problems/173-synchronize-view-broken-after-upgrading-to-radrails-203

Software setup

I use the Eclipse Java IDE as my primary development application. Alongside this I use the CFEclipse plug-in for ColdFusion functionality, the Aptana Studio plug-in for CSS and JavaScript functionality. I also use the subclipse plug-in for SVN integration.

For Flex/AIR I use a standalone FLEX studio installation. This is pretty much a custom workspace in an Eclipse IDE. I only do this as I have had several issues trying to get FLEX installed into the regular Eclipse IDE.

I recently tried to switch to the 64 bit version of Eclipse, but it would not recognise my Java install, and from what I've read online you need to install a 64 bit version of Java. The only version of this I can find is flagged as "experimental" so I think I'll leave it well alone.

I've found it quite good to increase the default 256mb heap space in Eclipse to 512mb, there e is an article detailing how to edit the Eclipse ini file here: http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F

Download links

Eclipse downloads: http://www.eclipse.org/downloads/

CFEclipse downloads: http://trac.cfeclipse.org/wiki/InstallingCfeclipse

Aptana downloads: http://www.aptana.org/studio/plugin

Subclipse downloads: http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA

 
10
F
E
B
2010

Dynamically editing web content inline, using JavaScript and AJAX

Most of us are familiar with the standard method of displaying data in a tabulated fashion, selecting a record, and populating the form that follows. What about editing the content directly into a template that mirrors the actual live version of a page?

This article examines how to edit web content directly inline, and commit it back to a server using an AJAX post request.

The main catalyst for this is that clients that use a content management system do not often have a clear image of how their content will look online. The traditional form layout for entering text does not lend itself well to representing the actual content in the format it is display in.

The aim here is to build a flexible system that allows for inline content editing, and saves it gracefully to a server based database.

I will start by saying thank you to Peter-Paul Koch. His article here (http://www.quirksmode.org/dom/cms.html) on making content editable was invaluable, and a lot of this is based on his theory.

We start by setting a value "editing" to false. This is the default for the page, as the user isn't editing anything when the page loads.

view plain print about
1var editing = false;
2
3if (document.getElementById && document.createElement) {
4    var butt = document.createElement('BUTTON');
5    var buttext = document.createTextNode('Save');
6    butt.appendChild(buttext);
7    butt.onclick = saveEdit;
8}
9
10function catchIt(e) {
11    if (editing) return;
12    if (!document.getElementById || !document.createElement) return;
13    if (!e) var obj = window.event.srcElement;
14    else var obj = e.target;
15    while (obj.nodeType != 1) {
16        obj = obj.parentNode;
17    }
18    if (obj.tagName == 'TEXTAREA' || obj.tagName == 'A') return;
19    while (obj.nodeName != 'P' && obj.nodeName != 'HTML') {
20        obj = obj.parentNode;
21    }
22    if (obj.nodeName == 'HTML') return;
23    var x = obj.innerHTML;
24    var y = document.createElement('TEXTAREA');
25    var z = obj.parentNode;
26    z.insertBefore(y,obj);
27    z.insertBefore(butt,obj);
28    z.removeChild(obj);
29    y.value = x;
30    y.focus();
31    editing = true;
32    getId(e)
33}
34
35function getId(e) {
36    var targ;
37    if (!e) var e = window.event;
38    if (e.target) targ = e.target;
39    else if (e.srcElement) targ = e.srcElement;
40    if (targ.nodeType == 3) // defeat Safari bug
41        targ = targ.parentNode;
42    thisTarget = e.target.id;
43    
44}
45
46function saveEdit() {
47    var area = document.getElementsByTagName('TEXTAREA')[0];
48    var y = document.createElement('P');
49    // set the id back to the original value as the real one is destroyed
50    y.setAttribute('id', thisTarget);
51
52    var z = area.parentNode;
53    y.innerHTML = area.value;
54    z.insertBefore(y,area);
55    z.removeChild(area);
56    z.removeChild(document.getElementsByTagName('button')[0]);
57    editing = false;
58    // action the server request, first var is the value, second var is the id
59    saveToServer(y.innerHTML,thisTarget);
60}
61
62function saveToServer(valToCommit,fieldname) {
63    //alert(valToCommit);
64    $.post("view/appeals/act_commitChange.cfm", { newValue: valToCommit, field: fieldname, appeal: intId },
65
66    function(data){
67        alert(data);
68    });
69
70document.onclick = catchIt;

I wont go into massive depth on a line by line basis but Peter's article does break this down a lot. The premise is that there is a function catchit(), which will intercept any click events. It will then check that the event was triggered from a 'P' tag, which is our defining element for editable content. IE any P elements hold editable content. It will then remove the P html container, replacing it with a textarea, and re insert the P tags previous html content using the innerHTML JavaScript function.

In this way we can create editable inline textareas within the framework of our page.

The next step is to create a save function. The function 'saveToServer{)' take several arguments. It needs the value to commit, IE what the amended text string is, and the fieldname. Each 'P' tag has an id that I am matching to a data field. In this way if there are multiple p tags in a display they can each be attributed to a specific storage field in a database.

Because we are destroying the 'P' tag when we create the textarea we need to re assign the id to it when we save. We can do this by using the JavaScript function 'setAttribute'. The setAttribute function is used to set the value of an attribute on an object. It is typically used along with objects returned by document.getElementById to assign a new value to the object's attribute.

view plain print about
1// set the id back to the original value as the real one is destroyed
2y.setAttribute('id', thisTarget);

If we don't do this then the recreated 'P' tag no longer has an id attribute, so will error on any subsequent updates.

Next we use a JQuery Post function to post the values through an AJAX request.

view plain print about
1$.post("commitChange.cfc", { newValue: valToCommit, field: fieldname, appeal: intId },

This will post the values to the cfml CFC "commitChange.cfc", which handles them in a function.

This will allow you to perform seamless inline edits to the display layer, and commit them back to a server, so they are stored in real time.

There is an example of this here. (Minus the storing). You can track the AJAX post using a tool like charles http proxy, or firefox's firebug.

Now, to write a nice JQuery response handler to fade the returned massage in and out.

 
28
J
A
N
2010

Passing url variables through Isapi re write - Regular Expression

One of the more common tasks in ColdFusion development is passing variables through the URL string. We are all familiar with the idea that the question mark (?) denotes the url query string start, and that name value pairs are separated with the ampersand (&).

I usually avoid using this in display templates, as it isn't great exposing your internal site workings to customers, and with Fusebox it is very easy to pass the URL variables to an "act_" template and remain hidden.

What happens when you want to use dynamic url variables with a URL re writing application like Isapi re write? I've been using Isapi re write in some FuseBox framework application, and it is relatively easy to set up a rewrite rule, as shown below.

view plain print about
1RewriteRule home(/) index.cfm?fuseaction=circuitname.circuitfunction

Where the url /home/ would actually serve up the content specified in the fuse specified. But this is hard coded. What about dynamic variables?

We can create a regular expression to handle the translation of the variables.

view plain print about
1RewriteRule destination/(.*)/(.*)/ index.cfm?go=circuitname.circuitfunction&$1=$2

We use a similar URL, but append the dollar ($) 1 = dollar ($) 2 string. In the re write rule we specify that appended variables are transposed into the string using the slash (/) as a separator.

So as an example we could pass a product id of 24 into the rule like this:

view plain print about
1www.siteurl.com/cart/productId/24/
2RewriteRule buy/(.*)/(.*)/ index.cfm?go=cart.buy&$1=$2

It would be rewritten to the more familiar url string. A handy way of continuing to mask the url.

 
22
J
A
N
2010

Strict or Transitional DTD type validation, worth hacking just to pass?

An area of web development that I previously had little exposure to was WCAG validation. This is the industry standard for Accessibility coding for web platforms. For version two (V2) of the WCAG there are three standards, A, AA and triple A (AAA). Each represents different levels of Accessible compatibility.

What this also does is validate against the W3C doctype standards. This is where my problems arose. The main aim of the doctype standard is to clearly define a separation layer between content and behaviour. In practical terms this equates to best practices such as having an external .CSS files rather than inline styling, and declaring the language types for scripting, such as JavaScript etc.

Using a free online tool, http://www.totalvalidator.com/ you can check if your site is W3C and WCAG complaint. It will base the validation on the doctype declared in your html. There are three types of DTD declaration for html 4.01.

view plain print about
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
3<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4
5<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/frameset.dtd">

You can read more about Doctypes here: http://www.w3schools.com/tags/tag_DOCTYPE.asp

The main difference between these is that the frameset DTD will accept frameset as valid html, whereas the others will not. Also the Strict DTD imposes a very tight restriction of what is accepted as valid in comparison to the Transitional DTD. One is a Strict adherance to the standard, whereas the other shows that you are Transitioning from old code into the new.

The site http://24ways.org/2005/transitional-vs-strict-markup goes into more detail about what the exact differences are, what I am going to discuss is the option of creating functional hacks, merely to pass validation.

One of the deprecated attributes in Strict validation is the target attribute.

view plain print about
1<a href=http://www.mywebsite.com target=_blank>Follow this link to go to my website</a>

We are all familiar with this attribute, but when you examine it you find that it is actually a declaration of behaviour. We are forcing the user into a specific action. IE open a new window. As a best practice guideline whenever we have a link on a site that exits that site, we open a new window. The only work around for this is creating a specific JavaScript function to open a new window, as this will not be marked as invalid. This seems overkill, just to pass validation.

So I am left with the dilemma that if I want my sites to pass Strict DTD validation I must create a JavaScript hack, or compromise the functionality. I'd like to pass the validation, but I view the functionality as key to a site, so it's an easy decision for me.

More Entries


This content is purely my opinon, any offence or errors are unintentional, please comment your views appropriately
Site Credits
Aggregated by ColdfusionBloggers.org Powered by Coldfusion

Technology & Science Blogs - BlogCatalog Blog Directory Blog Directory & Search engine