Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
442 ddelon 1
 
2
	/*
3
	written by chris wetherell
4
	http://www.massless.org
5
	chris [THE AT SIGN] massless.org
6
	warning: it only works for IE4+/Win and Moz1.1+
7
	feel free to take it for your site
8
	if there are any problems, let chris know.
9
	*/
10
 
11
 
12
	var ACEditor;    /* make sure to change the onload handler of the
13
	 <body> tag to the form you're using!... */
14
 
15
 
16
	 addEvent(window, 'load', startAce);
17
 
18
        function startAce() {
19
 
20
                thisForm=document.ACEditor;
21
        }
22
 
23
 
24
 
25
	function addEvent(obj, evType, fn) {
26
	if (obj.addEventListener) {
27
		obj.addEventListener(evType, fn, true);
28
		return true;
29
		}
30
 
31
	else if (obj.attachEvent) {
32
		var r = obj.attachEvent('on'+evType, fn);
33
		return r;
34
		}
35
 
36
	else {
37
		return false;
38
		}
39
	}
40
 
41
 
42
 
43
	function mozWrap(txtarea, lft, rgt) {
44
		var selLength = txtarea.textLength;
45
		var selStart = txtarea.selectionStart;
46
		var selEnd = txtarea.selectionEnd;
47
		if (selEnd==1 || selEnd==2) selEnd=selLength;
48
		var s1 = (txtarea.value).substring(0,selStart);
49
		var s2 = (txtarea.value).substring(selStart, selEnd)
50
		var s3 = (txtarea.value).substring(selEnd, selLength);
51
		txtarea.value = s1 + lft + s2 + rgt + s3;
52
	}
53
 
54
	function IEWrap(lft, rgt) {
55
		strSelection = document.selection.createRange().text;
56
		if (strSelection!="") {
57
		    document.selection.createRange().text = lft + strSelection + rgt;
58
		}
59
	}
60
	// Cette fonction permet de faire fonctionner l'insertion de tag image dans un textarea de IE sans sélection initiale,
61
	// à la position du curseur
62
 
63
	function IEWrap2(txtarea,lft, rgt) {
64
	    txtarea.focus();
65
    	if (document.selection) {
66
    		txtarea.focus();
67
    		sel = document.selection.createRange();
68
    		sel.text = lft+rgt;
69
    	}
70
	}
71
 
72
	function wrapSelection(txtarea, lft, rgt) {
73
		if (document.all) {IEWrap(lft, rgt);}
74
		else if (document.getElementById) {mozWrap(txtarea, lft, rgt);}
75
	}
76
 
77
	function wrapSelectionBis(txtarea, lft, rgt) {
78
	    // pareil que la wrapSelection, avec une différence dans IE
79
	    // qui permet à wrapSelectionBis de pouvoir insérer à l'endroit du curseur même sans avoir sélectionné des caractères !!!
80
	    // Pour mozilla, c'est bien la fonction Wrap standard qui est appelée, aucun changement
81
 
82
        if (document.all) { // document.all est une infamie de IE, on détecte cette horreur !
83
            IEWrap2(txtarea,lft, rgt); // Attention, un parametre de plus que IEWrap
84
        } else if (document.getElementById) {
85
            mozWrap(txtarea, lft, rgt); // là on est chez les gentils
86
        }
87
	}
88
 
89
	function wrapSelectionWithLink(txtarea) {
90
		var my_link = prompt("Entrez l'URL: ","http://");
91
		if (my_link != null) {
92
			lft="[[" + my_link + " ";
93
			rgt="]]";
94
			wrapSelection(txtarea, lft, rgt);
95
		}
96
		return;
97
	}
98
	/* Aaaxl modif for ACeditor */
99
	function wrapSelectionWithImage(txtarea) {
100
	    nom = document.ACEditor.filename.value;
101
	    descript = document.ACEditor.description.value;
102
	    align = document.ACEditor.alignment.value;
103
 
104
	    lft= " {{attach file=\"" + nom + "\" desc=\"" + descript + "\" class=\"" + align + "\" }} ";
105
	    rgt = "";
106
        wrapSelectionBis(txtarea, lft, rgt);
107
		return;
108
	}
109
 
110
	document.onkeypress = function (e) {
111
	  if (document.all) {
112
		key=event.keyCode; txtarea=thisForm.body;
113
		if (key == 1) wrapSelectionWithLink(txtarea);
114
		if (key == 2) wrapSelection(txtarea,'**','**');
115
		if (key == 20) wrapSelection(txtarea,'//','//');
116
	  }
117
	  else if (document.getElementById) {
118
	  	ctrl=e.ctrlKey; shft=e.shiftKey; chr=e.charCode;
119
	  	if (ctrl) if (shft) if (chr==65) wrapSelectionWithLink(thisForm.body);
120
	  	if (ctrl) if (shft) if (chr==66) wrapSelection(thisForm.body,'**','**');
121
	  	if (ctrl) if (shft) if (chr==84) wrapSelection(thisForm.body,'//','//');
122
	  	//if (ctrl) if (shft) if (chr==85) wrapSelection(thisForm.body,'__','__');
123
	  }
124
	  return true;
125
	}
126
	/* end chris w. script */
127
 
128
 
129
 
130
	/*
131
	written by meg hourihan
132
	http://www.megnut.com
133
	meg@megnut.com
134
 
135
	warning: it only works for IE4+/Win and Moz1.1+
136
	feel free to take it for your site
137
	but leave this text in place.
138
	any problems, let meg know.
139
	*/
140
	function mouseover(el) {
141
		el.className = "raise";
142
	}
143
	function mouseout(el) {
144
		el.className = "buttons";
145
	}
146
	function mousedown(el) {
147
		el.className = "press";
148
	}
149
	function mouseup(el) {
150
		el.className = "raise";
151
	}
152
	/* end meg script */