Featured Posts

document.readyState = interactive have a bug in firefox? Well at least I think it is a bug... When the readyState is interactive and not complete, you can use document.getElementById - BUT - you cannot use document.getElementsByName - it will return 'undefined',...

Read more

When Not To Use Drupal? Drupal is an amazing system, with a huge community. So why not use Drupal in every project you'll build? because Drupal is  content oriented - everything is based on nodes. and it can get really ugly...

Read more

My Experience With Backbone.js I will start with saying that i really like Backbone.js, It makes tour code flow more elegantly. Re-using code in Backbone.js is easy - just call the event that handle that. I didn't like so much the...

Read more

Starting With Backbone.js I fell in love with Backbone.js... I mean, I just learned 3 function and I already LOVE IT! I always liked an event driven approach, and I have implemented my own on my projects, Seeing that the basics...

Read more

Starting with Underscore.js Well underscore.js is really straight forward.. and it'd documentation is great! It's easy because all it does is supplying some function for the developer to use when he write his JavaScript. function...

Read more

Backbone.js & Underscore.js Here I Come O so I heard a lot about the usage of Backbone.js and decided to check it out, as it says in the Backbone.js website - Backbone's only hard dependency is Underscore.js. I like to know stuff and because...

Read more

Windows Phone 7 Browser Orientation Detection I just found out that the Windows Phone 7 does not have an orientationChange() event. That sucks! The product I'm working on right now use this feature and it looks great both on Android devices and...

Read more

Annoying JavaScript Bug On Android Browser I'm currently working on a product that is displayed according to the user location on the screen.  This product is for mobile devices & this bug is related to the Iphone bug I already found. Because...

Read more

PHPStorm released a new version Jetbrains just released the new version of PHPStorm 3.0. I took a ride on the trial version and it looks great. The PHP autocomplete is so smart and so useful.  It easy to set up your project. I really...

Read more

Host Your Git Repository for free I found this cool website that you can host your Git repository for free, and it is secure, that mean that it is your private repository that you can share with others but only with the ones you want. That...

Read more

Zuckerberg Q&A A very nice interview with Facebook founder and CEO Mark Zuckerberg from yesterday Y combinator's Startup School. Go to minute 43 to see it, but I suggest to see the whole video. (first few minute are...

Read more

How To Start Implementing Your Idea After working on a few complex project that started from scratch. I can say that the first big challenge is to know where to start. Think And Save Your Thoughts Think, and then think some more, and...

Read more

Another Problem With Quirks Mode On IE7 I thought that with 'document.compatMode' it will be enough to detect the IE Quircks Mode. But as it turns out - it isn't! The 'document.compatMode' command could return the usual 'BackCompat' if it...

Read more

