TwitterCounter for @bigclick_dean

dBlog.com.au

My Development Blog

Posts Tagged ‘ Web Development ’

I have been working on a clients project recently and really didn’t like the way the standard selects looked on the page and as we all know they are impossible to style consistently across all browsers. Being a jQuery fan I knew that there must have been an existing plugin to help…but alas there were many plugins that kind of worked, some of them didn’t include a full feature set, some didn’t work in all browsers and some didn’t degrade back to regular selects when needed (e.g. GoogleBot, Screen Readers, no JavaScript, etc).

I did however manage to find a reasonable good custom select over at http://www.adelaidewebdesigns.com/2008/08/01/adelaide-web-designs-releases-customselect-with-icons (even happened to be a fellow aussie!). It wasn’t perfect and it wouldn’t allow for multiple selects on the one page and the icons weren’t really what I needed. Reading through the comments I found that someone else (http://www.ildavid.com/dblog/selectcustomizer/) had made some modifications to allow for multiple selects on the one page. This was great I was getting closer to the solution that I needed, but there were still some issues like keyboard navigation and the ability to click anywhere in the window to close the select just like a regular select.

So I set out to further modify the code and put in some of my own requirements and then re-share it, I have managed to get the drop-down to close when you click outside it, I have also introduced keyboard navigation (up, down and enter). To get the keyboard navigation working I needed to use the scrollTo plugin to allow smooth scrolling up and down in the select.

There are still a few minor bugs that need to be fixed but it works enough for me, one bug is that in IE you need to click in the drop-down area if you don’t want the page to jump when using the keys.

I would also like to get the menu to activate when a user is tabbing around the site, but that’s a job for another rainy day!

