Put your message here! Contact me for more information
 
 







 

Archive for the ‘CSS’ Category


 

I was implementing an Ajax feature for a project and felt the need to display messages (progressing, savings prompt, etc.) to the users visibly and unobtrusively. Usually, to indicate a background activity, I tend to hide the link/button/checkbox and show a spinning indicator when the Ajax request was created, then return the link when the request has completed. In this case, there is no user-controllable submit button. It is a photo album page which allows users to rearrange their photos by simply dragging-and-dropping the photos into the correct positions. The positions are saved automatically on the fly. If I am to implement a typical spinning indicator, I have to make sure that it is visible enough for the user to know that the positions are being saved. However, if the user is at mid-page, any indicator at the top section of the page won’t be visible. If I place the indicator at the bottom of the page, I still run into the same situation. My solution is to implement a smart “Prompt” bar that stays affixed to the screen. With Prototype and Scriptaculous, implementation is a breeze.

Show, don’t just tell
Here is a demo which you can try out.

Details
This is made possible by using the “position:fixed” feature of CSS. According to W3Schools,

position: fixed
An element with position: fixed is positioned at the specified coordinates relative to the browser window. The element’s position is specified with the “left”, “top”, “right”, and “bottom” properties. The element remains at that position regardless of scrolling. Works in IE7 (strict mode)

The markup
Here is the HTML for the prompt bar. You can place this HTML anywhere in the page. Ideally it should be outside any container.

Some Prompt Here
Cross

CSS

