[Linpha-cvs] SF.net SVN: linpha: [4930] trunk/linpha2/lib/js
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2008-04-27 09:36:09
|
Revision: 4930 http://linpha.svn.sourceforge.net/linpha/?rev=4930&view=rev Author: fangehrn Date: 2008-04-27 02:35:57 -0700 (Sun, 27 Apr 2008) Log Message: ----------- moved not needed javascript files Added Paths: ----------- trunk/linpha2/lib/js/old/LinGlobal_old.js trunk/linpha2/lib/js/old/LinImage_old.js trunk/linpha2/lib/js/old/LinThumbnails_old.js trunk/linpha2/lib/js/old/builder.js trunk/linpha2/lib/js/old/builder.yui.js trunk/linpha2/lib/js/old/controls.js trunk/linpha2/lib/js/old/controls.yui.js trunk/linpha2/lib/js/old/dragdrop.js trunk/linpha2/lib/js/old/dragdrop.yui.js trunk/linpha2/lib/js/old/effects.js trunk/linpha2/lib/js/old/effects.yui.js trunk/linpha2/lib/js/old/prototype/ trunk/linpha2/lib/js/old/prototype.js trunk/linpha2/lib/js/old/prototype.yui.js trunk/linpha2/lib/js/old/scriptaculous-js/ trunk/linpha2/lib/js/old/scriptaculous.js trunk/linpha2/lib/js/old/scriptaculous.yui.js trunk/linpha2/lib/js/old/slider.js trunk/linpha2/lib/js/old/slider.yui.js trunk/linpha2/lib/js/old/sound.js trunk/linpha2/lib/js/old/sound.yui.js trunk/linpha2/lib/js/old/unittest.js trunk/linpha2/lib/js/old/unittest.yui.js Removed Paths: ------------- trunk/linpha2/lib/js/LinGlobal_old.js trunk/linpha2/lib/js/LinImage_old.js trunk/linpha2/lib/js/LinThumbnails_old.js trunk/linpha2/lib/js/builder.js trunk/linpha2/lib/js/builder.yui.js trunk/linpha2/lib/js/controls.js trunk/linpha2/lib/js/controls.yui.js trunk/linpha2/lib/js/dragdrop.js trunk/linpha2/lib/js/dragdrop.yui.js trunk/linpha2/lib/js/effects.js trunk/linpha2/lib/js/effects.yui.js trunk/linpha2/lib/js/prototype/ trunk/linpha2/lib/js/prototype.js trunk/linpha2/lib/js/prototype.yui.js trunk/linpha2/lib/js/scriptaculous-js/ trunk/linpha2/lib/js/scriptaculous.js trunk/linpha2/lib/js/scriptaculous.yui.js trunk/linpha2/lib/js/slider.js trunk/linpha2/lib/js/slider.yui.js trunk/linpha2/lib/js/sound.js trunk/linpha2/lib/js/sound.yui.js trunk/linpha2/lib/js/unittest.js trunk/linpha2/lib/js/unittest.yui.js Deleted: trunk/linpha2/lib/js/LinGlobal_old.js =================================================================== --- trunk/linpha2/lib/js/LinGlobal_old.js 2008-04-27 09:34:07 UTC (rev 4929) +++ trunk/linpha2/lib/js/LinGlobal_old.js 2008-04-27 09:35:57 UTC (rev 4930) @@ -1,311 +0,0 @@ - -/** - * class and global definitions - */ -var LinGlobal = Class.create(); -var myLinGlobal; - -LinGlobal.prototype = -{ - /** - * initialize() - * Constructor runs on completion of the DOM loading. - */ - initialize: function() - { - this.menuNeedsUpdating = false; - - this.linInnerWidth = 0; - this.linInnerHeight = 0; - this.linPageXOffset = 0; - this.linPageYOffset = 0; - - this.tabs = new Array(); - - this.nofPopups = 0; - }, - - /** - * dynamically open syslog - * used in ajax context - */ - linSyslog: function(text) - { - if( typeof $('linDivSyslogText') != 'undefined' ) - { - if( $('linDivSyslogText').innerHTML == '' ) - { - $('linDivSyslogText').innerHTML += text; - } - else - { - $('linDivSyslogText').innerHTML += '<br />' + text; - } - - this.setScrollSize(); - $('linDivSyslog').style.top = (this.linPageYOffset + 15) + 'px'; - $('linDivSyslog').style.left = (this.linPageXOffset + 15) + 'px'; - Element.show('linDivSyslog'); - } - }, - closeSyslog: function() - { - $('linDivSyslogText').innerHTML = ''; - Element.hide('linDivSyslog'); - }, - - /** - * check ajax compatibilty - * will be on every page view until it was successfully - * then, the page will be reloaded - * - * use this on every page and not only on home page, because if user is linked directly to an image - * - * ajax may be disabled with ./?linCat=ajax&disable_ajax - * and may be re-enabled with ./?linCat=ajax&enable_ajax - * - * http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request - */ - checkAjaxCompatibility: function() - { - new Ajax.Request(LINPHA_LINK + '&linCat=ajax&use_js', {method:'get', asynchronous:true, onSuccess:myLinGlobal.checkAjaxCompatibilitySuccess} ); - }, - - /** - * reload page, now with ajax activated - * will be called if the request in checkAjaxCompatibility() was successfully - */ - checkAjaxCompatibilitySuccess: function(t) - { - if( t.responseText == 'use_js saved' ) - { - myLinGlobal.linSyslog('Ajax enabled'); - location.href = document.location; - } - }, - - AjaxPost: function(url, parameters, successFunction) - { - var opt = { - // Use POST - method: 'post', - // Send this lovely data - postBody: parameters - , - // asynchron, of course - asynchronous:true, - - // Handle successful response - onSuccess: successFunction, - - // Handle 404 - on404: function(t) { - alert('Error 404: ' + t.statusText); - }, - // Handle other errors - onFailure: function(t) { - alert('Error ' + t.status + ' -- ' + t.statusText); - } - } - - new Ajax.Request(url, opt); - }, - - /*reloadMenu: function() - { - if( this.menuNeedsUpdating ) - { - new Ajax.Updater('menu', LINPHA_LINK + '&linCat=ajax&reloadmenu&linId='+IdCurrent, {method: 'get', asynchronous:true, evalScripts:true}); - this.menuNeedsUpdating = false; - } - },*/ - - /** - * setWindowSize() - * - * sets two variables of the inner window width and height - * takes care of browser incompatibilities - */ - setWindowSize: function() - { - /** - * browser incompatibilities... - */ - if (window.innerHeight) // all except Explorer - { - this.linInnerWidth = self.innerWidth; - this.linInnerHeight = self.innerHeight; - } - else if (document.body && document.body.offsetWidth) - { - this.linInnerWidth = document.body.offsetWidth; - this.linInnerHeight = document.body.offsetHeight; - } - else - { - this.linInnerWidth = 500; - this.linInnerHeight = 300; - } - }, - - /** - * setMainHeight - * - * sets the height in thumb and image view of the "linDivMainOuter" - */ - setMainHeight: function() - { - this.setWindowSize(); - - var newHeight = this.linInnerHeight - $('linDivMain').offsetTop - 40; // 35 = 15 (bottom rounded corners) + 10 (margin-bottom) + 15 (??) - if(newHeight < 100) - { - newHeight = 100; - } - - $('linDivMain').style.height = newHeight + 'px'; - }, - - /** - * setScrollSize - * - * sets two variables with the scroll offset - * takes care of browser incompatibilites - * @uses linSyslog() - */ - setScrollSize: function() - { - if (self.pageYOffset) // all except Explorer - { - this.linPageXOffset = self.pageXOffset; - this.linPageYOffset = self.pageYOffset; - } - else if (document.documentElement && document.documentElement.scrollTop) - // Explorer 6 Strict - { - this.linPageXOffset = document.documentElement.scrollLeft; - this.linPageYOffset = document.documentElement.scrollTop; - } - else if (document.body) // all other Explorers - { - this.linPageXOffset = document.body.scrollLeft; - this.linPageYOffset = document.body.scrollTop; - } - }, - - fOnError: function(txt_message, url, line) { - var txt = "Error occured...\n\n"; - txt += "Message: " + txt_message + "\n"; - txt += "URL: " + url + "\n"; - txt += "Line: " + line; - alert(txt); - }, - - /** - * menu tab functions - - openTab: function( className, tabNr ) { - divElems = document.getElementsByTagName('div'); - for(i = 0, n = 0; i < divElems.length; i++) - { - if( divElems[i].className == className ) - { - if(n == tabNr && - typeof this.tabs[ className ]!='undefined' && - typeof this.tabs[ className ][ tabNr ]!='undefined' && - this.tabs[ className ][ tabNr ]!='disabled') - { - divElems[i].style.display = ''; - } else { - divElems[i].style.display = 'none'; - } - - n++; - } - } - }, - disableTab: function( className, tabNr, elemAId ) { - this.tabs[ className ][ tabNr ] = 'disabled'; - $(elemAId).style.color = 'gray'; - }, - enableTab: function( className, tabNr, elemAId ) { - //alert(className + ' ' + typeof this.tabs[ className ] + ' ' + this.tabs[ className ]); - //this.tabs[ className ][ tabNr ] = ''; - //this.tabs.className.tabNr = ''; - $(elemAId).style.color = ''; - },*/ - - /** - * popup functions - */ - createPopup: function( elemId ) { - this.divPopupWindow = Builder.node('div', {id: 'linPopup'+this.nofPopups, className: 'linPopupWindow'} ); - - var divClose = Builder.node('div', {className: 'linPopupClose'}); - var divCloseButton = Builder.node('input', {type: 'button', value: 'X', - onclick: 'myLinGlobal.closePopup(\'linPopup'+this.nofPopups+'\')', className: 'linPopupCloseButton'}); - divClose.appendChild(divCloseButton); - - var divTitleBar = Builder.node('div', {className: 'linPopupTitleBar'} ); - divTitleBar.appendChild(divClose); - - - var divText = $(elemId).cloneNode(true); - divText.className = 'linPopupText'; - Element.show(divText); - - this.divPopupWindow.appendChild(divTitleBar); - this.divPopupWindow.appendChild(divText); - - document.body.appendChild(this.divPopupWindow); - - new Draggable(this.divPopupWindow, {handle: 'linPopupTitleBar'}); - - this.nofPopups++; - }, - closePopup: function(elemId) { - document.body.removeChild($(elemId)); - } - - - // no comma at last function. firefox works, but IE not! -} - -/** - * initLinGlobal() - * - * create the class object - */ -function initLinGlobal() -{ - myLinGlobal = new LinGlobal(); - - Event.observe(window, 'error', myLinGlobal.fOnError, false); - - /*if( checkAjaxCompatibility ) { - myLinGlobal.checkAjaxCompatibility(); - }*/ -} - -//Event.observe(window, 'load', initLinGlobal, false); -initLinGlobal(); - - -/** - * on resize functions - */ -function linEnableOnResize() -{ - Event.observe(window, 'resize', linOnResizeCreateTrigger, false); -} - -/** - * resizeWindow, use this wrapper function because internet explorer triggers the resize event to fast - * - * linOnResizeWrapper() must be defined where it's actually used (LinThumbnails.js, LinMapView.js) - */ -function linOnResizeCreateTrigger() -{ - clearTimeout(this.timerResize); - this.timerResize = setTimeout(linOnResizeWrapper,250); -} Deleted: trunk/linpha2/lib/js/LinImage_old.js =================================================================== --- trunk/linpha2/lib/js/LinImage_old.js 2008-04-27 09:34:07 UTC (rev 4929) +++ trunk/linpha2/lib/js/LinImage_old.js 2008-04-27 09:35:57 UTC (rev 4930) @@ -1,1186 +0,0 @@ - -/** - * class and global definitions - */ -var LinImage = Class.create(); -var myLinImage; - -LinImage.prototype = { - - /** - * initialize() - * - * Constructor runs on completion of the DOM loading. - */ - initialize: function() - { - /*this.imgInfoColorNotActive = $('linDivInfoLink').style.color; - this.imgInfoColorActive = $('linHrefInfoLink').style.color;*/ - this.imgInfoShowHide = 'hide'; - - - this.fullscreenActive = false; - this.fullscreenOldMaxWidth, this.fullscreenOldMaxHeight, this.previousBodyOverflow; - this.slideshowActive = false; - this.ssCurrentTimerID; - this.ssCurrentDelay = 5000; - this.ssRandom = false; - this.ssLoop = false; - - this.xmlDoc = new Array(); - this.nextThumbs = new Array(); - this.prevThumbs = new Array(); - this.preloadImageSrc = new Array(); // image array, will contain a lot of preloaded images - this.finishedPreloadedImages = new Array(); // set to true after preload completed - this.preloadXmlFinished = new Array(); - - this.currentFileType; // 1 = image, 2 = video, 3 = others - - this.curLocationHash; - //this.timerResize; - }, - - - // ----------------------------------------------------------------------------------- - // functions to load xml data of images - // ----------------------------------------------------------------------------------- - - loadImage: function(imgId) { - if(IdCurrent != imgId) - { - IdCurrent = imgId; - //myLinGlobal.menuNeedsUpdating = true; // IdCurrent changed, update menu on next hover of the menu - location.hash = 'idCurrent='+IdCurrent; - } - - this.curLocationHash = location.hash; // update current Hash, this value is periodically checked to reload the image if neccessary - - // do not load the data again if it is already cached - if(this.preloadXmlFinished[imgId] && typeof this.xmlDoc[imgId] != "undefined" ) // use typeof to work in IE - { - this.changeImage(); - } - else - { - this.loadImageXml(imgId); - } - }, - - loadImageXml: function(imgId) { - myLinGlobal.AjaxPost(linUrlBase + '&linId=' + imgId + '&xml', '', myLinImage.loadImageContinue); - }, - - loadImageContinue: function(t) { - var loadedimgid = t.responseXML.documentElement.getElementsByTagName('imgid').item(0).firstChild.data; - - // save xml data - myLinImage.xmlDoc[loadedimgid] = t.responseXML.documentElement; - myLinImage.preloadXmlFinished[loadedimgid] = true; - - if( loadedimgid == IdCurrent ) // coming from loadImage() - { - myLinImage.changeImage(); - } - else // coming from preloadImage() - { - myLinImage.preloadImage(loadedimgid); - } - }, - - - // ----------------------------------------------------------------------------------- - // Navigation functions - // ----------------------------------------------------------------------------------- - - movePrev: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - if(this.prevThumbs[ this.prevThumbs.length - 1 ]) - { - Element.setOpacity('linSsImgPrev',0.7); - new Effect.Appear('linSsImgPrev', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage(this.prevThumbs[ this.prevThumbs.length - 1 ]); - - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - } - else // end reached, do nothing but enable keyboard navigation again - { - myLinImage.enableKeyboardNav(); - } - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - moveNext: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - if(this.nextThumbs[0]) - { - Element.setOpacity('linSsImgNext',0.7); - new Effect.Appear('linSsImgNext', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage(this.nextThumbs[0]); - } - else if( this.ssLoop ) - { - Element.setOpacity('linSsImgNext',0.7); - new Effect.Appear('linSsImgNext', { duration: 0.5, from: 0.7, to: 1.0 }); - this.moveFirst(); - } - else // end reached, do nothing but enable keyboard navigation again - { - myLinImage.enableKeyboardNav(); - } - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - moveFirst: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - Element.setOpacity('linSsImgFirst',0.7); - new Effect.Appear('linSsImgFirst', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage( firstImgId ); - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - moveLast: function() { - if( this.slideshowActive ) - { - clearTimeout(this.ssCurrentTimerID); - } - - Element.setOpacity('linSsImgLast',0.7); - new Effect.Appear('linSsImgLast', { duration: 0.5, from: 0.7, to: 1.0 }); - myLinImage.loadImage( lastImgId ); - - if( this.slideshowActive ) - { - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - }, - - // ----------------------------------------------------------------------------------- - // Change image functions - // ----------------------------------------------------------------------------------- - - /** - * changeImage() - */ - changeImage: function() { - - /** - * set height of outer div to prevent the whole page getting smaller, and if the image is loaded getting bigger again - * but in fullscreen, we want no activities in background - */ - if(! this.fullscreenActive) { - $('linDivMainimage').style.height = $('linImgMainimage').style.height; - //$('linDivMain').style.height = $('linDivMain').offsetHeight; - //alert($('linDivMain').offsetHeight); - } - - /** - * hide elements during transition - */ - this.hideImgInfoNow(); // hide text info link immediately - Element.hide('linImgMainimage'); // hide mainimage while changing image to prevent flicker - Element.hide('linDivInfoLink'); - - this.currentFileType = this.xmlDoc[IdCurrent].getElementsByTagName('filetype').item(0).firstChild.data; - - switch( this.currentFileType ) - { - case '1': // image - - if(! this.finishedPreloadedImages[IdCurrent] ) - { - Element.show('linDivloading'); - } - - //$('linImgMainimage').style.marginLeft = 0; // restore left margin, set when viewing videos - - /** - * calc image width and height - */ - var orgWidth = this.xmlDoc[IdCurrent].getElementsByTagName('imgwidth').item(0).firstChild.data; - var orgHeight = this.xmlDoc[IdCurrent].getElementsByTagName('imgheight').item(0).firstChild.data; - var sizeArray = this.scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); - var imgWidth = sizeArray[0]; - var imgHeight = sizeArray[1]; - - /** - * preload image - */ - var currentImgSrc = imageSrc + IdCurrent + '&width=' + imgWidth + '&height=' + imgHeight; - imgPreloader = new Image(); - - /** - * once image is preloaded, resize image container - * - * pay attention with the other image preloader! - * if imgWidth and imgWidth was not set with trailing 'var' it got overlapping with the other variables - * and this caused the image not resized correctly in resizeImageContainer() !!! - */ - imgPreloader.onload=function(){ - myLinImage.finishedPreloadedImages[IdCurrent] = true; - $('linImgMainimage').src = currentImgSrc; - myLinImage.resizeImageContainer(imgWidth, imgHeight); - } - imgPreloader.src = currentImgSrc; - - break; - case '2': // video - - //$('linImgMainimage').style.marginLeft = 200; - - /** - * show video thumbnail - */ - $('linImgMainimage').src = thumbSrc + IdCurrent ; - $('linImgMainimage').style.width = 'auto'; - $('linImgMainimage').style.height = 'auto'; - - /** - * show image and set div height - */ - this.showImage(); - - break; - case '0': // others - break; - } - }, - - /** - * resizeImageContainer() - */ - resizeImageContainer: function( imgWidth, imgHeight) { - - // get current height and width - /*this.wCur = $('linImgMainimage').offsetWidth; - this.hCur = $('linImgMainimage').offsetHeight; - - // scalars based on change from old to new - this.xScale = ((imgWidth + (borderSize * 2)) / this.wCur) * 100; - this.yScale = ((imgHeight + (borderSize * 2)) / this.hCur) * 100; - - // calculate size difference between new and old image, and resize if necessary - wDiff = (this.wCur - borderSize * 2) - imgWidth; - hDiff = (this.hCur - borderSize * 2) - imgHeight; - - if(!( hDiff == 0)){ new Effect.Scale('linImgMainimage', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); } - if(!( wDiff == 0)){ new Effect.Scale('linImgMainimage', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); } - - // if new and old image are same size and no scaling transition is necessary, - // do a quick pause to prevent image flicker. - if((hDiff == 0) && (wDiff == 0)){ - if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} - }*/ - - $('linImgMainimage').style.width = imgWidth + 'px'; - $('linImgMainimage').style.height = imgHeight + 'px'; - - - /*Element.setHeight('prevLink', imgHeight); - Element.setHeight('nextLink', imgHeight); - Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2));*/ - - /** - * show panorama link - * the only reason why do this at this point is, because this is only done on images - * and we just know the width and height - */ - if( imgWidth/imgHeight >= 2 || imgHeight/imgWidth >= 2 ) - { - Element.show('linHrefPanoLink'); - } - - this.showImage(); - }, - - /** - * showImage() - * - * Display image and begin preloading next images. - */ - showImage: function(){ - Element.hide('linDivloading'); - - if( useEffects ) - { - new Effect.Appear('linImgMainimage', { duration: 0.2, afterFinish: function(){ myLinImage.setImageData(); } }); - } - else - { - Element.show('linImgMainimage'); - this.setImageData() - } - - if(! this.fullscreenActive) - { - $('linDivMainimage').style.height = $('linImgMainimage').style.height; // reset to correct height to prevent trouble if image is bigger or smaller - //$('linDivMain').style.height = 'auto'; - } - }, - - /** - * setImageData() - */ - setImageData: function() - { - this.enableKeyboardNav(); - - /** - * set title - */ - if( typeof $('linDivTitle') != 'undefined' ) - { - $('linDivTitle').innerHTML = this.xmlDoc[IdCurrent].getElementsByTagName('title').item(0).firstChild.data; - } - - /** - * update the menu - * - * replace the image ids in the menu - * replace( /linId=[0-9]* /g , "linId=" + IdCurrent ); - * its just an search/replace of 'linId=x' in the menu - * its very fast (about 0 - 15ms) and its executed every time the image changes - * - * but only in menuMore and menuAdmin, because we have in menuLogin - * linId='+IdCurrent, and ooh this will create very unexpected results..!! - */ - /*if( typeof $('linMenuAdmin') != 'undefined' ) - {*/ - //$('linMenuAdmin').innerHTML = $('linMenuAdmin').innerHTML.replace( /linId=[0-9]*/g , "linId=" + IdCurrent ); - /*}*/ - - /** - * menuMore - */ - /*if( typeof $('linMenuMore') != 'undefined' ) - {*/ - //$('linMenuMore').innerHTML = $('linMenuMore').innerHTML.replace( /linId=[0-9]*/g , "linId=" + IdCurrent ); - - // replace the width and height dimensions of the view at fullscreen link - //var orgWidth = this.xmlDoc[IdCurrent].getElementsByTagName('imgwidth').item(0).firstChild.data; - //var orgHeight = this.xmlDoc[IdCurrent].getElementsByTagName('imgheight').item(0).firstChild.data; - //$('linLiViewAtFullscreen').innerHTML = $('linLiViewAtFullscreen').innerHTML.replace( /width=[0-9]*/ , "width=" + orgWidth ); - //$('linLiViewAtFullscreen').innerHTML = $('linLiViewAtFullscreen').innerHTML.replace( /height=[0-9]*/ , "height=" + orgHeight ); - //$('linLiViewAtFullscreen').innerHTML = $('linLiViewAtFullscreen').innerHTML.replace( /[0-9]*x[0-9]*/ , orgWidth + "x" + orgHeight ); - /*}*/ - - /** - * set current thumb - */ - $('linDivThumbnavi_Current').innerHTML = '<a href="javascript:myLinImage.loadImage(' + IdCurrent + ')"><img class="linImgThumbnavi_Current" src="' + thumbSrc + IdCurrent + '" /></a>'; - - /** - * set prev thumbs - */ - $('linDivThumbnavi_Prev').innerHTML = ''; - this.prevThumbs = new Array(); - if(this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length; i++) - { - var thumbId = this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').item(i).firstChild.data; - this.prevThumbs[i] = thumbId; - this.setPrevNextThumb(thumbId, 'linDivThumbnavi_Prev'); - } - } - - /** - * set next thumbs - */ - $('linDivThumbnavi_Next').innerHTML = ''; - this.nextThumbs = new Array(); - if(this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length; i++) - { - var thumbId = this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').item(i).firstChild.data; - this.nextThumbs[i] = thumbId; - this.setPrevNextThumb(thumbId, 'linDivThumbnavi_Next'); - } - } - - /** - * set meta data - */ - $('linDivMeta').innerHTML = ''; - if(this.xmlDoc[IdCurrent].getElementsByTagName('meta').length > 0) - { - var table = Builder.node('table', {id: 'linTableMeta'} ); - var tbody = Builder.node('tbody'); - - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('meta').length; i++) - { - var meta = this.xmlDoc[IdCurrent].getElementsByTagName('meta').item(i); - var metaname = meta.getElementsByTagName('name').item(0).firstChild.data; - if(meta.getElementsByTagName('value').item(0).hasChildNodes()) { // prevent error in IE - var metavalue = meta.getElementsByTagName('value').item(0).firstChild.data; - } else { - var metavalue = ''; - } - - var tr = Builder.node('tr'); - var tdleft = Builder.node('td', {className: 'linTdMetaLeftColumn'}, metaname ); - var tdright = Builder.node('td', metavalue ); - - tr.appendChild(tdleft); - tr.appendChild(tdright); - tbody.appendChild(tr); - } - - table.appendChild(tbody); - - $('linDivMeta').appendChild(table); - - } - - /** - * file type specific meta data stuff - */ - switch( this.currentFileType ) - { - case '1': // image - this.setImageInfoLink(); // show the "info" link, must be called after Appear('linImgMainimage') - - //Element.hide('linDivVideoLink'); - //Element.show('linDivExifLink'); - //$('linAMetaExif').href = '#' + $('linAMetaExif').href; - //myLinGlobal.enableTab( 'linDivTab', 3, 'linAMetaExif' ); - - break; - case '2': // video - - //Element.show('linDivVideoLink'); - //Element.hide('linDivExifLink'); - //$('linAMetaExif').href = $('linAMetaExif').href.substring(1); - //$('linAMetaExif').href = '#' + $('linAMetaExif').href; - - //myLinGlobal.disableTab( 'linDivTab', 3, 'linAMetaExif' ); - - /*$('linDivMetaOuter').style.top = $('linImgMainimage').offsetTop + 'px'; - $('linDivMetaOuter').style.height = $('linImgMainimage').offsetHeight + 'px'; // 'auto' - Element.show('linDivMetaOuter');*/ - - break; - } - - this.initTextareaAddComment(); - this.setComments(); - - /** - * set image nr - * currently only in slideshow used - */ - $('linDivSlideshowImgNr').innerHTML = this.xmlDoc[IdCurrent].getElementsByTagName('imgnr').item(0).firstChild.data; - - - /** - * and at last, start preloading next and previous images - */ - this.preloadXml(); - - - }, - - /** - * setPrevNextThumb() - * - * code to generate a thumbnail with a <div><a><img> tag - */ - setPrevNextThumb: function(thumbId, divId) - { - var ElemImg = Builder.node('img', {id: 'thumb'+thumbId, className: 'linImgThumbnavi_PrevNext', src: thumbSrc + thumbId}); - var ElemA = Builder.node('a', {href: 'javascript:myLinImage.loadImage(' + thumbId + ')'}); - var ElemDiv = Builder.node('div', {className: 'linDivThumbnavi_PrevNext'}); - - ElemA.appendChild( ElemImg ); - ElemDiv.appendChild( ElemA ); - $(divId).appendChild(ElemDiv); - - if(! this.finishedPreloadedImages[thumbId]) { - Element.setOpacity('thumb'+thumbId,0.5); - } - - }, - - - // ----------------------------------------------------------------------------------- - // Keyboard actions - // ----------------------------------------------------------------------------------- - - /** - * enableKeyboardNav() - */ - enableKeyboardNav: function() { - document.onkeydown = this.keyboardAction; - }, - - /** - * disableKeyboardNav() - */ - disableKeyboardNav: function() { - document.onkeydown = ''; - }, - - /** - * keyboardAction() - * - * very nice - * http://www.mediaevent.de/javascript/needful_tables.html - */ - keyboardAction: function(e) { - - if (e == null) { // ie - keycode = event.keyCode; - ctrlKey = event.ctrlKey; - } else { // mozilla - keycode = e.which; - ctrlKey = e.ctrlKey; - } - - /*if( ctrlKey ) - { - alert('ctrl pressed'); - return; - }*/ - - //alert(keycode); - - key = String.fromCharCode(keycode).toLowerCase(); - - //if ((keycode == 39) && (ctrlKey == true)) // ctrl + arrow right - if (keycode == 34) // page down - { - myLinImage.disableKeyboardNav(); - myLinImage.moveNext(); - return false; - } - //else if ((keycode == 37) && (ctrlKey == true)) // ctrl + arrow left - else if (keycode == 33) // page up - { - myLinImage.disableKeyboardNav(); - myLinImage.movePrev(); - return false; - } - else if ((keycode == 32) && (ctrlKey == true)) // ctrl + space - { - myLinImage.slideshowStartStop(); - } - else if ((keycode == 122)) // F11 - { - if( myLinImage.fullscreenActive ) { - $('linDivSlideshowExit').show(); // hide exit button to force exit again with F11 - myLinImage.fullscreenStop(); - } else { - $('linDivSlideshowExit').hide(); - myLinImage.fullscreenStart(); - } - } - else if ((keycode == 36) && (ctrlKey == true)) // ctrl + home - //else if (keycode == 36) // home - { - myLinImage.moveFirst(); - return false; - } - else if ((keycode == 35) && (ctrlKey == true)) // ctrl + end - //else if (keycode == 35) // end - { - myLinImage.moveLast(); - return false; - } - else if( myLinImage.fullscreenActive && ((key == 'f') || (key == 'x') || (key == 'o') || (key == 'c') ) ) // close fullscreen - { - myLinImage.fullscreenStop(); - } - else if(myLinImage.fullscreenActive && key == 's') // start/stop slideshow - { - myLinImage.slideshowStartStop(); - } - else if(myLinImage.fullscreenActive && key == 'p') // display previous image - { - myLinImage.disableKeyboardNav(); - myLinImage.movePrev(); - } - else if(myLinImage.fullscreenActive && key == 'n') // display next image - { - myLinImage.disableKeyboardNav(); - myLinImage.moveNext(); - } - }, - - - // ----------------------------------------------------------------------------------- - // Preload functions - // ----------------------------------------------------------------------------------- - - /** - * preloadXml() - * Preload previous and next images. - * - * normally, loadImageXml() will call also preloadImage() - * but we also need to call preloadImage() if the Xml data is preloaded, - * but not yet the image (this may occur if we change to fullscreen, - * then, the images need to be re preloaded all - */ - preloadXml: function() { - - // preload nextthumb from left to right - if(this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').length; i++) - { - var imgId = this.xmlDoc[IdCurrent].getElementsByTagName('nextthumb').item(i).firstChild.data; - - if(! this.preloadXmlFinished[imgId]) - { - this.loadImageXml(imgId); - } - else if(! this.finishedPreloadedImages[imgId] ) - { - this.preloadImage(imgId); - } - } - } - - // preload prevthumb from right to left - if(this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length > 0) - { - for(var i = this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').length-1; i >= 0; i--) - { - var imgId = this.xmlDoc[IdCurrent].getElementsByTagName('prevthumb').item(i).firstChild.data; - - if(! this.preloadXmlFinished[imgId]) - { - this.loadImageXml(imgId); - } - else if(! this.finishedPreloadedImages[imgId] ) - { - this.preloadImage(imgId); - } - } - } - }, - - /** - * preloadImage() - * - * will be called after getting the xml data - */ - preloadImage: function(imgId) - { - if(! this.finishedPreloadedImages[imgId] ) - { - switch(this.xmlDoc[imgId].getElementsByTagName('filetype').item(0).firstChild.data) - { - case '1': // image - /** - * set image width and height - */ - var orgWidth = this.xmlDoc[imgId].getElementsByTagName('imgwidth').item(0).firstChild.data; - var orgHeight = this.xmlDoc[imgId].getElementsByTagName('imgheight').item(0).firstChild.data; - var sizeArray = this.scaleToFit(orgWidth,orgHeight,maxImageWidth,maxImageHeight,1); - var imgWidth = sizeArray[0]; - var imgHeight = sizeArray[1]; - - /** - * preload image - */ - this.preloadImageSrc[imgId] = new Image(); - - this.preloadImageSrc[imgId].onload=function(){ - myLinImage.preloadImageFinished(imgId); - } - this.preloadImageSrc[imgId].src = imageSrc + imgId + '&width=' + imgWidth + '&height=' + imgHeight; - - break; - case '2': // video - this.preloadImageFinished(imgId); - break; - case '0': // other - break; - } - } - }, - - preloadImageFinished: function(imgId) { - - this.finishedPreloadedImages[imgId] = true; - - if( $('thumb'+imgId) ) // maybe its not here anymore - { - new Effect.Appear('thumb'+imgId, { duration: 0.5, from: 0.5, to: 1.0 }); - } - - }, - - - // ----------------------------------------------------------------------------------- - // Slideshow functions - // ----------------------------------------------------------------------------------- - - fullscreenStart: function() - { - this.fullscreenActive = true; - - /** - * save old values to restore if slideshow ends - */ - this.fullscreenOldMaxWidth = maxImageWidth; - this.fullscreenOldMaxHeight = maxImageHeight; - - /** - * disable scrollbars - */ - this.previousBodyOverflow = document.getElementsByTagName("body")[0].style.overflow; - document.getElementsByTagName("body")[0].style.overflow='hidden'; - - /** - * start slideshow with some superduper effects - */ - Effect.Appear('linDivSlideshowOverlay', { queue: 'end', duration: 1.0, from: 0.0, to: 0.9 }); - Effect.BlindDown('linDivSlideshowControlsOuter', { queue: 'end'} ); - Element.show('linDivSlideshowImage'); - - /** - * steal the mainimage - */ - $('linDivMainimage').innerHTML = ''; - $('linDivSlideshowImage').innerHTML = '<img id="linImgMainimage" style="display: none;" class="linImgSlideshow">'; - - /** - * reload image with new position and size - */ - //this.resizeWindow(); - //linOnResizeCreateTrigger(); - linOnResizeWrapper(); - }, - fullscreenStop: function() - { - this.fullscreenActive = false; - - /** - * restore max image size - */ - maxImageWidth = this.fullscreenOldMaxWidth; - maxImageHeight = this.fullscreenOldMaxHeight; - - /** - * re-enable scrollbars - */ - document.getElementsByTagName("body")[0].style.overflow = this.previousBodyOverflow; - - /** - * delete preloaded images after stopping fullscreen - */ - this.finishedPreloadedImages = new Array(); - - /** - * end slideshow with some superduper effects - */ - Effect.Fold('linDivSlideshowControlsOuter', { queue: 'end'} ); - Effect.Fade('linDivSlideshowOverlay', { queue: 'end', duration: 0.5, from: 0.9, to: 0.0 } ); - Element.hide('linDivSlideshowImage'); - - /** - * give back the mainimage - */ - $('linDivSlideshowImage').innerHTML = ''; - $('linDivMainimage').innerHTML = '<img id="linImgMainimage" style="display: none;">'; - - /** - * reload image with old position and size - */ - this.loadImage( IdCurrent ); - }, - - slideshowStartStop: function() - { - // start Slideshow - if(! this.slideshowActive) - { - this.slideshowActive = true; - Element.setOpacity('linSsImgStart',0.7); - this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - else // stop Slideshow - { - this.slideshowActive = false; - Element.setOpacity('linSsImgStart',1); - clearTimeout(this.ssCurrentTimerID); - } - }, - slideshowPlay: function() - { - if(this.nextThumbs[0] || this.ssLoop) - { - this.moveNext(); - //this.ssCurrentTimerID = setTimeout("myLinImage.slideshowPlay()", this.ssCurrentDelay); - } - else - { - // force stop slideshow - this.slideshowActive = true; - this.slideshowStartStop(); - } - }, - - slideshowChangeDelay: function() - { - this.ssCurrentDelay = $('linSsDelay').options[ $('linSsDelay').selectedIndex ].value * 1000; - //document.optionsForm.delay.options[document.optionsForm.delay.selectedIndex].value * 1000; - }, - slideshowChangeLoop: function() - { - if(! this.ssLoop) { - this.ssLoop = true; - Element.setOpacity('linSsImgLoop',0.7); - } else { - this.ssLoop = false; - Element.setOpacity('linSsImgLoop',1); - } - }, - slideshowChangeRandom: function() - { - if(! this.ssRandom) { - this.ssRandom = true; - Element.setOpacity('linSsImgRandom',0.7); - } else { - this.ssRandom = false; - Element.setOpacity('linSsImgRandom',1); - } - alert('This feature is currently not implemented, do we really need that?'); - }, - - - // ----------------------------------------------------------------------------------- - // Image info functions - // ----------------------------------------------------------------------------------- - - /** - * setImageInfoLink() - * - * positions the info link on bottom right of the image - * could only be done after image is not hidden anymore - * - * if this can be done without javascript, please tell me - */ - setImageInfoLink: function() - { - $('linDivInfoLink').style.top = ($('linImgMainimage').offsetTop + $('linImgMainimage').offsetHeight + 3) + 'px'; - $('linDivInfoLink').style.left = ($('linImgMainimage').offsetLeft + $('linImgMainimage').offsetWidth - 200) + 'px'; // 200: width of linDivInfoLink, value set view_img.css width = 200px; can't get width with javascript because element is hidden - Element.show('linDivInfoLink'); - }, - - /** - * DEPRECATED - * showImgInfo() - * - * fade out the image, show the meta infos, sets the color of the "Info" link to another - * - * idea: - * swap the colors of <a> and <div> tag (id 'linHrefInfoLink' and 'linDivInfoLink' - * so it is possible to set the colors in the css template (and not in javascript file) - - showImgInfo: function() - { - // make visible/invisible - if( this.imgInfoShowHide == 'hide' ) - { - this.imgInfoShowHide = 'show'; - - // set position - $('linDivMetaOuter').style.top = $('linImgMainimage').offsetTop + 'px'; - $('linDivMetaOuter').style.height = $('linImgMainimage').offsetHeight + 'px'; - - new Effect.Appear('linDivMetaOuter', { duration: 0.3 }); //, from: 0.0, to: 1.0 - new Effect.Fade('linDivMainimage', { duration: 0.3, from: 1.0, to: 0.2 }); - - $('linHrefInfoLink').style.color = this.imgInfoColorNotActive; - } - else - { - this.imgInfoShowHide = 'hide'; - - new Effect.Fade('linDivMetaOuter', { duration: 0.3 }); // , from: 1.0, to: 0.0 - new Effect.Appear('linDivMainimage', { duration: 0.3, from: 0.2, to: 1.0 }); - - $('linHrefInfoLink').style.color = this.imgInfoColorActive; - } - },*/ - hideImgInfoNow: function() - { - //Element.hide('linDivMetaOuter'); - Element.hide('linHrefPanoLink'); - Element.hide('linDivVideoLink'); - - //Element.setOpacity('linDivMainimage',1); - this.imgInfoShowHide = 'hide'; - - //$('linHrefInfoLink').style.color = this.imgInfoColorActive; - }, - - /** - * returns an array(width, height) with the correct size to fit - * in dst_w and dst_h - */ - scaleToFit: function(src_w,src_h,dst_w,dst_h,no_increase) - { - if(src_h == 0 || src_w == 0) - { - return new Array(0, 0); - } - - var img_relation = src_w / src_h; - - // Image is smaller than screen, no resize required - if ((src_w <= dst_w) && (src_h <= dst_h) && no_increase) - { - var returnarray = new Array( Math.round(src_w), Math.round(src_h) ); - } - else - { - /* - The image is way bigger than the screen, resize maintaining aspect ratio - - $src_w, $src_h: original image sizes - $dst_w, $dst_h: screen width and height - $img_relation = $src_w/$src_h; - - Either $dst_w decisive or $dst_h, usually $dst_h - */ - - var tmp_height = dst_w / img_relation; // calc the new height with screen width - if (tmp_height > dst_h) // we were wrong, it's still widther than screen -> $dst_h is decisive - { - var returnarray = new Array( Math.round(img_relation*dst_h), Math.round(dst_h) ); - } - else - { - var returnarray = new Array( Math.round(dst_w), Math.round(tmp_height) ); - } - } - - return returnarray; - }, - - - // ----------------------------------------------------------------------------------- - // Comments - // ----------------------------------------------------------------------------------- - - setComments: function() - { - $('linDivComments').innerHTML = ''; - - if(this.xmlDoc[IdCurrent].getElementsByTagName('comment').length > 0) - { - for(var i = 0; i < this.xmlDoc[IdCurrent].getElementsByTagName('comment').length; i++) - { - var tagcomment = this.xmlDoc[IdCurrent].getElementsByTagName('comment').item(i); - var commenttime = document.createTextNode( tagcomment.getElementsByTagName('time').item(0).firstChild.data + ' by ' ); - var commentauthor = document.createTextNode( tagcomment.getElementsByTagName('author').item(0).firstChild.data ); -// var commenttext = document.createTextNode( tagcomment.getElementsByTagName('text').item(0).firstChild.data ); - - var commenttextdiv = Builder.node('div', {id: 'linComment'+i}); - - $('linDivComments').appendChild(commenttime); - $('linDivComments').appendChild(commentauthor); - $('linDivComments').appendChild( document.createElement("hr") ); - $('linDivComments').appendChild(commenttextdiv); - $('linDivComments').appendChild( document.createElement("br") ); - $('linDivComments').appendChild( document.createElement("br") ); - - $('linComment'+i).innerHTML = tagcomment.getElementsByTagName('text').item(0).firstChild.data; - } - } - }, - - saveComment: function(t) - { - // not use 'this.' doesnt work if call from ajax success function - - myLinImage.xmlDoc[IdCurrent] = t.responseXML.documentElement; - - if(myLinImage.xmlDoc[IdCurrent].getElementsByTagName('commentadded').length > 0) - { - myLinImage.initTextareaAddComment(); - myLinGlobal.linSyslog( myLinImage.xmlDoc[IdCurrent].getElementsByTagName('commentadded').item(0).firstChild.data ); - } - - //myLinImage.loadImage(IdCurrent); - myLinImage.setComments(); - }, - - /** - * openTextarea() - * - * opens the bigger textarea to enter longer image comments - * this function is defined in view_img_static.html.php too - */ - openTextarea: function() - { - Element.show('linDivAddCommentTextarea'); - Element.hide('linDivAddCommentText'); - - $('linInputAddCommentTextarea').value = $('linInputAddCommentText').value; - }, - - initTextareaAddComment: function() - { - Element.hide('linDivAddCommentTextarea'); - Element.show('linDivAddCommentText'); - - $('linInputAddCommentTextarea').value = ''; - $('linInputAddCommentText').value = ''; - }, - - - // ----------------------------------------------------------------------------------- - // Meta functions - // ----------------------------------------------------------------------------------- - - updateLinId: function(elemId) - { - elemId.href = elemId.href.replace( /linId=[0-9]*/g , "linId=" + IdCurrent ); - } - - - // ----------------------------------------------------------------------------------- - // Common used functions - // ----------------------------------------------------------------------------------- - - /** - * resizeWindow, use this wrapper function because internet explorer triggers the resize event to fast - */ - /*resizeWindow: function () - { - clearTimeout(this.timerResize); - this.timerResize = setTimeout(linImageWrapper,250); - }*/ -} - -/** - * linImageWrapper() - * - * use this wrapper function if called from setTimeout() - * because 'this.' would not work otherwise - */ -function linOnResizeWrapper() -{ - if(myLinImage.fullscreenActive) - { - /** - * delete preloaded images after starting fullscreen and resizing window - */ - myLinImage.finishedPreloadedImages = new Array(); - - myLinGlobal.setWindowSize(); - maxImageWidth = myLinGlobal.linInnerWidth - 70; - maxImageHeight = myLinGlobal.linInnerHeight - 120; - - myLinImage.loadImage( IdCurrent ); - } - else - { - myLinImage.setImageInfoLink(); - // myLinGlobal.setMainHeight(); - } -} - -/** - * init on finished page load - */ -function initLinImage() -{ - $('linDivMainimage').style.height = startImgHeight + 'px'; // initial sets correct height at begin and not after the image is loaded - myLinImage = new LinImage(); - - /** - * doing something very important! - * rebuild the browsers histroy back, forware and reload functions - * if we have a #idCurrent=xyz in the url use this as the id - */ - if( document.location.hash.indexOf('idCurrent') != -1 ) - { - IdCurrent = document.location.hash.substr(11); - } - - /** - * and again something important - * rebuild the browsers histroy back, forware and reload functions - * periodically check if the url has changed - * if so, load the new id - */ - myLinImage.curLocationHash = location.hash; - window.setInterval(function() - { - if (myLinImage.curLocationHash != location.hash) - { - if( document.location.hash.substr(11) != '' ) - { - IdCurrent = document.location.hash.substr(11); - - } - else // location.hash contains no '#idCurrent', we're back on start - { - IdCurrent = startIdCurrent; - } - - myLinImage.loadImage(IdCurrent); - } - }, 1000); - - - /** - * append the slideshow divs to the body - * we need to append to body to be sure to get the real fullscreen - * even if we are locked in another div - */ - var objBody = document.getElementsByTagName("body").item(0); - objBody.appendChild( Builder.node('div', {id: "linDivSlideshowOverlay", style: "display: none;"}) ); - objBody.appendChild( Builder.node('div', {id: "linDivSlideshowImage", style: "display: none;"}) ); - objBody.appendChild( Builder.node('div', {id: "linDivSlideshowControlsOuter", style: "display: none;"}) ); - - $('linDivSlideshowControlsOuter').innerHTML = linSlideshowHtml; - - - // automatically start slideshow if requested (coming from thumbview) - if( document.location.search.indexOf('slideshow') != -1 ) - { - myLinImage.fullscreenStart(); - } - else - { - myLinImage.loadImage(IdCurrent); - // setMainHeight(); // defined in LinGlobal.js - // window.onresize = onWindowResize; - // Event.observe(window, 'resize', onWindowResize, false); - Event.observe(window, 'resize', linOnResizeCreateTrigger, false); - } -} - -Event.observe(window, 'load', initLinImage, false); - Deleted: trunk/linpha2/lib/js/LinThumbnails_old.js =================================================================== --- trunk/linpha2/lib/js/LinThumbnails_old.js 2008-04-27 09:34:07 UTC (rev 4929) +++ trunk/linpha2/lib/js/LinThumbnails_old.js 2008-04-27 09:35:57 UTC (rev 4930) @@ -1,426 +0,0 @@ -/** - * javascript thumbnail viewer - * - * check performance: - var start = new Date().getTime(); - alert( (new Date().getTime() - start) + 'ms' ); - * - */ - -/** - * class and global definitions - */ -var LinThumbnails = Class.create(); -var myLinThumbnails; - -LinThumbnails.prototype = -{ - /** - * initialize() - * Constructor runs on completion of the DOM loading. - */ - initialize: function() - { - this.currentPage = linStartupPage - this.nrPages = 0; - this.timerResize; - - /** - * page numbers - */ - this.pnLeft = 3; - this.pnRight = 3; - this.pnMiddleLeft = 2; - this.pnMiddleRight = 4; - this.pnConstant = this.pnLeft + this.pnRight + this.pnMiddleLeft + this.pnMiddleRight + 1; - this.spaceMin = 2; // minimum space before replacing numbers with dots - }, - - displayThumbs: function() - { - /** - * set correct main height only if linPhotosPerPage == auto - * needs to be in linDisplayThumbs! - */ - myLinGlobal.setMainHeight(); // defined in LinGlobal.js - - /** - * calculate nr of photos per page (from select form) - */ - switch( linPhotosPerPage ) - { - case 'auto': - var nr_cols = Math.floor( (document.getElementById('linDivMain')['offsetWidth']-linMainSpacerWidth) / (linTnSize + linImgSpacerWidth) ); - var nr_rows = Math.floor( (document.getElementById('linDivMain')['offsetHeight']-linMainSpacerHeight) / (linTnSize + linImgSpacerHeight + (linImgDivSpacerHeight*linNrTextLines) ) ); - var max_photos_per_page = nr_rows * nr_cols; - break; - case 'all': - var nr_cols = Math.floor( (document.getElementById('linDivMain')['offsetWidth']-linMainSpacerWidth) / (linTnSize + linImgSpacerWidth) ); - var max_photos_per_page = linTotPhotos; - var nr_rows = Math.ceil(max_photos_per_page / nr_cols); - break; - default: - /** - * ceil max_photos_per_page to complet the row! - */ - var nr_cols = Math.floor( (document.getElementById('linDivMain')['offsetWidth']-linMainSpacerWidth-5) / (linTnSize + linImgSpacerWidth) ); /* -5 -> scrollbars */ - var nr_rows = Math.ceil( linPhotosPerPage / nr_cols); - var max_photos_per_page = nr_rows * nr_cols; - break; - } - - /** - * at least on image per page - */ - (nr_cols == 0) ? nr_cols = 1 : ''; - (nr_rows == 0) ? nr_rows = 1 : ''; - (max_photos_per_page == 0) ? max_photos_per_page = nr_rows * nr_cols : ''; - - - /** - * prepare page numbers - */ - this.nrPages = Math.ceil( linTotPhotos / max_photos_per_page ); - - - /** - * check if our current page still exists (maybe we changed the linTnSize and now there arent so much pages anymore) - * (but not if this.currentPage == 1 and this.nrPages == 0) - */ - if(this.currentPage > this.nrPages && this.currentPage != 1) - { - this.currentPage = this.nrPages; - } - - /** - * write page numbers - */ - this.writePageNumbers(); - - /** - * write divs - */ - var img_nr = 1; - var startup_img_nr = (this.currentPage - 1)*max_photos_per_page; - - $('linDivMain').innerHTML=''; - divhtmltext = ''; - - if(linViewMode == 'thumbdetail') { - var style1text = ''; - var style2text = ' linDivImgDetail'; - var style3text = 'class="linDivTextDetail"'; - } else { - var style1text = ' style="width: ' + linTnSize + '"'; - var style2text = ''; - var style3text = 'class="linDivText"'; - } - - /** - * Prototype modfies the core Array object and you shouldn't use any for - * .. in -loops, instead do like this: - * [...] - * for (var i=0; $t = $aTOC[i]; i++) { - * $temp += 't=' + $t + '<br />'; - * } - * [...] - * - * for( var i=0; index = linImgIds[i] ; i++ ) - * but does not work because the index doesnt starts from 0 - */ - for (index in linImgIds) - { - if(index >= startup_img_nr && img_nr <= max_photos_per_page) - { - if( (img_nr-1) % nr_cols == 0) { - //var styletext = ' style="clear:left;"'; - divhtmltext += '<div style="clear: left;"></div>'; - } - - divhtmltext += - '<div id="linDivThumb' + index + '" class="linDivThumb"' + style1text + '>' + - linImgIds[index]['before'] + '<div class="linDivImg' + style2text + '">' + - '<a href="' + linUrlBase + '&linId=' + linImgIds[index]['id'] + '">' + - '<img src="' + LINPHA_CLIENT + '/get_thumb.php?linId=' + linImgIds[index]['id'] + '"' + - ' height="' + linTnSize + '" width="' + linTnSize + '" ' + - ' alt="' + linImgIds[index]['title'] + '" title="' + linImgIds[index]['title'] + '"' + - ' class="linImgThumb" />' + - '</a></div><div ' + style3text + '>' + linImgIds[index]['after'] + '</div></div>'; - - /** - * flush buffer of divhtmltext on end of line - * with this buffer, we're 3-4 as fast as without !! - * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! - * - * update: using the DOM functions with createElement etc. we would be at least 2 times slower!! - * - * this is the way to go: - var i, j, el, idx, html; - idx = 0; - html = []; - html[idx++] = "<table>"; - for (i = 0; i < 1000; i++) { - html[idx++] = "<tr>"; - for (j = 0; j < 5; j++) { - html[idx++] = "<td></td>"; - } - html[idx++] = "</tr>"; - } - html[idx++] = "</table>"; - el = document.createElement("div"); - document.body.appendChild(el); - el.innerHTML = html.join(""); - */ - if( (img_nr-1) % nr_cols == 0) - { - $('linDivMain').innerHTML += divhtmltext; - divhtmltext = ''; - } - - img_nr++; - } - } - - $('linDivMain').innerHTML += divhtmltext; - }, - - writePageNumbers: function() - { - /** - * create an array with page numbers - */ - pn_nrs = new Array(); - var nr_pages_shown = 0; - var start_gap = 0; - var end_gap = 0; - - /** - * get all pages which should be shown - */ - for(var i = 1; i <= this.nrPages; i++) - { - if( this.pnConstant >= this.nrPages // show all pages if we dont have much - || i <= this.pnLeft // left side - || (i > ( this.nrPages - this.pnRight ) ) // right side - || (i >= ( this.currentPage - this.pnMiddleLeft ) && i <= this.currentPage) // middle left - || (i <= ( this.currentPage + this.pnMiddleRight ) && i >= this.currentPage) // middle right - ) - { - pn_nrs[i] = 1; - nr_pages_shown++; - - if(start_gap != 0 && end_gap == 0) // make sure this is done only with the first gap - { - end_gap = i-1; // used later to fill up this gap if needed - } - } - else - { - pn_nrs[i] = 0; - - if(start_gap == 0) // make sure this is done only with the first gap - { - start_gap = i; // used later to fill up this gap if needed - } - } - } - - /** - * add this.currentPage to array, and increment nr_pages_shown if needed - */ - if(pn_nrs[this.currentPage] == 0) - { - nr_pages_shown++; - } - pn_nrs[this.currentPage] = 2; - - /** - * if with have a lot of pages, fill up the array so that we have all the time the same number of page numbers - */ - if( this.pnConstant > nr_pages_shown && this.nrPages > this.pnConstant) - { - /** - * fill up the gap (there is only _one_ gap if we have to fill up the array) - * stop if we filled up enough the needed value, - * or stop if we are reaching the this.spaceMin (to prevent: 1 2 3 4 5 6 ... 8 9 10 11) - */ - beginn_with_startgap = 1; - while( this.pnConstant > nr_pages_shown && (end_gap - start_gap) >= this.spaceMin) - { - if(beginn_with_startgap == 1) - { - pn_nrs[start_gap] = 1; - nr_pages_shown++; - start_gap++; - - beginn_with_startgap = 0; - } - else //beginn_with_startgap = 0 - { - pn_nrs[end_gap] = 1; - nr_pages_shown++; - end_gap--; - - beginn_with_startgap = 1; - } - } - } - - /** - * search for small gaps (this.spaceMin) and fill up - */ - var counter = 0; - for(var i = 1; i <= this.nrPages; i++) - { - if(pn_nrs[i] == 0) - { - counter++; - } - else - { - if(counter < this.spaceMin) - { - /** - * fill up gap - */ - for(var ii = (i-1); ii >= (i-counter); ii--) - { - pn_nrs[ii] = 1; - } - } - - /** - * reset counter - */ - counter = 0; - } - } - - - - /** - * write starting '<<' and '<' - */ - if(this.currentPage == 1) - { - $('linDivPagenrLeft').innerHTML = "<< <"; - } - else - { - $('linDivPagenrLeft').innerHTML = ""; - - $('linDivPagenrLeft').appendChild( Builder.node( 'a', {href: 'javascript:myLinThumbnails.gotoPage(1)'}, "<<" ) ); - $('linDivPagenrLeft').appendChild( document.createTextNode(" ") ); - $('linDivPagenrLeft').appendChild( Builder.node( 'a', {href: 'javascript:myLinThumbnails.gotoPage( (myLinThumbnails.currentPage)-1 ) '}, "<" ) ); - } - - /** - * write page numbers - */ - $('linDivPagenrMiddle').innerHTML=''; - - for(var i = 1; i <= this.nrPages; i++) - { - if(pn_nrs[i] != 0) - { - start_gap = 0; - - if(pn_nrs[i] == 2) - { - var myText = document.createTextNode(i); - } - else if(pn_nrs[i] == 1) - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:myLinThumbnails.gotoPage('+i+')'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode(i); - myText.appendChild(myText2); - } - $('linDivPagenrMiddle').appendChild(myText); - - var myText = document.createTextNode(' '); - $('linDivPagenrMiddle').appendChild(myText); - } - else - { - if(start_gap == 0) - { - start_gap = 1; - - var myText = document.createTextNode(' ... '); - $('linDivPagenrMiddle').appendChild(myText); - } - } - } - - /** - * write ending '>' and '>>' - */ - if(this.currentPage == this.nrPages || this.nrPages == 0) // need check this.nrPages != 0 because we don't need links if this.nrPages == 0! - { - $('linDivPagenrRight').innerHTML = "> >>"; - } - else - { - $('linDivPagenrRight').innerHTML = ""; - - $('linDivPagenrRight').appendChild( Builder.node( 'a', {href: 'javascript:myLinThumbnails.gotoPage( (myLinThumbnails.currentPage)+1 )'}, ">" ) ); - $('linDivPagenrRight').appendChild( document.createTextNode(" ") ); - $('linDivPagenrRight').appendChild( Builder.node( 'a', {href: 'javascript:myLinThumbnails.gotoPage( myLinThumbnails.nrPages ) '}, ">>" ) ); - } - }, - - gotoPage: function(nr) - { - this.currentPage = nr; - this.displayThumbs(); - }, - - setTnSize: function( tn_size_local ) - { - linTnSize = tn_size_local; - this.displayThumbs(); - }, - - setNrImages: function( photos_per_page_local) - { - linPhotosPerPage = photos_per_page_local; - this.displayThumbs(); - }, - - /** - * loadSlideshow() - * - * to start the slideshow, first open imageview with first image, and then start slideshow - */ - loadSlideshow: function() - { - location.href = linUrlBase + '&linId=' + linImgIds[0]['id'] + '&slideshow'; - }, -} - - - -/** - * initLinThumbnails() - * - * create the object and initially display the thumbnails - */ -function initLinThumbnails() -{ - myLinThumbnails = new LinThumbnails(); - - linEnableOnResize(); - myLinThumbnails.displayThumbs(); -} - -function linOnResizeWrapper() -{ - myLinThumbnails.displayThumbs(); -} - -Event.observe(window, 'load', initLinThumbnails, false); Deleted: trunk/linpha2/lib/js/builder.js =================================================================== --- trunk/linpha2/lib/js/builder.js 2008-04-27 09:34:07 UTC (rev 4929) +++ trunk/linpha2/lib/js/builder.js 2008-04-27 09:35:57 UTC (rev 4930) @@ -1,136 +0,0 @@ -// script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008 - -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// -// script.aculo.us is freely distributable under the terms of an MIT-style license. -// For details, see the script.aculo.us web site: http://script.aculo.us/ - -var Builder = { - NODEMAP: { - AREA: 'map', - CAPTION: 'table', - COL: 'table', - COLGROUP: 'table', - LEGEND: 'fieldset', - OPTGROUP: 'select', - OPTION: 'select', - PARAM: 'object', - TBODY: 'table', - TD: 'table', - TFOOT: 'table', - TH: 'table', - THEAD: 'table', - TR: 'table' - }, - // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken, - // due to a Firefox bug - node: function(elementName) { - elementName = elementName.toUpperCase(); - - // try innerHTML approach - var parentTag = this.NODEMAP[elementName] || 'div'; - var parentElement = document.createElement(parentTag); - try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 - parentElement.innerHTML = "<" + elementName + "></" + elementName + ">"; - } catch(e) {} - var element = parentElement.firstChild || null; - - // see if browser added wrapping tags - if(element && (element.tagName.toUpperCase() != elementName)) - element = element.getElementsByTagName(elementName)[0]; - - // fallback to createElement approach - if(!element) element = document.createElement(elementName); - - // abort if nothing could be created - if(!element) return; - - // attributes (or text) - if(arguments[1]) - if(this._isStringOrNumber(arguments[1]) || - (arguments[1] instanceof Array) || - arguments[1].tagName) { - this._children(element, arguments[1]); - } else { - var attrs = this._attributes(arguments[1]); - if(attrs.length) { - try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 - parentElement.innerHTML = "<" +elementName + " " + - ... [truncated message content] |