Subversion Repositories wpShopGermany4

Rev

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


        /**
         * Wrapper, um die Editierfunktion austauschbarer zu machen
         */
        jQuery.fn.wspg_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 (options.type == 'select' && typeof options.data == "string") {
                                
                                var ar = [];
                                var arData = jQuery.parseJSON(options.data);
                                                                
                                for (var i in arData)
                                {
                                
                                        ar.push( { 
                                                'value': i,
                                                'text': arData[i]
                                        } );
                                        
                                        if (arData[i] == jQuery(this).text()) opt.value = i;
                                        
                                }
                                
                                opt.type = 'select';
                                opt.source = ar;
                                
                        }
                        else
                        {
                        
                                opt.display = function(value, sourceData) {
                        
                                        jQuery(this).html(sourceData);
                                
                                };
                                
                        }
                        
                        jQuery(this).editable(opt);
                        
                } );
        
        }