Skip to main content

Set Popup in center of window

<script type="text/javascript">

        $(document).ready(function() {

            //select all the a tag with name equal to modal
            $('a[name=modal]').click(function(e) {
                //Cancel the link behavior
                e.preventDefault();

                //Get the A tag
                var id = $(this).attr('href');

                //Get the screen height and width
                var maskHeight = $(document).height();
                var maskWidth = $(window).width();

                //Set heigth and width to mask to fill up the whole screen
                $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

                //transition effect       
                $('#mask').fadeIn(1000);
                $('#mask').fadeTo("slow", 0.8);

                //Get the window height and width
                var winH = $(window).height();
                var winW = $(window).width();

                //Set the popup window to center
                $(id).css('top', winH / 2 - $(id).height() / 2);
                $(id).css('left', winW / 2 - $(id).width() / 2);

                //transition effect
                $(id).fadeIn(2000);

            });

            //if close button is clicked
            $('.window .close').click(function(e) {
                //Cancel the link behavior
                e.preventDefault();

                $('#mask').hide();
                $('.window').hide();
            });

            //if mask is clicked
            // $('#mask').click(function() {
            //   $(this).hide();
            //   $('.window').hide();
            // });

            $(window).resize(function() {

                var box = $('#boxes .window');

                //Get the screen height and width
                var maskHeight = $(document).height();
                var maskWidth = $(window).width();
                //Set height and width to mask to fill up the whole screen
                $('#mask').css({ 'width': maskWidth, 'height': maskHeight });
                //Get the window height and width
                var winH = $(window).height();
                var winW = $(window).width();
                //Set the popup window to center
                box.css('top', winH / 2 - box.height() / 2);
                box.css('left', winW / 2 - box.width() / 2);

            });

        });

    </script>

Comments

Popular posts from this blog

Create Strong Name Assembly

From a VS.NET command prompt, enter the following: 1. Generate a KeyFile sn -k keyPair.snk 2. Get the MSIL for the assembly ildasm SomeAssembly.dll /out:SomeAssembly.il 3. Rename the original assembly, just in case ren SomeAssembly.dll SomeAssembly.dll.orig 4. Build a new assembly from the MSIL output and your KeyFile ilasm SomeAssembly.il /dll /key= keyPair.snk   more read visit : http://www.geekzilla.co.uk/ViewCE64BEF3-51A6-4F1C-90C9-6A76B015C9FB.htm

Caching in ASP.Net

Caching is a technique of storing frequently used data/information in memory, so that, when the same data/information is needed next time, it could be directly retrieved from the memory instead of being generated by the application. The ASP.Net runtime includes a key-value map of CLR objects called cache. This lives with the application and is available via the HttpContext and System.Web.UI.Page. Output Caching: Output cache stores a copy of the finally rendered HTML pages or part of pages sent to the client. When the next client requests for this page, instead of regenerating the page, a cached copy of the page is sent, thus saving time. Data Caching: Data caching means caching data from a data source. As long as the cache is not expired, a request for the data will be fulfilled from the cache. When the cache is expired, fresh data is obtained by the data source and the cache is refilled. Object Caching: Object caching is caching the objects on a page, such as data-boun...

Sql Helper into Xamarin Forms PCL Project

public abstract class SQLiteConnection : IDisposable { public string DatabasePath { get ; private set ; } public bool TimeExecution { get ; set ; } public bool Trace { get ; set ; } public SQLiteConnection ( string databasePath) { DatabasePath = databasePath; } public abstract int CreateTable < T > (); public abstract SQLiteCommand CreateCommand ( string cmdText, params object [] ps); public abstract int Execute ( string query, params object [] args); public abstract List < T > Query < T > ( string query, params object [] args) where T : new (); public abstract TableQuery < T > Table < T > () where T : new (); public abstract T Get < T > ( object pk) where T : new (); public bool IsInTransaction { get ; protected set ; } public abstract void BeginTransaction (); public abstract void Rollback (); public abstract void Co...