diff -rbBu ImageFlow_1.2.1.bak/imageflow.js ImageFlow_1.2.1/imageflow.js --- ImageFlow_1.2.1.bak/imageflow.js 2009-08-10 16:51:54.000000000 +0200 +++ ImageFlow_1.2.1/imageflow.js 2009-12-12 18:51:53.000000000 +0100 @@ -26,11 +26,13 @@ of Richard Daveys easyreflections [2] written in PHP. The mouse wheel support is an implementation of Adomas Paltanavicius JavaScript mouse wheel code [3]. It also uses the domReadyEvent from Tanny O'Haley [4]. + Functions to simulate PHP's function htmlentities come from php.js [5]. [1] http://www.adventuresinsoftware.com/blog/?p=104#comment-1981 [2] http://reflection.corephp.co.uk/v2.php [3] http://adomas.org/javascript-mouse-wheel/ [4] http://tanny.ica.com/ICA/TKO/tkoblog.nsf/dx/domcontentloaded-for-browsers-part-v + [5] http://phpjs.org/ */ /* ImageFlow constructor */ @@ -65,7 +67,12 @@ sliderWidth: 14, /* Width of the slider in px */ startID: 1, /* Glide to this image ID on startup */ startAnimation: false, /* Animate images moving in from the right on startup */ - xStep: 150 /* Step width on the x-axis in px */ + xStep: 150, /* Step width on the x-axis in px */ + animationSpeed: 50, /* time in milliseconds for one transition */ + singleItemTag: 'IMG', /* tagname which will wrap a single item (default IMG, you may want to set it e.g. LI)*/ + slideshow: false, /* enables slideshow */ + slideshowInterval: 2000, /* time in milliseconds for holding one image */ + slideshowLeftToRight: true /* cycle from left to right (true) or right to left (false) */ }; @@ -77,7 +84,7 @@ this.init = function (options) { /* Evaluate options */ - var optionsArray = ['aspectRatio', 'buttons', 'captions', 'imageCursor', 'imagesM', 'ImageFlowID', 'imageFocusM', 'imageFocusMax', 'imagesHeight', 'onClick', 'opacity', 'opacityArray', 'percentLandscape', 'percentOther', 'preloadImages', 'reflections', 'reflectionGET', 'reflectionP', 'reflectionPNG','imageScaling', 'scrollbarP', 'slider', 'sliderCursor', 'sliderWidth', 'startID', 'startAnimation', 'xStep']; + var optionsArray = ['aspectRatio', 'buttons', 'captions', 'imageCursor', 'imagesM', 'ImageFlowID', 'imageFocusM', 'imageFocusMax', 'imagesHeight', 'onClick', 'opacity', 'opacityArray', 'percentLandscape', 'percentOther', 'preloadImages', 'reflections', 'reflectionGET', 'reflectionP', 'reflectionPNG','imageScaling', 'scrollbarP', 'slider', 'sliderCursor', 'sliderWidth', 'startID', 'startAnimation', 'xStep', 'animationSpeed', 'singleItemTag', 'slideshow', 'slideshowInterval', 'slideshowLeftToRight', 'cycle']; var max = optionsArray.length; for (var i = 0; i < max; i++) { @@ -116,7 +123,7 @@ /* Toggle Slider */ if(this.slider === false) { - this.scrollbarDiv.style.display = 'none'; + this.sliderDiv.style.display = 'none'; } /* Set height of the ImageFlow container and center the loading bar */ @@ -143,8 +150,16 @@ for(var index = 0; index < max; index++) { node = this.ImageFlowDiv.childNodes[index]; - if (node && node.nodeType == 1 && node.nodeName == 'IMG') + if (node && node.nodeType == 1 && node.nodeName == thisObject.singleItemTag) { + if (thisObject.singleItemTag != 'IMG') { + var imgNode = this.getImagesFromStructure(node); + if (imgNode) { + node = imgNode; + } else { + continue; + } + } /* Add 'reflect.php?img=' */ if(thisObject.reflections === true) { @@ -206,7 +221,7 @@ for(index = 0; index < max; index++) { node = this.ImageFlowDiv.childNodes[index]; - if (node && node.nodeType == 1 && node.nodeName == 'IMG') + if (node && node.nodeType == 1 && node.nodeName == thisObject.singleItemTag) { this.ImageFlowDiv.removeChild(node); } @@ -216,6 +231,42 @@ return success; }; + /* gets images recursively from within some HTML structure and sets longDesc, if wrapped into a link and / or caption, if a class 'Imageflow_caption' is set */ + this.getImagesFromStructure = function(structure, level) { + if (!level) level = 0; + var imgNode = null; + var linkURL = null; + var caption = null; + var tempNode = null; + var childLength = structure.childNodes.length; + for (var child = 0; child < childLength; child++) { + tempNode = structure.childNodes[child]; + if (tempNode.hasChildNodes()) { + if (!imgNode) { + imgNode = this.getImagesFromStructure(tempNode, level++); + if (tempNode.nodeName == 'A' && tempNode.href && tempNode.href != '') { + linkURL = tempNode.href; + } + } + if (tempNode.className == 'Imageflow_caption') { + caption = thisObject.Helper.htmlentities(tempNode.innerHTML); + } + } else { + if (tempNode) { + if (tempNode.nodeName == 'IMG') { + imgNode = tempNode; + } + } + } + } + if (caption) { + imgNode.setAttribute('alt', caption); + } + if (linkURL) { + imgNode.setAttribute('longdesc', linkURL); + } + return imgNode; + }; /* Manage loading progress and call the refresh function */ this.loadingProgress = function() @@ -272,9 +323,31 @@ { thisObject.moveTo(5000); } + if (thisObject.slideshow) { + window.setTimeout(thisObject.slideshowImages, thisObject.slideshowInterval); + } } }; + /* create a slideshow */ + this.slideshowImages = function() { + var newImageId = 0; + if (thisObject.slideshowLeftToRight) { + if(thisObject.imageID < (thisObject.max-1)) { + newImageID = thisObject.imageID + 1; + } else { + newImageID = 0; + } + } else { + if(thisObject.imageID > 0) { + newImageID = thisObject.imageID - 1; + } else { + newImageID = thisObject.max-1; + } + } + thisObject.glideTo(newImageID); + window.setTimeout(thisObject.slideshowImages, thisObject.slideshowInterval); + }; /* Return loaded images in percent, set loading bar width and loading text */ this.loadingStatus = function() @@ -633,7 +706,7 @@ { case true: thisObject.moveTo(thisObject.current + (thisObject.target-thisObject.current)/3); - window.setTimeout(thisObject.animate, 50); + window.setTimeout(thisObject.animate, thisObject.animationSpeed); thisObject.busy = true; break; @@ -1011,6 +1084,188 @@ thisObject.refresh(); }; } + }, + + /* + * @see http://phpjs.org/functions/htmlentities + */ + htmlentities: function(string, quote_style) { + // Convert all applicable characters to HTML entities + // + // version: 909.322 + // discuss at: http://phpjs.org/functions/htmlentities // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + improved by: nobbler + // + tweaked by: Jack + // + bugfixed by: Onno Marsman // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: Brett Zamir (http://brett-zamir.me) + // + input by: Ratheous + // - depends on: get_html_translation_table + // * example 1: htmlentities('Kevin & van Zonneveld'); // * returns 1: 'Kevin & van Zonneveld' + // * example 2: htmlentities("foo'bar","ENT_QUOTES"); + // * returns 2: 'foo'bar' + var hash_map = {}, symbol = '', tmp_str = '', entity = ''; + tmp_str = string.toString(); + if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) { + return false; + } + hash_map["'"] = '''; + for (symbol in hash_map) { + entity = hash_map[symbol]; + tmp_str = tmp_str.split(symbol).join(entity); + } + return tmp_str; + }, + + /* + * @see http://phpjs.org/functions/get_html_translation_table:416 + */ + get_html_translation_table: function(table, quote_style) { + // Returns the internal translation table used by htmlspecialchars and htmlentities + // + // version: 909.322 + // discuss at: http://phpjs.org/functions/get_html_translation_table // + original by: Philip Peterson + // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: noname + // + bugfixed by: Alex + // + bugfixed by: Marco // + bugfixed by: madipta + // + improved by: KELAN + // + improved by: Brett Zamir (http://brett-zamir.me) + // + bugfixed by: Brett Zamir (http://brett-zamir.me) + // + input by: Frank Forte // + bugfixed by: T.Wild + // + input by: Ratheous + // % note: It has been decided that we're not going to add global + // % note: dependencies to php.js, meaning the constants are not + // % note: real constants, but strings instead. Integers are also supported if someone // % note: chooses to create the constants themselves. + // * example 1: get_html_translation_table('HTML_SPECIALCHARS'); + // * returns 1: {'"': '"', '&': '&', '<': '<', '>': '>'} + var entities = {}, hash_map = {}, decimal = 0, symbol = ''; var constMappingTable = {}, constMappingQuoteStyle = {}; + var useTable = {}, useQuoteStyle = {}; + + // Translate arguments + constMappingTable[0] = 'HTML_SPECIALCHARS'; constMappingTable[1] = 'HTML_ENTITIES'; + constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; + constMappingQuoteStyle[2] = 'ENT_COMPAT'; + constMappingQuoteStyle[3] = 'ENT_QUOTES'; + useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; + useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'; + if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') { + throw new Error("Table: "+useTable+' not supported'); // return false; + } + entities['38'] = '&'; + if (useTable === 'HTML_ENTITIES') { + entities['160'] = ' '; + entities['161'] = '¡'; + entities['162'] = '¢'; + entities['163'] = '£'; + entities['164'] = '¤'; + entities['165'] = '¥'; + entities['166'] = '¦'; + entities['167'] = '§'; + entities['168'] = '¨'; + entities['169'] = '©'; + entities['170'] = 'ª'; + entities['171'] = '«'; + entities['172'] = '¬'; + entities['173'] = '­'; + entities['174'] = '®'; + entities['175'] = '¯'; + entities['176'] = '°'; + entities['177'] = '±'; + entities['178'] = '²'; + entities['179'] = '³'; + entities['180'] = '´'; + entities['181'] = 'µ'; + entities['182'] = '¶'; + entities['183'] = '·'; + entities['184'] = '¸'; + entities['185'] = '¹'; + entities['186'] = 'º'; + entities['187'] = '»'; + entities['188'] = '¼'; + entities['189'] = '½'; + entities['190'] = '¾'; + entities['191'] = '¿'; + entities['192'] = 'À'; + entities['193'] = 'Á'; + entities['194'] = 'Â'; + entities['195'] = 'Ã'; + entities['196'] = 'Ä'; + entities['197'] = 'Å'; + entities['198'] = 'Æ'; + entities['199'] = 'Ç'; + entities['200'] = 'È'; + entities['201'] = 'É'; + entities['202'] = 'Ê'; + entities['203'] = 'Ë'; + entities['204'] = 'Ì'; + entities['205'] = 'Í'; + entities['206'] = 'Î'; + entities['207'] = 'Ï'; + entities['208'] = 'Ð'; + entities['209'] = 'Ñ'; + entities['210'] = 'Ò'; + entities['211'] = 'Ó'; + entities['212'] = 'Ô'; + entities['213'] = 'Õ'; + entities['214'] = 'Ö'; + entities['215'] = '×'; + entities['216'] = 'Ø'; + entities['217'] = 'Ù'; + entities['218'] = 'Ú'; + entities['219'] = 'Û'; + entities['220'] = 'Ü'; + entities['221'] = 'Ý'; + entities['222'] = 'Þ'; + entities['223'] = 'ß'; + entities['224'] = 'à'; + entities['225'] = 'á'; + entities['226'] = 'â'; + entities['227'] = 'ã'; + entities['228'] = 'ä'; + entities['229'] = 'å'; + entities['230'] = 'æ'; + entities['231'] = 'ç'; + entities['232'] = 'è'; + entities['233'] = 'é'; + entities['234'] = 'ê'; + entities['235'] = 'ë'; + entities['236'] = 'ì'; + entities['237'] = 'í'; + entities['238'] = 'î'; + entities['239'] = 'ï'; + entities['240'] = 'ð'; + entities['241'] = 'ñ'; + entities['242'] = 'ò'; + entities['243'] = 'ó'; + entities['244'] = 'ô'; + entities['245'] = 'õ'; + entities['246'] = 'ö'; + entities['247'] = '÷'; + entities['248'] = 'ø'; + entities['249'] = 'ù'; + entities['250'] = 'ú'; + entities['251'] = 'û'; + entities['252'] = 'ü'; + entities['253'] = 'ý'; + entities['254'] = 'þ'; + entities['255'] = 'ÿ'; + } + if (useQuoteStyle !== 'ENT_NOQUOTES') { + entities['34'] = '"'; + } + if (useQuoteStyle === 'ENT_QUOTES') { + entities['39'] = '''; + } + entities['60'] = '<'; + entities['62'] = '>'; + + // ascii decimals to real symbols + for (decimal in entities) { + symbol = String.fromCharCode(decimal); + hash_map[symbol] = entities[decimal]; + } + return hash_map; } }; } diff -rbBu ImageFlow_1.2.1.bak/index.html ImageFlow_1.2.1/index.html --- ImageFlow_1.2.1.bak/index.html 2009-08-10 16:56:36.000000000 +0200 +++ ImageFlow_1.2.1/index.html 2009-12-12 18:53:33.000000000 +0100 @@ -8,7 +8,7 @@ - + @@ -33,5 +34,38 @@ Image 15 + + + + \ Kein Zeilenumbruch am Dateiende. diff -rbBu ImageFlow_1.2.1.bak/style.css ImageFlow_1.2.1/style.css --- ImageFlow_1.2.1.bak/style.css 2009-08-10 16:45:10.000000000 +0200 +++ ImageFlow_1.2.1/style.css 2009-12-12 18:26:33.000000000 +0100 @@ -28,4 +28,12 @@ text-align:center; margin:0.4em 0 1.3em 0; } + ul#myImageFlow, + ul#myImageFlow li { + margin:0; + padding:0; + } + ul#myImageFlow li { + list-style-type:none; + } } \ Kein Zeilenumbruch am Dateiende.