' ) ; 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 != '' ) { var rate = Math.max( oImg.width / GetE( 'txtMaxWidth' ).value, oImg.height / GetE( 'txtMaxHeight' ).value ) ; eSelected.setAttribute( "width", Math.floor( oImg.width / rate ), 0 ) ; eSelected.setAttribute( "height", Math.floor( oImg.height / rate ), 0 ) ; } // No link selected, so try to create one. if ( !oLink ) oLink = oEditor.FCK.CreateLink( sUri ) ; sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL). oLink.href = sUri ; oLink.rel = 'lightbox' + ( (GetE( 'txtImageSet' ).value == '') ? '' : '[' + GetE( 'txtImageSet' ).value + ']'); oLink.title = GetE( 'txtTitle' ).value ; SetAttribute( oLink, '_fcksavedurl', sUri ) ; oLink.innerHTML = sInnerHtml ; // Set (or restore) the innerHTML FCK.Selection.SelectNode( oLink ) ; return true ; } // -->
|