Using text-indent with text-align

So… I found something interesting on this. (after reading this)

If you have an element with `text-align:right` and you indent the text left (`text-indent:-9999px`) the text will show.

I guess aligning text one direction and indenting another is rather contradictory. However, changing the `text-indent` to a positive number (`text-indent:9999px`) the indent is respected.

However, a more elegant solution is to not indent the text at all but to push it outside the element.

JS Fiddle: http://jsfiddle.net/robche/TNdbh

Facebook Events SDK

I’ve been playing with the Facebook SDK over the last few weeks and thought I’d share a little of my frustrations…

Firstly, when working with a page rather than a user it can be very frustrating. Finding the User ID of the page is troublesome in itself – this page helped : http://findmyfacebookid.com.

Firstly, download the Facebook SDK from GitHub and include the facebook.php file – then you will need to register your application to get the App ID and Secret.

Once you have these and your access token you can start to write queries. Here’s a query to get a list of events for a particular user (in this case a Facebook Page).

ff

Running Expression Engine locally

OK – so I came across an issue earlier where I couldn’t save template files from the Expression Engine Dashboard as I kept getting the error:

Unable to save your template as a text file

It was really frustrating as you are required to input the full ‘server path’ to your template files. For me, I assumed this would only go back as far as the MAMP server directory but I was wrong. Instead I had to specify the full machine path.

In my case (MacBook Pro) : /Users/robhadfield/Dropbox/Web/ExpressionEngine/system/expressionengine/templates/

I’m new to EE so maybe this will be the last time I forget this… Until then, I’ll just leave the is here as a reminder :)

Instagram’s new terms of service clarify how it uses your data for advertising — Tech News and Analysis

Source : Instagram’s new terms of service clarify how it uses your data for advertising — Tech News and Analysis.

So, the Facebook acquisition many Instagram users were dreading seemed unfounded – no loss of service, no change to the lovely user interface and

Instagram updated its terms of service on Monday, elaborating on how it can use personal data for advertising purposes, and making clear that user photos and information can be used across the web as the photo-sharing app works through monetization under Facebook.

So, not only can Instagram (Facebook) push advertising to you they can also make money from using your data and imagery in advertising.

The link to the terms is here : http://instagram.com/about/legal/terms/updated/. Read it carefully… then download your images and delete your account? :(

Instagram API basics

The Instagram API is pretty easy to use – as with most APIs these days, send off a URL request and get a bunch of JSON data back to display in your page.

There are a few things you need to do, here’s the steps I used:

1 ) Register your application

Head over to http://instagram.com/developer, log in and register your app. The developer console will then provide you with two ‘keys’, Client ID and Client Secret. Keep this page open or paste them somewhere – you will need them in a mo.

2 ) Send for token

Use the following URL, replacing the client ID and the Return URL (Uri) provided when you registered your app. ( [ClientID] & [callbackuri] ). Paste into your browser and hit “Go” – it will send a request to authenticate your app and return to your chosen Return URL.

https://instagram.com/oauth/authorize/?display=touch&client_id=[ClientID]&redirect_uri=[callbackuri]&response_type=token

When this returns, you will see a token appended to the URL. eg: http://robhadfield.co.uk/?access_token=123ABC123ABC. Grab this and paste it somewhere safe, this is your authentication code.

3 ) Send an Ajax request to Instagram

Here we send our request for data to the Instagram API:

$.ajax({
    type: "GET",
    dataType: "jsonp",
    cache: false,
    url: "https://api.instagram.com/v1/users/[UserID]/media/recent/?access_token=[CODE]",
    success: function(data) { ... }
});

4 ) Now we write a function to pull back the images

The API has loads of data attached to each image. User / User Avatar / Date /TAGS etc etc. What we’re interested in is the image and the URL of the original image (Instagram page).

function(data) {
    for (var i = 0; i < 10; i++) {
        $(".instagram_catch").append("<a target='_blank' href='" + data.data[i].link +
"'><img src='" + data.data[i].images.low_resolution.url +"'></img></a>");
    }
}

This code is looping over the results 10 times and using the data fields “link” and “images > low_resolution”. “Link” is the link back to the Instagram page for the image and image.low_resolution is a large, but low resolution version of the image. Other options include standard_resolution, and thumbnail.

http://instagram.com/developer/endpoints/media/

It’s a simple loop, building an HTML string then appending it to an element with the class “instagram_catch”.

And that’s it. I hope that makes sense – I hope I haven’t missed anything, if I have drop me a comment and I’ll amend the post.

See it in use here : Laurel Canyons (this time using the hash tag “#laurelcanyonsband”).

CSS : hover classes on mobile

I’ve recently ditched using the CSS pseudo class :hover.

CSS has a few pseudo classes that existed way before mobile was being considered – how were to know we would have devices without those pesky little mice hovering all over the screen?

The problem I have found is that mobile touch events often ‘activate’ the hover class but do not register the click – but elements without a hover class work just fine. A single click just displayed the hovered element in all its glory but went nowhere – in the best cases a second click took you to the link, in the worst cases the link died altogether! Rendered unclickabbababable by the hover pseudo class.

So what to do?

Well, this is fresh out of my brain so don’t take my advice quite yet but I’ve switched to using javascript to render any hover actions for now. In my javascript (jquery), I identify the device and serve a hover class if it will accept it.

http://detectmobilebrowsers.com

I’ve used the detectmobilebrowsers scripts with great success recently, detecting mobile user agents to serve flash/non-flash content from an old (pre-jquery) site. I even added my own to the list to look for the latest Nexus-7 device.

Once you have identified your device you can choose to serve it a hover effect:

if($mobile){
    $(window).on('hover', '$link', function(){
        $(this).css('background-color' , 'red')
    })
}

It’s clunky looking and long but you get the idea – but more importantly it works. No more dead links.

I’ll probably update this when I create a better, more elegant approach. Probably.