Subversion Repositories wpShopGermany4

Rev

Rev 5934 | Rev 6244 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed


        /**
         * Wrapper, um die Editierfunktion austauschbarer zu machen
         */
        jQuery.fn.wpsg_editable = function(url, options) {
        
                return this.each(function() {
                        
                        var opt = { 
                                'type': 'text',
                                'url': url,
                                'pk': 1,
                                'ajaxOptions': {
                                        'type': 'post'
                                },
                                'params': options['submitdata'],
                                'placeholder': wpsg_ajax.ie_placeholder,
                                'emptytext': wpsg_ajax.ie_emptytext,
                                'validate': function(value) {
                                        
                                    //if(jQuery.trim(value) == '') { return wpsg_ajax.ie_validate_empty; }
                                    
                                }                               
                        };

            if (typeof options.type == "string") opt['type'] = options.type;

                        if (options.type == "select" && Array.isArray(options.data))
                        {
                                 
                                var value = "0";
                                var strValue = jQuery(this).html();
                                
                                for (var i in options.data)
                                {
                                
                                        if (options.data[i].text == strValue) value = options.data[i].value;
                                        
                                }
                                
                                opt.source = options.data;
                opt.type = 'select';
                opt.value = value;
                                
                        }                        
            else if (options.type == 'multiarray')
            {

                var ar = [];
                var arData = jQuery.parseJSON(options.data);
                                var strValue = jQuery(this).html();
 
                for (var i in arData)
                {

                    objData = { 'text': arData[i].name, 'children': [] };

                    for (var j in arData[i]['fields'])
                    {

                        objData['children'].push( { 'value': j, 'text': arData[i]['fields'][j] } );

                                                if (arData[i]['fields'][j] == strValue) value = j;
                                                
                    }

                    ar.push(objData);

                }

                opt.source = ar;
                opt.type = 'select';
                                opt.value = value; //j;

                        }
                        else
                        {

                                opt.display = function(value, sourceData) {
                        
                                        jQuery(this).html(sourceData);
                                
                                };
                                
                        }

            if (typeof options.callback == "function") opt.success = options.callback;
                        
                        jQuery(this).editable(opt);
                        
                } );
        
        }