Thursday 20 June 2013

On button click open Jquery calendar

Generally if you find Jquery calendar it will open while you focus the input textbox.

The datepicker is tied to a standard form input field. Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay. Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. If a date is chosen, feedback is shown as the input's value.

So, here is my solution ..while you click on button or link..jquery calendar will open.


Html is
  
    One Time

Style tag
 .ui-datepicker
        {
            top: 29.5px !important;
        }

Script tag
 var textBox = $('#mdatepicker');
        var icon = $('#btnOneTime');
        var mydatepicker = textBox.datepicker
            ({
                minDate: 0, /*Here user can only select future n current date*/
                onSelect: function (selectedDate) {
                    $('#hdnSchdule').val(selectedDate);
                    $('#hdnSchduleType').val(1);
                    $('.button_part a').removeClass("button2").removeClass("button2_active");
                    $('.button_part a').addClass("button2");
                    $('#btnOneTime').addClass("button2_active");
                    // alert(selectedDate);
                    // alert($('#hdnSchdule').val());
                }
            });

        icon.click(function () {
            mydatepicker.datepicker("show");
        });

Monday 17 June 2013

Multiple selection (checkbox) dropdwon client side

Description

Dropdown Check List is a javascript plugin based on the jQuery library that transforms a regular select html element into a dropdown checkbox list.


How does it work?

Dropdown CheckList uses the existing structure of the html select elements on which it is applied to dynamically build a container with checkboxes and labels, then hides the original select element. The plugin does not change in any way the existing select element, it only synchronizes the checked values from the new container to the original select. This approach has the added benefit to allow the use of the plugin with any server technology.
The widget will hide the existing select element by modifying its display attribute to none. The new widget will keep the replaced select options synchronized with the checkbox list so the postback is not affected. The text of the control is composed on the concatenated text of selected options in the list. Because the width of the control will not allways accomodate all selected options, the control will show the full text on hover by setting its title attribute.

Examples

Simple Multi-selector

Nothing originally selected
$("#s1").dropdownchecklist();

In head tag
  jQuery Dropdown CheckList - TESTING
    
    
    

    
    
    
    
    
    
    
    
    
    
    
     

 
    


In body tag
   

Reference link : Click here

 

 

Saturday 15 June 2013

Heighlight portion in Image

 
ImageMapster is a jQuery plugin that lets you activate HTML image maps without using Flash. It works just about everywhere that Javascript does, including modern browsers, Internet Explorer 6, and mobile devices like iPads, iPhones and Androids.


You can see online demo http://www.outsharked.com/imagemapster/

In heade tag

 
    
    
  


In html tag
Venus 123
123 123 123 123

Thursday 13 June 2013

Using #region Directive With JavaScript Files in Visual Studio

Suppose how nice it would be to use #region directive when writing javascript code.
Javascript is becoming more and more complicated, and it is hard to scroll up and down every time we want to find needed function name and see what parameters it accepts.
I was so tired with this scrolling that started to search some alternative small IDE-s or highlighting text editors which would allow me to use collapsible regions in js files, but in this case I would lose javascript intellisense in VS 2008. I even thought about creating my own text editor plug-in for VS, but again - what about intellisense.
Earlier or later, I found one nice solution to the problem on Microsoft forums. Yes - it's so simple. The solution uses simple macros which parses current document and creates collapsible regions for
//#region
//#endregion
pairs.
So simple :)
Thanks to the author!
And because I don't not find it to be easily detectable in the internet, I decided to blog this.

Just do the following steps to support //#region directive:
1) Open Macro explorer:
image

2) Create new macro:
image

3) Name it "OutlineRegions":
image

4) Click "Edit" macro and paste the following VB code into it:
Option Strict Off
Option Explicit Off

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports System.Collections

