Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript
JavaScript Forum programmation JavaScript. Lire : Cours JavaScript, FAQ JavaScript, Toutes les FAQ JavaScript et Sources JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/11/2011, 00h02   #1
Invité régulier
 
Inscription : avril 2008
Messages : 8
Détails du profil
Informations forums :
Inscription : avril 2008
Messages : 8
Points : 5
Points : 5
Par défaut plugin tinymce galère avec les diférents navigateurs

bonjour,
je galère un peu car je suis plus que débutant en javascript, autodidact et comme un âne je n'ai pas suivi les cours de ce forum ni celui du zero
je suis entrain de créer un plugin tinymce pour intégrer un module diaporama dans un cms (ziteplus).
j'ai réussi à intégrer mon plugin et à faire fonctionner celui ci mais j'ai un souci avec les navigateurs !!!
voici mon code (inspirer d'un autre module qui fonctionne)
Code :
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);
mon souci ce trouve au niveau de l'update
Code :
1
2
3
4
5
6
7
8
		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();
		}
cela fonctionne bien sous firefox mais pas les autres navigateur car le fait d'utiliser remove fait perdre dans tinymce la position initial du noeud ( et ie ne m'implémente pas le "+code"
j'ai essayer avec replace mais mon "+code+" n'est pas implémenter
avez vous des pistes car j'ai quelque personne qui attendent cruellement ce plugin et je rame pour le finaliser
merci par avance
snypi est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 11h05.


 
 
 
 
Partenaires

Hébergement Web