Файл: wysiwyg/redactor/js/redactor.plugins.js
Строк: 241
<?php
if (!RedactorPlugins) var RedactorPlugins = {};
RedactorPlugins.fontcolor = {
    init: function()
    {
        var colors = ['#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00', '#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca', '#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694', '#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314', '#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100', '#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000'];
        var buttons = ['fontcolor', 'backcolor'];
        this.buttonAddSeparator();
        for (var i = 0; i < 2; i++)
        {
            var name = buttons[i];
            var $dropdown = $('<div class="redactor_dropdown redactor_dropdown_box_' + name + '" style="display: none; width: 210px;">');
            this.pickerBuild($dropdown, name, colors);
            $(this.$toolbar).append($dropdown);
            this.buttonAdd(name, this.opts.curLang[name], $.proxy(function(btnName, $button, btnObject, e)
            {
                this.dropdownShow(e, btnName);
            }, this));
        }
    },
    pickerBuild: function($dropdown, name, colors)
    {
        var rule = 'color';
        if (name === 'backcolor') rule = 'background-color';
        var _self = this;
        var onSwatch = function(e)
        {
            e.preventDefault();
            var $this = $(this);
            _self.pickerSet($this.data('rule'), $this.attr('rel'));
        }
        var len = colors.length;
        for (var z = 0; z < len; z++)
        {
            var color = colors[z];
            var $swatch = $('<a rel="' + color + '" data-rule="' + rule +'" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 15px; height: 15px;"></a>');
            $swatch.css('background-color', color);
            $dropdown.append($swatch);
            $swatch.on('click', onSwatch);
        }
        var $elNone = $('<a href="#" style="display: block; clear: both; padding: 4px 0; font-size: 11px; line-height: 1;"></a>')
        .html(this.opts.curLang.none)
        .on('click', function(e)
        {
            e.preventDefault();
            _self.pickerSet(rule, false);
        });
        $dropdown.append($elNone);
    },
    pickerSet: function(rule, type)
    {
        this.bufferSet();
        this.$editor.focus();
        this.inlineRemoveStyle(rule);
        if (type !== false) this.inlineSetStyle(rule, type);
        if (this.opts.air) this.$air.fadeOut(100);
        this.sync();
    }
};
RedactorPlugins.fontfamily = {
    init: function ()
    {
        var fonts = [ 'Arial', 'Helvetica', 'Georgia', 'Times New Roman', 'Monospace' ];
        var that = this;
        var dropdown = {};
        $.each(fonts, function(i, s)
        {
            dropdown['s' + i] = { title: s, callback: function() { that.setFontfamily(s); }};
        });
        dropdown['remove'] = { title: 'Remove font', callback: function() { that.resetFontfamily(); }};
        this.buttonAdd('fontfamily', 'Change font family', false, dropdown);
    },
    setFontfamily: function (value)
    {
        this.inlineSetStyle('font-family', value);
    },
    resetFontfamily: function()
    {
        this.inlineRemoveStyle('font-family');
    }
};
RedactorPlugins.fontsize = {
    init: function()
    {
        var fonts = [10, 11, 12, 14, 16, 18, 20, 24, 28, 30];
        var that = this;
        var dropdown = {};
        $.each(fonts, function(i, s)
        {
            dropdown['s' + i] = { title: s + 'px', callback: function() { that.setFontsize(s); } };
        });
        dropdown['remove'] = { title: 'Remove font size', callback: function() { that.resetFontsize(); } };
        this.buttonAdd( 'fontsize', 'Change font size', false, dropdown);
    },
    setFontsize: function(size)
    {
        this.inlineSetStyle('font-size', size + 'px');
    },
    resetFontsize: function()
    {
        this.inlineRemoveStyle('font-size');
    }
};
RedactorPlugins.fullscreen = {
    init: function()
    {
        this.fullscreen = false;
        this.buttonAdd('fullscreen', 'Fullscreen', $.proxy(this.toggleFullscreen, this));
        this.buttonSetRight('fullscreen');
        if (this.opts.fullscreen) this.toggleFullscreen();
    },
    toggleFullscreen: function()
    {
        var html;
        if (!this.fullscreen)
        {
            this.buttonChangeIcon('fullscreen', 'normalscreen');
            this.buttonActive('fullscreen');
            this.fullscreen = true;
            if (this.opts.toolbarExternal)
            {
                this.toolcss = {};
                this.boxcss = {};
                this.toolcss.width = this.$toolbar.css('width');
                this.toolcss.top = this.$toolbar.css('top');
                this.toolcss.position = this.$toolbar.css('position');
                this.boxcss.top = this.$box.css('top');
            }
            this.fsheight = this.$editor.height();
            if (this.opts.iframe) html = this.get();
            this.tmpspan = $('<span></span>');
            this.$box.addClass('redactor_box_fullscreen').after(this.tmpspan);
            $('body, html').css('overflow', 'hidden');
            $('body').prepend(this.$box);
            if (this.opts.iframe) this.fullscreenIframe(html);
            this.fullScreenResize();
            $(window).resize($.proxy(this.fullScreenResize, this));
            $(document).scrollTop(0, 0);
            this.focus();
            this.observeStart();
        }
        else
        {
            this.buttonRemoveIcon('fullscreen', 'normalscreen');
            this.buttonInactive('fullscreen');
            this.fullscreen = false;
            $(window).off('resize', $.proxy(this.fullScreenResize, this));
            $('body, html').css('overflow', '');
            this.$box.removeClass('redactor_box_fullscreen').css({ width: 'auto', height: 'auto' });
            if (this.opts.iframe) html = this.$editor.html();
            this.tmpspan.after(this.$box).remove();
            if (this.opts.iframe) this.fullscreenIframe(html);
            else this.sync();
            var height = this.fsheight;
            if (this.opts.autoresize) height = 'auto';
            if (this.opts.toolbarExternal)
            {
                this.$box.css('top', this.boxcss.top);
                this.$toolbar.css({
                    'width': this.toolcss.width,
                    'top': this.toolcss.top,
                    'position': this.toolcss.position
                });
            }
            if (!this.opts.iframe) this.$editor.css('height', height);
            else this.$frame.css('height', height);
            this.$editor.css('height', height);
            this.focus();
            this.observeStart();
        }
    },
    fullscreenIframe: function(html)
    {
        this.$editor = this.$frame.contents().find('body').attr({
            'contenteditable': true,
            'dir': this.opts.direction
        });
        // set document & window
        if (this.$editor[0])
        {
            this.document = this.$editor[0].ownerDocument;
            this.window = this.document.defaultView || window;
        }
        // iframe css
        this.iframeAddCss();
        if (this.opts.fullpage) this.setFullpageOnInit(html);
        else this.set(html);
        if (this.opts.wym) this.$editor.addClass('redactor_editor_wym');
    },
    fullScreenResize: function()
    {
        if (!this.fullscreen) return false;
        var toolbarHeight = this.$toolbar.height();
        var pad = this.$editor.css('padding-top').replace('px', '');
        var height = $(window).height() - toolbarHeight;
        this.$box.width($(window).width() - 2).height(height + toolbarHeight);
        if (this.opts.toolbarExternal)
        {
            this.$toolbar.css({
                'top': '0px',
                'position': 'absolute',
                'width': '100%'
            });
            this.$box.css('top', toolbarHeight + 'px');
        }
        if (!this.opts.iframe) this.$editor.height(height - (pad * 2));
        else
        {
            setTimeout($.proxy(function()
            {
                this.$frame.height(height);
            }, this), 1);
        }
        this.$editor.height(height);
    }
};
?>