Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<script src="mootools.js" type="text/javascript"></script>
<script src="moo.rd.js" type="text/javascript"></script>
<script src="mooWindow.js" type="text/javascript"></script>
<script>
window.addEvent('domready',function(){
var test = new MooWindow('open',{
'prefisso': 'window' ,
'rezoom': 'true' ,
'zoom': 'true' ,
'height': '500' ,
'width': '500' ,
'min_height': '200' ,
'min_width': '200' ,
'container': 'container' ,
'table': 'window_table'
});
});
</script>
</head>
<body>
<div id="container" style="height:100%;width:100%;position:fixed;top:0px;left:0px">
<div id="open">Apri</div>
<div align="center" id="window" style="position:fixed;top:50px;left:50px">
<table style="width:100%;height:100%;" id="window_table" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="14" height="20" background="top-sx.png"></td>
<td height="20" background="top-mid.png">
<div id="window_drag" style="cursor:move;position:absolute;top:1px;left:15px;color:white;">Finestra di test</div>
[img]1.png[/img]
[img]2.png[/img]
[img]close.png[/img]
</td>
<td width="14" height="20" background="top-dx.png"></td>
</tr>
<tr>
<td width="14" background="mid-sx.png"></td>
<td background="bg.png"></td>
<td width="14" background="mid-dx.png"></td>
</tr>
<tr>
<td width="14" height="14" background="bot-sx.png"></td>
<td height="14" background="bot-mid.png"></td>
<td width="14" height="14"></td>
</tr>
</table>
<div id="window_resize" style="position:absolute;bottom:0;right:0;cursor:nw-resize">[img]bot-dx.png[/img]</div>
</div>
</div>
</body>
</html>
MooWindow.js
Codice PHP:
/* autore: Gabriel
* creato per: DarkSoft
* versione: 1.0 beta
* licenza: MIT-style license
*info:
*/
var MooWindow = new Class({
Implements : Options,
options: {
prefisso: 'window' ,
rezoom: 'true' ,
zoom: 'true' ,
drag: 'true' ,
resize: 'true' ,
height: '500' ,
width: '500' ,
min_height: '200' ,
min_width: '200' ,
container: 'container' ,
table: 'table' ,
min_resizeW: '250' ,
min_resizeH: '35' ,
},
initialize: function(el, options) {
this.setOptions(options);
var body = $(this.options.prefisso) ;
var table = $(this.options.prefisso+'_table') ;
var drag = $(this.options.prefisso+'_drag') ;
var diminuiz = $(this.options.prefisso+'_zoom') ;
var ingrand = $(this.options.prefisso+'_zoom2') ;
var close = $(this.options.prefisso+'_close') ;
var resize = $(this.options.prefisso+'_resize') ;
var toggle_height = new Fx.Toggle(body, {
duration:1000
});
var toggle_width = new Fx.Toggle(body, {
duration:1000
});
var move = new Fx.Move(body, {
duration:1000
});
if (this.options.drag == 'true'){
var dragger = new Drag.Move(this.options.prefisso,{container: this.options.container ,
onStart: function(){
this.options.table.setStyle('border','1px black dotted');
this.options.table.fade('out');},
onComplete: function(){
this.options.table.setStyle('border','0px black dotted');
this.options.table.fade('in');}
}).attach();
}
if (this.options.resize == 'true'){
var minW = this.options.min_resizeW, minH = this.options.min_resizeH;
var resizer = body.makeResizable({
onStart: function(){
resizer.attach();
dragger.detach();
body.setStyle('border','1px black dotted');
table.fade('out'); },
onDrag: function(div){
var size = div.getSize();
if(size.x < minW)div.setStyle('width', minW);
if(size.y < minH)div.setStyle('height', minH);},
onComplete: function(){
body.setStyle('border','0px black dotted');
table.fade('in');
resizer.detach();
dragger.attach();}
}).detach();
}
body.fade(0) ;
toggle_height.toggleProperty('height', 0, 0, true);
toggle_width.toggleProperty('width', 0, 0, true);
$(el).addEvent('click',function(){
body.fade(1);
toggle_height.toggleProperty('height', this.options.height, this.options.height, true);
toggle_width.toggleProperty('width', this.options.width, this.options.width, true);
}.bindWithEvent(this)) ;
if (this.options.rezoom == 'true'){
diminuiz.addEvent('click',function(){
toggle_height.toggleProperty('height', this.options.min_height, this.options.min_height, true);
toggle_width.toggleProperty('width', this.options.min_width, this.options.min_width, true);
move.start(50,50) ;
}.bindWithEvent(this)) ;
} else {
return ;
}
if (this.options.zoom == 'true'){
ingrand.addEvent('click',function(){
toggle_height.toggleProperty('height', 640, 640, true);
toggle_width.toggleProperty('width', 1024, 1024, true);
move.start(0,0) ;
}.bindWithEvent(this)) ;
} else {
return ;
}
close.addEvent('click',function(){
body.fade(0);
toggle_height.toggleProperty('height', 0, 0, true);
toggle_width.toggleProperty('width', 0, 0, true);
}.bindWithEvent(this)) ;
drag.addEvent('click',function(){
resizer.detach();
dragger.attach();
}.bindWithEvent(this)) ;
resize.addEvent('click',function(){
resizer.attach();
dragger.detach();
}.bindWithEvent(this)) ;
}
});
non so dov'è l'errore ma non funziona il drag e il resize, e impalla tutto lo script.