$.fn.SelectCustomizer = function(){
    // Select Customizer jQuery plug-in
	// based on customselect by Ace Web Design http://www.adelaidewebdesigns.com/2008/08/01/adelaide-web-designs-releases-customselect-with-icons/
	// modified by David Vian http://www.ildavid.com/dblog
	// and then modified AGAIN be Dean Collins http://www.dblog.com.au
    return this.each(function(){
        var obj = $(this);
		var name = obj.attr('id');
		var id_slc_options = name+'_options';
		var id_icn_select = name+'_iconselect';
		var id_holder = name+'_holder';
		var custom_select = name+'_customselect';
        obj.after("<div id=\""+id_slc_options+"\" class=\"optionswrapper\"> </div>");
        obj.find('option').each(function(i){
            $("#"+id_slc_options).append("<div title=\"" + $(this).attr("value") + "\" class=\"selectitems\"><span>" + $(this).html() + "</span></div>");
        });
        obj.before("<input type=\"hidden\" value =\"\" name=\"" + this.name + "\" id=\""+custom_select+"\"/><div id=\""+id_icn_select+"\">" + this.title + "</div><div id=\""+id_holder+"\" class=\"selectwrapper\"> </div>").remove();
        $("#"+id_icn_select).click(function(a){
			if($("#"+id_holder).css('display') == 'none') {
				$("#"+id_holder).fadeIn(200);
				$("#"+id_holder).focus();
				a.stopPropagation();
				$(document).keypress(function(e) {
					if(!e) var e = window.event;
					e.cancelBubble = true;
					e.returnValue = false;
					if (e.stopPropagation) {
						e.stopPropagation();
						e.preventDefault();
					}
				});
				$(document).keyup(function(e) {

					if(e.which == 40) {
						var lastSelected = $("#"+id_holder+" .selectedclass");
						if(lastSelected.size() == 0) {
							var nextSelected =  $("#"+id_slc_options+" div:first:");
						} else {
							var nextSelected = lastSelected.next(".selectitems");
						}
						if(nextSelected.size() == 1) {
							lastSelected.removeClass("selectedclass");
							nextSelected.addClass("selectedclass");
							$("#"+custom_select).val(nextSelected.title);
           					$("#"+id_icn_select).html(nextSelected.html());
							var rowOffset = (nextSelected.offset().top - $("#"+id_holder).offset().top);
							if(rowOffset > 130) {
								$("#"+id_slc_options).scrollTo(($("#"+id_slc_options).scrollTop() + 27) +  "px");
							}
						}

					} else if(e.which == 38) {
						var lastSelected = $("#"+id_holder+" .selectedclass");
						var nextSelected = lastSelected.prev(".selectitems");
						if(nextSelected.size() == 1) {
							lastSelected.removeClass("selectedclass");
							nextSelected.addClass("selectedclass");
							$("#"+custom_select).val(nextSelected.title);
           					$("#"+id_icn_select).html(nextSelected.html());
							var rowOffset = (nextSelected.offset().top - $("#"+id_holder).offset().top);
							if(rowOffset > 0) {
								$("#"+id_slc_options).scrollTo(($("#"+id_slc_options).scrollTop() - 27) +  "px");
							}
						}
					} else if(e.which == 13) {
						$("#"+id_holder).fadeOut(250);
						$(document).unbind('keyup');
						$(document).unbind('keypress');
						$('body').unbind('click');
					}

				});
				$('body').click(function(){
					$("#"+id_holder).fadeOut(200);
					$('body').unbind('click');
					$(document).unbind('keyup');
					$(document).unbind('keypress');
				});
			} else {
				$("#"+id_holder).fadeOut(200);
				$('body').unbind('click');
				$(document).unbind('keyup');
				$(document).unbind('keypress');
			}

        });
        $("#"+id_holder).append($("#"+id_slc_options)[0]);
		$("#"+id_holder).append("<div class=\"selectfooter\"></div>");
		$("#"+id_slc_options+" > div:last").addClass("last");
        $("#"+id_holder+ " .selectitems").mouseover(function(){
            $(this).addClass("hoverclass");
        });
        $("#"+id_holder+" .selectitems").mouseout(function(){
            $(this).removeClass("hoverclass");
        });
        $("#"+id_holder+" .selectitems").click(function(){
            $("#"+id_holder+" .selectedclass").removeClass("selectedclass");
            $(this).addClass("selectedclass");
            var thisselection = $(this).html();
            $("#"+custom_select).val(this.title);
            $("#"+id_icn_select).html(thisselection);
            $("#"+id_holder).fadeOut(250);
			$(document).unbind('keyup');
			$(document).unbind('keypress');
			$('body').unbind('click');
        });
    });
}


You can see a working demo here

You can also download a full working example here

Popularity: 2% [?]

I sat here for quite some time banging my head against the wall trying to figure out why I was getting a null object reference error for some of my components in a TabNavigator.

After some Googling and hair pulling I found out that only the first tab is actually initialized, while the other tabs only initialized when they were selected…Go figure Adobe to leave this vital point out of the LiveDocs!

Never fear! There is a solution…

On your TabNavigator you need to set the creationPolicy property to all and then all the tabs and their children will be initialized when the application starts.

e.g. <mx:TabNavigator id=”sampleTabNavigator” creationPolicy=”all”>

Hope this saves someone else some time, and hair!

Popularity: 1% [?]

Whilst trekking around the wilderness learning the ins and outs of CakePHP I have compiled a list of helpful CakePHP related sites that have gotten me through some tough times.

After spending so much time finding these resources I thought that I would compile them into a list and publish them.

CakePHP.org

1. Official CakePHP website: The number one source for CakePHP manuals, blogs, API’s, articles and tutorials.

Donutczar.com

2. Donutczar.com: Great information and examples on Helpers in CakePHP 1.2, a really good source for people who want a hand’s on and visual explanation.

Cakebaker

3. cakebaker.42dh.com: Always has new and brilliant ideas for CakePHP applications and offers easy to understand and user-friendly tutorials.

ThinkingPHP

4. ThinkingPHP: Although ThinkingPHP is an all-round PHP information site it also has a very helpful and detailed area dedicated to CakePHP. ThinkingPHP also monitors other popular CakePHP blogs and provides all the information in a common and easy to manage area.

RosSoft

