File manager - Edit - /home/jardides/www/Jardi-design/old/components/com_jce/editor/tiny_mce/plugins/nge/editor_plugin.js
Back
(function () { var matches, partid; tinymce.create("tinymce.plugins.NgePlugin", { init: function (ed, url) { //var css = [ed.documentBaseURI.source+'media/com_nge/css/nge.css']; var css = [ed.baseURI.source+'/plugins/nge/css/nge.css']; ed.contentCSS.append(css); ed.addCommand("mceNge", function () { var ed = tinymce.activeEditor; // éditeur actif dans la page var we_are_in_part = false; var start_part_position = 0; var part_string = ''; // tag html ou est positionné le curseur curTag = ed.selection.getNode().nodeName; curElm = ed.selection.getRng().startContainer; content_text = curElm.textContent; /* deprecate : search for {part [xxx]} // position du cuseur dans la ligne ou l'élément var caretPos; try { caretPos = ed.selection.getBookmark(content_text).rng.startOffset; } catch (e) { caretPos = 1; } console.log(caretPos); // on remonte pour trouver une { ouvrante for(var i=caretPos; i>=0; i--) { // on trouve un } fermant, on est pas dans une part => insertion d'une nouvelle part if(content_text[i] == '}') break; // on trouve un { ouvrant, on est dans une part if(content_text[i]== '{') { we_are_in_part = true; start_part_position = i; break; } } // si on est dans une part, on cherche le } fermant en mettant le contenu de la part en variable if(we_are_in_part) { // on remonte pour trouver une { ouvrante for(var i=start_part_position; i<content_text.length; i++) { part_string += content_text[i]; // on trouve un } fermant, on est à la fin de la part if(content_text[i] == '}') break; // if } // for } // if // recherch d'un numero de part' matches = part_string.match(/{part \[(.*]*)\]}/); */ // get the part id from attribute data-part partid = ed.selection.getNode().getAttribute("data-part"); window.top.partid = partid; data = getData(ed.selection.getNode()); console.log(ed.selection.getNode()); window.top.pkid = ''; if(partid) url_jcck = 'index.php?option=com_nge&view=config&caller=jce&mode=edit&format=raw&pk='+partid else url_jcck = 'index.php?option=com_nge&view=librarygallery&format=raw&caller=jce'; var strbaseuri = window.top.location.href; var prefixe=''; if(strbaseuri.indexOf('administrator')>=0) prefixe = 'administrator/'; url_jcck = ed.documentBaseURI.source + prefixe + url_jcck; // url_jcck = ed.BaseURI.source + url_jcck; if (window.innerHeight==window.parent.innerHeight) { height = window.innerHeight*0.85; width = window.innerWidth*0.85; } else { height = window.innerHeight-100; width = window.innerWidth-100; } ed.windowManager.open({ url: ed.getParam('site_url') + 'index.php?option=com_jce&view=editor&layout=plugin&plugin=nge', width: width , height: height , close_previous: false, inline: true, popup_css: false }, { url_jcck : url_jcck } ); }); function jepHtmlToData(html) { var data = {}; new tinymce.html.SaxParser({ validate: false, allow_conditional_comments: true, start: function(name, attrs) { data = tinymce.extend(attrs.map, data); } }).parse(html); return data; } function getData(element) { if (element.getAttribute("data-mce-object") == "part") { return jepHtmlToData(ed.serializer.serialize(element, {selection: true})); } return {}; } /*ed.onObjectSelected.add( function(e) { if (e.target.getAttribute('data-mce-object') == "part") { //To avoid resizing e.preventDefault(); } });*/ ed.onDblClick.add(function(e) { if (ed.selection.getNode().getAttribute('data-mce-object') == "part") ed.execCommand('mceNge'); }); // preInit function, // transform span part in imgTag ed.onPreInit.add(function() { // Add CSS for customizing parts var editor=ed; var rootClass = '.mceContentBody'; editor.contentStyles.push( rootClass + ' img[data-mce-object=part] {' + 'background: #fff;' + 'border: 1px solid #ccc;' + 'border-radius: 5px;' + 'width: 64px;' + 'height: 64px;' + 'padding: 10px;' + 'cursor: default;' + '}' ); // Allow part elements to be saved editor.schema.addValidElements('part[*]'); // While loading, converts all part tags in the content into placeholder images editor.parser.addNodeFilter('part', function(nodes, name) { var i = nodes.length, ai, node, placeHolder, attrName, attrValue, attribs, innerHtml; while (i--) { node = nodes[i]; if (!node.parent) { continue; } placeHolder = new tinymce.html.Node('img', 1); placeHolder.shortEnded = true; var dataclass = node.attr('data-class'); var srcpath = 'components/com_nge/parts/'+ dataclass.replace('.', '/') +'/thumb.png'; placeHolder.attr({ "data-part": node.attr('data-part'), "data-class": node.attr('data-class'), src: srcpath, "data-mce-object": "part", "class": "mceItemObject mce-object-part" }); node.replace(placeHolder); } }); // While saving, replaces placeholder images with real part tag editor.serializer.addAttributeFilter('data-mce-object', function(nodes, name) { var i = nodes.length, node, realElm, ai, attribs, innerHtml, innerNode, realElmName; while (i--) { node = nodes[i]; if (!node.parent) { continue; } realElmName = node.attr(name); realElm = new tinymce.html.Node(realElmName, 1); // Add specific attributes if (realElmName == "part") { realElm.attr({ 'data-part': node.attr('data-part'), 'data-class': node.attr('data-class') }); // Add text content to avoid tag removing when saving innerNode = new tinymce.html.Node('#text', 3); innerNode.raw = true; innerNode.value = ' '; realElm.append(innerNode); //Replacing tag node.replace(realElm); } } }); }); ed.addCommand("mceNgeInsert", function (editor, partid) { if(!partid && window.top.htmlpart !='' ) { var htmlContent = window.top.htmlpart; var beforeObjects, afterObjects, i, y; beforeObjects = editor.dom.select('img[data-mce-object]'); //editor.insertContent(dataToHtml(this.toJSON())); //editor.insertContent(htmlContent); editor.execCommand('mceInsertContent', false, htmlContent); afterObjects = editor.dom.select('img[data-mce-object]'); // Find new image placeholder so we can select it for (i = 0; i < beforeObjects.length; i++) { for (y = afterObjects.length - 1; y >= 0; y--) { if (beforeObjects[i] == afterObjects[y]) { afterObjects.splice(y, 1); } } } editor.selection.select(afterObjects[0]); editor.nodeChanged(); } }); // Add a button that opens a window ed.addButton('emotions', { image : url+"/img/library.png", title: 'NextGenEditor', cmd : "mceNge", stateSelector: ".part" } ); ed.onNodeChange.add(function(editor, controlManager, node) { controlManager.setActive('emotions', node.className.search("part")>=0); }); } }); tinymce.PluginManager.add("nge", tinymce.plugins.NgePlugin); })();
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings