/*
 * $Id: faba5.sectionRaw-1.0.js 4521 2011-11-09 17:57:22Z markus.tripp@fabasoft.com $
 * 
 * Copyright © Fabasoft R&D GmbH, A-4020 Linz, 1995-2011.
 * 
 * All rights reserved. All hardware and software names used are registered trade names and/or registered trademarks of  
 * the respective manufacturers.
 * 
 * The user of this computer program acknowledges that the above copyright notice, which constitutes the Universal 
 * Copyright Convention, will be attached at the position in the function of the computer program which the author has 
 * deemed to sufficiently express the reservation of copyright. It is prohibited for customers, users and/or third  
 * parties to remove, modify or move this copyright notice.
 * 
 * This computer program is protected by copyright law and international treaties. Unauthorized reproduction or 
 * redistribution of this program, or any portion of it, may result in severe civil and criminal penalties.
 * 
 * The use of this software requires a valid license agreement for this software. This license agreement specifies 
 * especially permitted use through the licensing model. A license agreement must already exist prior to installing the 
 * software as the installation process of this software does not include the conclusion of a license agreement.
 */

(function ($) {
    var sectionRawMethods = {
        type: function() {
            return 'raw';
        },
        supports: function(type) {
            return true;
        },
        edit: function(content, edit) {
            var contentHeight = $(this).find('.fcontent').outerHeight();
            var height = Math.max(contentHeight, 100);
            
            var textarea = $('<textarea></textarea>').css({
                width: '100%',
                height: height + 'px'
            });
            
            edit.append(textarea);
            textarea.val($.trim(content.replace(/\&amp;/g,'&')));
        },
        val: function(edit) {
            return edit.find('textarea').val();
        },
        close: function(edit) {
            return true;
        }
    };

    $.fn.sectionRaw = function(method) {
        if (sectionRawMethods[method]) {
            return sectionRawMethods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        }
    };
}) (jQuery);