5. Rolsoft.wordpress.com: The RolSoft Blog is an oldie, but a goodie! It has articles on integrating AJAX, speeding up SQL queries in CakePHP and much more. Most of the content is outdated, but it still serves to point people in the right direction and to offer food for thought.

RolSoft

6. Mariano Iglesias: Not only does this blog look amazing, it has buckets of information, everything from CakeFest information, CakePHP tips, framework write-ups and more. This is a a site that you will want to add to your favourites and your blog reader!

Google Group

7. CakePHP Google Group: This is the official Google Code group for CakePHP and it has a large memberbase and has lots of information available. Sometimes it can be a little unwielding to find your way around, but once you have the hang of it you will be flying around in no time.

Tim Trice

8. Tim Trice: This is a great blog that concentrates on articles aimed at the CakePHP beginner. With articles ranging from “What CakePHP can do” through to extending the CakePHP Blog tutorial.

CakePHP.nu

9. CakePHP.nu: Another little CakePHP blog that had a couple of articles that really stood out to me. It is relativly new so there isn’t a great deal of content, but its more like quality over quantity.

In the Kitchen with CakePHP

10. In the Kitchen with CakePHP: This isn’t really a “site” as such but I thought it was worth a mention. “In the Kitchen with CakePHP” is a great tutorial for beginners who need a start to finish walkthrough of CakePHP and its features, it is also useful to have a read before selecting CakePHP as your framework of choice as it goes over many of the key features.

Well for now thats my 10 Helpful resources that got me out of some trouble, if you have any suggestions or comments then please feel free to post them below.

Popularity: 1% [?]

Today is the day that Booksaround, an Australian Online Second hand bookstore is launched.

The CMS for BooksAround was written from scratch and utilises the CakePHP 1.2 framework for everything from inventory management through to payment processing and order fulfillment.

Why CakePHP you ask? Well CakePHP offers a strong yet flexible PHP framework to kickstart application development allowing for a shorter build time and a more affordable project for the client.

The BooksAround CMS allows staff to Add, Edit and Remove books from the database with the ease of integrated Barcode Scanning and automated lookups to ISBN databases such as Amazon and Book Finder. The CMS also allows staff to assign a book source (or Vendor) to each entry in the database and a commission percent, upon sale of a book the application will automatically calculate how much is oweing to the vendor from that sale and apply it to their account.

Payments are processed in real-time through PayPal with their Websites Payments Standard product and the items purchased are automatically marked as sold and Order/Shipping information is sent through to a designated staff member who deals with shipping fulfilment. By using PayPal we were able to completely automate the whole order process from start to finish to ensure that the end-user feels confident in placing an order and that the Site Owner can rest assured that the funds will be cleared before the order is processed.

Nearly every aspect of the site can be modified through the CMS allowing the Site Owner to take complete control of the site and its contents, adding/removing a book, changing vendor details, generating sales reports and even editing page content in real-time are available at their fingertips.

All in all the project was a pleasure to work on and the end result surpassed my expectations on the limited budget, CakePHP once again ame to the party by offering an amazing framework to start with and followed through with a solid, speedy and self contained end product.

So go on over and check out BooksAround.com, there are currently nearly 1,000 books available at a great price and you even receive a 10% discount by ordering online!

-Dean

Popularity: 1% [?]

Come one, come all!

If you are reading this I am assuming that you have randomly stumbled across my web development blog!

First off, a little about myself… By day I am a Web Developer over at YouPlay.com (a casual gaming/puzzle site based in sunny Australia) and by night I slave away by the glow of two LCD screens on anything I can get my hands on, learning new technologies (CakePHP, YUI, jQuery, SmartFox Server, etc), freelance web development and much much more.

I also enjoy going out to the local pub for drinks with mates, having a nice dinner and seeing the latest flicks with my lovely girlfriend and I am a longtime supporter of the Central Coast Mariners Football Club and the Hyundai A-League.

Well thats about it for my first post, hopefully there will be many to come and that they will bring a smile to someone’s face.

Thanks,
-Dean

Popularity: 1% [?]