Public Module JsMacros

    Sub OutlineRegions()
        Dim selection As EnvDTE.TextSelection = DTE.ActiveDocument.Selection

        Const REGION_START As String = "//#region"
        Const REGION_END As String = "//#endregion"

        selection.SelectAll()
        Dim text As String = selection.Text
        selection.StartOfDocument(True)

        Dim startIndex As Integer
        Dim endIndex As Integer
        Dim lastIndex As Integer = 0
        Dim startRegions As Stack = New Stack()

        Do
            startIndex = text.IndexOf(REGION_START, lastIndex)
            endIndex = text.IndexOf(REGION_END, lastIndex)

            If startIndex = -1 AndAlso endIndex = -1 Then
                Exit Do
            End If

            If startIndex <> -1 AndAlso startIndex < endIndex Then
                startRegions.Push(startIndex)
                lastIndex = startIndex + 1
            Else
                ' Outline region ...
                selection.MoveToLineAndOffset(CalcLineNumber(text, CInt(startRegions.Pop())), 1)
                selection.MoveToLineAndOffset(CalcLineNumber(text, endIndex) + 1, 1, True)
                selection.OutlineSection()

                lastIndex = endIndex + 1
            End If
        Loop

        selection.StartOfDocument()
    End Sub

    Private Function CalcLineNumber(ByVal text As String, ByVal index As Integer)
        Dim lineNumber As Integer = 1
        Dim i As Integer = 0

        While i < index
            If text.Chars(i) = vbCr Then
                lineNumber += 1
                i += 1
            End If

            i += 1
        End While

        Return lineNumber
    End Function

End Module
5) Save the macro and close the editor.

6) Now let's assign shortcut to the macro. Go to Tools->Options->Environment->Keyboard and search for your macro in "show commands containing" textbox:
image

7) now in textbox under the "Press shortcut keys" you can enter the desired shortcut. I use Ctrl+M+E. I don't know why - I just entered it first time and use it now :)

That's it, now if you write the following javascript code:
/// <reference name="MicrosoftAjax.debug.js" />
/// <reference name="MicrosoftAjaxTimer.debug.js" />
/// <reference name="MicrosoftAjaxWebForms.debug.js" />

// KWB.BaseWizard class constructor
//#region
Type.registerNamespace("KWB");
KWB.BaseWizard = function(field) {
    // call base constructor
    KWB.BaseWizard.initializeBase(this);
    this._state = null;
}
//#endregion

// KWB.BaseWizard Class Body
//#region
KWB.BaseWizard.prototype = {
    // Sys.Component Overrides
    //#region
    dispose : function () {
        this._state = null;
        this._stateField = null;
        this.lastClicked = null;
        Sys.Application.remove_load(this.appLoad);
        KWB.BaseWizard.callBaseMethod(this, 'dispose');
    },
    
    initialize : function() {
        KWB.BaseWizard.callBaseMethod(this, 'initialize');
    },
    //#endregion
    
    // Properties
    //#region
    get_state : function() {
        return this._state;
    },
    
    set_state : function(value) {
        this._state = value;
    },
    //#endregion
    
    // Methods
    //#region
    getNext : function(current) {
        /// <summary>
        /// Override. Called when 'next' is called. Determines next frame to display
        /// </summary>
        /// <param name="current">current SelectedIndex</param>
        return current + 1;
    },
    
    getPrevious : function(current) {
        /// <summary>
        /// Override. Called when 'previous' is called. Determines previous frame to display
        /// </summary>
        /// <param name="current">current SelectedIndex</param>
        return current - 1;
    },
    
    finish : function() {
        /// <summary>
        /// Override. Called when 'finish' is pressed
        /// </summary>
        return true;
    },
    //#endregion
    
    // Event handlers
    //#region
    nextClick : function() {
        //TODO: add contents later
    }
    //#endregion
};
KWB.BaseWizard.registerClass('KWB.BaseWizard', Sys.Component);
//#endregion

// WizardStepType enumeration
//#region
KWB.WSType = function(){};
KWB.WSType.prototype = 
{
        Server  : 1, 
        Client  : 2,
        Service : 4 
}
KWB.WSType.registerEnum("KWB.WSType", false);
//#endregion

if(typeof(Sys) !== "undefined")Sys.Application.notifyScriptLoaded();

Now click Ctrl+M+E and you will see:
image

Veeery handy !