About design and nearby

How to Use Multiple Fonts powered by Cufón on the Same Page

Posted: May 12th, 2012 | Author: Julia | Filed under: Tips and Tricks | Tags: , , | No Comments »

When I need to use any custom font at my design, my usual choice is Cufon javascript library. Once I was trying to implement 2 different cufon fonts on the same page. The solution is pretty easy, but you should know where to look for ))

  1. <script type="text/javascript">
  2.         $(document).ready(function () {      
  3.         Cufon.replace('.apercu_bold', { fontFamily: 'Apercu' });
  4.         Cufon.replace('.apercu_reg', { fontFamily: 'Apercu Light' });  
  5.         });  
  6. </script>

How do I know that my fontFamily are ‘Apercu’ and ‘Apercu Light’? I’ve generated 2 files for my fonts (apercu_700.font.js and apercu_light_300.font.js). Cufon is getting the registration information with the curve data for each font. So if you view the source, you find how your custom fonts are named – line 29 for me, Cufon.registerFont({”w”:213,”face”:{”font-family”:”Apercu”,…}});


Mobile-friendly jQuery Lightbox Solution

Posted: May 1st, 2012 | Author: Julia | Filed under: Tips and Tricks | Tags: , , , , | No Comments »

Everyone knows jQuery LightBox plugin – it’s simple and elegant, used for handling images through the power of jQuery’s selector. It’s perfect for image galleries, portfolios (for example, try my portfolio page >> view full size images).

The plugin works perfect, just one day while testing a client’s website for mobile devices, I found a bug – every full size image appeared at the very bottom of my page and was hidden for the very first sight, I had to scroll down the page to see it.

After setting up alerts and trying the result )) the solution for Lightbox v2.05 (by Lokesh Dhakar) was found – see line 245 or nearby:

  1.  if ((navigator.userAgent.match(/HTC_/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i|>) ||
  2.         navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/blackberry/i|>) ||
  3.         navigator.userAgent.match(/Windows Phone OS 7/i) || navigator.userAgent.match(/webOS/i|>))) {
  4.  
  5.             var arrayPageScroll = document.viewport.getScrollOffsets();
  6.             var lightboxTop = arrayPageScroll[1] + (100);
  7.             var lightboxLeft = (jQuery(window).width() / 2 – document.viewport.getWidth() /|> 2);
  8.             this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();
  9.  
  10.             this.changeImage(imageNum);
  11.         }
  12.         else {
  13.             // calculate top and left offset for the lightbox
  14.             var arrayPageScroll = document.viewport.getScrollOffsets();
  15.             var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
  16.             var lightboxLeft = arrayPageScroll[0];
  17.             this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();
  18.  
  19.             this.changeImage(imageNum);
  20.         }
  21.     },

Note: I used navigator.userAgent.match(/HTC_/i) because navigator.userAgent.match(/Android/i) had no result for my HTC.

You can load Lightbox v2.05 with my changes here.

Related post: Your Mobile Website: be Up-to-Date!


How to Disable Button until Input Fields Have Values (powered by jQuery)

Posted: March 21st, 2012 | Author: Julia | Filed under: Tips and Tricks | Tags: , , , | No Comments »

One [working] day I was in need of a disabled submit button until my input fields have value. It’s a typical solution if you propose any service only after signing an agreement by your users (as it was at my case).

I had a form with input fields and a submit button on my page, I would like to have the feature that the ’submit’ button is disabled until there are values on input fields. This button should be clickable if and only if there are values input in all fields.

I decided to implement this with jQuery (so I included the jquery library at the head section firstly).
Read the rest of this entry »


Cufón.js and Hover Effect

Posted: March 8th, 2012 | Author: Julia | Filed under: Tips and Tricks | Tags: , , , , | No Comments »

One of the problems for Cufon developers is the strange behaviour of elements powered by Cufon.js which have defined :hover state in the CSS stylesheet. I stumbled upon this and tried so many different things to make it work the correct way… My

  1. .cufon a:hover {color:#e7aa05;}

had no results, so after reading the official docs I set hover option for the certain element at the very beginning of my file – sure, after loading my custom Cufon script. The key phrase for the solution is ‘hover calls must go first’, because the hover option cannot be added to an element that has been replaced before:

  1. <script type="text/javascript"> // should be called in the first place
  2.     Cufon.replace('a.cufon', {
  3.         color: '#222',
  4.         hover: {
  5.             color: '#e7aa05'
  6.         }
  7.     });
  8. </script>
  9. <script type="text/javascript"> // should be called after
  10.     Cufon.replace(".cufon", {
  11.         textShadow: '1px 1px 1px white'
  12.     });    
  13. </script>

Live example: click here>>

Related post: Using Non-standard Fonts with Cufón.js
Related post: Using Cufón.js with jCarousel


How to Make Sweet Buttons with CSS only

Posted: February 29th, 2012 | Author: Julia | Filed under: Tips and Tricks | Tags: , , | No Comments »

Buttons are a very important element of any website, through buttons visitors trigger an action and interact with content.

As for my mind, CSS buttons are much more efficient than image-based buttons. They are rather easier to handle. It’s pretty simple to create dynamic buttons with cross browser compatibility, let me show the way I do it.

Since I need my button to be flexible, I make its width expand with the size of the button’s text and I use an <a> tag for that:

  1. <a class="button" href="#">CSS Button</a>

Read the rest of this entry »