Proto.Menu è una semplice e leggera (2Kb) soluzione Javascript per aggiungere funzionalità di menu contestuali alle pagine HMTL. Questa libreria sfrutta il recente rilascio di prototype 1.6.0_rc0. Le sue caratteristiche essenziali sono:
- Leggerezza: ~2 KB (~1.5 KB versione ridotta)
- Unobtrusive: non intrusiva
- Supporta tutti i browser
- Personalizzabile a livello di style-sheet
- Estremamente veloce
Per il suo uso è richiesto:
- prototype.js 1.6.0_rc0
- provata sui browser: Firefox 1.5+, Internet Explorer 6+, Safari 3+, Opera 9+, Netscape Navigator 9+
Per utilizzarla basta includere la libreria prototype e proto.menu:
Download Proto.Menu.js (o versione compressa)
1 2 |
Si possono includere file CSS personalizzati
1 | <link rel="stylesheet" href="Proto.Menu.css" type="text/css" media="screen" /> |
E il suo uso è davvero semplice, si crea un array con i link da mostrare:
1 2 3 4 5 6 7 8 9 10 11 | var myLinks = [ {name: 'Back', callback: function(){alert('back function called')}}, {name: 'Forward', callback: function(){alert('Forward function called')}}, {separator: true}, {name: 'Reload', callback: function(){alert('Reload function called')}}, {name: 'Disabled option', disabled: true}, {name: 'Toggle previous option', callback: function(){ var item = oLinks.find(function(l){return l.name == 'Disabled option'}); item.disabled = item.disabled == false ? true : false; }} ] |
Si attivano i menu passando il riferimento all’array creato:
1 2 3 4 5 6 7 | <script type="text/javascript"> new Proto.Menu({ selector: '.contextmenu' // context menu will be shown when element with class name of "contextmenu" is clicked className: 'myContextMenu', // this is a class which will be attached to menu container (used for css styling) menuItems: myLinks // array of menu items }) </script> |
Notare la proprietà selector che indica l’elemento legato al click per questo menu contestuale.








11
[...] YouTube Proto.Menu: menu contestuali in Javascript con Prototype 1.6.0 » This Summary is from an article posted at undolog on Tuesday, August 28, 2007 Tags: Internet, Javascript, Sviluppo Proto.Menu è una semplice e leggera (2Kb) … : prototype.js 1.6.0_rc0 provata sui browser: Firefox 1.5+, Internet Explorer 6+, Safari 3+, Opera Summary Provided by Technorati.comView Original Article at undolog » 10 Most Recent News Articles About Firefox [...]