Archive for the ‘Web Developement’ Category

Dreamweaver 5.5 HTML5 / CSS / JS Setup done right

Saturday, February 18th, 2012

At work I recently upgraded to Adobe Dreamweaver 5.5. I forgot that I added the HTML5 Pack via Adobe Extensions to DW, but was quickly reminded when I created new files and no longer had CSS reset or dom.ready in my files. I soon found that the HTML5 Pack is ‘included’ with the defaults of DW5.5, except my default files were all lame and empty.

[I already know that most 'professionals' poop all over DW, but it is the program I learned to code in and mocking me will not get me to change my mind]

This led me to learn how actually customize the default files for DW and eventually I created a nice little stripped down DW Boilerplate for myself. I didn’t find any good documentation, so I figured I use the moment of inspiration to write a post.

Setup the default html file

  • Summary: HTML5 Template with generic links to styles, scripts, etc
  • 1. Set DW to open your html files with the HTML5 doctype.
    – Dreamweaver -> Preferences -> New Document -> Default Document Type (DDT):
    – change the setting to HTML5
    This will give you a nice little naked HTML5 file, but we can make it better.
  • 2. Build you preferred HTML template that will open each time you open a new html document.
    – In your computer, find: Dreamweaver 5.5 -> Configuration -> DocumentTypes -> NewDocuments -> Default.html
    Open the file in DW, then just type or copy/paste in your new html template. Save, then open a new html file, and you should see exactly what you just added!

Setup the default javascript file

  • Summary: basic js file with jQuery doc.ready and window.load ready to rock
  • 1. Build you preferred javascript template that will open each time you open a new javascript document. Really, the html file is the hardest to to, because it is two steps.
    – In your computer, find: Dreamweaver 5.5 -> Configuration -> DocumentTypes -> NewDocuments -> Default.js
    Open the file in DW, then just type or copy/paste in your new javascript template. Follow the same process for testing.

Setup the default css file

  • Summary: default css file with reset, author comments, indexing and device widths
  • 1. HTML5 is sweet, JS is ok, but the CSS is where I really pat myself on the back.
    – In your computer, find: Dreamweaver 5.5 -> Configuration -> DocumentTypes -> NewDocuments -> Default.css
    Thats it, you are good to go.

So now knowing these principles, you know where every default file template is in DW and you can customize all the templates you use.

As for more details about my boilerplate. I found other boilerplates to be informative, but bloated. I was always removing things or noticing things I forgot to remove. I wanted to come from the other direction. Just the proper basics that will provide the things I need and save me time. This is my first draft of these files, but this shit is organic and will evolve, so feel free to take mine and use them as your starting point.

  • HTML: HTML5 document with title tag, favicon link, screen/mobile/print css linked, html5 shiv, some base html tags (header/content/footer), js file linked.
  • js: I always find myself using jQuery, so the file has the standard doc.ready and window.load functions
  • css: This is the file that I really appreciate. It starts with project details, including the math my heights & widths are based on (used for my mobile specific css). It is followed by a basic index, I do this because css files always become a mess if you don’t stay on top of them. Then we roll into Eric Meyer’s reset css with html5 selectors included (I remove the body {line-height} css because it causes me more problems that it solves). It then has the comments that match the index setup. Finishing with some CSS Media Queries for device width. This has it’s own index for all my testing devices and then the corresponding widths breaking down the devices again. Like I said above, I’m pretty proud of this file, makes my life easier.

Download the files(html, css, js)[8kb]

I would love to hear how other folks start there projects off. Their default files.

HTML5 Input Placeholder Safari Bug

Monday, December 5th, 2011

When using placeholder in text inputs, Safari won’t respect line-height. The text won’t appear to be centered vertically. But if you remove the line-height, it will. Just a heads up.

JS101 Week 4

Wednesday, March 9th, 2011

TRACK 1 – Javascript Videos
Please watch the videos in the links listed below. Some links may contain further notes and links to resources covered in the videos. After watching the videos, reflect on the questions, discuss them on the forums, post your reflections on your blogs. The assignments are for practicing the concepts learned. You can discuss them on the forums, and upload them on your blog or any open source repository where your course peers and facilitators can review and comment on them.

