Pagina 7 di 9 primaprima ... 5 6 7 8 9 ultimoultimo
Visualizzazione dei risultati da 61 a 70 su 87
  1. #61
    Scusate ma perchè è stato cancellato il mio post di ieri?? non rispettavo qualche regola???

  2. #62
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    anche se fosse, ti sembra il caso chiedere spiegazioni in questa discussione?
    puoi usare i messaggi privati per i chiarimenti circa la moderazione

    a me poi risultano essere presenti le tue due discussioni di ieri
    http://forum.html.it/forum/search.ph...archid=1355892

  3. #63
    Articolo sulla programmazione ad oggetti (OOP) in Javascript:
    Creazione di oggetti, membri public/private, membri static,
    utilizzo di prototype e constructor ed infine ereditarietà in JavaScript.

    http://mirkoagrati.110mb.com/articol...dir=JavaScript
    Mirko Agrati
    WEB : http://mirkoagrati.110mb.com
    RSS : http://feeds.feedburner.com/MirkoAgratiArticoli

  4. #64
    Frontend samurai L'avatar di fcaldera
    Registrato dal
    Feb 2003
    Messaggi
    12,924
    http://forum.html.it/forum/showthrea...readid=1220048

    Un oggetto in grado di fare calcoli tra date con una notevole potenza espressiva dei metodi (chaining)
    Vuoi aiutare la riforestazione responsabile?

    Iscriviti a Ecologi e inizia a rimuovere la tua impronta ecologica (30 alberi extra usando il referral)

  5. #65
    Qui trovate un manuale opensource da scaricare:
    http://www.booksopen.org/index.php?o...cati&Itemid=56
    Scarica manuali e libri open source in formato epub, pdf, mpeg: www.ebooksopen.org

  6. #66
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669

    Programmazione ad oggetti

    Posto una piccola funzione per clonare gli oggetti (oggetti in senso stretto, array, stringhe, etc.).

    codice:
    	function clone(aObj){
    	    if (aObj === null || typeof(aObj) !== "object") { return(aObj); }
    	    var newClone = new aObj.constructor();
    	    for (var objKey in aObj) { newClone[objKey] = clone(aObj[objKey]); }
    	    return(newClone);
    	}
    Fonte: Keith Devens .com (http://keithdevens.com/weblog/archiv...vascript.clone).

  7. #67
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669

    Slider

    Ciao a tutt*,
    per mia necessità ho dovuto creare un campo di modulo di tipo Slider control (tipo il controllo volume, per intenderci). Condivido il codice per chi ne fosse interessato...

    Ciao.

    codice:
    <!doctype html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>Slider form field</title>
    <script type="text/javascript">
    function newEvent(oTo, oEvntType1, fncToAssign) {
    	if (oTo.addEventListener) { oTo.addEventListener(oEvntType1, fncToAssign, false); }
    	else if (oTo.attachEvent) { oTo.attachEvent("on" + oEvntType1, fncToAssign); }
    	else { oTo["on" + oEvntType1] = fncToAssign; }
    }
    function divestEvent(oFrom, oEvntType2, fncToRemove) {
    	if (oFrom.removeEventListener) { oFrom.removeEventListener(oEvntType2, fncToRemove, false);}
    	else if (oFrom.detachEvent) { oFrom.detachEvent("on" + oEvntType2, fncToRemove); }
    	else { oFrom["on" + oEvntType2] = null; }
    }
    function setAttribs() { for (var iAttr = 0; iAttr < arguments.length; iAttr++) { this[arguments[iAttr][0]] = arguments[iAttr][1]; } }
    function setStyles() { for (var iPropr = 0; iPropr < arguments.length; iPropr++) { this.style[arguments[iPropr][0]] = arguments[iPropr][1]; } }
    
    function createSlider(sFieldName, nDents, nWidth, nDefault, fncOnChange) {
    	var nProcW = nWidth && nWidth > 72 ? nWidth : 72, nPointerW = 24, nPointerH = 12, nBarH = 1, nBarBorder = 1;
    	var nHScroll, iBarPos, nRelMsPos, nPointerLeft = 0, nBarW = (nProcW > nPointerW * 2 + 6 ? nProcW : nPointerW * 2 + 6) - nPointerW - nBarBorder * 2, nMod = nBarW / (nDents - 1), nHalfPtW = nPointerW >> 1, oContainer = document.createElement("span"), oPointer = document.createElement("span"), oBarBox = document.createElement("span"), oFormField = document.createElement("input"), oFragment = document.createDocumentFragment();
    
    	function captMsMv(oMsEvnt2) {
    		var nRelPos = oMsEvnt2.clientX + nHScroll - nRelMsPos - iBarPos + nHalfPtW;
    		if (!oMsEvnt2) { oMsEvnt2 = window.event; }
    
    		if (nRelPos < 0) { nPointerLeft = 0; }
    		else if (nRelPos > nBarW) { nPointerLeft = nBarW; }
    		else { nPointerLeft = nRelPos - nRelPos % nMod; }
    
    		oFormField.value = Math.round(nPointerLeft / nMod);
    		oPointer.style.left = nPointerLeft + "px";
    		if (fncOnChange) { fncOnChange.call(oFormField); }
    	}
    
    	function captMsUp() {
    		divestEvent(document, "mousemove", captMsMv);
    		divestEvent(document, "mouseup", captMsUp);
    	}
    
    	function captPtMsDwn(oMsEvnt1) {
    		var iContainer = oContainer, iPointerPos = oPointer.offsetLeft;
    		if (!oMsEvnt1) { oMsEvnt1 = window.event; }
    		nHScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
    		iBarPos = oBarBox.offsetLeft;
    		while (iContainer.offsetParent) {
    			iBarPos += iContainer.offsetLeft;
    			iPointerPos += iContainer.offsetLeft;
    			iContainer = iContainer.offsetParent;
    		}
    		nRelMsPos = nHScroll + oMsEvnt1.clientX - iPointerPos - (nMod >> 1);
    		newEvent(document, "mousemove", captMsMv);
    		newEvent(document, "mouseup", captMsUp);
    		return(false);
    	}
    
    	function captBarMsDwn(oMsEvnt3) {
    		if (!oMsEvnt3) { oMsEvnt3 = window.event; }
    		if (oMsEvnt3.which === 2 || oMsEvnt3.which === 3) { return(false); }
    		var iContainer = oBarBox;
    
    		iBarPos = 0;
    		nRelMsPos = nHalfPtW - (nMod >> 1);
    		nHScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
    
    		while (iContainer.offsetParent) {
    			iBarPos += iContainer.offsetLeft;
    			iContainer = iContainer.offsetParent;
    		}
    		newEvent(document, "mousemove", captMsMv);
    		newEvent(document, "mouseup", captMsUp);
    		return(false);
    	}
    
    	oContainer.className = "sliderBox";
    	oContainer.style.paddingLeft = String(nProcW) + "px";
    	oPointer.className = "sliderPointer";
    	oBarBox.className = "sliderBar";
    
    	setAttribs.call(oFormField, ["type", "hidden"], ["name", sFieldName], ["value", nDefault ? nDefault % nDents : 0]);
    	setStyles.call(oBarBox, ["position", "absolute"], ["left", String(nHalfPtW + 1) + "px"], ["bottom", String((nPointerH - nBarH >> 1) - nBarBorder + 1) + "px"], ["width", String(nBarW - 1) + "px"], ["height", nBarH + "px"], ["borderWidth", nBarBorder ? nBarBorder + "px" : "0"]);
    	setStyles.call(oPointer, ["position", "absolute"], ["left", String(nDefault ? nDefault % nDents * nMod : 0) + "px"], ["bottom", "0"], ["width", nPointerW + "px"], ["height", nPointerH + "px"]);
    	oPointer.onmousedown = captPtMsDwn;
    	oBarBox.onmousedown = captBarMsDwn;
    	oContainer.appendChild(oBarBox);
    	oContainer.appendChild(oPointer);
    	oFragment.appendChild(oContainer);
    	oFragment.appendChild(oFormField);
    	return(oFragment);
    }
    /* use: createSlider(sFieldName, nDents[, nWidth, nDefault, fncOnChange]) */
    </script>
    <style type="text/css">
    /**
    * The following properties are already defined within the script and therefore should not be redefined in this stylesheet as would be ignored.
    *
    * padding-left: [VARIABLE VALUE];
    */
    span.sliderBox {
    	position: relative;
    	left: 0;
    	bottom: 0;
    	width: auto;
    	height: auto;
    	margin-right: 6px;
    }
    
    /**
    /**
    * The following properties are already defined within the script and therefore should not be redefined in this stylesheet as would be ignored.
    *
    * position: [VARIABLE VALUE];
    * left: [VARIABLE VALUE];
    * top: [VARIABLE VALUE];
    * width: [VARIABLE VALUE];
    * height: [VARIABLE VALUE];
    * border-size: [VARIABLE VALUE];
    */
    span.sliderBox span.sliderBar {
    	background-color: #ffffff;
    	border-color: #333333;
    	border-style: inset;
    	z-index: 100;
    }
    
    /**
    /**
    * The following properties are already defined within the script and therefore should not be redefined in this stylesheet as would be ignored.
    *
    * position: [VARIABLE VALUE];
    * left: [VARIABLE VALUE];
    * top: [VARIABLE VALUE];
    * width: [VARIABLE VALUE];
    * height: [VARIABLE VALUE];
    */
    span.sliderBox span.sliderPointer {
    	border: 1px #aaaaaa solid;
    	background-color: #cccccc;
    	-moz-border-radius: 2px;
    	-moz-box-shadow: 1px 1px 9px 1px #cccccc;
    	-webkit-border-radius: 2px;
    	-webkit-box-shadow: 1px 1px 9px 1px #cccccc;
    	border-radius: 2px;
    	box-shadow: 1px 1px 9px 1px #cccccc;
    	z-index: 101;
    }
    
    input[type="text"] { border: 1px #aaaaaa solid; }
    
    input[type="text"], span.sliderBox span.sliderBar, #ratingResults {
    	-moz-border-radius: 1px;
    	-moz-box-shadow: 2px 2px 5px black, inset 0 0 2px red;
    	-webkit-border-radius: 1px;
    	-webkit-box-shadow: 2px 2px 5px black, inset 0 0 2px red;
    	border-radius: 1px;
    	box-shadow: 2px 2px 5px black, inset 0 0 2px red;
    }
    
    #ratingResults {
    	padding: 2px 4px 2px 4px;
    	font-size: 90%;
    	border: 1px #aaaaaa solid;
    }
    </style>
    </head>
    <body onload="var rResults = document.getElementById('ratingResults'); rResults.parentNode.insertBefore(createSlider('sampleRating', 6, 150, 4, function() { rResults.innerHTML = this.value; }), rResults);">
    
    <form name="sampleForm" action="http://www.google.it/" method="get">
    
    
    Name: <input type="text" name="sampleName" />
    
    
    E-Mail: <input type="text" name="sampleEmail" />
    
    
    Rate this page: <span id="ratingResults">4</span></p>
    
    
    <input type="submit" /></p>
    </form>
    
    </body>
    </html>

  8. #68
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669
    Perdonatemi, ma c'è una piccola mancanza nel codice che ho postato... alla riga 70, dopo:
    codice:
    		while (iContainer.offsetParent) {
    			iBarPos += iContainer.offsetLeft;
    			iContainer = iContainer.offsetParent;
    		}
    andrebbe aggiunta la seguente riga:
    codice:
    		captMsMv(oMsEvnt3);
    altrimenti la funzione captBarMsDwn è del tutto inutile

  9. #69
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    per favore Carlo, non postare gli script direttamente qui,
    apri una discussione apposita per lo script, anche nell' eventualita' se ne voglia discutere piu' approfonditamente

  10. #70
    Utente di HTML.it L'avatar di carlomarx
    Registrato dal
    Oct 2009
    Messaggi
    1,669
    Originariamente inviato da Xinod
    per favore Carlo, non postare gli script direttamente qui,
    apri una discussione apposita per lo script, anche nell' eventualita' se ne voglia discutere piu' approfonditamente
    Hai ragione...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.