Updates from January, 2010 Toggle Comment Threads | Keyboard Shortcuts

  • Mohammad Jangda 11:02 am on April 2, 2010 Permalink | Reply
    Tags: email, , ,   

    Plugin Preview: HTML Emails for WordPress 

    HTML emails from WordPress? Yes, please!

    Coming very, very soon!

     
  • Mohammad Jangda 5:17 pm on March 3, 2010 Permalink | Reply
    Tags: , gd, glee,   

    PHP Magic: Building a static countdown clock using PHP and GD 

    Update (2010-04-20): These Gleeks are crazy. Since being released, the clock has been viewed over 200,000 times. Insane.

    If you like Glee, you’ll like this. If you like image processing using PHP, you’ll like this even more.

    Using PHP and the GD image library*, it’s pretty easy to create a static, image-based countdown clock, which is useful for situations where javascript cannot be used (think WordPress.com/Blogger). A new image is automatically generated server-side for every minute (assuming a request is made for the clock for that minute), and all images are cached to avoid killing the server processor. Check it out in action on Gleeks United or after the jump.

    Don’t have code yet, but I’ll post it when I get a chance.

    (More …)

     
    • Eugenia 2:12 pm on March 26, 2010 Permalink | Reply

      How can i put this on my facebook profile?

  • Mohammad Jangda 12:42 pm on February 23, 2010 Permalink | Reply
    Tags: , jqtouch,   

    jQTouch: Tap vs Click 

    jQTouch has a sweet feature which adds a fast touch or “tap” event. It’s pointless for me to try and rephrase, so learn all about it on the jQTouch blog: Milliseconds Responsiveness and the Fast Tap

    Now, the only downside to the tap event, is that it doesn’t work on anything other than Mobile Safari. So for iPhones, you can use tap event, but non-iPhones, you have to use click event. You could just make things easy on yourself and use clicks across the board, but I can tell you that the tap event immensely increases the performance and responsivity for jQTouch apps on iPhones. Good news is, there’s an easy way to work with both.

    The code below was inspired by Samuel’s message on the jQTouch Google Group.

    <script type="text/javascript">
    var userAgent = navigator.userAgent.toLowerCase();
    var isiPhone = (userAgent.indexOf('iphone') != -1 || userAgent.indexOf('ipod') != -1) ? true : false;
    clickEvent = isiPhone ? 'tap' : 'click';
    </script>
    

    You can now easily bind your events as follows:

    <a href="#link" id="mylink">Click or Tap me!</a>
    <script type="text/javascript">
    $('#mylink').bind(clickEvent, function() {
        e.preventDefault();
        alert('Yay! You just ' + clickEvent + 'ed me!');
    });
    </script>
    

    Note: in my testing, the tap event doesn’t register too well on the iPod Touch. If that seems to be the case, I’d recommend defaulting iPod Touches to use clicks instead. However, since the iPod Touch user agent includes the term “iPhone”, we have to un-include it from our tap list:

    <script type="text/javascript">
    var userAgent = navigator.userAgent.toLowerCase();
    var isiPhone = (userAgent.indexOf('iphone') != -1) ? true : false;
    if(userAgent.indexOf('ipod') != -1) isiPhone = false; // turn off taps for iPod Touches
    clickEvent = isiPhone ? 'tap' : 'click';
    </script>
    
     
    • rblon 7:05 am on May 11, 2010 Permalink | Reply

      It appears that if you have <a href=”…” rel=”nofollow”> that, with an iPhone, tapping does activate the link, but not the click event. So

      “You could just make things easy on yourself and use clicks across the board”

      actually doesn’t hold (assuming you want the event handler to run). So to me it seems you always have to include this bit of code.

    • rblon 7:08 am on May 11, 2010 Permalink | Reply

      sorry for the formatting of my previous comment (I had included example html code).

      It should say:

      It appears that if you have “an anchor tag with href”, that, with an Iphone….

    • John 2:58 pm on July 7, 2010 Permalink | Reply

      I run code on a real iPhone / iPod Touch / iPad, but also find that it’s useful to run the same code in Safari (in emulation mode), and in the iPhone simulator (which seems not to handle tap!!??).

      So I’m doing something like this:

      var isRealMobile = (userAgent.indexOf(‘iphone’) != -1 ||
      userAgent.indexOf(‘ipod’) != -1 ||
      userAgent.indexOf(‘ipad’) != -1) &&
      userAgent.indexOf(‘safari’) == -1 && userAgent.indexOf(‘simulator’) == -1;
      var touchEvent = isRealMobile ? ‘tap’ : ‘click’;

      $(“#something”).bind(touchEvent, something);

      Here are the user agent strings I looked at:

      Safari emulating:
      Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16

      Simulator:
      Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Mobile/8A293

      Real iPhone:
      Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Mobile/8A293

    • Tumble Weed 11:30 am on August 5, 2010 Permalink | Reply

      Sooooooooooo much appreciated!!!!!

    • Michael 3:28 am on September 10, 2010 Permalink | Reply

      All, the very good advice of John, but I wonder is it a good idea to track ipod ipad and iphone via indexOf. What if Apple added another mobile, iSomething? Would it not be better to track AppleWebKit.*Mobile using a regexp?

    • Michael 3:32 am on September 10, 2010 Permalink | Reply

      Another thing I found is that on the desktop safari with emulated iphone i had to use “click” and not “tap”. Since I debug on my local host, it is enough to exclude localhost

    • David Mark 1:58 am on November 21, 2010 Permalink | Reply

      The cross-browser solution is to attach both click and tap listeners and cancel one of them the first time through. You know you will get a tap first, so remove the click listener on tap. If the click listener fires, remove the tap listener.

      All of this UA sniffing is for the birds (as you have found out).

    • Chris 9:24 am on June 17, 2011 Permalink | Reply

      I use something similar, checking for iPhone, iPod and iPad, as well as simulator and general mobile devices

      var userAgent = navigator.userAgent.toLowerCase();
      var isMobile = (userAgent.indexOf('iphone') != -1 || userAgent.indexOf('ipod') != -1 || userAgent.indexOf('mobile') || userAgent.indexOf('ipad')) ? true : false;
      clickEvent = isMobile ? 'tap' : 'click';

    • Oskar 8:53 am on November 4, 2011 Permalink | Reply

      You have an error in your code:
      $(‘#mylink’).bind(clickEvent, function() {
      e.preventDefault();
      alert(‘Yay! You just ‘ + clickEvent + ‘ed me!’);
      });

      It should be:
      function(e)

  • Mohammad Jangda 9:33 am on February 10, 2010 Permalink | Reply
    Tags: awesome, ,   

    jQuery.data() = love 

    Why did I never know about jQuery.data()?

    More details to come about fun things you can do with it.

     
  • Mohammad Jangda 1:58 pm on January 29, 2010 Permalink | Reply
    Tags: ,   

    Distraction-free WordPress-ing 

    Zen: distraction-free writing for WordPress.

    Here’s a sneak peek at a plugin I’ve been working on. If you blog using WordPress and you’re a fan of WriteRoom, OmmWriter, or similar tools that help you focus on your words instead of the tools you’re using, then this plugin will soon make your wildest dreams come true (and give you a simple clean environment to write to your heart’s content)! It looks like crap right now, but I’m working on polishing the look and adding some cool features (themes, backgrounds, etc.), and hopefully release something soon.

    If there are any features you’d like to see, add a comment or contact moi.

    Zen: coming soon to anow available in a WordPress Plugin Directory near you!

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel