问题描述:
         在添加图片或者音频视频的时候,如果需要一个资源title字段来表示该资源的标题内容,并需要控制这个必填项,如果该项输入为空就不能完成整个内容的添加。
首先,需要在图片或资源输入对话框里添加一个字段resourceTitle输入框,(我们以音频视频为例)在editor\dialog下的fck_flash.html添加以下内容:
 <TR>
<TR>
 <TD nowrap>
                                <TD nowrap>
 <span fckLang="DlgResourceTitle">resourcetitle</span><br>
                                    <span fckLang="DlgResourceTitle">resourcetitle</span><br>
 <input id="resourceTitle" type="text" size="33">
                                    <input id="resourceTitle" type="text" size="33">
 </TD>
                                </TD>
 <TD> </TD>
                                <TD> </TD>
 </TR>
                            </TR>
其中,DlgResouceTitle在\editor\lang下的zh-cn.js文件中定义,如:DlgResourceTitle : "资源标题"。
这样对话框中就可以多出一条“资源标题”的输入框,要对其进行判断和控制需要修改editor\dialog\fck_flash下的fck_flash.js文件,如:1)在
1 function LoadSelection()
function LoadSelection()
2 {
{
3 if ( ! oEmbed ) return ;
    if ( ! oEmbed ) return ;
4
5 GetE('txtUrl').value    = GetAttribute( oEmbed, 'src', '' ) ;
    GetE('txtUrl').value    = GetAttribute( oEmbed, 'src', '' ) ;
6 GetE('txtWidth').value  = GetAttribute( oEmbed, 'width', '' ) ;
    GetE('txtWidth').value  = GetAttribute( oEmbed, 'width', '' ) ;
7 GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ;
    GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ;
8 GetE('resourceTitle').value = GetAttribute( oEmbed, 'resourcetitle', '' ) ;
    GetE('resourceTitle').value = GetAttribute( oEmbed, 'resourcetitle', '' ) ; 
中添加8行那段代码;2)然后在function Ok()方法中,添加:
1 if ( GetE('resourceTitle').value.length == 0 )
if ( GetE('resourceTitle').value.length == 0 )
2 {
    {
3 dialog.SetSelectedTab( 'Info' ) ;
        dialog.SetSelectedTab( 'Info' ) ;
4 GetE('resourceTitle').focus() ;
        GetE('resourceTitle').focus() ;
5
6 alert( oEditor.FCKLang.DlgAlertFlashTitle ) ;
        alert( oEditor.FCKLang.DlgAlertFlashTitle ) ;
7
8 return false ;
        return false ;
9 }
    } 
这个方法中的DlgAlerFlashTitle同样是在\editor\lang下的zh-cn.js文件中定义,文字内容就是弹出的警告信息的内容。
 DlgAlertFlashTitle    : "请输入资源标题",
DlgAlertFlashTitle    : "请输入资源标题",
3)为了在修改参数时能显示“资源标题”的内容,需要在UpdateEmbed( e )方法中:
 1 if(FlashPlayer(GetE('txtUrl').value)!=null){
if(FlashPlayer(GetE('txtUrl').value)!=null){
 2
 3 SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
 4
 5 SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
 6
 7 }
}
 8
 9
10 SetAttribute( e, 'src', GetE('txtUrl').value ) ;
    SetAttribute( e, 'src', GetE('txtUrl').value ) ;
11 SetAttribute( e, "resourcetitle" , GetE('resourceTitle').value ) ;
    SetAttribute( e, "resourcetitle" , GetE('resourceTitle').value ) ;
12 SetAttribute( e, "width" , GetE('txtWidth').value ) ;
    SetAttribute( e, "width" , GetE('txtWidth').value ) ;
13 SetAttribute( e, "height", GetE('txtHeight').value ) ;
    SetAttribute( e, "height", GetE('txtHeight').value ) ;
14
15 // Advances Attributes
    // Advances Attributes 
添加11行代码。
图片输入对话框的方法大致一样,就不做多解释。
	
posted on 2008-09-24 14:56 
matthew 阅读(1628) 
评论(1)  编辑  收藏  所属分类: 
JavaEE