X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=www%2FDTN_Technical_Details%2FScripts%2FiWebImage.js;fp=www%2FDTN_Technical_Details%2FScripts%2FiWebImage.js;h=0000000000000000000000000000000000000000;hb=cb3168238332ab07236096afdc7abc5caf6e9de3;hp=c7589b4baa54122cc699e2b76d31a1b9a36b63bc;hpb=213b8b80bc034929b6d2bcbdd4e56b7db5c72af2;p=dtn diff --git a/www/DTN_Technical_Details/Scripts/iWebImage.js b/www/DTN_Technical_Details/Scripts/iWebImage.js deleted file mode 100644 index c7589b4..0000000 --- a/www/DTN_Technical_Details/Scripts/iWebImage.js +++ /dev/null @@ -1,339 +0,0 @@ -// -// iWeb - iWebImage.js -// Copyright 2007-2008 Apple Inc. -// All rights reserved. -// - -var IWAllImages={};var IWAllImageObjects={};function IWCreateImage(url) -{return IWAllImages[url]||new IWImage(url);} -var IWNamedImages={};function IWImageNamed(name) -{var url=IWNamedImages[name];return url?IWCreateImage(url):null} -function IWRegisterNamedImage(name,url) -{IWNamedImages[name]=url;} -var IWImageEnableUnload=isiPhone;var IWImage=Class.create({initialize:function(url) -{if(IWAllImages.hasOwnProperty(url)) -{iWLog("warning -- use IWCreateImage rather than new IWImage and you'll get better performance");} -this.mPreventUnloading=0;this.mLoading=false;this.mLoaded=false;this.mURL=url;this.mCallbacks=[];IWAllImages[url]=this;},sourceURL:function() -{return this.mURL;},loaded:function() -{return this.mLoaded;},load:function(callback,delayCallbackIfLoaded) -{if(this.mLoaded&&(callback!=null)) -{delayCallbackIfLoaded?setTimeout(callback,0):callback();} -else -{if(callback!=null) -{this.mCallbacks.push(callback);} -if(this.mLoading==false) -{this.mLoading=true;var img=new Image();IWAllImageObjects[this.sourceURL()]=img;img.onload=this.p_onload.bind(this);img.src=this.mURL;}}},unload:function(evenIfNotEnabled) -{if((evenIfNotEnabled||IWImageEnableUnload)&&this.mLoaded) -{if(this.mPreventUnloading<=0) -{this.mLoaded=false;this.mLoading=false;IWAllImageObjects[this.sourceURL()]=null;} -else -{this.mPreventedUnload=true;}}},preventUnloading:function() -{if(this.mPreventUnloading==0) -{this.mPreventedUnload=false;} -++this.mPreventUnloading;},allowUnloading:function() -{--this.mPreventUnloading;if(this.mPreventUnloading<=0&&this.mPreventedUnload) -{this.unload();}},naturalSize:function() -{(function(){return this.mNaturalSize!==undefined}).bind(this).assert();return this.mNaturalSize;},imgObject:function() -{return IWAllImageObjects[this.sourceURL()];},p_onload:function() -{this.preventUnloading();this.mLoaded=true;if(this.mNaturalSize===undefined) -{var imgObject=this.imgObject();(function(){return imgObject!==undefined}).assert();this.mNaturalSize=new IWSize(imgObject.width,imgObject.height);} -for(var i=0;i0) -{var element=elements.shift();var children=element.select("."+effectClass);if(children.length>0) -{elements=elements.minusArray(children);effectQueue=effectQueue.concat(this.p_queueForEffectClass(effect,effectClass,children));} -effectQueue.push({element:element,effect:effect});} -return effectQueue;},p_allStyleSheetsLoaded:function() -{if(isCamino||isFirefox) -{if(timeStyleSheetsAppearedInDOM!=null) -{duration=(new Date().getTime())-timeStyleSheetsAppearedInDOM;if(duration>100) -{allStyleSheetsLoaded=true;timeStyleSheetsAppearedInDOM=null;}} -else if(!allStyleSheetsLoaded) -{for(var i=0,sheetCount=document.styleSheets.length;i0&&duration<100&&readyToApplyEffects) -{var queueEntry=queue.shift();if(queueEntry&&queueEntry.effect&&queueEntry.element) -{queueEntry.effect.applyToElement(queueEntry.element);} -duration=(new Date().getTime())-startTime;} -if(queue.length>0) -{setTimeout(this.p_applyEffectsFromQueue.bind(this,queue),0);} -else -{performPostEffectsFixups();}}});function IWChildOffset(child,parent,positionedOnly) -{var l=0;var t=0;if(parent) -{var current=child;while(current&¤t!=parent) -{if(!positionedOnly||(current.style.position=="absolute")||(current.style.position=="relative")) -{l+=current.offsetLeft;t+=current.offsetTop;} -current=current.parentNode;}} -return new IWPoint(l,t);} -function IWImageExtents(ancestor,images,left,top,right,bottom) -{var unionedBounds=new IWRect(left,top,right-left,bottom-top);for(var e=0;e0)&&(imageClippedBounds.size.height>0)) -{if((unionedBounds.size.width>0)&&(unionedBounds.size.height>0)) -{unionedBounds=unionedBounds.union(imageClippedBounds);} -else -{unionedBounds=imageClippedBounds.clone();}}} -var extents={left:unionedBounds.origin.x,top:unionedBounds.origin.y,right:unionedBounds.origin.x+unionedBounds.size.width,bottom:unionedBounds.origin.y+unionedBounds.size.height};return extents;} -function IWEffectChildren(element,imagesOnly) -{element=$(element);var inlineBlocks=element.select('.inline-block');return element.descendants().findAll(function(child){if((!imagesOnly&&child.match("div.badge-fill"))||child.match("img")) -{var inline=false;for(var index=0,end=inlineBlocks.length;inline==false&&index0);var divBounds=new IWRect(-leftOffset,-topOffset,frameSize.width,frameSize.height).round();if(fillBackground) -{context.fillStyle='rgba(0,0,0,1)';divBounds.fill(context);} -for(var k=0;k=4) -{context.shadowColor="rgba("+parseInt(components[1],16)+", "+parseInt(components[2],16)+", "+parseInt(components[3],16)+", "+self.mOpacity+")";} -else -{components=self.mColor.match(/rgb\(([0-9\.]+),[ ]*([0-9\.]+),[ ]*([0-9\.]+)\)/);if(components&&components.length>=4) -{context.shadowColor="rgba("+components[1]+", "+components[2]+", "+components[3]+", "+self.mOpacity+")";} -else -{iWLog("not using shadow alpha, failed to match "+self.mColor);usingShadowAlpha=false;}}} -if(usingShadowAlpha==false) -{context.globalAlpha*=self.mOpacity;context.shadowColor=self.mColor;} -context.shadowBlur=self.mBlurRadius;context.shadowOffsetX=self.mOffset.x;context.shadowOffsetY=self.mOffset.y;context.drawImage(workingCanvas,0,0);context.restore();if(usingShadowAlpha==false) -{drawImageUnshadowed=self.mOpacity<1.0;} -else -{drawImageUnshadowed=false;}} -if(drawImageUnshadowed) -{context.drawImage(workingCanvas,0,0);} -if(fillBackground) -{divBounds.clear(context);context.save();context.globalAlpha=opacity;context.rect(divBounds.origin.x,divBounds.origin.y,divBounds.size.width,divBounds.size.height);context.clip();for(var k=0;k0) -{for(var j=0;j=this.imgCount) -{allImagesLoaded=true;for(var k=0;allImagesLoaded&&k';clippingDivPost='';thumbRect.origin.x-=left;thumbRect.origin.y-=top;} -var markup='
';markup+=clippingDivPre;markup+=imageStreamEntry.thumbnailMarkupForRect(thumbRect);markup+=clippingDivPost;markup+=this.p_imageMarkup(imageSize,2);markup+='
';return markup;},applyToElement:function(div) -{div=$(div);if(div!=null) -{if(div.parentNode) -{$(div.parentNode).ensureHasLayoutForIE();} -var size=new IWSize(div.offsetWidth,div.offsetHeight);div.insert(this.p_imageMarkup(size,(div.hasClassName("aboveStrokesAndFrames")?-1:"auto")));if(!div.hasClassName("flowDefining")) -{if(div.style.position!='absolute') -{var divRect=new IWRect(0,0,div.offsetWidth,div.offsetHeight);var unionRect=IWZeroRect();var layoutRects=this.p_imageLayout(size);layoutRects.each(function(r) -{unionRect=unionRect.union(r);});var padding=divRect.paddingToRect(unionRect);var marginLeft=Element.getStyle(div,"marginLeft");marginLeft=marginLeft?(toPixelsAtElement(div,marginLeft,false)):0;var marginTop=Element.getStyle(div,"marginTop");marginTop=marginTop?(toPixelsAtElement(div,marginTop,true)):0;var marginRight=Element.getStyle(div,"marginRight");marginRight=marginRight?(toPixelsAtElement(div,marginRight,false)):0;var marginBottom=Element.getStyle(div,"marginBottom");marginBottom=marginBottom?(toPixelsAtElement(div,marginBottom,true)):0;if(windowsInternetExplorer) -{div.setStyle({marginLeft:px(Math.max(0,padding.left-1)+marginLeft),marginTop:px(Math.max(0,padding.top-1)+marginTop),marginRight:px(Math.max(0,padding.right-1)+marginRight),marginBottom:px(Math.max(0,padding.bottom-1)+marginBottom)});if(effectiveBrowserVersion==7) -{updateListOfIE7FloatsFix(div);}} -else -{div.setStyle({marginLeft:px(padding.left+marginLeft),marginTop:px(padding.top+marginTop),marginRight:px(padding.right+marginRight),marginBottom:px(padding.bottom+marginBottom)});}}}}},strokeExtra:function(imageSize) -{if(!imageSize) -{imageSize=this.mMaxImageSize;} -rect=new IWRect(IWZeroPoint(),imageSize);var layout=this.p_imageLayout(rect.size);var unionRect=IWZeroRect();layout.each(function(r) -{unionRect=unionRect.union(r);});return rect.paddingToRect(unionRect);}});var IWStroke=Class.create({initialize:function(strokeURL,strokeRect,maxImageSize) -{this.mStrokeURL=strokeURL;this.mStrokeRect=strokeRect;this.mMaxImageSize=maxImageSize;},p_strokeRect:function(imageSize) -{var hScale=imageSize.width/this.mMaxImageSize.width;var vScale=imageSize.height/this.mMaxImageSize.height;var strokeRect=this.mStrokeRect.scale(hScale,vScale,true);return strokeRect;},p_imageMarkup:function(imageSize,zIndex) -{var style=this.p_strokeRect(imageSize).position();if(zIndex) -{style+='z-index: '+zIndex+';';} -return imgMarkup(this.mStrokeURL,style);},markupForImageStreamEntry:function(imageStreamEntry,imageSize) -{var rect=new IWRect(0,0,imageSize.width,imageSize.height);var markup='
';markup+=imageStreamEntry.thumbnailMarkupForRect(rect);markup+=this.p_imageMarkup(imageSize,2);markup+='
';return markup;},applyToElement:function(div) -{div=$(div);if(div!=null) -{if(div.parentNode) -{$(div.parentNode).ensureHasLayoutForIE();} -var size=new IWSize(div.offsetWidth,div.offsetHeight);div.insert(this.p_imageMarkup(size,(div.hasClassName("aboveStrokesAndFrames")?-1:"auto")));if(!div.hasClassName("flowDefining")) -{if(div.style.position!='absolute') -{var divRect=new IWRect(0,0,div.offsetWidth,div.offsetHeight);var padding=divRect.paddingToRect(this.mStrokeRect);var marginLeft=Element.getStyle(div,"marginLeft");marginLeft=marginLeft?(toPixelsAtElement(div,marginLeft,false)):0;var marginTop=Element.getStyle(div,"marginTop");marginTop=marginTop?(toPixelsAtElement(div,marginTop,true)):0;var marginRight=Element.getStyle(div,"marginRight");marginRight=marginRight?(toPixelsAtElement(div,marginRight,false)):0;var marginBottom=Element.getStyle(div,"marginBottom");marginBottom=marginBottom?(toPixelsAtElement(div,marginBottom,true)):0;div.setStyle({marginLeft:px(padding.left+marginLeft),marginTop:px(padding.top+marginTop),marginRight:px(padding.right+marginRight),marginBottom:px(padding.bottom+marginBottom)});if(windowsInternetExplorer&&effectiveBrowserVersion==7) -{updateListOfIE7FloatsFix(div);}}}}},strokeExtra:function(imageSize) -{if(imageSize===undefined) -{imageSize=this.mMaxImageSize;} -var imageRect=new IWRect(IWZeroPoint(),imageSize);return imageRect.paddingToRect(this.p_strokeRect(imageSize));}});var IWEmptyStroke=Class.create({initialize:function() -{},markupForImageStreamEntry:function(imageStreamEntry,imageSize) -{var rect=new IWRect(0,0,imageSize.width,imageSize.height);var markup='
';markup+=imageStreamEntry.thumbnailMarkupForRect(rect);markup+='
';return markup;},applyToElement:function(div) -{},strokeExtra:function() -{return new IWPadding(0,0,0,0);}});var kSFRFrameTopLeft=0;var kSFRFrameTop=1;var kSFRFrameTopRight=2;var kSFRFrameRight=3;var kSFRFrameBottomRight=4;var kSFRFrameBottom=5;var kSFRFrameBottomLeft=6;var kSFRFrameLeft=7;var kSFRFrameClip=0;var kSFRFrameStretchEvenly=1;var kSFRFrameStretchToFit=2;var IWPhotoFrame=Class.create({initialize:function(images,maskImages,tilingMode,assetScale,leftInset,topInset,rightInset,bottomInset,unscaledLeftWidth,unscaledTopHeight,unscaledRightWidth,unscaledBottomHeight,leftTileHeight,topTileWidth,rightTileHeight,bottomTileWidth,adornmentURL,adornmentPosition,adornmentSize,minimumAssetScale) -{this.mImages=images;this.mMaskImages=maskImages;this.mTilingMode=tilingMode;this.mLeftInset=leftInset;this.mTopInset=topInset;this.mRightInset=rightInset;this.mBottomInset=bottomInset;this.mUnscaledLeftWidth=unscaledLeftWidth;this.mUnscaledTopHeight=unscaledTopHeight;this.mUnscaledRightWidth=unscaledRightWidth;this.mUnscaledBottomHeight=unscaledBottomHeight;this.mLeftTileHeight=leftTileHeight;this.mTopTileWidth=topTileWidth;this.mRightTileHeight=rightTileHeight;this.mBottomTileWidth=bottomTileWidth;this.mAdornmentURL=adornmentURL;this.mAdornmentPosition=adornmentPosition;this.mAdornmentSize=adornmentSize;this.mMinimumAssetScale=minimumAssetScale;this.setAssetScale(assetScale);},setAssetScale:function(assetScale) -{assetScale=Math.min(assetScale,1.0);assetScale=Math.max(this.mMinimumAssetScale,assetScale);this.mAssetScale=assetScale;this.mLeftWidth=this.scaledValue(this.mUnscaledLeftWidth);this.mTopHeight=this.scaledValue(this.mUnscaledTopHeight);this.mRightWidth=this.scaledValue(this.mUnscaledRightWidth);this.mBottomHeight=this.scaledValue(this.mUnscaledBottomHeight);},scaledValue:function(valueToScale) -{return Math.ceil(valueToScale*this.mAssetScale);},markupForImageStreamEntry:function(imageStreamEntry,size) -{var oldAssetScale=this.mAssetScale;var maximumScale=this.maximumAssetScaleForImageSize(size);if((maximumScale=this.mMinimumAssetScale)) -{this.setAssetScale(maximumScale);} -var coverageRect=this.coverageRect(new IWRect(0,0,size.width,size.height));var imageRect=new IWRect(-coverageRect.origin.x,-coverageRect.origin.y,size.width,size.height);coverageRect=coverageRect.offsetToOrigin();var markup='
';markup+=imageStreamEntry.thumbnailMarkupForRect(imageRect);if(maximumScale>=this.mMinimumAssetScale) -{if(this.mImages!=null) -{markup+=this.p_buildFrame(this.mImages,coverageRect.size,2);} -if(this.mAdornmentURL!=null) -{markup+=this.p_adornmentMarkupForRect(imageRect,2);} -if(this.mMaskImages) -{}} -markup+='
';if(oldAssetScale!=this.mAssetScale)this.setAssetScale(oldAssetScale);return markup;},strokeExtra:function() -{var adornmentExtraTopMargin=0;if(this.mAdornmentURL) -{adornmentExtraTopMargin=Math.max(0,(this.scaledValue(this.mAdornmentSize.height)-this.mTopHeight)/2.0-this.mAdornmentPosition.y);} -return new IWPadding(this.mLeftWidth-this.scaledValue(this.mLeftInset),this.mTopHeight-this.scaledValue(this.mTopInset)+adornmentExtraTopMargin,this.mRightWidth-this.scaledValue(this.mRightInset),this.mBottomHeight-this.scaledValue(this.mBottomInset));},applyToElement:function(div) -{div=$(div);if(div!=null) -{if(div.parentNode) -{$(div.parentNode).ensureHasLayoutForIE();} -var markup='';var divRect=new IWRect(0,0,div.offsetWidth,div.offsetHeight);if((divRect.size.width>=(this.scaledValue(this.mLeftInset)+this.scaledValue(this.mRightInset)))&&(divRect.size.height>=(this.scaledValue(this.mTopInset)+this.scaledValue(this.mTopInset)))) -{if(this.mImages!=null) -{var coverageRect=this.coverageRect(divRect);var containerRect=new IWRect(coverageRect.origin.x,coverageRect.origin.y,0,0);markup+='
';markup+=this.p_buildFrame(this.mImages,coverageRect.size,(div.hasClassName("aboveStrokesAndFrames")?-1:"auto"));markup+='
';} -if(this.mAdornmentURL!=null) -{markup+=this.p_adornmentMarkupForRect(divRect);}} -div.insert(markup);if(!div.hasClassName("flowDefining")) -{if(div.style.position!='absolute') -{var frameExtra=this.strokeExtra();var marginLeft=Element.getStyle(div,"marginLeft");marginLeft=marginLeft?(toPixelsAtElement(div,marginLeft,false)):0;var marginTop=Element.getStyle(div,"marginTop");marginTop=marginTop?(toPixelsAtElement(div,marginTop,true)):0;var marginRight=Element.getStyle(div,"marginRight");marginRight=marginRight?(toPixelsAtElement(div,marginRight,false)):0;var marginBottom=Element.getStyle(div,"marginBottom");marginBottom=marginBottom?(toPixelsAtElement(div,marginBottom,true)):0;div.setStyle({marginLeft:px(frameExtra.left+marginLeft),marginTop:px(frameExtra.top+marginTop),marginRight:px(frameExtra.right+marginRight),marginBottom:px(frameExtra.bottom+marginBottom)});if(windowsInternetExplorer&&effectiveBrowserVersion==7) -{updateListOfIE7FloatsFix(div);}}}}},maximumAssetScaleForImageSize:function(in_imgSize) -{var maxScale=1;if((in_imgSize.width>this.mLeftInset+this.mRightInset)&&(in_imgSize.height>this.mTopInset+this.mBottomInset)) -{maxScale=1;} -else if((in_imgSize.width=in_imgSize.width)&&((this.mLeftInset+this.mRightInset)>0)) -{var leftChunkRatio=Math.floor(this.mLeftInset/(this.mLeftInset+this.mRightInset)*in_imgSize.width)/this.mLeftInset;var rightChunkRatio=Math.floor(this.mRightInset/(this.mLeftInset+this.mRightInset)*in_imgSize.width)/this.mRightInset;leftChunkRatio-=floatEpsilon;rightChunkRatio-=floatEpsilon;maxWidthScale=Math.max(leftChunkRatio,rightChunkRatio);if(in_imgSize.width<(Math.ceil(this.mLeftInset*maxWidthScale)+Math.ceil(this.mRightInset*maxWidthScale))) -{maxWidthScale=Math.min(leftChunkRatio,rightChunkRatio);} -if((maxWidthScale=in_imgSize.height)&&((this.mTopInset+this.mBottomInset)>0)) -{var topChunkRatio=Math.floor(this.mTopInset/(this.mTopInset+this.mBottomInset)*in_imgSize.height)/this.mTopInset;var bottomChunkRatio=Math.floor(this.mBottomInset/(this.mTopInset+this.mBottomInset)*in_imgSize.height)/this.mBottomInset;topChunkRatio-=floatEpsilon;bottomChunkRatio-=floatEpsilon;maxHeightScale=Math.max(topChunkRatio,bottomChunkRatio);if(in_imgSize.height<(Math.ceil(this.mTopInset*maxHeightScale)+Math.ceil(this.mBottomInset*maxHeightScale))) -{maxHeightScale=Math.min(topChunkRatio,bottomChunkRatio);} -if((maxHeightScale20) -{IWAssert(function(){return true},"Please remove this assert and the surrouding block.");iWLog("Too many frame image tiles are getting generated. Performance may be affected.");} -if(tilingMode==kSFRFrameStretchEvenly) -{offset=(end-start)/maxTiles;if(vertical) -{imageRect.size.height=offset;} -else -{imageRect.size.width=offset;}} -else if(tilingMode==kSFRFrameClip) -{markup+='
';imageRect.origin.x=0;imageRect.origin.y=0;} -for(var i=0;i