Asv3's Blog

December 21, 2009

Skinning YUI Data Table

Filed under: css — Tags: , , , , , , , , — asv3 @ 3:54 pm

we do generally think skinning any css thing is very easy, I started skinning YUI data table with the same assumption, but what turned out is my assumption was wrong, it needed bit more that css sense, that is cascading sense. the better understanding of data table. Finally I am done with that, here is the css for skinning your data table to purple color. append it to your skin.css (inside /assets/skin/sam/ folder)

.yui-skin-sam tr.yui-dt-odd {background-color:#f1edff;}
.yui-skin-sam tr.yui-dt-odd td.yui-dt-asc{background-color:#e5dbff;}
.yui-skin-sam tr.yui-dt-even td.yui-dt-asc{background-color:#f1edff;}
.yui-skin-sam tr.yui-dt-highlighted{background-color:#c6b2ff;}
.yui-skin-sam tr.yui-dt-highlighted td, .yui-skin-sam tr.yui-dt-highlighted td.yui-dt-asc, .yui-skin-sam tr.yui-dt-highlighted td.yui-dt-desc{background-color:#c6b2ff;}
.yui-skin-sam tr.yui-dt-selected{background-color:#7c42d9;}
.yui-skin-sam tr.yui-dt-selected td, .yui-skin-sam tr.yui-dt-selected td.yui-dt-asc, .yui-skin-sam tr.yui-dt-selected td.yui-dt-desc {background-color:#7c42d9;}

make sure you won’t mess with the order, order is more important than the content.

check out preview image @ http://www.flickr.com/photos/ananthara/4202372041/

September 19, 2009

Anonymous Functions, Closure

Filed under: javascript — Tags: , , , , , , — asv3 @ 7:55 am

JavaScript is loosely typed language. You don’t define data type while you declare any variable. But it’s not like it won’t belong to any data type, depending on the value you store, variable automatically changes it’s data type.

Type Casting is possible with JavaScript. But it happens so easily that you don’t have to worry on the type casting.Primitive data types in JavaScript are

  1. Number
  2. String
  3. Boolean
  4. null
  5. undefined

these are the primitive data types, there are other non-primitive data types like Array, Function etc. Primitive data types are passed by value, where as non-primitive data types passed by reference.

Anonymous Functions: A function that is defined without a name is called Anonymous Function. In JavaScript Functions are first-class objects, you can do almost any thing with functions,

  • you can assign them to variables
  • pass as arguments to functions
  • return as result from a function
  • can be constructed run-time

These are the features on JavaScript which makes this language more exiting.

here is an example of anonymous function:

/* Anonymouse Function */

(function(){

    var a=10;

    var b=20;

    alert(a+b);

})();

 

/*Anonymous Function with arguments */

(function(a,b){

    alert(a+b)

})(10,20);

 

 

/* Anonymous function that returns a value */

var sum = (function(a,b){

    return a+b;

})(10,20);

 

//sum eaual tp 30.

Most interesting use of anonymous function is closure. Closure is a protected variable space, created by using nested functions. Here is an example with closure.

var sum;

(function(){

    a=10;

    b=20;

    sum = function (){

        return a+b;

    };

})();

sum has access to a and b, even though it’s executed outside of the anonymous function.

Blog at WordPress.com.