1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| var zdiaporamaDialog = {
preInit : function() {
var url;
tinyMCEPopup.requireLangPack();
},
init : function(ed) {
tinyMCEPopup.resizeToInnerSize();
var formObj=document.forms[0];
var dom = ed.dom;
var node = ed.selection.getNode();
var action = "insert";
//std: var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode();
var nl=formObj.elements;
if ((node.nodeName == 'DIV') && (dom.getAttrib(node,'zdiaporama'))) {
action="update";
document.getElementById("rubrique").value=dom.getAttrib(node,'zdiaporama');
prm = dom.getAttrib(node,'param');
nl.insert.value = ed.getLang('update');
} else {
document.getElementById('id').value = '__mce_tmp';
}
document.getElementById("rubrique").onchange();
// prm = prm.replace(/;/g,'&');
prm = prm.split('&');
// valeur par défaut
for (i=0;i<prm.length;i++) {
t=prm[i].split('=');
s0=t[0];s1=t[1];
if ( s0=='h'|| s0=='w'|| s0=='t'||s0=='float'|| s0=='pl'|| s0=='pr'|| s0=='pt'|| s0=='pb') {//si bon paramètre
document.getElementById(s0).value = s1;
}
}
// TinyMCE_EditableSelects.init();
},
getSelectValue:function(form_obj, field_name) {
var elm = form_obj.elements[field_name];
if (elm == null || elm.options == null)
return "";
return elm.options[elm.selectedIndex].value;
},
insert:function() {
var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
var dom = ed.dom;
tinyMCEPopup.restoreSelection();
// Fixes crash in Safari
if (tinymce.isWebKit)
ed.getWin().focus();
paramv = 'ng='+nl.rubrique.value+'&h='+nl.h.value+
'&w='+nl.w.value+'&t='+nl.t.value+'&float='+nl.float.value+'&pl='+nl.pl.value+'&pr='+nl.pr.value+'&pt='+nl.pt.value+'&pb='+nl.pb.value;
tinymce.extend(args, {
zdiaporama : nl.rubrique.value,
param : paramv,
});
var code = '<!--?php echo $this->page_module("zdiaporama","'+paramv+'")?-->';
var stylediv= 'class="zdiapo '+nl.rubrique.value+'_zdiapo" style="height:'+nl.h.value+'px ; Width:'+nl.w.value+'px ; float:'+nl.float.value+'"';
var node = ed.selection.getNode();
if ((node.nodeName == 'DIV') && (dom.getAttrib(node,'zdiaporama'))) {
//on execute l update
ed.dom.remove(node);
ed.execCommand('mceInsertContent', false, '<div id="__mce_tmp" '+stylediv+'>'+code+'</div>', {skip_undo : 1});
ed.dom.setAttribs('__mce_tmp', args);
ed.dom.setAttrib('__mce_tmp', 'id', '');
ed.undoManager.add();
} else {
ed.execCommand('mceInsertContent', false, '<div id="__mce_tmp" '+stylediv+'>'+code+'</div>', {skip_undo : 1});
ed.dom.setAttribs('__mce_tmp', args);
ed.dom.setAttrib('__mce_tmp', 'id', '');
ed.undoManager.add();
}
node = ed.selection.getNode();
ed.addVisual();
ed.nodeChanged();
// ed.execCommand('mceEndUndoLevel');
ed.execCommand('mceRepaint');
tinyMCEPopup.close();
}
};
zdiaporamaDialog.preInit();
tinyMCEPopup.onInit.add(zdiaporamaDialog.init, zdiaporamaDialog); |
Partager