Text rotation for all

Jonathan Snook has posted a nice nugget on text rotation with CSS that takes a nice bit of markup like this:

  1. <div class="example-date">
  2. <span class="day">31</span>
  3. <span class="month">July</span>
  4. <span class="year">2009</span>
  5. </div>

and converts it to:

all via the CSS:
  1. -webkit-transform: rotate(-90deg);
  2. -moz-transform: rotate(-90deg);
  3. filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

If you have better solution, just tell me !

Even designers are using CSS3?...

Sean Martell is my hero. He did the Bespin logos and a bunch of the Mozilla works in general. When Ben and I were in Toronto we got to see him at work at his WACOM tablet, and it is a sight to behold.

I wish I could do that kind of design work, but for me it isn't to be.... my design is left to code :

Anyway, he has been working a lot on the Fennec (Firefox mobile) design and just
wrote about using CSS3 to build flexible UI elements without recutting UI graphics all over:

Designing UI elements for a mobile browser has taught me a great deal when it comes to creating interactive graphical elements that are to be used in a very small space. Of course, when I say small space, I mean a small space that has the potential to be different for each handset out there. Not only are we talking resolution differences, but the screen DPI can change from device to device as well.

So after resizing and re-slicing the Fennec UI for the second time, I quickly realized that this could be a full-time job for a team of designers depending on the list of handsets Fennec will be appearing on.

Hold the phone… whats this? Firefox 3.5 enables a new slew of fun CSS3 design styles eh? Rounded edges eh? Embedded fonts eh?

gears turning, monkeys typing, hamsters running *

What if we could replace almost all of the graphical UI elements within Fennec with CSS created equivalents? As a designer, am I comfortable bypassing Photoshop and letting CSS run the pixel rodeo? After a few initial tests, the answer to both of those questions was a very solid “yes”. A solid “friggin’ right” if in Cape Breton.

Here are some nice dark toggles:


with code looking like:

CSS:
  1. .toggleONleft {
  2. font-family: ‘DroidSans-Bold’;
  3. text-transform:uppercase;
  4. padding: 0px 8px 0px 12px;
  5. -moz-border-radius-topleft: 0.5em;
  6. -moz-border-radius-bottomleft: 0.5em;
  7. -webkit-border-top-left-radius: 0.5em;
  8. -webkit-border-bottom-left-radius: 0.5em;
  9. border-top: 4px solid #aaa;
  10. border-left: 4px solid #ccc;
  11. border-right: 4px solid #ccc;
  12. border-bottom: 4px solid #ccc;
  13. -moz-border-top-colors:#aaa #bbb #ccc #ddd;
  14. -moz-border-left-colors:#aaa #bbb #ccc #ddd;
  15. -moz-border-bottom-colors:#aaa #bbb #ccc #ddd;
  16. -moz-border-right-colors:#aaa #bbb #ccc #ddd;
  17. background-color: #ddd;
  18. display: inline;
  19. }
  20. .toggleOFFright {
  21. font-family: ‘DroidSans-Bold’;
  22. text-transform:uppercase;
  23. color:#414141;
  24. padding: 0px 12px 0px 8px;
  25. -moz-border-radius-topright: 0.5em;
  26. -moz-border-radius-bottomright: 0.5em;
  27. -webkit-border-top-right-radius: 0.5em;
  28. -webkit-border-bottom-right-radius: 0.5em;
  29. border-top: 4px solid #ccc;
  30. border-left: 4px solid #ccc;
  31. border-right: 4px solid #ccc;
  32. border-bottom: 4px solid #aaa;
  33. -moz-border-top-colors:#aaa #fff #fff #fff;
  34. -moz-border-right-colors:#aaa #dedede #efefef #fafafa;
  35. -moz-border-left-colors:#aaa #dedede #efefef #fafafa;
  36. -moz-border-bottom-colors:#aaa #dedede #efefef #fafafa;
  37. background-color: #fff;
  38. display: inline;
  39. }

If you have better solution, just tell me !

PHP for Microsoft Ajax Library

The Microsoft AJAX Library is a pure-JavaScript library that's used by ASP.NET AJAX but is also available as a separate download. Because it's pure JavaScript, it's not tied to ASP.NET on the backend. PHP for MS AJAX is code to help you make use of the Microsoft AJAX Library from PHP applications. With this first Alpha release, it simply supports exposing PHP classes as AJAX-enabled web services, just as in ASP.NET applications. In fact, the generated proxies are identical to what you get from ASP.NET, meaning you can have full interoperability.

Hello World

The service on the backend so to speak:


HTML:
  1. <?php
  2. require_once '../../dist/MSAjaxService.php';
  3. class HelloService extends MSAjaxService
  4. {
  5. function SayHello($name)
  6. {
  7. return "Hello, " . $name . "!";
  8. }
  9. }
  10. $h = new HelloService();
  11. $h->ProcessRequest();

