Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Extensions - jQuery

RSS
Modified on Fri, Dec 07, 2012, 12:30 PM by Administrator Categorized as (Favorites), JavaScript, jQuery, and Angular
/*===============================================================================================*/
(function ($) {
    /*-------------------------------------------------------------------------------------------*/
    $.fn.showIf = function (show, fade) {

        if (fade == undefined) fade = false;

        if (show) {
            if (fade) this.fadeIn(); else this.show();
        }
        else {
            if (fade) this.fadeOut(); else this.hide();
        }
        return this;
    }
    /*-------------------------------------------------------------------------------------------*/
    $.fn.enableIf = function (enabled, disabledClass) {

        if (enabled) {
            this.removeAttr('disabled');
            if (disabledClass!= undefined)
                this.removeClass(disabledClass);
        }
        else {
            this.attr('disabled', 'disabled');
            if (disabledClass!= undefined)
                this.addClass(disabledClass);
        }

        return this;
    }
    /*-------------------------------------------------------------------------------------------*/
    $.fn.lockEditIf = function (readOnly) {

        if (readOnly)
            this.removeAttr('readonly');
        else
            this.attr('readonly', 'readonly');

        return this;
    }
    /*-------------------------------------------------------------------------------------------*/
    $.fn.setCheckedIf = function (checked) {

        if (checked)
            this.attr('checked', 'checked');
        else
            this.removeAttr('checked');

        return this;
    }
    /*-------------------------------------------------------------------------------------------*/
    $.fn.validateInt = function (errorClassName) {

        var input = $(this).val();
        if ((input - 0) == input && Math.ceil(input) == Math.floor(input)) {
            $(this).removeClass(errorClassName);
            return true;
        }
        else {
            $(this).addClass(errorClassName);
            return false;
        }
    }
    /*-------------------------------------------------------------------------------------------*/
})(jQuery);
/*===============================================================================================*/

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.