Google Web Fonts API The Google web fonts API is so cool!! You can do very coll things that until now you could do only with images. (Google didn't invented anything new - they just created a VERY cool API that is easy...

Read more

Nice Image With jQuery OK - so I wanted to create a nice "wow" effect when the images are loaded into the page. The only limitation was that the client wanted that he could still add images easily, and that the change would...

Read more

Is The iPhone Supports CSS2 Fully? Well this post started with a bug I found in the iPhone/iPad browser.. I am also not the first to write about this bug. OK - Apple always talking about going HTML5 and supporting it. I Think that a basic...

Read more

Bug Of Safari 4.0.3 On Windows I was trying to modify an element height with JavaScript, It worked on all browsers, even IE6. except on Safari for windows (Safari for Mac was cool too...), This bug was really hard to find - it is...

Read more

Animations And DOM Changes Yesterday I worked on a simple animation, it didn't worked properly - it was just a simple slide-in with an absolute position. and from some weird reason it was not fluent - it just kept on "hiccup" at...

Read more

Slideshow With JQuery Now this is a cool plugin for jQuery! it has amazing slideshow transition effects out of the box. It currently has 12 different type of transition and I must admit - it looks amazing! The WOW Slider...

Read more

Client Side Templating (Handlebars.js library) In the new age of AJAX, It will be great to transfer only data in the AJAX requests and to do the wrapping in the client side. well... there are a lot of JavaScript libraries out there, I am going to focus...

Read more

The Hell With Quirks Mode Why ohh why? It's not like IE is making our developer life better, but the quirks mode is making them a really pain in the &$#!! I am currently working on a new product that need to stick on the...

Read more

JavaScript - Browser Detection A lot of times I need to know what kind of browser the user uses and according to that I do things differently. Sure, most of the detection is testing if it's IE or something else - but there are case...

Read more

How To Learn JavaScript? There are a lot of resources out there that will teach you Javascript. Most of them are OK for the basics, but for the more complex stuff it if really hard to find good resources. A lot of them promise...

Read more

JavaScript - Create your object the right way! You can use JavaScript in so many ways, if you use a lot of variables and function and don't want to mess things up - I suggest that you create an object that will contain all of that, and also will have...

Read more

Javascript - Do we really need it? I encounter a lot a specific question of people who want to "build a website" - What do I need to learn in order to build a website? and truly there is no one special answere.. Here is the long version...

Read more

Cross Domain Calls Well, most programmers don't encounter the cross-domain problem in a day to day life. But the first time you deal with it it looks like the biggest curse of client side programming. It can get really frustrating...

Read more

Canvas - conclusions Well.. after playing around with the canvas feature of HTML5 - I have a few conclusion: It's easy to use when you get deep into it. the basic is easy for everyone - but - If you want to take it to...

Read more

Canvas - Extra Effects On Object Canvas Object Shadow You can assign shadow to any shape / image, even for contours... The use of shadow is easy as everything else. ctx.shadowOffsetX = 2; // X axis distance ctx.shadowOffsetY = 2; //...

Read more

Canvas - Creating Text Beside creating shapes you can also draw text on the canvas. We have lot's of control on how the text will look like. We can control the font type, size color, position and the angle of the text. the filling...

Read more

Canvas - Filling The Shapes We now know how to create shapes, filling the shapes is even easier... Just use the fillStyle property. You can use the fillStyle in a few ways, the most basic way is assigning a color to it.  the color...

Read more

Canvas Curves - Putting It All Together Now that we learned the different types of the curves, all there is left is to give an example that use it all. It's easy to combine between the different types, actually it's easier to combine them than...

Read more

Types Of Curve Paths We already learned how to draw a line, and how to draw a few lines (path) together in the last post. There are few types of curves that we are going to learn about now. The Canvas Arc We already saw...

Read more

Continue With Basic Shapes In the canvas element there are a few types of basic shapes: Rectangles Lines Rounded curves (Circles - but I call them rounded curves because they don't have to be closed... you can specify the...

Read more

Starting With Basic Shapes How to create a rectangle with border? well the example in the previous post was just to intrigue your mind about the use of the canvas, to create any shape on the canvas it's a good idea to start with...

Read more

Using The Canvas With JavaScript After we have our canvas tag in it's place we need a way to interact with it in JavaScript, that's actually pretty simple: // Get a reference to the element. var elem = document.getElementById('myCanvas'); //...

Read more

The Canvas Element To start playing with the canvas you first need to add the canvas element in your HTML. Just insert these lines where you want to position the canvas in your page: <canvas id="example" width="200"...

Read more

Starting Point I thought a lot about what to write in my blog, I want to make it fun and informative. I'm an experienced web developer with a lot of background in PHP, Drupal, HTML, CSS & JavaScript. So, I...

Read more

  • Prev
  • Next

document.readyState = interactive have a bug in firefox?

Posted on : 15-03-2012 | By : gmadar | In : Uncategorized

Well at least I think it is a bug…

When the readyState is interactive and not complete, you can use document.getElementById – BUT – you cannot use document.getElementsByName – it will return ‘undefined’, same scenario at Chrome will work fine.

One of the two have a bug, it looks like it is Firefox bug…

When does it causes a problem?

When you wait for DOM ready in Firefox it’s fired on the interactive mode
(seems like jQuery has the same bug: http://bugs.jquery.com/ticket/10067)
and  although you may think you are on domReady mode -you are not! because document.getElementsByName will return ‘undefined’ (not even an empty array)

Now that is a bug you don’t want to get to know!

When Not To Use Drupal?

Posted on : 15-03-2012 | By : gmadar | In : Uncategorized

Drupal is an amazing system, with a huge community.

So why not use Drupal in every project you’ll build? because Drupal is  content oriented – everything is based on nodes. and it can get really ugly if you are trying to build a complex data types. for example: try building in Drupal a content type that is called “contact” and this data type can have one or more emails, and each contact can have friends who are other contacts. the number of friends a contact can have is not bound (he could have +5,000 friends). This is not an out-of-the-box feature and because of the way Drupal is build – it is not an easy thing to implement.

If you need to develop something complicated that doesn’t have a module that someone else already build – think twice before you are choosing Drupal as your CMS.

Also – if you are building some SaaS that is not a CMS don’t use Drupal – it’s not the way Drupal was build and you will have a lot of traps along development process, choosing some cool MVC like Yii will make your life feel like heaven.

Yii is great because you have your frame work and you can do anything with it.. You are not limited on the DB schema – you create the schema yourself! and Yii has a lot of other functionality awsomeness that maybe I will get into in another post in the the future

Tell me what’s your opinion on this topic,

P.S – all of the above is written on Drupal 6, Since I left Drupal – version 7 was out. I don’t think this kind of problem was fixed but if it is – let me know @gmadar and I’ll post an update.

Happy coding!

My Experience With Backbone.js

Posted on : 13-03-2012 | By : gmadar | In : JavaScript

I will start with saying that i really like Backbone.js, It makes tour code flow more elegantly. Re-using code in Backbone.js is easy – just call the event that handle that.

I didn’t like so much the documentation, for example in a collection – the get() function can get an ‘id’ bat in what format should the id be in? I know it needs to be an integer – but what this integer represents? I’ve tried sending it 0 (zero) to get the first model in the collection, but that didn’t work…

Also – I didn’t used the ‘view’ part of the MVC, why? because the events are hard to manage if I want to control them (bind/unbind) . maybe I didn’t used the Backbone.js library the I should, a better documentation would have helped a lot more.

I had the same documentation problem in Dojo a few years ago, but now the Dojo docs are great (although I’m using JQuery – again because back then the Dojo docs were terrible…)

Overall – I will keep developing in Backbone.js – because it has a lot of great features like the events driven programming, templating, the Underscore.js functions.

Conclusion? definitely try Backbone.js out and I’m sure you will add it to your library tools..

Starting With Backbone.js

Posted on : 02-02-2012 | By : gmadar | In : Uncategorized

I fell in love with Backbone.js… I mean, I just learned 3 function and I already LOVE IT!

I always liked an event driven approach, and I have implemented my own on my projects, Seeing that the basics of what I have implemented with what Backbone.js have done was very similar – made me feel like home. It is just plain logic for using objects that way…

What Do You Mean?

Well.. It is really easy to give my objects the Backbone functionality – just extend it with Underscore (which is the Backbone only dependency.. I wish it didn’t had any dependency at all!!) like so:

_.extend(myObject, Backbone.Events);

from here on I can use the Backbone.js events on my object. So If I will take the event driven approach – let’s bind the object with every ‘buttonClick’ event that will be triggered in the page. (You can use any event name you want – I just made that one up)

myObject.bind("buttonClick", function(msg) {
 ++myObject.counter;
});

Now, whenever the ‘buttonClick’ event will be fired {triggered => in Backbone.js} the object.counter will go up by one. to trigger the event just use

myObject.trigger("alert", "an event");

Now I told you that I loved 3 function what is the third one? the unbind function:

myObject.unbind("buttonClick");

We can also fire a function on every trigger fired on our object using the ‘all’ event.

This is good if you are using one centralized object through your entire scope, but what if I have a few object to deal with? You need an object to know all the other objects, some object called Singleton that will trigger the events when he is triggered (chain triggering? Like a domino effect…) and if you can implement it that way – in most cases you can implement it in one main object. This is a good solution for migrating existing websites into Backbone.js – in the beginning – start from a Singleton that triggers current data on the page, you can develop it on the go…

I’m excited – I only learned 3 function and I love it… gimme some more!

Starting with Underscore.js

Posted on : 31-01-2012 | By : gmadar | In : JavaScript, Uncategorized

Well underscore.js is really straight forward.. and it’d documentation is great!

It’s easy because all it does is supplying some function for the developer to use when he write his JavaScript. function like

  • each()
  • filter()
  • once()
  • delay()
  • extend() – really useful for extending objects

using these function is a good practice because it is a cross-browser – if a browser is implementing a for-each function then underscore will use the native browser function. That means that Underscore.js will be used as a layer to avoid cross browser bugs (fallback function).

Underscore.js is more than a separating layer… it give the developer a robust tools to do things more quickly, like sorting, filtering, templating, string escaping and much more…

Underscore supports chaining, similar to the way JQuery do.

If you want to know what exactly is Underscore.js – it is a set of powerful function that currently not exist in the core JavaScript (most of them) and it will make your life as a developer easier by letting you use them instead of developing them yourself.

As it says so in the Underscore.js site “ It’s the tie to go along with jQuery‘s tux”

Backbone.js & Underscore.js Here I Come

Posted on : 30-01-2012 | By : gmadar | In : JavaScript

O so I heard a lot about the usage of Backbone.js and decided to check it out, as it says in the Backbone.js website - Backbone’s only hard dependency is Underscore.js.

I like to know stuff and because the Underscore.js is a dependency –  I will start from the Underscore and then will move on to Backbone.js…

What is Underscore.js?

Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. It’s the tie to go along with jQuery‘s tux, and Backbone.js‘s suspenders.

OR, in other words : Underscore is a small JavaScript framework that is adding some additional functionality to the existing ones that the JavaScript has.

I will write my learning experience here… of cource…

Windows Phone 7 Browser Orientation Detection

Posted on : 07-12-2011 | By : gmadar | In : Uncategorized

I just found out that the Windows Phone 7 does not have an orientationChange() event. That sucks!

The product I’m working on right now use this feature and it looks great both on Android devices and on iOS devices – but the Windows phone doesn’t have a Javascript event that is fired when the orientation changes… at least I could’nt find one :(

Annoying JavaScript Bug On Android Browser

Posted on : 06-12-2011 | By : gmadar | In : Browser, CSS, JavaScript

I’m currently working on a product that is displayed according to the user location on the screen.  This product is for mobile devices & this bug is related to the Iphone bug I already found. Because the iPhone doesn’t support fix-position before version 5 of their iOS I used position-absolute to position the product.

To calculate the position on the page we are currently in I used the page height and the cursor height, BUT when you zoom in the cursor is getting bigger and although the page size is not changing – the cursor size is getting pretty huge!

Why I think it’s a bug?

because it is! :) if the height of the page (in pixels) is not changing – than the height of the cursor (in pixels) is not changing, and the size that is returned is in pixels. iPhone doesn’t have that bug.

The solution?

Just separate the logic and use position-fixed for Android devices. The problem will be in devices that use versions of Android prior to version 2.1. they will not have a position-fixed. but maybe they don’t have the zoom problem though, need to check that! (where can I find an old Android device? the emulator is not so great….)

Update:(06/12/2011)

The position fixed does not working so well in Android 2.3.5 so I rolled back to the position:absolute and for now I will live with this bug.

Update2:(07/12/2011)

Position fixed on Windows phone 7 will also behave like position absolute… Whats up with that?!?!?

PHPStorm released a new version

Posted on : 01-12-2011 | By : gmadar | In : Uncategorized

Jetbrains just released the new version of PHPStorm 3.0. I took a ride on the trial version and it looks great.

The PHP autocomplete is so smart and so useful.  It easy to set up your project. I really like the integration with PHPUNIT for immediate unit testing (just press SHIFT+F10 and you get an immediate feedback of your tests),  The Git integration look awesome!

I really like an IDE that you can do everything directly from it. and PHPStorm 3.0 sure looks like one of those rare kind.

It has a lot more features – you can learn about them in Jetbrain website. Give it a try – you will love it!

I usually like free & open source, but in this case – It is worth every penny!

Host Your Git Repository for free

Posted on : 13-11-2011 | By : gmadar | In : Uncategorized

I found this cool website that you can host your Git repository for free, and it is secure, that mean that it is your private repository that you can share with others but only with the ones you want.

That feature on github cost at least 9$/mo.

It is totally free, and you can share your repository with up to 5 other users. you can crate as many repositories as you like! now that is a great service.

To create your free Git repository just go to bitbuccket.com.

If you are using Eclipse as your IDE then you can use EGit,  a tool for VCS  with Git directly from Eclipse. The benefit is that you can see all of your changes directly from your IDE (You can also commit, push, etc.. ).

My preferred IDE is PhpStorm and it also has a Git tool. I haven’t used it yet because I currently use IntelliJ in my current job.