在添加圖片或者音頻視頻的時候,如果需要一個資源title字段來表示該資源的標題內容,并需要控制這個必填項,如果該項輸入為空就不能完成整個內容的添加。
首先,需要在圖片或資源輸入對話框里添加一個字段resourceTitle輸入框,(我們以音頻視頻為例)在editor\dialog下的fck_flash.html添加以下內容:







這樣對話框中就可以多出一條“資源標題”的輸入框,要對其進行判斷和控制需要修改editor\dialog\fck_flash下的fck_flash.js文件,如:1)在
1
function LoadSelection()
2
{
3
if ( ! oEmbed ) return ;
4
5
GetE('txtUrl').value = GetAttribute( oEmbed, 'src', '' ) ;
6
GetE('txtWidth').value = GetAttribute( oEmbed, 'width', '' ) ;
7
GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ;
8
GetE('resourceTitle').value = GetAttribute( oEmbed, 'resourcetitle', '' ) ;
中添加8行那段代碼;2)然后在function Ok()方法中,添加:
2

3

4

5

6

7

8

1
if ( GetE('resourceTitle').value.length == 0 )
2
{
3
dialog.SetSelectedTab( 'Info' ) ;
4
GetE('resourceTitle').focus() ;
5
6
alert( oEditor.FCKLang.DlgAlertFlashTitle ) ;
7
8
return false ;
9
}
這個方法中的DlgAlerFlashTitle同樣是在\editor\lang下的zh-cn.js文件中定義,文字內容就是彈出的警告信息的內容。
2

3

4

5

6

7

8

9


3)為了在修改參數時能顯示“資源標題”的內容,需要在UpdateEmbed( e )方法中:
1
if(FlashPlayer(GetE('txtUrl').value)!=null){
2
3
SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
4
5
SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
6
7
}
8
9
10
SetAttribute( e, 'src', GetE('txtUrl').value ) ;
11
SetAttribute( e, "resourcetitle" , GetE('resourceTitle').value ) ;
12
SetAttribute( e, "width" , GetE('txtWidth').value ) ;
13
SetAttribute( e, "height", GetE('txtHeight').value ) ;
14
15
// Advances Attributes

2

3

4

5

6

7

8

9

10

11

12

13

14

15

添加11行代碼。
圖片輸入對話框的方法大致一樣,就不做多解釋。