Sha256: 746f54fed8aec4f48a3cf5ff8df573b399a3e9ecf45ddc14af3177652127ea39

Contents?: true

Size: 1.54 KB

Versions: 101

Compression:

Stored size: 1.54 KB

Contents

/**
 * @file checkbox plugin for jquery-jeditable
 * @author Mika Tuupola, Nicolas CARPi
 * @home https://github.com/NicolasCARPi/jquery_jeditable
 * @licence MIT (see LICENCE file)
 * @name PluginCheckbox
 */
'use strict';
(function ($) {
    $.editable.addInputType('checkbox', {
        element : function(settings, original) {
            var input = $('<input type="checkbox">');
            $(this).append(input);

            $(input).bind('click', function() {
                if ($(input).val() === 'on') {
                    $(input).val('off');
                    $(input).removeAttr('checked');
                } else {
                    $(input).val('on');
                    $(input).attr('checked', 'checked');
                }
            });

        return(input);
        },

        content : function(string, settings, original) {

            var checked = (string === 'yes') ? 'on' : 'off';
            var input = $(':input:first', this);

            if (checked === 'on') {
                $(input).attr('checked', checked);
            } else {
                $(input).removeAttr('checked');
            }

            var value = $(input).is(':checked') ? 'on' : 'off';
            $(input).val(value);
        },

        submit: function (settings, original) {
            var value;
            var input = $(':input:first', this);
            if (input.is(':checked')) {
                value = '1';
            } else {
                value = '0';
            }
            $('input', this).val(value);
        }
    });
})(jQuery);

Version data entries

101 entries across 101 versions & 2 rubygems

Version Path
phcthemes_admin_panel_pack-4.0.7 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-4.0.6 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-4.0.5 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-4.0.3 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-4.0.2 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-4.0.6 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-4.0.1 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-4.0.5 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-4.0.4 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-4.0.3 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-4.0.2 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-4.0.1 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-4.0.0 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-4.0.0 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-3.2.0 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-3.2.0 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-3.1.3 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-3.1.2 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_admin_panel_pack-3.1.1 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js
phcthemes_web_theme_pack-3.0.2 app/assets/javascripts/common/jquery-jeditable/jquery.jeditable.checkbox.js