{"size": 2476, "ext": "js", "max_stars_repo_path": "public/scripts/properties/addProperty.js", "max_stars_repo_name": "arunssjoshi/Boutique-Retail-Billing", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/scripts/properties/addProperty.js", "max_issues_repo_name": "arunssjoshi/Boutique-Retail-Billing", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/scripts/properties/addProperty.js", "max_forks_repo_name": "arunssjoshi/Boutique-Retail-Billing", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 38.6875, "max_line_length": 117, "alphanum_fraction": 0.4236672052}
var addProperty = function () {
    var totalUnfilledRowsCount
    return {
        init: function () {
            this.registerEvents();
            this.initValidation();
        },
        registerEvents: function(){
            $('#optionWrap').append($('#optionHtml').html());
            $(document).on('keyup','.txtPropertyOption',function(){
                totalUnfilledRowsCount = $('#optionWrap .txtPropertyOption').filter(function(){
                    return $(this).val()=='';
                }).length;
                if(totalUnfilledRowsCount == 0) {
                    $('#optionWrap').append($('#optionHtml').html());
                    parent.$.fn.colorbox.resize({innerHeight:$('.content').height()+40});
                }
            });

            $(document).on('click','.btnDeleteOption',function(){
                if ($('#optionWrap .optionRow').length > 1) {
                    $(this).parents('#optionWrap .optionRow').remove();
                }
            });
        },
        initValidation: function(){
            var newPropertyValidator = $("#frmNewProperty").validate({
                rules: {
                    property: {
                        required: true
                    }
                },
                messages: {
                    property: {
                        required: "Property required",
                    }
                },
                invalidHandler: function(form, validator){
                    parent.$.fn.colorbox.resize({innerHeight:$('.content').height()+80});
                },
                submitHandler: function(form) {
                    $('#btnPropertySave-error').html('').hide()
                    $.post( baseUrl+'/admin/properties/new', $("#frmNewProperty").serialize(), function( response ) {
                        if(response.status) {
                            parent.properties.updateDT();
                            parent.$.fn.colorbox.close();
                        } else {
                            $('#btnPropertySave-error').html(response.message).show();
                        }
                    }, "json");
                }
            });

            $.validator.messages.required = 'Option required';
            jQuery.validator.addClassRules( {
                txtPropertyOption:{
                    required: true,
                    minlength: 1,
                }   
            });
        }
    };
}();
addProperty.init();