Javascript "object or function?"

יום רביעי, יולי 20, 2011

Hi all,See below example, how to make your javascript code sexy.If you call --> getTimeStamp as variable, return object of the Date.now, but if you call --> getTimeStamp() as function, return a timestamp value. var getTimeStamp = Date.now || function () { return +(new Date).getTime(); }; BestBasil
תגובה אחת

JavaScript Breadcrumbs navigation

יום שבת, ינואר 23, 2010

In this code listing I want to demonstrate how to implement "Breadcrumbs" in JavaScript for the pages collection, where page object have a two main key's pageId and parentPageId, and create a new collection sorted by current parents.   Listing 1:  function page(pageId, parentPageId, title) { return this.constructor(pageId, parentPageId, title); }page.prototype = { // properties pageId: null, parentPageId: null, title: "", setPageId: function(pageId) { this.pageId = pageId; ...

Defining your own functions in jQuery

יום שני, ספטמבר 22, 2008

Defining your own functions in jQuery. In this post i want to present how easy define your own functions in jQuery and using them. As you know, jQuery it's a very rich JavaScript library and it's a pity not to use all it resources. Ok. Do you want to create your own jQuery function to work with elements look like this: $(element).yourfunctionname() What is your steps to define it? At first, define "jQuery.fn" and add to this object your function name see below. (jQuery.fn is a prototype of jQuery object) jQuery.fn.yourfunctionname = function() { var o = $(this) // It's your element}; Now you...
תגיות: , , ,
22 תגובות

jQuery.create() – jQuery plugin to create HTML elements

יום חמישי, אוגוסט 21, 2008

jQuery.create() - it's a featured plugin for jQuery JavaScript Library. You can create any types of HTML elements, set attributes and context or HTML using jQuery.create(). See below the HTML example declaration. I think it make easy and fast your programming in JavaScript. jQuery.create = function() { if (arguments.length == 0) return ; var args = arguments || {}, elem = null, elements = null; var siblings = null; // In case someone passes in a null object, // assume that they want an empty string. ...
תגיות: , , , ,
26 תגובות

JavaScript Repeater Control (dataRepeater) – from jQuery.Presenter.1.0.8 – UIControls Library

יום רביעי, אוגוסט 20, 2008

In this post, I want to present a new JavaScript Repeater Control from my latest UIControls Library jQuery.Presenter 1.0.8. This control like (ASP.NET Repeater Control) created using jQuery Library 1.2.3 and support for later versions. It's a free open source script... Enjoy... /* * jQuery.Presenter 1.0.8 * Author: (basil.goldman@gmail.com) * Description: developed and tested on jQuery 1.2.1, * support and fixes for jQuery 1.2.6 */jQuery.fn.presenter = function() { if (arguments.length == 0) return ; var args = arguments || {}; // Global arguments var controlType = args.controlType; ...
10 תגובות

Understand prototype in JavaScript (JavaScript prototype)

יום שלישי, פברואר 26, 2008

Understand prototype in JavaScript Hi Guy’s Sorry on this syntaxed post, but I think for understand syntax you will read. Follow my comments Hope!!! // Namespace core function core() { return this.constructor('1.0.0.0'); } core.prototype = { // String type version:'', constructor: function(version){ this.version = version; }, remote:{ // Empty }, web:{ ui:{ controls:{ ...
תגיות:
תגובה אחת

How to set absolutePath using CSS expression for AlphaImageLoader (IE) *.png files

יום שני, פברואר 25, 2008

TIP: "Set absolutePath using CSS expression for AlphaImageLoader (IE) *.png files".So what you can do to write absolute path in CSS files not like "HARD CODE" Here attached below examples CSS syntax. Before: _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/ machine/app_resources/ui/images/wrapper.png',sizingMethod='image'); After: _filter: expression("progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ absolutePath +"wrapper.png', sizingMethod='image')"); DESCRIPTION: The absolutePath - is javascript variable get this value "/machine/app_resources/ui/images/" and declared between HTML <head></head> block of page.NOTE: JavaScript variable must to be declared before including CSS files see the next example. <head>     <title>...</title>        <script type="text/javascript">        var absolutePath = "/machine/app_resources/ui/images/";        </script>        <link href="<%=ResolveUrl("~/") %> Read more about CSS Expression
תגיות: , ,
אין תגובות

How to write JavaScript right?

יום שלישי, פברואר 19, 2008

Ok guy's.We are having 3 ways (Prototype, Object and Closure) to write JavaScript but I like at once strong and beautiful "Prototype". Here attached example for Prototype way (with Namespaces, Classes and Methods as in C#). // Namespace Corefunction core() { return this.constructor('release 1.2.3'); }core.prototype = {    version:'',    constructor: function(version) { this.version = version },    remote:{        access:{            get:function(url, data, callback) {                // Do            }        }    },    web:{        ui:{            init:function() {},            controls:{                message:{                    show: function(title, context) {                        // Do                     }                }            }        }    },    user:{        info:{            get: function(userName) {                var property = ;                property = this.prototype.remote.access.get('http://',{rq:userName}, function(){ });                return property;            }        },       ...
תגיות:
3 תגובות

JavaScript String.format & StringBuilder

יום שני, פברואר 18, 2008

// String.Format String.format = function() { var s = arguments; for (var i = 0;i<arguments.length-1;i++){ var reg = new RegExp("\\{"+i+"\\}","gm"); s = s.replace(reg,arguments); } return s; } String.prototype.format = function() { ...
תגיות: ,
תגובה אחת