Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript > Bibliothèques & Frameworks > Prototype & Script.aculo.us
Prototype & Script.aculo.us Forum d'entraide sur les frameworks Prototype et Script.aculo.us
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 13/09/2007, 11h34   #1
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
Par défaut Framework prototype Event OnKeyPress

Bonjour, je travaille actuellement sur un framework de javascript. il me sert a afficher une pop-up. je souhaite que cette pop up se ferme avec la touche echap.

voici le code :

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
var Window = Class.create();
Window.keepMultiModalWindow = false;
Window.prototype = {
	// Constructor
	// Available parameters : className, title, minWidth, minHeight, maxWidth, maxHeight, width, height, top, left, bottom, right, resizable, zIndex, opacity, 
	//                        hideEffect, showEffect, showEffectOptions, hideEffectOptions, effectOptions, url, draggable, closable, minimizable, maximizable, parent, onload
	initialize: function(id) {
	  //if ($(id))
	    //alert("Window " + id + " is already register is the DOM!!, be sure to use setDestroyOnClose()")
	    
		this.hasEffectLib = String.prototype.parseColor != null;
		this.options = Object.extend({
		  className:         "dialog",
      minWidth:          100,
      minHeight:         20,
      resizable:         true,
      closable:          true,
      minimizable:       true,
      maximizable:       true,
      draggable:         true,
      userData:          null,
      showEffect:        (this.hasEffectLib ? Effect.Appear : Element.show),
      hideEffect:        (this.hasEffectLib ? Effect.Fade : Element.hide),
      showEffectOptions: {},
      hideEffectOptions: {},
      effectOptions:     null,
      parent:            document.getElementsByTagName("body").item(0),
      title:             " ",
      url:               null,
      onload:            Prototype.emptyFunction,
      width:             200,
      height:            300,
      opacity:           1,
      recenterAuto:      true
    }, arguments[1] || {});
    		
	  if (this.options.effectOptions) {
	    Object.extend(this.options.hideEffectOptions, this.options.effectOptions);
	    Object.extend(this.options.showEffectOptions, this.options.effectOptions);
	  }
		if (this.options.hideEffect == Element.hide)
		  this.options.hideEffect = function(){ Element.hide(this.element); if (this.destroyOnClose) this.destroy(); }.bind(this)
		  
		this.element = this._createWindow(id);
		
		// Bind event listener
    this.eventMouseDown = this._initDrag.bindAsEventListener(this);
  	this.eventMouseUp   = this._endDrag.bindAsEventListener(this);
  	this.eventMouseMove = this._updateDrag.bindAsEventListener(this);
  	this.eventOnLoad    = this._getWindowBorderSize.bindAsEventListener(this);
    this.eventMouseDownContent = this.toFront.bindAsEventListener(this);
    if (this.options.recenterAuto)
      this.eventResize = this._recenter.bindAsEventListener(this);
 
		this.topbar = $(this.element.id + "_top");
		this.bottombar = $(this.element.id + "_bottom");
    this.content = $(this.element.id + "_content");
    
		Event.observe(this.topbar, "mousedown", this.eventMouseDown);
		Event.observe(this.bottombar, "mousedown", this.eventMouseDown);
		Event.observe(this.content, "mousedown", this.eventMouseDownContent);
		Event.observe(window, "load", this.eventOnLoad);
    if (this.options.recenterAuto) {
		  Event.observe(window, "resize", this.eventResize);
  	  Event.observe(window, "scroll", this.eventResize);
	  }
  	
		if (this.options.draggable)  {
			this.bottombar.addClassName("bottom_draggable");
			this.topbar.addClassName("top_draggable");
    }		
    
		if (this.options.resizable) {
			this.sizer = $(this.element.id + "_sizer");
    	Event.observe(this.sizer, "mousedown", this.eventMouseDown);
    }	
    
    this.useLeft = null;
    this.useTop = null;
		if (arguments[1].left != null) {
			this.element.setStyle({left: parseFloat(arguments[1].left) + 'px'});
			this.useLeft = true;
		}
		if (arguments[1].right != null) {
			this.element.setStyle({right: parseFloat(arguments[1].right) + 'px'});
			this.useLeft = false;
		}
    if (this.useLeft == null) {
	    this.element.setStyle({left: "0px"});
			this.useLeft = true;
    }
    
		if (arguments[1].top != null) {
			this.element.setStyle({top: parseFloat(arguments[1].top) + 'px'});
			this.useTop = true;
		}
		if (arguments[1].bottom != null) {
			this.element.setStyle({bottom: parseFloat(arguments[1].bottom) + 'px'});			
			this.useTop = false;
		}
    if (this.useTop == null) {
			this.element.setStyle({top: "0px"});
			this.useTop = true;
    }

    this.storedLocation = null;
    
		this.setOpacity(this.options.opacity);
		if (this.options.zIndex)
			this.setZIndex(this.options.zIndex)

		this.destroyOnClose = false;

    this._getWindowBorderSize();
    this.width = this.options.width;
    this.height = this.options.height;
    this.visible = false;
    
    if (this.width && this.height)
		  this.setSize(this.options.width, this.options.height);
		this.setTitle(this.options.title)
		Windows.register(this);	    
  },

	// Destructor
 	destroy: function() {
		Windows.notify("onDestroy", this);
  	Event.stopObserving(this.topbar, "mousedown", this.eventMouseDown);
  	Event.stopObserving(this.bottombar, "mousedown", this.eventMouseDown);
  	Event.stopObserving(this.content, "mousedown", this.eventMouseDownContent);
    
		Event.stopObserving(window, "load", this.eventOnLoad);
		if (this.options.recenterAuto) {
		  Event.stopObserving(window, "resize", this.eventResize);
  	  Event.stopObserving(window, "scroll", this.eventResize);
	  }
		
		Event.stopObserving(this.content, "load", this.options.onload);

		if (this._oldParent) {
			var content = this.getContent();
			var originalContent = null;
			for(var i = 0; i < content.childNodes.length; i++) {
				originalContent = content.childNodes[i];
				if (Node.ELEMENT_NODE == originalContent.nodeType) break;
				originalContent = null;
			}
			if (originalContent)
			  this._oldParent.appendChild(originalContent);
			this._oldParent = null;
		}

		if (this.sizer)
    		Event.stopObserving(this.sizer, "mousedown", this.eventMouseDown);

		if (this.options.url)
		  this.content.src = null

	 	if(this.iefix) 
			Element.remove(this.iefix);

    Element.remove(this.element);
		Windows.unregister(this);	    
	},
  	
	// Sets window deleagte, should have functions: "canClose(window)" 
	setDelegate: function(delegate) {
		this.delegate = delegate
	},
	
	// Gets current window delegate
	getDelegate: function() {
		return this.delegate;
	},
	
	// Gets window content
	getContent: function () {
		return this.content;
	},
	
	// Sets the content with an element id
	setContent: function(id, autoresize, autoposition) {
		var element = $(id);
		if (null == element) throw "Unable to find element '" + id + "' in DOM";
		this._oldParent = element.parentNode;

		var d = null;
		var p = null;

		if (autoresize) 
			d = Element.getDimensions(element);
		if (autoposition) 
			p = Position.cumulativeOffset(element);

		var content = this.getContent()
		content.appendChild(element);
		element.show();
		if (autoresize) 
			this.setSize(d.width, d.height);
		if (autoposition) 
		  this.setLocation(p[1] - this.heightN, p[0] - this.widthW);	  
	},
	
	setAjaxContent: function(url, options, showCentered, showModal) {
	  this.showFunction = showCentered ? "showCenter" : "show";
	  this.showModal = showModal || false;
	
	  if (options == null)
	    options = {}  
	  this.onComplete = options.onComplete;
	  options.onComplete = this._setAjaxContent.bind(this);
	  
	  new Ajax.Request(url, options);
	},
	
	_setAjaxContent: function(originalRequest) {
	  Element.update(this.getContent(), originalRequest.responseText);
	  if (this.onComplete)
	    this.onComplete(originalRequest);
	  this[this.showFunction](this.showModal)
	},
	
	// Stores position/size in a cookie, by default named with window id
	setCookie: function(name, expires, path, domain, secure) {
		name = name || this.element.id;
		this.cookie = [name, expires, path, domain, secure];
		
		// Get cookie
		var value = WindowUtilities.getCookie(name)
		// If exists
		if (value) {
			var values = value.split(',');
			var x = values[0].split(':');
			var y = values[1].split(':');

			var w = parseFloat(values[2]), h = parseFloat(values[3]);
			var mini = values[4];
			var maxi = values[5];

		  this.setSize(w, h);
			if (mini == "true")
		    this.doMinimize = true; // Minimize will be done at onload window event
			else if (maxi == "true")
			  this.doMaximize = true; // Maximize will be done at onload window event

			this.useLeft = x[0] == "l";
			this.useTop = y[0] == "t";

			this.element.setStyle(this.useLeft ? {left: x[1]} : {right: x[1]});
			this.element.setStyle(this.useTop ? {top: y[1]} : {bottom: y[1]});
		}
	},
	
	// Gets window ID
	getId: function() {
		return this.element.id;
	},
	
	// Detroys itself when closing 
	setDestroyOnClose: function() {
    var destroyFunc = this.destroy.bind(this);
	  if (this.options.hideEffectOptions.afterFinish) {
	    var func = this.options.hideEffectOptions.afterFinish;
	    this.options.hideEffectOptions.afterFinish = function() {func();destroyFunc() }
    }
    else 
      this.options.hideEffectOptions.afterFinish = function() {destroyFunc() }
	  this.destroyOnClose = true;
	},
	
	// initDrag event
	_initDrag: function(event) {
    // Get pointer X,Y
  	this.pointer = [Event.pointerX(event), Event.pointerY(event)];

    // Resize
		if (Event.element(event) == this.sizer) {
			this.doResize = true;
    	this.widthOrg = this.width;
    	this.heightOrg = this.height;
    	this.bottomOrg = parseFloat(this.element.getStyle('bottom'));
    	this.rightOrg = parseFloat(this.element.getStyle('right'));
			Windows.notify("onStartResize", this);
		}
    else {
		  this.doResize = false;

  		// Check if click on close button, 
  		var closeButton = $(this.getId() + '_close');
  		if (closeButton && Position.within(closeButton, this.pointer[0], this.pointer[1])) 
  			return;

  		this.toFront();

  		if (! this.options.draggable) 
  		  return;
  		Windows.notify("onStartMove", this);
    }  	
  	// Register global event to capture mouseUp and mouseMove
  	Event.observe(document, "mouseup", this.eventMouseUp, false);
    Event.observe(document, "mousemove", this.eventMouseMove, false);
		
  	// Add an invisible div to keep catching mouse event over iframes
  	WindowUtilities.disableScreen('__invisible__', '__invisible__');

    // Stop selection while dragging
    document.body.ondrag = function () { return false; };
    document.body.onselectstart = function () { return false; };
    
    Event.stop(event);
  },

  // updateDrag event
	_updateDrag: function(event) {
   	var pointer = [Event.pointerX(event), Event.pointerY(event)];    
		var dx = pointer[0] - this.pointer[0];
		var dy = pointer[1] - this.pointer[1];
		
		// Resize case, update width/height
		if (this.doResize) {
			this.setSize(this.widthOrg + dx , this.heightOrg + dy);
			
      dx = this.width - this.widthOrg
      dy = this.height - this.heightOrg
			
		  // Check if it's a right position, update it to keep upper-left corner at the same position
			if (! this.useLeft) 
				this.element.setStyle({right: (this.rightOrg -dx) + 'px'});
			// Check if it's a bottom position, update it to keep upper-left corner at the same position
			if (! this.useTop) 
				this.element.setStyle({bottom: (this.bottomOrg -dy) + 'px'});
		}
		// Move case, update top/left
		else {
		  this.pointer = pointer;
  		
			if (this.useLeft) 
				this.element.setStyle({left: parseFloat(this.element.getStyle('left')) + dx + 'px'});
			else 
				this.element.setStyle({right: parseFloat(this.element.getStyle('right')) - dx + 'px'});
			
			if (this.useTop) 
				this.element.setStyle({top: parseFloat(this.element.getStyle('top')) + dy + 'px'});
		  else 
				this.element.setStyle({bottom: parseFloat(this.element.getStyle('bottom')) - dy + 'px'});
		}
		if (this.iefix) 
			this._fixIEOverlapping(); 
			
		this._removeStoreLocation();
    Event.stop(event);
	},

	 // endDrag callback
 	_endDrag: function(event) {
		// Remove temporary div over iframes
 	  WindowUtilities.enableScreen('__invisible__');
		
		if (this.doResize)
			Windows.notify("onEndResize", this);
		else
			Windows.notify("onEndMove", this);
		
		// Release event observing
		Event.stopObserving(document, "mouseup", this.eventMouseUp,false);
    Event.stopObserving(document, "mousemove", this.eventMouseMove, false);

		// Store new location/size if need be
		this._saveCookie()

    Event.stop(event);
    
    // Restore selection
    document.body.ondrag = null;
    document.body.onselectstart = null;
  },

	// Creates HTML window code
	_createWindow: function(id) {
	  var className = this.options.className;
		var win = document.createElement("div");
		win.setAttribute('id', id);
		win.className = "dialog";

		var content;
		if (this.options.url)
			content= "<iframe frameborder=\"0\" name=\"" + id + "_content\"  id=\"" + id + "_content\" src=\"" + this.options.url + "\"> </iframe>";
		else
			content ="<div id=\"" + id + "_content\" class=\"" +className + "_content\"> </div>";

		var closeDiv = this.options.closable ? "<div class='"+ className +"_close' id='"+ id +"_close' onclick='Windows.close(\""+ id +"\", event)'> </div>" : "";
		var minDiv = this.options.minimizable ? "<div class='"+ className + "_minimize' id='"+ id +"_minimize' onclick='Windows.minimize(\""+ id +"\", event)'> </div>" : "";
		var maxDiv = this.options.maximizable ? "<div class='"+ className + "_maximize' id='"+ id +"_maximize' onclick='Windows.maximize(\""+ id +"\", event)'> </div>" : "";
		var seAttributes = this.options.resizable ? "class='" + className + "_sizer' id='" + id + "_sizer'" : "class='"  + className + "_se'";
		
    win.innerHTML = closeDiv + minDiv + maxDiv + "\
      <table id='"+ id +"_row1' class=\"top table_window\">\
        <tr>\
          <td class='"+ className +"_nw'>&nbsp;</td>\
          <td class='"+ className +"_n'><div id='"+ id +"_top' class='"+ className +"_title title_window'>"+ this.options.title +"</div></td>\
          <td class='"+ className +"_ne'>&nbsp;</td>\
        </tr>\
      </table>\
      <table id='"+ id +"_row2' class=\"mid table_window\">\
        <tr>\
          <td class='"+ className +"_w'></td>\
            <td id='"+ id +"_table_content' class='"+ className +"_content' valign='top'>" + content + "</td>\
          <td class='"+ className +"_e'></td>\
        </tr>\
      </table>\
        <table id='"+ id +"_row3' class=\"bot table_window\">\
        <tr>\
          <td class='"+ className +"_sw'>&nbsp;</td>\
            <td class='"+ className +"_s'><div id='"+ id +"_bottom' class='status_bar'>&nbsp;</div></td>\
            <td " + seAttributes + ">&nbsp;</td>\
        </tr>\
      </table>\
    ";
		Element.hide(win);
		this.options.parent.insertBefore(win, this.options.parent.firstChild);
		Event.observe($(id + "_content"), "load", this.options.onload);
		return win;
	},

[ . . . ][ . . . ]
je pense qu'il faut ajouter une ligne dans le style de

this.EventOnKeyPress = this.fonction à appeler ()

mais ca ne marche pas.
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 11h42   #2
Modérateur
 
Avatar de Bisûnûrs
 
Josselin
Développeur Web
Inscription : janvier 2004
Messages : 9 050
Détails du profil
Informations personnelles :
Nom : Josselin
Âge : 29
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : janvier 2004
Messages : 9 050
Points : 12 181
Points : 12 181
Essaie plutôt :

Code :
element.onkeypress = function(){ functionAAppeler(); };
Bisûnûrs est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 11h51   #3
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
ok l'evenement est bien intercepté avec ton code merci

et maintenant il faut verifier que la touche pressé est " échap "

this.onkeypress = function(){ if("c'est touche echap") this.destroy(); };
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 11h56   #4
Modérateur
 
Avatar de Bisûnûrs
 
Josselin
Développeur Web
Inscription : janvier 2004
Messages : 9 050
Détails du profil
Informations personnelles :
Nom : Josselin
Âge : 29
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : janvier 2004
Messages : 9 050
Points : 12 181
Points : 12 181
Tu as ça :
http://developpez.net/forums/showpos...95&postcount=5

ou ça :
http://developpez.net/forums/showpos...66&postcount=2
Bisûnûrs est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 12h06   #5
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
heu en fait jme suis trompé :

this.onKeyPress = function()
{
alert("hihi");
};

n'intercepte pas levenement clavier ... pas d'alert ...
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 12h09   #6
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
il ne faudrait aps ajouter une ligne de ce style :


Event.observe(this.topbar, "mousedown", this.eventMouseDown);
Event.observe(this.bottombar, "mousedown", this.eventMouseDown);
Event.observe(this.content, "mousedown", this.eventMouseDownContent);
Event.observe(window, "load", this.eventOnLoad);

mais spécifique a onkeypress ?
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 12h09   #7
Modérateur
 
Avatar de Bisûnûrs
 
Josselin
Développeur Web
Inscription : janvier 2004
Messages : 9 050
Détails du profil
Informations personnelles :
Nom : Josselin
Âge : 29
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : janvier 2004
Messages : 9 050
Points : 12 181
Points : 12 181
Bizarre. Essaie comme ça alors :

Code :
1
2
3
4
5
this.onkeypress = uneFonction;
 
function uneFonction(){
   alert('test');
}
ou :

Code :
1
2
3
4
5
this.onkeydown = uneFonction;
 
function uneFonction(){
   alert('test');
}
Bisûnûrs est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 12h19   #8
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
voici ce que deviens mon code :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
		// Bind event listener
    this.eventMouseDown = this._initDrag.bindAsEventListener(this);
  	this.eventMouseUp   = this._endDrag.bindAsEventListener(this);
  	this.eventMouseMove = this._updateDrag.bindAsEventListener(this);
  	this.eventOnLoad    = this._getWindowBorderSize.bindAsEventListener(this);
    this.eventMouseDownContent = this.toFront.bindAsEventListener(this);
    this.eventOnKeyPress = this.myfunction;
 
    function myfunction()
    {alert("hihi");};
 
 
    if (this.options.recenterAuto)
      this.eventResize = this._recenter.bindAsEventListener(this);
 
		this.topbar = $(this.element.id + "_top");
		this.bottombar = $(this.element.id + "_bottom");
        this.content = $(this.element.id + "_content");
        Event.observe(this.content, "onkeypress", this.eventOnKeyPress);
mais ca ne fonctionne toujours pas ...
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 12h23   #9
Modérateur
 
Avatar de Bisûnûrs
 
Josselin
Développeur Web
Inscription : janvier 2004
Messages : 9 050
Détails du profil
Informations personnelles :
Nom : Josselin
Âge : 29
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web

Informations forums :
Inscription : janvier 2004
Messages : 9 050
Points : 12 181
Points : 12 181
Ben déjà là tu mets une fonction dans une autre fonction.

Créé une fonction en dehors de celle-ci, sur la base des autres fonctions toFront, endrag, etc.

Et appelle comme ça :
Code :
this.eventOnKeyPress = this.myFunction.bindAsEventListener(this);
Je ne sais pas si ça va marcher vu que je ne connais pas prototype, mais c'est ce qui me paraît le plus logique.
Bisûnûrs est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 13h45   #10
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
j'ai modifié mon script comme dit mais rien ne se passe la pop - up ne se charge plus et aucune erreur detectée par la console javascript de ff ...

Code :
1
2
3
4
5
6
7
// Bind event listener
    this.eventMouseDown = this._initDrag.bindAsEventListener(this);
  	this.eventMouseUp   = this._endDrag.bindAsEventListener(this);
  	this.eventMouseMove = this._updateDrag.bindAsEventListener(this);
  	this.eventOnLoad    = this._getWindowBorderSize.bindAsEventListener(this);
    this.eventMouseDownContent = this.toFront.bindAsEventListener(this);
    this.eventOnKeyPress = this.myFunction.bindAsEventListener(this);
voici la fonction de destruction appellée :
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
 
// Destructor
 	destroy: function() {
		Windows.notify("onDestroy", this);
  	Event.stopObserving(this.topbar, "mousedown", this.eventMouseDown);
  	Event.stopObserving(this.bottombar, "mousedown", this.eventMouseDown);
  	Event.stopObserving(this.content, "mousedown", this.eventMouseDownContent);
 
		Event.stopObserving(window, "load", this.eventOnLoad);
		if (this.options.recenterAuto) {
		  Event.stopObserving(window, "resize", this.eventResize);
  	  Event.stopObserving(window, "scroll", this.eventResize);
	  }
 
		Event.stopObserving(this.content, "load", this.options.onload);
 
		if (this._oldParent) {
			var content = this.getContent();
			var originalContent = null;
			for(var i = 0; i < content.childNodes.length; i++) {
				originalContent = content.childNodes[i];
				if (Node.ELEMENT_NODE == originalContent.nodeType) break;
				originalContent = null;
			}
			if (originalContent)
			  this._oldParent.appendChild(originalContent);
			this._oldParent = null;
		}
 
		if (this.sizer)
    		Event.stopObserving(this.sizer, "mousedown", this.eventMouseDown);
 
		if (this.options.url)
		  this.content.src = null
 
	 	if(this.iefix) 
			Element.remove(this.iefix);
 
    Element.remove(this.element);
		Windows.unregister(this);	    
	},
le code de MyFunction :

Code :
1
2
3
4
 
myFunction: function() {
	  	this.destroy();	
	},
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 14h29   #11
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
ca fait une heure que je cherche apres la solution mais il m'a l'air que ce framework n'a pas beaucoup de doc dispo ... c'est dommage ... quelqu'u pourrait t'il se pencher sur ma question ?


je pense qu'il ne faut pas reflechir sur :

Event.observe(element HTML | id , nom de l'evenement, fonction à executer, [useCapture])

car on ne peut surveiller que des element HTML, div ... et pas d'evenement clavier.
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 15h15   #12
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
lol une question qui restera sans reponses ...

pour faire simple : comment gère t'on des événements claviers avec le framework prototype javascript ?
__________________
.-*K.E.U.B*-.
keub51 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/09/2007, 17h10   #13
Membre régulier
 
Avatar de keub51
 
Inscription : janvier 2007
Messages : 349
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 349
Points : 79
Points : 79
Up. mais j'ai vraiment besoin d'une réponse
__________________
.-*K.E.U.B*-.
keub51 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 05h27.


 
 
 
 
Partenaires

Hébergement Web