Questions for reflection (please reflect on your blog and discuss in comments below):

  • Q: There were two key innovations to the original (fetch-parse-flow-paint) linear workflow that the Mosaic browser used to render web pages. One allowed for a perception of faster rendering, and the other allowed for us to use AJAX. Explain both?
    A: 1) The Mosaic engine had a problem with images, it didn’t know the size of the image. It would reach the parse stage of the workflow have to return fetch stage of the workflow. To fix this, Netscape followed the same workflow, but put a marker in the fetch stage and kept going, and then later, when it got the image, it would paint it in. Essentially, the load didn’t get hung up on an image, it would build around it. Flow and Paint multiple times.
    2) Netscape 2 built on this by adding events, which cause a script to get executed. Creating a ‘Flow -> Paint -> Event -> Script’ loop. Something all browsers still use today.
  • Q: What are the roles of ‘name’ and ‘id’ attributes in HTML tags? What is an appropriate use of both?
    A: ‘name’ = Identifies values in form data, Identifies a window/frame. They are mostly used in forms and such
    ‘id’ = Uniquely identifies an element. This can be used to gain access to an object for use with JS & CSS.
  • Q: Which pointers does each node in the DOM tree typically have?
    A: child, sibling, parent.
  • Q: Given a node object from a DOM tree, how do we determine if it is a text node or a regular node?
    A: If you get a nodes nodeName, a Text node will return #text, a regular node will return something other that #text.

    Element The tag name, eg. HTML
    Attr The attribute name, eg. id
    Text #text
    CDATASection #cdata-section
    EntityReference The name of the entity reference, eg. amp
    Entity The entity name, eg. &
    ProcessingInstruction The target of the processing instruction, eg. xml-stylesheet
    Comment #comment
    Document #document
    DocumentType The name of the document type, eg. html
    DocumentFragment #document-fragment
    Notation The notation name

    or refer to this check node.nodeType for these:
    Node.ELEMENT_NODE == 1
    Node.ATTRIBUTE_NODE == 2
    Node.TEXT_NODE == 3
    Node.CDATA_SECTION_NODE == 4
    Node.ENTITY_REFERENCE_NODE == 5
    Node.ENTITY_NODE == 6
    Node.PROCESSING_INSTRUCTION_NODE == 7
    Node.COMMENT_NODE == 8
    Node.DOCUMENT_NODE == 9
    Node.DOCUMENT_TYPE_NODE == 10
    Node.DOCUMENT_FRAGMENT_NODE == 11
    Node.NOTATION_NODE == 12

Homework:

  • Q: Download the source for the web page ‘http://www.useit.com/about/nographics.html’. In the source page itself, write a Javascript function which counts the number of text nodes in the document and shows the count in an alert dialogue. You can choose how you want to trigger the function (through a button click, link click, or any other event).
    A: I had a real hard time putting this one together. I couldn’t think it all the way through the process, I actually poached the code from Melipone Moody. See my version in action here.

    function walkTheDOM(node, func) {
    	func(node);
    	node = node.firstChild;
    	while (node) {
    		walkTheDOM(node, func);
    		node = node.nextSibling;
    	}
    }
    function countTextNodes() {
    	var sum = 0;
    	function count (node) {
    		if (node.nodeType == 3) // TEXT_NODE
    	sum++;
    	}
    	var root = document.documentElement;
    	walkTheDOM(root, count);
    	alert (sum + " text nodes found");
    }
    countTextNodes()
    
  • Q: Change the example above so that instead of displaying the count in an alert dialogue, it is displayed in a span tag in the HTML page itself.
    A: Simply just built of the previous example and used innerHTML. See it in action here.

    function walkTheDOM(node, func) {
    	func(node);
    	node = node.firstChild;
    	while (node) {
    		walkTheDOM(node, func);
    		node = node.nextSibling;
    	}
    }
    function countTextNodes() {
    	var sum = 0;
    	function count (node) {
    		if (node.nodeType == 3) // TEXT_NODE
    	sum++;
    	}
    	var root = document.documentElement;
    	walkTheDOM(root, count);
    	var add_this_copy = (sum + " text nodes found");
    	// alert(add_this_copy);
    	document.getElementById('place_content_here').innerHTML = add_this_copy;
    
    }
    countTextNodes()
    
  • Q: Add a link besides the button, such that when the link is click, it changes the style on the span tag to make it’s contents bold.
    A: Again, building off the previous example… See it here.

    window.onload=function(){
    	countTextNodes();
    }
    function walkTheDOM(node, func) {
    	func(node);
    	node = node.firstChild;
    	while (node) {
    		walkTheDOM(node, func);
    		node = node.nextSibling;
    	}
    }
    function countTextNodes() {
    	var sum = 0;
    	function count (node) {
    		if (node.nodeType == 3) // TEXT_NODE
    	sum++;
    	}
    	var root = document.documentElement;
    	walkTheDOM(root, count);
    	var add_this_copy = (sum + " text nodes found");
    	// alert(add_this_copy);
    	document.getElementById('place_content_here').innerHTML = add_this_copy;
    	return add_this_copy;
    }
    function change_to_bold(){
    	var current_text = document.getElementById('place_content_here').innerHTML;
    	var current_text = ''+current_text+'';
    	document.getElementById('place_content_here').innerHTML = current_text;
    }
    function change_to_normal(){
    	var current_text = document.getElementById('place_content_here').lastChild.innerHTML;
    	document.getElementById('place_content_here').innerHTML = current_text;
    }
    

#p2pu-Jan2011-javascript101

this site is now HTML5

Tuesday, July 13th, 2010

As of today, this site is built using version 5 of Hyper Text Markup Language (HTML5). The bloggery is next! Combining WordPress and HTML5, here we go.

Please update your browser to see the full set of features. The update option is usually under the help option in your browser.

Thanks for keeping your browser technology up to date!

Learning HTML5, as much as I can…

Wednesday, June 2nd, 2010

This is a template for HTML5 pages, I think this is the first technological upgrade in mark up language that I will be actively involved with while it transitions.

This layout is very simple, it uses header, section, footer, aside, nav, article, & figure tags as well as the google js and minor CSS styles needed to make it work cross browser. It also has some notes I collected while reading up on said tags. This is the first draft, but I will use it from here on out to get myself going, HTML5 style. I just want a simple, clean starting point to learn from, I felt other sites were making templates that were over complicated. It has no styles, except one, but it’s pretty self explanatory. Hope it helps you too!

My HTML5 Template