#prompt
{ position: fixed; width: 400px; height: 20px; border: 1px solid #7F7F7F;z-index: 9999; background-color: #F3FF8F; }

#prompt_message
{ float: left; text-align: center; width: 380px; font-weight: bold;}
#prompt_close
{ float: right; width:16px;}

We have to set the prompt bar’s position to be fixed so that it will stay in place when we scroll the browser window.

The script
The javascript code is fairly simple, since Prototype and Scriptaculous already do the all the heavy lifting (e.g. positioning, animation). The only catch with position:fixed div is that we cannot center the prompt div using CSS. We have to explicitly set the left coordinate before we display the bar (line 16, _center() method). This is to also useful when the user resizes the browser window, we recalculate the position and center the div accordingly.

    var Prompt = {
      autoHideTime: 5000

      ,display: function( msg, options ) {
        $('prompt_message').innerHTML = msg;
        Prompt.show();
        if( options && options.autoHide )
          setTimeout('Prompt.hide()', options.autoHideTime || Prompt.autoHideTime );
      }

      ,working: function(msg, options) {
        msg = '  ’ + msg;
        Prompt.display( msg, options );
      }

      , _center: function(){
        $(’prompt’).style.left = ( ( document.viewport.getWidth() - parseInt( $(’prompt’).offsetWidth ) ) / 2 ) + ‘px’ ;
      }

      ,show: function(){
        Prompt._center();
        new Effect.Move ($(’prompt’),{ x: parseInt( $(’prompt’).style.left ), y: 0, mode: ‘absolute’, duration: 0.2 });
      }
      ,hide: function( msg) {
        new Effect.Move ($(’prompt’),{ x: parseInt( $(’prompt’).style.left ), y: -30, mode: ‘absolute’, duration: 0.1 });
      }
    }

Since the code is simple enough, I’d like to leave the details to you to work out.

Enjoy!

Download

I packaged the demo as a zip file so you can grab it and have some fun. Cheers!

view comments
 

if($p) {adsense_deluxe_ads(”);}Opening files with different custom extensions in DreamWeaver is pretty annoying: it’ll ask you for the external edit after shouting out the complain. And yes, after you configure Dreamweaver to open the file (through **Edit > Preference > File Type/ Editors**), you only get a plain Code view of the file. **Where the @#$@#$ is the Design View?** And you are working on the next killer template for a site but the template just happens to be of extension ***.thml**. In this case, I’m talking about **CakePHP**. Its default template extension is ***.THTML**. But don’t worry, be happy. Here is the solution to enable DreamWeaver Design View for any custom filetypes, and ***.THML** in particular.

**Now take a deep breath, I know you’ve been waiting for this answer. I know I have.**

- Go to **[Your_Drive_Here]:\Program Files\Macromedia\Dreamweaver MX 2004\Configuration\**
- Open the file **Extensions.txt** and add your custom extensions to the list. Remeber, in **Extensions.txt**, it’s got to be all CAPS. For **CakePhp**, add **THML** to the first line (the one ends with :All Documents) and the **16th** line of the PHP group. Here is the code for the Extensions.txt fileHTM,HTML,SHTM,SHTML,HTA,HTC,XHTML,STM,SSI,JS,AS,ASC,ASR,XML,XSL,XSD,DTD,XSLT,RSS,RDF,LBI,DWT,ASP,ASA,ASPX,ASCX,ASMX,CONFIG,CS,CSS,CFM,CFML,CFC,TLD,TXT,PHP,PHP3,PHP4,PHP5,TPL,LASSO,JSP,JSF,VB,VBS,VTM,VTML,INC,JAVA,EDML,WML,THTML,INC:All Documents
HTM,HTML,HTA,HTC,XHTML:HTML Documents
SHTM,SHTML,STM,SSI,INC:Server-Side Includes
JS:JavaScript Documents
XML,DTD,XSD,XSL,XSLT,RSS,RDF:XML Files
LBI:Library Files
DWT:Template Files
CSS:Style Sheets
ASP,ASA:Active Server Pages
ASPX,ASCX,ASMX,CS,VB,CONFIG:Active Server Plus Pages
CFM,CFML,CFC:ColdFusion Templates
AS:ActionScript Files
ASC:ActionScript Communication Files
ASR:ActionScript Remote Files
TXT:Text Files
PHP,PHP3,PHP4,PHP5,TPL,INC,THTML:PHP Files
LASSO:Lasso Files
JSP,JST:Java Server Pages
JSF:Fireworks Script
TLD:Tag Library Descriptor Files
JAVA:Java Files
WML:WML Files
EDML:EDML Files
VBS:VBScript Files
VTM,VTML:VTML Files
As this first step is just for Dreamweaver to recognize the new file extensions, we have to further edit another config file.
- Go to the **DocumentTypes** folder (still in the same path), edit the file **MMDocumentTypes.xml**\\ (fullpath: [Your_Drive_Here]:\Program Files\Macromedia\Dreamweaver MX 2004\Configuration\**DocumentTypes\MMDocumentTypes.xml**) with a Text Editor (i.e. Notepad or Notepad++). It’s not advisible to edit this particular xml file with Dreamweaver as the software may go crazy as it’s being used to edit itself.
- Go to l**ine 67**, add the THTML extesion to the **winfileextension** and **macfileextensionlist** attributes. Here is the code exerpt

<br /> <MMString:loadString id="mmdocumenttypes_14" /><br />





- Restart DreamWeaver, then open the .thml of CakePHP. Voila! It’s working! Yay! No more blind-coding.

=== Final Remarks ===

I hope you enjoy the tip. To consult the original documentations, please visit [[http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16410|Dreamweaver Technote: Changing and adding file extensions recognized by Dreamweaver MX]]. if($p)adsense_deluxe_ads(’MediumRectangleLeft’);My final take on this: Dreamweaver is an excellent tool, but the engineers did short of this very important features. Why is it not easier to assign a file extension to be opened with the Design View? Frontpage’s been doing it for years! I don’t know what is the problem with the Dreamweaver team but this is just plain dumb. Sorry, it’s pretty dumb - and it actually managed to be looked over during the user testing. Amazing. But how hard is it to include the new assignment in the GUI? Not that hard at all. -1 for you Dreamweaver!

Anyway, now with the THTML file is through, good luck with CakePHP. Please design the next killer websites to take back the glory for PHP from the RoR crowd.

view comments
 

After surfing around sitepoint.com for a few days, I decided to put up my own proxy site. If Intel have Core Duo 2 (shouldn’t it be Core Quadro or something?), then my site should have dual-proxy — both PHP and CGI flavor.

Besides the regular features of the proxy, I’m thinking about adding countries IP-filtering, which should not be too hard to implement becase the documentations at Maxmind have the code exerpt. So it’s a matter of tweaking the script to work with my site. In light of a site-auction at sitepoint.com forum, .htaccess will also be added to avoid hot-linking. I think there are tons tutorials on how to do this.

Below is a screencast (gif!) of the template is below … I’m pretty happy with the result so far. The design process went really well and I have to admit that I LOVE my stripedesigner.com site. It’s awesome! Can you tell what stripes did I use for this particular design?

LastProxy

Comments are welcome as usual. :)

view comments
 

view comments
 

After another all nighter, I proudly announce the release of Stripe Designer 0.1 for Web 2.0. I guess you have seen those stripes of Web 2.0 applications and wonder how they did it. Or in case you already know how to make those stripes in Photoshop, you know it would take a while to actually make them. Now behold … here comes Stripe Designer to the rescue.

I won’t be explaining much for now as Stripe Designer is a product of merely 4 hours of my sleeping time — it’s not primetime for the big trumpet announcements and big-word proclamation. Just have a look at the Flash demo and give it a shot at Stripe Designer. I will do some more work on the interface and adding more features to it, or even write an article on the coding part (if there are enough requested, I mean just ask)

view comments