Вход Регистрация
Файл: wysiwyg/tinymce/files/plugins/smiles/plugin.min.js
Строк: 93
<?php
tinymce
.PluginManager.add('smiles', function (editorurl) {

    if(!
editor.settings.smiles_url){
        return 
false;
    }

    var 
smiles = [];
    var 
smiles_list = [];

    var 
load = function (callback) {
        if(
smiles.length 0){
            return 
callback();
        }
        $.
ajax({
            
urleditor.settings.smiles_url,
            
type"POST",
            
asyncfalse,
            
success: function(result){
                if(!
result.smiles){ return; }
                for(var 
s in result.smiles){
                    var 
tag '<img class="smile_image" title="'+s+'" src="'+result.smiles[s]+'" />';
                    
smiles.push({
                        
texts,
                        
values,
                        
icontag
                    
});
                    
smiles_list[s] = tag;
                }
            },
            
dataType'json'
        
});
        return 
callback();
    };

    var 
openDialog = function () {
        return 
editor.windowManager.open({
            
title'Insert smiles',
            
body: {
                
type'panel',
                
items: [{
                    
type'collection',
                    
columns'auto',
                    
name'results'
                
}]
            },
            
initialData: {
                
resultssmiles
            
},
            
onAction: function (apidetails) {
                if (
details.name === 'results') {
                    
editor.insertContent(smiles_list[details.value]);
                    
api.close();
                }
            },
            
buttons: [
                {
                    
type'cancel',
                    
text'Close',
                    
primarytrue
                
}
            ]
        });
    };

    
editor.ui.registry.addButton('smiles', {
        
tooltip'Insert smiles',
        
icon'emoji',
        
onAction: function () {
            
load(openDialog);
        }
    });

    
editor.ui.registry.addAutocompleter('smilesComplete', {
        
ch')',
        
minChars1,
        
columns'auto',
        
fetch: function (pattern) {

            return 
load(function (){

                var 
matchedChars smiles.filter(function (char) {
                    return 
char.text.indexOf(pattern) !== -1;
                });

                return new 
tinymce.util.Promise(function (resolve) {

                    var 
results matchedChars.map(function (char) {
                        return {
                            
valuechar.value,
                            
textchar.text,
                            
iconchar.icon
                        
};
                    });

                    
resolve(results);

                });

            });

        },
        
onAction: function (autocompleteApirngvalue) {
            
editor.selection.setRng(rng);
            
editor.insertContent(smiles_list[value]);
            
autocompleteApi.hide();
        }
    });

    return {
        
getMetadata: function () {
            return  {
                
name"Smiles",
                
url"https://instantcms.ru/"
            
};
        }
    };
});
?>
Онлайн: 0
Реклама