' ) ; var eSelected ; var sUri ; var oLink ; var oImg ; //#### Initialization Code window.onload = function() { // Translate the dialog box texts. oEditor.FCKLanguageManager.TranslatePage(document) ; eSelected = oEditor.FCKSelection.GetSelectedElement() ; sUri = eSelected.src ; if ( eSelected.parentNode.tagName == 'A' ) { oLink = eSelected.parentNode ; FCK.Selection.SelectNode( oLink ) ; } // Create 'IMG' element for get original size. oImg = document.createElement('IMG') ; oImg.src = sUri ; imageLoad() ; } function imageLoad() { if ( ! oImg.complete ) { setTimeout( imageLoad, 200 ) ; return ; } GetE( 'tdCurrentWidth' ).innerHTML = eSelected.width ? eSelected.width : '' ; GetE( 'tdCurrentHeight' ).innerHTML = eSelected.height ? eSelected.height : '' ; GetE( 'tdOriginalWidth' ).innerHTML = oImg.width ; GetE( 'tdOriginalHeight' ).innerHTML = oImg.height ; GetE( 'txtMaxWidth' ).value = 120 ; GetE( 'txtMaxHeight' ).value = 120 ; var sMaxAuto = (oLink) ? '' : (((eSelected.width == oImg.width) && (eSelected.height == oImg.height)) ? 'checked' : '') ; GetE( 'cmdMaxAuto' ).checked = sMaxAuto ; OnMaxAutoChanged() ; if ( oLink ) { GetE( 'txtTitle' ).value = oLink.title ; if ( oLink.rel.match( /^lightbox\[([^\]]*)\]$/ ) ) GetE( 'txtImageSet' ).value = oLink.rel.replace( /^lightbox\[([^\]]*)\]$/, '$1') ; else GetE( 'txtImageSet' ).value = '' ; } else { GetE( 'txtTitle' ).value = '' ; GetE( 'txtImageSet' ).value = '' ; } window.parent.SetAutoSize( true ) ; // Activate the "OK" button. window.parent.SetOkButton( true ) ; } function OnMaxAutoChanged() { GetE( 'txtMaxWidth' ).disabled = (GetE( 'cmdMaxAuto' ).checked == '') ; GetE( 'txtMaxHeight' ).disabled = (GetE( 'cmdMaxAuto' ).checked == '') ; if (GetE( 'cmdMaxAuto' ).checked == '') { GetE( 'tdAutoWidth' ).innerHTML = eSelected.width ; GetE( 'tdAutoHeight' ).innerHTML = eSelected.height ; } else OnSizeChanged() ; } function OnSizeChanged() { var rate = Math.max( oImg.width / GetE( 'txtMaxWidth' ).value, oImg.height / GetE( 'txtMaxHeight' ).value ) ; GetE( 'tdAutoWidth' ).innerHTML = Math.floor( oImg.width / rate ) ; GetE( 'tdAutoHeight' ).innerHTML = Math.floor( oImg.height / rate ) ; } //#### The OK button was hit. function Ok() { if ( GetE( 'cmdMaxAuto' ).checked != '' ) { if ( GetE( 'txtMaxWidth' ).value == '' ) { alert( FCKLang.LightboxMaxWidthError ) ; GetE( 'txtMaxWidth' ).focus() ; return false ; } if ( isNaN( GetE( 'txtMaxWidth' ).value ) ) { alert( FCKLang.LightboxMaxWidthError ) ; GetE( 'txtMaxWidth' ).focus() ; return false ; } if ( GetE( 'txtMaxHeight' ).value == '' ) { alert( FCKLang.LightboxMaxHeightError ) ; GetE( 'txtMaxHeight' ).focus() ; return false ; } if ( isNaN( GetE( 'txtMaxHeight' ).value ) ) { alert( FCKLang.LightboxMaxHeightError ) ; GetE( 'txtMaxHeight' ).focus() ; return false ; } } if ( GetE( 'txtImageSet' ).value.match( /[\[\]]/ ) ) { alert( FCKLang.LightboxImageSetError ) ; GetE( 'txtImageSet' ).focus() ; return false ; } oEditor.FCKUndo.SaveUndoStep() ; if ( GetE( 'cmdMaxAuto' ).checked != '' ) { if ( ( GetE( 'txtMaxHeight' ).value / oImg.height ) < ( GetE( 'txtMaxWidth' ).value / oImg.width ) ) { eSelected.removeAttribute( "width", 0 ) ; eSelected.setAttribute( "height", GetE( 'txtMaxHeight' ).value, 0 ) ; } else { eSelected.setAttribute( "width", GetE( 'txtMaxWidth' ).value, 0 ) ; eSelected.removeAttribute( "height", 0 ) ; } } // If no link is selected, create a new one (it may result in more than one link creation - #220). var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri ) ; // If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26) var aHasSelection = ( aLinks.length > 0 ) ; if ( !aHasSelection ) { sInnerHtml = sUri; var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ; var asLinkPath = oLinkPathRegEx.exec( sUri ) ; if (asLinkPath != null) sInnerHtml = asLinkPath[1]; // use matched path // Create a new (empty) anchor. aLinks = [ oEditor.FCK.CreateElement( 'a' ) ] ; } var sRel = 'lightbox' + ( (GetE( 'txtImageSet' ).value == '') ? '' : '[' + GetE( 'txtImageSet' ).value + ']') ; for ( var i = 0 ; i < aLinks.length ; i++ ) { oLink = aLinks[i] ; if ( aHasSelection ) sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL). oLink.href = sUri ; SetAttribute( oLink, '_fcksavedurl', sUri ) ; SetAttribute( oLink, 'title' , GetE('txtTitle').value ) ; SetAttribute( oLink, 'rel' , sRel ) ; oLink.innerHTML = sInnerHtml ; // Set (or restore) the innerHTML } // Select the (first) link. oEditor.FCKSelection.SelectNode( aLinks[0] ); return true ; } // -->
|