And the front end that will talk to it:



  1. <title>Hello, World!</title>
  2. <script type="text/javascript" src="../../MicrosoftAjaxLibrary/MicrosoftAjax.js"></script>
  3. <script type="text/javascript" src="HelloService.php/js"></script>
  4. </head>
  5. Name: <input id="name" type="text" />
  6. <input type="button" value="Say Hello" onclick="button_click(); return false;" />
  7. <br />
  8. Response from server: <span id="response"></span>
  9. </body>
  10. <script type="text/javascript">
  11. function button_click() {
  12. HelloService.SayHello($get('name').value, function (result) {
  13. $get('response').innerHTML = result;
  14. });
  15. }
  16. </script>
  17. </html>

If you have better solution, just tell me !


FirePHP: Tying together Firebug and PHP

FirePHP solves the problem of AJAX debugging by sending debug information along with the response. To avoid breaking the response content, the debug information is placed into special HTTP response headers.

This works for all types of requests, not just AJAX requests, which means you can even debug requests for images that are dynamically generated by a PHP script. You can use FirePHP in your development environment, or use it to track down bugs that only appear on your production site.This is what Christoph Dorn has to say about FirePHP in his recent writeup.He goes into detail on how you can setup the Firebug plugin, and how you use it from within PHP:


  1. // use an ini file to turn it on and off
  2. $settings = @parse_ini_file('settings.ini');
  3. if ($settings['FirePHP'] == 'Enabled') {
  4. FB::setEnabled(true);
  5. } else {
  6. FB::setEnabled(false);
  7. }
  8. // log away!
  9. FB::log('This is a log message');
  10. // selectively log
  11. if (Debug::getOption('DisableCache')) {
  12. // code to disable cache
  13. FB::info('Cache has been disabled!');
  14. } else {
  15. // default code
  16. }

Check out the article for more info.

In related news, Zend just stepped it up a notch with their new Zend Server that fits in nicely with the cloud

If you have better solution, just tell me !

Showing progress with the Safari 4 multiple file upload

Andrea Giammarchi has taken the new Safari 4 implementation of multi input file upload functionality and has written an article on how to write the client and server to enable this.He shares the new XHR implementation:


  1. var xhr = new XMLHttpRequest,
  2. upload = xhr.upload;
  3. upload.onload = function(){
  4. console.log("Data fully sent");
  5. };
  6. xhr.open("post", page, true);
  7. xhr.send(binaryData);

and the delves into a PHP server backend that groks things like X-File-Size and X-File-Name.

Then, he shows the client side code to push this all forward and packages it all up:

If you have better solution, just tell me !

Using Base64 encoded images on IE too

Being able to use data: URIs to do interesting things such as inline images is incredibly useful.

IE 8 added support for data URIs but what about older versions of IE (which are still far too prevalent)?

This nice PHP script shows how you can send back data URIs for those who support it, and for older IE, use the message/rfc822 mime type that email clients often use to encode images:

  1. header('Content-type:message/rfc822');
  2. MIME-Version: 1.0
  3. Content-Type: multipart/related; boundary="NEXT_MHTML_DATA_PART"
  4. --NEXT_MHTML_DATA_PART
  5. Content-Location:
  6. Content-Transfer-Encoding: quoted-printable
  7. Content-Type: text/html; charset="utf-8"
  8. <!-- put the HTML in here including a for loop displaying: -->
  9. <div class="img" style="background-image:url(MHTML_IMG<?php echo $index?>)"></div>
  10. --NEXT_MHTML_DATA_PART
  11. Content-Location: MHTML_IMG<?php echo $index?> <!-- for each index -->
  12. Content-Transfer-Encoding: base64
  13. Content-Type: image/png
  14. <!-- the image data here -->
  15. --NEXT_MHTML_DATA_PART
  16. Content-Location: END_OF_MHTML_FILE
  17. Content-Transfer-Encoding: base64
  18. Content-Type: image/png
  19. IE_NEED_THIS_TO_END_DATA

If you have better solution, just tell me!

Chroma Hash: Interesting visualization of your password

Matt Thompson has created a fun little jQuery plugin called Chroma-Hash that "dynamically visualizes secure text-field values using ambient color bars":
Password entry can be frustrating, especially with long or difficult passwords. On a webpage, secure fields obscure your input with •'s, so others can't read it. Unfortunately, neither can you—you can't tell if you got your password right until you click "Log In".

Here is a snippet of the magic:


  1. $(this).css({position: 'absolute',
  2. left: position.left + width - 2,
  3. top: position.top,
  4. height: height + "px",
  5. width: 8 + "px",
  6. margin: 5 + "px",
  7. marginLeft: -8 * (i + 1) + "px"
  8. }
  9. );
  10. });
  11. var id = $(this).attr('id');
  12. var md5 = hex_md5($(this).val());
  13. var colors = md5.match(/([\dABCDEF]{6})/ig);
  14. $(".chroma-hash").stop();
  15. chromaHashesForElement(this).each(function(i) {
  16. $(this).animate({backgroundColor:"#" +
  17. colors[i]});
  18. });

If you have better solution, just tell me !