rails_kindeditor 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +115 -16
- data/app/controllers/kindeditor/assets_controller.rb +119 -42
- data/app/uploaders/kindeditor/asset_uploader.rb +68 -0
- data/app/uploaders/kindeditor/file_uploader.rb +3 -58
- data/app/uploaders/kindeditor/flash_uploader.rb +14 -0
- data/app/uploaders/kindeditor/image_uploader.rb +3 -58
- data/app/uploaders/kindeditor/media_uploader.rb +14 -0
- data/lib/generators/rails_kindeditor/install/install_generator.rb +1 -2
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-init.js +9 -8
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-min.js +158 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/en.js +208 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_CN.js +210 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_TW.js +210 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/clearhtml/clearhtml.js +28 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/code/code.js +57 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/code/prettify.css +13 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/code/prettify.js +28 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/emoticons.js +129 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{0.gif → images/0.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{1.gif → images/1.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{10.gif → images/10.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{100.gif → images/100.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{101.gif → images/101.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{102.gif → images/102.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{103.gif → images/103.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{104.gif → images/104.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{105.gif → images/105.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{106.gif → images/106.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{107.gif → images/107.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{108.gif → images/108.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{109.gif → images/109.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{11.gif → images/11.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{110.gif → images/110.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{111.gif → images/111.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{112.gif → images/112.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{113.gif → images/113.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{114.gif → images/114.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{115.gif → images/115.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{116.gif → images/116.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{117.gif → images/117.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{118.gif → images/118.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{119.gif → images/119.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{12.gif → images/12.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{120.gif → images/120.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{121.gif → images/121.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{122.gif → images/122.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{123.gif → images/123.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{124.gif → images/124.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{125.gif → images/125.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{126.gif → images/126.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{127.gif → images/127.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{128.gif → images/128.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{129.gif → images/129.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{13.gif → images/13.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{130.gif → images/130.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{131.gif → images/131.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{132.gif → images/132.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{133.gif → images/133.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{134.gif → images/134.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{14.gif → images/14.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{15.gif → images/15.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{16.gif → images/16.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{17.gif → images/17.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{18.gif → images/18.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{19.gif → images/19.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{2.gif → images/2.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{20.gif → images/20.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{21.gif → images/21.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{22.gif → images/22.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{23.gif → images/23.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{24.gif → images/24.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{25.gif → images/25.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{26.gif → images/26.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{27.gif → images/27.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{28.gif → images/28.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{29.gif → images/29.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{3.gif → images/3.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{30.gif → images/30.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{31.gif → images/31.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{32.gif → images/32.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{33.gif → images/33.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{34.gif → images/34.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{35.gif → images/35.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{36.gif → images/36.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{37.gif → images/37.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{38.gif → images/38.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{39.gif → images/39.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{4.gif → images/4.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{40.gif → images/40.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{41.gif → images/41.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{42.gif → images/42.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{43.gif → images/43.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{44.gif → images/44.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{45.gif → images/45.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{46.gif → images/46.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{47.gif → images/47.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{48.gif → images/48.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{49.gif → images/49.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{5.gif → images/5.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{50.gif → images/50.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{51.gif → images/51.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{52.gif → images/52.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{53.gif → images/53.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{54.gif → images/54.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{55.gif → images/55.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{56.gif → images/56.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{57.gif → images/57.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{58.gif → images/58.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{59.gif → images/59.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{6.gif → images/6.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{60.gif → images/60.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{61.gif → images/61.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{62.gif → images/62.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{63.gif → images/63.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{64.gif → images/64.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{65.gif → images/65.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{66.gif → images/66.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{67.gif → images/67.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{68.gif → images/68.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{69.gif → images/69.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{7.gif → images/7.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{70.gif → images/70.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{71.gif → images/71.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{72.gif → images/72.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{73.gif → images/73.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{74.gif → images/74.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{75.gif → images/75.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{76.gif → images/76.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{77.gif → images/77.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{78.gif → images/78.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{79.gif → images/79.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{8.gif → images/8.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{80.gif → images/80.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{81.gif → images/81.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{82.gif → images/82.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{83.gif → images/83.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{84.gif → images/84.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{85.gif → images/85.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{86.gif → images/86.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{87.gif → images/87.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{88.gif → images/88.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{89.gif → images/89.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{9.gif → images/9.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{90.gif → images/90.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{91.gif → images/91.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{92.gif → images/92.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{93.gif → images/93.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{94.gif → images/94.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{95.gif → images/95.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{96.gif → images/96.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{97.gif → images/97.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{98.gif → images/98.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{99.gif → images/99.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/emoticons/{qq.gif → images/static.gif} +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/filemanager/filemanager.js +189 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/{file_manager → filemanager}/images/file-16.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/{file_manager → filemanager}/images/file-64.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/{file_manager → filemanager}/images/folder-16.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/{file_manager → filemanager}/images/folder-64.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/{file_manager → filemanager}/images/go-up.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/flash/flash.js +128 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.js +226 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js +104 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/lineheight/lineheight.js +38 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/link/link.js +59 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/map/map.html +57 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/map/map.js +135 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/media/media.js +136 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/pagebreak/pagebreak.js +26 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/plainpaste/plainpaste.js +41 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/preview/preview.js +31 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/quickformat/quickformat.js +71 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/table/table.js +661 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/template/html/1.html +14 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/template/html/2.html +42 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/template/html/3.html +36 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/template/template.js +58 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/wordpaste/wordpaste.js +57 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/{skins → themes}/common/blank.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/{skins → themes}/common/flash.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/{skins → themes}/common/loading.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/{skins → themes}/common/media.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/{skins → themes}/common/rm.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/{skins → themes}/default/bg.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/{skins → themes/default}/default.css +427 -396
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/simple/simple.css +148 -0
- data/lib/generators/rails_kindeditor/migration/migration_generator.rb +16 -3
- data/{app/models → lib/generators/rails_kindeditor/migration/templates/models/active_record}/kindeditor/asset.rb +2 -5
- data/{app/models → lib/generators/rails_kindeditor/migration/templates/models/active_record}/kindeditor/file.rb +1 -2
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/flash.rb +3 -0
- data/{app/models → lib/generators/rails_kindeditor/migration/templates/models/active_record}/kindeditor/image.rb +1 -2
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/media.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb +20 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/file.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/flash.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/image.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/media.rb +3 -0
- data/lib/rails_kindeditor/helper.rb +14 -2
- data/lib/rails_kindeditor/version.rb +1 -1
- data/rails_kindeditor.gemspec +3 -3
- metadata +199 -182
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor.js +0 -4688
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/about.html +0 -52
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/accessory.html +0 -74
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/advtable/advtable.html +0 -235
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/advtable/cell.html +0 -201
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/file_manager/file_manager.css +0 -64
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/file_manager/file_manager.html +0 -31
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/file_manager/file_manager.js +0 -221
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/flash.html +0 -69
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.html +0 -305
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/link/link.html +0 -82
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/media.html +0 -73
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/plainpaste.html +0 -44
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/wordpaste.html +0 -50
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/skins/common/doc.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/skins/common/editor.css +0 -47
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/skins/common/mp3.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/skins/common/pdf.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/skins/common/rar.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/skins/common/xls.gif +0 -0
- data/lib/generators/rails_kindeditor/install/templates/kindeditor/skins/default/default.gif +0 -0
@@ -1,4688 +0,0 @@
|
|
1
|
-
/*******************************************************************************
|
2
|
-
* KindEditor - WYSIWYG HTML Editor for Internet
|
3
|
-
* Copyright (C) 2006-2011 Longhao Luo
|
4
|
-
*
|
5
|
-
* @author Roddy <luolonghao@gmail.com>
|
6
|
-
* @site http://www.kindsoft.net/
|
7
|
-
* @licence http://www.kindsoft.net/license.php
|
8
|
-
* @version 3.5.5 (2011-05-22)
|
9
|
-
*******************************************************************************/
|
10
|
-
|
11
|
-
(function (undefined) {
|
12
|
-
|
13
|
-
if (window.KindEditor !== undefined) return;
|
14
|
-
|
15
|
-
var KE = {};
|
16
|
-
|
17
|
-
KE.version = '3.5.5 (2011-05-22)';
|
18
|
-
|
19
|
-
KE.scriptPath = (function() {
|
20
|
-
var elements = document.getElementsByTagName('script');
|
21
|
-
for (var i = 0, len = elements.length; i < len; i++) {
|
22
|
-
var src = elements[i].src;
|
23
|
-
if (src && src.match(/kindeditor[\w\-\.]*\.js/)) {
|
24
|
-
return src.substring(0, src.lastIndexOf('/') + 1);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
return '';
|
28
|
-
})();
|
29
|
-
|
30
|
-
KE.browser = (function() {
|
31
|
-
var ua = navigator.userAgent.toLowerCase();
|
32
|
-
return {
|
33
|
-
VERSION: ua.match(/(msie|firefox|webkit|opera)[\/:\s](\d+)/) ? RegExp.$2 : '0',
|
34
|
-
IE: (ua.indexOf('msie') > -1 && ua.indexOf('opera') == -1),
|
35
|
-
GECKO: (ua.indexOf('gecko') > -1 && ua.indexOf('khtml') == -1),
|
36
|
-
WEBKIT: (ua.indexOf('applewebkit') > -1),
|
37
|
-
OPERA: (ua.indexOf('opera') > -1)
|
38
|
-
};
|
39
|
-
})();
|
40
|
-
|
41
|
-
KE.setting = {
|
42
|
-
wyswygMode : true,
|
43
|
-
loadStyleMode : true,
|
44
|
-
resizeMode : 2,
|
45
|
-
filterMode : false,
|
46
|
-
autoSetDataMode : false,
|
47
|
-
shadowMode : true,
|
48
|
-
useContextmenu : true,
|
49
|
-
urlType : '',
|
50
|
-
skinType : 'default',
|
51
|
-
syncType : 'form',
|
52
|
-
newlineTag : 'p',
|
53
|
-
dialogAlignType : 'page',
|
54
|
-
cssPath : '',
|
55
|
-
skinsPath : KE.scriptPath + 'skins/',
|
56
|
-
pluginsPath : KE.scriptPath + 'plugins/',
|
57
|
-
minWidth : 200,
|
58
|
-
minHeight : 100,
|
59
|
-
minChangeSize : 5,
|
60
|
-
toolbarLineHeight : 24,
|
61
|
-
statusbarHeight : 11,
|
62
|
-
items : [
|
63
|
-
'source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
|
64
|
-
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
|
65
|
-
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
66
|
-
'superscript', '|', 'selectall', '-',
|
67
|
-
'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
|
68
|
-
'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image', 'accessory',
|
69
|
-
'flash', 'media', 'advtable', 'hr', 'emoticons', 'link', 'unlink', '|', 'about'
|
70
|
-
],
|
71
|
-
colorTable : [
|
72
|
-
['#E53333', '#E56600', '#FF9900', '#64451D', '#DFC5A4', '#FFE500'],
|
73
|
-
['#009900', '#006600', '#99BB00', '#B8D100', '#60D978', '#00D5FF'],
|
74
|
-
['#337FE5', '#003399', '#4C33E5', '#9933E5', '#CC33E5', '#EE33EE'],
|
75
|
-
['#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000']
|
76
|
-
],
|
77
|
-
noEndTags : ['br', 'hr', 'img', 'area', 'col', 'embed', 'input', 'param'],
|
78
|
-
inlineTags : ['b', 'del', 'em', 'font', 'i', 'span', 'strike', 'strong', 'sub', 'sup', 'u'],
|
79
|
-
endlineTags : [
|
80
|
-
'br', 'hr', 'table', 'tbody', 'td', 'tr', 'th', 'div', 'p', 'ol', 'ul',
|
81
|
-
'li', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'script', 'style', 'marquee'
|
82
|
-
],
|
83
|
-
htmlTags : {
|
84
|
-
font : ['color', 'size', 'face', '.background-color'],
|
85
|
-
span : [
|
86
|
-
'.color', '.background-color', '.font-size', '.font-family', '.background',
|
87
|
-
'.font-weight', '.font-style', '.text-decoration', '.vertical-align'
|
88
|
-
],
|
89
|
-
div : [
|
90
|
-
'align', '.border', '.margin', '.padding', '.text-align', '.color',
|
91
|
-
'.background-color', '.font-size', '.font-family', '.font-weight', '.background',
|
92
|
-
'.font-style', '.text-decoration', '.vertical-align', '.margin-left'
|
93
|
-
],
|
94
|
-
table: [
|
95
|
-
'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
|
96
|
-
'.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
|
97
|
-
'.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.background',
|
98
|
-
'.width', '.height'
|
99
|
-
],
|
100
|
-
'td,th': [
|
101
|
-
'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
|
102
|
-
'.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
|
103
|
-
'.font-style', '.text-decoration', '.vertical-align', '.background'
|
104
|
-
],
|
105
|
-
a : ['href', 'target', 'name'],
|
106
|
-
embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess', '/'],
|
107
|
-
img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height', '/'],
|
108
|
-
hr : ['/'],
|
109
|
-
br : ['/'],
|
110
|
-
'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
|
111
|
-
'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background',
|
112
|
-
'.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
|
113
|
-
],
|
114
|
-
'tbody,tr,strong,b,sub,sup,em,i,u,strike' : []
|
115
|
-
},
|
116
|
-
mediaTypes : {
|
117
|
-
rm : 'audio/x-pn-realaudio-plugin',
|
118
|
-
flash : 'application/x-shockwave-flash',
|
119
|
-
media : 'video/x-ms-asf-plugin'
|
120
|
-
},
|
121
|
-
afterTab : function(id) {
|
122
|
-
KE.util.setSelection(id);
|
123
|
-
KE.util.insertHtml(id, ' ');
|
124
|
-
}
|
125
|
-
};
|
126
|
-
|
127
|
-
KE.g = {};
|
128
|
-
|
129
|
-
KE.plugin = {};
|
130
|
-
|
131
|
-
KE.$ = function(id, doc){
|
132
|
-
var doc = doc || document;
|
133
|
-
return doc.getElementById(id);
|
134
|
-
};
|
135
|
-
|
136
|
-
KE.$$ = function(name, doc){
|
137
|
-
var doc = doc || document;
|
138
|
-
return doc.createElement(name);
|
139
|
-
};
|
140
|
-
|
141
|
-
KE.event = {
|
142
|
-
add : function(el, type, fn, id) {
|
143
|
-
if (el.addEventListener){
|
144
|
-
el.addEventListener(type, fn, false);
|
145
|
-
} else if (el.attachEvent){
|
146
|
-
el.attachEvent('on' + type, fn);
|
147
|
-
}
|
148
|
-
if (id !== undefined) {
|
149
|
-
KE.g[id].eventStack.push({
|
150
|
-
el : el,
|
151
|
-
type : type,
|
152
|
-
fn : fn
|
153
|
-
});
|
154
|
-
}
|
155
|
-
},
|
156
|
-
remove : function(el, type, fn, id) {
|
157
|
-
if (el.removeEventListener){
|
158
|
-
el.removeEventListener(type, fn, false);
|
159
|
-
} else if (el.detachEvent){
|
160
|
-
el.detachEvent('on' + type, fn);
|
161
|
-
}
|
162
|
-
if (id !== undefined) {
|
163
|
-
var stack = KE.g[id].eventStack;
|
164
|
-
for (var i = 0, len = stack.length; i < len; i++) {
|
165
|
-
var item = stack[i];
|
166
|
-
if (item && el === item.el && type === item.type && fn === item.fn) {
|
167
|
-
delete stack[i];
|
168
|
-
}
|
169
|
-
}
|
170
|
-
}
|
171
|
-
},
|
172
|
-
stopPropagation : function(e) {
|
173
|
-
if (e.stopPropagation) e.stopPropagation();
|
174
|
-
if (e.cancelBubble !== undefined) e.cancelBubble = true;
|
175
|
-
},
|
176
|
-
preventDefault : function(e) {
|
177
|
-
if (e.preventDefault) e.preventDefault();
|
178
|
-
if (e.returnValue !== undefined) e.returnValue = false;
|
179
|
-
},
|
180
|
-
stop : function(e) {
|
181
|
-
this.stopPropagation(e);
|
182
|
-
this.preventDefault(e);
|
183
|
-
},
|
184
|
-
bind : function(el, type, fn, id) {
|
185
|
-
this.add(el, type, function(e) {
|
186
|
-
fn(e);
|
187
|
-
KE.event.stop(e);
|
188
|
-
return false;
|
189
|
-
}, id);
|
190
|
-
},
|
191
|
-
input : function(el, func, id) {
|
192
|
-
this.add(el, 'keyup', function(e) {
|
193
|
-
if (!e.ctrlKey && !e.altKey && (e.keyCode < 16 || e.keyCode > 18) && e.keyCode != 116) {
|
194
|
-
func(e);
|
195
|
-
KE.event.stop(e);
|
196
|
-
return false;
|
197
|
-
}
|
198
|
-
}, id);
|
199
|
-
function handler (e) {
|
200
|
-
window.setTimeout(function() {
|
201
|
-
func(e);
|
202
|
-
}, 1);
|
203
|
-
}
|
204
|
-
var newElement = (el.nodeName == '#document') ? el.body : el;
|
205
|
-
this.add(newElement, 'paste', handler, id);
|
206
|
-
this.add(newElement, 'cut', handler, id);
|
207
|
-
},
|
208
|
-
ctrl : function(el, key, func, id) {
|
209
|
-
key = key.toString().match(/^\d{2,}$/) ? key : key.toUpperCase().charCodeAt(0);
|
210
|
-
this.add(el, 'keydown', function(e) {
|
211
|
-
if (e.ctrlKey && e.keyCode == key && !e.shiftKey && !e.altKey) {
|
212
|
-
func(e);
|
213
|
-
KE.event.stop(e);
|
214
|
-
return false;
|
215
|
-
}
|
216
|
-
}, id);
|
217
|
-
},
|
218
|
-
ready : function(func, win, doc, id) {
|
219
|
-
var win = win || window;
|
220
|
-
var doc = doc || document;
|
221
|
-
var loaded = false;
|
222
|
-
var readyFunc = function() {
|
223
|
-
if (loaded) return;
|
224
|
-
loaded = true;
|
225
|
-
func();
|
226
|
-
};
|
227
|
-
if (doc.addEventListener) {
|
228
|
-
this.add(doc, "DOMContentLoaded", readyFunc, id);
|
229
|
-
} else if (doc.attachEvent){
|
230
|
-
this.add(doc, "readystatechange", function() {
|
231
|
-
if (doc.readyState == "complete") readyFunc();
|
232
|
-
}, id);
|
233
|
-
if ( doc.documentElement.doScroll && typeof win.frameElement === "undefined" ) {
|
234
|
-
var ieReadyFunc = function() {
|
235
|
-
if (loaded) return;
|
236
|
-
try {
|
237
|
-
doc.documentElement.doScroll("left");
|
238
|
-
} catch(e) {
|
239
|
-
window.setTimeout(ieReadyFunc, 0);
|
240
|
-
return;
|
241
|
-
}
|
242
|
-
readyFunc();
|
243
|
-
};
|
244
|
-
ieReadyFunc();
|
245
|
-
}
|
246
|
-
}
|
247
|
-
this.add(win, 'load', readyFunc, id);
|
248
|
-
}
|
249
|
-
};
|
250
|
-
|
251
|
-
KE.each = function(obj, func) {
|
252
|
-
for (var key in obj) {
|
253
|
-
if (obj.hasOwnProperty(key)) func(key, obj[key]);
|
254
|
-
}
|
255
|
-
};
|
256
|
-
|
257
|
-
KE.eachNode = function(node, func) {
|
258
|
-
var walkNodes = function(parent) {
|
259
|
-
if (KE.util.getNodeType(parent) != 1) return true;
|
260
|
-
var n = parent.firstChild;
|
261
|
-
while (n) {
|
262
|
-
var next = n.nextSibling;
|
263
|
-
if (!func(n)) return false;
|
264
|
-
if (!walkNodes(n)) return false;
|
265
|
-
n = next;
|
266
|
-
}
|
267
|
-
return true;
|
268
|
-
};
|
269
|
-
walkNodes(node);
|
270
|
-
};
|
271
|
-
|
272
|
-
KE.selection = function(doc) {
|
273
|
-
this.sel = null;
|
274
|
-
this.range = null;
|
275
|
-
this.keRange = null;
|
276
|
-
this.isControl = false;
|
277
|
-
var win = doc.parentWindow || doc.defaultView;
|
278
|
-
this.init = function() {
|
279
|
-
var sel = doc.selection ? doc.selection : win.getSelection();
|
280
|
-
var range;
|
281
|
-
try {
|
282
|
-
if (sel.rangeCount > 0) range = sel.getRangeAt(0);
|
283
|
-
else range = sel.createRange();
|
284
|
-
} catch(e) {}
|
285
|
-
if (!range) range = KE.util.createRange(doc);
|
286
|
-
this.sel = sel;
|
287
|
-
this.range = range;
|
288
|
-
var startNode, startPos, endNode, endPos;
|
289
|
-
if (KE.browser.IE) {
|
290
|
-
if (range.item) {
|
291
|
-
this.isControl = true;
|
292
|
-
var el = range.item(0);
|
293
|
-
startNode = endNode = el;
|
294
|
-
startPos = endPos = 0;
|
295
|
-
} else {
|
296
|
-
this.isControl = false;
|
297
|
-
var getStartEnd = function(isStart) {
|
298
|
-
var pointRange = range.duplicate();
|
299
|
-
pointRange.collapse(isStart);
|
300
|
-
var parentNode = pointRange.parentElement();
|
301
|
-
var nodes = parentNode.childNodes;
|
302
|
-
if (nodes.length == 0) return {node: parentNode, pos: 0};
|
303
|
-
var startNode;
|
304
|
-
var endElement;
|
305
|
-
var startPos = 0;
|
306
|
-
var isEnd = false;
|
307
|
-
var testRange = range.duplicate();
|
308
|
-
KE.util.moveToElementText(testRange, parentNode);
|
309
|
-
for (var i = 0, len = nodes.length; i < len; i++) {
|
310
|
-
var node = nodes[i];
|
311
|
-
var cmp = testRange.compareEndPoints('StartToStart', pointRange);
|
312
|
-
if (cmp > 0) {
|
313
|
-
isEnd = true;
|
314
|
-
} else if (cmp == 0) {
|
315
|
-
if (node.nodeType == 1) {
|
316
|
-
var keRange = new KE.range(doc);
|
317
|
-
keRange.selectTextNode(node);
|
318
|
-
return {node: keRange.startNode, pos: 0};
|
319
|
-
} else {
|
320
|
-
return {node: node, pos: 0};
|
321
|
-
}
|
322
|
-
}
|
323
|
-
if (node.nodeType == 1) {
|
324
|
-
var nodeRange = range.duplicate();
|
325
|
-
KE.util.moveToElementText(nodeRange, node);
|
326
|
-
testRange.setEndPoint('StartToEnd', nodeRange);
|
327
|
-
if (isEnd) startPos += nodeRange.text.replace(/\r\n|\n|\r/g, '').length;
|
328
|
-
else startPos = 0;
|
329
|
-
} else if (node.nodeType == 3) {
|
330
|
-
//fix bug: typeof node.nodeValue can return "unknown" in IE.
|
331
|
-
if (typeof node.nodeValue === 'string') {
|
332
|
-
testRange.moveStart('character', node.nodeValue.length);
|
333
|
-
startPos += node.nodeValue.length;
|
334
|
-
}
|
335
|
-
}
|
336
|
-
if (!isEnd) startNode = node;
|
337
|
-
}
|
338
|
-
if (!isEnd && startNode.nodeType == 1) {
|
339
|
-
var startNode = parentNode.lastChild;
|
340
|
-
return {node: startNode, pos: startNode.nodeType == 1 ? 1 : startNode.nodeValue.length};
|
341
|
-
}
|
342
|
-
testRange = range.duplicate();
|
343
|
-
KE.util.moveToElementText(testRange, parentNode);
|
344
|
-
testRange.setEndPoint('StartToEnd', pointRange);
|
345
|
-
startPos -= testRange.text.replace(/\r\n|\n|\r/g, '').length;
|
346
|
-
return {node: startNode, pos: startPos};
|
347
|
-
};
|
348
|
-
var start = getStartEnd(true);
|
349
|
-
var end = getStartEnd(false);
|
350
|
-
startNode = start.node;
|
351
|
-
startPos = start.pos;
|
352
|
-
endNode = end.node;
|
353
|
-
endPos = end.pos;
|
354
|
-
}
|
355
|
-
} else {
|
356
|
-
startNode = range.startContainer;
|
357
|
-
startPos = range.startOffset;
|
358
|
-
endNode = range.endContainer;
|
359
|
-
endPos = range.endOffset;
|
360
|
-
if (startNode.nodeType == 1 && typeof startNode.childNodes[startPos] != 'undefined') {
|
361
|
-
startNode = startNode.childNodes[startPos];
|
362
|
-
startPos = 0;
|
363
|
-
}
|
364
|
-
if (endNode.nodeType == 1) {
|
365
|
-
endPos = endPos == 0 ? 1 : endPos;
|
366
|
-
if (typeof endNode.childNodes[endPos - 1] != 'undefined') {
|
367
|
-
endNode = endNode.childNodes[endPos - 1];
|
368
|
-
endPos = (endNode.nodeType == 1) ? 0 : endNode.nodeValue.length;
|
369
|
-
}
|
370
|
-
}
|
371
|
-
this.isControl = (startNode.nodeType == 1 && startNode === endNode && range.startOffset + 1 == range.endOffset);
|
372
|
-
if (startNode.nodeType == 1 && endNode.nodeType == 3 && endPos == 0 && endNode.previousSibling) {
|
373
|
-
var node = endNode.previousSibling;
|
374
|
-
while (node) {
|
375
|
-
if (node === startNode) {
|
376
|
-
endNode = startNode;
|
377
|
-
break;
|
378
|
-
}
|
379
|
-
if (node.childNodes.length != 1) break;
|
380
|
-
node = node.childNodes[0];
|
381
|
-
}
|
382
|
-
}
|
383
|
-
if (range.collapsed) {
|
384
|
-
var keRange = new KE.range(doc);
|
385
|
-
keRange.setTextStart(startNode, startPos);
|
386
|
-
endNode = keRange.startNode;
|
387
|
-
endPos = keRange.startPos;
|
388
|
-
}
|
389
|
-
}
|
390
|
-
var keRange = new KE.range(doc);
|
391
|
-
keRange.setTextStart(startNode, startPos);
|
392
|
-
keRange.setTextEnd(endNode, endPos);
|
393
|
-
this.keRange = keRange;
|
394
|
-
};
|
395
|
-
this.init();
|
396
|
-
this.addRange = function(keRange) {
|
397
|
-
if (KE.browser.GECKO && KE.browser.VERSION < 3) return;
|
398
|
-
this.keRange = keRange;
|
399
|
-
if (KE.browser.IE) {
|
400
|
-
var getEndRange = function(isStart) {
|
401
|
-
var range = KE.util.createRange(doc);
|
402
|
-
var node = isStart ? keRange.startNode : keRange.endNode;
|
403
|
-
if (node.nodeType == 1) {
|
404
|
-
KE.util.moveToElementText(range, node);
|
405
|
-
range.collapse(isStart);
|
406
|
-
} else if (node.nodeType == 3) {
|
407
|
-
range = KE.util.getNodeStartRange(doc, node);
|
408
|
-
var pos = isStart ? keRange.startPos : keRange.endPos;
|
409
|
-
range.moveStart('character', pos);
|
410
|
-
}
|
411
|
-
return range;
|
412
|
-
}
|
413
|
-
if (!this.range.item) {
|
414
|
-
var node = keRange.startNode;
|
415
|
-
if (node == keRange.endNode && KE.util.getNodeType(node) == 1 && KE.util.getNodeTextLength(node) == 0) {
|
416
|
-
var temp = doc.createTextNode(" ");
|
417
|
-
node.appendChild(temp);
|
418
|
-
KE.util.moveToElementText(this.range, node);
|
419
|
-
this.range.collapse(false);
|
420
|
-
this.range.select();
|
421
|
-
node.removeChild(temp);
|
422
|
-
} else {
|
423
|
-
if (node.nodeType == 3 && keRange.collapsed()) {
|
424
|
-
this.range = getEndRange(true);
|
425
|
-
this.range.collapse(true);
|
426
|
-
} else {
|
427
|
-
this.range.setEndPoint('StartToStart', getEndRange(true));
|
428
|
-
this.range.setEndPoint('EndToStart', getEndRange(false));
|
429
|
-
}
|
430
|
-
this.range.select();
|
431
|
-
}
|
432
|
-
}
|
433
|
-
} else {
|
434
|
-
var getNodePos = function(node) {
|
435
|
-
var pos = 0;
|
436
|
-
while (node) {
|
437
|
-
node = node.previousSibling;
|
438
|
-
pos++;
|
439
|
-
}
|
440
|
-
return --pos;
|
441
|
-
};
|
442
|
-
var range = new KE.range(doc);
|
443
|
-
range.setTextStart(keRange.startNode, keRange.startPos);
|
444
|
-
range.setTextEnd(keRange.endNode, keRange.endPos);
|
445
|
-
var startNode = range.startNode;
|
446
|
-
var endNode = range.endNode;
|
447
|
-
if (KE.util.getNodeType(startNode) == 88) {
|
448
|
-
this.range.setStart(startNode.parentNode, getNodePos(range.startNode));
|
449
|
-
} else {
|
450
|
-
this.range.setStart(startNode, range.startPos);
|
451
|
-
}
|
452
|
-
if (KE.util.getNodeType(endNode) == 88) {
|
453
|
-
this.range.setEnd(endNode.parentNode, getNodePos(range.endNode) + 1);
|
454
|
-
} else {
|
455
|
-
this.range.setEnd(endNode, range.endPos);
|
456
|
-
}
|
457
|
-
this.sel.removeAllRanges();
|
458
|
-
this.sel.addRange(this.range);
|
459
|
-
}
|
460
|
-
};
|
461
|
-
this.focus = function() {
|
462
|
-
if (KE.browser.IE && this.range != null) this.range.select();
|
463
|
-
}
|
464
|
-
};
|
465
|
-
|
466
|
-
KE.range = function(doc) {
|
467
|
-
this.startNode = null;
|
468
|
-
this.startPos = null;
|
469
|
-
this.endNode = null;
|
470
|
-
this.endPos = null;
|
471
|
-
this.getParentElement = function() {
|
472
|
-
var scanParent = function(node, func) {
|
473
|
-
while (node && (!node.tagName || node.tagName.toLowerCase() != 'body')) {
|
474
|
-
node = node.parentNode;
|
475
|
-
if (func(node)) return;
|
476
|
-
}
|
477
|
-
}
|
478
|
-
var nodeList = [];
|
479
|
-
scanParent(this.startNode, function(node) {
|
480
|
-
nodeList.push(node);
|
481
|
-
});
|
482
|
-
var parentNode;
|
483
|
-
scanParent(this.endNode, function(node) {
|
484
|
-
if (KE.util.inArray(node, nodeList)) {
|
485
|
-
parentNode = node;
|
486
|
-
return true;
|
487
|
-
}
|
488
|
-
});
|
489
|
-
return parentNode ? parentNode : doc.body;
|
490
|
-
};
|
491
|
-
this.getNodeList = function() {
|
492
|
-
var self = this;
|
493
|
-
var parentNode = this.getParentElement();
|
494
|
-
var nodeList = [];
|
495
|
-
var isStarted = false;
|
496
|
-
if (parentNode == self.startNode) isStarted = true;
|
497
|
-
if (isStarted) nodeList.push(parentNode);
|
498
|
-
KE.eachNode(parentNode, function(node) {
|
499
|
-
if (node == self.startNode) isStarted = true;
|
500
|
-
var range = new KE.range(doc);
|
501
|
-
range.selectTextNode(node);
|
502
|
-
var cmp = range.comparePoints('START_TO_END', self);
|
503
|
-
if (cmp > 0) {
|
504
|
-
return false;
|
505
|
-
} else if (cmp == 0) {
|
506
|
-
if (range.startNode !== range.endNode || range.startPos !== range.endPos) return false;
|
507
|
-
}
|
508
|
-
if (isStarted) nodeList.push(node);
|
509
|
-
return true;
|
510
|
-
});
|
511
|
-
return nodeList;
|
512
|
-
};
|
513
|
-
this.comparePoints = function(how, range) {
|
514
|
-
var compareNodes = function(nodeA, posA, nodeB, posB) {
|
515
|
-
var cmp;
|
516
|
-
if (KE.browser.IE) {
|
517
|
-
var getStartRange = function(node, pos, isStart) {
|
518
|
-
var range = KE.util.createRange(doc);
|
519
|
-
var type = KE.util.getNodeType(node);
|
520
|
-
if (type == 1) {
|
521
|
-
KE.util.moveToElementText(range, node);
|
522
|
-
range.collapse(isStart);
|
523
|
-
} else if (type == 3) {
|
524
|
-
range = KE.util.getNodeStartRange(doc, node);
|
525
|
-
range.moveStart('character', pos);
|
526
|
-
range.collapse(true);
|
527
|
-
}
|
528
|
-
return range;
|
529
|
-
}
|
530
|
-
var rangeA, rangeB;
|
531
|
-
if (how == 'START_TO_START' || how == 'START_TO_END') rangeA = getStartRange(nodeA, posA, true);
|
532
|
-
else rangeA = getStartRange(nodeA, posA, false);
|
533
|
-
if (how == 'START_TO_START' || how == 'END_TO_START') rangeB = getStartRange(nodeB, posB, true);
|
534
|
-
else rangeB = getStartRange(nodeB, posB, false);
|
535
|
-
return rangeA.compareEndPoints('StartToStart', rangeB);
|
536
|
-
} else {
|
537
|
-
var rangeA = KE.util.createRange(doc);
|
538
|
-
rangeA.selectNode(nodeA);
|
539
|
-
if (how == 'START_TO_START' || how == 'START_TO_END') rangeA.collapse(true);
|
540
|
-
else rangeA.collapse(false);
|
541
|
-
var rangeB = KE.util.createRange(doc);
|
542
|
-
rangeB.selectNode(nodeB);
|
543
|
-
if (how == 'START_TO_START' || how == 'END_TO_START') rangeB.collapse(true);
|
544
|
-
else rangeB.collapse(false);
|
545
|
-
if (rangeA.compareBoundaryPoints(Range.START_TO_START, rangeB) > 0) {
|
546
|
-
cmp = 1;
|
547
|
-
} else if (rangeA.compareBoundaryPoints(Range.START_TO_START, rangeB) == 0) {
|
548
|
-
if (posA > posB) cmp = 1;
|
549
|
-
else if (posA == posB) cmp = 0;
|
550
|
-
else cmp = -1;
|
551
|
-
} else {
|
552
|
-
cmp = -1;
|
553
|
-
}
|
554
|
-
}
|
555
|
-
return cmp;
|
556
|
-
}
|
557
|
-
if (how == 'START_TO_START') return compareNodes(this.startNode, this.startPos, range.startNode, range.startPos);
|
558
|
-
if (how == 'START_TO_END') return compareNodes(this.startNode, this.startPos, range.endNode, range.endPos);
|
559
|
-
if (how == 'END_TO_START') return compareNodes(this.endNode, this.endPos, range.startNode, range.startPos);
|
560
|
-
if (how == 'END_TO_END') return compareNodes(this.endNode, this.endPos, range.endNode, range.endPos);
|
561
|
-
};
|
562
|
-
this.collapsed = function() {
|
563
|
-
return (this.startNode === this.endNode && this.startPos === this.endPos);
|
564
|
-
};
|
565
|
-
this.collapse = function(toStart) {
|
566
|
-
if (toStart) {
|
567
|
-
this.setEnd(this.startNode, this.startPos);
|
568
|
-
} else {
|
569
|
-
this.setStart(this.endNode, this.endPos);
|
570
|
-
}
|
571
|
-
};
|
572
|
-
this.setTextStart = function(node, pos) {
|
573
|
-
var textNode = node;
|
574
|
-
KE.eachNode(node, function(n) {
|
575
|
-
if (KE.util.getNodeType(n) == 3 && n.nodeValue.length > 0 || KE.util.getNodeType(n) == 88) {
|
576
|
-
textNode = n;
|
577
|
-
pos = 0;
|
578
|
-
return false;
|
579
|
-
}
|
580
|
-
return true;
|
581
|
-
});
|
582
|
-
this.setStart(textNode, pos);
|
583
|
-
};
|
584
|
-
this.setStart = function(node, pos) {
|
585
|
-
this.startNode = node;
|
586
|
-
this.startPos = pos;
|
587
|
-
if (this.endNode === null) {
|
588
|
-
this.endNode = node;
|
589
|
-
this.endPos = pos;
|
590
|
-
}
|
591
|
-
};
|
592
|
-
this.setTextEnd = function(node, pos) {
|
593
|
-
var textNode = node;
|
594
|
-
KE.eachNode(node, function(n) {
|
595
|
-
if (KE.util.getNodeType(n) == 3 && n.nodeValue.length > 0 || KE.util.getNodeType(n) == 88) {
|
596
|
-
textNode = n;
|
597
|
-
pos = KE.util.getNodeType(n) == 3 ? n.nodeValue.length : 0;
|
598
|
-
}
|
599
|
-
return true;
|
600
|
-
});
|
601
|
-
this.setEnd(textNode, pos);
|
602
|
-
};
|
603
|
-
this.setEnd = function(node, pos) {
|
604
|
-
this.endNode = node;
|
605
|
-
this.endPos = pos;
|
606
|
-
if (this.startNode === null) {
|
607
|
-
this.startNode = node;
|
608
|
-
this.startPos = pos;
|
609
|
-
}
|
610
|
-
};
|
611
|
-
this.selectNode = function(node) {
|
612
|
-
this.setStart(node, 0);
|
613
|
-
this.setEnd(node, node.nodeType == 1 ? 0 : node.nodeValue.length);
|
614
|
-
};
|
615
|
-
this.selectTextNode = function(node) {
|
616
|
-
this.setTextStart(node, 0);
|
617
|
-
this.setTextEnd(node, node.nodeType == 1 ? 0 : node.nodeValue.length);
|
618
|
-
};
|
619
|
-
this.extractContents = function(isDelete) {
|
620
|
-
isDelete = (isDelete === undefined) ? true : isDelete;
|
621
|
-
var thisRange = this;
|
622
|
-
var startNode = this.startNode;
|
623
|
-
var startPos = this.startPos;
|
624
|
-
var endNode = this.endNode;
|
625
|
-
var endPos = this.endPos;
|
626
|
-
var removedNodes = [];
|
627
|
-
function extractTextNode(node, startPos, endPos) {
|
628
|
-
var length = node.nodeValue.length;
|
629
|
-
var cloneNode = node.cloneNode(true);
|
630
|
-
var centerNode = cloneNode.splitText(startPos);
|
631
|
-
centerNode.splitText(endPos - startPos);
|
632
|
-
if (isDelete) {
|
633
|
-
var center = node;
|
634
|
-
if (startPos > 0) center = node.splitText(startPos);
|
635
|
-
if (endPos < length) center.splitText(endPos - startPos);
|
636
|
-
removedNodes.push(center);
|
637
|
-
}
|
638
|
-
return centerNode;
|
639
|
-
};
|
640
|
-
var noEndTagHash = KE.util.arrayToHash(KE.setting.noEndTags);
|
641
|
-
var isStarted = false;
|
642
|
-
var isEnd = false;
|
643
|
-
function extractNodes(parent, frag) {
|
644
|
-
if (KE.util.getNodeType(parent) != 1) return true;
|
645
|
-
var node = parent.firstChild;
|
646
|
-
while (node) {
|
647
|
-
if (node == startNode) isStarted = true;
|
648
|
-
if (node == endNode) isEnd = true;
|
649
|
-
var nextNode = node.nextSibling;
|
650
|
-
var type = node.nodeType;
|
651
|
-
if (type == 1) {
|
652
|
-
var range = new KE.range(doc);
|
653
|
-
range.selectNode(node);
|
654
|
-
var cmp = range.comparePoints('END_TO_END', thisRange);
|
655
|
-
if (isStarted && (cmp < 0 || (cmp == 0 && noEndTagHash[node.nodeName.toLowerCase()] !== undefined))) {
|
656
|
-
var cloneNode = node.cloneNode(true);
|
657
|
-
frag.appendChild(cloneNode);
|
658
|
-
if (isDelete) {
|
659
|
-
node.parentNode.removeChild(node);
|
660
|
-
}
|
661
|
-
} else {
|
662
|
-
var childFlag = node.cloneNode(false);
|
663
|
-
if (noEndTagHash[childFlag.nodeName.toLowerCase()] === undefined) {
|
664
|
-
frag.appendChild(childFlag);
|
665
|
-
if (!extractNodes(node, childFlag)) return false;
|
666
|
-
}
|
667
|
-
}
|
668
|
-
} else if (type == 3) {
|
669
|
-
if (isStarted) {
|
670
|
-
var textNode;
|
671
|
-
if (node == startNode && node == endNode) {
|
672
|
-
textNode = extractTextNode(node, startPos, endPos);
|
673
|
-
frag.appendChild(textNode);
|
674
|
-
return false;
|
675
|
-
} else if (node == startNode) {
|
676
|
-
textNode = extractTextNode(node, startPos, node.nodeValue.length);
|
677
|
-
frag.appendChild(textNode);
|
678
|
-
} else if (node == endNode) {
|
679
|
-
textNode = extractTextNode(node, 0, endPos);
|
680
|
-
frag.appendChild(textNode);
|
681
|
-
return false;
|
682
|
-
} else {
|
683
|
-
textNode = extractTextNode(node, 0, node.nodeValue.length);
|
684
|
-
frag.appendChild(textNode);
|
685
|
-
}
|
686
|
-
}
|
687
|
-
}
|
688
|
-
node = nextNode;
|
689
|
-
if (isEnd) return false;
|
690
|
-
}
|
691
|
-
if (frag.innerHTML.replace(/<.*?>/g, '') === '' && frag.parentNode) {
|
692
|
-
frag.parentNode.removeChild(frag);
|
693
|
-
}
|
694
|
-
return true;
|
695
|
-
}
|
696
|
-
var parentNode = this.getParentElement();
|
697
|
-
var docFrag = parentNode.cloneNode(false);
|
698
|
-
extractNodes(parentNode, docFrag);
|
699
|
-
KE.each(removedNodes, function(key, val) {
|
700
|
-
if (val.nodeType != 3 || val.nodeValue.length > 0) {
|
701
|
-
val.parentNode.removeChild(val);
|
702
|
-
}
|
703
|
-
});
|
704
|
-
return docFrag;
|
705
|
-
};
|
706
|
-
this.cloneContents = function() {
|
707
|
-
return this.extractContents(false);
|
708
|
-
};
|
709
|
-
this.getText = function() {
|
710
|
-
var html = this.cloneContents().innerHTML;
|
711
|
-
return html.replace(/<.*?>/g, "");
|
712
|
-
};
|
713
|
-
};
|
714
|
-
|
715
|
-
KE.cmd = function(id) {
|
716
|
-
this.doc = KE.g[id].iframeDoc;
|
717
|
-
this.keSel = KE.g[id].keSel;
|
718
|
-
this.keRange = KE.g[id].keRange;
|
719
|
-
this.mergeAttributes = function(el, attr) {
|
720
|
-
for (var i = 0, len = attr.length; i < len; i++) {
|
721
|
-
KE.each(attr[i], function(key, value) {
|
722
|
-
if (key.charAt(0) == '.') {
|
723
|
-
var jsKey = KE.util.getJsKey(key.substr(1));
|
724
|
-
el.style[jsKey] = value;
|
725
|
-
} else {
|
726
|
-
if (KE.browser.IE && KE.browser.VERSION < 8 && key == 'class') key = 'className';
|
727
|
-
el.setAttribute(key, value);
|
728
|
-
}
|
729
|
-
});
|
730
|
-
}
|
731
|
-
return el;
|
732
|
-
};
|
733
|
-
this.wrapTextNode = function(node, startPos, endPos, element, attributes) {
|
734
|
-
var length = node.nodeValue.length;
|
735
|
-
var isFull = (startPos == 0 && endPos == length);
|
736
|
-
var range = new KE.range(this.doc);
|
737
|
-
range.selectTextNode(node.parentNode);
|
738
|
-
if (isFull &&
|
739
|
-
node.parentNode.tagName == element.tagName &&
|
740
|
-
range.comparePoints('END_TO_END', this.keRange) <= 0 &&
|
741
|
-
range.comparePoints('START_TO_START', this.keRange) >= 0) {
|
742
|
-
this.mergeAttributes(node.parentNode, attributes);
|
743
|
-
return node;
|
744
|
-
} else {
|
745
|
-
var el = element.cloneNode(true);
|
746
|
-
if (isFull) {
|
747
|
-
var cloneNode = node.cloneNode(true);
|
748
|
-
el.appendChild(cloneNode);
|
749
|
-
node.parentNode.replaceChild(el, node);
|
750
|
-
return cloneNode;
|
751
|
-
} else {
|
752
|
-
var centerNode = node;
|
753
|
-
if (startPos < endPos) {
|
754
|
-
if (startPos > 0) centerNode = node.splitText(startPos);
|
755
|
-
if (endPos < length) centerNode.splitText(endPos - startPos);
|
756
|
-
var cloneNode = centerNode.cloneNode(true);
|
757
|
-
el.appendChild(cloneNode);
|
758
|
-
centerNode.parentNode.replaceChild(el, centerNode);
|
759
|
-
return cloneNode;
|
760
|
-
} else {
|
761
|
-
if (startPos < length) {
|
762
|
-
centerNode = node.splitText(startPos);
|
763
|
-
centerNode.parentNode.insertBefore(el, centerNode);
|
764
|
-
} else {
|
765
|
-
if (centerNode.nextSibling) {
|
766
|
-
centerNode.parentNode.insertBefore(el, centerNode.nextSibling);
|
767
|
-
} else {
|
768
|
-
centerNode.parentNode.appendChild(el);
|
769
|
-
}
|
770
|
-
}
|
771
|
-
return el;
|
772
|
-
}
|
773
|
-
}
|
774
|
-
}
|
775
|
-
};
|
776
|
-
this.wrap = function(tagName, attributes) {
|
777
|
-
attributes = attributes || [];
|
778
|
-
var self = this;
|
779
|
-
this.keSel.focus();
|
780
|
-
var element = KE.$$(tagName, this.doc);
|
781
|
-
this.mergeAttributes(element, attributes);
|
782
|
-
var keRange = this.keRange;
|
783
|
-
var startNode = keRange.startNode;
|
784
|
-
var startPos = keRange.startPos;
|
785
|
-
var endNode = keRange.endNode;
|
786
|
-
var endPos = keRange.endPos;
|
787
|
-
var parentNode = keRange.getParentElement();
|
788
|
-
if (KE.util.inMarquee(parentNode)) return;
|
789
|
-
var isStarted = false;
|
790
|
-
KE.eachNode(parentNode, function(node) {
|
791
|
-
if (node == startNode) isStarted = true;
|
792
|
-
if (node.nodeType == 1) {
|
793
|
-
if (node == startNode && node == endNode) {
|
794
|
-
if (KE.util.inArray(node.tagName.toLowerCase(), KE.g[id].noEndTags)) {
|
795
|
-
if (startPos > 0) node.parentNode.appendChild(element);
|
796
|
-
else node.parentNode.insertBefore(element, node);
|
797
|
-
} else {
|
798
|
-
node.appendChild(element);
|
799
|
-
}
|
800
|
-
keRange.selectNode(element);
|
801
|
-
return false;
|
802
|
-
} else if (node == startNode) {
|
803
|
-
keRange.setStart(node, 0);
|
804
|
-
} else if (node == endNode) {
|
805
|
-
keRange.setEnd(node, 0);
|
806
|
-
return false;
|
807
|
-
}
|
808
|
-
} else if (node.nodeType == 3) {
|
809
|
-
if (isStarted) {
|
810
|
-
if (node == startNode && node == endNode) {
|
811
|
-
var rangeNode = self.wrapTextNode(node, startPos, endPos, element, attributes);
|
812
|
-
keRange.selectNode(rangeNode);
|
813
|
-
return false;
|
814
|
-
} else if (node == startNode) {
|
815
|
-
var rangeNode = self.wrapTextNode(node, startPos, node.nodeValue.length, element, attributes);
|
816
|
-
keRange.setStart(rangeNode, 0);
|
817
|
-
} else if (node == endNode) {
|
818
|
-
var rangeNode = self.wrapTextNode(node, 0, endPos, element, attributes);
|
819
|
-
keRange.setEnd(rangeNode, rangeNode.nodeType == 1 ? 0 : rangeNode.nodeValue.length);
|
820
|
-
return false;
|
821
|
-
} else {
|
822
|
-
self.wrapTextNode(node, 0, node.nodeValue.length, element, attributes);
|
823
|
-
}
|
824
|
-
}
|
825
|
-
}
|
826
|
-
return true;
|
827
|
-
});
|
828
|
-
this.keSel.addRange(keRange);
|
829
|
-
};
|
830
|
-
this.getTopParent = function(tagNames, node) {
|
831
|
-
var parent = null;
|
832
|
-
while (node) {
|
833
|
-
node = node.parentNode;
|
834
|
-
if (KE.util.inArray(node.tagName.toLowerCase(), tagNames)) {
|
835
|
-
parent = node;
|
836
|
-
} else {
|
837
|
-
break;
|
838
|
-
}
|
839
|
-
}
|
840
|
-
return parent;
|
841
|
-
};
|
842
|
-
this.splitNodeParent = function(parent, node, pos) {
|
843
|
-
var leftRange = new KE.range(this.doc);
|
844
|
-
leftRange.selectNode(parent.firstChild);
|
845
|
-
leftRange.setEnd(node, pos);
|
846
|
-
var leftFrag = leftRange.extractContents();
|
847
|
-
parent.parentNode.insertBefore(leftFrag, parent);
|
848
|
-
return {left : leftFrag, right : parent};
|
849
|
-
};
|
850
|
-
this.remove = function(tags) {
|
851
|
-
var self = this;
|
852
|
-
var keRange = this.keRange;
|
853
|
-
var startNode = keRange.startNode;
|
854
|
-
var startPos = keRange.startPos;
|
855
|
-
var endNode = keRange.endNode;
|
856
|
-
var endPos = keRange.endPos;
|
857
|
-
this.keSel.focus();
|
858
|
-
if (KE.util.inMarquee(keRange.getParentElement())) return;
|
859
|
-
var isCollapsed = (keRange.getText().replace(/\s+/g, '') === '');
|
860
|
-
if (isCollapsed && !KE.browser.IE) return;
|
861
|
-
var tagNames = [];
|
862
|
-
KE.each(tags, function(key, val) {
|
863
|
-
if (key != '*') tagNames.push(key);
|
864
|
-
});
|
865
|
-
var startParent = this.getTopParent(tagNames, startNode);
|
866
|
-
var endParent = this.getTopParent(tagNames, endNode);
|
867
|
-
if (startParent) {
|
868
|
-
var startFrags = this.splitNodeParent(startParent, startNode, startPos);
|
869
|
-
keRange.setStart(startFrags.right, 0);
|
870
|
-
if (startNode == endNode && KE.util.getNodeTextLength(startFrags.right) > 0) {
|
871
|
-
keRange.selectNode(startFrags.right);
|
872
|
-
var range = new KE.range(this.doc);
|
873
|
-
range.selectTextNode(startFrags.left);
|
874
|
-
if (startPos > 0) endPos -= range.endNode.nodeValue.length;
|
875
|
-
range.selectTextNode(startFrags.right);
|
876
|
-
endNode = range.startNode;
|
877
|
-
}
|
878
|
-
}
|
879
|
-
if (isCollapsed) {
|
880
|
-
var node = keRange.startNode;
|
881
|
-
if (node.nodeType == 1) {
|
882
|
-
if (node.nodeName.toLowerCase() == 'br') return;
|
883
|
-
keRange.selectNode(node);
|
884
|
-
} else {
|
885
|
-
return;
|
886
|
-
}
|
887
|
-
} else if (endParent) {
|
888
|
-
var endFrags = this.splitNodeParent(endParent, endNode, endPos);
|
889
|
-
keRange.setEnd(endFrags.left, 0);
|
890
|
-
if (startParent == endParent) {
|
891
|
-
keRange.setStart(endFrags.left, 0);
|
892
|
-
}
|
893
|
-
}
|
894
|
-
var removeAttr = function(node, attr) {
|
895
|
-
if (attr.charAt(0) == '.') {
|
896
|
-
var jsKey = KE.util.getJsKey(attr.substr(1));
|
897
|
-
node.style[jsKey] = '';
|
898
|
-
} else {
|
899
|
-
if (KE.browser.IE && KE.browser.VERSION < 8 && attr == 'class') attr = 'className';
|
900
|
-
node.removeAttribute(attr);
|
901
|
-
}
|
902
|
-
};
|
903
|
-
var nodeList = keRange.getNodeList();
|
904
|
-
keRange.setTextStart(keRange.startNode, keRange.startPos);
|
905
|
-
keRange.setTextEnd(keRange.endNode, keRange.endPos);
|
906
|
-
for (var i = 0, length = nodeList.length; i < length; i++) {
|
907
|
-
var node = nodeList[i];
|
908
|
-
if (node.nodeType == 1) {
|
909
|
-
var tagName = node.tagName.toLowerCase();
|
910
|
-
if (tags[tagName]) {
|
911
|
-
var attr = tags[tagName];
|
912
|
-
for (var j = 0, len = attr.length; j < len; j++) {
|
913
|
-
if (attr[j] == '*') {
|
914
|
-
KE.util.removeParent(node);
|
915
|
-
break;
|
916
|
-
} else {
|
917
|
-
removeAttr(node, attr[j]);
|
918
|
-
var attrs = [];
|
919
|
-
if (node.outerHTML) {
|
920
|
-
attrHash = KE.util.getAttrList(node.outerHTML);
|
921
|
-
KE.each(attrHash, function(key, val) {
|
922
|
-
attrs.push({
|
923
|
-
name : key,
|
924
|
-
value : val
|
925
|
-
});
|
926
|
-
});
|
927
|
-
} else {
|
928
|
-
attrs = node.attributes;
|
929
|
-
}
|
930
|
-
if (attrs.length == 0) {
|
931
|
-
KE.util.removeParent(node);
|
932
|
-
break;
|
933
|
-
} else if (attrs[0].name == 'style' && attrs[0].value === '') {
|
934
|
-
KE.util.removeParent(node);
|
935
|
-
break;
|
936
|
-
}
|
937
|
-
}
|
938
|
-
}
|
939
|
-
}
|
940
|
-
if (tags['*']) {
|
941
|
-
var attr = tags['*'];
|
942
|
-
for (var j = 0, len = attr.length; j < len; j++) {
|
943
|
-
removeAttr(node, attr[j]);
|
944
|
-
}
|
945
|
-
}
|
946
|
-
}
|
947
|
-
}
|
948
|
-
try {
|
949
|
-
this.keSel.addRange(keRange);
|
950
|
-
} catch(e) {}
|
951
|
-
};
|
952
|
-
};
|
953
|
-
|
954
|
-
KE.format = {
|
955
|
-
getUrl : function(url, mode, host, pathname) {
|
956
|
-
if (!mode) return url;
|
957
|
-
mode = mode.toLowerCase();
|
958
|
-
if (!KE.util.inArray(mode, ['absolute', 'relative', 'domain'])) return url;
|
959
|
-
host = host || location.protocol + '//' + location.host;
|
960
|
-
if (pathname === undefined) {
|
961
|
-
var m = location.pathname.match(/^(\/.*)\//);
|
962
|
-
pathname = m ? m[1] : '';
|
963
|
-
}
|
964
|
-
var matches = url.match(/^(\w+:\/\/[^\/]*)/);
|
965
|
-
if (matches) {
|
966
|
-
if (matches[1] !== host) return url;
|
967
|
-
} else if (url.match(/^\w+:/)) {
|
968
|
-
return url;
|
969
|
-
}
|
970
|
-
var getRealPath = function(path) {
|
971
|
-
var parts = path.split('/');
|
972
|
-
paths = [];
|
973
|
-
for (var i = 0, len = parts.length; i < len; i++) {
|
974
|
-
var part = parts[i];
|
975
|
-
if (part == '..') {
|
976
|
-
if (paths.length > 0) paths.pop();
|
977
|
-
} else if (part !== '' && part != '.') {
|
978
|
-
paths.push(part);
|
979
|
-
}
|
980
|
-
}
|
981
|
-
return '/' + paths.join('/');
|
982
|
-
};
|
983
|
-
if (url.match(/^\//)) {
|
984
|
-
url = host + getRealPath(url.substr(1));
|
985
|
-
} else if (!url.match(/^\w+:\/\//)) {
|
986
|
-
url = host + getRealPath(pathname + '/' + url);
|
987
|
-
}
|
988
|
-
if (mode == 'relative') {
|
989
|
-
var getRelativePath = function(path, depth) {
|
990
|
-
if (url.substr(0, path.length) === path) {
|
991
|
-
var arr = [];
|
992
|
-
for (var i = 0; i < depth; i++) {
|
993
|
-
arr.push('..');
|
994
|
-
}
|
995
|
-
var prefix = '.';
|
996
|
-
if (arr.length > 0) prefix += '/' + arr.join('/');
|
997
|
-
if (pathname == '/') prefix += '/';
|
998
|
-
return prefix + url.substr(path.length);
|
999
|
-
} else {
|
1000
|
-
var m = path.match(/^(.*)\//);
|
1001
|
-
if (m) {
|
1002
|
-
return getRelativePath(m[1], ++depth);
|
1003
|
-
}
|
1004
|
-
}
|
1005
|
-
};
|
1006
|
-
url = getRelativePath(host + pathname, 0).substr(2);
|
1007
|
-
} else if (mode == 'absolute') {
|
1008
|
-
if (url.substr(0, host.length) === host) {
|
1009
|
-
url = url.substr(host.length);
|
1010
|
-
}
|
1011
|
-
}
|
1012
|
-
return url;
|
1013
|
-
},
|
1014
|
-
getHtml : function(html, htmlTags, urlType) {
|
1015
|
-
var isFilter = htmlTags ? true : false;
|
1016
|
-
html = html.replace(/(<pre[^>]*>)([\s\S]*?)(<\/pre>)/ig, function($0, $1, $2, $3){
|
1017
|
-
return $1 + $2.replace(/<br[^>]*>/ig, '\n') + $3;
|
1018
|
-
});
|
1019
|
-
var htmlTagHash = {};
|
1020
|
-
var fontSizeHash = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
|
1021
|
-
if (isFilter) {
|
1022
|
-
KE.each(htmlTags, function(key, val) {
|
1023
|
-
var arr = key.split(',');
|
1024
|
-
for (var i = 0, len = arr.length; i < len; i++) htmlTagHash[arr[i]] = KE.util.arrayToHash(val);
|
1025
|
-
});
|
1026
|
-
}
|
1027
|
-
var skipFlag = false;
|
1028
|
-
var noEndTagHash = KE.util.arrayToHash(KE.setting.noEndTags);
|
1029
|
-
var inlineTagHash = KE.util.arrayToHash(KE.setting.inlineTags);
|
1030
|
-
var endlineTagHash = KE.util.arrayToHash(KE.setting.endlineTags);
|
1031
|
-
var re = /((?:\r\n|\n|\r)*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:]+="[^"]*")|(?:\s+[\w\-:]+='[^']*'))*)(\/)?>((?:\r\n|\n|\r)*)/g;
|
1032
|
-
html = html.replace(re, function($0, $1, $2, $3, $4, $5, $6) {
|
1033
|
-
var startNewline = $1 || '';
|
1034
|
-
var startSlash = $2 || '';
|
1035
|
-
var tagName = $3.toLowerCase();
|
1036
|
-
var attr = $4 || '';
|
1037
|
-
var endSlash = $5 ? ' ' + $5 : '';
|
1038
|
-
var endNewline = $6 || '';
|
1039
|
-
if (tagName === 'script' && startSlash !== '') skipFlag = false;
|
1040
|
-
if (skipFlag) return $0;
|
1041
|
-
if (tagName === 'script' && startSlash === '') skipFlag = true;
|
1042
|
-
if (isFilter && typeof htmlTagHash[tagName] == "undefined") return '';
|
1043
|
-
if (endSlash === '' && typeof noEndTagHash[tagName] != "undefined") endSlash = ' /';
|
1044
|
-
if (tagName in endlineTagHash) {
|
1045
|
-
if (startSlash || endSlash) endNewline = '\n';
|
1046
|
-
} else {
|
1047
|
-
if (endNewline) endNewline = ' ';
|
1048
|
-
}
|
1049
|
-
if (tagName !== 'script' && tagName !== 'style') {
|
1050
|
-
startNewline = '';
|
1051
|
-
}
|
1052
|
-
if (tagName === 'font') {
|
1053
|
-
var style = {}, styleStr = '';
|
1054
|
-
attr = attr.replace(/\s*([\w\-:]+)=([^\s"'<>]+|"[^"]*"|'[^']*')/g, function($0, $1, $2) {
|
1055
|
-
var key = $1.toLowerCase();
|
1056
|
-
var val = $2 || '';
|
1057
|
-
val = val.replace(/^["']|["']$/g, '');
|
1058
|
-
if (key === 'color') {
|
1059
|
-
style['color'] = val;
|
1060
|
-
return ' ';
|
1061
|
-
}
|
1062
|
-
if (key === 'size') {
|
1063
|
-
style['font-size'] = fontSizeHash[parseInt(val) - 1] || '';
|
1064
|
-
return ' ';
|
1065
|
-
}
|
1066
|
-
if (key === 'face') {
|
1067
|
-
style['font-family'] = val;
|
1068
|
-
return ' ';
|
1069
|
-
}
|
1070
|
-
if (key === 'style') {
|
1071
|
-
styleStr = val;
|
1072
|
-
return ' ';
|
1073
|
-
}
|
1074
|
-
return $0;
|
1075
|
-
});
|
1076
|
-
if (styleStr && !/;$/.test(styleStr)) styleStr += ';';
|
1077
|
-
KE.each(style, function(key, val) {
|
1078
|
-
if (val !== '') {
|
1079
|
-
if (/\s/.test(val)) val = "'" + val + "'";
|
1080
|
-
styleStr += key + ':' + val + ';';
|
1081
|
-
}
|
1082
|
-
});
|
1083
|
-
if (styleStr) attr += ' style="' + styleStr + '"';
|
1084
|
-
tagName = 'span';
|
1085
|
-
}
|
1086
|
-
if (attr !== '') {
|
1087
|
-
attr = attr.replace(/\s*([\w\-:]+)=([^\s"'<>]+|"[^"]*"|'[^']*')/g, function($0, $1, $2) {
|
1088
|
-
var key = $1.toLowerCase();
|
1089
|
-
var val = $2 || '';
|
1090
|
-
if (isFilter) {
|
1091
|
-
if (key.charAt(0) === "." || (key !== "style" && typeof htmlTagHash[tagName][key] == "undefined")) return ' ';
|
1092
|
-
}
|
1093
|
-
if (val === '') {
|
1094
|
-
val = '""';
|
1095
|
-
} else {
|
1096
|
-
if (key === "style") {
|
1097
|
-
val = val.substr(1, val.length - 2);
|
1098
|
-
val = val.replace(/\s*([^\s]+?)\s*:(.*?)(;|$)/g, function($0, $1, $2) {
|
1099
|
-
var k = $1.toLowerCase();
|
1100
|
-
if (isFilter) {
|
1101
|
-
if (typeof htmlTagHash[tagName]['style'] == "undefined" && typeof htmlTagHash[tagName]['.' + k] == "undefined") return '';
|
1102
|
-
}
|
1103
|
-
var v = KE.util.trim($2);
|
1104
|
-
v = KE.util.rgbToHex(v);
|
1105
|
-
return k + ':' + v + ';';
|
1106
|
-
});
|
1107
|
-
val = KE.util.trim(val);
|
1108
|
-
if (val === '') return '';
|
1109
|
-
val = '"' + val + '"';
|
1110
|
-
}
|
1111
|
-
if (KE.util.inArray(key, ['src', 'href'])) {
|
1112
|
-
if (val.charAt(0) === '"') {
|
1113
|
-
val = val.substr(1, val.length - 2);
|
1114
|
-
}
|
1115
|
-
val = KE.format.getUrl(val, urlType);
|
1116
|
-
}
|
1117
|
-
if (val.charAt(0) !== '"') val = '"' + val + '"';
|
1118
|
-
}
|
1119
|
-
return ' ' + key + '=' + val + ' ';
|
1120
|
-
});
|
1121
|
-
attr = attr.replace(/\s+(checked|selected|disabled|readonly)(\s+|$)/ig, function($0, $1) {
|
1122
|
-
var key = $1.toLowerCase();
|
1123
|
-
if (isFilter) {
|
1124
|
-
if (key.charAt(0) === "." || typeof htmlTagHash[tagName][key] == "undefined") return ' ';
|
1125
|
-
}
|
1126
|
-
return ' ' + key + '="' + key + '"' + ' ';
|
1127
|
-
});
|
1128
|
-
attr = KE.util.trim(attr);
|
1129
|
-
attr = attr.replace(/\s+/g, ' ');
|
1130
|
-
if (attr) attr = ' ' + attr;
|
1131
|
-
return startNewline + '<' + startSlash + tagName + attr + endSlash + '>' + endNewline;
|
1132
|
-
} else {
|
1133
|
-
return startNewline + '<' + startSlash + tagName + endSlash + '>' + endNewline;
|
1134
|
-
}
|
1135
|
-
});
|
1136
|
-
if (!KE.browser.IE) {
|
1137
|
-
html = html.replace(/<p><br\s+\/>\n<\/p>/ig, '<p> </p>');
|
1138
|
-
html = html.replace(/<br\s+\/>\n<\/p>/ig, '</p>');
|
1139
|
-
}
|
1140
|
-
html = html.replace(/\u200B/g, '');
|
1141
|
-
var reg = KE.setting.inlineTags.join('|');
|
1142
|
-
var trimHtml = function(inHtml) {
|
1143
|
-
var outHtml = inHtml.replace(new RegExp('<(' + reg + ')[^>]*><\\/(' + reg + ')>', 'ig'), function($0, $1, $2) {
|
1144
|
-
if ($1 == $2) return '';
|
1145
|
-
else return $0;
|
1146
|
-
});
|
1147
|
-
if (inHtml !== outHtml) outHtml = trimHtml(outHtml);
|
1148
|
-
return outHtml;
|
1149
|
-
};
|
1150
|
-
return KE.util.trim(trimHtml(html));
|
1151
|
-
}
|
1152
|
-
};
|
1153
|
-
|
1154
|
-
KE.attr = function(el, key, val) {
|
1155
|
-
if (KE.browser.IE && KE.browser.VERSION < 8 && key.toLowerCase() == 'class') key = 'className';
|
1156
|
-
val = '' + val;
|
1157
|
-
el.setAttribute(key, val);
|
1158
|
-
if (val === '') el.removeAttribute(key);
|
1159
|
-
};
|
1160
|
-
|
1161
|
-
KE.addClass = function(el, className) {
|
1162
|
-
if (typeof el == 'object') {
|
1163
|
-
var cls = el.className;
|
1164
|
-
if (cls) {
|
1165
|
-
if ((' ' + cls + ' ').indexOf(' ' + className + ' ') < 0) {
|
1166
|
-
el.className = cls + ' ' + className;
|
1167
|
-
}
|
1168
|
-
} else {
|
1169
|
-
el.className = className;
|
1170
|
-
}
|
1171
|
-
} else if (typeof el == 'string') {
|
1172
|
-
if (/\s+class\s*=/.test(el)) {
|
1173
|
-
el = el.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/, function($0, $1, $2, $3) {
|
1174
|
-
if ((' ' + $2 + ' ').indexOf(' ' + className + ' ') < 0) {
|
1175
|
-
return $2 === '' ? $1 + className + $3 : $1 + $2 + ' ' + className + $3;
|
1176
|
-
} else {
|
1177
|
-
return $0;
|
1178
|
-
}
|
1179
|
-
});
|
1180
|
-
} else {
|
1181
|
-
el = el.substr(0, el.length - 1) + ' class="' + className + '">';
|
1182
|
-
}
|
1183
|
-
}
|
1184
|
-
return el;
|
1185
|
-
};
|
1186
|
-
|
1187
|
-
KE.removeClass = function(el, className) {
|
1188
|
-
var cls = el.className || '';
|
1189
|
-
cls = ' ' + cls + ' ';
|
1190
|
-
className = ' ' + className + ' ';
|
1191
|
-
if (cls.indexOf(className) >= 0) {
|
1192
|
-
cls = KE.util.trim(cls.replace(new RegExp(className, 'ig'), ''));
|
1193
|
-
if (cls === '') {
|
1194
|
-
var key = el.getAttribute('class') ? 'class' : 'className';
|
1195
|
-
el.removeAttribute(key);
|
1196
|
-
} else {
|
1197
|
-
el.className = cls;
|
1198
|
-
}
|
1199
|
-
}
|
1200
|
-
return el;
|
1201
|
-
};
|
1202
|
-
|
1203
|
-
KE.getComputedStyle = function(el, key) {
|
1204
|
-
var doc = el.ownerDocument,
|
1205
|
-
win = doc.parentWindow || doc.defaultView,
|
1206
|
-
jsKey = KE.util.getJsKey(key),
|
1207
|
-
val = '';
|
1208
|
-
if (win.getComputedStyle) {
|
1209
|
-
var style = win.getComputedStyle(el, null);
|
1210
|
-
val = style[jsKey] || style.getPropertyValue(key) || el.style[jsKey];
|
1211
|
-
} else if (el.currentStyle) {
|
1212
|
-
val = el.currentStyle[jsKey] || el.style[jsKey];
|
1213
|
-
}
|
1214
|
-
return val;
|
1215
|
-
};
|
1216
|
-
|
1217
|
-
KE.getCommonAncestor = function(keSel, tagName) {
|
1218
|
-
var range = keSel.range,
|
1219
|
-
keRange = keSel.keRange,
|
1220
|
-
startNode = keRange.startNode,
|
1221
|
-
endNode = keRange.endNode;
|
1222
|
-
if (KE.util.inArray(tagName, ['table', 'td', 'tr'])) {
|
1223
|
-
if (KE.browser.IE) {
|
1224
|
-
if (range.item) {
|
1225
|
-
if (range.item(0).nodeName.toLowerCase() === tagName) {
|
1226
|
-
startNode = endNode = range.item(0);
|
1227
|
-
}
|
1228
|
-
} else {
|
1229
|
-
var rangeA = range.duplicate();
|
1230
|
-
rangeA.collapse(true);
|
1231
|
-
var rangeB = range.duplicate();
|
1232
|
-
rangeB.collapse(false);
|
1233
|
-
startNode = rangeA.parentElement();
|
1234
|
-
endNode = rangeB.parentElement();
|
1235
|
-
}
|
1236
|
-
} else {
|
1237
|
-
var rangeA = range.cloneRange();
|
1238
|
-
rangeA.collapse(true);
|
1239
|
-
var rangeB = range.cloneRange();
|
1240
|
-
rangeB.collapse(false);
|
1241
|
-
startNode = rangeA.startContainer;
|
1242
|
-
endNode = rangeB.startContainer;
|
1243
|
-
}
|
1244
|
-
}
|
1245
|
-
function find(node) {
|
1246
|
-
while (node) {
|
1247
|
-
if (node.nodeType == 1) {
|
1248
|
-
if (node.tagName.toLowerCase() === tagName) return node;
|
1249
|
-
}
|
1250
|
-
node = node.parentNode;
|
1251
|
-
}
|
1252
|
-
return null;
|
1253
|
-
};
|
1254
|
-
var start = find(startNode),
|
1255
|
-
end = find(endNode);
|
1256
|
-
if (start && end && start === end) {
|
1257
|
-
return start;
|
1258
|
-
}
|
1259
|
-
return null;
|
1260
|
-
};
|
1261
|
-
|
1262
|
-
KE.queryCommandValue = function(doc, cmd) {
|
1263
|
-
cmd = cmd.toLowerCase();
|
1264
|
-
function commandValue() {
|
1265
|
-
var val = doc.queryCommandValue(cmd);
|
1266
|
-
if (typeof val !== 'string') val = '';
|
1267
|
-
return val;
|
1268
|
-
}
|
1269
|
-
var val = '';
|
1270
|
-
if (cmd === 'fontname') {
|
1271
|
-
val = commandValue();
|
1272
|
-
val = val.replace(/['"]/g, '');
|
1273
|
-
} else if (cmd === 'formatblock') {
|
1274
|
-
val = commandValue();
|
1275
|
-
if (val === '') {
|
1276
|
-
var keSel = new KE.selection(doc);
|
1277
|
-
var el = KE.getCommonAncestor(keSel, 'h1');
|
1278
|
-
if (!el) el = KE.getCommonAncestor(keSel, 'h2');
|
1279
|
-
if (!el) el = KE.getCommonAncestor(keSel, 'h3');
|
1280
|
-
if (!el) el = KE.getCommonAncestor(keSel, 'h4');
|
1281
|
-
if (!el) el = KE.getCommonAncestor(keSel, 'p');
|
1282
|
-
if (el) val = el.nodeName;
|
1283
|
-
}
|
1284
|
-
if (val === 'Normal') val = 'p';
|
1285
|
-
} else if (cmd === 'fontsize') {
|
1286
|
-
var keSel = new KE.selection(doc);
|
1287
|
-
var el = KE.getCommonAncestor(keSel, 'span');
|
1288
|
-
if (el) val = KE.getComputedStyle(el, 'font-size');
|
1289
|
-
} else if (cmd === 'textcolor') {
|
1290
|
-
var keSel = new KE.selection(doc);
|
1291
|
-
var el = KE.getCommonAncestor(keSel, 'span');
|
1292
|
-
if (el) val = KE.getComputedStyle(el, 'color');
|
1293
|
-
val = KE.util.rgbToHex(val);
|
1294
|
-
if (val === '') val = 'default';
|
1295
|
-
} else if (cmd === 'bgcolor') {
|
1296
|
-
var keSel = new KE.selection(doc);
|
1297
|
-
var el = KE.getCommonAncestor(keSel, 'span');
|
1298
|
-
if (el) val = KE.getComputedStyle(el, 'background-color');
|
1299
|
-
val = KE.util.rgbToHex(val);
|
1300
|
-
if (val === '') val = 'default';
|
1301
|
-
}
|
1302
|
-
return val.toLowerCase();
|
1303
|
-
};
|
1304
|
-
|
1305
|
-
KE.util = {
|
1306
|
-
getDocumentElement : function(doc) {
|
1307
|
-
doc = doc || document;
|
1308
|
-
return (doc.compatMode != "CSS1Compat") ? doc.body : doc.documentElement;
|
1309
|
-
},
|
1310
|
-
getDocumentHeight : function(doc) {
|
1311
|
-
var el = this.getDocumentElement(doc);
|
1312
|
-
return Math.max(el.scrollHeight, el.clientHeight);
|
1313
|
-
},
|
1314
|
-
getDocumentWidth : function(doc) {
|
1315
|
-
var el = this.getDocumentElement(doc);
|
1316
|
-
return Math.max(el.scrollWidth, el.clientWidth);
|
1317
|
-
},
|
1318
|
-
createTable : function(doc) {
|
1319
|
-
var table = KE.$$('table', doc);
|
1320
|
-
table.cellPadding = 0;
|
1321
|
-
table.cellSpacing = 0;
|
1322
|
-
table.border = 0;
|
1323
|
-
return {table: table, cell: table.insertRow(0).insertCell(0)};
|
1324
|
-
},
|
1325
|
-
loadStyle : function(path) {
|
1326
|
-
var link = KE.$$('link');
|
1327
|
-
link.setAttribute('type', 'text/css');
|
1328
|
-
link.setAttribute('rel', 'stylesheet');
|
1329
|
-
link.setAttribute('href', path);
|
1330
|
-
document.getElementsByTagName("head")[0].appendChild(link);
|
1331
|
-
},
|
1332
|
-
getAttrList : function(tag) {
|
1333
|
-
var re = /\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([\w\-:]+))|(?:([\w\-:]+)="([^"]*)")|(?:([\w\-:]+)='([^']*)'))(?=(?:\s|\/|>)+)/g;
|
1334
|
-
var arr, key, val, list = {};
|
1335
|
-
while ((arr = re.exec(tag))) {
|
1336
|
-
key = arr[1] || arr[2] || arr[4] || arr[6];
|
1337
|
-
val = arr[1] || (arr[2] ? arr[3] : (arr[4] ? arr[5] : arr[7]));
|
1338
|
-
list[key] = val;
|
1339
|
-
}
|
1340
|
-
return list;
|
1341
|
-
},
|
1342
|
-
inArray : function(str, arr) {
|
1343
|
-
for (var i = 0; i < arr.length; i++) {if (str == arr[i]) return true;}
|
1344
|
-
return false;
|
1345
|
-
},
|
1346
|
-
trim : function(str) {
|
1347
|
-
return str.replace(/^\s+|\s+$/g, "");
|
1348
|
-
},
|
1349
|
-
getJsKey : function(key) {
|
1350
|
-
var arr = key.split('-');
|
1351
|
-
key = '';
|
1352
|
-
for (var i = 0, len = arr.length; i < len; i++) {
|
1353
|
-
key += (i > 0) ? arr[i].charAt(0).toUpperCase() + arr[i].substr(1) : arr[i];
|
1354
|
-
}
|
1355
|
-
return key;
|
1356
|
-
},
|
1357
|
-
arrayToHash : function(arr) {
|
1358
|
-
var hash = {};
|
1359
|
-
for (var i = 0, len = arr.length; i < len; i++) hash[arr[i]] = 1;
|
1360
|
-
return hash;
|
1361
|
-
},
|
1362
|
-
escape : function(str) {
|
1363
|
-
str = str.replace(/&/g, '&');
|
1364
|
-
str = str.replace(/</g, '<');
|
1365
|
-
str = str.replace(/>/g, '>');
|
1366
|
-
str = str.replace(/"/g, '"');
|
1367
|
-
return str;
|
1368
|
-
},
|
1369
|
-
unescape : function(str) {
|
1370
|
-
str = str.replace(/</g, '<');
|
1371
|
-
str = str.replace(/>/g, '>');
|
1372
|
-
str = str.replace(/"/g, '"');
|
1373
|
-
str = str.replace(/&/g, '&');
|
1374
|
-
return str;
|
1375
|
-
},
|
1376
|
-
getScrollPos : function() {
|
1377
|
-
var x, y;
|
1378
|
-
if (KE.browser.IE || KE.browser.OPERA) {
|
1379
|
-
var el = this.getDocumentElement();
|
1380
|
-
x = el.scrollLeft;
|
1381
|
-
y = el.scrollTop;
|
1382
|
-
} else {
|
1383
|
-
x = window.scrollX;
|
1384
|
-
y = window.scrollY;
|
1385
|
-
}
|
1386
|
-
return {x : x, y : y};
|
1387
|
-
},
|
1388
|
-
getElementPos : function(el) {
|
1389
|
-
var x = 0, y = 0;
|
1390
|
-
if (el.getBoundingClientRect) {
|
1391
|
-
var box = el.getBoundingClientRect();
|
1392
|
-
var pos = this.getScrollPos();
|
1393
|
-
x = box.left + pos.x;
|
1394
|
-
y = box.top + pos.y;
|
1395
|
-
} else {
|
1396
|
-
x = el.offsetLeft;
|
1397
|
-
y = el.offsetTop;
|
1398
|
-
var parent = el.offsetParent;
|
1399
|
-
while (parent) {
|
1400
|
-
x += parent.offsetLeft;
|
1401
|
-
y += parent.offsetTop;
|
1402
|
-
parent = parent.offsetParent;
|
1403
|
-
}
|
1404
|
-
}
|
1405
|
-
return {x : x, y : y};
|
1406
|
-
},
|
1407
|
-
getCoords : function(ev) {
|
1408
|
-
ev = ev || window.event;
|
1409
|
-
return {
|
1410
|
-
x : ev.clientX,
|
1411
|
-
y : ev.clientY
|
1412
|
-
};
|
1413
|
-
},
|
1414
|
-
setOpacity : function(el, opacity) {
|
1415
|
-
if (typeof el.style.opacity == "undefined") {
|
1416
|
-
el.style.filter = (opacity == 100) ? "" : "alpha(opacity=" + opacity + ")";
|
1417
|
-
} else {
|
1418
|
-
el.style.opacity = (opacity == 100) ? "" : (opacity / 100);
|
1419
|
-
}
|
1420
|
-
},
|
1421
|
-
getIframeDoc : function(iframe) {
|
1422
|
-
return iframe.contentDocument || iframe.contentWindow.document;
|
1423
|
-
},
|
1424
|
-
rgbToHex : function(str) {
|
1425
|
-
function hex(s) {
|
1426
|
-
s = parseInt(s).toString(16);
|
1427
|
-
return s.length > 1 ? s : '0' + s;
|
1428
|
-
};
|
1429
|
-
return str.replace(/rgb\s*?\(\s*?(\d+)\s*?,\s*?(\d+)\s*?,\s*?(\d+)\s*?\)/ig,
|
1430
|
-
function($0, $1, $2, $3) {
|
1431
|
-
return '#' + hex($1) + hex($2) + hex($3);
|
1432
|
-
}
|
1433
|
-
);
|
1434
|
-
},
|
1435
|
-
parseJson : function (text) {
|
1436
|
-
//extract JSON string
|
1437
|
-
var match;
|
1438
|
-
if ((match = /\{[\s\S]*\}|\[[\s\S]*\]/.exec(text))) {
|
1439
|
-
text = match[0];
|
1440
|
-
}
|
1441
|
-
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
1442
|
-
cx.lastIndex = 0;
|
1443
|
-
if (cx.test(text)) {
|
1444
|
-
text = text.replace(cx, function (a) {
|
1445
|
-
return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
1446
|
-
});
|
1447
|
-
}
|
1448
|
-
if (/^[\],:{}\s]*$/.
|
1449
|
-
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
|
1450
|
-
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
|
1451
|
-
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
1452
|
-
return eval('(' + text + ')');
|
1453
|
-
}
|
1454
|
-
throw 'JSON parse error';
|
1455
|
-
},
|
1456
|
-
getParam : function(url, name) {
|
1457
|
-
return url.match(new RegExp('[?&]' + name + '=([^?&]+)', 'i')) ? unescape(RegExp.$1) : '';
|
1458
|
-
},
|
1459
|
-
createRange : function(doc) {
|
1460
|
-
return doc.body.createTextRange ? doc.body.createTextRange() : doc.createRange();
|
1461
|
-
},
|
1462
|
-
getNodeType : function(node) {
|
1463
|
-
return (node.nodeType == 1 && KE.util.inArray(node.tagName.toLowerCase(), KE.setting.noEndTags)) ? 88 : node.nodeType;
|
1464
|
-
},
|
1465
|
-
inMarquee : function(node) {
|
1466
|
-
var n = node, nodeName;
|
1467
|
-
while (n) {
|
1468
|
-
nodeName = n.nodeName.toLowerCase();
|
1469
|
-
if (nodeName == 'marquee' || nodeName == 'select') return true;
|
1470
|
-
n = n.parentNode;
|
1471
|
-
}
|
1472
|
-
return false;
|
1473
|
-
},
|
1474
|
-
moveToElementText : function (range, el) {
|
1475
|
-
if (!this.inMarquee(el)) range.moveToElementText(el);
|
1476
|
-
},
|
1477
|
-
getNodeTextLength : function(node) {
|
1478
|
-
var type = KE.util.getNodeType(node);
|
1479
|
-
if (type == 1) {
|
1480
|
-
var html = node.innerHTML;
|
1481
|
-
return html.replace(/<.*?>/ig, "").length;
|
1482
|
-
} else if (type == 3) {
|
1483
|
-
return node.nodeValue.length;
|
1484
|
-
}
|
1485
|
-
},
|
1486
|
-
getNodeStartRange : function(doc, node) {
|
1487
|
-
var range = KE.util.createRange(doc);
|
1488
|
-
var type = node.nodeType;
|
1489
|
-
if (type == 1) {
|
1490
|
-
KE.util.moveToElementText(range, node);
|
1491
|
-
return range;
|
1492
|
-
} else if (type == 3) {
|
1493
|
-
var offset = 0;
|
1494
|
-
var sibling = node.previousSibling;
|
1495
|
-
while (sibling) {
|
1496
|
-
if (sibling.nodeType == 1) {
|
1497
|
-
var nodeRange = KE.util.createRange(doc);
|
1498
|
-
KE.util.moveToElementText(nodeRange, sibling);
|
1499
|
-
range.setEndPoint('StartToEnd', nodeRange);
|
1500
|
-
range.moveStart('character', offset);
|
1501
|
-
return range;
|
1502
|
-
} else if (sibling.nodeType == 3) {
|
1503
|
-
offset += sibling.nodeValue.length;
|
1504
|
-
}
|
1505
|
-
sibling = sibling.previousSibling;
|
1506
|
-
}
|
1507
|
-
KE.util.moveToElementText(range, node.parentNode);
|
1508
|
-
range.moveStart('character', offset);
|
1509
|
-
return range;
|
1510
|
-
}
|
1511
|
-
},
|
1512
|
-
removeParent : function(parent) {
|
1513
|
-
if (parent.hasChildNodes) {
|
1514
|
-
var node = parent.firstChild;
|
1515
|
-
while (node) {
|
1516
|
-
var nextNode = node.nextSibling;
|
1517
|
-
parent.parentNode.insertBefore(node, parent);
|
1518
|
-
node = nextNode;
|
1519
|
-
}
|
1520
|
-
}
|
1521
|
-
parent.parentNode.removeChild(parent);
|
1522
|
-
},
|
1523
|
-
pluginLang : function(pluginName, doc) {
|
1524
|
-
KE.each(KE.lang.plugins[pluginName], function (key, val) {
|
1525
|
-
var span = KE.$('lang.' + key, doc);
|
1526
|
-
if (span) {
|
1527
|
-
span.parentNode.insertBefore(doc.createTextNode(val), span);
|
1528
|
-
span.parentNode.removeChild(span);
|
1529
|
-
}
|
1530
|
-
});
|
1531
|
-
},
|
1532
|
-
drag : function(id, mousedownObj, moveObj, func) {
|
1533
|
-
var g = KE.g[id];
|
1534
|
-
mousedownObj.onmousedown = function(e) {
|
1535
|
-
var self = this;
|
1536
|
-
e = e || window.event;
|
1537
|
-
var pos = KE.util.getCoords(e);
|
1538
|
-
var objTop = parseInt(moveObj.style.top);
|
1539
|
-
var objLeft = parseInt(moveObj.style.left);
|
1540
|
-
var objWidth = moveObj.style.width;
|
1541
|
-
var objHeight = moveObj.style.height;
|
1542
|
-
if (objWidth.match(/%$/)) objWidth = moveObj.offsetWidth + 'px';
|
1543
|
-
if (objHeight.match(/%$/)) objHeight = moveObj.offsetHeight + 'px';
|
1544
|
-
objWidth = parseInt(objWidth);
|
1545
|
-
objHeight = parseInt(objHeight);
|
1546
|
-
var mouseTop = pos.y;
|
1547
|
-
var mouseLeft = pos.x;
|
1548
|
-
var scrollPos = KE.util.getScrollPos();
|
1549
|
-
var scrollTop = scrollPos.y;
|
1550
|
-
var scrollLeft = scrollPos.x;
|
1551
|
-
var dragFlag = true;
|
1552
|
-
function moveListener(e) {
|
1553
|
-
if (dragFlag) {
|
1554
|
-
var pos = KE.util.getCoords(e);
|
1555
|
-
var scrollPos = KE.util.getScrollPos();
|
1556
|
-
var top = parseInt(pos.y - mouseTop - scrollTop + scrollPos.y);
|
1557
|
-
var left = parseInt(pos.x - mouseLeft - scrollLeft + scrollPos.x);
|
1558
|
-
func(objTop, objLeft, objWidth, objHeight, top, left);
|
1559
|
-
}
|
1560
|
-
}
|
1561
|
-
var iframePos = KE.util.getElementPos(g.iframe);
|
1562
|
-
function iframeMoveListener(e) {
|
1563
|
-
if (dragFlag) {
|
1564
|
-
var pos = KE.util.getCoords(e, g.iframeDoc);
|
1565
|
-
var top = parseInt(iframePos.y + pos.y - mouseTop - scrollTop);
|
1566
|
-
var left = parseInt(iframePos.x + pos.x - mouseLeft - scrollLeft);
|
1567
|
-
func(objTop, objLeft, objWidth, objHeight, top, left);
|
1568
|
-
}
|
1569
|
-
}
|
1570
|
-
var selectListener = function() { return false; };
|
1571
|
-
function upListener(e) {
|
1572
|
-
dragFlag = false;
|
1573
|
-
if (self.releaseCapture) self.releaseCapture();
|
1574
|
-
KE.event.remove(document, 'mousemove', moveListener);
|
1575
|
-
KE.event.remove(document, 'mouseup', upListener);
|
1576
|
-
KE.event.remove(g.iframeDoc, 'mousemove', iframeMoveListener);
|
1577
|
-
KE.event.remove(g.iframeDoc, 'mouseup', upListener);
|
1578
|
-
KE.event.remove(document, 'selectstart', selectListener);
|
1579
|
-
KE.event.stop(e);
|
1580
|
-
return false;
|
1581
|
-
}
|
1582
|
-
KE.event.add(document, 'mousemove', moveListener);
|
1583
|
-
KE.event.add(document, 'mouseup', upListener);
|
1584
|
-
KE.event.add(g.iframeDoc, 'mousemove', iframeMoveListener);
|
1585
|
-
KE.event.add(g.iframeDoc, 'mouseup', upListener);
|
1586
|
-
KE.event.add(document, 'selectstart', selectListener);
|
1587
|
-
if (self.setCapture) self.setCapture();
|
1588
|
-
KE.event.stop(e);
|
1589
|
-
return false;
|
1590
|
-
};
|
1591
|
-
},
|
1592
|
-
resize : function(id, width, height, isCheck, isResizeWidth) {
|
1593
|
-
isResizeWidth = (typeof isResizeWidth == "undefined") ? true : isResizeWidth;
|
1594
|
-
var g = KE.g[id];
|
1595
|
-
if (!g.container) return;
|
1596
|
-
if (isCheck && (parseInt(width) <= g.minWidth || parseInt(height) <= g.minHeight)) return;
|
1597
|
-
if (isResizeWidth) g.container.style.width = width;
|
1598
|
-
if (KE.browser.IE) {
|
1599
|
-
//improve IE performance (issue #126)
|
1600
|
-
var temp = g.toolbarTable && g.toolbarTable.offsetHeight;
|
1601
|
-
}
|
1602
|
-
g.container.style.height = height;
|
1603
|
-
var diff = parseInt(height) - g.toolbarHeight - g.statusbarHeight;
|
1604
|
-
if (diff >= 0) {
|
1605
|
-
g.iframe.style.height = diff + 'px';
|
1606
|
-
g.newTextarea.style.height = (((KE.browser.IE && KE.browser.VERSION < 8 || document.compatMode != 'CSS1Compat') && diff >= 2) ? diff - 2 : diff) + 'px';
|
1607
|
-
}
|
1608
|
-
},
|
1609
|
-
hideLoadingPage : function(id) {
|
1610
|
-
var stack = KE.g[id].dialogStack;
|
1611
|
-
var dialog = stack[stack.length - 1];
|
1612
|
-
dialog.loading.style.display = 'none';
|
1613
|
-
dialog.iframe.style.display = '';
|
1614
|
-
},
|
1615
|
-
showLoadingPage : function(id) {
|
1616
|
-
var stack = KE.g[id].dialogStack;
|
1617
|
-
var dialog = stack[stack.length - 1];
|
1618
|
-
dialog.loading.style.display = '';
|
1619
|
-
dialog.iframe.style.display = 'none';
|
1620
|
-
},
|
1621
|
-
setDefaultPlugin : function(id) {
|
1622
|
-
var items = [
|
1623
|
-
'selectall', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull',
|
1624
|
-
'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
1625
|
-
'superscript', 'bold', 'italic', 'underline', 'strikethrough'
|
1626
|
-
];
|
1627
|
-
var shortcuts = {
|
1628
|
-
bold : 'B',
|
1629
|
-
italic : 'I',
|
1630
|
-
underline : 'U'
|
1631
|
-
};
|
1632
|
-
for (var i = 0; i < items.length; i++) {
|
1633
|
-
var item = items[i],
|
1634
|
-
plugin = {};
|
1635
|
-
if (item in shortcuts) {
|
1636
|
-
plugin.init = (function(item) {
|
1637
|
-
return function(id) {
|
1638
|
-
KE.event.ctrl(KE.g[id].iframeDoc, shortcuts[item], function(e) {
|
1639
|
-
KE.plugin[item].click(id);
|
1640
|
-
KE.util.focus(id);
|
1641
|
-
}, id);
|
1642
|
-
};
|
1643
|
-
})(item);
|
1644
|
-
}
|
1645
|
-
plugin.click = (function(item) {
|
1646
|
-
return function(id) {
|
1647
|
-
KE.util.execCommand(id, item, null);
|
1648
|
-
};
|
1649
|
-
})(item);
|
1650
|
-
KE.plugin[item] = plugin;
|
1651
|
-
}
|
1652
|
-
},
|
1653
|
-
getFullHtml : function(id) {
|
1654
|
-
var html = '<html>';
|
1655
|
-
html += '<head>';
|
1656
|
-
html += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
|
1657
|
-
html += '<title>KindEditor</title>';
|
1658
|
-
html += '<link href="' + KE.g[id].skinsPath + 'common/editor.css?ver=' + escape(KE.version) + '" rel="stylesheet" type="text/css" />';
|
1659
|
-
var cssPath = KE.g[id].cssPath;
|
1660
|
-
if (typeof cssPath == 'string') cssPath = [cssPath];
|
1661
|
-
for (var i = 0, len = cssPath.length; i < len; i++) {
|
1662
|
-
if (cssPath[i] !== '') html += '<link href="' + cssPath[i] + '" rel="stylesheet" type="text/css" />';
|
1663
|
-
}
|
1664
|
-
html += '</head>';
|
1665
|
-
html += '<body class="ke-content"></body>';
|
1666
|
-
html += '</html>';
|
1667
|
-
return html;
|
1668
|
-
},
|
1669
|
-
getMediaType : function(src) {
|
1670
|
-
if (src.match(/\.(rm|rmvb)(\?|$)/i)) return 'rm';
|
1671
|
-
else if (src.match(/\.(swf|flv)(\?|$)/i)) return 'flash';
|
1672
|
-
else return 'media';
|
1673
|
-
},
|
1674
|
-
getMediaImage : function(id, type, attrs) {
|
1675
|
-
var width = attrs.width;
|
1676
|
-
var height = attrs.height;
|
1677
|
-
type = type || this.getMediaType(attrs.src);
|
1678
|
-
var srcTag = this.getMediaEmbed(attrs);
|
1679
|
-
var style = '';
|
1680
|
-
if (width > 0) style += 'width:' + width + 'px;';
|
1681
|
-
if (height > 0) style += 'height:' + height + 'px;';
|
1682
|
-
var className = 'ke-' + type;
|
1683
|
-
var html = '<img class="' + className + '" src="' + KE.g[id].skinsPath + 'common/blank.gif" ';
|
1684
|
-
if (style !== '') html += 'style="' + style + '" ';
|
1685
|
-
html += 'kesrctag="' + escape(srcTag) + '" alt="" />';
|
1686
|
-
return html;
|
1687
|
-
},
|
1688
|
-
getMediaEmbed : function(attrs) {
|
1689
|
-
var html = '<embed ';
|
1690
|
-
KE.each(attrs, function(key, val) {
|
1691
|
-
html += key + '="' + val + '" ';
|
1692
|
-
});
|
1693
|
-
html += '/>';
|
1694
|
-
return html;
|
1695
|
-
},
|
1696
|
-
execGetHtmlHooks : function(id, html) {
|
1697
|
-
var hooks = KE.g[id].getHtmlHooks;
|
1698
|
-
for (var i = 0, len = hooks.length; i < len; i++) {
|
1699
|
-
html = hooks[i](html);
|
1700
|
-
}
|
1701
|
-
return html;
|
1702
|
-
},
|
1703
|
-
execSetHtmlHooks : function(id, html) {
|
1704
|
-
var hooks = KE.g[id].setHtmlHooks;
|
1705
|
-
for (var i = 0, len = hooks.length; i < len; i++) {
|
1706
|
-
html = hooks[i](html);
|
1707
|
-
}
|
1708
|
-
return html;
|
1709
|
-
},
|
1710
|
-
execOnchangeHandler : function(id) {
|
1711
|
-
var handlers = KE.g[id].onchangeHandlerStack;
|
1712
|
-
for (var i = 0, len = handlers.length; i < len; i++) {
|
1713
|
-
handlers[i]();
|
1714
|
-
}
|
1715
|
-
},
|
1716
|
-
toData : function(id, srcData) {
|
1717
|
-
var g = KE.g[id];
|
1718
|
-
var html = this.execGetHtmlHooks(id, srcData);
|
1719
|
-
html = html.replace(/^\s*<br[^>]*>\s*$/ig, '');
|
1720
|
-
html = html.replace(/^\s*<p>\s* \s*<\/p>\s*$/ig, '');
|
1721
|
-
if (g.filterMode) {
|
1722
|
-
return KE.format.getHtml(html, g.htmlTags, g.urlType);
|
1723
|
-
} else {
|
1724
|
-
return KE.format.getHtml(html, null, g.urlType);
|
1725
|
-
}
|
1726
|
-
},
|
1727
|
-
getData : function(id, wyswygMode) {
|
1728
|
-
var g = KE.g[id];
|
1729
|
-
wyswygMode = (wyswygMode === undefined) ? g.wyswygMode : wyswygMode;
|
1730
|
-
if (!wyswygMode) {
|
1731
|
-
this.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, g.newTextarea.value));
|
1732
|
-
}
|
1733
|
-
return this.toData(id, g.iframeDoc.body.innerHTML);
|
1734
|
-
},
|
1735
|
-
getSrcData : function(id) {
|
1736
|
-
var g = KE.g[id];
|
1737
|
-
if (!g.wyswygMode) {
|
1738
|
-
this.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, g.newTextarea.value));
|
1739
|
-
}
|
1740
|
-
return g.iframeDoc.body.innerHTML;
|
1741
|
-
},
|
1742
|
-
getPureData : function(id) {
|
1743
|
-
return this.extractText(this.getData(id));
|
1744
|
-
},
|
1745
|
-
extractText : function(str) {
|
1746
|
-
str = str.replace(/<(?!img|embed).*?>/ig, '');
|
1747
|
-
str = str.replace(/ /ig, ' ');
|
1748
|
-
return str;
|
1749
|
-
},
|
1750
|
-
isEmpty : function(id) {
|
1751
|
-
return this.getPureData(id).replace(/\r\n|\n|\r/, '').replace(/^\s+|\s+$/, '') === '';
|
1752
|
-
},
|
1753
|
-
setData : function(id) {
|
1754
|
-
var g = KE.g[id];
|
1755
|
-
if (g.srcTextarea) g.srcTextarea.value = this.getData(id);
|
1756
|
-
},
|
1757
|
-
focus : function(id) {
|
1758
|
-
var g = KE.g[id];
|
1759
|
-
if (g.wyswygMode) {
|
1760
|
-
g.iframeWin.focus();
|
1761
|
-
} else {
|
1762
|
-
g.newTextarea.focus();
|
1763
|
-
}
|
1764
|
-
},
|
1765
|
-
click : function(id, cmd) {
|
1766
|
-
this.focus(id);
|
1767
|
-
KE.hideMenu(id);
|
1768
|
-
KE.plugin[cmd].click(id);
|
1769
|
-
},
|
1770
|
-
selection : function(id) {
|
1771
|
-
if (!KE.browser.IE || !KE.g[id].keRange) {
|
1772
|
-
this.setSelection(id);
|
1773
|
-
}
|
1774
|
-
},
|
1775
|
-
setSelection : function(id) {
|
1776
|
-
var g = KE.g[id];
|
1777
|
-
var keSel = new KE.selection(g.iframeDoc);
|
1778
|
-
if (!KE.browser.IE || keSel.range.item || keSel.range.parentElement().ownerDocument === g.iframeDoc) {
|
1779
|
-
g.keSel = keSel;
|
1780
|
-
g.keRange = g.keSel.keRange;
|
1781
|
-
g.sel = g.keSel.sel;
|
1782
|
-
g.range = g.keSel.range;
|
1783
|
-
}
|
1784
|
-
},
|
1785
|
-
select : function(id) {
|
1786
|
-
if (KE.browser.IE && KE.g[id].wyswygMode && KE.g[id].range) KE.g[id].range.select();
|
1787
|
-
},
|
1788
|
-
execCommand : function(id, cmd, value) {
|
1789
|
-
KE.util.focus(id);
|
1790
|
-
KE.util.select(id);
|
1791
|
-
try {
|
1792
|
-
KE.g[id].iframeDoc.execCommand(cmd, false, value);
|
1793
|
-
} catch(e) {}
|
1794
|
-
KE.toolbar.updateState(id);
|
1795
|
-
KE.util.execOnchangeHandler(id);
|
1796
|
-
},
|
1797
|
-
innerHtml : function(el, html) {
|
1798
|
-
if (KE.browser.IE) {
|
1799
|
-
el.innerHTML = '<img id="__ke_temp_tag__" width="0" height="0" />' + html;
|
1800
|
-
var temp = KE.$('__ke_temp_tag__', el.ownerDocument);
|
1801
|
-
if (temp) temp.parentNode.removeChild(temp);
|
1802
|
-
} else {
|
1803
|
-
el.innerHTML = html;
|
1804
|
-
}
|
1805
|
-
},
|
1806
|
-
pasteHtml : function(id, html, isStart) {
|
1807
|
-
var g = KE.g[id];
|
1808
|
-
var imgStr = '<img id="__ke_temp_tag__" width="0" height="0" />';
|
1809
|
-
if (isStart) html = imgStr + html;
|
1810
|
-
else html += imgStr;
|
1811
|
-
if (KE.browser.IE) {
|
1812
|
-
if (g.range.item) g.range.item(0).outerHTML = html;
|
1813
|
-
else g.range.pasteHTML(html);
|
1814
|
-
} else {
|
1815
|
-
g.range.deleteContents();
|
1816
|
-
var frag = g.range.createContextualFragment(html);
|
1817
|
-
g.range.insertNode(frag);
|
1818
|
-
}
|
1819
|
-
var node = KE.$('__ke_temp_tag__', g.iframeDoc);
|
1820
|
-
var blank = g.iframeDoc.createTextNode('');
|
1821
|
-
node.parentNode.replaceChild(blank, node);
|
1822
|
-
g.keRange.selectNode(blank);
|
1823
|
-
g.keSel.addRange(g.keRange);
|
1824
|
-
},
|
1825
|
-
insertHtml : function(id, html) {
|
1826
|
-
if (html === '') return;
|
1827
|
-
var g = KE.g[id];
|
1828
|
-
if (!g.wyswygMode) return;
|
1829
|
-
if (!g.range) return;
|
1830
|
-
html = this.execSetHtmlHooks(id, html);
|
1831
|
-
if (KE.browser.IE) {
|
1832
|
-
this.select(id);
|
1833
|
-
if (g.range.item) {
|
1834
|
-
try {
|
1835
|
-
g.range.item(0).outerHTML = html;
|
1836
|
-
} catch(e) {
|
1837
|
-
var el = g.range.item(0);
|
1838
|
-
var parent = el.parentNode;
|
1839
|
-
parent.removeChild(el);
|
1840
|
-
if (parent.nodeName.toLowerCase() != 'body') parent = parent.parentNode;
|
1841
|
-
this.innerHtml(parent, html + parent.innerHTML);
|
1842
|
-
}
|
1843
|
-
} else {
|
1844
|
-
g.range.pasteHTML('<span id="__ke_temp_tag__">\u200B</span>' + html);
|
1845
|
-
var node = KE.$('__ke_temp_tag__', g.iframeDoc);
|
1846
|
-
node.parentNode.removeChild(node);
|
1847
|
-
}
|
1848
|
-
} else if (KE.browser.GECKO) {
|
1849
|
-
this.execCommand(id, 'inserthtml', html);
|
1850
|
-
return;
|
1851
|
-
} else {
|
1852
|
-
this.pasteHtml(id, html);
|
1853
|
-
}
|
1854
|
-
KE.util.execOnchangeHandler(id);
|
1855
|
-
},
|
1856
|
-
setFullHtml : function(id, html) {
|
1857
|
-
var g = KE.g[id];
|
1858
|
-
if (!KE.browser.IE && html === '') html = '<br />';
|
1859
|
-
var html = KE.util.execSetHtmlHooks(id, html);
|
1860
|
-
this.innerHtml(g.iframeDoc.body, html);
|
1861
|
-
if (!g.wyswygMode) g.newTextarea.value = KE.util.getData(id, true);
|
1862
|
-
KE.util.execOnchangeHandler(id);
|
1863
|
-
},
|
1864
|
-
selectImageWebkit : function(id, e, isSelection) {
|
1865
|
-
if (KE.browser.WEBKIT) {
|
1866
|
-
var target = e.srcElement || e.target;
|
1867
|
-
if (target.tagName.toLowerCase() == 'img') {
|
1868
|
-
if (isSelection) KE.util.selection(id);
|
1869
|
-
var range = KE.g[id].keRange;
|
1870
|
-
range.selectNode(target);
|
1871
|
-
KE.g[id].keSel.addRange(range);
|
1872
|
-
}
|
1873
|
-
}
|
1874
|
-
},
|
1875
|
-
addTabEvent : function(id) {
|
1876
|
-
var g = KE.g[id];
|
1877
|
-
KE.event.add(g.iframeDoc, 'keydown', function(e) {
|
1878
|
-
if (e.keyCode == 9) {
|
1879
|
-
if (g.afterTab) g.afterTab(id);
|
1880
|
-
KE.event.stop(e);
|
1881
|
-
return false;
|
1882
|
-
}
|
1883
|
-
}, id);
|
1884
|
-
},
|
1885
|
-
addContextmenuEvent : function(id) {
|
1886
|
-
var g = KE.g[id];
|
1887
|
-
if (g.contextmenuItems.length == 0) return;
|
1888
|
-
if (!g.useContextmenu) return;
|
1889
|
-
KE.event.add(g.iframeDoc, 'contextmenu', function(e){
|
1890
|
-
KE.hideMenu(id);
|
1891
|
-
KE.util.setSelection(id);
|
1892
|
-
KE.util.selectImageWebkit(id, e, false);
|
1893
|
-
var maxWidth = 0;
|
1894
|
-
var items = [];
|
1895
|
-
for (var i = 0, len = g.contextmenuItems.length; i < len; i++) {
|
1896
|
-
var item = g.contextmenuItems[i];
|
1897
|
-
if (item === '-') {
|
1898
|
-
items.push(item);
|
1899
|
-
} else if (item.cond && item.cond(id)) {
|
1900
|
-
items.push(item);
|
1901
|
-
if (item.options) {
|
1902
|
-
var width = parseInt(item.options.width) || 0;
|
1903
|
-
if (width > maxWidth) maxWidth = width;
|
1904
|
-
}
|
1905
|
-
}
|
1906
|
-
prevItem = item;
|
1907
|
-
}
|
1908
|
-
while (items.length > 0 && items[0] === '-') {
|
1909
|
-
items.shift();
|
1910
|
-
}
|
1911
|
-
while (items.length > 0 && items[items.length - 1] === '-') {
|
1912
|
-
items.pop();
|
1913
|
-
}
|
1914
|
-
var prevItem = null;
|
1915
|
-
for (var i = 0, len = items.length; i < len; i++) {
|
1916
|
-
if (items[i] === '-' && prevItem === '-') delete items[i];
|
1917
|
-
prevItem = items[i] || null;
|
1918
|
-
}
|
1919
|
-
if (items.length > 0) {
|
1920
|
-
var menu = new KE.menu({
|
1921
|
-
id : id,
|
1922
|
-
event : e,
|
1923
|
-
type : 'contextmenu',
|
1924
|
-
width : maxWidth
|
1925
|
-
});
|
1926
|
-
for (var i = 0, len = items.length; i < len; i++) {
|
1927
|
-
var item = items[i];
|
1928
|
-
if (!item) continue;
|
1929
|
-
if (item === '-') {
|
1930
|
-
if (i < len - 1) menu.addSeparator();
|
1931
|
-
} else {
|
1932
|
-
menu.add(item.text, (function(item) {
|
1933
|
-
return function() {
|
1934
|
-
item.click(id, menu);
|
1935
|
-
};
|
1936
|
-
})(item), item.options);
|
1937
|
-
}
|
1938
|
-
}
|
1939
|
-
menu.show();
|
1940
|
-
KE.event.stop(e);
|
1941
|
-
return false;
|
1942
|
-
}
|
1943
|
-
return true;
|
1944
|
-
}, id);
|
1945
|
-
},
|
1946
|
-
addNewlineEvent : function(id) {
|
1947
|
-
var g = KE.g[id];
|
1948
|
-
if (KE.browser.IE && g.newlineTag.toLowerCase() != 'br') return;
|
1949
|
-
if (KE.browser.GECKO && KE.browser.VERSION < 3 && g.newlineTag.toLowerCase() != 'p') return;
|
1950
|
-
if (KE.browser.OPERA) return;
|
1951
|
-
KE.event.add(g.iframeDoc, 'keydown', function(e) {
|
1952
|
-
if (e.keyCode != 13 || e.shiftKey || e.ctrlKey || e.altKey) return true;
|
1953
|
-
KE.util.setSelection(id);
|
1954
|
-
var parent = g.keRange.getParentElement();
|
1955
|
-
if (KE.util.inMarquee(parent)) return;
|
1956
|
-
var tagName = parent.tagName.toLowerCase();
|
1957
|
-
if (g.newlineTag.toLowerCase() == 'br') {
|
1958
|
-
if (!KE.util.inArray(tagName, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li'])) {
|
1959
|
-
KE.util.pasteHtml(id, '<br />');
|
1960
|
-
var nextNode = g.keRange.startNode.nextSibling;
|
1961
|
-
if (KE.browser.IE) {
|
1962
|
-
if (!nextNode) KE.util.pasteHtml(id, '<br />', true);
|
1963
|
-
} else if (KE.browser.WEBKIT) {
|
1964
|
-
if (!nextNode) {
|
1965
|
-
KE.util.pasteHtml(id, '<br />', true);
|
1966
|
-
} else {
|
1967
|
-
var range = new KE.range(g.iframeDoc);
|
1968
|
-
range.selectNode(nextNode.parentNode);
|
1969
|
-
range.setStart(nextNode, 0);
|
1970
|
-
if (range.cloneContents().innerHTML.replace(/<(?!img|embed).*?>/ig, '') === '') {
|
1971
|
-
KE.util.pasteHtml(id, '<br />', true);
|
1972
|
-
}
|
1973
|
-
}
|
1974
|
-
}
|
1975
|
-
KE.event.stop(e);
|
1976
|
-
return false;
|
1977
|
-
}
|
1978
|
-
} else {
|
1979
|
-
if (!KE.util.inArray(tagName, ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'div', 'li'])) {
|
1980
|
-
KE.util.execCommand(id, 'formatblock', '<P>');
|
1981
|
-
}
|
1982
|
-
}
|
1983
|
-
return true;
|
1984
|
-
}, id);
|
1985
|
-
}
|
1986
|
-
};
|
1987
|
-
|
1988
|
-
KE.layout = {
|
1989
|
-
hide : function(id) {
|
1990
|
-
var g = KE.g[id];
|
1991
|
-
KE.hideMenu(id);
|
1992
|
-
var stack = g.dialogStack;
|
1993
|
-
while (stack.length > 0) {
|
1994
|
-
var dialog = stack[stack.length - 1];
|
1995
|
-
dialog.hide();
|
1996
|
-
}
|
1997
|
-
g.maskDiv.style.display = 'none';
|
1998
|
-
}
|
1999
|
-
};
|
2000
|
-
|
2001
|
-
KE.hideMenu = function(id) {
|
2002
|
-
var g = KE.g[id];
|
2003
|
-
g.hideDiv.innerHTML = '';
|
2004
|
-
g.hideDiv.style.display = 'none';
|
2005
|
-
};
|
2006
|
-
|
2007
|
-
KE.colorpicker = function(arg) {
|
2008
|
-
var wrapper;
|
2009
|
-
var x = arg.x || 0;
|
2010
|
-
var y = arg.y || 0;
|
2011
|
-
var z = arg.z || 0;
|
2012
|
-
var colors = arg.colors || KE.setting.colorTable;
|
2013
|
-
var doc = arg.doc || document;
|
2014
|
-
var onclick = arg.onclick;
|
2015
|
-
var selectedColor = (arg.selectedColor || '').toLowerCase();
|
2016
|
-
function init() {
|
2017
|
-
wrapper = KE.$$('div');
|
2018
|
-
wrapper.className = 'ke-colorpicker';
|
2019
|
-
wrapper.style.top = y + 'px';
|
2020
|
-
wrapper.style.left = x + 'px';
|
2021
|
-
wrapper.style.zIndex = z;
|
2022
|
-
}
|
2023
|
-
init.call(this);
|
2024
|
-
this.remove = function() {
|
2025
|
-
doc.body.removeChild(wrapper);
|
2026
|
-
};
|
2027
|
-
this.getElement = function() {
|
2028
|
-
function addAttr(cell, color, cls) {
|
2029
|
-
if (selectedColor === color.toLowerCase()) cls += ' ke-colorpicker-cell-selected';
|
2030
|
-
cell.className = cls;
|
2031
|
-
cell.title = color || KE.lang['noColor'];
|
2032
|
-
cell.onmouseover = function() { this.className = cls + ' ke-colorpicker-cell-on'; };
|
2033
|
-
cell.onmouseout = function() { this.className = cls; };
|
2034
|
-
cell.onclick = function() { onclick(color); };
|
2035
|
-
if (color) {
|
2036
|
-
var div = KE.$$('div');
|
2037
|
-
div.className = 'ke-colorpicker-cell-color';
|
2038
|
-
div.style.backgroundColor = color;
|
2039
|
-
cell.appendChild(div);
|
2040
|
-
} else {
|
2041
|
-
cell.innerHTML = KE.lang['noColor'];
|
2042
|
-
}
|
2043
|
-
}
|
2044
|
-
var table = KE.$$('table');
|
2045
|
-
table.className = 'ke-colorpicker-table';
|
2046
|
-
table.cellPadding = 0;
|
2047
|
-
table.cellSpacing = 0;
|
2048
|
-
table.border = 0;
|
2049
|
-
var row = table.insertRow(0),
|
2050
|
-
cell = row.insertCell(0);
|
2051
|
-
cell.colSpan = colors[0].length;
|
2052
|
-
addAttr(cell, '', 'ke-colorpicker-cell-top');
|
2053
|
-
for (var i = 0; i < colors.length; i++) {
|
2054
|
-
var row = table.insertRow(i + 1);
|
2055
|
-
for (var j = 0; j < colors[i].length; j++) {
|
2056
|
-
var color = colors[i][j],
|
2057
|
-
cell = row.insertCell(j);
|
2058
|
-
addAttr(cell, color, 'ke-colorpicker-cell');
|
2059
|
-
}
|
2060
|
-
}
|
2061
|
-
return table;
|
2062
|
-
};
|
2063
|
-
this.create = function() {
|
2064
|
-
wrapper.appendChild(this.getElement());
|
2065
|
-
KE.event.bind(wrapper, 'click', function(e){});
|
2066
|
-
KE.event.bind(wrapper, 'mousedown', function(e){});
|
2067
|
-
doc.body.appendChild(wrapper);
|
2068
|
-
};
|
2069
|
-
};
|
2070
|
-
|
2071
|
-
KE.menu = function(arg){
|
2072
|
-
function getPos(width, height) {
|
2073
|
-
var id = arg.id;
|
2074
|
-
var x = 0;
|
2075
|
-
var y = 0;
|
2076
|
-
if (this.type == 'menu') {
|
2077
|
-
var obj = KE.g[id].toolbarIcon[arg.cmd];
|
2078
|
-
var pos = KE.util.getElementPos(obj[0]);
|
2079
|
-
x = pos.x;
|
2080
|
-
y = pos.y + obj[0].offsetHeight;
|
2081
|
-
} else {
|
2082
|
-
var pos = KE.util.getCoords(arg.event);
|
2083
|
-
var iframePos = KE.util.getElementPos(KE.g[id].iframe);
|
2084
|
-
x = pos.x + iframePos.x;
|
2085
|
-
y = pos.y + iframePos.y + 5;
|
2086
|
-
}
|
2087
|
-
if (width > 0 || height > 0) {
|
2088
|
-
var scrollPos = KE.util.getScrollPos();
|
2089
|
-
var docEl = KE.util.getDocumentElement();
|
2090
|
-
var maxLeft = scrollPos.x + docEl.clientWidth - width - 2;
|
2091
|
-
if (x > maxLeft) x = maxLeft;
|
2092
|
-
}
|
2093
|
-
return {x : x, y : y};
|
2094
|
-
};
|
2095
|
-
function init() {
|
2096
|
-
var width = arg.width;
|
2097
|
-
this.type = (arg.type && arg.type == 'contextmenu') ? arg.type : 'menu';
|
2098
|
-
var div = KE.$$('div');
|
2099
|
-
div.className = 'ke-' + this.type;
|
2100
|
-
div.setAttribute('name', arg.cmd);
|
2101
|
-
var pos = getPos.call(this, 0, 0);
|
2102
|
-
div.style.top = pos.y + 'px';
|
2103
|
-
div.style.left = pos.x + 'px';
|
2104
|
-
if (arg.width) div.style.width = (/^\d+$/.test(width)) ? width + 'px' : width;
|
2105
|
-
KE.event.bind(div, 'click', function(e){}, arg.id);
|
2106
|
-
KE.event.bind(div, 'mousedown', function(e){}, arg.id);
|
2107
|
-
this.div = div;
|
2108
|
-
};
|
2109
|
-
init.call(this);
|
2110
|
-
this.add = function(html, event, options) {
|
2111
|
-
var height, iconHtml, checked = false;
|
2112
|
-
if (options !== undefined) {
|
2113
|
-
height = options.height;
|
2114
|
-
iconHtml = options.iconHtml;
|
2115
|
-
checked = options.checked;
|
2116
|
-
}
|
2117
|
-
var self = this;
|
2118
|
-
var cDiv = KE.$$('div');
|
2119
|
-
cDiv.className = 'ke-' + self.type + '-item';
|
2120
|
-
if (height) cDiv.style.height = height;
|
2121
|
-
var left = KE.$$('div');
|
2122
|
-
left.className = 'ke-' + this.type + '-left';
|
2123
|
-
var center = KE.$$('div');
|
2124
|
-
center.className = 'ke-' + self.type + '-center';
|
2125
|
-
if (height) center.style.height = height;
|
2126
|
-
var right = KE.$$('div');
|
2127
|
-
right.className = 'ke-' + this.type + '-right';
|
2128
|
-
if (height) right.style.lineHeight = height;
|
2129
|
-
cDiv.onmouseover = function() {
|
2130
|
-
this.className = 'ke-' + self.type + '-item ke-' + self.type + '-item-on';
|
2131
|
-
center.className = 'ke-' + self.type + '-center ke-' + self.type + '-center-on';
|
2132
|
-
};
|
2133
|
-
cDiv.onmouseout = function() {
|
2134
|
-
this.className = 'ke-' + self.type + '-item';
|
2135
|
-
center.className = 'ke-' + self.type + '-center';
|
2136
|
-
};
|
2137
|
-
cDiv.onclick = event;
|
2138
|
-
cDiv.appendChild(left);
|
2139
|
-
cDiv.appendChild(center);
|
2140
|
-
cDiv.appendChild(right);
|
2141
|
-
if (checked) {
|
2142
|
-
KE.util.innerHtml(left, '<span class="ke-common-icon ke-common-icon-url ke-icon-checked"></span>');
|
2143
|
-
} else {
|
2144
|
-
if (iconHtml) KE.util.innerHtml(left, iconHtml);
|
2145
|
-
}
|
2146
|
-
KE.util.innerHtml(right, html);
|
2147
|
-
this.append(cDiv);
|
2148
|
-
};
|
2149
|
-
this.addSeparator = function() {
|
2150
|
-
var div = KE.$$('div');
|
2151
|
-
div.className = 'ke-' + this.type + '-separator';
|
2152
|
-
this.append(div);
|
2153
|
-
};
|
2154
|
-
this.append = function(el) {
|
2155
|
-
this.div.appendChild(el);
|
2156
|
-
};
|
2157
|
-
this.insert = function(html) {
|
2158
|
-
KE.util.innerHtml(this.div, html);
|
2159
|
-
};
|
2160
|
-
this.hide = function() {
|
2161
|
-
KE.hideMenu(arg.id);
|
2162
|
-
};
|
2163
|
-
this.show = function() {
|
2164
|
-
this.hide();
|
2165
|
-
var id = arg.id;
|
2166
|
-
KE.g[id].hideDiv.style.display = '';
|
2167
|
-
KE.g[id].hideDiv.appendChild(this.div);
|
2168
|
-
var pos = getPos.call(this, this.div.clientWidth, this.div.clientHeight);
|
2169
|
-
this.div.style.top = pos.y + 'px';
|
2170
|
-
this.div.style.left = pos.x + 'px';
|
2171
|
-
};
|
2172
|
-
this.picker = function(color) {
|
2173
|
-
var colorTable = KE.g[arg.id].colorTable;
|
2174
|
-
var picker = new KE.colorpicker({
|
2175
|
-
colors : colorTable,
|
2176
|
-
onclick : function(color) { KE.plugin[arg.cmd].exec(arg.id, color); },
|
2177
|
-
selectedColor : color
|
2178
|
-
});
|
2179
|
-
this.append(picker.getElement());
|
2180
|
-
this.show();
|
2181
|
-
};
|
2182
|
-
};
|
2183
|
-
|
2184
|
-
KE.button = function(arg) {
|
2185
|
-
arg = arg || {};
|
2186
|
-
doc = arg.doc || document;
|
2187
|
-
var span = KE.$$('span', doc);
|
2188
|
-
span.className = 'ke-button-common ke-button-outer ' + (arg.className || '');
|
2189
|
-
span.title = arg.text;
|
2190
|
-
btn = KE.$$('input', doc);
|
2191
|
-
btn.className = 'ke-button-common ke-button';
|
2192
|
-
btn.type = 'button';
|
2193
|
-
btn.value = arg.text || '';
|
2194
|
-
if (arg.clickFn) {
|
2195
|
-
btn.onclick = arg.clickFn;
|
2196
|
-
}
|
2197
|
-
span.appendChild(btn);
|
2198
|
-
return {span : span, btn : btn};
|
2199
|
-
}
|
2200
|
-
|
2201
|
-
KE.dialog = function(arg){
|
2202
|
-
var self = this;
|
2203
|
-
this.widthMargin = 30;
|
2204
|
-
this.heightMargin = 100;
|
2205
|
-
this.zIndex = 19811214;
|
2206
|
-
this.width = arg.width;
|
2207
|
-
this.height = arg.height;
|
2208
|
-
var minTop, minLeft;
|
2209
|
-
function setLimitNumber() {
|
2210
|
-
var docEl = KE.util.getDocumentElement();
|
2211
|
-
var pos = KE.util.getScrollPos();
|
2212
|
-
minTop = pos.y;
|
2213
|
-
minLeft = pos.x;
|
2214
|
-
}
|
2215
|
-
function init() {
|
2216
|
-
this.beforeHide = arg.beforeHide;
|
2217
|
-
this.afterHide = arg.afterHide;
|
2218
|
-
this.beforeShow = arg.beforeShow;
|
2219
|
-
this.afterShow = arg.afterShow;
|
2220
|
-
this.ondrag = arg.ondrag;
|
2221
|
-
}
|
2222
|
-
init.call(this);
|
2223
|
-
function getPos() {
|
2224
|
-
var width = this.width + this.widthMargin;
|
2225
|
-
var height = this.height + this.heightMargin;
|
2226
|
-
var id = arg.id;
|
2227
|
-
var g = KE.g[id];
|
2228
|
-
var x = 0, y = 0;
|
2229
|
-
if (g.dialogAlignType == 'page') {
|
2230
|
-
var el = KE.util.getDocumentElement();
|
2231
|
-
var scrollPos = KE.util.getScrollPos();
|
2232
|
-
x = Math.round(scrollPos.x + (el.clientWidth - width) / 2);
|
2233
|
-
y = Math.round(scrollPos.y + (el.clientHeight - height) / 2);
|
2234
|
-
} else {
|
2235
|
-
var pos = KE.util.getElementPos(KE.g[id].container);
|
2236
|
-
var el = g.container;
|
2237
|
-
var xDiff = Math.round(el.clientWidth / 2) - Math.round(width / 2);
|
2238
|
-
var yDiff = Math.round(el.clientHeight / 2) - Math.round(height / 2);
|
2239
|
-
x = xDiff < 0 ? pos.x : pos.x + xDiff;
|
2240
|
-
y = yDiff < 0 ? pos.y : pos.y + yDiff;
|
2241
|
-
}
|
2242
|
-
x = x < 0 ? 0 : x;
|
2243
|
-
y = y < 0 ? 0 : y;
|
2244
|
-
return {x : x, y : y};
|
2245
|
-
};
|
2246
|
-
this.resize = function(width, height) {
|
2247
|
-
if (width) this.width = width;
|
2248
|
-
if (height) this.height = height;
|
2249
|
-
this.hide();
|
2250
|
-
this.show();
|
2251
|
-
};
|
2252
|
-
this.hide = function() {
|
2253
|
-
if (this.beforeHide) this.beforeHide(id);
|
2254
|
-
var id = arg.id;
|
2255
|
-
var stack = KE.g[id].dialogStack;
|
2256
|
-
if (stack[stack.length - 1] != this) return;
|
2257
|
-
var dialog = stack.pop();
|
2258
|
-
var iframe = dialog.iframe;
|
2259
|
-
iframe.src = 'javascript:false';
|
2260
|
-
iframe.parentNode.removeChild(iframe);
|
2261
|
-
document.body.removeChild(this.div);
|
2262
|
-
if (stack.length < 1) {
|
2263
|
-
KE.g[id].maskDiv.style.display = 'none';
|
2264
|
-
}
|
2265
|
-
KE.event.remove(window, 'resize', setLimitNumber);
|
2266
|
-
KE.event.remove(window, 'scroll', setLimitNumber);
|
2267
|
-
if (this.afterHide) this.afterHide(id);
|
2268
|
-
KE.util.focus(id);
|
2269
|
-
};
|
2270
|
-
this.show = function() {
|
2271
|
-
if (this.beforeShow) this.beforeShow(id);
|
2272
|
-
var self = this;
|
2273
|
-
var id = arg.id;
|
2274
|
-
var div = KE.$$('div');
|
2275
|
-
div.className = 'ke-dialog';
|
2276
|
-
KE.event.bind(div, 'click', function(e){}, id);
|
2277
|
-
var stack = KE.g[id].dialogStack;
|
2278
|
-
if (stack.length > 0) {
|
2279
|
-
this.zIndex = stack[stack.length - 1].zIndex + 1;
|
2280
|
-
}
|
2281
|
-
div.style.zIndex = this.zIndex;
|
2282
|
-
var pos = getPos.call(this);
|
2283
|
-
div.style.top = pos.y + 'px';
|
2284
|
-
div.style.left = pos.x + 'px';
|
2285
|
-
if (KE.g[id].shadowMode) {
|
2286
|
-
KE.addClass(div, 'ke-dialog-shadow');
|
2287
|
-
} else {
|
2288
|
-
KE.addClass(div, 'ke-dialog-no-shadow');
|
2289
|
-
}
|
2290
|
-
var titleDiv = KE.$$('div');
|
2291
|
-
titleDiv.className = 'ke-dialog-title';
|
2292
|
-
titleDiv.innerHTML = arg.title;
|
2293
|
-
var span = KE.$$('span');
|
2294
|
-
span.className = 'ke-dialog-close';
|
2295
|
-
span.alt = KE.lang['close'];
|
2296
|
-
span.title = KE.lang['close'];
|
2297
|
-
span.onclick = function () {
|
2298
|
-
self.hide();
|
2299
|
-
KE.util.select(id);
|
2300
|
-
};
|
2301
|
-
titleDiv.appendChild(span);
|
2302
|
-
setLimitNumber();
|
2303
|
-
KE.event.add(window, 'resize', setLimitNumber);
|
2304
|
-
KE.event.add(window, 'scroll', setLimitNumber);
|
2305
|
-
KE.util.drag(id, titleDiv, div, function(objTop, objLeft, objWidth, objHeight, top, left) {
|
2306
|
-
if (self.ondrag) self.ondrag(id);
|
2307
|
-
setLimitNumber();
|
2308
|
-
top = objTop + top;
|
2309
|
-
left = objLeft + left;
|
2310
|
-
if (top < minTop) top = minTop;
|
2311
|
-
if (left < minLeft) left = minLeft;
|
2312
|
-
div.style.top = top + 'px';
|
2313
|
-
div.style.left = left + 'px';
|
2314
|
-
});
|
2315
|
-
div.appendChild(titleDiv);
|
2316
|
-
var bodyDiv = KE.$$('div');
|
2317
|
-
bodyDiv.className = 'ke-dialog-body';
|
2318
|
-
var loadingTable = KE.util.createTable();
|
2319
|
-
loadingTable.table.className = 'ke-loading-table';
|
2320
|
-
loadingTable.table.style.width = this.width + 'px';
|
2321
|
-
loadingTable.table.style.height = this.height + 'px';
|
2322
|
-
var loadingImg = KE.$$('span');
|
2323
|
-
loadingImg.className = 'ke-loading-img';
|
2324
|
-
loadingTable.cell.appendChild(loadingImg);
|
2325
|
-
var iframe = (KE.g[id].dialogStack.length == 0 && KE.g[id].dialog) ? KE.g[id].dialog : KE.$$('iframe');
|
2326
|
-
if (arg.useFrameCSS) {
|
2327
|
-
iframe.className = 'ke-dialog-iframe ke-dialog-iframe-border';
|
2328
|
-
} else {
|
2329
|
-
iframe.className = 'ke-dialog-iframe';
|
2330
|
-
}
|
2331
|
-
iframe.setAttribute("frameBorder", "0");
|
2332
|
-
iframe.style.width = this.width + 'px';
|
2333
|
-
iframe.style.height = this.height + 'px';
|
2334
|
-
iframe.style.display = 'none';
|
2335
|
-
bodyDiv.appendChild(iframe);
|
2336
|
-
bodyDiv.appendChild(loadingTable.table);
|
2337
|
-
div.appendChild(bodyDiv);
|
2338
|
-
var bottomDiv = KE.$$('div');
|
2339
|
-
bottomDiv.className = 'ke-dialog-bottom';
|
2340
|
-
var noButton = null;
|
2341
|
-
var yesButton = null;
|
2342
|
-
var previewButton = null;
|
2343
|
-
if (arg.previewButton) {
|
2344
|
-
var btn = KE.button({
|
2345
|
-
className : 'ke-dialog-preview',
|
2346
|
-
text : arg.previewButton,
|
2347
|
-
clickFn : function() {
|
2348
|
-
var stack = KE.g[id].dialogStack;
|
2349
|
-
if (stack[stack.length - 1] == self) {
|
2350
|
-
if (arg.previewClickFn) {
|
2351
|
-
arg.previewClickFn(id);
|
2352
|
-
} else {
|
2353
|
-
KE.plugin[arg.cmd].preview(id);
|
2354
|
-
}
|
2355
|
-
}
|
2356
|
-
}
|
2357
|
-
});
|
2358
|
-
previewButton = btn.btn;
|
2359
|
-
bottomDiv.appendChild(btn.span);
|
2360
|
-
}
|
2361
|
-
if (arg.yesButton) {
|
2362
|
-
var btn = KE.button({
|
2363
|
-
className : 'ke-dialog-yes',
|
2364
|
-
text : arg.yesButton,
|
2365
|
-
clickFn : function() {
|
2366
|
-
var stack = KE.g[id].dialogStack;
|
2367
|
-
if (stack[stack.length - 1] == self) {
|
2368
|
-
if (arg.yesClickFn) {
|
2369
|
-
arg.yesClickFn(id);
|
2370
|
-
} else {
|
2371
|
-
KE.plugin[arg.cmd].exec(id);
|
2372
|
-
}
|
2373
|
-
}
|
2374
|
-
}
|
2375
|
-
});
|
2376
|
-
yesButton = btn.btn;
|
2377
|
-
bottomDiv.appendChild(btn.span);
|
2378
|
-
}
|
2379
|
-
if (arg.noButton) {
|
2380
|
-
var btn = KE.button({
|
2381
|
-
className : 'ke-dialog-no',
|
2382
|
-
text : arg.noButton,
|
2383
|
-
clickFn : function() {
|
2384
|
-
self.hide();
|
2385
|
-
KE.util.select(id);
|
2386
|
-
}
|
2387
|
-
});
|
2388
|
-
noButton = btn.btn;
|
2389
|
-
bottomDiv.appendChild(btn.span);
|
2390
|
-
}
|
2391
|
-
if (arg.yesButton || arg.noButton || arg.previewButton) {
|
2392
|
-
div.appendChild(bottomDiv);
|
2393
|
-
}
|
2394
|
-
document.body.appendChild(div);
|
2395
|
-
KE.event.bind(div, 'mousedown', function(e){}, id);
|
2396
|
-
window.focus();
|
2397
|
-
if (arg.html !== undefined) {
|
2398
|
-
var dialogDoc = KE.util.getIframeDoc(iframe);
|
2399
|
-
var html = KE.util.getFullHtml(id);
|
2400
|
-
dialogDoc.open();
|
2401
|
-
dialogDoc.write(html);
|
2402
|
-
dialogDoc.close();
|
2403
|
-
KE.util.innerHtml(dialogDoc.body, arg.html);
|
2404
|
-
} else if (arg.url !== undefined) {
|
2405
|
-
iframe.src = arg.url;
|
2406
|
-
} else {
|
2407
|
-
var param = 'id=' + escape(id) + '&ver=' + escape(KE.version);
|
2408
|
-
if (arg.file === undefined) {
|
2409
|
-
iframe.src = KE.g[id].pluginsPath + arg.cmd + '.html?' + param;
|
2410
|
-
} else {
|
2411
|
-
param = (/\?/.test(arg.file) ? '&' : '?') + param;
|
2412
|
-
iframe.src = KE.g[id].pluginsPath + arg.file + param;
|
2413
|
-
}
|
2414
|
-
}
|
2415
|
-
KE.g[id].maskDiv.style.width = KE.util.getDocumentWidth() + 'px';
|
2416
|
-
KE.g[id].maskDiv.style.height = KE.util.getDocumentHeight() + 'px';
|
2417
|
-
KE.g[id].maskDiv.style.display = 'block';
|
2418
|
-
this.iframe = iframe;
|
2419
|
-
this.loading = loadingTable.table;
|
2420
|
-
this.noButton = noButton;
|
2421
|
-
this.yesButton = yesButton;
|
2422
|
-
this.previewButton = previewButton;
|
2423
|
-
this.div = div;
|
2424
|
-
KE.g[id].dialogStack.push(this);
|
2425
|
-
KE.g[id].dialog = iframe;
|
2426
|
-
KE.g[id].yesButton = yesButton;
|
2427
|
-
KE.g[id].noButton = noButton;
|
2428
|
-
KE.g[id].previewButton = previewButton;
|
2429
|
-
if (!arg.loadingMode) KE.util.hideLoadingPage(id);
|
2430
|
-
if (this.afterShow) this.afterShow(id);
|
2431
|
-
if (KE.g[id].afterDialogCreate) KE.g[id].afterDialogCreate(id);
|
2432
|
-
};
|
2433
|
-
};
|
2434
|
-
|
2435
|
-
KE.toolbar = {
|
2436
|
-
updateState : function(id) {
|
2437
|
-
var cmdList = [
|
2438
|
-
'justifyleft', 'justifycenter', 'justifyright',
|
2439
|
-
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript',
|
2440
|
-
'bold', 'italic', 'underline', 'strikethrough'
|
2441
|
-
];
|
2442
|
-
for (var i = 0; i < cmdList.length; i++) {
|
2443
|
-
var cmd = cmdList[i];
|
2444
|
-
var state = false;
|
2445
|
-
try {
|
2446
|
-
state = KE.g[id].iframeDoc.queryCommandState(cmd);
|
2447
|
-
} catch(e) {}
|
2448
|
-
if (state) {
|
2449
|
-
KE.toolbar.select(id, cmd);
|
2450
|
-
} else {
|
2451
|
-
KE.toolbar.unselect(id, cmd);
|
2452
|
-
}
|
2453
|
-
}
|
2454
|
-
},
|
2455
|
-
isSelected : function(id, cmd) {
|
2456
|
-
if (KE.plugin[cmd] && KE.plugin[cmd].isSelected) return true;
|
2457
|
-
else return false;
|
2458
|
-
},
|
2459
|
-
select : function(id, cmd) {
|
2460
|
-
if (KE.g[id].toolbarIcon[cmd]) {
|
2461
|
-
var a = KE.g[id].toolbarIcon[cmd][0];
|
2462
|
-
a.className = 'ke-icon ke-icon-selected';
|
2463
|
-
a.onmouseover = null;
|
2464
|
-
a.onmouseout = null;
|
2465
|
-
}
|
2466
|
-
},
|
2467
|
-
unselect : function(id, cmd) {
|
2468
|
-
if (KE.g[id].toolbarIcon[cmd]) {
|
2469
|
-
var a = KE.g[id].toolbarIcon[cmd][0];
|
2470
|
-
a.className = 'ke-icon';
|
2471
|
-
a.onmouseover = function(){ this.className = 'ke-icon ke-icon-on'; };
|
2472
|
-
a.onmouseout = function(){ this.className = 'ke-icon'; };
|
2473
|
-
}
|
2474
|
-
},
|
2475
|
-
_setAttr : function(id, a, cmd) {
|
2476
|
-
a.className = 'ke-icon';
|
2477
|
-
a.href = 'javascript:;';
|
2478
|
-
a.onclick = function(e) {
|
2479
|
-
e = e || window.event;
|
2480
|
-
var div = KE.g[id].hideDiv.firstChild;
|
2481
|
-
if (div && div.getAttribute('name') == cmd) {
|
2482
|
-
KE.hideMenu(id);
|
2483
|
-
} else {
|
2484
|
-
KE.util.click(id, cmd);
|
2485
|
-
}
|
2486
|
-
if (e.preventDefault) e.preventDefault();
|
2487
|
-
if (e.stopPropagation) e.stopPropagation();
|
2488
|
-
if (e.cancelBubble !== undefined) e.cancelBubble = true;
|
2489
|
-
return false;
|
2490
|
-
};
|
2491
|
-
a.onmouseover = function(){ this.className = 'ke-icon ke-icon-on'; };
|
2492
|
-
a.onmouseout = function(){ this.className = 'ke-icon'; };
|
2493
|
-
a.hidefocus = true;
|
2494
|
-
a.title = KE.lang[cmd];
|
2495
|
-
},
|
2496
|
-
able : function(id, arr) {
|
2497
|
-
var self = this;
|
2498
|
-
KE.each(KE.g[id].toolbarIcon, function(cmd, obj) {
|
2499
|
-
if (!KE.util.inArray(cmd, arr)) {
|
2500
|
-
var a = obj[0];
|
2501
|
-
var span = obj[1];
|
2502
|
-
self._setAttr(id, a, cmd);
|
2503
|
-
KE.util.setOpacity(span, 100);
|
2504
|
-
}
|
2505
|
-
});
|
2506
|
-
},
|
2507
|
-
disable : function(id, arr) {
|
2508
|
-
KE.each(KE.g[id].toolbarIcon, function(cmd, obj) {
|
2509
|
-
if (!KE.util.inArray(cmd, arr)) {
|
2510
|
-
var a = obj[0];
|
2511
|
-
var span = obj[1];
|
2512
|
-
a.className = 'ke-icon ke-icon-disabled';
|
2513
|
-
KE.util.setOpacity(span, 50);
|
2514
|
-
a.onclick = null;
|
2515
|
-
a.onmouseover = null;
|
2516
|
-
a.onmouseout = null;
|
2517
|
-
}
|
2518
|
-
});
|
2519
|
-
},
|
2520
|
-
create : function(id) {
|
2521
|
-
var self = this;
|
2522
|
-
var defaultItemHash = KE.util.arrayToHash(KE.setting.items);
|
2523
|
-
KE.g[id].toolbarIcon = [];
|
2524
|
-
var tableObj = KE.util.createTable();
|
2525
|
-
var toolbar = tableObj.table;
|
2526
|
-
toolbar.className = 'ke-toolbar';
|
2527
|
-
toolbar.oncontextmenu = function() { return false; };
|
2528
|
-
toolbar.onmousedown = function() { return false; };
|
2529
|
-
toolbar.onmousemove = function() { return false; };
|
2530
|
-
var toolbarCell = tableObj.cell;
|
2531
|
-
var length = KE.g[id].items.length;
|
2532
|
-
var cellNum = 0;
|
2533
|
-
var row;
|
2534
|
-
KE.g[id].toolbarHeight = KE.g[id].toolbarLineHeight;
|
2535
|
-
for (var i = 0; i < length; i++) {
|
2536
|
-
var cmd = KE.g[id].items[i];
|
2537
|
-
if (i == 0 || cmd == '-') {
|
2538
|
-
var table = KE.$$('table');
|
2539
|
-
table.cellPadding = 0;
|
2540
|
-
table.cellSpacing = 0;
|
2541
|
-
table.border = 0;
|
2542
|
-
table.className = 'ke-toolbar-table';
|
2543
|
-
row = table.insertRow(0);
|
2544
|
-
cellNum = 0;
|
2545
|
-
toolbarCell.appendChild(table);
|
2546
|
-
if (cmd == '-') {
|
2547
|
-
KE.g[id].toolbarHeight += KE.g[id].toolbarLineHeight;
|
2548
|
-
continue;
|
2549
|
-
}
|
2550
|
-
}
|
2551
|
-
var cell = row.insertCell(cellNum);
|
2552
|
-
cell.hideforcus = true;
|
2553
|
-
cellNum++;
|
2554
|
-
if (cmd == '|') {
|
2555
|
-
var div = KE.$$('div');
|
2556
|
-
div.className = 'ke-toolbar-separator';
|
2557
|
-
cell.appendChild(div);
|
2558
|
-
continue;
|
2559
|
-
}
|
2560
|
-
var a = KE.$$('a');
|
2561
|
-
a.tabIndex = -1;
|
2562
|
-
self._setAttr(id, a, cmd);
|
2563
|
-
var span = KE.$$('span');
|
2564
|
-
if (typeof defaultItemHash[cmd] == 'undefined') {
|
2565
|
-
span.className = 'ke-common-icon ke-icon-' + cmd;
|
2566
|
-
} else {
|
2567
|
-
span.className = 'ke-common-icon ke-common-icon-url ke-icon-' + cmd;
|
2568
|
-
}
|
2569
|
-
a.appendChild(span);
|
2570
|
-
cell.appendChild(a);
|
2571
|
-
KE.g[id].toolbarIcon[cmd] = [a, span];
|
2572
|
-
if (KE.toolbar.isSelected(id, cmd)) KE.toolbar.select(id, cmd);
|
2573
|
-
}
|
2574
|
-
return toolbar;
|
2575
|
-
}
|
2576
|
-
};
|
2577
|
-
|
2578
|
-
KE.history = {
|
2579
|
-
addStackData : function(stack, data) {
|
2580
|
-
var prev = '';
|
2581
|
-
if (stack.length > 0) {
|
2582
|
-
prev = stack[stack.length - 1];
|
2583
|
-
}
|
2584
|
-
if (stack.length == 0 || data !== prev) stack.push(data);
|
2585
|
-
},
|
2586
|
-
add : function(id, minChangeSize) {
|
2587
|
-
var g = KE.g[id];
|
2588
|
-
var html = KE.util.getSrcData(id);
|
2589
|
-
if (g.undoStack.length > 0) {
|
2590
|
-
var prevHtml = g.undoStack[g.undoStack.length - 1];
|
2591
|
-
if (Math.abs(html.length - prevHtml.length) < minChangeSize) return;
|
2592
|
-
}
|
2593
|
-
this.addStackData(g.undoStack, html);
|
2594
|
-
},
|
2595
|
-
undo : function(id) {
|
2596
|
-
var g = KE.g[id];
|
2597
|
-
if (g.undoStack.length == 0) return;
|
2598
|
-
var html = KE.util.getSrcData(id);
|
2599
|
-
this.addStackData(g.redoStack, html);
|
2600
|
-
var prevHtml = g.undoStack.pop();
|
2601
|
-
if (html === prevHtml && g.undoStack.length > 0) {
|
2602
|
-
prevHtml = g.undoStack.pop();
|
2603
|
-
}
|
2604
|
-
prevHtml = KE.util.toData(id, prevHtml);
|
2605
|
-
if (g.wyswygMode) {
|
2606
|
-
KE.util.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, prevHtml));
|
2607
|
-
} else {
|
2608
|
-
g.newTextarea.value = prevHtml;
|
2609
|
-
}
|
2610
|
-
},
|
2611
|
-
redo : function(id) {
|
2612
|
-
var g = KE.g[id];
|
2613
|
-
if (g.redoStack.length == 0) return;
|
2614
|
-
var html = KE.util.getSrcData(id);
|
2615
|
-
this.addStackData(g.undoStack, html);
|
2616
|
-
var nextHtml = g.redoStack.pop();
|
2617
|
-
nextHtml = KE.util.toData(id, nextHtml);
|
2618
|
-
if (g.wyswygMode) {
|
2619
|
-
KE.util.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, nextHtml));
|
2620
|
-
} else {
|
2621
|
-
g.newTextarea.value = nextHtml;
|
2622
|
-
}
|
2623
|
-
}
|
2624
|
-
};
|
2625
|
-
|
2626
|
-
KE.readonly = function(id, isReadonly) {
|
2627
|
-
isReadonly = isReadonly == undefined ? true : isReadonly;
|
2628
|
-
var g = KE.g[id];
|
2629
|
-
if (KE.browser.IE) g.iframeDoc.body.contentEditable = isReadonly ? 'false' : 'true';
|
2630
|
-
else g.iframeDoc.designMode = isReadonly ? 'off' : 'on';
|
2631
|
-
};
|
2632
|
-
|
2633
|
-
KE.focus = function(id, position) {
|
2634
|
-
position = (position || '').toLowerCase();
|
2635
|
-
if (!KE.g[id].container) return;
|
2636
|
-
KE.util.focus(id);
|
2637
|
-
if (position === 'end') {
|
2638
|
-
KE.util.setSelection(id);
|
2639
|
-
if (!KE.g[id].sel) return; //issue #120: Sometimes Firefox does not get selection
|
2640
|
-
var sel = KE.g[id].keSel,
|
2641
|
-
range = KE.g[id].keRange,
|
2642
|
-
doc = KE.g[id].iframeDoc;
|
2643
|
-
range.selectTextNode(doc.body);
|
2644
|
-
range.collapse(false);
|
2645
|
-
sel.addRange(range);
|
2646
|
-
}
|
2647
|
-
};
|
2648
|
-
|
2649
|
-
KE.blur = function(id) {
|
2650
|
-
var g = KE.g[id];
|
2651
|
-
if (!g.container) return;
|
2652
|
-
if (KE.browser.IE) {
|
2653
|
-
var input = KE.$$('input');
|
2654
|
-
input.type = 'text';
|
2655
|
-
g.container.appendChild(input);
|
2656
|
-
input.focus();
|
2657
|
-
g.container.removeChild(input);
|
2658
|
-
} else {
|
2659
|
-
g.wyswygMode ? g.iframeWin.blur() : g.newTextarea.blur();
|
2660
|
-
}
|
2661
|
-
};
|
2662
|
-
|
2663
|
-
KE.html = function(id, val) {
|
2664
|
-
if (val === undefined) {
|
2665
|
-
return KE.util.getData(id);
|
2666
|
-
} else {
|
2667
|
-
if (!KE.g[id].container) return;
|
2668
|
-
KE.util.setFullHtml(id, val);
|
2669
|
-
KE.focus(id);
|
2670
|
-
}
|
2671
|
-
};
|
2672
|
-
|
2673
|
-
KE.text = function(id, val) {
|
2674
|
-
if (val === undefined) {
|
2675
|
-
val = KE.html(id);
|
2676
|
-
val = val.replace(/<.*?>/ig, '');
|
2677
|
-
val = val.replace(/ /ig, ' ');
|
2678
|
-
val = KE.util.trim(val);
|
2679
|
-
return val;
|
2680
|
-
} else {
|
2681
|
-
KE.html(id, KE.util.escape(val));
|
2682
|
-
}
|
2683
|
-
};
|
2684
|
-
|
2685
|
-
KE.insertHtml = function(id, val) {
|
2686
|
-
if (!KE.g[id].container) return;
|
2687
|
-
var range = KE.g[id].range;
|
2688
|
-
if (!range) {
|
2689
|
-
KE.appendHtml(id, val);
|
2690
|
-
} else {
|
2691
|
-
KE.focus(id);
|
2692
|
-
KE.util.selection(id);
|
2693
|
-
KE.util.insertHtml(id, val);
|
2694
|
-
}
|
2695
|
-
};
|
2696
|
-
|
2697
|
-
KE.appendHtml = function(id, val) {
|
2698
|
-
KE.html(id, KE.html(id) + val);
|
2699
|
-
};
|
2700
|
-
|
2701
|
-
KE.isEmpty = function(id) {
|
2702
|
-
return KE.util.isEmpty(id);
|
2703
|
-
};
|
2704
|
-
|
2705
|
-
KE.selectedHtml = function(id) {
|
2706
|
-
var range = KE.g[id].range;
|
2707
|
-
if (!range) return '';
|
2708
|
-
var html = '';
|
2709
|
-
if (KE.browser.IE) {
|
2710
|
-
if (range.item) {
|
2711
|
-
html = range.item(0).outerHTML;
|
2712
|
-
} else {
|
2713
|
-
html = range.htmlText;
|
2714
|
-
}
|
2715
|
-
} else {
|
2716
|
-
var temp = KE.$$('div', KE.g[id].iframeDoc);
|
2717
|
-
temp.appendChild(range.cloneContents());
|
2718
|
-
html = temp.innerHTML;
|
2719
|
-
}
|
2720
|
-
return KE.util.toData(id, html);
|
2721
|
-
};
|
2722
|
-
|
2723
|
-
KE.count = function(id, mode) {
|
2724
|
-
mode = (mode || 'html').toLowerCase();
|
2725
|
-
if (mode === 'html') {
|
2726
|
-
return KE.html(id).length;
|
2727
|
-
} else if (mode === 'text') {
|
2728
|
-
var data = KE.util.getPureData(id);
|
2729
|
-
data = data.replace(/<(?:img|embed).*?>/ig, 'K');
|
2730
|
-
data = data.replace(/\r\n|\n|\r/g, '');
|
2731
|
-
data = KE.util.trim(data);
|
2732
|
-
return data.length;
|
2733
|
-
}
|
2734
|
-
return 0;
|
2735
|
-
};
|
2736
|
-
|
2737
|
-
KE.sync = function(id) {
|
2738
|
-
return KE.util.setData(id);
|
2739
|
-
};
|
2740
|
-
|
2741
|
-
KE.remove = function(id, mode) {
|
2742
|
-
var g = KE.g[id];
|
2743
|
-
if (!g.container) return false;
|
2744
|
-
mode = (typeof mode == "undefined") ? 0 : mode;
|
2745
|
-
KE.util.setData(id);
|
2746
|
-
var container = g.container;
|
2747
|
-
var eventStack = g.eventStack;
|
2748
|
-
for (var i = 0, len = eventStack.length; i < len; i++) {
|
2749
|
-
var item = eventStack[i];
|
2750
|
-
if (item) KE.event.remove(item.el, item.type, item.fn, id);
|
2751
|
-
}
|
2752
|
-
g.iframeDoc.src = 'javascript:false';
|
2753
|
-
g.iframe.parentNode.removeChild(g.iframe);
|
2754
|
-
if (mode == 1) {
|
2755
|
-
document.body.removeChild(container);
|
2756
|
-
} else {
|
2757
|
-
var srcTextarea = g.srcTextarea;
|
2758
|
-
srcTextarea.parentNode.removeChild(container);
|
2759
|
-
if (mode == 0) srcTextarea.style.display = '';
|
2760
|
-
}
|
2761
|
-
document.body.removeChild(g.hideDiv);
|
2762
|
-
document.body.removeChild(g.maskDiv);
|
2763
|
-
g.container = null;
|
2764
|
-
g.dialogStack = [];
|
2765
|
-
g.contextmenuItems = [];
|
2766
|
-
g.getHtmlHooks = [];
|
2767
|
-
g.setHtmlHooks = [];
|
2768
|
-
g.onchangeHandlerStack = [];
|
2769
|
-
g.eventStack = [];
|
2770
|
-
};
|
2771
|
-
|
2772
|
-
KE.create = function(id, mode) {
|
2773
|
-
if (KE.g[id].beforeCreate) KE.g[id].beforeCreate(id);
|
2774
|
-
if (KE.browser.IE && KE.browser.VERSION < 7) try { document.execCommand('BackgroundImageCache', false, true); }catch(e){}
|
2775
|
-
var srcTextarea = KE.$(id) || document.getElementsByName(id)[0];
|
2776
|
-
mode = (typeof mode == "undefined") ? 0 : mode;
|
2777
|
-
if (mode == 0 && KE.g[id].container) return;
|
2778
|
-
var width = KE.g[id].width || srcTextarea.style.width || srcTextarea.offsetWidth + 'px';
|
2779
|
-
var height = KE.g[id].height || srcTextarea.style.height || srcTextarea.offsetHeight + 'px';
|
2780
|
-
var tableObj = KE.util.createTable();
|
2781
|
-
var container = tableObj.table;
|
2782
|
-
container.className = 'ke-container';
|
2783
|
-
container.style.width = width;
|
2784
|
-
container.style.height = height;
|
2785
|
-
var toolbarOuter = tableObj.cell;
|
2786
|
-
toolbarOuter.className = 'ke-toolbar-outer';
|
2787
|
-
var textareaOuter = container.insertRow(1).insertCell(0);
|
2788
|
-
textareaOuter.className = 'ke-textarea-outer';
|
2789
|
-
tableObj = KE.util.createTable();
|
2790
|
-
var textareaTable = tableObj.table;
|
2791
|
-
textareaTable.className = 'ke-textarea-table';
|
2792
|
-
var textareaCell = tableObj.cell;
|
2793
|
-
textareaOuter.appendChild(textareaTable);
|
2794
|
-
var bottomOuter = container.insertRow(2).insertCell(0);
|
2795
|
-
bottomOuter.className = 'ke-bottom-outer';
|
2796
|
-
srcTextarea.style.display = 'none';
|
2797
|
-
if (mode == 1) document.body.appendChild(container);
|
2798
|
-
else srcTextarea.parentNode.insertBefore(container, srcTextarea);
|
2799
|
-
var toolbarTable = KE.toolbar.create(id);
|
2800
|
-
toolbarTable.style.height = KE.g[id].toolbarHeight + 'px';
|
2801
|
-
toolbarOuter.appendChild(toolbarTable);
|
2802
|
-
var iframe = KE.g[id].iframe || KE.$$('iframe');
|
2803
|
-
iframe.tabIndex = KE.g[id].tabIndex || srcTextarea.tabIndex;
|
2804
|
-
iframe.className = 'ke-iframe';
|
2805
|
-
iframe.setAttribute("frameBorder", "0");
|
2806
|
-
var newTextarea = KE.$$('textarea');
|
2807
|
-
newTextarea.tabIndex = iframe.tabIndex;
|
2808
|
-
newTextarea.className = 'ke-textarea';
|
2809
|
-
newTextarea.style.display = 'none';
|
2810
|
-
KE.g[id].container = container;
|
2811
|
-
KE.g[id].iframe = iframe;
|
2812
|
-
KE.g[id].newTextarea = newTextarea;
|
2813
|
-
KE.util.resize(id, width, height);
|
2814
|
-
textareaCell.appendChild(iframe);
|
2815
|
-
textareaCell.appendChild(newTextarea);
|
2816
|
-
var bottom = KE.$$('table');
|
2817
|
-
bottom.className = 'ke-bottom';
|
2818
|
-
bottom.cellPadding = 0;
|
2819
|
-
bottom.cellSpacing = 0;
|
2820
|
-
bottom.border = 0;
|
2821
|
-
bottom.style.height = KE.g[id].statusbarHeight + 'px';
|
2822
|
-
var row = bottom.insertRow(0);
|
2823
|
-
var bottomLeft = row.insertCell(0);
|
2824
|
-
bottomLeft.className = 'ke-bottom-left';
|
2825
|
-
var leftImg = KE.$$('span');
|
2826
|
-
leftImg.className = 'ke-bottom-left-img';
|
2827
|
-
if (KE.g[id].config.resizeMode == 0 || mode == 1) {
|
2828
|
-
bottomLeft.style.cursor = 'default';
|
2829
|
-
leftImg.style.visibility = 'hidden';
|
2830
|
-
}
|
2831
|
-
bottomLeft.appendChild(leftImg);
|
2832
|
-
var bottomRight = row.insertCell(1);
|
2833
|
-
bottomRight.className = 'ke-bottom-right';
|
2834
|
-
var rightImg = KE.$$('span');
|
2835
|
-
rightImg.className = 'ke-bottom-right-img';
|
2836
|
-
if (KE.g[id].config.resizeMode == 0 || mode == 1) {
|
2837
|
-
bottomRight.style.cursor = 'default';
|
2838
|
-
rightImg.style.visibility = 'hidden';
|
2839
|
-
} else if (KE.g[id].config.resizeMode == 1) {
|
2840
|
-
bottomRight.style.cursor = 's-resize';
|
2841
|
-
rightImg.style.visibility = 'hidden';
|
2842
|
-
}
|
2843
|
-
bottomRight.appendChild(rightImg);
|
2844
|
-
bottomOuter.appendChild(bottom);
|
2845
|
-
var hideDiv = KE.$$('div');
|
2846
|
-
hideDiv.className = 'ke-reset';
|
2847
|
-
hideDiv.style.display = 'none';
|
2848
|
-
var maskDiv = KE.$$('div');
|
2849
|
-
maskDiv.className = 'ke-mask';
|
2850
|
-
KE.util.setOpacity(maskDiv, 50);
|
2851
|
-
KE.event.bind(maskDiv, 'click', function(e){}, id);
|
2852
|
-
KE.event.bind(maskDiv, 'mousedown', function(e){}, id);
|
2853
|
-
document.body.appendChild(hideDiv);
|
2854
|
-
document.body.appendChild(maskDiv);
|
2855
|
-
KE.util.setDefaultPlugin(id);
|
2856
|
-
var iframeWin = iframe.contentWindow;
|
2857
|
-
var iframeDoc = KE.util.getIframeDoc(iframe);
|
2858
|
-
if (!KE.browser.IE) iframeDoc.designMode = 'on';
|
2859
|
-
var html = KE.util.getFullHtml(id);
|
2860
|
-
iframeDoc.open();
|
2861
|
-
iframeDoc.write(html);
|
2862
|
-
iframeDoc.close();
|
2863
|
-
if (!KE.g[id].wyswygMode) {
|
2864
|
-
newTextarea.value = KE.util.execSetHtmlHooks(id, srcTextarea.value);
|
2865
|
-
newTextarea.style.display = 'block';
|
2866
|
-
iframe.style.display = 'none';
|
2867
|
-
KE.toolbar.disable(id, ['source', 'fullscreen']);
|
2868
|
-
KE.toolbar.select(id, 'source');
|
2869
|
-
}
|
2870
|
-
if (KE.g[id].syncType == 'form') {
|
2871
|
-
var el = srcTextarea;
|
2872
|
-
while ((el = el.parentNode)) {
|
2873
|
-
if (el.nodeName.toLowerCase() == 'form') {
|
2874
|
-
KE.event.add(el, 'submit', function() { KE.sync(id); }, id);
|
2875
|
-
break;
|
2876
|
-
}
|
2877
|
-
}
|
2878
|
-
}
|
2879
|
-
function hideMenu() {
|
2880
|
-
KE.hideMenu(id);
|
2881
|
-
}
|
2882
|
-
function updateToolbar() {
|
2883
|
-
KE.toolbar.updateState(id);
|
2884
|
-
}
|
2885
|
-
if (KE.browser.WEBKIT) {
|
2886
|
-
KE.event.add(iframeDoc, 'click', function(e) {
|
2887
|
-
KE.util.selectImageWebkit(id, e, true);
|
2888
|
-
}, id);
|
2889
|
-
}
|
2890
|
-
if (KE.browser.IE) {
|
2891
|
-
KE.event.add(iframeDoc, 'keydown', function(e) {
|
2892
|
-
if (e.keyCode == 8) {
|
2893
|
-
var range = KE.g[id].range;
|
2894
|
-
if (range.item) {
|
2895
|
-
var item = range.item(0);
|
2896
|
-
item.parentNode.removeChild(item);
|
2897
|
-
KE.util.execOnchangeHandler(id);
|
2898
|
-
KE.event.stop(id);
|
2899
|
-
return false;
|
2900
|
-
}
|
2901
|
-
}
|
2902
|
-
}, id);
|
2903
|
-
}
|
2904
|
-
function afterFocus() {
|
2905
|
-
if (KE.g[id].afterFocus) KE.g[id].afterFocus(id);
|
2906
|
-
}
|
2907
|
-
function afterBlur() {
|
2908
|
-
if (KE.g[id].afterBlur) KE.g[id].afterBlur(id);
|
2909
|
-
}
|
2910
|
-
KE.event.add(iframeDoc, 'mousedown', hideMenu, id);
|
2911
|
-
KE.event.add(iframeDoc, 'click', updateToolbar, id);
|
2912
|
-
KE.event.input(iframeDoc, updateToolbar, id);
|
2913
|
-
KE.event.bind(newTextarea, 'click', hideMenu, id);
|
2914
|
-
KE.event.add(document, 'click', hideMenu, id);
|
2915
|
-
KE.event.add(iframeWin, 'focus', afterFocus);
|
2916
|
-
KE.event.add(newTextarea, 'focus', afterFocus);
|
2917
|
-
KE.event.add(iframeWin, 'blur', afterBlur);
|
2918
|
-
KE.event.add(newTextarea, 'blur', afterBlur);
|
2919
|
-
KE.g[id].toolbarTable = toolbarTable;
|
2920
|
-
KE.g[id].textareaTable = textareaTable;
|
2921
|
-
KE.g[id].srcTextarea = srcTextarea;
|
2922
|
-
KE.g[id].bottom = bottom;
|
2923
|
-
KE.g[id].hideDiv = hideDiv;
|
2924
|
-
KE.g[id].maskDiv = maskDiv;
|
2925
|
-
KE.g[id].iframeWin = iframeWin;
|
2926
|
-
KE.g[id].iframeDoc = iframeDoc;
|
2927
|
-
KE.g[id].width = width;
|
2928
|
-
KE.g[id].height = height;
|
2929
|
-
KE.util.drag(id, bottomRight, container, function(objTop, objLeft, objWidth, objHeight, top, left) {
|
2930
|
-
if (KE.g[id].resizeMode == 2) KE.util.resize(id, (objWidth + left) + 'px', (objHeight + top) + 'px', true);
|
2931
|
-
else if (KE.g[id].resizeMode == 1) KE.util.resize(id, objWidth + 'px', (objHeight + top) + 'px', true, false);
|
2932
|
-
});
|
2933
|
-
KE.util.drag(id, bottomLeft, container, function(objTop, objLeft, objWidth, objHeight, top, left) {
|
2934
|
-
if (KE.g[id].resizeMode > 0) KE.util.resize(id, objWidth + 'px', (objHeight + top) + 'px', true, false);
|
2935
|
-
});
|
2936
|
-
KE.each(KE.plugin, function(cmd, plugin) {
|
2937
|
-
if (plugin.init) plugin.init(id);
|
2938
|
-
});
|
2939
|
-
KE.g[id].getHtmlHooks.push(function(html) {
|
2940
|
-
html = html.replace(/(<[^>]*)kesrc="([^"]+)"([^>]*>)/ig, function(full, start, src, end) {
|
2941
|
-
full = full.replace(/(\s+(?:href|src)=")[^"]+(")/i, '$1' + src + '$2');
|
2942
|
-
full = full.replace(/\s+kesrc="[^"]+"/i, '');
|
2943
|
-
return full;
|
2944
|
-
});
|
2945
|
-
html = html.replace(/(<[^>]+\s)ke-(on\w+="[^"]+"[^>]*>)/ig, function(full, start, end) {
|
2946
|
-
return start + end;
|
2947
|
-
});
|
2948
|
-
return html;
|
2949
|
-
});
|
2950
|
-
KE.g[id].setHtmlHooks.push(function(html) {
|
2951
|
-
html = html.replace(/(<[^>]*)(href|src)="([^"]+)"([^>]*>)/ig, function(full, start, key, src, end) {
|
2952
|
-
if (full.match(/\skesrc="[^"]+"/i)) return full;
|
2953
|
-
full = start + key + '="' + src + '"' + ' kesrc="' + src + '"' + end;
|
2954
|
-
return full;
|
2955
|
-
});
|
2956
|
-
html = html.replace(/(<[^>]+\s)(on\w+="[^"]+"[^>]*>)/ig, function(full, start, end) {
|
2957
|
-
return start + 'ke-' + end;
|
2958
|
-
});
|
2959
|
-
return html;
|
2960
|
-
});
|
2961
|
-
KE.util.addContextmenuEvent(id);
|
2962
|
-
KE.util.addNewlineEvent(id);
|
2963
|
-
KE.util.addTabEvent(id);
|
2964
|
-
function setSelectionHandler() {
|
2965
|
-
KE.util.setSelection(id);
|
2966
|
-
}
|
2967
|
-
KE.event.input(iframeDoc, setSelectionHandler, id);
|
2968
|
-
KE.event.add(iframeDoc, 'mouseup', setSelectionHandler, id);
|
2969
|
-
KE.event.add(document, 'mousedown', setSelectionHandler, id);
|
2970
|
-
KE.onchange(id, function(id) {
|
2971
|
-
if (KE.g[id].autoSetDataMode || KE.g[id].syncType == 'auto') {
|
2972
|
-
KE.util.setData(id);
|
2973
|
-
if (KE.g[id].afterSetData) KE.g[id].afterSetData(id);
|
2974
|
-
}
|
2975
|
-
if (KE.g[id].afterChange) KE.g[id].afterChange(id);
|
2976
|
-
KE.history.add(id, KE.g[id].minChangeSize);
|
2977
|
-
});
|
2978
|
-
if (KE.browser.IE) {
|
2979
|
-
iframeDoc.body.disabled = true;
|
2980
|
-
KE.readonly(id, false);
|
2981
|
-
iframeDoc.body.removeAttribute('disabled');
|
2982
|
-
}
|
2983
|
-
KE.util.setFullHtml(id, srcTextarea.value);
|
2984
|
-
KE.history.add(id, 0);
|
2985
|
-
if (mode > 0) KE.util.focus(id);
|
2986
|
-
if (KE.g[id].afterCreate) KE.g[id].afterCreate(id);
|
2987
|
-
};
|
2988
|
-
|
2989
|
-
KE.onchange = function(id, func) {
|
2990
|
-
var g = KE.g[id];
|
2991
|
-
function handler() {
|
2992
|
-
func(id);
|
2993
|
-
};
|
2994
|
-
g.onchangeHandlerStack.push(handler);
|
2995
|
-
KE.event.input(g.iframeDoc, handler, id);
|
2996
|
-
KE.event.input(g.newTextarea, handler, id);
|
2997
|
-
KE.event.add(g.iframeDoc, 'mouseup', function(e) {
|
2998
|
-
window.setTimeout(function() {
|
2999
|
-
func(id);
|
3000
|
-
}, 0);
|
3001
|
-
}, id);
|
3002
|
-
};
|
3003
|
-
|
3004
|
-
var _needStyle = true;
|
3005
|
-
|
3006
|
-
KE.init = function(args) {
|
3007
|
-
var g = KE.g[args.id] = args;
|
3008
|
-
g.config = {};
|
3009
|
-
g.undoStack = [];
|
3010
|
-
g.redoStack = [];
|
3011
|
-
g.dialogStack = [];
|
3012
|
-
g.contextmenuItems = [];
|
3013
|
-
g.getHtmlHooks = [];
|
3014
|
-
g.setHtmlHooks = [];
|
3015
|
-
g.onchangeHandlerStack = [];
|
3016
|
-
g.eventStack = [];
|
3017
|
-
KE.each(KE.setting, function(key, val) {
|
3018
|
-
g[key] = (typeof args[key] == 'undefined') ? val : args[key];
|
3019
|
-
g.config[key] = g[key];
|
3020
|
-
});
|
3021
|
-
if (g.loadStyleMode && _needStyle) {
|
3022
|
-
KE.util.loadStyle(g.skinsPath + g.skinType + '.css');
|
3023
|
-
_needStyle = false;
|
3024
|
-
}
|
3025
|
-
}
|
3026
|
-
|
3027
|
-
KE.show = function(args) {
|
3028
|
-
KE.init(args);
|
3029
|
-
KE.event.ready(function() { KE.create(args.id); });
|
3030
|
-
};
|
3031
|
-
|
3032
|
-
if (window.KE === undefined) window.KE = KE;
|
3033
|
-
window.KindEditor = KE;
|
3034
|
-
|
3035
|
-
})();
|
3036
|
-
|
3037
|
-
(function (KE, undefined) {
|
3038
|
-
|
3039
|
-
KE.langType = 'en';
|
3040
|
-
|
3041
|
-
KE.lang = {
|
3042
|
-
source : 'Source',
|
3043
|
-
undo : 'Undo(Ctrl+Z)',
|
3044
|
-
redo : 'Redo(Ctrl+Y)',
|
3045
|
-
cut : 'Cut(Ctrl+X)',
|
3046
|
-
copy : 'Copy(Ctrl+C)',
|
3047
|
-
paste : 'Paste(Ctrl+V)',
|
3048
|
-
plainpaste : 'Paste as plain text',
|
3049
|
-
wordpaste : 'Paste from Word',
|
3050
|
-
selectall : 'Select all',
|
3051
|
-
justifyleft : 'Align left',
|
3052
|
-
justifycenter : 'Align center',
|
3053
|
-
justifyright : 'Align right',
|
3054
|
-
justifyfull : 'Align full',
|
3055
|
-
insertorderedlist : 'Ordered list',
|
3056
|
-
insertunorderedlist : 'Unordered list',
|
3057
|
-
indent : 'Increase indent',
|
3058
|
-
outdent : 'Decrease indent',
|
3059
|
-
subscript : 'Subscript',
|
3060
|
-
superscript : 'Superscript',
|
3061
|
-
title : 'Paragraph format',
|
3062
|
-
fontname : 'Font family',
|
3063
|
-
fontsize : 'Font size',
|
3064
|
-
textcolor : 'Text color',
|
3065
|
-
bgcolor : 'Highlight color',
|
3066
|
-
bold : 'Bold(Ctrl+B)',
|
3067
|
-
italic : 'Italic(Ctrl+I)',
|
3068
|
-
underline : 'Underline(Ctrl+U)',
|
3069
|
-
strikethrough : 'Strikethrough',
|
3070
|
-
removeformat : 'Remove format',
|
3071
|
-
image : 'Image',
|
3072
|
-
flash : 'Insert Flash',
|
3073
|
-
media : 'Insert embeded media',
|
3074
|
-
table : 'Insert table',
|
3075
|
-
hr : 'Insert horizontal line',
|
3076
|
-
emoticons : 'Insert emoticon',
|
3077
|
-
link : 'Link',
|
3078
|
-
unlink : 'Unlink',
|
3079
|
-
fullscreen : 'Toggle fullscreen mode',
|
3080
|
-
about : 'About',
|
3081
|
-
print : 'Print',
|
3082
|
-
fileManager : 'File Manager',
|
3083
|
-
advtable : 'Table',
|
3084
|
-
tablecell : 'Cell',
|
3085
|
-
yes : 'OK',
|
3086
|
-
no : 'Cancel',
|
3087
|
-
close : 'Close',
|
3088
|
-
editImage : 'Image properties',
|
3089
|
-
deleteImage : 'Delete image',
|
3090
|
-
editLink : 'Link properties',
|
3091
|
-
deleteLink : 'Unlink',
|
3092
|
-
tableprop : 'Table properties',
|
3093
|
-
tablecellprop : 'Cell properties',
|
3094
|
-
tableinsert : 'Insert table',
|
3095
|
-
tabledelete : 'Delete table',
|
3096
|
-
tablecolinsertleft : 'Insert column left',
|
3097
|
-
tablecolinsertright : 'Insert column right',
|
3098
|
-
tablerowinsertabove : 'Insert row above',
|
3099
|
-
tablerowinsertbelow : 'Insert row below',
|
3100
|
-
tablecoldelete : 'Delete column',
|
3101
|
-
tablerowdelete : 'Delete row',
|
3102
|
-
noColor : 'Default',
|
3103
|
-
invalidImg : "Please type valid URL.\nAllowed file extension: jpg,gif,bmp,png",
|
3104
|
-
invalidMedia : "Please type valid URL.\nAllowed file extension: swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb",
|
3105
|
-
invalidWidth : "The width must be number.",
|
3106
|
-
invalidHeight : "The height must be number.",
|
3107
|
-
invalidBorder : "The border must be number.",
|
3108
|
-
invalidUrl : "Please type valid URL.",
|
3109
|
-
invalidRows : 'Invalid rows.',
|
3110
|
-
invalidCols : 'Invalid columns.',
|
3111
|
-
invalidPadding : 'The padding must be number.',
|
3112
|
-
invalidSpacing : 'The spacing must be number.',
|
3113
|
-
invalidBorder : 'The border width must be number.',
|
3114
|
-
pleaseInput : "Please type content.",
|
3115
|
-
invalidJson : 'Invalid JSON string.',
|
3116
|
-
cutError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+X) instead.',
|
3117
|
-
copyError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+C) instead.',
|
3118
|
-
pasteError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+V) instead.',
|
3119
|
-
accessory : 'Insert file.',
|
3120
|
-
invalidAccessory : 'Only doc,xls,pdf,docx,xlsx,pptx,txt,ppt,rar,zip Files can upload.'
|
3121
|
-
};
|
3122
|
-
|
3123
|
-
var plugins = KE.lang.plugins = {};
|
3124
|
-
|
3125
|
-
plugins.about = {
|
3126
|
-
version : KE.version,
|
3127
|
-
title : 'WYSIWYG Editor'
|
3128
|
-
};
|
3129
|
-
|
3130
|
-
plugins.plainpaste = {
|
3131
|
-
comment : 'Use keyboard shortcut(Ctrl+V) to paste the text into the window.'
|
3132
|
-
};
|
3133
|
-
|
3134
|
-
plugins.wordpaste = {
|
3135
|
-
comment : 'Use keyboard shortcut(Ctrl+V) to paste the text into the window.'
|
3136
|
-
};
|
3137
|
-
|
3138
|
-
plugins.link = {
|
3139
|
-
url : 'Link URL',
|
3140
|
-
linkType : 'Target',
|
3141
|
-
newWindow : 'New window',
|
3142
|
-
selfWindow : 'Same window'
|
3143
|
-
};
|
3144
|
-
|
3145
|
-
plugins.flash = {
|
3146
|
-
url : 'Flash URL',
|
3147
|
-
width : 'Width',
|
3148
|
-
height : 'Height'
|
3149
|
-
};
|
3150
|
-
|
3151
|
-
plugins.media = {
|
3152
|
-
url : 'Media URL',
|
3153
|
-
width : 'Width',
|
3154
|
-
height : 'Height',
|
3155
|
-
autostart : 'Auto start'
|
3156
|
-
};
|
3157
|
-
|
3158
|
-
plugins.image = {
|
3159
|
-
remoteImage : 'Insert URL',
|
3160
|
-
localImage : 'Upload',
|
3161
|
-
remoteUrl : 'URL',
|
3162
|
-
localUrl : 'File',
|
3163
|
-
size : 'Size',
|
3164
|
-
width : 'Width',
|
3165
|
-
height : 'Height',
|
3166
|
-
resetSize : 'Reset dimensions',
|
3167
|
-
align : 'Align',
|
3168
|
-
defaultAlign : 'Default',
|
3169
|
-
leftAlign : 'Left',
|
3170
|
-
rightAlign : 'Right',
|
3171
|
-
imgTitle : 'Title',
|
3172
|
-
viewServer : 'Browse'
|
3173
|
-
};
|
3174
|
-
|
3175
|
-
plugins.file_manager = {
|
3176
|
-
emptyFolder : 'Blank',
|
3177
|
-
moveup : 'Parent folder',
|
3178
|
-
viewType : 'Display: ',
|
3179
|
-
viewImage : 'Thumbnails',
|
3180
|
-
listImage : 'List',
|
3181
|
-
orderType : 'Sorting: ',
|
3182
|
-
fileName : 'By name',
|
3183
|
-
fileSize : 'By size',
|
3184
|
-
fileType : 'By type'
|
3185
|
-
};
|
3186
|
-
|
3187
|
-
plugins.advtable = {
|
3188
|
-
cells : 'Cells',
|
3189
|
-
rows : 'Rows',
|
3190
|
-
cols : 'Columns',
|
3191
|
-
size : 'Size',
|
3192
|
-
width : 'Width',
|
3193
|
-
height : 'Height',
|
3194
|
-
percent : '%',
|
3195
|
-
px : 'px',
|
3196
|
-
space : 'Space',
|
3197
|
-
padding : 'Padding',
|
3198
|
-
spacing : 'Spacing',
|
3199
|
-
align : 'Align',
|
3200
|
-
textAlign : 'Horizontal',
|
3201
|
-
verticalAlign : 'Vertical',
|
3202
|
-
alignDefault : 'Default',
|
3203
|
-
alignLeft : 'Left',
|
3204
|
-
alignCenter : 'Center',
|
3205
|
-
alignRight : 'Right',
|
3206
|
-
alignTop : 'Top',
|
3207
|
-
alignMiddle : 'Middle',
|
3208
|
-
alignBottom : 'Bottom',
|
3209
|
-
alignBaseline : 'Baseline',
|
3210
|
-
border : 'Border',
|
3211
|
-
borderWidth : 'Width',
|
3212
|
-
borderColor : 'Color',
|
3213
|
-
backgroundColor : 'Background'
|
3214
|
-
};
|
3215
|
-
|
3216
|
-
plugins.title = {
|
3217
|
-
h1 : 'Heading 1',
|
3218
|
-
h2 : 'Heading 2',
|
3219
|
-
h3 : 'Heading 3',
|
3220
|
-
h4 : 'Heading 4',
|
3221
|
-
p : 'Normal'
|
3222
|
-
};
|
3223
|
-
|
3224
|
-
plugins.fontname = {
|
3225
|
-
fontName : {
|
3226
|
-
'Arial' : 'Arial',
|
3227
|
-
'Arial Black' : 'Arial Black',
|
3228
|
-
'Comic Sans MS' : 'Comic Sans MS',
|
3229
|
-
'Courier New' : 'Courier New',
|
3230
|
-
'Garamond' : 'Garamond',
|
3231
|
-
'Georgia' : 'Georgia',
|
3232
|
-
'Tahoma' : 'Tahoma',
|
3233
|
-
'Times New Roman' : 'Times New Roman',
|
3234
|
-
'Trebuchet MS' : 'Trebuchet MS',
|
3235
|
-
'Verdana' : 'Verdana'
|
3236
|
-
}
|
3237
|
-
};
|
3238
|
-
|
3239
|
-
})(KindEditor);
|
3240
|
-
|
3241
|
-
(function (KE, undefined) {
|
3242
|
-
|
3243
|
-
KE.plugin.about = {
|
3244
|
-
click : function(id) {
|
3245
|
-
KE.util.selection(id);
|
3246
|
-
var dialog = new KE.dialog({
|
3247
|
-
id : id,
|
3248
|
-
cmd : 'about',
|
3249
|
-
file : 'about.html',
|
3250
|
-
width : 300,
|
3251
|
-
height : 70,
|
3252
|
-
loadingMode : true,
|
3253
|
-
title : KE.lang['about'],
|
3254
|
-
noButton : KE.lang['close']
|
3255
|
-
});
|
3256
|
-
dialog.show();
|
3257
|
-
}
|
3258
|
-
};
|
3259
|
-
|
3260
|
-
KE.plugin.undo = {
|
3261
|
-
init : function(id) {
|
3262
|
-
KE.event.ctrl(KE.g[id].iframeDoc, 'Z', function(e) {
|
3263
|
-
KE.plugin['undo'].click(id);
|
3264
|
-
KE.util.focus(id);
|
3265
|
-
}, id);
|
3266
|
-
KE.event.ctrl(KE.g[id].newTextarea, 'Z', function(e) {
|
3267
|
-
KE.plugin['undo'].click(id);
|
3268
|
-
KE.util.focus(id);
|
3269
|
-
}, id);
|
3270
|
-
},
|
3271
|
-
click : function(id) {
|
3272
|
-
KE.history.undo(id);
|
3273
|
-
KE.util.execOnchangeHandler(id);
|
3274
|
-
}
|
3275
|
-
};
|
3276
|
-
|
3277
|
-
KE.plugin.redo = {
|
3278
|
-
init : function(id) {
|
3279
|
-
KE.event.ctrl(KE.g[id].iframeDoc, 'Y', function(e) {
|
3280
|
-
KE.plugin['redo'].click(id);
|
3281
|
-
KE.util.focus(id);
|
3282
|
-
}, id);
|
3283
|
-
KE.event.ctrl(KE.g[id].newTextarea, 'Y', function(e) {
|
3284
|
-
KE.plugin['redo'].click(id);
|
3285
|
-
KE.util.focus(id);
|
3286
|
-
}, id);
|
3287
|
-
},
|
3288
|
-
click : function(id) {
|
3289
|
-
KE.history.redo(id);
|
3290
|
-
KE.util.execOnchangeHandler(id);
|
3291
|
-
}
|
3292
|
-
};
|
3293
|
-
|
3294
|
-
KE.plugin.cut = {
|
3295
|
-
click : function(id) {
|
3296
|
-
try {
|
3297
|
-
if (!KE.g[id].iframeDoc.queryCommandSupported('cut')) throw 'e';
|
3298
|
-
} catch(e) {
|
3299
|
-
alert(KE.lang.cutError);
|
3300
|
-
return;
|
3301
|
-
}
|
3302
|
-
KE.util.execCommand(id, 'cut', null);
|
3303
|
-
}
|
3304
|
-
};
|
3305
|
-
|
3306
|
-
KE.plugin.copy = {
|
3307
|
-
click : function(id) {
|
3308
|
-
try {
|
3309
|
-
if (!KE.g[id].iframeDoc.queryCommandSupported('copy')) throw 'e';
|
3310
|
-
} catch(e) {
|
3311
|
-
alert(KE.lang.copyError);
|
3312
|
-
return;
|
3313
|
-
}
|
3314
|
-
KE.util.execCommand(id, 'copy', null);
|
3315
|
-
}
|
3316
|
-
};
|
3317
|
-
|
3318
|
-
KE.plugin.paste = {
|
3319
|
-
click : function(id) {
|
3320
|
-
try {
|
3321
|
-
if (!KE.g[id].iframeDoc.queryCommandSupported('paste')) throw 'e';
|
3322
|
-
} catch(e) {
|
3323
|
-
alert(KE.lang.pasteError);
|
3324
|
-
return;
|
3325
|
-
}
|
3326
|
-
KE.util.execCommand(id, 'paste', null);
|
3327
|
-
}
|
3328
|
-
};
|
3329
|
-
|
3330
|
-
KE.plugin.plainpaste = {
|
3331
|
-
click : function(id) {
|
3332
|
-
KE.util.selection(id);
|
3333
|
-
this.dialog = new KE.dialog({
|
3334
|
-
id : id,
|
3335
|
-
cmd : 'plainpaste',
|
3336
|
-
file : 'plainpaste.html',
|
3337
|
-
width : 450,
|
3338
|
-
height : 300,
|
3339
|
-
loadingMode : true,
|
3340
|
-
title : KE.lang['plainpaste'],
|
3341
|
-
yesButton : KE.lang['yes'],
|
3342
|
-
noButton : KE.lang['no']
|
3343
|
-
});
|
3344
|
-
this.dialog.show();
|
3345
|
-
},
|
3346
|
-
exec : function(id) {
|
3347
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3348
|
-
var html = KE.$('textArea', dialogDoc).value;
|
3349
|
-
html = KE.util.escape(html);
|
3350
|
-
html = html.replace(/ /g, ' ');
|
3351
|
-
if (KE.g[id].newlineTag == 'p') {
|
3352
|
-
html = html.replace(/^/, '<p>').replace(/$/, '</p>').replace(/\r\n|\n|\r/g, '</p><p>');
|
3353
|
-
} else {
|
3354
|
-
html = html.replace(/\r\n|\n|\r/g, '<br />$&');
|
3355
|
-
}
|
3356
|
-
KE.util.insertHtml(id, html);
|
3357
|
-
this.dialog.hide();
|
3358
|
-
KE.util.focus(id);
|
3359
|
-
}
|
3360
|
-
};
|
3361
|
-
|
3362
|
-
KE.plugin.wordpaste = {
|
3363
|
-
click : function(id) {
|
3364
|
-
KE.util.selection(id);
|
3365
|
-
this.dialog = new KE.dialog({
|
3366
|
-
id : id,
|
3367
|
-
cmd : 'wordpaste',
|
3368
|
-
file : 'wordpaste.html',
|
3369
|
-
width : 450,
|
3370
|
-
height : 300,
|
3371
|
-
loadingMode : true,
|
3372
|
-
title : KE.lang['wordpaste'],
|
3373
|
-
yesButton : KE.lang['yes'],
|
3374
|
-
noButton : KE.lang['no']
|
3375
|
-
});
|
3376
|
-
this.dialog.show();
|
3377
|
-
},
|
3378
|
-
exec : function(id) {
|
3379
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3380
|
-
var wordIframe = KE.$('wordIframe', dialogDoc);
|
3381
|
-
var str = KE.util.getIframeDoc(wordIframe).body.innerHTML;
|
3382
|
-
str = str.replace(/<meta(\n|.)*?>/ig, "");
|
3383
|
-
str = str.replace(/<!(\n|.)*?>/ig, "");
|
3384
|
-
str = str.replace(/<style[^>]*>(\n|.)*?<\/style>/ig, "");
|
3385
|
-
str = str.replace(/<script[^>]*>(\n|.)*?<\/script>/ig, "");
|
3386
|
-
str = str.replace(/<w:[^>]+>(\n|.)*?<\/w:[^>]+>/ig, "");
|
3387
|
-
str = str.replace(/<xml>(\n|.)*?<\/xml>/ig, "");
|
3388
|
-
str = str.replace(/\r\n|\n|\r/ig, "");
|
3389
|
-
str = KE.util.execGetHtmlHooks(id, str);
|
3390
|
-
str = KE.format.getHtml(str, KE.g[id].htmlTags, KE.g[id].urlType);
|
3391
|
-
KE.util.insertHtml(id, str);
|
3392
|
-
this.dialog.hide();
|
3393
|
-
KE.util.focus(id);
|
3394
|
-
}
|
3395
|
-
};
|
3396
|
-
|
3397
|
-
KE.plugin.fullscreen = {
|
3398
|
-
click : function(id) {
|
3399
|
-
var g = KE.g[id];
|
3400
|
-
var self = this;
|
3401
|
-
var resetSize = function() {
|
3402
|
-
var el = KE.util.getDocumentElement();
|
3403
|
-
g.width = el.clientWidth + 'px';
|
3404
|
-
g.height = el.clientHeight + 'px';
|
3405
|
-
};
|
3406
|
-
var windowSize = '';
|
3407
|
-
var resizeListener = function() {
|
3408
|
-
if (!self.isSelected) return;
|
3409
|
-
var el = KE.util.getDocumentElement();
|
3410
|
-
var size = [el.clientWidth, el.clientHeight].join('');
|
3411
|
-
if (windowSize != size) {
|
3412
|
-
windowSize = size;
|
3413
|
-
resetSize();
|
3414
|
-
KE.util.resize(id, g.width, g.height);
|
3415
|
-
}
|
3416
|
-
}
|
3417
|
-
if (this.isSelected) {
|
3418
|
-
this.isSelected = false;
|
3419
|
-
KE.util.setData(id);
|
3420
|
-
KE.remove(id, 1);
|
3421
|
-
g.width = this.width;
|
3422
|
-
g.height = this.height;
|
3423
|
-
KE.create(id, 2);
|
3424
|
-
document.body.parentNode.style.overflow = 'auto';
|
3425
|
-
KE.event.remove(window, 'resize', resizeListener);
|
3426
|
-
g.resizeMode = g.config.resizeMode;
|
3427
|
-
KE.toolbar.unselect(id, "fullscreen");
|
3428
|
-
} else {
|
3429
|
-
this.isSelected = true;
|
3430
|
-
this.width = g.container.style.width;
|
3431
|
-
this.height = g.container.style.height;
|
3432
|
-
KE.util.setData(id);
|
3433
|
-
KE.remove(id, 2);
|
3434
|
-
document.body.parentNode.style.overflow = 'hidden';
|
3435
|
-
resetSize();
|
3436
|
-
KE.create(id, 1);
|
3437
|
-
var pos = KE.util.getScrollPos();
|
3438
|
-
var div = g.container;
|
3439
|
-
div.style.position = 'absolute';
|
3440
|
-
div.style.left = pos.x + 'px';
|
3441
|
-
div.style.top = pos.y + 'px';
|
3442
|
-
div.style.zIndex = 19811211;
|
3443
|
-
KE.event.add(window, 'resize', resizeListener);
|
3444
|
-
g.resizeMode = 0;
|
3445
|
-
KE.toolbar.select(id, "fullscreen");
|
3446
|
-
}
|
3447
|
-
}
|
3448
|
-
};
|
3449
|
-
|
3450
|
-
KE.plugin.bgcolor = {
|
3451
|
-
click : function(id) {
|
3452
|
-
KE.util.selection(id);
|
3453
|
-
var color = KE.queryCommandValue(KE.g[id].iframeDoc, 'bgcolor');
|
3454
|
-
this.menu = new KE.menu({
|
3455
|
-
id : id,
|
3456
|
-
cmd : 'bgcolor'
|
3457
|
-
});
|
3458
|
-
this.menu.picker(color);
|
3459
|
-
},
|
3460
|
-
exec : function(id, value) {
|
3461
|
-
var cmd = new KE.cmd(id);
|
3462
|
-
if (value == '') {
|
3463
|
-
cmd.remove({
|
3464
|
-
'span' : ['.background-color']
|
3465
|
-
});
|
3466
|
-
} else {
|
3467
|
-
cmd.wrap('span', [{'.background-color': value}]);
|
3468
|
-
}
|
3469
|
-
KE.util.execOnchangeHandler(id);
|
3470
|
-
this.menu.hide();
|
3471
|
-
KE.util.focus(id);
|
3472
|
-
}
|
3473
|
-
};
|
3474
|
-
|
3475
|
-
KE.plugin.fontname = {
|
3476
|
-
click : function(id) {
|
3477
|
-
var fontName = KE.lang.plugins.fontname.fontName;
|
3478
|
-
var cmd = 'fontname';
|
3479
|
-
KE.util.selection(id);
|
3480
|
-
var menu = new KE.menu({
|
3481
|
-
id : id,
|
3482
|
-
cmd : cmd,
|
3483
|
-
width : 150
|
3484
|
-
});
|
3485
|
-
var font = KE.queryCommandValue(KE.g[id].iframeDoc, cmd);
|
3486
|
-
KE.each(fontName, function(key, value) {
|
3487
|
-
var html = '<span class="ke-reset" style="font-family: ' + key + ';">' + value + '</span>';
|
3488
|
-
menu.add(
|
3489
|
-
html,
|
3490
|
-
function() { KE.plugin[cmd].exec(id, key); },
|
3491
|
-
{ checked : (font === key.toLowerCase() || font === value.toLowerCase()) }
|
3492
|
-
);
|
3493
|
-
});
|
3494
|
-
menu.show();
|
3495
|
-
this.menu = menu;
|
3496
|
-
},
|
3497
|
-
exec : function(id, value) {
|
3498
|
-
var cmd = new KE.cmd(id);
|
3499
|
-
cmd.wrap('span', [{'.font-family': value}]);
|
3500
|
-
KE.util.execOnchangeHandler(id);
|
3501
|
-
this.menu.hide();
|
3502
|
-
KE.util.focus(id);
|
3503
|
-
}
|
3504
|
-
};
|
3505
|
-
|
3506
|
-
KE.plugin.fontsize = {
|
3507
|
-
click : function(id) {
|
3508
|
-
var fontSize = ['9px', '10px', '12px', '14px', '16px', '18px', '24px', '32px'];
|
3509
|
-
var cmd = 'fontsize';
|
3510
|
-
KE.util.selection(id);
|
3511
|
-
var size = KE.queryCommandValue(KE.g[id].iframeDoc, 'fontsize');
|
3512
|
-
var menu = new KE.menu({
|
3513
|
-
id : id,
|
3514
|
-
cmd : cmd,
|
3515
|
-
width : 120
|
3516
|
-
});
|
3517
|
-
for (var i = 0, len = fontSize.length; i < len; i++) {
|
3518
|
-
var value = fontSize[i];
|
3519
|
-
var html = '<span class="ke-reset" style="font-size: ' + value + ';">' + value + '</span>';
|
3520
|
-
menu.add(
|
3521
|
-
html,
|
3522
|
-
(function(value) {
|
3523
|
-
return function() {
|
3524
|
-
KE.plugin[cmd].exec(id, value);
|
3525
|
-
};
|
3526
|
-
})(value),
|
3527
|
-
{
|
3528
|
-
height : (parseInt(value) + 12) + 'px',
|
3529
|
-
checked : (size === value)
|
3530
|
-
}
|
3531
|
-
);
|
3532
|
-
}
|
3533
|
-
menu.show();
|
3534
|
-
this.menu = menu;
|
3535
|
-
},
|
3536
|
-
exec : function(id, value) {
|
3537
|
-
var cmd = new KE.cmd(id);
|
3538
|
-
cmd.wrap('span', [{'.font-size': value}]);
|
3539
|
-
KE.util.execOnchangeHandler(id);
|
3540
|
-
this.menu.hide();
|
3541
|
-
KE.util.focus(id);
|
3542
|
-
}
|
3543
|
-
};
|
3544
|
-
|
3545
|
-
KE.plugin.hr = {
|
3546
|
-
click : function(id) {
|
3547
|
-
KE.util.selection(id);
|
3548
|
-
KE.util.insertHtml(id, '<hr />');
|
3549
|
-
KE.util.focus(id);
|
3550
|
-
}
|
3551
|
-
};
|
3552
|
-
|
3553
|
-
KE.plugin.print = {
|
3554
|
-
click : function(id) {
|
3555
|
-
KE.util.selection(id);
|
3556
|
-
KE.g[id].iframeWin.print();
|
3557
|
-
}
|
3558
|
-
};
|
3559
|
-
|
3560
|
-
KE.plugin.removeformat = {
|
3561
|
-
click : function(id) {
|
3562
|
-
KE.util.selection(id);
|
3563
|
-
var cmd = new KE.cmd(id);
|
3564
|
-
var tags = {
|
3565
|
-
'*' : ['class', 'style']
|
3566
|
-
};
|
3567
|
-
for (var i = 0, len = KE.g[id].inlineTags.length; i < len; i++) {
|
3568
|
-
tags[KE.g[id].inlineTags[i]] = ['*'];
|
3569
|
-
}
|
3570
|
-
cmd.remove(tags);
|
3571
|
-
KE.util.execOnchangeHandler(id);
|
3572
|
-
KE.toolbar.updateState(id);
|
3573
|
-
KE.util.focus(id);
|
3574
|
-
}
|
3575
|
-
};
|
3576
|
-
|
3577
|
-
KE.plugin.source = {
|
3578
|
-
click : function(id) {
|
3579
|
-
var g = KE.g[id];
|
3580
|
-
if (!g.wyswygMode) {
|
3581
|
-
KE.util.setFullHtml(id, g.newTextarea.value);
|
3582
|
-
g.iframe.style.display = 'block';
|
3583
|
-
g.newTextarea.style.display = 'none';
|
3584
|
-
KE.toolbar.able(id, ['source', 'fullscreen']);
|
3585
|
-
g.wyswygMode = true;
|
3586
|
-
this.isSelected = false;
|
3587
|
-
KE.toolbar.unselect(id, "source");
|
3588
|
-
} else {
|
3589
|
-
KE.hideMenu(id);
|
3590
|
-
g.newTextarea.value = KE.util.getData(id);
|
3591
|
-
g.iframe.style.display = 'none';
|
3592
|
-
g.newTextarea.style.display = 'block';
|
3593
|
-
KE.toolbar.disable(id, ['source', 'fullscreen']);
|
3594
|
-
g.wyswygMode = false;
|
3595
|
-
this.isSelected = true;
|
3596
|
-
KE.toolbar.select(id, "source");
|
3597
|
-
}
|
3598
|
-
KE.util.focus(id);
|
3599
|
-
}
|
3600
|
-
};
|
3601
|
-
|
3602
|
-
KE.plugin.textcolor = {
|
3603
|
-
click : function(id) {
|
3604
|
-
KE.util.selection(id);
|
3605
|
-
var color = KE.queryCommandValue(KE.g[id].iframeDoc, 'textcolor');
|
3606
|
-
this.menu = new KE.menu({
|
3607
|
-
id : id,
|
3608
|
-
cmd : 'textcolor'
|
3609
|
-
});
|
3610
|
-
this.menu.picker(color);
|
3611
|
-
},
|
3612
|
-
exec : function(id, value) {
|
3613
|
-
var cmd = new KE.cmd(id);
|
3614
|
-
if (value == '') {
|
3615
|
-
cmd.remove({
|
3616
|
-
'span' : ['.color'],
|
3617
|
-
'font' : ['color']
|
3618
|
-
});
|
3619
|
-
} else {
|
3620
|
-
cmd.wrap('span', [{'.color': value}]);
|
3621
|
-
}
|
3622
|
-
KE.util.execOnchangeHandler(id);
|
3623
|
-
this.menu.hide();
|
3624
|
-
KE.util.focus(id);
|
3625
|
-
}
|
3626
|
-
};
|
3627
|
-
|
3628
|
-
KE.plugin.title = {
|
3629
|
-
click : function(id) {
|
3630
|
-
var lang = KE.lang.plugins.title;
|
3631
|
-
var title = {
|
3632
|
-
'H1' : lang.h1,
|
3633
|
-
'H2' : lang.h2,
|
3634
|
-
'H3' : lang.h3,
|
3635
|
-
'H4' : lang.h4,
|
3636
|
-
'P' : lang.p
|
3637
|
-
};
|
3638
|
-
var sizeHash = {
|
3639
|
-
'H1' : 28,
|
3640
|
-
'H2' : 24,
|
3641
|
-
'H3' : 18,
|
3642
|
-
'H4' : 14,
|
3643
|
-
'P' : 12
|
3644
|
-
};
|
3645
|
-
var cmd = 'title';
|
3646
|
-
KE.util.selection(id);
|
3647
|
-
var block = KE.queryCommandValue(KE.g[id].iframeDoc, 'formatblock');
|
3648
|
-
var menu = new KE.menu({
|
3649
|
-
id : id,
|
3650
|
-
cmd : cmd,
|
3651
|
-
width : (KE.langType == 'en' ? 200 : 150)
|
3652
|
-
});
|
3653
|
-
KE.each(title, function(key, value) {
|
3654
|
-
var style = 'font-size:' + sizeHash[key] + 'px;'
|
3655
|
-
if (key !== 'P') style += 'font-weight:bold;';
|
3656
|
-
var html = '<span class="ke-reset" style="' + style + '">' + value + '</span>';
|
3657
|
-
menu.add(html, function() {
|
3658
|
-
KE.plugin[cmd].exec(id, '<' + key + '>'); },
|
3659
|
-
{
|
3660
|
-
height : (sizeHash[key] + 12) + 'px',
|
3661
|
-
checked : (block === key.toLowerCase() || block === value.toLowerCase() )
|
3662
|
-
}
|
3663
|
-
);
|
3664
|
-
});
|
3665
|
-
menu.show();
|
3666
|
-
this.menu = menu;
|
3667
|
-
},
|
3668
|
-
exec : function(id, value) {
|
3669
|
-
KE.util.select(id);
|
3670
|
-
KE.util.execCommand(id, 'formatblock', value);
|
3671
|
-
this.menu.hide();
|
3672
|
-
KE.util.focus(id);
|
3673
|
-
}
|
3674
|
-
};
|
3675
|
-
|
3676
|
-
KE.plugin.emoticons = {
|
3677
|
-
click : function(id) {
|
3678
|
-
var self = this,
|
3679
|
-
cmd = 'emoticons',
|
3680
|
-
rows = 5,
|
3681
|
-
cols = 9,
|
3682
|
-
total = 135,
|
3683
|
-
startNum = 0,
|
3684
|
-
cells = rows * cols,
|
3685
|
-
pages = Math.ceil(total / cells),
|
3686
|
-
colsHalf = Math.floor(cols / 2),
|
3687
|
-
g = KE.g[id],
|
3688
|
-
path = g.pluginsPath + 'emoticons/',
|
3689
|
-
allowPreview = (g.allowPreviewEmoticons === undefined) ? true : g.allowPreviewEmoticons;
|
3690
|
-
KE.util.selection(id);
|
3691
|
-
var wrapperDiv = KE.$$('div');
|
3692
|
-
wrapperDiv.className = 'ke-plugin-emoticons-wrapper';
|
3693
|
-
var previewDiv, previewImg;
|
3694
|
-
if (allowPreview) {
|
3695
|
-
previewDiv = KE.$$('div');
|
3696
|
-
previewDiv.className = 'ke-plugin-emoticons-preview';
|
3697
|
-
previewDiv.style.right = 0;
|
3698
|
-
var previewImg = KE.$$('img');
|
3699
|
-
previewImg.className = 'ke-reset';
|
3700
|
-
previewImg.src = path + '0.gif';
|
3701
|
-
previewImg.border = 0;
|
3702
|
-
previewDiv.appendChild(previewImg);
|
3703
|
-
wrapperDiv.appendChild(previewDiv);
|
3704
|
-
}
|
3705
|
-
function createEmoticonsTable(pageNum) {
|
3706
|
-
var table = KE.$$('table');
|
3707
|
-
if (previewDiv) {
|
3708
|
-
table.onmouseover = function() { previewDiv.style.display = 'block'; };
|
3709
|
-
table.onmouseout = function() { previewDiv.style.display = 'none'; };
|
3710
|
-
}
|
3711
|
-
table.className = 'ke-plugin-emoticons-table';
|
3712
|
-
table.cellPadding = 0;
|
3713
|
-
table.cellSpacing = 0;
|
3714
|
-
table.border = 0;
|
3715
|
-
var num = (pageNum - 1) * cells + startNum;
|
3716
|
-
for (var i = 0; i < rows; i++) {
|
3717
|
-
var row = table.insertRow(i);
|
3718
|
-
for (var j = 0; j < cols; j++) {
|
3719
|
-
var cell = row.insertCell(j);
|
3720
|
-
cell.className = 'ke-plugin-emoticons-cell';
|
3721
|
-
if (previewDiv) {
|
3722
|
-
cell.onmouseover = (function(j, num) {
|
3723
|
-
return function() {
|
3724
|
-
if (j > colsHalf) {
|
3725
|
-
previewDiv.style.left = 0;
|
3726
|
-
previewDiv.style.right = '';
|
3727
|
-
} else {
|
3728
|
-
previewDiv.style.left = '';
|
3729
|
-
previewDiv.style.right = 0;
|
3730
|
-
}
|
3731
|
-
previewImg.src = path + num + '.gif';;
|
3732
|
-
this.className = 'ke-plugin-emoticons-cell ke-plugin-emoticons-cell-on';
|
3733
|
-
};
|
3734
|
-
})(j, num);
|
3735
|
-
} else {
|
3736
|
-
cell.onmouseover = function() {
|
3737
|
-
this.className = 'ke-plugin-emoticons-cell ke-plugin-emoticons-cell-on';
|
3738
|
-
};
|
3739
|
-
}
|
3740
|
-
cell.onmouseout = function() { this.className = 'ke-plugin-emoticons-cell'; };
|
3741
|
-
cell.onclick = (function(num) {
|
3742
|
-
return function() {
|
3743
|
-
self.exec(id, num);
|
3744
|
-
return false;
|
3745
|
-
};
|
3746
|
-
})(num);
|
3747
|
-
var span = KE.$$('span');
|
3748
|
-
span.className = 'ke-plugin-emoticons-img';
|
3749
|
-
span.style.backgroundPosition = '-' + (24 * num) + 'px 0px';
|
3750
|
-
cell.appendChild(span);
|
3751
|
-
num++;
|
3752
|
-
}
|
3753
|
-
}
|
3754
|
-
return table;
|
3755
|
-
}
|
3756
|
-
var table = createEmoticonsTable(1);
|
3757
|
-
wrapperDiv.appendChild(table);
|
3758
|
-
var pageDiv = KE.$$('div');
|
3759
|
-
pageDiv.className = 'ke-plugin-emoticons-page';
|
3760
|
-
wrapperDiv.appendChild(pageDiv);
|
3761
|
-
function createPageTable(currentPageNum) {
|
3762
|
-
for (var pageNum = 1; pageNum <= pages; pageNum++) {
|
3763
|
-
if (currentPageNum !== pageNum) {
|
3764
|
-
var a = KE.$$('a');
|
3765
|
-
a.href = 'javascript:;';
|
3766
|
-
a.innerHTML = '[' + pageNum + ']';
|
3767
|
-
a.onclick = (function(pageNum) {
|
3768
|
-
return function() {
|
3769
|
-
wrapperDiv.removeChild(table);
|
3770
|
-
var newTable = createEmoticonsTable(pageNum);
|
3771
|
-
wrapperDiv.insertBefore(newTable, pageDiv);
|
3772
|
-
table = newTable;
|
3773
|
-
pageDiv.innerHTML = '';
|
3774
|
-
createPageTable(pageNum);
|
3775
|
-
return false;
|
3776
|
-
};
|
3777
|
-
})(pageNum);
|
3778
|
-
pageDiv.appendChild(a);
|
3779
|
-
} else {
|
3780
|
-
pageDiv.appendChild(document.createTextNode('[' + pageNum + ']'));
|
3781
|
-
}
|
3782
|
-
pageDiv.appendChild(document.createTextNode(' '));
|
3783
|
-
}
|
3784
|
-
}
|
3785
|
-
createPageTable(1);
|
3786
|
-
var menu = new KE.menu({
|
3787
|
-
id : id,
|
3788
|
-
cmd : cmd
|
3789
|
-
});
|
3790
|
-
menu.append(wrapperDiv);
|
3791
|
-
menu.show();
|
3792
|
-
this.menu = menu;
|
3793
|
-
},
|
3794
|
-
exec : function(id, num) {
|
3795
|
-
var src = KE.g[id].pluginsPath + 'emoticons/' + num + '.gif';
|
3796
|
-
var html = '<img src="' + src + '" kesrc="' + src + '" alt="" />';
|
3797
|
-
KE.util.insertHtml(id, html);
|
3798
|
-
this.menu.hide();
|
3799
|
-
KE.util.focus(id);
|
3800
|
-
}
|
3801
|
-
};
|
3802
|
-
|
3803
|
-
KE.plugin.flash = {
|
3804
|
-
init : function(id) {
|
3805
|
-
var self = this;
|
3806
|
-
KE.g[id].getHtmlHooks.push(function(html) {
|
3807
|
-
return html.replace(/<img[^>]*class="?ke-flash"?[^>]*>/ig, function(imgStr) {
|
3808
|
-
var width = imgStr.match(/style="[^"]*;?\s*width:\s*(\d+)/i) ? RegExp.$1 : 0;
|
3809
|
-
var height = imgStr.match(/style="[^"]*;?\s*height:\s*(\d+)/i) ? RegExp.$1 : 0;
|
3810
|
-
width = width || (imgStr.match(/width="([^"]+)"/i) ? RegExp.$1 : 0);
|
3811
|
-
height = height || (imgStr.match(/height="([^"]+)"/i) ? RegExp.$1 : 0);
|
3812
|
-
if (imgStr.match(/kesrctag="([^"]+)"/i)) {
|
3813
|
-
var attrs = KE.util.getAttrList(unescape(RegExp.$1));
|
3814
|
-
attrs.width = width || attrs.width || 0;
|
3815
|
-
attrs.height = height || attrs.height || 0;
|
3816
|
-
attrs.kesrc = attrs.src;
|
3817
|
-
return KE.util.getMediaEmbed(attrs);
|
3818
|
-
}
|
3819
|
-
});
|
3820
|
-
});
|
3821
|
-
KE.g[id].setHtmlHooks.push(function(html) {
|
3822
|
-
return html.replace(/<embed[^>]*type="application\/x-shockwave-flash"[^>]*>(?:<\/embed>)?/ig, function($0) {
|
3823
|
-
var src = $0.match(/\s+src="([^"]+)"/i) ? RegExp.$1 : '';
|
3824
|
-
if ($0.match(/\s+kesrc="([^"]+)"/i)) src = RegExp.$1;
|
3825
|
-
var width = $0.match(/\s+width="([^"]+)"/i) ? RegExp.$1 : 0;
|
3826
|
-
var height = $0.match(/\s+height="([^"]+)"/i) ? RegExp.$1 : 0;
|
3827
|
-
var attrs = KE.util.getAttrList($0);
|
3828
|
-
attrs.src = src;
|
3829
|
-
attrs.width = width;
|
3830
|
-
attrs.height = height;
|
3831
|
-
return KE.util.getMediaImage(id, 'flash', attrs);
|
3832
|
-
});
|
3833
|
-
});
|
3834
|
-
},
|
3835
|
-
click : function(id) {
|
3836
|
-
KE.util.selection(id);
|
3837
|
-
this.dialog = new KE.dialog({
|
3838
|
-
id : id,
|
3839
|
-
cmd : 'flash',
|
3840
|
-
file : 'flash.html',
|
3841
|
-
width : 400,
|
3842
|
-
height : 140,
|
3843
|
-
loadingMode : true,
|
3844
|
-
title : KE.lang['flash'],
|
3845
|
-
yesButton : KE.lang['yes'],
|
3846
|
-
noButton : KE.lang['no']
|
3847
|
-
});
|
3848
|
-
this.dialog.show();
|
3849
|
-
},
|
3850
|
-
check : function(id, url, width, height) {
|
3851
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3852
|
-
if (!url.match(/^.{3,}$/)) {
|
3853
|
-
alert(KE.lang['invalidUrl']);
|
3854
|
-
KE.$('url', dialogDoc).focus();
|
3855
|
-
return false;
|
3856
|
-
}
|
3857
|
-
if (!width.match(/^\d*$/)) {
|
3858
|
-
alert(KE.lang['invalidWidth']);
|
3859
|
-
KE.$('width', dialogDoc).focus();
|
3860
|
-
return false;
|
3861
|
-
}
|
3862
|
-
if (!height.match(/^\d*$/)) {
|
3863
|
-
alert(KE.lang['invalidHeight']);
|
3864
|
-
KE.$('height', dialogDoc).focus();
|
3865
|
-
return false;
|
3866
|
-
}
|
3867
|
-
return true;
|
3868
|
-
},
|
3869
|
-
exec : function(id) {
|
3870
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3871
|
-
var url = KE.$('url', dialogDoc).value;
|
3872
|
-
var width = KE.$('width', dialogDoc).value;
|
3873
|
-
var height = KE.$('height', dialogDoc).value;
|
3874
|
-
if (!this.check(id, url, width, height)) return false;
|
3875
|
-
var html = KE.util.getMediaImage(id, 'flash', {
|
3876
|
-
src : url,
|
3877
|
-
type : KE.g[id].mediaTypes['flash'],
|
3878
|
-
width : width,
|
3879
|
-
height : height,
|
3880
|
-
quality : 'high'
|
3881
|
-
});
|
3882
|
-
KE.util.insertHtml(id, html);
|
3883
|
-
this.dialog.hide();
|
3884
|
-
KE.util.focus(id);
|
3885
|
-
}
|
3886
|
-
};
|
3887
|
-
|
3888
|
-
KE.plugin.image = {
|
3889
|
-
getSelectedNode : function(id) {
|
3890
|
-
var g = KE.g[id];
|
3891
|
-
var startNode = g.keRange.startNode;
|
3892
|
-
var endNode = g.keRange.endNode;
|
3893
|
-
if (!KE.browser.WEBKIT && !g.keSel.isControl) return;
|
3894
|
-
if (startNode.nodeType != 1) return;
|
3895
|
-
if (startNode.tagName.toLowerCase() != 'img') return;
|
3896
|
-
if (startNode != endNode) return;
|
3897
|
-
if (!startNode.className.match(/^ke-\w+/i)) return startNode;
|
3898
|
-
},
|
3899
|
-
init : function(id) {
|
3900
|
-
var self = this;
|
3901
|
-
var g = KE.g[id];
|
3902
|
-
g.contextmenuItems.push({
|
3903
|
-
text : KE.lang['editImage'],
|
3904
|
-
click : function(id, menu) {
|
3905
|
-
KE.util.select(id);
|
3906
|
-
menu.hide();
|
3907
|
-
self.click(id);
|
3908
|
-
},
|
3909
|
-
cond : function(id) {
|
3910
|
-
return self.getSelectedNode(id);
|
3911
|
-
},
|
3912
|
-
options : {
|
3913
|
-
width : '150px',
|
3914
|
-
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-image"></span>'
|
3915
|
-
}
|
3916
|
-
});
|
3917
|
-
g.contextmenuItems.push({
|
3918
|
-
text : KE.lang['deleteImage'],
|
3919
|
-
click : function(id, menu) {
|
3920
|
-
KE.util.select(id);
|
3921
|
-
menu.hide();
|
3922
|
-
var img = self.getSelectedNode(id);
|
3923
|
-
img.parentNode.removeChild(img);
|
3924
|
-
KE.util.execOnchangeHandler(id);
|
3925
|
-
},
|
3926
|
-
cond : function(id) {
|
3927
|
-
return self.getSelectedNode(id);
|
3928
|
-
},
|
3929
|
-
options : {
|
3930
|
-
width : '150px'
|
3931
|
-
}
|
3932
|
-
});
|
3933
|
-
g.contextmenuItems.push('-');
|
3934
|
-
},
|
3935
|
-
click : function(id) {
|
3936
|
-
KE.util.selection(id);
|
3937
|
-
this.dialog = new KE.dialog({
|
3938
|
-
id : id,
|
3939
|
-
cmd : 'image',
|
3940
|
-
file : 'image/image.html',
|
3941
|
-
width : 400,
|
3942
|
-
height : 220,
|
3943
|
-
loadingMode : true,
|
3944
|
-
title : KE.lang['image'],
|
3945
|
-
yesButton : KE.lang['yes'],
|
3946
|
-
noButton : KE.lang['no']
|
3947
|
-
});
|
3948
|
-
this.dialog.show();
|
3949
|
-
},
|
3950
|
-
check : function(id) {
|
3951
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3952
|
-
var type = KE.$('type', dialogDoc).value;
|
3953
|
-
var width = KE.$('imgWidth', dialogDoc).value;
|
3954
|
-
var height = KE.$('imgHeight', dialogDoc).value;
|
3955
|
-
var title = KE.$('imgTitle', dialogDoc).value;
|
3956
|
-
var urlBox;
|
3957
|
-
if (type == 2) {
|
3958
|
-
urlBox = KE.$('imgFile', dialogDoc);
|
3959
|
-
} else {
|
3960
|
-
urlBox = KE.$('url', dialogDoc);
|
3961
|
-
}
|
3962
|
-
if (!urlBox.value.match(/\.(jpg|jpeg|gif|bmp|png)(\s|\?|$)/i)) {
|
3963
|
-
alert(KE.lang['invalidImg']);
|
3964
|
-
urlBox.focus();
|
3965
|
-
return false;
|
3966
|
-
}
|
3967
|
-
if (!width.match(/^\d*$/)) {
|
3968
|
-
alert(KE.lang['invalidWidth']);
|
3969
|
-
KE.$('imgWidth', dialogDoc).focus();
|
3970
|
-
return false;
|
3971
|
-
}
|
3972
|
-
if (!height.match(/^\d*$/)) {
|
3973
|
-
alert(KE.lang['invalidHeight']);
|
3974
|
-
KE.$('imgHeight', dialogDoc).focus();
|
3975
|
-
return false;
|
3976
|
-
}
|
3977
|
-
return true;
|
3978
|
-
},
|
3979
|
-
exec : function(id) {
|
3980
|
-
var self = this;
|
3981
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3982
|
-
var type = KE.$('type', dialogDoc).value;
|
3983
|
-
var width = KE.$('imgWidth', dialogDoc).value;
|
3984
|
-
var height = KE.$('imgHeight', dialogDoc).value;
|
3985
|
-
var title = KE.$('imgTitle', dialogDoc).value;
|
3986
|
-
var alignElements = dialogDoc.getElementsByName('align');
|
3987
|
-
var align = '';
|
3988
|
-
for (var i = 0, len = alignElements.length; i < len; i++) {
|
3989
|
-
if (alignElements[i].checked) {
|
3990
|
-
align = alignElements[i].value;
|
3991
|
-
break;
|
3992
|
-
}
|
3993
|
-
}
|
3994
|
-
if (!this.check(id)) return false;
|
3995
|
-
if (type == 2) {
|
3996
|
-
KE.$('editorId', dialogDoc).value = id;
|
3997
|
-
var uploadIframe = KE.$('uploadIframe', dialogDoc);
|
3998
|
-
KE.util.showLoadingPage(id);
|
3999
|
-
var onloadFunc = function() {
|
4000
|
-
KE.event.remove(uploadIframe, 'load', onloadFunc);
|
4001
|
-
KE.util.hideLoadingPage(id);
|
4002
|
-
var uploadDoc = KE.util.getIframeDoc(uploadIframe);
|
4003
|
-
var data = '';
|
4004
|
-
try {
|
4005
|
-
data = KE.util.parseJson(uploadDoc.body.innerHTML);
|
4006
|
-
} catch(e) {
|
4007
|
-
alert(KE.lang.invalidJson);
|
4008
|
-
}
|
4009
|
-
if (typeof data === 'object' && 'error' in data) {
|
4010
|
-
if (data.error === 0) {
|
4011
|
-
var url = KE.format.getUrl(data.url, 'absolute');
|
4012
|
-
self.insert(id, url, title, width, height, 0, align);
|
4013
|
-
} else {
|
4014
|
-
alert(data.message);
|
4015
|
-
return false;
|
4016
|
-
}
|
4017
|
-
}
|
4018
|
-
};
|
4019
|
-
KE.event.add(uploadIframe, 'load', onloadFunc);
|
4020
|
-
dialogDoc.uploadForm.submit();
|
4021
|
-
return;
|
4022
|
-
} else {
|
4023
|
-
var url = KE.$('url', dialogDoc).value;
|
4024
|
-
this.insert(id, url, title, width, height, 0, align);
|
4025
|
-
}
|
4026
|
-
},
|
4027
|
-
insert : function(id, url, title, width, height, border, align) {
|
4028
|
-
var html = '<img src="' + url + '" kesrc="' + url + '" ';
|
4029
|
-
if (width > 0) html += 'width="' + width + '" ';
|
4030
|
-
if (height > 0) html += 'height="' + height + '" ';
|
4031
|
-
if (title) html += 'title="' + title + '" ';
|
4032
|
-
if (align) html += 'align="' + align + '" ';
|
4033
|
-
html += 'alt="' + title + '" ';
|
4034
|
-
if (border) html += 'border="' + border + '" ';
|
4035
|
-
html += '/>';
|
4036
|
-
KE.util.insertHtml(id, html);
|
4037
|
-
this.dialog.hide();
|
4038
|
-
KE.util.focus(id);
|
4039
|
-
}
|
4040
|
-
};
|
4041
|
-
|
4042
|
-
KE.plugin.link = {
|
4043
|
-
getSelectedNode : function(id) {
|
4044
|
-
return KE.getCommonAncestor(KE.g[id].keSel, 'a');
|
4045
|
-
},
|
4046
|
-
init : function(id) {
|
4047
|
-
var self = this;
|
4048
|
-
KE.g[id].contextmenuItems.push({
|
4049
|
-
text : KE.lang['editLink'],
|
4050
|
-
click : function(id, menu) {
|
4051
|
-
KE.util.select(id);
|
4052
|
-
menu.hide();
|
4053
|
-
self.click(id);
|
4054
|
-
},
|
4055
|
-
cond : function(id) {
|
4056
|
-
return self.getSelectedNode(id);
|
4057
|
-
},
|
4058
|
-
options : {
|
4059
|
-
width : '150px',
|
4060
|
-
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-link"></span>'
|
4061
|
-
}
|
4062
|
-
});
|
4063
|
-
},
|
4064
|
-
click : function(id) {
|
4065
|
-
KE.util.selection(id);
|
4066
|
-
this.dialog = new KE.dialog({
|
4067
|
-
id : id,
|
4068
|
-
cmd : 'link',
|
4069
|
-
file : 'link/link.html',
|
4070
|
-
width : 400,
|
4071
|
-
height : 90,
|
4072
|
-
loadingMode : true,
|
4073
|
-
title : KE.lang['link'],
|
4074
|
-
yesButton : KE.lang['yes'],
|
4075
|
-
noButton : KE.lang['no']
|
4076
|
-
});
|
4077
|
-
this.dialog.show();
|
4078
|
-
},
|
4079
|
-
exec : function(id) {
|
4080
|
-
var g = KE.g[id];
|
4081
|
-
KE.util.select(id);
|
4082
|
-
var range = g.keRange;
|
4083
|
-
var startNode = range.startNode;
|
4084
|
-
var endNode = range.endNode;
|
4085
|
-
var iframeDoc = g.iframeDoc;
|
4086
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4087
|
-
var url = KE.$('hyperLink', dialogDoc).value;
|
4088
|
-
var target = KE.$('linkType', dialogDoc).value;
|
4089
|
-
if (!url.match(/.+/) || url.match(/^\w+:\/\/\/?$/)) {
|
4090
|
-
alert(KE.lang['invalidUrl']);
|
4091
|
-
KE.$('hyperLink', dialogDoc).focus();
|
4092
|
-
return false;
|
4093
|
-
}
|
4094
|
-
var node = range.getParentElement();
|
4095
|
-
while (node) {
|
4096
|
-
if (node.tagName.toLowerCase() == 'a' || node.tagName.toLowerCase() == 'body') break;
|
4097
|
-
node = node.parentNode;
|
4098
|
-
}
|
4099
|
-
node = node.parentNode;
|
4100
|
-
var isItem;
|
4101
|
-
if (KE.browser.IE) {
|
4102
|
-
isItem = !!g.range.item;
|
4103
|
-
} else {
|
4104
|
-
isItem = (startNode.nodeType == 1 && startNode === endNode && startNode.nodeName.toLowerCase() != 'br');
|
4105
|
-
}
|
4106
|
-
var isEmpty = !isItem;
|
4107
|
-
if (!isItem) isEmpty = KE.browser.IE ? g.range.text === '' : g.range.toString() === '';
|
4108
|
-
if (isEmpty || KE.util.isEmpty(id)) {
|
4109
|
-
var html = '<a href="' + url + '"';
|
4110
|
-
if (target) html += ' target="' + target + '"';
|
4111
|
-
html += '>' + url + '</a>';
|
4112
|
-
KE.util.insertHtml(id, html);
|
4113
|
-
} else {
|
4114
|
-
iframeDoc.execCommand('createlink', false, '__ke_temp_url__');
|
4115
|
-
var arr = node.getElementsByTagName('a');
|
4116
|
-
for (var i = 0, l = arr.length; i < l; i++) {
|
4117
|
-
if (arr[i].href.match(/\/?__ke_temp_url__$/)) {
|
4118
|
-
arr[i].href = url;
|
4119
|
-
arr[i].setAttribute('kesrc', url);
|
4120
|
-
if (target) arr[i].target = target;
|
4121
|
-
else arr[i].removeAttribute('target');
|
4122
|
-
}
|
4123
|
-
}
|
4124
|
-
if (KE.browser.WEBKIT && isItem && startNode.tagName.toLowerCase() == 'img') {
|
4125
|
-
var parent = startNode.parentNode;
|
4126
|
-
if (parent.tagName.toLowerCase() != 'a') {
|
4127
|
-
var a = KE.$$('a', iframeDoc);
|
4128
|
-
parent.insertBefore(a, startNode);
|
4129
|
-
a.appendChild(startNode);
|
4130
|
-
parent = a;
|
4131
|
-
}
|
4132
|
-
parent.href = url;
|
4133
|
-
parent.setAttribute('kesrc', url);
|
4134
|
-
if (target) parent.target = target;
|
4135
|
-
else parent.removeAttribute('target');
|
4136
|
-
g.keSel.addRange(range);
|
4137
|
-
}
|
4138
|
-
}
|
4139
|
-
KE.util.execOnchangeHandler(id);
|
4140
|
-
this.dialog.hide();
|
4141
|
-
KE.util.focus(id);
|
4142
|
-
}
|
4143
|
-
};
|
4144
|
-
|
4145
|
-
KE.plugin.unlink = {
|
4146
|
-
init : function(id) {
|
4147
|
-
var self = this;
|
4148
|
-
KE.g[id].contextmenuItems.push({
|
4149
|
-
text : KE.lang['deleteLink'],
|
4150
|
-
click : function(id, menu) {
|
4151
|
-
KE.util.select(id);
|
4152
|
-
menu.hide();
|
4153
|
-
self.click(id);
|
4154
|
-
},
|
4155
|
-
cond : function(id) {
|
4156
|
-
return KE.plugin['link'].getSelectedNode(id);
|
4157
|
-
},
|
4158
|
-
options : {
|
4159
|
-
width : '150px',
|
4160
|
-
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-unlink"></span>'
|
4161
|
-
}
|
4162
|
-
});
|
4163
|
-
KE.g[id].contextmenuItems.push('-');
|
4164
|
-
},
|
4165
|
-
click : function(id) {
|
4166
|
-
var g = KE.g[id];
|
4167
|
-
var iframeDoc = g.iframeDoc;
|
4168
|
-
KE.util.selection(id);
|
4169
|
-
var range = g.keRange;
|
4170
|
-
var startNode = range.startNode;
|
4171
|
-
var endNode = range.endNode;
|
4172
|
-
var isItem = (startNode.nodeType == 1 && startNode === endNode);
|
4173
|
-
var isEmpty = !isItem;
|
4174
|
-
if (!isItem) isEmpty = KE.browser.IE ? g.range.text === '' : g.range.toString() === '';
|
4175
|
-
if (isEmpty) {
|
4176
|
-
var linkNode = KE.plugin['link'].getSelectedNode(id);
|
4177
|
-
if (!linkNode) return;
|
4178
|
-
var range = g.keRange;
|
4179
|
-
range.selectTextNode(linkNode);
|
4180
|
-
g.keSel.addRange(range);
|
4181
|
-
KE.util.select(id);
|
4182
|
-
iframeDoc.execCommand('unlink', false, null);
|
4183
|
-
if (KE.browser.WEBKIT && startNode.tagName.toLowerCase() == 'img') {
|
4184
|
-
var parent = startNode.parentNode;
|
4185
|
-
if (parent.tagName.toLowerCase() == 'a') {
|
4186
|
-
KE.util.removeParent(parent);
|
4187
|
-
g.keSel.addRange(range);
|
4188
|
-
}
|
4189
|
-
}
|
4190
|
-
} else {
|
4191
|
-
iframeDoc.execCommand('unlink', false, null);
|
4192
|
-
}
|
4193
|
-
KE.util.execOnchangeHandler(id);
|
4194
|
-
KE.toolbar.updateState(id);
|
4195
|
-
KE.util.focus(id);
|
4196
|
-
}
|
4197
|
-
};
|
4198
|
-
|
4199
|
-
KE.plugin.media = {
|
4200
|
-
init : function(id) {
|
4201
|
-
var self = this;
|
4202
|
-
var typeHash = {};
|
4203
|
-
KE.each(KE.g[id].mediaTypes, function(key, val) {
|
4204
|
-
typeHash[val] = key;
|
4205
|
-
});
|
4206
|
-
KE.g[id].getHtmlHooks.push(function(html) {
|
4207
|
-
return html.replace(/<img[^>]*class="?ke-\w+"?[^>]*>/ig, function($0) {
|
4208
|
-
var width = $0.match(/style="[^"]*;?\s*width:\s*(\d+)/i) ? RegExp.$1 : 0;
|
4209
|
-
var height = $0.match(/style="[^"]*;?\s*height:\s*(\d+)/i) ? RegExp.$1 : 0;
|
4210
|
-
width = width || ($0.match(/width="([^"]+)"/i) ? RegExp.$1 : 0);
|
4211
|
-
height = height || ($0.match(/height="([^"]+)"/i) ? RegExp.$1 : 0);
|
4212
|
-
if ($0.match(/\s+kesrctag="([^"]+)"/i)) {
|
4213
|
-
var attrs = KE.util.getAttrList(unescape(RegExp.$1));
|
4214
|
-
attrs.width = width || attrs.width || 0;
|
4215
|
-
attrs.height = height || attrs.height || 0;
|
4216
|
-
attrs.kesrc = attrs.src;
|
4217
|
-
return KE.util.getMediaEmbed(attrs);
|
4218
|
-
}
|
4219
|
-
});
|
4220
|
-
});
|
4221
|
-
KE.g[id].setHtmlHooks.push(function(html) {
|
4222
|
-
return html.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/ig, function($0, $1) {
|
4223
|
-
if (typeof typeHash[$1] == 'undefined') return $0;
|
4224
|
-
var src = $0.match(/\s+src="([^"]+)"/i) ? RegExp.$1 : '';
|
4225
|
-
if ($0.match(/\s+kesrc="([^"]+)"/i)) src = RegExp.$1;
|
4226
|
-
var width = $0.match(/\s+width="([^"]+)"/i) ? RegExp.$1 : 0;
|
4227
|
-
var height = $0.match(/\s+height="([^"]+)"/i) ? RegExp.$1 : 0;
|
4228
|
-
var attrs = KE.util.getAttrList($0);
|
4229
|
-
attrs.src = src;
|
4230
|
-
attrs.width = width;
|
4231
|
-
attrs.height = height;
|
4232
|
-
return KE.util.getMediaImage(id, '', attrs);
|
4233
|
-
});
|
4234
|
-
});
|
4235
|
-
},
|
4236
|
-
click : function(id) {
|
4237
|
-
KE.util.selection(id);
|
4238
|
-
this.dialog = new KE.dialog({
|
4239
|
-
id : id,
|
4240
|
-
cmd : 'media',
|
4241
|
-
file : 'media.html',
|
4242
|
-
width : 400,
|
4243
|
-
height : 170,
|
4244
|
-
loadingMode : true,
|
4245
|
-
title : KE.lang['media'],
|
4246
|
-
yesButton : KE.lang['yes'],
|
4247
|
-
noButton : KE.lang['no']
|
4248
|
-
});
|
4249
|
-
this.dialog.show();
|
4250
|
-
},
|
4251
|
-
check : function(id, url, width, height) {
|
4252
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4253
|
-
if (!url.match(/^.{3,}\.(swf|flv|mp3|wav|wma|wmv|mid|avi|mpg|mpeg|asf|rm|rmvb)(\?|$)/i)) {
|
4254
|
-
alert(KE.lang['invalidMedia']);
|
4255
|
-
KE.$('url', dialogDoc).focus();
|
4256
|
-
return false;
|
4257
|
-
}
|
4258
|
-
if (!width.match(/^\d*$/)) {
|
4259
|
-
alert(KE.lang['invalidWidth']);
|
4260
|
-
KE.$('width', dialogDoc).focus();
|
4261
|
-
return false;
|
4262
|
-
}
|
4263
|
-
if (!height.match(/^\d*$/)) {
|
4264
|
-
alert(KE.lang['invalidHeight']);
|
4265
|
-
KE.$('height', dialogDoc).focus();
|
4266
|
-
return false;
|
4267
|
-
}
|
4268
|
-
return true;
|
4269
|
-
},
|
4270
|
-
exec : function(id) {
|
4271
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4272
|
-
var url = KE.$('url', dialogDoc).value;
|
4273
|
-
var width = KE.$('width', dialogDoc).value;
|
4274
|
-
var height = KE.$('height', dialogDoc).value;
|
4275
|
-
if (!this.check(id, url, width, height)) return false;
|
4276
|
-
var autostart = KE.$('autostart', dialogDoc).checked ? 'true' : 'false';
|
4277
|
-
var html = KE.util.getMediaImage(id, '', {
|
4278
|
-
src : url,
|
4279
|
-
type : KE.g[id].mediaTypes[KE.util.getMediaType(url)],
|
4280
|
-
width : width,
|
4281
|
-
height : height,
|
4282
|
-
autostart : autostart,
|
4283
|
-
loop : 'true'
|
4284
|
-
});
|
4285
|
-
KE.util.insertHtml(id, html);
|
4286
|
-
this.dialog.hide();
|
4287
|
-
KE.util.focus(id);
|
4288
|
-
}
|
4289
|
-
};
|
4290
|
-
|
4291
|
-
KE.plugin.advtable = {
|
4292
|
-
getSelectedTable : function(id) {
|
4293
|
-
return KE.getCommonAncestor(KE.g[id].keSel, 'table');
|
4294
|
-
},
|
4295
|
-
getSelectedRow : function(id) {
|
4296
|
-
return KE.getCommonAncestor(KE.g[id].keSel, 'tr');
|
4297
|
-
},
|
4298
|
-
getSelectedCell : function(id) {
|
4299
|
-
return KE.getCommonAncestor(KE.g[id].keSel, 'td');
|
4300
|
-
},
|
4301
|
-
tableprop : function(id) {
|
4302
|
-
this.click(id);
|
4303
|
-
},
|
4304
|
-
tablecellprop : function(id) {
|
4305
|
-
var self = this;
|
4306
|
-
KE.util.selection(id);
|
4307
|
-
var dialog = new KE.dialog({
|
4308
|
-
id : id,
|
4309
|
-
cmd : 'advtable',
|
4310
|
-
file : 'advtable/cell.html',
|
4311
|
-
width : 420,
|
4312
|
-
height : 150,
|
4313
|
-
loadingMode : true,
|
4314
|
-
title : KE.lang['tablecell'],
|
4315
|
-
yesButton : KE.lang['yes'],
|
4316
|
-
noButton : KE.lang['no'],
|
4317
|
-
yesClickFn : function(id) {
|
4318
|
-
var dialogDoc = KE.util.getIframeDoc(dialog.iframe),
|
4319
|
-
widthBox = KE.$('width', dialogDoc),
|
4320
|
-
heightBox = KE.$('height', dialogDoc),
|
4321
|
-
widthTypeBox = KE.$('widthType', dialogDoc),
|
4322
|
-
heightTypeBox = KE.$('heightType', dialogDoc),
|
4323
|
-
textAlignBox = KE.$('textAlign', dialogDoc),
|
4324
|
-
verticalAlignBox = KE.$('verticalAlign', dialogDoc),
|
4325
|
-
borderBox = KE.$('border', dialogDoc),
|
4326
|
-
borderColorBox = KE.$('borderColor', dialogDoc),
|
4327
|
-
backgroundColorBox = KE.$('backgroundColor', dialogDoc),
|
4328
|
-
width = widthBox.value,
|
4329
|
-
height = heightBox.value,
|
4330
|
-
widthType = widthTypeBox.value,
|
4331
|
-
heightType = heightTypeBox.value,
|
4332
|
-
textAlign = textAlignBox.value,
|
4333
|
-
verticalAlign = verticalAlignBox.value,
|
4334
|
-
border = borderBox.value,
|
4335
|
-
borderColor = borderColorBox.innerHTML,
|
4336
|
-
backgroundColor = backgroundColorBox.innerHTML;
|
4337
|
-
if (!width.match(/^\d*$/)) {
|
4338
|
-
alert(KE.lang['invalidWidth']);
|
4339
|
-
widthBox.focus();
|
4340
|
-
return false;
|
4341
|
-
}
|
4342
|
-
if (!height.match(/^\d*$/)) {
|
4343
|
-
alert(KE.lang['invalidHeight']);
|
4344
|
-
heightBox.focus();
|
4345
|
-
return false;
|
4346
|
-
}
|
4347
|
-
if (!border.match(/^\d*$/)) {
|
4348
|
-
alert(KE.lang['invalidBorder']);
|
4349
|
-
borderBox.focus();
|
4350
|
-
return false;
|
4351
|
-
}
|
4352
|
-
var cell = self.getSelectedCell(id);
|
4353
|
-
cell.style.width = width !== '' ? (width + widthType) : '';
|
4354
|
-
cell.style.height = height !== '' ? (height + heightType) : '';
|
4355
|
-
cell.style.backgroundColor = backgroundColor;
|
4356
|
-
cell.style.textAlign = textAlign;
|
4357
|
-
cell.style.verticalAlign = verticalAlign;
|
4358
|
-
cell.style.borderWidth = border;
|
4359
|
-
cell.style.borderStyle = border !== '' ? 'solid' : '';
|
4360
|
-
cell.style.borderColor = borderColor;
|
4361
|
-
KE.util.execOnchangeHandler(id);
|
4362
|
-
dialog.hide();
|
4363
|
-
KE.util.focus(id);
|
4364
|
-
}
|
4365
|
-
});
|
4366
|
-
dialog.show();
|
4367
|
-
},
|
4368
|
-
tableinsert : function(id) {
|
4369
|
-
this.click(id, 'insert');
|
4370
|
-
},
|
4371
|
-
tabledelete : function(id) {
|
4372
|
-
var table = this.getSelectedTable(id);
|
4373
|
-
table.parentNode.removeChild(table);
|
4374
|
-
},
|
4375
|
-
tablecolinsert : function(id, offset) {
|
4376
|
-
var table = this.getSelectedTable(id),
|
4377
|
-
cell = this.getSelectedCell(id),
|
4378
|
-
index = cell.cellIndex + offset;
|
4379
|
-
for (var i = 0, len = table.rows.length; i < len; i++) {
|
4380
|
-
var newCell = table.rows[i].insertCell(index);
|
4381
|
-
newCell.innerHTML = ' ';
|
4382
|
-
}
|
4383
|
-
},
|
4384
|
-
tablecolinsertleft : function(id) {
|
4385
|
-
this.tablecolinsert(id, 0);
|
4386
|
-
},
|
4387
|
-
tablecolinsertright : function(id) {
|
4388
|
-
this.tablecolinsert(id, 1);
|
4389
|
-
},
|
4390
|
-
tablerowinsert : function(id, offset) {
|
4391
|
-
var table = this.getSelectedTable(id),
|
4392
|
-
row = this.getSelectedRow(id),
|
4393
|
-
newRow = table.insertRow(row.rowIndex + offset);
|
4394
|
-
for (var i = 0, len = row.cells.length; i < len; i++) {
|
4395
|
-
var cell = newRow.insertCell(i);
|
4396
|
-
cell.innerHTML = ' ';
|
4397
|
-
}
|
4398
|
-
},
|
4399
|
-
tablerowinsertabove : function(id) {
|
4400
|
-
this.tablerowinsert(id, 0);
|
4401
|
-
},
|
4402
|
-
tablerowinsertbelow : function(id) {
|
4403
|
-
this.tablerowinsert(id, 1);
|
4404
|
-
},
|
4405
|
-
tablecoldelete : function(id) {
|
4406
|
-
var table = this.getSelectedTable(id),
|
4407
|
-
cell = this.getSelectedCell(id),
|
4408
|
-
index = cell.cellIndex;
|
4409
|
-
for (var i = 0, len = table.rows.length; i < len; i++) {
|
4410
|
-
table.rows[i].deleteCell(index);
|
4411
|
-
}
|
4412
|
-
},
|
4413
|
-
tablerowdelete : function(id) {
|
4414
|
-
var table = this.getSelectedTable(id);
|
4415
|
-
var row = this.getSelectedRow(id);
|
4416
|
-
table.deleteRow(row.rowIndex);
|
4417
|
-
},
|
4418
|
-
init : function(id) {
|
4419
|
-
var self = this;
|
4420
|
-
var zeroborder = 'ke-zeroborder';
|
4421
|
-
var tableCmds = 'prop,cellprop,colinsertleft,colinsertright,rowinsertabove,rowinsertbelow,coldelete,rowdelete,insert,delete'.split(',');
|
4422
|
-
for (var i = 0, len = tableCmds.length; i < len; i++) {
|
4423
|
-
var name = 'table' + tableCmds[i];
|
4424
|
-
KE.g[id].contextmenuItems.push({
|
4425
|
-
text : KE.lang[name],
|
4426
|
-
click : (function(name) {
|
4427
|
-
return function(id, menu) {
|
4428
|
-
KE.util.select(id);
|
4429
|
-
menu.hide();
|
4430
|
-
if (self[name] !== undefined) self[name](id);
|
4431
|
-
if (!/prop/.test(name)) {
|
4432
|
-
KE.util.execOnchangeHandler(id);
|
4433
|
-
}
|
4434
|
-
};
|
4435
|
-
})(name),
|
4436
|
-
cond : (function(name) {
|
4437
|
-
if (KE.util.inArray(name, ['tableprop', 'tabledelete'])) {
|
4438
|
-
return function(id) {
|
4439
|
-
return self.getSelectedTable(id);
|
4440
|
-
};
|
4441
|
-
} else {
|
4442
|
-
return function(id) {
|
4443
|
-
return self.getSelectedCell(id);
|
4444
|
-
};
|
4445
|
-
}
|
4446
|
-
})(name),
|
4447
|
-
options : {
|
4448
|
-
width : '170px',
|
4449
|
-
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-' + name + '"></span>'
|
4450
|
-
}
|
4451
|
-
});
|
4452
|
-
}
|
4453
|
-
KE.g[id].contextmenuItems.push('-');
|
4454
|
-
KE.g[id].setHtmlHooks.push(function(html) {
|
4455
|
-
return html.replace(/<table([^>]*)>/ig, function($0, $1) {
|
4456
|
-
if ($1.match(/\s+border=["']?(\d*)["']?/ig)) {
|
4457
|
-
var border = RegExp.$1;
|
4458
|
-
if ($1.indexOf(zeroborder) < 0 && (border === '' || border === '0')) {
|
4459
|
-
return KE.addClass($0, zeroborder);
|
4460
|
-
} else {
|
4461
|
-
return $0;
|
4462
|
-
}
|
4463
|
-
} else {
|
4464
|
-
return KE.addClass($0, zeroborder);
|
4465
|
-
}
|
4466
|
-
});
|
4467
|
-
});
|
4468
|
-
},
|
4469
|
-
click : function(id, mode) {
|
4470
|
-
mode = mode || 'default';
|
4471
|
-
var cmd = 'advtable';
|
4472
|
-
KE.util.selection(id);
|
4473
|
-
this.dialog = new KE.dialog({
|
4474
|
-
id : id,
|
4475
|
-
cmd : cmd,
|
4476
|
-
file : 'advtable/advtable.html?mode=' + mode,
|
4477
|
-
width : 420,
|
4478
|
-
height : 220,
|
4479
|
-
loadingMode : true,
|
4480
|
-
title : KE.lang['advtable'],
|
4481
|
-
yesButton : KE.lang['yes'],
|
4482
|
-
noButton : KE.lang['no']
|
4483
|
-
});
|
4484
|
-
this.dialog.show();
|
4485
|
-
},
|
4486
|
-
exec : function(id) {
|
4487
|
-
var zeroborder = 'ke-zeroborder',
|
4488
|
-
dialogDoc = KE.util.getIframeDoc(this.dialog.iframe),
|
4489
|
-
modeBox = KE.$('mode', dialogDoc),
|
4490
|
-
rowsBox = KE.$('rows', dialogDoc),
|
4491
|
-
colsBox = KE.$('cols', dialogDoc),
|
4492
|
-
widthBox = KE.$('width', dialogDoc),
|
4493
|
-
heightBox = KE.$('height', dialogDoc),
|
4494
|
-
widthTypeBox = KE.$('widthType', dialogDoc),
|
4495
|
-
heightTypeBox = KE.$('heightType', dialogDoc),
|
4496
|
-
paddingBox = KE.$('padding', dialogDoc),
|
4497
|
-
spacingBox = KE.$('spacing', dialogDoc),
|
4498
|
-
alignBox = KE.$('align', dialogDoc),
|
4499
|
-
borderBox = KE.$('border', dialogDoc),
|
4500
|
-
borderColorBox = KE.$('borderColor', dialogDoc),
|
4501
|
-
backgroundColorBox = KE.$('backgroundColor', dialogDoc),
|
4502
|
-
rows = rowsBox.value,
|
4503
|
-
cols = colsBox.value,
|
4504
|
-
width = widthBox.value,
|
4505
|
-
height = heightBox.value,
|
4506
|
-
widthType = widthTypeBox.value,
|
4507
|
-
heightType = heightTypeBox.value,
|
4508
|
-
padding = paddingBox.value,
|
4509
|
-
spacing = spacingBox.value,
|
4510
|
-
align = alignBox.value,
|
4511
|
-
border = borderBox.value,
|
4512
|
-
borderColor = borderColorBox.innerHTML,
|
4513
|
-
backgroundColor = backgroundColorBox.innerHTML;
|
4514
|
-
if (rows == '' || rows == 0 || !rows.match(/^\d*$/)) {
|
4515
|
-
alert(KE.lang['invalidRows']);
|
4516
|
-
rowsBox.focus();
|
4517
|
-
return false;
|
4518
|
-
}
|
4519
|
-
if (cols == '' || cols == 0 || !cols.match(/^\d*$/)) {
|
4520
|
-
alert(KE.lang['invalidCols']);
|
4521
|
-
colsBox.focus();
|
4522
|
-
return false;
|
4523
|
-
}
|
4524
|
-
if (!width.match(/^\d*$/)) {
|
4525
|
-
alert(KE.lang['invalidWidth']);
|
4526
|
-
widthBox.focus();
|
4527
|
-
return false;
|
4528
|
-
}
|
4529
|
-
if (!height.match(/^\d*$/)) {
|
4530
|
-
alert(KE.lang['invalidHeight']);
|
4531
|
-
heightBox.focus();
|
4532
|
-
return false;
|
4533
|
-
}
|
4534
|
-
if (!padding.match(/^\d*$/)) {
|
4535
|
-
alert(KE.lang['invalidPadding']);
|
4536
|
-
paddingBox.focus();
|
4537
|
-
return false;
|
4538
|
-
}
|
4539
|
-
if (!spacing.match(/^\d*$/)) {
|
4540
|
-
alert(KE.lang['invalidSpacing']);
|
4541
|
-
spacingBox.focus();
|
4542
|
-
return false;
|
4543
|
-
}
|
4544
|
-
if (!border.match(/^\d*$/)) {
|
4545
|
-
alert(KE.lang['invalidBorder']);
|
4546
|
-
borderBox.focus();
|
4547
|
-
return false;
|
4548
|
-
}
|
4549
|
-
if (modeBox.value === 'update') {
|
4550
|
-
var table = this.getSelectedTable(id);
|
4551
|
-
table.style.width = width !== '' ? (width + widthType) : '';
|
4552
|
-
table.style.height = height !== '' ? (height + heightType) : '';
|
4553
|
-
table.style.backgroundColor = backgroundColor;
|
4554
|
-
KE.attr(table, 'width', '');
|
4555
|
-
KE.attr(table, 'height', '');
|
4556
|
-
KE.attr(table, 'bgColor', '');
|
4557
|
-
KE.attr(table, 'cellPadding', padding);
|
4558
|
-
KE.attr(table, 'cellSpacing', spacing);
|
4559
|
-
KE.attr(table, 'align', align);
|
4560
|
-
if (border === '' || border === '0') {
|
4561
|
-
KE.addClass(table, zeroborder);
|
4562
|
-
} else {
|
4563
|
-
KE.removeClass(table, zeroborder);
|
4564
|
-
}
|
4565
|
-
KE.attr(table, 'border', border);
|
4566
|
-
KE.attr(table, 'borderColor', borderColor);
|
4567
|
-
KE.util.execOnchangeHandler(id);
|
4568
|
-
} else {
|
4569
|
-
var style = '';
|
4570
|
-
if (width !== '') style += 'width:' + width + widthType + ';';
|
4571
|
-
if (height !== '') style += 'height:' + height + heightType + ';';
|
4572
|
-
if (backgroundColor !== '') style += 'background-color:' + backgroundColor + ';';
|
4573
|
-
var html = '<table';
|
4574
|
-
if (style !== '') html += ' style="' + style + '"';
|
4575
|
-
if (padding !== '') html += ' cellpadding="' + padding + '"';
|
4576
|
-
if (spacing !== '') html += ' cellspacing="' + spacing + '"';
|
4577
|
-
if (align !== '') html += ' align="' + align + '"';
|
4578
|
-
if (border === '' || border === '0') html += ' class="' + zeroborder + '"';
|
4579
|
-
if (border !== '') html += ' border="' + border + '"';
|
4580
|
-
if (borderColor !== '') html += ' bordercolor="' + borderColor + '"';
|
4581
|
-
html += '>';
|
4582
|
-
for (var i = 0; i < rows; i++) {
|
4583
|
-
html += '<tr>';
|
4584
|
-
for (var j = 0; j < cols; j++) {
|
4585
|
-
html += '<td> </td>';
|
4586
|
-
}
|
4587
|
-
html += '</tr>';
|
4588
|
-
}
|
4589
|
-
html += '</table>';
|
4590
|
-
KE.util.insertHtml(id, html);
|
4591
|
-
}
|
4592
|
-
this.dialog.hide();
|
4593
|
-
KE.util.focus(id);
|
4594
|
-
}
|
4595
|
-
};
|
4596
|
-
|
4597
|
-
})(KindEditor);
|
4598
|
-
|
4599
|
-
KE.plugin['accessory'] = {
|
4600
|
-
click: function(id) {
|
4601
|
-
KE.util.selection(id);
|
4602
|
-
this.dialog = new KE.dialog({
|
4603
|
-
id: id,
|
4604
|
-
cmd: 'accessory',
|
4605
|
-
file: 'accessory.html',
|
4606
|
-
width: 390,
|
4607
|
-
height: 100,
|
4608
|
-
title: KE.lang['accessory'],
|
4609
|
-
yesButton: KE.lang['yes'],
|
4610
|
-
noButton: KE.lang['no']
|
4611
|
-
});
|
4612
|
-
this.dialog.show();
|
4613
|
-
},
|
4614
|
-
check: function(id) {
|
4615
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4616
|
-
var type = KE.$('type', dialogDoc).value;
|
4617
|
-
var url = '';
|
4618
|
-
if (type == 1) {
|
4619
|
-
url = KE.$('imgFile', dialogDoc).value;
|
4620
|
-
} else {
|
4621
|
-
url = KE.$('url', dialogDoc).value;
|
4622
|
-
}
|
4623
|
-
if (url.match(/\.(doc|xls|ppt|docx|xlsx|pptx|pdf|txt|rar|zip|mp3)$/i) == null) {
|
4624
|
-
alert(KE.lang['invalidAccessory']);
|
4625
|
-
window.focus();
|
4626
|
-
KE.g[id].yesButton.focus();
|
4627
|
-
return false;
|
4628
|
-
}
|
4629
|
-
return true;
|
4630
|
-
},
|
4631
|
-
exec: function(id) {
|
4632
|
-
KE.util.select(id);
|
4633
|
-
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4634
|
-
var type = KE.$('type', dialogDoc).value;
|
4635
|
-
if (!this.check(id)) return false;
|
4636
|
-
if (type == 1) {
|
4637
|
-
KE.$('editorId', dialogDoc).value = id;
|
4638
|
-
dialogDoc.uploadForm.submit();
|
4639
|
-
return false;
|
4640
|
-
} else {
|
4641
|
-
var url = KE.$('url', dialogDoc).value;
|
4642
|
-
var title = KE.$('description', dialogDoc).value;
|
4643
|
-
if (url != '') {
|
4644
|
-
var re = /(\\+)/g;
|
4645
|
-
var filename = url.replace(re, "#");
|
4646
|
-
var one = filename.split("#");
|
4647
|
-
var two = one[one.length - 1];
|
4648
|
-
var three = two.split(".");
|
4649
|
-
ext = three[three.length - 1];
|
4650
|
-
this.insert(id, url, title, ext);
|
4651
|
-
}
|
4652
|
-
}
|
4653
|
-
},
|
4654
|
-
insert: function(id, url, title, ext) {
|
4655
|
-
var img;
|
4656
|
-
var path = "/javascripts/kindeditor/skins/common/";
|
4657
|
-
switch (ext) {
|
4658
|
-
case "doc":
|
4659
|
-
case "docx":
|
4660
|
-
img = "doc.gif";
|
4661
|
-
break;
|
4662
|
-
case "xls":
|
4663
|
-
case "xlsx":
|
4664
|
-
img = "xls.gif";
|
4665
|
-
break;
|
4666
|
-
case "rar":
|
4667
|
-
case "zip":
|
4668
|
-
img = "rar.gif";
|
4669
|
-
break;
|
4670
|
-
case "mp3":
|
4671
|
-
img = "mp3.gif";
|
4672
|
-
break;
|
4673
|
-
case "pdf":
|
4674
|
-
img = "pdf.gif";
|
4675
|
-
break;
|
4676
|
-
default:
|
4677
|
-
img = "rar.gif";
|
4678
|
-
}
|
4679
|
-
var html = '<img src="' + path + img + '" > ';
|
4680
|
-
html += '<a href="' + url + '" >';
|
4681
|
-
if (title) html += title;
|
4682
|
-
html += '</a>';
|
4683
|
-
KE.util.insertHtml(id, html);
|
4684
|
-
this.dialog.hide();
|
4685
|
-
KE.util.focus(id);
|
4686
|
-
}
|
4687
|
-
};
|
4688
|
-
|