*Fix* added margin when showing admin bar

Posted by & filed under Uncategorized.

This is probably a massively obvious code snippet, but one that its exclusion has annoyed me for a long time now.

The admin bar in wordpress, whilst helpful, it is a little intrusive on your layout, especially when using a number of absolutely position elements. When you have the admin bar enabled, it *kindly* adds 28px to the top of the page to allow room for it. As said, this can sometime knock out the alignment of your absolutely positioned elements.

In the past I’ve added a couple of lines to my css, to counteract the added margin:

html { margin-top: 0px !important;}
* html body { margin-top: 0px !important;}

However, this will then be present in the css, even when the user isn’t logged in.

So a better method is to use the is_user_logged_in() function – <a href=”http://codex.wordpress.org/Function_Reference/is_user_logged_in”>read more</a>.

I thought best to also put the code into the footer, out the way and also as it is later in the markup, it will have higher importance to that of the other code.

So here’s the code to pop in the footer:

<?php if ( is_user_logged_in() ) { ?>
<style type="text/css" media="screen">
html { margin-top: 0px !important; }
* html body { margin-top: 0px !important; }
</style>
<?php } ?>

And that’s it…

.mousedown() > .click() when using IE8 and focus

Posted by & filed under Uncategorized.

I created some extra features for kupu a while back for work. In a nut shell, when the user click a button, the function places some dummy content where the carat is placed in an iframe, then performs some wizardry then replaces the dummy content with the out put of the wizardry, say a back to top link for example.

This worked fine in the obvious browsers (FF, Chrome, Safari, etc.) and also in IE 6 and 7! The business is in the process of upgrading us to Windows 7, thus adding another layer of fail IE8. It was drawn to my attention that the extra features id created, didn’t work in IE8, GREAT! So i started my line of enquiries…

My first thoughts were that I wasn’t declaring my variables with var whatEver = x, maybe this was causing the errors? Turns out this wasn’t the issue as I added var, wherever i was creating variables, and the features still failed in IE8.

I started to mess around with the code in jsfiddle, trying to work out what the problem was. I noticed that when I was clicking a button in IE8, the focus on the element is wished to change, was lost far quicker than it was in the other *working* browsers. I decided to go down this route.

It turns out that focus is triggered before you .click() function has started. So if your function relies on a specific element having focus, when you click the button, it will lose it before the function is ran. The way around this is to use .mousedown() instead of .click(). Using this method, your element still has focus when the function is ran.

eg:

Try these fiddles out in IE8:

using .click() - http://jsfiddle.net/nXGn9/

$(document).ready(function() { 
    document.getElementById("editor").contentWindow. document.designMode="on";
    $("#imabutton").clcik(loadBackToTop);
    function loadBackToTop(){
        if ($("#editor").is(":focus")) {
            alert('you got it!');
        }
    }
});

using .mousedown() - http://jsfiddle.net/nXGn9/1/

$(document).ready(function() { 
    document.getElementById("editor").contentWindow. document.designMode="on";
    $("#imabutton").mousedown(loadBackToTop);
    function loadBackToTop(){
        if ($("#editor").is(":focus")) {
            alert('you got it!');
        }
    }
});

You see how using .mousedown() differs to .click()? Hope this helps you out, leave a comment if it did/didn’t

Google search results – July

Posted by & filed under Google.

Its been just over a month since I last check my google position, for a number of different key words, so i thought i check to see if i improved. The number in brackets shows the improvement or decline on my position from last month

“freelance wordpress uk – 19 (+20) Great improvement !

freelance wordpress yorkshire – 4 (NA) Wasn’t even showing for this last month

freelance wordpress leeds – 2 (+5) Happy with this

freelance wordpress css – 34 (0) Stayed in the same position, a little dissapointe

freelance wordpress jquery – 1 (+5) Top, what can I say!

freelance wordpress jquery css – 1 (+1) Top again, really happy

freelance wordpress jquery css leeds – 1 (0) Retained my title…

Still reveling in my improvement i decided to get a bit a head of my self and tried less specific key words:

“freelance wordpress” – 35. Shocked, but very happy with this!

“freelance” – NA. Hmmmm

“wordpress” – Now im just being silly

But on a more serious not, it appears that I have ‘freelance wordpress *’ nailed, I maybe now need to work on improving the more generic term ‘Wep Developer’. Checked this and as i expected, no results returned.

So thats my goal for next month, start appearing in the search results for ‘web developer *’

Google search results update

Posted by & filed under Google.

I thought I’d check where I end up in the google search results when querying a few keywords. I thought id also make this a regular thing, so I can track my improvement or demise!

So here’s the results:

“freelance wordpress uk” – 39th. Needs improvement!

“freelance wordpress yorkshire” – gave up looking after the 10th page, definitely needs improvement!

“freelance wordpress leeds” – 7th. Bit better, first page at least.

“freelance wordpress css” – 34th. This could defiantly be better.

“freelance wordpress jquery” – 6th. Again on the first page so can’t complain, but I would like to be higher.

“freelance wordpress jquery css” – 2nd. more like it!

“freelance wordpress jquery css leeds” – 1st as I expected really.

So in conclusion if anyone is looking for a freelance WordPress developer with excellent jquery and CSS skills based in Leeds, I should be a perfect fit! I need to work on the location search results a bit more, plus the CSS, as that’s one of my core skills.

Bones – The HTML5 WordPress Starter Theme

Posted by & filed under Designers' HQ, reblog, Wordpress.

I wrote this post over at Designers’ HQ:

One of the really great things about WordPress is the amount of quality free themes and Bones is no exception!

Bones provides two template options, “classic” and “responsive”, if you’re not familiar with the term responsive, where have you been! Bones its self describes it as:

Designing for multiple devices is a tough task. Right off the bat, you need a flexible and solid starting point. The Responsive version of Bones is that starting point. With a stylesheet setup for media queries and a Mobile First approach, you’ll already be ahead of the curve.

This is by far one of the best, if not the best, theme frameworks i’ve ever come across.

It utilises a number of other cool frameworks including but not limited to; Less,  1140 css grid, Oh and it also uses HTML5!

So what you waiting for, download it and start using Bones!

Browser screen resolution stats rile devs

Posted by & filed under reblog.

StatCounter has announced that its statistics show 1024-by-768 has fallen as the most popular screen resolution, surpassed by 1366-by-768.

The company painted this as a milestone, and CEO Aodhan Cullen remarked: “The data reflects a continuing trend of users moving to larger screen resolution sizes. The screen resolution size people are using is a critical factor for developers when it comes to web design, particularly in the case of fixed-width web pages.”

A very interesting read. I’ve been developing sites, to a minimum screen resolution of 1280 wide for some time now. I must admit though that the sites i’ve been developing haven’t been of fluid design, so mobile users are getting the “full screen” version. This is largely down to the designer only supplying a “full screen” layout. Is it upto the developer to adapt this design for a fluid layout, or should the designer be supplying fluid layouts?

Read the full article