Вход Регистрация
Файл: concrete5.7.5.6/concrete/js/build/core/redactor/magic.js
Строк: 139
<?php
if (typeof RedactorPlugins === 'undefined') var RedactorPlugins = {};

RedactorPlugins.concrete5magic = function() {

    return {
        
styles: [],

        
createButton: function(dropdown) {
            if (!
dropdown) {
                var 
dropdown = [];
            }
            var 
plugin this.concrete5magic;
            var 
btn;

            
this.button.remove('styles');
            if (
this.button.get('formatting').length) {
                
btn this.button.addAfter('formatting','styles'this.lang.get('customStyles'), falsedropdown);
            } else {
                
btn this.button.add('styles'this.lang.get('customStyles'), falsedropdown)
            }
            
this.button.setAwesome('styles''fa-magic');
            
this.button.addDropdown(btndropdown);
        },

        
init: function() {

            var 
plugin this.concrete5magic;
            var 
that this;

            $.
ajax({
                
'type''get',
                
'dataType''json',
                
'url'CCM_DISPATCHER_FILENAME '/ccm/system/backend/editor_data',
                
'data': {
                    
'ccm_token'CCM_EDITOR_SECURITY_TOKEN,
                    
'cID'CCM_CID
                
},

                
success: function(response) {
                    var 
dropdown = {};

                    
plugin.snippetsByHandle = {};
                    $.
each(response.snippets, function(isnippet) {
                        
plugin.snippetsByHandle[snippet.scsHandle] = {
                            
'scsHandle'snippet.scsHandle,
                            
'scsName'snippet.scsName
                        
}
                        
dropdown[snippet.scsHandle] = {
                            
'title'snippet.scsName,
                            
'func': function(option$itemobje) {
                                var 
selectedSnippet plugin.snippetsByHandle[option];
                                var 
html String() +
                                    
'<span class="ccm-content-editor-snippet" contenteditable="false" data-scsHandle="' selectedSnippet.scsHandle '">' +
                                    
selectedSnippet.scsName +
                                    
'</span>';

                                
that.insert.htmlWithoutClean(html);
                            }
                        }
                    });

                    var 
button that.button.get('styles');

                    
that.styles response.classes;
                    
jQuery.each(response.classes, function(is)
                    {
                        
dropdown['s' i] = { titles.titleclassName:s.menuClassfunc: function() { plugin.setCustomFormat(s); }};
                    });

                    
dropdown['remove'] = { titlethat.lang.get('remove_style'), func: function() { plugin.resetCustomFormat(); }};
                    
plugin.createButton(dropdown);

                }
            });
            
plugin.createButton();

        },

        
setCustomFormat: function (s)
        {
            if (
s.forceBlock != -&& (s.forceBlock == || (s.wrap && !(jQuery.inArray(s.wrap,['a','em','strong','small','s','cite','q','dfn','abbr','data','time','var','samp','kbd','i','b','u','mark','ruby','rt','rp','bdi','bdo','span','sub','sup','code']) > -1)))) {
                if(
s.wrapthis.selection.wrap(s.wrap);
                if(
s.stylethis.block.setAttr('style',s.style);
                if(
s.spanClassthis.block.setClass(s.spanClass);
            }
            else {
                if(
s.wrapthis.inline.format(s.wrap);
                if(
s.stylethis.block.setAttr('style's.style);
                if(
s.spanClassthis.inline.toggleClass(s.spanClass);
            }
        },
        
resetCustomFormat: function()
        {
            var 
that this;
            
jQuery.each(this.styles, function(i,s) {
                if(
s.spanClass) {
                    
that.inline.removeFormat();
                    
that.block.removeClass(s.spanClass);
                }
            });
        }
    }

}
?>
Онлайн: 1
Реклама